diff --git a/.gitignore b/.gitignore index 490342a4bd161..1eb86299e2089 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,8 @@ atlassian* /app/config_sandbox /app/etc/local.xml /app/etc/local.xml.* -/app/etc/modules/XEnterprise_Enabler.xml +/app/etc/modules/XEnterprise_Edition.xml +/app/etc/modules/XSaas_Edition.xml /downloader/.cache /downloader/cache.cfg /downloader/connect.cfg @@ -28,6 +29,7 @@ atlassian* /pub/media/* /pub/media/customer/* /pub/media/downloadable/* -/pub/media/theme/* -/pub/media/theme/customization/* +/pub/static/* +!/pub/static/.htaccess /var/* +*swp diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index a3010683ee3a6..b181ed336ea96 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -1,3 +1,107 @@ +2.0.0.0-dev44 +============= +* Product creating & editing: + * Added ability to control base text styling without WYSIWYG when editing description fields + * Added validation for price and quantity fields + * Removed category suggest limit +* Product template management: + * Automatically update Product Template when modifying structure in Create Product flow + * Improvements to change attribute set functionality +* Refactored JavaScript to use JQuery library: + * Refactored the following pages: catalog tags, one page checkout, multishipping checkout, gift options, gift messages (across the board) + * Converted jQuery popupwindow.js plugin to a jQuery widget + * Replaced Prototype code for Switch/Maestro and Solo credit card with jQuery widget + * Replaced Prototype Validation with jQuery validation plugin + * Converted credit card payment tool tip to jQuery in all themes + * Removed legacy JS files from all themes +* Various improvements in look & feel of backend UI: + * Styling of components: catalog, sales, customers, reports, CMS, newsletter + * Generic styling: grids, popup windows + * Changes to support IE browser +* Enhancements in "suggest" JavaScript widget: + * Ability to delete selected item using keyboard + * Ability to display all available search items, if "recent items" is empty + * Fixes of behavior of currently selected elements and "spinner" + * Display "No Records" message in suggest widget if all items already selected + * Fixed suggest widget to no longer show deleted items +* Improved `Magento_Test_Helper_ObjectManager` in unit tests to discover types of constructor arguments +* Removed workaround of unsetting objects referenced in `tearDown()` of integration tests +* Updated Menu and Navigation layout, including redesigned backend menu item System -> My Account +* Made store address format consistent with format of shipping origin address +* Added ability to navigate directly to a section in backend system configuration, with corresponding accordion expanded +* Removed some of unnecessary coupling between several modules +* General improvements to unit and integration test code coverage, as well as compliance with coding standards +* Application framework: + * Implemented ability to compress/decompress data in a cache backend + * Verified ability to disable in configuration triggering of system upgrade + * Abolished code pools and the mechanism of overriding files using include\_path (without alternative) + * Implemented segmentation of cache by types -- ability to assign separate cache configuration per type. Reviewed and verified possibility to isolate configuration cache segment + * Segregated application configuration into several layers. Primary configuration is used by the object manager and loaded before application is initialized + * Instead of `Zend\Di`, implemented `Magento\ObjectManager` library that has less features and suits Magento application needs better in terms of performance + * Introduced "context" object as dependencies for super-classes (`Mage_Core_Model_Abstract`, `Mage_Core_Block_Abstract`, etc) to reduce complexity of their constructors' API + * Implemented tools for pre-populating all auto-generated proxy and factory classes, used by dependency injection framework + * Replaced "developer" mode with general "mode", that has 3 states: developer, default, production + * In "production" mode, the application will not invoke fallback for static view files (images, CSS-files, JavaScript). Instead, it will assume that they are already placed in a fully qualified location. Added tools for populating static view files from `app` directory into `pub/static` + * Introduced support for Twig templating + * template rendering, including phtml, was abstracted into a `Mage_Core_Block_Template_Engine` to make support for other template engines easier + * included Magento-specific Twig functions and filters + * phtml templates can now only access public methods of the corresponding Block class + * ability to define dependencies on data provided by a service that is then made available to the templates -- eliminates some of the code in Blocks + * Introduced support for webhooks and callbacks: outbound HTTP requests for notifications and real-time integrations + * Added ability to define options for System Configuration select fields in XML: static options are defined inline, dynamic options can reuse data provided by a service +* Moved product business logic found in blocks into `Mage_Catalog_Service_Product` to consolidate logic into a single structure that both controllers and web services can invoke +* Converted product view page to demonstrate use of Twig templates and services +* Updated shipping carrier `collectRates` logic to support remote callbacks and converted the FedEx shipping carrier to comply with the same interface +* Added webhook support for the following topics: `customer/created`, `customer/updated`, `customer/deleted`, and `order/created` +* Visual design editor: + * Ability to view all CSS-files of a theme + * Ported numerous features of visual design editor from Magento Go 1.x to Magento Core 2.x: style editing, managing catalog images + * Various improvements in UI + * Improved image sizing functionality + * Improved test coverage + * Ability to launch physical themes, including workflow preview mode and workflow design mode + * Ability to duplicate existing themes for customization +* GitHub requests + * [#162](https://github.com/magento/magento2/pull/162) -- classmap needs to be prepended to autoloader stack to have any effect + * [#179](https://github.com/magento/magento2/pull/179) -- fix that makes `Mage_Install` compatible with the new version of SimpleXml + * [#180](https://github.com/magento/magento2/pull/180) -- fixed `getBaseUrl()` when type was injected via setter + * [#203](https://github.com/magento/magento2/pull/203) -- fixed problem with login in to backend area on php 5.4 + * [#216](https://github.com/magento/magento2/pull/216) -- explicit nullification of `$_store` in `Mage_Core_Model_Sore_Storage_Db->_initStores()` + * [#220](https://github.com/magento/magento2/pull/220) -- make topmenu HTML editable by an event + * [#221](https://github.com/magento/magento2/pull/221) -- changed minimum required PHP version from PHP 5.2.3 to 5.3.3 +* Bug fixes: + * Restored missing Paypal configuration options + * Fixed numerous display issues on the following pages: admin login, product management, category management, CMS poll, VDE, tax, shipping + * Fixed XSS vulnerability related to customer data & bundle options + * Fixed "Preview Theme" functionality + * Fixed JS File upload problem with Internet Explorer + * Replaced `truncateOptions` function in `varien/js.js` with inline widget + * Fixed broken XPaths in `SystemConfiguration.yml` + * Fixed jQuery metadata plugin's data attribute scanning for validation + * Synchronized default value of `quantity_and_stock_status` with Stock Availability control + * Fixed display of G.T. Purchased column in Order grid when order in non-default currency + * Fixed Foreign Key support for MS SQL + * Fixed "Create Customer" functionality on New Order screen + * Restored State/Province field to Review Order page + * Fixed Add New Tax Rate functionality + * Fixed problem with displaying New Shopping Cart Price Rule tab + * Fixed problem of configurable product options getting lost when adding product to wishlist + * Fixed UPS Shipping label printing + * Fixed performance issue with Catalog Management + * Fixed input file type validation when importing customers + * Fixed custom product placeholder image display + * Added missing files referenced by `quick\_style.css` + * Fixed validation error messaging and message placement + * Fixed access problem to SOAP/XML User and Roles pages + * Fixed access problem created when editing your own permissions + * Several fixes for problems with cleaning cache in tag scope + * Fixed invalid link problem in Gift Card email + * Fixed problem with deleting selected product category after changing attribute set + * Fixed theme management for Windows by adopting `Magento_Filesystem` abstraction to access directories + * Fixed cart rendering in case of empty cart + * Remove duplicate "Link to Store Front" link from admin, made obsolete by "Customer View" link + * Removed "Flat Rate" from pre-installed shipping methods + 2.0.0.0-dev43 ============= * Implemented functional limitation that restricts max number of catalog products in the system diff --git a/app/Mage.php b/app/Mage.php index 7b63049b6225d..483a51ff8a599 100644 --- a/app/Mage.php +++ b/app/Mage.php @@ -46,6 +46,11 @@ final class Mage */ const PARAM_RUN_TYPE = 'MAGE_RUN_TYPE'; + /** + * Application run code + */ + const PARAM_MODE = 'MAGE_MODE'; + /** * Base directory */ @@ -99,7 +104,7 @@ final class Mage * * @var array */ - static private $_registry = array(); + static private $_registry = array(); /** * Application root absolute path @@ -141,21 +146,14 @@ final class Mage * * @var bool */ - static private $_isDownloader = false; - - /** - * Is developer mode flag - * - * @var bool - */ - static private $_isDeveloperMode = false; + static private $_isDownloader = false; /** * Is allow throw Exception about headers already sent * * @var bool */ - public static $headersSentThrowsException = true; + public static $headersSentThrowsException = true; /** * Logger entities @@ -220,7 +218,7 @@ public static function getVersionInfo() 'revision' => '0', 'patch' => '0', 'stability' => 'dev', - 'number' => '43', + 'number' => '44', ); } @@ -258,9 +256,9 @@ public static function reset() self::$_config = null; self::$_objects = null; self::$_isDownloader = false; - self::$_isDeveloperMode = false; self::$_loggers = array(); self::$_design = null; + self::$_objectManager = null; // do not reset $headersSentThrowsException } @@ -375,9 +373,7 @@ public static function objects($key = null) */ public static function getBaseDir($type = Mage_Core_Model_Dir::ROOT) { - /** @var $dirs Mage_Core_Model_Dir */ - $dirs = self::$_objectManager->get('Mage_Core_Model_Dir'); - return $dirs->getDir($type); + return self::getSingleton('Mage_Core_Model_Dir')->getDir($type); } /** @@ -442,8 +438,7 @@ public static function getBaseUrl($type = Mage_Core_Model_Store::URL_TYPE_LINK, */ public static function getUrl($route = '', $params = array()) { - return self::getObjectManager()->create('Mage_Core_Model_Url', array('data' => array())) - ->getUrl($route, $params); + return self::getObjectManager()->create('Mage_Core_Model_Url')->getUrl($route, $params); } /** @@ -488,9 +483,7 @@ public static function getConfig() */ public static function dispatchEvent($name, array $data = array()) { - /** @var $eventManager Mage_Core_Model_Event_Manager */ - $eventManager = self::$_objectManager->get('Mage_Core_Model_Event_Manager'); - $eventManager->dispatch($name, $data); + return Mage::getSingleton('Mage_Core_Model_Event_Manager')->dispatch($name, $data); } /** @@ -506,21 +499,20 @@ public static function getModel($modelClass = '', $arguments = array()) if (!is_array($arguments)) { $arguments = array($arguments); } - return self::getObjectManager()->create($modelClass, $arguments, false); + return self::getObjectManager()->create($modelClass, $arguments); } /** * Retrieve model object singleton * * @param string $modelClass - * @param array $arguments * @return Mage_Core_Model_Abstract */ - public static function getSingleton($modelClass = '', array $arguments=array()) + public static function getSingleton($modelClass = '') { $registryKey = '_singleton/'.$modelClass; if (!self::registry($registryKey)) { - self::register($registryKey, self::getObjectManager()->get($modelClass, $arguments)); + self::register($registryKey, self::getObjectManager()->get($modelClass)); } return self::registry($registryKey); } @@ -565,17 +557,16 @@ public static function getResourceModel($modelClass, $arguments = array()) } /** - * Retrieve resource vodel object singleton + * Retrieve resource model object singleton * * @param string $modelClass - * @param array $arguments * @return object */ - public static function getResourceSingleton($modelClass = '', array $arguments = array()) + public static function getResourceSingleton($modelClass = '') { $registryKey = '_resource_singleton/'.$modelClass; if (!self::registry($registryKey)) { - self::register($registryKey, self::getObjectManager()->get($modelClass, $arguments)); + self::register($registryKey, self::getObjectManager()->get($modelClass)); } return self::registry($registryKey); } @@ -629,7 +620,13 @@ public static function getResourceHelper($moduleName) if (substr($moduleName, 0, 5) == 'Mage_') { $connection = substr($connection, 5); } - return self::getObjectManager()->get($helperClassName, array('modulePrefix' => $connection)); + $key = 'resourceHelper/' . $connection; + if (!self::registry($key)) { + self::register( + $key, self::getObjectManager()->create($helperClassName, array('modulePrefix' => $connection)) + ); + } + return self::registry($key); } /** @@ -682,7 +679,7 @@ public static function app() */ public static function isInstalled() { - return (bool) self::$_objectManager->get('Mage_Core_Model_Config_Primary')->getInstallDate(); + return (bool) Mage::getSingleton('Mage_Core_Model_Config_Primary')->getInstallDate(); } /** @@ -723,29 +720,26 @@ public static function logException(Exception $e) self::$_objectManager->get('Mage_Core_Model_Logger')->logException($e); } - /** - * Set enabled developer mode - * - * @param bool $mode - * @return bool - * - * @deprecated use Mage_Core_Model_App_State::setIsDeveloperMode() - */ - public static function setIsDeveloperMode($mode) - { - self::$_isDeveloperMode = (bool)$mode; - return self::$_isDeveloperMode; - } - /** * Retrieve enabled developer mode * * @return bool - * @deprecated use Mage_Core_Model_App_State::isDeveloperMode() + * @deprecated use Mage_Core_Model_App_State::getMode() */ public static function getIsDeveloperMode() { - return self::$_isDeveloperMode; + $objectManager = self::getObjectManager(); + if (!$objectManager) { + return false; + } + + $appState = $objectManager->get('Mage_Core_Model_App_State'); + if (!$appState) { + return false; + } + + $mode = $appState->getMode(); + return $mode == Mage_Core_Model_App_State::MODE_DEVELOPER; } /** @@ -756,7 +750,7 @@ public static function getIsDeveloperMode() */ public static function printException(Exception $e, $extra = '') { - if (self::$_isDeveloperMode) { + if (self::getIsDeveloperMode()) { print '
';
 
             if (!empty($extra)) {
diff --git a/app/bootstrap.php b/app/bootstrap.php
index d20ee4c1956c8..d258845e54e7d 100644
--- a/app/bootstrap.php
+++ b/app/bootstrap.php
@@ -34,20 +34,18 @@
  * Environment initialization
  */
 error_reporting(E_ALL | E_STRICT);
-#ini_set('display_errors', 1);
+ini_set('display_errors', 1);
 umask(0);
 
 /**
  * Require necessary files
  */
-require_once BP . '/app/code/core/Mage/Core/functions.php';
+require_once BP . '/app/code/Mage/Core/functions.php';
 require_once BP . '/app/Mage.php';
 
 require_once __DIR__ . '/autoload.php';
 Magento_Autoload_IncludePath::addIncludePath(array(
-    BP . DS . 'app' . DS . 'code' . DS . 'local',
-    BP . DS . 'app' . DS . 'code' . DS . 'community',
-    BP . DS . 'app' . DS . 'code' . DS . 'core',
+    BP . DS . 'app' . DS . 'code',
     BP . DS . 'lib',
     BP . DS . 'var' . DS . 'generation',
 ));
@@ -56,14 +54,14 @@
     require_once BP . '/lib/Magento/Autoload/ClassMap.php';
     $classMap = new Magento_Autoload_ClassMap(BP);
     $classMap->addMap(unserialize(file_get_contents($classMapPath)));
-    spl_autoload_register(array($classMap, 'load'));
+    spl_autoload_register(array($classMap, 'load'), true, true);
 }
 
 if (!defined('BARE_BOOTSTRAP')) {
     /* PHP version validation */
-    if (version_compare(phpversion(), '5.3.0', '<') === true) {
+    if (version_compare(phpversion(), '5.3.3', '<') === true) {
         if (PHP_SAPI == 'cli') {
-            echo 'Magento supports PHP 5.3.0 or newer. Please read http://www.magento.com/install.';
+            echo 'Magento supports PHP 5.3.3 or newer. Please read http://www.magento.com/install.';
         } else {
             echo <<
@@ -71,7 +69,7 @@
         

Whoops, it looks like you have an invalid PHP version.

-

Magento supports PHP 5.3.0 or newer. +

Magento supports PHP 5.3.3 or newer. Find out how to install Magento using PHP-CGI as a work-around.

@@ -88,9 +86,6 @@ } exit; } - if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) { - Mage::setIsDeveloperMode(true); - } if (!empty($_SERVER['MAGE_PROFILER'])) { $profilerConfigData = $_SERVER['MAGE_PROFILER']; diff --git a/app/code/core/Mage/AdminNotification/Helper/Data.php b/app/code/Mage/AdminNotification/Helper/Data.php similarity index 100% rename from app/code/core/Mage/AdminNotification/Helper/Data.php rename to app/code/Mage/AdminNotification/Helper/Data.php diff --git a/app/code/core/Mage/AdminNotification/Model/Config/Source/Frequency.php b/app/code/Mage/AdminNotification/Model/Config/Source/Frequency.php similarity index 100% rename from app/code/core/Mage/AdminNotification/Model/Config/Source/Frequency.php rename to app/code/Mage/AdminNotification/Model/Config/Source/Frequency.php diff --git a/app/code/core/Mage/AdminNotification/Model/Feed.php b/app/code/Mage/AdminNotification/Model/Feed.php similarity index 100% rename from app/code/core/Mage/AdminNotification/Model/Feed.php rename to app/code/Mage/AdminNotification/Model/Feed.php diff --git a/app/code/core/Mage/AdminNotification/Model/Inbox.php b/app/code/Mage/AdminNotification/Model/Inbox.php similarity index 100% rename from app/code/core/Mage/AdminNotification/Model/Inbox.php rename to app/code/Mage/AdminNotification/Model/Inbox.php diff --git a/app/code/core/Mage/AdminNotification/Model/Observer.php b/app/code/Mage/AdminNotification/Model/Observer.php similarity index 100% rename from app/code/core/Mage/AdminNotification/Model/Observer.php rename to app/code/Mage/AdminNotification/Model/Observer.php diff --git a/app/code/core/Mage/AdminNotification/Model/Resource/Inbox.php b/app/code/Mage/AdminNotification/Model/Resource/Inbox.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/AdminNotification/Model/Resource/Inbox.php rename to app/code/Mage/AdminNotification/Model/Resource/Inbox.php diff --git a/app/code/core/Mage/AdminNotification/Model/Resource/Inbox/Collection.php b/app/code/Mage/AdminNotification/Model/Resource/Inbox/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/AdminNotification/Model/Resource/Inbox/Collection.php rename to app/code/Mage/AdminNotification/Model/Resource/Inbox/Collection.php diff --git a/app/code/core/Mage/AdminNotification/Model/Survey.php b/app/code/Mage/AdminNotification/Model/Survey.php similarity index 100% rename from app/code/core/Mage/AdminNotification/Model/Survey.php rename to app/code/Mage/AdminNotification/Model/Survey.php diff --git a/app/code/Mage/AdminNotification/etc/adminhtml/acl.xml b/app/code/Mage/AdminNotification/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..39db7fd2495d0 --- /dev/null +++ b/app/code/Mage/AdminNotification/etc/adminhtml/acl.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Mage/AdminNotification/etc/adminhtml/menu.xml b/app/code/Mage/AdminNotification/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..edcecc10b7e2d --- /dev/null +++ b/app/code/Mage/AdminNotification/etc/adminhtml/menu.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/app/code/core/Mage/AdminNotification/etc/adminhtml/system.xml b/app/code/Mage/AdminNotification/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/AdminNotification/etc/adminhtml/system.xml rename to app/code/Mage/AdminNotification/etc/adminhtml/system.xml diff --git a/app/code/Mage/AdminNotification/etc/config.xml b/app/code/Mage/AdminNotification/etc/config.xml new file mode 100644 index 0000000000000..76aa7397979f5 --- /dev/null +++ b/app/code/Mage/AdminNotification/etc/config.xml @@ -0,0 +1,81 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + + Mage_AdminNotification + + + + + + + + + + Mage_AdminNotification.csv + + + + + + + + + Mage_AdminNotification_Model_Observer + preDispatch + + + + + + + + + notifications.magentocommerce.com/community/notifications.rss + widgets.magentocommerce.com/notificationPopup + widgets.magentocommerce.com/%s/%s.gif + 0 + 1 + 0 + + + + diff --git a/app/code/core/Mage/AdminNotification/locale/de_DE/Mage_AdminNotification.csv b/app/code/Mage/AdminNotification/locale/de_DE/Mage_AdminNotification.csv similarity index 100% rename from app/code/core/Mage/AdminNotification/locale/de_DE/Mage_AdminNotification.csv rename to app/code/Mage/AdminNotification/locale/de_DE/Mage_AdminNotification.csv diff --git a/app/code/core/Mage/AdminNotification/locale/en_US/Mage_AdminNotification.csv b/app/code/Mage/AdminNotification/locale/en_US/Mage_AdminNotification.csv similarity index 100% rename from app/code/core/Mage/AdminNotification/locale/en_US/Mage_AdminNotification.csv rename to app/code/Mage/AdminNotification/locale/en_US/Mage_AdminNotification.csv diff --git a/app/code/core/Mage/AdminNotification/locale/es_ES/Mage_AdminNotification.csv b/app/code/Mage/AdminNotification/locale/es_ES/Mage_AdminNotification.csv similarity index 100% rename from app/code/core/Mage/AdminNotification/locale/es_ES/Mage_AdminNotification.csv rename to app/code/Mage/AdminNotification/locale/es_ES/Mage_AdminNotification.csv diff --git a/app/code/core/Mage/AdminNotification/locale/fr_FR/Mage_AdminNotification.csv b/app/code/Mage/AdminNotification/locale/fr_FR/Mage_AdminNotification.csv similarity index 100% rename from app/code/core/Mage/AdminNotification/locale/fr_FR/Mage_AdminNotification.csv rename to app/code/Mage/AdminNotification/locale/fr_FR/Mage_AdminNotification.csv diff --git a/app/code/core/Mage/AdminNotification/locale/nl_NL/Mage_AdminNotification.csv b/app/code/Mage/AdminNotification/locale/nl_NL/Mage_AdminNotification.csv similarity index 100% rename from app/code/core/Mage/AdminNotification/locale/nl_NL/Mage_AdminNotification.csv rename to app/code/Mage/AdminNotification/locale/nl_NL/Mage_AdminNotification.csv diff --git a/app/code/core/Mage/AdminNotification/locale/pt_BR/Mage_AdminNotification.csv b/app/code/Mage/AdminNotification/locale/pt_BR/Mage_AdminNotification.csv similarity index 100% rename from app/code/core/Mage/AdminNotification/locale/pt_BR/Mage_AdminNotification.csv rename to app/code/Mage/AdminNotification/locale/pt_BR/Mage_AdminNotification.csv diff --git a/app/code/core/Mage/AdminNotification/locale/zh_CN/Mage_AdminNotification.csv b/app/code/Mage/AdminNotification/locale/zh_CN/Mage_AdminNotification.csv similarity index 100% rename from app/code/core/Mage/AdminNotification/locale/zh_CN/Mage_AdminNotification.csv rename to app/code/Mage/AdminNotification/locale/zh_CN/Mage_AdminNotification.csv diff --git a/app/code/core/Mage/AdminNotification/sql/adminnotification_setup/install-1.6.0.0.php b/app/code/Mage/AdminNotification/sql/adminnotification_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/AdminNotification/sql/adminnotification_setup/install-1.6.0.0.php rename to app/code/Mage/AdminNotification/sql/adminnotification_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Adminhtml/Block/Api/Buttons.php b/app/code/Mage/Adminhtml/Block/Api/Buttons.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Api/Buttons.php rename to app/code/Mage/Adminhtml/Block/Api/Buttons.php diff --git a/app/code/core/Mage/Adminhtml/Block/Api/Editroles.php b/app/code/Mage/Adminhtml/Block/Api/Editroles.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Api/Editroles.php rename to app/code/Mage/Adminhtml/Block/Api/Editroles.php diff --git a/app/code/core/Mage/Adminhtml/Block/Api/Grid/Role.php b/app/code/Mage/Adminhtml/Block/Api/Grid/Role.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Api/Grid/Role.php rename to app/code/Mage/Adminhtml/Block/Api/Grid/Role.php diff --git a/app/code/core/Mage/Adminhtml/Block/Api/Role.php b/app/code/Mage/Adminhtml/Block/Api/Role.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Api/Role.php rename to app/code/Mage/Adminhtml/Block/Api/Role.php diff --git a/app/code/core/Mage/Adminhtml/Block/Api/Role/Grid/User.php b/app/code/Mage/Adminhtml/Block/Api/Role/Grid/User.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Api/Role/Grid/User.php rename to app/code/Mage/Adminhtml/Block/Api/Role/Grid/User.php diff --git a/app/code/core/Mage/Adminhtml/Block/Api/Roles.php b/app/code/Mage/Adminhtml/Block/Api/Roles.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Api/Roles.php rename to app/code/Mage/Adminhtml/Block/Api/Roles.php diff --git a/app/code/core/Mage/Adminhtml/Block/Api/Tab/Roleinfo.php b/app/code/Mage/Adminhtml/Block/Api/Tab/Roleinfo.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Api/Tab/Roleinfo.php rename to app/code/Mage/Adminhtml/Block/Api/Tab/Roleinfo.php diff --git a/app/code/core/Mage/Adminhtml/Block/Api/Tab/Rolesedit.php b/app/code/Mage/Adminhtml/Block/Api/Tab/Rolesedit.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Api/Tab/Rolesedit.php rename to app/code/Mage/Adminhtml/Block/Api/Tab/Rolesedit.php diff --git a/app/code/core/Mage/Adminhtml/Block/Api/Tab/Rolesusers.php b/app/code/Mage/Adminhtml/Block/Api/Tab/Rolesusers.php similarity index 97% rename from app/code/core/Mage/Adminhtml/Block/Api/Tab/Rolesusers.php rename to app/code/Mage/Adminhtml/Block/Api/Tab/Rolesusers.php index bacf853a40378..f7bbd8630fcd0 100644 --- a/app/code/core/Mage/Adminhtml/Block/Api/Tab/Rolesusers.php +++ b/app/code/Mage/Adminhtml/Block/Api/Tab/Rolesusers.php @@ -47,7 +47,7 @@ protected function _prepareLayout() return parent::_prepareLayout(); } - protected function _getGridHtml() + public function getGridHtml() { return $this->getChildHtml('userGrid'); } diff --git a/app/code/core/Mage/Adminhtml/Block/Api/User.php b/app/code/Mage/Adminhtml/Block/Api/User.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Api/User.php rename to app/code/Mage/Adminhtml/Block/Api/User.php diff --git a/app/code/core/Mage/Adminhtml/Block/Api/User/Edit.php b/app/code/Mage/Adminhtml/Block/Api/User/Edit.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Api/User/Edit.php rename to app/code/Mage/Adminhtml/Block/Api/User/Edit.php diff --git a/app/code/core/Mage/Adminhtml/Block/Api/User/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Api/User/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Api/User/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/Api/User/Edit/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Api/User/Edit/Tab/Main.php b/app/code/Mage/Adminhtml/Block/Api/User/Edit/Tab/Main.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Api/User/Edit/Tab/Main.php rename to app/code/Mage/Adminhtml/Block/Api/User/Edit/Tab/Main.php diff --git a/app/code/core/Mage/Adminhtml/Block/Api/User/Edit/Tab/Roles.php b/app/code/Mage/Adminhtml/Block/Api/User/Edit/Tab/Roles.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Api/User/Edit/Tab/Roles.php rename to app/code/Mage/Adminhtml/Block/Api/User/Edit/Tab/Roles.php diff --git a/app/code/core/Mage/Adminhtml/Block/Api/User/Edit/Tabs.php b/app/code/Mage/Adminhtml/Block/Api/User/Edit/Tabs.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Api/User/Edit/Tabs.php rename to app/code/Mage/Adminhtml/Block/Api/User/Edit/Tabs.php diff --git a/app/code/core/Mage/Adminhtml/Block/Api/User/Grid.php b/app/code/Mage/Adminhtml/Block/Api/User/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Api/User/Grid.php rename to app/code/Mage/Adminhtml/Block/Api/User/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Backup.php b/app/code/Mage/Adminhtml/Block/Backup.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Backup.php rename to app/code/Mage/Adminhtml/Block/Backup.php diff --git a/app/code/core/Mage/Adminhtml/Block/Backup/Dialogs.php b/app/code/Mage/Adminhtml/Block/Backup/Dialogs.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Backup/Dialogs.php rename to app/code/Mage/Adminhtml/Block/Backup/Dialogs.php diff --git a/app/code/core/Mage/Adminhtml/Block/Cache.php b/app/code/Mage/Adminhtml/Block/Cache.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Cache.php rename to app/code/Mage/Adminhtml/Block/Cache.php diff --git a/app/code/core/Mage/Adminhtml/Block/Cache/Additional.php b/app/code/Mage/Adminhtml/Block/Cache/Additional.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Cache/Additional.php rename to app/code/Mage/Adminhtml/Block/Cache/Additional.php diff --git a/app/code/core/Mage/Adminhtml/Block/Cache/Grid.php b/app/code/Mage/Adminhtml/Block/Cache/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Cache/Grid.php rename to app/code/Mage/Adminhtml/Block/Cache/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Cache/Notifications.php b/app/code/Mage/Adminhtml/Block/Cache/Notifications.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Cache/Notifications.php rename to app/code/Mage/Adminhtml/Block/Cache/Notifications.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php b/app/code/Mage/Adminhtml/Block/Catalog/Category/Abstract.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php rename to app/code/Mage/Adminhtml/Block/Catalog/Category/Abstract.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Checkboxes/Tree.php b/app/code/Mage/Adminhtml/Block/Catalog/Category/Checkboxes/Tree.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Category/Checkboxes/Tree.php rename to app/code/Mage/Adminhtml/Block/Catalog/Category/Checkboxes/Tree.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit.php b/app/code/Mage/Adminhtml/Block/Catalog/Category/Edit.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit.php rename to app/code/Mage/Adminhtml/Block/Catalog/Category/Edit.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Catalog/Category/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/Catalog/Category/Edit/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Image.php b/app/code/Mage/Adminhtml/Block/Catalog/Category/Helper/Image.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Image.php rename to app/code/Mage/Adminhtml/Block/Catalog/Category/Helper/Image.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Pricestep.php b/app/code/Mage/Adminhtml/Block/Catalog/Category/Helper/Pricestep.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Pricestep.php rename to app/code/Mage/Adminhtml/Block/Catalog/Category/Helper/Pricestep.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Sortby/Available.php b/app/code/Mage/Adminhtml/Block/Catalog/Category/Helper/Sortby/Available.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Sortby/Available.php rename to app/code/Mage/Adminhtml/Block/Catalog/Category/Helper/Sortby/Available.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Sortby/Default.php b/app/code/Mage/Adminhtml/Block/Catalog/Category/Helper/Sortby/Default.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Sortby/Default.php rename to app/code/Mage/Adminhtml/Block/Catalog/Category/Helper/Sortby/Default.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php b/app/code/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php rename to app/code/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Design.php b/app/code/Mage/Adminhtml/Block/Catalog/Category/Tab/Design.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Design.php rename to app/code/Mage/Adminhtml/Block/Catalog/Category/Tab/Design.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/General.php b/app/code/Mage/Adminhtml/Block/Catalog/Category/Tab/General.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/General.php rename to app/code/Mage/Adminhtml/Block/Catalog/Category/Tab/General.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php b/app/code/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php rename to app/code/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tabs.php b/app/code/Mage/Adminhtml/Block/Catalog/Category/Tabs.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tabs.php rename to app/code/Mage/Adminhtml/Block/Catalog/Category/Tabs.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php b/app/code/Mage/Adminhtml/Block/Catalog/Category/Tree.php similarity index 98% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php rename to app/code/Mage/Adminhtml/Block/Catalog/Category/Tree.php index 67619d263620d..2223168468494 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php +++ b/app/code/Mage/Adminhtml/Block/Catalog/Category/Tree.php @@ -34,8 +34,6 @@ */ class Mage_Adminhtml_Block_Catalog_Category_Tree extends Mage_Adminhtml_Block_Catalog_Category_Abstract { - const XML_PATH_SUGGESTED_CATEGORIES_LIMIT = 'global/catalog/suggested_categories/limit'; - protected $_withProductCount; protected $_template = 'catalog/category/tree.phtml'; @@ -123,7 +121,6 @@ public function getSuggestedCategoriesJson($namePart) $matchingNamesCollection->addAttributeToFilter('name', array('like' => $escapedNamePart)) ->addAttributeToFilter('entity_id', array('neq' => Mage_Catalog_Model_Category::TREE_ROOT_ID)) ->addAttributeToSelect('path') - ->setPageSize((string)Mage::getConfig()->getNode(self::XML_PATH_SUGGESTED_CATEGORIES_LIMIT)) ->setStoreId($storeId); $shownCategoriesIds = array(); diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Widget/Chooser.php b/app/code/Mage/Adminhtml/Block/Catalog/Category/Widget/Chooser.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Category/Widget/Chooser.php rename to app/code/Mage/Adminhtml/Block/Catalog/Category/Widget/Chooser.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Form.php b/app/code/Mage/Adminhtml/Block/Catalog/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Form.php rename to app/code/Mage/Adminhtml/Block/Catalog/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Attribute/Urlkey.php b/app/code/Mage/Adminhtml/Block/Catalog/Form/Renderer/Attribute/Urlkey.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Attribute/Urlkey.php rename to app/code/Mage/Adminhtml/Block/Catalog/Form/Renderer/Attribute/Urlkey.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Config/DateFieldsOrder.php b/app/code/Mage/Adminhtml/Block/Catalog/Form/Renderer/Config/DateFieldsOrder.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Config/DateFieldsOrder.php rename to app/code/Mage/Adminhtml/Block/Catalog/Form/Renderer/Config/DateFieldsOrder.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Config/YearRange.php b/app/code/Mage/Adminhtml/Block/Catalog/Form/Renderer/Config/YearRange.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Config/YearRange.php rename to app/code/Mage/Adminhtml/Block/Catalog/Form/Renderer/Config/YearRange.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Fieldset/Element.php b/app/code/Mage/Adminhtml/Block/Catalog/Form/Renderer/Fieldset/Element.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Fieldset/Element.php rename to app/code/Mage/Adminhtml/Block/Catalog/Form/Renderer/Fieldset/Element.php diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Helper/Form/Wysiwyg.php b/app/code/Mage/Adminhtml/Block/Catalog/Helper/Form/Wysiwyg.php new file mode 100644 index 0000000000000..4ab9d280d8a27 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Catalog/Helper/Form/Wysiwyg.php @@ -0,0 +1,96 @@ + + */ +class Mage_Adminhtml_Block_Catalog_Helper_Form_Wysiwyg extends Varien_Data_Form_Element_Textarea +{ + /** + * Retrieve additional html and put it at the end of element html + * + * @return string + */ + public function getAfterElementHtml() + { + $html = parent::getAfterElementHtml(); + if ($this->getIsWysiwygEnabled()) { + $disabled = ($this->getDisabled() || $this->getReadonly()); + $html .= Mage::app()->getLayout() + ->createBlock('Mage_Adminhtml_Block_Widget_Button', '', array('data' => array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('WYSIWYG Editor'), + 'type' => 'button', + 'disabled' => $disabled, + 'class' => ($disabled) ? 'disabled action-wysiwyg' : 'action-wysiwyg', + 'onclick' => 'catalogWysiwygEditor.open(\'' + . Mage::helper('Mage_Adminhtml_Helper_Data')->getUrl('adminhtml/catalog_product/wysiwyg') + . '\', \'' . $this->getHtmlId().'\')' + )))->toHtml(); + $html .= << +jQuery('#{$this->getHtmlId()}') + .addClass('wysiwyg-editor') + .data( + 'wysiwygEditor', + new tinyMceWysiwygSetup( + '{$this->getHtmlId()}', + { + settings: { + theme_advanced_buttons1 : 'bold,italic,|,justifyleft,justifycenter,justifyright,|,' + + 'fontselect,fontsizeselect,|,forecolor,backcolor,|,link,unlink,image,|,bullist,numlist,|,code', + theme_advanced_buttons2: null, + theme_advanced_buttons3: null, + theme_advanced_buttons4: null, + theme_advanced_statusbar_location: null + } + } + ).turnOn() + ); + +HTML; + } + return $html; + } + + /** + * Check whether wysiwyg enabled or not + * + * @return boolean + */ + public function getIsWysiwygEnabled() + { + if (Mage::helper('Mage_Catalog_Helper_Data')->isModuleEnabled('Mage_Cms')) { + return (bool)(Mage::getSingleton('Mage_Cms_Model_Wysiwyg_Config')->isEnabled() + && $this->getEntityAttribute()->getIsWysiwygEnabled()); + } + + return false; + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Helper/Form/Wysiwyg/Content.php b/app/code/Mage/Adminhtml/Block/Catalog/Helper/Form/Wysiwyg/Content.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Helper/Form/Wysiwyg/Content.php rename to app/code/Mage/Adminhtml/Block/Catalog/Helper/Form/Wysiwyg/Content.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product.php b/app/code/Mage/Adminhtml/Block/Catalog/Product.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute.php diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit.php new file mode 100644 index 0000000000000..faafc38e7a4cf --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit.php @@ -0,0 +1,123 @@ + + */ + +class Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit extends Mage_Adminhtml_Block_Widget_Form_Container +{ + + protected function _construct() + { + $this->_objectId = 'attribute_id'; + $this->_controller = 'catalog_product_attribute'; + + parent::_construct(); + + if($this->getRequest()->getParam('popup')) { + $this->_removeButton('back'); + $this->_addButton( + 'save_in_new_set', + array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Save in New Attribute Set'), + 'class' => 'save', + 'onclick' => 'saveAttributeInNewSet(\'' + . Mage::helper('Mage_Catalog_Helper_Data')->__('Enter Name for New Attribute Set') + . '\')', + ) + ); + } else { + $this->_addButton( + 'save_and_edit_button', + array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Save and Continue Edit'), + 'class' => 'save', + 'data_attribute' => array( + 'mage-init' => array( + 'button' => array('event' => 'saveAndContinueEdit', 'target' => '#edit_form'), + ), + ), + ), + 100 + ); + } + + $this->_updateButton('save', 'label', Mage::helper('Mage_Catalog_Helper_Data')->__('Save Attribute')); + $this->_updateButton('save', 'data_attribute', array( + 'mage-init' => array( + 'button' => array('event' => 'save', 'target' => '#edit_form'), + ), + )); + + if (!Mage::registry('entity_attribute') || !Mage::registry('entity_attribute')->getIsUserDefined()) { + $this->_removeButton('delete'); + } else { + $this->_updateButton('delete', 'label', Mage::helper('Mage_Catalog_Helper_Data')->__('Delete Attribute')); + } + } + + /** + * Retrieve header text + * + * @return string + */ + public function getHeaderText() + { + if (Mage::registry('entity_attribute')->getId()) { + $frontendLabel = Mage::registry('entity_attribute')->getFrontendLabel(); + if (is_array($frontendLabel)) { + $frontendLabel = $frontendLabel[0]; + } + return Mage::helper('Mage_Catalog_Helper_Data')->__('Edit Product Attribute "%s"', $this->escapeHtml($frontendLabel)); + } + return Mage::helper('Mage_Catalog_Helper_Data')->__('New Product Attribute'); + } + + /** + * Retrieve URL for validation + * + * @return string + */ + public function getValidationUrl() + { + return $this->getUrl('*/*/validate', array('_current'=>true)); + } + + /** + * Retrieve URL for save + * + * @return string + */ + public function getSaveUrl() + { + return $this->getUrl('*/'.$this->_controller.'/save', array('_current'=>true, 'back'=>null)); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Front.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Front.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Front.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Front.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Main.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Main.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Main.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Main.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Options.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Options.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Options.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Options.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/System.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/System.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/System.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/System.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tabs.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tabs.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tabs.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tabs.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Grid.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Grid.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Attributes.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Attributes.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Attributes.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Attributes.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Created.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Created.php similarity index 92% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Created.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Created.php index e2b61043d8bce..2053341a464dc 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Created.php +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Created.php @@ -48,11 +48,6 @@ protected function _prepareLayout() $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Attribute_New_Product_Attributes') ->setGroupAttributes($this->_getGroupAttributes()) ); - - $this->addChild('close_button', 'Mage_Adminhtml_Block_Widget_Button', array( - 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Close Window'), - 'onclick' => 'addAttribute(true)' - )); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formattribute.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formattribute.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formattribute.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formattribute.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formgroup.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formgroup.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formgroup.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formgroup.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formset.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formset.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formset.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formset.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Tree/Attribute.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Tree/Attribute.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Tree/Attribute.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Tree/Attribute.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Tree/Group.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Tree/Group.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Tree/Group.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Tree/Group.php diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Add.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Add.php new file mode 100644 index 0000000000000..be947e0ee6a86 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Add.php @@ -0,0 +1,89 @@ + + */ +class Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Toolbar_Add extends Mage_Adminhtml_Block_Template +{ + + protected $_template = 'catalog/product/attribute/set/toolbar/add.phtml'; + + protected function _prepareLayout() + { + $this->addChild('save_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Save Attribute Set'), + 'class' => 'save', + 'data_attribute' => array( + 'mage-init' => array( + 'button' => array('event' => 'save', 'target' => '#set-prop-form'), + ), + ), + )); + $this->addChild('back_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Back'), + 'onclick' => 'setLocation(\''.$this->getUrl('*/*/').'\')', + 'class' => 'back' + )); + + $this->addChild('setForm', 'Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Main_Formset'); + return parent::_prepareLayout(); + } + + protected function _getHeader() + { + return Mage::helper('Mage_Catalog_Helper_Data')->__('Add New Attribute Set'); + } + + protected function getSaveButtonHtml() + { + return $this->getChildHtml('save_button'); + } + + protected function getBackButtonHtml() + { + return $this->getChildHtml('back_button'); + } + + protected function getFormHtml() + { + return $this->getChildHtml('setForm'); + } + + /** + * Return id of form, used by this block + * + * @return string + */ + public function getFormId() + { + return $this->getChildBlock('setForm')->getForm()->getId(); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main/Filter.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main/Filter.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main/Filter.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main/Filter.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Configure.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Composite/Configure.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Configure.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Composite/Configure.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Error.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Composite/Error.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Error.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Composite/Error.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Configurable.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Configurable.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Configurable.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Configurable.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Grouped.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Grouped.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Grouped.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Grouped.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Options.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Options.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Options.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Options.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Qty.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Qty.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Qty.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Qty.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Update/Result.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Composite/Update/Result.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Update/Result.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Composite/Update/Result.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Created.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Created.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Created.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Created.php diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit.php new file mode 100644 index 0000000000000..23a543176da1d --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit.php @@ -0,0 +1,360 @@ + + */ +class Mage_Adminhtml_Block_Catalog_Product_Edit extends Mage_Adminhtml_Block_Widget +{ + protected $_template = 'catalog/product/edit.phtml'; + + protected function _construct() + { + parent::_construct(); + $this->setId('product_edit'); + } + + /** + * Retrieve currently edited product object + * + * @return Mage_Catalog_Model_Product + */ + public function getProduct() + { + return Mage::registry('current_product'); + } + + /** + * Add elements in layout + * + * @return Mage_Adminhtml_Block_Catalog_Product_Edit + */ + protected function _prepareLayout() + { + if (!$this->getRequest()->getParam('popup')) { + $this->addChild('back_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Back'), + 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Back'), + 'onclick' => 'setLocation(\'' + . $this->getUrl('*/*/', array('store' => $this->getRequest()->getParam('store', 0))) . '\')', + 'class' => 'action-back' + )); + } else { + $this->addChild('back_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Close Window'), + 'onclick' => 'window.close()', + 'class' => 'cancel' + )); + } + + if (!$this->getProduct()->isReadonly()) { + $this->addChild('reset_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Reset'), + 'onclick' => 'setLocation(\'' . $this->getUrl('*/*/*', array('_current' => true)) . '\')' + )); + } + + if (!$this->getRequest()->getParam('popup')) { + if ($this->getProduct()->isDeleteable()) { + $this->addChild('delete_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Delete'), + 'onclick' => 'confirmSetLocation(\'' + . Mage::helper('Mage_Catalog_Helper_Data')->__('Are you sure?') . '\', \'' . $this->getDeleteUrl() . '\')', + 'class' => 'delete' + )); + } + } + if (!$this->getProduct()->isReadonly()) { + $this->addChild('save-split-button', 'Mage_Backend_Block_Widget_Button_Split', array( + 'id' => 'save-split-button', + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Save'), + 'class_name' => 'Mage_Backend_Block_Widget_Button_Split', + 'button_class' => 'widget-button-save', + 'options' => $this->_getSaveSplitButtonOptions() + )); + } + + return parent::_prepareLayout(); + } + + public function getBackButtonHtml() + { + return $this->getChildHtml('back_button'); + } + + public function getCancelButtonHtml() + { + return $this->getChildHtml('reset_button'); + } + + public function getSaveButtonHtml() + { + return $this->getChildHtml('save_button'); + } + + public function getSaveAndEditButtonHtml() + { + return $this->getChildHtml('save_and_edit_button'); + } + + public function getDeleteButtonHtml() + { + return $this->getChildHtml('delete_button'); + } + + public function getDuplicateButtonHtml() + { + return $this->getChildHtml('duplicate_button'); + } + + /** + * Get Save Split Button html + * + * @return string + */ + public function getSaveSplitButtonHtml() + { + return $this->getChildHtml('save-split-button'); + } + + public function getValidationUrl() + { + return $this->getUrl('*/*/validate', array('_current'=>true)); + } + + public function getSaveUrl() + { + return $this->getUrl('*/*/save', array('_current'=>true, 'back'=>null)); + } + + public function getSaveAndContinueUrl() + { + return $this->getUrl('*/*/save', array( + '_current' => true, + 'back' => 'edit', + 'tab' => '{{tab_id}}', + 'active_tab' => null + )); + } + + public function getProductId() + { + return $this->getProduct()->getId(); + } + + public function getProductSetId() + { + $setId = false; + if (!($setId = $this->getProduct()->getAttributeSetId()) && $this->getRequest()) { + $setId = $this->getRequest()->getParam('set', null); + } + return $setId; + } + + public function getIsGrouped() + { + return $this->getProduct()->isGrouped(); + } + + public function getDeleteUrl() + { + return $this->getUrl('*/*/delete', array('_current'=>true)); + } + + public function getDuplicateUrl() + { + return $this->getUrl('*/*/duplicate', array('_current'=>true)); + } + + public function getHeader() + { + if ($this->getProduct()->getId()) { + $header = $this->escapeHtml($this->getProduct()->getName()); + } else { + $header = Mage::helper('Mage_Catalog_Helper_Data')->__('New Product'); + } + return $header; + } + + public function getAttributeSetName() + { + if ($setId = $this->getProduct()->getAttributeSetId()) { + $set = Mage::getModel('Mage_Eav_Model_Entity_Attribute_Set') + ->load($setId); + return $set->getAttributeSetName(); + } + return ''; + } + + public function getIsConfigured() + { + $result = true; + + $product = $this->getProduct(); + if ($product->isConfigurable()) { + $superAttributes = $product->getTypeInstance()->getUsedProductAttributeIds($product); + $result = !empty($superAttributes); + } + + return $result; + } + + public function getSelectedTabId() + { + return addslashes(htmlspecialchars($this->getRequest()->getParam('tab'))); + } + + /** + * Get fields masks from config + * + * @return array + */ + public function getFieldsAutogenerationMasks() + { + return $this->helper('Mage_Catalog_Helper_Product')->getFieldsAutogenerationMasks(); + } + + /** + * Retrieve available placeholders + * + * @return array + */ + public function getAttributesAllowedForAutogeneration() + { + return $this->helper('Mage_Catalog_Helper_Product')->getAttributesAllowedForAutogeneration(); + } + + /** + * Get data for JS (product type transition) + * + * @return string + */ + public function getTypeSwitcherData() + { + return Mage::helper('Mage_Core_Helper_Data')->jsonEncode(array( + 'tab_id' => 'product_info_tabs_downloadable_items', + 'is_virtual_id' => Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Weight::VIRTUAL_FIELD_HTML_ID, + 'weight_id' => 'weight', + 'current_type' => $this->getProduct()->getTypeId(), + 'attributes' => $this->_getAttributes(), + )); + } + + /** + * Get formed array with attribute codes and Apply To property + * + * @return array + */ + protected function _getAttributes() + { + /** @var $product Mage_Catalog_Model_Product */ + $product = $this->getProduct(); + $attributes = array(); + + foreach ($product->getAttributes() as $key => $attribute) { + $attributes[$key] = $attribute->getApplyTo(); + } + return $attributes; + } + + /** + * Get dropdown options for save split button + * + * @return array + */ + protected function _getSaveSplitButtonOptions() + { + $options = array(); + if (!$this->getRequest()->getParam('popup')) { + $options[] = array( + 'id' => 'edit-button', + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Save & Edit'), + 'data_attribute' => array( + 'mage-init' => array( + 'button' => array('event' => 'saveAndContinueEdit', 'target' => '#product-edit-form'), + ), + ), + 'default' => true, + ); + } + + /** @var $limitation Mage_Catalog_Model_Product_Limitation */ + $limitation = Mage::getObjectManager()->get('Mage_Catalog_Model_Product_Limitation'); + if ($this->_isProductNew()) { + $showAddNewButtons = !$limitation->isCreateRestricted(2); + } else { + $showAddNewButtons = !$limitation->isCreateRestricted(); + } + if ($showAddNewButtons) { + $options[] = array( + 'id' => 'new-button', + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Save & New'), + 'data_attribute' => array( + 'mage-init' => array( + 'button' => array('event' => 'saveAndNew', 'target' => '#product-edit-form'), + ), + ), + ); + if (!$this->getRequest()->getParam('popup') && $this->getProduct()->isDuplicable()) { + $options[] = array( + 'id' => 'duplicate-button', + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Save & Duplicate'), + 'data_attribute' => array( + 'mage-init' => array( + 'button' => array('event' => '', 'target' => '#product-edit-form'), + ), + ), + 'onclick' => $this->_isProductNew() ? '' : 'setLocation(\'' . $this->getDuplicateUrl() . '\')', + ); + } + } + $options[] = array( + 'id' => 'close-button', + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Save & Close'), + 'data_attribute' => array( + 'mage-init' => array( + 'button' => array('event' => 'save', 'target' => '#product-edit-form'), + ), + ), + ); + return $options; + } + + /** + * Check whether new product is being created + * + * @return bool + */ + protected function _isProductNew() + { + $product = $this->getProduct(); + return !$product || !$product->getId(); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tab/Attributes.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tab/Attributes.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tab/Attributes.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tab/Attributes.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tab/Inventory.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tab/Inventory.php similarity index 93% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tab/Inventory.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tab/Inventory.php index 85d2da9c5a37a..35b4a2a3b3150 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tab/Inventory.php +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tab/Inventory.php @@ -82,12 +82,12 @@ public function getDefaultConfigValue($field) */ public function getTabLabel() { - return Mage::helper('Mage_Catalog_Helper_Data')->__('Inventory'); + return Mage::helper('Mage_Catalog_Helper_Data')->__('Advanced Inventory'); } public function getTabTitle() { - return Mage::helper('Mage_Catalog_Helper_Data')->__('Inventory'); + return Mage::helper('Mage_Catalog_Helper_Data')->__('Advanced Inventory'); } public function canShowTab() diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tab/Websites.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tab/Websites.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tab/Websites.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tab/Websites.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tabs.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tabs.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tabs.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tabs.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/AttributeSet.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/AttributeSet.php similarity index 90% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/AttributeSet.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/AttributeSet.php index f79a1eb4ab6f4..d8b09c5b92202 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/AttributeSet.php +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/AttributeSet.php @@ -44,11 +44,10 @@ public function getSelectorOptions() return array( 'source' => $this->getUrl('*/catalog_product/suggestProductTemplates'), 'className' => 'category-select', - 'template' => '#product-template-selector-template', 'showRecent' => true, 'storageKey' => 'product-template-key', 'minLength' => 0, - 'ajaxData' => array('current_template_id' => Mage::registry('product')->getAttributeSetId()), + 'currentlySelected' => Mage::registry('product')->getAttributeSetId(), ); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Js.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Js.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Js.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Js.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/NewCategory.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/NewCategory.php similarity index 88% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/NewCategory.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/NewCategory.php index cffde3ac48c01..8b27087349548 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/NewCategory.php +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/NewCategory.php @@ -61,6 +61,16 @@ protected function _prepareForm() $this->setForm($form); } + /** + * Category save action URL + * + * @return string + */ + public function getSaveCategoryUrl() + { + return $this->getUrl('adminhtml/catalog_category/save'); + } + /** * Attach new category dialog widget initialization * @@ -73,14 +83,13 @@ public function getAfterElementHtml() $widgetUrl = $coreHelper->jsonEncode($this->getViewFileUrl('Mage_Catalog::js/new-category-dialog.js')); $widgetOptions = $coreHelper->jsonEncode(array( 'suggestOptions' => array( - 'source' => $this->getUrl('*/catalog_category/suggestCategories'), + 'source' => $this->getUrl('adminhtml/catalog_category/suggestCategories'), 'valueField' => '#new_category_parent', - 'template' => '#category_ids-template', - 'control' => 'jstree', - 'multiselect' => true, 'className' => 'category-select', + 'multiselect' => true, + 'showAll' => true, ), - 'saveCategoryUrl' => $this->getUrl('*/catalog_category/save'), + 'saveCategoryUrl' => $this->getUrl('adminhtml/catalog_category/save'), )); return << diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Ajax/Serializer.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Ajax/Serializer.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Ajax/Serializer.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Ajax/Serializer.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts/Price.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts/Price.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts/Price.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts/Price.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts/Stock.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts/Stock.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts/Stock.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts/Stock.php diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php new file mode 100644 index 0000000000000..acdee5bc910c6 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php @@ -0,0 +1,184 @@ + + */ +class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes extends Mage_Adminhtml_Block_Catalog_Form +{ + /** + * Load Wysiwyg on demand and prepare layout + */ + protected function _prepareLayout() + { + parent::_prepareLayout(); + if (Mage::helper('Mage_Catalog_Helper_Data')->isModuleEnabled('Mage_Cms') + && Mage::getSingleton('Mage_Cms_Model_Wysiwyg_Config')->isEnabled() + ) { + $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true); + } + } + + /** + * Prepare attributes form + * + * @return null + */ + protected function _prepareForm() + { + /** @var $group Mage_Eav_Model_Entity_Attribute_Group */ + $group = $this->getGroup(); + if ($group) { + $form = new Varien_Data_Form(); + $product = Mage::registry('product'); + $isWrapped = Mage::registry('use_wrapper'); + if (!isset($isWrapped)) { + $isWrapped = true; + } + $isCollapsable = $isWrapped && $group->getAttributeGroupCode() == 'product-details'; + $legend = $isWrapped ? Mage::helper('Mage_Catalog_Helper_Data')->__($group->getAttributeGroupName()) : null; + // Initialize product object as form property to use it during elements generation + $form->setDataObject($product); + + $fieldset = $form->addFieldset( + 'group-fields-' .$group->getAttributeGroupCode(), + array( + 'class' => 'user-defined', + 'legend' => $legend, + 'collapsable' => $isCollapsable + ) + ); + + $attributes = $this->getGroupAttributes(); + + $this->_setFieldset($attributes, $fieldset, array('gallery')); + + $urlKey = $form->getElement('url_key'); + if ($urlKey) { + $urlKey->setRenderer( + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Form_Renderer_Attribute_Urlkey') + ); + } + + $tierPrice = $form->getElement('tier_price'); + if ($tierPrice) { + $tierPrice->setRenderer( + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Tier') + ); + } + + $groupPrice = $form->getElement('group_price'); + if ($groupPrice) { + $groupPrice->setRenderer( + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Group') + ); + } + + $recurringProfile = $form->getElement('recurring_profile'); + if ($recurringProfile) { + $recurringProfile->setRenderer( + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Recurring') + ); + } + + // Add new attribute button if it is not an image tab + if (!$form->getElement('media_gallery') + && Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Catalog::attributes_attributes') + && $isWrapped + ) { + $headerBar = $this->getLayout() + ->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes_Create'); + + $headerBar->getConfig() + ->setTabId('group_' . $group->getId()) + ->setGroupId($group->getId()) + ->setStoreId($form->getDataObject()->getStoreId()) + ->setAttributeSetId($form->getDataObject()->getAttributeSetId()) + ->setTypeId($form->getDataObject()->getTypeId()) + ->setProductId($form->getDataObject()->getId()); + + $fieldset->setHeaderBar($headerBar->toHtml()); + } + + $values = $product->getData(); + + // Set default attribute values for new product or on attribute set change + if (!$product->getId() || $product->dataHasChangedFor('attribute_set_id')) { + foreach ($attributes as $attribute) { + if (!isset($values[$attribute->getAttributeCode()])) { + $values[$attribute->getAttributeCode()] = $attribute->getDefaultValue(); + } + } + } + + if ($product->hasLockedAttributes()) { + foreach ($product->getLockedAttributes() as $attribute) { + $element = $form->getElement($attribute); + if ($element) { + $element->setReadonly(true, true); + } + } + } + $form->addValues($values); + $form->setFieldNameSuffix('product'); + + Mage::dispatchEvent('adminhtml_catalog_product_edit_prepare_form', array('form' => $form)); + + $this->setForm($form); + } + } + + /** + * Retrieve additional element types + * + * @return array + */ + protected function _getAdditionalElementTypes() + { + $result = array( + 'price' => 'Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Price', + 'weight' => 'Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Weight', + 'gallery' => 'Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery', + 'image' => 'Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Image', + 'boolean' => 'Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Boolean', + 'textarea' => 'Mage_Adminhtml_Block_Catalog_Helper_Form_Wysiwyg', + ); + + $response = new Varien_Object(); + $response->setTypes(array()); + Mage::dispatchEvent('adminhtml_catalog_product_edit_element_types', array('response' => $response)); + + foreach ($response->getTypes() as $typeName => $typeClass) { + $result[$typeName] = $typeClass; + } + + return $result; + } +} diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes/Create.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes/Create.php new file mode 100644 index 0000000000000..389f898b584a1 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes/Create.php @@ -0,0 +1,113 @@ + + */ +class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes_Create extends Mage_Adminhtml_Block_Widget_Button +{ + /** + * Config of create new attribute + * + * @var Varien_Object + */ + protected $_config = null; + + /** + * Retrive config of new attribute creation + * + * @return Varien_Object + */ + public function getConfig() + { + if (is_null($this->_config)) { + $this->_config = new Varien_Object(); + } + + return $this->_config; + } + + protected function _beforeToHtml() + { + $this->setId('create_attribute_' . $this->getConfig()->getGroupId()) + ->setType('button') + ->setClass('action-add') + ->setLabel(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Add Attribute')) + ->setDataAttribute(array('mage-init' => + array('productAttributes' => + array( + 'url' => $this->getUrl( + '*/catalog_product_attribute/new', + array( + 'group' => $this->getConfig()->getGroupId(), + 'product_tab' => $this->getConfig()->getTabId(), + 'store' => $this->getConfig()->getStoreId(), + 'product' => $this->getConfig()->getProductId(), + 'type' => $this->getConfig()->getTypeId(), + 'popup' => 1 + ) + ) + ) + ) + )); + + $this->getConfig() + ->setUrl($this->getUrl( + '*/catalog_product_attribute/new', + array( + 'group' => $this->getConfig()->getGroupId(), + 'product_tab' => $this->getConfig()->getTabId(), + 'store' => $this->getConfig()->getStoreId(), + 'product' => $this->getConfig()->getProductId(), + 'set' => $this->getConfig()->getAttributeSetId(), + 'type' => $this->getConfig()->getTypeId(), + 'popup' => 1 + ) + )); + + return parent::_beforeToHtml(); + } + + protected function _toHtml() + { + $this->setCanShow(true); + Mage::dispatchEvent('adminhtml_catalog_product_edit_tab_attributes_create_html_before', array('block' => $this)); + if (!$this->getCanShow()) { + return ''; + } + + return parent::_toHtml(); + } + + public function getJsObjectName() + { + return $this->getId() . 'JsObject'; + } +} // Class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes_Create End diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php similarity index 87% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php index c9dbed15a64d5..236e759a9ed36 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php @@ -134,33 +134,38 @@ protected function _prepareColumns() { if (!$this->isReadonly()) { $this->addColumn('in_products', array( - 'header_css_class' => 'a-center', 'type' => 'checkbox', 'name' => 'in_products', 'values' => $this->_getSelectedProducts(), 'align' => 'center', - 'index' => 'entity_id' + 'index' => 'entity_id', + 'header_css_class' => 'col-select', + 'column_css_class' => 'col-select' )); } $this->addColumn('entity_id', array( 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('ID'), 'sortable' => true, - 'width' => 60, - 'index' => 'entity_id' + 'index' => 'entity_id', + 'header_css_class' => 'col-id', + 'column_css_class' => 'col-id' )); $this->addColumn('name', array( 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Name'), - 'index' => 'name' + 'index' => 'name', + 'header_css_class' => 'col-name', + 'column_css_class' => 'col-name' )); $this->addColumn('type', array( 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Type'), - 'width' => 100, 'index' => 'type_id', 'type' => 'options', 'options' => Mage::getSingleton('Mage_Catalog_Model_Product_Type')->getOptionArray(), + 'header_css_class' => 'col-type', + 'column_css_class' => 'col-type' )); $sets = Mage::getResourceModel('Mage_Eav_Model_Resource_Entity_Attribute_Set_Collection') @@ -170,51 +175,58 @@ protected function _prepareColumns() $this->addColumn('set_name', array( 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Attrib. Set Name'), - 'width' => 130, 'index' => 'attribute_set_id', 'type' => 'options', 'options' => $sets, + 'header_css_class' => 'col-attr-name', + 'column_css_class' => 'col-attr-name' )); $this->addColumn('status', array( 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Status'), - 'width' => 90, 'index' => 'status', 'type' => 'options', 'options' => Mage::getSingleton('Mage_Catalog_Model_Product_Status')->getOptionArray(), + 'header_css_class' => 'col-status', + 'column_css_class' => 'col-status' )); $this->addColumn('visibility', array( 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Visibility'), - 'width' => 90, 'index' => 'visibility', 'type' => 'options', 'options' => Mage::getSingleton('Mage_Catalog_Model_Product_Visibility')->getOptionArray(), + 'header_css_class' => 'col-visibility', + 'column_css_class' => 'col-visibility' )); $this->addColumn('sku', array( 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('SKU'), - 'width' => 80, - 'index' => 'sku' + 'index' => 'sku', + 'header_css_class' => 'col-sku', + 'column_css_class' => 'col-sku' )); $this->addColumn('price', array( 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Price'), 'type' => 'currency', 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE), - 'index' => 'price' + 'index' => 'price', + 'header_css_class' => 'col-price', + 'column_css_class' => 'col-price' )); $this->addColumn('position', array( 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Position'), 'name' => 'position', - 'width' => 60, 'type' => 'number', 'validate_class' => 'validate-number', 'index' => 'position', 'editable' => !$this->isReadonly(), - 'edit_only' => !$this->_getProduct()->getId() + 'edit_only' => !$this->_getProduct()->getId(), + 'header_css_class' => 'col-position', + 'column_css_class' => 'col-position' )); return parent::_prepareColumns(); diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Inventory.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Inventory.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Inventory.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Inventory.php diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options.php new file mode 100644 index 0000000000000..87e4008b9129b --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options.php @@ -0,0 +1,67 @@ + + */ + +class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options extends Mage_Adminhtml_Block_Widget +{ + protected $_template = 'catalog/product/edit/options.phtml'; + + protected function _prepareLayout() + { + $this->addChild('add_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Add New Option'), + 'class' => 'add', + 'id' => 'add_new_defined_option' + )); + + $this->addChild('options_box', 'Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Option'); + + $this->addChild('import_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Import Options'), + 'class' => 'add', + 'id' => 'import_new_defined_option' + )); + + return parent::_prepareLayout(); + } + + public function getAddButtonHtml() + { + return $this->getChildHtml('add_button'); + } + + public function getOptionsBoxHtml() + { + return $this->getChildHtml('options_box'); + } +} diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php new file mode 100644 index 0000000000000..43a51e670a636 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php @@ -0,0 +1,352 @@ + + */ + +class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Option extends Mage_Adminhtml_Block_Widget +{ + protected $_product; + + protected $_productInstance; + + protected $_values; + + protected $_itemCount = 1; + + protected $_template = 'catalog/product/edit/options/option.phtml'; + + /** + * Class constructor + */ + protected function _construct() + { + parent::_construct(); + + $this->setCanReadPrice(true); + $this->setCanEditPrice(true); + } + + public function getItemCount() + { + return $this->_itemCount; + } + + public function setItemCount($itemCount) + { + $this->_itemCount = max($this->_itemCount, $itemCount); + return $this; + } + + /** + * Get Product + * + * @return Mage_Catalog_Model_Product + */ + public function getProduct() + { + if (!$this->_productInstance) { + if ($product = Mage::registry('product')) { + $this->_productInstance = $product; + } else { + $this->_productInstance = Mage::getSingleton('Mage_Catalog_Model_Product'); + } + } + + return $this->_productInstance; + } + + public function setProduct($product) + { + $this->_productInstance = $product; + return $this; + } + + /** + * Retrieve options field name prefix + * + * @return string + */ + public function getFieldName() + { + return 'product[options]'; + } + + /** + * Retrieve options field id prefix + * + * @return string + */ + public function getFieldId() + { + return 'product_option'; + } + + /** + * Check block is readonly + * + * @return boolean + */ + public function isReadonly() + { + return $this->getProduct()->getOptionsReadonly(); + } + + protected function _prepareLayout() + { + $path = 'global/catalog/product/options/custom/groups'; + + foreach (Mage::getConfig()->getNode($path)->children() as $group) { + $this->addChild( + $group->getName() . '_option_type', + (string)Mage::getConfig()->getNode($path . '/' . $group->getName() . '/render') + ); + } + + return parent::_prepareLayout(); + } + + public function getAddButtonId() + { + $buttonId = $this->getLayout() + ->getBlock('admin.product.options') + ->getChildBlock('add_button')->getId(); + return $buttonId; + } + + public function getTypeSelectHtml() + { + $select = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Html_Select') + ->setData(array( + 'id' => $this->getFieldId() . '_${id}_type', + 'class' => 'select select-product-option-type required-option-select', + )) + ->setName($this->getFieldName() . '[${id}][type]') + ->setOptions(Mage::getSingleton('Mage_Catalog_Model_Config_Source_Product_Options_Type')->toOptionArray()); + + return $select->getHtml(); + } + + public function getRequireSelectHtml() + { + $select = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Html_Select') + ->setData(array( + 'id' => $this->getFieldId() . '_${id}_is_require', + 'class' => 'select' + )) + ->setName($this->getFieldName() . '[${id}][is_require]') + ->setOptions(Mage::getSingleton('Mage_Backend_Model_Config_Source_Yesno')->toOptionArray()); + + return $select->getHtml(); + } + + /** + * Retrieve html templates for different types of product custom options + * + * @return string + */ + public function getTemplatesHtml() + { + $canEditPrice = $this->getCanEditPrice(); + $canReadPrice = $this->getCanReadPrice(); + $this->getChildBlock('select_option_type') + ->setCanReadPrice($canReadPrice) + ->setCanEditPrice($canEditPrice); + + $this->getChildBlock('file_option_type') + ->setCanReadPrice($canReadPrice) + ->setCanEditPrice($canEditPrice); + + $this->getChildBlock('date_option_type') + ->setCanReadPrice($canReadPrice) + ->setCanEditPrice($canEditPrice); + + $this->getChildBlock('text_option_type') + ->setCanReadPrice($canReadPrice) + ->setCanEditPrice($canEditPrice); + + $templates = $this->getChildHtml('text_option_type') . "\n" . + $this->getChildHtml('file_option_type') . "\n" . + $this->getChildHtml('select_option_type') . "\n" . + $this->getChildHtml('date_option_type'); + + return $templates; + } + + public function getOptionValues() + { + $optionsArr = $this->getProduct()->getOptions(); + + if (!$this->_values || $this->getIgnoreCaching()) { + $showPrice = $this->getCanReadPrice(); + $values = array(); + $scope = (int)Mage::app()->getStore()->getConfig(Mage_Core_Model_Store::XML_PATH_PRICE_SCOPE); + foreach ($optionsArr as $option) { + /* @var $option Mage_Catalog_Model_Product_Option */ + + $this->setItemCount($option->getOptionId()); + + $value = array(); + + $value['id'] = $option->getOptionId(); + $value['item_count'] = $this->getItemCount(); + $value['option_id'] = $option->getOptionId(); + $value['title'] = $this->escapeHtml($option->getTitle()); + $value['type'] = $option->getType(); + $value['is_require'] = $option->getIsRequire(); + $value['sort_order'] = $option->getSortOrder(); + $value['can_edit_price'] = $this->getCanEditPrice(); + + if ($this->getProduct()->getStoreId() != '0') { + $value['checkboxScopeTitle'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'title', + is_null($option->getStoreTitle())); + $value['scopeTitleDisabled'] = is_null($option->getStoreTitle()) ? 'disabled' : null; + } + + if ($option->getGroupByType() == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT) { + $i = 0; + $itemCount = 0; + foreach ($option->getValues() as $_value) { + /* @var $_value Mage_Catalog_Model_Product_Option_Value */ + $value['optionValues'][$i] = array( + 'item_count' => max($itemCount, $_value->getOptionTypeId()), + 'option_id' => $_value->getOptionId(), + 'option_type_id' => $_value->getOptionTypeId(), + 'title' => $this->escapeHtml($_value->getTitle()), + 'price' => ($showPrice) + ? $this->getPriceValue($_value->getPrice(), $_value->getPriceType()) : '', + 'price_type' => ($showPrice) ? $_value->getPriceType() : 0, + 'sku' => $this->escapeHtml($_value->getSku()), + 'sort_order' => $_value->getSortOrder(), + ); + + if ($this->getProduct()->getStoreId() != '0') { + $value['optionValues'][$i]['checkboxScopeTitle'] = $this->getCheckboxScopeHtml( + $_value->getOptionId(), 'title', is_null($_value->getStoreTitle()), + $_value->getOptionTypeId()); + $value['optionValues'][$i]['scopeTitleDisabled'] = is_null($_value->getStoreTitle()) + ? 'disabled' : null; + if ($scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE) { + $value['optionValues'][$i]['checkboxScopePrice'] = $this->getCheckboxScopeHtml( + $_value->getOptionId(), 'price', is_null($_value->getstorePrice()), + $_value->getOptionTypeId()); + $value['optionValues'][$i]['scopePriceDisabled'] = is_null($_value->getStorePrice()) + ? 'disabled' : null; + } + } + $i++; + } + } else { + $value['price'] = ($showPrice) + ? $this->getPriceValue($option->getPrice(), $option->getPriceType()) : ''; + $value['price_type'] = $option->getPriceType(); + $value['sku'] = $this->escapeHtml($option->getSku()); + $value['max_characters'] = $option->getMaxCharacters(); + $value['file_extension'] = $option->getFileExtension(); + $value['image_size_x'] = $option->getImageSizeX(); + $value['image_size_y'] = $option->getImageSizeY(); + if ($this->getProduct()->getStoreId() != '0' + && $scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE + ) { + $value['checkboxScopePrice'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'price', + is_null($option->getStorePrice())); + $value['scopePriceDisabled'] = is_null($option->getStorePrice()) ? 'disabled' : null; + } + } + $values[] = new Varien_Object($value); + } + $this->_values = $values; + } + + return $this->_values; + } + + /** + * Retrieve html of scope checkbox + * + * @param string $id + * @param string $name + * @param boolean $checked + * @param string $select_id + * @return string + */ + public function getCheckboxScopeHtml($id, $name, $checked = true, $select_id = '-1') + { + $checkedHtml = ''; + if ($checked) { + $checkedHtml = ' checked="checked"'; + } + $selectNameHtml = ''; + $selectIdHtml = ''; + if ($select_id != '-1') { + $selectNameHtml = '[values][' . $select_id . ']'; + $selectIdHtml = 'select_' . $select_id . '_'; + } + $useDefault = '
' + . '
'; + + return $useDefault; + } + + public function getPriceValue($value, $type) + { + if ($type == 'percent') { + return number_format($value, 2, null, ''); + } elseif ($type == 'fixed') { + return number_format($value, 2, null, ''); + } + } + + /** + * Return product grid url for custom options import popup + * + * @return string + */ + public function getProductGridUrl() + { + return $this->getUrl('*/*/optionsImportGrid'); + } + + /** + * Return custom options getter URL for ajax queries + * + * @return string + */ + public function getCustomOptionsUrl() + { + return $this->getUrl('*/*/customOptions'); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Popup/Grid.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Popup/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Popup/Grid.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Popup/Grid.php diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Abstract.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Abstract.php new file mode 100644 index 0000000000000..1bbe4db94d669 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Abstract.php @@ -0,0 +1,69 @@ + + */ + +class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Abstract extends Mage_Adminhtml_Block_Widget +{ + protected $_name = 'abstract'; + + protected function _prepareLayout() + { + $this->setChild('option_price_type', + $this->getLayout()->addBlock('Mage_Adminhtml_Block_Html_Select', '', $this->getNameInLayout()) + ->setData(array( + 'id' => 'product_option_${option_id}_price_type', + 'class' => 'select product-option-price-type' + )) + ); + + $this->getChildBlock('option_price_type') + ->setName('product[options][${option_id}][price_type]') + ->setOptions(Mage::getSingleton('Mage_Catalog_Model_Config_Source_Product_Options_Price')->toOptionArray()); + + return parent::_prepareLayout(); + } + + /** + * Get html of Price Type select element + * + * @return string + */ + public function getPriceTypeSelectHtml() + { + if ($this->getCanEditPrice() === false) { + $this->getChildBlock('option_price_type')->setExtraParams('disabled="disabled"'); + } + return $this->getChildHtml('option_price_type'); + } + +} diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Date.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Date.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Date.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Date.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/File.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/File.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/File.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/File.php diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Select.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Select.php new file mode 100644 index 0000000000000..6ebde3a9d46bc --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Select.php @@ -0,0 +1,87 @@ + + */ + +class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Select extends + Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Abstract +{ + + protected $_template = 'catalog/product/edit/options/type/select.phtml'; + + /** + * Class constructor + */ + protected function _construct() + { + parent::_construct(); + + $this->setCanEditPrice(true); + $this->setCanReadPrice(true); + } + + protected function _prepareLayout() + { + $this->addChild('add_select_row_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Add New Row'), + 'class' => 'add add-select-row', + 'id' => 'product_option_${option_id}_add_select_row' + )); + + $this->addChild('delete_select_row_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Delete Row'), + 'class' => 'delete delete-select-row icon-btn', + 'id' => 'product_option_${id}_select_${select_id}_delete' + )); + + return parent::_prepareLayout(); + } + + public function getAddButtonHtml() + { + return $this->getChildHtml('add_select_row_button'); + } + + public function getDeleteButtonHtml() + { + return $this->getChildHtml('delete_select_row_button'); + } + + public function getPriceTypeSelectHtml() + { + $this->getChildBlock('option_price_type') + ->setData('id', 'product_option_${id}_select_${select_id}_price_type') + ->setName('product[options][${id}][values][${select_id}][price_type]'); + + return parent::getPriceTypeSelectHtml(); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Text.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Text.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Text.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Text.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Recurring.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Recurring.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Recurring.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Recurring.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Tier.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Tier.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Tier.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Tier.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Related.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Related.php similarity index 87% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Related.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Related.php index 6b2e35556cb14..655d55dc5000a 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Related.php +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Related.php @@ -131,33 +131,38 @@ protected function _prepareColumns() { if (!$this->isReadonly()) { $this->addColumn('in_products', array( - 'header_css_class' => 'a-center', 'type' => 'checkbox', 'name' => 'in_products', 'values' => $this->_getSelectedProducts(), 'align' => 'center', - 'index' => 'entity_id' + 'index' => 'entity_id', + 'header_css_class' => 'col-select', + 'column_css_class' => 'col-select' )); } $this->addColumn('entity_id', array( 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('ID'), 'sortable' => true, - 'width' => 60, - 'index' => 'entity_id' + 'index' => 'entity_id', + 'header_css_class' => 'col-id', + 'column_css_class' => 'col-id' )); $this->addColumn('name', array( 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Name'), - 'index' => 'name' + 'index' => 'name', + 'header_css_class' => 'col-name', + 'column_css_class' => 'col-name' )); $this->addColumn('type', array( 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Type'), - 'width' => 100, 'index' => 'type_id', 'type' => 'options', 'options' => Mage::getSingleton('Mage_Catalog_Model_Product_Type')->getOptionArray(), + 'header_css_class' => 'col-type', + 'column_css_class' => 'col-type' )); $sets = Mage::getResourceModel('Mage_Eav_Model_Resource_Entity_Attribute_Set_Collection') @@ -167,39 +172,45 @@ protected function _prepareColumns() $this->addColumn('set_name', array( 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Attrib. Set Name'), - 'width' => 130, 'index' => 'attribute_set_id', 'type' => 'options', 'options' => $sets, + 'header_css_class' => 'col-attr-name', + 'column_css_class' => 'col-attr-name' )); $this->addColumn('status', array( 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Status'), - 'width' => 90, 'index' => 'status', 'type' => 'options', 'options' => Mage::getSingleton('Mage_Catalog_Model_Product_Status')->getOptionArray(), + 'header_css_class' => 'col-status', + 'column_css_class' => 'col-status' )); $this->addColumn('visibility', array( 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Visibility'), - 'width' => 90, 'index' => 'visibility', 'type' => 'options', 'options' => Mage::getSingleton('Mage_Catalog_Model_Product_Visibility')->getOptionArray(), + 'header_css_class' => 'col-visibility', + 'column_css_class' => 'col-visibility' )); $this->addColumn('sku', array( 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('SKU'), - 'width' => 80, - 'index' => 'sku' + 'index' => 'sku', + 'header_css_class' => 'col-sku', + 'column_css_class' => 'col-sku' )); $this->addColumn('price', array( 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Price'), 'type' => 'currency', 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE), - 'index' => 'price' + 'index' => 'price', + 'header_css_class' => 'col-price', + 'column_css_class' => 'col-price' )); $this->addColumn('position', array( @@ -208,9 +219,10 @@ protected function _prepareColumns() 'type' => 'number', 'validate_class' => 'validate-number', 'index' => 'position', - 'width' => 60, 'editable' => !$this->_getProduct()->getRelatedReadonly(), - 'edit_only' => !$this->_getProduct()->getId() + 'edit_only' => !$this->_getProduct()->getId(), + 'header_css_class' => 'col-position', + 'column_css_class' => 'col-position' )); return parent::_prepareColumns(); diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Reviews.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Reviews.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Reviews.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Reviews.php diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config.php new file mode 100644 index 0000000000000..1940b4f5a47c7 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config.php @@ -0,0 +1,383 @@ + + */ +class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config extends Mage_Adminhtml_Block_Widget + implements Mage_Adminhtml_Block_Widget_Tab_Interface +{ + + protected $_template = 'catalog/product/edit/super/config.phtml'; + + /** + * Initialize block + * + */ + protected function _construct() + { + parent::_construct(); + $this->setProductId($this->getRequest()->getParam('id')); + + $this->setId('config_super_product'); + $this->setCanEditPrice(true); + $this->setCanReadPrice(true); + } + + /** + * Retrieve Tab class (for loading) + * + * @return string + */ + public function getTabClass() + { + return 'ajax'; + } + + /** + * Check block is readonly + * + * @return boolean + */ + public function isReadonly() + { + return (bool) $this->getProduct()->getCompositeReadonly(); + } + + /** + * Check whether attributes of configurable products can be editable + * + * @return boolean + */ + public function isAttributesConfigurationReadonly() + { + return (bool) $this->getProduct()->getAttributesConfigurationReadonly(); + } + + /** + * Get configurable product type + * + * @return Mage_Catalog_Model_Product_Type_Configurable + */ + protected function _getProductType() + { + return Mage::getModel('Mage_Catalog_Model_Product_Type_Configurable'); + } + + /** + * Check whether prices of configurable products can be editable + * + * @return boolean + */ + public function isAttributesPricesReadonly() + { + return $this->getProduct()->getAttributesConfigurationReadonly() || + (Mage::helper('Mage_Catalog_Helper_Data')->isPriceGlobal() && $this->isReadonly()); + } + + /** + * Prepare Layout data + * + * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config + */ + protected function _prepareLayout() + { + $this->addChild('create_empty', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Create Empty'), + 'class' => 'add', + 'onclick' => 'superProduct.createEmptyProduct()' + )); + $this->addChild('super_settings', 'Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Settings'); + + if ($this->getProduct()->getId()) { + $this->setChild('simple', + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Simple', + 'catalog.product.edit.tab.super.config.simple') + ); + + $this->addChild('create_from_configurable', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Copy From Configurable'), + 'class' => 'add', + 'onclick' => 'superProduct.createNewProduct()' + )); + } + + $this->addChild( + 'generate', + 'Mage_Backend_Block_Widget_Button', + array( + 'id' => 'generate-variations-button', + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Generate Variations'), + 'data_attribute' => array( + 'mage-init' => array( + 'button' => array( + 'event' => 'generate', + 'target' => '#product-variations-matrix', + 'eventData' => array( + 'url' => $this->getUrl('*/*/variationsMatrix', array('_current' => true)), + ), + ), + ), + ), + ) + ); + + return parent::_prepareLayout(); + } + + /** + * Retrieve currently edited product object + * + * @return Mage_Catalog_Model_Product + */ + public function getProduct() + { + return Mage::registry('current_product'); + } + + /** + * Retrieve attributes data + * + * @return array + */ + public function getAttributes() + { + if (!$this->hasData('attributes')) { + $attributes = (array)$this->_getProductType()->getConfigurableAttributesAsArray($this->getProduct()); + $productData = (array)$this->getRequest()->getParam('product'); + if (isset($productData['configurable_attributes_data'])) { + $configurableData = $productData['configurable_attributes_data']; + foreach ($attributes as $key => &$attribute) { + if (isset($configurableData[$key])) { + $attribute['values'] = array_merge( + isset($attribute['values']) ? $attribute['values'] : array(), + isset($configurableData[$key]['values']) + ? array_filter($configurableData[$key]['values']) + : array() + ); + } + } + } + + foreach ($attributes as &$attribute) { + if (isset($attribute['values']) && is_array($attribute['values'])) { + foreach ($attribute['values'] as &$attributeValue) { + if (!$this->getCanReadPrice()) { + $attributeValue['pricing_value'] = ''; + $attributeValue['is_percent'] = 0; + } + $attributeValue['can_edit_price'] = $this->getCanEditPrice(); + $attributeValue['can_read_price'] = $this->getCanReadPrice(); + } + } + } + $this->setData('attributes', $attributes); + } + return $this->getData('attributes'); + } + + /** + * Retrieve Links in JSON format + * + * @return string + */ + public function getLinksJson() + { + $products = $this->_getProductType() + ->getUsedProducts($this->getProduct()); + if(!$products) { + return '{}'; + } + $data = array(); + foreach ($products as $product) { + $data[$product->getId()] = $this->getConfigurableSettings($product); + } + return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($data); + } + + /** + * Retrieve configurable settings + * + * @param Mage_Catalog_Model_Product $product + * @return array + */ + public function getConfigurableSettings($product) { + $data = array(); + $attributes = $this->_getProductType() + ->getUsedProductAttributes($this->getProduct()); + foreach ($attributes as $attribute) { + $data[] = array( + 'attribute_id' => $attribute->getId(), + 'label' => $product->getAttributeText($attribute->getAttributeCode()), + 'value_index' => $product->getData($attribute->getAttributeCode()) + ); + } + + return $data; + } + + /** + * Retrieve Grid child HTML + * + * @return string + */ + public function getGridHtml() + { + return $this->getChildHtml('grid'); + } + + /** + * Retrieve Grid JavaScript object name + * + * @return string + */ + public function getGridJsObject() + { + return $this->getChildBlock('grid')->getJsObjectName(); + } + + /** + * Retrieve Create New Empty Product URL + * + * @return string + */ + public function getNewEmptyProductUrl() + { + return $this->getUrl( + '*/*/new', + array( + 'set' => $this->getProduct()->getAttributeSetId(), + 'type' => Mage_Catalog_Model_Product_Type::TYPE_SIMPLE, + 'required' => $this->_getRequiredAttributesIds(), + 'popup' => 1 + ) + ); + } + + /** + * Retrieve Create New Product URL + * + * @return string + */ + public function getNewProductUrl() + { + return $this->getUrl( + '*/*/new', + array( + 'set' => $this->getProduct()->getAttributeSetId(), + 'type' => Mage_Catalog_Model_Product_Type::TYPE_SIMPLE, + 'required' => $this->_getRequiredAttributesIds(), + 'popup' => 1, + 'product' => $this->getProduct()->getId() + ) + ); + } + + /** + * Retrieve Required attributes Ids (comma separated) + * + * @return string + */ + protected function _getRequiredAttributesIds() + { + $attributesIds = array(); + $configurableAttributes = $this->getProduct() + ->getTypeInstance()->getConfigurableAttributes($this->getProduct()); + foreach ($configurableAttributes as $attribute) { + $attributesIds[] = $attribute->getProductAttribute()->getId(); + } + + return implode(',', $attributesIds); + } + + /** + * Retrieve Tab label + * + * @return string + */ + public function getTabLabel() + { + return Mage::helper('Mage_Catalog_Helper_Data')->__('Associated Products'); + } + + /** + * Retrieve Tab title + * + * @return string + */ + public function getTabTitle() + { + return Mage::helper('Mage_Catalog_Helper_Data')->__('Associated Products'); + } + + /** + * Can show tab flag + * + * @return bool + */ + public function canShowTab() + { + return true; + } + + /** + * Check is a hidden tab + * + * @return bool + */ + public function isHidden() + { + return false; + } + + /** + * Show "Use default price" checkbox + * + * @return bool + */ + public function getShowUseDefaultPrice() + { + return !Mage::helper('Mage_Catalog_Helper_Data')->isPriceGlobal() + && $this->getProduct()->getStoreId(); + } + + /** + * Get list of used attributes + * + * @return array + */ + public function getSelectedAttributes() + { + return $this->getProduct()->isConfigurable() + ? array_filter($this->_getProductType()->getUsedProductAttributes($this->getProduct())) + : array(); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Attribute.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Attribute.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Attribute.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Attribute.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid/Filter/Inventory.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid/Filter/Inventory.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid/Filter/Inventory.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid/Filter/Inventory.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid/Renderer/Checkbox.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid/Renderer/Checkbox.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid/Renderer/Checkbox.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid/Renderer/Checkbox.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid/Renderer/Inventory.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid/Renderer/Inventory.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid/Renderer/Inventory.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid/Renderer/Inventory.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Matrix.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Matrix.php similarity index 94% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Matrix.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Matrix.php index ec2c229d3ebfc..bc7feea65f4be 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Matrix.php +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Matrix.php @@ -49,7 +49,7 @@ protected function _getProductType() * * @return Mage_Catalog_Model_Product */ - protected function _getProduct() + public function getProduct() { return Mage::registry('current_product'); } @@ -136,7 +136,7 @@ public function getEditProductUrl($id) public function getAttributes() { if (!$this->hasData('attributes')) { - $attributes = (array)$this->_getProductType()->getConfigurableAttributesAsArray($this->_getProduct()); + $attributes = (array)$this->_getProductType()->getConfigurableAttributesAsArray($this->getProduct()); $productData = (array)$this->getRequest()->getParam('product'); if (isset($productData['configurable_attributes_data'])) { $configurableData = $productData['configurable_attributes_data']; @@ -164,7 +164,7 @@ public function getAttributes() */ public function getUsedAttributes() { - return $this->_getProductType()->getUsedProductAttributes($this->_getProduct()); + return $this->_getProductType()->getUsedProductAttributes($this->getProduct()); } /** @@ -194,8 +194,8 @@ public function getAssociatedProducts() */ protected function _getAssociatedProducts() { - $product = $this->_getProduct(); - $ids = $this->_getProduct()->getAssociatedProductIds(); + $product = $this->getProduct(); + $ids = $this->getProduct()->getAssociatedProductIds(); if ($ids === null) { // form data overrides any relations stored in database return $this->_getProductType()->getUsedProducts($product); } @@ -226,4 +226,14 @@ public function getAttributeFrontendClass($code) ? $attribute->getFrontend()->getClass() : ''; } + + /** + * Get url to upload files + * + * @return string + */ + protected function getImageUploadUrl() + { + return $this->getUrl('*/catalog_product_gallery/upload'); + } } diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Simple.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Simple.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Simple.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Simple.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Settings.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Settings.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Settings.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Settings.php diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Upsell.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Upsell.php new file mode 100644 index 0000000000000..b8e6d55bbbd95 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Upsell.php @@ -0,0 +1,269 @@ + + */ +class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Upsell extends Mage_Adminhtml_Block_Widget_Grid +{ + + /** + * Set grid params + * + */ + protected function _construct() + { + parent::_construct(); + $this->setId('up_sell_product_grid'); + $this->setDefaultSort('entity_id'); + $this->setUseAjax(true); + if ($this->_getProduct() && $this->_getProduct()->getId()) { + $this->setDefaultFilter(array('in_products'=>1)); + } + if ($this->isReadonly()) { + $this->setFilterVisibility(false); + } + } + + /** + * Retirve currently edited product model + * + * @return Mage_Catalog_Model_Product + */ + protected function _getProduct() + { + return Mage::registry('current_product'); + } + + /** + * Add filter + * + * @param object $column + * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Upsell + */ + protected function _addColumnFilterToCollection($column) + { + // Set custom filter for in product flag + if ($column->getId() == 'in_products') { + $productIds = $this->_getSelectedProducts(); + if (empty($productIds)) { + $productIds = 0; + } + if ($column->getFilter()->getValue()) { + $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds)); + } else { + if($productIds) { + $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds)); + } + } + } else { + parent::_addColumnFilterToCollection($column); + } + return $this; + } + + /** + * Checks when this block is readonly + * + * @return boolean + */ + public function isReadonly() + { + return $this->_getProduct() && $this->_getProduct()->getUpsellReadonly(); + } + + /** + * Prepare collection + * + * @return Mage_Adminhtml_Block_Widget_Grid + */ + protected function _prepareCollection() + { + $collection = Mage::getModel('Mage_Catalog_Model_Product_Link')->useUpSellLinks() + ->getProductCollection() + ->setProduct($this->_getProduct()) + ->addAttributeToSelect('*'); + + if ($this->isReadonly()) { + $productIds = $this->_getSelectedProducts(); + if (empty($productIds)) { + $productIds = array(0); + } + $collection->addFieldToFilter('entity_id', array('in'=>$productIds)); + } + + $this->setCollection($collection); + return parent::_prepareCollection(); + } + + /** + * Add columns to grid + * + * @return Mage_Adminhtml_Block_Widget_Grid + */ + protected function _prepareColumns() + { + if (!$this->_getProduct()->getUpsellReadonly()) { + $this->addColumn('in_products', array( + 'type' => 'checkbox', + 'name' => 'in_products', + 'values' => $this->_getSelectedProducts(), + 'align' => 'center', + 'index' => 'entity_id', + 'header_css_class' => 'col-select', + 'column_css_class' => 'col-select' + )); + } + + $this->addColumn('entity_id', array( + 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('ID'), + 'sortable' => true, + 'index' => 'entity_id', + 'header_css_class' => 'col-id', + 'column_css_class' => 'col-id' + )); + $this->addColumn('name', array( + 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Name'), + 'index' => 'name', + 'header_css_class' => 'col-name', + 'column_css_class' => 'col-name' + )); + + $this->addColumn('type', array( + 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Type'), + 'index' => 'type_id', + 'type' => 'options', + 'options' => Mage::getSingleton('Mage_Catalog_Model_Product_Type')->getOptionArray(), + 'header_css_class' => 'col-type', + 'column_css_class' => 'col-type' + )); + + $sets = Mage::getResourceModel('Mage_Eav_Model_Resource_Entity_Attribute_Set_Collection') + ->setEntityTypeFilter(Mage::getModel('Mage_Catalog_Model_Product')->getResource()->getTypeId()) + ->load() + ->toOptionHash(); + + $this->addColumn('set_name', array( + 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Attrib. Set Name'), + 'index' => 'attribute_set_id', + 'type' => 'options', + 'options' => $sets, + 'header_css_class' => 'col-attr-name', + 'column_css_class' => 'col-attr-name' + )); + + $this->addColumn('status', array( + 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Status'), + 'index' => 'status', + 'type' => 'options', + 'options' => Mage::getSingleton('Mage_Catalog_Model_Product_Status')->getOptionArray(), + 'header_css_class' => 'col-status', + 'column_css_class' => 'col-status' + )); + + $this->addColumn('visibility', array( + 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Visibility'), + 'index' => 'visibility', + 'type' => 'options', + 'options' => Mage::getSingleton('Mage_Catalog_Model_Product_Visibility')->getOptionArray(), + 'header_css_class' => 'col-visibility', + 'column_css_class' => 'col-visibility' + )); + + $this->addColumn('sku', array( + 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('SKU'), + 'index' => 'sku', + 'header_css_class' => 'col-sku', + 'column_css_class' => 'col-sku' + )); + + $this->addColumn('price', array( + 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Price'), + 'type' => 'currency', + 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE), + 'index' => 'price', + 'header_css_class' => 'col-price', + 'column_css_class' => 'col-price' + )); + + $this->addColumn('position', array( + 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Position'), + 'name' => 'position', + 'type' => 'number', + 'validate_class' => 'validate-number', + 'index' => 'position', + 'editable' => !$this->_getProduct()->getUpsellReadonly(), + 'edit_only' => !$this->_getProduct()->getId(), + 'header_css_class' => 'col-position', + 'column_css_class' => 'col-position' + )); + + return parent::_prepareColumns(); + } + + /** + * Rerieve grid URL + * + * @return string + */ + public function getGridUrl() + { + return $this->_getData('grid_url') ? $this->_getData('grid_url') : $this->getUrl('*/*/upsellGrid', array('_current'=>true)); + } + + /** + * Retrieve selected upsell products + * + * @return array + */ + protected function _getSelectedProducts() + { + $products = $this->getProductsUpsell(); + if (!is_array($products)) { + $products = array_keys($this->getSelectedUpsellProducts()); + } + return $products; + } + + /** + * Retrieve upsell products + * + * @return array + */ + public function getSelectedUpsellProducts() + { + $products = array(); + foreach (Mage::registry('current_product')->getUpSellProducts() as $product) { + $products[$product->getId()] = array('position' => $product->getPosition()); + } + return $products; + } + +} diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Websites.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Websites.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Websites.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Websites.php diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs.php new file mode 100644 index 0000000000000..73279db842f76 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs.php @@ -0,0 +1,260 @@ + + */ +class Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs +{ + const BASIC_TAB_GROUP_CODE = 'basic'; + const ADVANCED_TAB_GROUP_CODE = 'advanced'; + + /** @var string */ + protected $_attributeTabBlock = 'Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes'; + + /** @var string */ + protected $_template = 'Mage_Catalog::product/edit/tabs.phtml'; + + protected function _construct() + { + parent::_construct(); + $this->setId('product_info_tabs'); + $this->setDestElementId('product-edit-form-tabs'); + } + + protected function _prepareLayout() + { + $product = $this->getProduct(); + + if (!($setId = $product->getAttributeSetId())) { + $setId = $this->getRequest()->getParam('set', null); + } + + if ($setId) { + $groupCollection = Mage::getResourceModel('Mage_Eav_Model_Resource_Entity_Attribute_Group_Collection') + ->setAttributeSetFilter($setId) + ->setSortOrder() + ->load(); + + $tabAttributesBlock = $this->getLayout()->createBlock( + $this->getAttributeTabBlock(), $this->getNameInLayout() . '_attributes_tab' + ); + $advancedGroups = array(); + foreach ($groupCollection as $group) { + /** @var $group Mage_Eav_Model_Entity_Attribute_Group*/ + $attributes = $product->getAttributes($group->getId(), true); + + foreach ($attributes as $key => $attribute) { + if (!$attribute->getIsVisible()) { + unset($attributes[$key]); + } + } + + if ($attributes) { + $tabData = array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__($group->getAttributeGroupName()), + 'content' => $this->_translateHtml( + $tabAttributesBlock->setGroup($group) + ->setGroupAttributes($attributes) + ->toHtml() + ), + 'class' => 'user-defined', + 'group_code' => $group->getTabGroupCode() ?: self::BASIC_TAB_GROUP_CODE + ); + + if ($group->getAttributeGroupCode() === 'recurring-profile') { + $tabData['parent_tab'] = 'advanced-pricing'; + } + + if ($tabData['group_code'] === self::BASIC_TAB_GROUP_CODE) { + $this->addTab($group->getAttributeGroupCode(), $tabData); + } else { + $advancedGroups[$group->getAttributeGroupCode()] = $tabData; + } + } + } + + /* Don't display website tab for single mode */ + if (!Mage::app()->isSingleStoreMode()) { + $this->addTab('websites', array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Websites'), + 'content' => $this->_translateHtml($this->getLayout() + ->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Websites')->toHtml()), + 'group_code' => self::BASIC_TAB_GROUP_CODE, + )); + } + + if (isset($advancedGroups['advanced-pricing'])) { + $this->addTab('advanced-pricing', $advancedGroups['advanced-pricing']); + unset($advancedGroups['advanced-pricing']); + } + + if (Mage::helper('Mage_Core_Helper_Data')->isModuleEnabled('Mage_CatalogInventory')) { + $this->addTab('advanced-inventory', array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Advanced Inventory'), + 'content' => $this->_translateHtml($this->getLayout() + ->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Inventory')->toHtml()), + 'group_code' => self::ADVANCED_TAB_GROUP_CODE, + )); + } + + /** + * Do not change this tab id + * @see Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs_Configurable + * @see Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tabs + */ + if (!$product->isGrouped()) { + $this->addTab('customer_options', array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Custom Options'), + 'url' => $this->getUrl('*/*/options', array('_current' => true)), + 'class' => 'ajax', + 'group_code' => self::ADVANCED_TAB_GROUP_CODE, + )); + } + + $this->addTab('related', array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Related Products'), + 'url' => $this->getUrl('*/*/related', array('_current' => true)), + 'class' => 'ajax', + 'group_code' => self::ADVANCED_TAB_GROUP_CODE, + )); + + $this->addTab('upsell', array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Up-sells'), + 'url' => $this->getUrl('*/*/upsell', array('_current' => true)), + 'class' => 'ajax', + 'group_code' => self::ADVANCED_TAB_GROUP_CODE, + )); + + $this->addTab('crosssell', array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Cross-sells'), + 'url' => $this->getUrl('*/*/crosssell', array('_current' => true)), + 'class' => 'ajax', + 'group_code' => self::ADVANCED_TAB_GROUP_CODE, + )); + + if (isset($advancedGroups['design'])) { + $this->addTab('design', $advancedGroups['design']); + unset($advancedGroups['design']); + } + + $alertPriceAllow = Mage::getStoreConfig('catalog/productalert/allow_price'); + $alertStockAllow = Mage::getStoreConfig('catalog/productalert/allow_stock'); + if (($alertPriceAllow || $alertStockAllow) && !$product->isGrouped()) { + $this->addTab('product-alerts', array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Product Alerts'), + 'content' => $this->_translateHtml($this->getLayout() + ->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Alerts', 'admin.alerts.products') + ->toHtml() + ), + 'group_code' => self::ADVANCED_TAB_GROUP_CODE, + )); + } + + if ($this->getRequest()->getParam('id')) { + if (Mage::helper('Mage_Catalog_Helper_Data')->isModuleEnabled('Mage_Review')) { + if (Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Review::reviews_all')){ + $this->addTab('product-reviews', array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Product Reviews'), + 'url' => $this->getUrl('*/*/reviews', array('_current' => true)), + 'class' => 'ajax', + 'group_code' => self::ADVANCED_TAB_GROUP_CODE, + )); + } + } + } + + if (isset($advancedGroups['autosettings'])) { + $this->addTab('autosettings', $advancedGroups['autosettings']); + unset($advancedGroups['autosettings']); + } + + foreach ($advancedGroups as $groupCode => $group) { + $this->addTab($groupCode, $group); + } + } + + return parent::_prepareLayout(); + } + + /** + * Check whether active tab belong to advanced group + * + * @return bool + */ + public function isAdvancedTabGroupActive() + { + return $this->_tabs[$this->_activeTab]->getGroupCode() == self::ADVANCED_TAB_GROUP_CODE; + } + + /** + * Retrieve product object from object if not from registry + * + * @return Mage_Catalog_Model_Product + */ + public function getProduct() + { + if (!($this->getData('product') instanceof Mage_Catalog_Model_Product)) { + $this->setData('product', Mage::registry('product')); + } + return $this->getData('product'); + } + + /** + * Getting attribute block name for tabs + * + * @return string + */ + public function getAttributeTabBlock() + { + if (is_null(Mage::helper('Mage_Adminhtml_Helper_Catalog')->getAttributeTabBlock())) { + return $this->_attributeTabBlock; + } + return Mage::helper('Mage_Adminhtml_Helper_Catalog')->getAttributeTabBlock(); + } + + public function setAttributeTabBlock($attributeTabBlock) + { + $this->_attributeTabBlock = $attributeTabBlock; + return $this; + } + + /** + * Translate html content + * + * @param string $html + * @return string + */ + protected function _translateHtml($html) + { + Mage::getSingleton('Mage_Core_Model_Translate_Inline')->processResponseBody($html); + return $html; + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs/Configurable.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs/Configurable.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs/Configurable.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs/Configurable.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs/Grouped.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs/Grouped.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs/Grouped.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs/Grouped.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Frontend/Product/Watermark.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Frontend/Product/Watermark.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Frontend/Product/Watermark.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Frontend/Product/Watermark.php diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Grid.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Grid.php new file mode 100644 index 0000000000000..a353a70322bde --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Grid.php @@ -0,0 +1,353 @@ + + */ +class Mage_Adminhtml_Block_Catalog_Product_Grid extends Mage_Adminhtml_Block_Widget_Grid +{ + + protected function _construct() + { + parent::_construct(); + $this->setId('productGrid'); + $this->setDefaultSort('entity_id'); + $this->setDefaultDir('DESC'); + $this->setSaveParametersInSession(true); + $this->setUseAjax(true); + $this->setVarNameFilter('product_filter'); + + } + + protected function _getStore() + { + $storeId = (int) $this->getRequest()->getParam('store', 0); + return Mage::app()->getStore($storeId); + } + + protected function _prepareCollection() + { + $store = $this->_getStore(); + $collection = Mage::getModel('Mage_Catalog_Model_Product')->getCollection() + ->addAttributeToSelect('sku') + ->addAttributeToSelect('name') + ->addAttributeToSelect('attribute_set_id') + ->addAttributeToSelect('type_id'); + + if (Mage::helper('Mage_Catalog_Helper_Data')->isModuleEnabled('Mage_CatalogInventory')) { + $collection->joinField('qty', + 'cataloginventory_stock_item', + 'qty', + 'product_id=entity_id', + '{{table}}.stock_id=1', + 'left'); + } + if ($store->getId()) { + //$collection->setStoreId($store->getId()); + $adminStore = Mage_Core_Model_AppInterface::ADMIN_STORE_ID; + $collection->addStoreFilter($store); + $collection->joinAttribute( + 'name', + 'catalog_product/name', + 'entity_id', + null, + 'inner', + $adminStore + ); + $collection->joinAttribute( + 'custom_name', + 'catalog_product/name', + 'entity_id', + null, + 'inner', + $store->getId() + ); + $collection->joinAttribute( + 'status', + 'catalog_product/status', + 'entity_id', + null, + 'inner', + $store->getId() + ); + $collection->joinAttribute( + 'visibility', + 'catalog_product/visibility', + 'entity_id', + null, + 'inner', + $store->getId() + ); + $collection->joinAttribute( + 'price', + 'catalog_product/price', + 'entity_id', + null, + 'left', + $store->getId() + ); + } + else { + $collection->addAttributeToSelect('price'); + $collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner'); + $collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner'); + } + + $this->setCollection($collection); + + parent::_prepareCollection(); + $this->getCollection()->addWebsiteNamesToResult(); + return $this; + } + + protected function _addColumnFilterToCollection($column) + { + if ($this->getCollection()) { + if ($column->getId() == 'websites') { + $this->getCollection()->joinField('websites', + 'catalog_product_website', + 'website_id', + 'product_id=entity_id', + null, + 'left'); + } + } + return parent::_addColumnFilterToCollection($column); + } + + protected function _prepareColumns() + { + $this->addColumn('entity_id', + array( + 'header'=> Mage::helper('Mage_Catalog_Helper_Data')->__('ID'), + 'width' => '50px', + 'type' => 'number', + 'index' => 'entity_id', + 'header_css_class' => 'col-id', + 'column_css_class' => 'col-id' + )); + $this->addColumn('name', + array( + 'header'=> Mage::helper('Mage_Catalog_Helper_Data')->__('Name'), + 'index' => 'name', + 'class' => 'xxx', + 'header_css_class' => 'col-name', + 'column_css_class' => 'col-name' + )); + + $store = $this->_getStore(); + if ($store->getId()) { + $this->addColumn('custom_name', + array( + 'header'=> Mage::helper('Mage_Catalog_Helper_Data')->__('Name in %s', $store->getName()), + 'index' => 'custom_name', + 'header_css_class' => 'col-name', + 'column_css_class' => 'col-name' + )); + } + + $this->addColumn('type', + array( + 'header'=> Mage::helper('Mage_Catalog_Helper_Data')->__('Type'), + 'width' => '60px', + 'index' => 'type_id', + 'type' => 'options', + 'options' => Mage::getSingleton('Mage_Catalog_Model_Product_Type')->getOptionArray(), + 'header_css_class' => 'col-type', + 'column_css_class' => 'col-type' + )); + + $sets = Mage::getResourceModel('Mage_Eav_Model_Resource_Entity_Attribute_Set_Collection') + ->setEntityTypeFilter(Mage::getModel('Mage_Catalog_Model_Product')->getResource()->getTypeId()) + ->load() + ->toOptionHash(); + + $this->addColumn('set_name', + array( + 'header'=> Mage::helper('Mage_Catalog_Helper_Data')->__('Attrib. Set Name'), + 'width' => '100px', + 'index' => 'attribute_set_id', + 'type' => 'options', + 'options' => $sets, + 'header_css_class' => 'col-attr-name', + 'column_css_class' => 'col-attr-name' + )); + + $this->addColumn('sku', + array( + 'header'=> Mage::helper('Mage_Catalog_Helper_Data')->__('SKU'), + 'width' => '80px', + 'index' => 'sku', + 'header_css_class' => 'col-sku', + 'column_css_class' => 'col-sku' + )); + + $store = $this->_getStore(); + $this->addColumn('price', + array( + 'header'=> Mage::helper('Mage_Catalog_Helper_Data')->__('Price'), + 'type' => 'price', + 'currency_code' => $store->getBaseCurrency()->getCode(), + 'index' => 'price', + 'header_css_class' => 'col-price', + 'column_css_class' => 'col-price' + )); + + if (Mage::helper('Mage_Catalog_Helper_Data')->isModuleEnabled('Mage_CatalogInventory')) { + $this->addColumn('qty', + array( + 'header'=> Mage::helper('Mage_Catalog_Helper_Data')->__('Qty'), + 'width' => '100px', + 'type' => 'number', + 'index' => 'qty', + 'header_css_class' => 'col-qty', + 'column_css_class' => 'col-qty' + )); + } + + $this->addColumn('visibility', + array( + 'header'=> Mage::helper('Mage_Catalog_Helper_Data')->__('Visibility'), + 'width' => '70px', + 'index' => 'visibility', + 'type' => 'options', + 'options' => Mage::getModel('Mage_Catalog_Model_Product_Visibility')->getOptionArray(), + 'header_css_class' => 'col-visibility', + 'column_css_class' => 'col-visibility' + )); + + $this->addColumn('status', + array( + 'header'=> Mage::helper('Mage_Catalog_Helper_Data')->__('Status'), + 'width' => '70px', + 'index' => 'status', + 'type' => 'options', + 'options' => Mage::getSingleton('Mage_Catalog_Model_Product_Status')->getOptionArray(), + 'header_css_class' => 'col-status', + 'column_css_class' => 'col-status' + )); + + if (!Mage::app()->isSingleStoreMode()) { + $this->addColumn('websites', + array( + 'header'=> Mage::helper('Mage_Catalog_Helper_Data')->__('Websites'), + 'width' => '100px', + 'sortable' => false, + 'index' => 'websites', + 'type' => 'options', + 'options' => Mage::getModel('Mage_Core_Model_Website')->getCollection()->toOptionHash(), + 'header_css_class' => 'col-websites', + 'column_css_class' => 'col-websites' + )); + } + + $this->addColumn('edit', + array( + 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Edit'), + 'width' => '50px', + 'type' => 'action', + 'getter' => 'getId', + 'actions' => array( + array( + 'caption' => Mage::helper('Mage_Catalog_Helper_Data')->__('Edit'), + 'url' => array( + 'base'=>'*/*/edit', + 'params'=>array('store'=>$this->getRequest()->getParam('store')) + ), + 'field' => 'id' + ) + ), + 'filter' => false, + 'sortable' => false, + 'index' => 'stores', + 'header_css_class' => 'col-action', + 'column_css_class' => 'col-action' + )); + + if (Mage::helper('Mage_Catalog_Helper_Data')->isModuleEnabled('Mage_Rss')) { + $this->addRssList('rss/catalog/notifystock', Mage::helper('Mage_Catalog_Helper_Data')->__('Notify Low Stock RSS')); + } + + return parent::_prepareColumns(); + } + + protected function _prepareMassaction() + { + $this->setMassactionIdField('entity_id'); + $this->getMassactionBlock()->setTemplate('Mage_Catalog::product/grid/massaction_extended.phtml'); + $this->getMassactionBlock()->setFormFieldName('product'); + + $this->getMassactionBlock()->addItem('delete', array( + 'label'=> Mage::helper('Mage_Catalog_Helper_Data')->__('Delete'), + 'url' => $this->getUrl('*/*/massDelete'), + 'confirm' => Mage::helper('Mage_Catalog_Helper_Data')->__('Are you sure?') + )); + + $statuses = Mage::getSingleton('Mage_Catalog_Model_Product_Status')->getOptionArray(); + + array_unshift($statuses, array('label'=>'', 'value'=>'')); + $this->getMassactionBlock()->addItem('status', array( + 'label'=> Mage::helper('Mage_Catalog_Helper_Data')->__('Change status'), + 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)), + 'additional' => array( + 'visibility' => array( + 'name' => 'status', + 'type' => 'select', + 'class' => 'required-entry', + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Status'), + 'values' => $statuses + ) + ) + )); + + if (Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Catalog::update_attributes')){ + $this->getMassactionBlock()->addItem('attributes', array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Update Attributes'), + 'url' => $this->getUrl('*/catalog_product_action_attribute/edit', array('_current'=>true)) + )); + } + + Mage::dispatchEvent('adminhtml_catalog_product_grid_prepare_massaction', array('block' => $this)); + return $this; + } + + public function getGridUrl() + { + return $this->getUrl('*/*/grid', array('_current'=>true)); + } + + public function getRowUrl($row) + { + return $this->getUrl('*/*/edit', array( + 'store'=>$this->getRequest()->getParam('store'), + 'id'=>$row->getId()) + ); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Apply.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Apply.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Apply.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Apply.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/BaseImage.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/BaseImage.php similarity index 81% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/BaseImage.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/BaseImage.php index a9f3d8ee9235a..b963468465f7a 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/BaseImage.php +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/BaseImage.php @@ -103,6 +103,7 @@ public function getElementHtml() { $htmlId = $this->_coreHelper->escapeHtml($this->getHtmlId()); $uploadUrl = $this->_coreHelper->escapeHtml($this->_getUploadUrl()); + $spacerImage = Mage::getDesign()->getViewFileUrl('images/spacer.gif'); /** @var $product Mage_Catalog_Model_Product */ $html = <<
- + +

{$this->__('Click here or drag and drop to add images')}

+ + {$this->helper('Mage_Catalog_Helper_Data')->__('Image Management')} + + + HTML; return $html; } @@ -139,7 +156,7 @@ public function getElementHtml() */ protected function _getUploadUrl() { - return $this->_url->getUrl('*/catalog_product_gallery/upload'); + return $this->_url->getUrl('adminhtml/catalog_product_gallery/upload'); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Boolean.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Boolean.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Boolean.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Boolean.php diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Category.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Category.php new file mode 100644 index 0000000000000..a020e825e41d8 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Category.php @@ -0,0 +1,111 @@ + + */ +class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Category extends Varien_Data_Form_Element_Multiselect +{ + /** + * Get values for select + * @return array + */ + public function getValues() + { + $collection = $this->_getCategoriesCollection(); + $values = $this->getValue(); + if (!is_array($values)) { + $values = explode(',', $values); + } + $collection->addAttributeToSelect('name'); + $collection->addIdFilter($values); + + $options = array(); + + foreach ($collection as $category) { + $options[] = array( + 'label' => $category->getName(), + 'value' => $category->getId() + ); + } + return $options; + } + + /** + * Get categories collection + * @return Mage_Catalog_Model_Resource_Category_Collection + */ + protected function _getCategoriesCollection() + { + return Mage::getResourceModel('Mage_Catalog_Model_Resource_Category_Collection'); + } + + /** + * Attach category suggest widget initialization + * + * @return string + */ + public function getAfterElementHtml() + { + /** @var $coreHelper Mage_Core_Helper_Data */ + $coreHelper = Mage::helper('Mage_Core_Helper_Data'); + $htmlId = $this->getHtmlId(); + $suggestPlaceholder = Mage::helper('Mage_Catalog_Helper_Data')->__('start typing to search category'); + $selectorOptions = $coreHelper->jsonEncode($this->_getSelectorOptions()); + $newCategoryCaption = Mage::helper('Mage_Catalog_Helper_Data')->__('New Category'); + + return << + + +HTML; + } + + /** + * Get selector options + * + * @return array + */ + protected function _getSelectorOptions() + { + return array( + 'source' => Mage::helper('Mage_Backend_Helper_Data') + ->getUrl('adminhtml/catalog_category/suggestCategories'), + 'valueField' => '#' . $this->getHtmlId(), + 'className' => 'category-select', + 'multiselect' => true, + 'showAll' => true + ); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Config.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Config.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Config.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Config.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery.php diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery/Content.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery/Content.php new file mode 100644 index 0000000000000..7148ee69421a4 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery/Content.php @@ -0,0 +1,175 @@ + + * + * @method Varien_Data_Form_Element_Abstract getElement() + */ +class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery_Content extends Mage_Adminhtml_Block_Widget +{ + protected $_template = 'catalog/product/helper/gallery.phtml'; + + protected function _prepareLayout() + { + $this->addChild('uploader', 'Mage_Adminhtml_Block_Media_Uploader'); + + $this->getUploader()->getConfig() + ->setUrl( + Mage::getModel('Mage_Backend_Model_Url') + ->addSessionParam() + ->getUrl('adminhtml/catalog_product_gallery/upload') + ) + ->setFileField('image') + ->setFilters(array( + 'images' => array( + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Images (.gif, .jpg, .png)'), + 'files' => array('*.gif', '*.jpg','*.jpeg', '*.png') + ) + )); + + Mage::dispatchEvent('catalog_product_gallery_prepare_layout', array('block' => $this)); + + return parent::_prepareLayout(); + } + + + /** + * Retrive uploader block + * + * @return Mage_Adminhtml_Block_Media_Uploader + */ + public function getUploader() + { + return $this->getChildBlock('uploader'); + } + + /** + * Retrive uploader block html + * + * @return string + */ + public function getUploaderHtml() + { + return $this->getChildHtml('uploader'); + } + + public function getJsObjectName() + { + return $this->getHtmlId() . 'JsObject'; + } + + public function getAddImagesButton() + { + return $this->getButtonHtml( + Mage::helper('Mage_Catalog_Helper_Data')->__('Add New Images'), + $this->getJsObjectName() . '.showUploader()', + 'add', + $this->getHtmlId() . '_add_images_button' + ); + } + + public function getImagesJson() + { + if (is_array($this->getElement()->getValue())) { + $value = $this->getElement()->getValue(); + if (is_array($value['images']) && count($value['images']) > 0) { + foreach ($value['images'] as &$image) { + $image['url'] = Mage::getSingleton('Mage_Catalog_Model_Product_Media_Config') + ->getMediaUrl($image['file']); + $image['label'] = substr($image['file'], strrpos($image['file'], '/') + 1); + } + return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($value['images']); + } + } + return '[]'; + } + + public function getImagesValuesJson() + { + $values = array(); + foreach ($this->getMediaAttributes() as $attribute) { + /* @var $attribute Mage_Eav_Model_Entity_Attribute */ + $values[$attribute->getAttributeCode()] = $this->getElement()->getDataObject()->getData( + $attribute->getAttributeCode() + ); + } + return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($values); + } + + /** + * Get image types data + * + * @return array + */ + public function getImageTypes() + { + $imageTypes = array(); + foreach ($this->getMediaAttributes() as $attribute) { + /* @var $attribute Mage_Eav_Model_Entity_Attribute */ + $imageTypes[$attribute->getAttributeCode()] = array( + 'code' => $attribute->getAttributeCode(), + 'value' => $this->getElement()->getDataObject()->getData($attribute->getAttributeCode()), + 'label' => $attribute->getFrontend()->getLabel(), + 'scope' => Mage::helper('Mage_Catalog_Helper_Data')->__($this->getElement()->getScopeLabel($attribute)), + 'name' => $this->getElement()->getAttributeFieldName($attribute) + ); + } + return $imageTypes; + } + + public function hasUseDefault() + { + foreach ($this->getMediaAttributes() as $attribute) { + if($this->getElement()->canDisplayUseDefault($attribute)) { + return true; + } + } + + return false; + } + + /** + * Enter description here... + * + * @return array + */ + public function getMediaAttributes() + { + return $this->getElement()->getDataObject()->getMediaAttributes(); + } + + public function getImageTypesJson() + { + return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($this->getImageTypes()); + } + +} diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Image.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Image.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Image.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Image.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Msrp/Enabled.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Msrp/Enabled.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Msrp/Enabled.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Msrp/Enabled.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Msrp/Price.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Msrp/Price.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Msrp/Price.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Msrp/Price.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Price.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Price.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Price.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Price.php diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Weight.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Weight.php new file mode 100644 index 0000000000000..ce9e91d6efa3b --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Weight.php @@ -0,0 +1,95 @@ + + */ +class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Weight extends Varien_Data_Form_Element_Text +{ + const VIRTUAL_FIELD_HTML_ID = 'weight_and_type_switcher'; + + /** + * Is virtual checkbox element + * + * @var Varien_Data_Form_Element_Checkbox + */ + protected $_virtual; + + /** + * Catalog helper + * + * @var Mage_Catalog_Helper_Product + */ + protected $_helper; + + public function __construct(array $data = array()) + { + $this->_helper = isset($data['helper']) ? $data['helper'] : Mage::helper('Mage_Catalog_Helper_Product'); + $this->_virtual = isset($data['element']) + ? $data['element'] + : Mage::getModel('Varien_Data_Form_Element_Checkbox'); + $this->_virtual->setId(self::VIRTUAL_FIELD_HTML_ID)->setName('is_virtual') + ->setLabel($this->_helper->getTypeSwitcherControlLabel()); + $data['class'] = 'validate-number validate-zero-or-greater validate-number-range number-range-0-99999999.9999'; + parent::__construct($data); + } + + /** + * Add Is Virtual checkbox html to weight field + * + * @return string + */ + public function getElementHtml() + { + if (!$this->getForm()->getDataObject()->getTypeInstance()->hasWeight()) { + $this->_virtual->setChecked('checked'); + } + return '
' + . parent::getElementHtml() + . '' + . '
' + . $this->_virtual->getElementHtml() . $this->_virtual->getLabelHtml() + . '
'; + } + + /** + * Set form for both fields + * + * @param Varien_Data_Form $form + * @return Varien_Data_Form + */ + public function setForm($form) + { + $this->_virtual->setForm($form); + return parent::setForm($form); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Options/Ajax.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Options/Ajax.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Options/Ajax.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Options/Ajax.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Price.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Price.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Price.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Price.php diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Widget/Chooser.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Widget/Chooser.php new file mode 100644 index 0000000000000..9bcaaecc4d86c --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Widget/Chooser.php @@ -0,0 +1,296 @@ + + */ +class Mage_Adminhtml_Block_Catalog_Product_Widget_Chooser extends Mage_Adminhtml_Block_Widget_Grid +{ + protected $_selectedProducts = array(); + + /** + * Block construction, prepare grid params + */ + protected function _construct() + { + parent::_construct(); + $this->setDefaultSort('name'); + $this->setUseAjax(true); + } + + /** + * Prepare chooser element HTML + * + * @param Varien_Data_Form_Element_Abstract $element Form Element + * @return Varien_Data_Form_Element_Abstract + */ + public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element) + { + $uniqId = Mage::helper('Mage_Core_Helper_Data')->uniqHash($element->getId()); + $sourceUrl = $this->getUrl('*/catalog_product_widget/chooser', array( + 'uniq_id' => $uniqId, + 'use_massaction' => false, + )); + + $chooser = $this->getLayout()->createBlock('Mage_Widget_Block_Adminhtml_Widget_Chooser') + ->setElement($element) + ->setTranslationHelper($this->getTranslationHelper()) + ->setConfig($this->getConfig()) + ->setFieldsetId($this->getFieldsetId()) + ->setSourceUrl($sourceUrl) + ->setUniqId($uniqId); + + if ($element->getValue()) { + $value = explode('/', $element->getValue()); + $productId = false; + if (isset($value[0]) && isset($value[1]) && $value[0] == 'product') { + $productId = $value[1]; + } + $categoryId = isset($value[2]) ? $value[2] : false; + $label = ''; + if ($categoryId) { + $label = Mage::getResourceSingleton('Mage_Catalog_Model_Resource_Category') + ->getAttributeRawValue($categoryId, 'name', Mage::app()->getStore()) . '/'; + } + if ($productId) { + $label .= Mage::getResourceSingleton('Mage_Catalog_Model_Resource_Product') + ->getAttributeRawValue($productId, 'name', Mage::app()->getStore()); + } + $chooser->setLabel($label); + } + + $element->setData('after_element_html', $chooser->toHtml()); + return $element; + } + + /** + * Checkbox Check JS Callback + * + * @return string + */ + public function getCheckboxCheckCallback() + { + if ($this->getUseMassaction()) { + return "function (grid, element) { + $(grid.containerId).fire('product:changed', {element: element}); + }"; + } + } + + /** + * Grid Row JS Callback + * + * @return string + */ + public function getRowClickCallback() + { + if (!$this->getUseMassaction()) { + $chooserJsObject = $this->getId(); + return ' + function (grid, event) { + var trElement = Event.findElement(event, "tr"); + var productId = trElement.down("td").innerHTML; + var productName = trElement.down("td").next().next().innerHTML; + var optionLabel = productName; + var optionValue = "product/" + productId.replace(/^\s+|\s+$/g,""); + if (grid.categoryId) { + optionValue += "/" + grid.categoryId; + } + if (grid.categoryName) { + optionLabel = grid.categoryName + " / " + optionLabel; + } + '.$chooserJsObject.'.setElementValue(optionValue); + '.$chooserJsObject.'.setElementLabel(optionLabel); + '.$chooserJsObject.'.close(); + } + '; + } + } + + /** + * Category Tree node onClick listener js function + * + * @return string + */ + public function getCategoryClickListenerJs() + { + $js = ' + function (node, e) { + {jsObject}.addVarToUrl("category_id", node.attributes.id); + {jsObject}.reload({jsObject}.url); + {jsObject}.categoryId = node.attributes.id != "none" ? node.attributes.id : false; + {jsObject}.categoryName = node.attributes.id != "none" ? node.text : false; + } + '; + $js = str_replace('{jsObject}', $this->getJsObjectName(), $js); + return $js; + } + + /** + * Filter checked/unchecked rows in grid + * + * @param Mage_Adminhtml_Block_Widget_Grid_Column $column + * @return Mage_Adminhtml_Block_Catalog_Product_Widget_Chooser + */ + protected function _addColumnFilterToCollection($column) + { + if ($column->getId() == 'in_products') { + $selected = $this->getSelectedProducts(); + if ($column->getFilter()->getValue()) { + $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$selected)); + } else { + $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$selected)); + } + } else { + parent::_addColumnFilterToCollection($column); + } + return $this; + } + + /** + * Prepare products collection, defined collection filters (category, product type) + * + * @return Mage_Adminhtml_Block_Widget_Grid + */ + protected function _prepareCollection() + { + /* @var $collection Mage_Catalog_Model_Resource_Product_Collection */ + $collection = Mage::getResourceModel('Mage_Catalog_Model_Resource_Product_Collection') + ->setStoreId(0) + ->addAttributeToSelect('name'); + + if ($categoryId = $this->getCategoryId()) { + $category = Mage::getModel('Mage_Catalog_Model_Category')->load($categoryId); + if ($category->getId()) { + // $collection->addCategoryFilter($category); + $productIds = $category->getProductsPosition(); + $productIds = array_keys($productIds); + if (empty($productIds)) { + $productIds = 0; + } + $collection->addFieldToFilter('entity_id', array('in' => $productIds)); + } + } + + if ($productTypeId = $this->getProductTypeId()) { + $collection->addAttributeToFilter('type_id', $productTypeId); + } + + $this->setCollection($collection); + return parent::_prepareCollection(); + } + + /** + * Prepare columns for products grid + * + * @return Mage_Adminhtml_Block_Widget_Grid + */ + protected function _prepareColumns() + { + if ($this->getUseMassaction()) { + $this->addColumn('in_products', array( + 'header_css_class' => 'a-center', + 'type' => 'checkbox', + 'name' => 'in_products', + 'inline_css' => 'checkbox entities', + 'field_name' => 'in_products', + 'values' => $this->getSelectedProducts(), + 'align' => 'center', + 'index' => 'entity_id', + 'use_index' => true, + )); + } + + $this->addColumn('entity_id', array( + 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('ID'), + 'sortable' => true, + 'index' => 'entity_id', + 'header_css_class' => 'col-id', + 'column_css_class' => 'col-id' + )); + $this->addColumn('chooser_sku', array( + 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('SKU'), + 'name' => 'chooser_sku', + 'index' => 'sku', + 'header_css_class' => 'col-sku', + 'column_css_class' => 'col-sku' + )); + $this->addColumn('chooser_name', array( + 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Product Name'), + 'name' => 'chooser_name', + 'index' => 'name', + 'header_css_class' => 'col-product', + 'column_css_class' => 'col-product' + )); + + return parent::_prepareColumns(); + } + + /** + * Adds additional parameter to URL for loading only products grid + * + * @return string + */ + public function getGridUrl() + { + return $this->getUrl('*/catalog_product_widget/chooser', array( + 'products_grid' => true, + '_current' => true, + 'uniq_id' => $this->getId(), + 'use_massaction' => $this->getUseMassaction(), + 'product_type_id' => $this->getProductTypeId() + )); + } + + /** + * Setter + * + * @param array $selectedProducts + * @return Mage_Adminhtml_Block_Catalog_Product_Widget_Chooser + */ + public function setSelectedProducts($selectedProducts) + { + $this->_selectedProducts = $selectedProducts; + return $this; + } + + /** + * Getter + * + * @return array + */ + public function getSelectedProducts() + { + if ($selectedProducts = $this->getRequest()->getParam('selected_products', null)) { + $this->setSelectedProducts($selectedProducts); + } + return $this->_selectedProducts; + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Widget/Chooser/Container.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Widget/Chooser/Container.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Product/Widget/Chooser/Container.php rename to app/code/Mage/Adminhtml/Block/Catalog/Product/Widget/Chooser/Container.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Search.php b/app/code/Mage/Adminhtml/Block/Catalog/Search.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Search.php rename to app/code/Mage/Adminhtml/Block/Catalog/Search.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Search/Edit.php b/app/code/Mage/Adminhtml/Block/Catalog/Search/Edit.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Search/Edit.php rename to app/code/Mage/Adminhtml/Block/Catalog/Search/Edit.php diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Search/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Catalog/Search/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Catalog/Search/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/Catalog/Search/Edit/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Checkout/Agreement.php b/app/code/Mage/Adminhtml/Block/Checkout/Agreement.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Checkout/Agreement.php rename to app/code/Mage/Adminhtml/Block/Checkout/Agreement.php diff --git a/app/code/core/Mage/Adminhtml/Block/Checkout/Agreement/Edit.php b/app/code/Mage/Adminhtml/Block/Checkout/Agreement/Edit.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Checkout/Agreement/Edit.php rename to app/code/Mage/Adminhtml/Block/Checkout/Agreement/Edit.php diff --git a/app/code/core/Mage/Adminhtml/Block/Checkout/Agreement/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Checkout/Agreement/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Checkout/Agreement/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/Checkout/Agreement/Edit/Form.php diff --git a/app/code/Mage/Adminhtml/Block/Checkout/Agreement/Grid.php b/app/code/Mage/Adminhtml/Block/Checkout/Agreement/Grid.php new file mode 100644 index 0000000000000..cbc69d329b746 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Checkout/Agreement/Grid.php @@ -0,0 +1,116 @@ +setDefaultSort('agreement_id'); + $this->setId('agreementGrid'); + $this->setDefaultDir('asc'); + $this->setSaveParametersInSession(true); + } + + protected function _prepareCollection() + { + $collection = Mage::getModel('Mage_Checkout_Model_Agreement') + ->getCollection(); + $this->setCollection($collection); + return parent::_prepareCollection(); + } + + protected function _prepareColumns() + { + $this->addColumn('agreement_id', + array( + 'header'=>Mage::helper('Mage_Checkout_Helper_Data')->__('ID'), + 'index' => 'agreement_id', + 'header_css_class' => 'col-id', + 'column_css_class' => 'col-id' + ) + ); + + $this->addColumn('name', + array( + 'header'=>Mage::helper('Mage_Checkout_Helper_Data')->__('Condition Name'), + 'index' => 'name', + 'header_css_class' => 'col-name', + 'column_css_class' => 'col-name' + ) + ); + + if (!Mage::app()->isSingleStoreMode()) { + $this->addColumn('store_id', array( + 'header' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Store View'), + 'index' => 'store_id', + 'type' => 'store', + 'store_all' => true, + 'store_view' => true, + 'sortable' => false, + 'filter_condition_callback' + => array($this, '_filterStoreCondition'), + 'header_css_class' => 'col-store-view', + 'column_css_class' => 'col-store-view' + )); + } + + $this->addColumn('is_active', array( + 'header' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Status'), + 'index' => 'is_active', + 'type' => 'options', + 'options' => array( + 0 => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Disabled'), + 1 => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Enabled') + ), + 'header_css_class' => 'col-status', + 'column_css_class' => 'col-status' + )); + + return parent::_prepareColumns(); + } + + protected function _afterLoadCollection() + { + $this->getCollection()->walk('afterLoad'); + parent::_afterLoadCollection(); + } + + protected function _filterStoreCondition($collection, $column) + { + if (!$value = $column->getFilter()->getValue()) { + return; + } + + $this->getCollection()->addStoreFilter($value); + } + + public function getRowUrl($row) + { + return $this->getUrl('*/*/edit', array('id' => $row->getId())); + } + +} diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Block.php b/app/code/Mage/Adminhtml/Block/Cms/Block.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Cms/Block.php rename to app/code/Mage/Adminhtml/Block/Cms/Block.php diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit.php b/app/code/Mage/Adminhtml/Block/Cms/Block/Edit.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit.php rename to app/code/Mage/Adminhtml/Block/Cms/Block/Edit.php diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Block/Grid.php b/app/code/Mage/Adminhtml/Block/Cms/Block/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Cms/Block/Grid.php rename to app/code/Mage/Adminhtml/Block/Cms/Block/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Block/Widget/Chooser.php b/app/code/Mage/Adminhtml/Block/Cms/Block/Widget/Chooser.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Cms/Block/Widget/Chooser.php rename to app/code/Mage/Adminhtml/Block/Cms/Block/Widget/Chooser.php diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page.php b/app/code/Mage/Adminhtml/Block/Cms/Page.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Cms/Page.php rename to app/code/Mage/Adminhtml/Block/Cms/Page.php diff --git a/app/code/Mage/Adminhtml/Block/Cms/Page/Edit.php b/app/code/Mage/Adminhtml/Block/Cms/Page/Edit.php new file mode 100644 index 0000000000000..661863f9e0000 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Cms/Page/Edit.php @@ -0,0 +1,155 @@ + + */ +class Mage_Adminhtml_Block_Cms_Page_Edit extends Mage_Adminhtml_Block_Widget_Form_Container +{ + /** + * Initialize cms page edit block + * + * @return void + */ + protected function _construct() + { + $this->_objectId = 'page_id'; + $this->_controller = 'cms_page'; + + parent::_construct(); + + if ($this->_isAllowedAction('Mage_Cms::save')) { + $this->_updateButton('save', 'label', Mage::helper('Mage_Cms_Helper_Data')->__('Save Page')); + $this->_addButton('saveandcontinue', array( + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Save and Continue Edit'), + 'class' => 'save', + 'data_attribute' => array( + 'mage-init' => array( + 'button' => array('event' => 'saveAndContinueEdit', 'target' => '#edit_form'), + ), + ), + ), -100); + } else { + $this->_removeButton('save'); + } + + if ($this->_isAllowedAction('Mage_Cms::page_delete')) { + $this->_updateButton('delete', 'label', Mage::helper('Mage_Cms_Helper_Data')->__('Delete Page')); + } else { + $this->_removeButton('delete'); + } + } + + /** + * Retrieve text for header element depending on loaded page + * + * @return string + */ + public function getHeaderText() + { + if (Mage::registry('cms_page')->getId()) { + return Mage::helper('Mage_Cms_Helper_Data')->__("Edit Page '%s'", $this->escapeHtml(Mage::registry('cms_page')->getTitle())); + } + else { + return Mage::helper('Mage_Cms_Helper_Data')->__('New Page'); + } + } + + /** + * Check permission for passed action + * + * @param string $resourceId + * @return bool + */ + protected function _isAllowedAction($resourceId) + { + return Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed($resourceId); + } + + /** + * Getter of url for "Save and Continue" button + * tab_id will be replaced by desired by JS later + * + * @return string + */ + protected function _getSaveAndContinueUrl() + { + return $this->getUrl('*/*/save', array( + '_current' => true, + 'back' => 'edit', + 'active_tab' => '{{tab_id}}' + )); + } + + /** + * Prepare layout + * + * @return Mage_Core_Block_Abstract + */ + protected function _prepareLayout() + { + $tabsBlock = $this->getLayout()->getBlock('cms_page_edit_tabs'); + if ($tabsBlock) { + $tabsBlockJsObject = $tabsBlock->getJsObjectName(); + $tabsBlockPrefix = $tabsBlock->getId() . '_'; + } else { + $tabsBlockJsObject = 'page_tabsJsTabs'; + $tabsBlockPrefix = 'page_tabs_'; + } + + $this->_formScripts[] = " + function toggleEditor() { + if (tinyMCE.getInstanceById('page_content') == null) { + tinyMCE.execCommand('mceAddControl', false, 'page_content'); + } else { + tinyMCE.execCommand('mceRemoveControl', false, 'page_content'); + } + } + (function($) { + 'use strict'; + + head.js('{$this->getViewFileUrl('mage/backend/tabs.js')}', function() { + $(\"#{$tabsBlock->getId()}\") + .tabs('option', 'tabsBlockPrefix', '" . $tabsBlockPrefix . "') + .tabs('option', 'tabIdArgument', 'active_tab'); + }); + })(jQuery); + jQuery(function() { + var tabsElement = jQuery(\"#" . $tabsBlock->getId() ."\"); + tabsElement.on('tabscreate', function() { + tabsElement + .tabs('option', 'tabsBlockPrefix', '" . $tabsBlockPrefix . "') + .tabs('option', 'tabIdArgument', 'active_tab'); + }); + }); + "; + return parent::_prepareLayout(); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Cms/Page/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/Cms/Page/Edit/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php b/app/code/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php rename to app/code/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php b/app/code/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php rename to app/code/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Main.php b/app/code/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Main.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Main.php rename to app/code/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Main.php diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Meta.php b/app/code/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Meta.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Meta.php rename to app/code/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Meta.php diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tabs.php b/app/code/Mage/Adminhtml/Block/Cms/Page/Edit/Tabs.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tabs.php rename to app/code/Mage/Adminhtml/Block/Cms/Page/Edit/Tabs.php diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Grid.php b/app/code/Mage/Adminhtml/Block/Cms/Page/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Cms/Page/Grid.php rename to app/code/Mage/Adminhtml/Block/Cms/Page/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Grid/Renderer/Action.php b/app/code/Mage/Adminhtml/Block/Cms/Page/Grid/Renderer/Action.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Cms/Page/Grid/Renderer/Action.php rename to app/code/Mage/Adminhtml/Block/Cms/Page/Grid/Renderer/Action.php diff --git a/app/code/Mage/Adminhtml/Block/Cms/Page/Widget/Chooser.php b/app/code/Mage/Adminhtml/Block/Cms/Page/Widget/Chooser.php new file mode 100644 index 0000000000000..c73a441175cfc --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Cms/Page/Widget/Chooser.php @@ -0,0 +1,169 @@ + + */ +class Mage_Adminhtml_Block_Cms_Page_Widget_Chooser extends Mage_Adminhtml_Block_Widget_Grid +{ + /** + * Block construction, prepare grid params + * + * @param array $arguments Object data + */ + protected function _construct() + { + parent::_construct(); + //$this->setDefaultSort('name'); + $this->setUseAjax(true); + $this->setDefaultFilter(array('chooser_is_active' => '1')); + } + + /** + * Prepare chooser element HTML + * + * @param Varien_Data_Form_Element_Abstract $element Form Element + * @return Varien_Data_Form_Element_Abstract + */ + public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element) + { + $uniqId = Mage::helper('Mage_Core_Helper_Data')->uniqHash($element->getId()); + $sourceUrl = $this->getUrl('*/cms_page_widget/chooser', array('uniq_id' => $uniqId)); + + $chooser = $this->getLayout()->createBlock('Mage_Widget_Block_Adminhtml_Widget_Chooser') + ->setElement($element) + ->setTranslationHelper($this->getTranslationHelper()) + ->setConfig($this->getConfig()) + ->setFieldsetId($this->getFieldsetId()) + ->setSourceUrl($sourceUrl) + ->setUniqId($uniqId); + + + if ($element->getValue()) { + $page = Mage::getModel('Mage_Cms_Model_Page')->load((int)$element->getValue()); + if ($page->getId()) { + $chooser->setLabel($page->getTitle()); + } + } + + $element->setData('after_element_html', $chooser->toHtml()); + return $element; + } + + /** + * Grid Row JS Callback + * + * @return string + */ + public function getRowClickCallback() + { + $chooserJsObject = $this->getId(); + $js = ' + function (grid, event) { + var trElement = Event.findElement(event, "tr"); + var pageTitle = trElement.down("td").next().innerHTML; + var pageId = trElement.down("td").innerHTML.replace(/^\s+|\s+$/g,""); + '.$chooserJsObject.'.setElementValue(pageId); + '.$chooserJsObject.'.setElementLabel(pageTitle); + '.$chooserJsObject.'.close(); + } + '; + return $js; + } + + /** + * Prepare pages collection + * + * @return Mage_Adminhtml_Block_Widget_Grid + */ + protected function _prepareCollection() + { + $collection = Mage::getModel('Mage_Cms_Model_Page')->getCollection(); + /* @var $collection Mage_Cms_Model_Resource_Page_Collection */ + $collection->setFirstStoreFlag(true); + $this->setCollection($collection); + + return parent::_prepareCollection(); + } + + /** + * Prepare columns for pages grid + * + * @return Mage_Adminhtml_Block_Widget_Grid + */ + protected function _prepareColumns() + { + $this->addColumn('chooser_id', array( + 'header' => Mage::helper('Mage_Cms_Helper_Data')->__('ID'), + 'index' => 'page_id', + 'header_css_class' => 'col-id', + 'column_css_class' => 'col-id' + )); + + $this->addColumn('chooser_title', array( + 'header' => Mage::helper('Mage_Cms_Helper_Data')->__('Title'), + 'index' => 'title', + 'header_css_class' => 'col-title', + 'column_css_class' => 'col-title' + )); + + $this->addColumn('chooser_identifier', array( + 'header' => Mage::helper('Mage_Cms_Helper_Data')->__('URL Key'), + 'index' => 'identifier', + 'header_css_class' => 'col-url', + 'column_css_class' => 'col-url' + )); + + $this->addColumn('chooser_root_template', array( + 'header' => Mage::helper('Mage_Cms_Helper_Data')->__('Layout'), + 'index' => 'root_template', + 'type' => 'options', + 'options' => Mage::getSingleton('Mage_Page_Model_Source_Layout')->getOptions(), + 'header_css_class' => 'col-layout', + 'column_css_class' => 'col-layout' + )); + + $this->addColumn('chooser_is_active', array( + 'header' => Mage::helper('Mage_Cms_Helper_Data')->__('Status'), + 'index' => 'is_active', + 'type' => 'options', + 'options' => Mage::getModel('Mage_Cms_Model_Page')->getAvailableStatuses(), + 'header_css_class' => 'col-status', + 'column_css_class' => 'col-status' + )); + + return parent::_prepareColumns(); + } + + public function getGridUrl() + { + return $this->getUrl('*/cms_page_widget/chooser', array('_current' => true)); + } +} diff --git a/app/code/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content.php b/app/code/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content.php new file mode 100644 index 0000000000000..9f6109d1a463e --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content.php @@ -0,0 +1,161 @@ + + */ +class Mage_Adminhtml_Block_Cms_Wysiwyg_Images_Content extends Mage_Adminhtml_Block_Widget_Container +{ + /** + * Block construction + */ + protected function _construct() + { + parent::_construct(); + $this->_headerText = $this->helper('Mage_Cms_Helper_Data')->__('Media Storage'); + $this->_removeButton('back')->_removeButton('edit'); + $this->_addButton('newfolder', array( + 'class' => 'save', + 'label' => $this->helper('Mage_Cms_Helper_Data')->__('Create Folder...'), + 'type' => 'button', + 'onclick' => 'MediabrowserInstance.newFolder();' + )); + + $this->_addButton('delete_folder', array( + 'class' => 'delete no-display', + 'label' => $this->helper('Mage_Cms_Helper_Data')->__('Delete Folder'), + 'type' => 'button', + 'onclick' => 'MediabrowserInstance.deleteFolder();', + 'id' => 'button_delete_folder' + )); + + $this->_addButton('delete_files', array( + 'class' => 'delete no-display', + 'label' => $this->helper('Mage_Cms_Helper_Data')->__('Delete File'), + 'type' => 'button', + 'onclick' => 'MediabrowserInstance.deleteFiles();', + 'id' => 'button_delete_files' + )); + + $this->_addButton('insert_files', array( + 'class' => 'save no-display primary', + 'label' => $this->helper('Mage_Cms_Helper_Data')->__('Insert File'), + 'type' => 'button', + 'onclick' => 'MediabrowserInstance.insert();', + 'id' => 'button_insert_files' + )); + } + + /** + * Files action source URL + * + * @return string + */ + public function getContentsUrl() + { + return $this->getUrl('*/*/contents', array('type' => $this->getRequest()->getParam('type'))); + } + + /** + * Javascript setup object for filebrowser instance + * + * @return string + */ + public function getFilebrowserSetupObject() + { + $setupObject = new Varien_Object(); + + $setupObject->setData(array( + 'newFolderPrompt' => $this->helper('Mage_Cms_Helper_Data')->__('New Folder Name:'), + 'deleteFolderConfirmationMessage' => $this->helper('Mage_Cms_Helper_Data')->__('Are you sure you want to delete current folder?'), + 'deleteFileConfirmationMessage' => $this->helper('Mage_Cms_Helper_Data')->__('Are you sure you want to delete the selected file?'), + 'targetElementId' => $this->getTargetElementId(), + 'contentsUrl' => $this->getContentsUrl(), + 'onInsertUrl' => $this->getOnInsertUrl(), + 'newFolderUrl' => $this->getNewfolderUrl(), + 'deleteFolderUrl' => $this->getDeletefolderUrl(), + 'deleteFilesUrl' => $this->getDeleteFilesUrl(), + 'headerText' => $this->getHeaderText() + )); + + return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($setupObject); + } + + /** + * New directory action target URL + * + * @return string + */ + public function getNewfolderUrl() + { + return $this->getUrl('*/*/newFolder'); + } + + /** + * Delete directory action target URL + * + * @return string + */ + protected function getDeletefolderUrl() + { + return $this->getUrl('*/*/deleteFolder'); + } + + /** + * Description goes here... + * + * @param none + * @return void + */ + public function getDeleteFilesUrl() + { + return $this->getUrl('*/*/deleteFiles'); + } + + /** + * New directory action target URL + * + * @return string + */ + public function getOnInsertUrl() + { + return $this->getUrl('*/*/onInsert'); + } + + /** + * Target element ID getter + * + * @return string + */ + public function getTargetElementId() + { + return $this->getRequest()->getParam('target_element_id'); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content/Files.php b/app/code/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content/Files.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content/Files.php rename to app/code/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content/Files.php diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content/Newfolder.php b/app/code/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content/Newfolder.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content/Newfolder.php rename to app/code/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content/Newfolder.php diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content/Uploader.php b/app/code/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content/Uploader.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content/Uploader.php rename to app/code/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content/Uploader.php diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Tree.php b/app/code/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Tree.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Tree.php rename to app/code/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Tree.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer.php b/app/code/Mage/Adminhtml/Block/Customer.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer.php rename to app/code/Mage/Adminhtml/Block/Customer.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit.php b/app/code/Mage/Adminhtml/Block/Customer/Edit.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Attribute/Group.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Renderer/Attribute/Group.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Attribute/Group.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Renderer/Attribute/Group.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Newpass.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Renderer/Newpass.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Newpass.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Renderer/Newpass.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Region.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Renderer/Region.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Region.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Renderer/Region.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php similarity index 98% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php index e7d1dc2e46dff..54111b9169c58 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php +++ b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php @@ -250,15 +250,13 @@ protected function _addNewCustomerFormFields($form, $fieldset) '' diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Addresses.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Addresses.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Addresses.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Addresses.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Cart.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Cart.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Cart.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Cart.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Carts.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Carts.php similarity index 96% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Carts.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Carts.php index d7ca61cbb6c59..dfe4758de717c 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Carts.php +++ b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Carts.php @@ -42,7 +42,7 @@ protected function _prepareLayout() foreach ($sharedWebsiteIds as $websiteId) { $blockName = 'customer_cart_' . $websiteId; $block = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Customer_Edit_Tab_Cart', - $blockName, array('website_id' => $websiteId)); + $blockName, array('data' => array('website_id' => $websiteId))); if ($isShared) { $block->setCartHeader($this->__('Shopping Cart from %s', Mage::app()->getWebsite($websiteId)->getName())); } diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Filter/Status.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Filter/Status.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Filter/Status.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Filter/Status.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Renderer/Action.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Renderer/Action.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Renderer/Action.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Renderer/Action.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Renderer/Status.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Renderer/Status.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Renderer/Status.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Renderer/Status.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Orders.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Orders.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Orders.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Orders.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Reviews.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Reviews.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Reviews.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Reviews.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Accordion.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Accordion.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Accordion.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Accordion.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Cart.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Cart.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Cart.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Cart.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Grid/Renderer/Item.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Grid/Renderer/Item.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Grid/Renderer/Item.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Grid/Renderer/Item.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Orders.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Orders.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Orders.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Orders.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Sales.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Sales.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Sales.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Sales.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Wishlist.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Wishlist.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Wishlist.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Wishlist.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist/Grid/Renderer/Description.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist/Grid/Renderer/Description.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist/Grid/Renderer/Description.php rename to app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist/Grid/Renderer/Description.php diff --git a/app/code/Mage/Adminhtml/Block/Customer/Edit/Tabs.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tabs.php new file mode 100644 index 0000000000000..865a567f8eaa7 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tabs.php @@ -0,0 +1,129 @@ + + */ +class Mage_Adminhtml_Block_Customer_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs +{ + + protected function _construct() + { + parent::_construct(); + $this->setId('customer_info_tabs'); + $this->setDestElementId('edit_form'); + $this->setTitle(Mage::helper('Mage_Customer_Helper_Data')->__('Customer Information')); + } + + protected function _beforeToHtml() + { + Magento_Profiler::start('customer/tabs'); + + /* + if (Mage::registry('current_customer')->getId()) { + $this->addTab('view', array( + 'label' => Mage::helper('Mage_Customer_Helper_Data')->__('Customer View'), + 'content' => $this->getLayout() + ->createBlock('Mage_Adminhtml_Block_Customer_Edit_Tab_View')->toHtml(), + 'active' => true + )); + } + */ + $this->addTab('account', array( + 'label' => Mage::helper('Mage_Customer_Helper_Data')->__('Account Information'), + 'content' => $this->getLayout() + ->createBlock('Mage_Adminhtml_Block_Customer_Edit_Tab_Account')->initForm()->toHtml(), + 'active' => Mage::registry('current_customer')->getId() ? false : true + )); + + $this->addTab('addresses', array( + 'label' => Mage::helper('Mage_Customer_Helper_Data')->__('Addresses'), + 'content' => $this->getLayout() + ->createBlock('Mage_Adminhtml_Block_Customer_Edit_Tab_Addresses')->initForm()->toHtml(), + )); + + + // load: Orders, Shopping Cart, Wishlist, Product Reviews, Product Tags - with ajax + + if (Mage::registry('current_customer')->getId()) { + + if (Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Sales::actions_view')) { + $this->addTab('orders', array( + 'label' => Mage::helper('Mage_Customer_Helper_Data')->__('Orders'), + 'class' => 'ajax', + 'url' => $this->getUrl('*/*/orders', array('_current' => true)), + )); + } + + $this->addTab('cart', array( + 'label' => Mage::helper('Mage_Customer_Helper_Data')->__('Shopping Cart'), + 'class' => 'ajax', + 'url' => $this->getUrl('*/*/carts', array('_current' => true)), + )); + + $this->addTab('wishlist', array( + 'label' => Mage::helper('Mage_Customer_Helper_Data')->__('Wishlist'), + 'class' => 'ajax', + 'url' => $this->getUrl('*/*/wishlist', array('_current' => true)), + )); + + if (Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Newsletter::subscriber')) { + $this->addTab('newsletter', array( + 'label' => Mage::helper('Mage_Customer_Helper_Data')->__('Newsletter'), + 'content' => $this->getLayout() + ->createBlock('Mage_Adminhtml_Block_Customer_Edit_Tab_Newsletter')->initForm()->toHtml() + )); + } + + if (Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Review::reviews_all')) { + $this->addTab('reviews', array( + 'label' => Mage::helper('Mage_Customer_Helper_Data')->__('Product Reviews'), + 'class' => 'ajax', + 'url' => $this->getUrl('*/*/productReviews', array('_current' => true)), + )); + } + } + + $this->_updateActiveTab(); + Magento_Profiler::stop('customer/tabs'); + return parent::_beforeToHtml(); + } + + protected function _updateActiveTab() + { + $tabId = $this->getRequest()->getParam('tab'); + if ($tabId) { + $tabId = preg_replace("#{$this->getId()}_#", '', $tabId); + if ($tabId) { + $this->setActiveTab($tabId); + } + } + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Form/Element/Boolean.php b/app/code/Mage/Adminhtml/Block/Customer/Form/Element/Boolean.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Form/Element/Boolean.php rename to app/code/Mage/Adminhtml/Block/Customer/Form/Element/Boolean.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Form/Element/File.php b/app/code/Mage/Adminhtml/Block/Customer/Form/Element/File.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Form/Element/File.php rename to app/code/Mage/Adminhtml/Block/Customer/Form/Element/File.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Form/Element/Image.php b/app/code/Mage/Adminhtml/Block/Customer/Form/Element/Image.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Form/Element/Image.php rename to app/code/Mage/Adminhtml/Block/Customer/Form/Element/Image.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Grid.php b/app/code/Mage/Adminhtml/Block/Customer/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Grid.php rename to app/code/Mage/Adminhtml/Block/Customer/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Grid/Filter/Country.php b/app/code/Mage/Adminhtml/Block/Customer/Grid/Filter/Country.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Grid/Filter/Country.php rename to app/code/Mage/Adminhtml/Block/Customer/Grid/Filter/Country.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Grid/Renderer/Multiaction.php b/app/code/Mage/Adminhtml/Block/Customer/Grid/Renderer/Multiaction.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Grid/Renderer/Multiaction.php rename to app/code/Mage/Adminhtml/Block/Customer/Grid/Renderer/Multiaction.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Group.php b/app/code/Mage/Adminhtml/Block/Customer/Group.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Group.php rename to app/code/Mage/Adminhtml/Block/Customer/Group.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Group/Edit.php b/app/code/Mage/Adminhtml/Block/Customer/Group/Edit.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Group/Edit.php rename to app/code/Mage/Adminhtml/Block/Customer/Group/Edit.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Group/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Customer/Group/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Group/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/Customer/Group/Edit/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Group/Grid.php b/app/code/Mage/Adminhtml/Block/Customer/Group/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Group/Grid.php rename to app/code/Mage/Adminhtml/Block/Customer/Group/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Online.php b/app/code/Mage/Adminhtml/Block/Customer/Online.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Online.php rename to app/code/Mage/Adminhtml/Block/Customer/Online.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Online/Filter.php b/app/code/Mage/Adminhtml/Block/Customer/Online/Filter.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Online/Filter.php rename to app/code/Mage/Adminhtml/Block/Customer/Online/Filter.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid.php b/app/code/Mage/Adminhtml/Block/Customer/Online/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid.php rename to app/code/Mage/Adminhtml/Block/Customer/Online/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid/Renderer/Ip.php b/app/code/Mage/Adminhtml/Block/Customer/Online/Grid/Renderer/Ip.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid/Renderer/Ip.php rename to app/code/Mage/Adminhtml/Block/Customer/Online/Grid/Renderer/Ip.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid/Renderer/Type.php b/app/code/Mage/Adminhtml/Block/Customer/Online/Grid/Renderer/Type.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid/Renderer/Type.php rename to app/code/Mage/Adminhtml/Block/Customer/Online/Grid/Renderer/Type.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid/Renderer/Url.php b/app/code/Mage/Adminhtml/Block/Customer/Online/Grid/Renderer/Url.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid/Renderer/Url.php rename to app/code/Mage/Adminhtml/Block/Customer/Online/Grid/Renderer/Url.php diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Sales/Order/Address/Form/Renderer/Vat.php b/app/code/Mage/Adminhtml/Block/Customer/Sales/Order/Address/Form/Renderer/Vat.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Customer/Sales/Order/Address/Form/Renderer/Vat.php rename to app/code/Mage/Adminhtml/Block/Customer/Sales/Order/Address/Form/Renderer/Vat.php diff --git a/app/code/Mage/Adminhtml/Block/Customer/System/Config/Validatevat.php b/app/code/Mage/Adminhtml/Block/Customer/System/Config/Validatevat.php new file mode 100644 index 0000000000000..544b9f18692fb --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Customer/System/Config/Validatevat.php @@ -0,0 +1,158 @@ + + */ +class Mage_Adminhtml_Block_Customer_System_Config_Validatevat extends Mage_Backend_Block_System_Config_Form_Field +{ + /** + * Merchant Country Field Name + * + * @var string + */ + protected $_merchantCountry = 'general_store_information_country_id'; + + /** + * Merchant VAT Number Field + * + * @var string + */ + protected $_merchantVatNumber = 'general_store_information_merchant_vat_number'; + + /** + * Validate VAT Button Label + * + * @var string + */ + protected $_vatButtonLabel = 'Validate VAT Number'; + + /** + * Set Merchant Country Field Name + * + * @param string $countryField + * @return Mage_Adminhtml_Block_Customer_System_Config_Validatevat + */ + public function setMerchantCountryField($countryField) + { + $this->_merchantCountry = $countryField; + return $this; + } + + /** + * Get Merchant Country Field Name + * + * @return string + */ + public function getMerchantCountryField() + { + return $this->_merchantCountry; + } + + /** + * Set Merchant VAT Number Field + * + * @param string $vatNumberField + * @return Mage_Adminhtml_Block_Customer_System_Config_Validatevat + */ + public function setMerchantVatNumberField($vatNumberField) + { + $this->_merchantVatNumber = $vatNumberField; + return $this; + } + + /** + * Get Merchant VAT Number Field + * + * @return string + */ + public function getMerchantVatNumberField() + { + return $this->_merchantVatNumber; + } + + /** + * Set Validate VAT Button Label + * + * @param string $vatButtonLabel + * @return Mage_Adminhtml_Block_Customer_System_Config_Validatevat + */ + public function setVatButtonLabel($vatButtonLabel) + { + $this->_vatButtonLabel = $vatButtonLabel; + return $this; + } + + /** + * Set template to itself + * + * @return Mage_Adminhtml_Block_Customer_System_Config_Validatevat + */ + protected function _prepareLayout() + { + parent::_prepareLayout(); + if (!$this->getTemplate()) { + $this->setTemplate('customer/system/config/validatevat.phtml'); + } + return $this; + } + + /** + * Unset some non-related element parameters + * + * @param Varien_Data_Form_Element_Abstract $element + * @return string + */ + public function render(Varien_Data_Form_Element_Abstract $element) + { + $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); + return parent::render($element); + } + + /** + * Get the button and scripts contents + * + * @param Varien_Data_Form_Element_Abstract $element + * @return string + */ + protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) + { + $originalData = $element->getOriginalData(); + $buttonLabel = !empty($originalData['button_label']) ? $originalData['button_label'] : $this->_vatButtonLabel; + $this->addData(array( + 'button_label' => Mage::helper('Mage_Customer_Helper_Data')->__($buttonLabel), + 'html_id' => $element->getHtmlId(), + 'ajax_url' => Mage::getSingleton('Mage_Backend_Model_Url') + ->getUrl('adminhtml/customer_system_config_validatevat/validate') + )); + + return $this->_toHtml(); + } +} diff --git a/app/code/Mage/Adminhtml/Block/Customer/System/Config/ValidatevatFactory.php b/app/code/Mage/Adminhtml/Block/Customer/System/Config/ValidatevatFactory.php new file mode 100644 index 0000000000000..07f8ab3c44728 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Customer/System/Config/ValidatevatFactory.php @@ -0,0 +1,45 @@ + + */ +class Mage_Adminhtml_Block_Customer_System_Config_ValidatevatFactory +{ + /** + * Create new VAT validator + * + * @return Mage_Adminhtml_Block_Customer_System_Config_Validatevat + */ + public function createVatValidator() + { + return Mage::getBlockSingleton('Mage_Adminhtml_Block_Customer_System_Config_Validatevat'); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard.php b/app/code/Mage/Adminhtml/Block/Dashboard.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Dashboard.php rename to app/code/Mage/Adminhtml/Block/Dashboard.php diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard/Abstract.php b/app/code/Mage/Adminhtml/Block/Dashboard/Abstract.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Dashboard/Abstract.php rename to app/code/Mage/Adminhtml/Block/Dashboard/Abstract.php diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard/Bar.php b/app/code/Mage/Adminhtml/Block/Dashboard/Bar.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Dashboard/Bar.php rename to app/code/Mage/Adminhtml/Block/Dashboard/Bar.php diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard/Diagrams.php b/app/code/Mage/Adminhtml/Block/Dashboard/Diagrams.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Dashboard/Diagrams.php rename to app/code/Mage/Adminhtml/Block/Dashboard/Diagrams.php diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php b/app/code/Mage/Adminhtml/Block/Dashboard/Graph.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php rename to app/code/Mage/Adminhtml/Block/Dashboard/Graph.php diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard/Grid.php b/app/code/Mage/Adminhtml/Block/Dashboard/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Dashboard/Grid.php rename to app/code/Mage/Adminhtml/Block/Dashboard/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard/Grids.php b/app/code/Mage/Adminhtml/Block/Dashboard/Grids.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Dashboard/Grids.php rename to app/code/Mage/Adminhtml/Block/Dashboard/Grids.php diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard/Orders/Grid.php b/app/code/Mage/Adminhtml/Block/Dashboard/Orders/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Dashboard/Orders/Grid.php rename to app/code/Mage/Adminhtml/Block/Dashboard/Orders/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard/Sales.php b/app/code/Mage/Adminhtml/Block/Dashboard/Sales.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Dashboard/Sales.php rename to app/code/Mage/Adminhtml/Block/Dashboard/Sales.php diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard/Searches/Last.php b/app/code/Mage/Adminhtml/Block/Dashboard/Searches/Last.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Dashboard/Searches/Last.php rename to app/code/Mage/Adminhtml/Block/Dashboard/Searches/Last.php diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard/Searches/Renderer/Searchquery.php b/app/code/Mage/Adminhtml/Block/Dashboard/Searches/Renderer/Searchquery.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Dashboard/Searches/Renderer/Searchquery.php rename to app/code/Mage/Adminhtml/Block/Dashboard/Searches/Renderer/Searchquery.php diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard/Searches/Top.php b/app/code/Mage/Adminhtml/Block/Dashboard/Searches/Top.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Dashboard/Searches/Top.php rename to app/code/Mage/Adminhtml/Block/Dashboard/Searches/Top.php diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Amounts.php b/app/code/Mage/Adminhtml/Block/Dashboard/Tab/Amounts.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Amounts.php rename to app/code/Mage/Adminhtml/Block/Dashboard/Tab/Amounts.php diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Customers/Most.php b/app/code/Mage/Adminhtml/Block/Dashboard/Tab/Customers/Most.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Customers/Most.php rename to app/code/Mage/Adminhtml/Block/Dashboard/Tab/Customers/Most.php diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Customers/Newest.php b/app/code/Mage/Adminhtml/Block/Dashboard/Tab/Customers/Newest.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Customers/Newest.php rename to app/code/Mage/Adminhtml/Block/Dashboard/Tab/Customers/Newest.php diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Orders.php b/app/code/Mage/Adminhtml/Block/Dashboard/Tab/Orders.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Orders.php rename to app/code/Mage/Adminhtml/Block/Dashboard/Tab/Orders.php diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Products/Ordered.php b/app/code/Mage/Adminhtml/Block/Dashboard/Tab/Products/Ordered.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Products/Ordered.php rename to app/code/Mage/Adminhtml/Block/Dashboard/Tab/Products/Ordered.php diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Products/Viewed.php b/app/code/Mage/Adminhtml/Block/Dashboard/Tab/Products/Viewed.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Products/Viewed.php rename to app/code/Mage/Adminhtml/Block/Dashboard/Tab/Products/Viewed.php diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard/Totals.php b/app/code/Mage/Adminhtml/Block/Dashboard/Totals.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Dashboard/Totals.php rename to app/code/Mage/Adminhtml/Block/Dashboard/Totals.php diff --git a/app/code/core/Mage/Adminhtml/Block/Denied.php b/app/code/Mage/Adminhtml/Block/Denied.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Denied.php rename to app/code/Mage/Adminhtml/Block/Denied.php diff --git a/app/code/Mage/Adminhtml/Block/Html/Date.php b/app/code/Mage/Adminhtml/Block/Html/Date.php new file mode 100644 index 0000000000000..8f4c953f4498c --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Html/Date.php @@ -0,0 +1,36 @@ + + */ +class Mage_Adminhtml_Block_Html_Date extends Mage_Core_Block_Html_Date +{ +} diff --git a/app/code/Mage/Adminhtml/Block/Html/Select.php b/app/code/Mage/Adminhtml/Block/Html/Select.php new file mode 100644 index 0000000000000..7b0c63018b2a0 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Html/Select.php @@ -0,0 +1,36 @@ + + */ +class Mage_Adminhtml_Block_Html_Select extends Mage_Core_Block_Html_Select +{ +} diff --git a/app/code/core/Mage/Adminhtml/Block/Media/Uploader.php b/app/code/Mage/Adminhtml/Block/Media/Uploader.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Media/Uploader.php rename to app/code/Mage/Adminhtml/Block/Media/Uploader.php diff --git a/app/code/Mage/Adminhtml/Block/Messages.php b/app/code/Mage/Adminhtml/Block/Messages.php new file mode 100644 index 0000000000000..caf9d102ca50c --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Messages.php @@ -0,0 +1,37 @@ + + */ +class Mage_Adminhtml_Block_Messages extends Mage_Core_Block_Messages +{ +} diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Problem.php b/app/code/Mage/Adminhtml/Block/Newsletter/Problem.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Newsletter/Problem.php rename to app/code/Mage/Adminhtml/Block/Newsletter/Problem.php diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Problem/Grid/Filter/Checkbox.php b/app/code/Mage/Adminhtml/Block/Newsletter/Problem/Grid/Filter/Checkbox.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Newsletter/Problem/Grid/Filter/Checkbox.php rename to app/code/Mage/Adminhtml/Block/Newsletter/Problem/Grid/Filter/Checkbox.php diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Problem/Grid/Renderer/Checkbox.php b/app/code/Mage/Adminhtml/Block/Newsletter/Problem/Grid/Renderer/Checkbox.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Newsletter/Problem/Grid/Renderer/Checkbox.php rename to app/code/Mage/Adminhtml/Block/Newsletter/Problem/Grid/Renderer/Checkbox.php diff --git a/app/code/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php b/app/code/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php new file mode 100644 index 0000000000000..eae03306425a6 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php @@ -0,0 +1,259 @@ + + */ + +class Mage_Adminhtml_Block_Newsletter_Queue_Edit extends Mage_Adminhtml_Block_Template +{ + protected $_template = 'newsletter/queue/edit.phtml'; + + protected function _construct() + { + parent::_construct(); + $templateId = $this->getRequest()->getParam('template_id'); + if ($templateId) { + $this->setTemplateId($templateId); + } + } + + /** + * Retrieve current Newsletter Queue Object + * + * @return Mage_Newsletter_Model_Queue + */ + public function getQueue() + { + return Mage::registry('current_queue'); + } + + protected function _beforeToHtml() { + + + + $this->setChild('form', + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Newsletter_Queue_Edit_Form','form') + ); + + return parent::_beforeToHtml(); + } + + public function getSaveUrl() + { + if ($this->getTemplateId()) { + $params = array('template_id' => $this->getTemplateId()); + } else { + $params = array('id' => $this->getRequest()->getParam('id')); + } + return $this->getUrl('*/*/save', $params); + } + + protected function _prepareLayout() + { + // Load Wysiwyg on demand and Prepare layout + if (Mage::getSingleton('Mage_Cms_Model_Wysiwyg_Config')->isEnabled()) { + $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true); + } + + $this->addChild('preview_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Preview Template'), + 'onclick' => 'queueControl.preview();', + 'class' => 'preview' + )); + + $this->addChild('save_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Save Newsletter'), + 'class' => 'save primary', + 'data_attribute' => array( + 'mage-init' => array( + 'button' => array('event' => 'save', 'target' => '#queue_edit_form'), + ), + ), + )); + + $this->addChild('save_and_resume', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Save and Resume'), + 'class' => 'save', + 'data_attribute' => array( + 'mage-init' => array( + 'button' => array( + 'event' => 'save', + 'target' => '#queue_edit_form', + 'eventData' => array( + 'action' => array( + 'args' => array('_resume' => 1), + ), + ), + ), + ), + ), + )); + + $this->addChild('reset_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Reset'), + 'onclick' => 'window.location = window.location' + )); + + $this->addChild('back_button','Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Back'), + 'onclick' => "window.location.href = '" . $this->getUrl(( + $this->getTemplateId() ? '*/newsletter_template/' : '*/*')) . "'", + 'class' => 'action-back' + )); + + return parent::_prepareLayout(); + } + + /** + * Return preview action url for form + * + * @return string + */ + public function getPreviewUrl() + { + return $this->getUrl('*/*/preview'); + } + + /** + * Retrieve Preview Button HTML + * + * @return string + */ + public function getPreviewButtonHtml() + { + return $this->getChildHtml('preview_button'); + } + + /** + * Retrieve Save Button HTML + * + * @return string + */ + public function getSaveButtonHtml() + { + return $this->getChildHtml('save_button'); + } + + /** + * Retrieve Reset Button HTML + * + * @return string + */ + public function getResetButtonHtml() + { + return $this->getChildHtml('reset_button'); + } + + /** + * Retrieve Back Button HTML + * + * @return string + */ + public function getBackButtonHtml() + { + return $this->getChildHtml('back_button'); + } + + /** + * Retrieve Resume Button HTML + * + * @return string + */ + public function getResumeButtonHtml() + { + return $this->getChildHtml('save_and_resume'); + } + + /** + * Getter for availability preview mode + * + * @return boolean + */ + public function getIsPreview() + { + return !in_array($this->getQueue()->getQueueStatus(), array( + Mage_Newsletter_Model_Queue::STATUS_NEVER, + Mage_Newsletter_Model_Queue::STATUS_PAUSE + )); + } + + /** + * Getter for single store mode check + * + * @return boolean + */ + protected function isSingleStoreMode() + { + return Mage::app()->isSingleStoreMode(); + } + + /** + * Getter for id of current store (the only one in single-store mode and current in multi-stores mode) + * + * @return boolean + */ + protected function getStoreId() + { + return Mage::app()->getStore(true)->getId(); + } + + /** + * Getter for check is this newsletter the plain text. + * + * @return boolean + */ + public function getIsTextType() + { + return $this->getQueue()->isPlain(); + } + + /** + * Getter for availability resume action + * + * @return boolean + */ + public function getCanResume() + { + return in_array($this->getQueue()->getQueueStatus(), array( + Mage_Newsletter_Model_Queue::STATUS_PAUSE + )); + } + + /** + * Getter for header text + * + * @return boolean + */ + public function getHeaderText() + { + return ( $this->getIsPreview() ? Mage::helper('Mage_Newsletter_Helper_Data')->__('View Newsletter') : Mage::helper('Mage_Newsletter_Helper_Data')->__('Edit Newsletter')); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Newsletter/Queue/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/Newsletter/Queue/Edit/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Grid/Renderer/Action.php b/app/code/Mage/Adminhtml/Block/Newsletter/Queue/Grid/Renderer/Action.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Grid/Renderer/Action.php rename to app/code/Mage/Adminhtml/Block/Newsletter/Queue/Grid/Renderer/Action.php diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Preview.php b/app/code/Mage/Adminhtml/Block/Newsletter/Queue/Preview.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Preview.php rename to app/code/Mage/Adminhtml/Block/Newsletter/Queue/Preview.php diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Preview/Form.php b/app/code/Mage/Adminhtml/Block/Newsletter/Queue/Preview/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Preview/Form.php rename to app/code/Mage/Adminhtml/Block/Newsletter/Queue/Preview/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Subscriber.php b/app/code/Mage/Adminhtml/Block/Newsletter/Subscriber.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Newsletter/Subscriber.php rename to app/code/Mage/Adminhtml/Block/Newsletter/Subscriber.php diff --git a/app/code/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid.php b/app/code/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid.php new file mode 100644 index 0000000000000..6bd9fce3204ca --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid.php @@ -0,0 +1,237 @@ + + */ +class Mage_Adminhtml_Block_Newsletter_Subscriber_Grid extends Mage_Adminhtml_Block_Widget_Grid +{ + /** + * Application instance + * + * @var Mage_Core_Model_App + */ + protected $_app; + + /** + * Constructor + * + * Set main configuration of grid + */ + protected function _construct() + { + $this->_app = Mage::app(); + + parent::_construct(); + $this->setId('subscriberGrid'); + $this->setUseAjax(true); + $this->setDefaultSort('subscriber_id', 'desc'); + } + + /** + * Prepare collection for grid + * + * @return Mage_Adminhtml_Block_Widget_Grid + */ + protected function _prepareCollection() + { + $collection = Mage::getResourceSingleton('Mage_Newsletter_Model_Resource_Subscriber_Collection'); + /* @var $collection Mage_Newsletter_Model_Resource_Subscriber_Collection */ + $collection + ->showCustomerInfo(true) + ->addSubscriberTypeField() + ->showStoreInfo(); + + if($this->getRequest()->getParam('queue', false)) { + $collection->useQueue(Mage::getModel('Mage_Newsletter_Model_Queue') + ->load($this->getRequest()->getParam('queue'))); + } + + $this->setCollection($collection); + + return parent::_prepareCollection(); + } + + protected function _prepareColumns() + { + + $this->addColumn('subscriber_id', array( + 'header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('ID'), + 'index' => 'subscriber_id', + 'header_css_class' => 'col-id', + 'column_css_class' => 'col-id' + )); + + $this->addColumn('email', array( + 'header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Email'), + 'index' => 'subscriber_email', + 'header_css_class' => 'col-email', + 'column_css_class' => 'col-email' + )); + + $this->addColumn('type', array( + 'header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Type'), + 'index' => 'type', + 'type' => 'options', + 'options' => array( + 1 => Mage::helper('Mage_Newsletter_Helper_Data')->__('Guest'), + 2 => Mage::helper('Mage_Newsletter_Helper_Data')->__('Customer') + ), + 'header_css_class' => 'col-type', + 'column_css_class' => 'col-type' + )); + + $this->addColumn('firstname', array( + 'header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Customer First Name'), + 'index' => 'customer_firstname', + 'default' => '----', + 'header_css_class' => 'col-first-name', + 'column_css_class' => 'col-first-name' + )); + + $this->addColumn('lastname', array( + 'header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Customer Last Name'), + 'index' => 'customer_lastname', + 'default' => '----', + 'header_css_class' => 'col-last-name', + 'column_css_class' => 'col-last-name' + )); + + $this->addColumn('status', array( + 'header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Status'), + 'index' => 'subscriber_status', + 'type' => 'options', + 'options' => array( + Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE => Mage::helper('Mage_Newsletter_Helper_Data')->__('Not Activated'), + Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED => Mage::helper('Mage_Newsletter_Helper_Data')->__('Subscribed'), + Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED => Mage::helper('Mage_Newsletter_Helper_Data')->__('Unsubscribed'), + Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED => Mage::helper('Mage_Newsletter_Helper_Data')->__('Unconfirmed'), + ), + 'header_css_class' => 'col-status', + 'column_css_class' => 'col-status' + )); + + if (!$this->_app->isSingleStoreMode()) { + $this->addColumn('website', array( + 'header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Website'), + 'index' => 'website_id', + 'type' => 'options', + 'options' => $this->_getWebsiteOptions(), + 'header_css_class' => 'col-website', + 'column_css_class' => 'col-website' + )); + + $this->addColumn('group', array( + 'header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Store'), + 'index' => 'group_id', + 'type' => 'options', + 'options' => $this->_getStoreGroupOptions(), + 'header_css_class' => 'col-store', + 'column_css_class' => 'col-store' + )); + + $this->addColumn('store', array( + 'header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Store View'), + 'index' => 'store_id', + 'type' => 'options', + 'options' => $this->_getStoreOptions(), + 'header_css_class' => 'col-store-view', + 'column_css_class' => 'col-store-view' + )); + } + + $this->addExportType('*/*/exportCsv', Mage::helper('Mage_Customer_Helper_Data')->__('CSV')); + $this->addExportType('*/*/exportXml', Mage::helper('Mage_Customer_Helper_Data')->__('Excel XML')); + return parent::_prepareColumns(); + } + + /** + * Convert OptionsValue array to Options array + * + * @param array $optionsArray + * @return array + */ + protected function _getOptions($optionsArray) + { + $options = array(); + foreach ($optionsArray as $option) { + $options[$option['value']] = $option['label']; + } + return $options; + } + + /** + * Retrieve Website Options array + * + * @return array + */ + protected function _getWebsiteOptions() + { + return Mage::getModel('Mage_Core_Model_System_Store')->getWebsiteOptionHash(); + } + + /** + * Retrieve Store Group Options array + * + * @return array + */ + protected function _getStoreGroupOptions() + { + return Mage::getModel('Mage_Core_Model_System_Store')->getStoreGroupOptionHash(); + } + + /** + * Retrieve Store Options array + * + * @return array + */ + protected function _getStoreOptions() + { + return Mage::getModel('Mage_Core_Model_System_Store')->getStoreOptionHash(); + } + + protected function _prepareMassaction() + { + $this->setMassactionIdField('subscriber_id'); + $this->getMassactionBlock()->setFormFieldName('subscriber'); + + $this->getMassactionBlock()->addItem('unsubscribe', array( + 'label' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Unsubscribe'), + 'url' => $this->getUrl('*/*/massUnsubscribe') + )); + + $this->getMassactionBlock()->addItem('delete', array( + 'label' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Delete'), + 'url' => $this->getUrl('*/*/massDelete') + )); + + return $this; + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid/Filter/Checkbox.php b/app/code/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid/Filter/Checkbox.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid/Filter/Checkbox.php rename to app/code/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid/Filter/Checkbox.php diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid/Filter/Website.php b/app/code/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid/Filter/Website.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid/Filter/Website.php rename to app/code/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid/Filter/Website.php diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid/Renderer/Checkbox.php b/app/code/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid/Renderer/Checkbox.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid/Renderer/Checkbox.php rename to app/code/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid/Renderer/Checkbox.php diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Template.php b/app/code/Mage/Adminhtml/Block/Newsletter/Template.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Newsletter/Template.php rename to app/code/Mage/Adminhtml/Block/Newsletter/Template.php diff --git a/app/code/Mage/Adminhtml/Block/Newsletter/Template/Edit.php b/app/code/Mage/Adminhtml/Block/Newsletter/Template/Edit.php new file mode 100644 index 0000000000000..b80a9c22791f2 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Newsletter/Template/Edit.php @@ -0,0 +1,327 @@ + + */ +class Mage_Adminhtml_Block_Newsletter_Template_Edit extends Mage_Adminhtml_Block_Widget +{ + /** + * Edit Block model + * + * @var bool + */ + protected $_editMode = false; + + /** + * Retrieve template object + * + * @return Mage_Newsletter_Model_Template + */ + public function getModel() + { + return Mage::registry('_current_template'); + } + + /** + * Preparing block layout + * + * @return Mage_Adminhtml_Block_Newsletter_Template_Edit + */ + protected function _prepareLayout() + { + // Load Wysiwyg on demand and Prepare layout + if (Mage::getSingleton('Mage_Cms_Model_Wysiwyg_Config')->isEnabled() && ($block = $this->getLayout()->getBlock('head'))) { + $block->setCanLoadTinyMce(true); + } + + $this->addChild('back_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Back'), + 'onclick' => "window.location.href = '" . $this->getUrl('*/*') . "'", + 'class' => 'action-back' + )); + + $this->addChild('reset_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Reset'), + 'onclick' => 'window.location.href = window.location.href', + 'class' => 'reset' + )); + + $this->addChild('to_plain_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Convert to Plain Text'), + 'onclick' => 'templateControl.stripTags();', + 'id' => 'convert_button', + 'class' => 'convert' + )); + + $this->addChild('to_html_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Return HTML Version'), + 'onclick' => 'templateControl.unStripTags();', + 'id' => 'convert_button_back', + 'style' => 'display:none', + 'class' => 'return' + )); + + $this->addChild('save_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Save Template'), + 'onclick' => 'templateControl.save();', + 'class' => 'save primary' + )); + + $this->addChild('save_as_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Save As'), + 'onclick' => 'templateControl.saveAs();', + 'class' => 'save-as' + )); + + $this->addChild('preview_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Preview Template'), + 'onclick' => 'templateControl.preview();', + 'class' => 'preview' + )); + + $this->addChild('delete_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Delete Template'), + 'onclick' => 'templateControl.deleteTemplate();', + 'class' => 'delete' + )); + + return parent::_prepareLayout(); + } + + /** + * Retrieve Back Button HTML + * + * @return string + */ + public function getBackButtonHtml() + { + return $this->getChildHtml('back_button'); + } + + /** + * Retrieve Reset Button HTML + * + * @return string + */ + public function getResetButtonHtml() + { + return $this->getChildHtml('reset_button'); + } + + /** + * Retrieve Convert To Plain Button HTML + * + * @return string + */ + public function getToPlainButtonHtml() + { + return $this->getChildHtml('to_plain_button'); + } + + /** + * Retrieve Convert to HTML Button HTML + * + * @return string + */ + public function getToHtmlButtonHtml() + { + return $this->getChildHtml('to_html_button'); + } + + /** + * Retrieve Save Button HTML + * + * @return string + */ + public function getSaveButtonHtml() + { + return $this->getChildHtml('save_button'); + } + + /** + * Retrieve Preview Button HTML + * + * @return string + */ + public function getPreviewButtonHtml() + { + return $this->getChildHtml('preview_button'); + } + + /** + * Retrieve Delete Button HTML + * + * @return string + */ + public function getDeleteButtonHtml() + { + return $this->getChildHtml('delete_button'); + } + + /** + * Retrieve Save as Button HTML + * + * @return string + */ + public function getSaveAsButtonHtml() + { + return $this->getChildHtml('save_as_button'); + } + + /** + * Set edit flag for block + * + * @param boolean $value + * @return Mage_Adminhtml_Block_Newsletter_Template_Edit + */ + public function setEditMode($value = true) + { + $this->_editMode = (bool)$value; + return $this; + } + + /** + * Return edit flag for block + * + * @return boolean + */ + public function getEditMode() + { + return $this->_editMode; + } + + /** + * Return header text for form + * + * @return string + */ + public function getHeaderText() + { + if ($this->getEditMode()) { + return Mage::helper('Mage_Newsletter_Helper_Data')->__('Edit Newsletter Template'); + } + + return Mage::helper('Mage_Newsletter_Helper_Data')->__('New Newsletter Template'); + } + + /** + * Return form block HTML + * + * @return string + */ + public function getForm() + { + return $this->getLayout() + ->createBlock('Mage_Adminhtml_Block_Newsletter_Template_Edit_Form') + ->toHtml(); + } + + /** + * Return return template name for JS + * + * @return string + */ + public function getJsTemplateName() + { + return addcslashes($this->getModel()->getTemplateCode(), "\"\r\n\\"); + } + + /** + * Return action url for form + * + * @return string + */ + public function getSaveUrl() + { + return $this->getUrl('*/*/save'); + } + + /** + * Return preview action url for form + * + * @return string + */ + public function getPreviewUrl() + { + return $this->getUrl('*/*/preview'); + } + + /** + * Check Template Type is Plain Text + * + * @return bool + */ + public function isTextType() + { + return $this->getModel()->isPlain(); + } + + /** + * Return delete url for customer group + * + * @return string + */ + public function getDeleteUrl() + { + return $this->getUrl('*/*/delete', array('id' => $this->getRequest()->getParam('id'))); + } + + /** + * Retrieve Save As Flag + * + * @return int + */ + public function getSaveAsFlag() + { + return $this->getRequest()->getParam('_save_as_flag') ? '1' : ''; + } + + /** + * Getter for single store mode check + * + * @return boolean + */ + protected function isSingleStoreMode() + { + return Mage::app()->isSingleStoreMode(); + } + + /** + * Getter for id of current store (the only one in single-store mode and current in multi-stores mode) + * + * @return boolean + */ + protected function getStoreId() + { + return Mage::app()->getStore(true)->getId(); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Newsletter/Template/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/Newsletter/Template/Edit/Form.php diff --git a/app/code/Mage/Adminhtml/Block/Newsletter/Template/Grid.php b/app/code/Mage/Adminhtml/Block/Newsletter/Template/Grid.php new file mode 100644 index 0000000000000..21336ffa0bfbe --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Newsletter/Template/Grid.php @@ -0,0 +1,139 @@ + + */ +class Mage_Adminhtml_Block_Newsletter_Template_Grid extends Mage_Adminhtml_Block_Widget_Grid +{ + protected function _construct() + { + $this->setEmptyText(Mage::helper('Mage_Newsletter_Helper_Data')->__('No Templates Found')); + } + + protected function _prepareCollection() + { + $collection = Mage::getResourceSingleton('Mage_Newsletter_Model_Resource_Template_Collection') + ->useOnlyActual(); + + $this->setCollection($collection); + + return parent::_prepareCollection(); + } + + protected function _prepareColumns() + { + $this->addColumn('template_code', + array( + 'header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('ID'), + 'index' => 'template_id', + 'header_css_class' => 'col-id', + 'column_css_class' => 'col-id' + )); + $this->addColumn('code', + array( + 'header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Template Name'), + 'index' => 'template_code', + 'header_css_class' => 'col-template', + 'column_css_class' => 'col-template' + )); + + $this->addColumn('added_at', + array( + 'header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Date Added'), + 'index' => 'added_at', + 'gmtoffset' => true, + 'type' => 'datetime', + 'header_css_class' => 'col-added', + 'column_css_class' => 'col-added' + )); + + $this->addColumn('modified_at', + array( + 'header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Date Updated'), + 'index' => 'modified_at', + 'gmtoffset' => true, + 'type' => 'datetime', + 'header_css_class' => 'col-updated', + 'column_css_class' => 'col-updated' + )); + + $this->addColumn('subject', + array( + 'header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Subject'), + 'index' => 'template_subject', + 'header_css_class' => 'col-subject', + 'column_css_class' => 'col-subject' + )); + + $this->addColumn('sender', + array( + 'header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Sender'), + 'index' => 'template_sender_email', + 'renderer' => 'Mage_Adminhtml_Block_Newsletter_Template_Grid_Renderer_Sender', + 'header_css_class' => 'col-sender', + 'column_css_class' => 'col-sender' + )); + + $this->addColumn('type', + array( + 'header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Template Type'), + 'index' => 'template_type', + 'type' => 'options', + 'options' => array( + Mage_Newsletter_Model_Template::TYPE_HTML => 'html', + Mage_Newsletter_Model_Template::TYPE_TEXT => 'text' + ), + 'header_css_class' => 'col-type', + 'column_css_class' => 'col-type' + )); + + $this->addColumn('action', + array( + 'header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Action'), + 'index' => 'template_id', + 'sortable' => false, + 'filter' => false, + 'no_link' => true, + 'renderer' => 'Mage_Adminhtml_Block_Newsletter_Template_Grid_Renderer_Action', + 'header_css_class' => 'col-actions', + 'column_css_class' => 'col-actions' + )); + + return $this; + } + + public function getRowUrl($row) + { + return $this->getUrl('*/*/edit', array('id'=>$row->getId())); + } + +} + diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Grid/Renderer/Action.php b/app/code/Mage/Adminhtml/Block/Newsletter/Template/Grid/Renderer/Action.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Grid/Renderer/Action.php rename to app/code/Mage/Adminhtml/Block/Newsletter/Template/Grid/Renderer/Action.php diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Grid/Renderer/Sender.php b/app/code/Mage/Adminhtml/Block/Newsletter/Template/Grid/Renderer/Sender.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Grid/Renderer/Sender.php rename to app/code/Mage/Adminhtml/Block/Newsletter/Template/Grid/Renderer/Sender.php diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Preview.php b/app/code/Mage/Adminhtml/Block/Newsletter/Template/Preview.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Preview.php rename to app/code/Mage/Adminhtml/Block/Newsletter/Template/Preview.php diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Preview/Form.php b/app/code/Mage/Adminhtml/Block/Newsletter/Template/Preview/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Preview/Form.php rename to app/code/Mage/Adminhtml/Block/Newsletter/Template/Preview/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Notification/Baseurl.php b/app/code/Mage/Adminhtml/Block/Notification/Baseurl.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Notification/Baseurl.php rename to app/code/Mage/Adminhtml/Block/Notification/Baseurl.php diff --git a/app/code/core/Mage/Adminhtml/Block/Notification/Grid.php b/app/code/Mage/Adminhtml/Block/Notification/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Notification/Grid.php rename to app/code/Mage/Adminhtml/Block/Notification/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Notification/Grid/Renderer/Actions.php b/app/code/Mage/Adminhtml/Block/Notification/Grid/Renderer/Actions.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Notification/Grid/Renderer/Actions.php rename to app/code/Mage/Adminhtml/Block/Notification/Grid/Renderer/Actions.php diff --git a/app/code/core/Mage/Adminhtml/Block/Notification/Grid/Renderer/Notice.php b/app/code/Mage/Adminhtml/Block/Notification/Grid/Renderer/Notice.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Notification/Grid/Renderer/Notice.php rename to app/code/Mage/Adminhtml/Block/Notification/Grid/Renderer/Notice.php diff --git a/app/code/core/Mage/Adminhtml/Block/Notification/Grid/Renderer/Severity.php b/app/code/Mage/Adminhtml/Block/Notification/Grid/Renderer/Severity.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Notification/Grid/Renderer/Severity.php rename to app/code/Mage/Adminhtml/Block/Notification/Grid/Renderer/Severity.php diff --git a/app/code/core/Mage/Adminhtml/Block/Notification/Inbox.php b/app/code/Mage/Adminhtml/Block/Notification/Inbox.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Notification/Inbox.php rename to app/code/Mage/Adminhtml/Block/Notification/Inbox.php diff --git a/app/code/core/Mage/Adminhtml/Block/Notification/Security.php b/app/code/Mage/Adminhtml/Block/Notification/Security.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Notification/Security.php rename to app/code/Mage/Adminhtml/Block/Notification/Security.php diff --git a/app/code/core/Mage/Adminhtml/Block/Notification/Survey.php b/app/code/Mage/Adminhtml/Block/Notification/Survey.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Notification/Survey.php rename to app/code/Mage/Adminhtml/Block/Notification/Survey.php diff --git a/app/code/core/Mage/Adminhtml/Block/Notification/Toolbar.php b/app/code/Mage/Adminhtml/Block/Notification/Toolbar.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Notification/Toolbar.php rename to app/code/Mage/Adminhtml/Block/Notification/Toolbar.php diff --git a/app/code/core/Mage/Adminhtml/Block/Notification/Window.php b/app/code/Mage/Adminhtml/Block/Notification/Window.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Notification/Window.php rename to app/code/Mage/Adminhtml/Block/Notification/Window.php diff --git a/app/code/core/Mage/Adminhtml/Block/Page.php b/app/code/Mage/Adminhtml/Block/Page.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Page.php rename to app/code/Mage/Adminhtml/Block/Page.php diff --git a/app/code/core/Mage/Adminhtml/Block/Page/Footer.php b/app/code/Mage/Adminhtml/Block/Page/Footer.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Page/Footer.php rename to app/code/Mage/Adminhtml/Block/Page/Footer.php diff --git a/app/code/Mage/Adminhtml/Block/Page/Head.php b/app/code/Mage/Adminhtml/Block/Page/Head.php new file mode 100644 index 0000000000000..177241055b120 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Page/Head.php @@ -0,0 +1,47 @@ + + */ +class Mage_Adminhtml_Block_Page_Head extends Mage_Page_Block_Html_Head +{ + protected $_template = 'page/head.phtml'; + + /** + * Retrieve Session Form Key + * + * @return string + */ + public function getFormKey() + { + return Mage::getSingleton('Mage_Core_Model_Session')->getFormKey(); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Page/Header.php b/app/code/Mage/Adminhtml/Block/Page/Header.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Page/Header.php rename to app/code/Mage/Adminhtml/Block/Page/Header.php diff --git a/app/code/core/Mage/Adminhtml/Block/Page/Notices.php b/app/code/Mage/Adminhtml/Block/Page/Notices.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Page/Notices.php rename to app/code/Mage/Adminhtml/Block/Page/Notices.php diff --git a/app/code/core/Mage/Adminhtml/Block/Page/System/Config/Robots/Reset.php b/app/code/Mage/Adminhtml/Block/Page/System/Config/Robots/Reset.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Page/System/Config/Robots/Reset.php rename to app/code/Mage/Adminhtml/Block/Page/System/Config/Robots/Reset.php diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Answer/Edit.php b/app/code/Mage/Adminhtml/Block/Poll/Answer/Edit.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Poll/Answer/Edit.php rename to app/code/Mage/Adminhtml/Block/Poll/Answer/Edit.php diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Answer/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Poll/Answer/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Poll/Answer/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/Poll/Answer/Edit/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Edit.php b/app/code/Mage/Adminhtml/Block/Poll/Edit.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Poll/Edit.php rename to app/code/Mage/Adminhtml/Block/Poll/Edit.php diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Poll/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Poll/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/Poll/Edit/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers.php b/app/code/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers.php rename to app/code/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers.php diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/Form.php b/app/code/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/Form.php rename to app/code/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/Grid.php b/app/code/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/Grid.php rename to app/code/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/List.php b/app/code/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/List.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/List.php rename to app/code/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/List.php diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Form.php b/app/code/Mage/Adminhtml/Block/Poll/Edit/Tab/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Form.php rename to app/code/Mage/Adminhtml/Block/Poll/Edit/Tab/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tabs.php b/app/code/Mage/Adminhtml/Block/Poll/Edit/Tabs.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tabs.php rename to app/code/Mage/Adminhtml/Block/Poll/Edit/Tabs.php diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Grid.php b/app/code/Mage/Adminhtml/Block/Poll/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Poll/Grid.php rename to app/code/Mage/Adminhtml/Block/Poll/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Poll.php b/app/code/Mage/Adminhtml/Block/Poll/Poll.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Poll/Poll.php rename to app/code/Mage/Adminhtml/Block/Poll/Poll.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Catalog.php b/app/code/Mage/Adminhtml/Block/Promo/Catalog.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Catalog.php rename to app/code/Mage/Adminhtml/Block/Promo/Catalog.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit.php b/app/code/Mage/Adminhtml/Block/Promo/Catalog/Edit.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit.php rename to app/code/Mage/Adminhtml/Block/Promo/Catalog/Edit.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Promo/Catalog/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/Promo/Catalog/Edit/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit/Js.php b/app/code/Mage/Adminhtml/Block/Promo/Catalog/Edit/Js.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit/Js.php rename to app/code/Mage/Adminhtml/Block/Promo/Catalog/Edit/Js.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tab/Actions.php b/app/code/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tab/Actions.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tab/Actions.php rename to app/code/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tab/Actions.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tab/Conditions.php b/app/code/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tab/Conditions.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tab/Conditions.php rename to app/code/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tab/Conditions.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tab/Main.php b/app/code/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tab/Main.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tab/Main.php rename to app/code/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tab/Main.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tabs.php b/app/code/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tabs.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tabs.php rename to app/code/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tabs.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Grid.php b/app/code/Mage/Adminhtml/Block/Promo/Catalog/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Grid.php rename to app/code/Mage/Adminhtml/Block/Promo/Catalog/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Quote.php b/app/code/Mage/Adminhtml/Block/Promo/Quote.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Quote.php rename to app/code/Mage/Adminhtml/Block/Promo/Quote.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit.php b/app/code/Mage/Adminhtml/Block/Promo/Quote/Edit.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit.php rename to app/code/Mage/Adminhtml/Block/Promo/Quote/Edit.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Actions.php b/app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Actions.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Actions.php rename to app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Actions.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Conditions.php b/app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Conditions.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Conditions.php rename to app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Conditions.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons.php b/app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons.php rename to app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Form.php b/app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Form.php rename to app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Grid.php b/app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Grid.php rename to app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Grid/Column/Renderer/Used.php b/app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Grid/Column/Renderer/Used.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Grid/Column/Renderer/Used.php rename to app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Grid/Column/Renderer/Used.php diff --git a/app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Labels.php b/app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Labels.php new file mode 100644 index 0000000000000..75a79610b41ec --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Labels.php @@ -0,0 +1,166 @@ +_storeManager = $storeManager; + parent::__construct($context, $data); + } + + /** + * Prepare content for tab + * + * @return string + */ + public function getTabLabel() + { + return Mage::helper('Mage_SalesRule_Helper_Data')->__('Labels'); + } + + /** + * Prepare title for tab + * + * @return string + */ + public function getTabTitle() + { + return Mage::helper('Mage_SalesRule_Helper_Data')->__('Labels'); + } + + /** + * Returns status flag about this tab can be showen or not + * + * @return bool + */ + public function canShowTab() + { + return true; + } + + /** + * Returns status flag about this tab hidden or not + * + * @return bool + */ + public function isHidden() + { + return false; + } + + protected function _prepareForm() + { + $rule = Mage::registry('current_promo_quote_rule'); + $form = new Varien_Data_Form(); + $form->setHtmlIdPrefix('rule_'); + + $fieldset = $form->addFieldset('default_label_fieldset', array( + 'legend' => Mage::helper('Mage_SalesRule_Helper_Data')->__('Default Label') + )); + $labels = $rule->getStoreLabels(); + + $fieldset->addField('store_default_label', 'text', array( + 'name' => 'store_labels[0]', + 'required' => false, + 'label' => Mage::helper('Mage_SalesRule_Helper_Data')->__('Default Rule Label for All Store Views'), + 'value' => isset($labels[0]) ? $labels[0] : '', + )); + + if (!$this->_storeManager->isSingleStoreMode()) { + $fieldset = $this->_createStoreSpecificFieldset($form, $labels); + } + + if ($rule->isReadonly()) { + foreach ($fieldset->getElements() as $element) { + $element->setReadonly(true, true); + } + } + + $this->setForm($form); + return parent::_prepareForm(); + } + + /** + * Create store specific fieldset + * + * @param Varien_Data_Form $form + * @param array $labels + * @return Varien_Data_Form_Element_Fieldset mixed + */ + protected function _createStoreSpecificFieldset($form, $labels) + { + $fieldset = $form->addFieldset('store_labels_fieldset', array( + 'legend' => Mage::helper('Mage_SalesRule_Helper_Data')->__('Store View Specific Labels'), + 'table_class' => 'form-list stores-tree', + )); + $renderer = $this->getLayout()->createBlock('Mage_Backend_Block_Store_Switcher_Form_Renderer_Fieldset'); + $fieldset->setRenderer($renderer); + + foreach (Mage::app()->getWebsites() as $website) { + $fieldset->addField("w_{$website->getId()}_label", 'note', array( + 'label' => $website->getName(), + 'fieldset_html_class' => 'website', + )); + foreach ($website->getGroups() as $group) { + $stores = $group->getStores(); + if (count($stores) == 0) { + continue; + } + $fieldset->addField("sg_{$group->getId()}_label", 'note', array( + 'label' => $group->getName(), + 'fieldset_html_class' => 'store-group', + )); + foreach ($stores as $store) { + $fieldset->addField("s_{$store->getId()}", 'text', array( + 'name' => 'store_labels[' . $store->getId() . ']', + 'required' => false, + 'label' => $store->getName(), + 'value' => isset($labels[$store->getId()]) ? $labels[$store->getId()] : '', + 'fieldset_html_class' => 'store', + )); + } + } + } + return $fieldset; + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Main.php b/app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Main.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Main.php rename to app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Main.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Main/Renderer/Checkbox.php b/app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Main/Renderer/Checkbox.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Main/Renderer/Checkbox.php rename to app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Main/Renderer/Checkbox.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tabs.php b/app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Tabs.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tabs.php rename to app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Tabs.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Grid.php b/app/code/Mage/Adminhtml/Block/Promo/Quote/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Quote/Grid.php rename to app/code/Mage/Adminhtml/Block/Promo/Quote/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Widget/Chooser.php b/app/code/Mage/Adminhtml/Block/Promo/Widget/Chooser.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Widget/Chooser.php rename to app/code/Mage/Adminhtml/Block/Promo/Widget/Chooser.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Widget/Chooser/Daterange.php b/app/code/Mage/Adminhtml/Block/Promo/Widget/Chooser/Daterange.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Widget/Chooser/Daterange.php rename to app/code/Mage/Adminhtml/Block/Promo/Widget/Chooser/Daterange.php diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Widget/Chooser/Sku.php b/app/code/Mage/Adminhtml/Block/Promo/Widget/Chooser/Sku.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Promo/Widget/Chooser/Sku.php rename to app/code/Mage/Adminhtml/Block/Promo/Widget/Chooser/Sku.php diff --git a/app/code/core/Mage/Adminhtml/Block/Rating/Edit.php b/app/code/Mage/Adminhtml/Block/Rating/Edit.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Rating/Edit.php rename to app/code/Mage/Adminhtml/Block/Rating/Edit.php diff --git a/app/code/core/Mage/Adminhtml/Block/Rating/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Rating/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Rating/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/Rating/Edit/Form.php diff --git a/app/code/Mage/Adminhtml/Block/Rating/Edit/Tab/Form.php b/app/code/Mage/Adminhtml/Block/Rating/Edit/Tab/Form.php new file mode 100644 index 0000000000000..6a81fce0765de --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Rating/Edit/Tab/Form.php @@ -0,0 +1,190 @@ + + */ + +class Mage_Adminhtml_Block_Rating_Edit_Tab_Form extends Mage_Backend_Block_Widget_Form +{ + /** + * Store manager instance + * + * @var Mage_Core_Model_StoreManager + */ + protected $_storeManager; + + /** + * @param Mage_Core_Block_Template_Context $context + * @param Mage_Core_Model_StoreManager $storeManager + * @param array $data + */ + public function __construct( + Mage_Core_Block_Template_Context $context, + Mage_Core_Model_StoreManager $storeManager, + array $data = array() + ) { + $this->_storeManager = $storeManager; + parent::__construct($context, $data); + } + + + /** + * Prepare rating edit form + * + * @return Mage_Adminhtml_Block_Rating_Edit_Tab_Form + */ + protected function _prepareForm() + { + $form = new Varien_Data_Form(); + $this->setForm($form); + + $fieldset = $form->addFieldset('rating_form', array( + 'legend'=>Mage::helper('Mage_Rating_Helper_Data')->__('Rating Title') + )); + + $fieldset->addField('rating_code', 'text', array( + 'name' => 'rating_code', + 'label' => Mage::helper('Mage_Rating_Helper_Data')->__('Default Value'), + 'class' => 'required-entry', + 'required' => true, + )); + + foreach (Mage::getSingleton('Mage_Core_Model_System_Store')->getStoreCollection() as $store) { + $fieldset->addField('rating_code_' . $store->getId(), 'text', array( + 'label' => $store->getName(), + 'name' => 'rating_codes[' . $store->getId() . ']', + )); + } + + if (Mage::getSingleton('Mage_Adminhtml_Model_Session')->getRatingData()) { + $form->setValues(Mage::getSingleton('Mage_Adminhtml_Model_Session')->getRatingData()); + $data = Mage::getSingleton('Mage_Adminhtml_Model_Session')->getRatingData(); + if (isset($data['rating_codes'])) { + $this->_setRatingCodes($data['rating_codes']); + } + Mage::getSingleton('Mage_Adminhtml_Model_Session')->setRatingData(null); + } elseif (Mage::registry('rating_data')) { + $form->setValues(Mage::registry('rating_data')->getData()); + if (Mage::registry('rating_data')->getRatingCodes()) { + $this->_setRatingCodes(Mage::registry('rating_data')->getRatingCodes()); + } + } + + if (Mage::registry('rating_data')) { + $collection = Mage::getModel('Mage_Rating_Model_Rating_Option') + ->getResourceCollection() + ->addRatingFilter(Mage::registry('rating_data')->getId()) + ->load(); + + $i = 1; + foreach ($collection->getItems() as $item) { + $fieldset->addField('option_code_' . $item->getId() , 'hidden', array( + 'required' => true, + 'name' => 'option_title[' . $item->getId() . ']', + 'value' => ($item->getCode()) ? $item->getCode() : $i, + )); + + $i ++; + } + } else { + for ($i = 1; $i <= 5; $i++) { + $fieldset->addField('option_code_' . $i, 'hidden', array( + 'required' => true, + 'name' => 'option_title[add_' . $i . ']', + 'value' => $i, + )); + } + } + + $fieldset = $form->addFieldset('visibility_form', array( + 'legend' => Mage::helper('Mage_Rating_Helper_Data')->__('Rating Visibility') + )); + if (!$this->_storeManager->isSingleStoreMode()) { + $field = $fieldset->addField('stores', 'multiselect', array( + 'label' => Mage::helper('Mage_Rating_Helper_Data')->__('Visible In'), + 'name' => 'stores[]', + 'values' => Mage::getSingleton('Mage_Core_Model_System_Store')->getStoreValuesForForm(), + )); + $renderer = $this->getLayout()->createBlock('Mage_Backend_Block_Store_Switcher_Form_Renderer_Fieldset_Element'); + $field->setRenderer($renderer); + + if (Mage::registry('rating_data')) { + $form->getElement('stores')->setValue(Mage::registry('rating_data')->getStores()); + } + } + + $fieldset->addField('is_active', 'checkbox', array( + 'label' => Mage::helper('Mage_Rating_Helper_Data')->__('Is Active'), + 'name' => 'is_active', + 'value' => 1, + )); + + $fieldset->addField('position', 'text', array( + 'label' => Mage::helper('Mage_Rating_Helper_Data')->__('Sort Order'), + 'name' => 'position', + )); + + if (Mage::registry('rating_data')) { + $form->getElement('position')->setValue(Mage::registry('rating_data')->getPosition()); + $form->getElement('is_active')->setIsChecked(Mage::registry('rating_data')->getIsActive()); + } + + return parent::_prepareForm(); + } + + protected function _setRatingCodes($ratingCodes) { + foreach($ratingCodes as $store=>$value) { + if($element = $this->getForm()->getElement('rating_code_' . $store)) { + $element->setValue($value); + } + } + } + + protected function _toHtml() + { + return $this->_getWarningHtml() . parent::_toHtml(); + } + + protected function _getWarningHtml() + { + return '
+ +
'; + } + + +} diff --git a/app/code/core/Mage/Adminhtml/Block/Rating/Edit/Tab/Options.php b/app/code/Mage/Adminhtml/Block/Rating/Edit/Tab/Options.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Rating/Edit/Tab/Options.php rename to app/code/Mage/Adminhtml/Block/Rating/Edit/Tab/Options.php diff --git a/app/code/core/Mage/Adminhtml/Block/Rating/Edit/Tabs.php b/app/code/Mage/Adminhtml/Block/Rating/Edit/Tabs.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Rating/Edit/Tabs.php rename to app/code/Mage/Adminhtml/Block/Rating/Edit/Tabs.php diff --git a/app/code/core/Mage/Adminhtml/Block/Rating/Rating.php b/app/code/Mage/Adminhtml/Block/Rating/Rating.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Rating/Rating.php rename to app/code/Mage/Adminhtml/Block/Rating/Rating.php diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Config/Form/Field/MtdStart.php b/app/code/Mage/Adminhtml/Block/Report/Config/Form/Field/MtdStart.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Config/Form/Field/MtdStart.php rename to app/code/Mage/Adminhtml/Block/Report/Config/Form/Field/MtdStart.php diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Config/Form/Field/YtdStart.php b/app/code/Mage/Adminhtml/Block/Report/Config/Form/Field/YtdStart.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Config/Form/Field/YtdStart.php rename to app/code/Mage/Adminhtml/Block/Report/Config/Form/Field/YtdStart.php diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Filter/Form.php b/app/code/Mage/Adminhtml/Block/Report/Filter/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Filter/Form.php rename to app/code/Mage/Adminhtml/Block/Report/Filter/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php b/app/code/Mage/Adminhtml/Block/Report/Grid/Abstract.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php rename to app/code/Mage/Adminhtml/Block/Report/Grid/Abstract.php diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Grid/Column/Renderer/Blanknumber.php b/app/code/Mage/Adminhtml/Block/Report/Grid/Column/Renderer/Blanknumber.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Grid/Column/Renderer/Blanknumber.php rename to app/code/Mage/Adminhtml/Block/Report/Grid/Column/Renderer/Blanknumber.php diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Grid/Column/Renderer/Currency.php b/app/code/Mage/Adminhtml/Block/Report/Grid/Column/Renderer/Currency.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Grid/Column/Renderer/Currency.php rename to app/code/Mage/Adminhtml/Block/Report/Grid/Column/Renderer/Currency.php diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Grid/Column/Renderer/Customer.php b/app/code/Mage/Adminhtml/Block/Report/Grid/Column/Renderer/Customer.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Grid/Column/Renderer/Customer.php rename to app/code/Mage/Adminhtml/Block/Report/Grid/Column/Renderer/Customer.php diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Grid/Column/Renderer/Product.php b/app/code/Mage/Adminhtml/Block/Report/Grid/Column/Renderer/Product.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Grid/Column/Renderer/Product.php rename to app/code/Mage/Adminhtml/Block/Report/Grid/Column/Renderer/Product.php diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Grid/Shopcart.php b/app/code/Mage/Adminhtml/Block/Report/Grid/Shopcart.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Grid/Shopcart.php rename to app/code/Mage/Adminhtml/Block/Report/Grid/Shopcart.php diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Product.php b/app/code/Mage/Adminhtml/Block/Report/Product.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Product.php rename to app/code/Mage/Adminhtml/Block/Report/Product.php diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Product/Downloads.php b/app/code/Mage/Adminhtml/Block/Report/Product/Downloads.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Product/Downloads.php rename to app/code/Mage/Adminhtml/Block/Report/Product/Downloads.php diff --git a/app/code/Mage/Adminhtml/Block/Report/Product/Downloads/Grid.php b/app/code/Mage/Adminhtml/Block/Report/Product/Downloads/Grid.php new file mode 100644 index 0000000000000..9b558e7e2ce89 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Report/Product/Downloads/Grid.php @@ -0,0 +1,122 @@ + + */ +class Mage_Adminhtml_Block_Report_Product_Downloads_Grid extends Mage_Adminhtml_Block_Widget_Grid +{ + protected function _construct() + { + parent::_construct(); + $this->setId('downloadsGrid'); + $this->setUseAjax(false); + } + + protected function _prepareCollection() + { + if ($this->getRequest()->getParam('website')) { + $storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds(); + $storeId = array_pop($storeIds); + } else if ($this->getRequest()->getParam('group')) { + $storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds(); + $storeId = array_pop($storeIds); + } else if ($this->getRequest()->getParam('store')) { + $storeId = (int)$this->getRequest()->getParam('store'); + } else { + $storeId = ''; + } + + $collection = Mage::getResourceModel('Mage_Reports_Model_Resource_Product_Downloads_Collection') + ->addAttributeToSelect('*') + ->setStoreId($storeId) + ->addAttributeToFilter('type_id', array(Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE)) + ->addSummary(); + + if( $storeId ) { + $collection->addStoreFilter($storeId); + } + + $this->setCollection($collection); + return parent::_prepareCollection(); + } + + protected function _prepareColumns() + { + $this->addColumn('name', array( + 'header' => Mage::helper('Mage_Reports_Helper_Data')->__('Product Name'), + 'index' => 'name', + 'header_css_class' => 'col-product', + 'column_css_class' => 'col-product' + )); + + $this->addColumn('link_title', array( + 'header' => Mage::helper('Mage_Reports_Helper_Data')->__('Link'), + 'index' => 'link_title', + 'header_css_class' => 'col-link', + 'column_css_class' => 'col-link' + )); + + $this->addColumn('sku', array( + 'header' =>Mage::helper('Mage_Reports_Helper_Data')->__('Product SKU'), + 'index' =>'sku', + 'header_css_class' => 'col-sku', + 'column_css_class' => 'col-sku' + )); + + $this->addColumn('purchases', array( + 'header' => Mage::helper('Mage_Reports_Helper_Data')->__('Purchases'), + 'width' => '215px', + 'align' => 'right', + 'filter' => false, + 'index' => 'purchases', + 'type' => 'number', + 'renderer' => 'Mage_Adminhtml_Block_Report_Product_Downloads_Renderer_Purchases', + 'header_css_class' => 'col-purchases', + 'column_css_class' => 'col-purchases' + )); + + $this->addColumn('downloads', array( + 'header' => Mage::helper('Mage_Reports_Helper_Data')->__('Downloads'), + 'width' => '215px', + 'align' => 'right', + 'filter' => false, + 'index' => 'downloads', + 'type' => 'number', + 'header_css_class' => 'col-qty', + 'column_css_class' => 'col-qty' + )); + + $this->addExportType('*/*/exportDownloadsCsv', Mage::helper('Mage_Reports_Helper_Data')->__('CSV')); + $this->addExportType('*/*/exportDownloadsExcel', Mage::helper('Mage_Reports_Helper_Data')->__('Excel XML')); + + return parent::_prepareColumns(); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Product/Downloads/Renderer/Purchases.php b/app/code/Mage/Adminhtml/Block/Report/Product/Downloads/Renderer/Purchases.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Product/Downloads/Renderer/Purchases.php rename to app/code/Mage/Adminhtml/Block/Report/Product/Downloads/Renderer/Purchases.php diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Product/Grid.php b/app/code/Mage/Adminhtml/Block/Report/Product/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Product/Grid.php rename to app/code/Mage/Adminhtml/Block/Report/Product/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Product/Lowstock.php b/app/code/Mage/Adminhtml/Block/Report/Product/Lowstock.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Product/Lowstock.php rename to app/code/Mage/Adminhtml/Block/Report/Product/Lowstock.php diff --git a/app/code/Mage/Adminhtml/Block/Report/Product/Lowstock/Grid.php b/app/code/Mage/Adminhtml/Block/Report/Product/Lowstock/Grid.php new file mode 100644 index 0000000000000..18b091089b663 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Report/Product/Lowstock/Grid.php @@ -0,0 +1,110 @@ + + */ +class Mage_Adminhtml_Block_Report_Product_Lowstock_Grid extends Mage_Adminhtml_Block_Widget_Grid +{ +// protected $_saveParametersInSession = true; + + protected function _construct() + { + parent::_construct(); + $this->setId('gridLowstock'); + $this->setUseAjax(false); + } + + protected function _prepareCollection() + { + if ($this->getRequest()->getParam('website')) { + $storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds(); + $storeId = array_pop($storeIds); + } else if ($this->getRequest()->getParam('group')) { + $storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds(); + $storeId = array_pop($storeIds); + } else if ($this->getRequest()->getParam('store')) { + $storeId = (int)$this->getRequest()->getParam('store'); + } else { + $storeId = ''; + } + + /** @var $collection Mage_Reports_Model_Resource_Product_Lowstock_Collection */ + $collection = Mage::getResourceModel('Mage_Reports_Model_Resource_Product_Lowstock_Collection') + ->addAttributeToSelect('*') + ->setStoreId($storeId) + ->filterByIsQtyProductTypes() + ->joinInventoryItem('qty') + ->useManageStockFilter($storeId) + ->useNotifyStockQtyFilter($storeId) + ->setOrder('qty', Varien_Data_Collection::SORT_ORDER_ASC); + + if( $storeId ) { + $collection->addStoreFilter($storeId); + } + + $this->setCollection($collection); + return parent::_prepareCollection(); + } + + protected function _prepareColumns() + { + $this->addColumn('name', array( + 'header' =>Mage::helper('Mage_Reports_Helper_Data')->__('Product Name'), + 'sortable' =>false, + 'index' =>'name', + 'header_css_class' => 'col-product', + 'column_css_class' => 'col-product' + )); + + $this->addColumn('sku', array( + 'header' =>Mage::helper('Mage_Reports_Helper_Data')->__('Product SKU'), + 'sortable' =>false, + 'index' =>'sku', + 'header_css_class' => 'col-sku', + 'column_css_class' => 'col-sku' + )); + + $this->addColumn('qty', array( + 'header' =>Mage::helper('Mage_Reports_Helper_Data')->__('Stock Qty'), + 'sortable' =>false, + 'filter' =>'Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Range', + 'index' =>'qty', + 'type' =>'number', + 'header_css_class' => 'col-qty', + 'column_css_class' => 'col-qty' + )); + + $this->addExportType('*/*/exportLowstockCsv', Mage::helper('Mage_Reports_Helper_Data')->__('CSV')); + $this->addExportType('*/*/exportLowstockExcel', Mage::helper('Mage_Reports_Helper_Data')->__('Excel XML')); + + return parent::_prepareColumns(); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Product/Viewed.php b/app/code/Mage/Adminhtml/Block/Report/Product/Viewed.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Product/Viewed.php rename to app/code/Mage/Adminhtml/Block/Report/Product/Viewed.php diff --git a/app/code/Mage/Adminhtml/Block/Report/Product/Viewed/Grid.php b/app/code/Mage/Adminhtml/Block/Report/Product/Viewed/Grid.php new file mode 100644 index 0000000000000..4dcedf48b6133 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Report/Product/Viewed/Grid.php @@ -0,0 +1,132 @@ + + */ +class Mage_Adminhtml_Block_Report_Product_Viewed_Grid extends Mage_Adminhtml_Block_Report_Grid_Abstract +{ + /** + * Column for grid to be grouped by + * + * @var string + */ + protected $_columnGroupBy = 'period'; + + /** + * Grid resource collection name + * + * @var string + */ + protected $_resourceCollectionName = 'Mage_Reports_Model_Resource_Report_Product_Viewed_Collection'; + + /** + * Init grid parameters + */ + protected function _construct() + { + parent::_construct(); + $this->setCountTotals(true); + } + + /** + * Custom columns preparation + * + * @return Mage_Adminhtml_Block_Widget_Grid + */ + protected function _prepareColumns() + { + $this->addColumn('period', array( + 'header' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Period'), + 'index' => 'period', + 'width' => 100, + 'sortable' => false, + 'period_type' => $this->getPeriodType(), + 'renderer' => 'Mage_Adminhtml_Block_Report_Sales_Grid_Column_Renderer_Date', + 'totals_label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Total'), + 'html_decorators' => array('nobr'), + 'header_css_class' => 'col-period', + 'column_css_class' => 'col-period' + )); + + $this->addColumn('product_name', array( + 'header' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Product Name'), + 'index' => 'product_name', + 'type' => 'string', + 'sortable' => false, + 'header_css_class' => 'col-name', + 'column_css_class' => 'col-name' + )); + + if ($this->getFilterData()->getStoreIds()) { + $this->setStoreIds(explode(',', $this->getFilterData()->getStoreIds())); + } + $currencyCode = $this->getCurrentCurrencyCode(); + + $this->addColumn('product_price', array( + 'header' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Price'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'product_price', + 'sortable' => false, + 'rate' => $this->getRate($currencyCode), + 'header_css_class' => 'col-price', + 'column_css_class' => 'col-price' + )); + + $this->addColumn('views_num', array( + 'header' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Number of Views'), + 'index' => 'views_num', + 'type' => 'number', + 'total' => 'sum', + 'sortable' => false, + 'header_css_class' => 'col-qty', + 'column_css_class' => 'col-qty' + )); + + + $this->addExportType('*/*/exportViewedCsv', Mage::helper('Mage_Adminhtml_Helper_Data')->__('CSV')); + $this->addExportType('*/*/exportViewedExcel', Mage::helper('Mage_Adminhtml_Helper_Data')->__('Excel XML')); + + return parent::_prepareColumns(); + } + + /** + * Don't use orders in collection + * + * @param Mage_Reports_Model_Resource_Report_Collection_Abstract $collection + * @param Varien_Object $filterData + * @return Mage_Adminhtml_Block_Report_Grid_Abstract + */ + protected function _addOrderStatusFilter($collection, $filterData) + { + return $this; + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Review/Customer.php b/app/code/Mage/Adminhtml/Block/Report/Review/Customer.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Review/Customer.php rename to app/code/Mage/Adminhtml/Block/Report/Review/Customer.php diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Review/Detail.php b/app/code/Mage/Adminhtml/Block/Report/Review/Detail.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Review/Detail.php rename to app/code/Mage/Adminhtml/Block/Report/Review/Detail.php diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Review/Detail/Grid.php b/app/code/Mage/Adminhtml/Block/Report/Review/Detail/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Review/Detail/Grid.php rename to app/code/Mage/Adminhtml/Block/Report/Review/Detail/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Review/Product.php b/app/code/Mage/Adminhtml/Block/Report/Review/Product.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Review/Product.php rename to app/code/Mage/Adminhtml/Block/Report/Review/Product.php diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Bestsellers.php b/app/code/Mage/Adminhtml/Block/Report/Sales/Bestsellers.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Sales/Bestsellers.php rename to app/code/Mage/Adminhtml/Block/Report/Sales/Bestsellers.php diff --git a/app/code/Mage/Adminhtml/Block/Report/Sales/Bestsellers/Grid.php b/app/code/Mage/Adminhtml/Block/Report/Sales/Bestsellers/Grid.php new file mode 100644 index 0000000000000..48cf762924ae5 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Report/Sales/Bestsellers/Grid.php @@ -0,0 +1,104 @@ + + */ +class Mage_Adminhtml_Block_Report_Sales_Bestsellers_Grid extends Mage_Adminhtml_Block_Report_Grid_Abstract +{ + protected $_columnGroupBy = 'period'; + + protected function _construct() + { + parent::_construct(); + $this->setCountTotals(true); + } + + public function getResourceCollectionName() + { + return 'Mage_Sales_Model_Resource_Report_Bestsellers_Collection'; + } + + protected function _prepareColumns() + { + $this->addColumn('period', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Period'), + 'index' => 'period', + 'sortable' => false, + 'period_type' => $this->getPeriodType(), + 'renderer' => 'Mage_Adminhtml_Block_Report_Sales_Grid_Column_Renderer_Date', + 'totals_label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Total'), + 'html_decorators' => array('nobr'), + 'header_css_class' => 'col-period', + 'column_css_class' => 'col-period' + )); + + $this->addColumn('product_name', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Product Name'), + 'index' => 'product_name', + 'type' => 'string', + 'sortable' => false, + 'header_css_class' => 'col-product', + 'column_css_class' => 'col-product' + )); + + if ($this->getFilterData()->getStoreIds()) { + $this->setStoreIds(explode(',', $this->getFilterData()->getStoreIds())); + } + $currencyCode = $this->getCurrentCurrencyCode(); + + $this->addColumn('product_price', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Price'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'product_price', + 'sortable' => false, + 'rate' => $this->getRate($currencyCode), + 'header_css_class' => 'col-price', + 'column_css_class' => 'col-price' + )); + + $this->addColumn('qty_ordered', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Quantity Ordered'), + 'index' => 'qty_ordered', + 'type' => 'number', + 'total' => 'sum', + 'sortable' => false, + 'header_css_class' => 'col-qty', + 'column_css_class' => 'col-qty' + )); + + + $this->addExportType('*/*/exportBestsellersCsv', Mage::helper('Mage_Adminhtml_Helper_Data')->__('CSV')); + $this->addExportType('*/*/exportBestsellersExcel', Mage::helper('Mage_Adminhtml_Helper_Data')->__('Excel XML')); + + return parent::_prepareColumns(); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Coupons.php b/app/code/Mage/Adminhtml/Block/Report/Sales/Coupons.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Sales/Coupons.php rename to app/code/Mage/Adminhtml/Block/Report/Sales/Coupons.php diff --git a/app/code/Mage/Adminhtml/Block/Report/Sales/Coupons/Grid.php b/app/code/Mage/Adminhtml/Block/Report/Sales/Coupons/Grid.php new file mode 100644 index 0000000000000..1ee65bb3b2ea4 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Report/Sales/Coupons/Grid.php @@ -0,0 +1,198 @@ + + */ +class Mage_Adminhtml_Block_Report_Sales_Coupons_Grid extends Mage_Adminhtml_Block_Report_Grid_Abstract +{ + protected $_columnGroupBy = 'period'; + + protected function _construct() + { + parent::_construct(); + $this->setCountTotals(true); + $this->setCountSubTotals(true); + } + + public function getResourceCollectionName() + { + if (($this->getFilterData()->getData('report_type') == 'updated_at_order')) { + return 'Mage_SalesRule_Model_Resource_Report_Updatedat_Collection'; + } else { + return 'Mage_SalesRule_Model_Resource_Report_Collection'; + } + } + + protected function _prepareColumns() + { + $this->addColumn('period', array( + 'header' => Mage::helper('Mage_SalesRule_Helper_Data')->__('Period'), + 'index' => 'period', + 'sortable' => false, + 'period_type' => $this->getPeriodType(), + 'renderer' => 'Mage_Adminhtml_Block_Report_Sales_Grid_Column_Renderer_Date', + 'totals_label' => Mage::helper('Mage_SalesRule_Helper_Data')->__('Total'), + 'subtotals_label' => Mage::helper('Mage_SalesRule_Helper_Data')->__('Subtotal'), + 'html_decorators' => array('nobr'), + 'header_css_class' => 'col-period', + 'column_css_class' => 'col-period' + )); + + $this->addColumn('coupon_code', array( + 'header' => Mage::helper('Mage_SalesRule_Helper_Data')->__('Coupon Code'), + 'sortable' => false, + 'index' => 'coupon_code', + 'header_css_class' => 'col-code', + 'column_css_class' => 'col-code' + )); + + $this->addColumn('rule_name', array( + 'header' => Mage::helper('Mage_SalesRule_Helper_Data')->__('Shopping Cart Price Rule'), + 'sortable' => false, + 'index' => 'rule_name', + 'header_css_class' => 'col-rule', + 'column_css_class' => 'col-rule' + )); + + $this->addColumn('coupon_uses', array( + 'header' => Mage::helper('Mage_SalesRule_Helper_Data')->__('Number of Uses'), + 'sortable' => false, + 'index' => 'coupon_uses', + 'total' => 'sum', + 'type' => 'number', + 'header_css_class' => 'col-users', + 'column_css_class' => 'col-users' + )); + + if ($this->getFilterData()->getStoreIds()) { + $this->setStoreIds(explode(',', $this->getFilterData()->getStoreIds())); + } + $currencyCode = $this->getCurrentCurrencyCode(); + $rate = $this->getRate($currencyCode); + + $this->addColumn('subtotal_amount', array( + 'header' => Mage::helper('Mage_SalesRule_Helper_Data')->__('Sales Subtotal Amount'), + 'sortable' => false, + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'total' => 'sum', + 'index' => 'subtotal_amount', + 'rate' => $rate, + 'header_css_class' => 'col-sales', + 'column_css_class' => 'col-sales' + )); + + $this->addColumn('discount_amount', array( + 'header' => Mage::helper('Mage_SalesRule_Helper_Data')->__('Sales Discount Amount'), + 'sortable' => false, + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'total' => 'sum', + 'index' => 'discount_amount', + 'rate' => $rate, + 'header_css_class' => 'col-sales-discount', + 'column_css_class' => 'col-sales-discount' + )); + + $this->addColumn('total_amount', array( + 'header' => Mage::helper('Mage_SalesRule_Helper_Data')->__('Sales Total Amount'), + 'sortable' => false, + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'total' => 'sum', + 'index' => 'total_amount', + 'rate' => $rate, + 'header_css_class' => 'col-total-amount', + 'column_css_class' => 'col-total-amount' + )); + + $this->addColumn('subtotal_amount_actual', array( + 'header' => Mage::helper('Mage_SalesRule_Helper_Data')->__('Subtotal Amount'), + 'sortable' => false, + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'total' => 'sum', + 'index' => 'subtotal_amount_actual', + 'rate' => $rate, + 'header_css_class' => 'col-subtotal', + 'column_css_class' => 'col-subtotal' + )); + + $this->addColumn('discount_amount_actual', array( + 'header' => Mage::helper('Mage_SalesRule_Helper_Data')->__('Discount Amount'), + 'sortable' => false, + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'total' => 'sum', + 'index' => 'discount_amount_actual', + 'rate' => $rate, + 'header_css_class' => 'col-discount', + 'column_css_class' => 'col-discount' + )); + + $this->addColumn('total_amount_actual', array( + 'header' => Mage::helper('Mage_SalesRule_Helper_Data')->__('Total Amount'), + 'sortable' => false, + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'total' => 'sum', + 'index' => 'total_amount_actual', + 'rate' => $rate, + 'header_css_class' => 'col-total', + 'column_css_class' => 'col-total' + )); + + $this->addExportType('*/*/exportCouponsCsv', Mage::helper('Mage_Adminhtml_Helper_Data')->__('CSV')); + $this->addExportType('*/*/exportCouponsExcel', Mage::helper('Mage_Adminhtml_Helper_Data')->__('Excel XML')); + + return parent::_prepareColumns(); + } + + /** + * Add price rule filter + * + * @param Mage_Reports_Model_Resource_Report_Collection_Abstract $collection + * @param Varien_Object $filterData + * @return Mage_Adminhtml_Block_Report_Grid_Abstract + */ + protected function _addCustomFilter($collection, $filterData) + { + if ($filterData->getPriceRuleType()) { + $rulesList = $filterData->getData('rules_list'); + if (isset($rulesList[0])) { + $rulesIds = explode(',', $rulesList[0]); + $collection->addRuleFilter($rulesIds); + } + } + + return parent::_addCustomFilter($filterData, $collection); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Grid/Column/Renderer/Date.php b/app/code/Mage/Adminhtml/Block/Report/Sales/Grid/Column/Renderer/Date.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Sales/Grid/Column/Renderer/Date.php rename to app/code/Mage/Adminhtml/Block/Report/Sales/Grid/Column/Renderer/Date.php diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Invoiced.php b/app/code/Mage/Adminhtml/Block/Report/Sales/Invoiced.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Sales/Invoiced.php rename to app/code/Mage/Adminhtml/Block/Report/Sales/Invoiced.php diff --git a/app/code/Mage/Adminhtml/Block/Report/Sales/Invoiced/Grid.php b/app/code/Mage/Adminhtml/Block/Report/Sales/Invoiced/Grid.php new file mode 100644 index 0000000000000..646a9bf726fb5 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Report/Sales/Invoiced/Grid.php @@ -0,0 +1,132 @@ + + */ +class Mage_Adminhtml_Block_Report_Sales_Invoiced_Grid extends Mage_Adminhtml_Block_Report_Grid_Abstract +{ + protected $_columnGroupBy = 'period'; + + protected function _construct() + { + parent::_construct(); + $this->setCountTotals(true); + } + + public function getResourceCollectionName() + { + return ($this->getFilterData()->getData('report_type') == 'created_at_invoice') + ? 'Mage_Sales_Model_Resource_Report_Invoiced_Collection_Invoiced' + : 'Mage_Sales_Model_Resource_Report_Invoiced_Collection_Order'; + } + + protected function _prepareColumns() + { + $this->addColumn('period', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Period'), + 'index' => 'period', + 'sortable' => false, + 'period_type' => $this->getPeriodType(), + 'renderer' => 'Mage_Adminhtml_Block_Report_Sales_Grid_Column_Renderer_Date', + 'totals_label' => Mage::helper('Mage_Sales_Helper_Data')->__('Total'), + 'html_decorators' => array('nobr'), + 'header_css_class' => 'col-period', + 'column_css_class' => 'col-period' + )); + + $this->addColumn('orders_count', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Number of Orders'), + 'index' => 'orders_count', + 'type' => 'number', + 'total' => 'sum', + 'sortable' => false, + 'header_css_class' => 'col-qty', + 'column_css_class' => 'col-qty' + )); + + $this->addColumn('orders_invoiced', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Number of Invoiced Orders'), + 'index' => 'orders_invoiced', + 'type' => 'number', + 'total' => 'sum', + 'sortable' => false, + 'header_css_class' => 'col-invoiced', + 'column_css_class' => 'col-invoiced' + )); + + if ($this->getFilterData()->getStoreIds()) { + $this->setStoreIds(explode(',', $this->getFilterData()->getStoreIds())); + } + $currencyCode = $this->getCurrentCurrencyCode(); + $rate = $this->getRate($currencyCode); + + $this->addColumn('invoiced', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Total Invoiced'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'invoiced', + 'total' => 'sum', + 'sortable' => false, + 'rate' => $rate, + 'header_css_class' => 'col-total-invoiced', + 'column_css_class' => 'col-total-invoiced' + )); + + $this->addColumn('invoiced_captured', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Total Invoiced Paid'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'invoiced_captured', + 'total' => 'sum', + 'sortable' => false, + 'rate' => $rate, + 'header_css_class' => 'col-total-invoiced-paid', + 'column_css_class' => 'col-total-invoiced-paid' + )); + + $this->addColumn('invoiced_not_captured', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Total Invoiced not Paid'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'invoiced_not_captured', + 'total' => 'sum', + 'sortable' => false, + 'rate' => $rate, + 'header_css_class' => 'col-total-invoiced-not-paid', + 'column_css_class' => 'col-total-invoiced-not-paid' + )); + + $this->addExportType('*/*/exportInvoicedCsv', Mage::helper('Mage_Adminhtml_Helper_Data')->__('CSV')); + $this->addExportType('*/*/exportInvoicedExcel', Mage::helper('Mage_Adminhtml_Helper_Data')->__('Excel XML')); + + return parent::_prepareColumns(); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Refunded.php b/app/code/Mage/Adminhtml/Block/Report/Sales/Refunded.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Sales/Refunded.php rename to app/code/Mage/Adminhtml/Block/Report/Sales/Refunded.php diff --git a/app/code/Mage/Adminhtml/Block/Report/Sales/Refunded/Grid.php b/app/code/Mage/Adminhtml/Block/Report/Sales/Refunded/Grid.php new file mode 100644 index 0000000000000..85a214d9e42e0 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Report/Sales/Refunded/Grid.php @@ -0,0 +1,122 @@ + + */ +class Mage_Adminhtml_Block_Report_Sales_Refunded_Grid extends Mage_Adminhtml_Block_Report_Grid_Abstract +{ + protected $_columnGroupBy = 'period'; + + protected function _construct() + { + parent::_construct(); + $this->setCountTotals(true); + } + + public function getResourceCollectionName() + { + return ($this->getFilterData()->getData('report_type') == 'created_at_refunded') + ? 'Mage_Sales_Model_Resource_Report_Refunded_Collection_Refunded' + : 'Mage_Sales_Model_Resource_Report_Refunded_Collection_Order'; + } + + protected function _prepareColumns() + { + $this->addColumn('period', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Period'), + 'index' => 'period', + 'sortable' => false, + 'period_type' => $this->getPeriodType(), + 'renderer' => 'Mage_Adminhtml_Block_Report_Sales_Grid_Column_Renderer_Date', + 'totals_label' => Mage::helper('Mage_Sales_Helper_Data')->__('Total'), + 'html_decorators' => array('nobr'), + 'header_css_class' => 'col-period', + 'column_css_class' => 'col-period' + )); + + $this->addColumn('orders_count', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Number of Refunded Orders'), + 'index' => 'orders_count', + 'type' => 'number', + 'total' => 'sum', + 'sortable' => false, + 'header_css_class' => 'col-qty', + 'column_css_class' => 'col-qty' + )); + + if ($this->getFilterData()->getStoreIds()) { + $this->setStoreIds(explode(',', $this->getFilterData()->getStoreIds())); + } + $currencyCode = $this->getCurrentCurrencyCode(); + $rate = $this->getRate($currencyCode); + + $this->addColumn('refunded', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Total Refunded'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'refunded', + 'total' => 'sum', + 'sortable' => false, + 'rate' => $rate, + 'header_css_class' => 'col-ref-total', + 'column_css_class' => 'col-ref-total' + )); + + $this->addColumn('online_refunded', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Online Refunded'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'online_refunded', + 'total' => 'sum', + 'sortable' => false, + 'rate' => $rate, + 'header_css_class' => 'col-ref-online', + 'column_css_class' => 'col-ref-online' + )); + + $this->addColumn('offline_refunded', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Offline Refunded'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'offline_refunded', + 'total' => 'sum', + 'sortable' => false, + 'rate' => $rate, + 'header_css_class' => 'col-ref-offline', + 'column_css_class' => 'col-ref-offline' + )); + + $this->addExportType('*/*/exportRefundedCsv', Mage::helper('Mage_Adminhtml_Helper_Data')->__('CSV')); + $this->addExportType('*/*/exportRefundedExcel', Mage::helper('Mage_Adminhtml_Helper_Data')->__('Excel XML')); + + return parent::_prepareColumns(); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Sales.php b/app/code/Mage/Adminhtml/Block/Report/Sales/Sales.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Sales/Sales.php rename to app/code/Mage/Adminhtml/Block/Report/Sales/Sales.php diff --git a/app/code/Mage/Adminhtml/Block/Report/Sales/Sales/Grid.php b/app/code/Mage/Adminhtml/Block/Report/Sales/Sales/Grid.php new file mode 100644 index 0000000000000..c9f7ec8dbc8f4 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Report/Sales/Sales/Grid.php @@ -0,0 +1,270 @@ + + */ +class Mage_Adminhtml_Block_Report_Sales_Sales_Grid extends Mage_Adminhtml_Block_Report_Grid_Abstract +{ + protected $_columnGroupBy = 'period'; + + protected function _construct() + { + parent::_construct(); + $this->setCountTotals(true); + } + + public function getResourceCollectionName() + { + return ($this->getFilterData()->getData('report_type') == 'updated_at_order') + ? 'Mage_Sales_Model_Resource_Report_Order_Updatedat_Collection' + : 'Mage_Sales_Model_Resource_Report_Order_Collection'; + } + + protected function _prepareColumns() + { + $this->addColumn('period', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Period'), + 'index' => 'period', + 'sortable' => false, + 'period_type' => $this->getPeriodType(), + 'renderer' => 'Mage_Adminhtml_Block_Report_Sales_Grid_Column_Renderer_Date', + 'totals_label' => Mage::helper('Mage_Sales_Helper_Data')->__('Total'), + 'html_decorators' => array('nobr'), + 'header_css_class' => 'col-period', + 'column_css_class' => 'col-period' + )); + + $this->addColumn('orders_count', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Orders'), + 'index' => 'orders_count', + 'type' => 'number', + 'total' => 'sum', + 'sortable' => false, + 'header_css_class' => 'col-orders', + 'column_css_class' => 'col-orders' + )); + + $this->addColumn('total_qty_ordered', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Sales Items'), + 'index' => 'total_qty_ordered', + 'type' => 'number', + 'total' => 'sum', + 'sortable' => false, + 'header_css_class' => 'col-sales-items', + 'column_css_class' => 'col-sales-items' + )); + + $this->addColumn('total_qty_invoiced', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Items'), + 'index' => 'total_qty_invoiced', + 'type' => 'number', + 'total' => 'sum', + 'sortable' => false, + 'visibility_filter' => array('show_actual_columns'), + 'header_css_class' => 'col-items', + 'column_css_class' => 'col-items' + )); + + if ($this->getFilterData()->getStoreIds()) { + $this->setStoreIds(explode(',', $this->getFilterData()->getStoreIds())); + } + $currencyCode = $this->getCurrentCurrencyCode(); + $rate = $this->getRate($currencyCode); + + $this->addColumn('total_income_amount', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Sales Total'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'total_income_amount', + 'total' => 'sum', + 'sortable' => false, + 'rate' => $rate, + 'header_css_class' => 'col-sales-total', + 'column_css_class' => 'col-sales-total' + )); + + $this->addColumn('total_revenue_amount', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Revenue'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'total_revenue_amount', + 'total' => 'sum', + 'sortable' => false, + 'visibility_filter' => array('show_actual_columns'), + 'rate' => $rate, + 'header_css_class' => 'col-revenue', + 'column_css_class' => 'col-revenue' + )); + + $this->addColumn('total_profit_amount', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Profit'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'total_profit_amount', + 'total' => 'sum', + 'sortable' => false, + 'visibility_filter' => array('show_actual_columns'), + 'rate' => $rate, + 'header_css_class' => 'col-profit', + 'column_css_class' => 'col-profit' + )); + + $this->addColumn('total_invoiced_amount', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Invoiced'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'total_invoiced_amount', + 'total' => 'sum', + 'sortable' => false, + 'rate' => $rate, + 'header_css_class' => 'col-invoiced', + 'column_css_class' => 'col-invoiced' + )); + + $this->addColumn('total_paid_amount', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Paid'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'total_paid_amount', + 'total' => 'sum', + 'sortable' => false, + 'visibility_filter' => array('show_actual_columns'), + 'rate' => $rate, + 'header_css_class' => 'col-paid', + 'column_css_class' => 'col-paid' + )); + + $this->addColumn('total_refunded_amount', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Refunded'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'total_refunded_amount', + 'total' => 'sum', + 'sortable' => false, + 'rate' => $rate, + 'header_css_class' => 'col-refunded', + 'column_css_class' => 'col-refunded' + )); + + $this->addColumn('total_tax_amount', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Sales Tax'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'total_tax_amount', + 'total' => 'sum', + 'sortable' => false, + 'rate' => $rate, + 'header_css_class' => 'col-sales-tax', + 'column_css_class' => 'col-sales-tax' + )); + + $this->addColumn('total_tax_amount_actual', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Tax'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'total_tax_amount_actual', + 'total' => 'sum', + 'sortable' => false, + 'visibility_filter' => array('show_actual_columns'), + 'rate' => $rate, + 'header_css_class' => 'col-tax', + 'column_css_class' => 'col-tax' + )); + + $this->addColumn('total_shipping_amount', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Sales Shipping'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'total_shipping_amount', + 'total' => 'sum', + 'sortable' => false, + 'rate' => $rate, + 'header_css_class' => 'col-sales-shipping', + 'column_css_class' => 'col-sales-shipping' + )); + + $this->addColumn('total_shipping_amount_actual', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Shipping'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'total_shipping_amount_actual', + 'total' => 'sum', + 'sortable' => false, + 'visibility_filter' => array('show_actual_columns'), + 'rate' => $rate, + 'header_css_class' => 'col-shipping', + 'column_css_class' => 'col-shipping' + )); + + $this->addColumn('total_discount_amount', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Sales Discount'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'total_discount_amount', + 'total' => 'sum', + 'sortable' => false, + 'rate' => $rate, + 'header_css_class' => 'col-sales-discount', + 'column_css_class' => 'col-sales-discount' + )); + + $this->addColumn('total_discount_amount_actual', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Discount'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'total_discount_amount_actual', + 'total' => 'sum', + 'sortable' => false, + 'visibility_filter' => array('show_actual_columns'), + 'rate' => $rate, + 'header_css_class' => 'col-discount', + 'column_css_class' => 'col-discount' + )); + + $this->addColumn('total_canceled_amount', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Canceled'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'total_canceled_amount', + 'total' => 'sum', + 'sortable' => false, + 'rate' => $rate, + 'header_css_class' => 'col-canceled', + 'column_css_class' => 'col-canceled' + )); + + + $this->addExportType('*/*/exportSalesCsv', Mage::helper('Mage_Adminhtml_Helper_Data')->__('CSV')); + $this->addExportType('*/*/exportSalesExcel', Mage::helper('Mage_Adminhtml_Helper_Data')->__('Excel XML')); + + return parent::_prepareColumns(); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Shipping.php b/app/code/Mage/Adminhtml/Block/Report/Sales/Shipping.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Sales/Shipping.php rename to app/code/Mage/Adminhtml/Block/Report/Sales/Shipping.php diff --git a/app/code/Mage/Adminhtml/Block/Report/Sales/Shipping/Grid.php b/app/code/Mage/Adminhtml/Block/Report/Sales/Shipping/Grid.php new file mode 100644 index 0000000000000..1f4b5edda756e --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Report/Sales/Shipping/Grid.php @@ -0,0 +1,124 @@ + + */ +class Mage_Adminhtml_Block_Report_Sales_Shipping_Grid extends Mage_Adminhtml_Block_Report_Grid_Abstract +{ + protected $_columnGroupBy = 'period'; + + protected function _construct() + { + parent::_construct(); + $this->setCountTotals(true); + $this->setCountSubTotals(true); + } + + public function getResourceCollectionName() + { + return ($this->getFilterData()->getData('report_type') == 'created_at_shipment') + ? 'Mage_Sales_Model_Resource_Report_Shipping_Collection_Shipment' + : 'Mage_Sales_Model_Resource_Report_Shipping_Collection_Order'; + } + + protected function _prepareColumns() + { + $this->addColumn('period', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Period'), + 'index' => 'period', + 'sortable' => false, + 'period_type' => $this->getPeriodType(), + 'renderer' => 'Mage_Adminhtml_Block_Report_Sales_Grid_Column_Renderer_Date', + 'totals_label' => Mage::helper('Mage_Sales_Helper_Data')->__('Total'), + 'subtotals_label' => Mage::helper('Mage_Sales_Helper_Data')->__('Subtotal'), + 'html_decorators' => array('nobr'), + 'header_css_class' => 'col-period', + 'column_css_class' => 'col-period' + )); + + $this->addColumn('shipping_description', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Carrier/Method'), + 'index' => 'shipping_description', + 'sortable' => false, + 'header_css_class' => 'col-method', + 'column_css_class' => 'col-method' + )); + + $this->addColumn('orders_count', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Number of Orders'), + 'index' => 'orders_count', + 'total' => 'sum', + 'type' => 'number', + 'sortable' => false, + 'header_css_class' => 'col-qty', + 'column_css_class' => 'col-qty' + )); + + if ($this->getFilterData()->getStoreIds()) { + $this->setStoreIds(explode(',', $this->getFilterData()->getStoreIds())); + } + + $currencyCode = $this->getCurrentCurrencyCode(); + $rate = $this->getRate($currencyCode); + + $this->addColumn('total_shipping', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Total Sales Shipping'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'total_shipping', + 'total' => 'sum', + 'sortable' => false, + 'rate' => $rate, + 'header_css_class' => 'col-total-sales-shipping', + 'column_css_class' => 'col-total-sales-shipping' + )); + + $this->addColumn('total_shipping_actual', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Total Shipping'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'total_shipping_actual', + 'total' => 'sum', + 'sortable' => false, + 'rate' => $rate, + 'header_css_class' => 'col-total-shipping', + 'column_css_class' => 'col-total-shipping' + )); + + $this->addExportType('*/*/exportShippingCsv', Mage::helper('Mage_Adminhtml_Helper_Data')->__('CSV')); + $this->addExportType('*/*/exportShippingExcel', Mage::helper('Mage_Adminhtml_Helper_Data')->__('Excel XML')); + + return parent::_prepareColumns(); + } +} + + + diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Tax.php b/app/code/Mage/Adminhtml/Block/Report/Sales/Tax.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Sales/Tax.php rename to app/code/Mage/Adminhtml/Block/Report/Sales/Tax.php diff --git a/app/code/Mage/Adminhtml/Block/Report/Sales/Tax/Grid.php b/app/code/Mage/Adminhtml/Block/Report/Sales/Tax/Grid.php new file mode 100644 index 0000000000000..69fb25689d1a6 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Report/Sales/Tax/Grid.php @@ -0,0 +1,140 @@ + + */ +class Mage_Adminhtml_Block_Report_Sales_Tax_Grid extends Mage_Adminhtml_Block_Report_Grid_Abstract +{ + protected $_columnGroupBy = 'period'; + + protected function _construct() + { + parent::_construct(); + $this->setCountTotals(true); + $this->setCountSubTotals(true); + } + + public function getResourceCollectionName() + { + return ($this->getFilterData()->getData('report_type') == 'updated_at_order') + ? 'Mage_Tax_Model_Resource_Report_Updatedat_Collection' + : 'Mage_Tax_Model_Resource_Report_Collection'; + } + + protected function _prepareColumns() + { + $this->addColumn('period', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Period'), + 'index' => 'period', + 'sortable' => false, + 'period_type' => $this->getPeriodType(), + 'renderer' => 'Mage_Adminhtml_Block_Report_Sales_Grid_Column_Renderer_Date', + 'totals_label' => Mage::helper('Mage_Sales_Helper_Data')->__('Total'), + 'subtotals_label' => Mage::helper('Mage_Sales_Helper_Data')->__('Subtotal'), + 'html_decorators' => array('nobr'), + 'header_css_class' => 'col-period', + 'column_css_class' => 'col-period' + )); + + $this->addColumn('code', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Tax'), + 'index' => 'code', + 'type' => 'string', + 'sortable' => false, + 'header_css_class' => 'col-tax-name', + 'column_css_class' => 'col-tax-name' + )); + + $this->addColumn('percent', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Rate'), + 'index' => 'percent', + 'type' => 'number', + 'sortable' => false, + 'header_css_class' => 'col-rate', + 'column_css_class' => 'col-rate' + )); + + $this->addColumn('orders_count', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Number of Orders'), + 'index' => 'orders_count', + 'total' => 'sum', + 'type' => 'number', + 'sortable' => false, + 'header_css_class' => 'col-qty', + 'column_css_class' => 'col-qty' + )); + + if ($this->getFilterData()->getStoreIds()) { + $this->setStoreIds(explode(',', $this->getFilterData()->getStoreIds())); + } + $currencyCode = $this->getCurrentCurrencyCode(); + + $this->addColumn('tax_base_amount_sum', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Tax Amount'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'tax_base_amount_sum', + 'total' => 'sum', + 'sortable' => false, + 'rate' => $this->getRate($currencyCode), + 'header_css_class' => 'col-tax-amount', + 'column_css_class' => 'col-tax-amount' + )); + + $this->addExportType('*/*/exportTaxCsv', Mage::helper('Mage_Adminhtml_Helper_Data')->__('CSV')); + $this->addExportType('*/*/exportTaxExcel', Mage::helper('Mage_Adminhtml_Helper_Data')->__('Excel XML')); + + 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('Mage_Sales_Model_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/Report/Search.php b/app/code/Mage/Adminhtml/Block/Report/Search.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Search.php rename to app/code/Mage/Adminhtml/Block/Report/Search.php diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Shopcart/Abandoned.php b/app/code/Mage/Adminhtml/Block/Report/Shopcart/Abandoned.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Shopcart/Abandoned.php rename to app/code/Mage/Adminhtml/Block/Report/Shopcart/Abandoned.php diff --git a/app/code/Mage/Adminhtml/Block/Report/Shopcart/Abandoned/Grid.php b/app/code/Mage/Adminhtml/Block/Report/Shopcart/Abandoned/Grid.php new file mode 100644 index 0000000000000..e217ed61baaa2 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Report/Shopcart/Abandoned/Grid.php @@ -0,0 +1,183 @@ + + */ +class Mage_Adminhtml_Block_Report_Shopcart_Abandoned_Grid extends Mage_Adminhtml_Block_Report_Grid_Shopcart +{ + + protected function _construct() + { + parent::_construct(); + $this->setId('gridAbandoned'); + } + + protected function _prepareCollection() + { + /** @var $collection Mage_Reports_Model_Resource_Quote_Collection */ + $collection = Mage::getResourceModel('Mage_Reports_Model_Resource_Quote_Collection'); + + $filter = $this->getParam($this->getVarNameFilter(), array()); + if ($filter) { + $filter = base64_decode($filter); + parse_str(urldecode($filter), $data); + } + + if (!empty($data)) { + $collection->prepareForAbandonedReport($this->_storeIds, $data); + } else { + $collection->prepareForAbandonedReport($this->_storeIds); + } + + $this->setCollection($collection); + return parent::_prepareCollection(); + } + + protected function _addColumnFilterToCollection($column) + { + $field = ( $column->getFilterIndex() ) ? $column->getFilterIndex() : $column->getIndex(); + $skip = array('subtotal', 'customer_name', 'email'/*, 'created_at', 'updated_at'*/); + + if (in_array($field, $skip)) { + return $this; + } + + parent::_addColumnFilterToCollection($column); + return $this; + } + + protected function _prepareColumns() + { + $this->addColumn('customer_name', array( + 'header' => Mage::helper('Mage_Reports_Helper_Data')->__('Customer Name'), + 'index' => 'customer_name', + 'sortable' => false, + 'header_css_class' => 'col-name', + 'column_css_class' => 'col-name' + )); + + $this->addColumn('email', array( + 'header' => Mage::helper('Mage_Reports_Helper_Data')->__('Email'), + 'index' => 'email', + 'sortable' => false, + 'header_css_class' => 'col-email', + 'column_css_class' => 'col-email' + )); + + $this->addColumn('items_count', array( + 'header' => Mage::helper('Mage_Reports_Helper_Data')->__('Number of Items'), + 'index' => 'items_count', + 'sortable' => false, + 'type' => 'number', + 'header_css_class' => 'col-number', + 'column_css_class' => 'col-number' + )); + + $this->addColumn('items_qty', array( + 'header' => Mage::helper('Mage_Reports_Helper_Data')->__('Quantity of Items'), + 'index' => 'items_qty', + 'sortable' => false, + 'type' => 'number', + 'header_css_class' => 'col-qty', + 'column_css_class' => 'col-qty' + )); + + if ($this->getRequest()->getParam('website')) { + $storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds(); + } else if ($this->getRequest()->getParam('group')) { + $storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds(); + } else if ($this->getRequest()->getParam('store')) { + $storeIds = array((int)$this->getRequest()->getParam('store')); + } else { + $storeIds = array(); + } + $this->setStoreIds($storeIds); + $currencyCode = $this->getCurrentCurrencyCode(); + + $this->addColumn('subtotal', array( + 'header' => Mage::helper('Mage_Reports_Helper_Data')->__('Subtotal'), + 'type' => 'currency', + 'currency_code' => $currencyCode, + 'index' => 'subtotal', + 'sortable' => false, + 'renderer' => 'Mage_Adminhtml_Block_Report_Grid_Column_Renderer_Currency', + 'rate' => $this->getRate($currencyCode), + 'header_css_class' => 'col-subtotal', + 'column_css_class' => 'col-subtotal' + )); + + $this->addColumn('coupon_code', array( + 'header' => Mage::helper('Mage_Reports_Helper_Data')->__('Applied Coupon'), + 'index' => 'coupon_code', + 'sortable' => false, + 'header_css_class' => 'col-coupon', + 'column_css_class' => 'col-coupon' + )); + + $this->addColumn('created_at', array( + 'header' => Mage::helper('Mage_Reports_Helper_Data')->__('Created At'), + 'type' => 'datetime', + 'index' => 'created_at', + 'filter_index'=> 'main_table.created_at', + 'sortable' => false, + 'header_css_class' => 'col-created', + 'column_css_class' => 'col-created' + )); + + $this->addColumn('updated_at', array( + 'header' => Mage::helper('Mage_Reports_Helper_Data')->__('Updated At'), + 'type' => 'datetime', + 'index' => 'updated_at', + 'filter_index'=> 'main_table.updated_at', + 'sortable' => false, + 'header_css_class' => 'col-updated', + 'column_css_class' => 'col-updated' + )); + + $this->addColumn('remote_ip', array( + 'header' => Mage::helper('Mage_Reports_Helper_Data')->__('IP Address'), + 'index' => 'remote_ip', + 'sortable' => false, + 'header_css_class' => 'col-ip', + 'column_css_class' => 'col-ip' + )); + + $this->addExportType('*/*/exportAbandonedCsv', Mage::helper('Mage_Reports_Helper_Data')->__('CSV')); + $this->addExportType('*/*/exportAbandonedExcel', Mage::helper('Mage_Reports_Helper_Data')->__('Excel XML')); + + return parent::_prepareColumns(); + } + + public function getRowUrl($row) + { + return $this->getUrl('*/customer/edit', array('id'=>$row->getCustomerId(), 'active_tab'=>'cart')); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Shopcart/Customer.php b/app/code/Mage/Adminhtml/Block/Report/Shopcart/Customer.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Shopcart/Customer.php rename to app/code/Mage/Adminhtml/Block/Report/Shopcart/Customer.php diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Shopcart/Customer/Grid.php b/app/code/Mage/Adminhtml/Block/Report/Shopcart/Customer/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Shopcart/Customer/Grid.php rename to app/code/Mage/Adminhtml/Block/Report/Shopcart/Customer/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Shopcart/Product.php b/app/code/Mage/Adminhtml/Block/Report/Shopcart/Product.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Shopcart/Product.php rename to app/code/Mage/Adminhtml/Block/Report/Shopcart/Product.php diff --git a/app/code/Mage/Adminhtml/Block/Report/Shopcart/Product/Grid.php b/app/code/Mage/Adminhtml/Block/Report/Shopcart/Product/Grid.php new file mode 100644 index 0000000000000..06187cb4961c6 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Report/Shopcart/Product/Grid.php @@ -0,0 +1,112 @@ + + */ +class Mage_Adminhtml_Block_Report_Shopcart_Product_Grid extends Mage_Adminhtml_Block_Report_Grid_Shopcart +{ + + protected function _construct() + { + parent::_construct(); + $this->setId('gridProducts'); + } + + protected function _prepareCollection() + { + /** @var $collection Mage_Reports_Model_Resource_Quote_Collection */ + $collection = Mage::getResourceModel('Mage_Reports_Model_Resource_Quote_Collection'); + $collection->prepareForProductsInCarts() + ->setSelectCountSqlType(Mage_Reports_Model_Resource_Quote_Collection::SELECT_COUNT_SQL_TYPE_CART); + $this->setCollection($collection); + return parent::_prepareCollection(); + } + + protected function _prepareColumns() + { + $this->addColumn('entity_id', array( + 'header' =>Mage::helper('Mage_Reports_Helper_Data')->__('ID'), + 'align' =>'right', + 'index' =>'entity_id', + 'header_css_class' => 'col-id', + 'column_css_class' => 'col-id' + )); + + $this->addColumn('name', array( + 'header' =>Mage::helper('Mage_Reports_Helper_Data')->__('Product Name'), + 'index' =>'name', + 'header_css_class' => 'col-product', + 'column_css_class' => 'col-product' + )); + + $currencyCode = $this->getCurrentCurrencyCode(); + + $this->addColumn('price', array( + 'header' =>Mage::helper('Mage_Reports_Helper_Data')->__('Price'), + 'type' =>'currency', + 'currency_code' => $currencyCode, + 'index' =>'price', + 'renderer' =>'Mage_Adminhtml_Block_Report_Grid_Column_Renderer_Currency', + 'rate' => $this->getRate($currencyCode), + 'header_css_class' => 'col-price', + 'column_css_class' => 'col-price' + )); + + $this->addColumn('carts', array( + 'header' =>Mage::helper('Mage_Reports_Helper_Data')->__('Carts'), + 'align' =>'right', + 'index' =>'carts', + 'header_css_class' => 'col-carts', + 'column_css_class' => 'col-carts' + )); + + $this->addColumn('orders', array( + 'header' =>Mage::helper('Mage_Reports_Helper_Data')->__('Orders'), + 'align' =>'right', + 'index' =>'orders', + 'header_css_class' => 'col-qty', + 'column_css_class' => 'col-qty' + )); + + $this->setFilterVisibility(false); + + $this->addExportType('*/*/exportProductCsv', Mage::helper('Mage_Reports_Helper_Data')->__('CSV')); + $this->addExportType('*/*/exportProductExcel', Mage::helper('Mage_Reports_Helper_Data')->__('Excel XML')); + + return parent::_prepareColumns(); + } + + public function getRowUrl($row) + { + return $this->getUrl('*/catalog_product/edit', array('id'=>$row->getEntityId())); + } +} + diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Wishlist.php b/app/code/Mage/Adminhtml/Block/Report/Wishlist.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Wishlist.php rename to app/code/Mage/Adminhtml/Block/Report/Wishlist.php diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Wishlist/Grid.php b/app/code/Mage/Adminhtml/Block/Report/Wishlist/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Report/Wishlist/Grid.php rename to app/code/Mage/Adminhtml/Block/Report/Wishlist/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Review/Add.php b/app/code/Mage/Adminhtml/Block/Review/Add.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Review/Add.php rename to app/code/Mage/Adminhtml/Block/Review/Add.php diff --git a/app/code/core/Mage/Adminhtml/Block/Review/Add/Form.php b/app/code/Mage/Adminhtml/Block/Review/Add/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Review/Add/Form.php rename to app/code/Mage/Adminhtml/Block/Review/Add/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Review/Edit.php b/app/code/Mage/Adminhtml/Block/Review/Edit.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Review/Edit.php rename to app/code/Mage/Adminhtml/Block/Review/Edit.php diff --git a/app/code/core/Mage/Adminhtml/Block/Review/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Review/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Review/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/Review/Edit/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Review/Grid.php b/app/code/Mage/Adminhtml/Block/Review/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Review/Grid.php rename to app/code/Mage/Adminhtml/Block/Review/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Review/Grid/Filter/Type.php b/app/code/Mage/Adminhtml/Block/Review/Grid/Filter/Type.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Review/Grid/Filter/Type.php rename to app/code/Mage/Adminhtml/Block/Review/Grid/Filter/Type.php diff --git a/app/code/core/Mage/Adminhtml/Block/Review/Grid/Renderer/Type.php b/app/code/Mage/Adminhtml/Block/Review/Grid/Renderer/Type.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Review/Grid/Renderer/Type.php rename to app/code/Mage/Adminhtml/Block/Review/Grid/Renderer/Type.php diff --git a/app/code/core/Mage/Adminhtml/Block/Review/Main.php b/app/code/Mage/Adminhtml/Block/Review/Main.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Review/Main.php rename to app/code/Mage/Adminhtml/Block/Review/Main.php diff --git a/app/code/core/Mage/Adminhtml/Block/Review/Product/Grid.php b/app/code/Mage/Adminhtml/Block/Review/Product/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Review/Product/Grid.php rename to app/code/Mage/Adminhtml/Block/Review/Product/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Review/Rating/Detailed.php b/app/code/Mage/Adminhtml/Block/Review/Rating/Detailed.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Review/Rating/Detailed.php rename to app/code/Mage/Adminhtml/Block/Review/Rating/Detailed.php diff --git a/app/code/core/Mage/Adminhtml/Block/Review/Rating/Summary.php b/app/code/Mage/Adminhtml/Block/Review/Rating/Summary.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Review/Rating/Summary.php rename to app/code/Mage/Adminhtml/Block/Review/Rating/Summary.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Creditmemo.php b/app/code/Mage/Adminhtml/Block/Sales/Creditmemo.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Creditmemo.php rename to app/code/Mage/Adminhtml/Block/Sales/Creditmemo.php diff --git a/app/code/Mage/Adminhtml/Block/Sales/Creditmemo/Grid.php b/app/code/Mage/Adminhtml/Block/Sales/Creditmemo/Grid.php new file mode 100644 index 0000000000000..27c52140b692f --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Sales/Creditmemo/Grid.php @@ -0,0 +1,181 @@ + + */ +class Mage_Adminhtml_Block_Sales_Creditmemo_Grid extends Mage_Adminhtml_Block_Widget_Grid +{ + + protected function _construct() + { + parent::_construct(); + $this->setId('sales_creditmemo_grid'); + $this->setDefaultSort('created_at'); + $this->setDefaultDir('DESC'); + } + + /** + * Retrieve collection class + * + * @return string + */ + protected function _getCollectionClass() + { + return 'Mage_Sales_Model_Resource_Order_Creditmemo_Grid_Collection'; + } + + protected function _prepareCollection() + { + $collection = Mage::getResourceModel($this->_getCollectionClass()); + $this->setCollection($collection); + return parent::_prepareCollection(); + } + + + protected function _prepareColumns() + { + $this->addColumn('increment_id', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Credit Memo #'), + 'index' => 'increment_id', + 'type' => 'text', + 'header_css_class' => 'col-memo-number', + 'column_css_class' => 'col-memo-number' + )); + + $this->addColumn('created_at', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Created At'), + 'index' => 'created_at', + 'type' => 'datetime', + 'header_css_class' => 'col-period', + 'column_css_class' => 'col-period' + )); + + $this->addColumn('order_increment_id', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Order #'), + 'index' => 'order_increment_id', + 'type' => 'text', + 'header_css_class' => 'col-order-number', + 'column_css_class' => 'col-order-number' + )); + + $this->addColumn('order_created_at', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Order Date'), + 'index' => 'order_created_at', + 'type' => 'datetime', + 'header_css_class' => 'col-period', + 'column_css_class' => 'col-period' + )); + + $this->addColumn('billing_name', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Bill to Name'), + 'index' => 'billing_name', + 'header_css_class' => 'col-name', + 'column_css_class' => 'col-name' + )); + + $this->addColumn('state', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Status'), + 'index' => 'state', + 'type' => 'options', + 'options' => Mage::getModel('Mage_Sales_Model_Order_Creditmemo')->getStates(), + 'header_css_class' => 'col-status', + 'column_css_class' => 'col-status' + )); + + $this->addColumn('grand_total', array( + 'header' => Mage::helper('Mage_Customer_Helper_Data')->__('Refunded'), + 'index' => 'grand_total', + 'type' => 'currency', + 'currency' => 'order_currency_code', + 'header_css_class' => 'col-refunded', + 'column_css_class' => 'col-refunded' + )); + + $this->addColumn('action', + array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Action'), + 'type' => 'action', + 'getter' => 'getId', + 'actions' => array( + array( + 'caption' => Mage::helper('Mage_Sales_Helper_Data')->__('View'), + 'url' => array('base'=>'*/sales_creditmemo/view'), + 'field' => 'creditmemo_id' + ) + ), + 'filter' => false, + 'sortable' => false, + 'is_system' => true, + 'header_css_class' => 'col-actions', + 'column_css_class' => 'col-actions' + )); + + $this->addExportType('*/*/exportCsv', Mage::helper('Mage_Sales_Helper_Data')->__('CSV')); + $this->addExportType('*/*/exportExcel', Mage::helper('Mage_Sales_Helper_Data')->__('Excel XML')); + + return parent::_prepareColumns(); + } + + protected function _prepareMassaction() + { + $this->setMassactionIdField('entity_id'); + $this->getMassactionBlock()->setFormFieldName('creditmemo_ids'); + $this->getMassactionBlock()->setUseSelectAll(false); + + $this->getMassactionBlock()->addItem('pdfcreditmemos_order', array( + 'label'=> Mage::helper('Mage_Sales_Helper_Data')->__('PDF Credit Memos'), + 'url' => $this->getUrl('*/sales_creditmemo/pdfcreditmemos'), + )); + + return $this; + } + + public function getRowUrl($row) + { + if (!Mage::getSingleton('Mage_Core_Model_Authorization') + ->isAllowed(Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL) + ) { + return false; + } + + return $this->getUrl('*/sales_creditmemo/view', + array( + 'creditmemo_id'=> $row->getId(), + ) + ); + } + + public function getGridUrl() + { + return $this->getUrl('*/*/*', array('_current' => true)); + } + + + +} diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Invoice.php b/app/code/Mage/Adminhtml/Block/Sales/Invoice.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Invoice.php rename to app/code/Mage/Adminhtml/Block/Sales/Invoice.php diff --git a/app/code/Mage/Adminhtml/Block/Sales/Invoice/Grid.php b/app/code/Mage/Adminhtml/Block/Sales/Invoice/Grid.php new file mode 100644 index 0000000000000..950042b5e4059 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Sales/Invoice/Grid.php @@ -0,0 +1,182 @@ + + */ +class Mage_Adminhtml_Block_Sales_Invoice_Grid extends Mage_Adminhtml_Block_Widget_Grid +{ + + protected function _construct() + { + parent::_construct(); + $this->setId('sales_invoice_grid'); + $this->setUseAjax(true); + $this->setDefaultSort('created_at'); + $this->setDefaultDir('DESC'); + $this->setSaveParametersInSession(true); + } + + /** + * Retrieve collection class + * + * @return string + */ + protected function _getCollectionClass() + { + return 'Mage_Sales_Model_Resource_Order_Invoice_Grid_Collection'; + } + + protected function _prepareCollection() + { + $collection = Mage::getResourceModel($this->_getCollectionClass()); + $this->setCollection($collection); + return parent::_prepareCollection(); + } + + protected function _prepareColumns() + { + $this->addColumn('increment_id', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Invoice #'), + 'index' => 'increment_id', + 'type' => 'text', + 'header_css_class' => 'col-invoice-number', + 'column_css_class' => 'col-invoice-number' + )); + + $this->addColumn('created_at', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Invoice Date'), + 'index' => 'created_at', + 'type' => 'datetime', + 'header_css_class' => 'col-period', + 'column_css_class' => 'col-period' + )); + + $this->addColumn('order_increment_id', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Order #'), + 'index' => 'order_increment_id', + 'type' => 'text', + 'header_css_class' => 'col-order-number', + 'column_css_class' => 'col-order-number' + )); + + $this->addColumn('order_created_at', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Order Date'), + 'index' => 'order_created_at', + 'type' => 'datetime', + 'header_css_class' => 'col-period', + 'column_css_class' => 'col-period' + )); + + $this->addColumn('billing_name', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Bill to Name'), + 'index' => 'billing_name', + 'header_css_class' => 'col-name', + 'column_css_class' => 'col-name' + )); + + $this->addColumn('state', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Status'), + 'index' => 'state', + 'type' => 'options', + 'options' => Mage::getModel('Mage_Sales_Model_Order_Invoice')->getStates(), + 'header_css_class' => 'col-status', + 'column_css_class' => 'col-status' + )); + + $this->addColumn('grand_total', array( + 'header' => Mage::helper('Mage_Customer_Helper_Data')->__('Amount'), + 'index' => 'grand_total', + 'type' => 'currency', + 'align' => 'right', + 'currency' => 'order_currency_code', + 'header_css_class' => 'col-qty', + 'column_css_class' => 'col-qty' + )); + + $this->addColumn('action', + array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Action'), + 'width' => '50px', + 'type' => 'action', + 'getter' => 'getId', + 'actions' => array( + array( + 'caption' => Mage::helper('Mage_Sales_Helper_Data')->__('View'), + 'url' => array('base'=>'*/sales_invoice/view'), + 'field' => 'invoice_id' + ) + ), + 'filter' => false, + 'sortable' => false, + 'is_system' => true, + 'header_css_class' => 'col-actions', + 'column_css_class' => 'col-actions' + )); + + $this->addExportType('*/*/exportCsv', Mage::helper('Mage_Sales_Helper_Data')->__('CSV')); + $this->addExportType('*/*/exportExcel', Mage::helper('Mage_Sales_Helper_Data')->__('Excel XML')); + + return parent::_prepareColumns(); + } + + protected function _prepareMassaction() + { + $this->setMassactionIdField('entity_id'); + $this->getMassactionBlock()->setFormFieldName('invoice_ids'); + $this->getMassactionBlock()->setUseSelectAll(false); + + $this->getMassactionBlock()->addItem('pdfinvoices_order', array( + 'label'=> Mage::helper('Mage_Sales_Helper_Data')->__('PDF Invoices'), + 'url' => $this->getUrl('*/sales_invoice/pdfinvoices'), + )); + + return $this; + } + + public function getRowUrl($row) + { + if (!Mage::getSingleton('Mage_Core_Model_Authorization') + ->isAllowed(Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL) + ) { + return false; + } + + return $this->getUrl('*/sales_invoice/view', + array( + 'invoice_id'=> $row->getId(), + ) + ); + } + + public function getGridUrl() + { + return $this->getUrl('*/*/grid', array('_current' => true)); + } + +} diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php b/app/code/Mage/Adminhtml/Block/Sales/Items/Abstract.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php rename to app/code/Mage/Adminhtml/Block/Sales/Items/Abstract.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Items/Column/Default.php b/app/code/Mage/Adminhtml/Block/Sales/Items/Column/Default.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Items/Column/Default.php rename to app/code/Mage/Adminhtml/Block/Sales/Items/Column/Default.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Items/Column/Name.php b/app/code/Mage/Adminhtml/Block/Sales/Items/Column/Name.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Items/Column/Name.php rename to app/code/Mage/Adminhtml/Block/Sales/Items/Column/Name.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Items/Column/Name/Grouped.php b/app/code/Mage/Adminhtml/Block/Sales/Items/Column/Name/Grouped.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Items/Column/Name/Grouped.php rename to app/code/Mage/Adminhtml/Block/Sales/Items/Column/Name/Grouped.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Items/Column/Qty.php b/app/code/Mage/Adminhtml/Block/Sales/Items/Column/Qty.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Items/Column/Qty.php rename to app/code/Mage/Adminhtml/Block/Sales/Items/Column/Qty.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Items/Renderer/Configurable.php b/app/code/Mage/Adminhtml/Block/Sales/Items/Renderer/Configurable.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Items/Renderer/Configurable.php rename to app/code/Mage/Adminhtml/Block/Sales/Items/Renderer/Configurable.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Items/Renderer/Default.php b/app/code/Mage/Adminhtml/Block/Sales/Items/Renderer/Default.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Items/Renderer/Default.php rename to app/code/Mage/Adminhtml/Block/Sales/Items/Renderer/Default.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order.php b/app/code/Mage/Adminhtml/Block/Sales/Order.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order.php rename to app/code/Mage/Adminhtml/Block/Sales/Order.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Abstract.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Abstract.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Abstract.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Abstract.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Address.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Address.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Address.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Address.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Address/Form.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Address/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Address/Form.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Address/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Comments/View.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Comments/View.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Comments/View.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Comments/View.php diff --git a/app/code/Mage/Adminhtml/Block/Sales/Order/Create.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create.php new file mode 100644 index 0000000000000..d7069fbb7e6c6 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Sales/Order/Create.php @@ -0,0 +1,141 @@ + + */ + +class Mage_Adminhtml_Block_Sales_Order_Create extends Mage_Adminhtml_Block_Widget_Form_Container +{ + protected function _construct() + { + $this->_objectId = 'order_id'; + $this->_controller = 'sales_order'; + $this->_mode = 'create'; + + parent::_construct(); + + $this->setId('sales_order_create'); + + $customerId = $this->_getSession()->getCustomerId(); + $storeId = $this->_getSession()->getStoreId(); + + + $this->_updateButton('save', 'label', Mage::helper('Mage_Sales_Helper_Data')->__('Submit Order')); + $this->_updateButton('save', 'onclick', "order.submit()"); + $this->_updateButton('save', 'id', 'submit_order_top_button'); + if (is_null($customerId) || !$storeId) { + $this->_updateButton('save', 'style', 'display:none'); + } + + $this->_updateButton('back', 'id', 'back_order_top_button'); + $this->_updateButton('back', 'onclick', 'setLocation(\'' . $this->getBackUrl() . '\')'); + + $this->_updateButton('reset', 'id', 'reset_order_top_button'); + + if (is_null($customerId)) { + $this->_updateButton('reset', 'style', 'display:none'); + } else { + $this->_updateButton('back', 'style', 'display:none'); + } + + $confirm = Mage::helper('Mage_Sales_Helper_Data')->__('Are you sure you want to cancel this order?'); + $this->_updateButton('reset', 'label', Mage::helper('Mage_Sales_Helper_Data')->__('Cancel')); + $this->_updateButton('reset', 'class', 'cancel'); + $this->_updateButton('reset', 'onclick', 'deleteConfirm(\''.$confirm.'\', \'' . $this->getCancelUrl() . '\')'); + + $pageTitle = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Sales_Order_Create_Header')->toHtml(); + if (is_object($this->getLayout()->getBlock('page-title'))) { + $this->getLayout()->getBlock('page-title')->setPageTitle($pageTitle); + } + } + + /** + * Prepare header html + * + * @return string + */ + public function getHeaderHtml() + { + $out = '
' + . $this->getLayout()->createBlock('Mage_Adminhtml_Block_Sales_Order_Create_Header')->toHtml() + . '
'; + return $out; + } + + /** + * Prepare form html. Add block for configurable product modification interface + * + * @return string + */ + public function getFormHtml() + { + $html = parent::getFormHtml(); + return $html; + } + + public function getHeaderWidth() + { + return 'width: 70%;'; + } + + /** + * Retrieve quote session object + * + * @return Mage_Adminhtml_Model_Session_Quote + */ + protected function _getSession() + { + return Mage::getSingleton('Mage_Adminhtml_Model_Session_Quote'); + } + + public function getCancelUrl() + { + if ($this->_getSession()->getOrder()->getId()) { + $url = $this->getUrl('*/sales_order/view', array( + 'order_id' => Mage::getSingleton('Mage_Adminhtml_Model_Session_Quote')->getOrder()->getId() + )); + } else { + $url = $this->getUrl('*/*/cancel'); + } + + return $url; + } + + /** + * Get URL for back (reset) button + * + * @return string + */ + public function getBackUrl() + { + return $this->getUrl('*/' . $this->_controller . '/'); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Abstract.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Abstract.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Abstract.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Abstract.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Billing/Address.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Billing/Address.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Billing/Address.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Billing/Address.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Billing/Method.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Billing/Method.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Billing/Method.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Billing/Method.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Billing/Method/Form.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Billing/Method/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Billing/Method/Form.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Billing/Method/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Comment.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Comment.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Comment.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Comment.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Coupons.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Coupons.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Coupons.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Coupons.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Coupons/Form.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Coupons/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Coupons/Form.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Coupons/Form.php diff --git a/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Customer.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Customer.php new file mode 100644 index 0000000000000..0ad5c53b15735 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Customer.php @@ -0,0 +1,59 @@ + + */ + +class Mage_Adminhtml_Block_Sales_Order_Create_Customer extends Mage_Adminhtml_Block_Sales_Order_Create_Abstract +{ + + protected function _construct() + { + parent::_construct(); + $this->setId('sales_order_create_customer'); + } + + public function getHeaderText() + { + return Mage::helper('Mage_Sales_Helper_Data')->__('Please Select a Customer'); + } + + public function getButtonsHtml() + { + $addButtonData = array( + 'label' => Mage::helper('Mage_Sales_Helper_Data')->__('Create New Customer'), + 'onclick' => 'order.setCustomerId(false)', + 'class' => 'action-add', + ); + return $this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Button')->setData($addButtonData)->toHtml(); + } + +} diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Customer/Grid.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Customer/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Customer/Grid.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Customer/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Data.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Data.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Data.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Data.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Form.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Form.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Form/Abstract.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Form/Abstract.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Form/Abstract.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Form/Abstract.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Form/Account.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Form/Account.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Form/Account.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Form/Account.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Form/Address.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Form/Address.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Form/Address.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Form/Address.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Giftmessage.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Giftmessage.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Giftmessage.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Giftmessage.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Giftmessage/Form.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Giftmessage/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Giftmessage/Form.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Giftmessage/Form.php diff --git a/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Header.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Header.php new file mode 100644 index 0000000000000..eb20b71b77b52 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Header.php @@ -0,0 +1,61 @@ + + */ +class Mage_Adminhtml_Block_Sales_Order_Create_Header extends Mage_Adminhtml_Block_Sales_Order_Create_Abstract +{ + protected function _toHtml() + { + if ($this->_getSession()->getOrder()->getId()) { + return Mage::helper('Mage_Sales_Helper_Data')->__('Edit Order #%s', $this->_getSession()->getOrder()->getIncrementId()); + } + + $customerId = $this->getCustomerId(); + $storeId = $this->getStoreId(); + $out = ''; + if ($customerId && $storeId) { + $out.= Mage::helper('Mage_Sales_Helper_Data')->__('Create New Order for %s in %s', $this->getCustomer()->getName(), $this->getStore()->getName()); + } + elseif (!is_null($customerId) && $storeId){ + $out.= Mage::helper('Mage_Sales_Helper_Data')->__('Create New Order for New Customer in %s', $this->getStore()->getName()); + } + elseif ($customerId) { + $out.= Mage::helper('Mage_Sales_Helper_Data')->__('Create New Order for %s', $this->getCustomer()->getName()); + } + elseif (!is_null($customerId)){ + $out.= Mage::helper('Mage_Sales_Helper_Data')->__('Create New Order for New Customer'); + } + else { + $out.= Mage::helper('Mage_Sales_Helper_Data')->__('Create New Order'); + } + $out = $this->escapeHtml($out); + return $out; + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Items.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Items.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Items.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Items.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Items/Grid.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Items/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Items/Grid.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Items/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Load.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Load.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Load.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Load.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Messages.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Messages.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Messages.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Messages.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Newsletter.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Newsletter.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Newsletter.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Newsletter.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Newsletter/Form.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Newsletter/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Newsletter/Form.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Newsletter/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Search.php similarity index 98% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Search.php index 6d5888d66b9b2..06e79907ed75e 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search.php +++ b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Search.php @@ -51,7 +51,7 @@ public function getButtonsHtml() $addButtonData = array( 'label' => Mage::helper('Mage_Sales_Helper_Data')->__('Add Selected Product(s) to Order'), 'onclick' => 'order.productGridAddSelected()', - 'class' => 'add', + 'class' => 'action-add', ); return $this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Button')->setData($addButtonData)->toHtml(); } diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid/Renderer/Price.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid/Renderer/Price.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid/Renderer/Price.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid/Renderer/Price.php diff --git a/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid/Renderer/Product.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid/Renderer/Product.php new file mode 100644 index 0000000000000..def2ec6e6052b --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid/Renderer/Product.php @@ -0,0 +1,51 @@ + + */ +class Mage_Adminhtml_Block_Sales_Order_Create_Search_Grid_Renderer_Product extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Text +{ + /** + * Render product name to add Configure link + * + * @param Varien_Object $row + * @return string + */ + public function render(Varien_Object $row) + { + $rendered = parent::render($row); + $isConfigurable = $row->canConfigure(); + $style = $isConfigurable ? '' : 'disabled'; + $prodAttributes = $isConfigurable ? sprintf('list_type = "product_to_add" product_id = %s', $row->getId()) : 'disabled="disabled"'; + return sprintf('%s', + $style, $prodAttributes, Mage::helper('Mage_Sales_Helper_Data')->__('Configure')) . $rendered; + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid/Renderer/Qty.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid/Renderer/Qty.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid/Renderer/Qty.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid/Renderer/Qty.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Shipping/Address.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Shipping/Address.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Shipping/Address.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Shipping/Address.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Shipping/Method.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Shipping/Method.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Shipping/Method.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Shipping/Method.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Shipping/Method/Form.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Shipping/Method/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Shipping/Method/Form.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Shipping/Method/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Abstract.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Abstract.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Abstract.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Abstract.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Cart.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Cart.php similarity index 98% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Cart.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Cart.php index 55e679877d3c6..8785ed4e59f76 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Cart.php +++ b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Cart.php @@ -107,8 +107,7 @@ protected function _prepareLayout() $deleteAllConfirmString = Mage::helper('Mage_Sales_Helper_Data')->__('Are you sure you want to delete all items from shopping cart?'); $this->addChild('empty_customer_cart_button', 'Mage_Adminhtml_Block_Widget_Button', array( 'label' => Mage::helper('Mage_Sales_Helper_Data')->__('Clear Shopping Cart'), - 'onclick' => 'order.clearShoppingCart(\'' . $deleteAllConfirmString . '\')', - 'style' => 'float: right;' + 'onclick' => 'order.clearShoppingCart(\'' . $deleteAllConfirmString . '\')' )); return parent::_prepareLayout(); diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Compared.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Compared.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Compared.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Compared.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Pcompared.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Pcompared.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Pcompared.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Pcompared.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Pviewed.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Pviewed.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Pviewed.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Pviewed.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Reorder.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Reorder.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Reorder.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Reorder.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Viewed.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Viewed.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Viewed.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Viewed.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Wishlist.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Wishlist.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Wishlist.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar/Wishlist.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Store.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Store.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Store.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Store.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Store/Select.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Store/Select.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Store/Select.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Store/Select.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Totals.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Totals.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Totals.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Totals.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Default.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Default.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Default.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Default.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Discount.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Discount.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Discount.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Discount.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Grandtotal.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Grandtotal.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Grandtotal.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Grandtotal.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Shipping.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Shipping.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Shipping.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Shipping.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Subtotal.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Subtotal.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Subtotal.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Subtotal.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Table.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Table.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Table.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Table.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Tax.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Tax.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Tax.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Create/Totals/Tax.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create/Adjustments.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create/Adjustments.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create/Adjustments.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create/Adjustments.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create/Form.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create/Form.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create/Items.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create/Items.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create/Items.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create/Items.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Totals.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Totals.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Totals.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Totals.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View/Comments.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View/Comments.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View/Comments.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View/Comments.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View/Form.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View/Form.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View/Items.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View/Items.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View/Items.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View/Items.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Invoice/Create.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Invoice/Create.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Form.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Form.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Items.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Items.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Items.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Items.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Tracking.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Tracking.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Tracking.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Tracking.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Totals.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Invoice/Totals.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Totals.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Invoice/Totals.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/View.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Invoice/View.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/View.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Invoice/View.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/View/Comments.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Invoice/View/Comments.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/View/Comments.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Invoice/View/Comments.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/View/Form.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Invoice/View/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/View/Form.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Invoice/View/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/View/Items.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Invoice/View/Items.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/View/Items.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Invoice/View/Items.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Payment.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Payment.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Payment.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Payment.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/Create.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/Create.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create/Form.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/Create/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create/Form.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/Create/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create/Items.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/Create/Items.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create/Items.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/Create/Items.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create/Tracking.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/Create/Tracking.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create/Tracking.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/Create/Tracking.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging/Grid.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging/Grid.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Tracking/Info.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/Tracking/Info.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Tracking/Info.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/Tracking/Info.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/View.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/View.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/View.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/View.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/View/Comments.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/View/Comments.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/View/Comments.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/View/Comments.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/View/Form.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/View/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/View/Form.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/View/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/View/Items.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/View/Items.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/View/Items.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/View/Items.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/View/Tracking.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/View/Tracking.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/View/Tracking.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Shipment/View/Tracking.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Status.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Status.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Status.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/Assign.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Status/Assign.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/Assign.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Status/Assign.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/Assign/Form.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Status/Assign/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/Assign/Form.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Status/Assign/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/Edit.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Status/Edit.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/Edit.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Status/Edit.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Status/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Status/Edit/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/Grid.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Status/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/Grid.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Status/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/New.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Status/New.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/New.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Status/New.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/New/Form.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Status/New/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/New/Form.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Status/New/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Totalbar.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Totalbar.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Totalbar.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Totalbar.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Totals.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Totals.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Totals.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Totals.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Totals/Item.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Totals/Item.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Totals/Item.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Totals/Item.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Totals/Tax.php b/app/code/Mage/Adminhtml/Block/Sales/Order/Totals/Tax.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/Totals/Tax.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/Totals/Tax.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View.php b/app/code/Mage/Adminhtml/Block/Sales/Order/View.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/View.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/View.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Form.php b/app/code/Mage/Adminhtml/Block/Sales/Order/View/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Form.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/View/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Giftmessage.php b/app/code/Mage/Adminhtml/Block/Sales/Order/View/Giftmessage.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Giftmessage.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/View/Giftmessage.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/History.php b/app/code/Mage/Adminhtml/Block/Sales/Order/View/History.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/View/History.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/View/History.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Info.php b/app/code/Mage/Adminhtml/Block/Sales/Order/View/Info.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Info.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/View/Info.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Items.php b/app/code/Mage/Adminhtml/Block/Sales/Order/View/Items.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Items.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/View/Items.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Items/Renderer/Default.php b/app/code/Mage/Adminhtml/Block/Sales/Order/View/Items/Renderer/Default.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Items/Renderer/Default.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/View/Items/Renderer/Default.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Messages.php b/app/code/Mage/Adminhtml/Block/Sales/Order/View/Messages.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Messages.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/View/Messages.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/Creditmemos.php b/app/code/Mage/Adminhtml/Block/Sales/Order/View/Tab/Creditmemos.php similarity index 90% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/Creditmemos.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/View/Tab/Creditmemos.php index 091484b9add41..eda1256cef9f8 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/Creditmemos.php +++ b/app/code/Mage/Adminhtml/Block/Sales/Order/View/Tab/Creditmemos.php @@ -76,19 +76,24 @@ protected function _prepareColumns() { $this->addColumn('increment_id', array( 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Credit Memo #'), - 'width' => '120px', 'index' => 'increment_id', + 'header_css_class' => 'col-memo', + 'column_css_class' => 'col-memo' )); $this->addColumn('billing_name', array( 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Bill to Name'), 'index' => 'billing_name', + 'header_css_class' => 'col-name', + 'column_css_class' => 'col-name' )); $this->addColumn('created_at', array( 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Created At'), 'index' => 'created_at', 'type' => 'datetime', + 'header_css_class' => 'col-period', + 'column_css_class' => 'col-period' )); $this->addColumn('state', array( @@ -96,6 +101,8 @@ protected function _prepareColumns() 'index' => 'state', 'type' => 'options', 'options' => Mage::getModel('Mage_Sales_Model_Order_Creditmemo')->getStates(), + 'header_css_class' => 'col-status', + 'column_css_class' => 'col-status' )); $this->addColumn('base_grand_total', array( @@ -103,6 +110,8 @@ protected function _prepareColumns() 'index' => 'base_grand_total', 'type' => 'currency', 'currency' => 'base_currency_code', + 'header_css_class' => 'col-refunded', + 'column_css_class' => 'col-refunded' )); return parent::_prepareColumns(); diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/History.php b/app/code/Mage/Adminhtml/Block/Sales/Order/View/Tab/History.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/History.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/View/Tab/History.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/Info.php b/app/code/Mage/Adminhtml/Block/Sales/Order/View/Tab/Info.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/Info.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/View/Tab/Info.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/Invoices.php b/app/code/Mage/Adminhtml/Block/Sales/Order/View/Tab/Invoices.php similarity index 90% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/Invoices.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/View/Tab/Invoices.php index 63e393f62df2d..a3e0596df0d9d 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/Invoices.php +++ b/app/code/Mage/Adminhtml/Block/Sales/Order/View/Tab/Invoices.php @@ -77,18 +77,23 @@ protected function _prepareColumns() $this->addColumn('increment_id', array( 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Invoice #'), 'index' => 'increment_id', - 'width' => '120px', + 'header_css_class' => 'col-invoice-number', + 'column_css_class' => 'col-invoice-number' )); $this->addColumn('billing_name', array( 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Bill to Name'), 'index' => 'billing_name', + 'header_css_class' => 'col-name', + 'column_css_class' => 'col-name' )); $this->addColumn('created_at', array( 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Invoice Date'), 'index' => 'created_at', 'type' => 'datetime', + 'header_css_class' => 'col-period', + 'column_css_class' => 'col-period' )); $this->addColumn('state', array( @@ -96,6 +101,8 @@ protected function _prepareColumns() 'index' => 'state', 'type' => 'options', 'options' => Mage::getModel('Mage_Sales_Model_Order_Invoice')->getStates(), + 'header_css_class' => 'col-status', + 'column_css_class' => 'col-status' )); $this->addColumn('base_grand_total', array( @@ -103,6 +110,8 @@ protected function _prepareColumns() 'index' => 'base_grand_total', 'type' => 'currency', 'currency' => 'base_currency_code', + 'header_css_class' => 'col-qty', + 'column_css_class' => 'col-qty' )); return parent::_prepareColumns(); diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/Shipments.php b/app/code/Mage/Adminhtml/Block/Sales/Order/View/Tab/Shipments.php similarity index 91% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/Shipments.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/View/Tab/Shipments.php index dd73813c98d0e..5391e5c0f170e 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/Shipments.php +++ b/app/code/Mage/Adminhtml/Block/Sales/Order/View/Tab/Shipments.php @@ -71,23 +71,31 @@ protected function _prepareColumns() $this->addColumn('increment_id', array( 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Shipment #'), 'index' => 'increment_id', + 'header_css_class' => 'col-memo', + 'column_css_class' => 'col-memo' )); $this->addColumn('shipping_name', array( 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Ship to Name'), 'index' => 'shipping_name', + 'header_css_class' => 'col-name', + 'column_css_class' => 'col-name' )); $this->addColumn('created_at', array( 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Date Shipped'), 'index' => 'created_at', 'type' => 'datetime', + 'header_css_class' => 'col-period', + 'column_css_class' => 'col-period' )); $this->addColumn('total_qty', array( 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Total Qty'), 'index' => 'total_qty', 'type' => 'number', + 'header_css_class' => 'col-qty', + 'column_css_class' => 'col-qty' )); return parent::_prepareColumns(); diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/Transactions.php b/app/code/Mage/Adminhtml/Block/Sales/Order/View/Tab/Transactions.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/Transactions.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/View/Tab/Transactions.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tabs.php b/app/code/Mage/Adminhtml/Block/Sales/Order/View/Tabs.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tabs.php rename to app/code/Mage/Adminhtml/Block/Sales/Order/View/Tabs.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Reorder/Renderer/Action.php b/app/code/Mage/Adminhtml/Block/Sales/Reorder/Renderer/Action.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Reorder/Renderer/Action.php rename to app/code/Mage/Adminhtml/Block/Sales/Reorder/Renderer/Action.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Shipment.php b/app/code/Mage/Adminhtml/Block/Sales/Shipment.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Shipment.php rename to app/code/Mage/Adminhtml/Block/Sales/Shipment.php diff --git a/app/code/Mage/Adminhtml/Block/Sales/Shipment/Grid.php b/app/code/Mage/Adminhtml/Block/Sales/Shipment/Grid.php new file mode 100644 index 0000000000000..1524e07d0d593 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Sales/Shipment/Grid.php @@ -0,0 +1,202 @@ + + */ +class Mage_Adminhtml_Block_Sales_Shipment_Grid extends Mage_Adminhtml_Block_Widget_Grid +{ + + /** + * Initialization + */ + protected function _construct() + { + parent::_construct(); + $this->setId('sales_shipment_grid'); + $this->setDefaultSort('created_at'); + $this->setDefaultDir('DESC'); + } + + /** + * Retrieve collection class + * + * @return string + */ + protected function _getCollectionClass() + { + return 'Mage_Sales_Model_Resource_Order_Shipment_Grid_Collection'; + } + + /** + * Prepare and set collection of grid + * + * @return Mage_Adminhtml_Block_Widget_Grid + */ + protected function _prepareCollection() + { + $collection = Mage::getResourceModel($this->_getCollectionClass()); + $this->setCollection($collection); + return parent::_prepareCollection(); + } + + /** + * Prepare and add columns to grid + * + * @return Mage_Adminhtml_Block_Widget_Grid + */ + protected function _prepareColumns() + { + $this->addColumn('increment_id', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Shipment #'), + 'index' => 'increment_id', + 'type' => 'text', + 'header_css_class' => 'col-shipment-number', + 'column_css_class' => 'col-shipment-number' + )); + + $this->addColumn('created_at', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Date Shipped'), + 'index' => 'created_at', + 'type' => 'datetime', + 'header_css_class' => 'col-period', + 'column_css_class' => 'col-period' + )); + + $this->addColumn('order_increment_id', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Order #'), + 'index' => 'order_increment_id', + 'type' => 'text', + 'header_css_class' => 'col-order-number', + 'column_css_class' => 'col-order-number' + )); + + $this->addColumn('order_created_at', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Order Date'), + 'index' => 'order_created_at', + 'type' => 'datetime', + 'header_css_class' => 'col-period', + 'column_css_class' => 'col-period' + )); + + $this->addColumn('shipping_name', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Ship to Name'), + 'index' => 'shipping_name', + 'header_css_class' => 'col-memo', + 'column_css_class' => 'col-memo' + )); + + $this->addColumn('total_qty', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Total Qty'), + 'index' => 'total_qty', + 'type' => 'number', + 'header_css_class' => 'col-qty', + 'column_css_class' => 'col-qty' + )); + + $this->addColumn('action', + array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Action'), + 'type' => 'action', + 'getter' => 'getId', + 'actions' => array( + array( + 'caption' => Mage::helper('Mage_Sales_Helper_Data')->__('View'), + 'url' => array('base'=>'*/sales_shipment/view'), + 'field' => 'shipment_id' + ) + ), + 'filter' => false, + 'sortable' => false, + 'is_system' => true, + 'header_css_class' => 'col-actions', + 'column_css_class' => 'col-actions' + )); + + $this->addExportType('*/*/exportCsv', Mage::helper('Mage_Sales_Helper_Data')->__('CSV')); + $this->addExportType('*/*/exportExcel', Mage::helper('Mage_Sales_Helper_Data')->__('Excel XML')); + + return parent::_prepareColumns(); + } + + /** + * Get url for row + * + * @param string $row + * @return string + */ + public function getRowUrl($row) + { + if (!Mage::getSingleton('Mage_Core_Model_Authorization') + ->isAllowed(Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL) + ) { + return false; + } + + return $this->getUrl('*/sales_shipment/view', + array( + 'shipment_id'=> $row->getId(), + ) + ); + } + + /** + * Prepare and set options for massaction + * + * @return Mage_Adminhtml_Block_Sales_Shipment_Grid + */ + protected function _prepareMassaction() + { + $this->setMassactionIdField('entity_id'); + $this->getMassactionBlock()->setFormFieldName('shipment_ids'); + $this->getMassactionBlock()->setUseSelectAll(false); + + $this->getMassactionBlock()->addItem('pdfshipments_order', array( + 'label'=> Mage::helper('Mage_Sales_Helper_Data')->__('PDF Packing Slips'), + 'url' => $this->getUrl('*/sales_shipment/pdfshipments'), + )); + + $this->getMassactionBlock()->addItem('print_shipping_label', array( + 'label'=> Mage::helper('Mage_Sales_Helper_Data')->__('Print Shipping Labels'), + 'url' => $this->getUrl('*/sales_order_shipment/massPrintShippingLabel'), + )); + + return $this; + } + + /** + * Get url of grid + * + * @return string + */ + public function getGridUrl() + { + return $this->getUrl('*/*/*', array('_current' => true)); + } + +} diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Totals.php b/app/code/Mage/Adminhtml/Block/Sales/Totals.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Totals.php rename to app/code/Mage/Adminhtml/Block/Sales/Totals.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Transactions.php b/app/code/Mage/Adminhtml/Block/Sales/Transactions.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Transactions.php rename to app/code/Mage/Adminhtml/Block/Sales/Transactions.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Child/Grid.php b/app/code/Mage/Adminhtml/Block/Sales/Transactions/Child/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Child/Grid.php rename to app/code/Mage/Adminhtml/Block/Sales/Transactions/Child/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Detail.php b/app/code/Mage/Adminhtml/Block/Sales/Transactions/Detail.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Detail.php rename to app/code/Mage/Adminhtml/Block/Sales/Transactions/Detail.php diff --git a/app/code/Mage/Adminhtml/Block/Sales/Transactions/Detail/Grid.php b/app/code/Mage/Adminhtml/Block/Sales/Transactions/Detail/Grid.php new file mode 100644 index 0000000000000..0fbd22617c75d --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Sales/Transactions/Detail/Grid.php @@ -0,0 +1,104 @@ + + */ +class Mage_Adminhtml_Block_Sales_Transactions_Detail_Grid extends Mage_Adminhtml_Block_Widget_Grid +{ + /** + * Initialize default sorting and html ID + */ + protected function _construct() + { + $this->setId('transactionDetailsGrid'); + $this->setPagerVisibility(false); + $this->setFilterVisibility(false); + } + + /** + * Prepare collection for grid + * + * @return Mage_Adminhtml_Block_Widget_Grid + */ + protected function _prepareCollection() + { + $collection = new Varien_Data_Collection(); + foreach ($this->getTransactionAdditionalInfo() as $key => $value) { + $data = new Varien_Object(array('key' => $key, 'value' => $value)); + $collection->addItem($data); + } + + $this->setCollection($collection); + return parent::_prepareCollection(); + } + + /** + * Add columns to grid + * + * @return Mage_Adminhtml_Block_Widget_Grid + */ + protected function _prepareColumns() + { + $this->addColumn('key', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Key'), + 'index' => 'key', + 'sortable' => false, + 'type' => 'text', + 'header_css_class' => 'col-key', + 'column_css_class' => 'col-key' + )); + + $this->addColumn('value', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Value'), + 'index' => 'value', + 'sortable' => false, + 'type' => 'text', + 'escape' => true, + 'header_css_class' => 'col-value', + 'column_css_class' => 'col-value' + )); + + return parent::_prepareColumns(); + } + + /** + * Retrieve Transaction addtitional info + * + * @return array + */ + public function getTransactionAdditionalInfo() + { + $info = Mage::registry('current_transaction')->getAdditionalInformation( + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS + ); + return (is_array($info)) ? $info : array(); + } +} diff --git a/app/code/Mage/Adminhtml/Block/Sales/Transactions/Grid.php b/app/code/Mage/Adminhtml/Block/Sales/Transactions/Grid.php new file mode 100644 index 0000000000000..82b293e6cb9bb --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Sales/Transactions/Grid.php @@ -0,0 +1,177 @@ + + */ +class Mage_Adminhtml_Block_Sales_Transactions_Grid extends Mage_Adminhtml_Block_Widget_Grid +{ + /** + * Set grid params + * + */ + protected function _construct() + { + parent::_construct(); + $this->setId('order_transactions'); + $this->setUseAjax(true); + $this->setDefaultSort('created_at'); + $this->setDefaultDir('DESC'); + $this->setSaveParametersInSession(true); + } + + /** + * Prepare collection for grid + * + * @return Mage_Adminhtml_Block_Widget_Grid + */ + protected function _prepareCollection() + { + $collection = $this->getCollection(); + if (!$collection) { + $collection = Mage::getResourceModel('Mage_Sales_Model_Resource_Order_Payment_Transaction_Collection'); + } + $order = Mage::registry('current_order'); + if ($order) { + $collection->addOrderIdFilter($order->getId()); + } + $collection->addOrderInformation(array('increment_id')); + $collection->addPaymentInformation(array('method')); + $this->setCollection($collection); + return parent::_prepareCollection(); + } + + /** + * Add columns to grid + * + * @return Mage_Adminhtml_Block_Widget_Grid + */ + protected function _prepareColumns() + { + $this->addColumn('transaction_id', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('ID #'), + 'index' => 'transaction_id', + 'type' => 'number', + 'header_css_class' => 'col-id', + 'column_css_class' => 'col-id' + )); + + $this->addColumn('increment_id', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Order ID'), + 'index' => 'increment_id', + 'type' => 'text', + 'header_css_class' => 'col-order-id', + 'column_css_class' => 'col-order-id' + )); + + $this->addColumn('txn_id', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Transaction ID'), + 'index' => 'txn_id', + 'type' => 'text', + 'header_css_class' => 'col-transaction-id', + 'column_css_class' => 'col-transaction-id' + )); + + $this->addColumn('parent_txn_id', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Parent Transaction ID'), + 'index' => 'parent_txn_id', + 'type' => 'text', + 'header_css_class' => 'col-parent-transaction-id', + 'column_css_class' => 'col-parent-transaction-id' + )); + + $this->addColumn('method', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Payment Method Name'), + 'index' => 'method', + 'type' => 'options', + 'options' => Mage::helper('Mage_Payment_Helper_Data')->getPaymentMethodList(true), + 'option_groups' => Mage::helper('Mage_Payment_Helper_Data')->getPaymentMethodList(true, true, true), + 'header_css_class' => 'col-method', + 'column_css_class' => 'col-method' + )); + + $this->addColumn('txn_type', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Transaction Type'), + 'index' => 'txn_type', + 'type' => 'options', + 'options' => Mage::getSingleton('Mage_Sales_Model_Order_Payment_Transaction')->getTransactionTypes(), + 'header_css_class' => 'col-transaction-type', + 'column_css_class' => 'col-transaction-type' + )); + + $this->addColumn('is_closed', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Is Closed'), + 'index' => 'is_closed', + 'width' => 1, + 'type' => 'options', + 'align' => 'center', + 'options' => array( + 1 => Mage::helper('Mage_Sales_Helper_Data')->__('Yes'), + 0 => Mage::helper('Mage_Sales_Helper_Data')->__('No'), + ), + 'header_css_class' => 'col-closed', + 'column_css_class' => 'col-closed' + )); + + $this->addColumn('created_at', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Created At'), + 'index' => 'created_at', + 'width' => 1, + 'type' => 'datetime', + 'align' => 'center', + 'default' => $this->__('N/A'), + 'html_decorators' => array('nobr'), + 'header_css_class' => 'col-period', + 'column_css_class' => 'col-period' + )); + + return parent::_prepareColumns(); + } + + /** + * Retrieve grid url + * + * @return string + */ + public function getGridUrl() + { + return $this->getUrl('*/*/grid', array('_current' => true)); + } + + /** + * Retrieve row url + * + * @return string + */ + public function getRowUrl($item) + { + return $this->getUrl('*/*/view', array('txn_id' => $item->getId())); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Shipping/Carrier/Tablerate/Grid.php b/app/code/Mage/Adminhtml/Block/Shipping/Carrier/Tablerate/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Shipping/Carrier/Tablerate/Grid.php rename to app/code/Mage/Adminhtml/Block/Shipping/Carrier/Tablerate/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sitemap.php b/app/code/Mage/Adminhtml/Block/Sitemap.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sitemap.php rename to app/code/Mage/Adminhtml/Block/Sitemap.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sitemap/Edit.php b/app/code/Mage/Adminhtml/Block/Sitemap/Edit.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sitemap/Edit.php rename to app/code/Mage/Adminhtml/Block/Sitemap/Edit.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sitemap/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Sitemap/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sitemap/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/Sitemap/Edit/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sitemap/Grid/Renderer/Action.php b/app/code/Mage/Adminhtml/Block/Sitemap/Grid/Renderer/Action.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sitemap/Grid/Renderer/Action.php rename to app/code/Mage/Adminhtml/Block/Sitemap/Grid/Renderer/Action.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sitemap/Grid/Renderer/Link.php b/app/code/Mage/Adminhtml/Block/Sitemap/Grid/Renderer/Link.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sitemap/Grid/Renderer/Link.php rename to app/code/Mage/Adminhtml/Block/Sitemap/Grid/Renderer/Link.php diff --git a/app/code/core/Mage/Adminhtml/Block/Sitemap/Grid/Renderer/Time.php b/app/code/Mage/Adminhtml/Block/Sitemap/Grid/Renderer/Time.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Sitemap/Grid/Renderer/Time.php rename to app/code/Mage/Adminhtml/Block/Sitemap/Grid/Renderer/Time.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Account/Edit.php b/app/code/Mage/Adminhtml/Block/System/Account/Edit.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Account/Edit.php rename to app/code/Mage/Adminhtml/Block/System/Account/Edit.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Account/Edit/Form.php b/app/code/Mage/Adminhtml/Block/System/Account/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Account/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/System/Account/Edit/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Cache/Edit.php b/app/code/Mage/Adminhtml/Block/System/Cache/Edit.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Cache/Edit.php rename to app/code/Mage/Adminhtml/Block/System/Cache/Edit.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Cache/Form.php b/app/code/Mage/Adminhtml/Block/System/Cache/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Cache/Form.php rename to app/code/Mage/Adminhtml/Block/System/Cache/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Currency.php b/app/code/Mage/Adminhtml/Block/System/Currency.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Currency.php rename to app/code/Mage/Adminhtml/Block/System/Currency.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Currency/Edit/Form.php b/app/code/Mage/Adminhtml/Block/System/Currency/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Currency/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/System/Currency/Edit/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Currency/Edit/Tab/Main.php b/app/code/Mage/Adminhtml/Block/System/Currency/Edit/Tab/Main.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Currency/Edit/Tab/Main.php rename to app/code/Mage/Adminhtml/Block/System/Currency/Edit/Tab/Main.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Currency/Edit/Tab/Rates.php b/app/code/Mage/Adminhtml/Block/System/Currency/Edit/Tab/Rates.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Currency/Edit/Tab/Rates.php rename to app/code/Mage/Adminhtml/Block/System/Currency/Edit/Tab/Rates.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Currency/Edit/Tabs.php b/app/code/Mage/Adminhtml/Block/System/Currency/Edit/Tabs.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Currency/Edit/Tabs.php rename to app/code/Mage/Adminhtml/Block/System/Currency/Edit/Tabs.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Currency/Rate/Matrix.php b/app/code/Mage/Adminhtml/Block/System/Currency/Rate/Matrix.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Currency/Rate/Matrix.php rename to app/code/Mage/Adminhtml/Block/System/Currency/Rate/Matrix.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Currency/Rate/Services.php b/app/code/Mage/Adminhtml/Block/System/Currency/Rate/Services.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Currency/Rate/Services.php rename to app/code/Mage/Adminhtml/Block/System/Currency/Rate/Services.php diff --git a/app/code/Mage/Adminhtml/Block/System/Design.php b/app/code/Mage/Adminhtml/Block/System/Design.php new file mode 100644 index 0000000000000..4cd3d49734a94 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/System/Design.php @@ -0,0 +1,44 @@ +setTemplate('system/design/index.phtml'); + + $this->addChild('add_new_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Add Design Change'), + 'onclick' => "setLocation('".$this->getUrl('*/*/new')."')", + 'class' => 'add' + )); + + $this->getLayout()->getBlock('page-title')->setPageTitle('Schedule'); + + return parent::_prepareLayout(); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/System/Design/Edit.php b/app/code/Mage/Adminhtml/Block/System/Design/Edit.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Design/Edit.php rename to app/code/Mage/Adminhtml/Block/System/Design/Edit.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Design/Edit/Tab/General.php b/app/code/Mage/Adminhtml/Block/System/Design/Edit/Tab/General.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Design/Edit/Tab/General.php rename to app/code/Mage/Adminhtml/Block/System/Design/Edit/Tab/General.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Design/Edit/Tabs.php b/app/code/Mage/Adminhtml/Block/System/Design/Edit/Tabs.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Design/Edit/Tabs.php rename to app/code/Mage/Adminhtml/Block/System/Design/Edit/Tabs.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Email/Template.php b/app/code/Mage/Adminhtml/Block/System/Email/Template.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Email/Template.php rename to app/code/Mage/Adminhtml/Block/System/Email/Template.php diff --git a/app/code/Mage/Adminhtml/Block/System/Email/Template/Edit.php b/app/code/Mage/Adminhtml/Block/System/Email/Template/Edit.php new file mode 100644 index 0000000000000..81a4bb11edad2 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/System/Email/Template/Edit.php @@ -0,0 +1,466 @@ + + * @method array getTemplateOptions() + */ +class Mage_Adminhtml_Block_System_Email_Template_Edit extends Mage_Adminhtml_Block_Widget +{ + /** + * @var Mage_Core_Model_Registry + */ + protected $_registryManager; + + /** + * @var Mage_Backend_Model_Menu_Config + */ + protected $_menuConfig; + + /** + * @var Mage_Backend_Model_Config_Structure + */ + protected $_configStructure; + + /** + * Template file + * + * @var string + */ + protected $_template = 'system/email/template/edit.phtml'; + + /** + * @param Mage_Core_Block_Template_Context $context + * @param Mage_Core_Model_Registry $registry + * @param Mage_Backend_Model_Menu_Config $menuConfig + * @param Mage_Backend_Model_Config_Structure $configStructure + * @param array $data + */ + public function __construct( + Mage_Core_Block_Template_Context $context, + Mage_Core_Model_Registry $registry, + Mage_Backend_Model_Menu_Config $menuConfig, + Mage_Backend_Model_Config_Structure $configStructure, + array $data = array() + ) + { + parent::__construct($context, $data); + $this->_registryManager = $registry; + $this->_menuConfig = $menuConfig; + $this->_configStructure = $configStructure; + } + + protected function _prepareLayout() + { + $this->setChild('back_button', + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Button') + ->setData( + array( + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Back'), + 'onclick' => "window.location.href = '" . $this->getUrl('*/*') . "'", + 'class' => 'back' + ) + ) + ); + + + $this->setChild('reset_button', + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Button') + ->setData( + array( + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Reset'), + 'onclick' => 'window.location.href = window.location.href' + ) + ) + ); + + + $this->setChild('delete_button', + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Button') + ->setData( + array( + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Delete Template'), + 'onclick' => 'templateControl.deleteTemplate();', + 'class' => 'delete' + ) + ) + ); + + $this->setChild('to_plain_button', + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Button') + ->setData( + array( + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Convert to Plain Text'), + 'onclick' => 'templateControl.stripTags();', + 'id' => 'convert_button' + ) + ) + ); + + + $this->setChild('to_html_button', + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Button') + ->setData( + array( + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Return Html Version'), + 'onclick' => 'templateControl.unStripTags();', + 'id' => 'convert_button_back', + 'style' => 'display:none' + ) + ) + ); + + $this->setChild('toggle_button', + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Button') + ->setData( + array( + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Toggle Editor'), + 'onclick' => 'templateControl.toggleEditor();', + 'id' => 'toggle_button' + ) + ) + ); + + + $this->setChild('preview_button', + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Button') + ->setData( + array( + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Preview Template'), + 'onclick' => 'templateControl.preview();' + ) + ) + ); + + $this->setChild('save_button', + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Button') + ->setData( + array( + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Save Template'), + 'onclick' => 'templateControl.save();', + 'class' => 'save' + ) + ) + ); + + $this->setChild('load_button', + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Button') + ->setData( + array( + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Load Template'), + 'onclick' => 'templateControl.load();', + 'type' => 'button', + 'class' => 'save' + ) + ) + ); + + + $this->addChild('form', 'Mage_Adminhtml_Block_System_Email_Template_Edit_Form'); + return parent::_prepareLayout(); + } + + /** + * Collect, sort and set template options + * + * @return Mage_Adminhtml_Block_System_Email_Template_Edit + */ + protected function _beforeToHtml() + { + $groupedOptions = array(); + foreach (Mage_Core_Model_Email_Template::getDefaultTemplatesAsOptionsArray() as $option) { + $groupedOptions[$option['group']][] = $option; + } + ksort($groupedOptions); + $this->setData('template_options', $groupedOptions); + + return parent::_beforeToHtml(); + } + + public function getBackButtonHtml() + { + return $this->getChildHtml('back_button'); + } + + public function getToggleButtonHtml() + { + return $this->getChildHtml('toggle_button'); + } + + + public function getResetButtonHtml() + { + return $this->getChildHtml('reset_button'); + } + + public function getToPlainButtonHtml() + { + return $this->getChildHtml('to_plain_button'); + } + + public function getToHtmlButtonHtml() + { + return $this->getChildHtml('to_html_button'); + } + + public function getSaveButtonHtml() + { + return $this->getChildHtml('save_button'); + } + + public function getPreviewButtonHtml() + { + return $this->getChildHtml('preview_button'); + } + + public function getDeleteButtonHtml() + { + return $this->getChildHtml('delete_button'); + } + + public function getLoadButtonHtml() + { + return $this->getChildHtml('load_button'); + } + + /** + * Return edit flag for block + * + * @return boolean + */ + public function getEditMode() + { + return $this->getEmailTemplate()->getId(); + } + + /** + * Return header text for form + * + * @return string + */ + public function getHeaderText() + { + if($this->getEditMode()) { + return Mage::helper('Mage_Adminhtml_Helper_Data')->__('Edit Email Template'); + } + + return Mage::helper('Mage_Adminhtml_Helper_Data')->__('New Email Template'); + } + + + /** + * Return form block HTML + * + * @return string + */ + public function getFormHtml() + { + return $this->getChildHtml('form'); + } + + /** + * Return action url for form + * + * @return string + */ + public function getSaveUrl() + { + return $this->getUrl('*/*/save', array('_current' => true)); + } + + /** + * Return preview action url for form + * + * @return string + */ + public function getPreviewUrl() + { + return $this->getUrl('*/*/preview'); + } + + public function isTextType() + { + return $this->getEmailTemplate()->isPlain(); + } + + /** + * Return delete url for customer group + * + * @return string + */ + public function getDeleteUrl() + { + return $this->getUrl('*/*/delete', array('_current' => true)); + } + + /** + * Retrive email template model + * + * @return Mage_Core_Model_Email_Template + */ + public function getEmailTemplate() + { + return $this->_registryManager->registry('current_email_template'); + } + + /** + * Load template url + * + * @return string + */ + public function getLoadUrl() + { + return $this->getUrl('*/*/defaultTemplate'); + } + + /** + * Get paths of where current template is used as default + * + * @param bool $asJSON + * @return string + */ + public function getUsedDefaultForPaths($asJSON = true) + { + /** @var $template Mage_Adminhtml_Model_Email_Template */ + $template = $this->getEmailTemplate(); + $paths = $template->getSystemConfigPathsWhereUsedAsDefault(); + $pathsParts = $this->_getSystemConfigPathsParts($paths); + if($asJSON){ + return $this->helper('Mage_Core_Helper_Data')->jsonEncode($pathsParts); + } + return $pathsParts; + } + + /** + * Get paths of where current template is currently used + * + * @param bool $asJSON + * @return string + */ + public function getUsedCurrentlyForPaths($asJSON = true) + { + /** @var $template Mage_Adminhtml_Model_Email_Template */ + $template = $this->getEmailTemplate(); + $paths = $template->getSystemConfigPathsWhereUsedCurrently(); + $pathsParts = $this->_getSystemConfigPathsParts($paths); + if($asJSON){ + return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($pathsParts); + } + return $pathsParts; + } + + /** + * Convert xml config pathes to decorated names + * + * @param array $paths + * @return array + */ + protected function _getSystemConfigPathsParts($paths) + { + $result = $urlParams = $prefixParts = array(); + $scopeLabel = $this->helper('Mage_Backend_Helper_Data')->__('GLOBAL'); + if ($paths) { + /** @var $menu Mage_Backend_Model_Menu */ + $menu = $this->_menuConfig->getMenu(); + $item = $menu->get('Mage_Adminhtml::system'); + // create prefix path parts + $prefixParts[] = array( + 'title' => $item->getModuleHelper()->__($item->getTitle()), + ); + $item = $menu->get('Mage_Adminhtml::system_config'); + $prefixParts[] = array( + 'title' => $item->getModuleHelper()->__($item->getTitle()), + 'url' => $this->getUrl('adminhtml/system_config/'), + ); + + $pathParts = $prefixParts; + foreach ($paths as $pathData) { + $pathDataParts = explode('/', $pathData['path']); + $sectionName = array_shift($pathDataParts); + + $urlParams = array('section' => $sectionName); + if (isset($pathData['scope']) && isset($pathData['scope_id'])) { + switch ($pathData['scope']) { + case 'stores': + $store = Mage::app()->getStore($pathData['scope_id']); + if ($store) { + $urlParams['website'] = $store->getWebsite()->getCode(); + $urlParams['store'] = $store->getCode(); + $scopeLabel = $store->getWebsite()->getName() . '/' . $store->getName(); + } + break; + case 'websites': + $website = Mage::app()->getWebsite($pathData['scope_id']); + if ($website) { + $urlParams['website'] = $website->getCode(); + $scopeLabel = $website->getName(); + } + break; + default: + break; + } + } + $pathParts[] = array( + 'title' => $this->_configStructure->getElement($sectionName)->getLabel(), + 'url' => $this->getUrl('adminhtml/system_config/edit', $urlParams), + ); + $elementPathParts = array($sectionName); + while (count($pathDataParts) != 1) { + $elementPathParts[] = array_shift($pathDataParts); + $pathParts[] = array( + 'title' => $this->_configStructure + ->getElementByPathParts($elementPathParts) + ->getLabel() + ); + } + $elementPathParts[] = array_shift($pathDataParts); + $pathParts[] = array( + 'title' => $this->_configStructure + ->getElementByPathParts($elementPathParts) + ->getLabel(), + 'scope' => $scopeLabel + ); + $result[] = $pathParts; + $pathParts = $prefixParts; + } + } + return $result; + } + + /** + * Return original template code of current template + * + * @return string + */ + public function getOrigTemplateCode() + { + return $this->getEmailTemplate()->getOrigTemplateCode(); + } +} diff --git a/app/code/Mage/Adminhtml/Block/System/Email/Template/Edit/Form.php b/app/code/Mage/Adminhtml/Block/System/Email/Template/Edit/Form.php new file mode 100644 index 0000000000000..52938193a56da --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/System/Email/Template/Edit/Form.php @@ -0,0 +1,191 @@ + + */ + +class Mage_Adminhtml_Block_System_Email_Template_Edit_Form extends Mage_Adminhtml_Block_Widget_Form +{ + /** + * Prepare layout. + * Add files to use dialog windows + * + * @return Mage_Adminhtml_Block_System_Email_Template_Edit_Form + */ + protected function _prepareLayout() + { + if ($head = $this->getLayout()->getBlock('head')) { + $head->addJs('prototype/window.js') + ->addCss('prototype/windows/themes/default.css') + ->addCss('Mage_Core::prototype/magento.css') + ->addJs('Mage_Adminhtml::variables.js'); + } + return parent::_prepareLayout(); + } + + /** + * Add fields to form and create template info form + * + * @return Mage_Adminhtml_Block_Widget_Form + */ + protected function _prepareForm() + { + $form = new Varien_Data_Form(); + + $fieldset = $form->addFieldset('base_fieldset', array( + 'legend' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Template Information'), + 'class' => 'fieldset-wide' + )); + + $templateId = $this->getEmailTemplate()->getId(); + if ($templateId) { + $fieldset->addField('used_currently_for', 'label', array( + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Used Currently For'), + 'container_id' => 'used_currently_for', + 'after_element_html' => + '', + )); + } + + if (!$templateId) { + $fieldset->addField('used_default_for', 'label', array( + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Used as Default For'), + 'container_id' => 'used_default_for', + 'after_element_html' => + '', + )); + } + + $fieldset->addField('template_code', 'text', array( + 'name'=>'template_code', + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Template Name'), + 'required' => true + + )); + + $fieldset->addField('template_subject', 'text', array( + 'name'=>'template_subject', + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Template Subject'), + 'required' => true + )); + + $fieldset->addField('orig_template_variables', 'hidden', array( + 'name' => 'orig_template_variables', + )); + + $fieldset->addField('variables', 'hidden', array( + 'name' => 'variables', + 'value' => Zend_Json::encode($this->getVariables()) + )); + + $fieldset->addField('template_variables', 'hidden', array( + 'name' => 'template_variables', + )); + + $insertVariableButton = $this->getLayout() + ->createBlock('Mage_Adminhtml_Block_Widget_Button', '', array('data' => array( + 'type' => 'button', + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Insert Variable...'), + 'onclick' => 'templateControl.openVariableChooser();return false;' + ))); + + $fieldset->addField('insert_variable', 'note', array( + 'text' => $insertVariableButton->toHtml() + )); + + $fieldset->addField('template_text', 'textarea', array( + 'name'=>'template_text', + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Template Content'), + 'title' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Template Content'), + 'required' => true, + 'style' => 'height:24em;', + )); + + if (!$this->getEmailTemplate()->isPlain()) { + $fieldset->addField('template_styles', 'textarea', array( + 'name'=>'template_styles', + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Template Styles'), + 'container_id' => 'field_template_styles' + )); + } + + if ($templateId) { + $form->addValues($this->getEmailTemplate()->getData()); + } + + if ($values = Mage::getSingleton('Mage_Adminhtml_Model_Session')->getData('email_template_form_data', true)) { + $form->setValues($values); + } + + $this->setForm($form); + + return parent::_prepareForm(); + } + + /** + * Return current email template model + * + * @return Mage_Core_Model_Email_Template + */ + public function getEmailTemplate() + { + return Mage::registry('current_email_template'); + } + + /** + * Retrieve variables to insert into email + * + * @return array + */ + public function getVariables() + { + $variables = array(); + $variables[] = Mage::getModel('Mage_Core_Model_Source_Email_Variables') + ->toOptionArray(true); + $customVariables = Mage::getModel('Mage_Core_Model_Variable') + ->getVariablesOptionArray(true); + if ($customVariables) { + $variables[] = $customVariables; + } + /* @var $template Mage_Core_Model_Email_Template */ + $template = Mage::registry('current_email_template'); + if ($template->getId() && $templateVariables = $template->getVariablesOptionArray(true)) { + $variables[] = $templateVariables; + } + return $variables; + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Grid/Filter/Type.php b/app/code/Mage/Adminhtml/Block/System/Email/Template/Grid/Filter/Type.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Email/Template/Grid/Filter/Type.php rename to app/code/Mage/Adminhtml/Block/System/Email/Template/Grid/Filter/Type.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Grid/Renderer/Action.php b/app/code/Mage/Adminhtml/Block/System/Email/Template/Grid/Renderer/Action.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Email/Template/Grid/Renderer/Action.php rename to app/code/Mage/Adminhtml/Block/System/Email/Template/Grid/Renderer/Action.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Grid/Renderer/Sender.php b/app/code/Mage/Adminhtml/Block/System/Email/Template/Grid/Renderer/Sender.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Email/Template/Grid/Renderer/Sender.php rename to app/code/Mage/Adminhtml/Block/System/Email/Template/Grid/Renderer/Sender.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Grid/Renderer/Type.php b/app/code/Mage/Adminhtml/Block/System/Email/Template/Grid/Renderer/Type.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Email/Template/Grid/Renderer/Type.php rename to app/code/Mage/Adminhtml/Block/System/Email/Template/Grid/Renderer/Type.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Preview.php b/app/code/Mage/Adminhtml/Block/System/Email/Template/Preview.php similarity index 88% rename from app/code/core/Mage/Adminhtml/Block/System/Email/Template/Preview.php rename to app/code/Mage/Adminhtml/Block/System/Email/Template/Preview.php index 8dd9329866fd1..8678f812e63bd 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Preview.php +++ b/app/code/Mage/Adminhtml/Block/System/Email/Template/Preview.php @@ -42,7 +42,7 @@ protected function _toHtml() { /** @var $template Mage_Core_Model_Email_Template */ $template = Mage::getModel('Mage_Core_Model_Email_Template', - array('area' => Mage_Core_Model_App_Area::AREA_FRONTEND)); + array('data' => array('area' => Mage_Core_Model_App_Area::AREA_FRONTEND))); $id = (int)$this->getRequest()->getParam('id'); if ($id) { $template->load($id); @@ -62,6 +62,12 @@ protected function _toHtml() Magento_Profiler::start("email_template_proccessing"); $vars = array(); + $template->setDesignConfig( + array( + 'area' => Mage::getDesign()->getArea(), + 'store' => Mage::getSingleton('Mage_Core_Model_StoreManager')->getDefaultStoreView()->getId() + ) + ); $templateProcessed = $template->getProcessedTemplate($vars, true); if ($template->isPlain()) { diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Delete.php b/app/code/Mage/Adminhtml/Block/System/Store/Delete.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Store/Delete.php rename to app/code/Mage/Adminhtml/Block/System/Store/Delete.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Delete/Form.php b/app/code/Mage/Adminhtml/Block/System/Store/Delete/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Store/Delete/Form.php rename to app/code/Mage/Adminhtml/Block/System/Store/Delete/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Delete/Group.php b/app/code/Mage/Adminhtml/Block/System/Store/Delete/Group.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Store/Delete/Group.php rename to app/code/Mage/Adminhtml/Block/System/Store/Delete/Group.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Delete/Website.php b/app/code/Mage/Adminhtml/Block/System/Store/Delete/Website.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Store/Delete/Website.php rename to app/code/Mage/Adminhtml/Block/System/Store/Delete/Website.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Edit.php b/app/code/Mage/Adminhtml/Block/System/Store/Edit.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Store/Edit.php rename to app/code/Mage/Adminhtml/Block/System/Store/Edit.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Edit/Form/Group.php b/app/code/Mage/Adminhtml/Block/System/Store/Edit/Form/Group.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Store/Edit/Form/Group.php rename to app/code/Mage/Adminhtml/Block/System/Store/Edit/Form/Group.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Edit/Form/Store.php b/app/code/Mage/Adminhtml/Block/System/Store/Edit/Form/Store.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Store/Edit/Form/Store.php rename to app/code/Mage/Adminhtml/Block/System/Store/Edit/Form/Store.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Edit/Form/Website.php b/app/code/Mage/Adminhtml/Block/System/Store/Edit/Form/Website.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Store/Edit/Form/Website.php rename to app/code/Mage/Adminhtml/Block/System/Store/Edit/Form/Website.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Edit/FormAbstract.php b/app/code/Mage/Adminhtml/Block/System/Store/Edit/FormAbstract.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Store/Edit/FormAbstract.php rename to app/code/Mage/Adminhtml/Block/System/Store/Edit/FormAbstract.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Grid/Render/Group.php b/app/code/Mage/Adminhtml/Block/System/Store/Grid/Render/Group.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Store/Grid/Render/Group.php rename to app/code/Mage/Adminhtml/Block/System/Store/Grid/Render/Group.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Grid/Render/Store.php b/app/code/Mage/Adminhtml/Block/System/Store/Grid/Render/Store.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Store/Grid/Render/Store.php rename to app/code/Mage/Adminhtml/Block/System/Store/Grid/Render/Store.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Grid/Render/Website.php b/app/code/Mage/Adminhtml/Block/System/Store/Grid/Render/Website.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Store/Grid/Render/Website.php rename to app/code/Mage/Adminhtml/Block/System/Store/Grid/Render/Website.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Store.php b/app/code/Mage/Adminhtml/Block/System/Store/Store.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Store/Store.php rename to app/code/Mage/Adminhtml/Block/System/Store/Store.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Variable.php b/app/code/Mage/Adminhtml/Block/System/Variable.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Variable.php rename to app/code/Mage/Adminhtml/Block/System/Variable.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit.php b/app/code/Mage/Adminhtml/Block/System/Variable/Edit.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Variable/Edit.php rename to app/code/Mage/Adminhtml/Block/System/Variable/Edit.php diff --git a/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit/Form.php b/app/code/Mage/Adminhtml/Block/System/Variable/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/System/Variable/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/System/Variable/Edit/Form.php diff --git a/app/code/Mage/Adminhtml/Block/Tax/Rate/Form.php b/app/code/Mage/Adminhtml/Block/Tax/Rate/Form.php new file mode 100644 index 0000000000000..d5828e52357a5 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Tax/Rate/Form.php @@ -0,0 +1,197 @@ + + */ + +class Mage_Adminhtml_Block_Tax_Rate_Form extends Mage_Adminhtml_Block_Widget_Form +{ + const FORM_ELEMENT_ID = 'rate-form'; + + protected $_titles = null; + + protected $_template = 'tax/rate/form.phtml'; + + + protected function _construct() + { + parent::_construct(); + $this->setDestElementId(self::FORM_ELEMENT_ID); + + } + + protected function _prepareForm() + { + $rateObject = new Varien_Object(Mage::getSingleton('Mage_Tax_Model_Calculation_Rate')->getData()); + $form = new Varien_Data_Form(); + + $countries = Mage::getModel('Mage_Directory_Model_Config_Source_Country')->toOptionArray(); + unset($countries[0]); + + if (!$rateObject->hasTaxCountryId()) { + $rateObject->setTaxCountryId(Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_DEFAULT_COUNTRY)); + } + + if (!$rateObject->hasTaxRegionId()) { + $rateObject->setTaxRegionId(Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_DEFAULT_REGION)); + } + + $regionCollection = Mage::getModel('Mage_Directory_Model_Region') + ->getCollection() + ->addCountryFilter($rateObject->getTaxCountryId()); + + $regions = $regionCollection->toOptionArray(); + if ($regions) { + $regions[0]['label'] = '*'; + } else { + $regions = array(array('value' => '', 'label' => '*')); + } + + $fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('Mage_Tax_Helper_Data')->__('Tax Rate Information'))); + + if ($rateObject->getTaxCalculationRateId() > 0) { + $fieldset->addField('tax_calculation_rate_id', 'hidden', array( + 'name' => 'tax_calculation_rate_id', + 'value' => $rateObject->getTaxCalculationRateId() + )); + } + + $fieldset->addField('code', 'text', array( + 'name' => 'code', + 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('Tax Identifier'), + 'title' => Mage::helper('Mage_Tax_Helper_Data')->__('Tax Identifier'), + 'class' => 'required-entry', + 'required' => true, + )); + + $fieldset->addField('tax_country_id', 'select', array( + 'name' => 'tax_country_id', + 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('Country'), + 'required' => true, + 'values' => $countries + )); + + $fieldset->addField('tax_region_id', 'select', array( + 'name' => 'tax_region_id', + 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('State'), + 'values' => $regions + )); + + $fieldset->addField('zip_is_range', 'checkbox', array( + 'name' => 'zip_is_range', + 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('Zip/Post is Range'), + 'value' => '1' + )); + + if (!$rateObject->hasTaxPostcode()) { + $rateObject->setTaxPostcode(Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_DEFAULT_POSTCODE)); + } + + $fieldset->addField('tax_postcode', 'text', array( + 'name' => 'tax_postcode', + 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('Zip/Post Code'), + 'note' => Mage::helper('Mage_Tax_Helper_Data')->__("'*' - matches any; 'xyz*' - matches any that begins on 'xyz' and not longer than %d.", Mage::helper('Mage_Tax_Helper_Data')->getPostCodeSubStringLength()), + )); + + $fieldset->addField('zip_from', 'text', array( + 'name' => 'zip_from', + 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('Range From'), + 'required' => true, + 'maxlength' => 9, + 'class' => 'validate-digits', + 'css_class' => 'hidden', + )); + + $fieldset->addField('zip_to', 'text', array( + 'name' => 'zip_to', + 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('Range To'), + 'required' => true, + 'maxlength' => 9, + 'class' => 'validate-digits', + 'css_class' => 'hidden', + )); + + $fieldset->addField('rate', 'text', array( + 'name' => 'rate', + 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('Rate Percent'), + 'title' => Mage::helper('Mage_Tax_Helper_Data')->__('Rate Percent'), + 'required' => true, + 'class' => 'validate-not-negative-number' + )); + + $form->setAction($this->getUrl('adminhtml/tax_rate/save')); + $form->setUseContainer(true); + $form->setId(self::FORM_ELEMENT_ID); + $form->setMethod('post'); + + if (!Mage::app()->hasSingleStore()) { + $form->addElement( + Mage::getBlockSingleton('Mage_Adminhtml_Block_Tax_Rate_Title_Fieldset') + ->setLegend(Mage::helper('Mage_Tax_Helper_Data') + ->__('Tax Titles')) + ); + } + + $rateData = $rateObject->getData(); + if ($rateObject->getZipIsRange()) { + list($rateData['zip_from'], $rateData['zip_to']) = explode('-', $rateData['tax_postcode']); + } + $form->setValues($rateData); + $this->setForm($form); + + return parent::_prepareForm(); + } + + /** + * Get Tax Rates Collection + * + * @return array + */ + public function getRateCollection() + { + if ($this->getData('rate_collection') == null) { + $rateCollection = Mage::getModel('Mage_Tax_Model_Calculation_Rate')->getCollection() + ->joinRegionTable(); + $rates = array(); + + foreach ($rateCollection as $rate) { + $item = $rate->getData(); + foreach ($rate->getTitles() as $title) { + $item['title[' . $title->getStoreId() . ']'] = $title->getValue(); + } + $rates[] = $item; + } + + $this->setRateCollection($rates); + } + return $this->getData('rate_collection'); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Tax/Rate/Grid/Renderer/Country.php b/app/code/Mage/Adminhtml/Block/Tax/Rate/Grid/Renderer/Country.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Tax/Rate/Grid/Renderer/Country.php rename to app/code/Mage/Adminhtml/Block/Tax/Rate/Grid/Renderer/Country.php diff --git a/app/code/core/Mage/Adminhtml/Block/Tax/Rate/Grid/Renderer/Data.php b/app/code/Mage/Adminhtml/Block/Tax/Rate/Grid/Renderer/Data.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Tax/Rate/Grid/Renderer/Data.php rename to app/code/Mage/Adminhtml/Block/Tax/Rate/Grid/Renderer/Data.php diff --git a/app/code/core/Mage/Adminhtml/Block/Tax/Rate/ImportExport.php b/app/code/Mage/Adminhtml/Block/Tax/Rate/ImportExport.php similarity index 79% rename from app/code/core/Mage/Adminhtml/Block/Tax/Rate/ImportExport.php rename to app/code/Mage/Adminhtml/Block/Tax/Rate/ImportExport.php index cf378054cded3..b96a45dca3584 100644 --- a/app/code/core/Mage/Adminhtml/Block/Tax/Rate/ImportExport.php +++ b/app/code/Mage/Adminhtml/Block/Tax/Rate/ImportExport.php @@ -28,4 +28,16 @@ class Mage_Adminhtml_Block_Tax_Rate_ImportExport extends Mage_Adminhtml_Block_Widget { protected $_template = 'tax/importExport.phtml'; + + /** + * @param Mage_Core_Block_Template_Context $context + * @param array $data + */ + public function __construct(Mage_Core_Block_Template_Context $context, array $data = array()) + { + parent::__construct($context, $data); + $this->setUseContainer(true); + } + + } diff --git a/app/code/core/Mage/Adminhtml/Block/Tax/Rate/ImportExportHeader.php b/app/code/Mage/Adminhtml/Block/Tax/Rate/ImportExportHeader.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Tax/Rate/ImportExportHeader.php rename to app/code/Mage/Adminhtml/Block/Tax/Rate/ImportExportHeader.php diff --git a/app/code/core/Mage/Adminhtml/Block/Tax/Rate/Title.php b/app/code/Mage/Adminhtml/Block/Tax/Rate/Title.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Tax/Rate/Title.php rename to app/code/Mage/Adminhtml/Block/Tax/Rate/Title.php diff --git a/app/code/core/Mage/Adminhtml/Block/Tax/Rate/Title/Fieldset.php b/app/code/Mage/Adminhtml/Block/Tax/Rate/Title/Fieldset.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Tax/Rate/Title/Fieldset.php rename to app/code/Mage/Adminhtml/Block/Tax/Rate/Title/Fieldset.php diff --git a/app/code/core/Mage/Adminhtml/Block/Tax/Rate/Toolbar/Add.php b/app/code/Mage/Adminhtml/Block/Tax/Rate/Toolbar/Add.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Tax/Rate/Toolbar/Add.php rename to app/code/Mage/Adminhtml/Block/Tax/Rate/Toolbar/Add.php diff --git a/app/code/core/Mage/Adminhtml/Block/Tax/Rate/Toolbar/Save.php b/app/code/Mage/Adminhtml/Block/Tax/Rate/Toolbar/Save.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Tax/Rate/Toolbar/Save.php rename to app/code/Mage/Adminhtml/Block/Tax/Rate/Toolbar/Save.php diff --git a/app/code/core/Mage/Adminhtml/Block/Tax/Rule.php b/app/code/Mage/Adminhtml/Block/Tax/Rule.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Tax/Rule.php rename to app/code/Mage/Adminhtml/Block/Tax/Rule.php diff --git a/app/code/core/Mage/Adminhtml/Block/Tax/Rule/Edit.php b/app/code/Mage/Adminhtml/Block/Tax/Rule/Edit.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Tax/Rule/Edit.php rename to app/code/Mage/Adminhtml/Block/Tax/Rule/Edit.php diff --git a/app/code/Mage/Adminhtml/Block/Tax/Rule/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Tax/Rule/Edit/Form.php new file mode 100644 index 0000000000000..fc557699d3067 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Tax/Rule/Edit/Form.php @@ -0,0 +1,233 @@ + + */ + +class Mage_Adminhtml_Block_Tax_Rule_Edit_Form extends Mage_Backend_Block_Widget_Form +{ + /** + * Init class + * + */ + protected function _construct() + { + parent::_construct(); + + $this->setId('taxRuleForm'); + $this->setTitle(Mage::helper('Mage_Tax_Helper_Data')->__('Tax Rule Information')); + $this->setUseContainer(true); + } + + /** + * + * return Mage_Adminhtml_Block_Widget_Form + */ + protected function _prepareForm() + { + $model = Mage::registry('tax_rule'); + $form = new Varien_Data_Form(array( + 'id' => 'edit_form', + 'action' => $this->getData('action'), + 'method' => 'post' + )); + + $fieldset = $form->addFieldset('base_fieldset', array( + 'legend' => Mage::helper('Mage_Tax_Helper_Data')->__('Tax Rule Information') + )); + + $rates = Mage::getModel('Mage_Tax_Model_Calculation_Rate') + ->getCollection() + ->toOptionArray(); + + $fieldset->addField('code', 'text', + array( + 'name' => 'code', + 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('Name'), + 'class' => 'required-entry', + 'required' => true, + ) + ); + + // Editable multiselect for customer tax class + $selectConfig = $this->getTaxClassSelectConfig(Mage_Tax_Model_Class::TAX_CLASS_TYPE_CUSTOMER); + $selectedCustomerTax = $model->getId() + ? $model->getCustomerTaxClasses() + : $model->getCustomerTaxClassWithDefault(); + $fieldset->addField($this->getTaxClassSelectHtmlId(Mage_Tax_Model_Class::TAX_CLASS_TYPE_CUSTOMER), + 'editablemultiselect', + array( + 'name' => $this->getTaxClassSelectHtmlId(Mage_Tax_Model_Class::TAX_CLASS_TYPE_CUSTOMER), + 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('Customer Tax Class'), + 'class' => 'required-entry', + 'values' => $model->getAllOptionsForClass(Mage_Tax_Model_Class::TAX_CLASS_TYPE_CUSTOMER), + 'value' => $selectedCustomerTax, + 'required' => true, + 'select_config' => $selectConfig, + ), + false, + true + ); + + // Editable multiselect for product tax class + $selectConfig = $this->getTaxClassSelectConfig(Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT); + $selectedProductTax = $model->getId() + ? $model->getProductTaxClasses() + : $model->getProductTaxClassWithDefault(); + $fieldset->addField($this->getTaxClassSelectHtmlId(Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT), + 'editablemultiselect', + array( + 'name' => $this->getTaxClassSelectHtmlId(Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT), + 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('Product Tax Class'), + 'class' => 'required-entry', + 'values' => $model->getAllOptionsForClass(Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT), + 'value' => $selectedProductTax, + 'required' => true, + 'select_config' => $selectConfig + ), + false, + true + ); + + $fieldset->addField('tax_rate', + 'editablemultiselect', + array( + 'name' => 'tax_rate', + 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('Tax Rate'), + 'class' => 'required-entry', + 'values' => $rates, + 'value' => $model->getRates(), + 'required' => true, + 'element_js_class' => 'TaxRateEditableMultiselect', + 'select_config' => array('is_entity_editable' => true), + ) + ); + + $fieldset->addField('priority', 'text', + array( + 'name' => 'priority', + 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('Priority'), + 'class' => 'validate-not-negative-number', + 'value' => (int) $model->getPriority(), + 'required' => true, + 'note' => Mage::helper('Mage_Tax_Helper_Data')->__('Tax rates at the same priority are added, others are compounded.'), + ), + false, + true + ); + $fieldset->addField('position', 'text', + array( + 'name' => 'position', + 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('Sort Order'), + 'class' => 'validate-not-negative-number', + 'value' => (int) $model->getPosition(), + 'required' => true, + ), + false, + true + ); + + if ($model->getId() > 0 ) { + $fieldset->addField('tax_calculation_rule_id', 'hidden', + array( + 'name' => 'tax_calculation_rule_id', + 'value' => $model->getId(), + 'no_span' => true + ) + ); + } + + $form->addValues($model->getData()); + $form->setAction($this->getUrl('*/tax_rule/save')); + $form->setUseContainer($this->getUseContainer()); + $this->setForm($form); + + return parent::_prepareForm(); + } + + /** + * Retrieve HTML element ID for corresponding tax class selector + * + * @param string $classType + * @return string + */ + public function getTaxClassSelectHtmlId($classType) + { + return 'tax_' . strtolower($classType) . '_class'; + } + + + /** + * Retrieve configuration options for tax class editable multiselect + * + * @param string $classType + * @return array + */ + public function getTaxClassSelectConfig($classType) + { + $config = array( + 'new_url' => $this->getUrl('adminhtml/tax_class/ajaxSave/'), + 'save_url' => $this->getUrl('adminhtml/tax_class/ajaxSave/'), + 'delete_url' => $this->getUrl('adminhtml/tax_class/ajaxDelete/'), + 'delete_confirm_message' => Mage::helper('Mage_Tax_Helper_Data')->__('Do you really want to delete this tax class?'), + 'target_select_id' => $this->getTaxClassSelectHtmlId($classType), + 'add_button_caption' => Mage::helper('Mage_Tax_Helper_Data')->__('Add New Tax Class'), + 'submit_data' => array( + 'class_type' => $classType, + 'form_key' => Mage::getSingleton('Mage_Core_Model_Session')->getFormKey(), + ), + 'entity_id_name' => 'class_id', + 'entity_value_name' => 'class_name', + 'is_entity_editable' => true + ); + return $config; + } + + /** + * Retrieve Tax Rate delete URL + * + * @return string + */ + public function getTaxRateDeleteUrl() + { + return $this->getUrl('admin/tax_rate/ajaxDelete/'); + } + + /** + * Retrieve Tax Rate save URL + * + * @return string + */ + public function getTaxRateSaveUrl() + { + return $this->getUrl('admin/tax_rate/ajaxSave/'); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Tax/Rule/Grid.php b/app/code/Mage/Adminhtml/Block/Tax/Rule/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Tax/Rule/Grid.php rename to app/code/Mage/Adminhtml/Block/Tax/Rule/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Template.php b/app/code/Mage/Adminhtml/Block/Template.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Template.php rename to app/code/Mage/Adminhtml/Block/Template.php diff --git a/app/code/Mage/Adminhtml/Block/Text/List.php b/app/code/Mage/Adminhtml/Block/Text/List.php new file mode 100644 index 0000000000000..7f40dc8d11337 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Text/List.php @@ -0,0 +1,37 @@ + + */ +class Mage_Adminhtml_Block_Text_List extends Mage_Core_Block_Text_List +{ +} diff --git a/app/code/core/Mage/Adminhtml/Block/Urlrewrite.php b/app/code/Mage/Adminhtml/Block/Urlrewrite.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Urlrewrite.php rename to app/code/Mage/Adminhtml/Block/Urlrewrite.php diff --git a/app/code/Mage/Adminhtml/Block/Urlrewrite/Catalog/Category/Edit.php b/app/code/Mage/Adminhtml/Block/Urlrewrite/Catalog/Category/Edit.php new file mode 100644 index 0000000000000..ddb8de3a58851 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Urlrewrite/Catalog/Category/Edit.php @@ -0,0 +1,112 @@ + + */ +class Mage_Adminhtml_Block_Urlrewrite_Catalog_Category_Edit extends Mage_Adminhtml_Block_Urlrewrite_Edit +{ + /** + * Prepare layout for URL rewrite creating for category + */ + protected function _prepareLayoutFeatures() + { + /** @var $helper Mage_Adminhtml_Helper_Data */ + $helper = Mage::helper('Mage_Adminhtml_Helper_Data'); + + if ($this->_getUrlRewrite()->getId()) { + $this->_headerText = Mage::helper('Mage_Adminhtml_Helper_Data')->__('Edit URL Rewrite for a Category'); + } else { + $this->_headerText = Mage::helper('Mage_Adminhtml_Helper_Data')->__('Add URL Rewrite for a Category'); + } + + if ($this->_getCategory()->getId()) { + $this->_addCategoryLinkBlock(); + $this->_addEditFormBlock(); + $this->_updateBackButtonLink($helper->getUrl('*/*/edit') . 'category'); + } else { + $this->_addUrlRewriteSelectorBlock(); + $this->_addCategoryTreeBlock(); + } + } + + /** + * Get or create new instance of category + * + * @return Mage_Catalog_Model_Product + */ + private function _getCategory() + { + if (!$this->hasData('category')) { + $this->setCategory(Mage::getModel('Mage_Catalog_Model_Category')); + } + return $this->getCategory(); + } + + /** + * Add child category link block + */ + private function _addCategoryLinkBlock() + { + /** @var $helper Mage_Adminhtml_Helper_Data */ + $helper = Mage::helper('Mage_Adminhtml_Helper_Data'); + $this->addChild('category_link', 'Mage_Adminhtml_Block_Urlrewrite_Link', array( + 'item_url' => $helper->getUrl('*/*/*') . 'category', + 'item_name' => $this->_getCategory()->getName(), + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Category:') + )); + } + + /** + * Add child category tree block + */ + private function _addCategoryTreeBlock() + { + $this->addChild('categories_tree', 'Mage_Adminhtml_Block_Urlrewrite_Catalog_Category_Tree'); + } + + /** + * Creates edit form block + * + * @return Mage_Adminhtml_Block_Urlrewrite_Catalog_Edit_Form + */ + protected function _createEditFormBlock() + { + return $this->getLayout()->createBlock('Mage_Adminhtml_Block_Urlrewrite_Catalog_Edit_Form', '', array( + 'data' => array( + 'category' => $this->_getCategory(), + 'url_rewrite' => $this->_getUrlRewrite() + ) + )); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Catalog/Category/Tree.php b/app/code/Mage/Adminhtml/Block/Urlrewrite/Catalog/Category/Tree.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Urlrewrite/Catalog/Category/Tree.php rename to app/code/Mage/Adminhtml/Block/Urlrewrite/Catalog/Category/Tree.php diff --git a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Catalog/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Urlrewrite/Catalog/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Urlrewrite/Catalog/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/Urlrewrite/Catalog/Edit/Form.php diff --git a/app/code/Mage/Adminhtml/Block/Urlrewrite/Catalog/Product/Edit.php b/app/code/Mage/Adminhtml/Block/Urlrewrite/Catalog/Product/Edit.php new file mode 100644 index 0000000000000..f5833b97b85a6 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Urlrewrite/Catalog/Product/Edit.php @@ -0,0 +1,183 @@ + + */ +class Mage_Adminhtml_Block_Urlrewrite_Catalog_Product_Edit extends Mage_Adminhtml_Block_Urlrewrite_Edit +{ + /** + * Prepare layout for URL rewrite creating for product + */ + protected function _prepareLayoutFeatures() + { + /** @var $helper Mage_Adminhtml_Helper_Data */ + $helper = Mage::helper('Mage_Adminhtml_Helper_Data'); + + if ($this->_getUrlRewrite()->getId()) { + $this->_headerText = Mage::helper('Mage_Adminhtml_Helper_Data')->__('Edit URL Rewrite for a Product'); + } else { + $this->_headerText = Mage::helper('Mage_Adminhtml_Helper_Data')->__('Add URL Rewrite for a Product'); + } + + if ($this->_getProduct()->getId()) { + $this->_addProductLinkBlock($this->_getProduct()); + } + + if ($this->_getCategory()->getId()) { + $this->_addCategoryLinkBlock(); + } + + if ($this->_getProduct()->getId()) { + if ($this->_getCategory()->getId() || !$this->getIsCategoryMode()) { + $this->_addEditFormBlock(); + $this->_updateBackButtonLink( + $helper->getUrl('*/*/edit', array('product' => $this->_getProduct()->getId())) . 'category' + ); + } else { + // categories selector & skip categories button + $this->_addCategoriesTreeBlock(); + $this->_addSkipCategoriesBlock(); + $this->_updateBackButtonLink($helper->getUrl('*/*/edit') . 'product'); + } + } else { + $this->_addUrlRewriteSelectorBlock(); + $this->_addProductsGridBlock(); + } + } + + /** + * Get or create new instance of product + * + * @return Mage_Catalog_Model_Product + */ + private function _getProduct() + { + if (!$this->hasData('product')) { + $this->setProduct(Mage::getModel('Mage_Catalog_Model_Product')); + } + return $this->getProduct(); + } + + /** + * Get or create new instance of category + * + * @return Mage_Catalog_Model_Category + */ + private function _getCategory() + { + if (!$this->hasData('category')) { + $this->setCategory(Mage::getModel('Mage_Catalog_Model_Category')); + } + return $this->getCategory(); + } + + /** + * Add child product link block + */ + private function _addProductLinkBlock() + { + /** @var $helper Mage_Adminhtml_Helper_Data */ + $helper = Mage::helper('Mage_Adminhtml_Helper_Data'); + $this->addChild('product_link', 'Mage_Adminhtml_Block_Urlrewrite_Link', array( + 'item_url' => $helper->getUrl('*/*/*') . 'product', + 'item_name' => $this->_getProduct()->getName(), + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Product:') + )); + } + + /** + * Add child category link block + */ + private function _addCategoryLinkBlock() + { + /** @var $helper Mage_Adminhtml_Helper_Data */ + $helper = Mage::helper('Mage_Adminhtml_Helper_Data'); + $this->addChild('category_link', 'Mage_Adminhtml_Block_Urlrewrite_Link', array( + 'item_url' => $helper->getUrl('*/*/*', array('product' => $this->_getProduct()->getId())) . 'category', + 'item_name' => $this->_getCategory()->getName(), + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Category:') + )); + } + + /** + * Add child products grid block + */ + private function _addProductsGridBlock() + { + $this->addChild('products_grid', 'Mage_Adminhtml_Block_Urlrewrite_Catalog_Product_Grid'); + } + + /** + * Add child Categories Tree block + */ + private function _addCategoriesTreeBlock() + { + $this->addChild('categories_tree', 'Mage_Adminhtml_Block_Urlrewrite_Catalog_Category_Tree'); + } + + /** + * Add child Skip Categories block + */ + private function _addSkipCategoriesBlock() + { + /** @var $helper Mage_Adminhtml_Helper_Data */ + $helper = Mage::helper('Mage_Adminhtml_Helper_Data'); + $this->addChild('skip_categories', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Skip Category Selection'), + 'onclick' => 'window.location = \'' + . $helper->getUrl('*/*/*', array('product' => $this->_getProduct()->getId())) . '\'', + 'class' => 'save', + 'level' => -1 + )); + } + + /** + * Creates edit form block + * + * @return Mage_Adminhtml_Block_Urlrewrite_Catalog_Edit_Form + */ + protected function _createEditFormBlock() + { + return $this->getLayout()->createBlock('Mage_Adminhtml_Block_Urlrewrite_Catalog_Edit_Form', '', array( + 'data' => array( + 'product' => $this->_getProduct(), + 'category' => $this->_getCategory(), + 'url_rewrite' => $this->_getUrlRewrite() + ) + )); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Catalog/Product/Grid.php b/app/code/Mage/Adminhtml/Block/Urlrewrite/Catalog/Product/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Urlrewrite/Catalog/Product/Grid.php rename to app/code/Mage/Adminhtml/Block/Urlrewrite/Catalog/Product/Grid.php diff --git a/app/code/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/Edit.php b/app/code/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/Edit.php new file mode 100644 index 0000000000000..b4ed207897ed3 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/Edit.php @@ -0,0 +1,112 @@ + + */ +class Mage_Adminhtml_Block_Urlrewrite_Cms_Page_Edit extends Mage_Adminhtml_Block_Urlrewrite_Edit +{ + /** + * Prepare layout for URL rewrite creating for CMS page + */ + protected function _prepareLayoutFeatures() + { + /** @var $helper Mage_Adminhtml_Helper_Data */ + $helper = Mage::helper('Mage_Adminhtml_Helper_Data'); + + if ($this->_getUrlRewrite()->getId()) { + $this->_headerText = Mage::helper('Mage_Adminhtml_Helper_Data')->__('Edit URL Rewrite for CMS page'); + } else { + $this->_headerText = Mage::helper('Mage_Adminhtml_Helper_Data')->__('Add URL Rewrite for CMS page'); + } + + if ($this->_getCmsPage()->getId()) { + $this->_addCmsPageLinkBlock(); + $this->_addEditFormBlock(); + $this->_updateBackButtonLink($helper->getUrl('*/*/edit') . 'cms_page'); + } else { + $this->_addUrlRewriteSelectorBlock(); + $this->_addCmsPageGridBlock(); + } + } + + /** + * Get or create new instance of CMS page + * + * @return Mage_Cms_Model_Page + */ + private function _getCmsPage() + { + if (!$this->hasData('cms_page')) { + $this->setCmsPage(Mage::getModel('Mage_Cms_Model_Page')); + } + return $this->getCmsPage(); + } + + /** + * Add child CMS page link block + */ + private function _addCmsPageLinkBlock() + { + /** @var $helper Mage_Adminhtml_Helper_Data */ + $helper = Mage::helper('Mage_Adminhtml_Helper_Data'); + $this->addChild('cms_page_link', 'Mage_Adminhtml_Block_Urlrewrite_Link', array( + 'item_url' => $helper->getUrl('*/*/*') . 'cms_page', + 'item_name' => $this->getCmsPage()->getTitle(), + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('CMS page:') + )); + } + + /** + * Add child CMS page block + */ + private function _addCmsPageGridBlock() + { + $this->addChild('cms_pages_grid', 'Mage_Adminhtml_Block_Urlrewrite_Cms_Page_Grid'); + } + + /** + * Creates edit form block + * + * @return Mage_Adminhtml_Block_Urlrewrite_Cms_Page_Edit_Form + */ + protected function _createEditFormBlock() + { + return $this->getLayout()->createBlock('Mage_Adminhtml_Block_Urlrewrite_Cms_Page_Edit_Form', '', array( + 'data' => array( + 'cms_page' => $this->_getCmsPage(), + 'url_rewrite' => $this->_getUrlRewrite() + ) + )); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/Edit/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/Grid.php b/app/code/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/Grid.php rename to app/code/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/Grid.php diff --git a/app/code/Mage/Adminhtml/Block/Urlrewrite/Edit.php b/app/code/Mage/Adminhtml/Block/Urlrewrite/Edit.php new file mode 100644 index 0000000000000..4884666f2ffd4 --- /dev/null +++ b/app/code/Mage/Adminhtml/Block/Urlrewrite/Edit.php @@ -0,0 +1,251 @@ + + */ +class Mage_Adminhtml_Block_Urlrewrite_Edit extends Mage_Adminhtml_Block_Widget_Container +{ + /** + * @var Mage_Adminhtml_Block_Urlrewrite_Selector + */ + private $_selectorBlock; + + /** + * Part for building some blocks names + * + * @var string + */ + protected $_controller = 'urlrewrite'; + + /** + * Generated buttons html cache + * + * @var string + */ + protected $_buttonsHtml; + + /** + * Prepare URL rewrite editing layout + * + * @return Mage_Adminhtml_Block_Urlrewrite_Edit + */ + protected function _prepareLayout() + { + $this->setTemplate('urlrewrite/edit.phtml'); + + $this->_addBackButton(); + $this->_prepareLayoutFeatures(); + + return parent::_prepareLayout(); + } + + /** + * Prepare featured blocks for layout of URL rewrite editing + */ + protected function _prepareLayoutFeatures() + { + /** @var $helper Mage_Adminhtml_Helper_Data */ + $helper = Mage::helper('Mage_Adminhtml_Helper_Data'); + + if ($this->_getUrlRewrite()->getId()) { + $this->_headerText = Mage::helper('Mage_Adminhtml_Helper_Data')->__('Edit URL Rewrite'); + } else { + $this->_headerText = Mage::helper('Mage_Adminhtml_Helper_Data')->__('Add New URL Rewrite'); + } + + $this->_updateBackButtonLink($helper->getUrl('*/*/edit') . $this->_getSelectorBlock()->getDefaultMode()); + $this->_addUrlRewriteSelectorBlock(); + $this->_addEditFormBlock(); + } + + /** + * Add child edit form block + */ + protected function _addEditFormBlock() + { + $this->setChild('form', $this->_createEditFormBlock()); + + if ($this->_getUrlRewrite()->getId()) { + $this->_addResetButton(); + $this->_addDeleteButton(); + } + + $this->_addSaveButton(); + } + + /** + * Add reset button + */ + protected function _addResetButton() + { + $this->_addButton('reset', array( + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Reset'), + 'onclick' => '$(\'edit_form\').reset()', + 'class' => 'scalable', + 'level' => -1 + )); + } + + /** + * Add back button + */ + protected function _addBackButton() + { + /** @var $helper Mage_Adminhtml_Helper_Data */ + $helper = Mage::helper('Mage_Adminhtml_Helper_Data'); + + $this->_addButton('back', array( + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Back'), + 'onclick' => 'setLocation(\'' . $helper->getUrl('*/*/') . '\')', + 'class' => 'back', + 'level' => -1 + )); + } + + /** + * Update Back button location link + * + * @param string $link + */ + protected function _updateBackButtonLink($link) + { + $this->_updateButton('back', 'onclick', 'setLocation(\'' . $link . '\')'); + } + + /** + * Add delete button + */ + protected function _addDeleteButton() + { + /** @var $helper Mage_Adminhtml_Helper_Data */ + $helper = Mage::helper('Mage_Adminhtml_Helper_Data'); + + $this->_addButton('delete', array( + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Delete'), + 'onclick' => 'deleteConfirm(\'' + . addslashes(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Are you sure you want to do this?')) + . '\', \'' . $helper->getUrl('*/*/delete', array('id' => $this->getUrlRewrite()->getId())) . '\')', + 'class' => 'scalable delete', + 'level' => -1 + )); + } + + /** + * Add save button + */ + protected function _addSaveButton() + { + $this->_addButton('save', array( + 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Save'), + 'class' => 'save', + 'level' => -1, + 'data_attribute' => array( + 'mage-init' => array( + 'button' => array('event' => 'save', 'target' => '#edit_form'), + ), + ), + )); + } + + /** + * Creates edit form block + * + * @return Mage_Adminhtml_Block_Urlrewrite_Edit_Form + */ + protected function _createEditFormBlock() + { + return $this->getLayout()->createBlock('Mage_Adminhtml_Block_Urlrewrite_Edit_Form', '', array('data' => array( + 'url_rewrite' => $this->_getUrlRewrite() + ))); + } + + /** + * Add child URL rewrite selector block + */ + protected function _addUrlRewriteSelectorBlock() + { + $this->setChild('selector', $this->_getSelectorBlock()); + } + + /** + * Get selector block + * + * @return Mage_Adminhtml_Block_Urlrewrite_Selector + */ + private function _getSelectorBlock() + { + if (!$this->_selectorBlock) { + $this->_selectorBlock = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Urlrewrite_Selector'); + } + return $this->_selectorBlock; + } + + /** + * Get container buttons HTML + * + * Since buttons are set as children, we remove them as children after generating them + * not to duplicate them in future + * + * @param null $area + * @return string + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function getButtonsHtml($area = null) + { + if (null === $this->_buttonsHtml) { + $this->_buttonsHtml = parent::getButtonsHtml(); + $layout = $this->getLayout(); + foreach ($this->getChildNames() as $name) { + $alias = $layout->getElementAlias($name); + if (false !== strpos($alias, '_button')) { + $layout->unsetChild($this->getNameInLayout(), $alias); + } + } + } + return $this->_buttonsHtml; + } + + /** + * Get or create new instance of URL rewrite + * + * @return Mage_Core_Model_Url_Rewrite + */ + protected function _getUrlRewrite() + { + if (!$this->hasData('url_rewrite')) { + $this->setUrlRewrite(Mage::getModel('Mage_Core_Model_Url_Rewrite')); + } + return $this->getUrlRewrite(); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit/Form.php b/app/code/Mage/Adminhtml/Block/Urlrewrite/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit/Form.php rename to app/code/Mage/Adminhtml/Block/Urlrewrite/Edit/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Link.php b/app/code/Mage/Adminhtml/Block/Urlrewrite/Link.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Urlrewrite/Link.php rename to app/code/Mage/Adminhtml/Block/Urlrewrite/Link.php diff --git a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Selector.php b/app/code/Mage/Adminhtml/Block/Urlrewrite/Selector.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Urlrewrite/Selector.php rename to app/code/Mage/Adminhtml/Block/Urlrewrite/Selector.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget.php b/app/code/Mage/Adminhtml/Block/Widget.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget.php rename to app/code/Mage/Adminhtml/Block/Widget.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Accordion.php b/app/code/Mage/Adminhtml/Block/Widget/Accordion.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Accordion.php rename to app/code/Mage/Adminhtml/Block/Widget/Accordion.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Accordion/Item.php b/app/code/Mage/Adminhtml/Block/Widget/Accordion/Item.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Accordion/Item.php rename to app/code/Mage/Adminhtml/Block/Widget/Accordion/Item.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Breadcrumbs.php b/app/code/Mage/Adminhtml/Block/Widget/Breadcrumbs.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Breadcrumbs.php rename to app/code/Mage/Adminhtml/Block/Widget/Breadcrumbs.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Button.php b/app/code/Mage/Adminhtml/Block/Widget/Button.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Button.php rename to app/code/Mage/Adminhtml/Block/Widget/Button.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Container.php b/app/code/Mage/Adminhtml/Block/Widget/Container.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Container.php rename to app/code/Mage/Adminhtml/Block/Widget/Container.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Form.php b/app/code/Mage/Adminhtml/Block/Widget/Form.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Form.php rename to app/code/Mage/Adminhtml/Block/Widget/Form.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Form/Container.php b/app/code/Mage/Adminhtml/Block/Widget/Form/Container.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Form/Container.php rename to app/code/Mage/Adminhtml/Block/Widget/Form/Container.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Form/Element.php b/app/code/Mage/Adminhtml/Block/Widget/Form/Element.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Form/Element.php rename to app/code/Mage/Adminhtml/Block/Widget/Form/Element.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Form/Element/Dependence.php b/app/code/Mage/Adminhtml/Block/Widget/Form/Element/Dependence.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Form/Element/Dependence.php rename to app/code/Mage/Adminhtml/Block/Widget/Form/Element/Dependence.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Form/Element/Gallery.php b/app/code/Mage/Adminhtml/Block/Widget/Form/Element/Gallery.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Form/Element/Gallery.php rename to app/code/Mage/Adminhtml/Block/Widget/Form/Element/Gallery.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Form/Renderer/Element.php b/app/code/Mage/Adminhtml/Block/Widget/Form/Renderer/Element.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Form/Renderer/Element.php rename to app/code/Mage/Adminhtml/Block/Widget/Form/Renderer/Element.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Form/Renderer/Fieldset.php b/app/code/Mage/Adminhtml/Block/Widget/Form/Renderer/Fieldset.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Form/Renderer/Fieldset.php rename to app/code/Mage/Adminhtml/Block/Widget/Form/Renderer/Fieldset.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Form/Renderer/Fieldset/Element.php b/app/code/Mage/Adminhtml/Block/Widget/Form/Renderer/Fieldset/Element.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Form/Renderer/Fieldset/Element.php rename to app/code/Mage/Adminhtml/Block/Widget/Form/Renderer/Fieldset/Element.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php b/app/code/Mage/Adminhtml/Block/Widget/Grid.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Abstract.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Abstract.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Abstract.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Abstract.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Checkbox.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Checkbox.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Checkbox.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Checkbox.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Country.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Country.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Country.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Country.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Date.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Date.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Date.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Date.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Datetime.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Datetime.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Datetime.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Datetime.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Interface.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Interface.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Interface.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Interface.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Massaction.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Massaction.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Massaction.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Massaction.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Price.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Price.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Price.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Price.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Radio.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Radio.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Radio.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Radio.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Range.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Range.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Range.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Range.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Select.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Select.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Select.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Select.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Store.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Store.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Store.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Store.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Text.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Text.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Text.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Text.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Theme.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Theme.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Theme.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Theme.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Abstract.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Abstract.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Abstract.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Abstract.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Action.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Action.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Action.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Action.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Checkbox.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Checkbox.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Checkbox.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Checkbox.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Concat.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Concat.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Concat.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Concat.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Country.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Country.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Country.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Country.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Currency.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Currency.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Currency.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Currency.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Date.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Date.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Date.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Date.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Datetime.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Datetime.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Datetime.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Datetime.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Input.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Input.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Input.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Input.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Interface.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Interface.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Interface.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Interface.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Ip.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Ip.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Ip.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Ip.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Longtext.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Longtext.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Longtext.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Longtext.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Massaction.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Massaction.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Massaction.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Massaction.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Number.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Number.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Number.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Number.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Options.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Options.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Options.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Options.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Price.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Price.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Price.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Price.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Radio.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Radio.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Radio.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Radio.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Select.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Select.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Select.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Select.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Store.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Store.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Store.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Store.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Text.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Text.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Text.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Text.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Wrapline.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Wrapline.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Wrapline.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Wrapline.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Container.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Container.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Container.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Container.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Massaction.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Massaction.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Massaction.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Massaction.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Massaction/Abstract.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Massaction/Abstract.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Massaction/Abstract.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Massaction/Abstract.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Massaction/Item.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Massaction/Item.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Massaction/Item.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Massaction/Item.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Massaction/Item/Additional/Default.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Massaction/Item/Additional/Default.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Massaction/Item/Additional/Default.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Massaction/Item/Additional/Default.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Massaction/Item/Additional/Interface.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Massaction/Item/Additional/Interface.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Massaction/Item/Additional/Interface.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Massaction/Item/Additional/Interface.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Serializer.php b/app/code/Mage/Adminhtml/Block/Widget/Grid/Serializer.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Grid/Serializer.php rename to app/code/Mage/Adminhtml/Block/Widget/Grid/Serializer.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Tab/Interface.php b/app/code/Mage/Adminhtml/Block/Widget/Tab/Interface.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Tab/Interface.php rename to app/code/Mage/Adminhtml/Block/Widget/Tab/Interface.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Tabs.php b/app/code/Mage/Adminhtml/Block/Widget/Tabs.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/Tabs.php rename to app/code/Mage/Adminhtml/Block/Widget/Tabs.php diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/View/Container.php b/app/code/Mage/Adminhtml/Block/Widget/View/Container.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Block/Widget/View/Container.php rename to app/code/Mage/Adminhtml/Block/Widget/View/Container.php diff --git a/app/code/core/Mage/Adminhtml/Controller/Action.php b/app/code/Mage/Adminhtml/Controller/Action.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Controller/Action.php rename to app/code/Mage/Adminhtml/Controller/Action.php diff --git a/app/code/core/Mage/Adminhtml/Controller/Report/Abstract.php b/app/code/Mage/Adminhtml/Controller/Report/Abstract.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Controller/Report/Abstract.php rename to app/code/Mage/Adminhtml/Controller/Report/Abstract.php diff --git a/app/code/core/Mage/Adminhtml/Controller/Sales/Creditmemo.php b/app/code/Mage/Adminhtml/Controller/Sales/Creditmemo.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Controller/Sales/Creditmemo.php rename to app/code/Mage/Adminhtml/Controller/Sales/Creditmemo.php diff --git a/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php b/app/code/Mage/Adminhtml/Controller/Sales/Invoice.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php rename to app/code/Mage/Adminhtml/Controller/Sales/Invoice.php diff --git a/app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php b/app/code/Mage/Adminhtml/Controller/Sales/Shipment.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php rename to app/code/Mage/Adminhtml/Controller/Sales/Shipment.php diff --git a/app/code/core/Mage/Adminhtml/Exception.php b/app/code/Mage/Adminhtml/Exception.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Exception.php rename to app/code/Mage/Adminhtml/Exception.php diff --git a/app/code/core/Mage/Adminhtml/Helper/Addresses.php b/app/code/Mage/Adminhtml/Helper/Addresses.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Helper/Addresses.php rename to app/code/Mage/Adminhtml/Helper/Addresses.php diff --git a/app/code/core/Mage/Adminhtml/Helper/Catalog.php b/app/code/Mage/Adminhtml/Helper/Catalog.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Helper/Catalog.php rename to app/code/Mage/Adminhtml/Helper/Catalog.php diff --git a/app/code/core/Mage/Adminhtml/Helper/Catalog/Product/Composite.php b/app/code/Mage/Adminhtml/Helper/Catalog/Product/Composite.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Helper/Catalog/Product/Composite.php rename to app/code/Mage/Adminhtml/Helper/Catalog/Product/Composite.php diff --git a/app/code/core/Mage/Adminhtml/Helper/Catalog/Product/Edit/Action/Attribute.php b/app/code/Mage/Adminhtml/Helper/Catalog/Product/Edit/Action/Attribute.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Helper/Catalog/Product/Edit/Action/Attribute.php rename to app/code/Mage/Adminhtml/Helper/Catalog/Product/Edit/Action/Attribute.php diff --git a/app/code/core/Mage/Adminhtml/Helper/Dashboard/Abstract.php b/app/code/Mage/Adminhtml/Helper/Dashboard/Abstract.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Helper/Dashboard/Abstract.php rename to app/code/Mage/Adminhtml/Helper/Dashboard/Abstract.php diff --git a/app/code/core/Mage/Adminhtml/Helper/Dashboard/Data.php b/app/code/Mage/Adminhtml/Helper/Dashboard/Data.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Helper/Dashboard/Data.php rename to app/code/Mage/Adminhtml/Helper/Dashboard/Data.php diff --git a/app/code/core/Mage/Adminhtml/Helper/Dashboard/Order.php b/app/code/Mage/Adminhtml/Helper/Dashboard/Order.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Helper/Dashboard/Order.php rename to app/code/Mage/Adminhtml/Helper/Dashboard/Order.php diff --git a/app/code/core/Mage/Adminhtml/Helper/Data.php b/app/code/Mage/Adminhtml/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Helper/Data.php rename to app/code/Mage/Adminhtml/Helper/Data.php diff --git a/app/code/core/Mage/Adminhtml/Helper/Js.php b/app/code/Mage/Adminhtml/Helper/Js.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Helper/Js.php rename to app/code/Mage/Adminhtml/Helper/Js.php diff --git a/app/code/Mage/Adminhtml/Helper/Media/Js.php b/app/code/Mage/Adminhtml/Helper/Media/Js.php new file mode 100644 index 0000000000000..336e1e16a79c3 --- /dev/null +++ b/app/code/Mage/Adminhtml/Helper/Media/Js.php @@ -0,0 +1,74 @@ + + */ +class Mage_Adminhtml_Helper_Media_Js extends Mage_Core_Helper_Js +{ + /** + * @param Mage_Core_Helper_Context $context + * @param Mage_Core_Model_Config_Modules_Reader $configReader + */ + public function __construct( + Mage_Core_Helper_Context $context, + Mage_Core_Model_Config_Modules_Reader $configReader + ) { + parent::__construct($context, $configReader); + + $this->_translateData = array( + 'Complete' => $this->__('Complete'), + 'File size should be more than 0 bytes' => $this->__('File size should be more than 0 bytes'), + 'Upload Security Error' => $this->__('Upload Security Error'), + 'Upload HTTP Error' => $this->__('Upload HTTP Error'), + 'Upload I/O Error' => $this->__('Upload I/O Error'), + 'SSL Error: Invalid or self-signed certificate' => $this->__('SSL Error: Invalid or self-signed certificate'), + 'Tb' => $this->__('Tb'), + 'Gb' => $this->__('Gb'), + 'Mb' => $this->__('Mb'), + 'Kb' => $this->__('Kb'), + 'b' => $this->__('b') + ); + } + + /** + * Retrieve JS translator initialization javascript + * + * @return string + */ + public function getTranslatorScript() + { + $script = '(function($) {$.mage.translate.add(' . $this->getTranslateJson() . ')})(jQuery);'; + return $this->getScript($script); + } + +} diff --git a/app/code/core/Mage/Adminhtml/Helper/Sales.php b/app/code/Mage/Adminhtml/Helper/Sales.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Helper/Sales.php rename to app/code/Mage/Adminhtml/Helper/Sales.php diff --git a/app/code/core/Mage/Adminhtml/Model/Customer/Renderer/Region.php b/app/code/Mage/Adminhtml/Model/Customer/Renderer/Region.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Model/Customer/Renderer/Region.php rename to app/code/Mage/Adminhtml/Model/Customer/Renderer/Region.php diff --git a/app/code/core/Mage/Adminhtml/Model/Email/Template.php b/app/code/Mage/Adminhtml/Model/Email/Template.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Model/Email/Template.php rename to app/code/Mage/Adminhtml/Model/Email/Template.php diff --git a/app/code/core/Mage/Adminhtml/Model/Giftmessage/Save.php b/app/code/Mage/Adminhtml/Model/Giftmessage/Save.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Model/Giftmessage/Save.php rename to app/code/Mage/Adminhtml/Model/Giftmessage/Save.php diff --git a/app/code/core/Mage/Adminhtml/Model/LayoutUpdate/Validator.php b/app/code/Mage/Adminhtml/Model/LayoutUpdate/Validator.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Model/LayoutUpdate/Validator.php rename to app/code/Mage/Adminhtml/Model/LayoutUpdate/Validator.php diff --git a/app/code/core/Mage/Adminhtml/Model/Newsletter/Renderer/Text.php b/app/code/Mage/Adminhtml/Model/Newsletter/Renderer/Text.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Model/Newsletter/Renderer/Text.php rename to app/code/Mage/Adminhtml/Model/Newsletter/Renderer/Text.php diff --git a/app/code/core/Mage/Adminhtml/Model/Observer.php b/app/code/Mage/Adminhtml/Model/Observer.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Model/Observer.php rename to app/code/Mage/Adminhtml/Model/Observer.php diff --git a/app/code/core/Mage/Adminhtml/Model/Report/Item.php b/app/code/Mage/Adminhtml/Model/Report/Item.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Model/Report/Item.php rename to app/code/Mage/Adminhtml/Model/Report/Item.php diff --git a/app/code/core/Mage/Adminhtml/Model/Sales/Order.php b/app/code/Mage/Adminhtml/Model/Sales/Order.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Model/Sales/Order.php rename to app/code/Mage/Adminhtml/Model/Sales/Order.php diff --git a/app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php b/app/code/Mage/Adminhtml/Model/Sales/Order/Create.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php rename to app/code/Mage/Adminhtml/Model/Sales/Order/Create.php diff --git a/app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php b/app/code/Mage/Adminhtml/Model/Sales/Order/Random.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php rename to app/code/Mage/Adminhtml/Model/Sales/Order/Random.php diff --git a/app/code/core/Mage/Adminhtml/Model/Search/Catalog.php b/app/code/Mage/Adminhtml/Model/Search/Catalog.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Model/Search/Catalog.php rename to app/code/Mage/Adminhtml/Model/Search/Catalog.php diff --git a/app/code/core/Mage/Adminhtml/Model/Search/Customer.php b/app/code/Mage/Adminhtml/Model/Search/Customer.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Model/Search/Customer.php rename to app/code/Mage/Adminhtml/Model/Search/Customer.php diff --git a/app/code/core/Mage/Adminhtml/Model/Search/Order.php b/app/code/Mage/Adminhtml/Model/Search/Order.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Model/Search/Order.php rename to app/code/Mage/Adminhtml/Model/Search/Order.php diff --git a/app/code/core/Mage/Adminhtml/Model/Session.php b/app/code/Mage/Adminhtml/Model/Session.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Model/Session.php rename to app/code/Mage/Adminhtml/Model/Session.php diff --git a/app/code/core/Mage/Adminhtml/Model/Session/Quote.php b/app/code/Mage/Adminhtml/Model/Session/Quote.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Model/Session/Quote.php rename to app/code/Mage/Adminhtml/Model/Session/Quote.php diff --git a/app/code/core/Mage/Adminhtml/Model/UrlRewriteOptions.php b/app/code/Mage/Adminhtml/Model/UrlRewriteOptions.php similarity index 100% rename from app/code/core/Mage/Adminhtml/Model/UrlRewriteOptions.php rename to app/code/Mage/Adminhtml/Model/UrlRewriteOptions.php diff --git a/app/code/core/Mage/Adminhtml/controllers/AjaxController.php b/app/code/Mage/Adminhtml/controllers/AjaxController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/AjaxController.php rename to app/code/Mage/Adminhtml/controllers/AjaxController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php b/app/code/Mage/Adminhtml/controllers/Api/RoleController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php rename to app/code/Mage/Adminhtml/controllers/Api/RoleController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php b/app/code/Mage/Adminhtml/controllers/Api/UserController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Api/UserController.php rename to app/code/Mage/Adminhtml/controllers/Api/UserController.php diff --git a/app/code/Mage/Adminhtml/controllers/CacheController.php b/app/code/Mage/Adminhtml/controllers/CacheController.php new file mode 100644 index 0000000000000..d6ab267ef4f7c --- /dev/null +++ b/app/code/Mage/Adminhtml/controllers/CacheController.php @@ -0,0 +1,304 @@ +_cache = $cache; + $this->_cacheTypes = $cacheTypes; + $this->_cacheFrontendPool = $cacheFrontendPool; + } + + /** + * Retrieve session model + * + * @return Mage_Adminhtml_Model_Session + */ + protected function _getSession() + { + return Mage::getSingleton('Mage_Adminhtml_Model_Session'); + } + + /** + * Display cache management grid + */ + public function indexAction() + { + $this->_title($this->__('System'))->_title($this->__('Cache Management')); + + $this->loadLayout() + ->_setActiveMenu('Mage_Adminhtml::system_cache') + ->renderLayout(); + } + + /** + * Flush cache storage + */ + public function flushAllAction() + { + Mage::dispatchEvent('adminhtml_cache_flush_all'); + /** @var $cacheFrontend Magento_Cache_FrontendInterface */ + foreach ($this->_cacheFrontendPool as $cacheFrontend) { + $cacheFrontend->clean(); + } + $this->_getSession()->addSuccess( + Mage::helper('Mage_Adminhtml_Helper_Data')->__("The cache storage has been flushed.") + ); + $this->_redirect('*/*'); + } + + /** + * Flush all magento cache + */ + public function flushSystemAction() + { + $markerCacheTag = Mage_Core_Model_AppInterface::CACHE_TAG; + /** @var $cacheFrontend Magento_Cache_FrontendInterface */ + foreach ($this->_cacheFrontendPool as $cacheFrontend) { + $cacheFrontend->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array($markerCacheTag)); + } + Mage::dispatchEvent('adminhtml_cache_flush_system'); + $this->_getSession()->addSuccess( + Mage::helper('Mage_Adminhtml_Helper_Data')->__("The Magento cache storage has been flushed.") + ); + $this->_redirect('*/*'); + } + + /** + * Mass action for cache enabling + */ + public function massEnableAction() + { + try { + $types = $this->getRequest()->getParam('types'); + $updatedTypes = 0; + $this->_validateTypes($types); + foreach ($types as $code) { + if (!$this->_cacheTypes->isEnabled($code)) { + $this->_cacheTypes->setEnabled($code, true); + $updatedTypes++; + } + } + if ($updatedTypes > 0) { + $this->_cacheTypes->persist(); + $this->_getSession()->addSuccess( + Mage::helper('Mage_Adminhtml_Helper_Data')->__("%s cache type(s) enabled.", $updatedTypes) + ); + } + } catch (Mage_Core_Exception $e) { + $this->_getSession()->addError($e->getMessage()); + } + catch (Exception $e) { + $this->_getSession()->addException( + $e, + Mage::helper('Mage_Adminhtml_Helper_Data')->__('An error occurred while enabling cache.') + ); + } + $this->_redirect('*/*'); + } + + /** + * Mass action for cache disabling + */ + public function massDisableAction() + { + try { + $types = $this->getRequest()->getParam('types'); + $updatedTypes = 0; + $this->_validateTypes($types); + foreach ($types as $code) { + if ($this->_cacheTypes->isEnabled($code)) { + $this->_cacheTypes->setEnabled($code, false); + $updatedTypes++; + } + $this->_cache->cleanType($code); + } + if ($updatedTypes > 0) { + $this->_cacheTypes->persist(); + $this->_getSession()->addSuccess( + Mage::helper('Mage_Adminhtml_Helper_Data')->__("%s cache type(s) disabled.", $updatedTypes) + ); + } + } catch (Mage_Core_Exception $e) { + $this->_getSession()->addError($e->getMessage()); + } + catch (Exception $e) { + $this->_getSession()->addException( + $e, + Mage::helper('Mage_Adminhtml_Helper_Data')->__('An error occurred while disabling cache.') + ); + } + $this->_redirect('*/*'); + } + + /** + * Mass action for cache refresh + */ + public function massRefreshAction() + { + try { + $types = $this->getRequest()->getParam('types'); + $updatedTypes = 0; + $this->_validateTypes($types); + foreach ($types as $type) { + $this->_cache->cleanType($type); + Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => $type)); + $updatedTypes++; + } + if ($updatedTypes > 0) { + $this->_getSession()->addSuccess( + Mage::helper('Mage_Adminhtml_Helper_Data')->__("%s cache type(s) refreshed.", $updatedTypes) + ); + } + } catch (Mage_Core_Exception $e) { + $this->_getSession()->addError($e->getMessage()); + } + catch (Exception $e) { + $this->_getSession()->addException( + $e, + Mage::helper('Mage_Adminhtml_Helper_Data')->__('An error occurred while refreshing cache.') + ); + } + $this->_redirect('*/*'); + } + + /** + * Check whether specified cache types exist + * + * @param array $types + */ + protected function _validateTypes(array $types) + { + if (empty($types)) { + return; + } + $allTypes = array_keys($this->_cache->getTypes()); + $invalidTypes = array_diff($types, $allTypes); + if (count($invalidTypes) > 0) { + Mage::throwException(Mage::helper('Mage_Adminhtml_Helper_Data') + ->__("Specified cache type(s) don't exist: " . join(', ', $invalidTypes))); + } + } + + /** + * Clean JS/css files cache + */ + public function cleanMediaAction() + { + try { + Mage::getModel('Mage_Core_Model_Design_Package')->cleanMergedJsCss(); + Mage::dispatchEvent('clean_media_cache_after'); + $this->_getSession()->addSuccess( + Mage::helper('Mage_Adminhtml_Helper_Data')->__('The JavaScript/CSS cache has been cleaned.') + ); + } + catch (Exception $e) { + $this->_getSession()->addException( + $e, + Mage::helper('Mage_Adminhtml_Helper_Data')->__('An error occurred while clearing the JavaScript/CSS cache.') + ); + } + catch (Mage_Core_Exception $e) { + $this->_getSession()->addError($e->getMessage()); + } + $this->_redirect('*/*'); + } + + /** + * Clean JS/css files cache + */ + public function cleanImagesAction() + { + try { + Mage::getModel('Mage_Catalog_Model_Product_Image')->clearCache(); + Mage::dispatchEvent('clean_catalog_images_cache_after'); + $this->_getSession()->addSuccess( + Mage::helper('Mage_Adminhtml_Helper_Data')->__('The image cache was cleaned.') + ); + } + catch (Mage_Core_Exception $e) { + $this->_getSession()->addError($e->getMessage()); + } + catch (Exception $e) { + $this->_getSession()->addException( + $e, + Mage::helper('Mage_Adminhtml_Helper_Data')->__('An error occurred while clearing the image cache.') + ); + } + $this->_redirect('*/*'); + } + + /** + * Check if cache management is allowed + * + * @return bool + */ + protected function _isAllowed() + { + return Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Adminhtml::cache'); + } +} diff --git a/app/code/Mage/Adminhtml/controllers/Catalog/Category/WidgetController.php b/app/code/Mage/Adminhtml/controllers/Catalog/Category/WidgetController.php new file mode 100644 index 0000000000000..13a10e67f73d8 --- /dev/null +++ b/app/code/Mage/Adminhtml/controllers/Catalog/Category/WidgetController.php @@ -0,0 +1,74 @@ + + */ +class Mage_Adminhtml_Catalog_Category_WidgetController extends Mage_Adminhtml_Controller_Action +{ + /** + * Chooser Source action + */ + public function chooserAction() + { + $this->getResponse()->setBody( + $this->_getCategoryTreeBlock()->toHtml() + ); + } + + /** + * Categories tree node (Ajax version) + */ + public function categoriesJsonAction() + { + if ($categoryId = (int) $this->getRequest()->getPost('id')) { + + $category = Mage::getModel('Mage_Catalog_Model_Category')->load($categoryId); + if ($category->getId()) { + Mage::register('category', $category); + Mage::register('current_category', $category); + } + $this->getResponse()->setBody( + $this->_getCategoryTreeBlock()->getTreeJson($category) + ); + } + } + + protected function _getCategoryTreeBlock() + { + return $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Category_Widget_Chooser', '', array( + 'data' => array( + 'id' => $this->getRequest()->getParam('uniq_id'), + 'use_massaction' => $this->getRequest()->getParam('use_massaction', false) + ) + )); + } +} diff --git a/app/code/Mage/Adminhtml/controllers/Catalog/CategoryController.php b/app/code/Mage/Adminhtml/controllers/Catalog/CategoryController.php new file mode 100644 index 0000000000000..b7d7149e7f112 --- /dev/null +++ b/app/code/Mage/Adminhtml/controllers/Catalog/CategoryController.php @@ -0,0 +1,529 @@ +_title($this->__('Catalog')) + ->_title($this->__('Categories')) + ->_title($this->__('Manage Categories')); + + $categoryId = (int)$this->getRequest()->getParam('id', false); + $storeId = (int)$this->getRequest()->getParam('store'); + $category = $this->_objectManager->create('Mage_Catalog_Model_Category'); + $category->setStoreId($storeId); + + if ($categoryId) { + $category->load($categoryId); + if ($storeId) { + $rootId = $this->_objectManager->get('Mage_Core_Model_StoreManager')->getStore($storeId) + ->getRootCategoryId(); + if (!in_array($rootId, $category->getPathIds())) { + // load root category instead wrong one + if ($getRootInstead) { + $category->load($rootId); + } else { + $this->_redirect('*/*/', array('_current'=>true, 'id'=>null)); + return false; + } + } + } + } + + $activeTabId = (string)$this->getRequest()->getParam('active_tab_id'); + if ($activeTabId) { + $this->_objectManager->get('Mage_Backend_Model_Auth_Session')->setActiveTabId($activeTabId); + } + $this->_objectManager->get('Mage_Core_Model_Registry')->register('category', $category); + $this->_objectManager->get('Mage_Core_Model_Registry')->register('current_category', $category); + $this->_objectManager->get('Mage_Cms_Model_Wysiwyg_Config')->setStoreId($this->getRequest()->getParam('store')); + return $category; + } + /** + * Catalog categories index action + */ + public function indexAction() + { + $this->_forward('edit'); + } + + /** + * Add new category form + */ + public function addAction() + { + $this->_objectManager->get('Mage_Backend_Model_Auth_Session')->unsActiveTabId(); + $this->_forward('edit'); + } + + /** + * Edit category page + */ + public function editAction() + { + $params['_current'] = true; + $redirect = false; + + $storeId = (int)$this->getRequest()->getParam('store'); + $parentId = (int)$this->getRequest()->getParam('parent'); + $prevStoreId = $this->_objectManager->get('Mage_Backend_Model_Auth_Session') + ->getLastViewedStore(true); + + if (!empty($prevStoreId) && !$this->getRequest()->getQuery('isAjax')) { + $params['store'] = $prevStoreId; + $redirect = true; + } + + $categoryId = (int)$this->getRequest()->getParam('id'); + $_prevCategoryId = $this->_objectManager->get('Mage_Backend_Model_Auth_Session') + ->getLastEditedCategory(true); + + if ($_prevCategoryId + && !$this->getRequest()->getQuery('isAjax') + && !$this->getRequest()->getParam('clear') + ) { + $this->getRequest()->setParam('id', $_prevCategoryId); + } + + if ($redirect) { + $this->_redirect('*/*/edit', $params); + return; + } + + if ($storeId && !$categoryId && !$parentId) { + $store = $this->_objectManager->get('Mage_Core_Model_StoreManager')->getStore($storeId); + $_prevCategoryId = (int) $store->getRootCategoryId(); + $this->getRequest()->setParam('id', $_prevCategoryId); + } + + $category = $this->_initCategory(true); + if (!$category) { + return; + } + + $this->_title($categoryId ? $category->getName() : $this->__('Categories')); + + /** + * Check if we have data in session (if during category save was exception) + */ + $data = $this->_getSession()->getCategoryData(true); + if (isset($data['general'])) { + $category->addData($data['general']); + } + + /** + * Build response for ajax request + */ + if ($this->getRequest()->getQuery('isAjax')) { + // prepare breadcrumbs of selected category, if any + $breadcrumbsPath = $category->getPath(); + if (empty($breadcrumbsPath)) { + // but if no category, and it is deleted - prepare breadcrumbs from path, saved in session + $breadcrumbsPath = $this->_objectManager->get('Mage_Backend_Model_Auth_Session')->getDeletedPath(true); + if (!empty($breadcrumbsPath)) { + $breadcrumbsPath = explode('/', $breadcrumbsPath); + // no need to get parent breadcrumbs if deleting category level 1 + if (count($breadcrumbsPath) <= 1) { + $breadcrumbsPath = ''; + } else { + array_pop($breadcrumbsPath); + $breadcrumbsPath = implode('/', $breadcrumbsPath); + } + } + } + + $this->_objectManager->get('Mage_Backend_Model_Auth_Session') + ->setLastViewedStore($this->getRequest()->getParam('store')); + $this->_objectManager->get('Mage_Backend_Model_Auth_Session') + ->setLastEditedCategory($category->getId()); + $this->loadLayout(); + + $eventResponse = new Varien_Object(array( + 'content' => $this->getLayout()->getBlock('category.edit')->getFormHtml() + . $this->getLayout()->getBlock('category.tree') + ->getBreadcrumbsJavascript($breadcrumbsPath, 'editingCategoryBreadcrumbs'), + 'messages' => $this->getLayout()->getMessagesBlock()->getGroupedHtml(), + )); + $this->_objectManager->get('Mage_Core_Model_Event_Manager')->dispatch( + 'category_prepare_ajax_response', + array( + 'response' => $eventResponse, + 'controller' => $this + )); + $this->getResponse()->setHeader('Content-type', 'application/json', true); + $this->getResponse()->setBody( + $this->_objectManager->get('Mage_Core_Helper_Data')->jsonEncode($eventResponse->getData()) + ); + return; + } + + $this->loadLayout(); + $this->_setActiveMenu('Mage_Catalog::catalog_categories'); + $this->getLayout()->getBlock('head')->setCanLoadExtJs(true)->setContainerCssClass('catalog-categories'); + + $this->_addBreadcrumb($this->__('Manage Catalog Categories'), $this->__('Manage Categories')); + + $block = $this->getLayout()->getBlock('catalog.wysiwyg.js'); + if ($block) { + $block->setStoreId($storeId); + } + + $this->renderLayout(); + } + + /** + * WYSIWYG editor action for ajax request + * + */ + public function wysiwygAction() + { + $elementId = $this->getRequest()->getParam('element_id', md5(microtime())); + $storeId = $this->getRequest()->getParam('store_id', 0); + $storeMediaUrl = $this->_objectManager->get('Mage_Core_Model_StoreManager')->getStore($storeId) + ->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); + + $content = $this->getLayout()->createBlock( + 'Mage_Adminhtml_Block_Catalog_Helper_Form_Wysiwyg_Content', + '', + array( + 'data' => array( + 'editor_element_id' => $elementId, + 'store_id' => $storeId, + 'store_media_url' => $storeMediaUrl, + ) + ) + ); + + $this->getResponse()->setBody($content->toHtml()); + } + + /** + * Get tree node (Ajax version) + */ + public function categoriesJsonAction() + { + if ($this->getRequest()->getParam('expand_all')) { + $this->_objectManager->get('Mage_Backend_Model_Auth_Session')->setIsTreeWasExpanded(true); + } else { + $this->_objectManager->get('Mage_Backend_Model_Auth_Session')->setIsTreeWasExpanded(false); + } + $categoryId = (int)$this->getRequest()->getPost('id'); + if ($categoryId) { + $this->getRequest()->setParam('id', $categoryId); + + if (!$category = $this->_initCategory()) { + return; + } + $this->getResponse()->setBody( + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Category_Tree') + ->getTreeJson($category) + ); + } + } + + /** + * Category save + */ + public function saveAction() + { + if (!$category = $this->_initCategory()) { + return; + } + + $storeId = $this->getRequest()->getParam('store'); + $refreshTree = 'false'; + $data = $this->getRequest()->getPost(); + if ($data) { + $category->addData($data['general']); + if (!$category->getId()) { + $parentId = $this->getRequest()->getParam('parent'); + if (!$parentId) { + if ($storeId) { + $parentId = $this->_objectManager->get('Mage_Core_Model_StoreManager') + ->getStore($storeId)->getRootCategoryId(); + } else { + $parentId = Mage_Catalog_Model_Category::TREE_ROOT_ID; + } + } + $parentCategory = $this->_objectManager->create('Mage_Catalog_Model_Category')->load($parentId); + $category->setPath($parentCategory->getPath()); + } + + /** + * Process "Use Config Settings" checkboxes + */ + $useConfig = $this->getRequest()->getPost('use_config'); + if ($useConfig) { + foreach ($useConfig as $attributeCode) { + $category->setData($attributeCode, null); + } + } + + /** + * Create Permanent Redirect for old URL key + */ + // && $category->getOrigData('url_key') != $category->getData('url_key') + if ($category->getId() && isset($data['general']['url_key_create_redirect'])) { + $category->setData('save_rewrites_history', (bool)$data['general']['url_key_create_redirect']); + } + + $category->setAttributeSetId($category->getDefaultAttributeSetId()); + + if (isset($data['category_products']) && !$category->getProductsReadonly()) { + $products = array(); + parse_str($data['category_products'], $products); + $category->setPostedProducts($products); + } + $this->_objectManager->get('Mage_Core_Model_Event_Manager')->dispatch( + 'catalog_category_prepare_save', + array( + 'category' => $category, + 'request' => $this->getRequest() + )); + + /** + * Check "Use Default Value" checkboxes values + */ + $useDefaults = $this->getRequest()->getPost('use_default'); + if ($useDefaults) { + foreach ($useDefaults as $attributeCode) { + $category->setData($attributeCode, false); + } + } + + /** + * Proceed with $_POST['use_config'] + * set into category model for processing through validation + */ + $category->setData('use_post_data_config', $this->getRequest()->getPost('use_config')); + + try { + $validate = $category->validate(); + if ($validate !== true) { + foreach ($validate as $code => $error) { + if ($error === true) { + $attribute = $category->getResource()->getAttribute($code)->getFrontend()->getLabel(); + throw new Mage_Core_Exception( + $this->__('Attribute "%s" is required.', $attribute) + ); + } else { + throw new Mage_Core_Exception($error); + } + } + } + + $category->unsetData('use_post_data_config'); + if (isset($data['general']['entity_id'])) { + throw new Mage_Core_Exception($this->__('Unable to save the category')); + } + + $category->save(); + $this->_getSession()->addSuccess($this->__('The category has been saved.')); + $refreshTree = 'true'; + } catch (Exception $e){ + $this->_getSession()->addError($e->getMessage())->setCategoryData($data); + $refreshTree = 'false'; + } + } + + if ($this->getRequest()->getPost('return_session_messages_only')) { + $category->load($category->getId()); // to obtain truncated category name + + /** @var $block Mage_Core_Block_Messages */ + $block = $this->_objectManager->get('Mage_Core_Block_Messages'); + $block->setMessages($this->_getSession()->getMessages(true)); + $body = $this->_objectManager->get('Mage_Core_Helper_Data')->jsonEncode(array( + 'messages' => $block->getGroupedHtml(), + 'error' => $refreshTree !== 'true', + 'category' => $category->toArray(), + )); + } else { + $url = $this->getUrl('*/*/edit', array('_current' => true, 'id' => $category->getId())); + $body = ''; + } + + $this->getResponse()->setBody($body); + } + + /** + * Move category action + */ + public function moveAction() + { + $category = $this->_initCategory(); + if (!$category) { + $this->getResponse()->setBody($this->__('Category move error')); + return; + } + /** + * New parent category identifier + */ + $parentNodeId = $this->getRequest()->getPost('pid', false); + /** + * Category id after which we have put our category + */ + $prevNodeId = $this->getRequest()->getPost('aid', false); + + try { + $category->move($parentNodeId, $prevNodeId); + $this->getResponse()->setBody('SUCCESS'); + } catch (Mage_Core_Exception $e) { + $this->getResponse()->setBody($e->getMessage()); + } catch (Exception $e){ + $this->getResponse()->setBody($this->__('Category move error %s', $e)); + $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); + } + + } + + /** + * Delete category action + */ + public function deleteAction() + { + $categoryId = (int)$this->getRequest()->getParam('id'); + if ($categoryId) { + try { + $category = $this->_objectManager->create('Mage_Catalog_Model_Category')->load($categoryId); + $this->_objectManager->get('Mage_Core_Model_Event_Manager')->dispatch( + 'catalog_controller_category_delete', array('category' => $category) + ); + + $this->_objectManager->get('Mage_Backend_Model_Auth_Session')->setDeletedPath($category->getPath()); + + $category->delete(); + $this->_getSession()->addSuccess($this->__('The category has been deleted.')); + } catch (Mage_Core_Exception $e){ + $this->_getSession()->addError($e->getMessage()); + $this->getResponse()->setRedirect($this->getUrl('*/*/edit', array('_current' => true))); + return; + } catch (Exception $e){ + $this->_getSession()->addError($this->__('An error occurred while trying to delete the category.')); + $this->getResponse()->setRedirect($this->getUrl('*/*/edit', array('_current' => true))); + return; + } + } + $this->getResponse()->setRedirect($this->getUrl('*/*/', array('_current' => true, 'id' => null))); + } + + /** + * Grid Action + * Display list of products related to current category + */ + public function gridAction() + { + $category = $this->_initCategory(true); + if (!$category) { + return; + } + $this->getResponse()->setBody($this->getLayout()->createBlock( + 'Mage_Adminhtml_Block_Catalog_Category_Tab_Product', 'category.product.grid' + )->toHtml()); + } + + /** + * Tree Action + * Retrieve category tree + */ + public function treeAction() + { + $storeId = (int)$this->getRequest()->getParam('store'); + $categoryId = (int)$this->getRequest()->getParam('id'); + + if ($storeId) { + if (!$categoryId) { + $store = $this->_objectManager->get('Mage_Core_Model_StoreManager')->getStore($storeId); + $rootId = $store->getRootCategoryId(); + $this->getRequest()->setParam('id', $rootId); + } + } + + $category = $this->_initCategory(true); + + $block = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Category_Tree'); + $root = $block->getRoot(); + $this->getResponse()->setBody($this->_objectManager->get('Mage_Core_Helper_Data')->jsonEncode(array( + 'data' => $block->getTree(), + 'parameters' => array( + 'text' => $block->buildNodeName($root), + 'draggable' => false, + 'allowDrop' => (bool)$root->getIsVisible(), + 'id' => (int)$root->getId(), + 'expanded' => (int)$block->getIsWasExpanded(), + 'store_id' => (int)$block->getStore()->getId(), + 'category_id' => (int)$category->getId(), + 'root_visible'=> (int)$root->getIsVisible() + )))); + } + + /** + * Build response for refresh input element 'path' in form + */ + public function refreshPathAction() + { + $categoryId = (int)$this->getRequest()->getParam('id'); + if ($categoryId) { + $category = $this->_objectManager->create('Mage_Catalog_Model_Category')->load($categoryId); + $this->getResponse()->setBody( + $this->_objectManager->get('Mage_Core_Helper_Data')->jsonEncode(array( + 'id' => $categoryId, + 'path' => $category->getPath(), + )) + ); + } + } + + /** + * Category list suggestion based on already entered symbols + */ + public function suggestCategoriesAction() + { + $this->getResponse()->setBody($this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Category_Tree') + ->getSuggestedCategoriesJson($this->getRequest()->getParam('label_part'))); + } + + /** + * Check if admin has permissions to visit related pages + * + * @return boolean + */ + protected function _isAllowed() + { + return $this->_objectManager->get('Mage_Core_Model_Authorization')->isAllowed('Mage_Catalog::categories'); + } +} diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/Action/AttributeController.php b/app/code/Mage/Adminhtml/controllers/Catalog/Product/Action/AttributeController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Catalog/Product/Action/AttributeController.php rename to app/code/Mage/Adminhtml/controllers/Catalog/Product/Action/AttributeController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php b/app/code/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php similarity index 97% rename from app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php rename to app/code/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php index 72790cf7d52c3..317ca5eefae5a 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php +++ b/app/code/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php @@ -54,7 +54,6 @@ protected function _initAction() $this->loadLayout('popup'); } else { $this->loadLayout() - ->_setActiveMenu('Mage_Catalog::catalog_attributes') ->_addBreadcrumb(Mage::helper('Mage_Catalog_Helper_Data')->__('Catalog'), Mage::helper('Mage_Catalog_Helper_Data')->__('Catalog')) ->_addBreadcrumb( Mage::helper('Mage_Catalog_Helper_Data')->__('Manage Product Attributes'), @@ -68,6 +67,7 @@ public function indexAction() { $this->_initAction() ->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Attribute')) + ->_setActiveMenu('Mage_Catalog::catalog_attributes_attributes') ->renderLayout(); } @@ -135,11 +135,10 @@ public function validateAction() ->loadByCode($this->_entityTypeId, $attributeCode); if ($attribute->getId() && !$attributeId) { - Mage::getSingleton('Mage_Adminhtml_Model_Session')->addError( - Mage::helper('Mage_Catalog_Helper_Data')->__('Attribute with the same code already exists')); - $this->_initLayoutMessages('Mage_Adminhtml_Model_Session'); + $response->setAttributes(array( + 'attribute_code' => Mage::helper('Mage_Catalog_Helper_Data')->__('Attribute with the same code already exists') + )); $response->setError(true); - $response->setMessage($this->getLayout()->getMessagesBlock()->getGroupedHtml()); } $this->getResponse()->setBody($response->toJson()); diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/DatafeedsController.php b/app/code/Mage/Adminhtml/controllers/Catalog/Product/DatafeedsController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Catalog/Product/DatafeedsController.php rename to app/code/Mage/Adminhtml/controllers/Catalog/Product/DatafeedsController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php b/app/code/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php similarity index 98% rename from app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php rename to app/code/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php index ff78cc884d07d..eaf47d29f3b4a 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php +++ b/app/code/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php @@ -36,7 +36,7 @@ class Mage_Adminhtml_Catalog_Product_GalleryController extends Mage_Adminhtml_Co public function uploadAction() { try { - $uploader = Mage::getModel('Mage_Core_Model_File_Uploader', array('image')); + $uploader = Mage::getModel('Mage_Core_Model_File_Uploader', array('fileId' => 'image')); $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png')); $uploader->addValidateCallback('catalog_product_image', Mage::helper('Mage_Catalog_Helper_Image'), 'validateUploadFile'); diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GroupController.php b/app/code/Mage/Adminhtml/controllers/Catalog/Product/GroupController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GroupController.php rename to app/code/Mage/Adminhtml/controllers/Catalog/Product/GroupController.php diff --git a/app/code/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php b/app/code/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php new file mode 100644 index 0000000000000..99ff511ff7516 --- /dev/null +++ b/app/code/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php @@ -0,0 +1,390 @@ + + */ + +class Mage_Adminhtml_Catalog_Product_ReviewController extends Mage_Adminhtml_Controller_Action +{ + /** + * Array of actions which can be processed without secret key validation + * + * @var array + */ + protected $_publicActions = array('edit'); + + public function indexAction() + { + $this->_title($this->__('Catalog')) + ->_title($this->__('Reviews and Ratings')) + ->_title($this->__('Customer Reviews')); + + $this->_title($this->__('All Reviews')); + + if ($this->getRequest()->getParam('ajax')) { + return $this->_forward('reviewGrid'); + } + + $this->loadLayout(); + $this->_setActiveMenu('Mage_Review::catalog_reviews_ratings_reviews_all'); + + $this->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Review_Main')); + + $this->renderLayout(); + } + + public function pendingAction() + { + $this->_title($this->__('Catalog')) + ->_title($this->__('Reviews and Ratings')) + ->_title($this->__('Customer Reviews')); + + $this->_title($this->__('Pending Reviews')); + + if ($this->getRequest()->getParam('ajax')) { + Mage::register('usePendingFilter', true); + return $this->_forward('reviewGrid'); + } + + $this->loadLayout(); + + Mage::register('usePendingFilter', true); + $this->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Review_Main')); + + $this->renderLayout(); + } + + public function editAction() + { + $this->_title($this->__('Catalog')) + ->_title($this->__('Reviews and Ratings')) + ->_title($this->__('Customer Reviews')); + + $this->_title($this->__('Edit Review')); + + $this->loadLayout(); + $this->_setActiveMenu('Mage_Review::catalog_reviews_ratings_reviews_all'); + + $this->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Review_Edit')); + + $this->renderLayout(); + } + + public function newAction() + { + $this->_title($this->__('Catalog')) + ->_title($this->__('Reviews and Ratings')) + ->_title($this->__('Customer Reviews')); + + $this->_title($this->__('New Review')); + + $this->loadLayout(); + $this->_setActiveMenu('Mage_Review::catalog_reviews_ratings_reviews_all'); + + $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); + + $this->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Review_Add')); + $this->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Review_Product_Grid')); + + $this->renderLayout(); + } + + public function saveAction() + { + if (($data = $this->getRequest()->getPost()) && ($reviewId = $this->getRequest()->getParam('id'))) { + $review = Mage::getModel('Mage_Review_Model_Review')->load($reviewId); + $session = Mage::getSingleton('Mage_Adminhtml_Model_Session'); + if (! $review->getId()) { + $session->addError(Mage::helper('Mage_Catalog_Helper_Data')->__('The review was removed by another user or does not exist.')); + } else { + try { + $review->addData($data)->save(); + + $arrRatingId = $this->getRequest()->getParam('ratings', array()); + $votes = Mage::getModel('Mage_Rating_Model_Rating_Option_Vote') + ->getResourceCollection() + ->setReviewFilter($reviewId) + ->addOptionInfo() + ->load() + ->addRatingOptions(); + foreach ($arrRatingId as $ratingId=>$optionId) { + if($vote = $votes->getItemByColumnValue('rating_id', $ratingId)) { + Mage::getModel('Mage_Rating_Model_Rating') + ->setVoteId($vote->getId()) + ->setReviewId($review->getId()) + ->updateOptionVote($optionId); + } else { + Mage::getModel('Mage_Rating_Model_Rating') + ->setRatingId($ratingId) + ->setReviewId($review->getId()) + ->addOptionVote($optionId, $review->getEntityPkValue()); + } + } + + $review->aggregate(); + + $session->addSuccess(Mage::helper('Mage_Catalog_Helper_Data')->__('The review has been saved.')); + } catch (Mage_Core_Exception $e) { + $session->addError($e->getMessage()); + } catch (Exception $e){ + $session->addException($e, Mage::helper('Mage_Catalog_Helper_Data')->__('An error occurred while saving this review.')); + } + } + + $nextId = (int) $this->getRequest()->getParam('next_item'); + $url = $this->getUrl($this->getRequest()->getParam('ret') == 'pending' ? '*/*/pending' : '*/*/'); + if ($nextId) { + $url = $this->getUrl('*/*/edit', array('id' => $nextId)); + } + return $this->getResponse()->setRedirect($url); + } + $this->_redirect('*/*/'); + } + + public function deleteAction() + { + $reviewId = $this->getRequest()->getParam('id', false); + $session = Mage::getSingleton('Mage_Adminhtml_Model_Session'); + + try { + Mage::getModel('Mage_Review_Model_Review')->setId($reviewId) + ->aggregate() + ->delete(); + + $session->addSuccess(Mage::helper('Mage_Catalog_Helper_Data')->__('The review has been deleted')); + if( $this->getRequest()->getParam('ret') == 'pending' ) { + $this->getResponse()->setRedirect($this->getUrl('*/*/pending')); + } else { + $this->getResponse()->setRedirect($this->getUrl('*/*/')); + } + return; + } catch (Mage_Core_Exception $e) { + $session->addError($e->getMessage()); + } catch (Exception $e){ + $session->addException($e, Mage::helper('Mage_Catalog_Helper_Data')->__('An error occurred while deleting this review.')); + } + + $this->_redirect('*/*/edit/',array('id'=>$reviewId)); + } + + public function massDeleteAction() + { + $reviewsIds = $this->getRequest()->getParam('reviews'); + $session = Mage::getSingleton('Mage_Adminhtml_Model_Session'); + + if(!is_array($reviewsIds)) { + $session->addError(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Please select review(s).')); + } else { + try { + foreach ($reviewsIds as $reviewId) { + $model = Mage::getModel('Mage_Review_Model_Review')->load($reviewId); + $model->delete(); + } + Mage::getSingleton('Mage_Adminhtml_Model_Session')->addSuccess( + Mage::helper('Mage_Adminhtml_Helper_Data')->__('Total of %d record(s) have been deleted.', count($reviewsIds)) + ); + } catch (Mage_Core_Exception $e) { + $session->addError($e->getMessage()); + } catch (Exception $e){ + $session->addException($e, Mage::helper('Mage_Adminhtml_Helper_Data')->__('An error occurred while deleting record(s).')); + } + } + + $this->_redirect('*/*/' . $this->getRequest()->getParam('ret', 'index')); + } + + public function massUpdateStatusAction() + { + $reviewsIds = $this->getRequest()->getParam('reviews'); + $session = Mage::getSingleton('Mage_Adminhtml_Model_Session'); + + if(!is_array($reviewsIds)) { + $session->addError(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Please select review(s).')); + } else { + /* @var $session Mage_Adminhtml_Model_Session */ + try { + $status = $this->getRequest()->getParam('status'); + foreach ($reviewsIds as $reviewId) { + $model = Mage::getModel('Mage_Review_Model_Review')->load($reviewId); + $model->setStatusId($status) + ->save() + ->aggregate(); + } + $session->addSuccess( + Mage::helper('Mage_Adminhtml_Helper_Data')->__('Total of %d record(s) have been updated.', count($reviewsIds)) + ); + } catch (Mage_Core_Exception $e) { + $session->addError($e->getMessage()); + } catch (Exception $e) { + $session->addException($e, Mage::helper('Mage_Adminhtml_Helper_Data')->__('An error occurred while updating the selected review(s).')); + } + } + + $this->_redirect('*/*/' . $this->getRequest()->getParam('ret', 'index')); + } + + public function massVisibleInAction() + { + $reviewsIds = $this->getRequest()->getParam('reviews'); + $session = Mage::getSingleton('Mage_Adminhtml_Model_Session'); + + if(!is_array($reviewsIds)) { + $session->addError(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Please select review(s).')); + } else { + $session = Mage::getSingleton('Mage_Adminhtml_Model_Session'); + /* @var $session Mage_Adminhtml_Model_Session */ + try { + $stores = $this->getRequest()->getParam('stores'); + foreach ($reviewsIds as $reviewId) { + $model = Mage::getModel('Mage_Review_Model_Review')->load($reviewId); + $model->setSelectStores($stores); + $model->save(); + } + $session->addSuccess( + Mage::helper('Mage_Adminhtml_Helper_Data')->__('Total of %d record(s) have been updated.', count($reviewsIds)) + ); + } catch (Mage_Core_Exception $e) { + $session->addError($e->getMessage()); + } catch (Exception $e) { + $session->addException($e, Mage::helper('Mage_Adminhtml_Helper_Data')->__('An error occurred while updating the selected review(s).')); + } + } + + $this->_redirect('*/*/pending'); + } + + public function productGridAction() + { + $this->getResponse()->setBody( + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Review_Product_Grid')->toHtml() + ); + } + + public function reviewGridAction() + { + $this->getResponse()->setBody( + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Review_Grid')->toHtml() + ); + } + + public function jsonProductInfoAction() + { + $response = new Varien_Object(); + $id = $this->getRequest()->getParam('id'); + if( intval($id) > 0 ) { + $product = Mage::getModel('Mage_Catalog_Model_Product') + ->load($id); + + $response->setId($id); + $response->addData($product->getData()); + $response->setError(0); + } else { + $response->setError(1); + $response->setMessage(Mage::helper('Mage_Catalog_Helper_Data')->__('Unable to get the product ID.')); + } + $this->getResponse()->setBody($response->toJSON()); + } + + public function postAction() + { + $productId = $this->getRequest()->getParam('product_id', false); + $session = Mage::getSingleton('Mage_Adminhtml_Model_Session'); + + if ($data = $this->getRequest()->getPost()) { + if (Mage::app()->hasSingleStore()) { + $data['stores'] = array(Mage::app()->getStore(true)->getId()); + } else if (isset($data['select_stores'])) { + $data['stores'] = $data['select_stores']; + } + + $review = Mage::getModel('Mage_Review_Model_Review')->setData($data); + + $product = Mage::getModel('Mage_Catalog_Model_Product') + ->load($productId); + + try { + $review->setEntityId(1) // product + ->setEntityPkValue($productId) + ->setStoreId($product->getStoreId()) + ->setStatusId($data['status_id']) + ->setCustomerId(null)//null is for administrator only + ->save(); + + $arrRatingId = $this->getRequest()->getParam('ratings', array()); + foreach ($arrRatingId as $ratingId=>$optionId) { + Mage::getModel('Mage_Rating_Model_Rating') + ->setRatingId($ratingId) + ->setReviewId($review->getId()) + ->addOptionVote($optionId, $productId); + } + + $review->aggregate(); + + $session->addSuccess(Mage::helper('Mage_Catalog_Helper_Data')->__('The review has been saved.')); + if( $this->getRequest()->getParam('ret') == 'pending' ) { + $this->getResponse()->setRedirect($this->getUrl('*/*/pending')); + } else { + $this->getResponse()->setRedirect($this->getUrl('*/*/')); + } + + return; + } catch (Mage_Core_Exception $e) { + $session->addError($e->getMessage()); + } catch (Exception $e) { + $session->addException($e, Mage::helper('Mage_Adminhtml_Helper_Data')->__('An error occurred while saving review.')); + } + } + $this->getResponse()->setRedirect($this->getUrl('*/*/')); + return; + } + + public function ratingItemsAction() + { + $this->getResponse()->setBody( + $this->getLayout() + ->createBlock('Mage_Adminhtml_Block_Review_Rating_Detailed') + ->setIndependentMode() + ->toHtml() + ); + } + + protected function _isAllowed() + { + switch ($this->getRequest()->getActionName()) { + case 'pending': + return Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Review::pending'); + break; + default: + return Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Review::reviews_all'); + break; + } + } +} diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php b/app/code/Mage/Adminhtml/controllers/Catalog/Product/SetController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php rename to app/code/Mage/Adminhtml/controllers/Catalog/Product/SetController.php diff --git a/app/code/Mage/Adminhtml/controllers/Catalog/Product/WidgetController.php b/app/code/Mage/Adminhtml/controllers/Catalog/Product/WidgetController.php new file mode 100644 index 0000000000000..1cac995c52ebc --- /dev/null +++ b/app/code/Mage/Adminhtml/controllers/Catalog/Product/WidgetController.php @@ -0,0 +1,82 @@ + + */ +class Mage_Adminhtml_Catalog_Product_WidgetController extends Mage_Adminhtml_Controller_Action +{ + /** + * Chooser Source action + */ + public function chooserAction() + { + $uniqId = $this->getRequest()->getParam('uniq_id'); + $massAction = $this->getRequest()->getParam('use_massaction', false); + $productTypeId = $this->getRequest()->getParam('product_type_id', null); + + $productsGrid = $this->getLayout()->createBlock( + 'Mage_Adminhtml_Block_Catalog_Product_Widget_Chooser', + '', + array( + 'data' => array( + 'id' => $uniqId, + 'use_massaction' => $massAction, + 'product_type_id' => $productTypeId, + 'category_id' => $this->getRequest()->getParam('category_id') + ) + ) + ); + + $html = $productsGrid->toHtml(); + + if (!$this->getRequest()->getParam('products_grid')) { + $categoriesTree = $this->getLayout()->createBlock( + 'Mage_Adminhtml_Block_Catalog_Category_Widget_Chooser', + '', + array( + 'data' => array( + 'id' => $uniqId . 'Tree', + 'node_click_listener' => $productsGrid->getCategoryClickListenerJs(), + 'with_empty_node' => true + ) + ) + ); + + $html = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Widget_Chooser_Container') + ->setTreeHtml($categoriesTree->toHtml()) + ->setGridHtml($html) + ->toHtml(); + } + + $this->getResponse()->setBody($html); + } +} diff --git a/app/code/Mage/Adminhtml/controllers/Catalog/ProductController.php b/app/code/Mage/Adminhtml/controllers/Catalog/ProductController.php new file mode 100644 index 0000000000000..d2ef8708c1bfc --- /dev/null +++ b/app/code/Mage/Adminhtml/controllers/Catalog/ProductController.php @@ -0,0 +1,1056 @@ + + */ +class Mage_Adminhtml_Catalog_ProductController extends Mage_Adminhtml_Controller_Action +{ + /** + * The greatest value which could be stored in CatalogInventory Qty field + */ + const MAX_QTY_VALUE = 99999999.9999; + + /** + * Array of actions which can be processed without secret key validation + * + * @var array + */ + protected $_publicActions = array('edit'); + + protected function _construct() + { + // Define module dependent translate + $this->setUsedModuleName('Mage_Catalog'); + } + + /** + * Initialize product from request parameters + * + * @return Mage_Catalog_Model_Product + */ + protected function _initProduct() + { + $this->_title($this->__('Catalog')) + ->_title($this->__('Manage Products')); + + $productId = (int) $this->getRequest()->getParam('id'); + /** @var $product Mage_Catalog_Model_Product */ + $product = Mage::getModel('Mage_Catalog_Model_Product') + ->setStoreId($this->getRequest()->getParam('store', 0)); + + if (!$productId) { + if ($typeId = $this->getRequest()->getParam('type')) { + $product->setTypeId($typeId); + } + } + + $product->setData('_edit_mode', true); + if ($productId) { + try { + $product->load($productId); + } catch (Exception $e) { + $product->setTypeId(Mage_Catalog_Model_Product_Type::DEFAULT_TYPE); + Mage::logException($e); + } + } + + $setId = (int)$this->getRequest()->getParam('set'); + if ($setId) { + $product->setAttributeSetId($setId); + } + + if ($this->getRequest()->has('attributes')) { + $attributes = $this->getRequest()->getParam('attributes'); + if (!empty($attributes)) { + $product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE); + $this->_objectManager->get('Mage_Catalog_Model_Product_Type_Configurable')->setUsedProductAttributeIds( + $attributes, + $product + ); + } else { + $product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE); + } + } + + // Required attributes of simple product for configurable creation + if ($this->getRequest()->getParam('popup') + && $requiredAttributes = $this->getRequest()->getParam('required')) { + $requiredAttributes = explode(",", $requiredAttributes); + foreach ($product->getAttributes() as $attribute) { + if (in_array($attribute->getId(), $requiredAttributes)) { + $attribute->setIsRequired(1); + } + } + } + + if ($this->getRequest()->getParam('popup') + && $this->getRequest()->getParam('product') + && !is_array($this->getRequest()->getParam('product')) + && $this->getRequest()->getParam('id', false) === false) { + + $configProduct = Mage::getModel('Mage_Catalog_Model_Product') + ->setStoreId(0) + ->load($this->getRequest()->getParam('product')) + ->setTypeId($this->getRequest()->getParam('type')); + + /* @var $configProduct Mage_Catalog_Model_Product */ + $data = array(); + foreach ($configProduct->getTypeInstance()->getEditableAttributes($configProduct) as $attribute) { + /* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */ + if(!$attribute->getIsUnique() + && $attribute->getFrontend()->getInputType()!='gallery' + && $attribute->getAttributeCode() != 'required_options' + && $attribute->getAttributeCode() != 'has_options' + && $attribute->getAttributeCode() != $configProduct->getIdFieldName()) { + $data[$attribute->getAttributeCode()] = $configProduct->getData($attribute->getAttributeCode()); + } + } + $product->addData($data) + ->setWebsiteIds($configProduct->getWebsiteIds()); + } + + Mage::register('product', $product); + Mage::register('current_product', $product); + Mage::getSingleton('Mage_Cms_Model_Wysiwyg_Config')->setStoreId($this->getRequest()->getParam('store')); + return $product; + } + + /** + * Create serializer block for a grid + * + * @param string $inputName + * @param Mage_Adminhtml_Block_Widget_Grid $gridBlock + * @param array $productsArray + * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Ajax_Serializer + */ + protected function _createSerializerBlock($inputName, Mage_Adminhtml_Block_Widget_Grid $gridBlock, $productsArray) + { + return $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Ajax_Serializer') + ->setGridBlock($gridBlock) + ->setProducts($productsArray) + ->setInputElementName($inputName) + ; + } + + /** + * Output specified blocks as a text list + */ + protected function _outputBlocks() + { + $blocks = func_get_args(); + $output = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Text_List'); + foreach ($blocks as $block) { + $output->insert($block, '', true); + } + $this->getResponse()->setBody($output->toHtml()); + } + + /** + * Product list page + */ + public function indexAction() + { + $this->_title($this->__('Catalog')) + ->_title($this->__('Manage Products')); + /** @var $limitation Mage_Catalog_Model_Product_Limitation */ + $limitation = Mage::getObjectManager()->get('Mage_Catalog_Model_Product_Limitation'); + if ($limitation->isCreateRestricted()) { + $this->_getSession()->addNotice($limitation->getCreateRestrictedMessage()); + } + $this->loadLayout(); + $this->renderLayout(); + } + + /** + * Create new product page + */ + public function newAction() + { + if (!$this->getRequest()->getParam('set')) { + $this->_forward('noroute'); + return; + } + $product = $this->_initProduct(); + + $productData = $this->getRequest()->getPost('product'); + if ($productData) { + $this->_filterStockData($productData['stock_data']); + $product->addData($productData); + } + + $this->_title($this->__('New Product')); + + Mage::dispatchEvent('catalog_product_new_action', array('product' => $product)); + + if ($this->getRequest()->getParam('popup')) { + $this->loadLayout('popup'); + } else { + $_additionalLayoutPart = ''; + if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE + && !($product->getTypeInstance()->getUsedProductAttributeIds($product)) + ) { + $_additionalLayoutPart = '_new'; + } + $this->loadLayout(array( + 'default', + strtolower($this->getFullActionName()), + 'adminhtml_catalog_product_' . $product->getTypeId() . $_additionalLayoutPart + )); + $this->_setActiveMenu('Mage_Catalog::catalog_products'); + } + + $this->getLayout()->getBlock('head')->setCanLoadExtJs(false); + + $block = $this->getLayout()->getBlock('catalog.wysiwyg.js'); + if ($block) { + $block->setStoreId($product->getStoreId()); + } + + $this->renderLayout(); + } + + /** + * Product edit form + */ + public function editAction() + { + /** @var $limitation Mage_Catalog_Model_Product_Limitation */ + $limitation = Mage::getObjectManager()->get('Mage_Catalog_Model_Product_Limitation'); + if ($limitation->isCreateRestricted()) { + $this->_getSession()->addNotice($limitation->getCreateRestrictedMessage()); + } + + $productId = (int) $this->getRequest()->getParam('id'); + $product = $this->_initProduct(); + + if ($productId && !$product->getId()) { + $this->_getSession()->addError(Mage::helper('Mage_Catalog_Helper_Data')->__('This product no longer exists.')); + $this->_redirect('*/*/'); + return; + } + + $this->_title($product->getName()); + + Mage::dispatchEvent('catalog_product_edit_action', array('product' => $product)); + + $_additionalLayoutPart = ''; + if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE + && !($product->getTypeInstance()->getUsedProductAttributeIds($product)) + ) { + $_additionalLayoutPart = '_new'; + } + + $this->loadLayout(array( + 'default', + strtolower($this->getFullActionName()), + 'adminhtml_catalog_product_'.$product->getTypeId() . $_additionalLayoutPart + )); + + $this->_setActiveMenu('Mage_Catalog::catalog_products'); + + if (!Mage::app()->isSingleStoreMode() && ($switchBlock = $this->getLayout()->getBlock('store_switcher'))) { + $switchBlock->setDefaultStoreName($this->__('Default Values')) + ->setWebsiteIds($product->getWebsiteIds()) + ->setSwitchUrl( + $this->getUrl('*/*/*', array('_current'=>true, 'active_tab'=>null, 'tab' => null, 'store'=>null)) + ); + } + + $this->getLayout()->getBlock('head')->setCanLoadExtJs(false); + + $block = $this->getLayout()->getBlock('catalog.wysiwyg.js'); + if ($block) { + $block->setStoreId($product->getStoreId()); + } + + $this->renderLayout(); + } + + /** + * WYSIWYG editor action for ajax request + * + */ + public function wysiwygAction() + { + $elementId = $this->getRequest()->getParam('element_id', md5(microtime())); + $storeId = $this->getRequest()->getParam('store_id', 0); + $storeMediaUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); + + $content = $this->getLayout()->createBlock( + 'Mage_Adminhtml_Block_Catalog_Helper_Form_Wysiwyg_Content', + '', + array( + 'data' => array( + 'editor_element_id' => $elementId, + 'store_id' => $storeId, + 'store_media_url' => $storeMediaUrl, + ) + ) + ); + $this->getResponse()->setBody($content->toHtml()); + } + + /** + * Product grid for AJAX request + */ + public function gridAction() + { + $this->loadLayout(); + $this->renderLayout(); + } + + /** + * Get specified tab grid + */ + public function gridOnlyAction() + { + $this->_initProduct(); + $this->loadLayout(); + + $block = $this->getRequest()->getParam('gridOnlyBlock'); + $blockClassSuffix = str_replace(' ', '_', ucwords(str_replace('_', ' ', $block))); + + $this->getResponse()->setBody( + $this->getLayout() + ->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_' . $blockClassSuffix) + ->toHtml() + ); + } + + /** + * Get variations matrix block + * + */ + public function variationsMatrixAction() + { + $this->_initProductSave($this->_initProduct()); + $this->loadLayout(); + $this->renderLayout(); + } + + /** + * Get categories fieldset block + * + */ + public function categoriesAction() + { + $this->_initProduct(); + $this->loadLayout(); + $this->renderLayout(); + } + + /** + * Get options fieldset block + * + */ + public function optionsAction() + { + $this->_initProduct(); + $this->loadLayout(); + $this->renderLayout(); + } + + /** + * Get related products grid and serializer block + */ + public function relatedAction() + { + $this->_initProduct(); + $this->loadLayout(); + $this->getLayout()->getBlock('catalog.product.edit.tab.related') + ->setProductsRelated($this->getRequest()->getPost('products_related', null)); + $this->renderLayout(); + } + + /** + * Get upsell products grid and serializer block + */ + public function upsellAction() + { + $this->_initProduct(); + $this->loadLayout(); + $this->getLayout()->getBlock('catalog.product.edit.tab.upsell') + ->setProductsUpsell($this->getRequest()->getPost('products_upsell', null)); + $this->renderLayout(); + } + + /** + * Get crosssell products grid and serializer block + */ + public function crosssellAction() + { + $this->_initProduct(); + $this->loadLayout(); + $this->getLayout()->getBlock('catalog.product.edit.tab.crosssell') + ->setProductsCrossSell($this->getRequest()->getPost('products_crosssell', null)); + $this->renderLayout(); + } + + /** + * Get related products grid + */ + public function relatedGridAction() + { + $this->_initProduct(); + $this->loadLayout(); + $this->getLayout()->getBlock('catalog.product.edit.tab.related') + ->setProductsRelated($this->getRequest()->getPost('products_related', null)); + $this->renderLayout(); + } + + /** + * Get upsell products grid + */ + public function upsellGridAction() + { + $this->_initProduct(); + $this->loadLayout(); + $this->getLayout()->getBlock('catalog.product.edit.tab.upsell') + ->setProductsRelated($this->getRequest()->getPost('products_upsell', null)); + $this->renderLayout(); + } + + /** + * Get crosssell products grid + */ + public function crosssellGridAction() + { + $this->_initProduct(); + $this->loadLayout(); + $this->getLayout()->getBlock('catalog.product.edit.tab.crosssell') + ->setProductsRelated($this->getRequest()->getPost('products_crosssell', null)); + $this->renderLayout(); + } + + /** + * Get associated grouped products grid + */ + public function superGroupAction() + { + $this->loadLayout(false); + $this->renderLayout(); + } + + /** + * Get associated grouped products grid popup + */ + public function superGroupPopupAction() + { + $this->_initProduct(); + $this->loadLayout(false); + $this->renderLayout(); + } + + /** + * Get product reviews grid + * + */ + public function reviewsAction() + { + $this->_initProduct(); + $this->loadLayout(); + $this->getLayout()->getBlock('admin.product.reviews') + ->setProductId(Mage::registry('product')->getId()) + ->setUseAjax(true); + $this->renderLayout(); + } + + /** + * Get super config grid + * + */ + public function superConfigAction() + { + $this->_initProduct(); + $this->loadLayout(false); + $this->renderLayout(); + } + + /** + * Validate product + * + */ + public function validateAction() + { + $response = new Varien_Object(); + $response->setError(false); + + try { + $productData = $this->getRequest()->getPost('product'); + + if ($productData && !isset($productData['stock_data']['use_config_manage_stock'])) { + $productData['stock_data']['use_config_manage_stock'] = 0; + } + /* @var $product Mage_Catalog_Model_Product */ + $product = Mage::getModel('Mage_Catalog_Model_Product'); + $product->setData('_edit_mode', true); + if ($storeId = $this->getRequest()->getParam('store')) { + $product->setStoreId($storeId); + } + if ($setId = $this->getRequest()->getParam('set')) { + $product->setAttributeSetId($setId); + } + if ($typeId = $this->getRequest()->getParam('type')) { + $product->setTypeId($typeId); + } + if ($productId = $this->getRequest()->getParam('id')) { + $product->load($productId); + } + + $dateFields = array(); + $attributes = $product->getAttributes(); + foreach ($attributes as $attrKey => $attribute) { + if ($attribute->getBackend()->getType() == 'datetime') { + if (array_key_exists($attrKey, $productData) && $productData[$attrKey] != '') { + $dateFields[] = $attrKey; + } + } + } + $productData = $this->_filterDates($productData, $dateFields); + $product->addData($productData); + + /* set restrictions for date ranges */ + $resource = $product->getResource(); + $resource->getAttribute('special_from_date') + ->setMaxValue($product->getSpecialToDate()); + $resource->getAttribute('news_from_date') + ->setMaxValue($product->getNewsToDate()); + $resource->getAttribute('custom_design_from') + ->setMaxValue($product->getCustomDesignTo()); + + if ($products = $this->getRequest()->getPost('variations-matrix')) { + $validationResult = $this->_validateProductVariations($product, $products); + if (!empty($validationResult)) { + $response->setError(true) + ->setMessage(Mage::helper('Mage_Catalog_Helper_Data')->__('Some product variations fields are not valid.')) + ->setAttributes($validationResult); + } + } + $product->validate(); + /** + * @todo implement full validation process with errors returning which are ignoring now + */ +// if (is_array($errors = $product->validate())) { +// foreach ($errors as $code => $error) { +// if ($error === true) { +// Mage::throwException(Mage::helper('Mage_Catalog_Helper_Data')->__('Attribute "%s" is invalid.', $product->getResource()->getAttribute($code)->getFrontend()->getLabel())); +// } +// else { +// Mage::throwException($error); +// } +// } +// } + } + catch (Mage_Eav_Model_Entity_Attribute_Exception $e) { + $response->setError(true); + $response->setAttribute($e->getAttributeCode()); + $response->setMessage($e->getMessage()); + } catch (Mage_Core_Exception $e) { + $response->setError(true); + $response->setMessage($e->getMessage()); + } catch (Exception $e) { + $this->_getSession()->addError($e->getMessage()); + $this->_initLayoutMessages('Mage_Adminhtml_Model_Session'); + $response->setError(true); + $response->setMessage($this->getLayout()->getMessagesBlock()->getGroupedHtml()); + } + + $this->getResponse()->setBody($response->toJson()); + } + + /** + * Product variations attributes validation + * + * @param Mage_Catalog_Model_Product $parentProduct + * @param array $products + * + * @return array + */ + protected function _validateProductVariations($parentProduct, $products) + { + $validationResult = array(); + foreach ($products as $productData) { + $product = $this->_objectManager->create('Mage_Catalog_Model_Product'); + $product->setData('_edit_mode', true); + if ($storeId = $this->getRequest()->getParam('store')) { + $product->setStoreId($storeId); + } + $product->setAttributeSetId($parentProduct->getAttributeSetId()); + + $product->addData($productData); + $product->setCollectExceptionMessages(true); + $configurableAttribute = Mage::helper('Mage_Core_Helper_Data') + ->jsonDecode($productData['configurable_attribute']); + $configurableAttribute = implode('-', $configurableAttribute); + foreach ($product->validate() as $attributeCode => $result) { + if (is_string($result)) { + $validationResult['variations-matrix-' . $configurableAttribute . '-' . $attributeCode] = $result; + } + } + } + + return $validationResult; + } + + /** + * Initialize product before saving + * + * @param $product Mage_Catalog_Model_Product + * @return Mage_Catalog_Model_Product + */ + protected function _initProductSave($product) + { + $productData = $this->getRequest()->getPost('product'); + if ($productData) { + $this->_filterStockData($productData['stock_data']); + } + + /** + * Websites + */ + if (!isset($productData['website_ids'])) { + $productData['website_ids'] = array(); + } + + $wasLockedMedia = false; + if ($product->isLockedAttribute('media')) { + $product->unlockAttribute('media'); + $wasLockedMedia = true; + } + + $product->addData($productData); + + if ($wasLockedMedia) { + $product->lockAttribute('media'); + } + + if (Mage::app()->hasSingleStore()) { + $product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId())); + } + + /** + * Create Permanent Redirect for old URL key + */ + if ($product->getId() && isset($productData['url_key_create_redirect'])) + // && $product->getOrigData('url_key') != $product->getData('url_key') + { + $product->setData('save_rewrites_history', (bool)$productData['url_key_create_redirect']); + } + + /** + * Check "Use Default Value" checkboxes values + */ + if ($useDefaults = $this->getRequest()->getPost('use_default')) { + foreach ($useDefaults as $attributeCode) { + $product->setData($attributeCode, false); + } + } + + /** + * Init product links data (related, upsell, crosssel) + */ + $links = $this->getRequest()->getPost('links'); + if (isset($links['related']) && !$product->getRelatedReadonly()) { + $product->setRelatedLinkData( + Mage::helper('Mage_Adminhtml_Helper_Js')->decodeGridSerializedInput($links['related']) + ); + } + if (isset($links['upsell']) && !$product->getUpsellReadonly()) { + $product->setUpSellLinkData( + Mage::helper('Mage_Adminhtml_Helper_Js')->decodeGridSerializedInput($links['upsell']) + ); + } + if (isset($links['crosssell']) && !$product->getCrosssellReadonly()) { + $product->setCrossSellLinkData(Mage::helper('Mage_Adminhtml_Helper_Js') + ->decodeGridSerializedInput($links['crosssell'])); + } + if (isset($links['grouped']) && !$product->getGroupedReadonly()) { + $product->setGroupedLinkData( + Mage::helper('Mage_Core_Helper_Data')->jsonDecode($links['grouped']) + ); + } + + /** + * Initialize data for configurable product + */ + + $attributes = $this->getRequest()->getParam('attributes'); + if (!empty($attributes)) { + $this->_objectManager->get('Mage_Catalog_Model_Product_Type_Configurable')->setUsedProductAttributeIds( + $attributes, + $product + ); + + $product->setNewVariationsAttributeSetId($this->getRequest()->getPost('new-variations-attribute-set-id')); + $associatedProductIds = $this->getRequest()->getPost('associated_product_ids', array()); + if ($this->getRequest()->getActionName() != 'variationsMatrix') { + $generatedProductIds = $this->_objectManager->get('Mage_Catalog_Model_Product_Type_Configurable') + ->generateSimpleProducts($product, $this->getRequest()->getPost('variations-matrix', array())); + $associatedProductIds = array_merge($associatedProductIds, $generatedProductIds); + } + $product->setAssociatedProductIds(array_filter($associatedProductIds)); + + $product->setCanSaveConfigurableAttributes( + (bool)$this->getRequest()->getPost('affect_configurable_product_attributes') + ); + } + + /** + * Initialize product options + */ + if (isset($productData['options']) && !$product->getOptionsReadonly()) { + $product->setProductOptions($productData['options']); + } + + $product->setCanSaveCustomOptions( + (bool)$this->getRequest()->getPost('affect_product_custom_options') + && !$product->getOptionsReadonly() + ); + + Mage::dispatchEvent( + 'catalog_product_prepare_save', + array('product' => $product, 'request' => $this->getRequest()) + ); + + return $product; + } + + /** + * Filter product stock data + * + * @param array $stockData + */ + protected function _filterStockData(&$stockData) { + if (!isset($stockData['use_config_manage_stock'])) { + $stockData['use_config_manage_stock'] = 0; + } + if (isset($stockData['qty']) && (float)$stockData['qty'] > self::MAX_QTY_VALUE) { + $stockData['qty'] = self::MAX_QTY_VALUE; + } + if (isset($stockData['min_qty']) && (int)$stockData['min_qty'] < 0) { + $stockData['min_qty'] = 0; + } + if (!isset($stockData['is_decimal_divided']) || $stockData['is_qty_decimal'] == 0) { + $stockData['is_decimal_divided'] = 0; + } + } + + /** + * Save product action + */ + public function saveAction() + { + $storeId = $this->getRequest()->getParam('store'); + $redirectBack = $this->getRequest()->getParam('back', false); + $productId = $this->getRequest()->getParam('id'); + $isEdit = (int)($this->getRequest()->getParam('id') != null); + + $data = $this->getRequest()->getPost(); + if ($data) { + $this->_filterStockData($data['product']['stock_data']); + + $product = $this->_initProductSave($this->_initProduct()); + Mage::dispatchEvent( + 'catalog_product_transition_product_type', + array('product' => $product, 'request' => $this->getRequest()) + ); + + try { + if (isset($data['product'][$product->getIdFieldName()])) { + throw new Mage_Core_Exception($this->__('Unable to save product')); + } + + $originalSku = $product->getSku(); + $product->save(); + $productId = $product->getId(); + + /** + * Do copying data to stores + */ + if (isset($data['copy_to_stores'])) { + foreach ($data['copy_to_stores'] as $storeTo=>$storeFrom) { + Mage::getModel('Mage_Catalog_Model_Product') + ->setStoreId($storeFrom) + ->load($productId) + ->setStoreId($storeTo) + ->save(); + } + } + + Mage::getModel('Mage_CatalogRule_Model_Rule')->applyAllRulesToProduct($productId); + + $this->_getSession()->addSuccess($this->__('The product has been saved.')); + if ($product->getSku() != $originalSku) { + $this->_getSession()->addNotice( + $this->__('SKU for product %s has been changed to %s.', Mage::helper('Mage_Core_Helper_Data') + ->escapeHtml($product->getName()), + Mage::helper('Mage_Core_Helper_Data')->escapeHtml($product->getSku())) + ); + } + } catch (Mage_Core_Exception $e) { + $this->_getSession()->addError($e->getMessage()) + ->setProductData($data); + $redirectBack = true; + } catch (Exception $e) { + Mage::logException($e); + $this->_getSession()->addError($e->getMessage()); + $redirectBack = true; + } + } + + if ($redirectBack === 'new') { + $this->_redirect('*/*/new', array( + 'set' => $product->getAttributeSetId(), + 'type' => $product->getTypeId() + )); + } elseif ($redirectBack) { + $this->_redirect('*/*/edit', array( + 'id' => $productId, + '_current' => true + )); + } elseif ($this->getRequest()->getParam('popup')) { + $this->_redirect('*/*/created', array( + '_current' => true, + 'id' => $productId, + 'edit' => $isEdit + )); + } else { + $this->_redirect('*/*/', array('store'=>$storeId)); + } + } + + /** + * Create product duplicate + */ + public function duplicateAction() + { + $product = $this->_initProduct(); + try { + $newProduct = $product->duplicate(); + $this->_getSession()->addSuccess($this->__('The product has been duplicated.')); + $this->_redirect('*/*/edit', array('_current'=>true, 'id'=>$newProduct->getId())); + } catch (Exception $e) { + Mage::logException($e); + $this->_getSession()->addError($e->getMessage()); + $this->_redirect('*/*/edit', array('_current'=>true)); + } + } + + /** + * Delete product action + */ + public function deleteAction() + { + if ($id = $this->getRequest()->getParam('id')) { + $product = Mage::getModel('Mage_Catalog_Model_Product') + ->load($id); + $sku = $product->getSku(); + try { + $product->delete(); + $this->_getSession()->addSuccess($this->__('The product has been deleted.')); + } catch (Exception $e) { + $this->_getSession()->addError($e->getMessage()); + } + } + $this->getResponse() + ->setRedirect($this->getUrl('*/*/', array('store'=>$this->getRequest()->getParam('store')))); + } + + /** + * Get alerts price grid + */ + public function alertsPriceGridAction() + { + $this->loadLayout(false); + $this->renderLayout(); + } + + /** + * Get alerts stock grid + */ + public function alertsStockGridAction() + { + $this->loadLayout(false); + $this->renderLayout(); + } + + public function addAttributeAction() + { + $this->loadLayout('popup'); + $this->_initProduct(); + $this->_addContent( + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Attribute_New_Product_Created') + ); + $this->renderLayout(); + } + + public function createdAction() + { + $this->loadLayout('popup'); + $this->_addContent( + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Created') + ); + $this->renderLayout(); + } + + public function massDeleteAction() + { + $productIds = $this->getRequest()->getParam('product'); + if (!is_array($productIds)) { + $this->_getSession()->addError($this->__('Please select product(s).')); + } else { + if (!empty($productIds)) { + try { + foreach ($productIds as $productId) { + $product = Mage::getSingleton('Mage_Catalog_Model_Product')->load($productId); + $product->delete(); + } + $this->_getSession()->addSuccess( + $this->__('Total of %d record(s) have been deleted.', count($productIds)) + ); + } catch (Exception $e) { + $this->_getSession()->addError($e->getMessage()); + } + } + } + $this->_redirect('*/*/index'); + } + + /** + * Update product(s) status action + * + */ + public function massStatusAction() + { + $productIds = (array)$this->getRequest()->getParam('product'); + $storeId = (int)$this->getRequest()->getParam('store', 0); + $status = (int)$this->getRequest()->getParam('status'); + + try { + $this->_validateMassStatus($productIds, $status); + Mage::getSingleton('Mage_Catalog_Model_Product_Action') + ->updateAttributes($productIds, array('status' => $status), $storeId); + + $this->_getSession()->addSuccess( + $this->__('Total of %d record(s) have been updated.', count($productIds)) + ); + } + catch (Mage_Core_Model_Exception $e) { + $this->_getSession()->addError($e->getMessage()); + } catch (Mage_Core_Exception $e) { + $this->_getSession()->addError($e->getMessage()); + } catch (Exception $e) { + $this->_getSession() + ->addException($e, $this->__('An error occurred while updating the product(s) status.')); + } + + $this->_redirect('*/*/', array('store'=> $storeId)); + } + + /** + * Validate batch of products before theirs status will be set + * + * @throws Mage_Core_Exception + * @param array $productIds + * @param int $status + * @return void + */ + public function _validateMassStatus(array $productIds, $status) + { + if ($status == Mage_Catalog_Model_Product_Status::STATUS_ENABLED) { + if (!Mage::getModel('Mage_Catalog_Model_Product')->isProductsHasSku($productIds)) { + throw new Mage_Core_Exception( + $this->__('Some of the processed products have no SKU value defined. Please fill it prior to performing operations on these products.') + ); + } + } + } + + /** + * Check for is allowed + * + * @return boolean + */ + protected function _isAllowed() + { + return Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Catalog::products'); + } + + /** + * Show item update result from updateAction + * in Wishlist and Cart controllers. + * + */ + public function showUpdateResultAction() + { + $session = Mage::getSingleton('Mage_Adminhtml_Model_Session'); + if ($session->hasCompositeProductResult() && $session->getCompositeProductResult() instanceof Varien_Object){ + /* @var $helper Mage_Adminhtml_Helper_Catalog_Product_Composite */ + $helper = Mage::helper('Mage_Adminhtml_Helper_Catalog_Product_Composite'); + $helper->renderUpdateResult($this, $session->getCompositeProductResult()); + $session->unsCompositeProductResult(); + } else { + $session->unsCompositeProductResult(); + return false; + } + } + + /** + * Show product grid for custom options import popup + */ + public function optionsImportGridAction() + { + $this->loadLayout(); + $this->renderLayout(); + } + + /** + * Show custom options in JSON format for specified products + */ + public function customOptionsAction() + { + Mage::register('import_option_products', $this->getRequest()->getPost('products')); + $this->loadLayout(); + $this->renderLayout(); + } + + /** + * Action for product template selector + */ + public function suggestProductTemplatesAction() + { + $this->_initProduct(); + $this->getResponse()->setBody(Mage::helper('Mage_Core_Helper_Data')->jsonEncode( + $this->getLayout()->createBlock('Mage_Catalog_Block_Product_TemplateSelector') + ->getSuggestedTemplates($this->getRequest()->getParam('label_part')) + )); + } +} diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php b/app/code/Mage/Adminhtml/controllers/Catalog/SearchController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php rename to app/code/Mage/Adminhtml/controllers/Catalog/SearchController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php b/app/code/Mage/Adminhtml/controllers/Checkout/AgreementController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php rename to app/code/Mage/Adminhtml/controllers/Checkout/AgreementController.php diff --git a/app/code/Mage/Adminhtml/controllers/Cms/Block/WidgetController.php b/app/code/Mage/Adminhtml/controllers/Cms/Block/WidgetController.php new file mode 100644 index 0000000000000..ce4f074f4e3df --- /dev/null +++ b/app/code/Mage/Adminhtml/controllers/Cms/Block/WidgetController.php @@ -0,0 +1,48 @@ + + */ +class Mage_Adminhtml_Cms_Block_WidgetController extends Mage_Adminhtml_Controller_Action +{ + /** + * Chooser Source action + */ + public function chooserAction() + { + $uniqId = $this->getRequest()->getParam('uniq_id'); + $pagesGrid = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Cms_Block_Widget_Chooser', '', array( + 'data' => array('id' => $uniqId) + )); + $this->getResponse()->setBody($pagesGrid->toHtml()); + } +} diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php b/app/code/Mage/Adminhtml/controllers/Cms/BlockController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php rename to app/code/Mage/Adminhtml/controllers/Cms/BlockController.php diff --git a/app/code/Mage/Adminhtml/controllers/Cms/Page/WidgetController.php b/app/code/Mage/Adminhtml/controllers/Cms/Page/WidgetController.php new file mode 100644 index 0000000000000..403fb9673d6ff --- /dev/null +++ b/app/code/Mage/Adminhtml/controllers/Cms/Page/WidgetController.php @@ -0,0 +1,48 @@ + + */ +class Mage_Adminhtml_Cms_Page_WidgetController extends Mage_Adminhtml_Controller_Action +{ + /** + * Chooser Source action + */ + public function chooserAction() + { + $uniqId = $this->getRequest()->getParam('uniq_id'); + $pagesGrid = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Cms_Page_Widget_Chooser', '', array( + 'data' => array('id' => $uniqId) + )); + $this->getResponse()->setBody($pagesGrid->toHtml()); + } +} diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php b/app/code/Mage/Adminhtml/controllers/Cms/PageController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php rename to app/code/Mage/Adminhtml/controllers/Cms/PageController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php b/app/code/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php rename to app/code/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/WysiwygController.php b/app/code/Mage/Adminhtml/controllers/Cms/WysiwygController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Cms/WysiwygController.php rename to app/code/Mage/Adminhtml/controllers/Cms/WysiwygController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Customer/Cart/Product/Composite/CartController.php b/app/code/Mage/Adminhtml/controllers/Customer/Cart/Product/Composite/CartController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Customer/Cart/Product/Composite/CartController.php rename to app/code/Mage/Adminhtml/controllers/Customer/Cart/Product/Composite/CartController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Customer/GroupController.php b/app/code/Mage/Adminhtml/controllers/Customer/GroupController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Customer/GroupController.php rename to app/code/Mage/Adminhtml/controllers/Customer/GroupController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Customer/OnlineController.php b/app/code/Mage/Adminhtml/controllers/Customer/OnlineController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Customer/OnlineController.php rename to app/code/Mage/Adminhtml/controllers/Customer/OnlineController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Customer/System/Config/ValidatevatController.php b/app/code/Mage/Adminhtml/controllers/Customer/System/Config/ValidatevatController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Customer/System/Config/ValidatevatController.php rename to app/code/Mage/Adminhtml/controllers/Customer/System/Config/ValidatevatController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Customer/Wishlist/Product/Composite/WishlistController.php b/app/code/Mage/Adminhtml/controllers/Customer/Wishlist/Product/Composite/WishlistController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Customer/Wishlist/Product/Composite/WishlistController.php rename to app/code/Mage/Adminhtml/controllers/Customer/Wishlist/Product/Composite/WishlistController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/CustomerController.php b/app/code/Mage/Adminhtml/controllers/CustomerController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/CustomerController.php rename to app/code/Mage/Adminhtml/controllers/CustomerController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/DashboardController.php b/app/code/Mage/Adminhtml/controllers/DashboardController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/DashboardController.php rename to app/code/Mage/Adminhtml/controllers/DashboardController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/IndexController.php b/app/code/Mage/Adminhtml/controllers/IndexController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/IndexController.php rename to app/code/Mage/Adminhtml/controllers/IndexController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/JsonController.php b/app/code/Mage/Adminhtml/controllers/JsonController.php similarity index 79% rename from app/code/core/Mage/Adminhtml/controllers/JsonController.php rename to app/code/Mage/Adminhtml/controllers/JsonController.php index 8fbccee99308d..23035c687f497 100644 --- a/app/code/core/Mage/Adminhtml/controllers/JsonController.php +++ b/app/code/Mage/Adminhtml/controllers/JsonController.php @@ -43,17 +43,18 @@ public function countryRegionAction() $arrRes = array(); $countryId = $this->getRequest()->getParam('parent'); - $arrRegions = Mage::getResourceModel('Mage_Directory_Model_Resource_Region_Collection') - ->addCountryFilter($countryId) - ->load() - ->toOptionArray(); + if (!empty($countryId)) { + $arrRegions = Mage::getResourceModel('Mage_Directory_Model_Resource_Region_Collection') + ->addCountryFilter($countryId) + ->load() + ->toOptionArray(); - if (!empty($arrRegions)) { - foreach ($arrRegions as $region) { - $arrRes[] = $region; + if (!empty($arrRegions)) { + foreach ($arrRegions as $region) { + $arrRes[] = $region; + } } } - $this->getResponse()->setBody(Mage::helper('Mage_Core_Helper_Data')->jsonEncode($arrRes)); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php b/app/code/Mage/Adminhtml/controllers/Newsletter/ProblemController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php rename to app/code/Mage/Adminhtml/controllers/Newsletter/ProblemController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php b/app/code/Mage/Adminhtml/controllers/Newsletter/QueueController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php rename to app/code/Mage/Adminhtml/controllers/Newsletter/QueueController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php b/app/code/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php rename to app/code/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php b/app/code/Mage/Adminhtml/controllers/Newsletter/TemplateController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php rename to app/code/Mage/Adminhtml/controllers/Newsletter/TemplateController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/NotificationController.php b/app/code/Mage/Adminhtml/controllers/NotificationController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/NotificationController.php rename to app/code/Mage/Adminhtml/controllers/NotificationController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Poll/AnswerController.php b/app/code/Mage/Adminhtml/controllers/Poll/AnswerController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Poll/AnswerController.php rename to app/code/Mage/Adminhtml/controllers/Poll/AnswerController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/PollController.php b/app/code/Mage/Adminhtml/controllers/PollController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/PollController.php rename to app/code/Mage/Adminhtml/controllers/PollController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php b/app/code/Mage/Adminhtml/controllers/Promo/CatalogController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php rename to app/code/Mage/Adminhtml/controllers/Promo/CatalogController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php b/app/code/Mage/Adminhtml/controllers/Promo/QuoteController.php similarity index 99% rename from app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php rename to app/code/Mage/Adminhtml/controllers/Promo/QuoteController.php index 21133f219ec5b..334ce0ed74751 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php +++ b/app/code/Mage/Adminhtml/controllers/Promo/QuoteController.php @@ -400,7 +400,7 @@ public function chooserAction() { $uniqId = $this->getRequest()->getParam('uniq_id'); $chooserBlock = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Promo_Widget_Chooser', '', array( - 'id' => $uniqId + 'data' => array('id' => $uniqId) )); $this->getResponse()->setBody($chooserBlock->toHtml()); } diff --git a/app/code/Mage/Adminhtml/controllers/Promo/WidgetController.php b/app/code/Mage/Adminhtml/controllers/Promo/WidgetController.php new file mode 100644 index 0000000000000..a133e666794fa --- /dev/null +++ b/app/code/Mage/Adminhtml/controllers/Promo/WidgetController.php @@ -0,0 +1,133 @@ +getRequest(); + + switch ($request->getParam('attribute')) { + case 'sku': + $block = $this->getLayout()->createBlock( + 'Mage_Adminhtml_Block_Promo_Widget_Chooser_Sku', 'promo_widget_chooser_sku', + array('data' => array('js_form_object' => $request->getParam('form')), + )); + break; + + case 'category_ids': + $ids = $request->getParam('selected', array()); + if (is_array($ids)) { + foreach ($ids as $key => &$id) { + $id = (int) $id; + if ($id <= 0) { + unset($ids[$key]); + } + } + + $ids = array_unique($ids); + } else { + $ids = array(); + } + + + $block = $this->getLayout()->createBlock( + 'Mage_Adminhtml_Block_Catalog_Category_Checkboxes_Tree', 'promo_widget_chooser_category_ids', + array('data' => array('js_form_object' => $request->getParam('form'))) + ) + ->setCategoryIds($ids) + ; + break; + + default: + $block = false; + break; + } + + if ($block) { + $this->getResponse()->setBody($block->toHtml()); + } + } + + protected function _isAllowed() + { + return Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_CatalogRule::promo_catalog'); + } + + /** + * Get tree node (Ajax version) + */ + public function categoriesJsonAction() + { + if ($categoryId = (int) $this->getRequest()->getPost('id')) { + $this->getRequest()->setParam('id', $categoryId); + + if (!$category = $this->_initCategory()) { + return; + } + $this->getResponse()->setBody( + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Category_Tree') + ->getTreeJson($category) + ); + } + } + + /** + * Initialize category object in registry + * + * @return Mage_Catalog_Model_Category + */ + protected function _initCategory() + { + $categoryId = (int) $this->getRequest()->getParam('id',false); + $storeId = (int) $this->getRequest()->getParam('store'); + + $category = Mage::getModel('Mage_Catalog_Model_Category'); + $category->setStoreId($storeId); + + if ($categoryId) { + $category->load($categoryId); + if ($storeId) { + $rootId = Mage::app()->getStore($storeId)->getRootCategoryId(); + if (!in_array($rootId, $category->getPathIds())) { + $this->_redirect('*/*/', array('_current'=>true, 'id'=>null)); + return false; + } + } + } + + Mage::register('category', $category); + Mage::register('current_category', $category); + + return $category; + } +} diff --git a/app/code/core/Mage/Adminhtml/controllers/PromoController.php b/app/code/Mage/Adminhtml/controllers/PromoController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/PromoController.php rename to app/code/Mage/Adminhtml/controllers/PromoController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/RatingController.php b/app/code/Mage/Adminhtml/controllers/RatingController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/RatingController.php rename to app/code/Mage/Adminhtml/controllers/RatingController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php b/app/code/Mage/Adminhtml/controllers/Report/CustomerController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php rename to app/code/Mage/Adminhtml/controllers/Report/CustomerController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php b/app/code/Mage/Adminhtml/controllers/Report/ProductController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php rename to app/code/Mage/Adminhtml/controllers/Report/ProductController.php diff --git a/app/code/Mage/Adminhtml/controllers/Report/ReviewController.php b/app/code/Mage/Adminhtml/controllers/Report/ReviewController.php new file mode 100644 index 0000000000000..d3126c33c9e2b --- /dev/null +++ b/app/code/Mage/Adminhtml/controllers/Report/ReviewController.php @@ -0,0 +1,178 @@ + + */ +class Mage_Adminhtml_Report_ReviewController extends Mage_Adminhtml_Controller_Action +{ + public function _initAction() + { + $this->loadLayout() + ->_addBreadcrumb( + Mage::helper('Mage_Reports_Helper_Data')->__('Reports'), + Mage::helper('Mage_Reports_Helper_Data')->__('Reports') + ) + ->_addBreadcrumb( + Mage::helper('Mage_Reports_Helper_Data')->__('Review'), + Mage::helper('Mage_Reports_Helper_Data')->__('Reviews') + ); + return $this; + } + + public function customerAction() + { + $this->_title($this->__('Reports')) + ->_title($this->__('Reviews')) + ->_title($this->__('Customers Reviews')); + + $this->_initAction() + ->_setActiveMenu('Mage_Review::report_review_customer') + ->_addBreadcrumb( + Mage::helper('Mage_Reports_Helper_Data')->__('Customers Report'), + Mage::helper('Mage_Reports_Helper_Data')->__('Customers Report') + ); + $this->renderLayout(); + } + + /** + * Export review customer report to CSV format + */ + public function exportCustomerCsvAction() + { + $this->loadLayout(false); + $fileName = 'review_customer.csv'; + $exportBlock = $this->getLayout()->getChildBlock('adminhtml.block.report.review.customer.grid','grid.export'); + $this->_prepareDownloadResponse($fileName, $exportBlock->getCsvFile()); + } + + /** + * Export review customer report to Excel XML format + */ + public function exportCustomerExcelAction() + { + $this->loadLayout(false); + $fileName = 'review_customer.xml'; + $exportBlock = $this->getLayout()->getChildBlock('adminhtml.block.report.review.customer.grid','grid.export'); + $this->_prepareDownloadResponse($fileName, $exportBlock->getExcelFile()); + + } + + public function productAction() + { + $this->_title($this->__('Reports')) + ->_title($this->__('Reviews')) + ->_title($this->__('Products Reviews')); + + $this->_initAction() + ->_setActiveMenu('Mage_Review::report_review_product') + ->_addBreadcrumb( + Mage::helper('Mage_Reports_Helper_Data')->__('Products Report'), + Mage::helper('Mage_Reports_Helper_Data')->__('Products Report') + ); + $this->renderLayout(); + } + + /** + * Export review product report to CSV format + */ + public function exportProductCsvAction() + { + $this->loadLayout(false); + $fileName = 'review_product.csv'; + $exportBlock = $this->getLayout()->getChildBlock('adminhtml.block.report.review.product.grid','grid.export'); + $this->_prepareDownloadResponse($fileName, $exportBlock->getCsvFile()); + } + + /** + * Export review product report to Excel XML format + */ + public function exportProductExcelAction() + { + $this->loadLayout(false); + $fileName = 'review_product.xml'; + $exportBlock = $this->getLayout()->getChildBlock('adminhtml.block.report.review.product.grid','grid.export'); + $this->_prepareDownloadResponse($fileName, $exportBlock->getExcelFile()); + } + + public function productDetailAction() + { + $this->_title($this->__('Reports')) + ->_title($this->__('Reviews')) + ->_title($this->__('Product Reviews')) + ->_title($this->__('Details')); + + $this->_initAction() + ->_setActiveMenu('Mage_Review::report_review') + ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Products Report'), Mage::helper('Mage_Reports_Helper_Data')->__('Products Report')) + ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Product Reviews'), Mage::helper('Mage_Reports_Helper_Data')->__('Product Reviews')) + ->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Review_Detail')) + ->renderLayout(); + } + + /** + * Export review product detail report to CSV format + */ + public function exportProductDetailCsvAction() + { + $fileName = 'review_product_detail.csv'; + $content = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Review_Detail_Grid') + ->getCsv(); + + $this->_prepareDownloadResponse($fileName, $content); + } + + /** + * Export review product detail report to ExcelXML format + */ + public function exportProductDetailExcelAction() + { + $fileName = 'review_product_detail.xml'; + $content = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Review_Detail_Grid') + ->getExcel($fileName); + + $this->_prepareDownloadResponse($fileName, $content); + } + + protected function _isAllowed() + { + switch ($this->getRequest()->getActionName()) { + case 'customer': + return Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Reports::review_customer'); + break; + case 'product': + return Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Reports::review_product'); + break; + default: + return Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Reports::review'); + break; + } + } +} diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/SalesController.php b/app/code/Mage/Adminhtml/controllers/Report/SalesController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Report/SalesController.php rename to app/code/Mage/Adminhtml/controllers/Report/SalesController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/ShopcartController.php b/app/code/Mage/Adminhtml/controllers/Report/ShopcartController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Report/ShopcartController.php rename to app/code/Mage/Adminhtml/controllers/Report/ShopcartController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/StatisticsController.php b/app/code/Mage/Adminhtml/controllers/Report/StatisticsController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Report/StatisticsController.php rename to app/code/Mage/Adminhtml/controllers/Report/StatisticsController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/ReportController.php b/app/code/Mage/Adminhtml/controllers/ReportController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/ReportController.php rename to app/code/Mage/Adminhtml/controllers/ReportController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Billing/AgreementController.php b/app/code/Mage/Adminhtml/controllers/Sales/Billing/AgreementController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Sales/Billing/AgreementController.php rename to app/code/Mage/Adminhtml/controllers/Sales/Billing/AgreementController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/CreditmemoController.php b/app/code/Mage/Adminhtml/controllers/Sales/CreditmemoController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Sales/CreditmemoController.php rename to app/code/Mage/Adminhtml/controllers/Sales/CreditmemoController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/InvoiceController.php b/app/code/Mage/Adminhtml/controllers/Sales/InvoiceController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Sales/InvoiceController.php rename to app/code/Mage/Adminhtml/controllers/Sales/InvoiceController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php b/app/code/Mage/Adminhtml/controllers/Sales/Order/CreateController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php rename to app/code/Mage/Adminhtml/controllers/Sales/Order/CreateController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php b/app/code/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php rename to app/code/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/EditController.php b/app/code/Mage/Adminhtml/controllers/Sales/Order/EditController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Sales/Order/EditController.php rename to app/code/Mage/Adminhtml/controllers/Sales/Order/EditController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php b/app/code/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php rename to app/code/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php b/app/code/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php rename to app/code/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/StatusController.php b/app/code/Mage/Adminhtml/controllers/Sales/Order/StatusController.php similarity index 98% rename from app/code/core/Mage/Adminhtml/controllers/Sales/Order/StatusController.php rename to app/code/Mage/Adminhtml/controllers/Sales/Order/StatusController.php index b245ee796d17d..93faeb299e17a 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/StatusController.php +++ b/app/code/Mage/Adminhtml/controllers/Sales/Order/StatusController.php @@ -64,7 +64,7 @@ protected function _initStatus() public function indexAction() { $this->_title($this->__('Sales'))->_title($this->__('Order Statuses')); - $this->loadLayout()->_setActiveMenu('Mage_Adminhtml::system')->renderLayout(); + $this->loadLayout()->_setActiveMenu('Mage_Sales::system_order_statuses')->renderLayout(); } /** diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/View/GiftmessageController.php b/app/code/Mage/Adminhtml/controllers/Sales/Order/View/GiftmessageController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Sales/Order/View/GiftmessageController.php rename to app/code/Mage/Adminhtml/controllers/Sales/Order/View/GiftmessageController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php b/app/code/Mage/Adminhtml/controllers/Sales/OrderController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php rename to app/code/Mage/Adminhtml/controllers/Sales/OrderController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Recurring/ProfileController.php b/app/code/Mage/Adminhtml/controllers/Sales/Recurring/ProfileController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Sales/Recurring/ProfileController.php rename to app/code/Mage/Adminhtml/controllers/Sales/Recurring/ProfileController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/ShipmentController.php b/app/code/Mage/Adminhtml/controllers/Sales/ShipmentController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Sales/ShipmentController.php rename to app/code/Mage/Adminhtml/controllers/Sales/ShipmentController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/TransactionsController.php b/app/code/Mage/Adminhtml/controllers/Sales/TransactionsController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Sales/TransactionsController.php rename to app/code/Mage/Adminhtml/controllers/Sales/TransactionsController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/SitemapController.php b/app/code/Mage/Adminhtml/controllers/SitemapController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/SitemapController.php rename to app/code/Mage/Adminhtml/controllers/SitemapController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/SurveyController.php b/app/code/Mage/Adminhtml/controllers/SurveyController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/SurveyController.php rename to app/code/Mage/Adminhtml/controllers/SurveyController.php diff --git a/app/code/Mage/Adminhtml/controllers/System/AccountController.php b/app/code/Mage/Adminhtml/controllers/System/AccountController.php new file mode 100644 index 0000000000000..56229b02dfd0e --- /dev/null +++ b/app/code/Mage/Adminhtml/controllers/System/AccountController.php @@ -0,0 +1,90 @@ + + */ + +class Mage_Adminhtml_System_AccountController extends Mage_Adminhtml_Controller_Action +{ + public function indexAction() + { + $this->_title($this->__('System'))->_title($this->__('My Account')); + + $this->loadLayout(); + $this->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_System_Account_Edit')); + $this->renderLayout(); + } + + /** + * Saving edited user information + */ + public function saveAction() + { + $userId = Mage::getSingleton('Mage_Backend_Model_Auth_Session')->getUser()->getId(); + $password = (string)$this->getRequest()->getParam('password'); + $passwordConfirmation = (string)$this->getRequest()->getParam('password_confirmation'); + + /** @var $user Mage_User_Model_User */ + $user = Mage::getModel('Mage_User_Model_User')->load($userId); + + $user->setId($userId) + ->setUsername($this->getRequest()->getParam('username', false)) + ->setFirstname($this->getRequest()->getParam('firstname', false)) + ->setLastname($this->getRequest()->getParam('lastname', false)) + ->setEmail(strtolower($this->getRequest()->getParam('email', false))); + + if ($password !== '') { + $user->setPassword($password); + } + if ($passwordConfirmation !== '') { + $user->setPasswordConfirmation($passwordConfirmation); + } + + try { + $user->save(); + $this->_getSession()->addSuccess( + Mage::helper('Mage_Adminhtml_Helper_Data')->__('The account has been saved.') + ); + } catch (Mage_Core_Exception $e) { + $this->_getSession()->addMessages($e->getMessages()); + } catch (Exception $e) { + $this->_getSession()->addError( + Mage::helper('Mage_Adminhtml_Helper_Data')->__('An error occurred while saving account.') + ); + } + $this->getResponse()->setRedirect($this->getUrl("*/*/")); + } + + protected function _isAllowed() + { + return Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Adminhtml::myaccount'); + } +} diff --git a/app/code/core/Mage/Adminhtml/controllers/System/BackupController.php b/app/code/Mage/Adminhtml/controllers/System/BackupController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/System/BackupController.php rename to app/code/Mage/Adminhtml/controllers/System/BackupController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/System/Config/System/StorageController.php b/app/code/Mage/Adminhtml/controllers/System/Config/System/StorageController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/System/Config/System/StorageController.php rename to app/code/Mage/Adminhtml/controllers/System/Config/System/StorageController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php b/app/code/Mage/Adminhtml/controllers/System/CurrencyController.php similarity index 98% rename from app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php rename to app/code/Mage/Adminhtml/controllers/System/CurrencyController.php index 21f839006529d..09849fa50d0bf 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php +++ b/app/code/Mage/Adminhtml/controllers/System/CurrencyController.php @@ -56,7 +56,7 @@ public function indexAction() $this->_title($this->__('System'))->_title($this->__('Manage Currency Rates')); $this->loadLayout(); - $this->_setActiveMenu('Mage_Adminhtml::system_currency'); + $this->_setActiveMenu('Mage_CurrencySymbol::system_currency_rates'); $this->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_System_Currency')); $this->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php b/app/code/Mage/Adminhtml/controllers/System/DesignController.php similarity index 98% rename from app/code/core/Mage/Adminhtml/controllers/System/DesignController.php rename to app/code/Mage/Adminhtml/controllers/System/DesignController.php index b75c9819f5450..0e4646481232d 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php +++ b/app/code/Mage/Adminhtml/controllers/System/DesignController.php @@ -31,7 +31,7 @@ public function indexAction() { $this->_title($this->__('System'))->_title($this->__('Design')); $this->loadLayout(); - $this->_setActiveMenu('Mage_Adminhtml::system'); + $this->_setActiveMenu('Mage_Adminhtml::system_design_schedule'); $this->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php b/app/code/Mage/Adminhtml/controllers/System/Email/TemplateController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php rename to app/code/Mage/Adminhtml/controllers/System/Email/TemplateController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/System/StoreController.php b/app/code/Mage/Adminhtml/controllers/System/StoreController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/System/StoreController.php rename to app/code/Mage/Adminhtml/controllers/System/StoreController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/System/VariableController.php b/app/code/Mage/Adminhtml/controllers/System/VariableController.php similarity index 98% rename from app/code/core/Mage/Adminhtml/controllers/System/VariableController.php rename to app/code/Mage/Adminhtml/controllers/System/VariableController.php index 3ce338cfdd689..1ca3b49513fb4 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/VariableController.php +++ b/app/code/Mage/Adminhtml/controllers/System/VariableController.php @@ -101,7 +101,7 @@ public function editAction() $this->_initLayout() ->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_System_Variable_Edit')) ->_addJs($this->getLayout()->createBlock('Mage_Core_Block_Template', '', array( - 'template' => 'Mage_Adminhtml::system/variable/js.phtml' + 'data' => array('template' => 'Mage_Adminhtml::system/variable/js.phtml') ))) ->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/ClassController.php b/app/code/Mage/Adminhtml/controllers/Tax/ClassController.php similarity index 97% rename from app/code/core/Mage/Adminhtml/controllers/Tax/ClassController.php rename to app/code/Mage/Adminhtml/controllers/Tax/ClassController.php index 68cade209c47a..029ed6b44f114 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Tax/ClassController.php +++ b/app/code/Mage/Adminhtml/controllers/Tax/ClassController.php @@ -50,7 +50,6 @@ public function ajaxSaveAction() ->save(); $responseContent = Mage::helper('Mage_Core_Helper_Data')->jsonEncode(array( 'success' => true, - 'error' => false, 'error_message' => '', 'class_id' => $class->getId(), 'class_name' => $class->getClassName() @@ -58,7 +57,6 @@ public function ajaxSaveAction() } catch (Mage_Core_Exception $e) { $responseContent = Mage::helper('Mage_Core_Helper_Data')->jsonEncode(array( 'success' => false, - 'error' => true, 'error_message' => $e->getMessage(), 'class_id' => '', 'class_name' => '' @@ -66,7 +64,6 @@ public function ajaxSaveAction() } catch (Exception $e) { $responseContent = Mage::helper('Mage_Core_Helper_Data')->jsonEncode(array( 'success' => false, - 'error' => true, 'error_message' => Mage::helper('Mage_Tax_Helper_Data') ->__('There was an error saving tax class.'), 'class_id' => '', 'class_name' => '' @@ -88,19 +85,16 @@ public function ajaxDeleteAction() $classModel->delete(); $responseContent = Mage::helper('Mage_Core_Helper_Data')->jsonEncode(array( 'success' => true, - 'error' => false, 'error_message' => '' )); } catch (Mage_Core_Exception $e) { $responseContent = Mage::helper('Mage_Core_Helper_Data')->jsonEncode(array( 'success' => false, - 'error' => true, 'error_message' => $e->getMessage() )); } catch (Exception $e) { $responseContent = Mage::helper('Mage_Core_Helper_Data')->jsonEncode(array( 'success' => false, - 'error' => true, 'error_message' => Mage::helper('Mage_Tax_Helper_Data')->__('An error occurred while deleting this tax class.') )); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php b/app/code/Mage/Adminhtml/controllers/Tax/RateController.php similarity index 77% rename from app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php rename to app/code/Mage/Adminhtml/controllers/Tax/RateController.php index 516b781a255c5..b12790dd8f396 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php +++ b/app/code/Mage/Adminhtml/controllers/Tax/RateController.php @@ -134,7 +134,6 @@ public function ajaxSaveAction() ->save(); $responseContent = Mage::helper('Mage_Core_Helper_Data')->jsonEncode(array( 'success' => true, - 'error' => false, 'error_message' => '', 'tax_calculation_rate_id' => $rate->getId(), 'code' => $rate->getCode(), @@ -142,7 +141,6 @@ public function ajaxSaveAction() } catch (Mage_Core_Exception $e) { $responseContent = Mage::helper('Mage_Core_Helper_Data')->jsonEncode(array( 'success' => false, - 'error' => true, 'error_message' => $e->getMessage(), 'tax_calculation_rate_id' => '', 'code' => '', @@ -150,7 +148,6 @@ public function ajaxSaveAction() } catch (Exception $e) { $responseContent = Mage::helper('Mage_Core_Helper_Data')->jsonEncode(array( 'success' => false, - 'error' => true, 'error_message' => Mage::helper('Mage_Tax_Helper_Data') ->__('There was an error saving tax rate.'), 'tax_calculation_rate_id' => '', 'code' => '', @@ -263,19 +260,16 @@ public function ajaxDeleteAction() $rate->delete(); $responseContent = Mage::helper('Mage_Core_Helper_Data')->jsonEncode(array( 'success' => true, - 'error' => false, 'error_message' => '' )); } catch (Mage_Core_Exception $e) { $responseContent = Mage::helper('Mage_Core_Helper_Data')->jsonEncode(array( 'success' => false, - 'error' => true, 'error_message' => $e->getMessage() )); } catch (Exception $e) { $responseContent = Mage::helper('Mage_Core_Helper_Data')->jsonEncode(array( 'success' => false, - 'error' => true, 'error_message' => Mage::helper('Mage_Tax_Helper_Data')->__('An error occurred while deleting this tax rate.') )); } @@ -344,7 +338,9 @@ public function importPostAction() { if ($this->getRequest()->isPost() && !empty($_FILES['import_rates_file']['tmp_name'])) { try { - $this->_importRates(); + /** @var $importHandler Mage_Tax_Model_Rate_CsvImportHandler */ + $importHandler = $this->_objectManager->create('Mage_Tax_Model_Rate_CsvImportHandler'); + $importHandler->importFromCsvFile($this->getRequest()->getFiles('import_rates_file')); Mage::getSingleton('Mage_Adminhtml_Model_Session')->addSuccess(Mage::helper('Mage_Tax_Helper_Data')->__('The tax rate has been imported.')); } catch (Mage_Core_Exception $e) { @@ -358,124 +354,6 @@ public function importPostAction() $this->_redirectReferer(); } - protected function _importRates() - { - $fileName = $_FILES['import_rates_file']['tmp_name']; - $csvObject = new Varien_File_Csv(); - $csvData = $csvObject->getData($fileName); - - /** checks columns */ - $csvFields = array( - 0 => Mage::helper('Mage_Tax_Helper_Data')->__('Code'), - 1 => Mage::helper('Mage_Tax_Helper_Data')->__('Country'), - 2 => Mage::helper('Mage_Tax_Helper_Data')->__('State'), - 3 => Mage::helper('Mage_Tax_Helper_Data')->__('Zip/Post Code'), - 4 => Mage::helper('Mage_Tax_Helper_Data')->__('Rate'), - 5 => Mage::helper('Mage_Tax_Helper_Data')->__('Zip/Post is Range'), - 6 => Mage::helper('Mage_Tax_Helper_Data')->__('Range From'), - 7 => Mage::helper('Mage_Tax_Helper_Data')->__('Range To') - ); - - - $stores = array(); - $unset = array(); - $storeCollection = Mage::getModel('Mage_Core_Model_Store')->getCollection()->setLoadDefault(false); - $cvsFieldsNum = count($csvFields); - $cvsDataNum = count($csvData[0]); - for ($i = $cvsFieldsNum; $i < $cvsDataNum; $i++) { - $header = $csvData[0][$i]; - $found = false; - foreach ($storeCollection as $store) { - if ($header == $store->getCode()) { - $csvFields[$i] = $store->getCode(); - $stores[$i] = $store->getId(); - $found = true; - } - } - if (!$found) { - $unset[] = $i; - } - - } - - $regions = array(); - - if ($unset) { - foreach ($unset as $u) { - unset($csvData[0][$u]); - } - } - if ($csvData[0] == $csvFields) { - /** @var $helper Mage_Adminhtml_Helper_Data */ - $helper = Mage::helper('Mage_Adminhtml_Helper_Data'); - - foreach ($csvData as $k => $v) { - if ($k == 0) { - continue; - } - - //end of file has more then one empty lines - if (count($v) <= 1 && !strlen($v[0])) { - continue; - } - if ($unset) { - foreach ($unset as $u) { - unset($v[$u]); - } - } - - if (count($csvFields) != count($v)) { - Mage::getSingleton('Mage_Adminhtml_Model_Session')->addError(Mage::helper('Mage_Tax_Helper_Data')->__('Invalid file upload attempt')); - } - - $country = Mage::getModel('Mage_Directory_Model_Country')->loadByCode($v[1], 'iso2_code'); - if (!$country->getId()) { - Mage::getSingleton('Mage_Adminhtml_Model_Session')->addError(Mage::helper('Mage_Tax_Helper_Data')->__('One of the country has invalid code.')); - continue; - } - - if (!isset($regions[$v[1]])) { - $regions[$v[1]]['*'] = '*'; - $regionCollection = Mage::getModel('Mage_Directory_Model_Region')->getCollection() - ->addCountryFilter($v[1]); - if ($regionCollection->getSize()) { - foreach ($regionCollection as $region) { - $regions[$v[1]][$region->getCode()] = $region->getRegionId(); - } - } - } - - if (!empty($regions[$v[1]][$v[2]])) { - $rateData = array( - 'code' => $v[0], - 'tax_country_id' => $v[1], - 'tax_region_id' => ($regions[$v[1]][$v[2]] == '*') ? 0 : $regions[$v[1]][$v[2]], - 'tax_postcode' => (empty($v[3]) || $v[3]=='*') ? null : $v[3], - 'rate' => $v[4], - 'zip_is_range' => $v[5], - 'zip_from' => $v[6], - 'zip_to' => $v[7] - ); - - $rateModel = Mage::getModel('Mage_Tax_Model_Calculation_Rate')->loadByCode($rateData['code']); - foreach($rateData as $dataName => $dataValue) { - $rateModel->setData($dataName, $dataValue); - } - - $titles = array(); - foreach ($stores as $field=>$id) { - $titles[$id] = $v[$field]; - } - - $rateModel->setTitle($titles); - $rateModel->save(); - } - } - } else { - Mage::throwException(Mage::helper('Mage_Tax_Helper_Data')->__('Invalid file format upload attempt')); - } - } - /** * export action from import/export tax * diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php b/app/code/Mage/Adminhtml/controllers/Tax/RuleController.php similarity index 100% rename from app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php rename to app/code/Mage/Adminhtml/controllers/Tax/RuleController.php diff --git a/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php b/app/code/Mage/Adminhtml/controllers/UrlrewriteController.php similarity index 96% rename from app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php rename to app/code/Mage/Adminhtml/controllers/UrlrewriteController.php index eac20412852fd..9535aeffc0a03 100644 --- a/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php +++ b/app/code/Mage/Adminhtml/controllers/UrlrewriteController.php @@ -86,30 +86,34 @@ public function editAction() switch ($mode) { case self::PRODUCT_MODE: $editBlock = $this->getLayout() - ->createBlock('Mage_Adminhtml_Block_Urlrewrite_Catalog_Product_Edit', '', array( + ->createBlock('Mage_Adminhtml_Block_Urlrewrite_Catalog_Product_Edit', '', array('data' => array( 'category' => $this->_getCategory(), 'product' => $this->_getProduct(), 'is_category_mode' => $this->getRequest()->has('category'), 'url_rewrite' => $this->_getUrlRewrite() - )); + ))); break; case self::CATEGORY_MODE: $editBlock = $this->getLayout() - ->createBlock('Mage_Adminhtml_Block_Urlrewrite_Catalog_Category_Edit', '', array( + ->createBlock('Mage_Adminhtml_Block_Urlrewrite_Catalog_Category_Edit', '', array('data' => array( 'category' => $this->_getCategory(), 'url_rewrite' => $this->_getUrlRewrite() - )); + ))); break; case self::CMS_PAGE_MODE: - $editBlock = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Urlrewrite_Cms_Page_Edit', '', array( - 'cms_page' => $this->_getCmsPage(), - 'url_rewrite' => $this->_getUrlRewrite() - )); + $editBlock = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Urlrewrite_Cms_Page_Edit', '', + array( + 'data' => array( + 'cms_page' => $this->_getCmsPage(), + 'url_rewrite' => $this->_getUrlRewrite(), + ), + ) + ); break; case self::ID_MODE: default: $editBlock = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Urlrewrite_Edit', '', array( - 'url_rewrite' => $this->_getUrlRewrite() + 'data' => array('url_rewrite' => $this->_getUrlRewrite()) )); break; } diff --git a/app/code/Mage/Adminhtml/etc/adminhtml/acl.xml b/app/code/Mage/Adminhtml/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..717ab4d948d89 --- /dev/null +++ b/app/code/Mage/Adminhtml/etc/adminhtml/acl.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Mage/Adminhtml/etc/adminhtml/menu.xml b/app/code/Mage/Adminhtml/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..6f2bed0091e2d --- /dev/null +++ b/app/code/Mage/Adminhtml/etc/adminhtml/menu.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Mage/Adminhtml/etc/config.xml b/app/code/Mage/Adminhtml/etc/config.xml new file mode 100644 index 0000000000000..065f4bc8e07c2 --- /dev/null +++ b/app/code/Mage/Adminhtml/etc/config.xml @@ -0,0 +1,247 @@ + + + + + + 0.7.1 + true + + + + + + + + Mage_Adminhtml_Model_Observer + massactionPrepareKey + + + + + + + Mage_Adminhtml_Model_Observer + clearCacheConfigurationFilesAccessLevelVerification + + + + + + + + + admin + + + Mage_Adminhtml + + + + + + + + + + + Mage_Adminhtml_Model_Observer + bindLocale + + + + + + + Mage_Backend_Model_Config_Backend_Admin_Observer + afterCustomUrlChanged + + + + + + + Mage_Adminhtml_Model_Search_Catalog + Mage_Catalog::catalog + + + Mage_Adminhtml_Model_Search_Customer + Mage_Customer::customer + + + Mage_Adminhtml_Model_Search_Order + Mage_Sales::sales + + + + + + + Mage_Adminhtml.csv + + + + + + + + admin.xml + + + main.xml + + + adminnotification.xml + + + backup.xml + + + catalog.xml + + + cms.xml + + + customer.xml + + + system/design/design.xml + + + newsletter.xml + + + promo.xml + + + rating.xml + + + report.xml + + + sales.xml + + + system/store/store.xml + + + system/email/template.xml + + + tax.xml + + + urlrewrite.xml + + + variable.xml + + + search.xml + + + + + + + + + + + + + + + + + + + + + email + + + + system_emails_forgot_email_template + general + + + 1 + + + + + + + /*/sitemap.xml + + + + + + price + media_image + gallery + + + + + + + 1 + + + + + + + + default + + + default + + + + + + + + + + true + + + + admin/index/noRoute + + + + + diff --git a/app/code/core/Mage/Adminhtml/etc/jstranslator.xml b/app/code/Mage/Adminhtml/etc/jstranslator.xml similarity index 100% rename from app/code/core/Mage/Adminhtml/etc/jstranslator.xml rename to app/code/Mage/Adminhtml/etc/jstranslator.xml diff --git a/app/code/core/Mage/Adminhtml/locale/de_DE/Mage_Adminhtml.csv b/app/code/Mage/Adminhtml/locale/de_DE/Mage_Adminhtml.csv similarity index 100% rename from app/code/core/Mage/Adminhtml/locale/de_DE/Mage_Adminhtml.csv rename to app/code/Mage/Adminhtml/locale/de_DE/Mage_Adminhtml.csv diff --git a/app/code/core/Mage/Adminhtml/locale/en_US/Mage_Adminhtml.csv b/app/code/Mage/Adminhtml/locale/en_US/Mage_Adminhtml.csv similarity index 100% rename from app/code/core/Mage/Adminhtml/locale/en_US/Mage_Adminhtml.csv rename to app/code/Mage/Adminhtml/locale/en_US/Mage_Adminhtml.csv diff --git a/app/code/core/Mage/Adminhtml/locale/es_ES/Mage_Adminhtml.csv b/app/code/Mage/Adminhtml/locale/es_ES/Mage_Adminhtml.csv similarity index 100% rename from app/code/core/Mage/Adminhtml/locale/es_ES/Mage_Adminhtml.csv rename to app/code/Mage/Adminhtml/locale/es_ES/Mage_Adminhtml.csv diff --git a/app/code/core/Mage/Adminhtml/locale/fr_FR/Mage_Adminhtml.csv b/app/code/Mage/Adminhtml/locale/fr_FR/Mage_Adminhtml.csv similarity index 100% rename from app/code/core/Mage/Adminhtml/locale/fr_FR/Mage_Adminhtml.csv rename to app/code/Mage/Adminhtml/locale/fr_FR/Mage_Adminhtml.csv diff --git a/app/code/core/Mage/Adminhtml/locale/nl_NL/Mage_Adminhtml.csv b/app/code/Mage/Adminhtml/locale/nl_NL/Mage_Adminhtml.csv similarity index 100% rename from app/code/core/Mage/Adminhtml/locale/nl_NL/Mage_Adminhtml.csv rename to app/code/Mage/Adminhtml/locale/nl_NL/Mage_Adminhtml.csv diff --git a/app/code/core/Mage/Adminhtml/locale/pt_BR/Mage_Adminhtml.csv b/app/code/Mage/Adminhtml/locale/pt_BR/Mage_Adminhtml.csv similarity index 100% rename from app/code/core/Mage/Adminhtml/locale/pt_BR/Mage_Adminhtml.csv rename to app/code/Mage/Adminhtml/locale/pt_BR/Mage_Adminhtml.csv diff --git a/app/code/core/Mage/Adminhtml/locale/zh_CN/Mage_Adminhtml.csv b/app/code/Mage/Adminhtml/locale/zh_CN/Mage_Adminhtml.csv similarity index 100% rename from app/code/core/Mage/Adminhtml/locale/zh_CN/Mage_Adminhtml.csv rename to app/code/Mage/Adminhtml/locale/zh_CN/Mage_Adminhtml.csv diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/admin.xml b/app/code/Mage/Adminhtml/view/adminhtml/admin.xml similarity index 95% rename from app/code/core/Mage/Adminhtml/view/adminhtml/admin.xml rename to app/code/Mage/Adminhtml/view/adminhtml/admin.xml index 3dd1faf2bb3c2..5bfe69286086f 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/admin.xml +++ b/app/code/Mage/Adminhtml/view/adminhtml/admin.xml @@ -30,6 +30,7 @@ + 0 diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/admin/access_denied.phtml b/app/code/Mage/Adminhtml/view/adminhtml/admin/access_denied.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/admin/access_denied.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/admin/access_denied.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/admin/formkey.phtml b/app/code/Mage/Adminhtml/view/adminhtml/admin/formkey.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/admin/formkey.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/admin/formkey.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/admin/overlay_popup.phtml b/app/code/Mage/Adminhtml/view/adminhtml/admin/overlay_popup.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/admin/overlay_popup.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/admin/overlay_popup.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/admin/page.phtml b/app/code/Mage/Adminhtml/view/adminhtml/admin/page.phtml new file mode 100644 index 0000000000000..c3b14b7640378 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/admin/page.phtml @@ -0,0 +1,80 @@ + + + + + + + getChildHtml('head') ?> + + +getBodyClass() ? ' class="' . $this->getBodyClass() . '"' : ''; ?>> +
+ getChildHtml('notification_window'); ?> + getChildHtml('global_notices') ?> + getChildHtml('header') ?> + getChildHtml('menu') ?> + getChildHtml('notifications'); ?> + +
+ getChildHtml('main-top'); ?> +
+ getMessagesBlock()->getGroupedHtml() ?> +
+ + getChildHtml('left')): ?> + +
+
+ getChildHtml('content') ?> +
+ +
+ getChildHtml('left') ?> +
+
+ + +
+ getChildHtml('content') ?> +
+ +
+ + getChildHtml('js') ?> +
+ +
+ +
+ getChildHtml('before_body_end') ?> + + + + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/admin/popup.phtml b/app/code/Mage/Adminhtml/view/adminhtml/admin/popup.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/admin/popup.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/admin/popup.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/adminnotification.xml b/app/code/Mage/Adminhtml/view/adminhtml/adminnotification.xml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/adminnotification.xml rename to app/code/Mage/Adminhtml/view/adminhtml/adminnotification.xml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/api/role_users_grid_js.phtml b/app/code/Mage/Adminhtml/view/adminhtml/api/role_users_grid_js.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/api/role_users_grid_js.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/api/role_users_grid_js.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/api/roleinfo.phtml b/app/code/Mage/Adminhtml/view/adminhtml/api/roleinfo.phtml new file mode 100644 index 0000000000000..3109a6c86f6fd --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/api/roleinfo.phtml @@ -0,0 +1,43 @@ + + +
+ getBackButtonHtml() ?> + getResetButtonHtml() ?> + getDeleteButtonHtml() ?> + getSaveButtonHtml() ?> +
+ +
+ getBlockHtml('formkey')?> +
+ + diff --git a/app/code/Mage/Adminhtml/view/adminhtml/api/roles.phtml b/app/code/Mage/Adminhtml/view/adminhtml/api/roles.phtml new file mode 100644 index 0000000000000..0b3c6fa3aafb2 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/api/roles.phtml @@ -0,0 +1,32 @@ + + +
+ +
+ +getGridHtml() ?> diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/api/rolesedit.phtml b/app/code/Mage/Adminhtml/view/adminhtml/api/rolesedit.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/api/rolesedit.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/api/rolesedit.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/api/rolesusers.phtml b/app/code/Mage/Adminhtml/view/adminhtml/api/rolesusers.phtml similarity index 96% rename from app/code/core/Mage/Adminhtml/view/adminhtml/api/rolesusers.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/api/rolesusers.phtml index 38fd74195f7ce..f0a18829607a1 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/api/rolesusers.phtml +++ b/app/code/Mage/Adminhtml/view/adminhtml/api/rolesusers.phtml @@ -25,4 +25,4 @@ */ ?>

__('Role Users') ?>

-_getGridHtml() ?> +getGridHtml() ?> diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/api/user_roles_grid_js.phtml b/app/code/Mage/Adminhtml/view/adminhtml/api/user_roles_grid_js.phtml similarity index 97% rename from app/code/core/Mage/Adminhtml/view/adminhtml/api/user_roles_grid_js.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/api/user_roles_grid_js.phtml index a632e48c7bf0e..d537f1a03423b 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/api/user_roles_grid_js.phtml +++ b/app/code/Mage/Adminhtml/view/adminhtml/api/user_roles_grid_js.phtml @@ -30,7 +30,7 @@ getJsObjectName()): ?> var radioBoxes = $H({}); var warning = false; - var userRoles = $H(_getSelectedRoles(true) ?>); + var userRoles = $H(getSelectedRoles(true) ?>); if (userRoles.size() > 0) warning = true; $('user_user_roles').value = userRoles.toQueryString(); diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/api/userinfo.phtml b/app/code/Mage/Adminhtml/view/adminhtml/api/userinfo.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/api/userinfo.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/api/userinfo.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/api/usernroles.phtml b/app/code/Mage/Adminhtml/view/adminhtml/api/usernroles.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/api/usernroles.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/api/usernroles.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/backup.xml b/app/code/Mage/Adminhtml/view/adminhtml/backup.xml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/backup.xml rename to app/code/Mage/Adminhtml/view/adminhtml/backup.xml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/backup/dialogs.phtml b/app/code/Mage/Adminhtml/view/adminhtml/backup/dialogs.phtml similarity index 95% rename from app/code/core/Mage/Adminhtml/view/adminhtml/backup/dialogs.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/backup/dialogs.phtml index 68f1ffcdcca6c..043c5a08f515a 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/backup/dialogs.phtml +++ b/app/code/Mage/Adminhtml/view/adminhtml/backup/dialogs.phtml @@ -69,7 +69,7 @@ @@ -108,7 +108,7 @@ __('This action cannot be undone.')?>

__('Are you sure you want to proceed?')?>

-
+
@@ -141,7 +141,7 @@
- + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/backup/left.phtml b/app/code/Mage/Adminhtml/view/adminhtml/backup/left.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/backup/left.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/backup/left.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/backup/list.phtml b/app/code/Mage/Adminhtml/view/adminhtml/backup/list.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/backup/list.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/backup/list.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog.xml b/app/code/Mage/Adminhtml/view/adminhtml/catalog.xml similarity index 94% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog.xml rename to app/code/Mage/Adminhtml/view/adminhtml/catalog.xml index ce4806b341f5b..21d1b14cc5886 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog.xml +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog.xml @@ -49,9 +49,9 @@ Mage_Adminhtml::jquery/fileUploader/load-image.min.js Mage_Adminhtml::jquery/fileUploader/canvas-to-blob.min.js Mage_Adminhtml::jquery/fileUploader/jquery.fileupload-fp.js + mage/proxy-event.js Mage_Adminhtml::catalog/category-selector.css - Mage_Adminhtml::catalog/category-selector.js Mage_Adminhtml::json2.js Mage_Adminhtml::mage/backend/suggest.js Mage_Adminhtml::jquery/jstree/jquery.hotkeys.js @@ -61,6 +61,9 @@ Mage_Adminhtml::catalog/product-variation.js Mage_Adminhtml::catalog/base-image-uploader.js Mage_Catalog::js/product-gallery.js + Mage_Catalog::product/product.css + Mage_Catalog::js/custom-options.js + mage/backend/menu.js
@@ -92,7 +95,7 @@ - + @@ -171,7 +174,7 @@ entity_id 0 1 - associated-product-id + Mage_Catalog_Block_Product_Configurable_AssociatedSelector_Renderer_Id @@ -183,7 +186,6 @@ name 0 1 - associated-product-name @@ -194,7 +196,6 @@ price 0 1 - associated-product-price @@ -206,7 +207,6 @@ sku 0 1 - associated-product-sku @@ -217,7 +217,6 @@ weight 0 1 - associated-product-weight @@ -343,7 +342,7 @@ Layout handle for grouped products - + @@ -365,6 +364,7 @@ Layout handle for grouped products <_current>1 + data-table @@ -375,15 +375,15 @@ Layout handle for grouped products grip entity_id - 5px 0 - ui-icon ui-icon-grip-dotted-vertical + draggable-handle + col-draggable + col-draggable
Name
- grouped-product-name text name 1 @@ -394,10 +394,8 @@ Layout handle for grouped products
SKU
- grouped-product-sku text sku - 80px 0 1
@@ -405,22 +403,16 @@ Layout handle for grouped products
Price
- grouped-product-price currency price - 110px - right 0
Default Qty
- grouped-product-qty number qty - 110px - right 1 0
@@ -431,10 +423,10 @@ Layout handle for grouped products button button grouped-product-delete - 60px Mage_Backend_Block_Widget_Grid_Column_Renderer_Button - right 0 + col-actions + col-actions
@@ -473,17 +465,14 @@ Layout handle for grouped products checkbox - a-center - selected-products - 60px - center entity_id + col-select + col-select
Name
- associated-product-name text name 1 @@ -493,21 +482,16 @@ Layout handle for grouped products
SKU
- associated-product-sku text sku - 80px 1
Price
- associated-product-price currency price - 110px - right
diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/base-image-uploader.js b/app/code/Mage/Adminhtml/view/adminhtml/catalog/base-image-uploader.js similarity index 86% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/base-image-uploader.js rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/base-image-uploader.js index 8fb8fda72980c..0187a42c1174a 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/base-image-uploader.js +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/base-image-uploader.js @@ -22,10 +22,8 @@ * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ -/*jshint jquery:true*/ -/*global alert*/ +/*global alert:true*/ (function ($) { - "use strict"; $.widget('mage.baseImage', { /** * Button creation @@ -41,7 +39,7 @@ var findElement = function(data) { return $container.find('.image:not(.image-placeholder)').filter(function() { - return $(this).data('image').file === data.file; + return $(this).data('image').file == data.file; }).first(); }; var updateVisibility = function() { @@ -49,11 +47,11 @@ elementsList.each(function(index) { $(this)[index < maximumImageCount ? 'show' : 'hide'](); }); - $dropPlaceholder[elementsList.length >= maximumImageCount ? 'hide' : 'show'](); + $dropPlaceholder[elementsList.length > maximumImageCount ? 'hide' : 'show'](); }; $galleryContainer.on('setImageType', function(event, data) { - if (data.type === 'image') { + if (data.type == 'image') { $container.find('.' + mainClass).removeClass(mainClass); if (data.imageData) { findElement(data.imageData).addClass(mainClass); @@ -87,13 +85,13 @@ $container.on('click', '[data-role="make-main-button"]', function(event) { event.preventDefault(); - var data = $(this.target).closest('.image').data('image'); + var data = $(event.target).closest('.image').data('image'); $galleryContainer.productGallery('setMain', data); }); $container.on('click', '[data-role="delete-button"]', function(event) { event.preventDefault(); - $galleryContainer.trigger('removeItem', $(this.target).closest('.image').data('image')); + $galleryContainer.trigger('removeItem', $(event.target).closest('.image').data('image')); }); $container.sortable({ @@ -134,6 +132,16 @@ progress: function(e, data) { var progress = parseInt(data.loaded / data.total * 100, 10); $dropPlaceholder.find('.progress-bar').addClass('in-progress').text(progress + '%'); + }, + start: function(event) { + var uploaderContainer = $(event.target).closest('.image-placeholder'); + + uploaderContainer.addClass('loading'); + }, + stop: function(event) { + var uploaderContainer = $(event.target).closest('.image-placeholder'); + + uploaderContainer.removeClass('loading'); } }); } diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/category-selector.css b/app/code/Mage/Adminhtml/view/adminhtml/catalog/category-selector.css new file mode 100644 index 0000000000000..1b963e32f4d85 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/category-selector.css @@ -0,0 +1,176 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Adminhtml + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +.field-category_ids .category-select { + margin: 0 0 6px 0; + padding: 2px; + width: 67.999999997%; +} + +.mage-new-category-dialog .category-select { + width: 100%; + padding: 0; +} + +.field-category_ids .mage-suggest-inner { + padding-right: 27px; +} + +.field-category_ids .addon > button { + float: right; + margin-left: 2.127659574%; + width: 28.4%; +} + +.field-category_ids .category-select:after, +.mage-new-category-dialog .category-select:after { + position: absolute; + top: 0; + right: 5px; + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: '\e013'; /* unordered list icon */ + font-size: 20px; + color: #b2b2b2; +} + +/* Category Selector in "Create New Category" popup */ +.mage-new-category-dialog .mage-suggest { + border: none; + box-shadow: none; +} +.mage-new-category-dialog .mage-suggest .mage-suggest-inner { + padding: 0; +} + +.mage-new-category-dialog .mage-suggest-choices { + position: relative; + padding: 2px 22px 2px 2px; + background-color: #fff; + border: 1px solid #ccc; + border-radius: 3px; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); +} + +.mage-new-category-dialog .mage-suggest-dropdown { + position: relative; + margin: 3px 1px 0; +} + +.mage-new-category-dialog .mage-suggest-inner { + padding: 2px 22px 2px 2px; +} + +.mage-suggest-choices { + margin: 0; + padding: 0; + list-style: none; +} + +.mage-suggest-choices > li { + display: inline-block; +} + +.mage-suggest-search-field { + width: 100%; + white-space: nowrap; + margin: 0; + padding: 0; +} + +.mage-suggest-search-field > input, +.mage-suggest-search-field > input:focus, +.mage-suggest-search-field > input:active { + width: 100%; + height: 22px; + line-height: 22px; + outline: 0 none; + border: 0 none; + box-shadow: none; + padding: 0 3px; +} + +.mage-suggest-search-field > input.mage-suggest-state-loading { + background: #fff url('images/spinner.gif') no-repeat 100%; + padding-right: 18px; +} + +.mage-suggest-choice { + position: relative; + background: #cdecf6; + border: 1px solid #a7cedb; + border-radius: 3px; + padding: 2px 22px 1px 9px; + margin: 1px 2px 1px 0; + vertical-align: top; + cursor: default; + -moz-transition: background .3s; + -webkit-transition: background .3s; + transition: background .3s; +} + +.mage-suggest-choice:hover { + background: #aae3f5; +} + +.mage-suggest-choice-close { + position: absolute; + top: 0; + right: 0; + bottom: 0; + width: 20px; + line-height: 16px; + text-align: center; + color: #7b94a1; + cursor: pointer; +} + +.mage-suggest-choice-close:hover { + color: #000; +} + +.mage-suggest-choice-close:before { + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: '\e07d'; /* close icon */ + font-size: 6px; +} + +.mage-suggest-no-records { + display: inline-block; + padding: 10px; +} + +.ui-helper-hidden-accessible { + display: none; +} diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/category/checkboxes/tree.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/category/checkboxes/tree.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/category/checkboxes/tree.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/category/checkboxes/tree.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/category/edit.js b/app/code/Mage/Adminhtml/view/adminhtml/catalog/category/edit.js similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/category/edit.js rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/category/edit.js diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/category/edit.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/category/edit.phtml new file mode 100644 index 0000000000000..d3d50574336c8 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/category/edit.phtml @@ -0,0 +1,174 @@ + + + +
+ getChildHtml('form') ?> +
+ diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/category/edit/form.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/category/edit/form.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/category/edit/form.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/category/edit/form.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/category/form.js b/app/code/Mage/Adminhtml/view/adminhtml/catalog/category/form.js similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/category/form.js rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/category/form.js diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/category/tree.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/category/tree.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/category/tree.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/category/tree.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/category/widget/tree.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/category/widget/tree.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/category/widget/tree.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/category/widget/tree.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/configurable-product.css b/app/code/Mage/Adminhtml/view/adminhtml/catalog/configurable-product.css similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/configurable-product.css rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/configurable-product.css diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/form/renderer/fieldset/element.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/form/renderer/fieldset/element.phtml new file mode 100644 index 0000000000000..15cd2cbdd3285 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/form/renderer/fieldset/element.phtml @@ -0,0 +1,91 @@ + + +getElement(); +$note = $element->getNote() ? '
' . $element->getNote() . '
' : ''; +$elementBeforeLabel = $element->getExtType() == 'checkbox' || $element->getExtType() == 'radio'; +$addOn = $element->getBeforeElementHtml() || $element->getAfterElementHtml(); +$fieldId = ($element->getHtmlId()) ? ' id="attribute-' . $element->getHtmlId() . '-container"' : ''; +$fieldClass = "field field-{$element->getId()} {$element->getCssClass()}"; +$fieldClass .= ($elementBeforeLabel) ? ' choice' : ''; +$fieldClass .= ($addOn) ? ' with-addon' : ''; +$fieldClass .= ($element->getRequired()) ? ' required' : ''; +$fieldClass .= ($note) ? ' with-note' : ''; + +$fieldAttributes = $fieldId . ' class="' . $fieldClass . '" ' + . $this->getUiId('form-field', $element->getId()); +?> + +checkFieldDisable() ?> +getToggleCode() ? $element->getToggleCode() + : 'toggleValueElements(this, this.parentNode.parentNode.parentNode)'; +?> +getNoDisplay()): ?> + getType() == 'hidden'): ?> + getElementHtml() ?> + + data-element-id="getHtmlId() ?>" + data-apply-to="escapeHtml($this->helper('Mage_Core_Helper_Data')->jsonEncode( + $element->hasEntityAttribute() ? $element->getEntityAttribute()->getApplyTo() : array() + ))?>" + > + + getElementHtml() ?> + getLabelHtml() ?> + + + getLabelHtml() ?> +
+ ' . $this->getElementHtml() . '
' : $this->getElementHtml(); ?> + + + +
+ canDisplayUseDefault()): ?> + + +
+ + + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/images/select2.png b/app/code/Mage/Adminhtml/view/adminhtml/catalog/images/select2.png similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/images/select2.png rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/images/select2.png diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/images/select2x2.png b/app/code/Mage/Adminhtml/view/adminhtml/catalog/images/select2x2.png similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/images/select2x2.png rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/images/select2x2.png diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/images/spinner.gif b/app/code/Mage/Adminhtml/view/adminhtml/catalog/images/spinner.gif similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/images/spinner.gif rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/images/spinner.gif diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product-variation.js b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product-variation.js similarity index 99% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product-variation.js rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/product-variation.js index 60ba2b4ea7ba9..543499ff52099 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product-variation.js +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product-variation.js @@ -28,6 +28,7 @@ this.element.sortable({ axis: 'y', handle: '.draggable-handle', + tolerance: 'pointer', update: function () { $(this).find('[name$="[position]"]').each(function (index) { $(this).val(index); diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/product.js b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product.js new file mode 100644 index 0000000000000..2ed823f37663d --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product.js @@ -0,0 +1,122 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Adminhtml + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +var Product = {}; + +(function ($) { + $.widget("mage.productAttributes", { + _create: function () { + this._on({'click':'_showPopup'}); + }, + _showPopup: function (event) { + var wrapper = $('
').appendTo('body').dialog({ + title: 'New Attribute', + minWidth: 980, + minHeight: 700, + modal: true, + resizeStop: function(event, ui) { + iframe.height($(this).outerHeight() + 'px'); + iframe.width($(this).outerWidth() + 'px'); + } + }); + wrapper.mage('loader', {showOnInit: true}); + var iframe = $('
-
-

__('Configure Product') ?>

-
-
- - -
diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/configurable.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/configurable.phtml new file mode 100644 index 0000000000000..8ce512ff190bc --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/configurable.phtml @@ -0,0 +1,58 @@ + + + +getProduct(); ?> +decorateArray($this->getAllowAttributes()); ?> +getSkipSaleableCheck(); ?> +isSaleable() || $_skipSaleableCheck) && count($_attributes)):?> +
+ __('Associated Products') ?> +
+
+ + +
+ +
+ +
+
+
+ + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/grouped.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/grouped.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/grouped.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/grouped.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/options.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/options.phtml new file mode 100644 index 0000000000000..88d73063f12d3 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/options.phtml @@ -0,0 +1,41 @@ + + + +decorateArray($this->getOptions()); ?> + + +getChildHtml('options_js') ?> + +
+ __('Custom Options') ?> + + getOptionHtml($option); ?> + +
+ + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/options/js.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/options/js.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/options/js.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/options/js.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/options/type/date.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/options/type/date.phtml new file mode 100644 index 0000000000000..508216d24895f --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/options/type/date.phtml @@ -0,0 +1,89 @@ + + +getOption(); ?> +getId(); ?> +
+ +
+ + getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DATE_TIME + || $_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DATE): ?> + + getDateHtml() ?> + + useCalendar()): ?> + + + + + + getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DATE_TIME + || $_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_TIME): ?> + getTimeHtml() ?> + + + + + diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/options/type/default.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/options/type/default.phtml new file mode 100644 index 0000000000000..21d42063fbd3c --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/options/type/default.phtml @@ -0,0 +1,31 @@ + + +getOption(); ?> +
+ +
diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/options/type/file.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/options/type/file.phtml new file mode 100644 index 0000000000000..8fe7322d03f75 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/options/type/file.phtml @@ -0,0 +1,107 @@ + +getOption(); ?> +getFileInfo(); ?> +hasData() ? true : false; ?> +getId() . '_file'; ?> + + + + + + + +
+ +
+ + getTitle(); ?> + + __('Change') ?> +   + getIsRequire()): ?> + + __('Delete') ?> + + +
> + /> + + getFileExtension()): ?> +

__('Allowed file extensions to upload')?>: getFileExtension() ?>

+ + getImageSizeX() > 0): ?> +

__('Maximum image width')?>: getImageSizeX() ?> __('px.')?>

+ + getImageSizeY() > 0): ?> +

__('Maximum image height')?>: getImageSizeY() ?> __('px.')?>

+ +
+
+
\ No newline at end of file diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/options/type/select.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/options/type/select.phtml new file mode 100644 index 0000000000000..ae11e463563d6 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/options/type/select.phtml @@ -0,0 +1,39 @@ + + +getOption(); ?> +
+ +
+ getValuesHtml() ?> + getIsRequire()): ?> + getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_RADIO || $_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_CHECKBOX): ?> + + + +
+
diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/options/type/text.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/options/type/text.phtml new file mode 100644 index 0000000000000..38b9a6704cfc2 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/options/type/text.phtml @@ -0,0 +1,46 @@ + + +getOption(); ?> +
+ +
+
+ getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_FIELD): ?> + + getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_AREA): ?> + + + getMaxCharacters()): ?> +

__('Maximum number of characters:')?> getMaxCharacters() ?>

+ +
+
+
diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/qty.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/qty.phtml new file mode 100644 index 0000000000000..7a828373b804a --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/fieldset/qty.phtml @@ -0,0 +1,37 @@ + + + + +
+
+ +
+ +
+
+
diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/created.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/created.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/created.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/product/created.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit.phtml new file mode 100644 index 0000000000000..545aa703ffdb8 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit.phtml @@ -0,0 +1,320 @@ + + + +
+
+
+ + +
+
+ +
+ + +
+ + getProductId()): ?> + getDeleteButtonHtml() ?> + getProductSetId() && $this->getIsConfigured()): ?> + getDuplicateButtonHtml() ?> + + + getProductSetId()): ?> + getChangeAttributeSetButtonHtml() ?> + getSaveSplitButtonHtml(); ?> + + getBackButtonHtml() ?> +
+ + + getBlockHtml('formkey')?> +
+ getChildHtml('product-type-tabs') ?> + + + + + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/edit/action/attribute.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/action/attribute.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/edit/action/attribute.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/action/attribute.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/action/inventory.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/action/inventory.phtml new file mode 100644 index 0000000000000..779c2ec20856b --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/action/inventory.phtml @@ -0,0 +1,181 @@ + + + +
+
+

__('Advanced Inventory') ?>

+
+
+ __('Advanced Inventory') ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + __('[GLOBAL]') ?>
+ + + + __('[GLOBAL]') ?>
+ + + + + __('[GLOBAL]') ?>
+ + + + + __('[GLOBAL]') ?>
+ + + + + __('[GLOBAL]') ?>
+ + + __('[GLOBAL]') ?>
+ + + + + __('[GLOBAL]') ?>
+ + + + + __('[GLOBAL]') ?>
+ + + + + __('[GLOBAL]') ?>
+ + + + + + __('[GLOBAL]') ?>
+ + + __('[GLOBAL]') ?>
+
+
diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/edit/action/websites.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/action/websites.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/edit/action/websites.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/action/websites.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/attribute_set.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/attribute_set.phtml new file mode 100644 index 0000000000000..8eea15d3d814e --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/attribute_set.phtml @@ -0,0 +1,61 @@ + + + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/edit/category/new/form.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/category/new/form.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/edit/category/new/form.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/category/new/form.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/options.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/options.phtml new file mode 100644 index 0000000000000..81e54dfb7f92d --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/options.phtml @@ -0,0 +1,64 @@ + + + +
+
+ + __('Custom Options') ?> + +
+
+
+ + +
+
+ getOptionsBoxHtml() ?> +
+ +
+ getChildHtml('import_button') ?> + getAddButtonHtml() ?> +
+
+
+
+ + diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/options/option.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/options/option.phtml new file mode 100644 index 0000000000000..0f6f91a229de3 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/options/option.phtml @@ -0,0 +1,131 @@ + + +getTemplatesHtml() ?> + + + +isReadonly()): ?> +
+ + diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/options/type/date.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/options/type/date.phtml new file mode 100644 index 0000000000000..7b6d4f517f4f9 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/options/type/date.phtml @@ -0,0 +1,62 @@ + + + \ No newline at end of file diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/options/type/file.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/options/type/file.phtml new file mode 100644 index 0000000000000..11a885c6ad22e --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/options/type/file.phtml @@ -0,0 +1,70 @@ + + + \ No newline at end of file diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/options/type/select.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/options/type/select.phtml new file mode 100644 index 0000000000000..7a6540bf0c007 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/options/type/select.phtml @@ -0,0 +1,85 @@ + + + + diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/options/type/text.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/options/type/text.phtml new file mode 100644 index 0000000000000..0a486a69fef87 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/options/type/text.phtml @@ -0,0 +1,67 @@ + + + \ No newline at end of file diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/edit/price/group.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/price/group.phtml similarity index 92% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/edit/price/group.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/price/group.phtml index ce92dbe9d8eca..bad7ddf46464e 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/edit/price/group.phtml +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/price/group.phtml @@ -26,6 +26,7 @@ ?> getElement(); $_htmlId = $this->getElement()->getHtmlId(); $_htmlClass = $this->getElement()->getClass(); $_htmlName = $this->getElement()->getName(); @@ -34,15 +35,20 @@ $_priceValueValidation = $this->getPriceValidation('validate-zero-or-greater'); $_showWebsite= $this->isMultiWebsites(); ?> -
+
- - + + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/edit/price/tier.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/price/tier.phtml similarity index 80% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/edit/price/tier.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/price/tier.phtml index ab3b8e302b910..a2a20b07cd59a 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/edit/price/tier.phtml +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/price/tier.phtml @@ -24,6 +24,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ /* @var $this Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Tier */ +$element = $this->getElement(); ?> getElement()->getHtmlId() ?> getElement()->getClass() ?> @@ -36,16 +37,21 @@ isShowWebsiteColumn(); ?> isMultiWebsites(); ?> -
+
-
style="display: none;">__('Website'); ?>__('Customer Group'); ?>getPriceColumnHeader(Mage::helper('Mage_Catalog_Helper_Data')->__('Price')); ?>__('Customer Group'); ?>getPriceColumnHeader(Mage::helper('Mage_Catalog_Helper_Data')->__('Price')); ?> __('Action'); ?>
+
- - - - + + + + @@ -60,19 +66,19 @@ + diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/super/matrix.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/super/matrix.phtml new file mode 100644 index 0000000000000..6396804e655cd --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/super/matrix.phtml @@ -0,0 +1,292 @@ + +getVariations(); +if (!$variations) { + return; +} +$usedProductAttributes = $this->getUsedAttributes(); +$productByUsedAttributes = $this->getAssociatedProducts(); +?> + +

__('Current Variations'); ?>

+ +
+
+
style="display:none">__('Website') ?>__('Customer Group') ?>__('Qty') ?>getPriceColumnHeader(Mage::helper('Mage_Catalog_Helper_Data')->__('Price')) ?>style="display:none">__('Website') ?>__('Customer Group') ?>__('Quantity') ?>getPriceColumnHeader(Mage::helper('Mage_Catalog_Helper_Data')->__('Price')) ?> __('Action') ?>
+ + + + + + + + + + getStoreLabel())) . '">', $attribute->getStoreLabel(), '', PHP_EOL; + } + ?> + + + + + getProduct()->getPrice(); + foreach ($variations as $variation) { + $attributeValues = array(); + $attributeLabels = array(); + $attributeStoreLabels = array(); + $price = $productPrice; + foreach ($usedProductAttributes as $attribute) { + /** @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */ + + $attributeValues[$attribute->getAttributeCode()] = $variation[$attribute->getId()]['value']; + $attributeLabels[$attribute->getAttributeCode()] = $variation[$attribute->getId()]['label']; + + if (isset($variation[$attribute->getId()]['price'])) { + $priceInfo = $variation[$attribute->getId()]['price']; + $price += ($priceInfo['is_percent'] ? $productPrice / 100.0 : 1.0) * $priceInfo['pricing_value']; + } + } + $attributeLabels = $this->escapeHtml($attributeLabels); + $key = implode('-', $attributeValues); + if (isset($productByUsedAttributes[$key])) { + $product = $productByUsedAttributes[$key]; + ?> + + + + + + + + + + getStoreLabel())) . '">', + $this->escapeHtml($variation[$attribute->getId()]['label']), '', PHP_EOL; + } + ?> + + + getProduct()->getId() && !$this->getProduct()->dataHasChangedFor('type_id') ? '' : ' checked="checked"'; + $disabled = $this->getProduct()->getId() && !$this->getProduct()->dataHasChangedFor('type_id') ? ' disabled="disabled"' : ''; + ?> + + + + + + + + + getStoreLabel())) . '">', $variation[$attribute->getId()]['label'], '', PHP_EOL; + } + ?> + + + + +
+ __('Display'); ?> + + __('Image'); ?> + + __('Name'); ?> + + __('SKU'); ?> + + __('Price'); ?> + + __('Quantity'); ?> + + __('Weight'); ?> +
+ + + getImage(); if ($image == 'no_selection'): $image = ''; endif; ;?> +
style="display:none"> + __('Upload Image'); ?> + + +
+ + + +
+ escapeHtml($product->getName())?> + + + + escapeHtml($product->getSku())?> + getStockItem()->getQty()?>getWeight()?>
+ /> + +
+ __('Upload Image'); ?> + /> + +
+
+ /> + /> + + + + /> + + + + > + + > +
+
+
+ diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/edit/websites.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/websites.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/edit/websites.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/product/edit/websites.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/helper/gallery.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/helper/gallery.phtml new file mode 100644 index 0000000000000..09b1b829034bb --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/helper/gallery.phtml @@ -0,0 +1,149 @@ +getElement()->getName() . '[images]'; +?> + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/js.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/js.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/js.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/product/js.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/price.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/price.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/price.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/product/price.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/tab/alert.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/tab/alert.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/tab/alert.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/product/tab/alert.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/tab/inventory.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/tab/inventory.phtml new file mode 100644 index 0000000000000..9741fb1d1969d --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/tab/inventory.phtml @@ -0,0 +1,342 @@ + +isReadonly()): ?> + + + + +
+__('Advanced Inventory') ?> +
+
+
+ +
+ + + getFieldValue('use_config_manage_stock') || $this->IsNew()) ? 'checked="checked"' : '' ?> + onclick="toggleValueElements(this, this.parentNode);" > + + isReadonly()): ?> + + +
+ isSingleStoreMode()): ?> +
__('[GLOBAL]') ?>
+ +
+ +getProduct()->isComposite()): ?> +
+ +
+ + + + > +
+ isSingleStoreMode()): ?> +
__('[GLOBAL]') ?>
+ +
+ +
+ +
+ > + getFieldValue('use_config_min_qty') || $this->IsNew()) ? 'checked="checked"' : '' ?> + onclick="toggleValueElements(this, this.parentNode);" > + + isReadonly()): ?> + + +
+ isSingleStoreMode()): ?> +
__('[GLOBAL]') ?>
+ +
+ +
+ +
+ > + getFieldValue('use_config_min_sale_qty') || $this->IsNew()) ? 'checked="checked"' : '' ?> + onclick="toggleValueElements(this, this.parentNode);" class="checkbox" > + + isReadonly()): ?> + + +
+ isSingleStoreMode()): ?> +
__('[GLOBAL]') ?>
+ +
+ +
+ +
+ > + getFieldValue('use_config_max_sale_qty') || $this->IsNew()) ? 'checked="checked"' : '' ?> + onclick="toggleValueElements(this, this.parentNode);" class="checkbox" > + + isReadonly()): ?> + + +
+ isSingleStoreMode()): ?> +
__('[GLOBAL]') ?>
+ +
+ + canUseQtyDecimals()): ?> +
+ +
+ +
+ isSingleStoreMode()): ?> +
__('[GLOBAL]') ?>
+ +
+ + isVirtual()) : ?> +
+ +
+ +
+ isSingleStoreMode()): ?> +
__('[GLOBAL]') ?>
+ +
+ + + +
+ +
+ + getFieldValue('use_config_backorders') || $this->IsNew()) ? 'checked="checked"' : '' ?> + onclick="toggleValueElements(this, this.parentNode);" > + + isReadonly()): ?> + + +
+ isSingleStoreMode()): ?> +
__('[GLOBAL]') ?>
+ +
+ +
+ +
+ > + getFieldValue('use_config_notify_stock_qty') || $this->IsNew()) ? 'checked="checked"' : '' ?> + onclick="toggleValueElements(this, this.parentNode);" > + + isReadonly()): ?> + + +
+ isSingleStoreMode()): ?> +
__('[GLOBAL]') ?>
+ +
+ + +
+ +
+ + + getFieldValue('use_config_enable_qty_inc') || $this->IsNew()) ? 'checked="checked"' : '' ?> + onclick="toggleValueElements(this, this.parentNode);" > + + isReadonly()): ?> + + +
+ isSingleStoreMode()): ?> +
__('[GLOBAL]') ?>
+ +
+ +
+ +
+ > + getFieldValue('use_config_qty_increments') || $this->IsNew()) ? 'checked="checked"' : '' ?> + onclick="toggleValueElements(this, this.parentNode);" > + + isReadonly()): ?> + + +
+ isSingleStoreMode()): ?> +
__('[GLOBAL]') ?>
+ +
+ +
+ +
+ +
+ isSingleStoreMode()): ?> +
__('[GLOBAL]') ?>
+ +
+
+
+ + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/widget/chooser/container.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/product/widget/chooser/container.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/widget/chooser/container.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/product/widget/chooser/container.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/type-switcher.js b/app/code/Mage/Adminhtml/view/adminhtml/catalog/type-switcher.js similarity index 83% rename from app/code/core/Mage/Adminhtml/view/adminhtml/catalog/type-switcher.js rename to app/code/Mage/Adminhtml/view/adminhtml/catalog/type-switcher.js index 0e43fc0f67ba9..c0bba28846157 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog/type-switcher.js +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/type-switcher.js @@ -59,7 +59,17 @@ var self = this, $type = this.$type; $type.on('change', function() { - self._switchToType($(this).val()); + self._switchToType($type.val()); + }); + + $('#product-edit-form-tabs').on('contentUpdated', function() { + self._switchToType($type.val()); + self.$is_virtual.trigger('change'); + }); + + $("#product_info_tabs").on("beforePanelsMove tabscreate tabsactivate", function(event) { + self._switchToType($type.val()); + self.$is_virtual.trigger('change'); }); this.$is_virtual.on('change click', function() { @@ -68,7 +78,7 @@ if ($type.val() != 'bundle') { // @TODO move this check to Mage_Bundle after refactoring as widget self.$weight.addClass('ignore-validate').prop('disabled', true); } - self.$tab.show(); + self.$tab.show().closest('li').removeClass('removed'); } else { $type.val(self.baseType.real).trigger('change'); if ($type.val() != 'bundle') { // @TODO move this check to Mage_Bundle after refactoring as widget @@ -95,11 +105,10 @@ * @private */ _switchToType: function(typeCode) { - var self = this, - attributes = this._data.attributes; - - $.each(attributes, function(code, applyTo) { - var attrContainer = self.getElementByCode(code); + var self = this; + $('[data-apply-to]:not(.removed)').each(function(index, element) { + var attrContainer = $(element), + applyTo = attrContainer.data('applyTo') || []; var $inputs = attrContainer.find('select, input, textarea'); if (applyTo.length === 0 || $.inArray(typeCode, applyTo) !== -1) { attrContainer.show(); diff --git a/app/code/Mage/Adminhtml/view/adminhtml/catalog/wysiwyg/js.phtml b/app/code/Mage/Adminhtml/view/adminhtml/catalog/wysiwyg/js.phtml new file mode 100644 index 0000000000000..fac4346d61a53 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/catalog/wysiwyg/js.phtml @@ -0,0 +1,120 @@ + + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/cms.xml b/app/code/Mage/Adminhtml/view/adminhtml/cms.xml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/cms.xml rename to app/code/Mage/Adminhtml/view/adminhtml/cms.xml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/cms/browser/content.phtml b/app/code/Mage/Adminhtml/view/adminhtml/cms/browser/content.phtml new file mode 100644 index 0000000000000..e1ac90cda81c7 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/cms/browser/content.phtml @@ -0,0 +1,47 @@ + + +getChildHtml('wysiwyg_images.js') ?> + +
+
+
+ getButtonsHtml() ?> +
+
getHeaderText() ?>
+
+
+ +
getChildHtml('wysiwyg_images.uploader') ?>
+
+
getChildHtml('wysiwyg_images.newfolder') ?>
diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/cms/browser/content/files.phtml b/app/code/Mage/Adminhtml/view/adminhtml/cms/browser/content/files.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/cms/browser/content/files.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/cms/browser/content/files.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/cms/browser/content/newfolder.phtml b/app/code/Mage/Adminhtml/view/adminhtml/cms/browser/content/newfolder.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/cms/browser/content/newfolder.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/cms/browser/content/newfolder.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/cms/browser/content/uploader.phtml b/app/code/Mage/Adminhtml/view/adminhtml/cms/browser/content/uploader.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/cms/browser/content/uploader.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/cms/browser/content/uploader.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/cms/browser/js.phtml b/app/code/Mage/Adminhtml/view/adminhtml/cms/browser/js.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/cms/browser/js.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/cms/browser/js.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/cms/browser/tree.phtml b/app/code/Mage/Adminhtml/view/adminhtml/cms/browser/tree.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/cms/browser/tree.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/cms/browser/tree.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/cms/page/edit/form/renderer/content.phtml b/app/code/Mage/Adminhtml/view/adminhtml/cms/page/edit/form/renderer/content.phtml new file mode 100644 index 0000000000000..b0a519166a134 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/cms/page/edit/form/renderer/content.phtml @@ -0,0 +1,33 @@ + +getElement() ?> + +getNoDisplay()): ?> +
+ getElementHtml()) ?> +
+ diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/customer.xml b/app/code/Mage/Adminhtml/view/adminhtml/customer.xml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/customer.xml rename to app/code/Mage/Adminhtml/view/adminhtml/customer.xml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/customer/edit/js.phtml b/app/code/Mage/Adminhtml/view/adminhtml/customer/edit/js.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/customer/edit/js.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/customer/edit/js.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/customer/edit/tab/account/form/renderer/group.phtml b/app/code/Mage/Adminhtml/view/adminhtml/customer/edit/tab/account/form/renderer/group.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/customer/edit/tab/account/form/renderer/group.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/customer/edit/tab/account/form/renderer/group.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/customer/edit/tab/view/grid/item.phtml b/app/code/Mage/Adminhtml/view/adminhtml/customer/edit/tab/view/grid/item.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/customer/edit/tab/view/grid/item.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/customer/edit/tab/view/grid/item.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/customer/online.phtml b/app/code/Mage/Adminhtml/view/adminhtml/customer/online.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/customer/online.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/customer/online.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/customer/sales/order/create/address/form/renderer/vat.phtml b/app/code/Mage/Adminhtml/view/adminhtml/customer/sales/order/create/address/form/renderer/vat.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/customer/sales/order/create/address/form/renderer/vat.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/customer/sales/order/create/address/form/renderer/vat.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/customer/system/config/validatevat.phtml b/app/code/Mage/Adminhtml/view/adminhtml/customer/system/config/validatevat.phtml similarity index 76% rename from app/code/core/Mage/Adminhtml/view/adminhtml/customer/system/config/validatevat.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/customer/system/config/validatevat.phtml index d513f6de1eefe..72c363f85254b 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/customer/system/config/validatevat.phtml +++ b/app/code/Mage/Adminhtml/view/adminhtml/customer/system/config/validatevat.phtml @@ -32,7 +32,7 @@
-
diff --git a/app/code/Mage/Adminhtml/view/adminhtml/customer/tab/addresses.phtml b/app/code/Mage/Adminhtml/view/adminhtml/customer/tab/addresses.phtml new file mode 100644 index 0000000000000..fe15ba6268c49 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/customer/tab/addresses.phtml @@ -0,0 +1,646 @@ + + +
+ + __('Customer Addresses') ?> + +
+ +
    + + + + +
  • + isReadonly()): ?> +
    + + +
    + + +
    + format('html') ?> +
    + +
    + isReadonly()):?> disabled="disabled" value="getId() ?>" id="address_item_billinggetId() ?>" name="account[default_billing]" title="__('Set as Default Billing Address') ?>"getId()==$customer->getDefaultBilling()): ?> checked="checked" /> + +
    +
    + isReadonly()):?> disabled="disabled" value="getId() ?>" id="address_item_shippinggetId() ?>" name="account[default_shipping]" title="__('Set as Default Shipping Address') ?>"getId()==$customer->getDefaultShipping()): ?> checked="checked" /> + +
    + +
  • + + +
  • getAddNewButtonHtml() ?>
  • +
+ + + getTemplatePrefix() ?> + + + +
+ getForm()->setHtmlIdPrefix($_templatePrefix) + ->setFieldNameSuffix('address['.$_templatePrefix.']'); + ?> + getForm()->getHtml() ?> +
+ + + + +
+ + + + + +
+
+ + + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/customer/tab/cart.phtml b/app/code/Mage/Adminhtml/view/adminhtml/customer/tab/cart.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/customer/tab/cart.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/customer/tab/cart.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/customer/tab/newsletter.phtml b/app/code/Mage/Adminhtml/view/adminhtml/customer/tab/newsletter.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/customer/tab/newsletter.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/customer/tab/newsletter.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/customer/tab/view.phtml b/app/code/Mage/Adminhtml/view/adminhtml/customer/tab/view.phtml new file mode 100644 index 0000000000000..bf2cbf6f3a75b --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/customer/tab/view.phtml @@ -0,0 +1,86 @@ + + +getLastLoginDate(); +$lastLoginDateStore = $this->getStoreLastLoginDate(); + +$createDateAdmin = $this->getCreateDate(); +$createDateStore = $this->getStoreCreateDate(); +?> + +
+
+ __('Personal Information') ?> +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
__('Last Logged In:') ?> (getCurrentStatus() ?>)
__('Last Logged In (%s):', $this->getStoreLastLoginDateTimezone()) ?> (getCurrentStatus() ?>)
__('Confirmed email:') ?>getIsConfirmedStatus() ?>
__('Account Created on:') ?>
__('Account Created on (%s):', $this->getStoreCreateDateTimezone()) ?>
__('Account Created in:') ?>getCreatedInStore() ?>
__('Customer Group:') ?>getGroupName() ?>
+
+ __('Default Billing Address') ?>
+ getBillingAddressHtml() ?> +
+ +
+getChildHtml('', true); ?> \ No newline at end of file diff --git a/app/code/Mage/Adminhtml/view/adminhtml/customer/tab/view/sales.phtml b/app/code/Mage/Adminhtml/view/adminhtml/customer/tab/view/sales.phtml new file mode 100644 index 0000000000000..c9052e73fdd42 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/customer/tab/view/sales.phtml @@ -0,0 +1,93 @@ + +
+ +
+ __('Sales Statistics') ?> +
+ + + + + isSingleStoreMode()): ?> + + + + + + + + + isSingleStoreMode()): ?> + + + + + + + + + getRows()): ?> + + + getRows() as $_websiteId => $_groups): ?> + + $_stores): ?> + + + isSingleStoreMode()): ?> + getStoreId() == 0): ?> + + + > + + + + + + + + + + + + + + + + + + + + + + + + + +
__('Website') ?>__('Store') ?>__('Store View') ?>__('Lifetime Sales') ?>__('Average Sale') ?>
__('All Store Views') ?>formatCurrency($this->getTotals()->getBaseLifetime()) ?>formatCurrency($this->getTotals()->getAvgsale()) ?>
getStoreName() ?>getWebsiteName() ?>getGroupName() ?>getStoreName() ?>
formatCurrency($_row->getLifetime(), $_row->getWebsiteId()) ?>formatCurrency($_row->getAvgsale(), $_row->getWebsiteId()) ?>
+
\ No newline at end of file diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/dashboard/graph.phtml b/app/code/Mage/Adminhtml/view/adminhtml/dashboard/graph.phtml similarity index 76% rename from app/code/core/Mage/Adminhtml/view/adminhtml/dashboard/graph.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/dashboard/graph.phtml index 1bbc8eb437cae..caeedfe5338eb 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/dashboard/graph.phtml +++ b/app/code/Mage/Adminhtml/view/adminhtml/dashboard/graph.phtml @@ -46,20 +46,21 @@
-
-

__('Select Range') ?>: -


+
+
__('Select Range') ?>: + +
getWidth()}px;height:{$this->getHeight()}px; margin:0 auto;"; ?> getCount()): ?> -

chart

+
chart
-

__('No Data Found') ?>

+
__('No Data Found') ?>
diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/dashboard/graph/disabled.phtml b/app/code/Mage/Adminhtml/view/adminhtml/dashboard/graph/disabled.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/dashboard/graph/disabled.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/dashboard/graph/disabled.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/dashboard/grid.phtml b/app/code/Mage/Adminhtml/view/adminhtml/dashboard/grid.phtml new file mode 100644 index 0000000000000..d96f5489a361e --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/dashboard/grid.phtml @@ -0,0 +1,88 @@ + +getColumns()); +?> +getCollection()): ?> +
+ + tags from the code. */ + /* foreach ($this->getColumns() as $_column): ?> + getHtmlProperty() ?> /> + + getHeadersVisibility() || $this->getFilterVisibility()): ?> + + getHeadersVisibility()): ?> + + getColumns() as $_column): ?> + + + + + + + + getCollection()->getSize()>0) && (!$this->getIsCollapsed())): ?> + getCollection() as $_index=>$_item): ?> + + getColumns() as $_column): ?> + + + + + getEmptyText()): ?> + + + + + +
getHeaderHtmlProperty() ?>>getHeaderHtml() ?>
getRowField($_item)) != '' ? $_html : ' ') ?>
getEmptyText() ?>
+
+canDisplayContainer()): ?> + + + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/dashboard/index.phtml b/app/code/Mage/Adminhtml/view/adminhtml/dashboard/index.phtml similarity index 97% rename from app/code/core/Mage/Adminhtml/view/adminhtml/dashboard/index.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/dashboard/index.phtml index 4e28869cb3cc8..350bc55d3fe8a 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/dashboard/index.phtml +++ b/app/code/Mage/Adminhtml/view/adminhtml/dashboard/index.phtml @@ -88,12 +88,16 @@ function toggleCal(id) { //]]> + +
getChildHtml('store_switcher') ?> -
+
getChildHtml('diagrams') ?> getChildBlock('diagrams')->getTabsIds())) : ?>
diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/dashboard/salebar.phtml b/app/code/Mage/Adminhtml/view/adminhtml/dashboard/salebar.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/dashboard/salebar.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/dashboard/salebar.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/dashboard/searches.phtml b/app/code/Mage/Adminhtml/view/adminhtml/dashboard/searches.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/dashboard/searches.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/dashboard/searches.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/dashboard/store/switcher.phtml b/app/code/Mage/Adminhtml/view/adminhtml/dashboard/store/switcher.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/dashboard/store/switcher.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/dashboard/store/switcher.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/dashboard/totalbar.phtml b/app/code/Mage/Adminhtml/view/adminhtml/dashboard/totalbar.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/dashboard/totalbar.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/dashboard/totalbar.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/email/order/items.phtml b/app/code/Mage/Adminhtml/view/adminhtml/email/order/items.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/email/order/items.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/email/order/items.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/images/btn_bg.gif b/app/code/Mage/Adminhtml/view/adminhtml/images/btn_bg.gif similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/images/btn_bg.gif rename to app/code/Mage/Adminhtml/view/adminhtml/images/btn_bg.gif diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/images/btn_on_bg.gif b/app/code/Mage/Adminhtml/view/adminhtml/images/btn_on_bg.gif similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/images/btn_on_bg.gif rename to app/code/Mage/Adminhtml/view/adminhtml/images/btn_on_bg.gif diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/images/btn_over_bg.gif b/app/code/Mage/Adminhtml/view/adminhtml/images/btn_over_bg.gif similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/images/btn_over_bg.gif rename to app/code/Mage/Adminhtml/view/adminhtml/images/btn_over_bg.gif diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/images/error_msg_icon.gif b/app/code/Mage/Adminhtml/view/adminhtml/images/error_msg_icon.gif similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/images/error_msg_icon.gif rename to app/code/Mage/Adminhtml/view/adminhtml/images/error_msg_icon.gif diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/images/fam_bullet_error.gif b/app/code/Mage/Adminhtml/view/adminhtml/images/fam_bullet_error.gif similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/images/fam_bullet_error.gif rename to app/code/Mage/Adminhtml/view/adminhtml/images/fam_bullet_error.gif diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/images/fam_bullet_success.gif b/app/code/Mage/Adminhtml/view/adminhtml/images/fam_bullet_success.gif similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/images/fam_bullet_success.gif rename to app/code/Mage/Adminhtml/view/adminhtml/images/fam_bullet_success.gif diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/images/image-placeholder.png b/app/code/Mage/Adminhtml/view/adminhtml/images/image-placeholder.png similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/images/image-placeholder.png rename to app/code/Mage/Adminhtml/view/adminhtml/images/image-placeholder.png diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/images/note_msg_icon.gif b/app/code/Mage/Adminhtml/view/adminhtml/images/note_msg_icon.gif similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/images/note_msg_icon.gif rename to app/code/Mage/Adminhtml/view/adminhtml/images/note_msg_icon.gif diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/images/success_msg_icon.gif b/app/code/Mage/Adminhtml/view/adminhtml/images/success_msg_icon.gif similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/images/success_msg_icon.gif rename to app/code/Mage/Adminhtml/view/adminhtml/images/success_msg_icon.gif diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/images/warning_msg_icon.gif b/app/code/Mage/Adminhtml/view/adminhtml/images/warning_msg_icon.gif similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/images/warning_msg_icon.gif rename to app/code/Mage/Adminhtml/view/adminhtml/images/warning_msg_icon.gif diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/main.xml b/app/code/Mage/Adminhtml/view/adminhtml/main.xml similarity index 98% rename from app/code/core/Mage/Adminhtml/view/adminhtml/main.xml rename to app/code/Mage/Adminhtml/view/adminhtml/main.xml index 6b55fc2a40667..304150224e7e5 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/main.xml +++ b/app/code/Mage/Adminhtml/view/adminhtml/main.xml @@ -55,12 +55,14 @@ Supported layout update handles (special): Magento Admin - jquery/jquery.min.js + jquery/jquery.js mage/jquery-no-conflict.js jquery/jquery-ui.js head.load.min.js + underscore.js mage/mage.js jquery/jquery.tmpl.min.js + jquery/jquery.validate.js jquery/jquery.hoverIntent.js mage/translate.js mage/backend/bootstrap.js diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/media/uploader.phtml b/app/code/Mage/Adminhtml/view/adminhtml/media/uploader.phtml similarity index 98% rename from app/code/core/Mage/Adminhtml/view/adminhtml/media/uploader.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/media/uploader.phtml index 5c4b6441ad50d..968a022111117 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/media/uploader.phtml +++ b/app/code/Mage/Adminhtml/view/adminhtml/media/uploader.phtml @@ -78,6 +78,7 @@ $('#' + data.fileId) .delay(2000) .hide('highlight'); + alert($.mage.__('File extension not known or unsupported type.')); } $('#' + data.fileId).remove(); }, diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/newsletter.xml b/app/code/Mage/Adminhtml/view/adminhtml/newsletter.xml similarity index 83% rename from app/code/core/Mage/Adminhtml/view/adminhtml/newsletter.xml rename to app/code/Mage/Adminhtml/view/adminhtml/newsletter.xml index 9a6e5203c2f6d..2c810dad54565 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/newsletter.xml +++ b/app/code/Mage/Adminhtml/view/adminhtml/newsletter.xml @@ -46,6 +46,12 @@ + + Mage_Adminhtml::jquery/fileUploader/css/jquery.fileupload-ui.css + Mage_Adminhtml::jquery/fileUploader/jquery.fileupload.js + Mage_Adminhtml::jquery/fileUploader/load-image.min.js + Mage_Adminhtml::jquery/fileUploader/jquery.fileupload-fp.js + @@ -109,14 +115,16 @@ 0 Mage_Adminhtml_Block_Newsletter_Problem_Grid_Filter_Checkbox Mage_Adminhtml_Block_Newsletter_Problem_Grid_Renderer_Checkbox - 20px + col-select + col-select
ID
- 50px problem_id + col-id + col-id
@@ -124,6 +132,8 @@
Subscriber
#$subscriber_id $customer_name ($subscriber_email) subscriber_id + col-subscriber + col-subscriber
@@ -132,12 +142,16 @@ queue_start_at true datetime + col-start + col-start
Queue Subject
template_subject + col-subject + col-subject
@@ -145,12 +159,16 @@
Error Code
problem_error_code number + col-error-code + col-error-code
Error Text
problem_error_text + col-error + col-error
diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/newsletter/preview/iframeswitcher.phtml b/app/code/Mage/Adminhtml/view/adminhtml/newsletter/preview/iframeswitcher.phtml similarity index 84% rename from app/code/core/Mage/Adminhtml/view/adminhtml/newsletter/preview/iframeswitcher.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/newsletter/preview/iframeswitcher.phtml index 74d7a10b0faa4..07f730761575e 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/newsletter/preview/iframeswitcher.phtml +++ b/app/code/Mage/Adminhtml/view/adminhtml/newsletter/preview/iframeswitcher.phtml @@ -27,22 +27,19 @@ - + getChildHtml('head') ?> - - +
isSingleStoreMode()) :?> -

+

getChildHtml('store_switcher') ?> - -

+ +
diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/newsletter/preview/store.phtml b/app/code/Mage/Adminhtml/view/adminhtml/newsletter/preview/store.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/newsletter/preview/store.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/newsletter/preview/store.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/newsletter/problem/list.phtml b/app/code/Mage/Adminhtml/view/adminhtml/newsletter/problem/list.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/newsletter/problem/list.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/newsletter/problem/list.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/newsletter/queue/edit.phtml b/app/code/Mage/Adminhtml/view/adminhtml/newsletter/queue/edit.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/newsletter/queue/edit.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/newsletter/queue/edit.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/newsletter/queue/preview.phtml b/app/code/Mage/Adminhtml/view/adminhtml/newsletter/queue/preview.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/newsletter/queue/preview.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/newsletter/queue/preview.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/newsletter/subscriber/list.phtml b/app/code/Mage/Adminhtml/view/adminhtml/newsletter/subscriber/list.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/newsletter/subscriber/list.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/newsletter/subscriber/list.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/newsletter/template/edit.phtml b/app/code/Mage/Adminhtml/view/adminhtml/newsletter/template/edit.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/newsletter/template/edit.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/newsletter/template/edit.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/newsletter/template/list.phtml b/app/code/Mage/Adminhtml/view/adminhtml/newsletter/template/list.phtml similarity index 91% rename from app/code/core/Mage/Adminhtml/view/adminhtml/newsletter/template/list.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/newsletter/template/list.phtml index 597bc5b214a99..3ddb6b3581900 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/newsletter/template/list.phtml +++ b/app/code/Mage/Adminhtml/view/adminhtml/newsletter/template/list.phtml @@ -25,7 +25,7 @@ */ ?>
-
diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/newsletter/template/preview.phtml b/app/code/Mage/Adminhtml/view/adminhtml/newsletter/template/preview.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/newsletter/template/preview.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/newsletter/template/preview.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/notification/baseurl.phtml b/app/code/Mage/Adminhtml/view/adminhtml/notification/baseurl.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/notification/baseurl.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/notification/baseurl.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/notification/security.phtml b/app/code/Mage/Adminhtml/view/adminhtml/notification/security.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/notification/security.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/notification/security.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/notification/survey.phtml b/app/code/Mage/Adminhtml/view/adminhtml/notification/survey.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/notification/survey.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/notification/survey.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/notification/toolbar.phtml b/app/code/Mage/Adminhtml/view/adminhtml/notification/toolbar.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/notification/toolbar.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/notification/toolbar.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/notification/window.phtml b/app/code/Mage/Adminhtml/view/adminhtml/notification/window.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/notification/window.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/notification/window.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/page/footer.phtml b/app/code/Mage/Adminhtml/view/adminhtml/page/footer.phtml similarity index 99% rename from app/code/core/Mage/Adminhtml/view/adminhtml/page/footer.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/page/footer.phtml index f4fbe887b374a..89307556a6bd0 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/page/footer.phtml +++ b/app/code/Mage/Adminhtml/view/adminhtml/page/footer.phtml @@ -24,6 +24,5 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> - __('Copyright © %s Magento Inc. All rights reserved.', date('Y')) ?> / __('Magento ver. %s', Mage::getVersion()) ?> diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/page/head.phtml b/app/code/Mage/Adminhtml/view/adminhtml/page/head.phtml similarity index 98% rename from app/code/core/Mage/Adminhtml/view/adminhtml/page/head.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/page/head.phtml index aedbd980035ba..a6f9b5266f6d7 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/page/head.phtml +++ b/app/code/Mage/Adminhtml/view/adminhtml/page/head.phtml @@ -47,7 +47,7 @@ getCanLoadTinyMce()): // TinyMCE is broken when loaded through index.php ?> - + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/promo/rules.js b/app/code/Mage/Adminhtml/view/adminhtml/promo/rules.js similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/promo/rules.js rename to app/code/Mage/Adminhtml/view/adminhtml/promo/rules.js diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/promo/salesrulejs.phtml b/app/code/Mage/Adminhtml/view/adminhtml/promo/salesrulejs.phtml similarity index 96% rename from app/code/core/Mage/Adminhtml/view/adminhtml/promo/salesrulejs.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/promo/salesrulejs.phtml index 584c9cab58df5..474211dc50818 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/promo/salesrulejs.phtml +++ b/app/code/Mage/Adminhtml/view/adminhtml/promo/salesrulejs.phtml @@ -64,11 +64,7 @@ function generateCouponCodes(idPrefix, generateUrl, grid) { $(idPrefix + 'information_fieldset').removeClassName('ignore-validate'); var validationResult = $(idPrefix + 'information_fieldset').select('input', 'select', 'textarea').collect( function(elm) { - return Validation.validate(elm, { - useTitle :false, - onElementValidate : function() { - } - }); + return jQuery.validator.validateElement(elm); }).all(); $(idPrefix + 'information_fieldset').addClassName('ignore-validate'); diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/rating.xml b/app/code/Mage/Adminhtml/view/adminhtml/rating.xml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/rating.xml rename to app/code/Mage/Adminhtml/view/adminhtml/rating.xml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/rating/detailed.phtml b/app/code/Mage/Adminhtml/view/adminhtml/rating/detailed.phtml new file mode 100644 index 0000000000000..25af949706d31 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/rating/detailed.phtml @@ -0,0 +1,54 @@ + +getRating() && $this->getRating()->getSize()): ?> +
+ getRating() as $_rating): ?> +
+ + + getRatingOptions() ) ? $_rating->getRatingOptions() : $_rating->getOptions() ?> +
+ + isSelected($_option, $_rating)): ?>checked="checked" /> + + + +
+
+ + +
+ + + __("Rating isn't Available") ?> + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/rating/options.phtml b/app/code/Mage/Adminhtml/view/adminhtml/rating/options.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/rating/options.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/rating/options.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/rating/stars/detailed.phtml b/app/code/Mage/Adminhtml/view/adminhtml/rating/stars/detailed.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/rating/stars/detailed.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/rating/stars/detailed.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/rating/stars/summary.phtml b/app/code/Mage/Adminhtml/view/adminhtml/rating/stars/summary.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/rating/stars/summary.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/rating/stars/summary.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/report.xml b/app/code/Mage/Adminhtml/view/adminhtml/report.xml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/report.xml rename to app/code/Mage/Adminhtml/view/adminhtml/report.xml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/report/grid/container.phtml b/app/code/Mage/Adminhtml/view/adminhtml/report/grid/container.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/report/grid/container.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/report/grid/container.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/report/refresh/statistics.phtml b/app/code/Mage/Adminhtml/view/adminhtml/report/refresh/statistics.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/report/refresh/statistics.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/report/refresh/statistics.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/report/wishlist.phtml b/app/code/Mage/Adminhtml/view/adminhtml/report/wishlist.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/report/wishlist.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/report/wishlist.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/review/add.phtml b/app/code/Mage/Adminhtml/view/adminhtml/review/add.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/review/add.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/review/add.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales.xml b/app/code/Mage/Adminhtml/view/adminhtml/sales.xml similarity index 97% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales.xml rename to app/code/Mage/Adminhtml/view/adminhtml/sales.xml index 5f5ea72c5286b..e1a0e00401eae 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/sales.xml +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales.xml @@ -120,10 +120,11 @@
Order #
- 80px text increment_id real_order_id + col-order-number + col-order-number
@@ -134,15 +135,18 @@ 1 store_id store_id + col-from-store + col-from-store
Purchased On
- 100px datetime created_at created_at + col-period + col-period
@@ -150,6 +154,8 @@ billing_name
Bill to Name
billing_name + col-bill-to-name + col-bill-to-name
@@ -157,6 +163,8 @@ shipping_name
Ship to Name
shipping_name + col-ship-to-name + col-ship-to-name
@@ -166,6 +174,8 @@ currency base_currency_code base_grand_total + col-gtbase + col-gtbase @@ -174,25 +184,28 @@
G.T. (Purchased)
currency order_currency_code + 1 grand_total + col-gtpurchased + col-gtpurchased
status
Status
- 70px options order_currency_code status Mage_Sales_Model_Resource_Order_Grid_StatusesArray + col-status + col-status
action
Action
- 50px action getId 0 @@ -208,6 +221,8 @@ order_id + col-actions + col-actions
@@ -727,6 +742,11 @@ + + order-header + + + true @@ -737,6 +757,7 @@ varien/configurable.js Mage_Adminhtml::sales/order/giftoptions_tooltip.js + Mage_Core::prototype/magento.css @@ -793,6 +814,9 @@ + + + diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/items/column/name.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/items/column/name.phtml new file mode 100644 index 0000000000000..94e0ad574b7bb --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/items/column/name.phtml @@ -0,0 +1,60 @@ + + + +getItem()): ?> +
escapeHtml($_item->getName()) ?>
+ helper('Mage_Sales_Helper_Data')->__('SKU') ?>: ', Mage::helper('Mage_Catalog_Helper_Data')->splitSku($this->escapeHtml($this->getSku()))); ?> + getOrderOptions()): ?> +
+ getOrderOptions() as $_option): ?> +
+
+ + getCustomizedOptionValue($_option); ?> + + getFormattedOption($_option['value']); ?> + ... + + + +
+ +
+ + escapeHtml($_item->getDescription()) ?> + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/items/column/qty.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/items/column/qty.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/items/column/qty.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/items/column/qty.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/items/renderer/default.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/items/renderer/default.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/items/renderer/default.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/items/renderer/default.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/address/form.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/address/form.phtml new file mode 100644 index 0000000000000..bb53216f3cf3e --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/address/form.phtml @@ -0,0 +1,40 @@ + +
+
+
__('Changing address information will not recalculate shipping, tax or other order amount.') ?>
+
+
+
+ + getHeaderText() ?> + +
+
+ getForm()->toHtml() ?> +
+
diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/comments/view.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/comments/view.phtml new file mode 100644 index 0000000000000..a8dbd87e45b2c --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/comments/view.phtml @@ -0,0 +1,71 @@ + +getEntity()): ?> +
+
+ + +
+
+
+ getChildHtml('submit_button') ?> +
+
+ canSendCommentEmail()): ?> +
+ + +
+
+
    + getCommentsCollection(true) as $_comment): ?> +
  • + helper('Mage_Core_Helper_Data')->formatDate($_comment->getCreatedAtDate(), 'medium') ?> + helper('Mage_Core_Helper_Data')->formatTime($_comment->getCreatedAtDate(), 'medium') ?> + + helper('Mage_Sales_Helper_Data')->__('Customer') ?> + getIsCustomerNotified()): ?> + helper('Mage_Sales_Helper_Data')->__('Notified') ?> + + helper('Mage_Sales_Helper_Data')->__('Not Notified') ?> + + +
    escapeHtml($_comment->getComment(), array('b','br','strong','i','u')) ?>
    +
  • + +
+
+ + diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/abstract.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/abstract.phtml new file mode 100644 index 0000000000000..a841bffe8d87d --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/abstract.phtml @@ -0,0 +1,32 @@ + + +
+ getHeaderText() ?> +
getButtonsHtml() ?>
+
+getChildHtml('', true) ?> diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/billing/method/form.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/billing/method/form.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/billing/method/form.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/billing/method/form.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/comment.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/comment.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/comment.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/comment.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/coupons/form.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/coupons/form.phtml new file mode 100644 index 0000000000000..422b474bfa0d7 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/coupons/form.phtml @@ -0,0 +1,47 @@ + + +
+

__('Apply Coupon Code') ?>

+
+
+

 getButtonHtml(Mage::helper('Mage_Sales_Helper_Data')->__('Apply'), 'order.applyCoupon($F(\'coupons:code\'))') ?>

+ getCouponCode()): ?> +

escapeHtml($this->getCouponCode()) ?> [__('Remove') ?>]

+ + +
+
+
diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/data.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/data.phtml new file mode 100644 index 0000000000000..889c711cc6b31 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/data.phtml @@ -0,0 +1,93 @@ + +
+ + +
+ +
+ + getCustomerId()): ?> +
+ getChildHtml('sidebar') ?> +
+ +
+
+ + +
getChildHtml('items') ?>
+
getChildHtml('errors') ?>
+ + +
+
getChildHtml('billing_address') ?>
+
getChildHtml('shipping_address') ?>
+
+ +
+
+
+ getChildHtml('billing_method') ?> +
+
+
+
+ getChildHtml('shipping_method') ?> +
+
+
+ + getChildBlock('card_validation')): ?> +
getChildHtml('card_validation') ?>
+ + + getChildHtml('gift_options') ?> + +
+
+
+ __('Order History') ?> + getChildHtml('comment') ?> +
+
+
+
+ getChildHtml('totals') ?> +
+
+
+ +
+
+
diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/form.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/form.phtml new file mode 100644 index 0000000000000..9d68b77d2e1bd --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/form.phtml @@ -0,0 +1,47 @@ + + +
+ getBlockHtml('formkey')?> +
+ getChildHtml('message') ?> +
+
+ getChildHtml('customer') ?> +
+
+ getChildHtml('store') ?> +
+
+ getChildHtml('data') ?> +
+
diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/form/account.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/form/account.phtml new file mode 100644 index 0000000000000..0236375083568 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/form/account.phtml @@ -0,0 +1,34 @@ + +
+ getHeaderText() ?> +
+
+
+ getForm()->getHtml() ?> +
+ diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/form/address.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/form/address.phtml new file mode 100644 index 0000000000000..780283bffc5df --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/form/address.phtml @@ -0,0 +1,93 @@ +getIsShipping()): + $_fieldsContainerId = 'order-shipping_address_fields'; + $_addressChoiceContainerId = 'order-shipping_address_choice'; + ?> + + + + + + + +
+ getHeaderText() ?> +
+ + getForm()->getHtmlIdPrefix() . 'customer_address_id' ?> +
+ +
+ getIsShipping()): ?> + + +   + +
+ +
+
+ getForm()->toHtml() ?> +
+
+ getDontSaveInAddressBook() && $this->getAddress()->getSaveInAddressBook()):?> checked="checked"/> + +
+
+ getIsShipping() ? 'shipping' : 'billing') . '-overlay'; ?> + + +
+ diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/giftmessage.js b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/giftmessage.js similarity index 91% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/giftmessage.js rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/giftmessage.js index b22032ce258b3..af741fcf0d185 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/giftmessage.js +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/giftmessage.js @@ -70,7 +70,7 @@ var giftMessagesController = { $(container).toogleGiftMessage = false; $(this.getFieldId(container, 'message')).formObj = $(this.getFieldId(container, 'form')); var form = jQuery('#' + this.getFieldId(container, 'form')); - jQuery('#' + this.getFieldId(container, 'form')).validation(); + jQuery('#' + this.getFieldId(container, 'form')).validate({errorClass: 'mage-error'}); if(!form.valid()) { return false; @@ -103,7 +103,7 @@ var giftMessagesController = { $(this.getFieldId(container, 'message')).formObj = $(this.getFieldId(container, 'form')); var form = jQuery('#' + this.getFieldId(container, 'form')); - form.validation(); + form.validate({errorClass: 'mage-error'}); if(!form.valid()) { return; @@ -138,7 +138,7 @@ function findFieldLabel(field) { /********************* GIFT OPTIONS POPUP ***********************/ var GiftOptionsPopup = Class.create(); GiftOptionsPopup.prototype = { - giftOptionsWindowMask: null, + //giftOptionsWindowMask: null, giftOptionsWindow: null, initialize: function() { @@ -163,21 +163,24 @@ GiftOptionsPopup.prototype = { formContents.parentNode.appendChild(form); form.appendChild(formContents); } + + this.giftOptionsWindow = $('gift_options_configure'); + + jQuery(this.giftOptionsWindow).dialog({ + autoOpen: false, + modal: true, + resizable: false, + minWidth: 500, + dialogClass: 'gift-options-popup' + }); }, showItemGiftOptions : function(event) { var element = Event.element(event).id; var itemId = element.sub('gift_options_link_',''); - toggleSelectsUnderBlock(this.giftOptionsWindowMask, false); - this.giftOptionsWindowMask = $('gift_options_window_mask'); - this.giftOptionsWindow = $('gift_options_configure'); - this.giftOptionsWindow.select('select').each(function(el){ - el.style.visibility = 'visible'; - }); + jQuery(this.giftOptionsWindow).dialog('open'); - this.giftOptionsWindowMask.setStyle({'height': $('html-body').getHeight() + 'px'}).show(); - this.giftOptionsWindow.setStyle({'marginTop': -this.giftOptionsWindow.getHeight()/2 + 'px', 'display': 'block'}); this.setTitle(itemId); Event.observe($('gift_options_cancel_button'), 'click', this.onCloseButton.bind(this)); @@ -191,12 +194,12 @@ GiftOptionsPopup.prototype = { if (productTitleElement) { productTitle = productTitleElement.innerHTML; } - $('gift_options_configure_title').update(productTitle); + jQuery(this.giftOptionsWindow).dialog({ title: jQuery.mage.__('Gift Options for ') + productTitle }); }, onOkButton : function() { var giftOptionsForm = jQuery('#gift_options_configuration_form'); - if (!giftOptionsForm.validation().valid()) { + if (!giftOptionsForm.validate({errorClass: 'mage-error'}).valid()) { return false; } if (jQuery.isFunction(giftOptionsForm[0].reset)) { @@ -211,9 +214,7 @@ GiftOptionsPopup.prototype = { }, closeWindow : function() { - toggleSelectsUnderBlock(this.giftOptionsWindowMask, true); - this.giftOptionsWindowMask.style.display = 'none'; - this.giftOptionsWindow.style.display = 'none'; + jQuery(this.giftOptionsWindow).dialog('close'); } } diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/giftmessage.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/giftmessage.phtml new file mode 100644 index 0000000000000..488e8ef6fccc7 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/giftmessage.phtml @@ -0,0 +1,46 @@ + +helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('main', $this->getQuote(), $this->getStoreId())): ?> +getItems(); ?> +
+
+
+ __('Gift Message for the Entire Order') ?> +
+ helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('main', $this->getQuote(), $this->getStoreId())): ?> +
+

__('You can leave a box blank if you don\'t wish to add a gift message for whole order') ?>

+ getFormHtml($this->getQuote(), 'main') ?> +
+ +
+
+ +
+ diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/items.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/items.phtml new file mode 100644 index 0000000000000..0b7757c52890d --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/items.phtml @@ -0,0 +1,34 @@ + + +
+ getHeaderText() ?> +
+ getButtonsHtml() ?> +
+
+getChildHtml() ?> diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/items/grid.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/items/grid.phtml new file mode 100644 index 0000000000000..688b012ef200c --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/items/grid.phtml @@ -0,0 +1,455 @@ + + + +getItems() ?> + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
helper('Mage_Sales_Helper_Data')->__('Product') ?>helper('Mage_Sales_Helper_Data')->__('Price') ?>helper('Mage_Sales_Helper_Data')->__('Qty') ?>helper('Mage_Sales_Helper_Data')->__('Subtotal') ?>helper('Mage_Sales_Helper_Data')->__('Discount') ?>helper('Mage_Sales_Helper_Data')->__('Row Subtotal') ?>helper('Mage_Sales_Helper_Data')->__('Action') ?>
helper('Mage_Sales_Helper_Data')->__('No ordered items') ?>
+
+ +
+ 10): ?> +

+ getButtonHtml($this->helper('Mage_Sales_Helper_Data')->__('Update Items and Qty\'s'),'order.itemsUpdate()'); ?> +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + getItemExtraInfo($_item)->toHtml(); ?> + + +
helper('Mage_Sales_Helper_Data')->__('Product') ?>helper('Mage_Sales_Helper_Data')->__('Price') ?>helper('Mage_Sales_Helper_Data')->__('Qty') ?>helper('Mage_Sales_Helper_Data')->__('Subtotal') ?>helper('Mage_Sales_Helper_Data')->__('Discount') ?>helper('Mage_Sales_Helper_Data')->__('Row Subtotal') ?>helper('Mage_Sales_Helper_Data')->__('Action') ?>
helper('Mage_Sales_Helper_Data')->__('Total %d product(s)', count($_items)) ?>helper('Mage_Sales_Helper_Data')->__('Subtotal:') ?>formatPrice($this->getSubtotal()) ?>formatPrice($this->getDiscountAmount()) ?> + formatPrice($this->getSubtotal() + $this->getDiscountAmount()); + ?> 
+ escapeHtml($_item->getName()) ?> +
+ helper('Mage_Sales_Helper_Data')->__('SKU') ?>: + ', Mage::helper('Mage_Catalog_Helper_Data')->splitSku($this->escapeHtml($_item->getSku()))); ?> +
+ getMessage(false)): ?> + getMessage(false) as $message): ?> +
+
escapeHtml($message); ?>
+
+ + +
+ getConfigureButtonHtml($_item) ?> + + + + + + helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax($this->getStore()) || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices($this->getStore())): ?> + helper('Mage_Tax_Helper_Data')->displayCartBothPrices($this->getStore())): ?> + __('Excl. Tax'); ?>: + + typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> + formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?> + + formatPrice($_item->getCalculationPrice()) ?> + + + + getApplied($_item)): ?> +
+ typeOfDisplay($_item, 1, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : formatPrice($tax['amount'],true,true); ?>
+ +
+ typeOfDisplay($_item, 2, 'sales')): ?> + getApplied($_item) as $tax): ?> + : formatPrice($tax['amount_incl_tax'],true,true); ?>
+ + typeOfDisplay($_item, 4, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : formatPrice($tax['amount_incl_tax'],true,true); ?>
+ +
+ + + typeOfDisplay($_item, 2, 'sales')): ?> +
+ __('Total'); ?>:
formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>
+ + + + + + helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax($this->getStore()) || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices($this->getStore())): ?> + helper('Mage_Tax_Helper_Data')->displayCartBothPrices($this->getStore())): ?> +
__('Incl. Tax'); ?>: + + helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item); ?> + typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> + formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?> + + formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?> + + getApplied($_item)): ?> +
+ typeOfDisplay($_item, 1, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : formatPrice($tax['amount'],true,true); ?>
+ +
+ typeOfDisplay($_item, 2, 'sales')): ?> + getApplied($_item) as $tax): ?> + : formatPrice($tax['amount_incl_tax'],true,true); ?>
+ + typeOfDisplay($_item, 4, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : formatPrice($tax['amount_incl_tax'],true,true); ?>
+ +
+ + + typeOfDisplay($_item, 2, 'sales')): ?> + __('Total incl. tax'); ?>:
formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?>
+ + + + + + + + usedCustomPriceForItem($_item) ?> + getTierHtml($_item)): ?> + + + canApplyCustomPrice($_item)): ?> +
+ checked="checked" onclick="order.toggleCustomPrice(this, 'item_custom_price_getId() ?>', 'item_tier_block_getId() ?>');"/> + +
+ + getOriginalEditablePrice($_item))?>" style="display:none" disabled="disabled" class="input-text item-price"/> +
+ + + + + helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax($this->getStore()) || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices($this->getStore())): ?> + helper('Mage_Tax_Helper_Data')->displayCartBothPrices($this->getStore())): ?> + __('Excl. Tax'); ?>: + + typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> + formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> + + formatPrice($_item->getRowTotal()) ?> + + + + getApplied($_item)): ?> +
+ typeOfDisplay($_item, 1, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : formatPrice($tax['row_amount'],true,true); ?>
+ +
+ typeOfDisplay($_item, 2, 'sales')): ?> + getApplied($_item) as $tax): ?> + : formatPrice($tax['row_amount_incl_tax'],true,true); ?>
+ + typeOfDisplay($_item, 4, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : formatPrice($tax['row_amount_incl_tax'],true,true); ?>
+ +
+ + + typeOfDisplay($_item, 2, 'sales')): ?> +
+ __('Total'); ?>:
formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?>
+ + + + + + helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax($this->getStore()) || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices($this->getStore())): ?> + helper('Mage_Tax_Helper_Data')->displayCartBothPrices($this->getStore())): ?> +
__('Incl. Tax'); ?>: + + helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item); ?> + typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> + formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> + + formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> + + getApplied($_item)): ?> +
+ typeOfDisplay($_item, 1, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : formatPrice($tax['row_amount'],true,true); ?>
+ +
+ typeOfDisplay($_item, 2, 'sales')): ?> + getApplied($_item) as $tax): ?> + : formatPrice($tax['row_amount_incl_tax'],true,true); ?>
+ + typeOfDisplay($_item, 4, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : formatPrice($tax['row_amount_incl_tax'],true,true); ?>
+ +
+ + + typeOfDisplay($_item, 2, 'sales')): ?> + __('Total incl. tax'); ?>:
formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
+ + + + + + +
+ formatPrice(-$_item->getDiscountAmount()) ?>
+ getNoDiscount()): ?>checked="checked" value="1" type="checkbox" /> + +
+ + + helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax($this->getStore()) || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices($this->getStore())): ?> + getPriceInclTax() * $_item->getQty() - $_item->getDiscountAmount() - $_item->getTaxAmount(); ?> + helper('Mage_Tax_Helper_Data')->displayCartBothPrices($this->getStore())): ?> + __('Excl. Tax'); ?>: + + typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> + formatPrice(max(0, $_rowTotalWithoutDiscount+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition())); ?> + + formatPrice(max(0, $_rowTotalWithoutDiscount)) ?> + + + + getApplied($_item)): ?> +
+ typeOfDisplay($_item, 1, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : formatPrice($tax['row_amount'],true,true); ?>
+ +
+ typeOfDisplay($_item, 2, 'sales')): ?> + getApplied($_item) as $tax): ?> + : formatPrice($tax['row_amount_incl_tax'],true,true); ?>
+ + typeOfDisplay($_item, 4, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : formatPrice($tax['row_amount_incl_tax'],true,true); ?>
+ +
+ + + typeOfDisplay($_item, 2, 'sales')): ?> +
+ __('Total'); ?>:
formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?>
+ + + + + + helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax($this->getStore()) || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices($this->getStore())): ?> + helper('Mage_Tax_Helper_Data')->displayCartBothPrices($this->getStore())): ?> +
__('Incl. Tax'); ?>: + + getPriceInclTax() * $_item->getQty() - $_item->getDiscountAmount(); ?> + typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> + formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> + + formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> + + getApplied($_item)): ?> +
+ typeOfDisplay($_item, 1, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : formatPrice($tax['row_amount'],true,true); ?>
+ +
+ typeOfDisplay($_item, 2, 'sales')): ?> + getApplied($_item) as $tax): ?> + : formatPrice($tax['row_amount_incl_tax'],true,true); ?>
+ + typeOfDisplay($_item, 4, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : formatPrice($tax['row_amount_incl_tax'],true,true); ?>
+ +
+ + + typeOfDisplay($_item, 2, 'sales')): ?> + __('Total incl. tax'); ?>:
formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
+ + + + +
+ +
+
+

getInclExclTaxMessage(); ?>

+

getButtonHtml($this->helper('Mage_Sales_Helper_Data')->__('Update Items and Qty\'s'),'order.itemsUpdate()'); ?>

+
getChildHtml();?>
+
+ +
+ +isGiftMessagesAvailable()) : ?> + + + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/js.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/js.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/js.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/js.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/newsletter/form.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/newsletter/form.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/newsletter/form.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/newsletter/form.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/scripts.js b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/scripts.js similarity index 99% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/scripts.js rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/scripts.js index d7dd94a7bbf3e..e4c8b80932bde 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/scripts.js +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/scripts.js @@ -47,7 +47,7 @@ AdminOrder.prototype = { this.dataArea = new OrderFormArea('data', $(this.getAreaId('data')), this); this.itemsArea = Object.extend(new OrderFormArea('items', $(this.getAreaId('items')), this), { addControlButton: function(button){ - var controlButtonArea = $(this.node).select('.form-buttons')[0]; + var controlButtonArea = $(this.node).select('.actions')[0]; if (typeof controlButtonArea != 'undefined') { var buttons = controlButtonArea.childElements(); for (var i = 0; i < buttons.length; i++) { @@ -962,7 +962,7 @@ AdminOrder.prototype = { if ('message' != id || response[id]) { var wrapper = new Element('div'); wrapper.update(response[id] ? response[id] : ''); - $(this.getAreaId(id)).update(Prototype.Browser.IE ? wrapper.outerHTML : wrapper); + $(this.getAreaId(id)).update(wrapper.innerHTML); } if ($(this.getAreaId(id)).callback) { this[$(this.getAreaId(id)).callback](); @@ -1134,14 +1134,7 @@ AdminOrder.prototype = { parentEl.setStyle({position: 'relative'}); el.setStyle({ - display: show ? 'none' : '', - position: 'absolute', - backgroundColor: '#999999', - opacity: 0.8, - width: parentEl.getWidth() + 'px', - height: parentEl.getHeight() + 'px', - top: 0, - left: 0 + display: show ? 'none' : '' }); }, @@ -1251,7 +1244,7 @@ ControlButton.prototype = { initialize: function(label){ this._label = label; this._node = new Element('button', { - 'class': 'scalable add', + 'class': 'scalable action-add', 'type': 'button' }); }, diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/shipping/method/form.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/shipping/method/form.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/shipping/method/form.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/shipping/method/form.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/sidebar.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/sidebar.phtml new file mode 100644 index 0000000000000..350dbed807607 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/sidebar.phtml @@ -0,0 +1,70 @@ + +
+

helper('Mage_Sales_Helper_Data')->__('Customer\'s Current Activities') ?>

+
+ getChildHtml('top_button'); ?> + getLayout()->getChildBlocks($this->getNameInLayout()) as $_alias => $_child): ?> + + canDisplay($_child)): ?> +
+ getChildHtml($_alias) ?> +
+ + + + getChildHtml('bottom_button'); ?> +
+
+ diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/sidebar/items.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/sidebar/items.phtml new file mode 100644 index 0000000000000..9c5078acf0435 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/sidebar/items.phtml @@ -0,0 +1,105 @@ + + + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/store/select.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/store/select.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/store/select.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/store/select.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/totals.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/totals.phtml new file mode 100644 index 0000000000000..8ceb08474ea1a --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/totals.phtml @@ -0,0 +1,65 @@ + +__('Order Totals') ?> + + + renderTotals(); ?> + renderTotals('footer'); ?> + +
+
+
+

+ + getNoteNotify()): ?>checked="true"/> +

+ canSendNewOrderConfirmationEmail()): ?> +

+ + +

+ +

getButtonHtml(Mage::helper('Mage_Sales_Helper_Data')->__('Submit Order'),'order.submit()','save'); ?>

+
+ + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/totals/default.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/totals/default.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/totals/default.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/totals/default.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/totals/grandtotal.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/totals/grandtotal.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/totals/grandtotal.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/totals/grandtotal.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/totals/shipping.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/totals/shipping.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/totals/shipping.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/totals/shipping.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/totals/subtotal.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/totals/subtotal.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/totals/subtotal.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/totals/subtotal.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/totals/tax.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/totals/tax.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/totals/tax.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/totals/tax.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/create/form.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/create/form.phtml new file mode 100644 index 0000000000000..584f4476e60fb --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/create/form.phtml @@ -0,0 +1,83 @@ + +
+ getBlockHtml('formkey')?> + getCreditmemo()->getOrder() ?> + getChildHtml('order_info') ?> +
+ getIsVirtual()): ?> +
+ +
+ + +
+
+ __('Payment Information') ?> +
+
getChildHtml('order_payment') ?>
+
__('Order was placed using %s', $_order->getOrderCurrencyCode()) ?>
+ getCreditmemo()->canRefund()): ?> + + + +
+
+ getIsVirtual()): ?> +
+ +
+
+ __('Shipping Information') ?> +
+
+
escapeHtml($_order->getShippingDescription()) ?>
+
+ helper('Mage_Sales_Helper_Data')->__('Total Shipping Charges'); ?>: + + helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax($this->getSource()->getStoreId())): ?> + displayShippingPriceInclTax($_order); ?> + + displayPriceAttribute('shipping_amount', false, ' '); ?> + + displayShippingPriceInclTax($_order); ?> + + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices($this->getSource()->getStoreId()) && $_incl != $_excl): ?> + (__('Incl. Tax'); ?> ) + +
+
+
+
+ +
+ +
+ getChildHtml('order_items') ?> +
+ diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/create/items.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/create/items.phtml new file mode 100644 index 0000000000000..c36189128c5b1 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/create/items.phtml @@ -0,0 +1,177 @@ + +getCreditmemo()->getAllItems() ?> +
+
+ __('Items to Refund') ?> +
+ +
+ + + + + + + canReturnToStock()) : ?> + + + + + + + + + + canEditQty()): ?> + + + + + + + + + + getOrderItem()->getParentItem()) continue; else $i++; ?> + + getItemHtml($_item) ?> + getItemExtraInfoHtml($_item->getOrderItem()) ?> + + +
helper('Mage_Sales_Helper_Data')->__('Product') ?>helper('Mage_Sales_Helper_Data')->__('Price') ?>helper('Mage_Sales_Helper_Data')->__('Qty') ?>helper('Mage_Sales_Helper_Data')->__('Return to Stock') ?>helper('Mage_Sales_Helper_Data')->__('Qty to Refund') ?>helper('Mage_Sales_Helper_Data')->__('Subtotal') ?>helper('Mage_Sales_Helper_Data')->__('Tax Amount') ?>helper('Mage_Sales_Helper_Data')->__('Discount Amount') ?>helper('Mage_Sales_Helper_Data')->__('Row Total') ?>
  + getUpdateButtonHtml() ?> +  
+
+ + +
+ helper('Mage_Sales_Helper_Data')->__('No Items To Refund') ?> +
+ +
+
+ getChildHtml('order_totalbar') ?> +
+
+ +
+
+
__('Credit Memo Comments') ?>
+
+
+ +
+
+
+
+
+
__('Refund Totals') ?>
+ getChildHtml('creditmemo_totals') ?> +
+
+ + +
+ canSendCreditmemoEmail()):?> +
+ + +
+ + getChildHtml('submit_before') ?> +
+ getChildHtml('submit_offline') ?> + getChildHtml('submit_button') ?> + getChildHtml('submit_after') ?> +
+
+
+
+
+ + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/create/items/renderer/configurable.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/create/items/renderer/configurable.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/create/items/renderer/configurable.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/create/items/renderer/configurable.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/create/items/renderer/default.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/create/items/renderer/default.phtml new file mode 100644 index 0000000000000..ee2c794b83634 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/create/items/renderer/default.phtml @@ -0,0 +1,245 @@ + +getItem() ?> +setPriceDataObject($_item); ?> + + getColumnHtml($_item, 'name') ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Excl. Tax'); ?>: + + + typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?> + displayPrices( + $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), + $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() + ); + ?> + + displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> + + + + getApplied($_item)): ?> +
+ typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount'], $tax['amount']); ?> + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> +
+ __('Total'); ?>:
+ displayPrices( + $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), + $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() + ); + ?> +
+ + +
+
+ + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Incl. Tax'); ?>: + + helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item); ?> + helper('Mage_Checkout_Helper_Data')->getBasePriceInclTax($_item); ?> + + typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?> + displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?> + + displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?> + + + getApplied($_item)): ?> +
+ typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount'], $tax['amount']); ?> + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> +
+ __('Total'); ?>:
displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?>
+ + +
+ + + getColumnHtml($_item, 'qty') ?> + canParentReturnToStock($_item)) : ?> + + canReturnItemToStock($_item)) : ?> + getBackToStock()):?> checked/> + + + + + canEditQty()) : ?> + + + getQty()*1 ?> + + + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Excl. Tax'); ?>: + + + typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?> + displayPrices( + $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), + $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() + ); + ?> + + displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> + + + + getApplied($_item)): ?> + typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> +
+ __('Total'); ?>:
+ displayPrices( + $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), + $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() + ); + ?> +
+ + +
+
+ + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Incl. Tax'); ?>: + + helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item); ?> + helper('Mage_Checkout_Helper_Data')->getBaseSubtotalInclTax($_item); ?> + typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?> + displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> + + displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?> + + + + getApplied($_item)): ?> + +
+ typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> +
__('Total'); ?>:
displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
+ + +
+ + + displayPriceAttribute('tax_amount') ?> + displayPriceAttribute('discount_amount') ?> + + displayPrices( + $_item->getBaseRowTotal() + $_item->getBaseTaxAmount() + $_item->getBaseHiddenTaxAmount() + $_item->getBaseWeeeTaxAppliedRowAmnt() - $_item->getBaseDiscountAmount(), + $_item->getRowTotal() + $_item->getTaxAmount() + $_item->getHiddenTaxAmount() + $_item->getWeeeTaxAppliedRowAmount() - $_item->getDiscountAmount() + ) ?> + + diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/create/totals/adjustments.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/create/totals/adjustments.phtml new file mode 100644 index 0000000000000..3941921f94cc5 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/create/totals/adjustments.phtml @@ -0,0 +1,76 @@ + +getSource() ?> + + + getShippingLabel() ?>
+ + + + helper('Mage_Sales_Helper_Data')->__('Adjustment Refund') ?>
+ + + + helper('Mage_Sales_Helper_Data')->__('Adjustment Fee') ?>
+ + + + + + diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/view/form.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/view/form.phtml new file mode 100644 index 0000000000000..9dac4d518c2ff --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/view/form.phtml @@ -0,0 +1,100 @@ + +getCreditmemo()->getOrder() ?> +getChildHtml('order_info') ?> +
+getIsVirtual()): ?> +
+ +
+ + +
+
+ helper('Mage_Sales_Helper_Data')->__('Payment Information') ?> +
+
getChildHtml('order_payment') ?>
+
__('Order was placed using %s', $_order->getOrderCurrencyCode()) ?>
+
+
+getIsVirtual()): ?> +
+ +
+
+ helper('Mage_Sales_Helper_Data')->__('Shipping Information') ?> +
+
+
escapeHtml($_order->getShippingDescription()) ?>
+
+ helper('Mage_Sales_Helper_Data')->__('Total Shipping Charges'); ?>: + + helper('Mage_Tax_Helper_Data')->displayShippingPriceIncludingTax()): ?> + displayShippingPriceInclTax($_order); ?> + + displayPriceAttribute('shipping_amount', false, ' '); ?> + + displayShippingPriceInclTax($_order); ?> + + + helper('Mage_Tax_Helper_Data')->displayShippingBothPrices() && $_incl != $_excl): ?> + (__('Incl. Tax'); ?> ) + +
+
+
+
+ +
+getCreditmemo()->getAllItems() ?> + + +
+ getChildHtml('creditmemo_items') ?> +
+ +
+
+ helper('Mage_Sales_Helper_Data')->__('Items Refunded') ?> +
+
helper('Mage_Sales_Helper_Data')->__('No Items') ?>
+
+ +
+
+
+
__('Credit Memo History') ?>
+
getChildHtml('order_comments') ?>
+
+
+
+
+
__('Credit Memo Totals') ?>
+
getChildHtml('creditmemo_totals') ?>
+
+
+
diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/view/items.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/view/items.phtml new file mode 100644 index 0000000000000..8603d647d9503 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/view/items.phtml @@ -0,0 +1,54 @@ + +getCreditmemo()->getAllItems() ?> +
+
+ helper('Mage_Sales_Helper_Data')->__('Items Refunded') ?> +
+
+ + + + + + + + + + + + + + getOrderItem()->getParentItem()) continue; else $i++; ?> + + getItemHtml($_item) ?> + getItemExtraInfoHtml($_item->getOrderItem()) ?> + + +
helper('Mage_Sales_Helper_Data')->__('Product') ?>helper('Mage_Sales_Helper_Data')->__('Price') ?>helper('Mage_Sales_Helper_Data')->__('Qty') ?>helper('Mage_Sales_Helper_Data')->__('Subtotal') ?>helper('Mage_Sales_Helper_Data')->__('Tax Amount') ?>helper('Mage_Sales_Helper_Data')->__('Discount Amount') ?>helper('Mage_Sales_Helper_Data')->__('Row Total') ?>
+
+
\ No newline at end of file diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/view/items/renderer/configurable.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/view/items/renderer/configurable.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/view/items/renderer/configurable.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/view/items/renderer/configurable.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/view/items/renderer/default.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/view/items/renderer/default.phtml new file mode 100644 index 0000000000000..fae432aaf9daf --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/creditmemo/view/items/renderer/default.phtml @@ -0,0 +1,233 @@ + +getItem() ?> +setStoreId($_item->getCreditMemo()->getStoreId()) ?> +setPriceDataObject($_item) ?> + + getColumnHtml($_item, 'name') ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Excl. Tax'); ?>: + + + typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?> + displayPrices( + $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), + $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() + ); + ?> + + displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> + + + + getApplied($_item)): ?> +
+ typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount'], $tax['amount']); ?> + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> +
+ __('Total'); ?>:
+ displayPrices( + $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), + $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() + ); + ?> +
+ + +
+
+ + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Incl. Tax'); ?>: + + helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item); ?> + helper('Mage_Checkout_Helper_Data')->getBasePriceInclTax($_item); ?> + + typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?> + displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?> + + displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?> + + + getApplied($_item)): ?> +
+ typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount'], $tax['amount']); ?> + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> +
+ __('Total'); ?>:
displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?>
+ + +
+ + + + getQty()*1 ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Excl. Tax'); ?>: + + + typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?> + displayPrices( + $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), + $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() + ); + ?> + + displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> + + + + getApplied($_item)): ?> + typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> +
+ __('Total'); ?>:
+ displayPrices( + $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), + $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() + ); + ?> +
+ + +
+
+ + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Incl. Tax'); ?>: + + helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item); ?> + helper('Mage_Checkout_Helper_Data')->getBaseSubtotalInclTax($_item); ?> + typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?> + displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> + + displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?> + + + + getApplied($_item)): ?> + +
+ typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> +
__('Total'); ?>:
displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
+ + +
+ + + displayPriceAttribute('tax_amount') ?> + displayPriceAttribute('discount_amount') ?> + + displayPrices( + $_item->getBaseRowTotal() + $_item->getBaseTaxAmount() + $_item->getBaseHiddenTaxAmount() + $_item->getBaseWeeeTaxAppliedRowAmnt() - $_item->getBaseDiscountAmount(), + $_item->getRowTotal() + $_item->getTaxAmount() + $_item->getHiddenTaxAmount() + $_item->getWeeeTaxAppliedRowAmount() - $_item->getDiscountAmount() + ) ?> + + diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/giftoptions.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/giftoptions.phtml new file mode 100644 index 0000000000000..747e621c97ee1 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/giftoptions.phtml @@ -0,0 +1,32 @@ + +getChildHtml()): ?> +
+
__('Gift Options') ?>
+ getChildHtml() ?> +
+ diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/giftoptions_tooltip.js b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/giftoptions_tooltip.js similarity index 98% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/giftoptions_tooltip.js rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/giftoptions_tooltip.js index c1764f19249d9..2f84b8dc29386 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/giftoptions_tooltip.js +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/giftoptions_tooltip.js @@ -71,6 +71,7 @@ GiftOptionsTooltip.prototype = { } this._tooltipWindow = $(windowId); this._tooltipWindowContent = $(contentId); + $(document.body).insert({ bottom: this._tooltipWindow }); this.hideTooltip(); return true; }, diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/create/form.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/create/form.phtml new file mode 100644 index 0000000000000..b5c9f21c27049 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/create/form.phtml @@ -0,0 +1,111 @@ + +
+ getBlockHtml('formkey')?> + getInvoice()->getOrder() ?> + getChildHtml('order_info') ?> + getIsVirtual()): ?> +
+ + +
+
+
+ __('Payment Information') ?> +
+
getChildHtml('order_payment') ?>
+
__('Order was placed using %s', $_order->getOrderCurrencyCode()) ?>
+
+
+ getIsVirtual()): ?> +
+ +
+
+ __('Shipping Information') ?> +
+
+
escapeHtml($_order->getShippingDescription()) ?>
+
+ helper('Mage_Sales_Helper_Data')->__('Total Shipping Charges'); ?>: + + helper('Mage_Tax_Helper_Data')->displayShippingPriceIncludingTax()): ?> + displayShippingPriceInclTax($_order); ?> + + displayPriceAttribute('shipping_amount', false, ' '); ?> + + displayShippingPriceInclTax($_order); ?> + + + helper('Mage_Tax_Helper_Data')->displayShippingBothPrices() && $_incl != $_excl): ?> + (__('Incl. Tax'); ?> ) + +
+
+ canCreateShipment() && $this->canShipPartiallyItem()): ?> +
+ + hasInvoiceShipmentTypeMismatch()?' disabled="disabled"':'' ?> /> +
+ hasInvoiceShipmentTypeMismatch()): ?> + __('Some items in this order have different invoice and shipment types. You can create shipment only after the invoice is created.') ?> + + + +
+
+ + +
+ +
+ getChildHtml('order_items') ?> +
+
+ diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/create/items.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/create/items.phtml new file mode 100644 index 0000000000000..55c20f08dab0c --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/create/items.phtml @@ -0,0 +1,177 @@ + +
+
+ getForcedShipmentCreate()?'Items to Invoice and Ship':'Items to Invoice'; ?> + __('%s', $_itemsGridLabel) ?> +
+
+ + + + + + + + + + + + + + canEditQty()): ?> + + + + + + + + + getInvoice()->getAllItems() ?> + + getOrderItem()->getParentItem()) continue; else $_i++; ?> + + getItemHtml($_item) ?> + getItemExtraInfoHtml($_item->getOrderItem()) ?> + + +
__('Product') ?>__('Price') ?>__('Qty') ?>__('Qty to Invoice') ?>__('Subtotal') ?>__('Tax Amount') ?>__('Discount Amount') ?>__('Row Total') ?>
 getUpdateButtonHtml() ?> 
+
+
+
+ getChildHtml('order_totalbar') ?> +
+
+
+
+
+ __('Invoice History') ?> +
+
+ + +
+
+
+
+
+
+ __('Invoice Totals') ?> +
+
+ getChildHtml('invoice_totals') ?> + isCaptureAllowed()): ?> + canCapture()):?> +
+ + + +
+ isGatewayUsed()):?> + +
__('Invoice will be created without communication with payment gateway.') ?>
+ + +
+ + +
+ canSendInvoiceEmail()): ?> +
+ + +
+ +
+ getChildHtml('submit_button') ?> +
+
+
+
+
+ + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/invoice/create/items/renderer/configurable.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/create/items/renderer/configurable.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/invoice/create/items/renderer/configurable.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/create/items/renderer/configurable.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/create/items/renderer/default.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/create/items/renderer/default.phtml new file mode 100644 index 0000000000000..05f749eec5f76 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/create/items/renderer/default.phtml @@ -0,0 +1,230 @@ + +getItem() ?> +setPriceDataObject($_item)?> + getColumnHtml($_item, 'name') ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Excl. Tax'); ?>: + + + typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?> + displayPrices( + $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), + $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() + ); + ?> + + displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> + + + getApplied($_item)): ?> +
+ typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount'], $tax['amount']); ?> + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> +
+ __('Total'); ?>:
+ displayPrices( + $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), + $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() + ); + ?> +
+ + +
+
+ + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Incl. Tax'); ?>: + + helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item); ?> + helper('Mage_Checkout_Helper_Data')->getBasePriceInclTax($_item); ?> + + typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?> + displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?> + + displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?> + + + getApplied($_item)): ?> +
+ typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount'], $tax['amount']); ?> + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> +
+ __('Total'); ?>:
displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?>
+ + +
+ + + getColumnHtml($_item, 'qty') ?> + + canEditQty()) : ?> + + + getQty()*1 ?> + + + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Excl. Tax'); ?>: + + + typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?> + displayPrices( + $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), + $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() + ); + ?> + + displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> + + + getApplied($_item)): ?> + typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> +
+ __('Total'); ?>:
+ displayPrices( + $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), + $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() + ); + ?> + + +
+
+ + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Incl. Tax'); ?>: + + helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item); ?> + helper('Mage_Checkout_Helper_Data')->getBaseSubtotalInclTax($_item); ?> + typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?> + displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> + + displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?> + + getApplied($_item)): ?> +
+ typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> +
__('Total'); ?>:
displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> + + +
+ + + displayPriceAttribute('tax_amount') ?> + displayPriceAttribute('discount_amount') ?> + + displayPrices( + $_item->getBaseRowTotal() + $_item->getBaseTaxAmount() + $_item->getBaseHiddenTaxAmount() + $_item->getBaseWeeeTaxAppliedRowAmnt() - $_item->getBaseDiscountAmount(), + $_item->getRowTotal() + $_item->getTaxAmount() + $_item->getHiddenTaxAmount() + $_item->getWeeeTaxAppliedRowAmount() - $_item->getDiscountAmount() + ) ?> + + diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/create/tracking.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/create/tracking.phtml new file mode 100644 index 0000000000000..d78fc3376708c --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/create/tracking.phtml @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +
__('Carrier') ?>__('Title') ?>__('Number') ?>__('Action') ?>
getChildHtml('add_button') ?>
+ + __('Delete') ?>
+ diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/view/form.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/view/form.phtml new file mode 100644 index 0000000000000..b3940119dba29 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/view/form.phtml @@ -0,0 +1,103 @@ + +getInvoice() ?> +getOrder() ?> +getChildHtml('order_info') ?> + +getIsVirtual()): ?> +
+ +
+ +
+
+ helper('Mage_Sales_Helper_Data')->__('Payment Information') ?> +
+
getChildHtml('order_payment') ?>
+
__('Order was placed using %s', $_order->getOrderCurrencyCode()) ?>
+
+
+ getIsVirtual()): ?> +
+ +
+
+ helper('Mage_Sales_Helper_Data')->__('Shipping Information') ?> +
+
+
escapeHtml($_order->getShippingDescription()) ?>
+
+ helper('Mage_Sales_Helper_Data')->__('Total Shipping Charges'); ?>: + + helper('Mage_Tax_Helper_Data')->displayShippingPriceIncludingTax()): ?> + displayShippingPriceInclTax($_order); ?> + + displayPriceAttribute('shipping_amount', false, ' '); ?> + + displayShippingPriceInclTax($_order); ?> + + + helper('Mage_Tax_Helper_Data')->displayShippingBothPrices() && $_incl != $_excl): ?> + (__('Incl. Tax'); ?> ) + +
getChildHtml('shipment_tracking') ?>
+
+
+
+ +
+
+ +
+
+ helper('Mage_Sales_Helper_Data')->__('Items Invoiced') ?> +
+
+ getChildHtml('invoice_items') ?> +
+
+ +
+
+
+
+ __('Invoice History') ?> +
+
+ getChildHtml('order_comments') ?> +
+
+
+
+
+
+ __('Invoice Totals') ?> +
+ getChildHtml('invoice_totals') ?> +
+
+
diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/view/items.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/view/items.phtml new file mode 100644 index 0000000000000..3fe4ca660db48 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/view/items.phtml @@ -0,0 +1,49 @@ + +
+ + + + + + + + + + + + + getInvoice()->getAllItems() ?> + + getOrderItem()->getParentItem()) continue; else $i++; ?> + + getItemHtml($_item) ?> + getItemExtraInfoHtml($_item->getOrderItem()) ?> + + +
helper('Mage_Sales_Helper_Data')->__('Product') ?>helper('Mage_Sales_Helper_Data')->__('Price') ?>helper('Mage_Sales_Helper_Data')->__('Qty') ?>helper('Mage_Sales_Helper_Data')->__('Subtotal') ?>helper('Mage_Sales_Helper_Data')->__('Tax Amount') ?>helper('Mage_Sales_Helper_Data')->__('Discount Amount') ?>helper('Mage_Sales_Helper_Data')->__('Row Total') ?>
+
diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/view/items/renderer/configurable.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/view/items/renderer/configurable.phtml new file mode 100644 index 0000000000000..4d138ce0ff2ec --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/view/items/renderer/configurable.phtml @@ -0,0 +1,235 @@ + +getItem() ?> +setPriceDataObject($_item)?> + + getColumnHtml($_item, 'configurable_name') ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Excl. Tax'); ?>: + + + typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> + displayPrices( + $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), + $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() + ); + ?> + + displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> + + + getApplied($_item)): ?> +
+ typeOfDisplay($_item, 1, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount'], $tax['amount']); ?> + + + typeOfDisplay($_item, 2, 'sales')): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales')): ?> +
+ __('Total'); ?>:
+ displayPrices( + $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), + $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() + ); + ?> +
+ + +
+
+ + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Incl. Tax'); ?>: + + helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item); ?> + helper('Mage_Checkout_Helper_Data')->getBasePriceInclTax($_item); ?> + + typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> + displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?> + + displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?> + + + getApplied($_item)): ?> +
+ typeOfDisplay($_item, 1, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount'], $tax['amount']); ?> + + + typeOfDisplay($_item, 2, 'sales')): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales')): ?> +
+ __('Total'); ?>:
displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?>
+ + +
+ + + getColumnHtml($_item, 'qty') ?> + + canEditQty()) : ?> + + + getQty()*1 ?> + + + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Excl. Tax'); ?>: + + + typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> + displayPrices( + $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), + $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() + ); + ?> + + displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> + + + getApplied($_item)): ?> + typeOfDisplay($_item, 1, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> + + + typeOfDisplay($_item, 2, 'sales')): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales')): ?> +
+ __('Total'); ?>:
+ displayPrices( + $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), + $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() + ); + ?> +
+ + +
+
+ + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Incl. Tax'); ?>: + + helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item); ?> + helper('Mage_Checkout_Helper_Data')->getBaseSubtotalInclTax($_item); ?> + typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> + displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> + + displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?> + + + getApplied($_item)): ?> + +
+ typeOfDisplay($_item, 1, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> + + + typeOfDisplay($_item, 2, 'sales')): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales')): ?> +
__('Total'); ?>:
displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmount(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
+ + +
+ + + displayPriceAttribute('tax_amount') ?> + displayPriceAttribute('discount_amount') ?> + + displayPrices( + $_item->getBaseRowTotal()+$_item->getBaseTaxAmount()-$_item->getBaseDiscountAmount()+$_item->getBaseWeeeTaxAppliedRowAmnt(), + $_item->getRowTotal()+$_item->getTaxAmount()-$_item->getDiscountAmount()+$_item->getWeeeTaxAppliedRowAmount() + ) ?> + + diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/view/items/renderer/default.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/view/items/renderer/default.phtml new file mode 100644 index 0000000000000..685e233130711 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/invoice/view/items/renderer/default.phtml @@ -0,0 +1,229 @@ + +getItem() ?> +setStoreId($_item->getInvoice()->getStoreId()) ?> +setPriceDataObject($_item) ?> + + getColumnHtml($_item, 'name') ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Excl. Tax'); ?>: + + + typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?> + displayPrices( + $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), + $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() + ); + ?> + + displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> + + + getApplied($_item)): ?> +
+ typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount'], $tax['amount']); ?> + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> +
+ __('Total'); ?>:
+ displayPrices( + $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), + $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() + ); + ?> +
+ + +
+
+ + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Incl. Tax'); ?>: + + helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item); ?> + helper('Mage_Checkout_Helper_Data')->getBasePriceInclTax($_item); ?> + + typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?> + displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?> + + displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?> + + + getApplied($_item)): ?> +
+ typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount'], $tax['amount']); ?> + + + typeOfDisplay($_item, 2, 'sales')): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> +
+ __('Total'); ?>:
displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?>
+ + +
+ + + getQty()*1 ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Excl. Tax'); ?>: + + + typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?> + displayPrices( + $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), + $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() + ); + ?> + + displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> + + + getApplied($_item)): ?> + typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> +
+ __('Total'); ?>:
+ displayPrices( + $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), + $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() + ); + ?> +
+ + +
+
+ + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Incl. Tax'); ?>: + + helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item); ?> + helper('Mage_Checkout_Helper_Data')->getBaseSubtotalInclTax($_item); ?> + typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?> + displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> + + displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?> + + + getApplied($_item)): ?> + +
+ typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> +
__('Total'); ?>:
displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
+ + +
+ + + displayPriceAttribute('tax_amount') ?> + displayPriceAttribute('discount_amount') ?> + + displayPrices( + $_item->getBaseRowTotal() + $_item->getBaseTaxAmount() + $_item->getBaseHiddenTaxAmount() + $_item->getBaseWeeeTaxAppliedRowAmnt() - $_item->getBaseDiscountAmount(), + $_item->getRowTotal() + $_item->getTaxAmount() + $_item->getHiddenTaxAmount() + $_item->getWeeeTaxAppliedRowAmount() - $_item->getDiscountAmount() + ) ?> + + diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/create/form.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/create/form.phtml new file mode 100644 index 0000000000000..bf714a4d79966 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/create/form.phtml @@ -0,0 +1,104 @@ + +
+ getBlockHtml('formkey')?> + getShipment()->getOrder() ?> + getChildHtml('order_info') ?> +
+
+ +
+
+ __('Payment Information') ?> +
+
getPaymentHtml() ?>
+
__('The order was placed using %s', $_order->getOrderCurrencyCode()) ?>
+
+
+
+ +
+
+ __('Shipping Information') ?> +
+
+
escapeHtml($_order->getShippingDescription()) ?>
+
+ helper('Mage_Sales_Helper_Data')->__('Total Shipping Charges'); ?>: + + helper('Mage_Tax_Helper_Data')->displayShippingPriceIncludingTax()): ?> + displayShippingPriceInclTax($_order); ?> + + displayPriceAttribute('shipping_amount', false, ' '); ?> + + displayShippingPriceInclTax($_order); ?> + + helper('Mage_Tax_Helper_Data')->displayShippingBothPrices() && $_incl != $_excl): ?> + (__('Incl. Tax'); ?> ) + +
+
+
getChildHtml('shipment_tracking') ?>
+
+
+
+
+ getItemsHtml() ?> +
+
+getChildHtml('shipment_packaging') ?> + diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/create/items.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/create/items.phtml new file mode 100644 index 0000000000000..ca418e6eb6503 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/create/items.phtml @@ -0,0 +1,137 @@ + +
+
+ __('Items to Ship') ?> +
+
+ + + + + + + canShipPartiallyItem()): ?> + + + + + getShipment()->getAllItems() ?> + getOrderItem()->getIsVirtual() || $_item->getOrderItem()->getParentItem()): continue; endif; $_i++ ?> + + getItemHtml($_item) ?> + getItemExtraInfoHtml($_item->getOrderItem()) ?> + + +
helper('Mage_Sales_Helper_Data')->__('Product') ?>helper('Mage_Sales_Helper_Data')->__('Qty') ?> + helper('Mage_Sales_Helper_Data')->__('Qty to Ship') ?> + helper('Mage_Sales_Helper_Data')->__('Ship') ?>
+
+
+
+
+
+
__('Shipment Comments') ?>
+
+
+ + +
+
+
+
+
+
+
+
+ getChildHtml('submit_button') ?> +
+ canCreateShippingLabel()): ?> +
+ + +
+ +
+ + +
+ canSendShipmentEmail()): ?> +
+ + +
+ +
+
+
+
+ diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/shipment/create/items/renderer/configurable.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/create/items/renderer/configurable.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/shipment/create/items/renderer/configurable.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/create/items/renderer/configurable.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/create/items/renderer/default.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/create/items/renderer/default.phtml new file mode 100644 index 0000000000000..31dd4f9482d5a --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/create/items/renderer/default.phtml @@ -0,0 +1,44 @@ + +getItem() ?> + + getColumnHtml($_item, 'name') ?> + getColumnHtml($_item, 'qty') ?> + + canShipPartiallyItem()): ?> + + + getQty()*1 ?> + + + canShipPartiallyItem()): ?> + + + + + + diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/create/tracking.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/create/tracking.phtml new file mode 100644 index 0000000000000..e30971cf6ad17 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/create/tracking.phtml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
__('Carrier') ?>__('Title') ?>__('Number') ?> *__('Action') ?>
getChildHtml('add_button') ?>
+ + __('Delete') ?>
+ diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/shipment/packaging.js b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/packaging.js similarity index 97% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/shipment/packaging.js rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/packaging.js index 6fd369e3e9935..c73488671a9e0 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/shipment/packaging.js +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/packaging.js @@ -28,6 +28,7 @@ Packaging.prototype = { * Initialize object */ initialize: function(params) { + jQuery.mage.load('validation'); this.packageIncrement = 0; this.packages = []; this.itemsAll = []; @@ -85,14 +86,35 @@ Packaging.prototype = { this.window.show().setStyle({ 'marginLeft': -this.window.getDimensions().width/2 + 'px' }); - this.windowMask.setStyle({ - height: $('html-body').getHeight() + 'px' - }).show(); + if (this.windowMask) { + this.windowMask.setStyle({ + height: $('html-body').getHeight() + 'px' + }).show(); + } else { + if( $$('.popup-window-mask')[0] ){ + $$('.popup-window-mask')[0].setStyle({ + 'display': 'block' + }); + } else { + $('html-body').insert(''); + $$('.popup-window-mask')[0].setStyle({ + height: $('html-body').getHeight() + 'px' + }); + + } + } }, cancelPackaging: function() { packaging.window.hide(); - packaging.windowMask.hide(); + if (this.windowMask) { + packaging.windowMask.hide(); + } else { + $$('.popup-window-mask')[0].setStyle({ + 'display': 'none' + }); + } + if (Object.isFunction(this.cancelCallback)) { this.cancelCallback(); } @@ -267,12 +289,13 @@ Packaging.prototype = { validateElement: function(elm) { var cn = $w(elm.className); return result = cn.all(function(value) { - var v = Validation.get(value); - if (Validation.isVisible(elm) && !v.test($F(elm), elm)) { - $(elm).addClassName('validation-failed'); + var v = jQuery.validator.methods[value], + element = jQuery(elm); + if (element.is(':visible') && !v(element.val(), elm)) { + element.addClass('mage-error'); return false; } else { - $(elm).removeClassName('validation-failed'); + element.removeClass('mage-error'); return true; } }); diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/packaging/grid.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/packaging/grid.phtml new file mode 100644 index 0000000000000..854b7065e0126 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/packaging/grid.phtml @@ -0,0 +1,89 @@ + +
+ + + + + + + + + + + + + + getCollection() as $item): ?> + getShipment()->getOrder() ?> + getItemById($item->getOrderItemId()); ?> + getIsVirtual() + || ($_orderItem->isShipSeparately() && !($_orderItem->getParentItemId() || $_orderItem->getParentItem())) + || (!$_orderItem->isShipSeparately() && ($_orderItem->getParentItemId() || $_orderItem->getParentItem()))): ?> + + + + + + displayCustomsValue()) { + $customsValueDisplay = ''; + $customsValueValidation = ' validate-zero-or-greater '; + } else { + $customsValueDisplay = ' style="display: none;" '; + $customsValueValidation = ''; + } + ?> + + + + + + + +
__('Product Name') ?>__('Weight') ?>displayCustomsValue() ? '' : 'style="display: none;"' ?>> + __('Customs Value') ?> + + + __('Qty Ordered') ?>__('Qty') ?>
+ getName(); ?> + + getWeight(); ?> + > + + + + + getOrderItem()->getQtyOrdered()*1; ?> + + +   + +
+
diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/packaging/packed.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/packaging/packed.phtml new file mode 100644 index 0000000000000..7b89aea418bd0 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/packaging/packed.phtml @@ -0,0 +1,201 @@ + + + + + diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/packaging/popup.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/packaging/popup.phtml new file mode 100644 index 0000000000000..975f7ca93e6b0 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/packaging/popup.phtml @@ -0,0 +1,217 @@ + +getShipment()->getOrder()->getShippingMethod(); +$sizeSource = Mage::getModel('Mage_Usa_Model_Shipping_Carrier_Usps_Source_Size')->toOptionArray(); +$girthEnabled = Mage::helper('Mage_Usa_Helper_Data')->displayGirthValue($shippingMethod) && $this->isGirthAllowed() ? 1 : 0; +?> + + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/shipment/tracking/info.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/tracking/info.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/shipment/tracking/info.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/tracking/info.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/view/form.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/view/form.phtml new file mode 100644 index 0000000000000..208bc798d5676 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/view/form.phtml @@ -0,0 +1,117 @@ + +getShipment()->getOrder() ?> +getChildHtml('order_info') ?> +
+
+ +
+
+ helper('Mage_Sales_Helper_Data')->__('Payment Information') ?> +
+
getChildHtml('order_payment') ?>
+
__('Order was placed using %s', $_order->getOrderCurrencyCode()) ?>
+
+
+
+ +
+
+ helper('Mage_Sales_Helper_Data')->__('Shipping and Tracking Information') ?> +
+
+ getShipment()->getTracksCollection()->count()): ?> +

+ __('Track this shipment') ?> +

+ +
escapeHtml($_order->getShippingDescription()) ?>
+ helper('Mage_Sales_Helper_Data')->__('Total Shipping Charges'); ?>: + + helper('Mage_Tax_Helper_Data')->displayShippingPriceIncludingTax()): ?> + displayShippingPriceInclTax($_order); ?> + + displayPriceAttribute('shipping_amount', false, ' '); ?> + + displayShippingPriceInclTax($_order); ?> + + + helper('Mage_Tax_Helper_Data')->displayShippingBothPrices() && $_incl != $_excl): ?> + (__('Incl. Tax'); ?> ) + +
+ canCreateShippingLabel()): ?> +

+ getCreateLabelButton()?> + getShipment()->getShippingLabel()): ?> + getPrintLabelButton() ?> + + getShipment()->getPackages()): ?> + getShowPackagesButton() ?> + +

+ +
getChildHtml('shipment_tracking') ?>
+ getChildHtml('shipment_packaging') ?> + +
+
+
+ +
+
+ helper('Mage_Sales_Helper_Data')->__('Items Shipped') ?> +
+ getChildHtml('shipment_items') ?> +
+ +
+ getChildHtml('shipment_packed') ?> + +
+
+
__('Shipment History') ?>
+
getChildHtml('order_comments') ?>
+
+
+
diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/view/items.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/view/items.phtml new file mode 100644 index 0000000000000..750508df0da97 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/view/items.phtml @@ -0,0 +1,43 @@ + +
+ + + + + + + + getShipment()->getAllItems() ?> + getOrderItem()->getIsVirtual() || $_item->getOrderItem()->getParentItem()): continue; endif; $_i++ ?> + + getItemHtml($_item) ?> + getItemExtraInfoHtml($_item->getOrderItem()) ?> + + +
helper('Mage_Sales_Helper_Data')->__('Product') ?>helper('Mage_Sales_Helper_Data')->__('Qty Shipped') ?>
+
diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/view/items/renderer/configurable.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/view/items/renderer/configurable.phtml new file mode 100644 index 0000000000000..ac8d0fab4e5eb --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/view/items/renderer/configurable.phtml @@ -0,0 +1,31 @@ + +getItem() ?> + + getColumnHtml($_item, 'configurable_name') ?> + getQty()*1 ?> + diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/view/items/renderer/default.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/view/items/renderer/default.phtml new file mode 100644 index 0000000000000..476266b254645 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/view/items/renderer/default.phtml @@ -0,0 +1,31 @@ + +getItem() ?> + + getColumnHtml($_item, 'name') ?> + getQty()*1 ?> + diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/view/tracking.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/view/tracking.phtml new file mode 100644 index 0000000000000..aa160a68a3934 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/view/tracking.phtml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + +getShipment()->getAllTracks()): ?> + + + + + + + + + + + +
__('Carrier') ?>__('Title') ?>__('Number') ?>__('Action') ?>
+ + getSaveButtonHtml() ?>
escapeHtml($this->getCarrierTitle($_track->getCarrierCode())) ?>escapeHtml($_track->getTitle()) ?> + isCustom()): ?> + escapeHtml($_track->getNumber()) ?> + + escapeHtml($_track->getNumber()) ?> +
+ +
__('Delete') ?>
+ diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/totalbar.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/totalbar.phtml new file mode 100644 index 0000000000000..d1e4c00bb50ee --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/totalbar.phtml @@ -0,0 +1,38 @@ + +getTotals()) > 0 ): ?> + + + getTotals() as $_total ): ?> + + + +
class="grand-total"> +
+ +
+ diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals.phtml new file mode 100644 index 0000000000000..3a917097edd22 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals.phtml @@ -0,0 +1,84 @@ + +getSource(); ?> +setPriceDataObject($_source) ?> + + + getChildHtml('main'); ?> + getChildHtml('footer'); ?> +
+ + + getTotals('footer')?> + + + getTotals('footer') as $_code => $_total): ?> + getBlockName()): ?> + getChildHtml($_total->getBlockName(), false); ?> + + + + + + + + + + + getTotals('')?> + + + $_total): ?> + getBlockName()): ?> + getChildHtml($_total->getBlockName(), false); ?> + + + + getStrong()):?> + + + + + + +
getLabelProperties()?> class="label"> + escapeHtml($_total->getLabel()); ?> + getValueProperties()?>> + formatValue($_total) ?> +
getLabelProperties()?> class="label"> + getStrong()):?> + escapeHtml($_total->getLabel()); ?> + + escapeHtml($_total->getLabel()); ?> + + getValueProperties()?>> + formatValue($_total) ?> + + getValueProperties()?>> + formatValue($_total) ?> + +
diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/totals/discount.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals/discount.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/totals/discount.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals/discount.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/totals/due.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals/due.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/totals/due.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals/due.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/totals/footer.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals/footer.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/totals/footer.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals/footer.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/totals/grand.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals/grand.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/totals/grand.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals/grand.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/totals/item.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals/item.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/totals/item.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals/item.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/totals/main.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals/main.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/totals/main.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals/main.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/totals/paid.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals/paid.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/totals/paid.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals/paid.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/totals/refunded.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals/refunded.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/totals/refunded.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals/refunded.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/totals/shipping.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals/shipping.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/totals/shipping.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals/shipping.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/totals/tax.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals/tax.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/totals/tax.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/totals/tax.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/view/form.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/form.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/view/form.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/form.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/view/giftmessage.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/giftmessage.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/view/giftmessage.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/giftmessage.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/history.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/history.phtml new file mode 100644 index 0000000000000..55b011c85ca49 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/history.phtml @@ -0,0 +1,81 @@ + +
+ canAddComment()):?> +
+
__('Add Order Comments') ?>
+
+ + +
+
+ + +
+
+
+ canSendCommentEmail()): ?> +
+ + +
+
+ getChildHtml('submit_button') ?> +
+
+
+ +
    + getOrder()->getStatusHistoryCollection(true) as $_item): ?> +
  • + helper('Mage_Core_Helper_Data')->formatDate($_item->getCreatedAtDate(), 'medium') ?> + helper('Mage_Core_Helper_Data')->formatTime($_item->getCreatedAtDate(), 'medium') ?> + getStatusLabel() ?> + + helper('Mage_Sales_Helper_Data')->__('Customer') ?> + isCustomerNotificationNotApplicable($_item)): ?> + helper('Mage_Sales_Helper_Data')->__('Notification Not Applicable') ?> + getIsCustomerNotified()): ?> + helper('Mage_Sales_Helper_Data')->__('Notified') ?> + + helper('Mage_Sales_Helper_Data')->__('Not Notified') ?> + + + getComment()): ?> +
    escapeHtml($_item->getComment(), array('b','br','strong','i','u')) ?>
    + +
  • + +
+ +
diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/info.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/info.phtml new file mode 100644 index 0000000000000..ba159930e118c --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/info.phtml @@ -0,0 +1,176 @@ + +getOrder() ?> +formatDate($_order->getCreatedAtDate(), 'medium', true); +$orderStoreDate = $this->formatDate($_order->getCreatedAtStoreDate(), 'medium', true); +?> +
+
+ +
+ getEmailSent()): + $_email = Mage::helper('Mage_Sales_Helper_Data')->__('the order confirmation email was sent'); + else: + $_email = Mage::helper('Mage_Sales_Helper_Data')->__('the order confirmation email is not sent'); + endif; ?> +
+ + getNoUseOrderLink()): ?> + __('Order # %s', $_order->getRealOrderId()) ?> () + + __('Order # %s', $_order->getRealOrderId()) ?> + () + + +
+ + + + + + + + + + + + + + + + isSingleStoreMode() == false):?> + + + + + + getRelationChildId()): ?> + + + + + + getRelationParentId()): ?> + + + + + + getRemoteIp() && $this->shouldDisplayCustomerIp()): ?> + + + + + + getGlobalCurrencyCode() != $_order->getBaseCurrencyCode()): ?> + + + + + + getBaseCurrencyCode() != $_order->getOrderCurrencyCode()): ?> + + + + +
__('Order Date') ?>
__('Order Date (%s)', $_order->getCreatedAtStoreDate()->getTimezone()) ?>
__('Order Status') ?>getStatusLabel() ?>
__('Purchased From') ?>getOrderStoreName() ?>
__('Link to the New Order') ?> + getRelationChildRealId() ?> +
__('Link to the Previous Order') ?> + getRelationParentRealId() ?> +
__('Placed from IP') ?>getRemoteIp(); echo ($_order->getXForwardedFor())?' (' . $this->escapeHtml($_order->getXForwardedFor()) . ')':''; ?>
__('%s / %s rate:', $_order->getGlobalCurrencyCode(), $_order->getBaseCurrencyCode()) ?>getBaseToGlobalRate() ?>
__('%s / %s rate:', $_order->getOrderCurrencyCode(), $_order->getBaseCurrencyCode()) ?>getBaseToOrderRate() ?> +
+
+
+ + +
+ +
+
+ +
+
+ isAllowed('Mage_Sales::actions_edit')) : ?> +
getAddressEditLink($_order->getBillingAddress()); ?>
+ + __('Billing Address') ?> +
+
getBillingAddress()->format('html') ?>
+
+
+ getOrder()->getIsVirtual()): ?> +
+ +
+
+ isAllowed('Mage_Sales::actions_edit')) : ?> +
getAddressEditLink($_order->getShippingAddress()); ?>
+ + __('Shipping Address') ?> +
+
getShippingAddress()->format('html') ?>
+
+
+
+ diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/items.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/items.phtml new file mode 100644 index 0000000000000..19da1af8078da --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/items.phtml @@ -0,0 +1,53 @@ + +getOrder() ?> +
+ + + + + + + + + + + + + + + + getItemsCollection() ?> + + getParentItem()) continue; else $i++;?> + + getItemHtml($_item) ?> + getItemExtraInfoHtml($_item) ?> + + +
helper('Mage_Sales_Helper_Data')->__('Product') ?>helper('Mage_Sales_Helper_Data')->__('Item Status') ?>helper('Mage_Sales_Helper_Data')->__('Original Price') ?>helper('Mage_Sales_Helper_Data')->__('Price') ?>helper('Mage_Sales_Helper_Data')->__('Qty') ?>helper('Mage_Sales_Helper_Data')->__('Subtotal') ?>helper('Mage_Sales_Helper_Data')->__('Tax Amount') ?>helper('Mage_Sales_Helper_Data')->__('Tax Percent') ?>helper('Mage_Sales_Helper_Data')->__('Discount Amount') ?>helper('Mage_Sales_Helper_Data')->__('Row Total') ?>
+
diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/items/renderer/default.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/items/renderer/default.phtml new file mode 100644 index 0000000000000..0e85d2ffbf793 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/items/renderer/default.phtml @@ -0,0 +1,240 @@ + +getItem() ?> +setPriceDataObject($_item) ?> + + + canDisplayContainer()): ?> +
+ + getColumnHtml($_item, 'name') ?> + canDisplayContainer()): ?> +
+ + + getStatus() ?> + displayPriceAttribute('original_price') ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> +
+ helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Excl. Tax'); ?>: + + + typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?> + displayPrices( + $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), + $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() + ); + ?> + + displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> + + + getApplied($_item)): ?> +
+ typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount'], $tax['amount']); ?> + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> +
+ __('Total'); ?>:
+ displayPrices( + $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), + $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() + ); + ?> +
+ + +
+ + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> +
+ helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Incl. Tax'); ?>: + + helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item); ?> + helper('Mage_Checkout_Helper_Data')->getBasePriceInclTax($_item); ?> + + typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?> + displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?> + + displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?> + + + getApplied($_item)): ?> +
+ typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount'], $tax['amount']); ?> + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> +
+ __('Total'); ?>:
displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?>
+ + +
+ + + getColumnHtml($_item, 'qty') ?> + + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> +
+ helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Excl. Tax'); ?>: + + + typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?> + displayPrices( + $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), + $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() + ); + ?> + + displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> + + + + getApplied($_item)): ?> + typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> +
+ __('Total'); ?>:
+ displayPrices( + $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), + $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() + ); + ?> +
+ + +
+ + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> +
+ helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + __('Incl. Tax'); ?>: + + helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item); ?> + helper('Mage_Checkout_Helper_Data')->getBaseSubtotalInclTax($_item); ?> + typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?> + displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> + + displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?> + + + + getApplied($_item)): ?> + +
+ typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?> + + getApplied($_item) as $tax): ?> + : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> + + + + + typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?> +
__('Total'); ?>:
displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
+ + +
+ + + displayPriceAttribute('tax_amount') ?> + displayTaxPercent($_item) ?> + displayPriceAttribute('discount_amount') ?> + + displayPrices( + $_item->getBaseRowTotal() + $_item->getBaseTaxAmount() + $_item->getBaseHiddenTaxAmount() + $_item->getBaseWeeeTaxAppliedRowAmnt() - $_item->getBaseDiscountAmount(), + $_item->getRowTotal() + $_item->getTaxAmount() + $_item->getHiddenTaxAmount() + $_item->getWeeeTaxAppliedRowAmount() - $_item->getDiscountAmount() + ); ?> + + diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/tab/history.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/tab/history.phtml new file mode 100644 index 0000000000000..891f5e1ad31b7 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/tab/history.phtml @@ -0,0 +1,52 @@ + +
+
    + getFullHistory() as $_item): ?> +
  • + getItemCreatedAt($_item) ?> + getItemCreatedAt($_item, 'time') ?> + getItemTitle($_item) ?> + isItemNotified($_item, false)): ?> + + helper('Mage_Sales_Helper_Data')->__('Customer') ?> + isCustomerNotificationNotApplicable($_item)): ?> + helper('Mage_Sales_Helper_Data')->__('Notification Not Applicable') ?> + isItemNotified($_item)): ?> + helper('Mage_Sales_Helper_Data')->__('Notified') ?> + + helper('Mage_Sales_Helper_Data')->__('Not Notified') ?> + + + + getItemComment($_item)): ?> +
    + +
  • + +
+
diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/tab/info.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/tab/info.phtml new file mode 100644 index 0000000000000..595498c8d6247 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/tab/info.phtml @@ -0,0 +1,132 @@ + + +getOrder() ?> +
+ getChildHtml('order_messages') ?> +
+ getChildHtml('order_info') ?> + +getIsVirtual()): ?> +
+ +
+ +
+
+ __('Payment Information') ?> +
+
getPaymentHtml() ?>
+
__('Order was placed using %s', $_order->getOrderCurrencyCode()) ?>
+
+
+ getIsVirtual()): ?> +
+ +
+
+ __('Shipping & Handling Information') ?> +
+
+ getTracksCollection()->count()) : ?> +

__('Track Order') ?>

+ + getShippingDescription()): ?> + escapeHtml($_order->getShippingDescription()) ?> + + helper('Mage_Tax_Helper_Data')->displayShippingPriceIncludingTax()): ?> + displayShippingPriceInclTax($_order); ?> + + displayPriceAttribute('shipping_amount', false, ' '); ?> + + displayShippingPriceInclTax($_order); ?> + + + helper('Mage_Tax_Helper_Data')->displayShippingBothPrices() && $_incl != $_excl): ?> + (__('Incl. Tax'); ?> ) + + + helper('Mage_Sales_Helper_Data')->__('No shipping information available'); ?> + +
+
+
+ +getIsVirtual()): ?> +
+ + getGiftOptionsHtml() ?> +
+
+ __('Items Ordered') ?> +
+ getItemsHtml() ?> +
+
+
+
+
+ __('Comments History') ?> +
+
getChildHtml('order_history') ?>
+
+
+
+
+
+ __('Order Totals') ?> +
+ getChildHtml('order_totals') ?> +
+
+
+getChildHtml('popup_window');?> + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/view/tracking.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/tracking.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/view/tracking.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/sales/order/view/tracking.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/sales/transactions/detail.phtml b/app/code/Mage/Adminhtml/view/adminhtml/sales/transactions/detail.phtml new file mode 100644 index 0000000000000..c2fac58c84a34 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/sales/transactions/detail.phtml @@ -0,0 +1,92 @@ + +
getButtonsHtml() ?>
+
+
+ __('Transaction Data'); ?> +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
__('Transaction ID'); ?>getTxnIdHtml() ?>
__('Parent Transaction ID'); ?> + getParentTxnIdHtml()): ?> + + getParentTxnIdHtml(); ?> + + + __('N/A'); ?> + +
__('Order ID'); ?> + + getOrderIncrementIdHtml() ?> + +
__('Transaction Type'); ?>getTxnTypeHtml() ?>
__('Is Closed'); ?>getIsClosedHtml(); ?>
__('Created At'); ?>getCreatedAtHtml(); ?>
+
+
+ +
+
+ __('Child Transactions'); ?> +
+
+ getChildHtml('child_grid') ?> +
+
+ +
+
+ __('Transaction Details'); ?> +
+
+ getChildHtml('detail_grid') ?> +
+
diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/search.xml b/app/code/Mage/Adminhtml/view/adminhtml/search.xml similarity index 88% rename from app/code/core/Mage/Adminhtml/view/adminhtml/search.xml rename to app/code/Mage/Adminhtml/view/adminhtml/search.xml index dcc63cd8cf63c..40b7ececa93fb 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/search.xml +++ b/app/code/Mage/Adminhtml/view/adminhtml/search.xml @@ -80,16 +80,19 @@
ID
- 50px 0 query_id number + col-id + col-id
Search Query
query_text + col-query + col-query
@@ -99,24 +102,26 @@ store 1 0 + col-store + col-store
Results
- 50px - right number num_results + col-results + col-results
Hits
- 50px - right number popularity + col-hits + col-hits
diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/store/switcher/enhanced.phtml b/app/code/Mage/Adminhtml/view/adminhtml/store/switcher/enhanced.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/store/switcher/enhanced.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/store/switcher/enhanced.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/system/autocomplete.phtml b/app/code/Mage/Adminhtml/view/adminhtml/system/autocomplete.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/system/autocomplete.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/system/autocomplete.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/system/cache/additional.phtml b/app/code/Mage/Adminhtml/view/adminhtml/system/cache/additional.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/system/cache/additional.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/system/cache/additional.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/system/cache/edit.phtml b/app/code/Mage/Adminhtml/view/adminhtml/system/cache/edit.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/system/cache/edit.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/system/cache/edit.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/system/cache/notifications.phtml b/app/code/Mage/Adminhtml/view/adminhtml/system/cache/notifications.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/system/cache/notifications.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/system/cache/notifications.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/system/currency/rate/matrix.phtml b/app/code/Mage/Adminhtml/view/adminhtml/system/currency/rate/matrix.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/system/currency/rate/matrix.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/system/currency/rate/matrix.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/system/currency/rate/services.phtml b/app/code/Mage/Adminhtml/view/adminhtml/system/currency/rate/services.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/system/currency/rate/services.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/system/currency/rate/services.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/system/currency/rates.phtml b/app/code/Mage/Adminhtml/view/adminhtml/system/currency/rates.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/system/currency/rates.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/system/currency/rates.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/system/design/design.xml b/app/code/Mage/Adminhtml/view/adminhtml/system/design/design.xml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/system/design/design.xml rename to app/code/Mage/Adminhtml/view/adminhtml/system/design/design.xml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/system/design/edit.phtml b/app/code/Mage/Adminhtml/view/adminhtml/system/design/edit.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/system/design/edit.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/system/design/edit.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/system/design/index.phtml b/app/code/Mage/Adminhtml/view/adminhtml/system/design/index.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/system/design/index.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/system/design/index.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/system/email/template.xml b/app/code/Mage/Adminhtml/view/adminhtml/system/email/template.xml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/system/email/template.xml rename to app/code/Mage/Adminhtml/view/adminhtml/system/email/template.xml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/system/email/template/edit.phtml b/app/code/Mage/Adminhtml/view/adminhtml/system/email/template/edit.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/system/email/template/edit.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/system/email/template/edit.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/system/email/template/list.phtml b/app/code/Mage/Adminhtml/view/adminhtml/system/email/template/list.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/system/email/template/list.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/system/email/template/list.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/system/email/template/preview.phtml b/app/code/Mage/Adminhtml/view/adminhtml/system/email/template/preview.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/system/email/template/preview.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/system/email/template/preview.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/system/info.phtml b/app/code/Mage/Adminhtml/view/adminhtml/system/info.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/system/info.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/system/info.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/system/shipping/applicable_country.phtml b/app/code/Mage/Adminhtml/view/adminhtml/system/shipping/applicable_country.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/system/shipping/applicable_country.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/system/shipping/applicable_country.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/system/shipping/ups.phtml b/app/code/Mage/Adminhtml/view/adminhtml/system/shipping/ups.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/system/shipping/ups.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/system/shipping/ups.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/system/store/store.xml b/app/code/Mage/Adminhtml/view/adminhtml/system/store/store.xml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/system/store/store.xml rename to app/code/Mage/Adminhtml/view/adminhtml/system/store/store.xml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/system/variable/js.phtml b/app/code/Mage/Adminhtml/view/adminhtml/system/variable/js.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/system/variable/js.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/system/variable/js.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/tax.xml b/app/code/Mage/Adminhtml/view/adminhtml/tax.xml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/tax.xml rename to app/code/Mage/Adminhtml/view/adminhtml/tax.xml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/tax/class/page/edit.phtml b/app/code/Mage/Adminhtml/view/adminhtml/tax/class/page/edit.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/tax/class/page/edit.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/tax/class/page/edit.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/tax/importExport.phtml b/app/code/Mage/Adminhtml/view/adminhtml/tax/importExport.phtml similarity index 82% rename from app/code/core/Mage/Adminhtml/view/adminhtml/tax/importExport.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/tax/importExport.phtml index a33297ae92ccd..304de083a57a1 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/tax/importExport.phtml +++ b/app/code/Mage/Adminhtml/view/adminhtml/tax/importExport.phtml @@ -27,14 +27,18 @@
getIsReadonly()): ?>
-
+ getUseContainer()): ?> + + getBlockHtml('formkey')?>
__('Import Tax Rates') ?> getButtonHtml('Import Tax Rates', '', 'import-submit') ?>
+ getUseContainer()): ?>
+
-
-
+
+ getUseContainer()): ?> + + getBlockHtml('formkey')?>
__('Export Tax Rates') ?> getButtonHtml('Export Tax Rates', "this.form.submit()") ?>
+ getUseContainer()): ?> +
diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/tax/importExportHeader.phtml b/app/code/Mage/Adminhtml/view/adminhtml/tax/importExportHeader.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/tax/importExportHeader.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/tax/importExportHeader.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/tax/rate/form.phtml b/app/code/Mage/Adminhtml/view/adminhtml/tax/rate/form.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/tax/rate/form.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/tax/rate/form.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/tax/rate/title.phtml b/app/code/Mage/Adminhtml/view/adminhtml/tax/rate/title.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/tax/rate/title.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/tax/rate/title.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/tax/rule/edit.phtml b/app/code/Mage/Adminhtml/view/adminhtml/tax/rule/edit.phtml new file mode 100644 index 0000000000000..3790e914fefb0 --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/tax/rule/edit.phtml @@ -0,0 +1,272 @@ + + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/tax/rule/rate/form.phtml b/app/code/Mage/Adminhtml/view/adminhtml/tax/rule/rate/form.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/tax/rule/rate/form.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/tax/rule/rate/form.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/tax/toolbar/class/add.phtml b/app/code/Mage/Adminhtml/view/adminhtml/tax/toolbar/class/add.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/tax/toolbar/class/add.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/tax/toolbar/class/add.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/tax/toolbar/class/save.phtml b/app/code/Mage/Adminhtml/view/adminhtml/tax/toolbar/class/save.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/tax/toolbar/class/save.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/tax/toolbar/class/save.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/tax/toolbar/rate/add.phtml b/app/code/Mage/Adminhtml/view/adminhtml/tax/toolbar/rate/add.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/tax/toolbar/rate/add.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/tax/toolbar/rate/add.phtml diff --git a/app/code/Mage/Adminhtml/view/adminhtml/tax/toolbar/rate/save.phtml b/app/code/Mage/Adminhtml/view/adminhtml/tax/toolbar/rate/save.phtml new file mode 100644 index 0000000000000..439da98cc47ea --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/tax/toolbar/rate/save.phtml @@ -0,0 +1,68 @@ + +
+ getBackButtonHtml(); ?> + getResetButtonHtml(); ?> + getDeleteButtonHtml(); ?> + getSaveButtonHtml(); ?> +
+ +toHtml();?> + + + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/tax/toolbar/rule/add.phtml b/app/code/Mage/Adminhtml/view/adminhtml/tax/toolbar/rule/add.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/tax/toolbar/rule/add.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/tax/toolbar/rule/add.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/tax/toolbar/rule/save.phtml b/app/code/Mage/Adminhtml/view/adminhtml/tax/toolbar/rule/save.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/tax/toolbar/rule/save.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/tax/toolbar/rule/save.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/urlrewrite.xml b/app/code/Mage/Adminhtml/view/adminhtml/urlrewrite.xml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/urlrewrite.xml rename to app/code/Mage/Adminhtml/view/adminhtml/urlrewrite.xml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/urlrewrite/categories.phtml b/app/code/Mage/Adminhtml/view/adminhtml/urlrewrite/categories.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/urlrewrite/categories.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/urlrewrite/categories.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/urlrewrite/edit.phtml b/app/code/Mage/Adminhtml/view/adminhtml/urlrewrite/edit.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/urlrewrite/edit.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/urlrewrite/edit.phtml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/urlrewrite/selector.phtml b/app/code/Mage/Adminhtml/view/adminhtml/urlrewrite/selector.phtml similarity index 96% rename from app/code/core/Mage/Adminhtml/view/adminhtml/urlrewrite/selector.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/urlrewrite/selector.phtml index 1737a33b5c8de..13f2042d34d08 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/urlrewrite/selector.phtml +++ b/app/code/Mage/Adminhtml/view/adminhtml/urlrewrite/selector.phtml @@ -32,7 +32,7 @@ ?>
-
+
getUrl('*/*/*')?> diff --git a/app/code/Mage/Adminhtml/view/adminhtml/validation-rules.js b/app/code/Mage/Adminhtml/view/adminhtml/validation-rules.js new file mode 100644 index 0000000000000..bc71504aa854f --- /dev/null +++ b/app/code/Mage/Adminhtml/view/adminhtml/validation-rules.js @@ -0,0 +1,70 @@ +/** + * Adminhtml client side validation rules + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Adminhtml + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +(function ($) { + //validation for selected input type + $.validator.addMethod('required-option-select', function(v, elm) { + if (elm.getValue() === '') { + return false; + } + return true; + }, 'Select type of option'); + $.validator.addMethod('required-option-select-type-rows', function(v, elm) { + var optionContainerElm = $(elm).closest('.form-list'); + var selectTypesFlag = false; + selectTypeElements = optionContainerElm.find('.select-type-title'); + selectTypeElements.each(function(i, element){ + if ($(element).prop('id') && $(element).closest('tr').is(':visible')) { + selectTypesFlag = true; + } + }); + elm.advaiceContainer = optionContainerElm.prop('id') + '_advice'; + return selectTypesFlag; + }, 'Please add rows to option.'); + + $.validator.addMethod('validate-rating', function(v) { + var ratings = $('#detailed_rating').find('.field-rating'); + var inputs; + var error = 1; + + ratings.each(function(i, rating) { + if (i > 0) { + inputs = $(rating).find('input'); + + inputs.each(function(j, input) { + if ($(input).is(':checked')) { + error = 0; + } + }); + + if (error == 1) { + return false; + } + } + }); + return !error; + }, 'Please select one of each ratings above'); +})(jQuery); \ No newline at end of file diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/variable.xml b/app/code/Mage/Adminhtml/view/adminhtml/variable.xml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/variable.xml rename to app/code/Mage/Adminhtml/view/adminhtml/variable.xml diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/variables.js b/app/code/Mage/Adminhtml/view/adminhtml/variables.js similarity index 76% rename from app/code/core/Mage/Adminhtml/view/adminhtml/variables.js rename to app/code/Mage/Adminhtml/view/adminhtml/variables.js index 9859562360d49..51db9734a64ec 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/variables.js +++ b/app/code/Mage/Adminhtml/view/adminhtml/variables.js @@ -47,13 +47,13 @@ var Variables = { openVariableChooser: function(variables) { if (this.variablesContent == null && variables) { - this.variablesContent = '
    '; + this.variablesContent = '
      '; variables.each(function(variableGroup) { if (variableGroup.label && variableGroup.value) { this.variablesContent += '
    • ' + variableGroup.label + '
    • '; (variableGroup.value).each(function(variable){ if (variable.value && variable.label) { - this.variablesContent += '
    • ' + + this.variablesContent += '
    • ' + this.prepareVariableRow(variable.value, variable.label) + '
    • '; } }.bind(this)); @@ -66,42 +66,28 @@ var Variables = { } }, openDialogWindow: function(variablesContent) { - if ($(this.dialogWindowId) && typeof(Windows) != 'undefined') { - Windows.focus(this.dialogWindowId); - return; - } + var windowId = this.dialogWindowId; + jQuery('body').append('
      '+ Variables.variablesContent +'
      '); + jQuery('#' + windowId).dialog({ + autoOpen: false, + title: "Insert Variable...", + modal: true, + resizable: false, + minWidth: 500, + close: function(event, ui) { + jQuery(this).dialog('destroy'); + jQuery('#' + windowId).remove(); + } + }); - this.overlayShowEffectOptions = Windows.overlayShowEffectOptions; - this.overlayHideEffectOptions = Windows.overlayHideEffectOptions; - Windows.overlayShowEffectOptions = {duration:0}; - Windows.overlayHideEffectOptions = {duration:0}; + jQuery('#' + windowId).dialog('open'); - this.dialogWindow = Dialog.info(variablesContent, { - draggable:true, - resizable:true, - closable:true, - className:"magento", - windowClassName:"popup-window", - title:'Insert Variable...', - width:700, - //height:270, - zIndex:1000, - recenterAuto:false, - hideEffect:Element.hide, - showEffect:Element.show, - id:this.dialogWindowId, - onClose: this.closeDialogWindow.bind(this) - }); variablesContent.evalScripts.bind(variablesContent).defer(); }, closeDialogWindow: function(window) { - if (!window) { - window = this.dialogWindow; - } - if (window) { - window.close(); - Windows.overlayShowEffectOptions = this.overlayShowEffectOptions; - Windows.overlayHideEffectOptions = this.overlayHideEffectOptions; + var windowId = this.dialogWindowId; + if(jQuery('#' + windowId).length){ + jQuery('#' + windowId).dialog('close'); } }, prepareVariableRow: function(varValue, varLabel) { @@ -110,7 +96,8 @@ var Variables = { return content; }, insertVariable: function(value) { - this.closeDialogWindow(this.dialogWindow); + var windowId = this.dialogWindowId; + jQuery('#' + windowId).dialog('close'); var textareaElm = $(this.textareaElementId); if (textareaElm) { var scrollPos = textareaElm.scrollTop; diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/widget/tabshoriz.phtml b/app/code/Mage/Adminhtml/view/adminhtml/widget/tabshoriz.phtml similarity index 96% rename from app/code/core/Mage/Adminhtml/view/adminhtml/widget/tabshoriz.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/widget/tabshoriz.phtml index e44fa7a011105..cb0a7730309b6 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/widget/tabshoriz.phtml +++ b/app/code/Mage/Adminhtml/view/adminhtml/widget/tabshoriz.phtml @@ -39,7 +39,7 @@ - + getTabLabel($_tab) ?> diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/widget/tabsleft.phtml b/app/code/Mage/Adminhtml/view/adminhtml/widget/tabsleft.phtml similarity index 100% rename from app/code/core/Mage/Adminhtml/view/adminhtml/widget/tabsleft.phtml rename to app/code/Mage/Adminhtml/view/adminhtml/widget/tabsleft.phtml diff --git a/app/code/core/Mage/Api/Controller/Action.php b/app/code/Mage/Api/Controller/Action.php similarity index 100% rename from app/code/core/Mage/Api/Controller/Action.php rename to app/code/Mage/Api/Controller/Action.php diff --git a/app/code/Mage/Api/Exception.php b/app/code/Mage/Api/Exception.php new file mode 100644 index 0000000000000..e2529626cd021 --- /dev/null +++ b/app/code/Mage/Api/Exception.php @@ -0,0 +1,53 @@ + + */ +class Mage_Api_Exception extends Mage_Core_Exception +{ + protected $_customMessage = null; + + public function __construct($faultCode, $customMessage = null) + { + parent::__construct($faultCode); + $this->_customMessage = $customMessage; + } + + /** + * Custom error message, if error is not in api. + * + * @return unknown + */ + public function getCustomMessage() + { + return $this->_customMessage; + } +} // Class Mage_Api_Model_Resource_Exception End diff --git a/app/code/core/Mage/Api/Helper/Data.php b/app/code/Mage/Api/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Api/Helper/Data.php rename to app/code/Mage/Api/Helper/Data.php diff --git a/app/code/core/Mage/Api/Model/Acl.php b/app/code/Mage/Api/Model/Acl.php similarity index 100% rename from app/code/core/Mage/Api/Model/Acl.php rename to app/code/Mage/Api/Model/Acl.php diff --git a/app/code/core/Mage/Api/Model/Acl/Resource.php b/app/code/Mage/Api/Model/Acl/Resource.php similarity index 100% rename from app/code/core/Mage/Api/Model/Acl/Resource.php rename to app/code/Mage/Api/Model/Acl/Resource.php diff --git a/app/code/core/Mage/Api/Model/Acl/Role.php b/app/code/Mage/Api/Model/Acl/Role.php similarity index 100% rename from app/code/core/Mage/Api/Model/Acl/Role.php rename to app/code/Mage/Api/Model/Acl/Role.php diff --git a/app/code/core/Mage/Api/Model/Acl/Role/Generic.php b/app/code/Mage/Api/Model/Acl/Role/Generic.php similarity index 100% rename from app/code/core/Mage/Api/Model/Acl/Role/Generic.php rename to app/code/Mage/Api/Model/Acl/Role/Generic.php diff --git a/app/code/core/Mage/Api/Model/Acl/Role/Group.php b/app/code/Mage/Api/Model/Acl/Role/Group.php similarity index 100% rename from app/code/core/Mage/Api/Model/Acl/Role/Group.php rename to app/code/Mage/Api/Model/Acl/Role/Group.php diff --git a/app/code/core/Mage/Api/Model/Acl/Role/Registry.php b/app/code/Mage/Api/Model/Acl/Role/Registry.php similarity index 100% rename from app/code/core/Mage/Api/Model/Acl/Role/Registry.php rename to app/code/Mage/Api/Model/Acl/Role/Registry.php diff --git a/app/code/core/Mage/Api/Model/Acl/Role/User.php b/app/code/Mage/Api/Model/Acl/Role/User.php similarity index 100% rename from app/code/core/Mage/Api/Model/Acl/Role/User.php rename to app/code/Mage/Api/Model/Acl/Role/User.php diff --git a/app/code/Mage/Api/Model/Cache/Type.php b/app/code/Mage/Api/Model/Cache/Type.php new file mode 100644 index 0000000000000..b5629c02fef7a --- /dev/null +++ b/app/code/Mage/Api/Model/Cache/Type.php @@ -0,0 +1,51 @@ +get(self::TYPE_IDENTIFIER), self::CACHE_TAG); + } +} diff --git a/app/code/Mage/Api/Model/Config.php b/app/code/Mage/Api/Model/Config.php new file mode 100644 index 0000000000000..efd9819347080 --- /dev/null +++ b/app/code/Mage/Api/Model/Config.php @@ -0,0 +1,292 @@ + + */ +class Mage_Api_Model_Config extends Varien_Simplexml_Config +{ + /** + * Constructor + * + * @see Varien_Simplexml_Config + */ + public function __construct($sourceData=null) + { + $this->setCacheId('config_api'); + $this->setCacheTags(array(Mage_Api_Model_Cache_Type::CACHE_TAG)); + + parent::__construct($sourceData); + $this->_construct(); + } + + /** + * Init configuration for webservices api + * + * @return Mage_Api_Model_Config + */ + protected function _construct() + { + if (Mage::app()->useCache(Mage_Api_Model_Cache_Type::TYPE_IDENTIFIER)) { + if ($this->loadCache()) { + return $this; + } + } + + $config = Mage::getSingleton('Mage_Core_Model_Config_Modules_Reader')->loadModulesConfiguration('api.xml'); + $this->setXml($config->getNode('api')); + + if (Mage::app()->useCache(Mage_Api_Model_Cache_Type::TYPE_IDENTIFIER)) { + $this->saveCache(); + } + return $this; + } + + /** + * Retrieve adapter aliases from config. + * + * @return array + */ + public function getAdapterAliases() + { + $aliases = array(); + + foreach ($this->getNode('adapter_aliases')->children() as $alias => $adapter) { + $aliases[$alias] = array( + (string) $adapter->suggest_class, // model class name + (string) $adapter->suggest_method // model method name + ); + } + return $aliases; + } + + /** + * Retrieve all adapters + * + * @return array + */ + public function getAdapters() + { + $adapters = array(); + foreach ($this->getNode('adapters')->children() as $adapterName => $adapter) { + /* @var $adapter Varien_SimpleXml_Element */ + if (isset($adapter->use)) { + $adapter = $this->getNode('adapters/' . (string) $adapter->use); + } + $adapters[$adapterName] = $adapter; + } + return $adapters; + } + + /** + * Retrieve active adapters + * + * @return array + */ + public function getActiveAdapters() + { + $adapters = array(); + foreach ($this->getAdapters() as $adapterName => $adapter) { + if (!isset($adapter->active) || $adapter->active == '0') { + continue; + } + + if (isset($adapter->required) && isset($adapter->required->extensions)) { + foreach ($adapter->required->extensions->children() as $extension=>$data) { + if (!extension_loaded($extension)) { + continue; + } + } + } + + $adapters[$adapterName] = $adapter; + } + + return $adapters; + } + + /** + * Retrieve handlers + * + * @return Varien_Simplexml_Element + */ + public function getHandlers() + { + return $this->getNode('handlers')->children(); + } + + /** + * Retrieve resources + * + * @return Varien_Simplexml_Element + */ + public function getResources() + { + return $this->getNode('resources')->children(); + } + + /** + * Retrieve resources alias + * + * @return Varien_Simplexml_Element + */ + public function getResourcesAlias() + { + return $this->getNode('resources_alias')->children(); + } + + + /** + * Load Acl resources from config + * + * @param Mage_Api_Model_Acl $acl + * @param Mage_Core_Model_Config_Element $resource + * @param string $parentName + * @return Mage_Api_Model_Config + */ + public function loadAclResources(Mage_Api_Model_Acl $acl, $resource=null, $parentName=null) + { + $resourceName = null; + if (is_null($resource)) { + $resource = $this->getNode('acl/resources'); + } else { + $resourceName = (is_null($parentName) ? '' : $parentName.'/').$resource->getName(); + $acl->addResource( + Mage::getModel('Mage_Api_Model_Acl_Resource', array('resourceId' => $resourceName)), + $parentName + ); + } + + $children = $resource->children(); + + if (empty($children)) { + return $this; + } + + foreach ($children as $res) { + if ($res->getName() != 'title' && $res->getName() != 'sort_order') { + $this->loadAclResources($acl, $res, $resourceName); + } + } + return $this; + } + + /** + * Get acl assert config + * + * @param string $name + * @return Mage_Core_Model_Config_Element|boolean + */ + public function getAclAssert($name='') + { + $asserts = $this->getNode('acl/asserts'); + if (''===$name) { + return $asserts; + } + + if (isset($asserts->$name)) { + return $asserts->$name; + } + + return false; + } + + /** + * Retrieve privilege set by name + * + * @param string $name + * @return Mage_Core_Model_Config_Element|boolean + */ + public function getAclPrivilegeSet($name='') + { + $sets = $this->getNode('acl/privilegeSets'); + if (''===$name) { + return $sets; + } + + if (isset($sets->$name)) { + return $sets->$name; + } + + return false; + } + + public function getFaults($resourceName=null) + { + if (is_null($resourceName) + || !isset($this->getResources()->$resourceName) + || !isset($this->getResources()->$resourceName->faults)) { + $faultsNode = $this->getNode('faults'); + } else { + $faultsNode = $this->getResources()->$resourceName->faults; + } + /* @var $faultsNode Varien_Simplexml_Element */ + + $translateModule = 'Mage_Api'; + if (isset($faultsNode['module'])) { + $translateModule = (string) $faultsNode['module']; + } + + $faults = array(); + foreach ($faultsNode->children() as $faultName => $fault) { + $faults[$faultName] = array( + 'code' => (string) $fault->code, + 'message' => Mage::helper($translateModule)->__((string)$fault->message) + ); + } + + return $faults; + } + + /** + * Retrieve cache object + * + * @return Zend_Cache_Frontend_File + */ + public function getCache() + { + return Mage::app()->getCache(); + } + + protected function _loadCache($id) + { + return Mage::app()->loadCache($id); + } + + protected function _saveCache($data, $id, $tags=array(), $lifetime=false) + { + return Mage::app()->saveCache($data, $id, $tags, $lifetime); + } + + protected function _removeCache($id) + { + return Mage::app()->removeCache($id); + } +} // Class Mage_Api_Model_Config End diff --git a/app/code/core/Mage/Api/Model/Resource/Abstract.php b/app/code/Mage/Api/Model/Resource/Abstract.php similarity index 100% rename from app/code/core/Mage/Api/Model/Resource/Abstract.php rename to app/code/Mage/Api/Model/Resource/Abstract.php diff --git a/app/code/core/Mage/Api/Model/Resource/Acl.php b/app/code/Mage/Api/Model/Resource/Acl.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Api/Model/Resource/Acl.php rename to app/code/Mage/Api/Model/Resource/Acl.php diff --git a/app/code/core/Mage/Api/Model/Resource/Acl/Role.php b/app/code/Mage/Api/Model/Resource/Acl/Role.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Api/Model/Resource/Acl/Role.php rename to app/code/Mage/Api/Model/Resource/Acl/Role.php diff --git a/app/code/core/Mage/Api/Model/Resource/Acl/Role/Collection.php b/app/code/Mage/Api/Model/Resource/Acl/Role/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Api/Model/Resource/Acl/Role/Collection.php rename to app/code/Mage/Api/Model/Resource/Acl/Role/Collection.php diff --git a/app/code/core/Mage/Api/Model/Resource/Permissions/Collection.php b/app/code/Mage/Api/Model/Resource/Permissions/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Api/Model/Resource/Permissions/Collection.php rename to app/code/Mage/Api/Model/Resource/Permissions/Collection.php diff --git a/app/code/core/Mage/Api/Model/Resource/Role.php b/app/code/Mage/Api/Model/Resource/Role.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Api/Model/Resource/Role.php rename to app/code/Mage/Api/Model/Resource/Role.php diff --git a/app/code/core/Mage/Api/Model/Resource/Role/Collection.php b/app/code/Mage/Api/Model/Resource/Role/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Api/Model/Resource/Role/Collection.php rename to app/code/Mage/Api/Model/Resource/Role/Collection.php diff --git a/app/code/core/Mage/Api/Model/Resource/Roles.php b/app/code/Mage/Api/Model/Resource/Roles.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Api/Model/Resource/Roles.php rename to app/code/Mage/Api/Model/Resource/Roles.php diff --git a/app/code/core/Mage/Api/Model/Resource/Roles/Collection.php b/app/code/Mage/Api/Model/Resource/Roles/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Api/Model/Resource/Roles/Collection.php rename to app/code/Mage/Api/Model/Resource/Roles/Collection.php diff --git a/app/code/core/Mage/Api/Model/Resource/Roles/User/Collection.php b/app/code/Mage/Api/Model/Resource/Roles/User/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Api/Model/Resource/Roles/User/Collection.php rename to app/code/Mage/Api/Model/Resource/Roles/User/Collection.php diff --git a/app/code/core/Mage/Api/Model/Resource/Rules.php b/app/code/Mage/Api/Model/Resource/Rules.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Api/Model/Resource/Rules.php rename to app/code/Mage/Api/Model/Resource/Rules.php diff --git a/app/code/core/Mage/Api/Model/Resource/Rules/Collection.php b/app/code/Mage/Api/Model/Resource/Rules/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Api/Model/Resource/Rules/Collection.php rename to app/code/Mage/Api/Model/Resource/Rules/Collection.php diff --git a/app/code/core/Mage/Api/Model/Resource/User.php b/app/code/Mage/Api/Model/Resource/User.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Api/Model/Resource/User.php rename to app/code/Mage/Api/Model/Resource/User.php diff --git a/app/code/core/Mage/Api/Model/Resource/User/Collection.php b/app/code/Mage/Api/Model/Resource/User/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Api/Model/Resource/User/Collection.php rename to app/code/Mage/Api/Model/Resource/User/Collection.php diff --git a/app/code/core/Mage/Api/Model/Role.php b/app/code/Mage/Api/Model/Role.php similarity index 100% rename from app/code/core/Mage/Api/Model/Role.php rename to app/code/Mage/Api/Model/Role.php diff --git a/app/code/core/Mage/Api/Model/Roles.php b/app/code/Mage/Api/Model/Roles.php similarity index 100% rename from app/code/core/Mage/Api/Model/Roles.php rename to app/code/Mage/Api/Model/Roles.php diff --git a/app/code/core/Mage/Api/Model/Rules.php b/app/code/Mage/Api/Model/Rules.php similarity index 100% rename from app/code/core/Mage/Api/Model/Rules.php rename to app/code/Mage/Api/Model/Rules.php diff --git a/app/code/core/Mage/Api/Model/Server.php b/app/code/Mage/Api/Model/Server.php similarity index 100% rename from app/code/core/Mage/Api/Model/Server.php rename to app/code/Mage/Api/Model/Server.php diff --git a/app/code/core/Mage/Api/Model/Server/Adapter/Soap.php b/app/code/Mage/Api/Model/Server/Adapter/Soap.php similarity index 100% rename from app/code/core/Mage/Api/Model/Server/Adapter/Soap.php rename to app/code/Mage/Api/Model/Server/Adapter/Soap.php diff --git a/app/code/core/Mage/Api/Model/Server/Adapter/Soap/Wsi.php b/app/code/Mage/Api/Model/Server/Adapter/Soap/Wsi.php similarity index 100% rename from app/code/core/Mage/Api/Model/Server/Adapter/Soap/Wsi.php rename to app/code/Mage/Api/Model/Server/Adapter/Soap/Wsi.php diff --git a/app/code/core/Mage/Api/Model/Server/Handler/Soap.php b/app/code/Mage/Api/Model/Server/Handler/Soap.php similarity index 100% rename from app/code/core/Mage/Api/Model/Server/Handler/Soap.php rename to app/code/Mage/Api/Model/Server/Handler/Soap.php diff --git a/app/code/core/Mage/Api/Model/Server/Handler/Soap/Wsi.php b/app/code/Mage/Api/Model/Server/Handler/Soap/Wsi.php similarity index 100% rename from app/code/core/Mage/Api/Model/Server/Handler/Soap/Wsi.php rename to app/code/Mage/Api/Model/Server/Handler/Soap/Wsi.php diff --git a/app/code/core/Mage/Api/Model/Server/HandlerAbstract.php b/app/code/Mage/Api/Model/Server/HandlerAbstract.php similarity index 100% rename from app/code/core/Mage/Api/Model/Server/HandlerAbstract.php rename to app/code/Mage/Api/Model/Server/HandlerAbstract.php diff --git a/app/code/core/Mage/Api/Model/Session.php b/app/code/Mage/Api/Model/Session.php similarity index 100% rename from app/code/core/Mage/Api/Model/Session.php rename to app/code/Mage/Api/Model/Session.php diff --git a/app/code/core/Mage/Api/Model/User.php b/app/code/Mage/Api/Model/User.php similarity index 100% rename from app/code/core/Mage/Api/Model/User.php rename to app/code/Mage/Api/Model/User.php diff --git a/app/code/Mage/Api/Model/Wsdl/Config.php b/app/code/Mage/Api/Model/Wsdl/Config.php new file mode 100644 index 0000000000000..46573fe121cc9 --- /dev/null +++ b/app/code/Mage/Api/Model/Wsdl/Config.php @@ -0,0 +1,147 @@ + + */ +class Mage_Api_Model_Wsdl_Config extends Mage_Api_Model_Wsdl_Config_Base +{ + protected static $_namespacesPrefix = null; + + /** + * @var Mage_Core_Model_Config_Modules_Reader + */ + protected $_configReader; + + /** + * @var Mage_Core_Model_Cache_Type_Config + */ + protected $_configCacheType; + + /** + * @param Mage_Core_Model_Config_Modules_Reader $configReader + * @param Mage_Core_Model_Cache_Type_Config $configCacheType + * @param Varien_Simplexml_Element|null $sourceData + */ + public function __construct( + Mage_Core_Model_Config_Modules_Reader $configReader, + Mage_Core_Model_Cache_Type_Config $configCacheType, + $sourceData = null + ) { + parent::__construct($sourceData); + $this->_configReader = $configReader; + $this->_configCacheType = $configCacheType; + } + + /** + * Return wsdl content + * + * @return string + */ + public function getWsdlContent() + { + return $this->_xml->asXML(); + } + + /** + * Return namespaces with their prefix + * + * @return array + */ + public static function getNamespacesPrefix() + { + if (is_null(self::$_namespacesPrefix)) { + self::$_namespacesPrefix = array(); + $config = Mage::getSingleton('Mage_Api_Model_Config')->getNode('v2/wsdl/prefix')->children(); + foreach ($config as $prefix => $namespace) { + self::$_namespacesPrefix[$namespace->asArray()] = $prefix; + } + } + return self::$_namespacesPrefix; + } + + protected function _loadCache($id) + { + return $this->_configCacheType->load($id); + } + + protected function _saveCache($data, $id, $tags = array(), $lifetime = false) + { + return $this->_configCacheType->save($data, $id, $tags, $lifetime); + } + + protected function _removeCache($id) + { + return $this->_configCacheType->remove($id); + } + + public function init() + { + $cacheId = 'wsdl_config_global'; + $cachedXml = $this->_configCacheType->load($cacheId); + if ($cachedXml) { + $this->loadString($cachedXml); + } else { + $mergeWsdl = new Mage_Api_Model_Wsdl_Config_Base(); + $mergeWsdl->setHandler($this->getHandler()); + + /** @var Mage_Api_Helper_Data $helper */ + $helper = Mage::helper('Mage_Api_Helper_Data'); + if ($helper->isWsiCompliant()) { + /** + * Exclude Mage_Api wsdl xml file because it used for previous version + * of API wsdl declaration + */ + $mergeWsdl->addLoadedFile($this->_configReader->getModuleDir('etc', "Mage_Api") . DS . 'wsi.xml'); + + $baseWsdlFile = $this->_configReader->getModuleDir('etc', "Mage_Api") . DS . 'wsi.xml'; + $this->loadFile($baseWsdlFile); + $this->_configReader->loadModulesConfiguration('wsi.xml', $this, $mergeWsdl); + } else { + $baseWsdlFile = $this->_configReader->getModuleDir('etc', "Mage_Api") . DS . 'wsdl.xml'; + $this->loadFile($baseWsdlFile); + $this->_configReader->loadModulesConfiguration('wsdl.xml', $this, $mergeWsdl); + } + + $this->_configCacheType->save($this->getXmlString(), $cacheId); + } + return $this; + } + + /** + * Return Xml of node as string + * + * @return string + */ + public function getXmlString() + { + return $this->getNode()->asXML(); + } +} diff --git a/app/code/core/Mage/Api/Model/Wsdl/Config/Base.php b/app/code/Mage/Api/Model/Wsdl/Config/Base.php similarity index 100% rename from app/code/core/Mage/Api/Model/Wsdl/Config/Base.php rename to app/code/Mage/Api/Model/Wsdl/Config/Base.php diff --git a/app/code/core/Mage/Api/Model/Wsdl/Config/Element.php b/app/code/Mage/Api/Model/Wsdl/Config/Element.php similarity index 100% rename from app/code/core/Mage/Api/Model/Wsdl/Config/Element.php rename to app/code/Mage/Api/Model/Wsdl/Config/Element.php diff --git a/app/code/core/Mage/Api/controllers/Soap/WsiController.php b/app/code/Mage/Api/controllers/Soap/WsiController.php similarity index 100% rename from app/code/core/Mage/Api/controllers/Soap/WsiController.php rename to app/code/Mage/Api/controllers/Soap/WsiController.php diff --git a/app/code/core/Mage/Api/controllers/SoapController.php b/app/code/Mage/Api/controllers/SoapController.php similarity index 100% rename from app/code/core/Mage/Api/controllers/SoapController.php rename to app/code/Mage/Api/controllers/SoapController.php diff --git a/app/code/Mage/Api/etc/adminhtml/acl.xml b/app/code/Mage/Api/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..32a38125db63c --- /dev/null +++ b/app/code/Mage/Api/etc/adminhtml/acl.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + diff --git a/app/code/Mage/Api/etc/adminhtml/menu.xml b/app/code/Mage/Api/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..7dd034fa9db52 --- /dev/null +++ b/app/code/Mage/Api/etc/adminhtml/menu.xml @@ -0,0 +1,34 @@ + + + + + + + + + diff --git a/app/code/core/Mage/Api/etc/adminhtml/system.xml b/app/code/Mage/Api/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Api/etc/adminhtml/system.xml rename to app/code/Mage/Api/etc/adminhtml/system.xml diff --git a/app/code/core/Mage/Api/etc/api.xml b/app/code/Mage/Api/etc/api.xml similarity index 100% rename from app/code/core/Mage/Api/etc/api.xml rename to app/code/Mage/Api/etc/api.xml diff --git a/app/code/Mage/Api/etc/config.xml b/app/code/Mage/Api/etc/config.xml new file mode 100644 index 0000000000000..52ae823b80c03 --- /dev/null +++ b/app/code/Mage/Api/etc/config.xml @@ -0,0 +1,106 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + + + + + + + Web Services definition files (api.xml). + Mage_Api_Model_Cache_Type + + + + + + + Mage_Api + + + + + + + + + + + + + standard + + Mage_Api + api + + + + + + + + Mage_Api.csv + + + + + + + + + + + Mage_Api.csv + + + + + + + + + UTF-8 + 3600 + 0 + + + + diff --git a/app/code/core/Mage/Api/etc/wsdl.xml b/app/code/Mage/Api/etc/wsdl.xml similarity index 100% rename from app/code/core/Mage/Api/etc/wsdl.xml rename to app/code/Mage/Api/etc/wsdl.xml diff --git a/app/code/core/Mage/Api/etc/wsi.xml b/app/code/Mage/Api/etc/wsi.xml similarity index 100% rename from app/code/core/Mage/Api/etc/wsi.xml rename to app/code/Mage/Api/etc/wsi.xml diff --git a/app/code/core/Mage/Api/locale/de_DE/Mage_Api.csv b/app/code/Mage/Api/locale/de_DE/Mage_Api.csv similarity index 100% rename from app/code/core/Mage/Api/locale/de_DE/Mage_Api.csv rename to app/code/Mage/Api/locale/de_DE/Mage_Api.csv diff --git a/app/code/core/Mage/Api/locale/en_US/Mage_Api.csv b/app/code/Mage/Api/locale/en_US/Mage_Api.csv similarity index 100% rename from app/code/core/Mage/Api/locale/en_US/Mage_Api.csv rename to app/code/Mage/Api/locale/en_US/Mage_Api.csv diff --git a/app/code/core/Mage/Api/locale/es_ES/Mage_Api.csv b/app/code/Mage/Api/locale/es_ES/Mage_Api.csv similarity index 100% rename from app/code/core/Mage/Api/locale/es_ES/Mage_Api.csv rename to app/code/Mage/Api/locale/es_ES/Mage_Api.csv diff --git a/app/code/core/Mage/Api/locale/fr_FR/Mage_Api.csv b/app/code/Mage/Api/locale/fr_FR/Mage_Api.csv similarity index 100% rename from app/code/core/Mage/Api/locale/fr_FR/Mage_Api.csv rename to app/code/Mage/Api/locale/fr_FR/Mage_Api.csv diff --git a/app/code/core/Mage/Api/locale/nl_NL/Mage_Api.csv b/app/code/Mage/Api/locale/nl_NL/Mage_Api.csv similarity index 100% rename from app/code/core/Mage/Api/locale/nl_NL/Mage_Api.csv rename to app/code/Mage/Api/locale/nl_NL/Mage_Api.csv diff --git a/app/code/core/Mage/Api/locale/pt_BR/Mage_Api.csv b/app/code/Mage/Api/locale/pt_BR/Mage_Api.csv similarity index 100% rename from app/code/core/Mage/Api/locale/pt_BR/Mage_Api.csv rename to app/code/Mage/Api/locale/pt_BR/Mage_Api.csv diff --git a/app/code/core/Mage/Api/locale/zh_CN/Mage_Api.csv b/app/code/Mage/Api/locale/zh_CN/Mage_Api.csv similarity index 100% rename from app/code/core/Mage/Api/locale/zh_CN/Mage_Api.csv rename to app/code/Mage/Api/locale/zh_CN/Mage_Api.csv diff --git a/app/code/core/Mage/Api/sql/api_setup/install-1.6.0.0.php b/app/code/Mage/Api/sql/api_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Api/sql/api_setup/install-1.6.0.0.php rename to app/code/Mage/Api/sql/api_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Authorizenet/Block/Directpost/Form.php b/app/code/Mage/Authorizenet/Block/Directpost/Form.php similarity index 100% rename from app/code/core/Mage/Authorizenet/Block/Directpost/Form.php rename to app/code/Mage/Authorizenet/Block/Directpost/Form.php diff --git a/app/code/core/Mage/Authorizenet/Block/Directpost/Iframe.php b/app/code/Mage/Authorizenet/Block/Directpost/Iframe.php similarity index 100% rename from app/code/core/Mage/Authorizenet/Block/Directpost/Iframe.php rename to app/code/Mage/Authorizenet/Block/Directpost/Iframe.php diff --git a/app/code/core/Mage/Authorizenet/Helper/Data.php b/app/code/Mage/Authorizenet/Helper/Data.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Authorizenet/Helper/Data.php rename to app/code/Mage/Authorizenet/Helper/Data.php diff --git a/app/code/core/Mage/Authorizenet/Model/Directpost.php b/app/code/Mage/Authorizenet/Model/Directpost.php similarity index 100% rename from app/code/core/Mage/Authorizenet/Model/Directpost.php rename to app/code/Mage/Authorizenet/Model/Directpost.php diff --git a/app/code/core/Mage/Authorizenet/Model/Directpost/Observer.php b/app/code/Mage/Authorizenet/Model/Directpost/Observer.php similarity index 100% rename from app/code/core/Mage/Authorizenet/Model/Directpost/Observer.php rename to app/code/Mage/Authorizenet/Model/Directpost/Observer.php diff --git a/app/code/core/Mage/Authorizenet/Model/Directpost/Request.php b/app/code/Mage/Authorizenet/Model/Directpost/Request.php similarity index 100% rename from app/code/core/Mage/Authorizenet/Model/Directpost/Request.php rename to app/code/Mage/Authorizenet/Model/Directpost/Request.php diff --git a/app/code/core/Mage/Authorizenet/Model/Directpost/Response.php b/app/code/Mage/Authorizenet/Model/Directpost/Response.php similarity index 100% rename from app/code/core/Mage/Authorizenet/Model/Directpost/Response.php rename to app/code/Mage/Authorizenet/Model/Directpost/Response.php diff --git a/app/code/core/Mage/Authorizenet/Model/Directpost/Session.php b/app/code/Mage/Authorizenet/Model/Directpost/Session.php similarity index 100% rename from app/code/core/Mage/Authorizenet/Model/Directpost/Session.php rename to app/code/Mage/Authorizenet/Model/Directpost/Session.php diff --git a/app/code/core/Mage/Authorizenet/controllers/Adminhtml/Authorizenet/Directpost/PaymentController.php b/app/code/Mage/Authorizenet/controllers/Adminhtml/Authorizenet/Directpost/PaymentController.php similarity index 100% rename from app/code/core/Mage/Authorizenet/controllers/Adminhtml/Authorizenet/Directpost/PaymentController.php rename to app/code/Mage/Authorizenet/controllers/Adminhtml/Authorizenet/Directpost/PaymentController.php diff --git a/app/code/core/Mage/Authorizenet/controllers/Directpost/PaymentController.php b/app/code/Mage/Authorizenet/controllers/Directpost/PaymentController.php similarity index 100% rename from app/code/core/Mage/Authorizenet/controllers/Directpost/PaymentController.php rename to app/code/Mage/Authorizenet/controllers/Directpost/PaymentController.php diff --git a/app/code/core/Mage/Authorizenet/etc/adminhtml/system.xml b/app/code/Mage/Authorizenet/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Authorizenet/etc/adminhtml/system.xml rename to app/code/Mage/Authorizenet/etc/adminhtml/system.xml diff --git a/app/code/Mage/Authorizenet/etc/config.xml b/app/code/Mage/Authorizenet/etc/config.xml new file mode 100644 index 0000000000000..32fbfb399d3a3 --- /dev/null +++ b/app/code/Mage/Authorizenet/etc/config.xml @@ -0,0 +1,147 @@ + + + + + + 1.5.0.0 + true + + + + + + + + + + + + + Mage_Authorizenet.csv + + + + + + + + layout.xml + + + + + + + + Mage_Authorizenet_Model_Directpost_Observer + updateAllEditIncrements + + + + + + + + + + + Mage_Authorizenet.csv + + + + + + + standard + + Mage_Authorizenet + authorizenet + + + + + + + layout.xml + + + + + + + + Mage_Authorizenet_Model_Directpost_Observer + saveOrderAfterSubmit + + + + + + + Mage_Authorizenet_Model_Directpost_Observer + addAdditionalFieldsToResponseFrontend + + + + + + + + + + + Mage_Authorizenet_Adminhtml + + + + + + + + + 0 + AE,VI,MC,DI + https://secure.authorize.net/gateway/transact.dll + 0 + 0 + + + Mage_Authorizenet_Model_Directpost + processing + authorize + 1 + Credit Card Direct Post (Authorize.net) + + + 0 + USD + 1 + + + + diff --git a/app/code/core/Mage/Authorizenet/locale/de_DE/Mage_Authorizenet.csv b/app/code/Mage/Authorizenet/locale/de_DE/Mage_Authorizenet.csv similarity index 100% rename from app/code/core/Mage/Authorizenet/locale/de_DE/Mage_Authorizenet.csv rename to app/code/Mage/Authorizenet/locale/de_DE/Mage_Authorizenet.csv diff --git a/app/code/core/Mage/Authorizenet/locale/en_US/Mage_Authorizenet.csv b/app/code/Mage/Authorizenet/locale/en_US/Mage_Authorizenet.csv similarity index 100% rename from app/code/core/Mage/Authorizenet/locale/en_US/Mage_Authorizenet.csv rename to app/code/Mage/Authorizenet/locale/en_US/Mage_Authorizenet.csv diff --git a/app/code/core/Mage/Authorizenet/locale/es_ES/Mage_Authorizenet.csv b/app/code/Mage/Authorizenet/locale/es_ES/Mage_Authorizenet.csv similarity index 100% rename from app/code/core/Mage/Authorizenet/locale/es_ES/Mage_Authorizenet.csv rename to app/code/Mage/Authorizenet/locale/es_ES/Mage_Authorizenet.csv diff --git a/app/code/core/Mage/Authorizenet/locale/fr_FR/Mage_Authorizenet.csv b/app/code/Mage/Authorizenet/locale/fr_FR/Mage_Authorizenet.csv similarity index 100% rename from app/code/core/Mage/Authorizenet/locale/fr_FR/Mage_Authorizenet.csv rename to app/code/Mage/Authorizenet/locale/fr_FR/Mage_Authorizenet.csv diff --git a/app/code/core/Mage/Authorizenet/locale/nl_NL/Mage_Authorizenet.csv b/app/code/Mage/Authorizenet/locale/nl_NL/Mage_Authorizenet.csv similarity index 100% rename from app/code/core/Mage/Authorizenet/locale/nl_NL/Mage_Authorizenet.csv rename to app/code/Mage/Authorizenet/locale/nl_NL/Mage_Authorizenet.csv diff --git a/app/code/core/Mage/Authorizenet/locale/pt_BR/Mage_Authorizenet.csv b/app/code/Mage/Authorizenet/locale/pt_BR/Mage_Authorizenet.csv similarity index 100% rename from app/code/core/Mage/Authorizenet/locale/pt_BR/Mage_Authorizenet.csv rename to app/code/Mage/Authorizenet/locale/pt_BR/Mage_Authorizenet.csv diff --git a/app/code/core/Mage/Authorizenet/locale/zh_CN/Mage_Authorizenet.csv b/app/code/Mage/Authorizenet/locale/zh_CN/Mage_Authorizenet.csv similarity index 100% rename from app/code/core/Mage/Authorizenet/locale/zh_CN/Mage_Authorizenet.csv rename to app/code/Mage/Authorizenet/locale/zh_CN/Mage_Authorizenet.csv diff --git a/app/code/core/Mage/Authorizenet/view/adminhtml/directpost/iframe.phtml b/app/code/Mage/Authorizenet/view/adminhtml/directpost/iframe.phtml similarity index 100% rename from app/code/core/Mage/Authorizenet/view/adminhtml/directpost/iframe.phtml rename to app/code/Mage/Authorizenet/view/adminhtml/directpost/iframe.phtml diff --git a/app/code/core/Mage/Authorizenet/view/adminhtml/directpost/info.phtml b/app/code/Mage/Authorizenet/view/adminhtml/directpost/info.phtml similarity index 100% rename from app/code/core/Mage/Authorizenet/view/adminhtml/directpost/info.phtml rename to app/code/Mage/Authorizenet/view/adminhtml/directpost/info.phtml diff --git a/app/code/core/Mage/Authorizenet/view/adminhtml/layout.xml b/app/code/Mage/Authorizenet/view/adminhtml/layout.xml similarity index 100% rename from app/code/core/Mage/Authorizenet/view/adminhtml/layout.xml rename to app/code/Mage/Authorizenet/view/adminhtml/layout.xml diff --git a/app/code/Mage/Authorizenet/view/frontend/directpost/form.phtml b/app/code/Mage/Authorizenet/view/frontend/directpost/form.phtml new file mode 100644 index 0000000000000..abb23532e617a --- /dev/null +++ b/app/code/Mage/Authorizenet/view/frontend/directpost/form.phtml @@ -0,0 +1,135 @@ + +getMethodCode(); +$_method = $_form->getMethod(); +$_controller = $this->helper('Mage_Authorizenet_Helper_Data')->getControllerName(); +$_orderUrl = $this->helper('Mage_Authorizenet_Helper_Data')->getPlaceOrderFrontUrl(); +?> +
      + + + +
      +
      +
      +
      __('Credit Card Information') ?>
      +
      +
        +
      • + +
        + +
        +
      • +
      • + +
        + +
        +
      • +
      • + +
        +
        + +
        +
        + getInfoData('cc_exp_year') ?> + +
        +
        +
      • + getChildHtml() ?> + hasVerification()): ?> +
      • + + +
      • + +
      +
      +
      +
      +
      +
      + + diff --git a/app/code/core/Mage/Authorizenet/view/frontend/directpost/iframe.phtml b/app/code/Mage/Authorizenet/view/frontend/directpost/iframe.phtml similarity index 100% rename from app/code/core/Mage/Authorizenet/view/frontend/directpost/iframe.phtml rename to app/code/Mage/Authorizenet/view/frontend/directpost/iframe.phtml diff --git a/app/code/core/Mage/Authorizenet/view/frontend/directpost/info.phtml b/app/code/Mage/Authorizenet/view/frontend/directpost/info.phtml similarity index 100% rename from app/code/core/Mage/Authorizenet/view/frontend/directpost/info.phtml rename to app/code/Mage/Authorizenet/view/frontend/directpost/info.phtml diff --git a/app/code/core/Mage/Authorizenet/view/frontend/layout.xml b/app/code/Mage/Authorizenet/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/Authorizenet/view/frontend/layout.xml rename to app/code/Mage/Authorizenet/view/frontend/layout.xml diff --git a/app/code/Mage/Backend/Block/Abstract.php b/app/code/Mage/Backend/Block/Abstract.php new file mode 100644 index 0000000000000..6912e58973bd6 --- /dev/null +++ b/app/code/Mage/Backend/Block/Abstract.php @@ -0,0 +1,38 @@ + + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class Mage_Backend_Block_Abstract extends Mage_Core_Block_Template +{ +} diff --git a/app/code/core/Mage/Backend/Block/Catalog/Product/Tab/Container.php b/app/code/Mage/Backend/Block/Catalog/Product/Tab/Container.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Catalog/Product/Tab/Container.php rename to app/code/Mage/Backend/Block/Catalog/Product/Tab/Container.php diff --git a/app/code/core/Mage/Backend/Block/Menu.php b/app/code/Mage/Backend/Block/Menu.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Menu.php rename to app/code/Mage/Backend/Block/Menu.php diff --git a/app/code/core/Mage/Backend/Block/Store/Switcher.php b/app/code/Mage/Backend/Block/Store/Switcher.php similarity index 82% rename from app/code/core/Mage/Backend/Block/Store/Switcher.php rename to app/code/Mage/Backend/Block/Store/Switcher.php index 23f4d599cf74c..03af671b5c9f9 100644 --- a/app/code/core/Mage/Backend/Block/Store/Switcher.php +++ b/app/code/Mage/Backend/Block/Store/Switcher.php @@ -94,49 +94,20 @@ class Mage_Backend_Block_Store_Switcher extends Mage_Backend_Block_Template /** * Constructor * - * @param Mage_Core_Controller_Request_Http $request - * @param Mage_Core_Model_Layout $layout - * @param Mage_Core_Model_Event_Manager $eventManager - * @param Mage_Backend_Model_Url $urlBuilder - * @param Mage_Core_Model_Translate $translator - * @param Mage_Core_Model_Cache $cache - * @param Mage_Core_Model_Design_Package $designPackage - * @param Mage_Core_Model_Session $session - * @param Mage_Core_Model_Store_Config $storeConfig - * @param Mage_Core_Controller_Varien_Front $frontController - * @param Mage_Core_Model_Factory_Helper $helperFactory - * @param Mage_Core_Model_Dir $dirs - * @param Mage_Core_Model_Logger $logger - * @param Magento_Filesystem $filesystem + * @param Mage_Core_Block_Template_Context $context * @param Mage_Core_Model_App $application * @param Mage_Core_Model_Website_Factory $websiteFactory * @param Mage_Core_Model_Store_Group_Factory $storeGroupFactory * @param array $data - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - Mage_Core_Controller_Request_Http $request, - Mage_Core_Model_Layout $layout, - Mage_Core_Model_Event_Manager $eventManager, - Mage_Backend_Model_Url $urlBuilder, - Mage_Core_Model_Translate $translator, - Mage_Core_Model_Cache $cache, - Mage_Core_Model_Design_Package $designPackage, - Mage_Core_Model_Session $session, - Mage_Core_Model_Store_Config $storeConfig, - Mage_Core_Controller_Varien_Front $frontController, - Mage_Core_Model_Factory_Helper $helperFactory, - Mage_Core_Model_Dir $dirs, - Mage_Core_Model_Logger $logger, - Magento_Filesystem $filesystem, + Mage_Core_Block_Template_Context $context, Mage_Core_Model_App $application, Mage_Core_Model_Website_Factory $websiteFactory, Mage_Core_Model_Store_Group_Factory $storeGroupFactory, array $data = array() ) { - parent::__construct($request, $layout, $eventManager, $urlBuilder, $translator, $cache, $designPackage, - $session, $storeConfig, $frontController, $helperFactory, $dirs, $logger, $filesystem, $data); + parent::__construct($context, $data); $this->_application = $application; $this->_websiteFactory = $websiteFactory; $this->_storeGroupFactory = $storeGroupFactory; @@ -218,7 +189,7 @@ public function getStoreGroups($website) public function getStoreCollection($group) { if (!$group instanceof Mage_Core_Model_Store_Group) { - $group = $this->_storeGroupFactory->createFromArray()->load($group); + $group = $this->_storeGroupFactory->create()->load($group); } $stores = $group->getStoreCollection(); $_storeIds = $this->getStoreIds(); diff --git a/app/code/core/Mage/Backend/Block/Store/Switcher/Form/Renderer/Fieldset.php b/app/code/Mage/Backend/Block/Store/Switcher/Form/Renderer/Fieldset.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Store/Switcher/Form/Renderer/Fieldset.php rename to app/code/Mage/Backend/Block/Store/Switcher/Form/Renderer/Fieldset.php diff --git a/app/code/core/Mage/Backend/Block/Store/Switcher/Form/Renderer/Fieldset/Element.php b/app/code/Mage/Backend/Block/Store/Switcher/Form/Renderer/Fieldset/Element.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Store/Switcher/Form/Renderer/Fieldset/Element.php rename to app/code/Mage/Backend/Block/Store/Switcher/Form/Renderer/Fieldset/Element.php diff --git a/app/code/core/Mage/Backend/Block/System/Config/Dwstree.php b/app/code/Mage/Backend/Block/System/Config/Dwstree.php similarity index 100% rename from app/code/core/Mage/Backend/Block/System/Config/Dwstree.php rename to app/code/Mage/Backend/Block/System/Config/Dwstree.php diff --git a/app/code/Mage/Backend/Block/System/Config/Edit.php b/app/code/Mage/Backend/Block/System/Config/Edit.php new file mode 100644 index 0000000000000..cdf66e2ecd27f --- /dev/null +++ b/app/code/Mage/Backend/Block/System/Config/Edit.php @@ -0,0 +1,123 @@ + + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class Mage_Backend_Block_System_Config_Edit extends Mage_Backend_Block_Widget +{ + const DEFAULT_SECTION_BLOCK = 'Mage_Backend_Block_System_Config_Form'; + + /** + * Form block class name + * + * @var string + */ + protected $_formBlockName; + + /** + * Block template File + * + * @var string + */ + protected $_template = 'Mage_Backend::system/config/edit.phtml'; + + /** + * Configuration structure + * + * @var Mage_Backend_Model_Config_Structure + */ + protected $_configStructure; + + /** + * @param Mage_Core_Block_Template_Context $context + * @param Mage_Backend_Model_Config_Structure $configStructure + * @param array $data + */ + public function __construct( + Mage_Core_Block_Template_Context $context, + Mage_Backend_Model_Config_Structure $configStructure, + array $data = array() + ) { + parent::__construct($context, $data); + $this->_configStructure = $configStructure; + } + + /** + * Prepare layout object + * + * @return Mage_Core_Block_Abstract + */ + protected function _prepareLayout() + { + /** @var $section Mage_Backend_Model_Config_Structure_Element_Section */ + $section = $this->_configStructure->getElement($this->getRequest()->getParam('section')); + $this->_formBlockName = $section->getFrontendModel(); + if (empty($this->_formBlockName)) { + $this->_formBlockName = self::DEFAULT_SECTION_BLOCK; + } + $this->setTitle($section->getLabel()); + $this->setHeaderCss($section->getHeaderCss()); + + $this->addChild('save_button', 'Mage_Backend_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_Backend_Helper_Data')->__('Save Config'), + 'class' => 'save', + 'data_attribute' => array( + 'mage-init' => array( + 'button' => array('event' => 'save', 'target' => '#config-edit-form'), + ), + ), + )); + $block = $this->getLayout()->createBlock($this->_formBlockName); + $this->setChild('form', $block); + return parent::_prepareLayout(); + } + + /** + * Retrieve rendered save buttons + * + * @return string + */ + public function getSaveButtonHtml() + { + return $this->getChildHtml('save_button'); + } + + /** + * Retrieve config save url + * + * @return string + */ + public function getSaveUrl() + { + return $this->getUrl('*/system_config_save/index', array('_current' => true)); + } +} diff --git a/app/code/Mage/Backend/Block/System/Config/Form.php b/app/code/Mage/Backend/Block/System/Config/Form.php new file mode 100644 index 0000000000000..a1ffd25a53ec3 --- /dev/null +++ b/app/code/Mage/Backend/Block/System/Config/Form.php @@ -0,0 +1,660 @@ + + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class Mage_Backend_Block_System_Config_Form extends Mage_Backend_Block_Widget_Form +{ + + const SCOPE_DEFAULT = 'default'; + const SCOPE_WEBSITES = 'websites'; + const SCOPE_STORES = 'stores'; + + /** + * Config data array + * + * @var array + */ + protected $_configData; + + /** + * Backend config data instance + * + * @var Mage_Backend_Model_Config + */ + protected $_configDataObject; + + /** + * System configuration root node + * + * @var Varien_Simplexml_Element + */ + protected $_configRoot; + + /** + * Default fieldset rendering block + * + * @var Mage_Backend_Block_System_Config_Form_Fieldset + */ + protected $_fieldsetRenderer; + + /** + * Default field rendering block + * + * @var Mage_Backend_Block_System_Config_Form_Field + */ + protected $_fieldRenderer; + + /** + * List of fieldset + * + * @var array + */ + protected $_fieldsets = array(); + + /** + * Translated scope labels + * + * @var array + */ + protected $_scopeLabels = array(); + + /** + * Backend Config model factory + * + * @var Mage_Backend_Model_Config_Factory + */ + protected $_configFactory; + + /** + * Varien_Data_Form_Factory + * + * @var Varien_Data_Form_Factory + */ + protected $_formFactory; + + /** + * System config structure + * + * @var Mage_Backend_Model_Config_Structure + */ + protected $_configStructure; + + /** + *Form fieldset factory + * + * @var Mage_Backend_Block_System_Config_Form_Fieldset_Factory + */ + protected $_fieldsetFactory; + + /** + * Form field factory + * + * @var Mage_Backend_Block_System_Config_Form_Field_Factory + */ + protected $_fieldFactory; + + /** + * Form field factory + * + * @var Mage_Core_Model_Config + */ + protected $_coreConfig; + + /** + * @param Mage_Core_Block_Template_Context $context + * @param Mage_Backend_Model_Config_Factory $configFactory + * @param Varien_Data_Form_Factory $formFactory + * @param Mage_Backend_Model_Config_Clone_Factory $cloneModelFactory + * @param Mage_Backend_Model_Config_Structure $configStructure + * @param Mage_Backend_Block_System_Config_Form_Fieldset_Factory $fieldsetFactory + * @param Mage_Backend_Block_System_Config_Form_Field_Factory $fieldFactory + * @param Mage_Core_Model_Config $coreConfig + * @param array $data + */ + public function __construct( + Mage_Core_Block_Template_Context $context, + Mage_Backend_Model_Config_Factory $configFactory, + Varien_Data_Form_Factory $formFactory, + Mage_Backend_Model_Config_Clone_Factory $cloneModelFactory, + Mage_Backend_Model_Config_Structure $configStructure, + Mage_Backend_Block_System_Config_Form_Fieldset_Factory $fieldsetFactory, + Mage_Backend_Block_System_Config_Form_Field_Factory $fieldFactory, + Mage_Core_Model_Config $coreConfig, + array $data = array() + ) { + parent::__construct($context, $data); + $this->_configFactory = $configFactory; + $this->_formFactory = $formFactory; + $this->_cloneModelFactory = $cloneModelFactory; + $this->_configStructure = $configStructure; + $this->_fieldsetFactory = $fieldsetFactory; + $this->_fieldFactory = $fieldFactory; + $this->_coreConfig = $coreConfig; + + $this->_scopeLabels = array( + self::SCOPE_DEFAULT => $this->helper('Mage_Backend_Helper_Data')->__('[GLOBAL]'), + self::SCOPE_WEBSITES => $this->helper('Mage_Backend_Helper_Data')->__('[WEBSITE]'), + self::SCOPE_STORES => $this->helper('Mage_Backend_Helper_Data')->__('[STORE VIEW]'), + ); + } + + /** + * Initialize objects required to render config form + * + * @return Mage_Backend_Block_System_Config_Form + */ + protected function _initObjects() + { + $this->_configRoot = $this->_coreConfig->getNode(null, $this->getScope(), $this->getScopeCode()); + + $this->_configDataObject = $this->_configFactory->create(array( + 'data' => array( + 'section' => $this->getSectionCode(), + 'website' => $this->getWebsiteCode(), + 'store' => $this->getStoreCode() + ) + )); + + $this->_configData = $this->_configDataObject->load(); + $this->_fieldsetRenderer = $this->_fieldsetFactory->create(); + $this->_fieldRenderer = $this->_fieldFactory->create(); + return $this; + } + + /** + * Initialize form + * + * @return Mage_Backend_Block_System_Config_Form + */ + public function initForm() + { + $this->_initObjects(); + + /** @var Varien_Data_Form $form */ + $form = $this->_formFactory->create(); + /** @var $section Mage_Backend_Model_Config_Structure_Element_Section */ + $section = $this->_configStructure->getElement($this->getSectionCode()); + if ($section && $section->isVisible($this->getWebsiteCode(), $this->getStoreCode())) { + foreach ($section->getChildren() as $group) { + $this->_initGroup($group, $section, $form); + } + } + + $this->setForm($form); + return $this; + } + + /** + * Initialize config field group + * + * @param Mage_Backend_Model_Config_Structure_Element_Group $group + * @param Mage_Backend_Model_Config_Structure_Element_Section $section + * @param Varien_Data_Form $form + */ + protected function _initGroup(Mage_Backend_Model_Config_Structure_Element_Group $group, + Mage_Backend_Model_Config_Structure_Element_Section $section, + Varien_Data_Form_Abstract $form + ) { + $frontendModelClass = $group->getFrontendModel(); + $fieldsetRenderer = $frontendModelClass ? + Mage::getBlockSingleton($frontendModelClass) : + $this->_fieldsetRenderer; + + $fieldsetRenderer->setForm($this); + $fieldsetRenderer->setConfigData($this->_configData); + $fieldsetRenderer->setGroup($group); + + $fieldsetConfig = array( + 'legend' => $group->getLabel(), + 'comment' => $group->getComment(), + 'expanded' => $group->isExpanded() + ); + + $fieldset = $form->addFieldset($this->_generateElementId($group->getPath()), $fieldsetConfig); + $fieldset->setRenderer($fieldsetRenderer); + $group->populateFieldset($fieldset); + $this->_addElementTypes($fieldset); + + $dependencies = $group->getDependencies($this->getStoreCode()); + $elementName = $this->_generateElementName($group->getPath()); + $elementId = $this->_generateElementId($group->getPath()); + + $this->_populateDependenciesBlock($dependencies, $elementId, $elementName); + + if ($group->shouldCloneFields()) { + $cloneModel = $group->getCloneModel(); + foreach ($cloneModel->getPrefixes() as $prefix) { + $this->initFields($fieldset, $group, $section, $prefix['field'], $prefix['label']); + } + } else { + $this->initFields($fieldset, $group, $section); + } + + $this->_fieldsets[$group->getId()] = $fieldset; + } + + /** + * Return dependency block object + * + * @return Mage_Backend_Block_Widget_Form_Element_Dependence + */ + protected function _getDependence() + { + if (!$this->getChildBlock('element_dependence')) { + $this->addChild('element_dependence', 'Mage_Backend_Block_Widget_Form_Element_Dependence'); + } + return $this->getChildBlock('element_dependence'); + } + + /** + * Initialize config group fields + * + * @param Varien_Data_Form_Element_Fieldset $fieldset + * @param Mage_Backend_Model_Config_Structure_Element_Group $group + * @param Mage_Backend_Model_Config_Structure_Element_Section $section + * @param string $fieldPrefix + * @param string $labelPrefix + * @return Mage_Backend_Block_System_Config_Form + */ + public function initFields( + Varien_Data_Form_Element_Fieldset $fieldset, + Mage_Backend_Model_Config_Structure_Element_Group $group, + Mage_Backend_Model_Config_Structure_Element_Section $section, + $fieldPrefix = '', + $labelPrefix = '' + ) { + if (!$this->_configDataObject) { + $this->_initObjects(); + } + + // Extends for config data + $extraConfigGroups = array(); + + /** @var $element Mage_Backend_Model_Config_Structure_Element_Field */ + foreach ($group->getChildren() as $element) { + if ($element instanceof Mage_Backend_Model_Config_Structure_Element_Group) { + $this->_initGroup($element, $section, $fieldset); + } else { + $path = $element->getPath($fieldPrefix); + if ($element->getSectionId() != $section->getId()) { + $groupPath = $element->getGroupPath(); + if (!isset($extraConfigGroups[$groupPath])) { + $this->_configData = $this->_configDataObject + ->extendConfig($groupPath, false, $this->_configData); + $extraConfigGroups[$groupPath] = true; + } + } + $this->_initElement($element, $fieldset, $path, $fieldPrefix, $labelPrefix); + } + } + return $this; + } + + /** + * Initialize form element + * + * @param Mage_Backend_Model_Config_Structure_Element_Field $field + * @param Varien_Data_Form_Element_Fieldset $fieldset + * @param $path + * @param string $fieldPrefix + * @param string $labelPrefix + */ + protected function _initElement( + Mage_Backend_Model_Config_Structure_Element_Field $field, + Varien_Data_Form_Element_Fieldset $fieldset, + $path, + $fieldPrefix = '', + $labelPrefix = '' + ) { + $inherit = true; + if (array_key_exists($path, $this->_configData)) { + $data = $this->_configData[$path]; + $inherit = false; + } elseif ($field->getConfigPath() !== null) { + $data = $this->_configRoot->descend($field->getConfigPath()); + } else { + $data = $this->_configRoot->descend($path); + } + $fieldRendererClass = $field->getFrontendModel(); + if ($fieldRendererClass) { + $fieldRenderer = Mage::getBlockSingleton($fieldRendererClass); + } else { + $fieldRenderer = $this->_fieldRenderer; + } + + $fieldRenderer->setForm($this); + $fieldRenderer->setConfigData($this->_configData); + + $elementName = $this->_generateElementName($field->getPath(), $fieldPrefix); + $elementId = $this->_generateElementId($field->getPath($fieldPrefix)); + + if ($field->hasBackendModel()) { + $backendModel = $field->getBackendModel(); + $backendModel->setPath($path) + ->setValue($data) + ->setWebsite($this->getWebsiteCode()) + ->setStore($this->getStoreCode()) + ->afterLoad(); + $data = $backendModel->getValue(); + } + + $dependencies = $field->getDependencies($fieldPrefix, $this->getStoreCode()); + $this->_populateDependenciesBlock($dependencies, $elementId, $elementName); + + + $formField = $fieldset->addField($elementId, $field->getType(), array( + 'name' => $elementName, + 'label' => $field->getLabel($labelPrefix), + 'comment' => $field->getComment($data), + 'tooltip' => $field->getTooltip(), + 'hint' => $field->getHint(), + 'value' => $data, + 'inherit' => $inherit, + 'class' => $field->getFrontendClass(), + 'field_config' => $field->getData(), + 'scope' => $this->getScope(), + 'scope_id' => $this->getScopeId(), + 'scope_label' => $this->getScopeLabel($field), + 'can_use_default_value' => $this->canUseDefaultValue($field->showInDefault()), + 'can_use_website_value' => $this->canUseWebsiteValue($field->showInWebsite()), + )); + $field->populateInput($formField); + + if ($field->hasValidation()) { + $formField->addClass($field->getValidation()); + } + if ($field->getType() == 'multiselect') { + $formField->setCanBeEmpty($field->canBeEmpty()); + } + if ($field->hasOptions()) { + $formField->setValues($field->getOptions()); + } + $formField->setRenderer($fieldRenderer); + } + + /** + * Populate dependencies block + * + * @param array $dependencies + * @param string $elementId + * @param string $elementName + */ + protected function _populateDependenciesBlock(array $dependencies, $elementId, $elementName) + { + foreach ($dependencies as $dependentId => $dependentValue) { + $fieldNameFrom = $this->_generateElementName($dependentId, null, '_'); + $this->_getDependence() + ->addFieldMap($elementId, $elementName) + ->addFieldMap($this->_generateElementId($dependentId), $fieldNameFrom) + ->addFieldDependence($elementName, $fieldNameFrom, $dependentValue); + } + } + + /** + * Generate element name + * + * @param string $elementPath + * @param string $fieldPrefix + * @param string $separator + * @return string + */ + protected function _generateElementName($elementPath, $fieldPrefix = '', $separator = '/') + { + $part = explode($separator, $elementPath); + array_shift($part); //shift section name + $fieldId = array_pop($part); //shift filed id + $groupName = implode('][groups][', $part); + $name = 'groups[' . $groupName . '][fields][' . $fieldPrefix . $fieldId . '][value]'; + return $name; + } + + /** + * Generate element id + * + * @param string $path + * @return string + */ + protected function _generateElementId($path) + { + return str_replace('/', '_', $path); + } + + /** + * Return config root node for current scope + * + * @return Varien_Simplexml_Element + */ + public function getConfigRoot() + { + if (empty($this->_configRoot)) { + $this->_configRoot = Mage::getConfig()->getNode(null, $this->getScope(), $this->getScopeCode()); + } + return $this->_configRoot; + } + + /** + * + * + * @return Mage_Backend_Block_Widget_Form|Mage_Core_Block_Abstract|void + */ + protected function _beforeToHtml() + { + $this->initForm(); + return parent::_beforeToHtml(); + } + + /** + * Append dependence block at then end of form block + * + * @param string $html + * @return string + */ + protected function _afterToHtml($html) + { + if ($this->_getDependence()) { + $html .= $this->_getDependence()->toHtml(); + } + $html = parent::_afterToHtml($html); + return $html; + } + + /** + * Check if can use default value + * + * @param int $fieldValue + * @return boolean + */ + public function canUseDefaultValue($fieldValue) + { + if ($this->getScope() == self::SCOPE_STORES && $fieldValue) { + return true; + } + if ($this->getScope() == self::SCOPE_WEBSITES && $fieldValue) { + return true; + } + return false; + } + + /** + * Check if can use website value + * + * @param int $fieldValue + * @return boolean + */ + public function canUseWebsiteValue($fieldValue) + { + if ($this->getScope() == self::SCOPE_STORES && $fieldValue) { + return true; + } + return false; + } + + /** + * Retrieve current scope + * + * @return string + */ + public function getScope() + { + $scope = $this->getData('scope'); + if (is_null($scope)) { + if ($this->getStoreCode()) { + $scope = self::SCOPE_STORES; + } elseif ($this->getWebsiteCode()) { + $scope = self::SCOPE_WEBSITES; + } else { + $scope = self::SCOPE_DEFAULT; + } + $this->setScope($scope); + } + + return $scope; + } + + /** + * Retrieve label for scope + * + * @param Mage_Backend_Model_Config_Structure_Element_Field $field + * @return string + */ + public function getScopeLabel(Mage_Backend_Model_Config_Structure_Element_Field $field) + { + $showInStore = $field->showInStore(); + $showInWebsite = $field->showInWebsite(); + + if ($showInStore == 1) { + return $this->_scopeLabels[self::SCOPE_STORES]; + } elseif ($showInWebsite == 1) { + return $this->_scopeLabels[self::SCOPE_WEBSITES]; + } + return $this->_scopeLabels[self::SCOPE_DEFAULT]; + } + + /** + * Get current scope code + * + * @return string + */ + public function getScopeCode() + { + $scopeCode = $this->getData('scope_code'); + if (is_null($scopeCode)) { + if ($this->getStoreCode()) { + $scopeCode = $this->getStoreCode(); + } elseif ($this->getWebsiteCode()) { + $scopeCode = $this->getWebsiteCode(); + } else { + $scopeCode = ''; + } + $this->setScopeCode($scopeCode); + } + + return $scopeCode; + } + + /** + * Get current scope code + * + * @return int|string + */ + public function getScopeId() + { + $scopeId = $this->getData('scope_id'); + if (is_null($scopeId)) { + if ($this->getStoreCode()) { + $scopeId = Mage::app()->getStore($this->getStoreCode())->getId(); + } elseif ($this->getWebsiteCode()) { + $scopeId = Mage::app()->getWebsite($this->getWebsiteCode())->getId(); + } else { + $scopeId = ''; + } + $this->setScopeId($scopeId); + } + return $scopeId; + } + + /** + * Get additional element types + * + * @return array + */ + protected function _getAdditionalElementTypes() + { + return array( + 'export' => 'Mage_Backend_Block_System_Config_Form_Field_Export', + 'import' => 'Mage_Backend_Block_System_Config_Form_Field_Import', + 'allowspecific' => 'Mage_Backend_Block_System_Config_Form_Field_Select_Allowspecific', + 'image' => 'Mage_Backend_Block_System_Config_Form_Field_Image', + 'file' => 'Mage_Backend_Block_System_Config_Form_Field_File', + ); + } + + /** + * Temporary moved those $this->getRequest()->getParam('blabla') from the code accross this block + * to getBlala() methods to be later set from controller with setters + */ + /** + * Enter description here... + * + * @TODO delete this methods when {^see above^} is done + * @return string + */ + public function getSectionCode() + { + return $this->getRequest()->getParam('section', ''); + } + + /** + * Enter description here... + * + * @TODO delete this methods when {^see above^} is done + * @return string + */ + public function getWebsiteCode() + { + return $this->getRequest()->getParam('website', ''); + } + + /** + * Enter description here... + * + * @TODO delete this methods when {^see above^} is done + * @return string + */ + public function getStoreCode() + { + return $this->getRequest()->getParam('store', ''); + } +} diff --git a/app/code/Mage/Backend/Block/System/Config/Form/Field.php b/app/code/Mage/Backend/Block/System/Config/Form/Field.php new file mode 100644 index 0000000000000..4dfcc7197c9c3 --- /dev/null +++ b/app/code/Mage/Backend/Block/System/Config/Form/Field.php @@ -0,0 +1,200 @@ + + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class Mage_Backend_Block_System_Config_Form_Field + extends Mage_Backend_Block_Abstract + implements Varien_Data_Form_Element_Renderer_Interface +{ + /** + * Application + * + * @var Mage_Core_Model_App + */ + protected $_application; + + /** + * @param Mage_Core_Block_Template_Context $context + * @param Mage_Core_Model_App $application + * @param array $data + */ + public function __construct( + Mage_Core_Block_Template_Context $context, + Mage_Core_Model_App $application, + array $data = array() + ) { + $this->_application = $application; + parent::__construct($context, $data); + } + + /** + * Retrieve element HTML markup + * + * @param Varien_Data_Form_Element_Abstract $element + * @return string + */ + protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) + { + return $element->getElementHtml(); + } + + /** + * Retrieve HTML markup for given form element + * + * @param Varien_Data_Form_Element_Abstract $element + * @return string + */ + public function render(Varien_Data_Form_Element_Abstract $element) + { + $htmlId = $element->getHtmlId(); + $isCheckboxRequired = $this->_isInheritCheckboxRequired($element); + + // Disable element if value is inherited from other scope. Flag has to be set before the value is rendered. + if ($element->getInherit() == 1 && $isCheckboxRequired) { + $element->setDisabled(true); + } + + $html = ''; + $html .= ''; + $html .= $this->_renderValue($element); + + if ($isCheckboxRequired) { + $html .= $this->_renderInheritCheckbox($element); + } + + $html .= $this->_renderScopeLabel($element); + $html .= $this->_renderHint($element); + + $html .= ''; + return $html; + } + + /** + * Render element value + * + * @param Varien_Data_Form_Element_Abstract $element + * @return string + */ + protected function _renderValue(Varien_Data_Form_Element_Abstract $element) + { + $html = ''; + $html .= $this->_getElementHtml($element); + if ($element->getComment()) { + $html .= '

      ' . $element->getComment() . '

      '; + } + $html .= ''; + return $html; + } + + /** + * Render inheritance checkbox (Use Default or Use Website) + * + * @param Varien_Data_Form_Element_Abstract $element + * @return string + */ + protected function _renderInheritCheckbox(Varien_Data_Form_Element_Abstract $element) + { + $htmlId = $element->getHtmlId(); + $namePrefix = preg_replace('#\[value\](\[\])?$#', '', $element->getName()); + $checkedHtml = ($element->getInherit() == 1) ? 'checked="checked"' : ''; + + $html = ''; + $html .= ' '; + $html .= ''; + $html .= ''; + + return $html; + } + + /** + * Check if inheritance checkbox has to be rendered + * + * @param Varien_Data_Form_Element_Abstract $element + * @return bool + */ + protected function _isInheritCheckboxRequired(Varien_Data_Form_Element_Abstract $element) + { + return $element->getCanUseWebsiteValue() || $element->getCanUseDefaultValue(); + } + + /** + * Retrieve label for the inheritance checkbox + * + * @param Varien_Data_Form_Element_Abstract $element + * @return string + */ + protected function _getInheritCheckboxLabel(Varien_Data_Form_Element_Abstract $element) + { + $checkboxLabel = $this->helper('Mage_Backend_Helper_Data')->__('Use Default'); + if ($element->getCanUseWebsiteValue()) { + $checkboxLabel = $this->helper('Mage_Backend_Helper_Data')->__('Use Website'); + } + return $checkboxLabel; + } + + /** + * Render scope label + * + * @param Varien_Data_Form_Element_Abstract $element + * @return string + */ + protected function _renderScopeLabel(Varien_Data_Form_Element_Abstract $element) + { + $html = ''; + if ($element->getScope() && false == $this->_application->isSingleStoreMode()) { + $html .= $element->getScopeLabel(); + } + $html .= ''; + return $html; + } + + /** + * Render field hint + * + * @param Varien_Data_Form_Element_Abstract $element + * @return string + */ + protected function _renderHint(Varien_Data_Form_Element_Abstract $element) + { + $html = ''; + if ($element->getHint()) { + $html .= '
      ' . $element->getHint() . '
      '; + } + $html .= ''; + return $html; + } +} diff --git a/app/code/Mage/Backend/Block/System/Config/Form/Field/Array/Abstract.php b/app/code/Mage/Backend/Block/System/Config/Form/Field/Array/Abstract.php new file mode 100644 index 0000000000000..8d927caa5b9a4 --- /dev/null +++ b/app/code/Mage/Backend/Block/System/Config/Form/Field/Array/Abstract.php @@ -0,0 +1,281 @@ + + */ +abstract class Mage_Backend_Block_System_Config_Form_Field_Array_Abstract + extends Mage_Backend_Block_System_Config_Form_Field +{ + /** + * Grid columns + * + * @var array + */ + protected $_columns = array(); + + /** + * Enable the "Add after" button or not + * + * @var bool + */ + protected $_addAfter = true; + + /** + * Label of add button + * + * @var string + */ + protected $_addButtonLabel; + + /** + * Rows cache + * + * @var array|null + */ + private $_arrayRowsCache; + + /** + * Indication whether block is prepared to render or no + * + * @var bool + */ + protected $_isPreparedToRender = false; + + protected $_template = 'Mage_Backend::system/config/form/field/array.phtml'; + + /** + * Check if columns are defined, set template + * + */ + protected function _construct() + { + if (!$this->_addButtonLabel) { + $this->_addButtonLabel = $this->helper('Mage_Backend_Helper_Data')->__('Add'); + } + parent::_construct(); + + } + + /** + * Add a column to array-grid + * + * @param string $name + * @param array $params + */ + public function addColumn($name, $params) + { + $this->_columns[$name] = array( + 'label' => $this->_getParam($params, 'label', 'Column'), + 'size' => $this->_getParam($params, 'size', false), + 'style' => $this->_getParam($params, 'style'), + 'class' => $this->_getParam($params, 'class'), + 'renderer' => false, + ); + if ((!empty($params['renderer'])) && ($params['renderer'] instanceof Mage_Core_Block_Abstract)) { + $this->_columns[$name]['renderer'] = $params['renderer']; + } + } + + /** + * Returns the list of columns + * + * @return array + */ + public function getColumns() + { + return $this->_columns; + } + + /** + * Whether or not to add the "Add After" button + */ + public function isAddAfter() + { + return $this->_addAfter; + } + + /** + * Label for the Add button + * + * @return string + */ + public function getAddButtonLabel() + { + return $this->_addButtonLabel; + } + + /** + * Retrieve param + * + * @param array $params + * @param string $paramName + * @param mixed $defaultValue + * @return mixed + */ + protected function _getParam($params, $paramName, $defaultValue = null) + { + return empty($params[$paramName]) ? $defaultValue : $params[$paramName]; + } + + /** + * Get the grid and scripts contents + * + * @param Varien_Data_Form_Element_Abstract $element + * @return string + */ + protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) + { + $this->setElement($element); + $html = $this->_toHtml(); + $this->_arrayRowsCache = null; // doh, the object is used as singleton! + return $html; + } + + /** + * Prepare existing row data object + * + * @param Varien_Object + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + protected function _prepareArrayRow(Varien_Object $row) + { + // override in descendants + } + + /** + * Obtain existing data from form element + * + * Each row will be instance of Varien_Object + * + * @return array + */ + public function getArrayRows() + { + if (null !== $this->_arrayRowsCache) { + return $this->_arrayRowsCache; + } + $result = array(); + /** @var Varien_Data_Form_Element_Abstract */ + $element = $this->getElement(); + if ($element->getValue() && is_array($element->getValue())) { + foreach ($element->getValue() as $rowId => $row) { + $rowColumnValues = array(); + foreach ($row as $key => $value) { + $row[$key] = $this->escapeHtml($value); + $rowColumnValues[$this->_getCellInputElementId($rowId, $key)] = $row[$key]; + } + $row['_id'] = $rowId; + $row['column_values'] = $rowColumnValues; + $result[$rowId] = new Varien_Object($row); + $this->_prepareArrayRow($result[$rowId]); + } + } + $this->_arrayRowsCache = $result; + return $this->_arrayRowsCache; + } + + /** + * Get name for cell element + * + * @param string $rowId + * @param string $columnName + * @return string + */ + protected function _getCellInputElementId($rowId, $columnName) + { + return $rowId . '_' . $columnName; + } + + /** + * Get id for cell element + * + * @param string $columnName + * @return string + */ + protected function _getCellInputElementName($columnName) + { + return $this->getElement()->getName() . '[#{_id}][' . $columnName . ']'; + } + + /** + * Render array cell for prototypeJS template + * + * @param string $columnName + * @return string + */ + public function renderCellTemplate($columnName) + { + if (empty($this->_columns[$columnName])) { + throw new Exception('Wrong column name specified.'); + } + $column = $this->_columns[$columnName]; + $inputName = $this->_getCellInputElementName($columnName); + + if ($column['renderer']) { + return $column['renderer']->setInputName($inputName) + ->setInputId($this->_getCellInputElementId('#{_id}', $columnName)) + ->setColumnName($columnName) + ->setColumn($column) + ->toHtml(); + } + + return ''; + } + + /** + * Prepare to render + */ + protected function _prepareToRender() + { + // Override in descendants to add columns, change add button label etc + } + + /** + * Render block HTML + * + * @return string + */ + protected function _toHtml() + { + if (!$this->_isPreparedToRender) { + $this->_prepareToRender(); + $this->_isPreparedToRender = true; + } + if (empty($this->_columns)) { + throw new Exception('At least one column must be defined.'); + } + return parent::_toHtml(); + } +} diff --git a/app/code/core/Mage/Backend/Block/System/Config/Form/Field/Datetime.php b/app/code/Mage/Backend/Block/System/Config/Form/Field/Datetime.php similarity index 100% rename from app/code/core/Mage/Backend/Block/System/Config/Form/Field/Datetime.php rename to app/code/Mage/Backend/Block/System/Config/Form/Field/Datetime.php diff --git a/app/code/core/Mage/Backend/Block/System/Config/Form/Field/Export.php b/app/code/Mage/Backend/Block/System/Config/Form/Field/Export.php similarity index 100% rename from app/code/core/Mage/Backend/Block/System/Config/Form/Field/Export.php rename to app/code/Mage/Backend/Block/System/Config/Form/Field/Export.php diff --git a/app/code/Mage/Backend/Block/System/Config/Form/Field/Factory.php b/app/code/Mage/Backend/Block/System/Config/Form/Field/Factory.php new file mode 100644 index 0000000000000..0eb630173bb36 --- /dev/null +++ b/app/code/Mage/Backend/Block/System/Config/Form/Field/Factory.php @@ -0,0 +1,55 @@ +_objectManager = $objectManager; + } + + /** + * Create new config object + * + * @param array $data + * @return Mage_Backend_Block_System_Config_Form_Field + */ + public function create(array $data = array()) + { + return $this->_objectManager->create('Mage_Backend_Block_System_Config_Form_Field', $data); + } +} diff --git a/app/code/core/Mage/Backend/Block/System/Config/Form/Field/File.php b/app/code/Mage/Backend/Block/System/Config/Form/Field/File.php similarity index 100% rename from app/code/core/Mage/Backend/Block/System/Config/Form/Field/File.php rename to app/code/Mage/Backend/Block/System/Config/Form/Field/File.php diff --git a/app/code/core/Mage/Backend/Block/System/Config/Form/Field/Heading.php b/app/code/Mage/Backend/Block/System/Config/Form/Field/Heading.php similarity index 100% rename from app/code/core/Mage/Backend/Block/System/Config/Form/Field/Heading.php rename to app/code/Mage/Backend/Block/System/Config/Form/Field/Heading.php diff --git a/app/code/core/Mage/Backend/Block/System/Config/Form/Field/Image.php b/app/code/Mage/Backend/Block/System/Config/Form/Field/Image.php similarity index 100% rename from app/code/core/Mage/Backend/Block/System/Config/Form/Field/Image.php rename to app/code/Mage/Backend/Block/System/Config/Form/Field/Image.php diff --git a/app/code/core/Mage/Backend/Block/System/Config/Form/Field/Import.php b/app/code/Mage/Backend/Block/System/Config/Form/Field/Import.php similarity index 100% rename from app/code/core/Mage/Backend/Block/System/Config/Form/Field/Import.php rename to app/code/Mage/Backend/Block/System/Config/Form/Field/Import.php diff --git a/app/code/core/Mage/Backend/Block/System/Config/Form/Field/Notification.php b/app/code/Mage/Backend/Block/System/Config/Form/Field/Notification.php similarity index 100% rename from app/code/core/Mage/Backend/Block/System/Config/Form/Field/Notification.php rename to app/code/Mage/Backend/Block/System/Config/Form/Field/Notification.php diff --git a/app/code/core/Mage/Backend/Block/System/Config/Form/Field/Regexceptions.php b/app/code/Mage/Backend/Block/System/Config/Form/Field/Regexceptions.php similarity index 95% rename from app/code/core/Mage/Backend/Block/System/Config/Form/Field/Regexceptions.php rename to app/code/Mage/Backend/Block/System/Config/Form/Field/Regexceptions.php index 60cba0f35462d..6ad1897473764 100644 --- a/app/code/core/Mage/Backend/Block/System/Config/Form/Field/Regexceptions.php +++ b/app/code/Mage/Backend/Block/System/Config/Form/Field/Regexceptions.php @@ -58,7 +58,7 @@ protected function _construct() * @param string $columnName * @return string */ - protected function _renderCellTemplate($columnName) + public function renderCellTemplate($columnName) { if ($columnName == 'value' && isset($this->_columns[$columnName])) { $element = new Varien_Data_Form_Element_Select(); @@ -70,6 +70,6 @@ protected function _renderCellTemplate($columnName) return str_replace("\n", '', $element->getElementHtml()); } - return parent::_renderCellTemplate($columnName); + return parent::renderCellTemplate($columnName); } } diff --git a/app/code/core/Mage/Backend/Block/System/Config/Form/Field/Select/Allowspecific.php b/app/code/Mage/Backend/Block/System/Config/Form/Field/Select/Allowspecific.php similarity index 100% rename from app/code/core/Mage/Backend/Block/System/Config/Form/Field/Select/Allowspecific.php rename to app/code/Mage/Backend/Block/System/Config/Form/Field/Select/Allowspecific.php diff --git a/app/code/Mage/Backend/Block/System/Config/Form/Fieldset.php b/app/code/Mage/Backend/Block/System/Config/Form/Fieldset.php new file mode 100644 index 0000000000000..78812bd4bff53 --- /dev/null +++ b/app/code/Mage/Backend/Block/System/Config/Form/Fieldset.php @@ -0,0 +1,215 @@ + + */ +class Mage_Backend_Block_System_Config_Form_Fieldset + extends Mage_Backend_Block_Abstract + implements Varien_Data_Form_Element_Renderer_Interface +{ + + /** + * Render fieldset html + * + * @param Varien_Data_Form_Element_Abstract $element + * @return string + */ + public function render(Varien_Data_Form_Element_Abstract $element) + { + $html = $this->_getHeaderHtml($element); + + foreach ($element->getSortedElements() as $field) { + if ($field instanceof Varien_Data_Form_Element_Fieldset) { + $html .= '' . $field->toHtml() . ''; + } else { + $html .= $field->toHtml(); + } + } + + $html .= $this->_getFooterHtml($element); + + return $html; + } + + /** + * Return header html for fieldset + * + * @param Varien_Data_Form_Element_Abstract $element + * @return string + */ + protected function _getHeaderHtml($element) + { + $default = !$this->getRequest()->getParam('website') && !$this->getRequest()->getParam('store'); + + $html = ''; + $html = '
      ' + . '' + . '' . $element->getLegend() . '
      '; + $html .= ''; + $html .= '
      '; + $html .= '' . $element->getLegend() . ''; + + if ($element->getComment()) { + $html .= '' . $element->getComment() . ''; + } + // field label column + $html .= ''; + if (!$default) { + $html .= ''; + } + $html .= ''; + + return $html; + } + + /** + * Return full css class name for form fieldset + * + * @return string + */ + protected function _getFieldsetCss() + { + /** @var Mage_Backend_Model_Config_Structure_Element_Group $group */ + $group = $this->getGroup(); + $configCss = $group->getFieldsetCss(); + return 'config collapseable' . ($configCss ? ' ' . $configCss: ''); + } + + /** + * Return footer html for fieldset + * Add extra tooltip comments to elements + * + * @param Varien_Data_Form_Element_Abstract $element + * @return string + */ + protected function _getFooterHtml($element) + { + $tooltipsExist = false; + $html = '
      '; + foreach ($element->getSortedElements() as $field) { + if ($field->getTooltip()) { + $tooltipsExist = true; + $html .= sprintf('', + $field->getId(), $field->getTooltip() + ); + } + } + $html .= '
      ' . $this->_getExtraJs($element, $tooltipsExist); + $html .= ''; + return $html; + } + + /** + * Return js code for fieldset: + * - observe fieldset rows; + * - apply collapse; + * + * @param Varien_Data_Form_Element_Abstract $element + * @param bool $tooltipsExist Init tooltips observer or not + * @return string + */ + protected function _getExtraJs($element, $tooltipsExist = false) + { + $htmlId = $element->getHtmlId(); + $output = "Fieldset.applyCollapse('{$htmlId}');"; + if ($tooltipsExist) { + $output.= "$$('#{$htmlId} table')[0].addClassName('system-tooltip-wrap'); + $$('#{$htmlId} table tbody tr').each(function(tr) { + Event.observe(tr, 'mouseover', function (event) { + var relatedTarget = $(event.relatedTarget || event.fromElement); + if (relatedTarget && (relatedTarget == this || relatedTarget.descendantOf(this))) { + return; + } + showTooltip(event); + }); + Event.observe(tr, 'mouseout', function (event) { + var relatedTarget = $(event.relatedTarget || event.toElement); + if (relatedTarget && (relatedTarget == this || relatedTarget.childOf(this))) { + return; + } + hideTooltip(event); + }); + }); + $$('#{$htmlId} table')[0].select('input','select').each(function(field) { + Event.observe(field, 'focus', function (event) { + showTooltip(event); + }); + Event.observe(field, 'blur', function (event) { + hideTooltip(event); + }); + }); + function showTooltip(event) { + var tableHeight = Event.findElement(event, 'table').getStyle('height'); + var tr = Event.findElement(event, 'tr'); + var id = tr.id + '_comment'; + $$('div.system-tooltip-box').invoke('hide'); + if ($(id)) { + $(id).show().setStyle({height : tableHeight}); + if (document.viewport.getWidth() < 1200) { + $(id).addClassName('system-tooltip-small').setStyle({height : 'auto'}); + } else { + $(id).removeClassName('system-tooltip-small'); + } + } + }; + function hideTooltip(event) { + var tr = Event.findElement(event, 'tr'); + var id = tr.id + '_comment'; + if ($(id)) { + setTimeout(function() { $(id).hide(); }, 1); + } + };"; + } + return $this->helper('Mage_Core_Helper_Js')->getScript($output); + } + + /** + * Collapsed or expanded fieldset when page loaded? + * + * @param Varien_Data_Form_Element_Abstract $element + * @return bool + */ + protected function _isCollapseState($element) + { + if ($element->getExpanded()) { + return true; + } + $extra = Mage::getSingleton('Mage_Backend_Model_Auth_Session')->getUser()->getExtra(); + if (isset($extra['configState'][$element->getId()])) { + return $extra['configState'][$element->getId()]; + } + return false; + } +} diff --git a/app/code/Mage/Backend/Block/System/Config/Form/Fieldset/Factory.php b/app/code/Mage/Backend/Block/System/Config/Form/Fieldset/Factory.php new file mode 100644 index 0000000000000..817f1f031782d --- /dev/null +++ b/app/code/Mage/Backend/Block/System/Config/Form/Fieldset/Factory.php @@ -0,0 +1,55 @@ +_objectManager = $objectManager; + } + + /** + * Create new config object + * + * @param array $data + * @return Mage_Backend_Block_System_Config_Form_Fieldset + */ + public function create(array $data = array()) + { + return $this->_objectManager->create('Mage_Backend_Block_System_Config_Form_Fieldset', $data); + } +} diff --git a/app/code/core/Mage/Backend/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php b/app/code/Mage/Backend/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php similarity index 100% rename from app/code/core/Mage/Backend/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php rename to app/code/Mage/Backend/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php diff --git a/app/code/core/Mage/Backend/Block/System/Config/Switcher.php b/app/code/Mage/Backend/Block/System/Config/Switcher.php similarity index 100% rename from app/code/core/Mage/Backend/Block/System/Config/Switcher.php rename to app/code/Mage/Backend/Block/System/Config/Switcher.php diff --git a/app/code/core/Mage/Backend/Block/System/Config/System/Storage/Media/Synchronize.php b/app/code/Mage/Backend/Block/System/Config/System/Storage/Media/Synchronize.php similarity index 100% rename from app/code/core/Mage/Backend/Block/System/Config/System/Storage/Media/Synchronize.php rename to app/code/Mage/Backend/Block/System/Config/System/Storage/Media/Synchronize.php diff --git a/app/code/Mage/Backend/Block/System/Config/Tabs.php b/app/code/Mage/Backend/Block/System/Config/Tabs.php new file mode 100644 index 0000000000000..71c6814e4f714 --- /dev/null +++ b/app/code/Mage/Backend/Block/System/Config/Tabs.php @@ -0,0 +1,127 @@ + + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class Mage_Backend_Block_System_Config_Tabs extends Mage_Backend_Block_Widget +{ + /** + * Tabs + * + * @var Mage_Backend_Model_Config_Structure_Element_Iterator + */ + protected $_tabs; + + /** + * Block template filename + * + * @var string + */ + protected $_template = 'system/config/tabs.phtml'; + + /** + * Currently selected section id + * + * @var string + */ + protected $_currentSectionId; + + /** + * Current website code + * + * @var string + */ + protected $_websiteCode; + + /** + * Current store code + * + * @var string + */ + protected $_storeCode; + + /** + * @param Mage_Core_Block_Template_Context $context + * @param Mage_Backend_Model_Config_Structure $configStructure + * @param array $data + */ + public function __construct( + Mage_Core_Block_Template_Context $context, + Mage_Backend_Model_Config_Structure $configStructure, + array $data = array() + ) { + parent::__construct($context, $data); + $this->_tabs = $configStructure->getTabs(); + + $this->setId('system_config_tabs'); + $this->setTitle($this->helper('Mage_Backend_Helper_Data')->__('Configuration')); + $this->_currentSectionId = $this->getRequest()->getParam('section'); + + $this->helper('Mage_Backend_Helper_Data')->addPageHelpUrl($this->getRequest()->getParam('section') . '/'); + } + + /** + * Get all tabs + * + * @return Mage_Backend_Model_Config_Structure_Element_Iterator + */ + public function getTabs() + { + return $this->_tabs; + } + + /** + * Retrieve section url by section id + * + * @param Mage_Backend_Model_Config_Structure_Element_Section $section + * @return string + */ + public function getSectionUrl(Mage_Backend_Model_Config_Structure_Element_Section $section) + { + return $this->getUrl('*/*/*', array('_current' => true, 'section' => $section->getId())); + } + + /** + * Check whether section should be displayed as active + * + * @param Mage_Backend_Model_Config_Structure_Element_Section $section + * @return bool + */ + public function isSectionActive(Mage_Backend_Model_Config_Structure_Element_Section $section) + { + return $section->getId() == $this->_currentSectionId; + } +} + diff --git a/app/code/Mage/Backend/Block/Template.php b/app/code/Mage/Backend/Block/Template.php new file mode 100644 index 0000000000000..4ecfe8839b485 --- /dev/null +++ b/app/code/Mage/Backend/Block/Template.php @@ -0,0 +1,76 @@ + + * + * @SuppressWarnings(PHPMD.NumberOfChildren) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class Mage_Backend_Block_Template extends Mage_Core_Block_Template +{ + /** + * Retrieve Session Form Key + * + * @return string + */ + public function getFormKey() + { + return Mage::getSingleton('Mage_Core_Model_Session')->getFormKey(); + } + + /** + * Check whether or not the module output is enabled + * + * Because many module blocks belong to Backend module, + * the feature "Disable module output" doesn't cover Admin area + * + * @param string $moduleName Full module name + * @return boolean + */ + public function isOutputEnabled($moduleName = null) + { + if ($moduleName === null) { + $moduleName = $this->getModuleName(); + } + return !Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $moduleName); + } + + /** + * Prepare html output + * + * @return string + */ + protected function _toHtml() + { + $this->_eventManager->dispatch('adminhtml_block_html_before', array('block' => $this)); + return parent::_toHtml(); + } +} diff --git a/app/code/core/Mage/Backend/Block/Widget.php b/app/code/Mage/Backend/Block/Widget.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget.php rename to app/code/Mage/Backend/Block/Widget.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Accordion.php b/app/code/Mage/Backend/Block/Widget/Accordion.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Accordion.php rename to app/code/Mage/Backend/Block/Widget/Accordion.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Accordion/Item.php b/app/code/Mage/Backend/Block/Widget/Accordion/Item.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Accordion/Item.php rename to app/code/Mage/Backend/Block/Widget/Accordion/Item.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Breadcrumbs.php b/app/code/Mage/Backend/Block/Widget/Breadcrumbs.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Breadcrumbs.php rename to app/code/Mage/Backend/Block/Widget/Breadcrumbs.php diff --git a/app/code/Mage/Backend/Block/Widget/Button.php b/app/code/Mage/Backend/Block/Widget/Button.php new file mode 100644 index 0000000000000..0d35933615f99 --- /dev/null +++ b/app/code/Mage/Backend/Block/Widget/Button.php @@ -0,0 +1,143 @@ + + */ +class Mage_Backend_Block_Widget_Button extends Mage_Backend_Block_Widget +{ + /** + * Define block template + */ + protected function _construct() + { + $this->setTemplate('Mage_Backend::widget/button.phtml'); + parent::_construct(); + } + + /** + * Retrieve button type + * + * @return string + */ + public function getType() + { + if (in_array($this->getData('type'), array('reset', 'submit'))) { + return $this->getData('type'); + } + return 'button'; + } + + /** + * Retrieve onclick handler + * + * @return null|string + */ + public function getOnClick() + { + return $this->getData('on_click') ?: $this->getData('onclick'); + } + + /** + * Retrieve attributes html + * + * @return string + */ + public function getAttributesHtml() + { + $disabled = $this->getDisabled() ? 'disabled' : ''; + $title = $this->getTitle(); + if (!$title) { + $title = $this->getLabel(); + } + $classes = array(); + $classes[] = 'action-'; + $classes[] = 'scalable'; + if ($this->getClass()) { + $classes[] = $this->getClass(); + } + if ($disabled) { + $classes[] = $disabled; + } + + return $this->_attributesToHtml( + $this->_prepareAttributes($title, $classes, $disabled) + ); + } + + /** + * Prepare attributes + * + * @param string $title + * @param array $classes + * @param string $disabled + * @return array + */ + protected function _prepareAttributes($title, $classes, $disabled) + { + $attributes = array( + 'id' => $this->getId(), + 'name' => $this->getElementName(), + 'title' => $title, + 'type' => $this->getType(), + 'class' => join(' ', $classes), + 'onclick' => $this->getOnClick(), + 'style' => $this->getStyle(), + 'value' => $this->getValue(), + 'disabled' => $disabled + ); + if ($this->getDataAttribute()) { + foreach ($this->getDataAttribute() as $key => $attr) { + $attributes['data-' . $key] = json_encode($attr); + } + } + return $attributes; + } + + /** + * Attributes list to html + * + * @param array $attributes + * @return string + */ + protected function _attributesToHtml($attributes) + { + $html = ''; + foreach ($attributes as $attributeKey => $attributeValue) { + if ($attributeValue === null || $attributeValue == '') { + continue; + } + $html .= $attributeKey . '="' + . $this->helper('Mage_Backend_Helper_Data')->escapeHtml($attributeValue) . '" '; + } + + return $html; + } +} diff --git a/app/code/Mage/Backend/Block/Widget/Button/Split.php b/app/code/Mage/Backend/Block/Widget/Button/Split.php new file mode 100644 index 0000000000000..502f0ae4d89c6 --- /dev/null +++ b/app/code/Mage/Backend/Block/Widget/Button/Split.php @@ -0,0 +1,265 @@ +setTemplate('Mage_Backend::widget/button/split.phtml'); + parent::_construct(); + } + + /** + * Retrieve
      wrapper attributes html + * + * @return string + */ + public function getAttributesHtml() + { + $title = $this->getTitle(); + if (!$title) { + $title = $this->getLabel(); + } + $classes = array(); + if ($this->hasSplit()) { + $classes[] = 'actions-split'; + } + //@TODO Perhaps use $this->getClass() instead + if ($this->getButtonClass()) { + $classes[] = $this->getButtonClass(); + } + + $attributes = array( + 'id' => $this->getId(), + 'title' => $title, + 'class' => join(' ', $classes), + ); + + $html = $this->_getAttributesString($attributes); + + return $html; + } + + /** + * Retrieve button attributes html + * + * @return string + */ + public function getButtonAttributesHtml() + { + $disabled = $this->getDisabled() ? 'disabled' : ''; + $title = $this->getTitle(); + if (!$title) { + $title = $this->getLabel(); + } + $classes = array(); + $classes[] = 'action-default'; + $classes[] = 'primary'; + // @TODO Perhaps use $this->getButtonClass() instead + if ($this->getClass()) { + $classes[] = $this->getClass(); + } + if ($disabled) { + $classes[] = $disabled; + } + $attributes = array( + 'id' => $this->getId() . '-button', + 'title' => $title, + 'class' => join(' ', $classes), + 'disabled' => $disabled, + 'style' => $this->getStyle(), + ); + + //TODO perhaps we need to skip data-mage-init when disabled="disabled" + if ($this->getDataAttribute()) { + $this->_getDataAttributes($this->getDataAttribute(), $attributes); + } + + $html = $this->_getAttributesString($attributes); + $html .= $this->getUiId(); + + return $html; + } + + /** + * Retrieve toggle button attributes html + * + * @return string + */ + public function getToggleAttributesHtml() + { + $disabled = $this->getDisabled() ? 'disabled' : ''; + $title = $this->getTitle(); + if (!$title) { + $title = $this->getLabel(); + } + $classes = array(); + $classes[] = 'action-toggle'; + $classes[] = 'primary'; + if ($this->getClass()) { + $classes[] = $this->getClass(); + } + if ($disabled) { + $classes[] = $disabled; + } + + $attributes = array( + 'title' => $title, + 'class' => join(' ', $classes), + 'disabled' => $disabled + ); + $this->_getDataAttributes(array('toggle' => 'dropdown'), $attributes); + + $html = $this->_getAttributesString($attributes); + $html .= $this->getUiId('dropdown'); + + return $html; + } + + /** + * Retrieve options attributes html + * + * @param string $key + * @param array $option + * @return string + * @SuppressWarnings(PHPMD.NPathComplexity) + */ + public function getOptionAttributesHtml($key, $option) + { + $disabled = (isset($option['disabled']) && $option['disabled']) ? 'disabled' : ''; + if (isset($option['title'])) { + $title = $option['title']; + } else { + $title = $option['label']; + } + $classes = array(); + $classes[] = 'item'; + if (!empty($option['default'])) { + $classes[] = 'item-default'; + } + if ($disabled) { + $classes[] = $disabled; + } + $attributes = $this->_prepareOptionAttributes($option, $title, $classes, $disabled); + $html = $this->_getAttributesString($attributes); + $html .= $this->getUiId(isset($option['id']) ? $option['id'] : 'item' . '-' . $key); + + return $html; + } + + /** + * Checks if the button needs actions-split functionality + * + * If this function returns false then split button will be rendered as simple button + * + * @return bool + */ + public function hasSplit() + { + return true; + } + + /** + * Add data attributes to $attributes array + * + * @param array $data + * @param array $attributes + */ + protected function _getDataAttributes($data, &$attributes) + { + foreach ($data as $key => $attr) { + if (is_scalar($attr)) { + $attributes['data-' . $key] = $attr; + } else { + $attributes['data-' . $key] = json_encode($attr); + } + } + } + + /** + * Prepare option attributes + * + * @param array $option + * @param string $title + * @param string $classes + * @param string $disabled + * @return array + * @SuppressWarnings(PHPMD.NPathComplexity) + */ + protected function _prepareOptionAttributes($option, $title, $classes, $disabled) + { + $attributes = array( + 'id' => isset($option['id']) ? $this->getId() . '-' . $option['id'] : '', + 'title' => $title, + 'class' => join(' ', $classes), + 'onclick' => isset($option['onclick']) ? $option['onclick'] : '', + 'style' => isset($option['style']) ? $option['style'] : '', + 'disabled' => $disabled, + ); + + if (isset($option['data_attribute'])) { + $this->_getDataAttributes($option['data_attribute'], $attributes); + } + + return $attributes; + } + + /** + * Render attributes array as attributes string + * + * @param array $attributes + * @return string + */ + protected function _getAttributesString($attributes) + { + /** @var $helper Mage_Backend_Helper_Data */ + $helper = $this->helper('Mage_Backend_Helper_Data'); + + $html = array(); + foreach ($attributes as $attributeKey => $attributeValue) { + if ($attributeValue === null || $attributeValue == '') { + continue; + } + $html[] = $attributeKey . '="' . $helper->escapeHtml($attributeValue) . '"'; + } + return join(' ', $html); + } +} diff --git a/app/code/core/Mage/Backend/Block/Widget/Container.php b/app/code/Mage/Backend/Block/Widget/Container.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Container.php rename to app/code/Mage/Backend/Block/Widget/Container.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Form.php b/app/code/Mage/Backend/Block/Widget/Form.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Form.php rename to app/code/Mage/Backend/Block/Widget/Form.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Form/Container.php b/app/code/Mage/Backend/Block/Widget/Form/Container.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Form/Container.php rename to app/code/Mage/Backend/Block/Widget/Form/Container.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Form/Element.php b/app/code/Mage/Backend/Block/Widget/Form/Element.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Form/Element.php rename to app/code/Mage/Backend/Block/Widget/Form/Element.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Form/Element/Dependence.php b/app/code/Mage/Backend/Block/Widget/Form/Element/Dependence.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Form/Element/Dependence.php rename to app/code/Mage/Backend/Block/Widget/Form/Element/Dependence.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Form/Element/Gallery.php b/app/code/Mage/Backend/Block/Widget/Form/Element/Gallery.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Form/Element/Gallery.php rename to app/code/Mage/Backend/Block/Widget/Form/Element/Gallery.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Form/Renderer/Element.php b/app/code/Mage/Backend/Block/Widget/Form/Renderer/Element.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Form/Renderer/Element.php rename to app/code/Mage/Backend/Block/Widget/Form/Renderer/Element.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Form/Renderer/Fieldset.php b/app/code/Mage/Backend/Block/Widget/Form/Renderer/Fieldset.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Form/Renderer/Fieldset.php rename to app/code/Mage/Backend/Block/Widget/Form/Renderer/Fieldset.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Form/Renderer/Fieldset/Element.php b/app/code/Mage/Backend/Block/Widget/Form/Renderer/Fieldset/Element.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Form/Renderer/Fieldset/Element.php rename to app/code/Mage/Backend/Block/Widget/Form/Renderer/Fieldset/Element.php diff --git a/app/code/Mage/Backend/Block/Widget/Grid.php b/app/code/Mage/Backend/Block/Widget/Grid.php new file mode 100644 index 0000000000000..3530e496d1604 --- /dev/null +++ b/app/code/Mage/Backend/Block/Widget/Grid.php @@ -0,0 +1,850 @@ + + * + * @method string getRowClickCallback() getRowClickCallback() + * @method Mage_Backend_Block_Widget_Grid setRowClickCallback() setRowClickCallback(string $value) + */ +class Mage_Backend_Block_Widget_Grid extends Mage_Backend_Block_Widget +{ + /** + * Page and sorting var names + * + * @var string + */ + protected $_varNameLimit = 'limit'; + protected $_varNamePage = 'page'; + protected $_varNameSort = 'sort'; + protected $_varNameDir = 'dir'; + protected $_varNameFilter = 'filter'; + + protected $_defaultLimit = 20; + protected $_defaultPage = 1; + protected $_defaultSort = false; + protected $_defaultDir = 'desc'; + protected $_defaultFilter = array(); + + /** + * Empty grid text + * + * @var string|null + */ + protected $_emptyText; + + /** + * Empty grid text CSS class + * + * @var string|null + */ + protected $_emptyTextCss = 'a-center'; + + /** + * Pager visibility + * + * @var boolean + */ + protected $_pagerVisibility = true; + + /** + * Massage block visibility + * + * @var boolean + */ + protected $_messageBlockVisibility = false; + + /** + * Should parameters be saved in session + * + * @var bool + */ + protected $_saveParametersInSession = false; + + /** + * Count totals + * + * @var boolean + */ + protected $_countTotals = false; + + /** + * Totals + * + * @var Varien_Object + */ + protected $_varTotals; + + /** + * RSS list + * + * @var array + */ + protected $_rssLists = array(); + + protected $_template = 'Mage_Backend::widget/grid.phtml'; + + protected function _construct() + { + parent::_construct(); + + if (!$this->getRowClickCallback()) { + $this->setRowClickCallback('openGridRow'); + } + + if ($this->hasData('id')) { + $this->setId($this->getData('id')); + } + + if ($this->hasData('default_sort')) { + $this->setDefaultSort($this->getData('default_sort')); + } + + if ($this->hasData('default_dir')) { + $this->setDefaultDir($this->getData('default_dir')); + } + + if ($this->hasData('save_parameters_in_session')) { + $this->setSaveParametersInSession($this->getData('save_parameters_in_session')); + } + + if ($this->hasData('grid_css_class')) { + $this->setGridCssClass($this->getData('grid_css_class')); + } + + $this->setPagerVisibility($this->hasData('pager_visibility')? (bool) $this->getData('pager_visibility') : true); + + $this->setData( + 'use_ajax', + $this->hasData('use_ajax') ? (bool) $this->getData('use_ajax') : false + ); + + if ($this->hasData('rssList') && is_array($this->getData('rssList'))) { + foreach ($this->getData('rssList') as $item) { + $this->addRssList($item['url'], $item['label']); + } + } + } + + /** + * Set collection object + * + * @param Varien_Data_Collection $collection + */ + public function setCollection($collection) + { + $this->setData('dataSource', $collection); + } + + /** + * Get collection object + * + * @return Varien_Data_Collection + */ + public function getCollection() + { + return $this->getData('dataSource'); + } + + /** + * Retrieve column set block + * + * @return Mage_Backend_Block_Widget_Grid_ColumnSet + */ + public function getColumnSet() + { + return $this->getChildBlock('grid.columnSet'); + } + + /** + * Retrieve export block + * + * @throws Mage_Core_Exception + * @return Mage_Core_Block_Abstract + */ + public function getExportBlock() + { + if (!$this->getChildBlock('grid.export')) { + Mage::throwException('Export block for grid ' . $this->getNameInLayout() . ' is not defined'); + } + return $this->getChildBlock('grid.export'); + } + + /** + * Retrieve list of grid columns + * + * @return array + */ + public function getColumns() + { + return $this->getColumnSet()->getColumns(); + } + + /** + * Count grid columns + * + * @return int + */ + public function getColumnCount() + { + return count($this->getColumns()); + } + + /** + * Retrieve column by id + * + * @param string $columnId + * @return Mage_Core_Block_Abstract + */ + public function getColumn($columnId) + { + return $this->getColumnSet()->getChildBlock($columnId); + } + + /** + * Process column filtration values + * + * @param mixed $data + * @return Mage_Backend_Block_Widget_Grid + */ + protected function _setFilterValues($data) + { + foreach ($this->getColumns() as $columnId => $column) { + if (isset($data[$columnId]) + && ((is_array($data[$columnId]) && !empty($data[$columnId])) || strlen($data[$columnId]) > 0) + && $column->getFilter() + ) { + $column->getFilter()->setValue($data[$columnId]); + $this->_addColumnFilterToCollection($column); + } + } + return $this; + } + + /** + * Add column filtering conditions to collection + * + * @param Mage_Backend_Block_Widget_Grid_Column $column + * @return Mage_Backend_Block_Widget_Grid + */ + protected function _addColumnFilterToCollection($column) + { + if ($this->getCollection()) { + $field = ( $column->getFilterIndex() ) ? $column->getFilterIndex() : $column->getIndex(); + if ($column->getFilterConditionCallback()) { + call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column); + } else { + $condition = $column->getFilter()->getCondition(); + if ($field && isset($condition)) { + $this->getCollection()->addFieldToFilter($field, $condition); + } + } + } + return $this; + } + + /** + * Sets sorting order by some column + * + * @param Mage_Backend_Block_Widget_Grid_Column $column + * @return Mage_Backend_Block_Widget_Grid + */ + protected function _setCollectionOrder($column) + { + $collection = $this->getCollection(); + if ($collection) { + $columnIndex = $column->getFilterIndex() ? + $column->getFilterIndex() : $column->getIndex(); + $collection->setOrder($columnIndex, strtoupper($column->getDir())); + } + return $this; + } + + /** + * Get prepared collection + * + * @return Varien_Data_Collection + */ + public function getPreparedCollection() + { + $this->_prepareCollection(); + return $this->getCollection(); + } + + /** + * Apply sorting and filtering to collection + * + * @return Mage_Backend_Block_Widget_Grid + */ + protected function _prepareCollection() + { + if ($this->getCollection()) { + + $this->_preparePage(); + + $columnId = $this->getParam($this->getVarNameSort(), $this->_defaultSort); + $dir = $this->getParam($this->getVarNameDir(), $this->_defaultDir); + $filter = $this->getParam($this->getVarNameFilter(), null); + + if (is_null($filter)) { + $filter = $this->_defaultFilter; + } + + if (is_string($filter)) { + $data = $this->helper('Mage_Backend_Helper_Data')->prepareFilterString($filter); + $this->_setFilterValues($data); + } else if ($filter && is_array($filter)) { + $this->_setFilterValues($filter); + } else if (0 !== sizeof($this->_defaultFilter)) { + $this->_setFilterValues($this->_defaultFilter); + } + + if ($this->getColumn($columnId) && $this->getColumn($columnId)->getIndex()) { + $dir = (strtolower($dir)=='desc') ? 'desc' : 'asc'; + $this->getColumn($columnId)->setDir($dir); + $this->_setCollectionOrder($this->getColumn($columnId)); + } + } + + return $this; + } + + /** + * Decode URL encoded filter value recursive callback method + * + * @var string $value + */ + protected function _decodeFilter(&$value) + { + $value = $this->helper('Mage_Backend_Helper_Data')->decodeFilter($value); + } + + /** + * Apply pagination to collection + */ + protected function _preparePage() + { + $this->getCollection()->setPageSize((int) $this->getParam($this->getVarNameLimit(), $this->_defaultLimit)); + $this->getCollection()->setCurPage((int) $this->getParam($this->getVarNamePage(), $this->_defaultPage)); + } + + /** + * Initialize grid + */ + protected function _prepareGrid() + { + if ($this->getChildBlock('grid.massaction') && $this->getChildBlock('grid.massaction')->isAvailable()) { + $this->getChildBlock('grid.massaction')->prepareMassactionColumn(); + } + + $this->_prepareCollection(); + if ($this->hasColumnRenderers()) { + foreach ($this->getColumnRenderers() as $renderer => $rendererClass) { + $this->getColumnSet()->setRendererType($renderer, $rendererClass); + } + } + if ($this->hasColumnFilters()) { + foreach ($this->getColumnFilters() as $filter => $filterClass) { + $this->getColumnSet()->setFilterType($filter, $filterClass); + } + } + $this->getColumnSet()->setSortable($this->getSortable()); + $this->_prepareFilterButtons(); + } + + /** + * Get massaction block + * + * @return bool|Mage_Core_Block_Abstract + */ + public function getMassactionBlock() + { + return $this->getChildBlock('grid.massaction'); + } + + /** + * Prepare grid filter buttons + */ + protected function _prepareFilterButtons() + { + $this->setChild('reset_filter_button', + $this->getLayout()->createBlock('Mage_Backend_Block_Widget_Button') + ->setData(array( + 'label' => Mage::helper('Mage_Backend_Helper_Data')->__('Reset Filter'), + 'onclick' => $this->getJsObjectName().'.resetFilter()', + )) + ); + $this->setChild('search_button', + $this->getLayout()->createBlock('Mage_Backend_Block_Widget_Button') + ->setData(array( + 'label' => Mage::helper('Mage_Backend_Helper_Data')->__('Search'), + 'onclick' => $this->getJsObjectName().'.doFilter()', + 'class' => 'task' + )) + ); + } + + /** + * Initialize grid before rendering + * + * @return Mage_Core_Block_Abstract + */ + protected function _beforeToHtml() + { + $this->_prepareGrid(); + return parent::_beforeToHtml(); + } + + /** + * Retrieve limit request key + * + * @return string + */ + public function getVarNameLimit() + { + return $this->_varNameLimit; + } + + /** + * Retrieve page request key + * + * @return string + */ + public function getVarNamePage() + { + return $this->_varNamePage; + } + + /** + * Retrieve sort request key + * + * @return string + */ + public function getVarNameSort() + { + return $this->_varNameSort; + } + + /** + * Retrieve sort direction request key + * + * @return string + */ + public function getVarNameDir() + { + return $this->_varNameDir; + } + + /** + * Retrieve filter request key + * + * @return string + */ + public function getVarNameFilter() + { + return $this->_varNameFilter; + } + + /** + * Set Limit request key + * + * @param string $name + * @return Mage_Backend_Block_Widget_Grid + */ + public function setVarNameLimit($name) + { + $this->_varNameLimit = $name; + return $this; + } + + /** + * Set Page request key + * + * @param string $name + * @return Mage_Backend_Block_Widget_Grid + */ + public function setVarNamePage($name) + { + $this->_varNamePage = $name; + return $this; + } + + /** + * Set Sort request key + * + * @param string $name + * @return Mage_Backend_Block_Widget_Grid + */ + public function setVarNameSort($name) + { + $this->_varNameSort = $name; + return $this; + } + + /** + * Set Sort Direction request key + * + * @param string $name + * @return Mage_Backend_Block_Widget_Grid + */ + public function setVarNameDir($name) + { + $this->_varNameDir = $name; + return $this; + } + + /** + * Set Filter request key + * + * @param string $name + * @return Mage_Backend_Block_Widget_Grid + */ + public function setVarNameFilter($name) + { + $this->_varNameFilter = $name; + return $this; + } + + /** + * Set visibility of pager + * + * @param boolean $visible + * @return Mage_Backend_Block_Widget_Grid + */ + public function setPagerVisibility($visible = true) + { + $this->_pagerVisibility = $visible; + return $this; + } + + /** + * Return visibility of pager + * + * @return boolean + */ + public function getPagerVisibility() + { + return $this->_pagerVisibility; + } + + /** + * Set visibility of message blocks + * + * @param boolean $visible + */ + public function setMessageBlockVisibility($visible = true) + { + $this->_messageBlockVisibility = $visible; + } + + /** + * Return visibility of message blocks + * + * @return boolean + */ + public function getMessageBlockVisibility() + { + return $this->_messageBlockVisibility; + } + + /** + * Set default limit + * + * @param int $limit + * @return Mage_Backend_Block_Widget_Grid + */ + public function setDefaultLimit($limit) + { + $this->_defaultLimit = $limit; + return $this; + } + + /** + * Set default page + * + * @param int $page + * @return Mage_Backend_Block_Widget_Grid + */ + public function setDefaultPage($page) + { + $this->_defaultPage = $page; + return $this; + } + + /** + * Set default sort + * + * @param string $sort + * @return Mage_Backend_Block_Widget_Grid + */ + public function setDefaultSort($sort) + { + $this->_defaultSort = $sort; + return $this; + } + + /** + * Set default direction + * + * @param string $dir + * @return Mage_Backend_Block_Widget_Grid + */ + public function setDefaultDir($dir) + { + $this->_defaultDir = $dir; + return $this; + } + + /** + * Set default filter + * + * @param string $filter + * @return Mage_Backend_Block_Widget_Grid + */ + public function setDefaultFilter($filter) + { + $this->_defaultFilter = $filter; + return $this; + } + + /** + * Retrieve rss lists types + * + * @return array|bool + */ + public function getRssLists() + { + return empty($this->_rssLists) ? false : $this->_rssLists; + } + + /** + * Returns url for RSS + * Can be overloaded in descendant classes to perform custom changes to url passed to addRssList() + * + * @param string $url + * @return string + */ + protected function _getRssUrl($url) + { + $urlModel = Mage::getModel('Mage_Core_Model_Url'); + if (Mage::app()->getStore()->getStoreInUrl()) { + // Url in 'admin' store view won't be accessible, so form it in default store view frontend + $urlModel->setStore(Mage::app()->getDefaultStoreView()); + } + return $urlModel->getUrl($url); + } + + /** + * Add new rss list to grid + * + * @param string $url + * @param string $label + * @return Mage_Backend_Block_Widget_Grid + */ + public function addRssList($url, $label) + { + $this->_rssLists[] = new Varien_Object( + array( + 'url' => $this->_getRssUrl($url), + 'label' => $label + ) + ); + return $this; + } + + /** + * Clear rss list in grid + * + * @return Mage_Backend_Block_Widget_Grid + */ + public function clearRss() + { + $this->_rssLists = array(); + return $this; + } + + /** + * Check whether grid container should be displayed + * + * @return bool + */ + public function canDisplayContainer() + { + if ($this->getRequest()->getQuery('ajax')) { + return false; + } + return true; + } + + /** + * Retrieve grid reload url + * + * @return string; + */ + public function getGridUrl() + { + return $this->hasData('grid_url') ? $this->getData('grid_url') : $this->getAbsoluteGridUrl(); + } + + /** + * Grid url getter + * Version of getGridUrl() but with parameters + * + * @param array $params url parameters + * @return string current grid url + */ + public function getAbsoluteGridUrl($params = array()) + { + return $this->getCurrentUrl($params); + } + + /** + * Retrieve grid + * + * @param string $paramName + * @param mixed $default + * @return mixed + */ + public function getParam($paramName, $default=null) + { + $session = Mage::getSingleton('Mage_Backend_Model_Session'); + $sessionParamName = $this->getId() . $paramName; + if ($this->getRequest()->has($paramName)) { + $param = $this->getRequest()->getParam($paramName); + if ($this->_saveParametersInSession) { + $session->setData($sessionParamName, $param); + } + return $param; + } elseif ($this->_saveParametersInSession && ($param = $session->getData($sessionParamName))) { + return $param; + } + + return $default; + } + + /** + * Set whether grid parameters should be saved in session + * + * @param bool $flag + * @return Mage_Backend_Block_Widget_Grid + */ + public function setSaveParametersInSession($flag) + { + $this->_saveParametersInSession = $flag; + return $this; + } + + /** + * Retrieve grid javascript object name + * + * @return string + */ + public function getJsObjectName() + { + return $this->getId() . 'JsObject'; + } + + /** + * Set count totals + * + * @param boolean $count + * @return Mage_Backend_Block_Widget_Grid + */ + public function setCountTotals($count = true) + { + $this->_countTotals = $count; + return $this; + } + + /** + * Return count totals + * + * @return boolean + */ + public function getCountTotals() + { + return $this->_countTotals; + } + + /** + * Set totals + * + * @param Varien_Object $totals + */ + public function setTotals(Varien_Object $totals) + { + $this->_varTotals = $totals; + } + + /** + * Retrieve totals + * + * @return Varien_Object + */ + public function getTotals() + { + return $this->_varTotals; + } + + /** + * Generate list of grid buttons + * + * @return string + */ + public function getMainButtonsHtml() + { + $html = ''; + if ($this->getColumnSet()->isFilterVisible()) { + $html.= $this->getResetFilterButtonHtml(); + $html.= $this->getSearchButtonHtml(); + } + return $html; + } + + /** + * Generate reset button + * + * @return string + */ + public function getResetFilterButtonHtml() + { + return $this->getChildHtml('reset_filter_button'); + } + + /** + * Generate search button + * + * @return string + */ + public function getSearchButtonHtml() + { + return $this->getChildHtml('search_button'); + } +} diff --git a/app/code/Mage/Backend/Block/Widget/Grid/Column.php b/app/code/Mage/Backend/Block/Widget/Grid/Column.php new file mode 100644 index 0000000000000..a044c93e13bcc --- /dev/null +++ b/app/code/Mage/Backend/Block/Widget/Grid/Column.php @@ -0,0 +1,502 @@ + + */ +class Mage_Backend_Block_Widget_Grid_Column extends Mage_Backend_Block_Widget +{ + /** + * Parent grid + * + * @var Mage_Backend_Block_Widget_Grid + */ + protected $_grid; + + /** + * Column renderer + * + * @var Mage_Backend_Block_Widget_Grid_Column_Renderer_Abstract + */ + protected $_renderer; + + /** + * Column filter + * + * @var Mage_Backend_Block_Widget_Grid_Column_Filter_Abstract + */ + protected $_filter; + + /** + * Column css classes + * + * @var string|null + */ + protected $_cssClass=null; + + /** + * Renderer types + * + * @var array + */ + protected $_rendererTypes = array( + 'action' => 'Mage_Backend_Block_Widget_Grid_Column_Renderer_Action', + 'button' => 'Mage_Backend_Block_Widget_Grid_Column_Renderer_Button', + 'checkbox' => 'Mage_Backend_Block_Widget_Grid_Column_Renderer_Checkbox', + 'concat' => 'Mage_Backend_Block_Widget_Grid_Column_Renderer_Concat', + 'country' => 'Mage_Backend_Block_Widget_Grid_Column_Renderer_Country', + 'currency' => 'Mage_Backend_Block_Widget_Grid_Column_Renderer_Currency', + 'date' => 'Mage_Backend_Block_Widget_Grid_Column_Renderer_Date', + 'datetime' => 'Mage_Backend_Block_Widget_Grid_Column_Renderer_Datetime', + 'default' => 'Mage_Backend_Block_Widget_Grid_Column_Renderer_Text', + 'grip' => 'Mage_Backend_Block_Widget_Grid_Column_Renderer_Grip', + 'input' => 'Mage_Backend_Block_Widget_Grid_Column_Renderer_Input', + 'massaction' => 'Mage_Backend_Block_Widget_Grid_Column_Renderer_Massaction', + 'number' => 'Mage_Backend_Block_Widget_Grid_Column_Renderer_Number', + 'options' => 'Mage_Backend_Block_Widget_Grid_Column_Renderer_Options', + 'price' => 'Mage_Backend_Block_Widget_Grid_Column_Renderer_Price', + 'radio' => 'Mage_Backend_Block_Widget_Grid_Column_Renderer_Radio', + 'select' => 'Mage_Backend_Block_Widget_Grid_Column_Renderer_Select', + 'store' => 'Mage_Backend_Block_Widget_Grid_Column_Renderer_Store', + 'text' => 'Mage_Backend_Block_Widget_Grid_Column_Renderer_Longtext', + 'wrapline' => 'Mage_Backend_Block_Widget_Grid_Column_Renderer_Wrapline', + ); + + /** + * Filter types + * + * @var array + */ + protected $_filterTypes = array( + 'datetime' => 'Mage_Backend_Block_Widget_Grid_Column_Filter_Datetime', + 'date' => 'Mage_Backend_Block_Widget_Grid_Column_Filter_Date', + 'range' => 'Mage_Backend_Block_Widget_Grid_Column_Filter_Range', + 'number' => 'Mage_Backend_Block_Widget_Grid_Column_Filter_Range', + 'currency' => 'Mage_Backend_Block_Widget_Grid_Column_Filter_Range', + 'price' => 'Mage_Backend_Block_Widget_Grid_Column_Filter_Price', + 'country' => 'Mage_Backend_Block_Widget_Grid_Column_Filter_Country', + 'options' => 'Mage_Backend_Block_Widget_Grid_Column_Filter_Select', + 'massaction' => 'Mage_Backend_Block_Widget_Grid_Column_Filter_Massaction', + 'checkbox' => 'Mage_Backend_Block_Widget_Grid_Column_Filter_Checkbox', + 'radio' => 'Mage_Backend_Block_Widget_Grid_Column_Filter_Radio', + 'store' => 'Mage_Backend_Block_Widget_Grid_Column_Filter_Store', + 'theme' => 'Mage_Backend_Block_Widget_Grid_Column_Filter_Theme', + 'default' => 'Mage_Backend_Block_Widget_Grid_Column_Filter_Text', + ); + + /** + * Column is grouped + * @var bool + */ + protected $_isGrouped = false; + + public function _construct() + { + if ($this->hasData('grouped')) { + $this->_isGrouped = (bool) $this->getData('grouped'); + } + + parent::_construct(); + } + + /** + * Should column be displayed in grid + * + * @return bool + */ + public function isDisplayed() + { + return true; + } + + /** + * Set grid block to column + * + * @param Mage_Backend_Block_Widget_Grid $grid + * @return Mage_Backend_Block_Widget_Grid_Column + */ + public function setGrid($grid) + { + $this->_grid = $grid; + // Init filter object + $this->getFilter(); + return $this; + } + + /** + * Get grid block + * + * @return Mage_Backend_Block_Widget_Grid + */ + public function getGrid() + { + return $this->_grid; + } + + /** + * Get html code for column properties + * + * @return string + */ + public function getHtmlProperty() + { + return $this->getRenderer()->renderProperty(); + } + + /** + * Get Header html + * @return string + */ + public function getHeaderHtml() + { + return $this->getRenderer()->renderHeader(); + } + + /** + * Get column css classes + * + * @return string + */ + public function getCssClass() + { + if ($this->_cssClass === null) { + if ($this->getAlign()) { + $this->_cssClass .= 'a-' . $this->getAlign(); + } + // Add a custom css class for column + if ($this->hasData('column_css_class')) { + $this->_cssClass .= ' ' . $this->getData('column_css_class'); + } + if ($this->getEditable()) { + $this->_cssClass .= ' editable'; + } + $this->_cssClass .= ' col-' . $this->getId(); + } + return $this->_cssClass; + } + + /** + * Get column css property + * + * @return string + */ + public function getCssProperty() + { + return $this->getRenderer()->renderCss(); + } + + /** + * Set is column sortable + * + * @param boolean $value + */ + public function setSortable($value) + { + $this->setData('sortable', $value); + } + + /** + * Get header css class name + * @return string + */ + public function getHeaderCssClass() + { + $class = $this->getData('header_css_class'); + $class .= false === $this->getSortable() ? ' no-link' : ''; + $class .= ' col-' . $this->getId(); + return $class; + } + + /** + * @return bool + */ + public function getSortable() + { + return $this->hasData('sortable') ? (bool) $this->getData('sortable') : true; + } + + /** + * Add css class to column header + * @param $className + */ + public function addHeaderCssClass($className) + { + $classes = $this->getData('header_css_class') ? $this->getData('header_css_class') . ' ' : ''; + $this->setData('header_css_class', $classes . $className); + } + + /** + * Get header class names + * @return string + */ + public function getHeaderHtmlProperty() + { + $str = ''; + if ($class = $this->getHeaderCssClass()) { + $str.= ' class="'.$class.'"'; + } + + return $str; + } + + /** + * Retrieve row column field value for display + * + * @param Varien_Object $row + * @return string + */ + public function getRowField(Varien_Object $row) + { + $renderedValue = $this->getRenderer()->render($row); + if ($this->getHtmlDecorators()) { + $renderedValue = $this->_applyDecorators($renderedValue, $this->getHtmlDecorators()); + } + + /* + * if column has determined callback for framing call + * it before give away rendered value + * + * callback_function($renderedValue, $row, $column, $isExport) + * should return new version of rendered value + */ + $frameCallback = $this->getFrameCallback(); + if (is_array($frameCallback)) { + $renderedValue = call_user_func($frameCallback, $renderedValue, $row, $this, false); + } + + return $renderedValue; + } + + /** + * Retrieve row column field value for export + * + * @param Varien_Object $row + * @return string + */ + public function getRowFieldExport(Varien_Object $row) + { + $renderedValue = $this->getRenderer()->renderExport($row); + + /* + * if column has determined callback for framing call + * it before give away rendered value + * + * callback_function($renderedValue, $row, $column, $isExport) + * should return new version of rendered value + */ + $frameCallback = $this->getFrameCallback(); + if (is_array($frameCallback)) { + $renderedValue = call_user_func($frameCallback, $renderedValue, $row, $this, true); + } + + return $renderedValue; + } + + /** + * Retrieve Header Name for Export + * + * @return string + */ + public function getExportHeader() + { + if ($this->getHeaderExport()) { + return $this->getHeaderExport(); + } + return $this->getHeader(); + } + + /** + * Decorate rendered cell value + * + * @param string $value + * @param array|string $decorators + * @return string + */ + protected function &_applyDecorators($value, $decorators) + { + if (!is_array($decorators)) { + if (is_string($decorators)) { + $decorators = explode(' ', $decorators); + } + } + if ((!is_array($decorators)) || empty($decorators)) { + return $value; + } + switch (array_shift($decorators)) { + case 'nobr': + $value = '' . $value . ''; + break; + } + if (!empty($decorators)) { + return $this->_applyDecorators($value, $decorators); + } + return $value; + } + + /** + * Set column renderer + * + * @param Mage_Backend_Block_Widget_Grid_Column_Renderer_Abstract $renderer + * @return Mage_Backend_Block_Widget_Grid_Column + */ + public function setRenderer($renderer) + { + $this->_renderer = $renderer; + return $this; + } + + /** + * Set renderer type class name + * + * @param string $type type of renderer + * @param string $className renderer class name + */ + public function setRendererType($type, $className) + { + $this->_rendererTypes[$type] = $className; + } + + /** + * Get renderer class name by renderer type + * + * @return string + */ + protected function _getRendererByType() + { + $type = strtolower($this->getType()); + $rendererClass = (isset($this->_rendererTypes[$type])) ? + $this->_rendererTypes[$type] : + $this->_rendererTypes['default']; + + return $rendererClass; + } + + /** + * Retrieve column renderer + * + * @return Mage_Backend_Block_Widget_Grid_Column_Renderer_Abstract + */ + public function getRenderer() + { + if (is_null($this->_renderer)) { + $rendererClass = $this->getData('renderer'); + if (empty($rendererClass)) { + $rendererClass = $this->_getRendererByType(); + } + $this->_renderer = $this->getLayout()->createBlock($rendererClass) + ->setColumn($this); + } + return $this->_renderer; + } + + /** + * Set column filter + * + * @param string $filterClass filter class name + */ + public function setFilter($filterClass) + { + $filterBlock = $this->getLayout()->createBlock($filterClass); + $filterBlock->setColumn($this); + $this->_filter = $filterBlock; + } + + /** + * Set filter type class name + * @param string $type type of filter + * @param string $className filter class name + */ + public function setFilterType($type, $className) + { + $this->_filterTypes[$type] = $className; + } + + /** + * Get column filter class name by filter type + * + * @return mixed + */ + protected function _getFilterByType() + { + $type = strtolower($this->getType()); + $filterClass = (isset($this->_filterTypes[$type])) ? + $this->_filterTypes[$type] : + $this->_filterTypes['default']; + + return $filterClass; + } + + /** + * Get filter block + * + * @return Mage_Backend_Block_Widget_Grid_Column_Filter_Abstract|bool + */ + public function getFilter() + { + if (is_null($this->_filter)) { + $filterClass = $this->getData('filter'); + if (false === (bool) $filterClass && false === is_null($filterClass)) { + return false; + } + if (!$filterClass) { + $filterClass = $this->_getFilterByType(); + if ($filterClass === false) { + return false; + } + } + $this->_filter = $this->getLayout()->createBlock($filterClass) + ->setColumn($this); + } + + return $this->_filter; + } + + /** + * Get filter html code + * + * @return null|string + */ + public function getFilterHtml() + { + $filter = $this->getFilter(); + $output = $filter ? $filter->getHtml() : ' '; + return $output; + } + + /** + * Check if column is grouped + * + * @return bool + */ + public function isGrouped() + { + return $this->_isGrouped; + } +} diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Filter/Abstract.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Abstract.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Filter/Abstract.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Abstract.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Filter/Checkbox.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Checkbox.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Filter/Checkbox.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Checkbox.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Filter/Country.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Country.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Filter/Country.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Country.php diff --git a/app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Date.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Date.php new file mode 100644 index 0000000000000..69eb872c04e63 --- /dev/null +++ b/app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Date.php @@ -0,0 +1,177 @@ + + * @todo date format + */ +class Mage_Backend_Block_Widget_Grid_Column_Filter_Date extends Mage_Backend_Block_Widget_Grid_Column_Filter_Abstract +{ + protected $_locale; + + protected function _prepareLayout() + { + if ($head = $this->getLayout()->getBlock('head')) { + $head->setCanLoadCalendarJs(true); + } + return $this; + } + + public function getHtml() + { + $htmlId = Mage::helper('Mage_Core_Helper_Data')->uniqHash($this->_getHtmlId()); + $format = $this->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); + $html = '
      ' + . 'getUiId('filter', $this->_getHtmlName(), 'from') . '/>' + . '
      '; + $html .= '
      ' + . 'getUiId('filter', $this->_getHtmlName(), 'to') . '/>' + . '
      '; + $html .= ''; + $html .= ''; + return $html; + } + + public function getEscapedValue($index=null) + { + $value = $this->getValue($index); + if ($value instanceof Zend_Date) { + return $value->toString($this->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)); + } + return $value; + } + + public function getValue($index=null) + { + if ($index) { + if ($data = $this->getData('value', 'orig_' . $index)) { + return $data;//date('Y-m-d', strtotime($data)); + } + return null; + } + $value = $this->getData('value'); + if (is_array($value)) { + $value['date'] = true; + } + return $value; + } + + public function getCondition() + { + $value = $this->getValue(); + + return $value; + } + + public function setValue($value) + { + if (isset($value['locale'])) { + if (!empty($value['from'])) { + $value['orig_from'] = $value['from']; + $value['from'] = $this->_convertDate($value['from'], $value['locale']); + } + if (!empty($value['to'])) { + $value['orig_to'] = $value['to']; + $value['to'] = $this->_convertDate($value['to'], $value['locale']); + } + } + if (empty($value['from']) && empty($value['to'])) { + $value = null; + } + $this->setData('value', $value); + return $this; + } + + /** + * Retrieve locale + * + * @return Mage_Core_Model_Locale + */ + public function getLocale() + { + if (!$this->_locale) { + $this->_locale = Mage::app()->getLocale(); + } + return $this->_locale; + } + + /** + * Convert given date to default (UTC) timezone + * + * @param string $date + * @param string $locale + * @return Zend_Date + */ + protected function _convertDate($date, $locale) + { + try { + $dateObj = $this->getLocale()->date(null, null, $locale, false); + + //set default timezone for store (admin) + $dateObj->setTimezone( + Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE) + ); + + //set begining of day + $dateObj->setHour(00); + $dateObj->setMinute(00); + $dateObj->setSecond(00); + + //set date with applying timezone of store + $dateObj->set($date, Zend_Date::DATE_SHORT, $locale); + + //convert store date to default date in UTC timezone without DST + $dateObj->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE); + + return $dateObj; + } catch (Exception $e) { + return null; + } + } +} diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Filter/Datetime.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Datetime.php similarity index 96% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Filter/Datetime.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Datetime.php index e42059d3add67..d3dff798f0eff 100644 --- a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Filter/Datetime.php +++ b/app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Datetime.php @@ -116,15 +116,13 @@ public function getHtml() } $html = '
      ' - . '' . $this->__('From') . ':' . 'getUiId('filter', $this->_getHtmlName(), 'from') . '/>' . '
      '; $html .= '
      ' - . '' . $this->__('To') . ' :' . 'getUiId('filter', $this->_getHtmlName(), 'to') . '/>' . '
      '; $html .= ' + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class Mage_Backend_Block_Widget_Grid_Column_Filter_Price extends Mage_Backend_Block_Widget_Grid_Column_Filter_Abstract +{ + /** + * @var array + */ + protected $_currencyList = null; + + /** + * @var Mage_Directory_Model_Currency + */ + protected $_currencyModel = null; + + /** + * @var Mage_Directory_Model_Currency_DefaultLocator + */ + protected $_currencyLocator = null; + + /** + * @param Mage_Core_Block_Template_Context $context + * @param Mage_Directory_Model_Currency $currencyModel + * @param Mage_Directory_Model_Currency_DefaultLocator $currencyLocator + * @param array $data + */ + public function __construct( + Mage_Core_Block_Template_Context $context, + Mage_Directory_Model_Currency $currencyModel, + Mage_Directory_Model_Currency_DefaultLocator $currencyLocator, + array $data = array() + ) { + parent::__construct($context, $data); + $this->_currencyModel = $currencyModel; + $this->_currencyLocator = $currencyLocator; + } + + /** + * Retrieve html + * + * @return string + */ + public function getHtml() + { + $html = '
      '; + $html .= '
      ' + . 'getUiId('filter', $this->_getHtmlName(), 'from') . '/>
      '; + $html .= '
      ' + . 'getUiId('filter', $this->_getHtmlName(), 'to') . '/>
      '; + + if ($this->getDisplayCurrencySelect()) { + $html .= '
      ' . $this->_getCurrencySelectHtml() . '
      '; + } + + $html .= '
      '; + + return $html; + } + + /** + * Retrieve display currency select + * + * @return bool|mixed + */ + public function getDisplayCurrencySelect() + { + if (!is_null($this->getColumn()->getData('display_currency_select'))) { + return $this->getColumn()->getData('display_currency_select'); + } else { + return true; + } + } + + /** + * Retrieve currency affect + * + * @return bool|mixed + */ + public function getCurrencyAffect() + { + if (!is_null($this->getColumn()->getData('currency_affect'))) { + return $this->getColumn()->getData('currency_affect'); + } else { + return true; + } + } + + /** + * Retrieve currency select html + * + * @return string + */ + protected function _getCurrencySelectHtml() + { + $value = $this->getEscapedValue('currency'); + if (!$value) { + $value = $this->_getColumnCurrencyCode(); + } + + $html = ''; + $html .= ''; + return $html; + } + + /** + * Retrieve list of currencies + * + * @return array|null + */ + protected function _getCurrencyList() + { + if (is_null($this->_currencyList)) { + $this->_currencyList = $this->_currencyModel->getConfigAllowCurrencies(); + } + return $this->_currencyList; + } + + /** + * Retrieve filter value + * + * @param null $index + * @return mixed|null + */ + public function getValue($index=null) + { + if ($index) { + return $this->getData('value', $index); + } + $value = $this->getData('value'); + if ((isset($value['from']) && strlen($value['from']) > 0) + || (isset($value['to']) && strlen($value['to']) > 0) + ) { + return $value; + } + return null; + } + + /** + * Retrieve filter condition + * + * @return array|mixed|null + */ + public function getCondition() + { + $value = $this->getValue(); + + if (isset($value['currency']) && $this->getCurrencyAffect()) { + $displayCurrency = $value['currency']; + } else { + $displayCurrency = $this->_getColumnCurrencyCode(); + } + $rate = $this->_getRate($displayCurrency, $this->_getColumnCurrencyCode()); + + if (isset($value['from'])) { + $value['from'] *= $rate; + } + + if (isset($value['to'])) { + $value['to'] *= $rate; + } + + $this->prepareRates($displayCurrency); + return $value; + } + + /** + * Retrieve column currency code + * + * @return string + */ + protected function _getColumnCurrencyCode() + { + return $this->getColumn()->getCurrencyCode()? + $this->getColumn()->getCurrencyCode() : $this->_currencyLocator->getDefaultCurrency($this->_request); + } + + /** + * Get currency rate + * + * @param $fromRate + * @param $toRate + * @return float + */ + protected function _getRate($fromRate, $toRate) + { + return $this->_currencyModel->load($fromRate)->getAnyRate($toRate); + } + + /** + * Prepare currency rates + * + * @param $displayCurrency + */ + public function prepareRates($displayCurrency) + { + $storeCurrency = $this->_getColumnCurrencyCode(); + + $rate = $this->_getRate($storeCurrency, $displayCurrency); + if ($rate) { + $this->getColumn()->setRate($rate); + $this->getColumn()->setCurrencyCode($displayCurrency); + } + } +} diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Filter/Radio.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Radio.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Filter/Radio.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Radio.php diff --git a/app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Range.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Range.php new file mode 100644 index 0000000000000..69788d150f448 --- /dev/null +++ b/app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Range.php @@ -0,0 +1,71 @@ + + */ +class Mage_Backend_Block_Widget_Grid_Column_Filter_Range extends Mage_Backend_Block_Widget_Grid_Column_Filter_Abstract +{ + public function getHtml() + { + $html = '
      ' + . 'getUiId('filter', $this->_getHtmlName(), 'from') . '/>
      '; + $html .= '
      ' + . 'getUiId('filter', $this->_getHtmlName(), 'to') . '/>
      '; + return $html; + } + + public function getValue($index=null) + { + if ($index) { + return $this->getData('value', $index); + } + $value = $this->getData('value'); + if ((isset($value['from']) && strlen($value['from']) > 0) + || (isset($value['to']) && strlen($value['to']) > 0) + ) { + return $value; + } + return null; + } + + public function getCondition() + { + $value = $this->getValue(); + return $value; + } +} diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Filter/Select.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Select.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Filter/Select.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Select.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Filter/Store.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Store.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Filter/Store.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Store.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Filter/Text.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Text.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Filter/Text.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Text.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Filter/Theme.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Theme.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Filter/Theme.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Filter/Theme.php diff --git a/app/code/Mage/Backend/Block/Widget/Grid/Column/Multistore.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Multistore.php new file mode 100644 index 0000000000000..b7f48e2413226 --- /dev/null +++ b/app/code/Mage/Backend/Block/Widget/Grid/Column/Multistore.php @@ -0,0 +1,66 @@ + + */ +class Mage_Backend_Block_Widget_Grid_Column_Multistore extends Mage_Backend_Block_Widget_Grid_Column +{ + /** + * Store manager + * + * @var Mage_Core_Model_StoreManager + */ + protected $_storeManager; + + /** + * @param Mage_Core_Block_Template_Context $context + * @param Mage_Core_Model_StoreManager $storeManager + * @param array $data + */ + public function __construct( + Mage_Core_Block_Template_Context $context, + Mage_Core_Model_StoreManager $storeManager, + array $data = array() + ) { + parent::__construct($context, $data); + $this->_storeManager = $storeManager; + } + + /** + * Get header css class name + * + * @return string + */ + public function isDisplayed() + { + return !$this->_storeManager->isSingleStoreMode(); + } +} diff --git a/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Abstract.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Abstract.php new file mode 100644 index 0000000000000..aa4f770d54fd3 --- /dev/null +++ b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Abstract.php @@ -0,0 +1,151 @@ + + */ + +abstract class Mage_Backend_Block_Widget_Grid_Column_Renderer_Abstract + extends Mage_Backend_Block_Abstract implements Mage_Backend_Block_Widget_Grid_Column_Renderer_Interface +{ + protected $_defaultWidth; + protected $_column; + + public function setColumn($column) + { + $this->_column = $column; + return $this; + } + + /** @return Mage_Backend_Block_Widget_Grid_Column */ + public function getColumn() + { + return $this->_column; + } + + /** + * Renders grid column + * + * @param Varien_Object $row + * @return string + */ + public function render(Varien_Object $row) + { + if ($this->getColumn()->getEditable()) { + $value = $this->_getValue($row); + return $value + . ($this->getColumn()->getEditOnly() ? '' : ($value != '' ? '' : ' ')) + . $this->_getInputValueElement($row); + } + return $this->_getValue($row); + } + + /** + * Render column for export + * + * @param Varien_Object $row + * @return string + */ + public function renderExport(Varien_Object $row) + { + return $this->render($row); + } + + protected function _getValue(Varien_Object $row) + { + if ($getter = $this->getColumn()->getGetter()) { + if (is_string($getter)) { + return $row->$getter(); + } elseif (is_callable($getter)) { + return call_user_func($getter, $row); + } + return ''; + } + return $row->getData($this->getColumn()->getIndex()); + } + + public function _getInputValueElement(Varien_Object $row) + { + return ''; + } + + protected function _getInputValue(Varien_Object $row) + { + return $this->_getValue($row); + } + + public function renderHeader() + { + if (false !== $this->getColumn()->getSortable()) { + $className = 'not-sort'; + $dir = strtolower($this->getColumn()->getDir()); + $nDir= ($dir=='asc') ? 'desc' : 'asc'; + if ($this->getColumn()->getDir()) { + $className = 'sort-arrow-' . $dir; + } + $out = '' + . $this->getColumn()->getHeader().''; + } else { + $out = $this->getColumn()->getHeader(); + } + return $out; + } + + public function renderProperty() + { + $out = ''; + $width = $this->_defaultWidth; + + if ($this->getColumn()->hasData('width')) { + $customWidth = $this->getColumn()->getData('width'); + if ((null === $customWidth) || (preg_match('/^[0-9]+%?$/', $customWidth))) { + $width = $customWidth; + } elseif (preg_match('/^([0-9]+)px$/', $customWidth, $matches)) { + $width = (int)$matches[1]; + } + } + + if (null !== $width) { + $out .= ' width="' . $width . '"'; + } + + return $out; + } + + public function renderCss() + { + return $this->getColumn()->getCssClass(); + } + +} diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Action.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Action.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Action.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Action.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Button.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Button.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Button.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Button.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Checkbox.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Checkbox.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Checkbox.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Checkbox.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Concat.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Concat.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Concat.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Concat.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Country.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Country.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Country.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Country.php diff --git a/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Currency.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Currency.php new file mode 100644 index 0000000000000..35576d5148b85 --- /dev/null +++ b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Currency.php @@ -0,0 +1,148 @@ + + */ + +class Mage_Backend_Block_Widget_Grid_Column_Renderer_Currency + extends Mage_Backend_Block_Widget_Grid_Column_Renderer_Abstract +{ + protected $_defaultWidth = 100; + + /** + * Currency objects cache + */ + protected static $_currencies = array(); + + /** + * Application object + * + * @var Mage_Core_Model_App + */ + protected $_app; + + /** + * Locale + * + * @var Mage_Core_Model_Locale + */ + protected $_locale; + + /** + * @var Mage_Directory_Model_Currency_DefaultLocator + */ + protected $_currencyLocator; + + /** + * @param Mage_Core_Block_Template_Context $context + * @param Mage_Core_Model_App $app + * @param Mage_Core_Model_Locale $locale + * @param Mage_Directory_Model_Currency_DefaultLocator $currencyLocator + * @param array $data + */ + public function __construct( + Mage_Core_Block_Template_Context $context, + Mage_Core_Model_App $app, + Mage_Core_Model_Locale $locale, + Mage_Directory_Model_Currency_DefaultLocator $currencyLocator, + array $data = array() + ) { + parent::__construct($context, $data); + $this->_app = $app; + $this->_locale = $locale; + $this->_currencyLocator = $currencyLocator; + } + + + /** + * Renders grid column + * + * @param Varien_Object $row + * @return string + */ + public function render(Varien_Object $row) + { + if ($data = (string)$row->getData($this->getColumn()->getIndex())) { + $currency_code = $this->_getCurrencyCode($row); + $data = floatval($data) * $this->_getRate($row); + $sign = (bool)(int)$this->getColumn()->getShowNumberSign() && ($data > 0) ? '+' : ''; + $data = sprintf("%f", $data); + $data = $this->_locale->currency($currency_code)->toCurrency($data); + return $sign . $data; + } + return $this->getColumn()->getDefault(); + } + + /** + * Returns currency code, false on error + * + * @param $row + * @return string + */ + protected function _getCurrencyCode($row) + { + if ($code = $this->getColumn()->getCurrencyCode()) { + return $code; + } + if ($code = $row->getData($this->getColumn()->getCurrency())) { + return $code; + } + + return $this->_currencyLocator->getDefaultCurrency($this->_request); + } + + /** + * Get rate for current row, 1 by default + * + * @param $row + * @return float|int + */ + protected function _getRate($row) + { + if ($rate = $this->getColumn()->getRate()) { + return floatval($rate); + } + if ($rate = $row->getData($this->getColumn()->getRateField())) { + return floatval($rate); + } + return $this->_app->getStore()->getBaseCurrency()->getRate($this->_getCurrencyCode($row)); + } + + /** + * Returns HTML for CSS + * + * @return string + */ + public function renderCss() + { + return parent::renderCss() . ' a-right'; + } +} diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Date.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Date.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Date.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Date.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Datetime.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Datetime.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Datetime.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Datetime.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Grip.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Grip.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Grip.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Grip.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Input.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Input.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Input.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Input.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Interface.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Interface.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Interface.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Interface.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Ip.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Ip.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Ip.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Ip.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Longtext.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Longtext.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Longtext.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Longtext.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Massaction.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Massaction.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Massaction.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Massaction.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Number.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Number.php similarity index 97% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Number.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Number.php index 809c7bd8d878e..57ee8afe48906 100644 --- a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Number.php +++ b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Number.php @@ -63,7 +63,7 @@ protected function _getValue(Varien_Object $row) */ public function renderCss() { - return parent::renderCss() . ' a-right'; + return parent::renderCss() . ' col-number'; } } diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Options.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Options.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Options.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Options.php diff --git a/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Price.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Price.php new file mode 100644 index 0000000000000..6bd30fe7fec5b --- /dev/null +++ b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Price.php @@ -0,0 +1,109 @@ + + */ +class Mage_Backend_Block_Widget_Grid_Column_Renderer_Price + extends Mage_Backend_Block_Widget_Grid_Column_Renderer_Abstract +{ + protected $_defaultWidth = 100; + /** + * Currency objects cache + */ + protected static $_currencies = array(); + + /** + * Renders grid column + * + * @param Varien_Object $row + * @return string + */ + public function render(Varien_Object $row) + { + if ($data = $row->getData($this->getColumn()->getIndex())) { + $currencyCode = $this->_getCurrencyCode($row); + + if (!$currencyCode) { + return $data; + } + + $data = floatval($data) * $this->_getRate($row); + $data = sprintf("%f", $data); + $data = Mage::app()->getLocale()->currency($currencyCode)->toCurrency($data); + return $data; + } + return $this->getColumn()->getDefault(); + } + + /** + * Returns currency code for the row, false on error + * + * @param Varien_Object $row + * @return string|bool + */ + protected function _getCurrencyCode($row) + { + if ($code = $this->getColumn()->getCurrencyCode()) { + return $code; + } + if ($code = $row->getData($this->getColumn()->getCurrency())) { + return $code; + } + return false; + } + + /** + * Returns rate for the row, 1 by default + * + * @param Varien_Object $row + * @return float|int + */ + protected function _getRate($row) + { + if ($rate = $this->getColumn()->getRate()) { + return floatval($rate); + } + if ($rate = $row->getData($this->getColumn()->getRateField())) { + return floatval($rate); + } + return 1; + } + + /** + * Renders CSS + * + * @return string + */ + public function renderCss() + { + return parent::renderCss() . ' col-price'; + } +} diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Radio.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Radio.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Radio.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Radio.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Select.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Select.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Select.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Select.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Store.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Store.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Store.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Store.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Text.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Text.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Text.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Text.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Wrapline.php b/app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Wrapline.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Column/Renderer/Wrapline.php rename to app/code/Mage/Backend/Block/Widget/Grid/Column/Renderer/Wrapline.php diff --git a/app/code/Mage/Backend/Block/Widget/Grid/ColumnSet.php b/app/code/Mage/Backend/Block/Widget/Grid/ColumnSet.php new file mode 100644 index 0000000000000..092b590dffaf2 --- /dev/null +++ b/app/code/Mage/Backend/Block/Widget/Grid/ColumnSet.php @@ -0,0 +1,653 @@ +_helper = $helper; + + $generatorClassName = 'Mage_Backend_Model_Widget_Grid_Row_UrlGenerator'; + if (isset($data['rowUrl'])) { + $rowUrlParams = $data['rowUrl']; + if (isset($rowUrlParams['generatorClass'])) { + $generatorClassName = $rowUrlParams['generatorClass']; + } + $this->_rowUrlGenerator + = $generatorFactory->createUrlGenerator($generatorClassName, array('args' => $rowUrlParams)); + } + + $this->setFilterVisibility( + array_key_exists('filter_visibility', $data) ? (bool) $data['filter_visibility'] : true + ); + + parent::__construct($context, $data); + + $this->setEmptyText($this->_helper->__( + isset($data['empty_text'])? $data['empty_text'] : 'No records found.' + )); + + $this->setEmptyCellLabel($this->_helper->__( + isset($data['empty_cell_label'])? $data['empty_cell_label'] : 'No records found.' + )); + + $this->setCountSubTotals(isset($data['count_subtotals'])? (bool) $data['count_subtotals'] : false); + $this->_subTotals = $subtotals; + + $this->setCountTotals(isset($data['count_totals'])? (bool) $data['count_totals'] : false); + $this->_totals = $totals; + } + + /** + * Retrieve the list of columns + * + * @return array + */ + public function getColumns() + { + $columns = $this->getLayout()->getChildBlocks($this->getNameInLayout()); + foreach ($columns as $key => $column) { + if (!$column->isDisplayed()) { + unset($columns[$key]); + } + } + return $columns; + } + + /** + * Count columns + * + * @return int + */ + public function getColumnCount() + { + return count($this->getColumns()); + } + + /** + * Set sortability flag for columns + * + * @param bool $value + * @return Mage_Backend_Block_Widget_Grid_ColumnSet + */ + public function setSortable($value) + { + if ($value === false) { + foreach ($this->getColumns() as $column) { + $column->setSortable(false); + } + } + return $this; + } + + /** + * Set custom renderer type for columns + * + * @param string $type + * @param string $className + * @return Mage_Backend_Block_Widget_Grid_ColumnSet + */ + public function setRendererType($type, $className) + { + foreach ($this->getColumns() as $column) { + $column->setRendererType($type, $className); + } + return $this; + } + + /** + * Set custom filter type for columns + * + * @param string $type + * @param string $className + * @return Mage_Backend_Block_Widget_Grid_ColumnSet + */ + public function setFilterType($type, $className) + { + foreach ($this->getColumns() as $column) { + $column->setFilterType($type, $className); + } + return $this; + } + + /** + * Prepare block for rendering + * + * @return Mage_Core_Block_Abstract + */ + protected function _beforeToHtml() + { + $columns = $this->getColumns(); + foreach ($columns as $columnId => $column) { + $column->setId($columnId); + $column->setGrid($this->getGrid()); + if ($column->isGrouped()) { + $this->isColumnGrouped($column->getIndex(), true); + } + } + $last = array_pop($columns); + if ($last) { + $last->addHeaderCssClass('last'); + } + } + + /** + * Return row url for js event handlers + * + * @param Varien_Object $item + * @return string + */ + public function getRowUrl($item) + { + $url = '#'; + if (null !== $this->_rowUrlGenerator) { + $url = $this->_rowUrlGenerator->getUrl($item); + } + return $url; + } + + /** + * Get children of specified item + * + * @param Varien_Object $item + * @return array + */ + public function getMultipleRows($item) + { + return $item->getChildren(); + } + + /** + * Has children of specified item + * + * @param Varien_Object $item + * @return bool + */ + public function hasMultipleRows($item) + { + return $item->hasChildren() && count($item->getChildren()) > 0; + } + + /** + * Retrieve columns for multiple rows + * @return array + */ + public function getMultipleRowColumns() + { + $columns = $this->getColumns(); + foreach ($this->_groupedColumn as $column) { + unset($columns[$column]); + } + return $columns; + } + + /** + * Check whether subtotal should be rendered + * + * @param Varien_Object $item + * @return boolean + */ + public function shouldRenderSubTotal($item) + { + return ($this->getCountSubTotals() && + count($this->getMultipleRows($item)) > 0 + ); + } + + /** + * Check whether total should be rendered + * + * @return boolean + */ + public function shouldRenderTotal() + { + return ($this->getCountTotals() && + count($this->getCollection()) > 0 + ); + } + + /** + * Retrieve rowspan number + * + * @param Varien_Object $item + * @param Mage_Backend_Block_Widget_Grid_Column $column + * @return integer|boolean + */ + public function getRowspan($item, $column) + { + if ($this->isColumnGrouped($column)) { + return count($this->getMultipleRows($item)) + count($this->_groupedColumn) - 1 + + (int)$this->shouldRenderSubTotal($item); + } + return false; + } + + /** + * Check whether given column is grouped + * + * @param string|object $column + * @param string $value + * @return boolean|Mage_Backend_Block_Widget_Grid + */ + public function isColumnGrouped($column, $value = null) + { + if (null === $value) { + if (is_object($column)) { + return in_array($column->getIndex(), $this->_groupedColumn); + } + return in_array($column, $this->_groupedColumn); + } + $this->_groupedColumn[] = $column; + return $this; + } + + /** + * Check whether should render empty cell + * + * @param Varien_Object $item + * @param Mage_Backend_Block_Widget_Grid_Column $column + * @return boolean + */ + public function shouldRenderEmptyCell($item, $column) + { + return ($item->getIsEmpty() && in_array($column['index'], $this->_groupedColumn)); + } + + /** + * Retrieve colspan for empty cell + * + * @return int + */ + public function getEmptyCellColspan() + { + return $this->getColumnCount() - count($this->_groupedColumn); + } + + /** + * Check whether should render cell + * + * @param Varien_Object $item + * @param Mage_Backend_Block_Widget_Grid_Column $column + * @return boolean + */ + public function shouldRenderCell($item, $column) + { + if ($this->isColumnGrouped($column) && $item->getIsEmpty()) { + return true; + } + if (!$item->getIsEmpty()) { + return true; + } + return false; + } + + /** + * Set visibility of column headers + * + * @param boolean $visible + */ + public function setHeadersVisibility($visible = true) + { + $this->_headersVisibility = $visible; + } + + /** + * Return visibility of column headers + * + * @return boolean + */ + public function isHeaderVisible() + { + return $this->_headersVisibility; + } + + /** + * Set visibility of filter + * + * @param boolean $visible + */ + public function setFilterVisibility($visible = true) + { + $this->_filterVisibility = $visible; + } + + /** + * Return visibility of filter + * + * @return boolean + */ + public function isFilterVisible() + { + return $this->_filterVisibility; + } + + /** + * Set empty text CSS class + * + * @param string $cssClass + * @return Mage_Backend_Block_Widget_Grid + */ + public function setEmptyTextClass($cssClass) + { + $this->_emptyTextCss = $cssClass; + return $this; + } + + /** + * Return empty text CSS class + * + * @return string + */ + public function getEmptyTextClass() + { + return $this->_emptyTextCss; + } + + /** + * Retrieve label for empty cell + * + * @return string + */ + public function getEmptyCellLabel() + { + return $this->_emptyCellLabel; + } + + /** + * Set label for empty cell + * + * @param string $label + * @return Mage_Backend_Block_Widget_Grid_ColumnSet + */ + public function setEmptyCellLabel($label) + { + $this->_emptyCellLabel = $label; + return $this; + } + + /** + * Set flag whether is collapsed + * @param $isCollapsed + * @return Mage_Backend_Block_Widget_Grid_ColumnSet + */ + public function setIsCollapsed($isCollapsed) + { + $this->_isCollapsed = $isCollapsed; + return $this; + } + + /** + * Retrieve flag is collapsed + * @return mixed + */ + public function getIsCollapsed() + { + return $this->_isCollapsed; + } + + /** + * Return grid of current column set + * @return Mage_Backend_Block_Widget_Grid + */ + public function getGrid() + { + return $this->getParentBlock(); + } + + /** + * Return collection of current grid + * @return Varien_Data_Collection + */ + public function getCollection() + { + return $this->getGrid()->getCollection(); + } + + /** + * Set subtotals + * + * @param boolean $flag + * @return Mage_Backend_Block_Widget_Grid + */ + public function setCountSubTotals($flag = true) + { + $this->_countSubTotals = $flag; + return $this; + } + + /** + * Return count subtotals + * + * @return mixed + */ + public function getCountSubTotals() + { + return $this->_countSubTotals; + } + + /** + * Set totals + * + * @param boolean $flag + * @return Mage_Backend_Block_Widget_Grid + */ + public function setCountTotals($flag = true) + { + $this->_countTotals = $flag; + return $this; + } + + /** + * Return count totals + * + * @return mixed + */ + public function getCountTotals() + { + return $this->_countTotals; + } + + /** + * Retrieve subtotal for item + * + * @param $item Varien_Object + * @return Varien_Object + */ + public function getSubTotals($item) + { + $this->_prepareSubTotals(); + $this->_subTotals->reset(); + return $this->_subTotals->countTotals($item->getChildren()); + } + + /** + * Retrieve subtotal items + * + * @return Varien_Object + */ + public function getTotals() + { + $this->_prepareTotals(); + $this->_totals->reset(); + return $this->_totals->countTotals($this->getCollection()); + } + + /** + * Update item with first sub-item data + * + * @param $item Varien_Object + */ + public function updateItemByFirstMultiRow(Varien_Object $item) + { + $multiRows = $this->getMultipleRows($item); + if (is_object($multiRows) && $multiRows instanceof Varien_Data_Collection) { + /** @var $multiRows Varien_Data_Collection */ + $item->addData($multiRows->getFirstItem()->getData()); + } elseif (is_array($multiRows)) { + $firstItem = $multiRows[0]; + $item->addData($firstItem); + } + } + + /** + * Prepare sub-total object for counting sub-totals + */ + public function _prepareSubTotals() + { + $columns = $this->_subTotals->getColumns(); + if (empty($columns)) { + foreach ($this->getMultipleRowColumns() as $column) { + if ($column->getTotal()) { + $this->_subTotals->setColumn($column->getIndex(), $column->getTotal()); + } + } + } + } + + /** + * Prepare total object for counting totals + */ + public function _prepareTotals() + { + $columns = $this->_totals->getColumns(); + if (empty($columns)) { + foreach ($this->getColumns() as $column) { + if ($column->getTotal()) { + $this->_totals->setColumn($column->getIndex(), $column->getTotal()); + } + } + } + } + +} diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Container.php b/app/code/Mage/Backend/Block/Widget/Grid/Container.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Container.php rename to app/code/Mage/Backend/Block/Widget/Grid/Container.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Export.php b/app/code/Mage/Backend/Block/Widget/Grid/Export.php similarity index 99% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Export.php rename to app/code/Mage/Backend/Block/Widget/Grid/Export.php index 94ea3b58f16cd..c624154e529a7 100644 --- a/app/code/core/Mage/Backend/Block/Widget/Grid/Export.php +++ b/app/code/Mage/Backend/Block/Widget/Grid/Export.php @@ -288,6 +288,7 @@ public function getCsvFile() $file = $this->_exportPath . DS . $name . '.csv'; $this->_filesystem->setIsAllowCreateDirectories(true); + $this->_filesystem->ensureDirectoryExists($this->_exportPath); $stream = $this->_filesystem->createAndOpenStream($file, 'w+', $this->_exportPath); $stream->writeCsv($this->_getExportHeaders()); @@ -414,6 +415,7 @@ public function getExcelFile($sheetName = '') $file = $this->_exportPath . DS . $name . '.xml'; $this->_filesystem->setIsAllowCreateDirectories(true); + $this->_filesystem->ensureDirectoryExists($this->_exportPath); $stream = $this->_filesystem->createAndOpenStream($file, 'w+', $this->_exportPath); $stream->lock(true); diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/ExportInterface.php b/app/code/Mage/Backend/Block/Widget/Grid/ExportInterface.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/ExportInterface.php rename to app/code/Mage/Backend/Block/Widget/Grid/ExportInterface.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Extended.php b/app/code/Mage/Backend/Block/Widget/Grid/Extended.php similarity index 99% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Extended.php rename to app/code/Mage/Backend/Block/Widget/Grid/Extended.php index 7fec3edcac081..a10993bd497e8 100644 --- a/app/code/core/Mage/Backend/Block/Widget/Grid/Extended.php +++ b/app/code/Mage/Backend/Block/Widget/Grid/Extended.php @@ -422,8 +422,9 @@ protected function _prepareMassactionColumn() 'filter_index' => $this->getMassactionIdFilter(), 'type' => 'massaction', 'name' => $this->getMassactionBlock()->getFormFieldName(), - 'align' => 'center', - 'is_system' => true + 'is_system' => true, + 'header_css_class' => 'col-select', + 'column_css_class' => 'col-select' )); if ($this->getNoFilterMassactionColumn()) { diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Massaction.php b/app/code/Mage/Backend/Block/Widget/Grid/Massaction.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Massaction.php rename to app/code/Mage/Backend/Block/Widget/Grid/Massaction.php diff --git a/app/code/Mage/Backend/Block/Widget/Grid/Massaction/Abstract.php b/app/code/Mage/Backend/Block/Widget/Grid/Massaction/Abstract.php new file mode 100644 index 0000000000000..25b19f0feea44 --- /dev/null +++ b/app/code/Mage/Backend/Block/Widget/Grid/Massaction/Abstract.php @@ -0,0 +1,342 @@ + + */ +abstract class Mage_Backend_Block_Widget_Grid_Massaction_Abstract extends Mage_Backend_Block_Widget +{ + /** + * Backend data helper + * + * @var Mage_Backend_Helper_Data + */ + protected $_backendHelper; + + /** + * Massaction items + * + * @var array + */ + protected $_items = array(); + + protected $_template = 'Mage_Backend::widget/grid/massaction.phtml'; + + protected function _construct() + { + parent::_construct(); + + $this->setErrorText($this->helper('Mage_Backend_Helper_Data') + ->jsQuoteEscape($this->helper('Mage_Backend_Helper_Data')->__('Please select items.'))); + + if (null !== $this->getOptions()) { + foreach ($this->getOptions() as $optionId => $option) { + $this->addItem($optionId, $option); + } + $this->unsetData('options'); + } + } + + /** + * Add new massaction item + * + * $item = array( + * 'label' => string, + * 'complete' => string, // Only for ajax enabled grid (optional) + * 'url' => string, + * 'confirm' => string, // text of confirmation of this action (optional) + * 'additional' => string // (optional) + * ); + * + * @param string $itemId + * @param array|Varien_Object $item + * @return Mage_Backend_Block_Widget_Grid_Massaction_Abstract + */ + public function addItem($itemId, $item) + { + if (is_array($item)) { + $item = new Varien_Object($item); + } + + if ($item instanceof Varien_Object) { + $item->setId($itemId); + $item->setUrl($this->getUrl($item->getUrl())); + $this->_items[$itemId] = $item; + } + + return $this; + } + + /** + * Retrieve massaction item with id $itemId + * + * @param string $itemId + * @return Mage_Backend_Block_Widget_Grid_Massaction_Item + */ + public function getItem($itemId) + { + if (isset($this->_items[$itemId])) { + return $this->_items[$itemId]; + } + + return null; + } + + /** + * Retrieve massaction items + * + * @return array + */ + public function getItems() + { + return $this->_items; + } + + /** + * Retrieve massaction items JSON + * + * @return string + */ + public function getItemsJson() + { + $result = array(); + foreach ($this->getItems() as $itemId=>$item) { + $result[$itemId] = $item->toArray(); + } + + return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($result); + } + + /** + * Retrieve massaction items count + * + * @return integer + */ + public function getCount() + { + return sizeof($this->_items); + } + + /** + * Checks are massactions available + * + * @return boolean + */ + public function isAvailable() + { + return $this->getCount() > 0 && $this->getMassactionIdField(); + } + + /** + * Retrieve global form field name for all massaction items + * + * @return string + */ + public function getFormFieldName() + { + return ($this->getData('form_field_name') ? $this->getData('form_field_name') : 'massaction'); + } + + /** + * Retrieve form field name for internal use. Based on $this->getFormFieldName() + * + * @return string + */ + public function getFormFieldNameInternal() + { + return 'internal_' . $this->getFormFieldName(); + } + + /** + * Retrieve massaction block js object name + * + * @return string + */ + public function getJsObjectName() + { + return $this->getHtmlId() . 'JsObject'; + } + + /** + * Retrieve grid block js object name + * + * @return string + */ + public function getGridJsObjectName() + { + return $this->getParentBlock()->getJsObjectName(); + } + + /** + * Retrieve JSON string of selected checkboxes + * + * @return string + */ + public function getSelectedJson() + { + if ($selected = $this->getRequest()->getParam($this->getFormFieldNameInternal())) { + $selected = explode(',', $selected); + return join(',', $selected); + } else { + return ''; + } + } + + /** + * Retrieve array of selected checkboxes + * + * @return array + */ + public function getSelected() + { + if ($selected = $this->getRequest()->getParam($this->getFormFieldNameInternal())) { + $selected = explode(',', $selected); + return $selected; + } else { + return array(); + } + } + + /** + * Retrieve apply button html + * + * @return string + */ + public function getApplyButtonHtml() + { + return $this->getButtonHtml($this->__('Submit'), $this->getJsObjectName() . ".apply()"); + } + + public function getJavaScript() + { + return " var {$this->getJsObjectName()} = new varienGridMassaction('{$this->getHtmlId()}', " + . "{$this->getGridJsObjectName()}, '{$this->getSelectedJson()}'" + . ", '{$this->getFormFieldNameInternal()}', '{$this->getFormFieldName()}');" + . "{$this->getJsObjectName()}.setItems({$this->getItemsJson()}); " + . "{$this->getJsObjectName()}.setGridIds('{$this->getGridIdsJson()}');" + . ($this->getUseAjax() ? "{$this->getJsObjectName()}.setUseAjax(true);" : '') + . ($this->getUseSelectAll() ? "{$this->getJsObjectName()}.setUseSelectAll(true);" : '') + . "{$this->getJsObjectName()}.errorText = '{$this->getErrorText()}';"; + } + + public function getGridIdsJson() + { + if (!$this->getUseSelectAll()) { + return ''; + } + + $gridIds = $this->getParentBlock()->getCollection()->getAllIds(); + + if (!empty($gridIds)) { + return join(",", $gridIds); + } + return ''; + } + + public function getHtmlId() + { + return $this->getParentBlock()->getHtmlId() . '_massaction'; + } + + /** + * Remove existing massaction item by its id + * + * @param string $itemId + * @return Mage_Backend_Block_Widget_Grid_Massaction_Abstract + */ + public function removeItem($itemId) + { + if (isset($this->_items[$itemId])) { + unset($this->_items[$itemId]); + } + + return $this; + } + + /** + * Retrieve select all functionality flag check + * + * @return boolean + */ + public function getUseSelectAll() + { + return $this->_getData('use_select_all') === null || $this->_getData('use_select_all'); + } + + /** + * Retrieve select all functionality flag check + * + * @param boolean $flag + * @return Mage_Backend_Block_Widget_Grid_Massaction_Abstract + */ + public function setUseSelectAll($flag) + { + $this->setData('use_select_all', (bool) $flag); + return $this; + } + + /** + * Prepare grid massaction column + * + * @return Mage_Backend_Block_Widget_Grid_Extended + */ + public function prepareMassactionColumn() + { + $columnId = 'massaction'; + $massactionColumn = $this->getLayout()->createBlock('Mage_Backend_Block_Widget_Grid_Column') + ->setData(array( + 'index' => $this->getMassactionIdField(), + 'filter_index' => $this->getMassactionIdFilter(), + 'type' => 'massaction', + 'name' => $this->getFormFieldName(), + 'is_system' => true, + 'header_css_class' => 'col-select', + 'column_css_class' => 'col-select' + )); + + if ($this->getNoFilterMassactionColumn()) { + $massactionColumn->setData('filter', false); + } + + $gridBlock = $this->getParentBlock(); + $massactionColumn->setSelected($this->getSelected()) + ->setGrid($gridBlock) + ->setId($columnId); + + /** @var $columnSetBlock Mage_Backend_Block_Widget_Grid_ColumnSet */ + $columnSetBlock = $gridBlock->getColumnSet(); + $childNames = $columnSetBlock->getChildNames(); + $siblingElement = count($childNames) ? current($childNames) : 0; + $columnSetBlock->insert($massactionColumn, $siblingElement, false, $columnId); + return $this; + } +} diff --git a/app/code/Mage/Backend/Block/Widget/Grid/Massaction/Additional.php b/app/code/Mage/Backend/Block/Widget/Grid/Massaction/Additional.php new file mode 100644 index 0000000000000..c043f1cf1000f --- /dev/null +++ b/app/code/Mage/Backend/Block/Widget/Grid/Massaction/Additional.php @@ -0,0 +1,87 @@ + + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class Mage_Backend_Block_Widget_Grid_Massaction_Additional extends Mage_Backend_Block_Widget_Form +{ + /** + * @var Mage_Core_Model_Layout_Argument_HandlerFactory + */ + protected $_handlerFactory; + + /** + * @param Mage_Core_Block_Template_Context $context + * @param Mage_Core_Model_Layout_Argument_HandlerFactory $handlerFactory + * @param array $data + */ + public function __construct( + Mage_Core_Block_Template_Context $context, + Mage_Core_Model_Layout_Argument_HandlerFactory $handlerFactory, + array $data = array() + ) { + parent::__construct($context, $data); + + $this->_handlerFactory = $handlerFactory; + } + + /** + * Prepare form before rendering HTML + * + * @return Mage_Backend_Block_Widget_Form + */ + protected function _prepareForm() + { + $form = new Varien_Data_Form(); + foreach ($this->getData('fields') as $itemId => $item) { + $this->_prepareFormItem($item); + $form->addField($itemId, $item['type'], $item); + } + $this->setForm($form); + return $this; + } + + /** + * Prepare form item + * + * @param array $item + */ + protected function _prepareFormItem(array &$item) + { + if ($item['type'] == 'select' && is_string($item['values'])) { + $argumentHandler = $this->_handlerFactory->getArgumentHandlerByType('options'); + $item['values'] = $argumentHandler->process($item['values']); + } + $item['class'] = isset($item['class']) ? $item['class'] . ' absolute-advice' : 'absolute-advice'; + } +} \ No newline at end of file diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Massaction/Extended.php b/app/code/Mage/Backend/Block/Widget/Grid/Massaction/Extended.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Massaction/Extended.php rename to app/code/Mage/Backend/Block/Widget/Grid/Massaction/Extended.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Massaction/Item.php b/app/code/Mage/Backend/Block/Widget/Grid/Massaction/Item.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Massaction/Item.php rename to app/code/Mage/Backend/Block/Widget/Grid/Massaction/Item.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Massaction/Item/Additional/Default.php b/app/code/Mage/Backend/Block/Widget/Grid/Massaction/Item/Additional/Default.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Massaction/Item/Additional/Default.php rename to app/code/Mage/Backend/Block/Widget/Grid/Massaction/Item/Additional/Default.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Massaction/Item/Additional/Interface.php b/app/code/Mage/Backend/Block/Widget/Grid/Massaction/Item/Additional/Interface.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Massaction/Item/Additional/Interface.php rename to app/code/Mage/Backend/Block/Widget/Grid/Massaction/Item/Additional/Interface.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid/Serializer.php b/app/code/Mage/Backend/Block/Widget/Grid/Serializer.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Grid/Serializer.php rename to app/code/Mage/Backend/Block/Widget/Grid/Serializer.php diff --git a/app/code/core/Mage/Backend/Block/Widget/Tab/Interface.php b/app/code/Mage/Backend/Block/Widget/Tab/Interface.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/Tab/Interface.php rename to app/code/Mage/Backend/Block/Widget/Tab/Interface.php diff --git a/app/code/Mage/Backend/Block/Widget/Tabs.php b/app/code/Mage/Backend/Block/Widget/Tabs.php new file mode 100644 index 0000000000000..8e00d79f2dc61 --- /dev/null +++ b/app/code/Mage/Backend/Block/Widget/Tabs.php @@ -0,0 +1,421 @@ + + */ +class Mage_Backend_Block_Widget_Tabs extends Mage_Backend_Block_Widget +{ + /** + * Tabs structure + * + * @var array + */ + protected $_tabs = array(); + + /** + * Active tab key + * + * @var string + */ + protected $_activeTab = null; + + /** + * Destination HTML element id + * + * @var string + */ + protected $_destElementId = 'content'; + + /** @var string */ + protected $_template = 'Mage_Backend::widget/tabs.phtml'; + + /** + * retrieve destination html element id + * + * @return string + */ + public function getDestElementId() + { + return $this->_destElementId; + } + + /** + * Set destination element id + * + * @param string $elementId + * @return Mage_Backend_Block_Widget_Tabs + */ + public function setDestElementId($elementId) + { + $this->_destElementId = $elementId; + return $this; + } + + /** + * Add new tab after another + * + * @param string $tabId new tab Id + * @param array|Varien_Object $tab + * @param string $afterTabId + * @return Mage_Backend_Block_Widget_Tabs + */ + public function addTabAfter($tabId, $tab, $afterTabId) + { + $this->addTab($tabId, $tab); + $this->_tabs[$tabId]->setAfter($afterTabId); + } + + /** + * Add new tab + * + * @param string $tabId + * @param array|Varien_Object|string $tab + * @return Mage_Backend_Block_Widget_Tabs + * @throws Exception + */ + public function addTab($tabId, $tab) + { + if (is_array($tab)) { + $this->_tabs[$tabId] = new Varien_Object($tab); + } elseif ($tab instanceof Varien_Object) { + $this->_tabs[$tabId] = $tab; + if (!$this->_tabs[$tabId]->hasTabId()) { + $this->_tabs[$tabId]->setTabId($tabId); + } + } elseif (is_string($tab)) { + $this->_addTabByName($tab, $tabId); + } else { + throw new Exception(Mage::helper('Mage_Backend_Helper_Data')->__('Wrong tab configuration.')); + } + + if (is_null($this->_tabs[$tabId]->getUrl())) { + $this->_tabs[$tabId]->setUrl('#'); + } + + if (!$this->_tabs[$tabId]->getTitle()) { + $this->_tabs[$tabId]->setTitle($this->_tabs[$tabId]->getLabel()); + } + + $this->_tabs[$tabId]->setId($tabId); + $this->_tabs[$tabId]->setTabId($tabId); + + if (is_null($this->_activeTab)) { + $this->_activeTab = $tabId; + } + if (true === $this->_tabs[$tabId]->getActive()) { + $this->setActiveTab($tabId); + } + + return $this; + } + + /** + * Add tab by tab block name + * + * @param string $tab + * @param string $tabId + * @throws Exception + */ + protected function _addTabByName($tab, $tabId) + { + if (strpos($tab, '_Block_')) { + $this->_tabs[$tabId] = $this->getLayout()->createBlock( + $tab, + $this->getNameInLayout() . '_tab_' . $tabId + ); + } elseif ($this->getChildBlock($tab)) { + $this->_tabs[$tabId] = $this->getChildBlock($tab); + } else { + $this->_tabs[$tabId] = null; + } + + if (!($this->_tabs[$tabId] instanceof Mage_Backend_Block_Widget_Tab_Interface)) { + throw new Exception(Mage::helper('Mage_Backend_Helper_Data')->__('Wrong tab configuration.')); + } + } + + public function getActiveTabId() + { + return $this->getTabId($this->_tabs[$this->_activeTab]); + } + + /** + * Set Active Tab + * Tab has to be not hidden and can show + * + * @param string $tabId + * @return Mage_Backend_Block_Widget_Tabs + */ + public function setActiveTab($tabId) + { + if (isset($this->_tabs[$tabId]) && $this->canShowTab($this->_tabs[$tabId]) + && !$this->getTabIsHidden($this->_tabs[$tabId])) { + $this->_activeTab = $tabId; + if (!(is_null($this->_activeTab)) && ($tabId !== $this->_activeTab)) { + foreach ($this->_tabs as $id => $tab) { + $tab->setActive($id === $tabId); + } + } + } + return $this; + } + + /** + * Set Active Tab + * + * @param string $tabId + * @return Mage_Backend_Block_Widget_Tabs + */ + protected function _setActiveTab($tabId) + { + foreach ($this->_tabs as $id => $tab) { + if ($this->getTabId($tab) == $tabId) { + $this->_activeTab = $id; + $tab->setActive(true); + return $this; + } + } + return $this; + } + + protected function _beforeToHtml() + { + if ($activeTab = $this->getRequest()->getParam('active_tab')) { + $this->setActiveTab($activeTab); + } elseif ($activeTabId = Mage::getSingleton('Mage_Backend_Model_Auth_Session')->getActiveTabId()) { + $this->_setActiveTab($activeTabId); + } + + $_new = array(); + foreach ($this->_tabs as $key => $tab ) { + foreach ($this->_tabs as $k => $t ) { + if ( $t->getAfter() == $key ) { + $_new[$key] = $tab; + $_new[$k] = $t; + } else { + if ( !$tab->getAfter() || !in_array($tab->getAfter(), array_keys($this->_tabs)) ) { + $_new[$key] = $tab; + } + } + } + } + + $this->_tabs = $_new; + unset($_new); + + $this->assign('tabs', $this->_tabs); + return parent::_beforeToHtml(); + } + + public function getJsObjectName() + { + return $this->getId() . 'JsTabs'; + } + + public function getTabsIds() + { + if (empty($this->_tabs)) { + return array(); + } + + return array_keys($this->_tabs); + } + + public function getTabId($tab, $withPrefix = true) + { + if ($tab instanceof Mage_Backend_Block_Widget_Tab_Interface) { + return ($withPrefix ? $this->getId().'_' : '').$tab->getTabId(); + } + return ($withPrefix ? $this->getId().'_' : '').$tab->getId(); + } + + public function canShowTab($tab) + { + if ($tab instanceof Mage_Backend_Block_Widget_Tab_Interface) { + return $tab->canShowTab(); + } + return true; + } + + public function getTabIsHidden($tab) + { + if ($tab instanceof Mage_Backend_Block_Widget_Tab_Interface) { + return $tab->isHidden(); + } + return $tab->getIsHidden(); + } + + public function getTabUrl($tab) + { + if ($tab instanceof Mage_Backend_Block_Widget_Tab_Interface) { + if (method_exists($tab, 'getTabUrl')) { + return $tab->getTabUrl(); + } + return '#'; + } + if (!is_null($tab->getUrl())) { + return $tab->getUrl(); + } + return '#'; + } + + public function getTabTitle($tab) + { + if ($tab instanceof Mage_Backend_Block_Widget_Tab_Interface) { + return $tab->getTabTitle(); + } + return $tab->getTitle(); + } + + public function getTabClass($tab) + { + if ($tab instanceof Mage_Backend_Block_Widget_Tab_Interface) { + if (method_exists($tab, 'getTabClass')) { + return $tab->getTabClass(); + } + return ''; + } + return $tab->getClass(); + } + + + public function getTabLabel($tab) + { + if ($tab instanceof Mage_Backend_Block_Widget_Tab_Interface) { + return $tab->getTabLabel(); + } + return $tab->getLabel(); + } + + public function getTabContent($tab) + { + if ($tab instanceof Mage_Backend_Block_Widget_Tab_Interface) { + if ($tab->getSkipGenerateContent()) { + return ''; + } + return $tab->toHtml(); + } + return $tab->getContent(); + } + + /** + * Mark tabs as dependant of each other + * Arbitrary number of tabs can be specified, but at least two + * + * @param string $tabOneId + * @param string $tabTwoId + * @param string $tabNId... + */ + public function bindShadowTabs($tabOneId, $tabTwoId) + { + $tabs = array(); + $args = func_get_args(); + if ((!empty($args)) && (count($args) > 1)) { + foreach ($args as $tabId) { + if (isset($this->_tabs[$tabId])) { + $tabs[$tabId] = $tabId; + } + } + $blockId = $this->getId(); + foreach ($tabs as $tabId) { + foreach ($tabs as $tabToId) { + if ($tabId !== $tabToId) { + if (!$this->_tabs[$tabToId]->getData('shadow_tabs')) { + $this->_tabs[$tabToId]->setData('shadow_tabs', array()); + } + $this->_tabs[$tabToId]->setData('shadow_tabs', array_merge( + $this->_tabs[$tabToId]->getData('shadow_tabs'), + array($blockId . '_' . $tabId) + )); + } + } + } + } + } + + /** + * Obtain shadow tabs information + * + * @param bool $asJson + * @return array|string + */ + public function getAllShadowTabs($asJson = true) + { + $result = array(); + if (!empty($this->_tabs)) { + $blockId = $this->getId(); + foreach (array_keys($this->_tabs) as $tabId) { + if ($this->_tabs[$tabId]->getData('shadow_tabs')) { + $result[$blockId . '_' . $tabId] = $this->_tabs[$tabId]->getData('shadow_tabs'); + } + } + } + if ($asJson) { + return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($result); + } + return $result; + } + + /** + * Set tab property by tab's identifier + * + * @param string $tab + * @param string $key + * @param mixed $value + * @return Mage_Backend_Block_Widget_Tabs + */ + public function setTabData($tab, $key, $value) + { + if (isset($this->_tabs[$tab]) && $this->_tabs[$tab] instanceof Varien_Object) { + if ($key == 'url') { + $value = $this->getUrl($value, array('_current' => true, '_use_rewrite' => true)); + } + $this->_tabs[$tab]->setData($key, $value); + } + + return $this; + } + + /** + * Removes tab with passed id from tabs block + * + * @param string $tabId + * @return Mage_Backend_Block_Widget_Tabs + */ + public function removeTab($tabId) + { + if (isset($this->_tabs[$tabId])) { + unset($this->_tabs[$tabId]); + } + return $this; + } +} + diff --git a/app/code/core/Mage/Backend/Block/Widget/View/Container.php b/app/code/Mage/Backend/Block/Widget/View/Container.php similarity index 100% rename from app/code/core/Mage/Backend/Block/Widget/View/Container.php rename to app/code/Mage/Backend/Block/Widget/View/Container.php diff --git a/app/code/core/Mage/Backend/Controller/ActionAbstract.php b/app/code/Mage/Backend/Controller/ActionAbstract.php similarity index 100% rename from app/code/core/Mage/Backend/Controller/ActionAbstract.php rename to app/code/Mage/Backend/Controller/ActionAbstract.php diff --git a/app/code/core/Mage/Backend/Controller/Router/Default.php b/app/code/Mage/Backend/Controller/Router/Default.php similarity index 100% rename from app/code/core/Mage/Backend/Controller/Router/Default.php rename to app/code/Mage/Backend/Controller/Router/Default.php diff --git a/app/code/core/Mage/Backend/Controller/System/ConfigAbstract.php b/app/code/Mage/Backend/Controller/System/ConfigAbstract.php similarity index 100% rename from app/code/core/Mage/Backend/Controller/System/ConfigAbstract.php rename to app/code/Mage/Backend/Controller/System/ConfigAbstract.php diff --git a/app/code/Mage/Backend/Helper/Data.php b/app/code/Mage/Backend/Helper/Data.php new file mode 100644 index 0000000000000..265cf026aa72e --- /dev/null +++ b/app/code/Mage/Backend/Helper/Data.php @@ -0,0 +1,190 @@ +_config = $applicationConfig; + } + + public function getPageHelpUrl() + { + if (!$this->_pageHelpUrl) { + $this->setPageHelpUrl(); + } + return $this->_pageHelpUrl; + } + + public function setPageHelpUrl($url=null) + { + if (is_null($url)) { + $request = Mage::app()->getRequest(); + $frontModule = $request->getControllerModule(); + if (!$frontModule) { + $frontName = $request->getModuleName(); + $router = Mage::app()->getFrontController()->getRouterByFrontName($frontName); + + $frontModule = $router->getModulesByFrontName($frontName); + if (empty($frontModule) === false) { + $frontModule = $frontModule[0]; + } else { + $frontModule = null; + } + } + $url = 'http://www.magentocommerce.com/gethelp/'; + $url.= Mage::app()->getLocale()->getLocaleCode().'/'; + $url.= $frontModule.'/'; + $url.= $request->getControllerName().'/'; + $url.= $request->getActionName().'/'; + + $this->_pageHelpUrl = $url; + } + $this->_pageHelpUrl = $url; + + return $this; + } + + public function addPageHelpUrl($suffix) + { + $this->_pageHelpUrl = $this->getPageHelpUrl().$suffix; + return $this; + } + + public function getUrl($route='', $params=array()) + { + return Mage::getSingleton('Mage_Backend_Model_Url')->getUrl($route, $params); + } + + public function getCurrentUserId() + { + if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->getUser()) { + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->getUser()->getId(); + } + return false; + } + + /** + * Decode filter string + * + * @param string $filterString + * @return array + */ + public function prepareFilterString($filterString) + { + $data = array(); + $filterString = base64_decode($filterString); + parse_str($filterString, $data); + array_walk_recursive($data, array($this, 'decodeFilter')); + return $data; + } + + /** + * Decode URL encoded filter value recursive callback method + * + * @param string $value + */ + public function decodeFilter(&$value) + { + $value = rawurldecode($value); + } + + /** + * Generate unique token for reset password confirmation link + * + * @return string + */ + public function generateResetPasswordLinkToken() + { + return Mage::helper('Mage_Core_Helper_Data')->uniqHash(); + } + + /** + * Get backend start page URL + * + * @return string + */ + public function getHomePageUrl() + { + return Mage::getSingleton('Mage_Backend_Model_Url')->getRouteUrl('adminhtml'); + } + + /** + * Return Backend area code + * + * @return string + */ + public function getAreaCode() + { + return self::BACKEND_AREA_CODE; + } + + /** + * Return Backend area front name + * + * @return string + */ + public function getAreaFrontName() + { + if (null === $this->_areaFrontName) { + $this->_areaFrontName = (bool)(string)$this->_config->getNode(self::XML_PATH_USE_CUSTOM_ADMIN_PATH) ? + (string)$this->_config->getNode(self::XML_PATH_CUSTOM_ADMIN_PATH) : + (string)$this->_config->getNode(self::XML_PATH_BACKEND_FRONTNAME); + } + return $this->_areaFrontName; + } + + /** + * Invalidate cache of area front name + * + * @return Mage_Backend_Helper_Data + */ + public function clearAreaFrontName() + { + $this->_areaFrontName = null; + return $this; + } +} diff --git a/app/code/Mage/Backend/Model/Acl/Config.php b/app/code/Mage/Backend/Model/Acl/Config.php new file mode 100644 index 0000000000000..15136b2f5b18a --- /dev/null +++ b/app/code/Mage/Backend/Model/Acl/Config.php @@ -0,0 +1,146 @@ + + */ +class Mage_Backend_Model_Acl_Config implements Mage_Core_Model_Acl_Config_ConfigInterface +{ + const CACHE_ID = 'backend_acl_resources'; + + const ACL_RESOURCE_ALL = 'Mage_Adminhtml::all'; + + /** + * @var Mage_Core_Model_Config + */ + protected $_config; + + /** + * @var Mage_Core_Model_Cache_Type_Config + */ + protected $_configCacheType; + + /** + * @var Magento_Acl_Config_Reader + */ + protected $_reader; + + /** + * Module configuration reader + * + * @var Mage_Core_Model_Config_Modules_Reader + */ + protected $_moduleReader; + + /** + * @param Mage_Core_Model_Config $config + * @param Mage_Core_Model_Cache_Type_Config $configCacheType + * @param Mage_Core_Model_Config_Modules_Reader $moduleReader + */ + public function __construct( + Mage_Core_Model_Config $config, + Mage_Core_Model_Cache_Type_Config $configCacheType, + Mage_Core_Model_Config_Modules_Reader $moduleReader + ) { + $this->_config = $config; + $this->_configCacheType = $configCacheType; + $this->_moduleReader = $moduleReader; + } + + /** + * Retrieve list of acl files from each module + * + * @return array + */ + protected function _getAclResourceFiles() + { + $files = $this->_moduleReader + ->getModuleConfigurationFiles('adminhtml' . DIRECTORY_SEPARATOR . 'acl.xml'); + return (array) $files; + } + + /** + * Reader object initialization + * + * @return Magento_Acl_Config_Reader + */ + protected function _getReader() + { + if (null === $this->_reader) { + $aclResourceFiles = $this->_getAclResourceFiles(); + $this->_reader = $this->_config->getModelInstance('Magento_Acl_Config_Reader', + array('configFiles' => $aclResourceFiles) + ); + } + return $this->_reader; + } + + /** + * Return ACL Resources loaded from cache if enabled or from files merged previously + * + * @return DOMNodeList + */ + public function getAclResources() + { + $aclResourcesXml = $this->_loadAclResourcesFromCache(); + if ($aclResourcesXml && is_string($aclResourcesXml)) { + $aclResources = new DOMDocument(); + $aclResources->loadXML($aclResourcesXml); + } else { + $aclResources = $this->_getReader()->getAclResources(); + $this->_saveAclResourcesToCache($aclResources->saveXML()); + } + $xpath = new DOMXPath($aclResources); + return $xpath->query('/config/acl/resources/*'); + } + + /** + * Load ACL resources from cache + * + * @return null|string + */ + private function _loadAclResourcesFromCache() + { + return $this->_configCacheType->load(self::CACHE_ID); + } + + /** + * Save ACL resources into the cache + * + * @param $data + * @return Mage_Backend_Model_Acl_Config + */ + private function _saveAclResourcesToCache($data) + { + $this->_configCacheType->save($data, self::CACHE_ID); + return $this; + } +} diff --git a/app/code/core/Mage/Backend/Model/Acl/Loader/Resource.php b/app/code/Mage/Backend/Model/Acl/Loader/Resource.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Acl/Loader/Resource.php rename to app/code/Mage/Backend/Model/Acl/Loader/Resource.php diff --git a/app/code/core/Mage/Backend/Model/Auth.php b/app/code/Mage/Backend/Model/Auth.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Auth.php rename to app/code/Mage/Backend/Model/Auth.php diff --git a/app/code/core/Mage/Backend/Model/Auth/Credential/StorageInterface.php b/app/code/Mage/Backend/Model/Auth/Credential/StorageInterface.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Auth/Credential/StorageInterface.php rename to app/code/Mage/Backend/Model/Auth/Credential/StorageInterface.php diff --git a/app/code/core/Mage/Backend/Model/Auth/Exception.php b/app/code/Mage/Backend/Model/Auth/Exception.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Auth/Exception.php rename to app/code/Mage/Backend/Model/Auth/Exception.php diff --git a/app/code/core/Mage/Backend/Model/Auth/Plugin/Exception.php b/app/code/Mage/Backend/Model/Auth/Plugin/Exception.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Auth/Plugin/Exception.php rename to app/code/Mage/Backend/Model/Auth/Plugin/Exception.php diff --git a/app/code/Mage/Backend/Model/Auth/Session.php b/app/code/Mage/Backend/Model/Auth/Session.php new file mode 100644 index 0000000000000..1034c2e8d8c58 --- /dev/null +++ b/app/code/Mage/Backend/Model/Auth/Session.php @@ -0,0 +1,220 @@ + + */ +class Mage_Backend_Model_Auth_Session + extends Mage_Core_Model_Session_Abstract + implements Mage_Backend_Model_Auth_StorageInterface +{ + const XML_PATH_SESSION_LIFETIME = 'admin/security/session_lifetime'; + + /** + * Whether it is the first page after successfull login + * + * @var boolean + */ + protected $_isFirstAfterLogin; + + /** + * Access Control List builder + * + * @var Mage_Core_Model_Acl_Builder + */ + protected $_aclBuilder; + + /** + * Class constructor + * + * @param array $data + */ + public function __construct(Mage_Core_Model_Acl_Builder $aclBuilder) + { + $this->_aclBuilder = $aclBuilder; + $this->init('admin'); + } + + /** + * Pull out information from session whether there is currently the first page after log in + * + * The idea is to set this value on login(), then redirect happens, + * after that on next request the value is grabbed once the session is initialized + * Since the session is used as a singleton, the value will be in $_isFirstPageAfterLogin until the end of request, + * unless it is reset intentionally from somewhere + * + * @param string $namespace + * @param string $sessionName + * @return Mage_Backend_Model_Auth_Session + * @see self::login() + */ + public function init($namespace, $sessionName = null) + { + parent::init($namespace, $sessionName); + $this->isFirstPageAfterLogin(); + return $this; + } + + /** + * Refresh ACL resources stored in session + * + * @param Mage_User_Model_User $user + * @return Mage_Backend_Model_Auth_Session + */ + public function refreshAcl($user = null) + { + if (is_null($user)) { + $user = $this->getUser(); + } + if (!$user) { + return $this; + } + if (!$this->getAcl() || $user->getReloadAclFlag()) { + $this->setAcl($this->_aclBuilder->getAcl(Mage_Core_Model_App_Area::AREA_ADMINHTML)); + } + if ($user->getReloadAclFlag()) { + $user->unsetData('password'); + $user->setReloadAclFlag('0')->save(); + } + return $this; + } + + /** + * Check current user permission on resource and privilege + * + * Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Catalog::catalog') + * Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Catalog::catalog') + * + * @param string $resource + * @param string $privilege + * @return boolean + */ + public function isAllowed($resource, $privilege = null) + { + $user = $this->getUser(); + $acl = $this->getAcl(); + + if ($user && $acl) { + try { + return $acl->isAllowed($user->getAclRole(), $resource, $privilege); + } catch (Exception $e) { + try { + if (!$acl->has($resource)) { + return $acl->isAllowed($user->getAclRole(), null, $privilege); + } + } catch (Exception $e) { + + } + } + } + return false; + } + + /** + * Check if user is logged in + * + * @return boolean + */ + public function isLoggedIn() + { + $lifetime = Mage::getStoreConfig(self::XML_PATH_SESSION_LIFETIME); + $currentTime = time(); + + /* Validate admin session lifetime that should be more than 60 seconds */ + if ($lifetime >= 60 && ($this->getUpdatedAt() < $currentTime - $lifetime)) { + return false; + } + + if ($this->getUser() && $this->getUser()->getId()) { + $this->setUpdatedAt($currentTime); + return true; + } + return false; + } + + /** + * Check if it is the first page after successfull login + * + * @return boolean + */ + public function isFirstPageAfterLogin() + { + if (is_null($this->_isFirstAfterLogin)) { + $this->_isFirstAfterLogin = $this->getData('is_first_visit', true); + } + return $this->_isFirstAfterLogin; + } + + /** + * Setter whether the current/next page should be treated as first page after login + * + * @param bool $value + * @return Mage_Backend_Model_Auth_Session + */ + public function setIsFirstPageAfterLogin($value) + { + $this->_isFirstAfterLogin = (bool)$value; + return $this->setIsFirstVisit($this->_isFirstAfterLogin); + } + + /** + * Process of configuring of current auth storage when login was performed + * + * @return Mage_Backend_Model_Auth_Session + */ + public function processLogin() + { + if ($this->getUser()) { + $this->renewSession(); + + if (Mage::getSingleton('Mage_Backend_Model_Url')->useSecretKey()) { + Mage::getSingleton('Mage_Backend_Model_Url')->renewSecretUrls(); + } + + $this->setIsFirstPageAfterLogin(true); + $this->setAcl($this->_aclBuilder->getAcl(Mage_Core_Model_App_Area::AREA_ADMINHTML)); + $this->setUpdatedAt(time()); + } + return $this; + } + + /** + * Process of configuring of current auth storage when logout was performed + * + * @return Mage_Backend_Model_Auth_Session + */ + public function processLogout() + { + $this->unsetAll(); + $this->getCookie()->delete($this->getSessionName()); + return $this; + } +} diff --git a/app/code/core/Mage/Backend/Model/Auth/StorageInterface.php b/app/code/Mage/Backend/Model/Auth/StorageInterface.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Auth/StorageInterface.php rename to app/code/Mage/Backend/Model/Auth/StorageInterface.php diff --git a/app/code/core/Mage/Backend/Model/Authorization/RoleLocator.php b/app/code/Mage/Backend/Model/Authorization/RoleLocator.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Authorization/RoleLocator.php rename to app/code/Mage/Backend/Model/Authorization/RoleLocator.php diff --git a/app/code/core/Mage/Backend/Model/Config.php b/app/code/Mage/Backend/Model/Config.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config.php rename to app/code/Mage/Backend/Model/Config.php diff --git a/app/code/Mage/Backend/Model/Config/Backend/Admin/Custom.php b/app/code/Mage/Backend/Model/Config/Backend/Admin/Custom.php new file mode 100644 index 0000000000000..55ba48ac2984f --- /dev/null +++ b/app/code/Mage/Backend/Model/Config/Backend/Admin/Custom.php @@ -0,0 +1,118 @@ + + */ +class Mage_Backend_Model_Config_Backend_Admin_Custom extends Mage_Core_Model_Config_Data +{ + const CONFIG_SCOPE = 'stores'; + const CONFIG_SCOPE_ID = 0; + + const XML_PATH_UNSECURE_BASE_URL = 'web/unsecure/base_url'; + const XML_PATH_SECURE_BASE_URL = 'web/secure/base_url'; + const XML_PATH_UNSECURE_BASE_LINK_URL = 'web/unsecure/base_link_url'; + const XML_PATH_SECURE_BASE_LINK_URL = 'web/secure/base_link_url'; + + /** + * Writer of configuration storage + * + * @var Mage_Core_Model_Config_Storage_WriterInterface + */ + protected $_configWriter; + + /** + * @param Mage_Core_Model_Context $context + * @param Mage_Core_Model_Config_Storage_WriterInterface $configWriter + * @param Mage_Core_Model_Resource_Abstract $resource + * @param Varien_Data_Collection_Db $resourceCollection + * @param array $data + */ + public function __construct( + Mage_Core_Model_Context $context, + Mage_Core_Model_Config_Storage_WriterInterface $configWriter, + Mage_Core_Model_Resource_Abstract $resource = null, + Varien_Data_Collection_Db $resourceCollection = null, + array $data = array() + ) { + $this->_configWriter = $configWriter; + parent::__construct($context, $resource, $resourceCollection, $data); + } + + /** + * Validate value before save + * + * @return Mage_Backend_Model_Config_Backend_Admin_Custom + */ + protected function _beforeSave() + { + $value = $this->getValue(); + + if (!empty($value) && substr($value, -2) !== '}}') { + $value = rtrim($value, '/').'/'; + } + + $this->setValue($value); + return $this; + } + + /** + * Change secure/unsecure base_url after use_custom_url was modified + * + * @return Mage_Backend_Model_Config_Backend_Admin_Custom + */ + public function _afterSave() + { + $useCustomUrl = $this->getData('groups/url/fields/use_custom/value'); + $value = $this->getValue(); + + if ($useCustomUrl == 1 && empty($value)) { + return $this; + } + + if ($useCustomUrl == 1) { + $this->_configWriter->save( + self::XML_PATH_SECURE_BASE_URL, + $value, + self::CONFIG_SCOPE, + self::CONFIG_SCOPE_ID + ); + $this->_configWriter->save( + self::XML_PATH_UNSECURE_BASE_URL, + $value, + self::CONFIG_SCOPE, + self::CONFIG_SCOPE_ID + ); + } + + return $this; + } +} diff --git a/app/code/core/Mage/Backend/Model/Config/Backend/Admin/Custompath.php b/app/code/Mage/Backend/Model/Config/Backend/Admin/Custompath.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Backend/Admin/Custompath.php rename to app/code/Mage/Backend/Model/Config/Backend/Admin/Custompath.php diff --git a/app/code/core/Mage/Backend/Model/Config/Backend/Admin/Observer.php b/app/code/Mage/Backend/Model/Config/Backend/Admin/Observer.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Backend/Admin/Observer.php rename to app/code/Mage/Backend/Model/Config/Backend/Admin/Observer.php diff --git a/app/code/core/Mage/Backend/Model/Config/Backend/Admin/Password/Link/Expirationperiod.php b/app/code/Mage/Backend/Model/Config/Backend/Admin/Password/Link/Expirationperiod.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Backend/Admin/Password/Link/Expirationperiod.php rename to app/code/Mage/Backend/Model/Config/Backend/Admin/Password/Link/Expirationperiod.php diff --git a/app/code/core/Mage/Backend/Model/Config/Backend/Admin/Robots.php b/app/code/Mage/Backend/Model/Config/Backend/Admin/Robots.php similarity index 90% rename from app/code/core/Mage/Backend/Model/Config/Backend/Admin/Robots.php rename to app/code/Mage/Backend/Model/Config/Backend/Admin/Robots.php index a02f2512a5968..9c726af6e2fc8 100644 --- a/app/code/core/Mage/Backend/Model/Config/Backend/Admin/Robots.php +++ b/app/code/Mage/Backend/Model/Config/Backend/Admin/Robots.php @@ -44,22 +44,20 @@ class Mage_Backend_Model_Config_Backend_Admin_Robots extends Mage_Core_Model_Con protected $_filePath; /** - * @param Mage_Core_Model_Event_Manager $eventDispatcher - * @param Mage_Core_Model_Cache $cacheManager + * @param Mage_Core_Model_Context $context * @param Magento_Filesystem $filesystem * @param Mage_Core_Model_Resource_Abstract $resource * @param Varien_Data_Collection_Db $resourceCollection * @param array $data */ public function __construct( - Mage_Core_Model_Event_Manager $eventDispatcher, - Mage_Core_Model_Cache $cacheManager, + Mage_Core_Model_Context $context, Magento_Filesystem $filesystem, Mage_Core_Model_Resource_Abstract $resource = null, Varien_Data_Collection_Db $resourceCollection = null, array $data = array() ) { - parent::__construct($eventDispatcher, $cacheManager, $resource, $resourceCollection, $data); + parent::__construct($context, $resource, $resourceCollection, $data); $this->_filesystem = $filesystem; $this->_filePath = Magento_Filesystem::getAbsolutePath(Mage::getBaseDir() . DS . 'robots.txt'); } diff --git a/app/code/core/Mage/Backend/Model/Config/Backend/Admin/Usecustom.php b/app/code/Mage/Backend/Model/Config/Backend/Admin/Usecustom.php similarity index 91% rename from app/code/core/Mage/Backend/Model/Config/Backend/Admin/Usecustom.php rename to app/code/Mage/Backend/Model/Config/Backend/Admin/Usecustom.php index 9f801cefdf041..83f4190b82c93 100644 --- a/app/code/core/Mage/Backend/Model/Config/Backend/Admin/Usecustom.php +++ b/app/code/Mage/Backend/Model/Config/Backend/Admin/Usecustom.php @@ -42,23 +42,21 @@ class Mage_Backend_Model_Config_Backend_Admin_Usecustom extends Mage_Core_Model_ protected $_configWriter; /** - * @param Mage_Core_Model_Event_Manager $eventDispatcher - * @param Mage_Core_Model_Cache $cacheManager + * @param Mage_Core_Model_Context $context + * @param Mage_Core_Model_Config_Storage_WriterInterface $configWriter * @param Mage_Core_Model_Resource_Abstract $resource * @param Varien_Data_Collection_Db $resourceCollection - * @param Mage_Core_Model_Config_Storage_WriterInterface $configWriter * @param array $data */ public function __construct( - Mage_Core_Model_Event_Manager $eventDispatcher, - Mage_Core_Model_Cache $cacheManager, + Mage_Core_Model_Context $context, Mage_Core_Model_Config_Storage_WriterInterface $configWriter, Mage_Core_Model_Resource_Abstract $resource = null, Varien_Data_Collection_Db $resourceCollection = null, array $data = array() ) { $this->_configWriter = $configWriter; - parent::__construct($eventDispatcher, $cacheManager, $resource, $resourceCollection, $data); + parent::__construct($context, $resource, $resourceCollection, $data); } diff --git a/app/code/core/Mage/Backend/Model/Config/Backend/Admin/Usecustompath.php b/app/code/Mage/Backend/Model/Config/Backend/Admin/Usecustompath.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Backend/Admin/Usecustompath.php rename to app/code/Mage/Backend/Model/Config/Backend/Admin/Usecustompath.php diff --git a/app/code/core/Mage/Backend/Model/Config/Backend/Admin/Usesecretkey.php b/app/code/Mage/Backend/Model/Config/Backend/Admin/Usesecretkey.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Backend/Admin/Usesecretkey.php rename to app/code/Mage/Backend/Model/Config/Backend/Admin/Usesecretkey.php diff --git a/app/code/core/Mage/Backend/Model/Config/Backend/Baseurl.php b/app/code/Mage/Backend/Model/Config/Backend/Baseurl.php similarity index 97% rename from app/code/core/Mage/Backend/Model/Config/Backend/Baseurl.php rename to app/code/Mage/Backend/Model/Config/Backend/Baseurl.php index 2871c24a2c48f..6d4396810c940 100644 --- a/app/code/core/Mage/Backend/Model/Config/Backend/Baseurl.php +++ b/app/code/Mage/Backend/Model/Config/Backend/Baseurl.php @@ -61,8 +61,9 @@ private function _validateUnsecure($value) case Mage_Core_Model_Store::XML_PATH_UNSECURE_BASE_LINK_URL: $this->_assertStartsWithValuesOrUrl($placeholders, $value); break; - case Mage_Core_Model_Store::XML_PATH_UNSECURE_BASE_MEDIA_URL: + case Mage_Core_Model_Store::XML_PATH_UNSECURE_BASE_STATIC_URL: case Mage_Core_Model_Store::XML_PATH_UNSECURE_BASE_LIB_URL: + case Mage_Core_Model_Store::XML_PATH_UNSECURE_BASE_MEDIA_URL: $this->_assertStartsWithValuesOrUrlOrEmpty($placeholders, $value); break; default: @@ -87,8 +88,9 @@ private function _validateSecure($value) case Mage_Core_Model_Store::XML_PATH_SECURE_BASE_LINK_URL: $this->_assertStartsWithValuesOrUrl($placeholders, $value); break; - case Mage_Core_Model_Store::XML_PATH_SECURE_BASE_MEDIA_URL: + case Mage_Core_Model_Store::XML_PATH_SECURE_BASE_STATIC_URL: case Mage_Core_Model_Store::XML_PATH_SECURE_BASE_LIB_URL: + case Mage_Core_Model_Store::XML_PATH_SECURE_BASE_MEDIA_URL: $this->_assertStartsWithValuesOrUrlOrEmpty($placeholders, $value); break; default: diff --git a/app/code/core/Mage/Backend/Model/Config/Backend/Cache.php b/app/code/Mage/Backend/Model/Config/Backend/Cache.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Backend/Cache.php rename to app/code/Mage/Backend/Model/Config/Backend/Cache.php diff --git a/app/code/core/Mage/Backend/Model/Config/Backend/Cookie.php b/app/code/Mage/Backend/Model/Config/Backend/Cookie.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Backend/Cookie.php rename to app/code/Mage/Backend/Model/Config/Backend/Cookie.php diff --git a/app/code/core/Mage/Backend/Model/Config/Backend/Currency/Abstract.php b/app/code/Mage/Backend/Model/Config/Backend/Currency/Abstract.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Backend/Currency/Abstract.php rename to app/code/Mage/Backend/Model/Config/Backend/Currency/Abstract.php diff --git a/app/code/core/Mage/Backend/Model/Config/Backend/Currency/Allow.php b/app/code/Mage/Backend/Model/Config/Backend/Currency/Allow.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Backend/Currency/Allow.php rename to app/code/Mage/Backend/Model/Config/Backend/Currency/Allow.php diff --git a/app/code/core/Mage/Backend/Model/Config/Backend/Currency/Base.php b/app/code/Mage/Backend/Model/Config/Backend/Currency/Base.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Backend/Currency/Base.php rename to app/code/Mage/Backend/Model/Config/Backend/Currency/Base.php diff --git a/app/code/core/Mage/Backend/Model/Config/Backend/Currency/Cron.php b/app/code/Mage/Backend/Model/Config/Backend/Currency/Cron.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Backend/Currency/Cron.php rename to app/code/Mage/Backend/Model/Config/Backend/Currency/Cron.php diff --git a/app/code/core/Mage/Backend/Model/Config/Backend/Currency/Default.php b/app/code/Mage/Backend/Model/Config/Backend/Currency/Default.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Backend/Currency/Default.php rename to app/code/Mage/Backend/Model/Config/Backend/Currency/Default.php diff --git a/app/code/core/Mage/Backend/Model/Config/Backend/Datashare.php b/app/code/Mage/Backend/Model/Config/Backend/Datashare.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Backend/Datashare.php rename to app/code/Mage/Backend/Model/Config/Backend/Datashare.php diff --git a/app/code/core/Mage/Backend/Model/Config/Backend/Design/Exception.php b/app/code/Mage/Backend/Model/Config/Backend/Design/Exception.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Backend/Design/Exception.php rename to app/code/Mage/Backend/Model/Config/Backend/Design/Exception.php diff --git a/app/code/core/Mage/Backend/Model/Config/Backend/Email/Address.php b/app/code/Mage/Backend/Model/Config/Backend/Email/Address.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Backend/Email/Address.php rename to app/code/Mage/Backend/Model/Config/Backend/Email/Address.php diff --git a/app/code/core/Mage/Backend/Model/Config/Backend/Email/Logo.php b/app/code/Mage/Backend/Model/Config/Backend/Email/Logo.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Backend/Email/Logo.php rename to app/code/Mage/Backend/Model/Config/Backend/Email/Logo.php diff --git a/app/code/core/Mage/Backend/Model/Config/Backend/Email/Sender.php b/app/code/Mage/Backend/Model/Config/Backend/Email/Sender.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Backend/Email/Sender.php rename to app/code/Mage/Backend/Model/Config/Backend/Email/Sender.php diff --git a/app/code/core/Mage/Backend/Model/Config/Backend/Encrypted.php b/app/code/Mage/Backend/Model/Config/Backend/Encrypted.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Backend/Encrypted.php rename to app/code/Mage/Backend/Model/Config/Backend/Encrypted.php diff --git a/app/code/Mage/Backend/Model/Config/Backend/File.php b/app/code/Mage/Backend/Model/Config/Backend/File.php new file mode 100644 index 0000000000000..8b674aae69bc3 --- /dev/null +++ b/app/code/Mage/Backend/Model/Config/Backend/File.php @@ -0,0 +1,244 @@ + + */ +class Mage_Backend_Model_Config_Backend_File extends Mage_Core_Model_Config_Data +{ + /** + * @var Mage_Backend_Model_Config_Backend_File_RequestData_Interface + */ + protected $_requestData; + + /** + * Upload max file size in kilobytes + * + * @var int + */ + protected $_maxFileSize = 0; + + /** + * @var Magento_Filesystem + */ + protected $_filesystem; + + /** + * @param Mage_Core_Model_Context $context + * @param Mage_Backend_Model_Config_Backend_File_RequestData_Interface $requestData + * @param Magento_Filesystem $filesystem + * @param Mage_Core_Model_Resource_Abstract $resource + * @param Varien_Data_Collection_Db $resourceCollection + * @param array $data + */ + public function __construct( + Mage_Core_Model_Context $context, + Mage_Backend_Model_Config_Backend_File_RequestData_Interface $requestData, + Magento_Filesystem $filesystem, + Mage_Core_Model_Resource_Abstract $resource = null, + Varien_Data_Collection_Db $resourceCollection = null, + array $data = array() + ) { + parent::__construct($context, $resource, $resourceCollection, $data); + $this->_requestData = $requestData; + $this->_filesystem = $filesystem; + } + + /** + * Save uploaded file before saving config value + * + * @return Mage_Backend_Model_Config_Backend_File + */ + protected function _beforeSave() + { + $value = $this->getValue(); + + $tmpName = $this->_requestData->getTmpName($this->getPath()); + $file = array(); + if ($tmpName) { + $file['tmp_name'] = $tmpName; + $file['name'] = $this->_requestData->getName($this->getPath()); + } elseif (!empty($value['tmp_name'])) { + $file['tmp_name'] = $value['tmp_name']; + $file['name'] = $value['value']; + } + if (!empty($file)) { + $uploadDir = $this->_getUploadDir(); + try { + $uploader = new Mage_Core_Model_File_Uploader($file); + $uploader->setAllowedExtensions($this->_getAllowedExtensions()); + $uploader->setAllowRenameFiles(true); + $uploader->addValidateCallback('size', $this, 'validateMaxSize'); + $result = $uploader->save($uploadDir); + + } catch (Exception $e) { + Mage::throwException($e->getMessage()); + return $this; + } + + $filename = $result['file']; + if ($filename) { + if ($this->_addWhetherScopeInfo()) { + $filename = $this->_prependScopeInfo($filename); + } + $this->setValue($filename); + } + } else { + if (is_array($value) && !empty($value['delete'])) { + $this->setValue(''); + } else { + $this->unsValue(); + } + } + + return $this; + } + + /** + * Validation callback for checking max file size + * + * @param string $filePath Path to temporary uploaded file + * @throws Mage_Core_Exception + */ + public function validateMaxSize($filePath) + { + if ($this->_maxFileSize > 0 + && $this->_filesystem->getFileSize($filePath, dirname($filePath)) > ($this->_maxFileSize * 1024)) { + throw Mage::exception('Mage_Core', + Mage::helper('Mage_Backend_Helper_Data') + ->__('Uploaded file is larger than %.2f kilobytes allowed by server', $this->_maxFileSize) + ); + } + } + + /** + * Makes a decision about whether to add info about the scope. + * + * @return boolean + */ + protected function _addWhetherScopeInfo() + { + $fieldConfig = $this->getFieldConfig(); + $dirParams = array_key_exists('upload_dir', $fieldConfig) ? $fieldConfig['upload_dir'] : array(); + return (is_array($dirParams) && array_key_exists('scope_info', $dirParams) && $dirParams['scope_info']); + } + + /** + * Return path to directory for upload file + * + * @return string + * @throw Mage_Core_Exception + */ + protected function _getUploadDir() + { + $fieldConfig = $this->getFieldConfig(); + /* @var $fieldConfig Varien_Simplexml_Element */ + + if (!array_key_exists('upload_dir', $fieldConfig)) { + Mage::throwException( + Mage::helper('Mage_Catalog_Helper_Data')->__('The base directory to upload file is not specified.') + ); + } + + if (is_array($fieldConfig['upload_dir'])) { + $uploadDir = $fieldConfig['upload_dir']['value']; + if (array_key_exists('scope_info', $fieldConfig['upload_dir']) + && $fieldConfig['upload_dir']['scope_info'] + ) { + $uploadDir = $this->_appendScopeInfo($uploadDir); + } + + if (array_key_exists('config', $fieldConfig['upload_dir'])) { + $uploadRoot = $this->_getUploadRoot($fieldConfig['upload_dir']['config']); + $uploadDir = $uploadRoot . '/' . $uploadDir; + } + } else { + $uploadDir = (string) $fieldConfig['upload_dir']; + } + + return $uploadDir; + } + + /** + * Return the root part of directory path for uploading + * + * @var string + * @return string + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + protected function _getUploadRoot($token) + { + return Mage::getBaseDir('media'); + } + + /** + * Prepend path with scope info + * + * E.g. 'stores/2/path' , 'websites/3/path', 'default/path' + * + * @param string $path + * @return string + */ + protected function _prependScopeInfo($path) + { + $scopeInfo = $this->getScope(); + if ('default' != $this->getScope()) { + $scopeInfo .= '/' . $this->getScopeId(); + } + return $scopeInfo . '/' . $path; + } + + /** + * Add scope info to path + * + * E.g. 'path/stores/2' , 'path/websites/3', 'path/default' + * + * @param string $path + * @return string + */ + protected function _appendScopeInfo($path) + { + $path .= '/' . $this->getScope(); + if ('default' != $this->getScope()) { + $path .= '/' . $this->getScopeId(); + } + return $path; + } + + /** + * Getter for allowed extensions of uploaded files + * + * @return array + */ + protected function _getAllowedExtensions() + { + return array(); + } +} diff --git a/app/code/Mage/Backend/Model/Config/Backend/File/RequestData.php b/app/code/Mage/Backend/Model/Config/Backend/File/RequestData.php new file mode 100644 index 0000000000000..69f98c1df5843 --- /dev/null +++ b/app/code/Mage/Backend/Model/Config/Backend/File/RequestData.php @@ -0,0 +1,85 @@ +_getParam('tmp_name', $path); + } + + /** + * Retrieve uploaded file name by path + * + * @param string $path + * @return string + */ + public function getName($path) + { + return $this->_getParam('name', $path); + } + + /** + * Get $_FILES superglobal value by path + * + * @param string $paramName + * @param string $path + * @return string + */ + protected function _getParam($paramName, $path) + { + $pathParts = explode('/', $path); + array_shift($pathParts); + $fieldId = array_pop($pathParts); + $firstGroupId = array_shift($pathParts); + if (!isset($_FILES['groups'][$paramName])) { + return null; + } + $groupData = $_FILES['groups'][$paramName]; + if (isset($groupData[$firstGroupId])) { + $groupData = $groupData[$firstGroupId]; + } + foreach ($pathParts as $groupId) { + if (isset($groupData['groups'][$groupId])) { + $groupData = $groupData['groups'][$groupId]; + } else { + return null; + } + } + if (isset($groupData['fields'][$fieldId]['value'])) { + return $groupData['fields'][$fieldId]['value']; + } + return null; + } +} diff --git a/app/code/Mage/Backend/Model/Config/Backend/File/RequestData/Interface.php b/app/code/Mage/Backend/Model/Config/Backend/File/RequestData/Interface.php new file mode 100644 index 0000000000000..e3ae44e9ed151 --- /dev/null +++ b/app/code/Mage/Backend/Model/Config/Backend/File/RequestData/Interface.php @@ -0,0 +1,47 @@ +_backendFactory = $backendFactory; + $this->_sourceFactory = $sourceFactory; + $this->_commentFactory = $commentFactory; + $this->_blockFactory = $blockFactory; + $this->_datasourceFactory = $datasourceFactory; + $this->_dependencyMapper = $dependencyMapper; + } + + /** + * Retrieve field label + * + * @param string $labelPrefix + * @return string + */ + public function getLabel($labelPrefix = '') + { + $label = ''; + if ($labelPrefix) { + $label .= $this->_helperFactory->get($this->_getTranslationModule())->__($labelPrefix) . ' '; + } + $label .= parent::getLabel(); + return $label; + } + + /** + * Retrieve field hint + * + * @return string + */ + public function getHint() + { + return $this->_getTranslatedAttribute('hint'); + } + + /** + * Retrieve comment + * + * @param string $currentValue + * @return string + */ + public function getComment($currentValue = '') + { + $comment = ''; + if (isset($this->_data['comment'])) { + if (is_array($this->_data['comment'])) { + if (isset($this->_data['comment']['model'])) { + $model = $this->_commentFactory->create($this->_data['comment']['model']); + $comment = $model->getCommentText($currentValue); + } + } else { + $comment = parent::getComment(); + } + } + return $comment; + } + + /** + * Retrieve tooltip text + * + * @return string + */ + public function getTooltip() + { + if (isset($this->_data['tooltip'])) { + return $this->_getTranslatedAttribute('tooltip'); + } elseif (isset($this->_data['tooltip_block'])) { + return $this->_blockFactory->createBlock($this->_data['tooltip_block'])->toHtml(); + } + return ''; + } + + /** + * Retrieve field type + * + * @return string + */ + public function getType() + { + return isset($this->_data['type']) ? $this->_data['type'] : 'text'; + } + + /** + * Retrieve frontend css class + * + * @return string + */ + public function getFrontendClass() + { + return isset($this->_data['frontend_class']) ? $this->_data['frontend_class'] : ''; + } + + /** + * Check whether field has backend model + * + * @return bool + */ + public function hasBackendModel() + { + return array_key_exists('backend_model', $this->_data) && $this->_data['backend_model']; + } + + /** + * Retrieve backend model + * + * @return Mage_Core_Model_Config_Data + */ + public function getBackendModel() + { + return $this->_backendFactory->create($this->_data['backend_model']); + } + + /** + * Retrieve field section id + * + * @return string + */ + public function getSectionId() + { + $parts = explode('/', $this->getPath()); + return current($parts); + } + + /** + * Retrieve field group path + * + * @return string + */ + public function getGroupPath() + { + return dirname($this->getPath()); + } + + /** + * Retrieve config path + * + * @return null|string + */ + public function getConfigPath() + { + return isset($this->_data['config_path']) ? $this->_data['config_path'] : null; + } + + /** + * Check whether field should be shown in default scope + * + * @return bool + */ + public function showInDefault() + { + return isset($this->_data['showInDefault']) && (int)$this->_data['showInDefault']; + } + + /** + * Check whether field should be shown in website scope + * + * @return bool + */ + public function showInWebsite() + { + return isset($this->_data['showInWebsite']) && (int)$this->_data['showInWebsite']; + } + + /** + * Check whether field should be shown in store scope + * + * @return bool + */ + public function showInStore() + { + return isset($this->_data['showInStore']) && (int)$this->_data['showInStore']; + } + + /** + * Populate form element with field data + * + * @param Varien_Data_Form_Element_Abstract $formField + */ + public function populateInput($formField) + { + $originalData = array(); + foreach ($this->_data as $key => $value) { + if (!is_array($value)) { + $originalData[$key] = $value; + } + } + $formField->setOriginalData($originalData); + } + + /** + * Check whether field has validation class + * + * @return bool + */ + public function hasValidation() + { + return isset($this->_data['validate']); + } + + /** + * Retrieve field validation class + * + * @return string + */ + public function getValidation() + { + return $this->_data['validate']; + } + + /** + * Check whether field can be empty + * + * @return bool + */ + public function canBeEmpty() + { + return isset($this->_data['can_be_empty']); + } + + /** + * Check whether field has source model + * + * @return bool + */ + public function hasSourceModel() + { + return isset($this->_data['source_model']); + } + + /** + * Check whether field has options or source model + * + * @return bool + */ + public function hasOptions() + { + return isset($this->_data['source_model']) || isset($this->_data['options']); + } + + /** + * Retrieve options or source model option list + * + * @return array + */ + public function getOptions() + { + if (isset($this->_data['source_model'])) { + $sourceModel = $this->_data['source_model']; + $optionArray = $this->_getOptionsFromSourceModel($sourceModel); + return $optionArray; + } else { + if (isset($this->_data['options']['service-call'])) { + $optionsNode = $this->_data['options']; + $serviceCall = $optionsNode['service-call']; + $idField = $optionsNode['idField']; + $labelField = $optionsNode['labelField']; + $includeSelectLine = $optionsNode['includeSelectLine'] == "true"; + return $this->_getOptionsFromService($serviceCall, $idField, + $labelField, $includeSelectLine); + } else { + $options = $this->_data['options']['option']; + for ($i=0; $i_helperFactory->get( + $this->_getTranslationModule())->__($options[$i]['label']); + $value = $options[$i]['value']; + if (is_string($value) && preg_match('/{{(.*::.*)}}.*/', $value, $matches)) { + $value = constant($matches[1]); + } + $options[$i]['value'] = $value; + } + return $options; + } + } + } + + /** + * Retrieve options list from datasource + * + * @return array + */ + protected function _getOptionsFromService( + string $serviceCall, + $idField = 'id', + $labelField = 'name', + $includeSelectLine = FALSE + ) { + $dataCollection = $this->_datasourceFactory->get($serviceCall); + $options = array(); + if ($includeSelectLine) { + $options[] = array('value' => '', 'label' => '-- Please Select --'); + } + foreach ($dataCollection as $dataItem) { + $options[] = array('value' => $dataItem[$idField], + 'label' => $dataItem[$labelField]); + } + return $options; + } + + /** + * Retrieve options list from source model + * + * @param $sourceModel + * @return array + */ + protected function _getOptionsFromSourceModel($sourceModel) + { + $method = false; + if (preg_match('/^([^:]+?)::([^:]+?)$/', $sourceModel, $matches)) { + array_shift($matches); + list($sourceModel, $method) = array_values($matches); + } + + $sourceModel = $this->_sourceFactory->create($sourceModel); + if ($sourceModel instanceof Varien_Object) { + $sourceModel->setPath($this->getPath()); + } + if ($method) { + if ($this->getType() == 'multiselect') { + $optionArray = $sourceModel->$method(); + return $optionArray; + } else { + $optionArray = array(); + foreach ($sourceModel->$method() as $key => $value) { + if (is_array($value)) { + $optionArray[] = $value; + } else { + $optionArray[] = array('label' => $value, 'value' => $key); + } + } + return $optionArray; + } + } else { + $optionArray = $sourceModel->toOptionArray($this->getType() == 'multiselect'); + return $optionArray; + } + } + + /** + * Retrieve field dependencies + * + * @param $fieldPrefix + * @param $storeCode + * @return array + */ + public function getDependencies($fieldPrefix, $storeCode) + { + $dependencies = array(); + if (false == isset($this->_data['depends']['fields'])) { + return $dependencies; + } + $dependencies = $this->_dependencyMapper->getDependencies( + $this->_data['depends']['fields'], + $storeCode, + $fieldPrefix + ); + return $dependencies; + } + + /** + * Check whether element should be displayed for advanced users + * + * @return bool + */ + public function isAdvanced() + { + return isset($this->_data['advanced']) && $this->_data['advanced']; + } +} diff --git a/app/code/core/Mage/Backend/Model/Config/Structure/Element/FlyweightFactory.php b/app/code/Mage/Backend/Model/Config/Structure/Element/FlyweightFactory.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Structure/Element/FlyweightFactory.php rename to app/code/Mage/Backend/Model/Config/Structure/Element/FlyweightFactory.php diff --git a/app/code/core/Mage/Backend/Model/Config/Structure/Element/Group.php b/app/code/Mage/Backend/Model/Config/Structure/Element/Group.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Structure/Element/Group.php rename to app/code/Mage/Backend/Model/Config/Structure/Element/Group.php diff --git a/app/code/core/Mage/Backend/Model/Config/Structure/Element/Group/Proxy.php b/app/code/Mage/Backend/Model/Config/Structure/Element/Group/Proxy.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Structure/Element/Group/Proxy.php rename to app/code/Mage/Backend/Model/Config/Structure/Element/Group/Proxy.php diff --git a/app/code/core/Mage/Backend/Model/Config/Structure/Element/Iterator.php b/app/code/Mage/Backend/Model/Config/Structure/Element/Iterator.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Structure/Element/Iterator.php rename to app/code/Mage/Backend/Model/Config/Structure/Element/Iterator.php diff --git a/app/code/core/Mage/Backend/Model/Config/Structure/Element/Iterator/Field.php b/app/code/Mage/Backend/Model/Config/Structure/Element/Iterator/Field.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Structure/Element/Iterator/Field.php rename to app/code/Mage/Backend/Model/Config/Structure/Element/Iterator/Field.php diff --git a/app/code/core/Mage/Backend/Model/Config/Structure/Element/Iterator/Group.php b/app/code/Mage/Backend/Model/Config/Structure/Element/Iterator/Group.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Structure/Element/Iterator/Group.php rename to app/code/Mage/Backend/Model/Config/Structure/Element/Iterator/Group.php diff --git a/app/code/core/Mage/Backend/Model/Config/Structure/Element/Iterator/Section.php b/app/code/Mage/Backend/Model/Config/Structure/Element/Iterator/Section.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Structure/Element/Iterator/Section.php rename to app/code/Mage/Backend/Model/Config/Structure/Element/Iterator/Section.php diff --git a/app/code/core/Mage/Backend/Model/Config/Structure/Element/Iterator/Tab.php b/app/code/Mage/Backend/Model/Config/Structure/Element/Iterator/Tab.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Structure/Element/Iterator/Tab.php rename to app/code/Mage/Backend/Model/Config/Structure/Element/Iterator/Tab.php diff --git a/app/code/core/Mage/Backend/Model/Config/Structure/Element/Section.php b/app/code/Mage/Backend/Model/Config/Structure/Element/Section.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Structure/Element/Section.php rename to app/code/Mage/Backend/Model/Config/Structure/Element/Section.php diff --git a/app/code/core/Mage/Backend/Model/Config/Structure/Element/Tab.php b/app/code/Mage/Backend/Model/Config/Structure/Element/Tab.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Structure/Element/Tab.php rename to app/code/Mage/Backend/Model/Config/Structure/Element/Tab.php diff --git a/app/code/core/Mage/Backend/Model/Config/Structure/ElementAbstract.php b/app/code/Mage/Backend/Model/Config/Structure/ElementAbstract.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Structure/ElementAbstract.php rename to app/code/Mage/Backend/Model/Config/Structure/ElementAbstract.php diff --git a/app/code/core/Mage/Backend/Model/Config/Structure/ElementInterface.php b/app/code/Mage/Backend/Model/Config/Structure/ElementInterface.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Structure/ElementInterface.php rename to app/code/Mage/Backend/Model/Config/Structure/ElementInterface.php diff --git a/app/code/core/Mage/Backend/Model/Config/Structure/Mapper/Attribute/Inheritance.php b/app/code/Mage/Backend/Model/Config/Structure/Mapper/Attribute/Inheritance.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Structure/Mapper/Attribute/Inheritance.php rename to app/code/Mage/Backend/Model/Config/Structure/Mapper/Attribute/Inheritance.php diff --git a/app/code/core/Mage/Backend/Model/Config/Structure/Mapper/Dependencies.php b/app/code/Mage/Backend/Model/Config/Structure/Mapper/Dependencies.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Structure/Mapper/Dependencies.php rename to app/code/Mage/Backend/Model/Config/Structure/Mapper/Dependencies.php diff --git a/app/code/Mage/Backend/Model/Config/Structure/Mapper/Factory.php b/app/code/Mage/Backend/Model/Config/Structure/Mapper/Factory.php new file mode 100644 index 0000000000000..c494d177e1b53 --- /dev/null +++ b/app/code/Mage/Backend/Model/Config/Structure/Mapper/Factory.php @@ -0,0 +1,94 @@ + 'Mage_Backend_Model_Config_Structure_Mapper_Sorting', + self::MAPPER_PATH => 'Mage_Backend_Model_Config_Structure_Mapper_Path', + self::MAPPER_IGNORE => 'Mage_Backend_Model_Config_Structure_Mapper_Ignore', + self::MAPPER_DEPENDENCIES => 'Mage_Backend_Model_Config_Structure_Mapper_Dependencies', + self::MAPPER_ATTRIBUTE_INHERITANCE => 'Mage_Backend_Model_Config_Structure_Mapper_Attribute_Inheritance', + ); + + public function __construct(Magento_ObjectManager $objectManager) + { + $this->_objectManager = $objectManager; + } + + /** + * Get mapper instance + * + * @param string $type + * @param array $arguments + * @return Mage_Backend_Model_Config_Structure_MapperInterface + * @throws Exception + */ + public function create($type) + { + $className = $this->_getMapperClassNameByType($type); + + /** @var Mage_Backend_Model_Config_Structure_MapperInterface $mapperInstance */ + $mapperInstance = $this->_objectManager->create($className); + + if (false == ($mapperInstance instanceof Mage_Backend_Model_Config_Structure_MapperInterface)) { + throw new Exception('Mapper object is not instance on Mage_Backend_Model_Config_Structure_MapperInterface'); + } + return $mapperInstance; + } + + /** + * Get mapper class name by type + * + * @param string $type + * @return string mixed + * @throws InvalidArgumentException + */ + protected function _getMapperClassNameByType($type) + { + if (false == isset($this->_typeMap[$type])) { + throw new InvalidArgumentException('Invalid mapper type: ' . $type); + } + return $this->_typeMap[$type]; + } +} diff --git a/app/code/core/Mage/Backend/Model/Config/Structure/Mapper/Ignore.php b/app/code/Mage/Backend/Model/Config/Structure/Mapper/Ignore.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Structure/Mapper/Ignore.php rename to app/code/Mage/Backend/Model/Config/Structure/Mapper/Ignore.php diff --git a/app/code/core/Mage/Backend/Model/Config/Structure/Mapper/Path.php b/app/code/Mage/Backend/Model/Config/Structure/Mapper/Path.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Structure/Mapper/Path.php rename to app/code/Mage/Backend/Model/Config/Structure/Mapper/Path.php diff --git a/app/code/core/Mage/Backend/Model/Config/Structure/Mapper/Sorting.php b/app/code/Mage/Backend/Model/Config/Structure/Mapper/Sorting.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Structure/Mapper/Sorting.php rename to app/code/Mage/Backend/Model/Config/Structure/Mapper/Sorting.php diff --git a/app/code/core/Mage/Backend/Model/Config/Structure/MapperAbstract.php b/app/code/Mage/Backend/Model/Config/Structure/MapperAbstract.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Structure/MapperAbstract.php rename to app/code/Mage/Backend/Model/Config/Structure/MapperAbstract.php diff --git a/app/code/core/Mage/Backend/Model/Config/Structure/MapperInterface.php b/app/code/Mage/Backend/Model/Config/Structure/MapperInterface.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Structure/MapperInterface.php rename to app/code/Mage/Backend/Model/Config/Structure/MapperInterface.php diff --git a/app/code/Mage/Backend/Model/Config/Structure/Reader.php b/app/code/Mage/Backend/Model/Config/Structure/Reader.php new file mode 100644 index 0000000000000..3012a2e2c2702 --- /dev/null +++ b/app/code/Mage/Backend/Model/Config/Structure/Reader.php @@ -0,0 +1,168 @@ + + */ +class Mage_Backend_Model_Config_Structure_Reader extends Magento_Config_XmlAbstract +{ + const CACHE_SYSTEM_CONFIGURATION_STRUCTURE = 'backend_system_configuration_structure'; + + /** + * Turns runtime validation on/off + * + * @var bool + */ + protected $_runtimeValidation; + + /** + * Structure converter + * + * @var Mage_Backend_Model_Config_Structure_Converter + */ + protected $_converter; + + /** + * Module configuration reader + * + * @var Mage_Core_Model_Config_Modules_Reader + */ + protected $_modulesReader; + + /** + * @param Mage_Core_Model_Cache_Type_Config $configCacheType + * @param Mage_Core_Model_Config_Modules_Reader $moduleReader + * @param Mage_Backend_Model_Config_Structure_Converter $structureConverter + * @param bool $runtimeValidation + */ + public function __construct( + Mage_Core_Model_Cache_Type_Config $configCacheType, + Mage_Core_Model_Config_Modules_Reader $moduleReader, + Mage_Backend_Model_Config_Structure_Converter $structureConverter, + $runtimeValidation = true + ) { + $this->_modulesReader = $moduleReader; + $this->_runtimeValidation = $runtimeValidation; + $this->_converter = $structureConverter; + + $cachedData = $configCacheType->load(self::CACHE_SYSTEM_CONFIGURATION_STRUCTURE); + if ($cachedData) { + $this->_data = unserialize($cachedData); + } else { + $fileNames = $this->_modulesReader->getModuleConfigurationFiles( + 'adminhtml' . DIRECTORY_SEPARATOR . 'system.xml' + ); + parent::__construct($fileNames); + $configCacheType->save(serialize($this->_data), self::CACHE_SYSTEM_CONFIGURATION_STRUCTURE); + } + } + + /** + * Get absolute path to the XML-schema file + * + * @return string + */ + public function getSchemaFile() + { + return $this->_modulesReader->getModuleDir('etc', 'Mage_Backend') . DIRECTORY_SEPARATOR . 'system.xsd'; + } + + /** + * Get absolute path to the XML-schema file + * + * @return string + */ + public function getPerFileSchemaFile() + { + return $this->_modulesReader->getModuleDir('etc', 'Mage_Backend') . DIRECTORY_SEPARATOR . 'system_file.xsd'; + } + + /** + * Extract configuration data from the DOM structure + * + * @param DOMDocument $dom + * @return array|DOMNodeList + */ + protected function _extractData(DOMDocument $dom) + { + $data = $this->_converter->convert($dom); + return $data['config']['system']; + } + + /** + * Get XML-contents, initial for merging + * + * @return string + */ + protected function _getInitialXml() + { + return ''; + } + + /** + * Get list of paths to identifiable nodes + * + * @return array + */ + protected function _getIdAttributes() + { + return array( + '/config/system/tab' => 'id', + '/config/system/section' => 'id', + '/config/system/section/group' => 'id', + '/config/system/section/group/field' => 'id', + '/config/system/section/group/group/field' => 'id', + '/config/system/section/group/group/group/field' => 'id', + '/config/system/section/group/group/group/group/field' => 'id', + ); + } + + /** + * Check whether runtime validation should be performed + * + * @return bool + */ + protected function _isRuntimeValidated() + { + return $this->_runtimeValidation; + } + + /** + * Retrieve all sections system configuration layout + * + * @return array + */ + public function getData() + { + return $this->_data; + } +} diff --git a/app/code/core/Mage/Backend/Model/Config/Structure/Search/Proxy.php b/app/code/Mage/Backend/Model/Config/Structure/Search/Proxy.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Structure/Search/Proxy.php rename to app/code/Mage/Backend/Model/Config/Structure/Search/Proxy.php diff --git a/app/code/core/Mage/Backend/Model/Config/Structure/SearchInterface.php b/app/code/Mage/Backend/Model/Config/Structure/SearchInterface.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Config/Structure/SearchInterface.php rename to app/code/Mage/Backend/Model/Config/Structure/SearchInterface.php diff --git a/app/code/core/Mage/Backend/Model/Menu.php b/app/code/Mage/Backend/Model/Menu.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Menu.php rename to app/code/Mage/Backend/Model/Menu.php diff --git a/app/code/Mage/Backend/Model/Menu/Builder.php b/app/code/Mage/Backend/Model/Menu/Builder.php new file mode 100644 index 0000000000000..44cefcc5796d1 --- /dev/null +++ b/app/code/Mage/Backend/Model/Menu/Builder.php @@ -0,0 +1,132 @@ +_itemFactory = $menuItemFactory; + $this->_menu = $menu; + } + + /** + * Process provided command object + * + * @param Mage_Backend_Model_Menu_Builder_CommandAbstract $command + * @return Mage_Backend_Model_Menu_Builder + */ + public function processCommand(Mage_Backend_Model_Menu_Builder_CommandAbstract $command) + { + if (!isset($this->_commands[$command->getId()])) { + $this->_commands[$command->getId()] = $command; + } else { + $this->_commands[$command->getId()]->chain($command); + } + return $this; + } + + /** + * @return Mage_Backend_Model_Menu + * @throws OutOfRangeException in case given parent id does not exists + */ + public function getResult() + { + /** @var $items Mage_Backend_Model_Menu_Item[] */ + $params = array(); + $items = array(); + + // Create menu items + foreach ($this->_commands as $id => $command) { + $params[$id] = $command->execute(); + $item = $this->_itemFactory->create($params[$id]); + $items[$id] = $item; + } + + // Build menu tree based on "parent" param + foreach ($items as $id => $item) { + $sortOrder = $this->_getParam($params[$id], 'sortOrder'); + $parentId = $this->_getParam($params[$id], 'parent'); + $isRemoved = isset($params[$id]['removed']); + + if ($isRemoved) { + continue; + } + if (!$parentId) { + $this->_menu->add($item, null, $sortOrder); + } else { + if (!isset($items[$parentId])) { + throw new OutOfRangeException(sprintf('Specified invalid parent id (%s)', $parentId)); + } + if (isset($params[$parentId]['removed'])) { + continue; + } + $items[$parentId]->getChildren()->add($item, null, $sortOrder); + } + } + + return $this->_menu; + } + + /** + * Retrieve param by name or default value + * + * @param array $params + * @param string $paramName + * @param mixed $defaultValue + * @return mixed + */ + protected function _getParam($params, $paramName, $defaultValue = null) + { + return isset($params[$paramName]) ? $params[$paramName] : $defaultValue; + } +} diff --git a/app/code/core/Mage/Backend/Model/Menu/Builder/Command/Add.php b/app/code/Mage/Backend/Model/Menu/Builder/Command/Add.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Menu/Builder/Command/Add.php rename to app/code/Mage/Backend/Model/Menu/Builder/Command/Add.php diff --git a/app/code/core/Mage/Backend/Model/Menu/Builder/Command/Remove.php b/app/code/Mage/Backend/Model/Menu/Builder/Command/Remove.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Menu/Builder/Command/Remove.php rename to app/code/Mage/Backend/Model/Menu/Builder/Command/Remove.php diff --git a/app/code/core/Mage/Backend/Model/Menu/Builder/Command/Update.php b/app/code/Mage/Backend/Model/Menu/Builder/Command/Update.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Menu/Builder/Command/Update.php rename to app/code/Mage/Backend/Model/Menu/Builder/Command/Update.php diff --git a/app/code/core/Mage/Backend/Model/Menu/Builder/CommandAbstract.php b/app/code/Mage/Backend/Model/Menu/Builder/CommandAbstract.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Menu/Builder/CommandAbstract.php rename to app/code/Mage/Backend/Model/Menu/Builder/CommandAbstract.php diff --git a/app/code/Mage/Backend/Model/Menu/Config.php b/app/code/Mage/Backend/Model/Menu/Config.php new file mode 100644 index 0000000000000..a47d1aac07479 --- /dev/null +++ b/app/code/Mage/Backend/Model/Menu/Config.php @@ -0,0 +1,198 @@ +_configCacheType = $configCacheType; + $this->_factory = $factory; + $this->_moduleReader = $moduleReader; + $this->_eventManager = $eventManager; + $this->_logger = $logger; + $this->_menuFactory = $menuFactory; + } + + /** + * Build menu model from config + * + * @return Mage_Backend_Model_Menu + * @throws InvalidArgumentException|BadMethodCallException|OutOfRangeException|Exception + */ + public function getMenu() + { + $store = $this->_factory->get('Mage_Core_Model_App')->getStore(); + $this->_logger->addStoreLog(Mage_Backend_Model_Menu::LOGGER_KEY, $store); + try { + $this->_initMenu(); + return $this->_menu; + } catch (InvalidArgumentException $e) { + $this->_logger->logException($e); + throw $e; + } catch (BadMethodCallException $e) { + $this->_logger->logException($e); + throw $e; + } catch (OutOfRangeException $e) { + $this->_logger->logException($e); + throw $e; + } catch (Exception $e) { + throw $e; + } + } + + /** + * Initialize menu object + * + * @return void + */ + protected function _initMenu() + { + if (!$this->_menu) { + $this->_menu = $this->_menuFactory->getMenuInstance(); + + $cache = $this->_configCacheType->load(self::CACHE_MENU_OBJECT); + if ($cache) { + $this->_menu->unserialize($cache); + return; + } + + /* @var $director Mage_Backend_Model_Menu_Builder */ + $menuBuilder = $this->_factory->create('Mage_Backend_Model_Menu_Builder', array( + 'menu' => $this->_menu, + 'menuItemFactory' => $this->_factory->get('Mage_Backend_Model_Menu_Item_Factory'), + )); + + /* @var $director Mage_Backend_Model_Menu_Director_Dom */ + $director = $this->_factory->create( + 'Mage_Backend_Model_Menu_Director_Dom', + array( + 'menuConfig' => $this->_getDom(), + 'factory' => $this->_factory, + 'menuLogger' => $this->_logger + ) + ); + $director->buildMenu($menuBuilder); + $this->_menu = $menuBuilder->getResult(); + $this->_eventManager->dispatch('backend_menu_load_after', array('menu' => $this->_menu)); + + $this->_configCacheType->save($this->_menu->serialize(), self::CACHE_MENU_OBJECT); + } + } + + /** + * @return DOMDocument + */ + protected function _getDom() + { + $mergedConfigXml = $this->_loadCache(); + if ($mergedConfigXml) { + $mergedConfig = new DOMDocument(); + $mergedConfig->loadXML($mergedConfigXml); + } else { + $fileList = $this->getMenuConfigurationFiles(); + $mergedConfig = $this->_factory + ->create('Mage_Backend_Model_Menu_Config_Menu', array('configFiles' => $fileList)) + ->getMergedConfig(); + $this->_saveCache($mergedConfig->saveXML()); + } + return $mergedConfig; + } + + protected function _loadCache() + { + return $this->_configCacheType->load(self::CACHE_ID); + } + + protected function _saveCache($xml) + { + $this->_configCacheType->save($xml, self::CACHE_ID); + return $this; + } + + /** + * Return array menu configuration files + * + * @return array + */ + public function getMenuConfigurationFiles() + { + $files = $this->_moduleReader + ->getModuleConfigurationFiles('adminhtml' . DIRECTORY_SEPARATOR . 'menu.xml'); + return (array) $files; + } +} diff --git a/app/code/core/Mage/Backend/Model/Menu/Config/Menu.php b/app/code/Mage/Backend/Model/Menu/Config/Menu.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Menu/Config/Menu.php rename to app/code/Mage/Backend/Model/Menu/Config/Menu.php diff --git a/app/code/core/Mage/Backend/Model/Menu/Config/Menu/Dom.php b/app/code/Mage/Backend/Model/Menu/Config/Menu/Dom.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Menu/Config/Menu/Dom.php rename to app/code/Mage/Backend/Model/Menu/Config/Menu/Dom.php diff --git a/app/code/core/Mage/Backend/Model/Menu/Director/Dom.php b/app/code/Mage/Backend/Model/Menu/Director/Dom.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Menu/Director/Dom.php rename to app/code/Mage/Backend/Model/Menu/Director/Dom.php diff --git a/app/code/core/Mage/Backend/Model/Menu/DirectorAbstract.php b/app/code/Mage/Backend/Model/Menu/DirectorAbstract.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Menu/DirectorAbstract.php rename to app/code/Mage/Backend/Model/Menu/DirectorAbstract.php diff --git a/app/code/Mage/Backend/Model/Menu/Factory.php b/app/code/Mage/Backend/Model/Menu/Factory.php new file mode 100644 index 0000000000000..76faa242b7a89 --- /dev/null +++ b/app/code/Mage/Backend/Model/Menu/Factory.php @@ -0,0 +1,59 @@ +_factory = $factory; + $this->_logger = $logger; + } + + /** + * Retrieve menu model + * @param string $path + * @return Mage_Backend_Model_Menu + */ + public function getMenuInstance($path = '') + { + return $this->_factory->create( + 'Mage_Backend_Model_Menu', array('menuLogger' => $this->_logger, 'pathInMenuStructure' => $path) + ); + } +} diff --git a/app/code/core/Mage/Backend/Model/Menu/Filter/Iterator.php b/app/code/Mage/Backend/Model/Menu/Filter/Iterator.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Menu/Filter/Iterator.php rename to app/code/Mage/Backend/Model/Menu/Filter/Iterator.php diff --git a/app/code/core/Mage/Backend/Model/Menu/Item.php b/app/code/Mage/Backend/Model/Menu/Item.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Menu/Item.php rename to app/code/Mage/Backend/Model/Menu/Item.php diff --git a/app/code/Mage/Backend/Model/Menu/Item/Factory.php b/app/code/Mage/Backend/Model/Menu/Item/Factory.php new file mode 100644 index 0000000000000..024bafb561faf --- /dev/null +++ b/app/code/Mage/Backend/Model/Menu/Item/Factory.php @@ -0,0 +1,134 @@ +_acl = $authorization; + $this->_objectFactory = $factory; + $this->_menuFactory = $menuFactory; + $this->_appConfig = $applicationConfig; + $this->_storeConfig = $storeConfig; + $this->_urlModel = $urlModel; + $this->_validator = $menuItemValidator; + + if (isset($data['helpers'])) { + $this->_helpers = $data['helpers']; + } + } + + /** + * Create menu item from array + * + * @param array $data + * @return Mage_Backend_Model_Menu_Item + */ + public function create(array $data = array()) + { + $module = 'Mage_Backend_Helper_Data'; + if (isset($data['module'])) { + $module = $data['module']; + unset($data['module']); + } + + $data = array('data' => $data); + + $data['authorization'] = $this->_acl; + $data['applicationConfig'] = $this->_appConfig; + $data['storeConfig'] = $this->_storeConfig; + $data['menuFactory'] = $this->_menuFactory; + $data['urlModel'] = $this->_urlModel; + $data['validator'] = $this->_validator; + $data['helper'] = isset($this->_helpers[$module]) ? $this->_helpers[$module] : Mage::helper($module); + return $this->_objectFactory->create('Mage_Backend_Model_Menu_Item', $data); + } +} diff --git a/app/code/core/Mage/Backend/Model/Menu/Item/Validator.php b/app/code/Mage/Backend/Model/Menu/Item/Validator.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Menu/Item/Validator.php rename to app/code/Mage/Backend/Model/Menu/Item/Validator.php diff --git a/app/code/core/Mage/Backend/Model/Menu/Iterator.php b/app/code/Mage/Backend/Model/Menu/Iterator.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Menu/Iterator.php rename to app/code/Mage/Backend/Model/Menu/Iterator.php diff --git a/app/code/Mage/Backend/Model/Observer.php b/app/code/Mage/Backend/Model/Observer.php new file mode 100644 index 0000000000000..89ee1aef76207 --- /dev/null +++ b/app/code/Mage/Backend/Model/Observer.php @@ -0,0 +1,74 @@ + + */ +class Mage_Backend_Model_Observer +{ + + public function bindLocale($observer) + { + if ($locale=$observer->getEvent()->getLocale()) { + if ($choosedLocale = Mage::getSingleton('Mage_Backend_Model_Session')->getLocale()) { + $locale->setLocaleCode($choosedLocale); + } + } + return $this; + } + + /** + * Prepare massaction separated data + * + * @return Mage_Backend_Model_Observer + */ + public function massactionPrepareKey() + { + $request = Mage::app()->getFrontController()->getRequest(); + if ($key = $request->getPost('massaction_prepare_key')) { + $postData = $request->getPost($key); + $value = is_array($postData) ? $postData : explode(',', $postData); + $request->setPost($key, $value ? $value : null); + } + return $this; + } + + /** + * Clear result of configuration files access level verification in system cache + * + * @return Mage_Backend_Model_Observer + */ + public function clearCacheConfigurationFilesAccessLevelVerification() + { + Mage::app()->removeCache(Mage_Adminhtml_Block_Notification_Security::VERIFICATION_RESULT_CACHE_KEY); + return $this; + } +} diff --git a/app/code/core/Mage/Backend/Model/Session.php b/app/code/Mage/Backend/Model/Session.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Session.php rename to app/code/Mage/Backend/Model/Session.php diff --git a/app/code/Mage/Backend/Model/Url.php b/app/code/Mage/Backend/Model/Url.php new file mode 100644 index 0000000000000..55dcab465509c --- /dev/null +++ b/app/code/Mage/Backend/Model/Url.php @@ -0,0 +1,368 @@ +_startupMenuItemId = $storeConfig->getConfig(self::XML_PATH_STARTUP_MENU_ITEM); + $this->_backendHelper = $backendHelper; + $this->_coreSession = $coreSession; + $this->_coreHelper = $coreHelper; + $this->_menuConfig = $menuConfig; + } + + /** + * Retrieve is secure mode for ULR logic + * + * @return bool + */ + public function isSecure() + { + if ($this->hasData('secure_is_forced')) { + return $this->getData('secure'); + } + return Mage::getStoreConfigFlag('web/secure/use_in_adminhtml'); + } + + /** + * Force strip secret key param if _nosecret param specified + * + * @param array $data + * @param bool $unsetOldParams + * @return Mage_Backend_Model_Url + */ + public function setRouteParams(array $data, $unsetOldParams=true) + { + if (isset($data['_nosecret'])) { + $this->setNoSecret(true); + unset($data['_nosecret']); + } else { + $this->setNoSecret(false); + } + + return parent::setRouteParams($data, $unsetOldParams); + } + + /** + * Custom logic to retrieve Urls + * + * @param string $routePath + * @param array $routeParams + * @return string + */ + public function getUrl($routePath=null, $routeParams=null) + { + $cacheSecretKey = false; + if (is_array($routeParams) && isset($routeParams['_cache_secret_key'])) { + unset($routeParams['_cache_secret_key']); + $cacheSecretKey = true; + } + + $result = parent::getUrl($routePath, $routeParams); + if (!$this->useSecretKey()) { + return $result; + } + + $routeName = $this->getRouteName('*'); + $controllerName = $this->getControllerName($this->getDefaultControllerName()); + $actionName = $this->getActionName($this->getDefaultActionName()); + + if ($cacheSecretKey) { + $secret = array(self::SECRET_KEY_PARAM_NAME => "\${$routeName}/{$controllerName}/{$actionName}\$"); + } else { + $secret = array( + self::SECRET_KEY_PARAM_NAME => $this->getSecretKey($routeName, $controllerName, $actionName) + ); + } + if (is_array($routeParams)) { + $routeParams = array_merge($secret, $routeParams); + } else { + $routeParams = $secret; + } + if (is_array($this->getRouteParams())) { + $routeParams = array_merge($this->getRouteParams(), $routeParams); + } + + return parent::getUrl("{$routeName}/{$controllerName}/{$actionName}", $routeParams); + } + + /** + * Generate secret key for controller and action based on form key + * + * @param string $routeName + * @param string $controller Controller name + * @param string $action Action name + * @return string + */ + public function getSecretKey($routeName = null, $controller = null, $action = null) + { + $salt = $this->_coreSession->getFormKey(); + $request = $this->getRequest(); + + if (!$routeName) { + if ($request->getBeforeForwardInfo('route_name') !== null) { + $routeName = $request->getBeforeForwardInfo('route_name'); + } else { + $routeName = $request->getRouteName(); + } + } + + if (!$controller) { + if ($request->getBeforeForwardInfo('controller_name') !== null) { + $controller = $request->getBeforeForwardInfo('controller_name'); + } else { + $controller = $request->getControllerName(); + } + } + + if (!$action) { + if ($request->getBeforeForwardInfo('action_name') !== null) { + $action = $request->getBeforeForwardInfo('action_name'); + } else { + $action = $request->getActionName(); + } + } + + $secret = $routeName . $controller . $action . $salt; + return $this->_coreHelper->getHash($secret); + } + + /** + * Return secret key settings flag + * + * @return boolean + */ + public function useSecretKey() + { + return Mage::getStoreConfigFlag('admin/security/use_form_key') && !$this->getNoSecret(); + } + + /** + * Enable secret key using + * + * @return Mage_Backend_Model_Url + */ + public function turnOnSecretKey() + { + $this->setNoSecret(false); + return $this; + } + + /** + * Disable secret key using + * + * @return Mage_Backend_Model_Url + */ + public function turnOffSecretKey() + { + $this->setNoSecret(true); + return $this; + } + + /** + * Refresh admin menu cache etc. + * + * @return Mage_Backend_Model_Url + */ + public function renewSecretUrls() + { + Mage::app()->cleanCache(array(Mage_Backend_Block_Menu::CACHE_TAGS)); + } + + /** + * Find admin start page url + * + * @return string + */ + public function getStartupPageUrl() + { + $menuItem = $this->_getMenu()->get($this->_startupMenuItemId); + if (!is_null($menuItem)) { + if ($menuItem->isAllowed() && $menuItem->getAction()) { + return $menuItem->getAction(); + } + } + return $this->findFirstAvailableMenu(); + } + + /** + * Find first menu item that user is able to access + * + * @return string + */ + public function findFirstAvailableMenu() + { + /* @var $menu Mage_Backend_Model_Menu_Item */ + $menu = $this->_getMenu(); + $item = $menu->getFirstAvailable(); + $action = $item ? $item->getAction() : null; + if (!$item) { + $user = $this->_getSession()->getUser(); + if ($user) { + $user->setHasAvailableResources(false); + } + $action = '*/*/denied'; + } + return $action; + + } + + /** + * Get Menu model + * + * @return Mage_Backend_Model_Menu + */ + protected function _getMenu() + { + if (is_null($this->_menu)) { + $this->_menu = $this->_menuConfig->getMenu(); + } + return $this->_menu; + } + + /** + * Set custom auth session + * + * @param Mage_Backend_Model_Auth_Session $session + * @return Mage_Backend_Model_Url + */ + public function setSession(Mage_Backend_Model_Auth_Session $session) + { + $this->_session = $session; + return $this; + } + + /** + * Retrieve auth session + * + * @return Mage_Backend_Model_Auth_Session + */ + protected function _getSession() + { + if ($this->_session == null) { + $this->_session = Mage::getSingleton('Mage_Backend_Model_Auth_Session'); + } + return $this->_session; + } + + + /** + * Return backend area front name, defined in configuration + * + * @return string + */ + public function getAreaFrontName() + { + if (!$this->_getData('area_front_name')) { + $this->setData('area_front_name', $this->_backendHelper->getAreaFrontName()); + } + + return $this->_getData('area_front_name'); + } + + /** + * Retrieve action path. + * Add backend area front name as a prefix to action path + * + * @return string + */ + public function getActionPath() + { + $path = parent::getActionPath(); + if ($path) { + if ($this->getAreaFrontName()) { + $path = $this->getAreaFrontName() . '/' . $path; + } + } + + return $path; + } +} diff --git a/app/code/Mage/Backend/Model/Url/Proxy.php b/app/code/Mage/Backend/Model/Url/Proxy.php new file mode 100644 index 0000000000000..7cdbea9b816ae --- /dev/null +++ b/app/code/Mage/Backend/Model/Url/Proxy.php @@ -0,0 +1,818 @@ +_objectManager = $objectManager; + } + + /** + * Get instance + * + * @return Mage_Backend_Model_Url + */ + protected function _getObject() + { + if (null === $this->_object) { + $this->_object = $this->_objectManager->get('Mage_Backend_Model_Url'); + } + return $this->_object; + } + + /** + * {@inheritdoc} + */ + public function isSecure() + { + return $this->_getObject()->isSecure(); + } + + /** + * {@inheritdoc} + */ + public function setRouteParams(array $data, $unsetOldParams = true) + { + return $this->_getObject()->setRouteParams($data, $unsetOldParams); + } + + /** + * {@inheritdoc} + */ + public function getUrl($routePath = null, $routeParams = null) + { + return $this->_getObject()->getUrl($routePath, $routeParams); + } + + /** + * {@inheritdoc} + */ + public function getSecretKey($routeName = null, $controller = null, $action = null) + { + return $this->_getObject()->getSecretKey($routeName, $controller, $action); + } + + /** + * {@inheritdoc} + */ + public function useSecretKey() + { + return $this->_getObject()->useSecretKey(); + } + + /** + * {@inheritdoc} + */ + public function turnOnSecretKey() + { + return $this->_getObject()->turnOnSecretKey(); + } + + /** + * {@inheritdoc} + */ + public function turnOffSecretKey() + { + return $this->_getObject()->turnOffSecretKey(); + } + + /** + * {@inheritdoc} + */ + public function renewSecretUrls() + { + return $this->_getObject()->renewSecretUrls(); + } + + /** + * {@inheritdoc} + */ + public function getStartupPageUrl() + { + return $this->_getObject()->getStartupPageUrl(); + } + + /** + * {@inheritdoc} + */ + public function findFirstAvailableMenu() + { + return $this->_getObject()->findFirstAvailableMenu(); + } + + /** + * {@inheritdoc} + */ + public function setSession(Mage_Backend_Model_Auth_Session $session) + { + return $this->_getObject()->setSession($session); + } + + /** + * {@inheritdoc} + */ + public function getAreaFrontName() + { + return $this->_getObject()->getAreaFrontName(); + } + + /** + * {@inheritdoc} + */ + public function getActionPath() + { + return $this->_getObject()->getActionPath(); + } + + /** + * {@inheritdoc} + */ + public function parseUrl($url) + { + return $this->_getObject()->parseUrl($url); + } + + /** + * {@inheritdoc} + */ + public function getDefaultControllerName() + { + return $this->_getObject()->getDefaultControllerName(); + } + + /** + * {@inheritdoc} + */ + public function setUseUrlCache($flag) + { + return $this->_getObject()->setUseUrlCache($flag); + } + + /** + * {@inheritdoc} + */ + public function setUseSession($useSession) + { + return $this->_getObject()->setUseSession($useSession); + } + + /** + * {@inheritdoc} + */ + public function setRouteFrontName($name) + { + return $this->_getObject()->setRouteFrontName($name); + } + + /** + * {@inheritdoc} + */ + public function getUseSession() + { + return $this->_getObject()->getUseSession(); + } + + /** + * {@inheritdoc} + */ + public function getDefaultActionName() + { + return $this->_getObject()->getDefaultActionName(); + } + + /** + * {@inheritdoc} + */ + public function getConfigData($key, $prefix = null) + { + return $this->_getObject()->getConfigData($key, $prefix); + } + + /** + * {@inheritdoc} + */ + public function setRequest(\Zend_Controller_Request_Http $request) + { + return $this->_getObject()->setRequest($request); + } + + /** + * {@inheritdoc} + */ + public function getRequest() + { + return $this->_getObject()->getRequest(); + } + + /** + * {@inheritdoc} + */ + public function getType() + { + return $this->_getObject()->getType(); + } + + /** + * {@inheritdoc} + */ + public function setStore($params) + { + return $this->_getObject()->setStore($params); + } + + /** + * {@inheritdoc} + */ + public function getStore() + { + return $this->_getObject()->getStore(); + } + + /** + * {@inheritdoc} + */ + public function getBaseUrl($params = array()) + { + return $this->_getObject()->getBaseUrl($params); + } + + /** + * {@inheritdoc} + */ + public function setRoutePath($data) + { + return $this->_getObject()->setRoutePath($data); + } + + /** + * {@inheritdoc} + */ + public function getRoutePath($routeParams = array()) + { + return $this->_getObject()->getRoutePath($routeParams); + } + + /** + * {@inheritdoc} + */ + public function setRouteName($data) + { + return $this->_getObject()->setRouteName($data); + } + + /** + * {@inheritdoc} + */ + public function getRouteFrontName() + { + return $this->_getObject()->getRouteFrontName(); + } + + /** + * {@inheritdoc} + */ + public function getRouteName($default = null) + { + return $this->_getObject()->getRouteName($default); + } + + /** + * {@inheritdoc} + */ + public function setControllerName($data) + { + return $this->_getObject()->setControllerName($data); + } + + /** + * {@inheritdoc} + */ + public function getControllerName($default = null) + { + return $this->_getObject()->getControllerName($default); + } + + /** + * {@inheritdoc} + */ + public function setActionName($data) + { + return $this->_getObject()->setActionName($data); + } + + /** + * {@inheritdoc} + */ + public function getActionName($default = null) + { + return $this->_getObject()->getActionName($default); + } + + /** + * {@inheritdoc} + */ + public function getRouteParams() + { + return $this->_getObject()->getRouteParams(); + } + + /** + * {@inheritdoc} + */ + public function setRouteParam($key, $data) + { + return $this->_getObject()->setRouteParam($key, $data); + } + + /** + * {@inheritdoc} + */ + public function getRouteParam($key) + { + return $this->_getObject()->getRouteParam($key); + } + + /** + * {@inheritdoc} + */ + public function getRouteUrl($routePath = null, $routeParams = null) + { + return $this->_getObject()->getRouteUrl($routePath, $routeParams); + } + + /** + * {@inheritdoc} + */ + public function checkCookieDomains() + { + return $this->_getObject()->checkCookieDomains(); + } + + /** + * {@inheritdoc} + */ + public function addSessionParam() + { + return $this->_getObject()->addSessionParam(); + } + + /** + * {@inheritdoc} + */ + public function setQuery($data) + { + return $this->_getObject()->setQuery($data); + } + + /** + * {@inheritdoc} + */ + public function getQuery($escape = false) + { + return $this->_getObject()->getQuery($escape); + } + + /** + * {@inheritdoc} + */ + public function setQueryParams(array $data) + { + return $this->_getObject()->setQueryParams($data); + } + + /** + * {@inheritdoc} + */ + public function purgeQueryParams() + { + return $this->_getObject()->purgeQueryParams(); + } + + /** + * {@inheritdoc} + */ + public function getQueryParams() + { + return $this->_getObject()->getQueryParams(); + } + + /** + * {@inheritdoc} + */ + public function setQueryParam($key, $data) + { + return $this->_getObject()->setQueryParam($key, $data); + } + + /** + * {@inheritdoc} + */ + public function getQueryParam($key) + { + return $this->_getObject()->getQueryParam($key); + } + + /** + * {@inheritdoc} + */ + public function setFragment($data) + { + return $this->_getObject()->setFragment($data); + } + + /** + * {@inheritdoc} + */ + public function getFragment() + { + return $this->_getObject()->getFragment(); + } + + /** + * {@inheritdoc} + */ + public function getRebuiltUrl($url) + { + return $this->_getObject()->getRebuiltUrl($url); + } + + /** + * {@inheritdoc} + */ + public function escape($value) + { + return $this->_getObject()->escape($value); + } + + /** + * {@inheritdoc} + */ + public function getDirectUrl($url, $params = array()) + { + return $this->_getObject()->getDirectUrl($url, $params); + } + + /** + * {@inheritdoc} + */ + public function sessionUrlVar($html) + { + return $this->_getObject()->sessionUrlVar($html); + } + + /** + * {@inheritdoc} + */ + public function useSessionIdForUrl($secure = false) + { + return $this->_getObject()->useSessionIdForUrl($secure); + } + + /** + * {@inheritdoc} + */ + public function sessionVarCallback($match) + { + return $this->_getObject()->sessionVarCallback($match); + } + + /** + * {@inheritdoc} + */ + public function isOwnOriginUrl() + { + return $this->_getObject()->isOwnOriginUrl(); + } + + /** + * {@inheritdoc} + */ + public function getRedirectUrl($url) + { + return $this->_getObject()->getRedirectUrl($url); + } + + /** + * {@inheritdoc} + */ + public function isDeleted($isDeleted = null) + { + return $this->_getObject()->isDeleted($isDeleted); + } + + /** + * {@inheritdoc} + */ + public function hasDataChanges() + { + return $this->_getObject()->hasDataChanges(); + } + + /** + * {@inheritdoc} + */ + public function setIdFieldName($name) + { + return $this->_getObject()->setIdFieldName($name); + } + + /** + * {@inheritdoc} + */ + public function getIdFieldName() + { + return $this->_getObject()->getIdFieldName(); + } + + /** + * {@inheritdoc} + */ + public function getId() + { + return $this->_getObject()->getId(); + } + + /** + * {@inheritdoc} + */ + public function setId($value) + { + return $this->_getObject()->setId($value); + } + + /** + * {@inheritdoc} + */ + public function addData(array $arr) + { + return $this->_getObject()->addData($arr); + } + + /** + * {@inheritdoc} + */ + public function setData($key, $value = null) + { + return $this->_getObject()->setData($key, $value); + } + + /** + * {@inheritdoc} + */ + public function unsetData($key = null) + { + return $this->_getObject()->unsetData($key); + } + + /** + * {@inheritdoc} + */ + public function getData($key = '', $index = null) + { + return $this->_getObject()->getData($key, $index); + } + + /** + * {@inheritdoc} + */ + public function getDataByPath($path) + { + return $this->_getObject()->getDataByPath($path); + } + + /** + * {@inheritdoc} + */ + public function getDataByKey($key) + { + return $this->_getObject()->getDataByKey($key); + } + + /** + * {@inheritdoc} + */ + public function setDataUsingMethod($key, $args = array()) + { + return $this->_getObject()->setDataUsingMethod($key, $args); + } + + /** + * {@inheritdoc} + */ + public function getDataUsingMethod($key, $args = null) + { + return $this->_getObject()->getDataUsingMethod($key, $args); + } + + /** + * {@inheritdoc} + */ + public function getDataSetDefault($key, $default) + { + return $this->_getObject()->getDataSetDefault($key, $default); + } + + /** + * {@inheritdoc} + */ + public function hasData($key = '') + { + return $this->_getObject()->hasData($key); + } + + /** + * {@inheritdoc} + */ + public function toArray(array $keys = array()) + { + return $this->_getObject()->toArray($keys); + } + + /** + * {@inheritdoc} + */ + public function __toArray(array $keys = array()) + { + return $this->_getObject()->__toArray($keys); + } + + /** + * {@inheritdoc} + */ + public function toXml(array $keys = array(), $rootName = 'item', $addOpenTag = false, $addCdata = true) + { + return $this->_getObject()->toXml($keys, $rootName, $addOpenTag, $addCdata); + } + + /** + * {@inheritdoc} + */ + public function __toXml(array $arrAttributes = array(), $rootName = 'item', $addOpenTag = false, $addCdata = true) + { + return $this->_getObject()->__toXml($arrAttributes, $rootName, $addOpenTag, $addCdata); + } + + /** + * {@inheritdoc} + */ + public function toJson(array $keys = array()) + { + return $this->_getObject()->toJson($keys); + } + + /** + * {@inheritdoc} + */ + public function __toJson(array $keys = array()) + { + return $this->_getObject()->__toJson($keys); + } + + /** + * {@inheritdoc} + */ + public function toString($format = '') + { + return $this->_getObject()->toString($format); + } + + /** + * {@inheritdoc} + */ + public function __call($method, $args) + { + return $this->_getObject()->__call($method, $args); + } + + /** + * {@inheritdoc} + */ + public function isEmpty() + { + return $this->_getObject()->isEmpty(); + } + + /** + * {@inheritdoc} + */ + public function serialize($keys = array(), $valueSeparator = '=', $fieldSeparator = ' ', $quote = '"') + { + return $this->_getObject()->serialize($keys, $valueSeparator, $fieldSeparator, $quote); + } + + /** + * {@inheritdoc} + */ + public function setOrigData($key = null, $data = null) + { + return $this->_getObject()->setOrigData($key, $data); + } + + /** + * {@inheritdoc} + */ + public function getOrigData($key = null) + { + return $this->_getObject()->getOrigData($key); + } + + /** + * {@inheritdoc} + */ + public function dataHasChangedFor($field) + { + return $this->_getObject()->dataHasChangedFor($field); + } + + /** + * {@inheritdoc} + */ + public function setDataChanges($value) + { + return $this->_getObject()->setDataChanges($value); + } + + /** + * {@inheritdoc} + */ + public function debug($data = null, &$objects = array()) + { + return $this->_getObject()->debug($data, $objects); + } + + /** + * {@inheritdoc} + */ + public function offsetSet($offset, $value) + { + $this->_getObject()->offsetSet($offset, $value); + } + + /** + * {@inheritdoc} + */ + public function offsetExists($offset) + { + return $this->_getObject()->offsetExists($offset); + } + + /** + * {@inheritdoc} + */ + public function offsetUnset($offset) + { + $this->_getObject()->offsetUnset($offset); + } + + /** + * {@inheritdoc} + */ + public function offsetGet($offset) + { + return $this->_getObject()->offsetGet($offset); + } +} diff --git a/app/code/core/Mage/Backend/Model/Widget/Grid/Parser.php b/app/code/Mage/Backend/Model/Widget/Grid/Parser.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Widget/Grid/Parser.php rename to app/code/Mage/Backend/Model/Widget/Grid/Parser.php diff --git a/app/code/core/Mage/Backend/Model/Widget/Grid/Row/UrlGenerator.php b/app/code/Mage/Backend/Model/Widget/Grid/Row/UrlGenerator.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Widget/Grid/Row/UrlGenerator.php rename to app/code/Mage/Backend/Model/Widget/Grid/Row/UrlGenerator.php diff --git a/app/code/core/Mage/Backend/Model/Widget/Grid/Row/UrlGeneratorFactory.php b/app/code/Mage/Backend/Model/Widget/Grid/Row/UrlGeneratorFactory.php similarity index 98% rename from app/code/core/Mage/Backend/Model/Widget/Grid/Row/UrlGeneratorFactory.php rename to app/code/Mage/Backend/Model/Widget/Grid/Row/UrlGeneratorFactory.php index 4ecb38da2e667..1c053af372747 100644 --- a/app/code/core/Mage/Backend/Model/Widget/Grid/Row/UrlGeneratorFactory.php +++ b/app/code/Mage/Backend/Model/Widget/Grid/Row/UrlGeneratorFactory.php @@ -57,7 +57,7 @@ public function __construct(Magento_ObjectManager $objectManager) */ public function createUrlGenerator($generatorClassName, array $arguments = array()) { - $rowUrlGenerator = $this->_objectManager->create($generatorClassName, $arguments, false); + $rowUrlGenerator = $this->_objectManager->create($generatorClassName, $arguments); if (false === ($rowUrlGenerator instanceof Mage_Backend_Model_Widget_Grid_Row_UrlGenerator)) { throw new InvalidArgumentException('Passed wrong parameters'); } diff --git a/app/code/core/Mage/Backend/Model/Widget/Grid/SubTotals.php b/app/code/Mage/Backend/Model/Widget/Grid/SubTotals.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Widget/Grid/SubTotals.php rename to app/code/Mage/Backend/Model/Widget/Grid/SubTotals.php diff --git a/app/code/core/Mage/Backend/Model/Widget/Grid/Totals.php b/app/code/Mage/Backend/Model/Widget/Grid/Totals.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Widget/Grid/Totals.php rename to app/code/Mage/Backend/Model/Widget/Grid/Totals.php diff --git a/app/code/core/Mage/Backend/Model/Widget/Grid/TotalsAbstract.php b/app/code/Mage/Backend/Model/Widget/Grid/TotalsAbstract.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Widget/Grid/TotalsAbstract.php rename to app/code/Mage/Backend/Model/Widget/Grid/TotalsAbstract.php diff --git a/app/code/core/Mage/Backend/Model/Widget/Grid/TotalsInterface.php b/app/code/Mage/Backend/Model/Widget/Grid/TotalsInterface.php similarity index 100% rename from app/code/core/Mage/Backend/Model/Widget/Grid/TotalsInterface.php rename to app/code/Mage/Backend/Model/Widget/Grid/TotalsInterface.php diff --git a/app/code/core/Mage/Backend/controllers/Adminhtml/AuthController.php b/app/code/Mage/Backend/controllers/Adminhtml/AuthController.php similarity index 100% rename from app/code/core/Mage/Backend/controllers/Adminhtml/AuthController.php rename to app/code/Mage/Backend/controllers/Adminhtml/AuthController.php diff --git a/app/code/core/Mage/Backend/controllers/Adminhtml/IndexController.php b/app/code/Mage/Backend/controllers/Adminhtml/IndexController.php similarity index 100% rename from app/code/core/Mage/Backend/controllers/Adminhtml/IndexController.php rename to app/code/Mage/Backend/controllers/Adminhtml/IndexController.php diff --git a/app/code/core/Mage/Backend/controllers/Adminhtml/System/Config/SaveController.php b/app/code/Mage/Backend/controllers/Adminhtml/System/Config/SaveController.php similarity index 100% rename from app/code/core/Mage/Backend/controllers/Adminhtml/System/Config/SaveController.php rename to app/code/Mage/Backend/controllers/Adminhtml/System/Config/SaveController.php diff --git a/app/code/core/Mage/Backend/controllers/Adminhtml/System/ConfigController.php b/app/code/Mage/Backend/controllers/Adminhtml/System/ConfigController.php similarity index 100% rename from app/code/core/Mage/Backend/controllers/Adminhtml/System/ConfigController.php rename to app/code/Mage/Backend/controllers/Adminhtml/System/ConfigController.php diff --git a/app/code/core/Mage/Backend/controllers/Adminhtml/SystemController.php b/app/code/Mage/Backend/controllers/Adminhtml/SystemController.php similarity index 100% rename from app/code/core/Mage/Backend/controllers/Adminhtml/SystemController.php rename to app/code/Mage/Backend/controllers/Adminhtml/SystemController.php diff --git a/app/code/Mage/Backend/etc/adminhtml/system.xml b/app/code/Mage/Backend/etc/adminhtml/system.xml new file mode 100644 index 0000000000000..bf938018d3ef5 --- /dev/null +++ b/app/code/Mage/Backend/etc/adminhtml/system.xml @@ -0,0 +1,649 @@ + + + + + + + + + + + + + +
      + + advanced + Mage_Adminhtml::advanced + + + Mage_Backend_Block_System_Config_Form_Fieldset_Modules_DisableOutput + +
      +
      + separator-top + + general + Mage_Adminhtml::trans_email + + + + + validate-email + Mage_Backend_Model_Config_Backend_Email_Address + + + + Mage_Backend_Model_Config_Backend_Email_Sender + validate-emailSender + + + + + + + validate-email + Mage_Backend_Model_Config_Backend_Email_Address + + + + Mage_Backend_Model_Config_Backend_Email_Sender + validate-emailSender + + + + + + + validate-email + Mage_Backend_Model_Config_Backend_Email_Address + + + + Mage_Backend_Model_Config_Backend_Email_Sender + validate-emailSender + + + + + + + validate-email + Mage_Backend_Model_Config_Backend_Email_Address + + + + Mage_Backend_Model_Config_Backend_Email_Sender + validate-emailSender + + + + + + + validate-email + Mage_Backend_Model_Config_Backend_Email_Address + + + + Mage_Backend_Model_Config_Backend_Email_Sender + validate-emailSender + + +
      +
      + + general + Mage_Adminhtml::config_design + + + + + Mage_Core_Model_Theme::getLabelsCollectionForSystemConfiguration + Mage_Core_Model_Design_Backend_Theme + + + + + Mage_Backend_Block_System_Config_Form_Field_Regexceptions + Mage_Core_Model_Design_Backend_Exceptions + + Firefox
      /^mozilla/i
      ]]> +
      + Find a string in client user-agent header and switch to specific design theme for that browser. +
      +
      + + + + + How many links to display at once. + + + + If the current frame position does not cover utmost pages, will render link to current position plus/minus this value. + + + + Alternative text for previous link in pagination menu. If empty, default arrow image will used. + + + + Alternative text for next link in pagination menu. If empty, default arrow image will used. + + + + + + + + + +
      +
      + + advanced + Mage_Adminhtml::dev + + + + + Leave empty for access from any location. + + + + + + + Mage_Backend_Model_Config_Source_Yesno + + + + Mage_Backend_Model_Config_Source_Yesno + + + + + + + Mage_Backend_Model_Config_Source_Yesno + Warning! Enabling this feature is not recommended on production environments because it represents a potential security risk. + + + + + + + Mage_Backend_Model_Config_Source_Yesno + Mage_Backend_Model_Config_Backend_Translate + + + + Mage_Backend_Model_Config_Source_Yesno + Mage_Backend_Model_Config_Backend_Translate + Translate, blocks and other output caches should be disabled for both frontend and admin inline translations. + + + + + + + Mage_Backend_Model_Config_Source_Yesno + + + + Mage_Backend_Model_Config_Backend_Filename + Logging from Mage::log(). File is located in {{base_dir}}/var/log + + + + Mage_Backend_Model_Config_Backend_Filename + Logging from Mage::logException(). File is located in {{base_dir}}/var/log + + + + + + + Mage_Backend_Model_Config_Source_Yesno + + + + + + + Mage_Backend_Model_Config_Source_Yesno + + + + + + + Mage_Backend_Model_Config_Source_Image_Adapter + Mage_Backend_Model_Config_Backend_Image_Adapter + When the adapter was changed, please, flush Catalog Images Cache. + + + + + + + Mage_Backend_Model_Config_Source_Yesno + + +
      +
      + + general + Mage_Adminhtml::config_general + + + + + Mage_Directory_Model_Config_Source_Country + 1 + + + + Mage_Directory_Model_Config_Source_Country + + + + Mage_Directory_Model_Config_Source_Country + + + + + + + Mage_Backend_Model_Config_Source_Locale_Timezone + Mage_Backend_Model_Config_Backend_Locale_Timezone + + + + Mage_Backend_Model_Config_Source_Locale + + + + Mage_Backend_Model_Config_Source_Locale_Weekdays + + + + Mage_Backend_Model_Config_Source_Locale_Weekdays + 1 + + + + + + + + + + + + + Mage_Directory_Model_Config_Source_Country + countries + 1 + + + + + + + + + + + + + + + + + + + 1 + + + + + + + Mage_Backend_Model_Config_Source_Yesno + This setting will not be taken into account if system has more than one store view. + + +
      +
      + separator-top + + advanced + Mage_Adminhtml::config_system + + + + + Mage_Backend_Model_Config_Source_Yesno + + + + For Windows server only. + + + + For Windows server only. + + + + Mage_Backend_Model_Config_Source_Yesnocustom + + + + validate-email + Mage_Backend_Model_Config_Backend_Email_Address + + 2 + + + + + + + + Mage_Backend_Model_Config_Source_Storage_Media_Storage + + + + Mage_Backend_Model_Config_Source_Storage_Media_Database + Mage_Backend_Model_Config_Backend_Storage_Media_Database + + 1 + + + + Mage_Backend_Block_System_Config_System_Storage_Media_Synchronize + After selecting a new media storage location, press the Synchronize button to transfer all media to that location. Media will not be available in the new location until the synchronization process is complete. + + + + + +
      +
      + + advanced + Mage_Adminhtml::config_admin + + + + + Mage_Backend_Model_Config_Source_Email_Template + + + + Mage_Backend_Model_Config_Source_Email_Identity + + + + Please enter a number 1 or greater in this field. + required-entry validate-digits validate-digits-range digits-range-1- + Mage_Backend_Model_Config_Backend_Admin_Password_Link_Expirationperiod + + + + + + + Mage_Backend_Model_Config_Source_Admin_Page + + + + + + + Mage_Backend_Model_Config_Source_Yesno + Mage_Backend_Model_Config_Backend_Admin_Usecustom + + + + Mage_Backend_Model_Config_Backend_Admin_Custom + + 1 + + Make sure that base URL ends with '/' (slash), e.g. http://yourdomain/magento/ + + + + Mage_Backend_Model_Config_Source_Yesno + Mage_Backend_Model_Config_Backend_Admin_Usecustompath + + + + required-entry validate-alphanum + Mage_Backend_Model_Config_Backend_Admin_Custompath + + 1 + + You will have to log in after you save your custom admin path. + + + + + + + Mage_Backend_Model_Config_Source_Yesno + Mage_Backend_Model_Config_Backend_Admin_Usesecretkey + + + + Mage_Backend_Model_Config_Source_Yesno + + + + Values less than 60 are ignored. + validate-digits + + + + + + + Mage_Backend_Model_Config_Source_Yesno + + +
      +
      + + general + Mage_Adminhtml::web + + + + + Mage_Backend_Model_Config_Source_Yesno + Mage_Backend_Model_Config_Backend_Store + + Warning! When using Store Code in URLs, in some cases system may not work properly if URLs without Store Codes are specified in the third party services (e.g. PayPal etc.).]]> + + + + + + + + + + + I.e. redirect from http://example.com/store/ to http://www.example.com/store/ + + + + + + + Mage_Backend_Model_Config_Source_Yesno + + + + + Any of the fields allow fully qualified URLs that end with '/' (slash) e.g. http://example.com/magento/ + + + Mage_Backend_Model_Config_Backend_Baseurl + Specify URL or {{base_url}} placeholder. + + + + Mage_Backend_Model_Config_Backend_Baseurl + May start with {{unsecure_base_url}} placeholder. + + + + Mage_Backend_Model_Config_Backend_Baseurl + May be empty or start with {{unsecure_base_url}} placeholder. + + + + Mage_Backend_Model_Config_Backend_Baseurl + May be empty or start with {{unsecure_base_url}} placeholder. <br/> <strong style="color:red">Warning!</strong> When using CDN, in some cases JavaScript may not run properly if CDN is not in your subdomain + + + + Mage_Backend_Model_Config_Backend_Baseurl + May be empty or start with {{unsecure_base_url}} placeholder. + + + + + Any of the fields allow fully qualified URLs that end with '/' (slash) e.g. http://example.com/magento/ + + + Mage_Backend_Model_Config_Backend_Baseurl + Specify URL or {{base_url}}, or {{unsecure_base_url}} placeholder. + + + + Mage_Backend_Model_Config_Backend_Baseurl + May start with {{secure_base_url}} or {{unsecure_base_url}} placeholder. + + + + Mage_Backend_Model_Config_Backend_Baseurl + May be empty or start with {{secure_base_url}}, or {{unsecure_base_url}} placeholder. + + + + Mage_Backend_Model_Config_Backend_Baseurl + May be empty or start with {{secure_base_url}}, or {{unsecure_base_url}} placeholder. + + + + Mage_Backend_Model_Config_Backend_Baseurl + May be empty or start with {{secure_base_url}}, or {{unsecure_base_url}} placeholder. + + + + Mage_Backend_Model_Config_Source_Yesno + Mage_Backend_Model_Config_Backend_Secure + + + + Mage_Backend_Model_Config_Source_Yesno + Mage_Backend_Model_Config_Backend_Secure + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Mage_Backend_Model_Config_Source_Yesno + + + + Mage_Backend_Model_Config_Source_Yesno + Mage_Backend_Model_Config_Backend_Cookie + + + + + + + Mage_Backend_Model_Config_Source_Yesno + + + + Mage_Backend_Model_Config_Source_Yesno + + + + Mage_Backend_Model_Config_Source_Yesno + + + + Mage_Backend_Model_Config_Source_Yesno + + + + Allows customers to stay logged in when switching between different stores. + Mage_Backend_Model_Config_Source_Yesno + + +
      +
      +
      diff --git a/app/code/Mage/Backend/etc/config.xml b/app/code/Mage/Backend/etc/config.xml new file mode 100644 index 0000000000000..297718b689bf2 --- /dev/null +++ b/app/code/Mage/Backend/etc/config.xml @@ -0,0 +1,144 @@ + + + + + + 2.0.0.0 + true + + + + + + + + + Mage_Backend_Controller_ActionAbstract + + + Mage_Backend_Controller_Router_Default + + + backend + + + Mage_Backend_Model_Acl_Loader_Resource + Mage_Backend_Model_Authorization_RoleLocator + Magento_Authorization_Policy_Acl + + + + + + + System(config.xml, local.xml) and modules configuration files(config.xml, menu.xml). + + + + + + Mage_Core_Model_Config_Storage_Writer_Db + + + + + + + admin + + Mage_Backend + admin + + + + + + + + + layout.xml + + + + + + Mage_Backend_Model_Url + Mage_Backend_Model_Auth_Session + Mage_Backend_Model_Config_Structure + Mage_Backend_Model_Config_Backend_File_RequestData + + + + adminhtml + + + + 0 + + + 0 + + + 0 + + + + Mage_Backend_Model_Config_Structure_Element_Group_Proxy + + 0 + + + + Mage_Backend_Model_Config_Structure_Search_Proxy + + 0 + + + + Mage_Backend_Model_Config_Structure_Element_Iterator_Section + + 0 + + + + Mage_Backend_Model_Config_Structure_Element_Iterator_Group + + 0 + + + + Mage_Backend_Model_Config_Structure_Element_Iterator_Field + + 0 + + + 0 + + + + diff --git a/app/code/core/Mage/Backend/etc/menu.xsd b/app/code/Mage/Backend/etc/menu.xsd similarity index 100% rename from app/code/core/Mage/Backend/etc/menu.xsd rename to app/code/Mage/Backend/etc/menu.xsd diff --git a/app/code/core/Mage/Backend/etc/system.xsd b/app/code/Mage/Backend/etc/system.xsd similarity index 92% rename from app/code/core/Mage/Backend/etc/system.xsd rename to app/code/Mage/Backend/etc/system.xsd index cd794a2851aa3..b37789c3e8851 100644 --- a/app/code/core/Mage/Backend/etc/system.xsd +++ b/app/code/Mage/Backend/etc/system.xsd @@ -201,6 +201,7 @@ + @@ -221,6 +222,39 @@ + + + + Options of a field + + + + + + + + + + Option of a field + + + + + + + + + + + + + + + + + + + diff --git a/app/code/core/Mage/Backend/etc/system_file.xsd b/app/code/Mage/Backend/etc/system_file.xsd similarity index 92% rename from app/code/core/Mage/Backend/etc/system_file.xsd rename to app/code/Mage/Backend/etc/system_file.xsd index 84111c1b7200f..76bca828a56c6 100644 --- a/app/code/core/Mage/Backend/etc/system_file.xsd +++ b/app/code/Mage/Backend/etc/system_file.xsd @@ -202,6 +202,7 @@ + @@ -223,6 +224,39 @@ + + + + Options of a field + + + + + + + + + + Option of a field + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Mage/Backend/view/adminhtml/admin/login.phtml b/app/code/Mage/Backend/view/adminhtml/admin/login.phtml new file mode 100644 index 0000000000000..8db5858dfcb6a --- /dev/null +++ b/app/code/Mage/Backend/view/adminhtml/admin/login.phtml @@ -0,0 +1,100 @@ + + + + + + + <?php echo Mage::helper('Mage_Backend_Helper_Data')->__('Log into Magento Admin Page') ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      +
      + +
      + +
      + +
      +
      diff --git a/app/code/core/Mage/Backend/view/adminhtml/admin/login_buttons.phtml b/app/code/Mage/Backend/view/adminhtml/admin/login_buttons.phtml similarity index 100% rename from app/code/core/Mage/Backend/view/adminhtml/admin/login_buttons.phtml rename to app/code/Mage/Backend/view/adminhtml/admin/login_buttons.phtml diff --git a/app/design/adminhtml/default/backend/Mage_Backend/images/draggable-handle-bg.gif b/app/code/Mage/Backend/view/adminhtml/images/draggable-handle-bg.gif similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/images/draggable-handle-bg.gif rename to app/code/Mage/Backend/view/adminhtml/images/draggable-handle-bg.gif diff --git a/app/code/Mage/Backend/view/adminhtml/images/gallery-image-base-label.png b/app/code/Mage/Backend/view/adminhtml/images/gallery-image-base-label.png new file mode 100644 index 0000000000000..49f86d4c08400 Binary files /dev/null and b/app/code/Mage/Backend/view/adminhtml/images/gallery-image-base-label.png differ diff --git a/app/code/Mage/Backend/view/adminhtml/images/gallery-image-panel-corner.png b/app/code/Mage/Backend/view/adminhtml/images/gallery-image-panel-corner.png new file mode 100644 index 0000000000000..d2122cc1133fe Binary files /dev/null and b/app/code/Mage/Backend/view/adminhtml/images/gallery-image-panel-corner.png differ diff --git a/app/code/Mage/Backend/view/adminhtml/layout.xml b/app/code/Mage/Backend/view/adminhtml/layout.xml new file mode 100644 index 0000000000000..ff3ade65932d3 --- /dev/null +++ b/app/code/Mage/Backend/view/adminhtml/layout.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + jquery/jquery.ba-hashchange.min.js + + + + + + + + + + + + + + + diff --git a/app/code/core/Mage/Backend/view/adminhtml/menu.phtml b/app/code/Mage/Backend/view/adminhtml/menu.phtml similarity index 100% rename from app/code/core/Mage/Backend/view/adminhtml/menu.phtml rename to app/code/Mage/Backend/view/adminhtml/menu.phtml diff --git a/app/code/Mage/Backend/view/adminhtml/store/switcher.phtml b/app/code/Mage/Backend/view/adminhtml/store/switcher.phtml new file mode 100644 index 0000000000000..7706e9657692b --- /dev/null +++ b/app/code/Mage/Backend/view/adminhtml/store/switcher.phtml @@ -0,0 +1,77 @@ + + +getWebsites()): ?> +
      + + + getHintHtml() ?> +
      + + diff --git a/app/code/core/Mage/Backend/view/adminhtml/store/switcher/form/renderer/fieldset.phtml b/app/code/Mage/Backend/view/adminhtml/store/switcher/form/renderer/fieldset.phtml similarity index 100% rename from app/code/core/Mage/Backend/view/adminhtml/store/switcher/form/renderer/fieldset.phtml rename to app/code/Mage/Backend/view/adminhtml/store/switcher/form/renderer/fieldset.phtml diff --git a/app/code/core/Mage/Backend/view/adminhtml/store/switcher/form/renderer/fieldset/element.phtml b/app/code/Mage/Backend/view/adminhtml/store/switcher/form/renderer/fieldset/element.phtml similarity index 100% rename from app/code/core/Mage/Backend/view/adminhtml/store/switcher/form/renderer/fieldset/element.phtml rename to app/code/Mage/Backend/view/adminhtml/store/switcher/form/renderer/fieldset/element.phtml diff --git a/app/code/Mage/Backend/view/adminhtml/system/config/edit.phtml b/app/code/Mage/Backend/view/adminhtml/system/config/edit.phtml new file mode 100644 index 0000000000000..54c3dafa62f7b --- /dev/null +++ b/app/code/Mage/Backend/view/adminhtml/system/config/edit.phtml @@ -0,0 +1,73 @@ + + +
      getSaveButtonHtml() ?>
      +
      + getBlockHtml('formkey')?> +
      + getChildHtml('form') ?> +
      +
      + diff --git a/app/code/core/Mage/Backend/view/adminhtml/system/config/form/field/array.phtml b/app/code/Mage/Backend/view/adminhtml/system/config/form/field/array.phtml similarity index 89% rename from app/code/core/Mage/Backend/view/adminhtml/system/config/form/field/array.phtml rename to app/code/Mage/Backend/view/adminhtml/system/config/form/field/array.phtml index 6659b0ef1a615..30e1ac28b8ca6 100644 --- a/app/code/core/Mage/Backend/view/adminhtml/system/config/form/field/array.phtml +++ b/app/code/Mage/Backend/view/adminhtml/system/config/form/field/array.phtml @@ -29,7 +29,7 @@ $_htmlId = $this->getHtmlId() ? $this->getHtmlId() : '_' . uniqid(); $_colspan = 2; -if (!$this->_addAfter) { +if (!$this->isAddAfter()) { $_colspan -= 1; } $_colspan = $_colspan > 1 ? 'colspan="' . $_colspan . '"' : ''; @@ -40,17 +40,17 @@ $_colspan = $_colspan > 1 ? 'colspan="' . $_colspan . '"' : ''; -_columns as $columnName => $column):?> +getColumns() as $columnName => $column):?> > - + > @@ -61,7 +61,7 @@ $_colspan = $_colspan > 1 ? 'colspan="' . $_colspan . '"' : '';
      @@ -72,12 +72,12 @@ var arrayRow = { // define row prototypeJS template template : new Template( '' -_columns as $columnName => $column):?> +getColumns() as $columnName => $column):?> +'' - +'_renderCellTemplate($columnName)?>' + +'renderCellTemplate($columnName)?>' +'<\/td>' -_addAfter):?> +isAddAfter()):?> +'
+ getHideFormElement() !== true):?> + + +
+ getItems() as $_item): ?> +
+ getAdditionalActionBlockHtml() ?> +
+ +
+
+ +
+getParentBlock()->canDisplayContainer()): ?> + + +
diff --git a/app/code/Mage/Catalog/view/adminhtml/product/grouped/container.phtml b/app/code/Mage/Catalog/view/adminhtml/product/grouped/container.phtml new file mode 100644 index 0000000000000..d4917cd69d204 --- /dev/null +++ b/app/code/Mage/Catalog/view/adminhtml/product/grouped/container.phtml @@ -0,0 +1,42 @@ + + + +
+
+
+ + getTabLabel() ?> + +
+
+
+ getChildHtml()?> +
+
+
+
diff --git a/app/code/core/Mage/Catalog/view/adminhtml/product/grouped/grouped.phtml b/app/code/Mage/Catalog/view/adminhtml/product/grouped/grouped.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/adminhtml/product/grouped/grouped.phtml rename to app/code/Mage/Catalog/view/adminhtml/product/grouped/grouped.phtml diff --git a/app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-bg_diagonals-thick_18_b81900_40x40.png b/app/code/Mage/Catalog/view/adminhtml/product/images/ui-bg_diagonals-thick_18_b81900_40x40.png similarity index 100% rename from app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-bg_diagonals-thick_18_b81900_40x40.png rename to app/code/Mage/Catalog/view/adminhtml/product/images/ui-bg_diagonals-thick_18_b81900_40x40.png diff --git a/app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-bg_diagonals-thick_20_666666_40x40.png b/app/code/Mage/Catalog/view/adminhtml/product/images/ui-bg_diagonals-thick_20_666666_40x40.png similarity index 100% rename from app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-bg_diagonals-thick_20_666666_40x40.png rename to app/code/Mage/Catalog/view/adminhtml/product/images/ui-bg_diagonals-thick_20_666666_40x40.png diff --git a/app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-bg_flat_10_000000_40x100.png b/app/code/Mage/Catalog/view/adminhtml/product/images/ui-bg_flat_10_000000_40x100.png similarity index 100% rename from app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-bg_flat_10_000000_40x100.png rename to app/code/Mage/Catalog/view/adminhtml/product/images/ui-bg_flat_10_000000_40x100.png diff --git a/app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-bg_glass_100_f6f6f6_1x400.png b/app/code/Mage/Catalog/view/adminhtml/product/images/ui-bg_glass_100_f6f6f6_1x400.png similarity index 100% rename from app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-bg_glass_100_f6f6f6_1x400.png rename to app/code/Mage/Catalog/view/adminhtml/product/images/ui-bg_glass_100_f6f6f6_1x400.png diff --git a/app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-bg_glass_100_fdf5ce_1x400.png b/app/code/Mage/Catalog/view/adminhtml/product/images/ui-bg_glass_100_fdf5ce_1x400.png similarity index 100% rename from app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-bg_glass_100_fdf5ce_1x400.png rename to app/code/Mage/Catalog/view/adminhtml/product/images/ui-bg_glass_100_fdf5ce_1x400.png diff --git a/app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-bg_glass_65_ffffff_1x400.png b/app/code/Mage/Catalog/view/adminhtml/product/images/ui-bg_glass_65_ffffff_1x400.png similarity index 100% rename from app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-bg_glass_65_ffffff_1x400.png rename to app/code/Mage/Catalog/view/adminhtml/product/images/ui-bg_glass_65_ffffff_1x400.png diff --git a/app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-bg_gloss-wave_35_f67028_500x100.png b/app/code/Mage/Catalog/view/adminhtml/product/images/ui-bg_gloss-wave_35_f67028_500x100.png similarity index 100% rename from app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-bg_gloss-wave_35_f67028_500x100.png rename to app/code/Mage/Catalog/view/adminhtml/product/images/ui-bg_gloss-wave_35_f67028_500x100.png diff --git a/app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-bg_highlight-soft_100_eeeeee_1x100.png b/app/code/Mage/Catalog/view/adminhtml/product/images/ui-bg_highlight-soft_100_eeeeee_1x100.png similarity index 100% rename from app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-bg_highlight-soft_100_eeeeee_1x100.png rename to app/code/Mage/Catalog/view/adminhtml/product/images/ui-bg_highlight-soft_100_eeeeee_1x100.png diff --git a/app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-bg_highlight-soft_75_ffe45c_1x100.png b/app/code/Mage/Catalog/view/adminhtml/product/images/ui-bg_highlight-soft_75_ffe45c_1x100.png similarity index 100% rename from app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-bg_highlight-soft_75_ffe45c_1x100.png rename to app/code/Mage/Catalog/view/adminhtml/product/images/ui-bg_highlight-soft_75_ffe45c_1x100.png diff --git a/app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-icons_222222_256x240.png b/app/code/Mage/Catalog/view/adminhtml/product/images/ui-icons_222222_256x240.png similarity index 100% rename from app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-icons_222222_256x240.png rename to app/code/Mage/Catalog/view/adminhtml/product/images/ui-icons_222222_256x240.png diff --git a/app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-icons_228ef1_256x240.png b/app/code/Mage/Catalog/view/adminhtml/product/images/ui-icons_228ef1_256x240.png similarity index 100% rename from app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-icons_228ef1_256x240.png rename to app/code/Mage/Catalog/view/adminhtml/product/images/ui-icons_228ef1_256x240.png diff --git a/app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-icons_ef8c08_256x240.png b/app/code/Mage/Catalog/view/adminhtml/product/images/ui-icons_ef8c08_256x240.png similarity index 100% rename from app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-icons_ef8c08_256x240.png rename to app/code/Mage/Catalog/view/adminhtml/product/images/ui-icons_ef8c08_256x240.png diff --git a/app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-icons_ffd27a_256x240.png b/app/code/Mage/Catalog/view/adminhtml/product/images/ui-icons_ffd27a_256x240.png similarity index 100% rename from app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-icons_ffd27a_256x240.png rename to app/code/Mage/Catalog/view/adminhtml/product/images/ui-icons_ffd27a_256x240.png diff --git a/app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-icons_ffffff_256x240.png b/app/code/Mage/Catalog/view/adminhtml/product/images/ui-icons_ffffff_256x240.png similarity index 100% rename from app/code/core/Mage/Catalog/view/adminhtml/product/images/ui-icons_ffffff_256x240.png rename to app/code/Mage/Catalog/view/adminhtml/product/images/ui-icons_ffffff_256x240.png diff --git a/app/code/Mage/Catalog/view/adminhtml/product/product.css b/app/code/Mage/Catalog/view/adminhtml/product/product.css new file mode 100644 index 0000000000000..7901fb52fda87 --- /dev/null +++ b/app/code/Mage/Catalog/view/adminhtml/product/product.css @@ -0,0 +1,762 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Catalog + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +/* Action "Back" as cross */ +[class^=" adminhtml-catalog-product-"] .page-actions .action-back, +[class^=" adminhtml-catalog-product-"] .page-actions .action-back:hover, +[class^=" adminhtml-catalog-product-"] .page-actions .action-back:active, +[class^=" adminhtml-newsletter-"] .page-actions .action-back, +[class^=" adminhtml-newsletter-"] .page-actions .action-back:hover, +[class^=" adminhtml-newsletter-"] .page-actions .action-back:active { + overflow: hidden; + padding: 5px 6px 3px; + margin-left: 12px; + color: #7a7976;; +} + +[class^=" adminhtml-catalog-product-"] .page-actions .action-back:hover, +[class^=" adminhtml-newsletter-"] .page-actions .action-back:hover { + color: #000; +} + +[class^=" adminhtml-catalog-product-"] .page-actions .action-back.mage-error, +[class^=" adminhtml-newsletter-"] .page-actions .action-back.mage-error { + color: #b57c72; +} + +[class^=" adminhtml-catalog-product-"] .page-actions .action-back:before, +[class^=" adminhtml-newsletter-"] .page-actions .action-back:before { + display: inline-block; + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: '\e07d'; /* close icon */ + font-size: 16px; +} + +[class^=" adminhtml-catalog-product-"] .page-actions .action-back span, +[class^=" adminhtml-newsletter-"] .page-actions .action-back span { + display: inline-block; + overflow: hidden; + text-indent: -999em; +} + +.page-actions .switcher { + display: inline-block; + vertical-align: top; + margin: 6px 17px 6px 6px; +} + +/* Image Management */ +.images { + position: relative; + border: 2px dotted #ccc; + border-radius: 5px; + margin-bottom: 2px; + padding: 5px; +} + +.image, +.gallery .ui-state-highlight { + position: relative; + width: 17.874%; + border: 1px solid #ccc; + border-radius: 4px; + float: left; + margin: 5px 1%; + overflow: hidden; + background: #fff; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + -ms-box-sizing: border-box; + box-sizing: border-box; +} + +.image .spacer { + width: 100%; +} + +.image .product-image { + position: absolute; + left: 0; + top: 0; + right: 0; + bottom: 0; + margin: auto; + width: 100%; +} + +.image.base-image:before { + position: absolute; + top: 0; + left: 0; + width: 33px; + height: 33px; + background: url(Mage_Backend::images/gallery-image-base-label.png) no-repeat; + content: ''; + z-index: 1; +} + +.image.hidden-for-front:after { + position: absolute; + left: 0; + right: 0; + top: 0; + bottom: 0; + background: rgba(247, 242, 236, .8); + content: attr(data-image-hidden-label); + text-align: center; + text-transform: uppercase; + color: #a69a8f; + font: 18px/110px 'CallunaSans', Arial, sans-serif; + font-weight: 500; + z-index: 1; +} + +.gallery .image.hidden-for-front:after { + line-height: 160px; +} + +.image.active { + box-shadow: 0 0 10px #2ea9ec; +} + +.image .actions { + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + text-align: center; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.image .actions [class^="action-"], +.image[data-image-hidden]:hover .actions [class^="action-"], +.image.hidden-for-front:hover .actions [class^="action-"] { + visibility: hidden; +} + +.image:hover .actions [class^="action-"], +.image[data-image-hidden]:hover .actions .action-delete, +.hidden-for-front:hover .actions .action-delete { + visibility: visible; +} + +.image .action-delete { + position: absolute; + top: 2px; + right: 2px; + z-index: 2; +} + +.image .action-make-main { + position: absolute; + bottom: 20px; + left: 10%; + right: 10%; + padding: 5px; + margin: auto; +} + +.image.base-image .action-make-main { + display: none; +} + +.image .draggable-handle { + position: absolute; + width: 14px; + height: 8px; + cursor: move; + left: 0; + right: 0; + bottom: 5px; + top: auto; + margin: auto; + background: url(Mage_Backend::images/draggable-handle-bg.gif) no-repeat; + z-index: 2; +} + +.image .draggable-handle:before { + content: ''; +} + +.gallery .image .action-delete { + top: 5px; + right: 5px; +} + +.image.ui-sortable-placeholder { + background: #d7ebf5; + border: 1px dotted #93dbff; + visibility: visible !important; +} + +.image-placeholder { + position: relative; + background: #fff url(Mage_Adminhtml::images/image-placeholder.png) no-repeat 50% 0; +} + +.image-placeholder .fileinput-button { + position: absolute; + left: 0; + top: 0; + right: 0; + bottom: 0; +} + +.image-placeholder .fileinput-button > span { + display: none; +} + +.image-placeholder input[type="file"] { + position: absolute; + top: 0; + right: 0; + left: 0; + bottom: 0; + width: 100%; + height: 100%; + opacity: 0; + border: 500px solid transparent; + font-size: 10em; + z-index: 2; + cursor: pointer; +} + +.image-placeholder .file-row, +.image-placeholder.loading:after { + position: absolute; + left: 0; + right: 0; + bottom: 0; + top: 0; + width: auto; + height: auto; + margin: auto; + overflow: hidden; + background: #fff url(../images/ajax-loader-big.gif) no-repeat 50% 50%; + z-index: 5; + text-indent: -999em; +} + +.image-placeholder-text { + padding: 0 10px; + position: absolute; + left: 0; + right: 0; + bottom: 0; + font-size: 11px; + font-weight: bold; + line-height: 1.333; + text-align: center; + color: #cac8c4; +} + +.gallery .image-placeholder { + background-position: 50% 30%; +} + +.gallery .image-placeholder-text { + margin-bottom: 15%; +} + +@media screen and (max-width: 1200px) { + .gallery .image-placeholder-text { + margin-bottom: 5px; + } +} + +/* Gallery image panel */ +.image-panel { + display: none; + position: relative; + top: 5px; + clear: both; + background: #fff; + margin: 0 -18px 15px; + padding: 20px 15px; + box-shadow: 0 1px 3px #aaa inset; + border-bottom: 1px solid #cfd0cb; +} + +.eq-ie8 .image-panel { + border: solid #d6d3d0; + border-width: 2px 1px 1px; +} + +.image-pointer { + position: absolute; + left: 50%; + top: -11px; + margin-left: -14px; + width: 28px; + height: 15px; + background: url(Mage_Backend::images/gallery-image-panel-corner.png) no-repeat; +} + +.eq-ie8 .image-pointer { + top: -13px; +} + +.image-panel-controls, +.image-panel-preview { + float: left; + width: 65.95744680199999%; + margin-left: 2.127659574%; +} + +.image-panel-preview { + margin-left: 0; +} + +.image-panel-controls { + width: 29.914893614%; + padding: 28px 1% 0 1%; +} + +.image-panel-controls .image-name { + display: block; + margin: 0 0 3px; + color: #666; +} + +.image-file-params { + margin: 0 0 10px 0; + font-size: 11px; + color: #666; +} + +.image-panel-controls .action-remove, +.image-panel-controls .action-remove:hover, +.image-panel-controls .action-remove:active, +.image-panel-controls .action-remove:focus, +.image-panel-controls .action-remove[disabled] { + color: #a29c94; + font: 12px/1.333 Arial, Verdana, sans-serif; + text-decoration: underline; + margin: 0 0 42px 0; +} + +.image-panel-controls .fieldset-alt { + padding: 0 5px 0 0; +} + +.image-panel-controls .fieldset-alt .field { + margin-bottom: 25px; +} + +.image-panel-controls .fieldset-alt .field > .control, +.image-panel-controls textarea { + width: 100%; + resize: vertical; +} + +.image-panel-preview img { + width: 100%; +} + +.image-panel .action-close { + position: absolute; + top: 15px; + right: 15px; +} + +.image-panel .action-close:before { + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: '\e07d'; /* close icon */ + font-size: 16px; + color: #bbb; +} + +.image-panel .action-close span { + display: none; +} + +/* action in fieldset wrapper */ +.fieldset-wrapper-title .action-add, +.fieldset-wrapper-title .action-add:hover, +.fieldset-wrapper-title .action-add:focus, +.fieldset-wrapper-title .action-add:active, +.fieldset-wrapper-title .action-add:hover { + font-size: 12px; + color: #a29c94; + text-decoration: underline; + margin: 4px 20px 0 0; +} + +.fieldset-wrapper-title .action-add:hover { + color: #000; +} + +.action-manage-images { + font: 11px/1.666 Arial, Verdana, sans-serif; + color: #a29c94; + text-decoration: underline; +} + +/* Quantity filed on product */ +.field-quantity_and_stock_status input[type="text"], +.field-weight .control .field:first-child { + width: 140px; + margin-right: 15px; +} + +.field-quantity_and_stock_status select { + vertical-align: middle; +} + +/* Weight field */ +.field-weight .control { + display: table; + width: 100%; +} + +.field-weight .control .field:first-child .control { + width: 100%; +} + +.field-weight .choice { + padding-top: 3px; +} + +.field-weight .choice input { + margin-right: 5px; + vertical-align: bottom; +} + +.field-price .addon > input { + width: 99px; + float: left; +} + +/* Validation for Product Fields with addons */ +.field-price .control, +.field-special_price .control, +.field-msrp .control, +.field-weight .control { + position: relative; +} + +.field-price label.mage-error, +.field-special_price label.mage-error, +.field-msrp label.mage-error, +.field-weight label.mage-error { + position: absolute; + left: 0; + top: 30px; +} + +/* Variations Search Field */ +#variations-search-field { + margin-bottom: 16px; +} + +#variations-search-field > .control { + position: relative; + width: 42%; +} + +#variations-search-field > .control > input { + padding-right: 25px; +} + +#configurable-attributes-container .field-variation > .label { + margin-left: -7px; +} + +#configurable-attributes-container .field-variation > .control { + width: 43%; +} + +#configurable-attributes-container { + margin-bottom: 23px; +} + +#configurable-attributes-container .col-include { + width: 80px; +} + +#configurable-attributes-container .col-actions { + width: 80px; +} + +#configurable-attributes-container .col-change-price { + width: 150px; + white-space: nowrap; +} + +#configurable-attributes-container .field-change-pricing .field { + float: left; +} + +#configurable-attributes-container .field-pricing-value .control { + width: 75px; +} + +#configurable-attributes-container .field-pricing-value .pricing-value { + width: 100%; + padding: 4px; + border-right: none; + border-radius: 4px 0 0 4px; +} + +#configurable-attributes-container .field-pricing-measure select { + border-radius: 0 4px 4px 0; +} + +#generate-variations-button { + margin-bottom: 18px; +} + +#product-variations-matrix > .title { + margin-bottom: 10px; +} + +#product-variations-matrix .action-upload { + background: #fff; + border-radius: 0; + border: 1px solid #b7b2a7; + padding: 0; + width: 31px; + height: 31px; + line-height: 30px; + text-align: center; + color: #9f9a91; + overflow: hidden; +} + +#product-variations-matrix .action-upload:hover { + color: #7e7e7e; +} + +#product-variations-matrix .action-upload:before { + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: '\e02d'; /* plus icon */ + font-size: 22px; +} + +#product-variations-matrix .action-upload span, +#product-variations-matrix .action-choose span { + display: none; +} + +#product-variations-matrix .action-choose, +#product-variations-matrix .action-choose:hover, +#product-variations-matrix .action-choose[disabled] { + color: #b8b3a7; + float: right; + margin: 6px 0 0 5px; +} + +#product-variations-matrix .action-choose:hover { + color: #7e7e7e; +} + +#product-variations-matrix .action-choose:before { + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: '\e03f'; /* user icon */ +} + +#product-variations-matrix .col-name > a + .action-choose:before { + content: '\e040'; /* user icon */ + color: #a09a8c; +} + +#product-variations-matrix .col-name > input { + width: 75%; +} + +#product-variations-matrix .col-actions { + width: 60px; +} + +#product-variations-matrix .col-name { + width: 30%; +} + +#product-variations-matrix .col-sku { + width: 20%; +} + +#product-variations-matrix .col-display, +#product-variations-matrix .col-qty, +#product-variations-matrix .col-weight { + width: 5%; +} + +#product_options_container .data-table td, +#attribute-tier_price-container .data-table td, +#attribute-group_price-container .data-table td { + vertical-align: top; +} + +#product_options_container .product-option-scope-checkbox { + margin: 10px 5px 10px 0; +} + +#product_options_container .select + .product-option-scope-checkbox { + margin: 0 5px; +} + +#allow_open_amount { + margin-top: 8px; +} + +.mage-new-category-dialog .ui-dialog-content .fieldset { + padding: 0; +} + +.mage-new-category-dialog .ui-dialog-content .label { + width: 25%; +} + +.mage-new-category-dialog .ui-dialog-content .control { + width: 75%; +} + +.mage-new-category-dialog .ui-dialog-buttonset { + text-align: left; +} + +.mage-new-category-dialog .ui-dialog-buttonset [class^="action-"], +.mage-new-category-dialog .ui-dialog-buttonset .action-cancel:hover { + margin: 0 25px 0 0; + vertical-align: middle; +} + +/* + Advanced Pricing tab +-------------------------------------- */ +.field-recurring_profile > .control > .field-row:first-child + .fieldset { + margin-top: -14px; +} + +.field-recurring_profile > .control > .fieldset > .field > .label { + width: 30%; +} + +.field-recurring_profile > .control > .fieldset > .field > .control { + width: 70%; +} + +.field-recurring_profile > .control > .fieldset > .field > .field-service { + display: none; +} + +/* Change Attribute Set */ +#product_info_tabs li.removed, +.field.removed { + display: none !important; +} + +/* + Grouped Products Grid +-------------------------------------- */ +#grouped_grid .col-name { + width: 25%; +} + +#grouped_grid .col-sku { + width: 10%; +} + +#grouped_grid .col-qty { + width: 7%; +} + +/* + Custom Options +-------------------------------------- */ +#product_options_container_top .field-option-title { + width: 500px; +} + +#product_options_container_top .field-option-input-type { + width: 170px; +} + +#product_options_container_top .col-draggable .draggable-handle { + top: 7px; +} + +#product_options_container_top .col-name, +#product_options_container_top .col-sku { + width: 38%; +} + +#product_options_container_top .add-select-row ~ label.mage-error { + display: block; + margin: 5px 0 0; +} + +.eq-ie8 #product_options_container_top .fieldset, +.eq-ie8 #product_options_container_top .fieldset-alt { + margin-bottom: 0; +} + +/* + Tier Price Table +-------------------------------------- */ +.tiers_table .col-qty { + text-align: left; + width: 150px; +} + +.tiers_table .col-qty > input { + width: 40%; + margin-right: 5px; +} + +.tiers_table .col-qty > .nobr { + width: 50%; + float: right; + margin-top: 6px; + text-overflow: ellipsis; + overflow: hidden; +} + +.tiers_table .col-price { + width: 15%; +} diff --git a/app/code/core/Mage/Catalog/view/frontend/category/view.phtml b/app/code/Mage/Catalog/view/frontend/category/view.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/category/view.phtml rename to app/code/Mage/Catalog/view/frontend/category/view.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/category/widget/link/link_block.phtml b/app/code/Mage/Catalog/view/frontend/category/widget/link/link_block.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/category/widget/link/link_block.phtml rename to app/code/Mage/Catalog/view/frontend/category/widget/link/link_block.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/category/widget/link/link_inline.phtml b/app/code/Mage/Catalog/view/frontend/category/widget/link/link_inline.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/category/widget/link/link_inline.phtml rename to app/code/Mage/Catalog/view/frontend/category/widget/link/link_inline.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/images/i_asc_arrow.gif b/app/code/Mage/Catalog/view/frontend/images/i_asc_arrow.gif similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/images/i_asc_arrow.gif rename to app/code/Mage/Catalog/view/frontend/images/i_asc_arrow.gif diff --git a/app/code/core/Mage/Catalog/view/frontend/images/i_block-list.gif b/app/code/Mage/Catalog/view/frontend/images/i_block-list.gif similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/images/i_block-list.gif rename to app/code/Mage/Catalog/view/frontend/images/i_block-list.gif diff --git a/app/code/core/Mage/Catalog/view/frontend/images/i_desc_arrow.gif b/app/code/Mage/Catalog/view/frontend/images/i_desc_arrow.gif similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/images/i_desc_arrow.gif rename to app/code/Mage/Catalog/view/frontend/images/i_desc_arrow.gif diff --git a/app/code/core/Mage/Catalog/view/frontend/images/i_widget-link.gif b/app/code/Mage/Catalog/view/frontend/images/i_widget-link.gif similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/images/i_widget-link.gif rename to app/code/Mage/Catalog/view/frontend/images/i_widget-link.gif diff --git a/app/code/core/Mage/Catalog/view/frontend/images/i_widget-new.gif b/app/code/Mage/Catalog/view/frontend/images/i_widget-new.gif similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/images/i_widget-new.gif rename to app/code/Mage/Catalog/view/frontend/images/i_widget-new.gif diff --git a/app/code/core/Mage/Catalog/view/frontend/images/magnifier_handle.gif b/app/code/Mage/Catalog/view/frontend/images/magnifier_handle.gif similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/images/magnifier_handle.gif rename to app/code/Mage/Catalog/view/frontend/images/magnifier_handle.gif diff --git a/app/code/core/Mage/Catalog/view/frontend/images/media/col_left_callout.jpg b/app/code/Mage/Catalog/view/frontend/images/media/col_left_callout.jpg similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/images/media/col_left_callout.jpg rename to app/code/Mage/Catalog/view/frontend/images/media/col_left_callout.jpg diff --git a/app/code/core/Mage/Catalog/view/frontend/images/media/col_right_callout.jpg b/app/code/Mage/Catalog/view/frontend/images/media/col_right_callout.jpg similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/images/media/col_right_callout.jpg rename to app/code/Mage/Catalog/view/frontend/images/media/col_right_callout.jpg diff --git a/app/code/core/Mage/Catalog/view/frontend/images/product/placeholder/image.jpg b/app/code/Mage/Catalog/view/frontend/images/product/placeholder/image.jpg similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/images/product/placeholder/image.jpg rename to app/code/Mage/Catalog/view/frontend/images/product/placeholder/image.jpg diff --git a/app/code/core/Mage/Catalog/view/frontend/images/product/placeholder/small_image.jpg b/app/code/Mage/Catalog/view/frontend/images/product/placeholder/small_image.jpg similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/images/product/placeholder/small_image.jpg rename to app/code/Mage/Catalog/view/frontend/images/product/placeholder/small_image.jpg diff --git a/app/code/core/Mage/Catalog/view/frontend/images/product/placeholder/thumbnail.jpg b/app/code/Mage/Catalog/view/frontend/images/product/placeholder/thumbnail.jpg similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/images/product/placeholder/thumbnail.jpg rename to app/code/Mage/Catalog/view/frontend/images/product/placeholder/thumbnail.jpg diff --git a/app/code/core/Mage/Catalog/view/frontend/images/slider_btn_zoom_in.gif b/app/code/Mage/Catalog/view/frontend/images/slider_btn_zoom_in.gif similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/images/slider_btn_zoom_in.gif rename to app/code/Mage/Catalog/view/frontend/images/slider_btn_zoom_in.gif diff --git a/app/code/core/Mage/Catalog/view/frontend/images/slider_btn_zoom_out.gif b/app/code/Mage/Catalog/view/frontend/images/slider_btn_zoom_out.gif similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/images/slider_btn_zoom_out.gif rename to app/code/Mage/Catalog/view/frontend/images/slider_btn_zoom_out.gif diff --git a/app/code/core/Mage/Catalog/view/frontend/js/compare.js b/app/code/Mage/Catalog/view/frontend/js/compare.js similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/js/compare.js rename to app/code/Mage/Catalog/view/frontend/js/compare.js diff --git a/app/code/core/Mage/Catalog/view/frontend/js/configurable.js b/app/code/Mage/Catalog/view/frontend/js/configurable.js similarity index 98% rename from app/code/core/Mage/Catalog/view/frontend/js/configurable.js rename to app/code/Mage/Catalog/view/frontend/js/configurable.js index fd618cca2f7ee..14237074ed029 100644 --- a/app/code/core/Mage/Catalog/view/frontend/js/configurable.js +++ b/app/code/Mage/Catalog/view/frontend/js/configurable.js @@ -115,6 +115,11 @@ $.each(this.options.settings, $.proxy(function(index, element) { $(element).on('change', this, this._configure); }, this)); + var superSelector = this.options.superSelector; + $('.link-wishlist').on('click', function () { + var url = $(this).attr('href'); + $(this).attr('href', url + (url.indexOf('?') == -1 ? '?' : '&') + $(superSelector).serialize()); + }); }, /** diff --git a/app/code/core/Mage/Catalog/view/frontend/js/date-option.js b/app/code/Mage/Catalog/view/frontend/js/date-option.js similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/js/date-option.js rename to app/code/Mage/Catalog/view/frontend/js/date-option.js diff --git a/app/code/core/Mage/Catalog/view/frontend/js/file-option.js b/app/code/Mage/Catalog/view/frontend/js/file-option.js similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/js/file-option.js rename to app/code/Mage/Catalog/view/frontend/js/file-option.js diff --git a/app/code/core/Mage/Catalog/view/frontend/js/gallery.js b/app/code/Mage/Catalog/view/frontend/js/gallery.js similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/js/gallery.js rename to app/code/Mage/Catalog/view/frontend/js/gallery.js diff --git a/app/code/core/Mage/Catalog/view/frontend/js/list.js b/app/code/Mage/Catalog/view/frontend/js/list.js similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/js/list.js rename to app/code/Mage/Catalog/view/frontend/js/list.js diff --git a/app/code/core/Mage/Catalog/view/frontend/js/mage-attributes-processing.js b/app/code/Mage/Catalog/view/frontend/js/mage-attributes-processing.js similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/js/mage-attributes-processing.js rename to app/code/Mage/Catalog/view/frontend/js/mage-attributes-processing.js diff --git a/app/code/core/Mage/Catalog/view/frontend/js/msrp.js b/app/code/Mage/Catalog/view/frontend/js/msrp.js similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/js/msrp.js rename to app/code/Mage/Catalog/view/frontend/js/msrp.js diff --git a/app/code/core/Mage/Catalog/view/frontend/js/price-option.js b/app/code/Mage/Catalog/view/frontend/js/price-option.js similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/js/price-option.js rename to app/code/Mage/Catalog/view/frontend/js/price-option.js diff --git a/app/code/core/Mage/Catalog/view/frontend/js/related-products.js b/app/code/Mage/Catalog/view/frontend/js/related-products.js similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/js/related-products.js rename to app/code/Mage/Catalog/view/frontend/js/related-products.js diff --git a/app/code/core/Mage/Catalog/view/frontend/js/tier-price.js b/app/code/Mage/Catalog/view/frontend/js/tier-price.js similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/js/tier-price.js rename to app/code/Mage/Catalog/view/frontend/js/tier-price.js diff --git a/app/code/core/Mage/Catalog/view/frontend/js/zoom.js b/app/code/Mage/Catalog/view/frontend/js/zoom.js similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/js/zoom.js rename to app/code/Mage/Catalog/view/frontend/js/zoom.js diff --git a/app/code/core/Mage/Catalog/view/frontend/layer/filter.phtml b/app/code/Mage/Catalog/view/frontend/layer/filter.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/layer/filter.phtml rename to app/code/Mage/Catalog/view/frontend/layer/filter.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/layer/state.phtml b/app/code/Mage/Catalog/view/frontend/layer/state.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/layer/state.phtml rename to app/code/Mage/Catalog/view/frontend/layer/state.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/layer/view.phtml b/app/code/Mage/Catalog/view/frontend/layer/view.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/layer/view.phtml rename to app/code/Mage/Catalog/view/frontend/layer/view.phtml diff --git a/app/code/Mage/Catalog/view/frontend/layout.xml b/app/code/Mage/Catalog/view/frontend/layout.xml new file mode 100644 index 0000000000000..7646204d67424 --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/layout.xml @@ -0,0 +1,382 @@ + + + + + + + + + Mage_Catalog::widgets.css + + + + + Mage_Catalog::images/media/col_left_callout.jpg + Our customer service is available 24/7. Call us at (555) 555-0123. + checkout/cart + + + + + + Mage_Catalog::images/media/col_right_callout.jpg + Keep your eyes open for our special Back to School items and save A LOT! + + + + + + + + + + + + + + + + + + empty6 + one_column5 + two_columns_left4 + two_columns_right4 + three_columns3 + product_list_toolbar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + scriptaculous/scriptaculous.js + + + + + + + + + catalog.compare.sidebar + + + + + + + + + + + + + Mage_Catalog::zoom.css + + + + + + + + + + + + 4 + upsell4 + + + + + detailed_info + + + detailed_info + + + + + + + + + + + textMage_Catalog_Block_Product_View_Options_Type_Text + fileMage_Catalog_Block_Product_View_Options_Type_File + selectMage_Catalog_Block_Product_View_Options_Type_Select + dateMage_Catalog_Block_Product_View_Options_Type_Date + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Mage_Catalog::zoom.css + {{data.selectedProductDetails.metaTitle}} + {{data.selectedProductDetails.metaKeyword}} + {{data.selectedProductDetails.metaDescription}} + canonical{{data.selectedProductDetails.linkRelUrl}} + + + + + + + + + + + + + + + + + + + + 4 + upsell4 + + + + + + detailed_info + + + + detailed_info + + + + + + + + + + + + + + optionsoptiontextMage_Catalog_Block_Product_View_Options_Type_Text + optionsoptionfileMage_Catalog_Block_Product_View_Options_Type_File + optionsoptionselectMage_Catalog_Block_Product_View_Options_Type_Select + optionsoptiondateMage_Catalog_Block_Product_View_Options_Type_Date + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/core/Mage/Catalog/view/frontend/msrp.xml b/app/code/Mage/Catalog/view/frontend/msrp.xml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/msrp.xml rename to app/code/Mage/Catalog/view/frontend/msrp.xml diff --git a/app/code/core/Mage/Catalog/view/frontend/msrp/popup.phtml b/app/code/Mage/Catalog/view/frontend/msrp/popup.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/msrp/popup.phtml rename to app/code/Mage/Catalog/view/frontend/msrp/popup.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/navigation/left.phtml b/app/code/Mage/Catalog/view/frontend/navigation/left.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/navigation/left.phtml rename to app/code/Mage/Catalog/view/frontend/navigation/left.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/navigation/top.phtml b/app/code/Mage/Catalog/view/frontend/navigation/top.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/navigation/top.phtml rename to app/code/Mage/Catalog/view/frontend/navigation/top.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/product/compare/list.phtml b/app/code/Mage/Catalog/view/frontend/product/compare/list.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/compare/list.phtml rename to app/code/Mage/Catalog/view/frontend/product/compare/list.phtml diff --git a/app/code/Mage/Catalog/view/frontend/product/compare/sidebar.phtml b/app/code/Mage/Catalog/view/frontend/product/compare/sidebar.phtml new file mode 100644 index 0000000000000..947809b96b9b4 --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/compare/sidebar.phtml @@ -0,0 +1,71 @@ + +helper('Mage_Catalog_Helper_Product_Compare'); +$_items = $_helper->getItemCount() > 0 ? $_helper->getItemCollection() : null; +?> +
+
+ __('Compare Products') ?> + getItemCount() > 0): ?> + __('(%d)', $_helper->getItemCount()) ?> + + +
+
+ getItemCount() > 0): ?> +
    + $_item): ?> +
  1. + + __('Remove This Item') ?> +

    helper('Mage_Catalog_Helper_Output')->productAttribute($_item, $_item->getName(), 'name') ?>

    +
  2. + +
+
+ __('Clear All') ?> + +
+ + +

__('You have no items to compare.') ?>

+ +
+
diff --git a/app/code/core/Mage/Catalog/view/frontend/product/gallery.phtml b/app/code/Mage/Catalog/view/frontend/product/gallery.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/gallery.phtml rename to app/code/Mage/Catalog/view/frontend/product/gallery.phtml diff --git a/app/code/Mage/Catalog/view/frontend/product/image.phtml b/app/code/Mage/Catalog/view/frontend/product/image.phtml new file mode 100644 index 0000000000000..1187551ab4e13 --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/image.phtml @@ -0,0 +1,32 @@ + + + +<?php echo $this->stripTags($this->getProductImageView()->getLabel(), null, true) ?> diff --git a/app/code/Mage/Catalog/view/frontend/product/image_with_borders.phtml b/app/code/Mage/Catalog/view/frontend/product/image_with_borders.phtml new file mode 100644 index 0000000000000..52811b0f4c9f8 --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/image_with_borders.phtml @@ -0,0 +1,33 @@ + + + +<?php echo $this->stripTags($this->getProductImageView()->getLabel(), null, true) ?> diff --git a/app/code/core/Mage/Catalog/view/frontend/product/list.phtml b/app/code/Mage/Catalog/view/frontend/product/list.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/list.phtml rename to app/code/Mage/Catalog/view/frontend/product/list.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/product/list/related.phtml b/app/code/Mage/Catalog/view/frontend/product/list/related.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/list/related.phtml rename to app/code/Mage/Catalog/view/frontend/product/list/related.phtml diff --git a/app/code/Mage/Catalog/view/frontend/product/list/related.twig b/app/code/Mage/Catalog/view/frontend/product/list/related.twig new file mode 100644 index 0000000000000..dc58f370226ba --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/list/related.twig @@ -0,0 +1,59 @@ +{# +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +#} +{% if related.items is iterable %} + +{% endif %} diff --git a/app/code/core/Mage/Catalog/view/frontend/product/list/toolbar.phtml b/app/code/Mage/Catalog/view/frontend/product/list/toolbar.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/list/toolbar.phtml rename to app/code/Mage/Catalog/view/frontend/product/list/toolbar.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/product/list/upsell.phtml b/app/code/Mage/Catalog/view/frontend/product/list/upsell.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/list/upsell.phtml rename to app/code/Mage/Catalog/view/frontend/product/list/upsell.phtml diff --git a/app/code/Mage/Catalog/view/frontend/product/list/upsell.twig b/app/code/Mage/Catalog/view/frontend/product/list/upsell.twig new file mode 100644 index 0000000000000..e33724fca177e --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/list/upsell.twig @@ -0,0 +1,53 @@ +{# +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +#} +{% if block.itemCollection.items is not empty %} +
+

{{ 'You may also be interested in the following product(s)'|translate }}

+ + {# block.setColumnCount(5); # uncomment this line if you want to have another number of columns. also can be changed in layout #} + {{ block.resetItemsIterator() }} + {% set rowCount = block.rowCount %} + {% for i in 0..rowCount %} + + {% set columnCount = block.columnCount%} + {% for j in 0..columnCount %} + {% set link = block.getIterableItem() %} + {% if link is not empty %} + + {% else %} + + {% endif %} + {% endfor %} + + {% endfor %} +
+ {{ block.escapeHtml(link.name) }} +

{{ block.escapeHtml(link.name) }}

+ {{ block.priceHtml(link, true, '-upsell') |raw }} + {{ block.reviewsSummaryHtml(link) }} +
 
+ +
+{% endif %} \ No newline at end of file diff --git a/app/code/core/Mage/Catalog/view/frontend/product/new.phtml b/app/code/Mage/Catalog/view/frontend/product/new.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/new.phtml rename to app/code/Mage/Catalog/view/frontend/product/new.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/product/price.phtml b/app/code/Mage/Catalog/view/frontend/product/price.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/price.phtml rename to app/code/Mage/Catalog/view/frontend/product/price.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/product/price_msrp.phtml b/app/code/Mage/Catalog/view/frontend/product/price_msrp.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/price_msrp.phtml rename to app/code/Mage/Catalog/view/frontend/product/price_msrp.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/product/price_msrp_item.phtml b/app/code/Mage/Catalog/view/frontend/product/price_msrp_item.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/price_msrp_item.phtml rename to app/code/Mage/Catalog/view/frontend/product/price_msrp_item.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/product/price_msrp_noform.phtml b/app/code/Mage/Catalog/view/frontend/product/price_msrp_noform.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/price_msrp_noform.phtml rename to app/code/Mage/Catalog/view/frontend/product/price_msrp_noform.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/product/price_msrp_rss.phtml b/app/code/Mage/Catalog/view/frontend/product/price_msrp_rss.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/price_msrp_rss.phtml rename to app/code/Mage/Catalog/view/frontend/product/price_msrp_rss.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/product/view.phtml b/app/code/Mage/Catalog/view/frontend/product/view.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/view.phtml rename to app/code/Mage/Catalog/view/frontend/product/view.phtml diff --git a/app/code/Mage/Catalog/view/frontend/product/view.twig b/app/code/Mage/Catalog/view/frontend/product/view.twig new file mode 100644 index 0000000000000..d781f82c2b4b5 --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/view.twig @@ -0,0 +1,138 @@ +{# +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +#} + +
{{ getMessagesHtml() }}
+{% set continueUrl = encodeUrl(getCurrentUrl()) %} +
+
+ {% set routeData = block.getSubmitRouteData %} + {% if routeData %} + {% set route = routeData.route %} + {% set params = (routeData.params) ? routeData.params : [] %} + {% set submitUrl = getUrl(route, params) %} + {% else %} + {% set routeParams = { + 'uenc': continueUrl, + 'product': product.entityId, + '_store': product.storeId, + '_store_to_url': true, + 'in_cart': 1} + %} + {% set submitUrl = getUrl('checkout/cart/add', routeParams) %} + {% endif %} +
+
+ + +
+ +
+
+

{{ product.name|raw }}

+
+ + {% if product.canEmailToFriend %} + {% set emailToFriend = getUrl('sendfriend/product/send', {'id': product.entityId, 'cat_id': product.categoryId}) %} + + {% endif %} + {{ getChildHtml('product_review_summary') }} + {{ getChildHtml('alert_urls') }} + {{ getChildHtml('product_type_data') }} + {{ executeRenderer('price', 'tier', product.productType) }} + {{ getChildHtml('extrahint') }} + {% if product.hasOptions==false %} +
+ {% if product.isSaleable %} + {{ getChildHtml('addtocart') }} + {% set compareAddUrlParams = {'product': product.entityId, 'uenc': continueUrl } %} + {% set compareAddUrl = getUrl('catalog/product_compare/add', compareAddUrlParams) %} + {% if (isModuleOutputEnabled('Mage_Wishlist') and getStoreConfig('wishlist/general/active')) + or compareAddUrl %} + {{ 'OR'|translate }} + {% endif %} + {% endif %} + {{ getChildHtml('addto') }} +
+ {{ getChildHtml('extra_buttons') }} + {% elseif product.isSaleable==false %} +
+ {{ getChildHtml('addto') }} +
+ {% endif %} + {% if product.shortDescription is not null %} +
+

{{ 'Quick Overview'|translate }}

+
{{ product.shortDescription|raw}}
+
+ {% endif %} + + {{ getChildHtml('other') }} + + {% if product.isSaleable and product.hasOptions + and product.optionsContainer == 'container1' %} + {{ getChildChildHtml('options_container') }} + {% endif %} +
+ +
{{ getChildHtml('media') }}
+ +
+ {% if product.isSaleable and product.hasOptions + and product.optionsContainer == 'container2' %} + {{ getChildChildHtml('options_container') }} + {% endif %} +
+
+ +
+ + {% for name in getGroupChildNames('detailed_info') %} + {% set html = renderElement(name) %} + {% if html %} + {% set alias = getElementAlias(name) %} +
+ {% set title = getChildData(alias, 'title') %} + {% if title %} +

{{ title|escape }}

+ {% endif %} + {{ html|raw }} +
+ {% endif %} + {% endfor %} + + {{ getChildHtml('upsell_products') }} + {{ getChildHtml('product_additional_data') }} +
+
diff --git a/app/code/core/Mage/Catalog/view/frontend/product/view/additional.phtml b/app/code/Mage/Catalog/view/frontend/product/view/additional.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/view/additional.phtml rename to app/code/Mage/Catalog/view/frontend/product/view/additional.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/product/view/addto.phtml b/app/code/Mage/Catalog/view/frontend/product/view/addto.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/view/addto.phtml rename to app/code/Mage/Catalog/view/frontend/product/view/addto.phtml diff --git a/app/code/Mage/Catalog/view/frontend/product/view/addto.twig b/app/code/Mage/Catalog/view/frontend/product/view/addto.twig new file mode 100644 index 0000000000000..5afb403f391bd --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/view/addto.twig @@ -0,0 +1,37 @@ +{# +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +#} +{% set continueUrl = encodeUrl(getCurrentUrl()) %} +{% set compareAddUrlParams = {'product': product.entityId, 'uenc': continueUrl } %} +{% set compareAddUrl = getUrl('catalog/product_compare/add', compareAddUrlParams) %} +{% set wishListAddUrl = getUrl('wishlist/index/add', {'product': product.entityId}) %} + + \ No newline at end of file diff --git a/app/code/core/Mage/Catalog/view/frontend/product/view/addtocart.phtml b/app/code/Mage/Catalog/view/frontend/product/view/addtocart.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/view/addtocart.phtml rename to app/code/Mage/Catalog/view/frontend/product/view/addtocart.phtml diff --git a/app/code/Mage/Catalog/view/frontend/product/view/addtocart.twig b/app/code/Mage/Catalog/view/frontend/product/view/addtocart.twig new file mode 100644 index 0000000000000..9c4948bd57123 --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/view/addtocart.twig @@ -0,0 +1,83 @@ +{# +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +#} +{% if product.isSaleable %} +
+ {% if not (product.isGrouped) %} + + + {% endif %} + + {{getChildHtml('', true)}} +
+{% endif %} + + diff --git a/app/code/core/Mage/Catalog/view/frontend/product/view/attributes.phtml b/app/code/Mage/Catalog/view/frontend/product/view/attributes.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/view/attributes.phtml rename to app/code/Mage/Catalog/view/frontend/product/view/attributes.phtml diff --git a/app/code/Mage/Catalog/view/frontend/product/view/attributes.twig b/app/code/Mage/Catalog/view/frontend/product/view/attributes.twig new file mode 100644 index 0000000000000..12600ffb380f1 --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/view/attributes.twig @@ -0,0 +1,40 @@ +{# +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +#} +{% if product.attributesData %} +

{{ 'Additional Information'|translate }}

+ + + + + {% for data in product.attributesData %} + + + + + {% endfor %} + +
{{ data['label']|translate|raw }}{{ data['output'] }}
+ +{% endif %} \ No newline at end of file diff --git a/app/code/core/Mage/Catalog/view/frontend/product/view/description.phtml b/app/code/Mage/Catalog/view/frontend/product/view/description.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/view/description.phtml rename to app/code/Mage/Catalog/view/frontend/product/view/description.phtml diff --git a/app/code/Mage/Catalog/view/frontend/product/view/description.twig b/app/code/Mage/Catalog/view/frontend/product/view/description.twig new file mode 100644 index 0000000000000..ae7b0a13ae993 --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/view/description.twig @@ -0,0 +1,30 @@ +{# +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +#} +{% if product.description is defined %} +

{{ 'Details'|translate }}

+
+ {{ product.description|raw }} +
+{% endif %} diff --git a/app/code/core/Mage/Catalog/view/frontend/product/view/media.phtml b/app/code/Mage/Catalog/view/frontend/product/view/media.phtml similarity index 79% rename from app/code/core/Mage/Catalog/view/frontend/product/view/media.phtml rename to app/code/Mage/Catalog/view/frontend/product/view/media.phtml index 728c428305a38..ed7b6c203d58d 100644 --- a/app/code/core/Mage/Catalog/view/frontend/product/view/media.phtml +++ b/app/code/Mage/Catalog/view/frontend/product/view/media.phtml @@ -48,18 +48,14 @@ <?php echo $this->__('Zoom In') ?>

@@ -76,16 +72,9 @@ getBaseImageIconSize()?> getGalleryImages() as $_image): ?>

  • - <?php echo $this->escapeHtml($_image->getLabel()) ?> + <?php echo $this->escapeHtml($_image->getLabel()) ?>
  • - diff --git a/app/code/Mage/Catalog/view/frontend/product/view/media.twig b/app/code/Mage/Catalog/view/frontend/product/view/media.twig new file mode 100644 index 0000000000000..98905ed18f376 --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/view/media.twig @@ -0,0 +1,66 @@ +{# +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +#} +{% set iconSize = getDesignVarValue('Mage_Catalog', 'product_base_image_icon_size') %} +{% if product.images is defined %} +

    + {{ product.images.label | escape }} +

    +

    {{ 'Double click on above image to view full picture'|translate }}

    +
    + {{ 'Zoom Out'|translate }} +
    + {{ 'Zoom In'|translate }} +
    + +{% else %} +

    + {% set defaultImage = getDefaultImage() %} + {{ product.name | escape }} +

    +{% endif %} +{% if product.mediaGallery is defined %} +
    +

    {{ 'More Views'|translate }}

    +
      + {% for element in product.mediaGallery.images %} +
    • + {% set galleryUrl = getUrl('catalog/product/gallery', {'id': product.entityId, 'image': element.image.valueId}) %} + + {{ element.image.label|escape }} + +
    • + {% endfor %} +
    +
    +{% endif %} diff --git a/app/code/core/Mage/Catalog/view/frontend/product/view/options.phtml b/app/code/Mage/Catalog/view/frontend/product/view/options.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/view/options.phtml rename to app/code/Mage/Catalog/view/frontend/product/view/options.phtml diff --git a/app/code/Mage/Catalog/view/frontend/product/view/options.twig b/app/code/Mage/Catalog/view/frontend/product/view/options.twig new file mode 100644 index 0000000000000..da405dcff98e1 --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/view/options.twig @@ -0,0 +1,47 @@ +{# +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +#} +{% if product.hasOptions is defined and product.hasOptions %} + +
    + {% for option in product.options.optionList %} + {% if (constant('Mage_Catalog_Model_Product_Option::OPTION_GROUP_TEXT') == option.groupByType) %} + {{ executeRenderer('options', 'option', 'text', {'option': option}) }} + {% elseif (constant('Mage_Catalog_Model_Product_Option::OPTION_GROUP_FILE') == option.groupByType) %} + {{ executeRenderer('options', 'option', 'file', {'option': option}) }} + {% elseif (constant('Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT') == option.groupByType) %} + {% set optionObject = block.getOption(option.id) %} + {{ executeRenderer('options', 'option', 'select', {'optionData':option, 'option': optionObject }) }} + {% elseif (constant('Mage_Catalog_Model_Product_Option::OPTION_GROUP_DATE') == option.groupByType) %} + {{ executeRenderer('options', 'option', 'date', {'option': option}) }} + {% endif %} + {% endfor %} +
    +{% endif %} \ No newline at end of file diff --git a/app/code/core/Mage/Catalog/view/frontend/product/view/options/js.phtml b/app/code/Mage/Catalog/view/frontend/product/view/options/js.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/view/options/js.phtml rename to app/code/Mage/Catalog/view/frontend/product/view/options/js.phtml diff --git a/app/code/Mage/Catalog/view/frontend/product/view/options/type/date.phtml b/app/code/Mage/Catalog/view/frontend/product/view/options/type/date.phtml new file mode 100644 index 0000000000000..17c819b613ed4 --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/view/options/type/date.phtml @@ -0,0 +1,80 @@ + +getOption() ?> +getId() ?> +
    getIsRequire()) echo ' class="required"' ?>> + getIsRequire()) echo '*' ?> + escapeHtml($_option->getTitle()) ?> + getFormatedPrice() ?> +
    +getDecoratedIsLast()):?> class="last"> + +getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DATE_TIME + || $_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DATE): ?> + + getDateHtml() ?> + + useCalendar()): ?> + + + + + +getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DATE_TIME + || $_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_TIME): ?> + getTimeHtml() ?> + + +getIsRequire()): ?> + + + + + + + + diff --git a/app/code/Mage/Catalog/view/frontend/product/view/options/type/date.twig b/app/code/Mage/Catalog/view/frontend/product/view/options/type/date.twig new file mode 100644 index 0000000000000..668f557a7822a --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/view/options/type/date.twig @@ -0,0 +1,108 @@ +{# +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +#} +{% set optionId = option.id %} +
    + {{ option.formattedPrice|raw }}
    + + +{% if ((option.type == constant('Mage_Catalog_Model_Product_Option::OPTION_TYPE_DATE_TIME')) + or (option.type == constant('Mage_Catalog_Model_Product_Option::OPTION_TYPE_DATE'))) %} + {% set dateBlock = createBlock('Mage_Core_Block_Html_Date') %} + {% set selectBlock = createBlock('Mage_Core_Block_Html_Select') %} + {% set calendarUrl = viewFileUrl('Mage_Core::calendar.gif') %} + + {% do dateBlock.setId('options_' ~ optionId ~ '_date') %} + {% do dateBlock.setName('options['~optionId~'][date]') %} + {% do dateBlock.setClass('product-custom-option datetime-picker input-text') %} + {% do dateBlock.setImage(calendarUrl) %} + {% do dateBlock.setDateFormat( getDateFormat(constant('Mage_Core_Model_Locale::FORMAT_TYPE_SHORT'))) %} + {% do dateBlock.setValue(option.dateOptionsById) %} + {% do dateBlock.setYearsRange(option.yearStart ~ ':' ~ option.yearEnd) %} + + {% if option.useCalendar %} + {{ dateBlock.getHtml()|raw }} + {% else %} + {% set monthsHtml = getSelectFromToHtml(selectBlock, 'month', 1, 12, option.nameOptionsById, optionId) %} + {% set daysHtml = getSelectFromToHtml(selectBlock, 'day', 1, 31, option.nameOptionsById, optionId) %} + {% set yearsHtml = getSelectFromToHtml(selectBlock, 'year', option.yearStart, option.yearEnd, option.nameOptionsById, optionId) %} + {{ option.dateFieldOrder|replace({',':' '})|replace({'d': daysHtml, 'm': monthsHtml, 'y': yearsHtml})|raw }} + + + {% endif %} +{% endif %} + +{% if (option.type == constant('Mage_Catalog_Model_Product_Option::OPTION_TYPE_DATE_TIME')) + or (option.type == constant('Mage_Catalog_Model_Product_Option::OPTION_TYPE_TIME')) %} + + {% set selectTimeBlock = createBlock('Mage_Core_Block_Html_Select') %} + {% if option.is24hTimeFormat %} + {% set hourStart = 0 %} + {% set hourEnd = 23 %} + {% set dayPartHtml = '' %} + {% else %} + {% set hourStart = 1 %} + {% set hourEnd = 12 %} + {% set dayPartOptions = {'am': 'AM'|translate, 'pm': 'PM'|translate} %} + {% set dayPartHtml = getSelectHtml(selectTimeBlock, optionId, 'day_part', dayPartOptions) %} + {% endif %} + {% set hoursHtml = getSelectFromToHtml(selectTimeBlock, 'hour', hourStart, hourEnd, option.nameOptionsById, optionId) %} + {% set minutesHtml = getSelectFromToHtml(selectTimeBlock, 'minute', 0, 59, option.nameOptionsById, optionId) %} + {% set html = hoursHtml ~ ' : ' ~ minutesHtml ~ ' ' ~ dayPartHtml %} + {{ html|raw }} + + +{% endif %} + +{% if option.isRequired %} + +{% else %} + +{% endif %} + + + + diff --git a/app/code/core/Mage/Catalog/view/frontend/product/view/options/type/default.phtml b/app/code/Mage/Catalog/view/frontend/product/view/options/type/default.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/view/options/type/default.phtml rename to app/code/Mage/Catalog/view/frontend/product/view/options/type/default.phtml diff --git a/app/code/Mage/Catalog/view/frontend/product/view/options/type/default.twig b/app/code/Mage/Catalog/view/frontend/product/view/options/type/default.twig new file mode 100644 index 0000000000000..f1fb6d55dc04d --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/view/options/type/default.twig @@ -0,0 +1,27 @@ +{# +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +#} +
    + +
    \ No newline at end of file diff --git a/app/code/core/Mage/Catalog/view/frontend/product/view/options/type/file.phtml b/app/code/Mage/Catalog/view/frontend/product/view/options/type/file.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/view/options/type/file.phtml rename to app/code/Mage/Catalog/view/frontend/product/view/options/type/file.phtml diff --git a/app/code/Mage/Catalog/view/frontend/product/view/options/type/file.twig b/app/code/Mage/Catalog/view/frontend/product/view/options/type/file.twig new file mode 100644 index 0000000000000..ae4027873849f --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/view/options/type/file.twig @@ -0,0 +1,89 @@ +{# +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +#} +{% set fileInfo = option.fileInfo %} +{% set fileName = 'options_' ~ option.id ~ '_file' %} +{% set fieldNameAction = fileName ~ '_action' %} + +{% set fileExists = fileInfo.hasData %} +{% set fileName = 'options_' ~ option.id ~ '_file' %} +{% set fieldNameAction = fileName ~ '_action' %} +{% if fileExists %} + {% set fieldValueAction = 'save_old' %} +{% else %} + {% set fieldValueAction = 'save_new' %} +{% endif %} +{% set fileNamed = fileName ~ '_name' %} + + + + +
    + {{ option.formattedPrice|raw }}
    + + +{% if fileExists %} +{{ fileInfo.title }} + + + {{ 'Change'|translate }} +  + + +{% if not option.isRequired %} + +{{ 'Delete'|translate }} +{% endif %} +{% endif %} + +
    + + + +{% if option.fileExtension %} +

    {{ 'Allowed file extensions to upload'|translate }}: {{ option.fileExtension }}

    +{% endif %} +{% if (option.imageSizeX > 0) %} +

    {{ 'Maximum image width'|translate}}: {{ option.imageSizeX }} {{ 'px.'|translate}}

    +{% endif %} +{% if (option.imageSizeY > 0) %} +

    {{ 'Maximum image height'|translate}}: {{ option.imageSizeY }} {{ 'px.'|translate}}

    +{% endif %} +
    + + diff --git a/app/code/core/Mage/Catalog/view/frontend/product/view/options/type/select.phtml b/app/code/Mage/Catalog/view/frontend/product/view/options/type/select.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/view/options/type/select.phtml rename to app/code/Mage/Catalog/view/frontend/product/view/options/type/select.phtml diff --git a/app/code/Mage/Catalog/view/frontend/product/view/options/type/select.twig b/app/code/Mage/Catalog/view/frontend/product/view/options/type/select.twig new file mode 100644 index 0000000000000..e6985b0ff82af --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/view/options/type/select.twig @@ -0,0 +1,36 @@ +{# +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +#} +
    {% if optionData.isRequired %}* {% endif %} {{ optionData.title }}
    + +
    + {{ block.getValuesHtml() | raw }} + {% if optionData.isRequired %} + {% if (optionData.type == constant('Mage_Catalog_Model_Product_Option::OPTION_TYPE_RADIO')) + or (optionData.type == constant('Mage_Catalog_Model_Product_Option::OPTION_TYPE_CHECKBOX')) %} + + {% endif %} + {% endif %} +
    + diff --git a/app/code/core/Mage/Catalog/view/frontend/product/view/options/type/text.phtml b/app/code/Mage/Catalog/view/frontend/product/view/options/type/text.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/view/options/type/text.phtml rename to app/code/Mage/Catalog/view/frontend/product/view/options/type/text.phtml diff --git a/app/code/Mage/Catalog/view/frontend/product/view/options/type/text.twig b/app/code/Mage/Catalog/view/frontend/product/view/options/type/text.twig new file mode 100644 index 0000000000000..7e246a51d648d --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/view/options/type/text.twig @@ -0,0 +1,52 @@ +{# +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +#} +
    {% if option.isRequired %}{{ '*' }}{% endif %}{{ option.title|raw }} + {{ option.formattedPrice|raw }}
    + +
    + {% if option.type == constant('Mage_Catalog_Model_Product_Option::OPTION_TYPE_FIELD') %} + {% set textValidate = [] %} + {% if option.isRequired %} + {% set textValidate = textValidate|merge({'required': true}) %} + {% endif %} + {% if option.maxCharacters %} + {% set textValidate = textValidate|merge({'maxlength': option.maxCharacters}) %} + {% endif %} + {{ option.maxCharacters }}

    + {% endif %} +
    + diff --git a/app/code/core/Mage/Catalog/view/frontend/product/view/options/wrapper.phtml b/app/code/Mage/Catalog/view/frontend/product/view/options/wrapper.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/view/options/wrapper.phtml rename to app/code/Mage/Catalog/view/frontend/product/view/options/wrapper.phtml diff --git a/app/code/Mage/Catalog/view/frontend/product/view/options/wrapper.twig b/app/code/Mage/Catalog/view/frontend/product/view/options/wrapper.twig new file mode 100644 index 0000000000000..9f639538a5f63 --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/view/options/wrapper.twig @@ -0,0 +1,31 @@ +{# +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +#} +
    + {{ block.childHtml('', true)|raw }} + {% if block.hasRequiredOptions() %} +

    {{ '* Required Fields'|translate }}

    + {% endif %} +
    + diff --git a/app/code/core/Mage/Catalog/view/frontend/product/view/options/wrapper/bottom.phtml b/app/code/Mage/Catalog/view/frontend/product/view/options/wrapper/bottom.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/view/options/wrapper/bottom.phtml rename to app/code/Mage/Catalog/view/frontend/product/view/options/wrapper/bottom.phtml diff --git a/app/code/Mage/Catalog/view/frontend/product/view/options/wrapper/bottom.twig b/app/code/Mage/Catalog/view/frontend/product/view/options/wrapper/bottom.twig new file mode 100644 index 0000000000000..ba0e72dedfa6d --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/view/options/wrapper/bottom.twig @@ -0,0 +1,27 @@ +{# +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +#} +
    + {{ getChildHtml('', true)|raw }} +
    diff --git a/app/code/core/Mage/Catalog/view/frontend/product/view/price_clone.phtml b/app/code/Mage/Catalog/view/frontend/product/view/price_clone.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/view/price_clone.phtml rename to app/code/Mage/Catalog/view/frontend/product/view/price_clone.phtml diff --git a/app/code/Mage/Catalog/view/frontend/product/view/price_clone.twig b/app/code/Mage/Catalog/view/frontend/product/view/price_clone.twig new file mode 100644 index 0000000000000..92bd1be41338e --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/view/price_clone.twig @@ -0,0 +1,26 @@ +{# +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +#} +{% set product = block.product %} +{{ block.priceHtml(product, false, '_clone')|raw }} diff --git a/app/code/core/Mage/Catalog/view/frontend/product/view/tierprices.phtml b/app/code/Mage/Catalog/view/frontend/product/view/tierprices.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/view/tierprices.phtml rename to app/code/Mage/Catalog/view/frontend/product/view/tierprices.phtml diff --git a/app/code/Mage/Catalog/view/frontend/product/view/type/default.phtml b/app/code/Mage/Catalog/view/frontend/product/view/type/default.phtml new file mode 100644 index 0000000000000..63e25bee85765 --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/view/type/default.phtml @@ -0,0 +1,38 @@ + + +getProduct() ?> + +displayProductStockStatus()): ?> + isAvailable()): ?> +

    __('Availability:') ?> __('In stock') ?>

    + +

    __('Availability:') ?> __('Out of stock') ?>

    + + +getChildHtml('product_type_data_extra') ?> +getPriceHtml($_product) ?> \ No newline at end of file diff --git a/app/code/Mage/Catalog/view/frontend/product/view/type/default.twig b/app/code/Mage/Catalog/view/frontend/product/view/type/default.twig new file mode 100644 index 0000000000000..25b0b7f09dcdd --- /dev/null +++ b/app/code/Mage/Catalog/view/frontend/product/view/type/default.twig @@ -0,0 +1,33 @@ +{# +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +#} +{% if block.displayProductStockStatus %} + {% if block.product.available %} +

    {{ 'Availability:' | translate }} {{ 'In stock' | translate }}

    + {% else %} +

    {{ 'Availability:' | translate }} {{ 'Out of stock' | translate }}

    + {%endif %} +{% endif %} +{{ getChildHtml('product_type_data_extra')|raw }} +{{ block.getPriceHtml(block.product)|raw }} \ No newline at end of file diff --git a/app/code/core/Mage/Catalog/view/frontend/product/view/type/grouped.phtml b/app/code/Mage/Catalog/view/frontend/product/view/type/grouped.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/view/type/grouped.phtml rename to app/code/Mage/Catalog/view/frontend/product/view/type/grouped.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/product/view/type/options/configurable.phtml b/app/code/Mage/Catalog/view/frontend/product/view/type/options/configurable.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/view/type/options/configurable.phtml rename to app/code/Mage/Catalog/view/frontend/product/view/type/options/configurable.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/product/widget/link/link_block.phtml b/app/code/Mage/Catalog/view/frontend/product/widget/link/link_block.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/widget/link/link_block.phtml rename to app/code/Mage/Catalog/view/frontend/product/widget/link/link_block.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/product/widget/link/link_inline.phtml b/app/code/Mage/Catalog/view/frontend/product/widget/link/link_inline.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/widget/link/link_inline.phtml rename to app/code/Mage/Catalog/view/frontend/product/widget/link/link_inline.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/product/widget/new/column/new_default_list.phtml b/app/code/Mage/Catalog/view/frontend/product/widget/new/column/new_default_list.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/widget/new/column/new_default_list.phtml rename to app/code/Mage/Catalog/view/frontend/product/widget/new/column/new_default_list.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/product/widget/new/column/new_images_list.phtml b/app/code/Mage/Catalog/view/frontend/product/widget/new/column/new_images_list.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/widget/new/column/new_images_list.phtml rename to app/code/Mage/Catalog/view/frontend/product/widget/new/column/new_images_list.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/product/widget/new/column/new_names_list.phtml b/app/code/Mage/Catalog/view/frontend/product/widget/new/column/new_names_list.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/widget/new/column/new_names_list.phtml rename to app/code/Mage/Catalog/view/frontend/product/widget/new/column/new_names_list.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/product/widget/new/content/new_grid.phtml b/app/code/Mage/Catalog/view/frontend/product/widget/new/content/new_grid.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/widget/new/content/new_grid.phtml rename to app/code/Mage/Catalog/view/frontend/product/widget/new/content/new_grid.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/product/widget/new/content/new_list.phtml b/app/code/Mage/Catalog/view/frontend/product/widget/new/content/new_list.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/product/widget/new/content/new_list.phtml rename to app/code/Mage/Catalog/view/frontend/product/widget/new/content/new_list.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/rss/product/price.phtml b/app/code/Mage/Catalog/view/frontend/rss/product/price.phtml similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/rss/product/price.phtml rename to app/code/Mage/Catalog/view/frontend/rss/product/price.phtml diff --git a/app/code/core/Mage/Catalog/view/frontend/widgets.css b/app/code/Mage/Catalog/view/frontend/widgets.css similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/widgets.css rename to app/code/Mage/Catalog/view/frontend/widgets.css diff --git a/app/code/core/Mage/Catalog/view/frontend/zoom.css b/app/code/Mage/Catalog/view/frontend/zoom.css similarity index 100% rename from app/code/core/Mage/Catalog/view/frontend/zoom.css rename to app/code/Mage/Catalog/view/frontend/zoom.css diff --git a/app/code/core/Mage/CatalogInventory/Block/Adminhtml/Form/Field/Customergroup.php b/app/code/Mage/CatalogInventory/Block/Adminhtml/Form/Field/Customergroup.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/Block/Adminhtml/Form/Field/Customergroup.php rename to app/code/Mage/CatalogInventory/Block/Adminhtml/Form/Field/Customergroup.php diff --git a/app/code/core/Mage/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php b/app/code/Mage/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php similarity index 97% rename from app/code/core/Mage/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php rename to app/code/Mage/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php index 625eec2f9c828..cb06166dec48c 100644 --- a/app/code/core/Mage/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php +++ b/app/code/Mage/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php @@ -49,7 +49,7 @@ protected function _getGroupRenderer() if (!$this->_groupRenderer) { $this->_groupRenderer = $this->getLayout()->createBlock( 'Mage_CatalogInventory_Block_Adminhtml_Form_Field_Customergroup', '', - array('is_render_to_js_template' => true) + array('data' => array('is_render_to_js_template' => true)) ); $this->_groupRenderer->setClass('customer_group_select'); $this->_groupRenderer->setExtraParams('style="width:120px"'); diff --git a/app/code/Mage/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php b/app/code/Mage/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php new file mode 100644 index 0000000000000..99487d743749a --- /dev/null +++ b/app/code/Mage/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php @@ -0,0 +1,230 @@ + + */ +class Mage_CatalogInventory_Block_Adminhtml_Form_Field_Stock extends Varien_Data_Form_Element_Select +{ + const QUANTITY_FIELD_HTML_ID = 'qty'; + + /** + * Quantity field element + * + * @var Varien_Data_Form_Element_Text + */ + protected $_qty; + + /** + * Is product composite (grouped or configurable) + * + * @var bool + */ + protected $_isProductComposite; + + public function __construct(array $data = array()) + { + $this->_qty = isset($data['qty']) ? $data['qty'] : $this->_createQtyElement(); + unset($data['qty']); + parent::__construct($data); + $this->setName($data['name']); + } + + /** + * Create quantity field + * + * @return Varien_Data_Form_Element_Text + */ + protected function _createQtyElement() + { + $element = Mage::getModel('Varien_Data_Form_Element_Text'); + $element->setId(self::QUANTITY_FIELD_HTML_ID)->setName('qty')->addClass('validate-number input-text'); + return $element; + } + + /** + * Join quantity and in stock elements' html + * + * @return string + */ + public function getElementHtml() + { + $this->_disableFields(); + return $this->_qty->getElementHtml() . parent::getElementHtml() + . $this->_getJs(self::QUANTITY_FIELD_HTML_ID, $this->getId()); + } + + /** + * Set form to quantity element in addition to current element + * + * @param $form + * @return Varien_Data_Form + */ + public function setForm($form) + { + $this->_qty->setForm($form); + return parent::setForm($form); + } + + /** + * Set value to quantity element in addition to current element + * + * @param $value + * @return Varien_Data_Form_Element_Select + */ + public function setValue($value) + { + if (is_array($value) && isset($value['qty'])) { + $this->_qty->setValue($value['qty']); + } + parent::setValue(is_array($value) && isset($value['is_in_stock']) ? $value['is_in_stock'] : $value); + return $this; + } + + /** + * Set name to quantity element in addition to current element + * + * @param string $name + */ + public function setName($name) + { + $this->_qty->setName($name . '[qty]'); + parent::setName($name . '[is_in_stock]'); + } + + /** + * Get whether product is configurable or grouped + * + * @return bool + */ + protected function _isProductComposite() + { + if ($this->_isProductComposite === null) { + $this->_isProductComposite = $this->_qty->getForm()->getDataObject()->isComposite(); + } + return $this->_isProductComposite; + } + + /** + * Disable fields depending on product type + * + * @return Mage_CatalogInventory_Block_Adminhtml_Form_Field_Stock + */ + protected function _disableFields() + { + if (!$this->_isProductComposite() && $this->_qty->getValue() === null) { + $this->setDisabled('disabled'); + } + if ($this->_isProductComposite()) { + $this->_qty->setDisabled('disabled'); + } + return $this; + } + + /** + * Get js for quantity and in stock synchronisation + * + * @param $quantityFieldId + * @param $inStockFieldId + * @return string + */ + protected function _getJs($quantityFieldId, $inStockFieldId) + { + return " + + "; + } +} diff --git a/app/code/core/Mage/CatalogInventory/Block/Qtyincrements.php b/app/code/Mage/CatalogInventory/Block/Qtyincrements.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/Block/Qtyincrements.php rename to app/code/Mage/CatalogInventory/Block/Qtyincrements.php diff --git a/app/code/core/Mage/CatalogInventory/Block/Stockqty/Abstract.php b/app/code/Mage/CatalogInventory/Block/Stockqty/Abstract.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/Block/Stockqty/Abstract.php rename to app/code/Mage/CatalogInventory/Block/Stockqty/Abstract.php diff --git a/app/code/core/Mage/CatalogInventory/Block/Stockqty/Composite.php b/app/code/Mage/CatalogInventory/Block/Stockqty/Composite.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/Block/Stockqty/Composite.php rename to app/code/Mage/CatalogInventory/Block/Stockqty/Composite.php diff --git a/app/code/core/Mage/CatalogInventory/Block/Stockqty/Default.php b/app/code/Mage/CatalogInventory/Block/Stockqty/Default.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/Block/Stockqty/Default.php rename to app/code/Mage/CatalogInventory/Block/Stockqty/Default.php diff --git a/app/code/core/Mage/CatalogInventory/Block/Stockqty/Type/Configurable.php b/app/code/Mage/CatalogInventory/Block/Stockqty/Type/Configurable.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/Block/Stockqty/Type/Configurable.php rename to app/code/Mage/CatalogInventory/Block/Stockqty/Type/Configurable.php diff --git a/app/code/core/Mage/CatalogInventory/Block/Stockqty/Type/Grouped.php b/app/code/Mage/CatalogInventory/Block/Stockqty/Type/Grouped.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/Block/Stockqty/Type/Grouped.php rename to app/code/Mage/CatalogInventory/Block/Stockqty/Type/Grouped.php diff --git a/app/code/core/Mage/CatalogInventory/Helper/Data.php b/app/code/Mage/CatalogInventory/Helper/Data.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/Helper/Data.php rename to app/code/Mage/CatalogInventory/Helper/Data.php diff --git a/app/code/core/Mage/CatalogInventory/Helper/Minsaleqty.php b/app/code/Mage/CatalogInventory/Helper/Minsaleqty.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/Helper/Minsaleqty.php rename to app/code/Mage/CatalogInventory/Helper/Minsaleqty.php diff --git a/app/code/core/Mage/CatalogInventory/Model/Config/Backend/Managestock.php b/app/code/Mage/CatalogInventory/Model/Config/Backend/Managestock.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/Model/Config/Backend/Managestock.php rename to app/code/Mage/CatalogInventory/Model/Config/Backend/Managestock.php diff --git a/app/code/core/Mage/CatalogInventory/Model/Indexer/Stock.php b/app/code/Mage/CatalogInventory/Model/Indexer/Stock.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/Model/Indexer/Stock.php rename to app/code/Mage/CatalogInventory/Model/Indexer/Stock.php diff --git a/app/code/core/Mage/CatalogInventory/Model/Observer.php b/app/code/Mage/CatalogInventory/Model/Observer.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/Model/Observer.php rename to app/code/Mage/CatalogInventory/Model/Observer.php diff --git a/app/code/core/Mage/CatalogInventory/Model/Resource/Indexer/Stock.php b/app/code/Mage/CatalogInventory/Model/Resource/Indexer/Stock.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/CatalogInventory/Model/Resource/Indexer/Stock.php rename to app/code/Mage/CatalogInventory/Model/Resource/Indexer/Stock.php diff --git a/app/code/core/Mage/CatalogInventory/Model/Resource/Indexer/Stock/Configurable.php b/app/code/Mage/CatalogInventory/Model/Resource/Indexer/Stock/Configurable.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/CatalogInventory/Model/Resource/Indexer/Stock/Configurable.php rename to app/code/Mage/CatalogInventory/Model/Resource/Indexer/Stock/Configurable.php diff --git a/app/code/core/Mage/CatalogInventory/Model/Resource/Indexer/Stock/Default.php b/app/code/Mage/CatalogInventory/Model/Resource/Indexer/Stock/Default.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/CatalogInventory/Model/Resource/Indexer/Stock/Default.php rename to app/code/Mage/CatalogInventory/Model/Resource/Indexer/Stock/Default.php diff --git a/app/code/core/Mage/CatalogInventory/Model/Resource/Indexer/Stock/Grouped.php b/app/code/Mage/CatalogInventory/Model/Resource/Indexer/Stock/Grouped.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/CatalogInventory/Model/Resource/Indexer/Stock/Grouped.php rename to app/code/Mage/CatalogInventory/Model/Resource/Indexer/Stock/Grouped.php diff --git a/app/code/core/Mage/CatalogInventory/Model/Resource/Indexer/Stock/Interface.php b/app/code/Mage/CatalogInventory/Model/Resource/Indexer/Stock/Interface.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/CatalogInventory/Model/Resource/Indexer/Stock/Interface.php rename to app/code/Mage/CatalogInventory/Model/Resource/Indexer/Stock/Interface.php diff --git a/app/code/core/Mage/CatalogInventory/Model/Resource/Stock.php b/app/code/Mage/CatalogInventory/Model/Resource/Stock.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/CatalogInventory/Model/Resource/Stock.php rename to app/code/Mage/CatalogInventory/Model/Resource/Stock.php diff --git a/app/code/Mage/CatalogInventory/Model/Resource/Stock/Item.php b/app/code/Mage/CatalogInventory/Model/Resource/Stock/Item.php new file mode 100644 index 0000000000000..b1a030e1a2c4a --- /dev/null +++ b/app/code/Mage/CatalogInventory/Model/Resource/Stock/Item.php @@ -0,0 +1,136 @@ + + */ +class Mage_CatalogInventory_Model_Resource_Stock_Item extends Mage_Core_Model_Resource_Db_Abstract +{ + /** + * Define main table and initialize connection + * + */ + protected function _construct() + { + $this->_init('cataloginventory_stock_item', 'item_id'); + } + + /** + * Loading stock item data by product + * + * @param Mage_CatalogInventory_Model_Stock_Item $item + * @param int $productId + * @return Mage_CatalogInventory_Model_Resource_Stock_Item + */ + public function loadByProductId(Mage_CatalogInventory_Model_Stock_Item $item, $productId) + { + $select = $this->_getLoadSelect('product_id', $productId, $item) + ->where('stock_id = :stock_id'); + $data = $this->_getReadAdapter()->fetchRow($select, array(':stock_id' => $item->getStockId())); + if ($data) { + $item->setData($data); + } + $this->_afterLoad($item); + return $this; + } + + /** + * Retrieve select object and join it to product entity table to get type ids + * + * @param string $field + * @param mixed $value + * @param Mage_CatalogInventory_Model_Stock_Item $object + * @return Varien_Db_Select + */ + protected function _getLoadSelect($field, $value, $object) + { + $select = parent::_getLoadSelect($field, $value, $object) + ->join(array('p' => $this->getTable('catalog_product_entity')), + 'product_id=p.entity_id', + array('type_id') + ); + return $select; + } + + /** + * Add join for catalog in stock field to product collection + * + * @param Mage_Catalog_Model_Resource_Product_Collection $productCollection + * @param array $columns + * @return Mage_CatalogInventory_Model_Resource_Stock_Item + */ + public function addCatalogInventoryToProductCollection($productCollection, $columns = null) + { + if ($columns === null) { + $adapter = $this->_getReadAdapter(); + $isManageStock = (int)Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK); + $stockExpr = $adapter->getCheckSql('cisi.use_config_manage_stock = 1', $isManageStock, 'cisi.manage_stock'); + $stockExpr = $adapter->getCheckSql("({$stockExpr} = 1)", 'cisi.is_in_stock', '1'); + + $columns = array( + 'is_saleable' => new Zend_Db_Expr($stockExpr), + 'inventory_in_stock' => 'is_in_stock' + ); + } + + $productCollection->joinTable( + array('cisi' => 'cataloginventory_stock_item'), + 'product_id=entity_id', + $columns, + null, + 'left' + ); + return $this; + } + + /** + * Use qty correction for qty column update + * + * @param Mage_Core_Model_Abstract $object + * @param string $table + * @return array + */ + protected function _prepareDataForTable(Varien_Object $object, $table) + { + $data = parent::_prepareDataForTable($object, $table); + $ifNullSql = $this->_getWriteAdapter()->getIfNullSql('qty'); + if (!$object->isObjectNew() && $object->getQtyCorrection()) { + if ($object->getQty() === null) { + $data['qty'] = null; + } elseif ($object->getQtyCorrection() < 0) { + $data['qty'] = new Zend_Db_Expr($ifNullSql . '-' . abs($object->getQtyCorrection())); + } else { + $data['qty'] = new Zend_Db_Expr($ifNullSql . '+' . $object->getQtyCorrection()); + } + } + return $data; + } +} diff --git a/app/code/core/Mage/CatalogInventory/Model/Resource/Stock/Item/Collection.php b/app/code/Mage/CatalogInventory/Model/Resource/Stock/Item/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/CatalogInventory/Model/Resource/Stock/Item/Collection.php rename to app/code/Mage/CatalogInventory/Model/Resource/Stock/Item/Collection.php diff --git a/app/code/core/Mage/CatalogInventory/Model/Resource/Stock/Status.php b/app/code/Mage/CatalogInventory/Model/Resource/Stock/Status.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/CatalogInventory/Model/Resource/Stock/Status.php rename to app/code/Mage/CatalogInventory/Model/Resource/Stock/Status.php diff --git a/app/code/core/Mage/CatalogInventory/Model/Source/Backorders.php b/app/code/Mage/CatalogInventory/Model/Source/Backorders.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/Model/Source/Backorders.php rename to app/code/Mage/CatalogInventory/Model/Source/Backorders.php diff --git a/app/code/core/Mage/CatalogInventory/Model/Source/Stock.php b/app/code/Mage/CatalogInventory/Model/Source/Stock.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/Model/Source/Stock.php rename to app/code/Mage/CatalogInventory/Model/Source/Stock.php diff --git a/app/code/core/Mage/CatalogInventory/Model/Stock.php b/app/code/Mage/CatalogInventory/Model/Stock.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/Model/Stock.php rename to app/code/Mage/CatalogInventory/Model/Stock.php diff --git a/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php b/app/code/Mage/CatalogInventory/Model/Stock/Item.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/Model/Stock/Item.php rename to app/code/Mage/CatalogInventory/Model/Stock/Item.php diff --git a/app/code/core/Mage/CatalogInventory/Model/Stock/Item/Api.php b/app/code/Mage/CatalogInventory/Model/Stock/Item/Api.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/Model/Stock/Item/Api.php rename to app/code/Mage/CatalogInventory/Model/Stock/Item/Api.php diff --git a/app/code/core/Mage/CatalogInventory/Model/Stock/Item/Api/V2.php b/app/code/Mage/CatalogInventory/Model/Stock/Item/Api/V2.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/Model/Stock/Item/Api/V2.php rename to app/code/Mage/CatalogInventory/Model/Stock/Item/Api/V2.php diff --git a/app/code/core/Mage/CatalogInventory/Model/Stock/Status.php b/app/code/Mage/CatalogInventory/Model/Stock/Status.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/CatalogInventory/Model/Stock/Status.php rename to app/code/Mage/CatalogInventory/Model/Stock/Status.php diff --git a/app/code/core/Mage/CatalogInventory/Model/System/Config/Backend/Minqty.php b/app/code/Mage/CatalogInventory/Model/System/Config/Backend/Minqty.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/Model/System/Config/Backend/Minqty.php rename to app/code/Mage/CatalogInventory/Model/System/Config/Backend/Minqty.php diff --git a/app/code/core/Mage/CatalogInventory/Model/System/Config/Backend/Minsaleqty.php b/app/code/Mage/CatalogInventory/Model/System/Config/Backend/Minsaleqty.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/Model/System/Config/Backend/Minsaleqty.php rename to app/code/Mage/CatalogInventory/Model/System/Config/Backend/Minsaleqty.php diff --git a/app/code/core/Mage/CatalogInventory/Model/System/Config/Backend/Qtyincrements.php b/app/code/Mage/CatalogInventory/Model/System/Config/Backend/Qtyincrements.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/Model/System/Config/Backend/Qtyincrements.php rename to app/code/Mage/CatalogInventory/Model/System/Config/Backend/Qtyincrements.php diff --git a/app/code/Mage/CatalogInventory/data/cataloginventory_setup/data-upgrade-1.6.0.0.3-1.6.0.0.4.php b/app/code/Mage/CatalogInventory/data/cataloginventory_setup/data-upgrade-1.6.0.0.3-1.6.0.0.4.php new file mode 100644 index 0000000000000..c62fc48cc1f06 --- /dev/null +++ b/app/code/Mage/CatalogInventory/data/cataloginventory_setup/data-upgrade-1.6.0.0.3-1.6.0.0.4.php @@ -0,0 +1,37 @@ +getEntityTypeId(Mage_Catalog_Model_Product::ENTITY); +$attributeSetId = $this->getAttributeSetId($entityTypeId, 'Default'); + +$attribute = $this->getAttribute($entityTypeId, 'quantity_and_stock_status'); +if ($attribute) { + $this->addAttributeToGroup($entityTypeId, $attributeSetId, $groupName, $attribute['attribute_id'], 60); + $this->updateAttribute($entityTypeId, $attribute['attribute_id'], 'default_value', 1); +} diff --git a/app/code/Mage/CatalogInventory/etc/adminhtml/acl.xml b/app/code/Mage/CatalogInventory/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..01ba713f14981 --- /dev/null +++ b/app/code/Mage/CatalogInventory/etc/adminhtml/acl.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + diff --git a/app/code/core/Mage/CatalogInventory/etc/adminhtml/system.xml b/app/code/Mage/CatalogInventory/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/CatalogInventory/etc/adminhtml/system.xml rename to app/code/Mage/CatalogInventory/etc/adminhtml/system.xml diff --git a/app/code/core/Mage/CatalogInventory/etc/api.xml b/app/code/Mage/CatalogInventory/etc/api.xml similarity index 100% rename from app/code/core/Mage/CatalogInventory/etc/api.xml rename to app/code/Mage/CatalogInventory/etc/api.xml diff --git a/app/code/Mage/CatalogInventory/etc/config.xml b/app/code/Mage/CatalogInventory/etc/config.xml new file mode 100644 index 0000000000000..e238458b29b6d --- /dev/null +++ b/app/code/Mage/CatalogInventory/etc/config.xml @@ -0,0 +1,304 @@ + + + + + + 1.6.0.0.4 + true + + + + + + + + + + Mage_CatalogInventory + Mage_Eav_Model_Entity_Setup + + + + + + + + Mage_CatalogInventory_Model_Observer + displayProductStatusInfo + + + + + + + Mage_CatalogInventory_Model_Observer + addInventoryData + + + + + + + Mage_CatalogInventory_Model_Observer + removeInventoryData + + + + + + + Mage_CatalogInventory_Model_Observer + addStockStatusToCollection + + + + + + + Mage_CatalogInventory_Model_Observer + prepareCatalogProductIndexSelect + + + + + + + Mage_CatalogInventory_Model_Observer + addInventoryDataToCollection + + + + + + + Mage_CatalogInventory_Model_Observer + checkQuoteItemQty + + + + + + + Mage_CatalogInventory_Model_Observer + checkoutAllSubmitAfter + + + + + + + Mage_CatalogInventory_Model_Observer + subtractQuoteInventory + + + + + + + Mage_CatalogInventory_Model_Observer + reindexQuoteInventory + + + + + + + Mage_CatalogInventory_Model_Observer + revertQuoteInventory + + + + + + + Mage_CatalogInventory_Model_Observer + cancelOrderItem + + + + + + + Mage_CatalogInventory_Model_Observer + refundOrderInventory + + + + + + + Mage_CatalogInventory_Model_Observer + saveInventoryData + + + + + + + Mage_CatalogInventory_Model_Observer + copyInventoryData + + + + + + + Mage_CatalogInventory_Model_Observer + updateItemsStockUponConfigChange + + + + + + + Mage_CatalogInventory_Model_Observer + prepareCatalogProductIndexSelect + + + + + + + Mage_CatalogInventory_Model_Observer + reindexProductsMassAction + + + + + + + Mage_CatalogInventory_Model_Observer + reindexProductsMassAction + + + + + + + + + 1 + + + 1 + + + Mage_CatalogInventory_Model_Resource_Indexer_Stock_Configurable + + + Mage_CatalogInventory_Model_Resource_Indexer_Stock_Grouped + + + + + + + + Mage_CatalogInventory_Model_Indexer_Stock + + + + + + + + + + + + + + + + + + + layout.xml + + + + + + + + Mage_CatalogInventory.csv + + + + + + + + + + layout.xml + + + + + + + + Mage_CatalogInventory.csv + + + + + + + + + Mage_CatalogInventory_Model_Observer + reindexProductsMassAction + + + + + + + + + 1 + 1 + 0 + 0 + 1 + + + 1 + 0 + 10000 + 1 + 0 + 1 + 0 + 1 + + + + diff --git a/app/code/core/Mage/CatalogInventory/etc/wsdl.xml b/app/code/Mage/CatalogInventory/etc/wsdl.xml similarity index 100% rename from app/code/core/Mage/CatalogInventory/etc/wsdl.xml rename to app/code/Mage/CatalogInventory/etc/wsdl.xml diff --git a/app/code/core/Mage/CatalogInventory/etc/wsi.xml b/app/code/Mage/CatalogInventory/etc/wsi.xml similarity index 100% rename from app/code/core/Mage/CatalogInventory/etc/wsi.xml rename to app/code/Mage/CatalogInventory/etc/wsi.xml diff --git a/app/code/core/Mage/CatalogInventory/locale/de_DE/Mage_CatalogInventory.csv b/app/code/Mage/CatalogInventory/locale/de_DE/Mage_CatalogInventory.csv similarity index 100% rename from app/code/core/Mage/CatalogInventory/locale/de_DE/Mage_CatalogInventory.csv rename to app/code/Mage/CatalogInventory/locale/de_DE/Mage_CatalogInventory.csv diff --git a/app/code/core/Mage/CatalogInventory/locale/en_US/Mage_CatalogInventory.csv b/app/code/Mage/CatalogInventory/locale/en_US/Mage_CatalogInventory.csv similarity index 100% rename from app/code/core/Mage/CatalogInventory/locale/en_US/Mage_CatalogInventory.csv rename to app/code/Mage/CatalogInventory/locale/en_US/Mage_CatalogInventory.csv diff --git a/app/code/core/Mage/CatalogInventory/locale/es_ES/Mage_CatalogInventory.csv b/app/code/Mage/CatalogInventory/locale/es_ES/Mage_CatalogInventory.csv similarity index 100% rename from app/code/core/Mage/CatalogInventory/locale/es_ES/Mage_CatalogInventory.csv rename to app/code/Mage/CatalogInventory/locale/es_ES/Mage_CatalogInventory.csv diff --git a/app/code/core/Mage/CatalogInventory/locale/fr_FR/Mage_CatalogInventory.csv b/app/code/Mage/CatalogInventory/locale/fr_FR/Mage_CatalogInventory.csv similarity index 100% rename from app/code/core/Mage/CatalogInventory/locale/fr_FR/Mage_CatalogInventory.csv rename to app/code/Mage/CatalogInventory/locale/fr_FR/Mage_CatalogInventory.csv diff --git a/app/code/core/Mage/CatalogInventory/locale/nl_NL/Mage_CatalogInventory.csv b/app/code/Mage/CatalogInventory/locale/nl_NL/Mage_CatalogInventory.csv similarity index 100% rename from app/code/core/Mage/CatalogInventory/locale/nl_NL/Mage_CatalogInventory.csv rename to app/code/Mage/CatalogInventory/locale/nl_NL/Mage_CatalogInventory.csv diff --git a/app/code/core/Mage/CatalogInventory/locale/pt_BR/Mage_CatalogInventory.csv b/app/code/Mage/CatalogInventory/locale/pt_BR/Mage_CatalogInventory.csv similarity index 100% rename from app/code/core/Mage/CatalogInventory/locale/pt_BR/Mage_CatalogInventory.csv rename to app/code/Mage/CatalogInventory/locale/pt_BR/Mage_CatalogInventory.csv diff --git a/app/code/core/Mage/CatalogInventory/locale/zh_CN/Mage_CatalogInventory.csv b/app/code/Mage/CatalogInventory/locale/zh_CN/Mage_CatalogInventory.csv similarity index 100% rename from app/code/core/Mage/CatalogInventory/locale/zh_CN/Mage_CatalogInventory.csv rename to app/code/Mage/CatalogInventory/locale/zh_CN/Mage_CatalogInventory.csv diff --git a/app/code/core/Mage/CatalogInventory/sql/cataloginventory_setup/install-1.6.0.0.php b/app/code/Mage/CatalogInventory/sql/cataloginventory_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/sql/cataloginventory_setup/install-1.6.0.0.php rename to app/code/Mage/CatalogInventory/sql/cataloginventory_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/CatalogInventory/sql/cataloginventory_setup/mysql4-upgrade-1.6.0.0-1.6.0.0.1.php b/app/code/Mage/CatalogInventory/sql/cataloginventory_setup/mysql4-upgrade-1.6.0.0-1.6.0.0.1.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/sql/cataloginventory_setup/mysql4-upgrade-1.6.0.0-1.6.0.0.1.php rename to app/code/Mage/CatalogInventory/sql/cataloginventory_setup/mysql4-upgrade-1.6.0.0-1.6.0.0.1.php diff --git a/app/code/core/Mage/CatalogInventory/sql/cataloginventory_setup/upgrade-1.6.0.0.1-1.6.0.0.2.php b/app/code/Mage/CatalogInventory/sql/cataloginventory_setup/upgrade-1.6.0.0.1-1.6.0.0.2.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/sql/cataloginventory_setup/upgrade-1.6.0.0.1-1.6.0.0.2.php rename to app/code/Mage/CatalogInventory/sql/cataloginventory_setup/upgrade-1.6.0.0.1-1.6.0.0.2.php diff --git a/app/code/core/Mage/CatalogInventory/sql/cataloginventory_setup/upgrade-1.6.0.0.2-1.6.0.0.3.php b/app/code/Mage/CatalogInventory/sql/cataloginventory_setup/upgrade-1.6.0.0.2-1.6.0.0.3.php similarity index 100% rename from app/code/core/Mage/CatalogInventory/sql/cataloginventory_setup/upgrade-1.6.0.0.2-1.6.0.0.3.php rename to app/code/Mage/CatalogInventory/sql/cataloginventory_setup/upgrade-1.6.0.0.2-1.6.0.0.3.php diff --git a/app/code/Mage/CatalogInventory/view/adminhtml/layout.xml b/app/code/Mage/CatalogInventory/view/adminhtml/layout.xml new file mode 100644 index 0000000000000..d0c83763a1a75 --- /dev/null +++ b/app/code/Mage/CatalogInventory/view/adminhtml/layout.xml @@ -0,0 +1,61 @@ + + + + + + + + Mage_Catalog_Model_Resource_Product_Collection_AssociatedProductUpdater + + + + + +
    Stock Availability
    + text + inventory_in_stock + inventory_in_stock + 0 + 1 + Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid_Renderer_Inventory +
    +
    + + +
    Qty
    + text + qty + qty + 0 + 1 +
    +
    +
    +
    +
    +
    diff --git a/app/code/core/Mage/CatalogInventory/view/frontend/layout.xml b/app/code/Mage/CatalogInventory/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/CatalogInventory/view/frontend/layout.xml rename to app/code/Mage/CatalogInventory/view/frontend/layout.xml diff --git a/app/code/core/Mage/CatalogInventory/view/frontend/qtyincrements.phtml b/app/code/Mage/CatalogInventory/view/frontend/qtyincrements.phtml similarity index 100% rename from app/code/core/Mage/CatalogInventory/view/frontend/qtyincrements.phtml rename to app/code/Mage/CatalogInventory/view/frontend/qtyincrements.phtml diff --git a/app/code/Mage/CatalogInventory/view/frontend/stockqty/composite.phtml b/app/code/Mage/CatalogInventory/view/frontend/stockqty/composite.phtml new file mode 100644 index 0000000000000..d4a936bc0f8e4 --- /dev/null +++ b/app/code/Mage/CatalogInventory/view/frontend/stockqty/composite.phtml @@ -0,0 +1,60 @@ + +isMsgVisible()): ?> +

    + __('Only %s left', "{$this->getStockQty()}") ?> +

    + + + + + + + + + + + getChildProducts() as $childProduct) : ?> + getProductStockQty($childProduct); ?> + 0) : ?> + + + + + + + +
    __('Product Name') ?>__('Qty') ?>
    getName() ?>
    + + diff --git a/app/code/core/Mage/CatalogInventory/view/frontend/stockqty/default.phtml b/app/code/Mage/CatalogInventory/view/frontend/stockqty/default.phtml similarity index 100% rename from app/code/core/Mage/CatalogInventory/view/frontend/stockqty/default.phtml rename to app/code/Mage/CatalogInventory/view/frontend/stockqty/default.phtml diff --git a/app/code/core/Mage/CatalogRule/Helper/Data.php b/app/code/Mage/CatalogRule/Helper/Data.php similarity index 100% rename from app/code/core/Mage/CatalogRule/Helper/Data.php rename to app/code/Mage/CatalogRule/Helper/Data.php diff --git a/app/code/core/Mage/CatalogRule/Model/Flag.php b/app/code/Mage/CatalogRule/Model/Flag.php similarity index 100% rename from app/code/core/Mage/CatalogRule/Model/Flag.php rename to app/code/Mage/CatalogRule/Model/Flag.php diff --git a/app/code/Mage/CatalogRule/Model/Observer.php b/app/code/Mage/CatalogRule/Model/Observer.php new file mode 100644 index 0000000000000..958e1306bda6d --- /dev/null +++ b/app/code/Mage/CatalogRule/Model/Observer.php @@ -0,0 +1,403 @@ +getEvent()->getProduct(); + if ($product->getIsMassupdate()) { + return; + } + + $productWebsiteIds = $product->getWebsiteIds(); + + $rules = Mage::getModel('Mage_CatalogRule_Model_Rule')->getCollection() + ->addFieldToFilter('is_active', 1); + + foreach ($rules as $rule) { + $websiteIds = array_intersect($productWebsiteIds, $rule->getWebsiteIds()); + $rule->applyToProduct($product, $websiteIds); + } + + return $this; + } + + /** + * Apply all price rules for current date. + * Handle cataolg_product_import_after event + * + * @param Varien_Event_Observer $observer + * + * @return Mage_CatalogRule_Model_Observer + */ + public function applyAllRules($observer) + { + $resource = Mage::getResourceSingleton('Mage_CatalogRule_Model_Resource_Rule'); + $resource->applyAllRulesForDateRange($resource->formatDate(mktime(0,0,0))); + Mage::getModel('Mage_CatalogRule_Model_Flag')->loadSelf() + ->setState(0) + ->save(); + + return $this; + } + + /** + * Apply catalog price rules to product on frontend + * + * @param Varien_Event_Observer $observer + * + * @return Mage_CatalogRule_Model_Observer + */ + public function processFrontFinalPrice($observer) + { + $product = $observer->getEvent()->getProduct(); + $pId = $product->getId(); + $storeId = $product->getStoreId(); + + if ($observer->hasDate()) { + $date = $observer->getEvent()->getDate(); + } else { + $date = Mage::app()->getLocale()->storeTimeStamp($storeId); + } + + if ($observer->hasWebsiteId()) { + $wId = $observer->getEvent()->getWebsiteId(); + } else { + $wId = Mage::app()->getStore($storeId)->getWebsiteId(); + } + + if ($observer->hasCustomerGroupId()) { + $gId = $observer->getEvent()->getCustomerGroupId(); + } elseif ($product->hasCustomerGroupId()) { + $gId = $product->getCustomerGroupId(); + } else { + $gId = Mage::getSingleton('Mage_Customer_Model_Session')->getCustomerGroupId(); + } + + $key = "$date|$wId|$gId|$pId"; + if (!isset($this->_rulePrices[$key])) { + $rulePrice = Mage::getResourceModel('Mage_CatalogRule_Model_Resource_Rule') + ->getRulePrice($date, $wId, $gId, $pId); + $this->_rulePrices[$key] = $rulePrice; + } + if ($this->_rulePrices[$key]!==false) { + $finalPrice = min($product->getData('final_price'), $this->_rulePrices[$key]); + $product->setFinalPrice($finalPrice); + } + return $this; + } + + /** + * Apply catalog price rules to product in admin + * + * @param Varien_Event_Observer $observer + * + * @return Mage_CatalogRule_Model_Observer + */ + public function processAdminFinalPrice($observer) + { + $product = $observer->getEvent()->getProduct(); + $storeId = $product->getStoreId(); + $date = Mage::app()->getLocale()->storeDate($storeId); + $key = false; + + if ($ruleData = Mage::registry('rule_data')) { + $wId = $ruleData->getWebsiteId(); + $gId = $ruleData->getCustomerGroupId(); + $pId = $product->getId(); + + $key = "$date|$wId|$gId|$pId"; + } + elseif (!is_null($product->getWebsiteId()) && !is_null($product->getCustomerGroupId())) { + $wId = $product->getWebsiteId(); + $gId = $product->getCustomerGroupId(); + $pId = $product->getId(); + $key = "$date|$wId|$gId|$pId"; + } + + if ($key) { + if (!isset($this->_rulePrices[$key])) { + $rulePrice = Mage::getResourceModel('Mage_CatalogRule_Model_Resource_Rule') + ->getRulePrice($date, $wId, $gId, $pId); + $this->_rulePrices[$key] = $rulePrice; + } + if ($this->_rulePrices[$key]!==false) { + $finalPrice = min($product->getData('final_price'), $this->_rulePrices[$key]); + $product->setFinalPrice($finalPrice); + } + } + + return $this; + } + + /** + * Calculate price using catalog price rules of configurable product + * + * @param Varien_Event_Observer $observer + * + * @return Mage_CatalogRule_Model_Observer + */ + public function catalogProductTypeConfigurablePrice(Varien_Event_Observer $observer) + { + $product = $observer->getEvent()->getProduct(); + if ($product instanceof Mage_Catalog_Model_Product + && $product->getConfigurablePrice() !== null + ) { + $configurablePrice = $product->getConfigurablePrice(); + $productPriceRule = Mage::getModel('Mage_CatalogRule_Model_Rule') + ->calcProductPriceRule($product, $configurablePrice); + if ($productPriceRule !== null) { + $product->setConfigurablePrice($productPriceRule); + } + } + + return $this; + } + + /** + * Daily update catalog price rule by cron + * Update include interval 3 days - current day - 1 days before + 1 days after + * This method is called from cron process, cron is working in UTC time and + * we should generate data for interval -1 day ... +1 day + * + * @param Varien_Event_Observer $observer + * + * @return Mage_CatalogRule_Model_Observer + */ + public function dailyCatalogUpdate($observer) + { + Mage::getResourceSingleton('Mage_CatalogRule_Model_Resource_Rule')->applyAllRulesForDateRange(); + + return $this; + } + + /** + * Clean out calculated catalog rule prices for products + */ + public function flushPriceCache() + { + $this->_rulePrices = array(); + } + + /** + * Calculate minimal final price with catalog rule price + * + * @param Varien_Event_Observer $observer + * @return Mage_CatalogRule_Model_Observer + */ + public function prepareCatalogProductPriceIndexTable(Varien_Event_Observer $observer) + { + $select = $observer->getEvent()->getSelect(); + + $indexTable = $observer->getEvent()->getIndexTable(); + $entityId = $observer->getEvent()->getEntityId(); + $customerGroupId = $observer->getEvent()->getCustomerGroupId(); + $websiteId = $observer->getEvent()->getWebsiteId(); + $websiteDate = $observer->getEvent()->getWebsiteDate(); + $updateFields = $observer->getEvent()->getUpdateFields(); + + Mage::getSingleton('Mage_CatalogRule_Model_Rule_Product_Price') + ->applyPriceRuleToIndexTable($select, $indexTable, $entityId, $customerGroupId, $websiteId, + $updateFields, $websiteDate); + + return $this; + } + + /** + * Check rules that contains affected attribute + * If rules were found they will be set to inactive and notice will be add to admin session + * + * @param string $attributeCode + * + * @return Mage_CatalogRule_Model_Observer + */ + protected function _checkCatalogRulesAvailability($attributeCode) + { + /* @var $collection Mage_CatalogRule_Model_Resource_Rule_Collection */ + $collection = Mage::getResourceModel('Mage_CatalogRule_Model_Resource_Rule_Collection') + ->addAttributeInConditionFilter($attributeCode); + + $disabledRulesCount = 0; + foreach ($collection as $rule) { + /* @var $rule Mage_CatalogRule_Model_Rule */ + $rule->setIsActive(0); + /* @var $rule->getConditions() Mage_CatalogRule_Model_Rule_Condition_Combine */ + $this->_removeAttributeFromConditions($rule->getConditions(), $attributeCode); + $rule->save(); + + $disabledRulesCount++; + } + + if ($disabledRulesCount) { + Mage::getModel('Mage_CatalogRule_Model_Rule')->applyAll(); + Mage::getSingleton('Mage_Adminhtml_Model_Session')->addWarning( + Mage::helper('Mage_CatalogRule_Helper_Data')->__('%d Catalog Price Rules based on "%s" attribute have been disabled.', $disabledRulesCount, $attributeCode)); + } + + return $this; + } + + /** + * Remove catalog attribute condition by attribute code from rule conditions + * + * @param Mage_CatalogRule_Model_Rule_Condition_Combine $combine + * + * @param string $attributeCode + */ + protected function _removeAttributeFromConditions($combine, $attributeCode) + { + $conditions = $combine->getConditions(); + foreach ($conditions as $conditionId => $condition) { + if ($condition instanceof Mage_CatalogRule_Model_Rule_Condition_Combine) { + $this->_removeAttributeFromConditions($condition, $attributeCode); + } + if ($condition instanceof Mage_Rule_Model_Condition_Product_Abstract) { + if ($condition->getAttribute() == $attributeCode) { + unset($conditions[$conditionId]); + } + } + } + $combine->setConditions($conditions); + } + + /** + * After save attribute if it is not used for promo rules already check rules for containing this attribute + * + * @param Varien_Event_Observer $observer + * + * @return Mage_CatalogRule_Model_Observer + */ + public function catalogAttributeSaveAfter(Varien_Event_Observer $observer) + { + $attribute = $observer->getEvent()->getAttribute(); + if ($attribute->dataHasChangedFor('is_used_for_promo_rules') && !$attribute->getIsUsedForPromoRules()) { + $this->_checkCatalogRulesAvailability($attribute->getAttributeCode()); + } + + return $this; + } + + /** + * After delete attribute check rules that contains deleted attribute + * + * @param Varien_Event_Observer $observer + * @return Mage_CatalogRule_Model_Observer + */ + public function catalogAttributeDeleteAfter(Varien_Event_Observer $observer) + { + $attribute = $observer->getEvent()->getAttribute(); + if ($attribute->getIsUsedForPromoRules()) { + $this->_checkCatalogRulesAvailability($attribute->getAttributeCode()); + } + + return $this; + } + + public function prepareCatalogProductCollectionPrices(Varien_Event_Observer $observer) + { + /* @var $collection Mage_Catalog_Model_Resource_Product_Collection */ + $collection = $observer->getEvent()->getCollection(); + $store = Mage::app()->getStore($observer->getEvent()->getStoreId()); + $websiteId = $store->getWebsiteId(); + if ($observer->getEvent()->hasCustomerGroupId()) { + $groupId = $observer->getEvent()->getCustomerGroupId(); + } else { + /* @var $session Mage_Customer_Model_Session */ + $session = Mage::getSingleton('Mage_Customer_Model_Session'); + if ($session->isLoggedIn()) { + $groupId = Mage::getSingleton('Mage_Customer_Model_Session')->getCustomerGroupId(); + } else { + $groupId = Mage_Customer_Model_Group::NOT_LOGGED_IN_ID; + } + } + if ($observer->getEvent()->hasDate()) { + $date = $observer->getEvent()->getDate(); + } else { + $date = Mage::app()->getLocale()->storeTimeStamp($store); + } + + $productIds = array(); + /* @var $product Mage_Catalog_Model_Product */ + foreach ($collection as $product) { + $key = implode('|', array($date, $websiteId, $groupId, $product->getId())); + if (!isset($this->_rulePrices[$key])) { + $productIds[] = $product->getId(); + } + } + + if ($productIds) { + $rulePrices = Mage::getResourceModel('Mage_CatalogRule_Model_Resource_Rule') + ->getRulePrices($date, $websiteId, $groupId, $productIds); + foreach ($productIds as $productId) { + $key = implode('|', array($date, $websiteId, $groupId, $productId)); + $this->_rulePrices[$key] = isset($rulePrices[$productId]) ? $rulePrices[$productId] : false; + } + } + + return $this; + } + + /** + * Create catalog rule relations for imported products + * + * @param Varien_Event_Observer $observer + */ + public function createCatalogRulesRelations(Varien_Event_Observer $observer) + { + $adapter = $observer->getEvent()->getAdapter(); + $affectedEntityIds = $adapter->getAffectedEntityIds(); + + if (empty($affectedEntityIds)) { + return; + } + + $rules = Mage::getModel('Mage_CatalogRule_Model_Rule')->getCollection() + ->addFieldToFilter('is_active', 1); + + foreach ($rules as $rule) { + $rule->setProductsFilter($affectedEntityIds); + Mage::getResourceSingleton('Mage_CatalogRule_Model_Resource_Rule')->updateRuleProductData($rule); + } + } +} diff --git a/app/code/core/Mage/CatalogRule/Model/Resource/Rule.php b/app/code/Mage/CatalogRule/Model/Resource/Rule.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/CatalogRule/Model/Resource/Rule.php rename to app/code/Mage/CatalogRule/Model/Resource/Rule.php diff --git a/app/code/core/Mage/CatalogRule/Model/Resource/Rule/Collection.php b/app/code/Mage/CatalogRule/Model/Resource/Rule/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/CatalogRule/Model/Resource/Rule/Collection.php rename to app/code/Mage/CatalogRule/Model/Resource/Rule/Collection.php diff --git a/app/code/core/Mage/CatalogRule/Model/Resource/Rule/Product/Price.php b/app/code/Mage/CatalogRule/Model/Resource/Rule/Product/Price.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/CatalogRule/Model/Resource/Rule/Product/Price.php rename to app/code/Mage/CatalogRule/Model/Resource/Rule/Product/Price.php diff --git a/app/code/core/Mage/CatalogRule/Model/Resource/Rule/Product/Price/Collection.php b/app/code/Mage/CatalogRule/Model/Resource/Rule/Product/Price/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/CatalogRule/Model/Resource/Rule/Product/Price/Collection.php rename to app/code/Mage/CatalogRule/Model/Resource/Rule/Product/Price/Collection.php diff --git a/app/code/core/Mage/CatalogRule/Model/Rule.php b/app/code/Mage/CatalogRule/Model/Rule.php similarity index 100% rename from app/code/core/Mage/CatalogRule/Model/Rule.php rename to app/code/Mage/CatalogRule/Model/Rule.php diff --git a/app/code/core/Mage/CatalogRule/Model/Rule/Action/Collection.php b/app/code/Mage/CatalogRule/Model/Rule/Action/Collection.php similarity index 100% rename from app/code/core/Mage/CatalogRule/Model/Rule/Action/Collection.php rename to app/code/Mage/CatalogRule/Model/Rule/Action/Collection.php diff --git a/app/code/core/Mage/CatalogRule/Model/Rule/Action/Product.php b/app/code/Mage/CatalogRule/Model/Rule/Action/Product.php similarity index 100% rename from app/code/core/Mage/CatalogRule/Model/Rule/Action/Product.php rename to app/code/Mage/CatalogRule/Model/Rule/Action/Product.php diff --git a/app/code/core/Mage/CatalogRule/Model/Rule/Condition/Combine.php b/app/code/Mage/CatalogRule/Model/Rule/Condition/Combine.php similarity index 100% rename from app/code/core/Mage/CatalogRule/Model/Rule/Condition/Combine.php rename to app/code/Mage/CatalogRule/Model/Rule/Condition/Combine.php diff --git a/app/code/core/Mage/CatalogRule/Model/Rule/Condition/Product.php b/app/code/Mage/CatalogRule/Model/Rule/Condition/Product.php similarity index 100% rename from app/code/core/Mage/CatalogRule/Model/Rule/Condition/Product.php rename to app/code/Mage/CatalogRule/Model/Rule/Condition/Product.php diff --git a/app/code/core/Mage/CatalogRule/Model/Rule/Product/Price.php b/app/code/Mage/CatalogRule/Model/Rule/Product/Price.php similarity index 100% rename from app/code/core/Mage/CatalogRule/Model/Rule/Product/Price.php rename to app/code/Mage/CatalogRule/Model/Rule/Product/Price.php diff --git a/app/code/core/Mage/CatalogRule/data/catalogrule_setup/data-upgrade-1.6.0.3-1.6.0.4.php b/app/code/Mage/CatalogRule/data/catalogrule_setup/data-upgrade-1.6.0.3-1.6.0.4.php similarity index 100% rename from app/code/core/Mage/CatalogRule/data/catalogrule_setup/data-upgrade-1.6.0.3-1.6.0.4.php rename to app/code/Mage/CatalogRule/data/catalogrule_setup/data-upgrade-1.6.0.3-1.6.0.4.php diff --git a/app/code/Mage/CatalogRule/etc/adminhtml/acl.xml b/app/code/Mage/CatalogRule/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..32b9a0ec5f764 --- /dev/null +++ b/app/code/Mage/CatalogRule/etc/adminhtml/acl.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + diff --git a/app/code/Mage/CatalogRule/etc/adminhtml/menu.xml b/app/code/Mage/CatalogRule/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..962fc0eb4f4ac --- /dev/null +++ b/app/code/Mage/CatalogRule/etc/adminhtml/menu.xml @@ -0,0 +1,33 @@ + + + + + + + + diff --git a/app/code/Mage/CatalogRule/etc/config.xml b/app/code/Mage/CatalogRule/etc/config.xml new file mode 100644 index 0000000000000..c678671876683 --- /dev/null +++ b/app/code/Mage/CatalogRule/etc/config.xml @@ -0,0 +1,184 @@ + + + + + + 1.6.0.4 + true + + + + + + + + + + + + Mage_CatalogRule + + + + + + + + Mage_CatalogRule_Model_Observer + prepareCatalogProductPriceIndexTable + + + + + + + Mage_CatalogRule_Model_Observer + catalogProductTypeConfigurablePrice + + + + + + + + + + + + + + + + Mage_CatalogRule_Model_Observer + processFrontFinalPrice + + + + + + + Mage_CatalogRule_Model_Observer + prepareCatalogProductCollectionPrices + + + + + + + + + Mage_CatalogRule.csv + + + + + + + + + + + Mage_CatalogRule.csv + + + + + + + + + Mage_CatalogRule_Model_Observer + processAdminFinalPrice + + + + + + + Mage_CatalogRule_Model_Observer + applyAllRulesOnProduct + + + + + + + Mage_CatalogRule_Model_Observer + createCatalogRulesRelations + + + + + + + Mage_CatalogRule_Model_Observer + applyAllRules + + + + + + + Mage_CatalogRule_Model_Observer + catalogAttributeDeleteAfter + + + + + + + Mage_CatalogRule_Model_Observer + catalogAttributeSaveAfter + + + + + + + + + + 0 1 * * * + + + Mage_CatalogRule_Model_Observer::dailyCatalogUpdate + + + + + + + + Mage_CatalogRule_Model_Observer + processAdminFinalPrice + + + + + + diff --git a/app/code/core/Mage/CatalogRule/locale/de_DE/Mage_CatalogRule.csv b/app/code/Mage/CatalogRule/locale/de_DE/Mage_CatalogRule.csv similarity index 100% rename from app/code/core/Mage/CatalogRule/locale/de_DE/Mage_CatalogRule.csv rename to app/code/Mage/CatalogRule/locale/de_DE/Mage_CatalogRule.csv diff --git a/app/code/core/Mage/CatalogRule/locale/en_US/Mage_CatalogRule.csv b/app/code/Mage/CatalogRule/locale/en_US/Mage_CatalogRule.csv similarity index 100% rename from app/code/core/Mage/CatalogRule/locale/en_US/Mage_CatalogRule.csv rename to app/code/Mage/CatalogRule/locale/en_US/Mage_CatalogRule.csv diff --git a/app/code/core/Mage/CatalogRule/locale/es_ES/Mage_CatalogRule.csv b/app/code/Mage/CatalogRule/locale/es_ES/Mage_CatalogRule.csv similarity index 100% rename from app/code/core/Mage/CatalogRule/locale/es_ES/Mage_CatalogRule.csv rename to app/code/Mage/CatalogRule/locale/es_ES/Mage_CatalogRule.csv diff --git a/app/code/core/Mage/CatalogRule/locale/fr_FR/Mage_CatalogRule.csv b/app/code/Mage/CatalogRule/locale/fr_FR/Mage_CatalogRule.csv similarity index 100% rename from app/code/core/Mage/CatalogRule/locale/fr_FR/Mage_CatalogRule.csv rename to app/code/Mage/CatalogRule/locale/fr_FR/Mage_CatalogRule.csv diff --git a/app/code/core/Mage/CatalogRule/locale/nl_NL/Mage_CatalogRule.csv b/app/code/Mage/CatalogRule/locale/nl_NL/Mage_CatalogRule.csv similarity index 100% rename from app/code/core/Mage/CatalogRule/locale/nl_NL/Mage_CatalogRule.csv rename to app/code/Mage/CatalogRule/locale/nl_NL/Mage_CatalogRule.csv diff --git a/app/code/core/Mage/CatalogRule/locale/pt_BR/Mage_CatalogRule.csv b/app/code/Mage/CatalogRule/locale/pt_BR/Mage_CatalogRule.csv similarity index 100% rename from app/code/core/Mage/CatalogRule/locale/pt_BR/Mage_CatalogRule.csv rename to app/code/Mage/CatalogRule/locale/pt_BR/Mage_CatalogRule.csv diff --git a/app/code/core/Mage/CatalogRule/locale/zh_CN/Mage_CatalogRule.csv b/app/code/Mage/CatalogRule/locale/zh_CN/Mage_CatalogRule.csv similarity index 100% rename from app/code/core/Mage/CatalogRule/locale/zh_CN/Mage_CatalogRule.csv rename to app/code/Mage/CatalogRule/locale/zh_CN/Mage_CatalogRule.csv diff --git a/app/code/core/Mage/CatalogRule/sql/catalogrule_setup/install-1.6.0.0.php b/app/code/Mage/CatalogRule/sql/catalogrule_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/CatalogRule/sql/catalogrule_setup/install-1.6.0.0.php rename to app/code/Mage/CatalogRule/sql/catalogrule_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/CatalogRule/sql/catalogrule_setup/upgrade-1.6.0.0-1.6.0.1.php b/app/code/Mage/CatalogRule/sql/catalogrule_setup/upgrade-1.6.0.0-1.6.0.1.php similarity index 100% rename from app/code/core/Mage/CatalogRule/sql/catalogrule_setup/upgrade-1.6.0.0-1.6.0.1.php rename to app/code/Mage/CatalogRule/sql/catalogrule_setup/upgrade-1.6.0.0-1.6.0.1.php diff --git a/app/code/core/Mage/CatalogRule/sql/catalogrule_setup/upgrade-1.6.0.1-1.6.0.2.php b/app/code/Mage/CatalogRule/sql/catalogrule_setup/upgrade-1.6.0.1-1.6.0.2.php similarity index 100% rename from app/code/core/Mage/CatalogRule/sql/catalogrule_setup/upgrade-1.6.0.1-1.6.0.2.php rename to app/code/Mage/CatalogRule/sql/catalogrule_setup/upgrade-1.6.0.1-1.6.0.2.php diff --git a/app/code/core/Mage/CatalogRule/sql/catalogrule_setup/upgrade-1.6.0.2-1.6.0.3.php b/app/code/Mage/CatalogRule/sql/catalogrule_setup/upgrade-1.6.0.2-1.6.0.3.php similarity index 100% rename from app/code/core/Mage/CatalogRule/sql/catalogrule_setup/upgrade-1.6.0.2-1.6.0.3.php rename to app/code/Mage/CatalogRule/sql/catalogrule_setup/upgrade-1.6.0.2-1.6.0.3.php diff --git a/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php b/app/code/Mage/CatalogSearch/Block/Advanced/Form.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php rename to app/code/Mage/CatalogSearch/Block/Advanced/Form.php diff --git a/app/code/core/Mage/CatalogSearch/Block/Advanced/Result.php b/app/code/Mage/CatalogSearch/Block/Advanced/Result.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/Block/Advanced/Result.php rename to app/code/Mage/CatalogSearch/Block/Advanced/Result.php diff --git a/app/code/core/Mage/CatalogSearch/Block/Autocomplete.php b/app/code/Mage/CatalogSearch/Block/Autocomplete.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/Block/Autocomplete.php rename to app/code/Mage/CatalogSearch/Block/Autocomplete.php diff --git a/app/code/core/Mage/CatalogSearch/Block/Layer.php b/app/code/Mage/CatalogSearch/Block/Layer.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/Block/Layer.php rename to app/code/Mage/CatalogSearch/Block/Layer.php diff --git a/app/code/core/Mage/CatalogSearch/Block/Layer/Filter/Attribute.php b/app/code/Mage/CatalogSearch/Block/Layer/Filter/Attribute.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/Block/Layer/Filter/Attribute.php rename to app/code/Mage/CatalogSearch/Block/Layer/Filter/Attribute.php diff --git a/app/code/core/Mage/CatalogSearch/Block/Result.php b/app/code/Mage/CatalogSearch/Block/Result.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/Block/Result.php rename to app/code/Mage/CatalogSearch/Block/Result.php diff --git a/app/code/core/Mage/CatalogSearch/Block/Term.php b/app/code/Mage/CatalogSearch/Block/Term.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/Block/Term.php rename to app/code/Mage/CatalogSearch/Block/Term.php diff --git a/app/code/core/Mage/CatalogSearch/Helper/Data.php b/app/code/Mage/CatalogSearch/Helper/Data.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/Helper/Data.php rename to app/code/Mage/CatalogSearch/Helper/Data.php diff --git a/app/code/core/Mage/CatalogSearch/Model/Advanced.php b/app/code/Mage/CatalogSearch/Model/Advanced.php similarity index 88% rename from app/code/core/Mage/CatalogSearch/Model/Advanced.php rename to app/code/Mage/CatalogSearch/Model/Advanced.php index d098b8e6f5c2a..d1d9dbb90f997 100644 --- a/app/code/core/Mage/CatalogSearch/Model/Advanced.php +++ b/app/code/Mage/CatalogSearch/Model/Advanced.php @@ -27,7 +27,6 @@ /** * Catalog advanced search model * - * @method Mage_CatalogSearch_Model_Resource_Advanced _getResource() * @method Mage_CatalogSearch_Model_Resource_Advanced getResource() * @method int getEntityTypeId() * @method Mage_CatalogSearch_Model_Advanced setEntityTypeId(int $value) @@ -74,36 +73,30 @@ class Mage_CatalogSearch_Model_Advanced extends Mage_Core_Model_Abstract protected $_productCollection; /** - * Initialize resource model - * + * @var Mage_CatalogSearch_Helper_Data */ - protected function _construct() - { - $this->_getEngine(); - $this->_init('Mage_CatalogSearch_Model_Resource_Advanced'); - } - - protected function _getEngine() - { - if ($this->_engine == null) { - $this->_engine = Mage::helper('Mage_CatalogSearch_Helper_Data')->getEngine(); - } - - return $this->_engine; - } + protected $_helper; /** - * Retrieve resource instance wrapper + * Initialize dependencies * - * @return Mage_CatalogSearch_Model_Resource_Advanced + * @param Mage_Core_Model_Context $context + * @param Mage_CatalogSearch_Helper_Data $helper + * @param Mage_Core_Model_Resource_Abstract $resource + * @param Varien_Data_Collection_Db $resourceCollection + * @param array $data */ - protected function _getResource() - { - $resourceName = $this->_engine->getResourceName(); - if ($resourceName) { - $this->_resourceName = $resourceName; - } - return parent::_getResource(); + public function __construct( + Mage_Core_Model_Context $context, + Mage_CatalogSearch_Helper_Data $helper, + Mage_Core_Model_Resource_Abstract $resource = null, + Varien_Data_Collection_Db $resourceCollection = null, + array $data = array() + ) { + $this->_helper = $helper; + $this->_engine = $helper->getEngine(); + $this->_setResourceModel($this->_engine->getResourceName()); + parent::__construct($context, $resource, $resourceCollection, $data); } /** @@ -136,6 +129,7 @@ public function getAttributes() * * @param array $values * @return Mage_CatalogSearch_Model_Advanced + * @throws Mage_Core_Exception */ public function addFilters($values) { @@ -194,7 +188,7 @@ public function addFilters($values) if ($allConditions) { $this->getProductCollection()->addFieldsToFilter($allConditions); } else if (!$hasConditions) { - Mage::throwException(Mage::helper('Mage_CatalogSearch_Helper_Data')->__('Please specify at least one search term.')); + throw new Mage_Core_Exception($this->_helper->__('Please specify at least one search term.')); } return $this; @@ -215,6 +209,7 @@ protected function _addSearchCriteria($attribute, $value) if (isset($value['from']) && isset($value['to'])) { if (!empty($value['from']) || !empty($value['to'])) { if (isset($value['currency'])) { + /** @var $currencyModel Mage_Directory_Model_Currency */ $currencyModel = Mage::getModel('Mage_Directory_Model_Currency')->load($value['currency']); $from = $currencyModel->format($value['from'], array(), false); $to = $currencyModel->format($value['to'], array(), false); @@ -228,10 +223,10 @@ protected function _addSearchCriteria($attribute, $value) ($currencyModel ? $from : $value['from']), ($currencyModel ? $to : $value['to'])); } elseif (strlen($value['from']) > 0) { // and more - $value = Mage::helper('Mage_CatalogSearch_Helper_Data')->__('%s and greater', ($currencyModel ? $from : $value['from'])); + $value = $this->_helper->__('%s and greater', ($currencyModel ? $from : $value['from'])); } elseif (strlen($value['to']) > 0) { // to - $value = Mage::helper('Mage_CatalogSearch_Helper_Data')->__('up to %s', ($currencyModel ? $to : $value['to'])); + $value = $this->_helper->__('up to %s', ($currencyModel ? $to : $value['to'])); } } else { return $this; @@ -256,8 +251,8 @@ protected function _addSearchCriteria($attribute, $value) $value = $value['label']; } else if ($attribute->getFrontendInput() == 'boolean') { $value = $value == 1 - ? Mage::helper('Mage_CatalogSearch_Helper_Data')->__('Yes') - : Mage::helper('Mage_CatalogSearch_Helper_Data')->__('No'); + ? $this->_helper->__('Yes') + : $this->_helper->__('No'); } $this->_searchCriterias[] = array('name' => $name, 'value' => $value); diff --git a/app/code/core/Mage/CatalogSearch/Model/Config/Backend/Search/Type.php b/app/code/Mage/CatalogSearch/Model/Config/Backend/Search/Type.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/Model/Config/Backend/Search/Type.php rename to app/code/Mage/CatalogSearch/Model/Config/Backend/Search/Type.php diff --git a/app/code/core/Mage/CatalogSearch/Model/Config/Source/Search/Type.php b/app/code/Mage/CatalogSearch/Model/Config/Source/Search/Type.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/Model/Config/Source/Search/Type.php rename to app/code/Mage/CatalogSearch/Model/Config/Source/Search/Type.php diff --git a/app/code/core/Mage/CatalogSearch/Model/Fulltext.php b/app/code/Mage/CatalogSearch/Model/Fulltext.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/Model/Fulltext.php rename to app/code/Mage/CatalogSearch/Model/Fulltext.php diff --git a/app/code/Mage/CatalogSearch/Model/Fulltext/Observer.php b/app/code/Mage/CatalogSearch/Model/Fulltext/Observer.php new file mode 100644 index 0000000000000..75f33130f18d8 --- /dev/null +++ b/app/code/Mage/CatalogSearch/Model/Fulltext/Observer.php @@ -0,0 +1,196 @@ + + */ +class Mage_CatalogSearch_Model_Fulltext_Observer +{ + /** + * Retrieve fulltext (indexer) model + * + * @return Mage_CatalogSearch_Model_Fulltext + */ + protected function _getFulltextModel() + { + return Mage::getSingleton('Mage_CatalogSearch_Model_Fulltext'); + } + + /** + * Update product index when product data updated + * + * @deprecated since 1.11 + * @param Varien_Event_Observer $observer + * @return Mage_CatalogSearch_Model_Fulltext_Observer + */ + public function refreshProductIndex(Varien_Event_Observer $observer) + { + $product = $observer->getEvent()->getProduct(); + + $this->_getFulltextModel() + ->rebuildIndex(null, $product->getId()) + ->resetSearchResults(); + + return $this; + } + + /** + * Clean product index when product deleted or marked as unsearchable/invisible + * + * @deprecated since 1.11 + * @param Varien_Event_Observer $observer + * @return Mage_CatalogSearch_Model_Fulltext_Observer + */ + public function cleanProductIndex(Varien_Event_Observer $observer) + { + $product = $observer->getEvent()->getProduct(); + + $this->_getFulltextModel() + ->cleanIndex(null, $product->getId()) + ->resetSearchResults(); + + return $this; + } + + /** + * Update all attribute-dependant index + * + * @param Varien_Event_Observer $observer + * @return Mage_CatalogSearch_Model_Fulltext_Observer + */ + public function eavAttributeChange(Varien_Event_Observer $observer) + { + $attribute = $observer->getEvent()->getAttribute(); + /* @var $attribute Mage_Eav_Model_Entity_Attribute */ + $entityType = Mage::getSingleton('Mage_Eav_Model_Config')->getEntityType(Mage_Catalog_Model_Product::ENTITY); + /* @var $entityType Mage_Eav_Model_Entity_Type */ + + if ($attribute->getEntityTypeId() != $entityType->getId()) { + return $this; + } + $delete = $observer->getEventName() == 'eav_entity_attribute_delete_after'; + + if (!$delete && !$attribute->dataHasChangedFor('is_searchable')) { + return $this; + } + + $showNotice = false; + if ($delete) { + if ($attribute->getIsSearchable()) { + $showNotice = true; + } + } + elseif ($attribute->dataHasChangedFor('is_searchable')) { + $showNotice = true; + } + + if ($showNotice) { + $url = Mage::getSingleton('Mage_Backend_Model_Url')->getUrl('adminhtml/system_cache'); + Mage::getSingleton('Mage_Adminhtml_Model_Session')->addNotice( + Mage::helper('Mage_CatalogSearch_Helper_Data')->__('Attribute setting change related with Search Index. Please run Rebuild Search Index process.', $url) + ); + } + + return $this; + } + + /** + * Rebuild index after import + * + * @return Mage_CatalogSearch_Model_Fulltext_Observer + */ + public function refreshIndexAfterImport() + { + $this->_getFulltextModel() + ->rebuildIndex(); + return $this; + } + + /** + * Refresh fulltext index when we add new store + * + * @param Varien_Event_Observer $observer + * @return Mage_CatalogSearch_Model_Fulltext_Observer + */ + public function refreshStoreIndex(Varien_Event_Observer $observer) + { + $storeId = $observer->getEvent()->getStore()->getId(); + $this->_getFulltextModel()->rebuildIndex($storeId); + return $this; + } + + /** + * Catalog Product mass website update + * + * @deprecated since 1.11 + * @param Varien_Event_Observer $observer + * @return Mage_CatalogSearch_Model_Fulltext_Observer + */ + public function catalogProductWebsiteUpdate(Varien_Event_Observer $observer) + { + $websiteIds = $observer->getEvent()->getWebsiteIds(); + $productIds = $observer->getEvent()->getProductIds(); + $actionType = $observer->getEvent()->getAction(); + + foreach ($websiteIds as $websiteId) { + foreach (Mage::app()->getWebsite($websiteId)->getStoreIds() as $storeId) { + if ($actionType == 'remove') { + $this->_getFulltextModel() + ->cleanIndex($storeId, $productIds) + ->resetSearchResults(); + } + elseif ($actionType == 'add') { + $this->_getFulltextModel() + ->rebuildIndex($storeId, $productIds) + ->resetSearchResults(); + } + } + } + + return $this; + } + + /** + * Store delete processing + * + * @param Varien_Event_Observer $observer + * @return Mage_CatalogSearch_Model_Fulltext_Observer + */ + public function cleanStoreIndex(Varien_Event_Observer $observer) + { + $store = $observer->getEvent()->getStore(); + /* @var $store Mage_Core_Model_Store */ + + $this->_getFulltextModel() + ->cleanIndex($store->getId()); + + return $this; + } +} diff --git a/app/code/Mage/CatalogSearch/Model/Indexer/Fulltext.php b/app/code/Mage/CatalogSearch/Model/Indexer/Fulltext.php new file mode 100644 index 0000000000000..ce66911155055 --- /dev/null +++ b/app/code/Mage/CatalogSearch/Model/Indexer/Fulltext.php @@ -0,0 +1,445 @@ + array( + Mage_Index_Model_Event::TYPE_SAVE, + Mage_Index_Model_Event::TYPE_MASS_ACTION, + Mage_Index_Model_Event::TYPE_DELETE + ), + Mage_Catalog_Model_Resource_Eav_Attribute::ENTITY => array( + Mage_Index_Model_Event::TYPE_SAVE, + Mage_Index_Model_Event::TYPE_DELETE, + ), + Mage_Core_Model_Store::ENTITY => array( + Mage_Index_Model_Event::TYPE_SAVE, + Mage_Index_Model_Event::TYPE_DELETE + ), + Mage_Core_Model_Store_Group::ENTITY => array( + Mage_Index_Model_Event::TYPE_SAVE + ), + Mage_Core_Model_Config_Data::ENTITY => array( + Mage_Index_Model_Event::TYPE_SAVE + ), + Mage_Catalog_Model_Category::ENTITY => array( + Mage_Index_Model_Event::TYPE_SAVE + ) + ); + + /** + * Related Configuration Settings for match + * + * @var array + */ + protected $_relatedConfigSettings = array( + Mage_CatalogSearch_Model_Fulltext::XML_PATH_CATALOG_SEARCH_TYPE + ); + + /** + * Retrieve Fulltext Search instance + * + * @return Mage_CatalogSearch_Model_Fulltext + */ + protected function _getIndexer() + { + return Mage::getSingleton('Mage_CatalogSearch_Model_Fulltext'); + } + + /** + * Retrieve Indexer name + * + * @return string + */ + public function getName() + { + return Mage::helper('Mage_CatalogSearch_Helper_Data')->__('Catalog Search'); + } + + /** + * Retrieve Indexer description + * + * @return string + */ + public function getDescription() + { + return Mage::helper('Mage_CatalogSearch_Helper_Data')->__('Rebuild Catalog product fulltext search index'); + } + + /** + * Check if event can be matched by process + * Overwrote for check is flat catalog product is enabled and specific save + * attribute, store, store_group + * + * @param Mage_Index_Model_Event $event + * @return bool + */ + public function matchEvent(Mage_Index_Model_Event $event) + { + $data = $event->getNewData(); + if (isset($data[self::EVENT_MATCH_RESULT_KEY])) { + return $data[self::EVENT_MATCH_RESULT_KEY]; + } + + $entity = $event->getEntity(); + if ($entity == Mage_Catalog_Model_Resource_Eav_Attribute::ENTITY) { + /* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */ + $attribute = $event->getDataObject(); + + if (!$attribute) { + $result = false; + } elseif ($event->getType() == Mage_Index_Model_Event::TYPE_SAVE) { + $result = $attribute->dataHasChangedFor('is_searchable'); + } elseif ($event->getType() == Mage_Index_Model_Event::TYPE_DELETE) { + $result = $attribute->getIsSearchable(); + } else { + $result = false; + } + } else if ($entity == Mage_Core_Model_Store::ENTITY) { + if ($event->getType() == Mage_Index_Model_Event::TYPE_DELETE) { + $result = true; + } else { + /* @var $store Mage_Core_Model_Store */ + $store = $event->getDataObject(); + if ($store && $store->isObjectNew()) { + $result = true; + } else { + $result = false; + } + } + } else if ($entity == Mage_Core_Model_Store_Group::ENTITY) { + /* @var $storeGroup Mage_Core_Model_Store_Group */ + $storeGroup = $event->getDataObject(); + if ($storeGroup && $storeGroup->dataHasChangedFor('website_id')) { + $result = true; + } else { + $result = false; + } + } else if ($entity == Mage_Core_Model_Config_Data::ENTITY) { + $data = $event->getDataObject(); + if ($data && in_array($data->getPath(), $this->_relatedConfigSettings)) { + $result = $data->isValueChanged(); + } else { + $result = false; + } + } else { + $result = parent::matchEvent($event); + } + + $event->addNewData(self::EVENT_MATCH_RESULT_KEY, $result); + + return $result; + } + + /** + * Register data required by process in event object + * + * @param Mage_Index_Model_Event $event + */ + protected function _registerEvent(Mage_Index_Model_Event $event) + { + $event->addNewData(self::EVENT_MATCH_RESULT_KEY, true); + switch ($event->getEntity()) { + case Mage_Catalog_Model_Product::ENTITY: + $this->_registerCatalogProductEvent($event); + break; + + case Mage_Core_Model_Config_Data::ENTITY: + case Mage_Core_Model_Store::ENTITY: + case Mage_Catalog_Model_Resource_Eav_Attribute::ENTITY: + case Mage_Core_Model_Store_Group::ENTITY: + $event->addNewData('catalogsearch_fulltext_skip_call_event_handler', true); + $process = $event->getProcess(); + $process->changeStatus(Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX); + break; + case Mage_Catalog_Model_Category::ENTITY: + $this->_registerCatalogCategoryEvent($event); + break; + default: + break; + } + } + + /** + * Get data required for category'es products reindex + * + * @param Mage_Index_Model_Event $event + * @return Mage_CatalogSearch_Model_Indexer_Search + */ + protected function _registerCatalogCategoryEvent(Mage_Index_Model_Event $event) + { + switch ($event->getType()) { + case Mage_Index_Model_Event::TYPE_SAVE: + /* @var $category Mage_Catalog_Model_Category */ + $category = $event->getDataObject(); + $productIds = $category->getAffectedProductIds(); + if ($productIds) { + $event->addNewData('catalogsearch_category_update_product_ids', $productIds); + $event->addNewData('catalogsearch_category_update_category_ids', array($category->getId())); + } else { + $movedCategoryId = $category->getMovedCategoryId(); + if ($movedCategoryId) { + $event->addNewData('catalogsearch_category_update_product_ids', array()); + $event->addNewData('catalogsearch_category_update_category_ids', array($movedCategoryId)); + } + } + break; + default: + break; + } + + return $this; + } + + /** + * Register data required by catatalog product process in event object + * + * @param Mage_Index_Model_Event $event + * @return Mage_CatalogSearch_Model_Indexer_Search + */ + protected function _registerCatalogProductEvent(Mage_Index_Model_Event $event) + { + switch ($event->getType()) { + case Mage_Index_Model_Event::TYPE_SAVE: + /* @var $product Mage_Catalog_Model_Product */ + $product = $event->getDataObject(); + + $event->addNewData('catalogsearch_update_product_id', $product->getId()); + break; + case Mage_Index_Model_Event::TYPE_DELETE: + /* @var $product Mage_Catalog_Model_Product */ + $product = $event->getDataObject(); + + $event->addNewData('catalogsearch_delete_product_id', $product->getId()); + break; + case Mage_Index_Model_Event::TYPE_MASS_ACTION: + /* @var $actionObject Varien_Object */ + $actionObject = $event->getDataObject(); + + $reindexData = array(); + $rebuildIndex = false; + + // check if status changed + $attrData = $actionObject->getAttributesData(); + if (isset($attrData['status'])) { + $rebuildIndex = true; + $reindexData['catalogsearch_status'] = $attrData['status']; + } + + // check changed websites + if ($actionObject->getWebsiteIds()) { + $rebuildIndex = true; + $reindexData['catalogsearch_website_ids'] = $actionObject->getWebsiteIds(); + $reindexData['catalogsearch_action_type'] = $actionObject->getActionType(); + } + + $searchableAttributes = array(); + if (is_array($attrData)) { + $searchableAttributes = array_intersect($this->_getSearchableAttributes(), array_keys($attrData)); + } + + if (count($searchableAttributes) > 0) { + $rebuildIndex = true; + $reindexData['catalogsearch_force_reindex'] = true; + } + + // register affected products + if ($rebuildIndex) { + $reindexData['catalogsearch_product_ids'] = $actionObject->getProductIds(); + foreach ($reindexData as $k => $v) { + $event->addNewData($k, $v); + } + } + break; + default: + break; + } + + return $this; + } + + /** + * Retrieve searchable attributes list + * + * @return array + */ + protected function _getSearchableAttributes() + { + if (is_null($this->_searchableAttributes)) { + /** @var $attributeCollection Mage_Catalog_Model_Resource_Product_Attribute_Collection */ + $attributeCollection = Mage::getResourceModel('Mage_Catalog_Model_Resource_Product_Attribute_Collection'); + $attributeCollection->addIsSearchableFilter(); + + foreach ($attributeCollection as $attribute) { + $this->_searchableAttributes[] = $attribute->getAttributeCode(); + } + } + + return $this->_searchableAttributes; + } + + /** + * Check if product is composite + * + * @param int $productId + * @return bool + */ + protected function _isProductComposite($productId) + { + $product = Mage::getModel('Mage_Catalog_Model_Product')->load($productId); + return $product->isComposite(); + } + + /** + * Process event + * + * @param Mage_Index_Model_Event $event + */ + protected function _processEvent(Mage_Index_Model_Event $event) + { + $data = $event->getNewData(); + + if (!empty($data['catalogsearch_fulltext_reindex_all'])) { + $this->reindexAll(); + } else if (!empty($data['catalogsearch_delete_product_id'])) { + $productId = $data['catalogsearch_delete_product_id']; + + if (!$this->_isProductComposite($productId)) { + $parentIds = $this->_getResource()->getRelationsByChild($productId); + if (!empty($parentIds)) { + $this->_getIndexer()->rebuildIndex(null, $parentIds); + } + } + + $this->_getIndexer()->cleanIndex(null, $productId) + ->getResource()->resetSearchResults(null, $productId); + } else if (!empty($data['catalogsearch_update_product_id'])) { + $productId = $data['catalogsearch_update_product_id']; + $productIds = array($productId); + + if (!$this->_isProductComposite($productId)) { + $parentIds = $this->_getResource()->getRelationsByChild($productId); + if (!empty($parentIds)) { + $productIds = array_merge($productIds, $parentIds); + } + } + + $this->_getIndexer()->rebuildIndex(null, $productIds); + } else if (!empty($data['catalogsearch_product_ids'])) { + // mass action + $productIds = $data['catalogsearch_product_ids']; + + if (!empty($data['catalogsearch_website_ids'])) { + $websiteIds = $data['catalogsearch_website_ids']; + $actionType = $data['catalogsearch_action_type']; + + foreach ($websiteIds as $websiteId) { + foreach (Mage::app()->getWebsite($websiteId)->getStoreIds() as $storeId) { + if ($actionType == 'remove') { + $this->_getIndexer() + ->cleanIndex($storeId, $productIds) + ->getResource()->resetSearchResults($storeId, $productIds); + } else if ($actionType == 'add') { + $this->_getIndexer() + ->rebuildIndex($storeId, $productIds); + } + } + } + } + if (isset($data['catalogsearch_status'])) { + $status = $data['catalogsearch_status']; + if ($status == Mage_Catalog_Model_Product_Status::STATUS_ENABLED) { + $this->_getIndexer() + ->rebuildIndex(null, $productIds); + } else { + $this->_getIndexer() + ->cleanIndex(null, $productIds) + ->getResource()->resetSearchResults(null, $productIds); + } + } + if (isset($data['catalogsearch_force_reindex'])) { + $this->_getIndexer() + ->rebuildIndex(null, $productIds) + ->resetSearchResults(); + } + } else if (isset($data['catalogsearch_category_update_product_ids'])) { + $productIds = $data['catalogsearch_category_update_product_ids']; + $categoryIds = $data['catalogsearch_category_update_category_ids']; + + $this->_getIndexer() + ->updateCategoryIndex($productIds, $categoryIds); + } + } + + /** + * Rebuild all index data + * + */ + public function reindexAll() + { + $resourceModel = $this->_getIndexer()->getResource(); + $resourceModel->beginTransaction(); + try { + $this->_getIndexer()->rebuildIndex(); + $resourceModel->commit(); + } catch (Exception $e) { + $resourceModel->rollBack(); + throw $e; + } + } +} diff --git a/app/code/core/Mage/CatalogSearch/Model/Layer.php b/app/code/Mage/CatalogSearch/Model/Layer.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/Model/Layer.php rename to app/code/Mage/CatalogSearch/Model/Layer.php diff --git a/app/code/core/Mage/CatalogSearch/Model/Layer/Filter/Attribute.php b/app/code/Mage/CatalogSearch/Model/Layer/Filter/Attribute.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/Model/Layer/Filter/Attribute.php rename to app/code/Mage/CatalogSearch/Model/Layer/Filter/Attribute.php diff --git a/app/code/core/Mage/CatalogSearch/Model/Query.php b/app/code/Mage/CatalogSearch/Model/Query.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/Model/Query.php rename to app/code/Mage/CatalogSearch/Model/Query.php diff --git a/app/code/core/Mage/CatalogSearch/Model/Resource/Advanced.php b/app/code/Mage/CatalogSearch/Model/Resource/Advanced.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/CatalogSearch/Model/Resource/Advanced.php rename to app/code/Mage/CatalogSearch/Model/Resource/Advanced.php diff --git a/app/code/core/Mage/CatalogSearch/Model/Resource/Advanced/Collection.php b/app/code/Mage/CatalogSearch/Model/Resource/Advanced/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/CatalogSearch/Model/Resource/Advanced/Collection.php rename to app/code/Mage/CatalogSearch/Model/Resource/Advanced/Collection.php diff --git a/app/code/Mage/CatalogSearch/Model/Resource/Fulltext.php b/app/code/Mage/CatalogSearch/Model/Resource/Fulltext.php new file mode 100644 index 0000000000000..5d81898348713 --- /dev/null +++ b/app/code/Mage/CatalogSearch/Model/Resource/Fulltext.php @@ -0,0 +1,830 @@ + + */ +class Mage_CatalogSearch_Model_Resource_Fulltext extends Mage_Core_Model_Resource_Db_Abstract +{ + /** + * Searchable attributes cache + * + * @var array + */ + protected $_searchableAttributes = null; + + /** + * Index values separator + * + * @var string + */ + protected $_separator = '|'; + + /** + * Array of Zend_Date objects per store + * + * @var array + */ + protected $_dates = array(); + + /** + * Product Type Instances cache + * + * @var array + */ + protected $_productTypes = array(); + + /** + * Product Emulators cache + * + * @var array + */ + protected $_productEmulators = array(); + + /** + * Store search engine instance + * + * @var object + */ + protected $_engine = null; + + /** + * Init resource model + * + */ + protected function _construct() + { + $this->_init('catalogsearch_fulltext', 'product_id'); + $this->_engine = Mage::helper('Mage_CatalogSearch_Helper_Data')->getEngine(); + } + + /** + * Return options separator + * + * @return string + */ + public function getSeparator() + { + return $this->_separator; + } + + /** + * Regenerate search index for store(s) + * + * @param int|null $storeId + * @param int|array|null $productIds + * @return Mage_CatalogSearch_Model_Resource_Fulltext + */ + public function rebuildIndex($storeId = null, $productIds = null) + { + if (is_null($storeId)) { + $storeIds = array_keys(Mage::app()->getStores()); + foreach ($storeIds as $storeId) { + $this->_rebuildStoreIndex($storeId, $productIds); + } + } else { + $this->_rebuildStoreIndex($storeId, $productIds); + } + + return $this; + } + + /** + * Regenerate search index for specific store + * + * @param int $storeId Store View Id + * @param int|array $productIds Product Entity Id + * @return Mage_CatalogSearch_Model_Resource_Fulltext + */ + protected function _rebuildStoreIndex($storeId, $productIds = null) + { + $this->cleanIndex($storeId, $productIds); + + // prepare searchable attributes + $staticFields = array(); + foreach ($this->_getSearchableAttributes('static') as $attribute) { + $staticFields[] = $attribute->getAttributeCode(); + } + $dynamicFields = array( + 'int' => array_keys($this->_getSearchableAttributes('int')), + 'varchar' => array_keys($this->_getSearchableAttributes('varchar')), + 'text' => array_keys($this->_getSearchableAttributes('text')), + 'decimal' => array_keys($this->_getSearchableAttributes('decimal')), + 'datetime' => array_keys($this->_getSearchableAttributes('datetime')), + ); + + // status and visibility filter + $visibility = $this->_getSearchableAttribute('visibility'); + $status = $this->_getSearchableAttribute('status'); + $statusVals = Mage::getSingleton('Mage_Catalog_Model_Product_Status')->getVisibleStatusIds(); + $allowedVisibility = $this->_engine->getAllowedVisibility(); + + $lastProductId = 0; + while (true) { + $products = $this->_getSearchableProducts($storeId, $staticFields, $productIds, $lastProductId); + if (!$products) { + break; + } + + $productAttributes = array(); + $productRelations = array(); + foreach ($products as $productData) { + $lastProductId = $productData['entity_id']; + $productAttributes[$productData['entity_id']] = $productData['entity_id']; + $productChildren = $this->_getProductChildIds($productData['entity_id'], $productData['type_id']); + $productRelations[$productData['entity_id']] = $productChildren; + if ($productChildren) { + foreach ($productChildren as $productChildId) { + $productAttributes[$productChildId] = $productChildId; + } + } + } + + $productIndexes = array(); + $productAttributes = $this->_getProductAttributes($storeId, $productAttributes, $dynamicFields); + foreach ($products as $productData) { + if (!isset($productAttributes[$productData['entity_id']])) { + continue; + } + + $productAttr = $productAttributes[$productData['entity_id']]; + if (!isset($productAttr[$visibility->getId()]) + || !in_array($productAttr[$visibility->getId()], $allowedVisibility) + ) { + continue; + } + if (!isset($productAttr[$status->getId()]) || !in_array($productAttr[$status->getId()], $statusVals)) { + continue; + } + + $productIndex = array( + $productData['entity_id'] => $productAttr + ); + + $productChildren = $productRelations[$productData['entity_id']]; + if ($productChildren) { + foreach ($productChildren as $productChildId) { + if (isset($productAttributes[$productChildId])) { + $productIndex[$productChildId] = $productAttributes[$productChildId]; + } + } + } + + $index = $this->_prepareProductIndex($productIndex, $productData, $storeId); + + $productIndexes[$productData['entity_id']] = $index; + } + + $this->_saveProductIndexes($storeId, $productIndexes); + } + + // Reset only product-specific queries and results. + $this->resetSearchResults($storeId, $productIds); + + return $this; + } + + /** + * Retrieve searchable products per store + * + * @param int $storeId + * @param array $staticFields + * @param array|int $productIds + * @param int $lastProductId + * @param int $limit + * @return array + */ + protected function _getSearchableProducts($storeId, array $staticFields, $productIds = null, $lastProductId = 0, + $limit = 100 + ) { + $websiteId = Mage::app()->getStore($storeId)->getWebsiteId(); + $writeAdapter = $this->_getWriteAdapter(); + + $select = $writeAdapter->select() + ->useStraightJoin(true) + ->from( + array('e' => $this->getTable('catalog_product_entity')), + array_merge(array('entity_id', 'type_id'), $staticFields) + ) + ->join( + array('website' => $this->getTable('catalog_product_website')), + $writeAdapter->quoteInto( + 'website.product_id=e.entity_id AND website.website_id=?', + $websiteId + ), + array() + ) + ->join( + array('stock_status' => $this->getTable('cataloginventory_stock_status')), + $writeAdapter->quoteInto( + 'stock_status.product_id=e.entity_id AND stock_status.website_id=?', + $websiteId + ), + array('in_stock' => 'stock_status') + ); + + if (!is_null($productIds)) { + $select->where('e.entity_id IN(?)', $productIds); + } + + $select->where('e.entity_id>?', $lastProductId) + ->limit($limit) + ->order('e.entity_id'); + + $result = $writeAdapter->fetchAll($select); + + return $result; + } + + /** + * Reset search results + * + * @param null|int $storeId + * @param null|array $productIds + * @return Mage_CatalogSearch_Model_Resource_Fulltext + */ + public function resetSearchResults($storeId = null, $productIds = null) + { + $adapter = $this->_getWriteAdapter(); + $adapter->update($this->getTable('catalogsearch_query'), array('is_processed' => 0)); + + if ($storeId === null && $productIds === null) { + // Keeping public interface + $adapter->update($this->getTable('catalogsearch_query'), array('is_processed' => 0)); + $adapter->truncateTable($this->getTable('catalogsearch_result')); + Mage::dispatchEvent('catalogsearch_reset_search_result'); + } else { + // Optimized deletion only product-related records + /** @var $select Varien_Db_Select */ + $select = $adapter->select() + ->from(array('r' => $this->getTable('catalogsearch_result')), null) + ->join( + array('q' => $this->getTable('catalogsearch_query')), + 'q.query_id=r.query_id', + array() + ) + ->join( + array('res' => $this->getTable('catalogsearch_result')), + 'q.query_id=res.query_id', + array() + ); + if (!empty($storeId)) { + $select->where('q.store_id = ?', $storeId); + } + if (!empty($productIds)) { + $select->where('r.product_id IN(?)', $productIds); + } + $query = $select->deleteFromSelect('res'); + $adapter->query($query); + + /** @var $select Varien_Db_Select */ + $select = $adapter->select(); + $subSelect = $adapter->select()->from(array('res' => $this->getTable('catalogsearch_result')), null); + $select->exists($subSelect, 'res.query_id=' . $this->getTable('catalogsearch_query') . '.query_id', false); + + $adapter->update( + $this->getTable('catalogsearch_query'), + array('is_processed' => 0), + $select->getPart(Zend_Db_Select::WHERE) + ); + } + + return $this; + } + + /** + * Delete search index data for store + * + * @param int $storeId Store View Id + * @param int $productId Product Entity Id + * @return Mage_CatalogSearch_Model_Resource_Fulltext + */ + public function cleanIndex($storeId = null, $productId = null) + { + if ($this->_engine) { + $this->_engine->cleanIndex($storeId, $productId); + } + + return $this; + } + + /** + * Prepare results for query + * + * @param Mage_CatalogSearch_Model_Fulltext $object + * @param string $queryText + * @param Mage_CatalogSearch_Model_Query $query + * @return Mage_CatalogSearch_Model_Resource_Fulltext + */ + public function prepareResult($object, $queryText, $query) + { + $adapter = $this->_getWriteAdapter(); + if (!$query->getIsProcessed()) { + $searchType = $object->getSearchType($query->getStoreId()); + + $preparedTerms = Mage::getResourceHelper('Mage_CatalogSearch') + ->prepareTerms($queryText, $query->getMaxQueryWords()); + + $bind = array(); + $like = array(); + $likeCond = ''; + if ($searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_LIKE + || $searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_COMBINE + ) { + $helper = Mage::getResourceHelper('Mage_Core'); + $words = Mage::helper('Mage_Core_Helper_String') + ->splitWords($queryText, true, $query->getMaxQueryWords()); + foreach ($words as $word) { + $like[] = $helper->getCILike('s.data_index', $word, array('position' => 'any')); + } + if ($like) { + $likeCond = '(' . join(' OR ', $like) . ')'; + } + } + $mainTableAlias = 's'; + $fields = array( + 'query_id' => new Zend_Db_Expr($query->getId()), + 'product_id', + ); + $select = $adapter->select() + ->from(array($mainTableAlias => $this->getMainTable()), $fields) + ->joinInner(array('e' => $this->getTable('catalog_product_entity')), + 'e.entity_id = s.product_id', + array()) + ->where($mainTableAlias.'.store_id = ?', (int)$query->getStoreId()); + + if ($searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_FULLTEXT + || $searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_COMBINE + ) { + $bind[':query'] = implode(' ', $preparedTerms[0]); + $where = Mage::getResourceHelper('Mage_CatalogSearch') + ->chooseFulltext($this->getMainTable(), $mainTableAlias, $select); + } + + if ($likeCond != '' && $searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_COMBINE) { + $where .= ($where ? ' OR ' : '') . $likeCond; + } elseif ($likeCond != '' && $searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_LIKE) { + $select->columns(array('relevance' => new Zend_Db_Expr(0))); + $where = $likeCond; + } + + if ($where != '') { + $select->where($where); + } + + $sql = $adapter->insertFromSelect($select, + $this->getTable('catalogsearch_result'), + array(), + Varien_Db_Adapter_Interface::INSERT_ON_DUPLICATE); + $adapter->query($sql, $bind); + + $query->setIsProcessed(1); + } + + return $this; + } + + /** + * Retrieve EAV Config Singleton + * + * @return Mage_Eav_Model_Config + */ + public function getEavConfig() + { + return Mage::getSingleton('Mage_Eav_Model_Config'); + } + + /** + * Retrieve searchable attributes + * + * @param string $backendType + * @return array + */ + protected function _getSearchableAttributes($backendType = null) + { + if (null === $this->_searchableAttributes) { + $this->_searchableAttributes = array(); + + $productAttributes = Mage::getResourceModel( + 'Mage_Catalog_Model_Resource_Product_Attribute_Collection' + ); + + if ($this->_engine && $this->_engine->allowAdvancedIndex()) { + $productAttributes->addToIndexFilter(true); + } else { + $productAttributes->addSearchableAttributeFilter(); + } + $attributes = $productAttributes->getItems(); + + Mage::dispatchEvent('catelogsearch_searchable_attributes_load_after', array( + 'engine' => $this->_engine, + 'attributes' => $attributes + )); + + $entity = $this->getEavConfig() + ->getEntityType(Mage_Catalog_Model_Product::ENTITY) + ->getEntity(); + + foreach ($attributes as $attribute) { + $attribute->setEntity($entity); + } + + $this->_searchableAttributes = $attributes; + } + + if (!is_null($backendType)) { + $attributes = array(); + foreach ($this->_searchableAttributes as $attributeId => $attribute) { + if ($attribute->getBackendType() == $backendType) { + $attributes[$attributeId] = $attribute; + } + } + + return $attributes; + } + + return $this->_searchableAttributes; + } + + /** + * Retrieve searchable attribute by Id or code + * + * @param int|string $attribute + * @return Mage_Eav_Model_Entity_Attribute + */ + protected function _getSearchableAttribute($attribute) + { + $attributes = $this->_getSearchableAttributes(); + if (is_numeric($attribute)) { + if (isset($attributes[$attribute])) { + return $attributes[$attribute]; + } + } elseif (is_string($attribute)) { + foreach ($attributes as $attributeModel) { + if ($attributeModel->getAttributeCode() == $attribute) { + return $attributeModel; + } + } + } + + return $this->getEavConfig()->getAttribute(Mage_Catalog_Model_Product::ENTITY, $attribute); + } + + /** + * Returns expression for field unification + * + * @param string $field + * @param string $backendType + * @return Zend_Db_Expr + */ + protected function _unifyField($field, $backendType = 'varchar') + { + if ($backendType == 'datetime') { + $expr = Mage::getResourceHelper('Mage_CatalogSearch')->castField( + $this->_getReadAdapter()->getDateFormatSql($field, '%Y-%m-%d %H:%i:%s')); + } else { + $expr = Mage::getResourceHelper('Mage_CatalogSearch')->castField($field); + } + return $expr; + } + + /** + * Load product(s) attributes + * + * @param int $storeId + * @param array $productIds + * @param array $attributeTypes + * @return array + */ + protected function _getProductAttributes($storeId, array $productIds, array $attributeTypes) + { + $result = array(); + $selects = array(); + $adapter = $this->_getWriteAdapter(); + $ifStoreValue = $adapter->getCheckSql('t_store.value_id > 0', 't_store.value', 't_default.value'); + foreach ($attributeTypes as $backendType => $attributeIds) { + if ($attributeIds) { + $tableName = $this->getTable('catalog_product_entity_' . $backendType); + $selects[] = $adapter->select() + ->from( + array('t_default' => $tableName), + array('entity_id', 'attribute_id') + )->joinLeft( + array('t_store' => $tableName), + $adapter->quoteInto( + 't_default.entity_id=t_store.entity_id' . + ' AND t_default.attribute_id=t_store.attribute_id' . + ' AND t_store.store_id=?', + $storeId), + array('value' => $this->_unifyField($ifStoreValue, $backendType)) + )->where('t_default.store_id=?', 0) + ->where('t_default.attribute_id IN (?)', $attributeIds) + ->where('t_default.entity_id IN (?)', $productIds); + } + } + + if ($selects) { + $select = $adapter->select()->union($selects, Zend_Db_Select::SQL_UNION_ALL); + $query = $adapter->query($select); + while ($row = $query->fetch()) { + $result[$row['entity_id']][$row['attribute_id']] = $row['value']; + } + } + + return $result; + } + + /** + * Retrieve Product Type Instance + * + * @param string $typeId + * @return Mage_Catalog_Model_Product_Type_Abstract + */ + protected function _getProductTypeInstance($typeId) + { + if (!isset($this->_productTypes[$typeId])) { + $productEmulator = $this->_getProductEmulator($typeId); + + $this->_productTypes[$typeId] = Mage::getSingleton('Mage_Catalog_Model_Product_Type') + ->factory($productEmulator); + } + return $this->_productTypes[$typeId]; + } + + /** + * Return all product children ids + * + * @param int $productId Product Entity Id + * @param string $typeId Super Product Link Type + * @return array + */ + protected function _getProductChildIds($productId, $typeId) + { + $typeInstance = $this->_getProductTypeInstance($typeId); + $relation = $typeInstance->isComposite($this->_getProductEmulator($typeId)) + ? $typeInstance->getRelationInfo() + : false; + + if ($relation && $relation->getTable() && $relation->getParentFieldName() && $relation->getChildFieldName()) { + $select = $this->_getReadAdapter()->select() + ->from( + array('main' => $this->getTable($relation->getTable())), + array($relation->getChildFieldName()) + )->where($relation->getParentFieldName() . '=?', $productId); + if (!is_null($relation->getWhere())) { + $select->where($relation->getWhere()); + } + return $this->_getReadAdapter()->fetchCol($select); + } + + return null; + } + + /** + * Retrieve Product Emulator (Varien Object) + * + * @param string $typeId + * @return Varien_Object + */ + protected function _getProductEmulator($typeId) + { + if (!isset($this->_productEmulators[$typeId])) { + $productEmulator = new Varien_Object(); + $productEmulator->setIdFieldName('entity_id') + ->setTypeId($typeId); + $this->_productEmulators[$typeId] = $productEmulator; + } + return $this->_productEmulators[$typeId]; + } + + /** + * Prepare Fulltext index value for product + * + * @param array $indexData + * @param array $productData + * @param int $storeId + * @return string + */ + protected function _prepareProductIndex($indexData, $productData, $storeId) + { + $index = array(); + + foreach ($this->_getSearchableAttributes('static') as $attribute) { + $attributeCode = $attribute->getAttributeCode(); + + if (isset($productData[$attributeCode])) { + $value = $this->_getAttributeValue($attribute->getId(), $productData[$attributeCode], $storeId); + if ($value) { + //For grouped products + if (isset($index[$attributeCode])) { + if (!is_array($index[$attributeCode])) { + $index[$attributeCode] = array($index[$attributeCode]); + } + $index[$attributeCode][] = $value; + } else { + //For other types of products + $index[$attributeCode] = $value; + } + } + } + } + + foreach ($indexData as $entityId => $attributeData) { + foreach ($attributeData as $attributeId => $attributeValue) { + $value = $this->_getAttributeValue($attributeId, $attributeValue, $storeId); + if (!is_null($value) && $value !== false) { + $attributeCode = $this->_getSearchableAttribute($attributeId)->getAttributeCode(); + + if (isset($index[$attributeCode])) { + $index[$attributeCode][$entityId] = $value; + } else { + $index[$attributeCode] = array($entityId => $value); + } + } + } + } + + if (!$this->_engine->allowAdvancedIndex()) { + $product = $this->_getProductEmulator($productData['type_id']) + ->setId($productData['entity_id']) + ->setStoreId($storeId); + $typeInstance = $this->_getProductTypeInstance($productData['type_id']); + $data = $typeInstance->getSearchableData($product); + if ($data) { + $index['options'] = $data; + } + } + + if (isset($productData['in_stock'])) { + $index['in_stock'] = $productData['in_stock']; + } + + if ($this->_engine) { + return $this->_engine->prepareEntityIndex($index, $this->_separator); + } + + return Mage::helper('Mage_CatalogSearch_Helper_Data')->prepareIndexdata($index, $this->_separator); + } + + /** + * Retrieve attribute source value for search + * + * @param int $attributeId + * @param mixed $value + * @param int $storeId + * @return mixed + */ + protected function _getAttributeValue($attributeId, $value, $storeId) + { + $attribute = $this->_getSearchableAttribute($attributeId); + if (!$attribute->getIsSearchable()) { + if ($this->_engine->allowAdvancedIndex()) { + if ($attribute->getAttributeCode() == 'visibility') { + return $value; + } elseif (!($attribute->getIsVisibleInAdvancedSearch() + || $attribute->getIsFilterable() + || $attribute->getIsFilterableInSearch() + || $attribute->getUsedForSortBy()) + ) { + return null; + } + } else { + return null; + } + } + + if ($attribute->usesSource()) { + if ($this->_engine->allowAdvancedIndex()) { + return $value; + } + + $attribute->setStoreId($storeId); + $value = $attribute->getSource()->getIndexOptionText($value); + + if (is_array($value)) { + $value = implode($this->_separator, $value); + } elseif (empty($value)) { + $inputType = $attribute->getFrontend()->getInputType(); + if ($inputType == 'select' || $inputType == 'multiselect') { + return null; + } + } + } elseif ($attribute->getBackendType() == 'datetime') { + $value = $this->_getStoreDate($storeId, $value); + } else { + $inputType = $attribute->getFrontend()->getInputType(); + if ($inputType == 'price') { + $value = Mage::app()->getStore($storeId)->roundPrice($value); + } + } + + $value = preg_replace("#\s+#siu", ' ', trim(strip_tags($value))); + + return $value; + } + + /** + * Save Product index + * + * @param int $productId + * @param int $storeId + * @param string $index + * @return Mage_CatalogSearch_Model_Resource_Fulltext + */ + protected function _saveProductIndex($productId, $storeId, $index) + { + if ($this->_engine) { + $this->_engine->saveEntityIndex($productId, $storeId, $index); + } + + return $this; + } + + /** + * Save Multiply Product indexes + * + * @param int $storeId + * @param array $productIndexes + * @return Mage_CatalogSearch_Model_Resource_Fulltext + */ + protected function _saveProductIndexes($storeId, $productIndexes) + { + if ($this->_engine) { + $this->_engine->saveEntityIndexes($storeId, $productIndexes); + } + + return $this; + } + + /** + * Retrieve Date value for store + * + * @param int $storeId + * @param string $date + * @return string + */ + protected function _getStoreDate($storeId, $date = null) + { + if (!isset($this->_dates[$storeId])) { + $timezone = Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE, $storeId); + $locale = Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, $storeId); + $locale = new Zend_Locale($locale); + + $dateObj = new Zend_Date(null, null, $locale); + $dateObj->setTimezone($timezone); + $this->_dates[$storeId] = array($dateObj, $locale->getTranslation(null, 'date', $locale)); + } + + if (!is_empty_date($date)) { + list($dateObj, $format) = $this->_dates[$storeId]; + $dateObj->setDate($date, Varien_Date::DATETIME_INTERNAL_FORMAT); + + return $dateObj->toString($format); + } + + return null; + } + + // Deprecated methods + /** + * Update category products indexes + * + * deprecated after 1.6.2.0 + * + * @param array $productIds + * @param array $categoryIds + * @return Mage_CatalogSearch_Model_Resource_Fulltext + */ + public function updateCategoryIndex($productIds, $categoryIds) + { + return $this; + } +} diff --git a/app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php b/app/code/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php rename to app/code/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php diff --git a/app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Engine.php b/app/code/Mage/CatalogSearch/Model/Resource/Fulltext/Engine.php old mode 100755 new mode 100644 similarity index 94% rename from app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Engine.php rename to app/code/Mage/CatalogSearch/Model/Resource/Fulltext/Engine.php index 86f9b28930ce5..bba2bf15a2fe6 --- a/app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Engine.php +++ b/app/code/Mage/CatalogSearch/Model/Resource/Fulltext/Engine.php @@ -129,7 +129,10 @@ public function cleanIndex($storeId = null, $entityId = null, $entity = 'product $where[] = $this->_getWriteAdapter()->quoteInto('product_id IN (?)', $entityId); } - $this->_getWriteAdapter()->delete($this->getMainTable(), $where); + // Delete locks reading queries and causes performance issues + // Insert into index goes with ON_DUPLICATE options. + // Insert into catalogsearch_result goes with catalog_product_entity inner join + //$this->_getWriteAdapter()->delete($this->getMainTable(), $where); return $this; } @@ -187,7 +190,7 @@ public function isLayeredNavigationAllowed() } /** - * Define if engine is avaliable + * Define if engine is available * * @return bool */ diff --git a/app/code/core/Mage/CatalogSearch/Model/Resource/Helper/Mysql4.php b/app/code/Mage/CatalogSearch/Model/Resource/Helper/Mysql4.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/Model/Resource/Helper/Mysql4.php rename to app/code/Mage/CatalogSearch/Model/Resource/Helper/Mysql4.php diff --git a/app/code/core/Mage/CatalogSearch/Model/Resource/Indexer/Fulltext.php b/app/code/Mage/CatalogSearch/Model/Resource/Indexer/Fulltext.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/Model/Resource/Indexer/Fulltext.php rename to app/code/Mage/CatalogSearch/Model/Resource/Indexer/Fulltext.php diff --git a/app/code/core/Mage/CatalogSearch/Model/Resource/Query.php b/app/code/Mage/CatalogSearch/Model/Resource/Query.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/CatalogSearch/Model/Resource/Query.php rename to app/code/Mage/CatalogSearch/Model/Resource/Query.php diff --git a/app/code/core/Mage/CatalogSearch/Model/Resource/Query/Collection.php b/app/code/Mage/CatalogSearch/Model/Resource/Query/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/CatalogSearch/Model/Resource/Query/Collection.php rename to app/code/Mage/CatalogSearch/Model/Resource/Query/Collection.php diff --git a/app/code/core/Mage/CatalogSearch/Model/Resource/Search/Collection.php b/app/code/Mage/CatalogSearch/Model/Resource/Search/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/CatalogSearch/Model/Resource/Search/Collection.php rename to app/code/Mage/CatalogSearch/Model/Resource/Search/Collection.php diff --git a/app/code/core/Mage/CatalogSearch/Model/Session.php b/app/code/Mage/CatalogSearch/Model/Session.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/Model/Session.php rename to app/code/Mage/CatalogSearch/Model/Session.php diff --git a/app/code/core/Mage/CatalogSearch/Model/Terms/Grid/OptionsArray.php b/app/code/Mage/CatalogSearch/Model/Terms/Grid/OptionsArray.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/Model/Terms/Grid/OptionsArray.php rename to app/code/Mage/CatalogSearch/Model/Terms/Grid/OptionsArray.php diff --git a/app/code/core/Mage/CatalogSearch/controllers/AdvancedController.php b/app/code/Mage/CatalogSearch/controllers/AdvancedController.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/controllers/AdvancedController.php rename to app/code/Mage/CatalogSearch/controllers/AdvancedController.php diff --git a/app/code/core/Mage/CatalogSearch/controllers/AjaxController.php b/app/code/Mage/CatalogSearch/controllers/AjaxController.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/controllers/AjaxController.php rename to app/code/Mage/CatalogSearch/controllers/AjaxController.php diff --git a/app/code/core/Mage/CatalogSearch/controllers/ResultController.php b/app/code/Mage/CatalogSearch/controllers/ResultController.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/controllers/ResultController.php rename to app/code/Mage/CatalogSearch/controllers/ResultController.php diff --git a/app/code/core/Mage/CatalogSearch/controllers/TermController.php b/app/code/Mage/CatalogSearch/controllers/TermController.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/controllers/TermController.php rename to app/code/Mage/CatalogSearch/controllers/TermController.php diff --git a/app/code/Mage/CatalogSearch/etc/adminhtml/acl.xml b/app/code/Mage/CatalogSearch/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..f86f358ba093c --- /dev/null +++ b/app/code/Mage/CatalogSearch/etc/adminhtml/acl.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + diff --git a/app/code/Mage/CatalogSearch/etc/adminhtml/menu.xml b/app/code/Mage/CatalogSearch/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..f774c3c7f137f --- /dev/null +++ b/app/code/Mage/CatalogSearch/etc/adminhtml/menu.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/app/code/core/Mage/CatalogSearch/etc/adminhtml/system.xml b/app/code/Mage/CatalogSearch/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/CatalogSearch/etc/adminhtml/system.xml rename to app/code/Mage/CatalogSearch/etc/adminhtml/system.xml diff --git a/app/code/Mage/CatalogSearch/etc/config.xml b/app/code/Mage/CatalogSearch/etc/config.xml new file mode 100644 index 0000000000000..1c92da3af4fa5 --- /dev/null +++ b/app/code/Mage/CatalogSearch/etc/config.xml @@ -0,0 +1,113 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + Mage_CatalogSearch + + + + + + + Mage_CatalogSearch_Model_Indexer_Fulltext + + + + + + + + standard + + Mage_CatalogSearch + catalogsearch + + + + + + + + Mage_CatalogSearch.csv + + + + + + + + layout.xml + + + + + + + + + layout.xml + + + + + + + + Mage_CatalogSearch.csv + + + + + + + + + 1 + + + 1 + 128 + 10 + 1 + 2000 + + + + diff --git a/app/code/core/Mage/CatalogSearch/locale/de_DE/Mage_CatalogSearch.csv b/app/code/Mage/CatalogSearch/locale/de_DE/Mage_CatalogSearch.csv similarity index 100% rename from app/code/core/Mage/CatalogSearch/locale/de_DE/Mage_CatalogSearch.csv rename to app/code/Mage/CatalogSearch/locale/de_DE/Mage_CatalogSearch.csv diff --git a/app/code/core/Mage/CatalogSearch/locale/en_US/Mage_CatalogSearch.csv b/app/code/Mage/CatalogSearch/locale/en_US/Mage_CatalogSearch.csv similarity index 100% rename from app/code/core/Mage/CatalogSearch/locale/en_US/Mage_CatalogSearch.csv rename to app/code/Mage/CatalogSearch/locale/en_US/Mage_CatalogSearch.csv diff --git a/app/code/core/Mage/CatalogSearch/locale/es_ES/Mage_CatalogSearch.csv b/app/code/Mage/CatalogSearch/locale/es_ES/Mage_CatalogSearch.csv similarity index 100% rename from app/code/core/Mage/CatalogSearch/locale/es_ES/Mage_CatalogSearch.csv rename to app/code/Mage/CatalogSearch/locale/es_ES/Mage_CatalogSearch.csv diff --git a/app/code/core/Mage/CatalogSearch/locale/fr_FR/Mage_CatalogSearch.csv b/app/code/Mage/CatalogSearch/locale/fr_FR/Mage_CatalogSearch.csv similarity index 100% rename from app/code/core/Mage/CatalogSearch/locale/fr_FR/Mage_CatalogSearch.csv rename to app/code/Mage/CatalogSearch/locale/fr_FR/Mage_CatalogSearch.csv diff --git a/app/code/core/Mage/CatalogSearch/locale/nl_NL/Mage_CatalogSearch.csv b/app/code/Mage/CatalogSearch/locale/nl_NL/Mage_CatalogSearch.csv similarity index 100% rename from app/code/core/Mage/CatalogSearch/locale/nl_NL/Mage_CatalogSearch.csv rename to app/code/Mage/CatalogSearch/locale/nl_NL/Mage_CatalogSearch.csv diff --git a/app/code/core/Mage/CatalogSearch/locale/pt_BR/Mage_CatalogSearch.csv b/app/code/Mage/CatalogSearch/locale/pt_BR/Mage_CatalogSearch.csv similarity index 100% rename from app/code/core/Mage/CatalogSearch/locale/pt_BR/Mage_CatalogSearch.csv rename to app/code/Mage/CatalogSearch/locale/pt_BR/Mage_CatalogSearch.csv diff --git a/app/code/core/Mage/CatalogSearch/locale/zh_CN/Mage_CatalogSearch.csv b/app/code/Mage/CatalogSearch/locale/zh_CN/Mage_CatalogSearch.csv similarity index 100% rename from app/code/core/Mage/CatalogSearch/locale/zh_CN/Mage_CatalogSearch.csv rename to app/code/Mage/CatalogSearch/locale/zh_CN/Mage_CatalogSearch.csv diff --git a/app/code/core/Mage/CatalogSearch/sql/catalogsearch_setup/install-1.6.0.0.php b/app/code/Mage/CatalogSearch/sql/catalogsearch_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/CatalogSearch/sql/catalogsearch_setup/install-1.6.0.0.php rename to app/code/Mage/CatalogSearch/sql/catalogsearch_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/CatalogSearch/view/adminhtml/layout.xml b/app/code/Mage/CatalogSearch/view/adminhtml/layout.xml similarity index 100% rename from app/code/core/Mage/CatalogSearch/view/adminhtml/layout.xml rename to app/code/Mage/CatalogSearch/view/adminhtml/layout.xml diff --git a/app/code/core/Mage/CatalogSearch/view/frontend/advanced/form.phtml b/app/code/Mage/CatalogSearch/view/frontend/advanced/form.phtml similarity index 100% rename from app/code/core/Mage/CatalogSearch/view/frontend/advanced/form.phtml rename to app/code/Mage/CatalogSearch/view/frontend/advanced/form.phtml diff --git a/app/code/core/Mage/CatalogSearch/view/frontend/advanced/result.phtml b/app/code/Mage/CatalogSearch/view/frontend/advanced/result.phtml similarity index 100% rename from app/code/core/Mage/CatalogSearch/view/frontend/advanced/result.phtml rename to app/code/Mage/CatalogSearch/view/frontend/advanced/result.phtml diff --git a/app/code/core/Mage/CatalogSearch/view/frontend/form-mini.js b/app/code/Mage/CatalogSearch/view/frontend/form-mini.js similarity index 100% rename from app/code/core/Mage/CatalogSearch/view/frontend/form-mini.js rename to app/code/Mage/CatalogSearch/view/frontend/form-mini.js diff --git a/app/code/core/Mage/CatalogSearch/view/frontend/form.mini.phtml b/app/code/Mage/CatalogSearch/view/frontend/form.mini.phtml similarity index 100% rename from app/code/core/Mage/CatalogSearch/view/frontend/form.mini.phtml rename to app/code/Mage/CatalogSearch/view/frontend/form.mini.phtml diff --git a/app/code/core/Mage/CatalogSearch/view/frontend/layout.xml b/app/code/Mage/CatalogSearch/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/CatalogSearch/view/frontend/layout.xml rename to app/code/Mage/CatalogSearch/view/frontend/layout.xml diff --git a/app/code/core/Mage/CatalogSearch/view/frontend/result.phtml b/app/code/Mage/CatalogSearch/view/frontend/result.phtml similarity index 100% rename from app/code/core/Mage/CatalogSearch/view/frontend/result.phtml rename to app/code/Mage/CatalogSearch/view/frontend/result.phtml diff --git a/app/code/core/Mage/CatalogSearch/view/frontend/term.phtml b/app/code/Mage/CatalogSearch/view/frontend/term.phtml similarity index 100% rename from app/code/core/Mage/CatalogSearch/view/frontend/term.phtml rename to app/code/Mage/CatalogSearch/view/frontend/term.phtml diff --git a/app/code/core/Mage/Centinel/Block/Adminhtml/Validation.php b/app/code/Mage/Centinel/Block/Adminhtml/Validation.php similarity index 100% rename from app/code/core/Mage/Centinel/Block/Adminhtml/Validation.php rename to app/code/Mage/Centinel/Block/Adminhtml/Validation.php diff --git a/app/code/core/Mage/Centinel/Block/Adminhtml/Validation/Form.php b/app/code/Mage/Centinel/Block/Adminhtml/Validation/Form.php similarity index 100% rename from app/code/core/Mage/Centinel/Block/Adminhtml/Validation/Form.php rename to app/code/Mage/Centinel/Block/Adminhtml/Validation/Form.php diff --git a/app/code/core/Mage/Centinel/Block/Authentication.php b/app/code/Mage/Centinel/Block/Authentication.php similarity index 100% rename from app/code/core/Mage/Centinel/Block/Authentication.php rename to app/code/Mage/Centinel/Block/Authentication.php diff --git a/app/code/core/Mage/Centinel/Block/Authentication/Complete.php b/app/code/Mage/Centinel/Block/Authentication/Complete.php similarity index 100% rename from app/code/core/Mage/Centinel/Block/Authentication/Complete.php rename to app/code/Mage/Centinel/Block/Authentication/Complete.php diff --git a/app/code/core/Mage/Centinel/Block/Authentication/Start.php b/app/code/Mage/Centinel/Block/Authentication/Start.php similarity index 100% rename from app/code/core/Mage/Centinel/Block/Authentication/Start.php rename to app/code/Mage/Centinel/Block/Authentication/Start.php diff --git a/app/code/core/Mage/Centinel/Block/Logo.php b/app/code/Mage/Centinel/Block/Logo.php similarity index 100% rename from app/code/core/Mage/Centinel/Block/Logo.php rename to app/code/Mage/Centinel/Block/Logo.php diff --git a/app/code/core/Mage/Centinel/Helper/Data.php b/app/code/Mage/Centinel/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Centinel/Helper/Data.php rename to app/code/Mage/Centinel/Helper/Data.php diff --git a/app/code/core/Mage/Centinel/Model/Api.php b/app/code/Mage/Centinel/Model/Api.php similarity index 100% rename from app/code/core/Mage/Centinel/Model/Api.php rename to app/code/Mage/Centinel/Model/Api.php diff --git a/app/code/core/Mage/Centinel/Model/Config.php b/app/code/Mage/Centinel/Model/Config.php similarity index 100% rename from app/code/core/Mage/Centinel/Model/Config.php rename to app/code/Mage/Centinel/Model/Config.php diff --git a/app/code/core/Mage/Centinel/Model/Observer.php b/app/code/Mage/Centinel/Model/Observer.php similarity index 100% rename from app/code/core/Mage/Centinel/Model/Observer.php rename to app/code/Mage/Centinel/Model/Observer.php diff --git a/app/code/core/Mage/Centinel/Model/Service.php b/app/code/Mage/Centinel/Model/Service.php similarity index 100% rename from app/code/core/Mage/Centinel/Model/Service.php rename to app/code/Mage/Centinel/Model/Service.php diff --git a/app/code/core/Mage/Centinel/Model/Session.php b/app/code/Mage/Centinel/Model/Session.php similarity index 100% rename from app/code/core/Mage/Centinel/Model/Session.php rename to app/code/Mage/Centinel/Model/Session.php diff --git a/app/code/core/Mage/Centinel/Model/State/Jcb.php b/app/code/Mage/Centinel/Model/State/Jcb.php similarity index 100% rename from app/code/core/Mage/Centinel/Model/State/Jcb.php rename to app/code/Mage/Centinel/Model/State/Jcb.php diff --git a/app/code/core/Mage/Centinel/Model/State/Mastercard.php b/app/code/Mage/Centinel/Model/State/Mastercard.php similarity index 100% rename from app/code/core/Mage/Centinel/Model/State/Mastercard.php rename to app/code/Mage/Centinel/Model/State/Mastercard.php diff --git a/app/code/core/Mage/Centinel/Model/State/Visa.php b/app/code/Mage/Centinel/Model/State/Visa.php similarity index 100% rename from app/code/core/Mage/Centinel/Model/State/Visa.php rename to app/code/Mage/Centinel/Model/State/Visa.php diff --git a/app/code/core/Mage/Centinel/Model/StateAbstract.php b/app/code/Mage/Centinel/Model/StateAbstract.php similarity index 100% rename from app/code/core/Mage/Centinel/Model/StateAbstract.php rename to app/code/Mage/Centinel/Model/StateAbstract.php diff --git a/app/code/core/Mage/Centinel/controllers/Adminhtml/Centinel/IndexController.php b/app/code/Mage/Centinel/controllers/Adminhtml/Centinel/IndexController.php similarity index 100% rename from app/code/core/Mage/Centinel/controllers/Adminhtml/Centinel/IndexController.php rename to app/code/Mage/Centinel/controllers/Adminhtml/Centinel/IndexController.php diff --git a/app/code/core/Mage/Centinel/controllers/IndexController.php b/app/code/Mage/Centinel/controllers/IndexController.php similarity index 100% rename from app/code/core/Mage/Centinel/controllers/IndexController.php rename to app/code/Mage/Centinel/controllers/IndexController.php diff --git a/app/code/core/Mage/Centinel/etc/adminhtml/system.xml b/app/code/Mage/Centinel/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Centinel/etc/adminhtml/system.xml rename to app/code/Mage/Centinel/etc/adminhtml/system.xml diff --git a/app/code/Mage/Centinel/etc/config.xml b/app/code/Mage/Centinel/etc/config.xml new file mode 100644 index 0000000000000..7df80c304e003 --- /dev/null +++ b/app/code/Mage/Centinel/etc/config.xml @@ -0,0 +1,176 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + + + Mage_Centinel_Model_Observer + salesEventConvertQuoteToOrder + + + + + + + Mage_Centinel_Model_Observer + checkoutSubmitAllAfter + + + + + + + + + + + Mage_Centinel.csv + + + + + + + + + model + Mage_Centinel_Model_Observer + paymentFormBlockToHtmlBefore + + + + + + + standard + + Mage_Centinel + centinel + + + + + + + layout.xml + + + + + /centinel/ + + + + + + + + model + Mage_Centinel_Model_Observer + paymentInfoBlockPrepareSpecificInformation + + + + + + + + + Mage_Centinel.csv + + + + + + + + layout.xml + + + + + + + + + + Mage_Centinel_Adminhtml + + + + + + + + + + + + + Mage_Centinel_Model_State_Visa + + + + + + + Mage_Centinel_Model_State_Mastercard + + + + + + + Mage_Centinel_Model_State_Jcb + + + + + + + Mage_Centinel_Model_State_Mastercard + + + + + + + + diff --git a/app/code/core/Mage/Centinel/locale/de_DE/Mage_Centinel.csv b/app/code/Mage/Centinel/locale/de_DE/Mage_Centinel.csv similarity index 100% rename from app/code/core/Mage/Centinel/locale/de_DE/Mage_Centinel.csv rename to app/code/Mage/Centinel/locale/de_DE/Mage_Centinel.csv diff --git a/app/code/core/Mage/Centinel/locale/en_US/Mage_Centinel.csv b/app/code/Mage/Centinel/locale/en_US/Mage_Centinel.csv similarity index 100% rename from app/code/core/Mage/Centinel/locale/en_US/Mage_Centinel.csv rename to app/code/Mage/Centinel/locale/en_US/Mage_Centinel.csv diff --git a/app/code/core/Mage/Centinel/locale/es_ES/Mage_Centinel.csv b/app/code/Mage/Centinel/locale/es_ES/Mage_Centinel.csv similarity index 100% rename from app/code/core/Mage/Centinel/locale/es_ES/Mage_Centinel.csv rename to app/code/Mage/Centinel/locale/es_ES/Mage_Centinel.csv diff --git a/app/code/core/Mage/Centinel/locale/fr_FR/Mage_Centinel.csv b/app/code/Mage/Centinel/locale/fr_FR/Mage_Centinel.csv similarity index 100% rename from app/code/core/Mage/Centinel/locale/fr_FR/Mage_Centinel.csv rename to app/code/Mage/Centinel/locale/fr_FR/Mage_Centinel.csv diff --git a/app/code/core/Mage/Centinel/locale/nl_NL/Mage_Centinel.csv b/app/code/Mage/Centinel/locale/nl_NL/Mage_Centinel.csv similarity index 100% rename from app/code/core/Mage/Centinel/locale/nl_NL/Mage_Centinel.csv rename to app/code/Mage/Centinel/locale/nl_NL/Mage_Centinel.csv diff --git a/app/code/core/Mage/Centinel/locale/pt_BR/Mage_Centinel.csv b/app/code/Mage/Centinel/locale/pt_BR/Mage_Centinel.csv similarity index 100% rename from app/code/core/Mage/Centinel/locale/pt_BR/Mage_Centinel.csv rename to app/code/Mage/Centinel/locale/pt_BR/Mage_Centinel.csv diff --git a/app/code/core/Mage/Centinel/locale/zh_CN/Mage_Centinel.csv b/app/code/Mage/Centinel/locale/zh_CN/Mage_Centinel.csv similarity index 100% rename from app/code/core/Mage/Centinel/locale/zh_CN/Mage_Centinel.csv rename to app/code/Mage/Centinel/locale/zh_CN/Mage_Centinel.csv diff --git a/app/code/core/Mage/Centinel/view/adminhtml/authentication/complete.phtml b/app/code/Mage/Centinel/view/adminhtml/authentication/complete.phtml similarity index 100% rename from app/code/core/Mage/Centinel/view/adminhtml/authentication/complete.phtml rename to app/code/Mage/Centinel/view/adminhtml/authentication/complete.phtml diff --git a/app/code/core/Mage/Centinel/view/adminhtml/authentication/start.phtml b/app/code/Mage/Centinel/view/adminhtml/authentication/start.phtml similarity index 100% rename from app/code/core/Mage/Centinel/view/adminhtml/authentication/start.phtml rename to app/code/Mage/Centinel/view/adminhtml/authentication/start.phtml diff --git a/app/code/core/Mage/Centinel/view/adminhtml/layout.xml b/app/code/Mage/Centinel/view/adminhtml/layout.xml similarity index 100% rename from app/code/core/Mage/Centinel/view/adminhtml/layout.xml rename to app/code/Mage/Centinel/view/adminhtml/layout.xml diff --git a/app/code/core/Mage/Centinel/view/adminhtml/order_create.js b/app/code/Mage/Centinel/view/adminhtml/order_create.js similarity index 100% rename from app/code/core/Mage/Centinel/view/adminhtml/order_create.js rename to app/code/Mage/Centinel/view/adminhtml/order_create.js diff --git a/app/code/core/Mage/Centinel/view/adminhtml/validation/form.phtml b/app/code/Mage/Centinel/view/adminhtml/validation/form.phtml similarity index 100% rename from app/code/core/Mage/Centinel/view/adminhtml/validation/form.phtml rename to app/code/Mage/Centinel/view/adminhtml/validation/form.phtml diff --git a/app/code/core/Mage/Centinel/view/frontend/authentication.phtml b/app/code/Mage/Centinel/view/frontend/authentication.phtml similarity index 100% rename from app/code/core/Mage/Centinel/view/frontend/authentication.phtml rename to app/code/Mage/Centinel/view/frontend/authentication.phtml diff --git a/app/code/core/Mage/Centinel/view/frontend/authentication/complete.phtml b/app/code/Mage/Centinel/view/frontend/authentication/complete.phtml similarity index 100% rename from app/code/core/Mage/Centinel/view/frontend/authentication/complete.phtml rename to app/code/Mage/Centinel/view/frontend/authentication/complete.phtml diff --git a/app/code/core/Mage/Centinel/view/frontend/authentication/start.phtml b/app/code/Mage/Centinel/view/frontend/authentication/start.phtml similarity index 100% rename from app/code/core/Mage/Centinel/view/frontend/authentication/start.phtml rename to app/code/Mage/Centinel/view/frontend/authentication/start.phtml diff --git a/app/code/core/Mage/Centinel/view/frontend/checkout.js b/app/code/Mage/Centinel/view/frontend/checkout.js similarity index 100% rename from app/code/core/Mage/Centinel/view/frontend/checkout.js rename to app/code/Mage/Centinel/view/frontend/checkout.js diff --git a/app/code/core/Mage/Centinel/view/frontend/images/sc_learn_62x34.gif b/app/code/Mage/Centinel/view/frontend/images/sc_learn_62x34.gif similarity index 100% rename from app/code/core/Mage/Centinel/view/frontend/images/sc_learn_62x34.gif rename to app/code/Mage/Centinel/view/frontend/images/sc_learn_62x34.gif diff --git a/app/code/core/Mage/Centinel/view/frontend/images/sc_learn_62x34.png b/app/code/Mage/Centinel/view/frontend/images/sc_learn_62x34.png similarity index 100% rename from app/code/core/Mage/Centinel/view/frontend/images/sc_learn_62x34.png rename to app/code/Mage/Centinel/view/frontend/images/sc_learn_62x34.png diff --git a/app/code/core/Mage/Centinel/view/frontend/images/vbv_ltbg_71x57.gif b/app/code/Mage/Centinel/view/frontend/images/vbv_ltbg_71x57.gif similarity index 100% rename from app/code/core/Mage/Centinel/view/frontend/images/vbv_ltbg_71x57.gif rename to app/code/Mage/Centinel/view/frontend/images/vbv_ltbg_71x57.gif diff --git a/app/code/core/Mage/Centinel/view/frontend/images/vbv_ltbg_71x57.png b/app/code/Mage/Centinel/view/frontend/images/vbv_ltbg_71x57.png similarity index 100% rename from app/code/core/Mage/Centinel/view/frontend/images/vbv_ltbg_71x57.png rename to app/code/Mage/Centinel/view/frontend/images/vbv_ltbg_71x57.png diff --git a/app/code/core/Mage/Centinel/view/frontend/layout.xml b/app/code/Mage/Centinel/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/Centinel/view/frontend/layout.xml rename to app/code/Mage/Centinel/view/frontend/layout.xml diff --git a/app/code/Mage/Centinel/view/frontend/logo.phtml b/app/code/Mage/Centinel/view/frontend/logo.phtml new file mode 100644 index 0000000000000..808f2eccffeba --- /dev/null +++ b/app/code/Mage/Centinel/view/frontend/logo.phtml @@ -0,0 +1,33 @@ + + diff --git a/app/code/core/Mage/Checkout/Block/Agreements.php b/app/code/Mage/Checkout/Block/Agreements.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Agreements.php rename to app/code/Mage/Checkout/Block/Agreements.php diff --git a/app/code/core/Mage/Checkout/Block/Cart.php b/app/code/Mage/Checkout/Block/Cart.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Cart.php rename to app/code/Mage/Checkout/Block/Cart.php diff --git a/app/code/core/Mage/Checkout/Block/Cart/Abstract.php b/app/code/Mage/Checkout/Block/Cart/Abstract.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Cart/Abstract.php rename to app/code/Mage/Checkout/Block/Cart/Abstract.php diff --git a/app/code/core/Mage/Checkout/Block/Cart/Coupon.php b/app/code/Mage/Checkout/Block/Cart/Coupon.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Cart/Coupon.php rename to app/code/Mage/Checkout/Block/Cart/Coupon.php diff --git a/app/code/core/Mage/Checkout/Block/Cart/Crosssell.php b/app/code/Mage/Checkout/Block/Cart/Crosssell.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Cart/Crosssell.php rename to app/code/Mage/Checkout/Block/Cart/Crosssell.php diff --git a/app/code/core/Mage/Checkout/Block/Cart/Item/Configure.php b/app/code/Mage/Checkout/Block/Cart/Item/Configure.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Cart/Item/Configure.php rename to app/code/Mage/Checkout/Block/Cart/Item/Configure.php diff --git a/app/code/core/Mage/Checkout/Block/Cart/Item/Renderer.php b/app/code/Mage/Checkout/Block/Cart/Item/Renderer.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Cart/Item/Renderer.php rename to app/code/Mage/Checkout/Block/Cart/Item/Renderer.php diff --git a/app/code/core/Mage/Checkout/Block/Cart/Item/Renderer/Configurable.php b/app/code/Mage/Checkout/Block/Cart/Item/Renderer/Configurable.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Cart/Item/Renderer/Configurable.php rename to app/code/Mage/Checkout/Block/Cart/Item/Renderer/Configurable.php diff --git a/app/code/core/Mage/Checkout/Block/Cart/Item/Renderer/Grouped.php b/app/code/Mage/Checkout/Block/Cart/Item/Renderer/Grouped.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Cart/Item/Renderer/Grouped.php rename to app/code/Mage/Checkout/Block/Cart/Item/Renderer/Grouped.php diff --git a/app/code/core/Mage/Checkout/Block/Cart/Shipping.php b/app/code/Mage/Checkout/Block/Cart/Shipping.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Cart/Shipping.php rename to app/code/Mage/Checkout/Block/Cart/Shipping.php diff --git a/app/code/core/Mage/Checkout/Block/Cart/Sidebar.php b/app/code/Mage/Checkout/Block/Cart/Sidebar.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Cart/Sidebar.php rename to app/code/Mage/Checkout/Block/Cart/Sidebar.php diff --git a/app/code/core/Mage/Checkout/Block/Cart/Totals.php b/app/code/Mage/Checkout/Block/Cart/Totals.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Cart/Totals.php rename to app/code/Mage/Checkout/Block/Cart/Totals.php diff --git a/app/code/core/Mage/Checkout/Block/Links.php b/app/code/Mage/Checkout/Block/Links.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Links.php rename to app/code/Mage/Checkout/Block/Links.php diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Abstract.php b/app/code/Mage/Checkout/Block/Multishipping/Abstract.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Multishipping/Abstract.php rename to app/code/Mage/Checkout/Block/Multishipping/Abstract.php diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Address/Select.php b/app/code/Mage/Checkout/Block/Multishipping/Address/Select.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Multishipping/Address/Select.php rename to app/code/Mage/Checkout/Block/Multishipping/Address/Select.php diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Addresses.php b/app/code/Mage/Checkout/Block/Multishipping/Addresses.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Multishipping/Addresses.php rename to app/code/Mage/Checkout/Block/Multishipping/Addresses.php diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Billing.php b/app/code/Mage/Checkout/Block/Multishipping/Billing.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Multishipping/Billing.php rename to app/code/Mage/Checkout/Block/Multishipping/Billing.php diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Billing/Items.php b/app/code/Mage/Checkout/Block/Multishipping/Billing/Items.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Multishipping/Billing/Items.php rename to app/code/Mage/Checkout/Block/Multishipping/Billing/Items.php diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Link.php b/app/code/Mage/Checkout/Block/Multishipping/Link.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Multishipping/Link.php rename to app/code/Mage/Checkout/Block/Multishipping/Link.php diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php b/app/code/Mage/Checkout/Block/Multishipping/Overview.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Multishipping/Overview.php rename to app/code/Mage/Checkout/Block/Multishipping/Overview.php diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Payment/Info.php b/app/code/Mage/Checkout/Block/Multishipping/Payment/Info.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Multishipping/Payment/Info.php rename to app/code/Mage/Checkout/Block/Multishipping/Payment/Info.php diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Shipping.php b/app/code/Mage/Checkout/Block/Multishipping/Shipping.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Multishipping/Shipping.php rename to app/code/Mage/Checkout/Block/Multishipping/Shipping.php diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/State.php b/app/code/Mage/Checkout/Block/Multishipping/State.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Multishipping/State.php rename to app/code/Mage/Checkout/Block/Multishipping/State.php diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Success.php b/app/code/Mage/Checkout/Block/Multishipping/Success.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Multishipping/Success.php rename to app/code/Mage/Checkout/Block/Multishipping/Success.php diff --git a/app/code/core/Mage/Checkout/Block/Onepage.php b/app/code/Mage/Checkout/Block/Onepage.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Onepage.php rename to app/code/Mage/Checkout/Block/Onepage.php diff --git a/app/code/Mage/Checkout/Block/Onepage/Abstract.php b/app/code/Mage/Checkout/Block/Onepage/Abstract.php new file mode 100644 index 0000000000000..9e67691b9c14e --- /dev/null +++ b/app/code/Mage/Checkout/Block/Onepage/Abstract.php @@ -0,0 +1,232 @@ + + */ +abstract class Mage_Checkout_Block_Onepage_Abstract extends Mage_Core_Block_Template +{ + /** + * @var Mage_Core_Model_Cache_Type_Config + */ + protected $_configCacheType; + + protected $_customer; + protected $_checkout; + protected $_quote; + protected $_countryCollection; + protected $_regionCollection; + protected $_addressesCollection; + + /** + * @param Mage_Core_Block_Template_Context $context + * @param Mage_Core_Model_Cache_Type_Config $configCacheType + * @param array $data + */ + public function __construct( + Mage_Core_Block_Template_Context $context, + Mage_Core_Model_Cache_Type_Config $configCacheType, + array $data = array() + ) { + parent::__construct($context, $data); + $this->_configCacheType = $configCacheType; + } + + /** + * Get logged in customer + * + * @return Mage_Customer_Model_Customer + */ + public function getCustomer() + { + if (empty($this->_customer)) { + $this->_customer = Mage::getSingleton('Mage_Customer_Model_Session')->getCustomer(); + } + return $this->_customer; + } + + /** + * Retrieve checkout session model + * + * @return Mage_Checkout_Model_Session + */ + public function getCheckout() + { + if (empty($this->_checkout)) { + $this->_checkout = Mage::getSingleton('Mage_Checkout_Model_Session'); + } + return $this->_checkout; + } + + /** + * Retrieve sales quote model + * + * @return Mage_Sales_Model_Quote + */ + public function getQuote() + { + if (empty($this->_quote)) { + $this->_quote = $this->getCheckout()->getQuote(); + } + return $this->_quote; + } + + public function isCustomerLoggedIn() + { + return Mage::getSingleton('Mage_Customer_Model_Session')->isLoggedIn(); + } + + public function getCountryCollection() + { + if (!$this->_countryCollection) { + $this->_countryCollection = Mage::getSingleton('Mage_Directory_Model_Country')->getResourceCollection() + ->loadByStore(); + } + return $this->_countryCollection; + } + + public function getRegionCollection() + { + if (!$this->_regionCollection) { + $this->_regionCollection = Mage::getModel('Mage_Directory_Model_Region')->getResourceCollection() + ->addCountryFilter($this->getAddress()->getCountryId()) + ->load(); + } + return $this->_regionCollection; + } + + public function customerHasAddresses() + { + return count($this->getCustomer()->getAddresses()); + } + + public function getAddressesHtmlSelect($type) + { + if ($this->isCustomerLoggedIn()) { + $options = array(); + foreach ($this->getCustomer()->getAddresses() as $address) { + $options[] = array( + 'value' => $address->getId(), + 'label' => $address->format('oneline') + ); + } + + $addressId = $this->getAddress()->getCustomerAddressId(); + if (empty($addressId)) { + if ($type=='billing') { + $address = $this->getCustomer()->getPrimaryBillingAddress(); + } else { + $address = $this->getCustomer()->getPrimaryShippingAddress(); + } + if ($address) { + $addressId = $address->getId(); + } + } + + $select = $this->getLayout()->createBlock('Mage_Core_Block_Html_Select') + ->setName($type.'_address_id') + ->setId($type.'-address-select') + ->setClass('address-select') + //->setExtraParams('onchange="'.$type.'.newAddress(!this.value)"') + // temp disable inline javascript, need to clean this later + ->setValue($addressId) + ->setOptions($options); + + $select->addOption('', Mage::helper('Mage_Checkout_Helper_Data')->__('New Address')); + + return $select->getHtml(); + } + return ''; + } + + public function getCountryHtmlSelect($type) + { + $countryId = $this->getAddress()->getCountryId(); + if (is_null($countryId)) { + $countryId = Mage::helper('Mage_Core_Helper_Data')->getDefaultCountry(); + } + $select = $this->getLayout()->createBlock('Mage_Core_Block_Html_Select') + ->setName($type.'[country_id]') + ->setId($type.':country_id') + ->setTitle(Mage::helper('Mage_Checkout_Helper_Data')->__('Country')) + ->setClass('validate-select') + ->setValue($countryId) + ->setOptions($this->getCountryOptions()); + return $select->getHtml(); + } + + + public function getRegionHtmlSelect($type) + { + $select = $this->getLayout()->createBlock('Mage_Core_Block_Html_Select') + ->setName($type.'[region]') + ->setId($type.':region') + ->setTitle(Mage::helper('Mage_Checkout_Helper_Data')->__('State/Province')) + ->setClass('required-entry validate-state') + ->setValue($this->getAddress()->getRegionId()) + ->setOptions($this->getRegionCollection()->toOptionArray()); + + return $select->getHtml(); + } + + public function getCountryOptions() + { + $options = false; + $cacheId = 'DIRECTORY_COUNTRY_SELECT_STORE_' . Mage::app()->getStore()->getCode(); + if ($optionsCache = $this->_configCacheType->load($cacheId)) { + $options = unserialize($optionsCache); + } + + if ($options == false) { + $options = $this->getCountryCollection()->toOptionArray(); + $this->_configCacheType->save(serialize($options), $cacheId); + } + return $options; + } + + /** + * Get checkout steps codes + * + * @return array + */ + protected function _getStepCodes() + { + return array('login', 'billing', 'shipping', 'shipping_method', 'payment', 'review'); + } + + + /** + * Retrieve is allow and show block + * + * @return bool + */ + public function isShow() + { + return true; + } +} diff --git a/app/code/core/Mage/Checkout/Block/Onepage/Billing.php b/app/code/Mage/Checkout/Block/Onepage/Billing.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Onepage/Billing.php rename to app/code/Mage/Checkout/Block/Onepage/Billing.php diff --git a/app/code/core/Mage/Checkout/Block/Onepage/Failure.php b/app/code/Mage/Checkout/Block/Onepage/Failure.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Onepage/Failure.php rename to app/code/Mage/Checkout/Block/Onepage/Failure.php diff --git a/app/code/core/Mage/Checkout/Block/Onepage/Link.php b/app/code/Mage/Checkout/Block/Onepage/Link.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Onepage/Link.php rename to app/code/Mage/Checkout/Block/Onepage/Link.php diff --git a/app/code/core/Mage/Checkout/Block/Onepage/Login.php b/app/code/Mage/Checkout/Block/Onepage/Login.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Onepage/Login.php rename to app/code/Mage/Checkout/Block/Onepage/Login.php diff --git a/app/code/core/Mage/Checkout/Block/Onepage/Payment.php b/app/code/Mage/Checkout/Block/Onepage/Payment.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Onepage/Payment.php rename to app/code/Mage/Checkout/Block/Onepage/Payment.php diff --git a/app/code/core/Mage/Checkout/Block/Onepage/Payment/Info.php b/app/code/Mage/Checkout/Block/Onepage/Payment/Info.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Onepage/Payment/Info.php rename to app/code/Mage/Checkout/Block/Onepage/Payment/Info.php diff --git a/app/code/core/Mage/Checkout/Block/Onepage/Payment/Methods.php b/app/code/Mage/Checkout/Block/Onepage/Payment/Methods.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Onepage/Payment/Methods.php rename to app/code/Mage/Checkout/Block/Onepage/Payment/Methods.php diff --git a/app/code/core/Mage/Checkout/Block/Onepage/Progress.php b/app/code/Mage/Checkout/Block/Onepage/Progress.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Onepage/Progress.php rename to app/code/Mage/Checkout/Block/Onepage/Progress.php diff --git a/app/code/core/Mage/Checkout/Block/Onepage/Review.php b/app/code/Mage/Checkout/Block/Onepage/Review.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Onepage/Review.php rename to app/code/Mage/Checkout/Block/Onepage/Review.php diff --git a/app/code/core/Mage/Checkout/Block/Onepage/Review/Info.php b/app/code/Mage/Checkout/Block/Onepage/Review/Info.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Onepage/Review/Info.php rename to app/code/Mage/Checkout/Block/Onepage/Review/Info.php diff --git a/app/code/core/Mage/Checkout/Block/Onepage/Shipping.php b/app/code/Mage/Checkout/Block/Onepage/Shipping.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Onepage/Shipping.php rename to app/code/Mage/Checkout/Block/Onepage/Shipping.php diff --git a/app/code/core/Mage/Checkout/Block/Onepage/Shipping/Method.php b/app/code/Mage/Checkout/Block/Onepage/Shipping/Method.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Onepage/Shipping/Method.php rename to app/code/Mage/Checkout/Block/Onepage/Shipping/Method.php diff --git a/app/code/core/Mage/Checkout/Block/Onepage/Shipping/Method/Additional.php b/app/code/Mage/Checkout/Block/Onepage/Shipping/Method/Additional.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Onepage/Shipping/Method/Additional.php rename to app/code/Mage/Checkout/Block/Onepage/Shipping/Method/Additional.php diff --git a/app/code/core/Mage/Checkout/Block/Onepage/Shipping/Method/Available.php b/app/code/Mage/Checkout/Block/Onepage/Shipping/Method/Available.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Onepage/Shipping/Method/Available.php rename to app/code/Mage/Checkout/Block/Onepage/Shipping/Method/Available.php diff --git a/app/code/core/Mage/Checkout/Block/Onepage/Success.php b/app/code/Mage/Checkout/Block/Onepage/Success.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Onepage/Success.php rename to app/code/Mage/Checkout/Block/Onepage/Success.php diff --git a/app/code/core/Mage/Checkout/Block/Success.php b/app/code/Mage/Checkout/Block/Success.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Success.php rename to app/code/Mage/Checkout/Block/Success.php diff --git a/app/code/core/Mage/Checkout/Block/Total/Default.php b/app/code/Mage/Checkout/Block/Total/Default.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Total/Default.php rename to app/code/Mage/Checkout/Block/Total/Default.php diff --git a/app/code/core/Mage/Checkout/Block/Total/Nominal.php b/app/code/Mage/Checkout/Block/Total/Nominal.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Total/Nominal.php rename to app/code/Mage/Checkout/Block/Total/Nominal.php diff --git a/app/code/core/Mage/Checkout/Block/Total/Tax.php b/app/code/Mage/Checkout/Block/Total/Tax.php similarity index 100% rename from app/code/core/Mage/Checkout/Block/Total/Tax.php rename to app/code/Mage/Checkout/Block/Total/Tax.php diff --git a/app/code/core/Mage/Checkout/Controller/Action.php b/app/code/Mage/Checkout/Controller/Action.php similarity index 100% rename from app/code/core/Mage/Checkout/Controller/Action.php rename to app/code/Mage/Checkout/Controller/Action.php diff --git a/app/code/core/Mage/Checkout/Exception.php b/app/code/Mage/Checkout/Exception.php similarity index 100% rename from app/code/core/Mage/Checkout/Exception.php rename to app/code/Mage/Checkout/Exception.php diff --git a/app/code/core/Mage/Checkout/Helper/Cart.php b/app/code/Mage/Checkout/Helper/Cart.php similarity index 100% rename from app/code/core/Mage/Checkout/Helper/Cart.php rename to app/code/Mage/Checkout/Helper/Cart.php diff --git a/app/code/core/Mage/Checkout/Helper/Data.php b/app/code/Mage/Checkout/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Checkout/Helper/Data.php rename to app/code/Mage/Checkout/Helper/Data.php diff --git a/app/code/core/Mage/Checkout/Helper/Url.php b/app/code/Mage/Checkout/Helper/Url.php similarity index 100% rename from app/code/core/Mage/Checkout/Helper/Url.php rename to app/code/Mage/Checkout/Helper/Url.php diff --git a/app/code/core/Mage/Checkout/Model/Agreement.php b/app/code/Mage/Checkout/Model/Agreement.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Agreement.php rename to app/code/Mage/Checkout/Model/Agreement.php diff --git a/app/code/core/Mage/Checkout/Model/Api/Resource.php b/app/code/Mage/Checkout/Model/Api/Resource.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Api/Resource.php rename to app/code/Mage/Checkout/Model/Api/Resource.php diff --git a/app/code/core/Mage/Checkout/Model/Api/Resource/Customer.php b/app/code/Mage/Checkout/Model/Api/Resource/Customer.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Api/Resource/Customer.php rename to app/code/Mage/Checkout/Model/Api/Resource/Customer.php diff --git a/app/code/core/Mage/Checkout/Model/Api/Resource/Product.php b/app/code/Mage/Checkout/Model/Api/Resource/Product.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Api/Resource/Product.php rename to app/code/Mage/Checkout/Model/Api/Resource/Product.php diff --git a/app/code/core/Mage/Checkout/Model/Cart.php b/app/code/Mage/Checkout/Model/Cart.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Cart.php rename to app/code/Mage/Checkout/Model/Cart.php diff --git a/app/code/core/Mage/Checkout/Model/Cart/Api.php b/app/code/Mage/Checkout/Model/Cart/Api.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Cart/Api.php rename to app/code/Mage/Checkout/Model/Cart/Api.php diff --git a/app/code/core/Mage/Checkout/Model/Cart/Api/V2.php b/app/code/Mage/Checkout/Model/Cart/Api/V2.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Cart/Api/V2.php rename to app/code/Mage/Checkout/Model/Cart/Api/V2.php diff --git a/app/code/core/Mage/Checkout/Model/Cart/Coupon/Api.php b/app/code/Mage/Checkout/Model/Cart/Coupon/Api.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Cart/Coupon/Api.php rename to app/code/Mage/Checkout/Model/Cart/Coupon/Api.php diff --git a/app/code/core/Mage/Checkout/Model/Cart/Coupon/Api/V2.php b/app/code/Mage/Checkout/Model/Cart/Coupon/Api/V2.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Cart/Coupon/Api/V2.php rename to app/code/Mage/Checkout/Model/Cart/Coupon/Api/V2.php diff --git a/app/code/core/Mage/Checkout/Model/Cart/Customer/Api.php b/app/code/Mage/Checkout/Model/Cart/Customer/Api.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Cart/Customer/Api.php rename to app/code/Mage/Checkout/Model/Cart/Customer/Api.php diff --git a/app/code/core/Mage/Checkout/Model/Cart/Customer/Api/V2.php b/app/code/Mage/Checkout/Model/Cart/Customer/Api/V2.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Cart/Customer/Api/V2.php rename to app/code/Mage/Checkout/Model/Cart/Customer/Api/V2.php diff --git a/app/code/core/Mage/Checkout/Model/Cart/Interface.php b/app/code/Mage/Checkout/Model/Cart/Interface.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Cart/Interface.php rename to app/code/Mage/Checkout/Model/Cart/Interface.php diff --git a/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php b/app/code/Mage/Checkout/Model/Cart/Payment/Api.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php rename to app/code/Mage/Checkout/Model/Cart/Payment/Api.php diff --git a/app/code/core/Mage/Checkout/Model/Cart/Payment/Api/V2.php b/app/code/Mage/Checkout/Model/Cart/Payment/Api/V2.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Cart/Payment/Api/V2.php rename to app/code/Mage/Checkout/Model/Cart/Payment/Api/V2.php diff --git a/app/code/core/Mage/Checkout/Model/Cart/Product/Api.php b/app/code/Mage/Checkout/Model/Cart/Product/Api.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Cart/Product/Api.php rename to app/code/Mage/Checkout/Model/Cart/Product/Api.php diff --git a/app/code/core/Mage/Checkout/Model/Cart/Product/Api/V2.php b/app/code/Mage/Checkout/Model/Cart/Product/Api/V2.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Cart/Product/Api/V2.php rename to app/code/Mage/Checkout/Model/Cart/Product/Api/V2.php diff --git a/app/code/core/Mage/Checkout/Model/Cart/Shipping/Api.php b/app/code/Mage/Checkout/Model/Cart/Shipping/Api.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Cart/Shipping/Api.php rename to app/code/Mage/Checkout/Model/Cart/Shipping/Api.php diff --git a/app/code/core/Mage/Checkout/Model/Cart/Shipping/Api/V2.php b/app/code/Mage/Checkout/Model/Cart/Shipping/Api/V2.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Cart/Shipping/Api/V2.php rename to app/code/Mage/Checkout/Model/Cart/Shipping/Api/V2.php diff --git a/app/code/core/Mage/Checkout/Model/Config/Source/Cart/Summary.php b/app/code/Mage/Checkout/Model/Config/Source/Cart/Summary.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Config/Source/Cart/Summary.php rename to app/code/Mage/Checkout/Model/Config/Source/Cart/Summary.php diff --git a/app/code/core/Mage/Checkout/Model/Observer.php b/app/code/Mage/Checkout/Model/Observer.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Observer.php rename to app/code/Mage/Checkout/Model/Observer.php diff --git a/app/code/core/Mage/Checkout/Model/Resource/Agreement.php b/app/code/Mage/Checkout/Model/Resource/Agreement.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Checkout/Model/Resource/Agreement.php rename to app/code/Mage/Checkout/Model/Resource/Agreement.php diff --git a/app/code/core/Mage/Checkout/Model/Resource/Agreement/Collection.php b/app/code/Mage/Checkout/Model/Resource/Agreement/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Checkout/Model/Resource/Agreement/Collection.php rename to app/code/Mage/Checkout/Model/Resource/Agreement/Collection.php diff --git a/app/code/core/Mage/Checkout/Model/Resource/Cart.php b/app/code/Mage/Checkout/Model/Resource/Cart.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Checkout/Model/Resource/Cart.php rename to app/code/Mage/Checkout/Model/Resource/Cart.php diff --git a/app/code/core/Mage/Checkout/Model/Resource/Setup.php b/app/code/Mage/Checkout/Model/Resource/Setup.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Checkout/Model/Resource/Setup.php rename to app/code/Mage/Checkout/Model/Resource/Setup.php diff --git a/app/code/core/Mage/Checkout/Model/Session.php b/app/code/Mage/Checkout/Model/Session.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Session.php rename to app/code/Mage/Checkout/Model/Session.php diff --git a/app/code/core/Mage/Checkout/Model/Type/Abstract.php b/app/code/Mage/Checkout/Model/Type/Abstract.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Type/Abstract.php rename to app/code/Mage/Checkout/Model/Type/Abstract.php diff --git a/app/code/core/Mage/Checkout/Model/Type/Multishipping.php b/app/code/Mage/Checkout/Model/Type/Multishipping.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Type/Multishipping.php rename to app/code/Mage/Checkout/Model/Type/Multishipping.php diff --git a/app/code/core/Mage/Checkout/Model/Type/Multishipping/State.php b/app/code/Mage/Checkout/Model/Type/Multishipping/State.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Type/Multishipping/State.php rename to app/code/Mage/Checkout/Model/Type/Multishipping/State.php diff --git a/app/code/core/Mage/Checkout/Model/Type/Onepage.php b/app/code/Mage/Checkout/Model/Type/Onepage.php similarity index 100% rename from app/code/core/Mage/Checkout/Model/Type/Onepage.php rename to app/code/Mage/Checkout/Model/Type/Onepage.php diff --git a/app/code/Mage/Checkout/Model/Webhook/Observer.php b/app/code/Mage/Checkout/Model/Webhook/Observer.php new file mode 100644 index 0000000000000..44aa5ea4df70d --- /dev/null +++ b/app/code/Mage/Checkout/Model/Webhook/Observer.php @@ -0,0 +1,56 @@ +getEvent()->getOrder()) { + //single shipping order + Mage::helper('Mage_Webhook_Helper_Data')->dispatchEvent( + 'order/created', + array('order' => $order, 'shipping_address' => $order->getShippingAddress()) + ); + } else if ($observer->getEvent()->getOrders()) { + //multi shipping case + foreach ($observer->getEvent()->getOrders() as $order) { + Mage::helper('Mage_Webhook_Helper_Data')->dispatchEvent( + 'order/created', + array('order' => $order, 'shipping_address' => $order->getShippingAddress()) + ); + } + } + } catch (Exception $exception) { + Mage::logException($exception); + } + return $this; + } +} diff --git a/app/code/core/Mage/Checkout/controllers/CartController.php b/app/code/Mage/Checkout/controllers/CartController.php similarity index 100% rename from app/code/core/Mage/Checkout/controllers/CartController.php rename to app/code/Mage/Checkout/controllers/CartController.php diff --git a/app/code/core/Mage/Checkout/controllers/IndexController.php b/app/code/Mage/Checkout/controllers/IndexController.php similarity index 100% rename from app/code/core/Mage/Checkout/controllers/IndexController.php rename to app/code/Mage/Checkout/controllers/IndexController.php diff --git a/app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php b/app/code/Mage/Checkout/controllers/Multishipping/AddressController.php similarity index 100% rename from app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php rename to app/code/Mage/Checkout/controllers/Multishipping/AddressController.php diff --git a/app/code/core/Mage/Checkout/controllers/MultishippingController.php b/app/code/Mage/Checkout/controllers/MultishippingController.php similarity index 100% rename from app/code/core/Mage/Checkout/controllers/MultishippingController.php rename to app/code/Mage/Checkout/controllers/MultishippingController.php diff --git a/app/code/core/Mage/Checkout/controllers/OnepageController.php b/app/code/Mage/Checkout/controllers/OnepageController.php similarity index 100% rename from app/code/core/Mage/Checkout/controllers/OnepageController.php rename to app/code/Mage/Checkout/controllers/OnepageController.php diff --git a/app/code/Mage/Checkout/etc/adminhtml/acl.xml b/app/code/Mage/Checkout/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..8d324700be5e8 --- /dev/null +++ b/app/code/Mage/Checkout/etc/adminhtml/acl.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + diff --git a/app/code/Mage/Checkout/etc/adminhtml/menu.xml b/app/code/Mage/Checkout/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..cd2833735ffc7 --- /dev/null +++ b/app/code/Mage/Checkout/etc/adminhtml/menu.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/app/code/core/Mage/Checkout/etc/adminhtml/system.xml b/app/code/Mage/Checkout/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Checkout/etc/adminhtml/system.xml rename to app/code/Mage/Checkout/etc/adminhtml/system.xml diff --git a/app/code/core/Mage/Checkout/etc/api.xml b/app/code/Mage/Checkout/etc/api.xml similarity index 100% rename from app/code/core/Mage/Checkout/etc/api.xml rename to app/code/Mage/Checkout/etc/api.xml diff --git a/app/code/Mage/Checkout/etc/config.xml b/app/code/Mage/Checkout/etc/config.xml new file mode 100644 index 0000000000000..8198c4211ba6c --- /dev/null +++ b/app/code/Mage/Checkout/etc/config.xml @@ -0,0 +1,171 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + + Mage_Checkout + Mage_Checkout_Model_Resource_Setup + + + + + + + + + Mage_Checkout_Block_Total_Nominal + + + + + + + + + Mage_Checkout_Model_Webhook_Observer + orderAfterCreate + + + + + + + + /checkout/onepage + /checkout/multishipping + + + + + + Mage_Checkout_Model_Observer + loadCustomerQuote + + + + + + + Mage_Checkout_Model_Observer + unsetAll + + + + + + + Mage_Checkout_Model_Observer + salesQuoteSaveAfter + + + + + + + standard + + Mage_Checkout + checkout + + + + + + + + Mage_Checkout.csv + + + + + + + + layout.xml + + + + + + + + + + Mage_Checkout.csv + + + + + + + + + 1 + 1 + + + 30 + 1 + itself + parent + + + 1 + + + 1 + 3 + + + general + general + + + + + diff --git a/app/code/core/Mage/Checkout/etc/fieldset.xml b/app/code/Mage/Checkout/etc/fieldset.xml similarity index 100% rename from app/code/core/Mage/Checkout/etc/fieldset.xml rename to app/code/Mage/Checkout/etc/fieldset.xml diff --git a/app/code/core/Mage/Checkout/etc/jstranslator.xml b/app/code/Mage/Checkout/etc/jstranslator.xml similarity index 100% rename from app/code/core/Mage/Checkout/etc/jstranslator.xml rename to app/code/Mage/Checkout/etc/jstranslator.xml diff --git a/app/code/Mage/Checkout/etc/webapi/acl.xml b/app/code/Mage/Checkout/etc/webapi/acl.xml new file mode 100644 index 0000000000000..c3aa56206e5fa --- /dev/null +++ b/app/code/Mage/Checkout/etc/webapi/acl.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/code/core/Mage/Checkout/etc/wsdl.xml b/app/code/Mage/Checkout/etc/wsdl.xml similarity index 100% rename from app/code/core/Mage/Checkout/etc/wsdl.xml rename to app/code/Mage/Checkout/etc/wsdl.xml diff --git a/app/code/core/Mage/Checkout/etc/wsi.xml b/app/code/Mage/Checkout/etc/wsi.xml similarity index 100% rename from app/code/core/Mage/Checkout/etc/wsi.xml rename to app/code/Mage/Checkout/etc/wsi.xml diff --git a/app/code/core/Mage/Checkout/locale/de_DE/Mage_Checkout.csv b/app/code/Mage/Checkout/locale/de_DE/Mage_Checkout.csv similarity index 100% rename from app/code/core/Mage/Checkout/locale/de_DE/Mage_Checkout.csv rename to app/code/Mage/Checkout/locale/de_DE/Mage_Checkout.csv diff --git a/app/code/core/Mage/Checkout/locale/en_US/Mage_Checkout.csv b/app/code/Mage/Checkout/locale/en_US/Mage_Checkout.csv similarity index 100% rename from app/code/core/Mage/Checkout/locale/en_US/Mage_Checkout.csv rename to app/code/Mage/Checkout/locale/en_US/Mage_Checkout.csv diff --git a/app/code/core/Mage/Checkout/locale/es_ES/Mage_Checkout.csv b/app/code/Mage/Checkout/locale/es_ES/Mage_Checkout.csv similarity index 100% rename from app/code/core/Mage/Checkout/locale/es_ES/Mage_Checkout.csv rename to app/code/Mage/Checkout/locale/es_ES/Mage_Checkout.csv diff --git a/app/code/core/Mage/Checkout/locale/fr_FR/Mage_Checkout.csv b/app/code/Mage/Checkout/locale/fr_FR/Mage_Checkout.csv similarity index 100% rename from app/code/core/Mage/Checkout/locale/fr_FR/Mage_Checkout.csv rename to app/code/Mage/Checkout/locale/fr_FR/Mage_Checkout.csv diff --git a/app/code/core/Mage/Checkout/locale/nl_NL/Mage_Checkout.csv b/app/code/Mage/Checkout/locale/nl_NL/Mage_Checkout.csv similarity index 100% rename from app/code/core/Mage/Checkout/locale/nl_NL/Mage_Checkout.csv rename to app/code/Mage/Checkout/locale/nl_NL/Mage_Checkout.csv diff --git a/app/code/core/Mage/Checkout/locale/pt_BR/Mage_Checkout.csv b/app/code/Mage/Checkout/locale/pt_BR/Mage_Checkout.csv similarity index 100% rename from app/code/core/Mage/Checkout/locale/pt_BR/Mage_Checkout.csv rename to app/code/Mage/Checkout/locale/pt_BR/Mage_Checkout.csv diff --git a/app/code/core/Mage/Checkout/locale/zh_CN/Mage_Checkout.csv b/app/code/Mage/Checkout/locale/zh_CN/Mage_Checkout.csv similarity index 100% rename from app/code/core/Mage/Checkout/locale/zh_CN/Mage_Checkout.csv rename to app/code/Mage/Checkout/locale/zh_CN/Mage_Checkout.csv diff --git a/app/code/core/Mage/Checkout/sql/checkout_setup/install-1.6.0.0.php b/app/code/Mage/Checkout/sql/checkout_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Checkout/sql/checkout_setup/install-1.6.0.0.php rename to app/code/Mage/Checkout/sql/checkout_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Checkout/view/email/failed_payment.html b/app/code/Mage/Checkout/view/email/failed_payment.html similarity index 100% rename from app/code/core/Mage/Checkout/view/email/failed_payment.html rename to app/code/Mage/Checkout/view/email/failed_payment.html diff --git a/app/code/core/Mage/Checkout/view/frontend/cart.phtml b/app/code/Mage/Checkout/view/frontend/cart.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/cart.phtml rename to app/code/Mage/Checkout/view/frontend/cart.phtml diff --git a/app/code/core/Mage/Checkout/view/frontend/cart/coupon.phtml b/app/code/Mage/Checkout/view/frontend/cart/coupon.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/cart/coupon.phtml rename to app/code/Mage/Checkout/view/frontend/cart/coupon.phtml diff --git a/app/code/core/Mage/Checkout/view/frontend/cart/crosssell.phtml b/app/code/Mage/Checkout/view/frontend/cart/crosssell.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/cart/crosssell.phtml rename to app/code/Mage/Checkout/view/frontend/cart/crosssell.phtml diff --git a/app/code/core/Mage/Checkout/view/frontend/cart/item/configure/updatecart.phtml b/app/code/Mage/Checkout/view/frontend/cart/item/configure/updatecart.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/cart/item/configure/updatecart.phtml rename to app/code/Mage/Checkout/view/frontend/cart/item/configure/updatecart.phtml diff --git a/app/code/Mage/Checkout/view/frontend/cart/item/configure/updatecart.twig b/app/code/Mage/Checkout/view/frontend/cart/item/configure/updatecart.twig new file mode 100644 index 0000000000000..bd60b5b987aab --- /dev/null +++ b/app/code/Mage/Checkout/view/frontend/cart/item/configure/updatecart.twig @@ -0,0 +1,51 @@ +{# +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +#} +{% if product.isSalable %} +
    + {% if product.isGrouped == false %} + + + {% endif %} + + {{ getChildHtml('', true) }} +
    + + +{% endif %} + + diff --git a/app/code/Mage/Checkout/view/frontend/cart/item/default.phtml b/app/code/Mage/Checkout/view/frontend/cart/item/default.phtml new file mode 100644 index 0000000000000..f1c08e7d70ba9 --- /dev/null +++ b/app/code/Mage/Checkout/view/frontend/cart/item/default.phtml @@ -0,0 +1,278 @@ + +getItem(); +$isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility(); +$canApplyMsrp = Mage::helper('Mage_Catalog_Helper_Data')->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM); +?> + + hasProductUrl()):?><?php echo $this->escapeHtml($this->getProductName()) ?>hasProductUrl()):?> + +

    + hasProductUrl()):?> + escapeHtml($this->getProductName()) ?> + + escapeHtml($this->getProductName()) ?> + +

    + getOptionList()):?> +
    + + getFormatedOptionValue($_option) ?> +
    escapeHtml($_option['label']) ?>
    + class="truncated" data-mage-init="{truncateOptions:[]}"> + +
    +
    +
    escapeHtml($_option['label']) ?>
    +
    +
    +
    + + + +
    + + getMessages()): ?> + +

    * escapeHtml($message['text']) ?>

    + + + getProductAdditionalInformationBlock(); ?> + + setItem($_item)->toHtml() ?> + + + + + __('Edit') ?> + + + helper('Mage_Wishlist_Helper_Data')->isAllowInCart()) : ?> + + + __('Move'); ?> + + + + + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> colspan="2"> + + __('See price before order confirmation.'); ?> + getId(); ?> + __("What's this?"); ?> + + + + + + helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + + + + + typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?> + + helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()) ?> + + + + + + getApplied($_item)): ?> + + + + typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + __('Total'); ?>: helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?> +
    + + + + + helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item); ?> + typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + + + + + + typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?> + + helper('Mage_Checkout_Helper_Data')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?> + + + + getApplied($_item)): ?> + + + + typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + __('Total incl. tax'); ?>: helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?> +
    + + + + + + + + + helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()) && !$_item->getNoSubtotal()): ?> + + typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + + + + + + + -- + + typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> + + helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()) ?> + + + + + getApplied($_item)): ?> + + + + typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + __('Total'); ?>: helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> +
    + + + + + helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()) && !$_item->getNoSubtotal()): ?> + + helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item); ?> + typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + + + + + + + -- + + typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> + + helper('Mage_Checkout_Helper_Data')->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> + + + + + + + getApplied($_item)): ?> + + + + typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + __('Total incl. tax'); ?>: helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> +
    + + + + + __('Remove item')?> + diff --git a/app/code/core/Mage/Checkout/view/frontend/cart/noItems.phtml b/app/code/Mage/Checkout/view/frontend/cart/noItems.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/cart/noItems.phtml rename to app/code/Mage/Checkout/view/frontend/cart/noItems.phtml diff --git a/app/code/core/Mage/Checkout/view/frontend/cart/shipping.phtml b/app/code/Mage/Checkout/view/frontend/cart/shipping.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/cart/shipping.phtml rename to app/code/Mage/Checkout/view/frontend/cart/shipping.phtml diff --git a/app/code/core/Mage/Checkout/view/frontend/cart/sidebar.phtml b/app/code/Mage/Checkout/view/frontend/cart/sidebar.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/cart/sidebar.phtml rename to app/code/Mage/Checkout/view/frontend/cart/sidebar.phtml diff --git a/app/code/Mage/Checkout/view/frontend/cart/sidebar/default.phtml b/app/code/Mage/Checkout/view/frontend/cart/sidebar/default.phtml new file mode 100644 index 0000000000000..ea51294838110 --- /dev/null +++ b/app/code/Mage/Checkout/view/frontend/cart/sidebar/default.phtml @@ -0,0 +1,145 @@ + +getItem(); + $isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility(); + $canApplyMsrp = Mage::helper('Mage_Catalog_Helper_Data')->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM); +?> +
  • + hasProductUrl()): ?> + <?php echo $this->escapeHtml($this->getProductName()) ?> + + <?php echo $this->escapeHtml($this->getProductName()) ?> + +
    + __('Remove This Item') ?> + + __('Edit item')?> + +

    hasProductUrl()): ?>escapeHtml($this->getProductName()) ?>hasProductUrl()): ?>

    + getQty() ?> x + + + + __('See price before order confirmation.'); ?> + + + + helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + __('Excl. Tax'); ?>: + + typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?> + + helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()) ?> + + getApplied($_item)): ?> +
    + typeOfDisplay($_item, 1, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : formatPrice($tax['amount'],true,true); ?>
    + +
    + typeOfDisplay($_item, 2, 'sales')): ?> + getApplied($_item) as $tax): ?> + : formatPrice($tax['amount_incl_tax'],true,true); ?>
    + + typeOfDisplay($_item, 4, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : formatPrice($tax['amount_incl_tax'],true,true); ?>
    + +
    + + typeOfDisplay($_item, 2, 'sales')): ?> + __('Total'); ?>:
    helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>
    + + + + + + + helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item); ?> + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> +
    __('Incl. Tax'); ?>: + + typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?> + + helper('Mage_Checkout_Helper_Data')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?> + + getApplied($_item)): ?> +
    + typeOfDisplay($_item, 1, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : formatPrice($tax['amount'],true,true); ?>
    + +
    + typeOfDisplay($_item, 2, 'sales')): ?> + getApplied($_item) as $tax): ?> + : formatPrice($tax['amount_incl_tax'],true,true); ?>
    + + typeOfDisplay($_item, 4, 'sales')): ?> + + getApplied($_item) as $tax): ?> + : formatPrice($tax['amount_incl_tax'],true,true); ?>
    + +
    + + typeOfDisplay($_item, 2, 'sales')): ?> + __('Total incl. tax'); ?>:
    helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?>
    + + + + + + + getOptionList()):?> +
    +
    +
    + +
    escapeHtml($_option['label']) ?>
    +
    + + + + + +
    + +
    +
    + __('Details') ?> +
    + +
    +
  • diff --git a/app/code/core/Mage/Checkout/view/frontend/cart/totals.phtml b/app/code/Mage/Checkout/view/frontend/cart/totals.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/cart/totals.phtml rename to app/code/Mage/Checkout/view/frontend/cart/totals.phtml diff --git a/app/code/core/Mage/Checkout/view/frontend/cvv.gif b/app/code/Mage/Checkout/view/frontend/cvv.gif similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/cvv.gif rename to app/code/Mage/Checkout/view/frontend/cvv.gif diff --git a/app/code/Mage/Checkout/view/frontend/js/accordion.js b/app/code/Mage/Checkout/view/frontend/js/accordion.js new file mode 100644 index 0000000000000..e595f089b73c9 --- /dev/null +++ b/app/code/Mage/Checkout/view/frontend/js/accordion.js @@ -0,0 +1,58 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category mage checkout + * @package accordion + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +/*jshint jquery:true browser:true*/ +(function($) { + 'use strict'; + // mage.accordion base functionality + $.widget('mage.accordion', $.ui.accordion, { + options: { + heightStyle: 'content', + animate: false, + beforeActivate: function(e, ui) { + // Make sure sections below current are not clickable and sections above are clickable + var newPanelParent = $(ui.newPanel).parent(); + if (!newPanelParent.hasClass('allow')) { + return false; + } + newPanelParent.addClass('active allow').prevAll().addClass('allow'); + newPanelParent.nextAll().removeClass('allow'); + $(ui.oldPanel).parent().removeClass('active'); + } + }, + + /** + * Accordion creation + * @protected + */ + _create: function() { + // Custom to enable section + this.element.on('enableSection', function(event, data) { + $(data.selector).addClass('allow').find('h2').trigger('click'); + }); + this._super(); + $(this.options.activeSelector).addClass('allow active').find('h2').trigger('click'); + } + }); +})(jQuery); diff --git a/app/code/core/Mage/Checkout/view/frontend/js/discount-codes.js b/app/code/Mage/Checkout/view/frontend/js/discount-codes.js similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/js/discount-codes.js rename to app/code/Mage/Checkout/view/frontend/js/discount-codes.js diff --git a/app/code/Mage/Checkout/view/frontend/js/multi-shipping.js b/app/code/Mage/Checkout/view/frontend/js/multi-shipping.js new file mode 100644 index 0000000000000..279f7f8687d7b --- /dev/null +++ b/app/code/Mage/Checkout/view/frontend/js/multi-shipping.js @@ -0,0 +1,63 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category checkout multi-shipping addresses + * @package mage + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +/*jshint jquery:true*/ +(function($) { + "use strict"; + $.widget('mage.multiShipping', { + options: { + addNewAddressBtn: 'button[data-role="add-new-address"]', // Add a new multishipping address. + addNewAddressFlag: '#add_new_address_flag', // Hidden input field with value 0 or 1. + canContinueBtn: 'button[data-role="can-continue"]', // Continue (update quantity or go to shipping). + canContinueFlag: '#can_continue_flag' // Hidden input field with value 0 or 1. + }, + + /** + * Bind event handlers to click events for corresponding buttons. + * @private + */ + _create: function() { + $(this.options.addNewAddressBtn).on('click', $.proxy(this._addNewAddress, this)); + $(this.options.canContinueBtn).on('click', $.proxy(this._canContinue, this)); + }, + + /** + * Add a new address. Set the hidden input field and submit the form. Then enter a new shipping address. + * @private + */ + _addNewAddress: function() { + $(this.options.addNewAddressFlag).val(1); + this.element.submit(); + }, + + /** + * Can the user continue to the next step? The data-flag attribute holds either 0 (no) or 1 (yes). + * @private + * @param event {Event} - Click event on the corresponding button. + */ + _canContinue: function(event) { + $(this.options.canContinueFlag).val(parseInt($(event.currentTarget).data('flag'), 10)); + } + }); +})(jQuery); diff --git a/app/code/Mage/Checkout/view/frontend/js/opcheckout.js b/app/code/Mage/Checkout/view/frontend/js/opcheckout.js new file mode 100644 index 0000000000000..200e3a15bc750 --- /dev/null +++ b/app/code/Mage/Checkout/view/frontend/js/opcheckout.js @@ -0,0 +1,500 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category one page checkout first step + * @package mage + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +(function($, window) { + 'use strict'; + // Base widget, handle ajax events and first section(Checkout Method) in one page checkout accordion + $.widget('mage.opcheckout', { + options: { + checkout: { + loginGuestSelector: '#login\\:guest', + loginRegisterSelector: '#login\\:register', + loginFormSelector: '#login-form', + continueSelector: '#onepage-guest-register-button', + registerCustomerPasswordSelector: '#register-customer-password', + suggestRegistration: false + }, + sectionSelectorPrefix: '#opc-', + billingSection: 'billing', + ajaxLoaderPlaceButton: false, + updateSelectorPrefix: '#checkout-', + updateSelectorSuffix: '-load', + backSelector: '.back-link', + minBalance: 0.0001 + }, + + _create: function() { + var _this = this; + this.checkoutPrice = this.options.quoteBaseGrandTotal; + if (this.options.checkout.suggestRegistration) { + $(this.options.checkout.loginGuestSelector).prop('checked', false); + $(this.options.checkout.loginRegisterSelector).prop('checked', true); + } + this.element + .on('click', this.options.checkout.continueSelector, function() { + $.proxy(_this._continue($(this)), _this); + }) + .on('gotoSection', function(event, section) { + $.proxy(_this._ajaxUpdateProgress(section), _this); + _this.element.trigger('enableSection', {selector: _this.options.sectionSelectorPrefix + section}); + }) + .on('ajaxError', $.proxy(this._ajaxError, this)) + .on('click', this.options.backSelector, function() { + _this.element.trigger('enableSection', {selector: '#' + _this.element.find('.active').prev().attr('id')}); + }) + .on('click', '[data-action="login-form-submit"]', function() { + $(_this.options.checkout.loginFormSelector).submit(); + }); + $(this.options.checkoutProgressContainer).on('click', '[data-goto-section]', $.proxy(function(e) { + var gotoSection = $(e.target).data('goto-section'); + this._ajaxUpdateProgress(gotoSection); + this.element.trigger('enableSection', {selector: _this.options.sectionSelectorPrefix + gotoSection}); + return false; + }, this)); + }, + + /** + * Callback function for before ajax send event(global) + * @private + */ + _ajaxSend: function() { + var loader = this.element.find('.section.active .please-wait').show(); + if (this.options.ajaxLoaderPlaceButton) { + loader.siblings('.button').hide(); + } + }, + + /** + * Callback function for ajax complete event(global) + * @private + */ + _ajaxComplete: function() { + this.element.find('.please-wait').hide(); + if (this.options.ajaxLoaderPlaceButton) { + this.element.find('.button').show(); + } + }, + + /** + * ajax error for all onepage checkout ajax calls + * @private + */ + _ajaxError: function() { + window.location.href = this.options.failureUrl; + }, + + /** + * callback function when continue button is clicked + * @private + * @param elem - continue button + * @return {Boolean} + */ + _continue: function(elem) { + var json = elem.data('checkout'); + if (json.isGuestCheckoutAllowed) { + if ($(this.options.checkout.loginGuestSelector).is(':checked')) { + this._ajaxContinue(this.options.checkout.saveUrl, {method:'guest'}, this.options.billingSection); + this.element.find(this.options.checkout.registerCustomerPasswordSelector).hide(); + } else if ($(this.options.checkout.loginRegisterSelector).is(':checked')) { + this._ajaxContinue(this.options.checkout.saveUrl, {method:'register'}, this.options.billingSection); + this.element.find(this.options.checkout.registerCustomerPasswordSelector).show(); + } else { + alert($.mage.__('Please choose to register or to checkout as a guest')); + } + } + return false; + }, + + /** + * Ajax call to save checkout info to backend and enable next section in accordion + * @private + * @param url - ajax url + * @param data - post data for ajax call + * @param gotoSection - the section needs to show after ajax call + * @param successCallback - custom callback function in ajax success + */ + _ajaxContinue: function(url, data, gotoSection, successCallback) { + $.ajax({ + url: url, + type: 'post', + context: this, + data: data, + dataType: 'json', + beforeSend: this._ajaxSend, + complete: this._ajaxComplete, + success: function(response) { + if (successCallback) { + successCallback.call(this, response); + } + if ($.type(response) === 'object' && !$.isEmptyObject(response)) { + if (response.error) { + var msg = response.message; + if (msg) { + if ($.type(msg) === 'array') { + msg = msg.join("\n"); + } + $(this.options.countrySelector).trigger('change'); + alert($.mage.__(msg)); + } else { + alert($.mage.__(response.error)); + } + return; + } + if (response.redirect) { + $.mage.redirect(response.redirect); + return false; + } + else if (response.success) { + $.mage.redirect(this.options.review.successUrl); + return false; + } + if (response.update_section) { + if (response.update_section.name === 'payment-method' && response.update_section.html.indexOf('data-checkout-price')) { + this.element.find(this.options.payment.form).find('[data-checkout-price]').remove(); + } + $(this.options.updateSelectorPrefix + response.update_section.name + this.options.updateSelectorSuffix) + .html($(response.update_section.html)).trigger('contentUpdated'); + } + if (response.duplicateBillingInfo) { + $(this.options.shipping.copyBillingSelector).prop('checked', true).trigger('click'); + $(this.options.shipping.addressDropdownSelector).val($(this.options.billing.addressDropdownSelector).val()).change(); + } + if (response.goto_section) { + this.element.trigger('gotoSection', response.goto_section); + } + } else { + this.element.trigger('gotoSection', gotoSection); + } + } + }); + }, + + /** + * Update progress sidebar content + * @private + * @param toStep + */ + _ajaxUpdateProgress: function(toStep) { + if (toStep) { + $.ajax({ + url: this.options.progressUrl, + type: 'get', + async: false, + cache: false, + context: this, + data: toStep ? {toStep: toStep} : null, + success: function(response) { + $(this.options.checkoutProgressContainer).html(response); + } + }); + } + } + }); + + // Extension for mage.opcheckout - second section(Billing Information) in one page checkout accordion + $.widget('mage.opcheckout', $.mage.opcheckout, { + options: { + billing: { + addressDropdownSelector: '#billing-address-select', + newAddressFormSelector: '#billing-new-address-form', + continueSelector: '#billing-buttons-container .button', + form: '#co-billing-form' + } + }, + + _create: function() { + this._super(); + this.element + .on('change', this.options.billing.addressDropdownSelector, $.proxy(function(e) { + this.element.find(this.options.billing.newAddressFormSelector).toggle(!$(e.target).val()); + }, this)) + .on('click', this.options.billing.continueSelector, $.proxy(function() { + if ($(this.options.billing.form).validation && $(this.options.billing.form).validation('isValid')) { + this._billingSave(); + } + }, this)) + .find(this.options.billing.form).validation(); + } , + + _billingSave: function() { + this._ajaxContinue(this.options.billing.saveUrl, $(this.options.billing.form).serialize(), false, function() { + //Trigger indicating billing save. eg. GiftMessage listens to this to inject gift options + this.element.trigger('billingSave'); + }); + } + }); + + // Extension for mage.opcheckout - third section(Shipping Information) in one page checkout accordion + $.widget('mage.opcheckout', $.mage.opcheckout, { + options: { + shipping: { + form: '#co-shipping-form', + addressDropdownSelector: '#shipping-address-select', + newAddressFormSelector: '#shipping-new-address-form', + copyBillingSelector: '#shipping\\:same_as_billing', + countrySelector: '#shipping\\:country_id', + continueSelector:'#shipping-buttons-container .button' + } + }, + + _create: function() { + this._super(); + this.element + .on('change', this.options.shipping.addressDropdownSelector, $.proxy(function(e) { + $(this.options.shipping.newAddressFormSelector).toggle(!$(e.target).val()); + }, this)) + .on('input propertychange', this.options.shipping.form + ' :input[name]', $.proxy(function() { + $(this.options.shipping.copyBillingSelector).prop('checked', false); + }, this)) + .on('click', this.options.shipping.copyBillingSelector, $.proxy(function(e) { + if ($(e.target).is(':checked')) { + this._billingToShipping(); + } + }, this)) + .on('click', this.options.shipping.continueSelector, $.proxy(function() { + if ($(this.options.shipping.form).validation && $(this.options.shipping.form).validation('isValid')) { + this._ajaxContinue(this.options.shipping.saveUrl, $(this.options.shipping.form).serialize(), false, function() { + //Trigger indicating shipping save. eg. GiftMessage listens to this to inject gift options + this.element.trigger('shippingSave'); + }); + } + }, this)) + .find(this.options.shipping.form).validation(); + }, + + /** + * Copy billing address info to shipping address + * @private + */ + _billingToShipping: function() { + $(':input[name]', this.options.billing.form).each($.proxy(function(key, value) { + var fieldObj = $(value.id.replace('billing:', '#shipping\\:')); + fieldObj.val($(value).val()); + if (fieldObj.is("select")) { + fieldObj.trigger('change'); + } + }, this)); + $(this.options.shipping.copyBillingSelector).prop('checked', true); + } + }); + + // Extension for mage.opcheckout - fourth section(Shipping Method) in one page checkout accordion + $.widget('mage.opcheckout', $.mage.opcheckout, { + options: { + shippingMethod: { + continueSelector: '#shipping-method-buttons-container .button', + form: '#co-shipping-method-form' + } + }, + + _create: function() { + this._super(); + var _this = this; + this.element + .on('click', this.options.shippingMethod.continueSelector, $.proxy(function() { + if (this._validateShippingMethod()&& + $(this.options.shippingMethod.form).validation && + $(this.options.shippingMethod.form).validation('isValid')) { + this._ajaxContinue(this.options.shippingMethod.saveUrl, $(this.options.shippingMethod.form).serialize()); + } + }, this)) + .on('click', 'input[name="shipping_method"]', function() { + var selectedPrice = _this.shippingCodePrice[$(this).val()] || 0, + oldPrice = _this.shippingCodePrice[_this.currentShippingMethod] || 0; + _this.checkoutPrice = _this.checkoutPrice - oldPrice + selectedPrice; + _this.currentShippingMethod = $(this).val(); + }) + .on('contentUpdated', $.proxy(function() { + this.currentShippingMethod = this.element.find('input[name="shipping_method"]:checked').val(); + this.shippingCodePrice = this.element.find('[data-shipping-code-price]').data('shipping-code-price'); + }, this)) + .find(this.options.shippingMethod.form).validation(); + }, + + /** + * Make sure at least one shipping method is selected + * @return {Boolean} + * @private + */ + _validateShippingMethod: function() { + var methods = this.element.find('[name="shipping_method"]'); + if (methods.length === 0) { + alert($.mage.__('Your order cannot be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address.')); + return false; + } + if (methods.filter(':checked').length) { + return true; + } + alert($.mage.__('Please specify shipping method.')); + return false; + } + }); + + // Extension for mage.opcheckout - fifth section(Payment Information) in one page checkout accordion + $.widget('mage.opcheckout', $.mage.opcheckout, { + options: { + payment: { + continueSelector: '#payment-buttons-container .button', + form: '#co-payment-form', + methodsContainer: '#checkout-payment-method-load', + rewardPointsCheckBoxSelector: '#use-reward-points', + customerBalanceCheckBoxSelector: '#use-customer-balance', + freeInput: { + tmpl: '', + selector: '#hidden-free' + } + } + }, + + _create: function() { + this._super(); + this.element + .on('click', this.options.payment.continueSelector, $.proxy(function() { + if (this._validatePaymentMethod() && + $(this.options.payment.form).validation && + $(this.options.payment.form).validation('isValid')) { + this._ajaxContinue(this.options.payment.saveUrl, $(this.options.payment.form).serialize()); + } + }, this)) + .on('updateCheckoutPrice', $.proxy(function(event, data) { + if (data.price) { + this.checkoutPrice += data.price; + } + if (data.totalPrice) { + data.totalPrice = this.checkoutPrice; + } + if (this.checkoutPrice < this.options.minBalance) { + // Add free input field, hide and disable unchecked checkbox payment method and all radio button payment methods + this._disablePaymentMethods(); + } else { + // Remove free input field, show all payment method + this._enablePaymentMethods(); + } + }, this)) + .on('contentUpdated', this.options.payment.form, $.proxy(function() { + $(this.options.payment.form).find('dd [name^="payment["]').prop('disabled', true); + var checkoutPrice = this.element.find(this.options.payment.form).find('[data-checkout-price]').data('checkout-price'); + $(this.options.payment.customerBalanceCheckBoxSelector) + .prop({'checked':this.options.customerBalanceSubstracted, + 'disabled':false}).change().parent().show(); + $(this.options.payment.rewardPointsCheckBoxSelector) + .prop({'checked':this.options.rewardPointsSubstracted, + 'disabled':false}).change().parent().show(); + if ($.isNumeric(checkoutPrice)) { + this.checkoutPrice = checkoutPrice; + } + if (this.checkoutPrice < this.options.minBalance) { + this._disablePaymentMethods(); + } else { + this._enablePaymentMethods(); + } + }, this)) + .on('click', this.options.payment.form + ' dt input:radio', $.proxy(this._paymentMethodHandler, this)) + .find(this.options.payment.form).validation(); + }, + + /** + * Display payment details when payment method radio button is checked + * @private + * @param e + */ + _paymentMethodHandler: function(e) { + var _this = $(e.target), + parentsDl = _this.closest('dl'); + parentsDl.find('dt input:radio').prop('checked', false); + _this.prop('checked', true); + parentsDl.find('dd ul').hide().find('[name^="payment["]').prop('disabled', true); + _this.parent().nextUntil('dt').find('ul').show().find('[name^="payment["]').prop('disabled', false); + }, + + /** + * make sure one payment method is selected + * @private + * @return {Boolean} + */ + _validatePaymentMethod: function() { + var methods = this.element.find('[name^="payment["]'); + if (methods.length === 0) { + alert($.mage.__('Your order cannot be completed at this time as there is no payment methods available for it.')); + return false; + } + if (this.checkoutPrice < this.options.minBalance) { + return true; + } else if (methods.filter('input:radio:checked').length) { + return true; + } + alert($.mage.__('Please specify payment method.')); + return false; + }, + + /** + * Disable and enable payment methods + * @private + */ + _disablePaymentMethods: function() { + var paymentForm = $(this.options.payment.form); + paymentForm.find('input[name="payment[method]"]').prop('disabled', true); + paymentForm.find(this.options.payment.methodsContainer).hide().find('[name^="payment["]').prop('disabled', true); + paymentForm.find('input[id^="use"][name^="payment[use"]:not(:checked)').prop('disabled', true).parent().hide(); + paymentForm.find(this.options.payment.freeInput.selector).remove(); + $.tmpl(this.options.payment.freeInput.tmpl).appendTo(paymentForm); + }, + + /** + * Enable and enable payment methods + * @private + */ + _enablePaymentMethods: function() { + var paymentForm = $(this.options.payment.form); + paymentForm.find('input[name="payment[method]"]').prop('disabled', false); + paymentForm.find(this.options.payment.methodsContainer).show(); + paymentForm.find('input[id^="use"][name^="payment[use"]:not(:checked)').prop('disabled', false).parent().show(); + paymentForm.find(this.options.payment.freeInput.selector).remove(); + } + }); + + // Extension for mage.opcheckout - last section(Order Review) in one page checkout accordion + $.widget('mage.opcheckout', $.mage.opcheckout, { + options: { + review: { + continueSelector: '#review-buttons-container .button' + } + }, + + _create: function() { + this._super(); + this.element + .on('click', this.options.review.continueSelector, $.proxy(function() { + if ($(this.options.payment.form).validation && + $(this.options.payment.form).validation('isValid')) { + this._ajaxContinue( + this.options.review.saveUrl, + $(this.options.payment.form).serialize()); + } + }, this)); + } + }); +})(jQuery, window); \ No newline at end of file diff --git a/app/code/Mage/Checkout/view/frontend/js/overview.js b/app/code/Mage/Checkout/view/frontend/js/overview.js new file mode 100644 index 0000000000000..e2f53ed1d1345 --- /dev/null +++ b/app/code/Mage/Checkout/view/frontend/js/overview.js @@ -0,0 +1,61 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category checkout multi-shipping review order overview + * @package mage + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +/*jshint jquery:true*/ +/*global alert*/ +(function($) { + "use strict"; + $.widget('mage.orderOverview', { + options: { + opacity: 0.5, // CSS opacity for the 'Place Order' button when it's clicked and then disabled. + pleaseWaitLoader: 'span.please-wait', // 'Submitting order information...' Ajax loader. + placeOrderSubmit: 'button[type="submit"]', // The 'Place Order' button. + agreements: '#checkout-agreements' // Container for all of the checkout billing agreements. + }, + + /** + * Bind a submit handler to the form. + * @private + */ + _create: function() { + this.element.on('submit', $.proxy(this._showLoader, this)); + }, + + /** + * Verify that all agreements and terms/conditions are checked. Show the Ajax loader. Disable + * the submit button (i.e. Place Order). + * @return {Boolean} + * @private + */ + _showLoader: function() { + if ($(this.options.agreements).find('input[type="checkbox"]:not(:checked)').length > 0) { + alert($.mage.__('Please agree to all Terms and Conditions before placing the orders.')); + return false; + } + this.element.find(this.options.pleaseWaitLoader).show().end() + .find(this.options.placeOrderSubmit).prop('disabled', true).css('opacity', this.options.opacity); + return true; + } + }); +})(jQuery); diff --git a/app/code/Mage/Checkout/view/frontend/js/payment.js b/app/code/Mage/Checkout/view/frontend/js/payment.js new file mode 100644 index 0000000000000..0b514b939ab34 --- /dev/null +++ b/app/code/Mage/Checkout/view/frontend/js/payment.js @@ -0,0 +1,129 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category multshipping payment + * @package mage + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +(function($) { + 'use strict'; + $.widget('mage.payment', { + options: { + continueSelector: '#payment-continue', + methodsContainer: '#payment-methods', + minBalance: 0.0001, + tmpl: '' + }, + + _create: function() { + if (this.options.checkoutPrice < this.options.minBalance) { + this._disablePaymentMethods(); + } + this.element.find('dd [name^="payment["]').prop('disabled', true).end() + .on('click', this.options.continueSelector, $.proxy(this._submitHandler, this)) + .on('updateCheckoutPrice', $.proxy(function(event, data) { + //updating the checkoutPrice + if (data.price) { + this.options.checkoutPrice += data.price; + } + //updating total price + if (data.totalPrice) { + data.totalPrice = this.options.checkoutPrice; + } + if (this.options.checkoutPrice < this.options.minBalance) { + // Add free input field, hide and disable unchecked checkbox payment method and all radio button payment methods + this._disablePaymentMethods(); + } else { + // Remove free input field, show all payment method + this._enablePaymentMethods(); + } + }, this)) + .on('click', 'dt input:radio', $.proxy(this._paymentMethodHandler, this)); + }, + + /** + * Display payment details when payment method radio button is checked + * @private + * @param e + */ + _paymentMethodHandler: function(e) { + var element = $(e.target), + parentsDl = element.closest('dl'); + parentsDl.find('dt input:radio').prop('checked', false); + parentsDl.find('dd ul').hide().find('[name^="payment["]').prop('disabled', true); + element.prop('checked', true).parent().nextUntil('dt').find('ul').show().find('[name^="payment["]').prop('disabled', false); + }, + + /** + * make sure one payment method is selected + * @private + * @return {Boolean} + */ + _validatePaymentMethod: function() { + var methods = this.element.find('[name^="payment["]'), + isValid = false; + if (methods.length === 0) { + alert($.mage.__('Your order cannot be completed at this time as there is no payment methods available for it.')); + } + else if (methods.filter(':checked').length) { + isValid = true; + } else { + alert($.mage.__('Please specify payment method.')); + } + return isValid; + }, + + /** + * Disable and enable payment methods + * @private + */ + _disablePaymentMethods: function() { + this.element.find('input[name="payment[method]"]').prop('disabled', true).end() + .find('input[id^="use"][name^="payment[use"]:not(:checked)').prop('disabled', true).parent().hide(); + this.element.find('[name="payment[method]"][value="free"]').parent('dt').remove(); + this.element.find(this.options.methodsContainer).hide().find('[name^="payment["]').prop('disabled', true); + $.tmpl(this.options.tmpl).appendTo(this.element); + }, + + /** + * Enable and enable payment methods + * @private + */ + _enablePaymentMethods: function() { + this.element.find('input[name="payment[method]"]').prop('disabled', false).end() + .find('input[name="payment[method]"][value="free"]').remove().end() + .find('input[id^="use"][name^="payment[use"]:not(:checked)').prop('disabled', false).parent().show(); + this.element.find(this.options.methodsContainer).show(); + }, + + /** + * Validate before form submit + * @private + */ + _submitHandler: function(e) { + e.preventDefault(); + if (this._validatePaymentMethod()) { + this.element.submit(); + } + } + }); +})(jQuery); \ No newline at end of file diff --git a/app/code/core/Mage/Checkout/view/frontend/js/region-updater.js b/app/code/Mage/Checkout/view/frontend/js/region-updater.js similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/js/region-updater.js rename to app/code/Mage/Checkout/view/frontend/js/region-updater.js diff --git a/app/code/core/Mage/Checkout/view/frontend/js/shopping-cart.js b/app/code/Mage/Checkout/view/frontend/js/shopping-cart.js similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/js/shopping-cart.js rename to app/code/Mage/Checkout/view/frontend/js/shopping-cart.js diff --git a/app/code/core/Mage/Checkout/view/frontend/js/sidebar.js b/app/code/Mage/Checkout/view/frontend/js/sidebar.js similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/js/sidebar.js rename to app/code/Mage/Checkout/view/frontend/js/sidebar.js diff --git a/app/code/Mage/Checkout/view/frontend/layout.xml b/app/code/Mage/Checkout/view/frontend/layout.xml new file mode 100644 index 0000000000000..87dd8f2a5f644 --- /dev/null +++ b/app/code/Mage/Checkout/view/frontend/layout.xml @@ -0,0 +1,415 @@ + + + + + + + + + + + + + + + + + + simpleMage_Checkout_Block_Cart_Item_Renderer + groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped + configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable + + + + + + + + + + + + + cart.phtml + cart/noItems.phtml + + simpleMage_Checkout_Block_Cart_Item_Renderer + groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped + configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + defaultMage_Checkout_Block_Cart_Item_Renderer + groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped + configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable + + + + + + + + + + + + + defaultMage_Checkout_Block_Cart_Item_Renderer + groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped + configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable + + + defaultMage_Checkout_Block_Cart_Item_Renderer + groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped + configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable + + + + + + + + + + + + + + purchaseorder + + + + + + + + + + + + + + + + defaultMage_Checkout_Block_Cart_Item_Renderer + groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped + configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable + groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped + configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + purchaseorder + + + + + + + + + + + + + + + + + + + + + + + + + + purchaseorder + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + defaultMage_Checkout_Block_Cart_Item_Renderer + groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped + configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/core/Mage/Checkout/view/frontend/multishipping/address/select.phtml b/app/code/Mage/Checkout/view/frontend/multishipping/address/select.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/multishipping/address/select.phtml rename to app/code/Mage/Checkout/view/frontend/multishipping/address/select.phtml diff --git a/app/code/Mage/Checkout/view/frontend/multishipping/addresses.phtml b/app/code/Mage/Checkout/view/frontend/multishipping/addresses.phtml new file mode 100644 index 0000000000000..4fcceb2af64b9 --- /dev/null +++ b/app/code/Mage/Checkout/view/frontend/multishipping/addresses.phtml @@ -0,0 +1,93 @@ + + +getMessagesBlock()->getGroupedHtml() ?> +
    +
    +
    +

    __('Ship to Multiple Addresses') ?>

    + +
    + + +

    __('Please select shipping address for applicable items') ?>

    + + + + + + + + + + + + + + + + + + + + getItems() as $_index => $_item): ?> + getQuoteItem()) :?> + + + + + + + + + +
    __('Product') ?>__('Qty') ?>__('Send To') ?> 
    getItemHtml($_item->getQuoteItem())?>getProduct()->getIsVirtual()): echo $this->__('Shipping selection is not applicable.'); else: echo $this->getAddressesHtmlSelect($_item, $_index); endif; ?>__('Remove Item') ?>
    + +
    + + +
    +
    +
    + diff --git a/app/code/core/Mage/Checkout/view/frontend/multishipping/agreements.phtml b/app/code/Mage/Checkout/view/frontend/multishipping/agreements.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/multishipping/agreements.phtml rename to app/code/Mage/Checkout/view/frontend/multishipping/agreements.phtml diff --git a/app/code/Mage/Checkout/view/frontend/multishipping/billing.phtml b/app/code/Mage/Checkout/view/frontend/multishipping/billing.phtml new file mode 100644 index 0000000000000..6557a43679a88 --- /dev/null +++ b/app/code/Mage/Checkout/view/frontend/multishipping/billing.phtml @@ -0,0 +1,103 @@ + + +
    +
    +

    __('Billing Information') ?>

    +
    + getMessagesBlock()->getGroupedHtml() ?> +
    +
    +
    +
    +
    +

    __('Billing Address') ?> | __('Change') ?>

    +
    +
    + getAddress() ?> +
    format('html') ?>
    +
    +
    +
    +
    +
    +
    +

    __('Payment Method') ?>

    +
    +
    + +
    + getMethods(); + $_methodsCount = count($_methods); + ?> + getCode() ?> +
    + 1): ?> + getSelectedMethodCode()==$_code): ?> checked="checked" class="radio" /> + + + + +
    + getChildHtml('payment.method.'.$_code)) : ?> +
    + +
    + + +
    + getChildHtml('checkout_billing_items') ?> +
    +
    +
    +
    +
    + + +
    +
    + +
    diff --git a/app/code/core/Mage/Checkout/view/frontend/multishipping/billing/items.phtml b/app/code/Mage/Checkout/view/frontend/multishipping/billing/items.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/multishipping/billing/items.phtml rename to app/code/Mage/Checkout/view/frontend/multishipping/billing/items.phtml diff --git a/app/code/Mage/Checkout/view/frontend/multishipping/item/default.phtml b/app/code/Mage/Checkout/view/frontend/multishipping/item/default.phtml new file mode 100644 index 0000000000000..9f29bfc973412 --- /dev/null +++ b/app/code/Mage/Checkout/view/frontend/multishipping/item/default.phtml @@ -0,0 +1,45 @@ + +

    escapeHtml($this->getProductName()) ?>

    +getOptionList()):?> +
    + + getFormatedOptionValue($_option) ?> +
    escapeHtml($_option['label']) ?>
    + class="truncated" data-mage-init="{truncateOptions:[]}"> + +
    +
    +
    escapeHtml($_option['label']) ?>
    +
    +
    +
    + + + +
    + diff --git a/app/code/core/Mage/Checkout/view/frontend/multishipping/link.phtml b/app/code/Mage/Checkout/view/frontend/multishipping/link.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/multishipping/link.phtml rename to app/code/Mage/Checkout/view/frontend/multishipping/link.phtml diff --git a/app/code/core/Mage/Checkout/view/frontend/multishipping/overview.phtml b/app/code/Mage/Checkout/view/frontend/multishipping/overview.phtml similarity index 90% rename from app/code/core/Mage/Checkout/view/frontend/multishipping/overview.phtml rename to app/code/Mage/Checkout/view/frontend/multishipping/overview.phtml index 473fd8fc61907..b72b71cdd6ac6 100644 --- a/app/code/core/Mage/Checkout/view/frontend/multishipping/overview.phtml +++ b/app/code/Mage/Checkout/view/frontend/multishipping/overview.phtml @@ -30,7 +30,7 @@

    __('Review Order') ?>

    getMessagesBlock()->getGroupedHtml() ?> -
    +

    __('Billing Information') ?>

    @@ -132,7 +132,7 @@ - +
    getShippingAddressCount()!=$_index+1): ?>
    @@ -182,7 +182,7 @@ - +
    @@ -210,33 +210,8 @@
    diff --git a/app/code/core/Mage/Checkout/view/frontend/multishipping/overview/item.phtml b/app/code/Mage/Checkout/view/frontend/multishipping/overview/item.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/multishipping/overview/item.phtml rename to app/code/Mage/Checkout/view/frontend/multishipping/overview/item.phtml diff --git a/app/code/core/Mage/Checkout/view/frontend/multishipping/shipping.phtml b/app/code/Mage/Checkout/view/frontend/multishipping/shipping.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/multishipping/shipping.phtml rename to app/code/Mage/Checkout/view/frontend/multishipping/shipping.phtml diff --git a/app/code/core/Mage/Checkout/view/frontend/multishipping/state.phtml b/app/code/Mage/Checkout/view/frontend/multishipping/state.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/multishipping/state.phtml rename to app/code/Mage/Checkout/view/frontend/multishipping/state.phtml diff --git a/app/code/core/Mage/Checkout/view/frontend/multishipping/success.phtml b/app/code/Mage/Checkout/view/frontend/multishipping/success.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/multishipping/success.phtml rename to app/code/Mage/Checkout/view/frontend/multishipping/success.phtml diff --git a/app/code/Mage/Checkout/view/frontend/onepage.phtml b/app/code/Mage/Checkout/view/frontend/onepage.phtml new file mode 100644 index 0000000000000..f3c56a32a1b7c --- /dev/null +++ b/app/code/Mage/Checkout/view/frontend/onepage.phtml @@ -0,0 +1,98 @@ + +getLayout()->getBlock('checkout.onepage.payment'); +$_registerParam = $this->getRequest()->getParam('register'); +?> +
    +

    __('Checkout') ?>

    +
    +
      +getSteps() as $_stepId => $_stepInfo): ?> +getChildBlock($_stepId) || !$this->getChildBlock($_stepId)->isShow()): continue; endif; $i++ ?> +
    1. +
      + +

      + __('Edit') ?> +
      + +
    2. + +
    + diff --git a/app/code/core/Mage/Checkout/view/frontend/onepage/accordion.js b/app/code/Mage/Checkout/view/frontend/onepage/accordion.js similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/onepage/accordion.js rename to app/code/Mage/Checkout/view/frontend/onepage/accordion.js diff --git a/app/code/core/Mage/Checkout/view/frontend/onepage/agreements.phtml b/app/code/Mage/Checkout/view/frontend/onepage/agreements.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/onepage/agreements.phtml rename to app/code/Mage/Checkout/view/frontend/onepage/agreements.phtml diff --git a/app/code/Mage/Checkout/view/frontend/onepage/billing.phtml b/app/code/Mage/Checkout/view/frontend/onepage/billing.phtml new file mode 100644 index 0000000000000..18ef4f936d73b --- /dev/null +++ b/app/code/Mage/Checkout/view/frontend/onepage/billing.phtml @@ -0,0 +1,216 @@ + +
    +
    +
      + customerHasAddresses()): ?> +
    • + +
      + getAddressesHtmlSelect('billing') ?> +
      +
    • + +
    • customerHasAddresses()): ?> style="display:none;"> +
      + +
        +
      • getLayout()->createBlock('Mage_Customer_Block_Widget_Name')->setObject($this->getAddress()->getFirstname() ? $this->getAddress() : $this->getQuote()->getCustomer())->setForceUseCustomerRequiredAttributes(!$this->isCustomerLoggedIn())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
      • +
      • +
        + +
        + +
        +
        + isCustomerLoggedIn()): ?> +
        + +
        + +
        +
        + +
      • + helper('Mage_Customer_Helper_Address')->getAttributeValidationClass('street'); ?> +
      • + +
        + +
        +
      • + + helper('Mage_Customer_Helper_Address')->getStreetLines(); $_i <= $_n; $_i++): ?> +
      • +
        + +
        +
      • + + helper('Mage_Customer_Helper_Address')->isVatAttributeVisible()) : ?> +
      • + +
        + +
        +
      • + +
      • +
        + +
        + +
        +
        +
        + +
        + + +
        +
        +
      • +
      • +
        + +
        + +
        +
        +
        + +
        + getCountryHtmlSelect('billing') ?> +
        +
        +
      • +
      • +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
      • + isCustomerLoggedIn()): ?> + + getLayout()->createBlock('Mage_Customer_Block_Widget_Dob') ?> + getLayout()->createBlock('Mage_Customer_Block_Widget_Gender') ?> + isEnabled() || $_gender->isEnabled()): ?> +
      • + isEnabled()): ?> +
        + setDate($this->getQuote()->getCustomerDob())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?> +
        + + isEnabled()): ?> +
        + setGender($this->getQuote()->getCustomerGender())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?> +
        + +
      • + + + getLayout()->createBlock('Mage_Customer_Block_Widget_Taxvat') ?> + isEnabled()): ?> +
      • + setTaxvat($this->getQuote()->getCustomerTaxvat())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?> +
      • + + +
      • +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
      • + + isCustomerLoggedIn() && $this->customerHasAddresses()):?> +
      • + getAddress()->getSaveInAddressBook()):?> checked="checked" class="checkbox" /> +
      • + +
      • + + getChildHtml('form.additional.info'); ?> +
      +
      +
    • + + getChildHtml('checkout.onepage.billing.extra')?> + canShip()): ?> +
    • + isUseBillingAddressForShipping()) {?> checked="checked" title="__('Ship to this address') ?>" class="radio" />
    • +
    • + isUseBillingAddressForShipping()) {?> checked="checked" title="__('Ship to different address') ?>" class="radio" /> +
    • + +
    + canShip()): ?> + + +
    +

    __('* Required Fields') ?>

    + + +
    +
    +
    + diff --git a/app/code/core/Mage/Checkout/view/frontend/onepage/failure.phtml b/app/code/Mage/Checkout/view/frontend/onepage/failure.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/onepage/failure.phtml rename to app/code/Mage/Checkout/view/frontend/onepage/failure.phtml diff --git a/app/code/core/Mage/Checkout/view/frontend/onepage/link.phtml b/app/code/Mage/Checkout/view/frontend/onepage/link.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/onepage/link.phtml rename to app/code/Mage/Checkout/view/frontend/onepage/link.phtml diff --git a/app/code/Mage/Checkout/view/frontend/onepage/login.phtml b/app/code/Mage/Checkout/view/frontend/onepage/login.phtml new file mode 100644 index 0000000000000..53c1dc97569a8 --- /dev/null +++ b/app/code/Mage/Checkout/view/frontend/onepage/login.phtml @@ -0,0 +1,120 @@ + + +getChildHtml('checkout.onepage.login.extra')?> +
    + getChildHtml('login_before')?> +
    +

    isAllowedGuestCheckout() ): ?>__('Checkout as a Guest or Register') ?>__('Register to Create an Account') ?>

    + isAllowedGuestCheckout() ): ?> +

    __('Register with us for future convenience:') ?>

    + +

    __('Register and save time!') ?>
    + __('Register with us for future convenience:') ?>

    +
      +
    • __('Fast and easy check out') ?>
    • +
    • __('Easy access to your order history and status') ?>
    • +
    + + isAllowedGuestCheckout() ): ?> +
      + isAllowedGuestCheckout() ): ?> +
    • + getQuote()->getCheckoutMethod()==Mage_Checkout_Model_Type_Onepage::METHOD_GUEST): ?> checked="checked" class="radio" /> +
    • + +
    • + getQuote()->getCheckoutMethod()==Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER || !$this->isAllowedGuestCheckout()): ?> checked="checked" class="radio" /> +
    • +
    +

    __('Register and save time!') ?>

    +

    __('Register with us for future convenience:') ?>

    +
      +
    • __('Fast and easy check out') ?>
    • +
    • __('Easy access to your order history and status') ?>
    • +
    + + + +
    +
    +

    __('Login') ?>

    + getMessagesBlock()->getGroupedHtml() ?> +
    +
    +

    __('Already registered?') ?>

    +

    __('Please log in below:') ?>

    +
      +
    • + +
      + +
      +
    • +
    • + +
      + +
      +
    • + getChildHtml('login.form.additional.info'); ?> +
    +
    +
    +
    +
    +
    +
    +
    +

     

    + + +
    +
    +
    +
    +

    __('* Required Fields') ?>

    + __('Forgot your password?') ?> + +
    +
    +
    + diff --git a/app/code/Mage/Checkout/view/frontend/onepage/payment.phtml b/app/code/Mage/Checkout/view/frontend/onepage/payment.phtml new file mode 100644 index 0000000000000..5b08c1b4f0c1d --- /dev/null +++ b/app/code/Mage/Checkout/view/frontend/onepage/payment.phtml @@ -0,0 +1,39 @@ + +
    +
    + getChildHtml('methods') ?> +
    +
    +
    +

    __('* Required Fields') ?>

    + + + +
    \ No newline at end of file diff --git a/app/code/core/Mage/Checkout/view/frontend/onepage/payment/methods.phtml b/app/code/Mage/Checkout/view/frontend/onepage/payment/methods.phtml similarity index 83% rename from app/code/core/Mage/Checkout/view/frontend/onepage/payment/methods.phtml rename to app/code/Mage/Checkout/view/frontend/onepage/payment/methods.phtml index c8c034762313b..a995ef8f1e1c3 100644 --- a/app/code/core/Mage/Checkout/view/frontend/onepage/payment/methods.phtml +++ b/app/code/Mage/Checkout/view/frontend/onepage/payment/methods.phtml @@ -46,7 +46,7 @@ ?>
    - getSelectedMethodCode()==$_code): ?> checked="checked" class="radio" /> + getSelectedMethodCode()==$_code): ?> checked="checked" class="radio" /> @@ -62,13 +62,5 @@ endif; ?> +
    getChildChildHtml('additional'); ?> - diff --git a/app/code/core/Mage/Checkout/view/frontend/onepage/progress.phtml b/app/code/Mage/Checkout/view/frontend/onepage/progress.phtml similarity index 89% rename from app/code/core/Mage/Checkout/view/frontend/onepage/progress.phtml rename to app/code/Mage/Checkout/view/frontend/onepage/progress.phtml index 0096c03eacf75..13eebcd0ec0dd 100644 --- a/app/code/core/Mage/Checkout/view/frontend/onepage/progress.phtml +++ b/app/code/Mage/Checkout/view/frontend/onepage/progress.phtml @@ -35,7 +35,7 @@ isStepComplete('billing')): ?>
    __('Billing Address') ?> | - __('Change') ?> + __('Change') ?>
    getBilling()->format('html') ?>
    @@ -51,7 +51,7 @@ isStepComplete('shipping')): ?>
    __('Shipping Address') ?> | - __('Change') ?> + __('Change') ?>
    getShipping()->format('html') ?>
    @@ -67,7 +67,7 @@ isStepComplete('shipping_method')): ?>
    __('Shipping Method') ?> | - __('Change') ?> + __('Change') ?>
    getShippingMethod()): ?> @@ -99,7 +99,7 @@ isStepComplete('payment')): ?>
    __('Payment Method') ?> | - __('Change') ?> + __('Change') ?>
    getPaymentHtml() ?> diff --git a/app/code/core/Mage/Checkout/view/frontend/onepage/review.phtml b/app/code/Mage/Checkout/view/frontend/onepage/review.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/onepage/review.phtml rename to app/code/Mage/Checkout/view/frontend/onepage/review.phtml diff --git a/app/code/Mage/Checkout/view/frontend/onepage/review/button.phtml b/app/code/Mage/Checkout/view/frontend/onepage/review/button.phtml new file mode 100644 index 0000000000000..2afc330775258 --- /dev/null +++ b/app/code/Mage/Checkout/view/frontend/onepage/review/button.phtml @@ -0,0 +1,27 @@ + + diff --git a/app/code/Mage/Checkout/view/frontend/onepage/review/info.phtml b/app/code/Mage/Checkout/view/frontend/onepage/review/info.phtml new file mode 100644 index 0000000000000..a1163a574b0d1 --- /dev/null +++ b/app/code/Mage/Checkout/view/frontend/onepage/review/info.phtml @@ -0,0 +1,74 @@ +\ +getChildHtml('items_before'); ?> +
    + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): $colspan = $rowspan = 2; else: $colspan = $rowspan = 1; endif; ?> + + + + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + + + + + + + + + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + + + + + + + + getChildHtml('totals'); ?> + + getItems() as $_item): ?> + getItemHtml($_item)?> + + +
    __('Product Name') ?>__('Price') ?>__('Qty') ?>__('Subtotal') ?>
    helper('Mage_Tax_Helper_Data')->getIncExcTaxLabel(false) ?>helper('Mage_Tax_Helper_Data')->getIncExcTaxLabel(true) ?>helper('Mage_Tax_Helper_Data')->getIncExcTaxLabel(false) ?>helper('Mage_Tax_Helper_Data')->getIncExcTaxLabel(true) ?>
    +
    +getChildHtml('items_after'); ?> + +
    + getChildHtml('agreements') ?> +
    +

    __('Forgot an Item?') ?> __('Edit Your Cart') ?>

    + getChildHtml('button') ?> + +
    +
    diff --git a/app/code/Mage/Checkout/view/frontend/onepage/review/item.phtml b/app/code/Mage/Checkout/view/frontend/onepage/review/item.phtml new file mode 100644 index 0000000000000..066644b02b423 --- /dev/null +++ b/app/code/Mage/Checkout/view/frontend/onepage/review/item.phtml @@ -0,0 +1,239 @@ + +getItem()?> + +

    escapeHtml($this->getProductName()) ?>

    + getOptionList()):?> +
    + + getFormatedOptionValue($_option) ?> +
    escapeHtml($_option['label']) ?>
    + class="truncated" data-mage-init="{truncateOptions:[]}"> + +
    +
    +
    escapeHtml($_option['label']) ?>
    +
    +
    +
    + +
    + + + + getProductAdditionalInformationBlock()):?> + setItem($_item)->toHtml() ?> + + + helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + + + + + + typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?> + + helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()) ?> + + + + + + getApplied($_item)): ?> + + + + typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + __('Total'); ?>:
    helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>
    +
    + + + + + helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item); ?> + typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + + + + + + typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?> + + helper('Mage_Checkout_Helper_Data')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?> + + + + getApplied($_item)): ?> + + + + typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + __('Total incl. tax'); ?>:
    helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?>
    +
    + + + + + getQty() ?> + helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + + + + + + typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> + + helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()) ?> + + + + getApplied($_item)): ?> + + + + typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + __('Total'); ?>:
    helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?>
    +
    + + + + + helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item); ?> + typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + + + + + + typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> + + helper('Mage_Checkout_Helper_Data')->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> + + + + + + getApplied($_item)): ?> + + + + typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + __('Total incl. tax'); ?>:
    helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
    +
    + + + + + diff --git a/app/code/core/Mage/Checkout/view/frontend/onepage/review/totals.phtml b/app/code/Mage/Checkout/view/frontend/onepage/review/totals.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/onepage/review/totals.phtml rename to app/code/Mage/Checkout/view/frontend/onepage/review/totals.phtml diff --git a/app/code/core/Mage/Checkout/view/frontend/onepage/shipping.phtml b/app/code/Mage/Checkout/view/frontend/onepage/shipping.phtml similarity index 84% rename from app/code/core/Mage/Checkout/view/frontend/onepage/shipping.phtml rename to app/code/Mage/Checkout/view/frontend/onepage/shipping.phtml index 7104b52555d24..fec1fe5606755 100644 --- a/app/code/core/Mage/Checkout/view/frontend/onepage/shipping.phtml +++ b/app/code/Mage/Checkout/view/frontend/onepage/shipping.phtml @@ -38,12 +38,12 @@
      -
    • getLayout()->createBlock('Mage_Customer_Block_Widget_Name')->setObject($this->getAddress())->setFieldIdFormat('shipping:%s')->setFieldNameFormat('shipping[%s]')->setFieldParams('onchange="shipping.setSameAsBilling(false)"')->toHtml() ?>
    • +
    • getLayout()->createBlock('Mage_Customer_Block_Widget_Name')->setObject($this->getAddress())->setFieldIdFormat('shipping:%s')->setFieldNameFormat('shipping[%s]')->toHtml() ?>
    • - +
    • @@ -51,14 +51,14 @@
    • - +
    • helper('Mage_Customer_Helper_Address')->getStreetLines(); $_i <= $_n; $_i++): ?>
    • - +
    • @@ -74,7 +74,7 @@
      - +
      @@ -91,7 +91,7 @@
      - +
      @@ -105,19 +105,19 @@
      - +
      - +
      isCustomerLoggedIn() && $this->customerHasAddresses()):?>
    • - getAddress()->getSaveInAddressBook()):?> checked="checked" class="checkbox" />
    • + getAddress()->getSaveInAddressBook()):?> checked="checked" class="checkbox" />
    • @@ -125,27 +125,18 @@
  • - getAddress()->getSameAsBilling()): ?> checked="checked" title="__('Use Billing Address') ?>" onclick="shipping.setSameAsBilling(this.checked)" class="checkbox" /> + getAddress()->getSameAsBilling()): ?> checked="checked" title="__('Use Billing Address') ?>" class="checkbox" />
  • __('* Required Fields') ?>

    - - + +
    -
    getChildHtml('additional') ?>
    - - + + diff --git a/app/code/core/Mage/Checkout/view/frontend/onepage/shipping_method/additional.phtml b/app/code/Mage/Checkout/view/frontend/onepage/shipping_method/additional.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/onepage/shipping_method/additional.phtml rename to app/code/Mage/Checkout/view/frontend/onepage/shipping_method/additional.phtml diff --git a/app/code/Mage/Checkout/view/frontend/onepage/shipping_method/available.phtml b/app/code/Mage/Checkout/view/frontend/onepage/shipping_method/available.phtml new file mode 100644 index 0000000000000..54f98a22f9b72 --- /dev/null +++ b/app/code/Mage/Checkout/view/frontend/onepage/shipping_method/available.phtml @@ -0,0 +1,65 @@ + + +getShippingRates(); ?> + +

    __('Sorry, no quotes are available for this order at this time.') ?>

    + +
    + + $_rates): ?> +
    escapeHtml($this->getCarrierName($code)) ?>
    +
    +
      + + getCode().'":'.(float)$_rate->getPrice(); ?> +
    • + getErrorMessage()): ?> +
        • escapeHtml($_rate->getErrorMessage()) ?>
      + + + + + getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio"/> + + + +
    • + +
    +
    + +
    +
    + diff --git a/app/code/core/Mage/Checkout/view/frontend/opcheckout.js b/app/code/Mage/Checkout/view/frontend/opcheckout.js similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/opcheckout.js rename to app/code/Mage/Checkout/view/frontend/opcheckout.js diff --git a/app/code/core/Mage/Checkout/view/frontend/success.phtml b/app/code/Mage/Checkout/view/frontend/success.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/success.phtml rename to app/code/Mage/Checkout/view/frontend/success.phtml diff --git a/app/code/core/Mage/Checkout/view/frontend/total/default.phtml b/app/code/Mage/Checkout/view/frontend/total/default.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/total/default.phtml rename to app/code/Mage/Checkout/view/frontend/total/default.phtml diff --git a/app/code/core/Mage/Checkout/view/frontend/total/nominal.phtml b/app/code/Mage/Checkout/view/frontend/total/nominal.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/total/nominal.phtml rename to app/code/Mage/Checkout/view/frontend/total/nominal.phtml diff --git a/app/code/core/Mage/Checkout/view/frontend/total/tax.phtml b/app/code/Mage/Checkout/view/frontend/total/tax.phtml similarity index 100% rename from app/code/core/Mage/Checkout/view/frontend/total/tax.phtml rename to app/code/Mage/Checkout/view/frontend/total/tax.phtml diff --git a/app/code/core/Mage/Cms/Block/Block.php b/app/code/Mage/Cms/Block/Block.php similarity index 100% rename from app/code/core/Mage/Cms/Block/Block.php rename to app/code/Mage/Cms/Block/Block.php diff --git a/app/code/core/Mage/Cms/Block/Page.php b/app/code/Mage/Cms/Block/Page.php similarity index 100% rename from app/code/core/Mage/Cms/Block/Page.php rename to app/code/Mage/Cms/Block/Page.php diff --git a/app/code/core/Mage/Cms/Block/Widget/Block.php b/app/code/Mage/Cms/Block/Widget/Block.php similarity index 100% rename from app/code/core/Mage/Cms/Block/Widget/Block.php rename to app/code/Mage/Cms/Block/Widget/Block.php diff --git a/app/code/core/Mage/Cms/Block/Widget/Page/Link.php b/app/code/Mage/Cms/Block/Widget/Page/Link.php similarity index 100% rename from app/code/core/Mage/Cms/Block/Widget/Page/Link.php rename to app/code/Mage/Cms/Block/Widget/Page/Link.php diff --git a/app/code/core/Mage/Cms/Controller/Router.php b/app/code/Mage/Cms/Controller/Router.php similarity index 100% rename from app/code/core/Mage/Cms/Controller/Router.php rename to app/code/Mage/Cms/Controller/Router.php diff --git a/app/code/core/Mage/Cms/Helper/Data.php b/app/code/Mage/Cms/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Cms/Helper/Data.php rename to app/code/Mage/Cms/Helper/Data.php diff --git a/app/code/core/Mage/Cms/Helper/Page.php b/app/code/Mage/Cms/Helper/Page.php similarity index 100% rename from app/code/core/Mage/Cms/Helper/Page.php rename to app/code/Mage/Cms/Helper/Page.php diff --git a/app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php b/app/code/Mage/Cms/Helper/Wysiwyg/Images.php similarity index 97% rename from app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php rename to app/code/Mage/Cms/Helper/Wysiwyg/Images.php index a282b00c54a4a..f477e314a2040 100644 --- a/app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php +++ b/app/code/Mage/Cms/Helper/Wysiwyg/Images.php @@ -55,12 +55,12 @@ class Mage_Cms_Helper_Wysiwyg_Images extends Mage_Core_Helper_Abstract protected $_filesystem; /** - * Constructor - * + * @param Mage_Core_Helper_Context $context * @param Magento_Filesystem $filesystem */ - public function __construct(Magento_Filesystem $filesystem) + public function __construct(Mage_Core_Helper_Context $context, Magento_Filesystem $filesystem) { + parent::__construct($context); $this->_filesystem = $filesystem; $this->_filesystem->setIsAllowCreateDirectories(true); $this->_filesystem->ensureDirectoryExists($this->getStorageRoot()); diff --git a/app/code/core/Mage/Cms/Model/Block.php b/app/code/Mage/Cms/Model/Block.php similarity index 100% rename from app/code/core/Mage/Cms/Model/Block.php rename to app/code/Mage/Cms/Model/Block.php diff --git a/app/code/core/Mage/Cms/Model/Config/Source/Page.php b/app/code/Mage/Cms/Model/Config/Source/Page.php similarity index 100% rename from app/code/core/Mage/Cms/Model/Config/Source/Page.php rename to app/code/Mage/Cms/Model/Config/Source/Page.php diff --git a/app/code/core/Mage/Cms/Model/Config/Source/Wysiwyg/Enabled.php b/app/code/Mage/Cms/Model/Config/Source/Wysiwyg/Enabled.php similarity index 100% rename from app/code/core/Mage/Cms/Model/Config/Source/Wysiwyg/Enabled.php rename to app/code/Mage/Cms/Model/Config/Source/Wysiwyg/Enabled.php diff --git a/app/code/core/Mage/Cms/Model/Observer.php b/app/code/Mage/Cms/Model/Observer.php similarity index 100% rename from app/code/core/Mage/Cms/Model/Observer.php rename to app/code/Mage/Cms/Model/Observer.php diff --git a/app/code/core/Mage/Cms/Model/Page.php b/app/code/Mage/Cms/Model/Page.php similarity index 100% rename from app/code/core/Mage/Cms/Model/Page.php rename to app/code/Mage/Cms/Model/Page.php diff --git a/app/code/core/Mage/Cms/Model/Page/Urlrewrite.php b/app/code/Mage/Cms/Model/Page/Urlrewrite.php similarity index 100% rename from app/code/core/Mage/Cms/Model/Page/Urlrewrite.php rename to app/code/Mage/Cms/Model/Page/Urlrewrite.php diff --git a/app/code/core/Mage/Cms/Model/Resource/Block.php b/app/code/Mage/Cms/Model/Resource/Block.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Cms/Model/Resource/Block.php rename to app/code/Mage/Cms/Model/Resource/Block.php diff --git a/app/code/core/Mage/Cms/Model/Resource/Block/Collection.php b/app/code/Mage/Cms/Model/Resource/Block/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Cms/Model/Resource/Block/Collection.php rename to app/code/Mage/Cms/Model/Resource/Block/Collection.php diff --git a/app/code/core/Mage/Cms/Model/Resource/Page.php b/app/code/Mage/Cms/Model/Resource/Page.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Cms/Model/Resource/Page.php rename to app/code/Mage/Cms/Model/Resource/Page.php diff --git a/app/code/core/Mage/Cms/Model/Resource/Page/Collection.php b/app/code/Mage/Cms/Model/Resource/Page/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Cms/Model/Resource/Page/Collection.php rename to app/code/Mage/Cms/Model/Resource/Page/Collection.php diff --git a/app/code/core/Mage/Cms/Model/Resource/Page/Service.php b/app/code/Mage/Cms/Model/Resource/Page/Service.php similarity index 100% rename from app/code/core/Mage/Cms/Model/Resource/Page/Service.php rename to app/code/Mage/Cms/Model/Resource/Page/Service.php diff --git a/app/code/core/Mage/Cms/Model/Resource/Page/Urlrewrite.php b/app/code/Mage/Cms/Model/Resource/Page/Urlrewrite.php similarity index 100% rename from app/code/core/Mage/Cms/Model/Resource/Page/Urlrewrite.php rename to app/code/Mage/Cms/Model/Resource/Page/Urlrewrite.php diff --git a/app/code/core/Mage/Cms/Model/Template/Filter.php b/app/code/Mage/Cms/Model/Template/Filter.php similarity index 100% rename from app/code/core/Mage/Cms/Model/Template/Filter.php rename to app/code/Mage/Cms/Model/Template/Filter.php diff --git a/app/code/core/Mage/Cms/Model/Wysiwyg/Config.php b/app/code/Mage/Cms/Model/Wysiwyg/Config.php similarity index 100% rename from app/code/core/Mage/Cms/Model/Wysiwyg/Config.php rename to app/code/Mage/Cms/Model/Wysiwyg/Config.php diff --git a/app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php b/app/code/Mage/Cms/Model/Wysiwyg/Images/Storage.php similarity index 100% rename from app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php rename to app/code/Mage/Cms/Model/Wysiwyg/Images/Storage.php diff --git a/app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage/Collection.php b/app/code/Mage/Cms/Model/Wysiwyg/Images/Storage/Collection.php similarity index 100% rename from app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage/Collection.php rename to app/code/Mage/Cms/Model/Wysiwyg/Images/Storage/Collection.php diff --git a/app/code/core/Mage/Cms/controllers/IndexController.php b/app/code/Mage/Cms/controllers/IndexController.php similarity index 100% rename from app/code/core/Mage/Cms/controllers/IndexController.php rename to app/code/Mage/Cms/controllers/IndexController.php diff --git a/app/code/core/Mage/Cms/controllers/PageController.php b/app/code/Mage/Cms/controllers/PageController.php similarity index 100% rename from app/code/core/Mage/Cms/controllers/PageController.php rename to app/code/Mage/Cms/controllers/PageController.php diff --git a/app/code/core/Mage/Cms/data/cms_setup/data-install-1.6.0.0.php b/app/code/Mage/Cms/data/cms_setup/data-install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Cms/data/cms_setup/data-install-1.6.0.0.php rename to app/code/Mage/Cms/data/cms_setup/data-install-1.6.0.0.php diff --git a/app/code/core/Mage/Cms/data/cms_setup/data-upgrade-1.6.0.0.0-1.6.0.0.1.php b/app/code/Mage/Cms/data/cms_setup/data-upgrade-1.6.0.0.0-1.6.0.0.1.php similarity index 100% rename from app/code/core/Mage/Cms/data/cms_setup/data-upgrade-1.6.0.0.0-1.6.0.0.1.php rename to app/code/Mage/Cms/data/cms_setup/data-upgrade-1.6.0.0.0-1.6.0.0.1.php diff --git a/app/code/core/Mage/Cms/data/cms_setup/data-upgrade-1.6.0.0.2-1.6.0.0.3.php b/app/code/Mage/Cms/data/cms_setup/data-upgrade-1.6.0.0.2-1.6.0.0.3.php similarity index 100% rename from app/code/core/Mage/Cms/data/cms_setup/data-upgrade-1.6.0.0.2-1.6.0.0.3.php rename to app/code/Mage/Cms/data/cms_setup/data-upgrade-1.6.0.0.2-1.6.0.0.3.php diff --git a/app/code/Mage/Cms/data/cms_setup/data-upgrade-1.6.0.0.3-2.0.0.0.php b/app/code/Mage/Cms/data/cms_setup/data-upgrade-1.6.0.0.3-2.0.0.0.php new file mode 100644 index 0000000000000..9b2a1f3e6a4ec --- /dev/null +++ b/app/code/Mage/Cms/data/cms_setup/data-upgrade-1.6.0.0.3-2.0.0.0.php @@ -0,0 +1,40 @@ +load('privacy-policy-cookie-restriction-mode','identifier'); + +if ($cookieRestrictionModel->getId()) { + $content = $cookieRestrictionModel->getContent(); + $replacment = '{{config path="general/store_information/street_line1"}} ' + . '{{config path="general/store_information/street_line2"}} ' + . '{{config path="general/store_information/city"}} ' + . '{{config path="general/store_information/postcode"}} ' + . '{{config path="general/store_information/region_id"}} ' + . '{{config path="general/store_information/country_id"}}'; + $content = preg_replace('/{{config path="general\\/store_information\\/address"}}/ims', $replacment, $content); + $cookieRestrictionModel->setContent($content)->save(); +} diff --git a/app/code/Mage/Cms/etc/adminhtml/acl.xml b/app/code/Mage/Cms/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..cce12bd68899c --- /dev/null +++ b/app/code/Mage/Cms/etc/adminhtml/acl.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Mage/Cms/etc/adminhtml/menu.xml b/app/code/Mage/Cms/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..7ea2f2b94f3ff --- /dev/null +++ b/app/code/Mage/Cms/etc/adminhtml/menu.xml @@ -0,0 +1,33 @@ + + + + + + + + diff --git a/app/code/core/Mage/Cms/etc/adminhtml/system.xml b/app/code/Mage/Cms/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Cms/etc/adminhtml/system.xml rename to app/code/Mage/Cms/etc/adminhtml/system.xml diff --git a/app/code/Mage/Cms/etc/config.xml b/app/code/Mage/Cms/etc/config.xml new file mode 100644 index 0000000000000..e588a2ac40eda --- /dev/null +++ b/app/code/Mage/Cms/etc/config.xml @@ -0,0 +1,183 @@ + + + + + + 2.0.0.0 + true + + + + + + + + + + standard + + Mage_Cms + cms + + + + + + + + Mage_Cms_Model_Observer + noRoute + + + + + + + Mage_Cms_Model_Observer + noCookies + + + + + + + + + Mage_Cms.csv + + + + + + + + layout.xml + + + + + + + + + + Mage_Cms.csv + + + + + + + + + + + + + + + + 1 + 1 + 1 + 1 + + + 1 + 1 + 1 + 1 + + + 1 + 1 + 1 + 1 + 1 + 1 + + + 1000 + 600 + 100 + 75 + + + + + + + + Mage_Cms + + + + + + + + Mage_Cms_Controller_Router + initControllerRouters + + + + + + + Mage_Cms_Model_Template_Filter + + + Mage_Cms_Model_Template_Filter + + + + + + + home + no-route + enable-cookies + cms + cms/index/noRoute + 1 + + + + + enabled + + + + + + wysiwyg + + + + + diff --git a/app/code/core/Mage/Cms/etc/widget.xml b/app/code/Mage/Cms/etc/widget.xml similarity index 100% rename from app/code/core/Mage/Cms/etc/widget.xml rename to app/code/Mage/Cms/etc/widget.xml diff --git a/app/code/core/Mage/Cms/locale/de_DE/Mage_Cms.csv b/app/code/Mage/Cms/locale/de_DE/Mage_Cms.csv similarity index 100% rename from app/code/core/Mage/Cms/locale/de_DE/Mage_Cms.csv rename to app/code/Mage/Cms/locale/de_DE/Mage_Cms.csv diff --git a/app/code/core/Mage/Cms/locale/en_US/Mage_Cms.csv b/app/code/Mage/Cms/locale/en_US/Mage_Cms.csv similarity index 100% rename from app/code/core/Mage/Cms/locale/en_US/Mage_Cms.csv rename to app/code/Mage/Cms/locale/en_US/Mage_Cms.csv diff --git a/app/code/core/Mage/Cms/locale/es_ES/Mage_Cms.csv b/app/code/Mage/Cms/locale/es_ES/Mage_Cms.csv similarity index 100% rename from app/code/core/Mage/Cms/locale/es_ES/Mage_Cms.csv rename to app/code/Mage/Cms/locale/es_ES/Mage_Cms.csv diff --git a/app/code/core/Mage/Cms/locale/fr_FR/Mage_Cms.csv b/app/code/Mage/Cms/locale/fr_FR/Mage_Cms.csv similarity index 100% rename from app/code/core/Mage/Cms/locale/fr_FR/Mage_Cms.csv rename to app/code/Mage/Cms/locale/fr_FR/Mage_Cms.csv diff --git a/app/code/core/Mage/Cms/locale/nl_NL/Mage_Cms.csv b/app/code/Mage/Cms/locale/nl_NL/Mage_Cms.csv similarity index 100% rename from app/code/core/Mage/Cms/locale/nl_NL/Mage_Cms.csv rename to app/code/Mage/Cms/locale/nl_NL/Mage_Cms.csv diff --git a/app/code/core/Mage/Cms/locale/pt_BR/Mage_Cms.csv b/app/code/Mage/Cms/locale/pt_BR/Mage_Cms.csv similarity index 100% rename from app/code/core/Mage/Cms/locale/pt_BR/Mage_Cms.csv rename to app/code/Mage/Cms/locale/pt_BR/Mage_Cms.csv diff --git a/app/code/core/Mage/Cms/locale/zh_CN/Mage_Cms.csv b/app/code/Mage/Cms/locale/zh_CN/Mage_Cms.csv similarity index 100% rename from app/code/core/Mage/Cms/locale/zh_CN/Mage_Cms.csv rename to app/code/Mage/Cms/locale/zh_CN/Mage_Cms.csv diff --git a/app/code/core/Mage/Cms/sql/cms_setup/install-1.6.0.0.php b/app/code/Mage/Cms/sql/cms_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Cms/sql/cms_setup/install-1.6.0.0.php rename to app/code/Mage/Cms/sql/cms_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Cms/sql/cms_setup/upgrade-1.6.0.0.1-1.6.0.0.2.php b/app/code/Mage/Cms/sql/cms_setup/upgrade-1.6.0.0.1-1.6.0.0.2.php similarity index 100% rename from app/code/core/Mage/Cms/sql/cms_setup/upgrade-1.6.0.0.1-1.6.0.0.2.php rename to app/code/Mage/Cms/sql/cms_setup/upgrade-1.6.0.0.1-1.6.0.0.2.php diff --git a/app/code/core/Mage/Cms/view/adminhtml/images/placeholder_thumbnail.jpg b/app/code/Mage/Cms/view/adminhtml/images/placeholder_thumbnail.jpg similarity index 100% rename from app/code/core/Mage/Cms/view/adminhtml/images/placeholder_thumbnail.jpg rename to app/code/Mage/Cms/view/adminhtml/images/placeholder_thumbnail.jpg diff --git a/app/code/core/Mage/Cms/view/adminhtml/images/widget_block.gif b/app/code/Mage/Cms/view/adminhtml/images/widget_block.gif similarity index 100% rename from app/code/core/Mage/Cms/view/adminhtml/images/widget_block.gif rename to app/code/Mage/Cms/view/adminhtml/images/widget_block.gif diff --git a/app/code/core/Mage/Cms/view/adminhtml/images/widget_page_link.gif b/app/code/Mage/Cms/view/adminhtml/images/widget_page_link.gif similarity index 100% rename from app/code/core/Mage/Cms/view/adminhtml/images/widget_page_link.gif rename to app/code/Mage/Cms/view/adminhtml/images/widget_page_link.gif diff --git a/app/code/core/Mage/Cms/view/adminhtml/images/wysiwyg_skin_image.png b/app/code/Mage/Cms/view/adminhtml/images/wysiwyg_skin_image.png similarity index 100% rename from app/code/core/Mage/Cms/view/adminhtml/images/wysiwyg_skin_image.png rename to app/code/Mage/Cms/view/adminhtml/images/wysiwyg_skin_image.png diff --git a/app/code/core/Mage/Cms/view/frontend/content.phtml b/app/code/Mage/Cms/view/frontend/content.phtml similarity index 100% rename from app/code/core/Mage/Cms/view/frontend/content.phtml rename to app/code/Mage/Cms/view/frontend/content.phtml diff --git a/app/code/core/Mage/Cms/view/frontend/content_heading.phtml b/app/code/Mage/Cms/view/frontend/content_heading.phtml similarity index 100% rename from app/code/core/Mage/Cms/view/frontend/content_heading.phtml rename to app/code/Mage/Cms/view/frontend/content_heading.phtml diff --git a/app/code/core/Mage/Cms/view/frontend/default/home.phtml b/app/code/Mage/Cms/view/frontend/default/home.phtml similarity index 100% rename from app/code/core/Mage/Cms/view/frontend/default/home.phtml rename to app/code/Mage/Cms/view/frontend/default/home.phtml diff --git a/app/code/core/Mage/Cms/view/frontend/default/no-route.phtml b/app/code/Mage/Cms/view/frontend/default/no-route.phtml similarity index 100% rename from app/code/core/Mage/Cms/view/frontend/default/no-route.phtml rename to app/code/Mage/Cms/view/frontend/default/no-route.phtml diff --git a/app/code/core/Mage/Cms/view/frontend/images/about_us_img.jpg b/app/code/Mage/Cms/view/frontend/images/about_us_img.jpg similarity index 100% rename from app/code/core/Mage/Cms/view/frontend/images/about_us_img.jpg rename to app/code/Mage/Cms/view/frontend/images/about_us_img.jpg diff --git a/app/code/core/Mage/Cms/view/frontend/images/cookies/firefox.png b/app/code/Mage/Cms/view/frontend/images/cookies/firefox.png similarity index 100% rename from app/code/core/Mage/Cms/view/frontend/images/cookies/firefox.png rename to app/code/Mage/Cms/view/frontend/images/cookies/firefox.png diff --git a/app/code/core/Mage/Cms/view/frontend/images/cookies/ie6-1.gif b/app/code/Mage/Cms/view/frontend/images/cookies/ie6-1.gif similarity index 100% rename from app/code/core/Mage/Cms/view/frontend/images/cookies/ie6-1.gif rename to app/code/Mage/Cms/view/frontend/images/cookies/ie6-1.gif diff --git a/app/code/core/Mage/Cms/view/frontend/images/cookies/ie6-2.gif b/app/code/Mage/Cms/view/frontend/images/cookies/ie6-2.gif similarity index 100% rename from app/code/core/Mage/Cms/view/frontend/images/cookies/ie6-2.gif rename to app/code/Mage/Cms/view/frontend/images/cookies/ie6-2.gif diff --git a/app/code/core/Mage/Cms/view/frontend/images/cookies/ie7-1.gif b/app/code/Mage/Cms/view/frontend/images/cookies/ie7-1.gif similarity index 100% rename from app/code/core/Mage/Cms/view/frontend/images/cookies/ie7-1.gif rename to app/code/Mage/Cms/view/frontend/images/cookies/ie7-1.gif diff --git a/app/code/core/Mage/Cms/view/frontend/images/cookies/ie7-2.gif b/app/code/Mage/Cms/view/frontend/images/cookies/ie7-2.gif similarity index 100% rename from app/code/core/Mage/Cms/view/frontend/images/cookies/ie7-2.gif rename to app/code/Mage/Cms/view/frontend/images/cookies/ie7-2.gif diff --git a/app/code/core/Mage/Cms/view/frontend/images/cookies/ie7-3.gif b/app/code/Mage/Cms/view/frontend/images/cookies/ie7-3.gif similarity index 100% rename from app/code/core/Mage/Cms/view/frontend/images/cookies/ie7-3.gif rename to app/code/Mage/Cms/view/frontend/images/cookies/ie7-3.gif diff --git a/app/code/core/Mage/Cms/view/frontend/images/cookies/ie7-4.gif b/app/code/Mage/Cms/view/frontend/images/cookies/ie7-4.gif similarity index 100% rename from app/code/core/Mage/Cms/view/frontend/images/cookies/ie7-4.gif rename to app/code/Mage/Cms/view/frontend/images/cookies/ie7-4.gif diff --git a/app/code/core/Mage/Cms/view/frontend/images/cookies/ie7-5.gif b/app/code/Mage/Cms/view/frontend/images/cookies/ie7-5.gif similarity index 100% rename from app/code/core/Mage/Cms/view/frontend/images/cookies/ie7-5.gif rename to app/code/Mage/Cms/view/frontend/images/cookies/ie7-5.gif diff --git a/app/code/core/Mage/Cms/view/frontend/images/cookies/ie7-6.gif b/app/code/Mage/Cms/view/frontend/images/cookies/ie7-6.gif similarity index 100% rename from app/code/core/Mage/Cms/view/frontend/images/cookies/ie7-6.gif rename to app/code/Mage/Cms/view/frontend/images/cookies/ie7-6.gif diff --git a/app/code/core/Mage/Cms/view/frontend/images/cookies/opera.png b/app/code/Mage/Cms/view/frontend/images/cookies/opera.png similarity index 100% rename from app/code/core/Mage/Cms/view/frontend/images/cookies/opera.png rename to app/code/Mage/Cms/view/frontend/images/cookies/opera.png diff --git a/app/code/core/Mage/Cms/view/frontend/images/i_widget-link.gif b/app/code/Mage/Cms/view/frontend/images/i_widget-link.gif similarity index 100% rename from app/code/core/Mage/Cms/view/frontend/images/i_widget-link.gif rename to app/code/Mage/Cms/view/frontend/images/i_widget-link.gif diff --git a/app/code/core/Mage/Cms/view/frontend/layout.xml b/app/code/Mage/Cms/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/Cms/view/frontend/layout.xml rename to app/code/Mage/Cms/view/frontend/layout.xml diff --git a/app/code/core/Mage/Cms/view/frontend/meta.phtml b/app/code/Mage/Cms/view/frontend/meta.phtml similarity index 100% rename from app/code/core/Mage/Cms/view/frontend/meta.phtml rename to app/code/Mage/Cms/view/frontend/meta.phtml diff --git a/app/code/core/Mage/Cms/view/frontend/widget/link/link_block.phtml b/app/code/Mage/Cms/view/frontend/widget/link/link_block.phtml similarity index 100% rename from app/code/core/Mage/Cms/view/frontend/widget/link/link_block.phtml rename to app/code/Mage/Cms/view/frontend/widget/link/link_block.phtml diff --git a/app/code/core/Mage/Cms/view/frontend/widget/link/link_inline.phtml b/app/code/Mage/Cms/view/frontend/widget/link/link_inline.phtml similarity index 100% rename from app/code/core/Mage/Cms/view/frontend/widget/link/link_inline.phtml rename to app/code/Mage/Cms/view/frontend/widget/link/link_inline.phtml diff --git a/app/code/core/Mage/Cms/view/frontend/widget/static_block/default.phtml b/app/code/Mage/Cms/view/frontend/widget/static_block/default.phtml similarity index 100% rename from app/code/core/Mage/Cms/view/frontend/widget/static_block/default.phtml rename to app/code/Mage/Cms/view/frontend/widget/static_block/default.phtml diff --git a/app/code/core/Mage/Cms/view/frontend/widgets.css b/app/code/Mage/Cms/view/frontend/widgets.css similarity index 100% rename from app/code/core/Mage/Cms/view/frontend/widgets.css rename to app/code/Mage/Cms/view/frontend/widgets.css diff --git a/app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit.php b/app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit.php similarity index 100% rename from app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit.php rename to app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit.php diff --git a/app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Form.php b/app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Form.php rename to app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Form.php diff --git a/app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Abstract.php b/app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Abstract.php similarity index 100% rename from app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Abstract.php rename to app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Abstract.php diff --git a/app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Authors.php b/app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Authors.php similarity index 100% rename from app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Authors.php rename to app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Authors.php diff --git a/app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Contents.php b/app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Contents.php similarity index 100% rename from app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Contents.php rename to app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Contents.php diff --git a/app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Depends.php b/app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Depends.php similarity index 100% rename from app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Depends.php rename to app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Depends.php diff --git a/app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Grid.php b/app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Grid.php similarity index 100% rename from app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Grid.php rename to app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Grid.php diff --git a/app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Load.php b/app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Load.php similarity index 100% rename from app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Load.php rename to app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Load.php diff --git a/app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Local.php b/app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Local.php similarity index 100% rename from app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Local.php rename to app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Local.php diff --git a/app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Package.php b/app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Package.php similarity index 100% rename from app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Package.php rename to app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Package.php diff --git a/app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Release.php b/app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Release.php similarity index 100% rename from app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Release.php rename to app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Release.php diff --git a/app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tabs.php b/app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tabs.php similarity index 100% rename from app/code/core/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tabs.php rename to app/code/Mage/Connect/Block/Adminhtml/Extension/Custom/Edit/Tabs.php diff --git a/app/code/Mage/Connect/Helper/Data.php b/app/code/Mage/Connect/Helper/Data.php new file mode 100644 index 0000000000000..3e18253f10f8b --- /dev/null +++ b/app/code/Mage/Connect/Helper/Data.php @@ -0,0 +1,166 @@ + + */ +class Mage_Connect_Helper_Data extends Mage_Core_Helper_Data +{ + /** + * @var Magento_Filesystem + */ + protected $_filesystem; + + /** + * @param Mage_Core_Helper_Context $context + * @param Mage_Core_Model_Config_Modules $modulesConfig + * @param Magento_Filesystem $filesystem + */ + public function __construct( + Mage_Core_Helper_Context $context, + Mage_Core_Model_Config_Modules $modulesConfig, + Magento_Filesystem $filesystem + ) { + parent::__construct($context, $modulesConfig); + $this->_filesystem = $filesystem; + } + + /** + * Retrieve file system path for local extension packages + * Return path with last directory separator + * + * @return string + */ + public function getLocalPackagesPath() + { + return Mage::getBaseDir('var') . DS . 'connect' . DS; + } + + /** + * Retrieve file system path for local extension packages (for version 1 packages only) + * Return path with last directory separator + * + * @return string + */ + public function getLocalPackagesPathV1x() + { + return Mage::getBaseDir('var') . DS . 'pear' . DS; + } + + /** + * Retrieve a map to convert a channel from previous version of Magento Connect Manager + * + * @return array + */ + public function getChannelMapFromV1x() + { + return array( + 'connect.magentocommerce.com/community' => 'community', + 'connect.magentocommerce.com/core' => 'community' + ); + } + + /** + * Retrieve a map to convert a channel to previous version of Magento Connect Manager + * + * @return array + */ + public function getChannelMapToV1x() + { + return array( + 'community' => 'connect.magentocommerce.com/community' + ); + } + + /** + * Convert package channel in order for it to be compatible with current version of Magento Connect Manager + * + * @param string $channel + * + * @return string + */ + public function convertChannelFromV1x($channel) + { + $channelMap = $this->getChannelMapFromV1x(); + if (isset($channelMap[$channel])) { + $channel = $channelMap[$channel]; + } + return $channel; + } + + /** + * Convert package channel in order for it to be compatible with previous version of Magento Connect Manager + * + * @param string $channel + * + * @return string + */ + public function convertChannelToV1x($channel) + { + $channelMap = $this->getChannelMapToV1x(); + if (isset($channelMap[$channel])) { + $channel = $channelMap[$channel]; + } + return $channel; + } + + /** + * Load local package data array + * + * @param string $packageName without extension + * @return array|false + */ + public function loadLocalPackage($packageName) + { + //check LFI protection + $this->checkLfiProtection($packageName); + + $path = $this->getLocalPackagesPath(); + $xmlFile = $path . $packageName . '.xml'; + $serFile = $path . $packageName . '.ser'; + + if ($this->_filesystem->isFile($xmlFile) && $this->_filesystem->isReadable($xmlFile)) { + $xml = simplexml_load_string($this->_filesystem->read($xmlFile)); + $data = Mage::helper('Mage_Core_Helper_Data')->xmlToAssoc($xml); + if (!empty($data)) { + return $data; + } + } + + if ($this->_filesystem->isFile($serFile) && $this->_filesystem->isReadable($xmlFile)) { + $data = unserialize($this->_filesystem->read($serFile)); + if (!empty($data)) { + return $data; + } + } + + return false; + } +} diff --git a/app/code/core/Mage/Connect/Model/Extension.php b/app/code/Mage/Connect/Model/Extension.php similarity index 100% rename from app/code/core/Mage/Connect/Model/Extension.php rename to app/code/Mage/Connect/Model/Extension.php diff --git a/app/code/core/Mage/Connect/Model/Extension/Collection.php b/app/code/Mage/Connect/Model/Extension/Collection.php similarity index 100% rename from app/code/core/Mage/Connect/Model/Extension/Collection.php rename to app/code/Mage/Connect/Model/Extension/Collection.php diff --git a/app/code/core/Mage/Connect/Model/Session.php b/app/code/Mage/Connect/Model/Session.php similarity index 100% rename from app/code/core/Mage/Connect/Model/Session.php rename to app/code/Mage/Connect/Model/Session.php diff --git a/app/code/core/Mage/Connect/controllers/Adminhtml/Extension/CustomController.php b/app/code/Mage/Connect/controllers/Adminhtml/Extension/CustomController.php similarity index 100% rename from app/code/core/Mage/Connect/controllers/Adminhtml/Extension/CustomController.php rename to app/code/Mage/Connect/controllers/Adminhtml/Extension/CustomController.php diff --git a/app/code/core/Mage/Connect/controllers/Adminhtml/Extension/LocalController.php b/app/code/Mage/Connect/controllers/Adminhtml/Extension/LocalController.php similarity index 100% rename from app/code/core/Mage/Connect/controllers/Adminhtml/Extension/LocalController.php rename to app/code/Mage/Connect/controllers/Adminhtml/Extension/LocalController.php diff --git a/app/code/core/Mage/Connect/etc/adminhtml/acl.xml b/app/code/Mage/Connect/etc/adminhtml/acl.xml similarity index 100% rename from app/code/core/Mage/Connect/etc/adminhtml/acl.xml rename to app/code/Mage/Connect/etc/adminhtml/acl.xml diff --git a/app/code/Mage/Connect/etc/adminhtml/menu.xml b/app/code/Mage/Connect/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..95c43ba96b67a --- /dev/null +++ b/app/code/Mage/Connect/etc/adminhtml/menu.xml @@ -0,0 +1,34 @@ + + + + + + + + + diff --git a/app/code/Mage/Connect/etc/config.xml b/app/code/Mage/Connect/etc/config.xml new file mode 100644 index 0000000000000..ddf1e9659afc8 --- /dev/null +++ b/app/code/Mage/Connect/etc/config.xml @@ -0,0 +1,65 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + Mage_Connect_Adminhtml + + + + + + + + + + layout.xml + + + + + + + + Mage_Connect.csv + + + + + + diff --git a/app/code/core/Mage/Connect/locale/de_DE/Mage_Connect.csv b/app/code/Mage/Connect/locale/de_DE/Mage_Connect.csv similarity index 100% rename from app/code/core/Mage/Connect/locale/de_DE/Mage_Connect.csv rename to app/code/Mage/Connect/locale/de_DE/Mage_Connect.csv diff --git a/app/code/core/Mage/Connect/locale/en_US/Mage_Connect.csv b/app/code/Mage/Connect/locale/en_US/Mage_Connect.csv similarity index 100% rename from app/code/core/Mage/Connect/locale/en_US/Mage_Connect.csv rename to app/code/Mage/Connect/locale/en_US/Mage_Connect.csv diff --git a/app/code/core/Mage/Connect/locale/es_ES/Mage_Connect.csv b/app/code/Mage/Connect/locale/es_ES/Mage_Connect.csv similarity index 100% rename from app/code/core/Mage/Connect/locale/es_ES/Mage_Connect.csv rename to app/code/Mage/Connect/locale/es_ES/Mage_Connect.csv diff --git a/app/code/core/Mage/Connect/locale/fr_FR/Mage_Connect.csv b/app/code/Mage/Connect/locale/fr_FR/Mage_Connect.csv similarity index 100% rename from app/code/core/Mage/Connect/locale/fr_FR/Mage_Connect.csv rename to app/code/Mage/Connect/locale/fr_FR/Mage_Connect.csv diff --git a/app/code/core/Mage/Connect/locale/nl_NL/Mage_Connect.csv b/app/code/Mage/Connect/locale/nl_NL/Mage_Connect.csv similarity index 100% rename from app/code/core/Mage/Connect/locale/nl_NL/Mage_Connect.csv rename to app/code/Mage/Connect/locale/nl_NL/Mage_Connect.csv diff --git a/app/code/core/Mage/Connect/locale/pt_BR/Mage_Connect.csv b/app/code/Mage/Connect/locale/pt_BR/Mage_Connect.csv similarity index 100% rename from app/code/core/Mage/Connect/locale/pt_BR/Mage_Connect.csv rename to app/code/Mage/Connect/locale/pt_BR/Mage_Connect.csv diff --git a/app/code/core/Mage/Connect/locale/zh_CN/Mage_Connect.csv b/app/code/Mage/Connect/locale/zh_CN/Mage_Connect.csv similarity index 100% rename from app/code/core/Mage/Connect/locale/zh_CN/Mage_Connect.csv rename to app/code/Mage/Connect/locale/zh_CN/Mage_Connect.csv diff --git a/app/code/core/Mage/Connect/view/adminhtml/extension/custom/authors.phtml b/app/code/Mage/Connect/view/adminhtml/extension/custom/authors.phtml similarity index 100% rename from app/code/core/Mage/Connect/view/adminhtml/extension/custom/authors.phtml rename to app/code/Mage/Connect/view/adminhtml/extension/custom/authors.phtml diff --git a/app/code/core/Mage/Connect/view/adminhtml/extension/custom/contents.phtml b/app/code/Mage/Connect/view/adminhtml/extension/custom/contents.phtml similarity index 100% rename from app/code/core/Mage/Connect/view/adminhtml/extension/custom/contents.phtml rename to app/code/Mage/Connect/view/adminhtml/extension/custom/contents.phtml diff --git a/app/code/core/Mage/Connect/view/adminhtml/extension/custom/depends.phtml b/app/code/Mage/Connect/view/adminhtml/extension/custom/depends.phtml similarity index 100% rename from app/code/core/Mage/Connect/view/adminhtml/extension/custom/depends.phtml rename to app/code/Mage/Connect/view/adminhtml/extension/custom/depends.phtml diff --git a/app/code/core/Mage/Connect/view/adminhtml/extension/custom/load.phtml b/app/code/Mage/Connect/view/adminhtml/extension/custom/load.phtml similarity index 100% rename from app/code/core/Mage/Connect/view/adminhtml/extension/custom/load.phtml rename to app/code/Mage/Connect/view/adminhtml/extension/custom/load.phtml diff --git a/app/code/core/Mage/Connect/view/adminhtml/extension/custom/package.phtml b/app/code/Mage/Connect/view/adminhtml/extension/custom/package.phtml similarity index 100% rename from app/code/core/Mage/Connect/view/adminhtml/extension/custom/package.phtml rename to app/code/Mage/Connect/view/adminhtml/extension/custom/package.phtml diff --git a/app/code/core/Mage/Connect/view/adminhtml/extension/custom/release.phtml b/app/code/Mage/Connect/view/adminhtml/extension/custom/release.phtml similarity index 100% rename from app/code/core/Mage/Connect/view/adminhtml/extension/custom/release.phtml rename to app/code/Mage/Connect/view/adminhtml/extension/custom/release.phtml diff --git a/app/code/core/Mage/Connect/view/adminhtml/layout.xml b/app/code/Mage/Connect/view/adminhtml/layout.xml similarity index 100% rename from app/code/core/Mage/Connect/view/adminhtml/layout.xml rename to app/code/Mage/Connect/view/adminhtml/layout.xml diff --git a/app/code/core/Mage/Contacts/Helper/Data.php b/app/code/Mage/Contacts/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Contacts/Helper/Data.php rename to app/code/Mage/Contacts/Helper/Data.php diff --git a/app/code/core/Mage/Contacts/Model/System/Config/Backend/Links.php b/app/code/Mage/Contacts/Model/System/Config/Backend/Links.php similarity index 100% rename from app/code/core/Mage/Contacts/Model/System/Config/Backend/Links.php rename to app/code/Mage/Contacts/Model/System/Config/Backend/Links.php diff --git a/app/code/core/Mage/Contacts/controllers/IndexController.php b/app/code/Mage/Contacts/controllers/IndexController.php similarity index 100% rename from app/code/core/Mage/Contacts/controllers/IndexController.php rename to app/code/Mage/Contacts/controllers/IndexController.php diff --git a/app/code/Mage/Contacts/etc/adminhtml/acl.xml b/app/code/Mage/Contacts/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..d6cd588f6e009 --- /dev/null +++ b/app/code/Mage/Contacts/etc/adminhtml/acl.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + diff --git a/app/code/core/Mage/Contacts/etc/adminhtml/system.xml b/app/code/Mage/Contacts/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Contacts/etc/adminhtml/system.xml rename to app/code/Mage/Contacts/etc/adminhtml/system.xml diff --git a/app/code/Mage/Contacts/etc/config.xml b/app/code/Mage/Contacts/etc/config.xml new file mode 100644 index 0000000000000..27ed8167b2a02 --- /dev/null +++ b/app/code/Mage/Contacts/etc/config.xml @@ -0,0 +1,108 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + standard + + Mage_Contacts + contacts + + + + + + + + Mage_Contacts.csv + + + + + + + + layout.xml + + + + + + + + + Mage_Contacts + + + + + + + + + + + + Mage_Contacts.csv + + + + + + + + + + 1 + + + + custom2 + contacts_email_email_template + + + + diff --git a/app/code/core/Mage/Contacts/locale/de_DE/Mage_Contacts.csv b/app/code/Mage/Contacts/locale/de_DE/Mage_Contacts.csv similarity index 100% rename from app/code/core/Mage/Contacts/locale/de_DE/Mage_Contacts.csv rename to app/code/Mage/Contacts/locale/de_DE/Mage_Contacts.csv diff --git a/app/code/core/Mage/Contacts/locale/en_US/Mage_Contacts.csv b/app/code/Mage/Contacts/locale/en_US/Mage_Contacts.csv similarity index 100% rename from app/code/core/Mage/Contacts/locale/en_US/Mage_Contacts.csv rename to app/code/Mage/Contacts/locale/en_US/Mage_Contacts.csv diff --git a/app/code/core/Mage/Contacts/locale/es_ES/Mage_Contacts.csv b/app/code/Mage/Contacts/locale/es_ES/Mage_Contacts.csv similarity index 100% rename from app/code/core/Mage/Contacts/locale/es_ES/Mage_Contacts.csv rename to app/code/Mage/Contacts/locale/es_ES/Mage_Contacts.csv diff --git a/app/code/core/Mage/Contacts/locale/fr_FR/Mage_Contacts.csv b/app/code/Mage/Contacts/locale/fr_FR/Mage_Contacts.csv similarity index 100% rename from app/code/core/Mage/Contacts/locale/fr_FR/Mage_Contacts.csv rename to app/code/Mage/Contacts/locale/fr_FR/Mage_Contacts.csv diff --git a/app/code/core/Mage/Contacts/locale/nl_NL/Mage_Contacts.csv b/app/code/Mage/Contacts/locale/nl_NL/Mage_Contacts.csv similarity index 100% rename from app/code/core/Mage/Contacts/locale/nl_NL/Mage_Contacts.csv rename to app/code/Mage/Contacts/locale/nl_NL/Mage_Contacts.csv diff --git a/app/code/core/Mage/Contacts/locale/pt_BR/Mage_Contacts.csv b/app/code/Mage/Contacts/locale/pt_BR/Mage_Contacts.csv similarity index 100% rename from app/code/core/Mage/Contacts/locale/pt_BR/Mage_Contacts.csv rename to app/code/Mage/Contacts/locale/pt_BR/Mage_Contacts.csv diff --git a/app/code/core/Mage/Contacts/locale/zh_CN/Mage_Contacts.csv b/app/code/Mage/Contacts/locale/zh_CN/Mage_Contacts.csv similarity index 100% rename from app/code/core/Mage/Contacts/locale/zh_CN/Mage_Contacts.csv rename to app/code/Mage/Contacts/locale/zh_CN/Mage_Contacts.csv diff --git a/app/code/core/Mage/Contacts/sql/contacts_setup/install-1.6.0.0.php b/app/code/Mage/Contacts/sql/contacts_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Contacts/sql/contacts_setup/install-1.6.0.0.php rename to app/code/Mage/Contacts/sql/contacts_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Contacts/view/email/submitted_form.html b/app/code/Mage/Contacts/view/email/submitted_form.html similarity index 100% rename from app/code/core/Mage/Contacts/view/email/submitted_form.html rename to app/code/Mage/Contacts/view/email/submitted_form.html diff --git a/app/code/core/Mage/Contacts/view/frontend/form.phtml b/app/code/Mage/Contacts/view/frontend/form.phtml similarity index 100% rename from app/code/core/Mage/Contacts/view/frontend/form.phtml rename to app/code/Mage/Contacts/view/frontend/form.phtml diff --git a/app/code/core/Mage/Contacts/view/frontend/layout.xml b/app/code/Mage/Contacts/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/Contacts/view/frontend/layout.xml rename to app/code/Mage/Contacts/view/frontend/layout.xml diff --git a/app/code/core/Mage/Core/Block.php b/app/code/Mage/Core/Block.php similarity index 100% rename from app/code/core/Mage/Core/Block.php rename to app/code/Mage/Core/Block.php diff --git a/app/code/Mage/Core/Block/Abstract.php b/app/code/Mage/Core/Block/Abstract.php new file mode 100644 index 0000000000000..568d425c21c84 --- /dev/null +++ b/app/code/Mage/Core/Block/Abstract.php @@ -0,0 +1,1083 @@ + + * @SuppressWarnings(PHPMD.ExcessivePublicCount) + * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +abstract class Mage_Core_Block_Abstract extends Varien_Object + implements Mage_Core_Block +{ + /** + * @var Mage_Core_Model_Design_Package + */ + protected $_designPackage; + + /** + * @var Mage_Core_Model_Session + */ + protected $_session; + + /** + * @var Mage_Core_Model_Translate + */ + protected $_translator; + + /** + * Cache group Tag + */ + const CACHE_GROUP = Mage_Core_Model_Cache_Type_Block::TYPE_IDENTIFIER; + /** + * Block name in layout + * + * @var string + */ + protected $_nameInLayout; + + /** + * Parent layout of the block + * + * @var Mage_Core_Model_Layout + */ + protected $_layout; + + /** + * @var Mage_Core_Controller_Request_Http + */ + protected $_request; + + /** + * Messages block instance + * + * @var Mage_Core_Block_Messages + */ + protected $_messagesBlock = null; + + /** + * Block html frame open tag + * @var string + */ + protected $_frameOpenTag; + + /** + * Block html frame close tag + * @var string + */ + protected $_frameCloseTag; + + /** + * Url Builder + * + * @var Mage_Core_Model_UrlInterface + */ + protected $_urlBuilder; + + /** + * System event manager + * + * + * @var Mage_Core_Model_Event_Manager + */ + protected $_eventManager; + + /** + * Application front controller + * + * @var Mage_Core_Controller_Varien_Front + */ + protected $_frontController; + + /** @var \Mage_Core_Model_Factory_Helper */ + protected $_helperFactory; + + /** + * @param Mage_Core_Block_Context $context + * @param array $data + */ + public function __construct(Mage_Core_Block_Context $context, array $data = array()) + { + $this->_request = $context->getRequest(); + $this->_layout = $context->getLayout(); + $this->_eventManager = $context->getEventManager(); + $this->_urlBuilder = $context->getUrlBuilder(); + $this->_translator = $context->getTranslator(); + $this->_cache = $context->getCache(); + $this->_designPackage = $context->getDesignPackage(); + $this->_session = $context->getSession(); + $this->_storeConfig = $context->getStoreConfig(); + $this->_frontController = $context->getFrontController(); + $this->_helperFactory = $context->getHelperFactory(); + parent::__construct($data); + $this->_construct(); + } + + /** + * @return Mage_Core_Controller_Request_Http + */ + public function getRequest() + { + return $this->_request; + } + + /** + * Internal constructor, that is called from real constructor + * + * Please override this one instead of overriding real __construct constructor + * + */ + protected function _construct() + { + /** + * Please override this one instead of overriding real __construct constructor + */ + } + + /** + * Retrieve parent block + * + * @return Mage_Core_Block_Abstract|bool + */ + public function getParentBlock() + { + $layout = $this->getLayout(); + if (!$layout) { + return false; + } + $parentName = $layout->getParentName($this->getNameInLayout()); + if ($parentName) { + return $layout->getBlock($parentName); + } + return false; + } + + /** + * Set layout object + * + * @param Mage_Core_Model_Layout $layout + * @return Mage_Core_Block_Abstract + */ + public function setLayout(Mage_Core_Model_Layout $layout) + { + $this->_layout = $layout; + $this->_eventManager->dispatch('core_block_abstract_prepare_layout_before', array('block' => $this)); + $this->_prepareLayout(); + $this->_eventManager->dispatch('core_block_abstract_prepare_layout_after', array('block' => $this)); + return $this; + } + + /** + * Preparing global layout + * + * You can redefine this method in child classes for changing layout + * + * @return Mage_Core_Block_Abstract + */ + protected function _prepareLayout() + { + return $this; + } + + /** + * Retrieve layout object + * + * @return Mage_Core_Model_Layout + */ + public function getLayout() + { + return $this->_layout; + } + + /** + * Sets/changes name of a block in layout + * + * @param string $name + * @return Mage_Core_Block_Abstract + */ + public function setNameInLayout($name) + { + $layout = $this->getLayout(); + if (!empty($this->_nameInLayout) && $layout) { + if ($name === $this->_nameInLayout) { + return $this; + } + $layout->renameElement($this->_nameInLayout, $name); + } + $this->_nameInLayout = $name; + return $this; + } + + /** + * Retrieves sorted list of child names + * + * @return array + */ + public function getChildNames() + { + $layout = $this->getLayout(); + if (!$layout) { + return array(); + } + return $layout->getChildNames($this->getNameInLayout()); + } + + /** + * Set block attribute value + * + * Wrapper for method "setData" + * + * @param string $name + * @param mixed $value + * @return Mage_Core_Block_Abstract + */ + public function setAttribute($name, $value = null) + { + return $this->setData($name, $value); + } + + /** + * Set child block + * + * @param string $alias + * @param Mage_Core_Block_Abstract|string $block + * @return Mage_Core_Block_Abstract + */ + public function setChild($alias, $block) + { + $layout = $this->getLayout(); + if (!$layout) { + return $this; + } + $thisName = $this->getNameInLayout(); + if ($layout->getChildName($thisName, $alias)) { + $this->unsetChild($alias); + } + if ($block instanceof self) { + $block = $block->getNameInLayout(); + } + $layout->setChild($thisName, $block, $alias); + + return $this; + } + + /** + * Create block with name: {parent}.{alias} and set as child + * + * @param string $alias + * @param string $block + * @param array $data + * @return Mage_Core_Block_Abstract new block + */ + public function addChild($alias, $block, $data = array()) + { + $block = $this->getLayout()->createBlock($block, $this->getNameInLayout() . '.' . $alias, + array('data' => $data) + ); + $this->setChild($alias, $block); + return $block; + } + + /** + * Unset child block + * + * @param string $alias + * @return Mage_Core_Block_Abstract + */ + public function unsetChild($alias) + { + $layout = $this->getLayout(); + if (!$layout) { + return $this; + } + $layout->unsetChild($this->getNameInLayout(), $alias); + return $this; + } + + /** + * Call a child and unset it, if callback matched result + * + * $params will pass to child callback + * $params may be array, if called from layout with elements with same name, for example: + * ...value_1value_2value_3 + * + * Or, if called like this: + * ...value_1value_2value_3 + * - then it will be $params1, $params2, $params3 + * + * It is no difference anyway, because they will be transformed in appropriate way. + * + * @param string $alias + * @param string $callback + * @param mixed $result + * @param array $params + * @return Mage_Core_Block_Abstract + */ + public function unsetCallChild($alias, $callback, $result, $params) + { + $child = $this->getChildBlock($alias); + if ($child) { + $args = func_get_args(); + $alias = array_shift($args); + $callback = array_shift($args); + $result = (string)array_shift($args); + if (!is_array($params)) { + $params = $args; + } + + if ($result == call_user_func_array(array(&$child, $callback), $params)) { + $this->unsetChild($alias); + } + } + return $this; + } + + /** + * Unset all children blocks + * + * @return Mage_Core_Block_Abstract + */ + public function unsetChildren() + { + $layout = $this->getLayout(); + if (!$layout) { + return $this; + } + $name = $this->getNameInLayout(); + $children = $layout->getChildNames($name); + foreach ($children as $childName) { + $layout->unsetChild($name, $childName); + } + return $this; + } + + /** + * Retrieve child block by name + * + * @param string $alias + * @return Mage_Core_Block_Abstract|bool + */ + public function getChildBlock($alias) + { + $layout = $this->getLayout(); + if (!$layout) { + return false; + } + $name = $layout->getChildName($this->getNameInLayout(), $alias); + if ($name) { + return $layout->getBlock($name); + } + return false; + } + + /** + * Retrieve child block HTML + * + * @param string $alias + * @param boolean $useCache + * @return string + */ + public function getChildHtml($alias = '', $useCache = true) + { + $layout = $this->getLayout(); + if (!$layout) { + return ''; + } + $name = $this->getNameInLayout(); + $out = ''; + if ($alias) { + $childName = $layout->getChildName($name, $alias); + if ($childName) { + $out = $layout->renderElement($childName, $useCache); + } + } else { + foreach ($layout->getChildNames($name) as $child) { + $out .= $layout->renderElement($child, $useCache); + } + } + + return $out; + } + + /** + * Render output of child child element + * + * @param string $alias + * @param string $childChildAlias + * @param bool $useCache + * @return string + */ + public function getChildChildHtml($alias, $childChildAlias = '', $useCache = true) + { + $layout = $this->getLayout(); + if (!$layout) { + return ''; + } + $childName = $layout->getChildName($this->getNameInLayout(), $alias); + if (!$childName) { + return ''; + } + $out = ''; + if ($childChildAlias) { + $childChildName = $layout->getChildName($childName, $childChildAlias); + $out = $layout->renderElement($childChildName, $useCache); + } else { + foreach ($layout->getChildNames($childName) as $childChild) { + $out .= $layout->renderElement($childChild, $useCache); + } + } + return $out; + } + + /** + * Retrieve block html + * + * @param string $name + * @return string + */ + public function getBlockHtml($name) + { + $block = $this->_layout->getBlock($name); + if ($block) { + return $block->toHtml(); + } + return ''; + } + + /** + * Insert child element into specified position + * + * By default inserts as first element into children list + * + * @param Mage_Core_Block_Abstract|string $element + * @param string|int|null $siblingName + * @param bool $after + * @param string $alias + * @return Mage_Core_Block_Abstract|bool + */ + public function insert($element, $siblingName = 0, $after = true, $alias = '') + { + $layout = $this->getLayout(); + if (!$layout) { + return false; + } + if ($element instanceof Mage_Core_Block_Abstract) { + $elementName = $element->getNameInLayout(); + } else { + $elementName = $element; + } + $layout->setChild($this->_nameInLayout, $elementName, $alias); + $layout->reorderChild($this->_nameInLayout, $elementName, $siblingName, $after); + return $this; + } + + /** + * Append element to the end of children list + * + * @param Mage_Core_Block_Abstract|string $element + * @param string $alias + * @return Mage_Core_Block_Abstract + */ + public function append($element, $alias = '') + { + return $this->insert($element, null, true, $alias); + } + + /** + * Add self to the specified group of parent block + * + * @param string $groupName + * @return Mage_Core_Block_Abstract|bool + */ + public function addToParentGroup($groupName) + { + $layout = $this->getLayout(); + if (!$layout) { + return false; + } + $layout->addToParentGroup($this->getNameInLayout(), $groupName); + + return $this; + } + + /** + * Get a group of child blocks + * + * Returns an array of => + * or an array of => + * The callback currently supports only $this methods and passes the alias as parameter + * + * @param string $groupName + * @return array + */ + public function getGroupChildNames($groupName) + { + return $this->getLayout()->getGroupChildNames($this->getNameInLayout(), $groupName); + } + + /** + * Get a value from child block by specified key + * + * @param string $alias + * @param string $key + * @return mixed + */ + public function getChildData($alias, $key = '') + { + $child = $this->getChildBlock($alias); + if ($child) { + return $child->getData($key); + } + return null; + } + + /** + * Before rendering html, but after trying to load cache + * + * @return Mage_Core_Block_Abstract + */ + protected function _beforeToHtml() + { + return $this; + } + + /** + * Specify block output frame tags + * + * @param $openTag + * @param $closeTag + * @return Mage_Core_Block_Abstract + */ + public function setFrameTags($openTag, $closeTag = null) + { + $this->_frameOpenTag = $openTag; + if ($closeTag) { + $this->_frameCloseTag = $closeTag; + } else { + $this->_frameCloseTag = '/' . $openTag; + } + return $this; + } + + /** + * Produce and return block's html output + * + * It is a final method, but you can override _toHtml() method in descendants if needed. + * + * @return string + */ + final public function toHtml() + { + $this->_eventManager->dispatch('core_block_abstract_to_html_before', array('block' => $this)); + if ($this->_storeConfig->getConfig('advanced/modules_disable_output/' . $this->getModuleName())) { + return ''; + } + $html = $this->_loadCache(); + if ($html === false) { + if ($this->hasData('translate_inline')) { + $this->_translator->setTranslateInline($this->getData('translate_inline')); + } + + $this->_beforeToHtml(); + $html = $this->_toHtml(); + $this->_saveCache($html); + + if ($this->hasData('translate_inline')) { + $this->_translator->setTranslateInline(true); + } + } + $html = $this->_afterToHtml($html); + + /** + * Check framing options + */ + if ($this->_frameOpenTag) { + $html = '<' . $this->_frameOpenTag . '>' . $html . '<' . $this->_frameCloseTag . '>'; + } + + return $html; + } + + /** + * Processing block html after rendering + * + * @param string $html + * @return string + */ + protected function _afterToHtml($html) + { + return $html; + } + + /** + * Override this method in descendants to produce html + * + * @return string + */ + protected function _toHtml() + { + return ''; + } + + /** + * Retrieve data-ui-id attribute which will distinguish link/input/container/anything else in template among others + * Function takes an arbitrary amount of parameters + * + * @return string + */ + public function getUiId() + { + return ' data-ui-id="' . call_user_func_array(array($this, 'getJsId'), func_get_args()) . '" '; + } + + /** + * Generate id for using in JavaScript UI + * Function takes an arbitrary amount of parameters + * + * @return string + */ + public function getJsId() + { + $rawId = $this->_nameInLayout . '-' . implode('-', func_get_args()); + return trim(preg_replace('/[^a-z0-9]+/', '-', strtolower($rawId)), '-'); + } + + /** + * Generate url by route and parameters + * + * @param string $route + * @param array $params + * @return string + */ + public function getUrl($route = '', $params = array()) + { + return $this->_urlBuilder->getUrl($route, $params); + } + + /** + * Generate base64-encoded url by route and parameters + * + * @param string $route + * @param array $params + * @return string + */ + public function getUrlBase64($route = '', $params = array()) + { + return $this->helper('Mage_Core_Helper_Data')->urlEncode($this->getUrl($route, $params)); + } + + /** + * Generate url-encoded url by route and parameters + * + * @param string $route + * @param array $params + * @return string + */ + public function getUrlEncoded($route = '', $params = array()) + { + return $this->helper('Mage_Core_Helper_Data')->urlEncode($this->getUrl($route, $params)); + } + + /** + * Retrieve url of themes file + * + * @param string $file path to file in theme + * @param array $params + * @return string + * @throws Magento_Exception + */ + public function getViewFileUrl($file = null, array $params = array()) + { + try { + return Mage::getDesign()->getViewFileUrl($file, $params); + } catch (Magento_Exception $e) { + Mage::logException($e); + return $this->_getNotFoundUrl(); + } + } + + /** + * Get 404 file not found url + * + * @param string $route + * @param array $params + * @return string + */ + protected function _getNotFoundUrl($route = '', $params = array('_direct' => 'core/index/notfound')) + { + return $this->getUrl($route, $params); + } + + /** + * Retrieve messages block + * + * @return Mage_Core_Block_Messages + */ + public function getMessagesBlock() + { + if (is_null($this->_messagesBlock)) { + return $this->getLayout()->getMessagesBlock(); + } + return $this->_messagesBlock; + } + + /** + * Set messages block + * + * @param Mage_Core_Block_Messages $block + * @return Mage_Core_Block_Abstract + */ + public function setMessagesBlock(Mage_Core_Block_Messages $block) + { + $this->_messagesBlock = $block; + return $this; + } + + /** + * Return helper object + * + * @param string $name + * @return Mage_Core_Helper_Abstract + */ + public function helper($name) + { + if ($this->getLayout()) { + return $this->getLayout()->helper($name); + } + return $this->_helperFactory->get($name); + } + + /** + * Retrieve formatting date + * + * @param string $date + * @param string $format + * @param bool $showTime + * @return string + */ + public function formatDate($date = null, $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, $showTime = false) + { + return $this->helper('Mage_Core_Helper_Data')->formatDate($date, $format, $showTime); + } + + /** + * Retrieve formatting time + * + * @param string $time + * @param string $format + * @param bool $showDate + * @return string + */ + public function formatTime($time = null, $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, $showDate = false) + { + return $this->helper('Mage_Core_Helper_Data')->formatTime($time, $format, $showDate); + } + + /** + * Retrieve module name of block + * + * @return string + */ + public function getModuleName() + { + if (!$this->_getData('module_name')) { + $this->setData('module_name', self::extractModuleName(get_class($this))); + } + return $this->_getData('module_name'); + } + + /** + * Extract module name from specified block class name + * + * @param string $className + * @return string + */ + public static function extractModuleName($className) + { + return substr($className, 0, strpos($className, '_Block')); + } + + /** + * Translate block sentence + * + * @return string + * @SuppressWarnings(PHPMD.ShortMethodName) + */ + public function __() + { + $args = func_get_args(); + $expr = new Mage_Core_Model_Translate_Expr(array_shift($args), $this->getModuleName()); + array_unshift($args, $expr); + return $this->_translator->translate($args); + } + + /** + * Escape html entities + * + * @param string|array $data + * @param array $allowedTags + * @return string + */ + public function escapeHtml($data, $allowedTags = null) + { + return $this->helper('Mage_Core_Helper_Data')->escapeHtml($data, $allowedTags); + } + + /** + * Wrapper for standard strip_tags() function with extra functionality for html entities + * + * @param string $data + * @param string $allowableTags + * @param bool $allowHtmlEntities + * @return string + */ + public function stripTags($data, $allowableTags = null, $allowHtmlEntities = false) + { + return $this->helper('Mage_Core_Helper_Data')->stripTags($data, $allowableTags, $allowHtmlEntities); + } + + /** + * Escape html entities in url + * + * @param string $data + * @return string + */ + public function escapeUrl($data) + { + return $this->helper('Mage_Core_Helper_Data')->escapeUrl($data); + } + + /** + * Escape quotes inside html attributes + * Use $addSlashes = false for escaping js that inside html attribute (onClick, onSubmit etc) + * + * @param string $data + * @param bool $addSlashes + * @return string + */ + public function quoteEscape($data, $addSlashes = false) + { + return $this->helper('Mage_Core_Helper_Data')->quoteEscape($data, $addSlashes); + } + + /** + * Escape quotes in java scripts + * + * @param mixed $data + * @param string $quote + * @return mixed + */ + public function jsQuoteEscape($data, $quote = '\'') + { + return $this->helper('Mage_Core_Helper_Data')->jsQuoteEscape($data, $quote); + } + + /** + * Get block name + * + * @return string + */ + public function getNameInLayout() + { + return $this->_nameInLayout; + } + + /** + * Prepare url for save to cache + * + * @return Mage_Core_Block_Abstract + */ + protected function _beforeCacheUrl() + { + if ($this->_cache->canUse(self::CACHE_GROUP)) { + Mage::app()->setUseSessionVar(true); + } + return $this; + } + + /** + * Replace URLs from cache + * + * @param string $html + * @return string + */ + protected function _afterCacheUrl($html) + { + if ($this->_cache->canUse(self::CACHE_GROUP)) { + Mage::app()->setUseSessionVar(false); + Magento_Profiler::start('CACHE_URL'); + $html = $this->_urlBuilder->sessionUrlVar($html); + Magento_Profiler::stop('CACHE_URL'); + } + return $html; + } + + /** + * Get cache key informative items + * Provide string array key to share specific info item with FPC placeholder + * + * @return array + */ + public function getCacheKeyInfo() + { + return array( + $this->getNameInLayout() + ); + } + + /** + * Get Key for caching block content + * + * @return string + */ + public function getCacheKey() + { + if ($this->hasData('cache_key')) { + return $this->getData('cache_key'); + } + /** + * don't prevent recalculation by saving generated cache key + * because of ability to render single block instance with different data + */ + $key = $this->getCacheKeyInfo(); + //ksort($key); // ignore order + $key = array_values($key); // ignore array keys + $key = implode('|', $key); + $key = sha1($key); + return $key; + } + + /** + * Get tags array for saving cache + * + * @return array + */ + public function getCacheTags() + { + if (!$this->hasData('cache_tags')) { + $tags = array(); + } else { + $tags = $this->getData('cache_tags'); + } + $tags[] = self::CACHE_GROUP; + return $tags; + } + + /** + * Get block cache life time + * + * @return int + */ + public function getCacheLifetime() + { + if (!$this->hasData('cache_lifetime')) { + return null; + } + return $this->getData('cache_lifetime'); + } + + /** + * Load block html from cache storage + * + * @return string | false + */ + protected function _loadCache() + { + if (is_null($this->getCacheLifetime()) || !$this->_cache->canUse(self::CACHE_GROUP)) { + return false; + } + $cacheKey = $this->getCacheKey(); + $cacheData = $this->_cache->load($cacheKey); + if ($cacheData) { + $cacheData = str_replace( + $this->_getSidPlaceholder($cacheKey), + $this->_session->getSessionIdQueryParam() . '=' . $this->_session->getEncryptedSessionId(), + $cacheData + ); + } + return $cacheData; + } + + /** + * Save block content to cache storage + * + * @param string $data + * @return Mage_Core_Block_Abstract + */ + protected function _saveCache($data) + { + if (is_null($this->getCacheLifetime()) || !$this->_cache->canUse(self::CACHE_GROUP)) { + return false; + } + $cacheKey = $this->getCacheKey(); + $data = str_replace( + $this->_session->getSessionIdQueryParam() . '=' . $this->_session->getEncryptedSessionId(), + $this->_getSidPlaceholder($cacheKey), + $data + ); + + $this->_cache->save($data, $cacheKey, $this->getCacheTags(), $this->getCacheLifetime()); + return $this; + } + + /** + * Get SID placeholder for cache + * + * @param null|string $cacheKey + * @return string + */ + protected function _getSidPlaceholder($cacheKey = null) + { + if (is_null($cacheKey)) { + $cacheKey = $this->getCacheKey(); + } + + return ''; + } + + /** + * Get variable value from view configuration + * + * Module name can be omitted. If omitted, it will be determined automatically. + * + * @param string $name variable name + * @param string $module optional module name + * @return string|false + */ + public function getVar($name, $module = null) + { + $module = $module ?: $this->getModuleName(); + return $this->_designPackage->getViewConfig()->getVarValue($module, $name); + } +} diff --git a/app/code/Mage/Core/Block/Context.php b/app/code/Mage/Core/Block/Context.php new file mode 100644 index 0000000000000..866965e77883b --- /dev/null +++ b/app/code/Mage/Core/Block/Context.php @@ -0,0 +1,212 @@ +_request = $request; + $this->_layout = $layout; + $this->_eventManager = $eventManager; + $this->_urlBuilder = $urlBuilder; + $this->_translator = $translator; + $this->_cache = $cache; + $this->_designPackage = $designPackage; + $this->_session = $session; + $this->_storeConfig = $storeConfig; + $this->_frontController = $frontController; + $this->_helperFactory = $helperFactory; + } + + /** + * @return Mage_Core_Model_CacheInterface + */ + public function getCache() + { + return $this->_cache; + } + + /** + * @return Mage_Core_Model_Design_Package + */ + public function getDesignPackage() + { + return $this->_designPackage; + } + + /** + * @return Mage_Core_Model_Event_Manager + */ + public function getEventManager() + { + return $this->_eventManager; + } + + /** + * @return Mage_Core_Controller_Varien_Front + */ + public function getFrontController() + { + return $this->_frontController; + } + + /** + * @return Mage_Core_Model_Factory_Helper + */ + public function getHelperFactory() + { + return $this->_helperFactory; + } + + /** + * @return Mage_Core_Model_Layout + */ + public function getLayout() + { + return $this->_layout; + } + + /** + * @return Mage_Core_Controller_Request_Http + */ + public function getRequest() + { + return $this->_request; + } + + /** + * @return Mage_Core_Model_Session|Mage_Core_Model_Session_Abstract + */ + public function getSession() + { + return $this->_session; + } + + /** + * @return Mage_Core_Model_Store_Config + */ + public function getStoreConfig() + { + return $this->_storeConfig; + } + + /** + * @return Mage_Core_Model_Translate + */ + public function getTranslator() + { + return $this->_translator; + } + + /** + * @return Mage_Core_Model_UrlInterface + */ + public function getUrlBuilder() + { + return $this->_urlBuilder; + } +} diff --git a/app/code/core/Mage/Core/Block/Html/Calendar.php b/app/code/Mage/Core/Block/Html/Calendar.php similarity index 100% rename from app/code/core/Mage/Core/Block/Html/Calendar.php rename to app/code/Mage/Core/Block/Html/Calendar.php diff --git a/app/code/core/Mage/Core/Block/Html/Date.php b/app/code/Mage/Core/Block/Html/Date.php similarity index 100% rename from app/code/core/Mage/Core/Block/Html/Date.php rename to app/code/Mage/Core/Block/Html/Date.php diff --git a/app/code/core/Mage/Core/Block/Html/Link.php b/app/code/Mage/Core/Block/Html/Link.php similarity index 100% rename from app/code/core/Mage/Core/Block/Html/Link.php rename to app/code/Mage/Core/Block/Html/Link.php diff --git a/app/code/core/Mage/Core/Block/Html/Select.php b/app/code/Mage/Core/Block/Html/Select.php similarity index 100% rename from app/code/core/Mage/Core/Block/Html/Select.php rename to app/code/Mage/Core/Block/Html/Select.php diff --git a/app/code/Mage/Core/Block/Messages.php b/app/code/Mage/Core/Block/Messages.php new file mode 100644 index 0000000000000..88893e15a36fc --- /dev/null +++ b/app/code/Mage/Core/Block/Messages.php @@ -0,0 +1,353 @@ + + */ +class Mage_Core_Block_Messages extends Mage_Core_Block_Template +{ + /** + * Messages collection + * + * @var Mage_Core_Model_Message_Collection + */ + protected $_messages; + + /** + * Store first level html tag name for messages html output + * + * @var string + */ + protected $_messagesFirstLevelTagName = 'ul'; + + /** + * Store second level html tag name for messages html output + * + * @var string + */ + protected $_messagesSecondLevelTagName = 'li'; + + /** + * Store content wrapper html tag name for messages html output + * + * @var string + */ + protected $_messagesContentWrapperTagName = 'span'; + + /** + * Flag which require message text escape + * + * @var bool + */ + protected $_escapeMessageFlag = false; + + /** + * Storage for used types of message storages + * + * @var array + */ + protected $_usedStorageTypes = array(); + + /** + * Grouped message types + * + * @var array + */ + protected $_messageTypes = array( + Mage_Core_Model_Message::ERROR, + Mage_Core_Model_Message::WARNING, + Mage_Core_Model_Message::NOTICE, + Mage_Core_Model_Message::SUCCESS + ); + + /** + * Preparing global layout + * + * @return Mage_Core_Block_Messages + */ + public function _prepareLayout() + { + $this->addStorageType(get_class($this->_session)); + $this->addMessages($this->_session->getMessages(true)); + parent::_prepareLayout(); + return $this; + } + + /** + * Set message escape flag + * + * @param bool $flag + * @return Mage_Core_Block_Messages + */ + public function setEscapeMessageFlag($flag) + { + $this->_escapeMessageFlag = $flag; + return $this; + } + + /** + * Set messages collection + * + * @param Mage_Core_Model_Message_Collection $messages + * @return Mage_Core_Block_Messages + */ + public function setMessages(Mage_Core_Model_Message_Collection $messages) + { + $this->_messages = $messages; + return $this; + } + + /** + * Add messages to display + * + * @param Mage_Core_Model_Message_Collection $messages + * @return Mage_Core_Block_Messages + */ + public function addMessages(Mage_Core_Model_Message_Collection $messages) + { + foreach ($messages->getItems() as $message) { + $this->getMessageCollection()->add($message); + } + return $this; + } + + /** + * Retrieve messages collection + * + * @return Mage_Core_Model_Message_Collection + */ + public function getMessageCollection() + { + if (!($this->_messages instanceof Mage_Core_Model_Message_Collection)) { + $this->_messages = Mage::getModel('Mage_Core_Model_Message_Collection'); + } + return $this->_messages; + } + + /** + * Adding new message to message collection + * + * @param Mage_Core_Model_Message_Abstract $message + * @return Mage_Core_Block_Messages + */ + public function addMessage(Mage_Core_Model_Message_Abstract $message) + { + $this->getMessageCollection()->add($message); + return $this; + } + + /** + * Adding new error message + * + * @param string $message + * @return Mage_Core_Block_Messages + */ + public function addError($message) + { + $this->addMessage(Mage::getSingleton('Mage_Core_Model_Message')->error($message)); + return $this; + } + + /** + * Adding new warning message + * + * @param string $message + * @return Mage_Core_Block_Messages + */ + public function addWarning($message) + { + $this->addMessage(Mage::getSingleton('Mage_Core_Model_Message')->warning($message)); + return $this; + } + + /** + * Adding new notice message + * + * @param string $message + * @return Mage_Core_Block_Messages + */ + public function addNotice($message) + { + $this->addMessage(Mage::getSingleton('Mage_Core_Model_Message')->notice($message)); + return $this; + } + + /** + * Adding new success message + * + * @param string $message + * @return Mage_Core_Block_Messages + */ + public function addSuccess($message) + { + $this->addMessage(Mage::getSingleton('Mage_Core_Model_Message')->success($message)); + return $this; + } + + /** + * Retrieve messages array by message type + * + * @param string $type + * @return array + */ + public function getMessages($type=null) + { + return $this->getMessageCollection()->getItems($type); + } + + /** + * Retrieve messages in HTML format + * + * @param string $type + * @return string + */ + public function getHtml($type = null) + { + $html = '<' . $this->_messagesFirstLevelTagName . ' id="admin_messages">'; + foreach ($this->getMessages($type) as $message) { + $html .= '<' . $this->_messagesSecondLevelTagName . ' class="' . $message->getType() . '-msg" ' + . $this->getUiId('message') . '>' + . $this->_escapeMessageFlag ? $this->escapeHtml($message->getText()) : $message->getText() + . '_messagesSecondLevelTagName . '>'; + } + $html .= '_messagesFirstLevelTagName . '>'; + return $html; + } + + /** + * Return grouped message types + * + * @return array + */ + public function getMessageTypes() + { + return $this->_messageTypes; + } + + /** + * Retrieve messages in HTML format grouped by type + * + * @return string + */ + public function getGroupedHtml() + { + $html = ''; + foreach ($this->getMessageTypes() as $type) { + if ($messages = $this->getMessages($type)) { + if (!$html) { + $html .= '<' . $this->_messagesFirstLevelTagName . ' class="messages">'; + } + $html .= '<' . $this->_messagesSecondLevelTagName . ' class="' . $type . '-msg">'; + $html .= '<' . $this->_messagesFirstLevelTagName . '>'; + + foreach ($messages as $message) { + $html.= '<' . $this->_messagesSecondLevelTagName . '>'; + $html.= '<' . $this->_messagesContentWrapperTagName . $this->getUiId('message', $type) . '>'; + $html.= ($this->_escapeMessageFlag) ? $this->escapeHtml($message->getText()) : $message->getText(); + $html.= '_messagesContentWrapperTagName . '>'; + $html.= '_messagesSecondLevelTagName . '>'; + } + $html .= '_messagesFirstLevelTagName . '>'; + $html .= '_messagesSecondLevelTagName . '>'; + } + } + if ($html) { + $html .= '_messagesFirstLevelTagName . '>'; + } + return $html; + } + + /** + * Render block HTML + * + * @return string + */ + protected function _toHtml() + { + if ($this->getTemplate()) { + $html = parent::_toHtml(); + } else { + $html = $this->getGroupedHtml(); + } + return $html; + } + + /** + * Set messages first level html tag name for output messages as html + * + * @param string $tagName + */ + public function setMessagesFirstLevelTagName($tagName) + { + $this->_messagesFirstLevelTagName = $tagName; + } + + /** + * Set messages first level html tag name for output messages as html + * + * @param string $tagName + */ + 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; + } + + /** + * Whether or not to escape the message. + * + * @return boolean + */ + public function shouldEscapeMessage() + { + return $this->_escapeMessageFlag; + } +} diff --git a/app/code/core/Mage/Core/Block/Store/Switcher.php b/app/code/Mage/Core/Block/Store/Switcher.php similarity index 100% rename from app/code/core/Mage/Core/Block/Store/Switcher.php rename to app/code/Mage/Core/Block/Store/Switcher.php diff --git a/app/code/Mage/Core/Block/Template.php b/app/code/Mage/Core/Block/Template.php new file mode 100644 index 0000000000000..84c4aa6fb45a7 --- /dev/null +++ b/app/code/Mage/Core/Block/Template.php @@ -0,0 +1,432 @@ + + */ +class Mage_Core_Block_Template extends Mage_Core_Block_Abstract +{ + const XML_PATH_DEBUG_TEMPLATE_HINTS = 'dev/debug/template_hints'; + const XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS = 'dev/debug/template_hints_blocks'; + const XML_PATH_TEMPLATE_ALLOW_SYMLINK = 'dev/template/allow_symlink'; + + /** + * Assigned variables for view + * + * @var array + */ + protected $_viewVars = array(); + + protected $_baseUrl; + + protected $_jsUrl; + + /** + * Is allowed symlinks flag + * + * @var bool + */ + protected $_allowSymlinks = null; + + protected static $_showTemplateHints; + protected static $_showTemplateHintsBlocks; + + /** + * @var Mage_Core_Model_Dir + */ + protected $_dirs; + + /** + * @var Mage_Core_Model_Logger + */ + protected $_logger; + + /** + * @var Magento_Filesystem + */ + protected $_filesystem; + + /** + * Path to template file in theme. + * + * @var string + */ + protected $_template; + + /** + * @var Mage_Core_Block_Template_Engine_Factory + */ + protected $_tmplEngineFactory; + + /** + * @var Magento_Datasource_Factory + */ + protected $_dataSourceFactory; + + /** + * @var array + */ + protected $_renderers = array(); + + /** + * @param Mage_Core_Block_Template_Context $context + * @param array $data + */ + public function __construct(Mage_Core_Block_Template_Context $context, + array $data = array()) + { + $this->_dirs = $context->getDirs(); + $this->_logger = $context->getLogger(); + $this->_filesystem = $context->getFilesystem(); + $this->_tmplEngineFactory = $context->getEngineFactory(); + $this->_dataSourceFactory = $context->getDataSourceFactory(); + parent::__construct($context, $data); + } + + /** + * Internal constructor, that is called from real constructor + */ + protected function _construct() + { + parent::_construct(); + + /* + * In case template was passed through constructor + * we assign it to block's property _template + * Mainly for those cases when block created + * not via Mage_Core_Model_Layout::addBlock() + */ + if ($this->hasData('template')) { + $this->setTemplate($this->getData('template')); + } + } + + /** + * Get relevant path to template + * + * @return string + */ + public function getTemplate() + { + return $this->_template; + } + + /** + * Set path to template used for generating block's output. + * + * @param string $template + * @return Mage_Core_Block_Template + */ + public function setTemplate($template) + { + $this->_template = $template; + return $this; + } + + /** + * Get absolute path to template + * + * @return string + */ + public function getTemplateFile() + { + $params = array('module' => $this->getModuleName()); + $area = $this->getArea(); + if ($area) { + $params['area'] = $area; + } + $templateName = $this->_designPackage->getFilename($this->getTemplate(), $params); + return $templateName; + } + + /** + * Get design area + * @return string + */ + public function getArea() + { + $result = $this->_getData('area'); + if (!$result && $this->getLayout()) { + $result = $this->getLayout()->getArea(); + } + return $result; + } + + /** + * Assign variable + * + * @param string|array $key + * @param mixed $value + * @return Mage_Core_Block_Template + */ + public function assign($key, $value=null) + { + if (is_array($key)) { + foreach ($key as $k=>$v) { + $this->assign($k, $v); + } + } else { + $this->_viewVars[$key] = $value; + } + return $this; + } + + /** + * Check if direct output is allowed for block + * + * @return bool + */ + public function getDirectOutput() + { + if ($this->getLayout()) { + return $this->getLayout()->isDirectOutput(); + } + return false; + } + + public function getShowTemplateHints() + { + if (is_null(self::$_showTemplateHints)) { + self::$_showTemplateHints = Mage::getStoreConfig(self::XML_PATH_DEBUG_TEMPLATE_HINTS) + && Mage::helper('Mage_Core_Helper_Data')->isDevAllowed(); + self::$_showTemplateHintsBlocks = Mage::getStoreConfig(self::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS) + && Mage::helper('Mage_Core_Helper_Data')->isDevAllowed(); + } + return self::$_showTemplateHints; + } + + /** + * Retrieve block view from file (template) + * + * @param string $fileName + * @return string + * @throws Exception + */ + public function fetchView($fileName) + { + $viewShortPath = str_replace($this->_dirs->getDir(Mage_Core_Model_Dir::ROOT), '', $fileName); + Magento_Profiler::start('TEMPLATE:' . $fileName, array('group' => 'TEMPLATE', 'file_name' => $viewShortPath)); + + + $do = $this->getDirectOutput(); + + if (!$do) { + ob_start(); + } + if ($this->getShowTemplateHints()) { + echo << +
    {$fileName}
    +HTML; + if (self::$_showTemplateHintsBlocks) { + $thisClass = get_class($this); + echo <<{$thisClass}
    +HTML; + } + } + + try { + if ((Magento_Filesystem::isPathInDirectory($fileName, $this->_dirs->getDir(Mage_Core_Model_Dir::APP)) + || Magento_Filesystem::isPathInDirectory($fileName, $this->_dirs->getDir(Mage_Core_Model_Dir::THEMES)) + || $this->_getAllowSymlinks()) && $this->_filesystem->isFile($fileName) + ) { + $extension = substr($fileName, strrpos($fileName, '.')+1); + $templateEngine = $this->_tmplEngineFactory->get($extension); + if ($templateEngine != null) { + $templateEngine->render($this, $fileName, $this->_viewVars); + } + } else { + $this->_logger->log("Invalid template file: '{$fileName}'", Zend_Log::CRIT); + } + + } catch (Exception $e) { + if (!$do) { + ob_get_clean(); + } + throw $e; + } + + if ($this->getShowTemplateHints()) { + echo '
    '; + } + + if (!$do) { + $html = ob_get_clean(); + } else { + $html = ''; + } + Magento_Profiler::stop('TEMPLATE:' . $fileName); + return $html; + } + + /** + * Render block HTML + * + * @return string + */ + protected function _toHtml() + { + if (!$this->getTemplate()) { + return ''; + } + return $this->fetchView($this->getTemplateFile()); + } + + /** + * Get base url of the application + * + * @return string + */ + public function getBaseUrl() + { + if (!$this->_baseUrl) { + $this->_baseUrl = $this->_urlBuilder->getBaseUrl(); + } + return $this->_baseUrl; + } + + /** + * Get data from specified object + * + * @param Varien_Object $object + * @param string $key + * @return mixed + */ + public function getObjectData(Varien_Object $object, $key) + { + return $object->getDataUsingMethod((string)$key); + } + + /** + * Get cache key informative items + * + * @return array + */ + public function getCacheKeyInfo() + { + return array( + 'BLOCK_TPL', + Mage::app()->getStore()->getCode(), + $this->getTemplateFile(), + 'template' => $this->getTemplate() + ); + } + + /** + * Get is allowed symliks flag + * + * @return bool + */ + protected function _getAllowSymlinks() + { + if (is_null($this->_allowSymlinks)) { + $this->_allowSymlinks = $this->_storeConfig->getConfigFlag(self::XML_PATH_TEMPLATE_ALLOW_SYMLINK); + } + return $this->_allowSymlinks; + } + + /** + * @param $namespace + * @param $staticType + * @param $dynamicType + * @param $type + * @param $template + * @param string $dataSourceName + * @param array $data + * @return $this + */ + public function addAdjustableRenderer($namespace, $staticType, $dynamicType, $type, $template, + $dataSourceName = '', $data = array()) + { + if (!isset($namespace)) { + $this->_renderers[$namespace] = array(); + } + if (!isset($namespace)) { + $this->_renderers[$namespace][$staticType] = array(); + } + $this->_renderers[$namespace][$staticType][$dynamicType] = array( + 'type' => $type, + 'template' => $template, + 'dataSourceName' => $dataSourceName, + 'data' => $data + ); + return $this; + } + + /** + * @param $namespace + * @param $staticType + * @param $dynamicType + * @return null + */ + public function getRendererOptions($namespace, $staticType, $dynamicType) + { + if (!isset($this->_renderers[$namespace])) { + return null; + } + if (!isset($this->_renderers[$namespace][$staticType])) { + return null; + } + if (!isset($this->_renderers[$namespace][$staticType][$dynamicType])) { + return null; + } + return $this->_renderers[$namespace][$staticType][$dynamicType]; + } + + /** + * @param $namespace + * @param $staticType + * @param $dynamicType + * @param $data + */ + public function executeRenderer($namespace, $staticType, $dynamicType, $data = array()) + { + if ($options = $this->getRendererOptions($namespace, $staticType, $dynamicType)) { + $dictionary = array(); + if (!empty($options['dataSourceName'])) { + $dictionary = $this->_dataSourceFactory->get($options['dataSourceName']); + } + /** @var $block Mage_Core_Block_Template */ + $block = $this->getLayout()->createBlock($options['type'], '') + ->setData($data) + ->assign($dictionary) + ->setTemplate($options['template']) + ->assign($data); + + echo $block->toHtml(); + } + } +} diff --git a/app/code/Mage/Core/Block/Template/Context.php b/app/code/Mage/Core/Block/Template/Context.php new file mode 100644 index 0000000000000..4ad86b1691d36 --- /dev/null +++ b/app/code/Mage/Core/Block/Template/Context.php @@ -0,0 +1,137 @@ +_dirs = $dirs; + $this->_logger = $logger; + $this->_filesystem = $filesystem; + $this->_dataSourceFactory = $dataSourceFactory; + $this->_engineFactory = $engineFactory; + } + + /** + * Get dirs instance + * @return Mage_Core_Model_Dir + */ + public function getDirs() + { + return $this->_dirs; + } + + /** + * Get filesystem instance + * + * @return Magento_Filesystem + */ + public function getFilesystem() + { + return $this->_filesystem; + } + + /** + * Get logger instance + * + * @return Mage_Core_Model_Logger + */ + public function getLogger() + { + return $this->_logger; + } + + /** + * Get datasource factory instance + * @return Magento_Datasource_Factory + */ + public function getDataSourceFactory() + { + return $this->_dataSourceFactory; + } + + /** + * Get the template engine factory instance + * + * @return Mage_Core_Block_Template_Engine_Factory + */ + public function getEngineFactory() + { + return $this->_engineFactory; + } +} diff --git a/app/code/Mage/Core/Block/Template/Engine/Factory.php b/app/code/Mage/Core/Block/Template/Engine/Factory.php new file mode 100644 index 0000000000000..c801a4f266dfa --- /dev/null +++ b/app/code/Mage/Core/Block/Template/Engine/Factory.php @@ -0,0 +1,54 @@ +_objectManager = $objectManager; + } + + /** + * Gets the singleton instance of the appropriate template engine + * + * @param string $name + * @return Mage_Core_Block_Template_EngineInterface + */ + public function get($name) + { + if ("twig" == $name) { + return $this->_objectManager->get('Mage_Core_Block_Template_Engine_Twig'); + } else if ("phtml" == $name) { + return $this->_objectManager->get('Mage_Core_Block_Template_Engine_Php'); + } + return null; + } +} diff --git a/app/code/Mage/Core/Block/Template/Engine/Php.php b/app/code/Mage/Core/Block/Template/Engine/Php.php new file mode 100644 index 0000000000000..a44cf46fe0427 --- /dev/null +++ b/app/code/Mage/Core/Block/Template/Engine/Php.php @@ -0,0 +1,71 @@ +_blockStack, $block); + $this->_currentBlock = $block; + + extract ($vars, EXTR_SKIP); + include $fileName; + + array_pop($this->_blockStack); + $this->_currentBlock = end($this->_blockStack); + } + + /** + * Redirects methods calls to the current block. This is needed because + * the templates are included in the context of this engine rather than + * in the context of the block. + * + * @param string $method + * @param array $args + * @return mixed + */ + public function __call($method, $args) + { + return call_user_func_array(array($this->_currentBlock, $method), $args); + } +} diff --git a/app/code/Mage/Core/Block/Template/Engine/Twig.php b/app/code/Mage/Core/Block/Template/Engine/Twig.php new file mode 100644 index 0000000000000..3ce24f2ded55e --- /dev/null +++ b/app/code/Mage/Core/Block/Template/Engine/Twig.php @@ -0,0 +1,104 @@ +_objectManager = $objectManager; + $this->_cache = $cache; + $this->_dir = $dir; + } + /** + * Render the named Twig template using the given block as the context of the + * Twig helper functions/filters. The $vars will be available to the Twig + * template as variables. + * + * @param Mage_Core_Block_Template $block + * @param string $templateFile + * @param array $vars + */ + public function render(Mage_Core_Block_Template $block, $fileName, $vars) + { + $twig = $this->getTwigEnvironment($fileName); + $this->updateTwigGlobalsAndFilters($twig, $block); + $data = $vars; + $data['block'] = $block; + + echo $twig->render(basename($fileName), $data); + } + + public function getTwigEnvironment($fileName) + { + $loader = new Twig_Loader_Filesystem(dirname($fileName)); + $twigEnvironmentOptions = array( + 'autoescape' => true, + 'cache' => $this->_dir->getDir(Mage_Core_Model_Dir::CACHE), + 'debug' => false, + 'optimizations' => 1, + 'strict_variables' => true, + ); + $environment = new Twig_Environment($loader, $twigEnvironmentOptions); + if (!$this->_cache->canUse('block_html')) { + $environment->clearCacheFiles(); + } + return $environment; + } + + public function updateTwigGlobalsAndFilters(Twig_Environment $environment, Mage_Core_Block_Template $block) + { + // build the array of filters + $filters = array(); + $filters['Mage_Core_ChildChildHtml'] = array($block, 'getChildChildHtml'); + $filters['Mage_Core_ChildHtml'] = array($block, 'getChildHtml'); + $filters['Mage_Core_ViewFileUrl'] = array($block, 'getViewFileUrl'); + $filters['translate'] = array($block, '__'); + + foreach ($filters as $name => $callable) { + //@TODO: not everything here should disable autoescape + $options = array('is_safe' => array('html')); + $filter = new Twig_SimpleFilter($name, $callable, $options); + $environment->addFilter($filter); + } + + $environment->addExtension( + $this->_objectManager->create('Mage_Core_Block_Template_Engine_TwigExtension', array('block' => $block))); + } + +} diff --git a/app/code/Mage/Core/Block/Template/Engine/TwigExtension.php b/app/code/Mage/Core/Block/Template/Engine/TwigExtension.php new file mode 100644 index 0000000000000..8f4771d79be79 --- /dev/null +++ b/app/code/Mage/Core/Block/Template/Engine/TwigExtension.php @@ -0,0 +1,213 @@ +_block = $block; + $this->_urlBuilder = $urlBuilder; + $this->_urlHelper = $urlHelper; + $this->_dataHelper = $dataHelper; + $this->_storeManager = $storeManager; + $this->_designPackage = $designPackage; + $this->_helperImage = $helperImage; + } + + public function getName() + { + return 'Magento'; + } + + /** + * Returns a list of global functions to add to the existing list. + * + * @return array An array of global functions + */ + public function getFunctions() + { + $options = array('is_safe' => array('html')); + + $urlEncodeFunction = function($url) { + return strtr(base64_encode($url), '+/=', '-_,'); + }; + + return array( + new Twig_SimpleFunction('createBlock', array($this->_block->getLayout(), 'createBlock')), + new Twig_SimpleFunction('executeRenderer', array($this->_block, 'executeRenderer'), $options), + new Twig_SimpleFunction('getChildChildHtml', array($this->_block, 'getChildChildHtml'), $options), + new Twig_SimpleFunction('getChildHtml', array($this->_block, 'getChildHtml'), $options), + new Twig_SimpleFunction('getChildData', array($this->_block, 'getChildData'), $options), + new Twig_SimpleFunction('getDateFormat', array(Mage::app()->getLocale(), 'getDateFormat')), + new Twig_SimpleFunction('getElementAlias', array($this->_block->getLayout(), 'getElementAlias'), $options), + new Twig_SimpleFunction('getGroupChildNames', array($this->_block, 'getGroupChildNames'), $options), + new Twig_SimpleFunction('getSelectHtml', array($this, '_getSelectHtml'), $options), + new Twig_SimpleFunction('getMessagesHtml', + array($this->_block->getMessagesBlock(), 'getGroupedHtml'), $options), + new Twig_SimpleFunction('getSelectFromToHtml', array($this, '_getSelectFromToHtml'), $options), + new Twig_SimpleFunction('renderElement', array($this->_block->getLayout(), 'renderElement'), $options), + new Twig_SimpleFunction('viewFileUrl', array($this->_block, 'getViewFileUrl'), $options), + new Twig_SimpleFunction('getUrl', array($this->_urlBuilder, 'getUrl'), $options), + new Twig_SimpleFunction('encodeUrl', $urlEncodeFunction, $options), + new Twig_SimpleFunction('getCurrentUrl', array($this->_urlHelper, 'getCurrentUrl'), $options), + new Twig_SimpleFunction('isModuleOutputEnabled', + array($this->_dataHelper, 'isModuleOutputEnabled'), $options), + new Twig_SimpleFunction('getStoreConfig', array($this->_storeManager->getStore(), 'getConfig'), $options), + new Twig_SimpleFunction('getDesignVarValue', array($this->_designPackage->getViewConfig(), 'getVarValue'), + $options), + new Twig_SimpleFunction('getDefaultImage', array($this->_helperImage, 'getDefaultImage'), $options), + ); + } + + /** + * From Mage_Catalog_Block_Product_View_Options_Type_Date: Return drop-down html with range of values + * + * @param $selectBlock + * @param string $name Id/name of html select element + * @param int $from Start position + * @param int $to End position + * @param $nameOptionsById + * @param $optionsId + * @param null $value Value selected + * @return string Formatted Html + */ + public function _getSelectFromToHtml($selectBlock, $name, $from, $to, $nameOptionsById, + $optionsId, $value = null) + { + $options = array( + array('value' => '', 'label' => '-') + ); + for ($i = $from; $i <= $to; $i++) { + $options[] = array('value' => $i, 'label' => $this->_getValueWithLeadingZeros(true, $i)); + } + return $this->_initSelectBlock($selectBlock, $optionsId, $name, $nameOptionsById, $value) + ->setOptions($options) + ->getHtml(); + } + + /** + * Initializes values in the selection list. + * From Mage_Catalog_Block_Product_View_Options_Type_Date: HTML select element + * + * @param $selectBlock + * @param $id + * @param $name + * @param $nameOptionsById + * @param null $value + * @return Mage_Core_Block_Html_Select + */ + public function _initSelectBlock($selectBlock, $id, $name, $nameOptionsById, $value = null) + { + //$this->setSkipJsReloadPrice(1); + + // $require = $this->getOption()->getIsRequire() ? ' required-entry' : ''; + $require = ''; + $selectBlock->setId('options_' . $id . '_' . $name) + ->setClass('product-custom-option datetime-picker' . $require) + ->setExtraParams() + ->setName('options[' . $id . '][' . $name . ']'); + + $extraParams = 'style="width:auto"'; + //if (!$this->getSkipJsReloadPrice()) { + // $extraParams .= ' onchange="opConfig.reloadPrice()"'; + //} + $selectBlock->setExtraParams($extraParams); + + if (is_null($value)) { + $value = $nameOptionsById; + } + if (!is_null($value)) { + $selectBlock->setValue($value); + } + + return $selectBlock; + } + + /** + * @param $selectBlock + * @param $id + * @param $name + * @param $nameOptionsById + * @param null $selectedValue + * @return mixed + */ + public function _getSelectHtml($selectBlock, $id, $name, $nameOptionsById, $selectedValue = null) { + + $options = array(); + foreach ($nameOptionsById as $value => $label) { + $options[] = array('value' => $value, 'label' => $label); + } + return $this->_initSelectBlock($selectBlock, $id, $name, $nameOptionsById, $selectedValue) + ->setOptions($options) + ->getHtml(); + } + + /** + * From Mage_Catalog_Block_Product_View_Options_Type_Date: Add Leading Zeros to number less than 10 + * + * @param int + * @return string + */ + protected static function _getValueWithLeadingZeros($fillLeadingZeros, $value) + { + if (!$fillLeadingZeros) { + return $value; + } + return $value < 10 ? '0'.$value : $value; + } +} \ No newline at end of file diff --git a/app/code/Mage/Core/Block/Template/EngineInterface.php b/app/code/Mage/Core/Block/Template/EngineInterface.php new file mode 100644 index 0000000000000..97268ae902b28 --- /dev/null +++ b/app/code/Mage/Core/Block/Template/EngineInterface.php @@ -0,0 +1,38 @@ + + */ +class Mage_Core_Controller_Response_Http extends Zend_Controller_Response_Http +{ + /** + * Transport object for observers to perform + * + * @var Varien_Object + */ + protected static $_transportObject = null; + + /** + * Fixes CGI only one Status header allowed bug + * + * @link http://bugs.php.net/bug.php?id=36705 + * + * @return Mage_Core_Controller_Response_Http + */ + public function sendHeaders() + { + if (!$this->canSendHeaders()) { + Mage::log('HEADERS ALREADY SENT: '.mageDebugBacktrace(true, true, true)); + return $this; + } + + if (substr(php_sapi_name(), 0, 3) == 'cgi') { + $statusSent = false; + foreach ($this->_headersRaw as $index => $header) { + if (stripos($header, 'status:')===0) { + if ($statusSent) { + unset($this->_headersRaw[$index]); + } else { + $statusSent = true; + } + } + } + foreach ($this->_headers as $index => $header) { + if (strcasecmp($header['name'], 'status') === 0) { + if ($statusSent) { + unset($this->_headers[$index]); + } else { + $statusSent = true; + } + } + } + } + return parent::sendHeaders(); + } + + public function sendResponse() + { + return parent::sendResponse(); + } + + /** + * Additionally check for session messages in several domains case + * + * @param string $url + * @param int $code + * @return Mage_Core_Controller_Response_Http + */ + public function setRedirect($url, $code = 302) + { + /** + * Use single transport object instance + */ + if (self::$_transportObject === null) { + self::$_transportObject = new Varien_Object; + } + self::$_transportObject->setUrl($url); + self::$_transportObject->setCode($code); + Mage::dispatchEvent('controller_response_redirect', + array('response' => $this, 'transport' => self::$_transportObject)); + + return parent::setRedirect(self::$_transportObject->getUrl(), self::$_transportObject->getCode()); + } +} diff --git a/app/code/Mage/Core/Controller/Varien/Action.php b/app/code/Mage/Core/Controller/Varien/Action.php new file mode 100644 index 0000000000000..4717c91b16781 --- /dev/null +++ b/app/code/Mage/Core/Controller/Varien/Action.php @@ -0,0 +1,1158 @@ + + */ +abstract class Mage_Core_Controller_Varien_Action extends Mage_Core_Controller_Varien_ActionAbstract +{ + const FLAG_NO_CHECK_INSTALLATION = 'no-install-check'; + const FLAG_NO_DISPATCH = 'no-dispatch'; + const FLAG_NO_PRE_DISPATCH = 'no-preDispatch'; + const FLAG_NO_POST_DISPATCH = 'no-postDispatch'; + const FLAG_NO_START_SESSION = 'no-startSession'; + const FLAG_NO_DISPATCH_BLOCK_EVENT = 'no-beforeGenerateLayoutBlocksDispatch'; + const FLAG_NO_COOKIES_REDIRECT = 'no-cookies-redirect'; + + const PARAM_NAME_SUCCESS_URL = 'success_url'; + const PARAM_NAME_ERROR_URL = 'error_url'; + const PARAM_NAME_REFERER_URL = 'referer_url'; + const PARAM_NAME_BASE64_URL = 'r64'; + const PARAM_NAME_URL_ENCODED = 'uenc'; + + const XML_PAGE_TYPE_RENDER_INHERITED = 'global/dev/page_type/render_inherited'; + + /** + * @var Mage_Core_Controller_Request_Http + */ + protected $_request; + + /** + * @var Mage_Core_Controller_Response_Http + */ + protected $_response; + + /** + * @var Magento_ObjectManager + */ + protected $_objectManager; + + /** + * Real module name (like 'Mage_Module') + * + * @var string + */ + protected $_realModuleName; + + /** + * Action flags + * + * for example used to disable rendering default layout + * + * @var array + */ + protected $_flags = array(); + + /** + * Action list where need check enabled cookie + * + * @var array + */ + protected $_cookieCheckActions = array(); + + /** + * Currently used area + * + * @var string + */ + protected $_currentArea; + + /** + * Namespace for session. + * Should be defined for proper working session. + * + * @var string + */ + protected $_sessionNamespace; + + /** + * Whether layout is loaded + * + * @see self::loadLayout() + * @var bool + */ + protected $_isLayoutLoaded = false; + + /** + * Title parts to be rendered in the page head title + * + * @see self::_title() + * @var array + */ + protected $_titles = array(); + + /** + * Whether the default title should be removed + * + * @see self::_title() + * @var bool + */ + protected $_removeDefaultTitle = false; + + /** + * @var Mage_Core_Controller_Varien_Front + */ + protected $_frontController = null; + + /** + * @var Mage_Core_Model_Layout_Factory + */ + protected $_layoutFactory; + + /** + * Constructor + * + * @param Mage_Core_Controller_Request_Http $request + * @param Mage_Core_Controller_Response_Http $response + * @param Magento_ObjectManager $objectManager + * @param Mage_Core_Controller_Varien_Front $frontController + * @param Mage_Core_Model_Layout_Factory $layoutFactory + * @param string $areaCode + */ + public function __construct( + Mage_Core_Controller_Request_Http $request, + Mage_Core_Controller_Response_Http $response, + Magento_ObjectManager $objectManager, + Mage_Core_Controller_Varien_Front $frontController, + Mage_Core_Model_Layout_Factory $layoutFactory, + $areaCode = null + ) { + parent::__construct($request, $response, $areaCode); + + $this->_objectManager = $objectManager; + $this->_frontController = $frontController; + $this->_layoutFactory = $layoutFactory; + $this->_frontController->setAction($this); + + $this->_construct(); + } + + protected function _construct() + { + } + + /** + * Set currently used area code + * @param string $areaCode + * @return Mage_Core_Controller_Varien_Action + */ + public function setCurrentArea($areaCode) + { + Mage::getConfig()->setCurrentAreaCode($areaCode); + $this->_currentArea = $areaCode; + return $this; + } + + public function hasAction($action) + { + return method_exists($this, $this->getActionMethodName($action)); + } + + /** + * Retrieve flag value + * + * @param string $action + * @param string $flag + * @return bool + */ + public function getFlag($action, $flag = '') + { + if ('' === $action) { + $action = $this->getRequest()->getActionName(); + } + if ('' === $flag) { + return $this->_flags; + } elseif (isset($this->_flags[$action][$flag])) { + return $this->_flags[$action][$flag]; + } else { + return false; + } + } + + /** + * Setting flag value + * + * @param string $action + * @param string $flag + * @param string $value + * @return Mage_Core_Controller_Varien_Action + */ + public function setFlag($action, $flag, $value) + { + if ('' === $action) { + $action = $this->getRequest()->getActionName(); + } + $this->_flags[$action][$flag] = $value; + return $this; + } + + /** + * Retrieve current layout object + * + * @return Mage_Core_Model_Layout + */ + public function getLayout() + { + return $this->_layoutFactory->createLayout(array('area' => $this->_currentArea)); + } + + /** + * Load layout by handles(s) + * + * @param string|null|bool $handles + * @param bool $generateBlocks + * @param bool $generateXml + * @return Mage_Core_Controller_Varien_Action + */ + public function loadLayout($handles = null, $generateBlocks = true, $generateXml = true) + { + // if handles were specified in arguments load them first + if (false !== $handles && '' !== $handles) { + $this->getLayout()->getUpdate()->addHandle($handles ? $handles : 'default'); + } + + // add default layout handles for this action + $this->addActionLayoutHandles(); + + $this->loadLayoutUpdates(); + + if (!$generateXml) { + return $this; + } + $this->generateLayoutXml(); + + if (!$generateBlocks) { + return $this; + } + $this->generateLayoutBlocks(); + $this->_isLayoutLoaded = true; + + return $this; + } + + /** + * Retrieve the default layout handle name for the current action + * + * @return string + */ + public function getDefaultLayoutHandle() + { + return strtolower($this->getFullActionName()); + } + + /** + * Add layout handle by full controller action name + * + * @return Mage_Core_Controller_Varien_Action + */ + public function addActionLayoutHandles() + { + $renderInherited = (string) Mage::app()->getConfig()->getNode(self::XML_PAGE_TYPE_RENDER_INHERITED); + if (!$renderInherited || !$this->addPageLayoutHandles()) { + $this->getLayout()->getUpdate()->addHandle($this->getDefaultLayoutHandle()); + } + return $this; + } + + /** + * Add layout updates handles associated with the action page + * + * @param array $parameters page parameters + * @return bool + */ + public function addPageLayoutHandles(array $parameters = array()) + { + $handle = $this->getDefaultLayoutHandle(); + $pageHandles = array($handle); + foreach ($parameters as $key => $value) { + $pageHandles[] = $handle . '_' . $key . '_' . $value; + } + return $this->getLayout()->getUpdate()->addPageHandles(array_reverse($pageHandles)); + } + + public function loadLayoutUpdates() + { + Magento_Profiler::start('LAYOUT'); + + // dispatch event for adding handles to layout update + Mage::dispatchEvent( + 'controller_action_layout_load_before', + array('action' => $this, 'layout' => $this->getLayout()) + ); + + // load layout updates by specified handles + Magento_Profiler::start('layout_load'); + $this->getLayout()->getUpdate()->load(); + Magento_Profiler::stop('layout_load'); + + Magento_Profiler::stop('LAYOUT'); + return $this; + } + + public function generateLayoutXml() + { + Magento_Profiler::start('LAYOUT'); + + // dispatch event for adding text layouts + if (!$this->getFlag('', self::FLAG_NO_DISPATCH_BLOCK_EVENT)) { + Mage::dispatchEvent( + 'controller_action_layout_generate_xml_before', + array('action' => $this, 'layout' => $this->getLayout()) + ); + } + + // generate xml from collected text updates + Magento_Profiler::start('layout_generate_xml'); + $this->getLayout()->generateXml(); + Magento_Profiler::stop('layout_generate_xml'); + + Magento_Profiler::stop('LAYOUT'); + return $this; + } + + public function generateLayoutBlocks() + { + Magento_Profiler::start('LAYOUT'); + + // dispatch event for adding xml layout elements + if(!$this->getFlag('', self::FLAG_NO_DISPATCH_BLOCK_EVENT)) { + Mage::dispatchEvent( + 'controller_action_layout_generate_blocks_before', + array('action' => $this, 'layout' => $this->getLayout()) + ); + } + + // generate blocks from xml layout + Magento_Profiler::start('layout_generate_blocks'); + $this->getLayout()->generateElements(); + + Magento_Profiler::stop('layout_generate_blocks'); + + if (!$this->getFlag('', self::FLAG_NO_DISPATCH_BLOCK_EVENT)) { + Mage::dispatchEvent( + 'controller_action_layout_generate_blocks_after', + array('action' => $this, 'layout' => $this->getLayout()) + ); + } + + Magento_Profiler::stop('LAYOUT'); + return $this; + } + + /** + * Rendering layout + * + * @param string $output + * @return Mage_Core_Controller_Varien_Action + */ + public function renderLayout($output = '') + { + if ($this->getFlag('', 'no-renderLayout')) { + return; + } + + if ($this->_frontController->getNoRender()) { + return; + } + + Magento_Profiler::start('LAYOUT'); + + $this->_renderTitles(); + + Magento_Profiler::start('layout_render'); + + if ('' !== $output) { + $this->getLayout()->addOutputElement($output); + } + + Mage::dispatchEvent('controller_action_layout_render_before'); + Mage::dispatchEvent('controller_action_layout_render_before_' . $this->getFullActionName()); + + $this->getLayout()->setDirectOutput(false); + + $output = $this->getLayout()->getOutput(); + Mage::getSingleton('Mage_Core_Model_Translate_Inline')->processResponseBody($output); + $this->getResponse()->appendBody($output); + Magento_Profiler::stop('layout_render'); + + Magento_Profiler::stop('LAYOUT'); + return $this; + } + + public function dispatch($action) + { + $this->getRequest()->setDispatched(true); + try { + $actionMethodName = $this->getActionMethodName($action); + if (!method_exists($this, $actionMethodName)) { + $actionMethodName = 'norouteAction'; + } + + $profilerKey = 'CONTROLLER_ACTION:' . $this->getFullActionName(); + Magento_Profiler::start($profilerKey); + + Mage::getConfig()->setCurrentAreaCode($this->_currentArea); + + Magento_Profiler::start('predispatch'); + $this->preDispatch(); + Magento_Profiler::stop('predispatch'); + + if ($this->getRequest()->isDispatched()) { + /** + * preDispatch() didn't change the action, so we can continue + */ + if (!$this->getFlag('', self::FLAG_NO_DISPATCH)) { + Magento_Profiler::start('action_body'); + $this->$actionMethodName(); + Magento_Profiler::stop('action_body'); + + Magento_Profiler::start('postdispatch'); + $this->postDispatch(); + Magento_Profiler::stop('postdispatch'); + } + } + + Magento_Profiler::stop($profilerKey); + } catch (Mage_Core_Controller_Varien_Exception $e) { + // set prepared flags + foreach ($e->getResultFlags() as $flagData) { + list($action, $flag, $value) = $flagData; + $this->setFlag($action, $flag, $value); + } + // call forward, redirect or an action + list($method, $parameters) = $e->getResultCallback(); + switch ($method) { + case Mage_Core_Controller_Varien_Exception::RESULT_REDIRECT: + list($path, $arguments) = $parameters; + $this->_redirect($path, $arguments); + break; + case Mage_Core_Controller_Varien_Exception::RESULT_FORWARD: + list($action, $controller, $module, $params) = $parameters; + $this->_forward($action, $controller, $module, $params); + break; + default: + $actionMethodName = $this->getActionMethodName($method); + $this->getRequest()->setActionName($method); + $this->$actionMethodName($method); + break; + } + } + } + + /** + * Retrieve action method name + * + * @param string $action + * @return string + */ + public function getActionMethodName($action) + { + return $action . 'Action'; + } + + /** + * Start session if it is not restricted + * + * @return Mage_Core_Controller_Varien_Action + */ + protected function _startSession() + { + if (!$this->getFlag('', self::FLAG_NO_START_SESSION)) { + $checkCookie = in_array($this->getRequest()->getActionName(), $this->_cookieCheckActions) + && !$this->getRequest()->getParam('nocookie', false); + $cookies = Mage::getSingleton('Mage_Core_Model_Cookie')->get(); + /** @var $session Mage_Core_Model_Session */ + $session = Mage::getSingleton('Mage_Core_Model_Session')->start(); + + if (empty($cookies)) { + if ($session->getCookieShouldBeReceived()) { + $this->setFlag('', self::FLAG_NO_COOKIES_REDIRECT, true); + $session->unsCookieShouldBeReceived(); + $session->setSkipSessionIdFlag(true); + } elseif ($checkCookie) { + if (isset($_GET[$session->getSessionIdQueryParam()]) && Mage::app()->getUseSessionInUrl() + && $this->_sessionNamespace != Mage_Backend_Controller_ActionAbstract::SESSION_NAMESPACE + ) { + $session->setCookieShouldBeReceived(true); + } else { + $this->setFlag('', self::FLAG_NO_COOKIES_REDIRECT, true); + } + } + } + } + return $this; + } + + /** + * Initialize area and design + * + * @return Mage_Core_Controller_Varien_Action + */ + protected function _initDesign() + { + $area = Mage::app()->getArea($this->getLayout()->getArea()); + $area->load(); + $area->detectDesign($this->getRequest()); + return $this; + } + + /** + * Dispatch event before action + * + * @return null + */ + public function preDispatch() + { + if (!$this->getFlag('', self::FLAG_NO_CHECK_INSTALLATION)) { + if (!Mage::isInstalled()) { + $this->setFlag('', self::FLAG_NO_DISPATCH, true); + $this->_redirect('install'); + return; + } + } + + // Prohibit disabled store actions + if (Mage::isInstalled() && !Mage::app()->getStore()->getIsActive()) { + Mage::app()->throwStoreException(); + } + + if ($this->_rewrite()) { + return; + } + + // Start session + $this->_startSession(); + + // Load area and initialize design depend on loaded area + $this->_initDesign(); + + if ($this->getFlag('', self::FLAG_NO_COOKIES_REDIRECT) + && Mage::getStoreConfig('web/browser_capabilities/cookies') + ) { + $this->_forward('noCookies', 'index', 'core'); + return; + } + + if ($this->getFlag('', self::FLAG_NO_PRE_DISPATCH)) { + return; + } + + $this->_firePreDispatchEvents(); + } + + /** + * Fire predispatch events, execute extra logic after predispatch + */ + protected function _firePreDispatchEvents() + { + Mage::dispatchEvent('controller_action_predispatch', array('controller_action' => $this)); + Mage::dispatchEvent('controller_action_predispatch_' . $this->getRequest()->getRouteName(), + array('controller_action' => $this)); + Mage::dispatchEvent('controller_action_predispatch_' . $this->getFullActionName(), + array('controller_action' => $this)); + } + + /** + * Dispatches event after action + */ + public function postDispatch() + { + if ($this->getFlag('', self::FLAG_NO_POST_DISPATCH)) { + return; + } + + Mage::dispatchEvent( + 'controller_action_postdispatch_' . $this->getFullActionName(), + array('controller_action' => $this) + ); + Mage::dispatchEvent( + 'controller_action_postdispatch_' . $this->getRequest()->getRouteName(), + array('controller_action' => $this) + ); + Mage::dispatchEvent('controller_action_postdispatch', array('controller_action' => $this)); + } + + public function norouteAction($coreRoute = null) + { + $status = $this->getRequest()->getParam('__status__'); + if (!$status instanceof Varien_Object) { + $status = new Varien_Object(); + } + + Mage::dispatchEvent('controller_action_noroute', array('action' => $this, 'status' => $status)); + + if ($status->getLoaded() !== true + || $status->getForwarded() === true + || !is_null($coreRoute) + ) { + $this->loadLayout(array('default', 'noRoute')); + $this->renderLayout(); + } else { + $status->setForwarded(true); + $this->_forward( + $status->getForwardAction(), + $status->getForwardController(), + $status->getForwardModule(), + array('__status__' => $status)); + } + } + + public function noCookiesAction() + { + $redirect = new Varien_Object(); + Mage::dispatchEvent('controller_action_nocookies', array( + 'action' => $this, + 'redirect' => $redirect + )); + + if ($url = $redirect->getRedirectUrl()) { + $this->_redirectUrl($url); + } elseif ($redirect->getRedirect()) { + $this->_redirect($redirect->getPath(), $redirect->getArguments()); + } else { + $this->loadLayout(array('default', 'noCookie')); + $this->renderLayout(); + } + + $this->getRequest()->setDispatched(true); + } + + /** + * Throw control to different action (control and module if was specified). + * + * @param string $action + * @param string|null $controller + * @param string|null $module + * @param array|null $params + */ + protected function _forward($action, $controller = null, $module = null, array $params = null) + { + $request = $this->getRequest(); + + $request->initForward(); + + if (isset($params)) { + $request->setParams($params); + } + + if (isset($controller)) { + $request->setControllerName($controller); + + // Module should only be reset if controller has been specified + if (isset($module)) { + $request->setModuleName($module); + } + } + + $request->setActionName($action) + ->setDispatched(false); + } + + /** + * Initializing layout messages by message storage(s), loading and adding messages to layout messages block + * + * @param string|array $messagesStorage + * @return Mage_Core_Controller_Varien_Action + */ + protected function _initLayoutMessages($messagesStorage) + { + if (!is_array($messagesStorage)) { + $messagesStorage = array($messagesStorage); + } + foreach ($messagesStorage as $storageName) { + $storage = Mage::getSingleton($storageName); + if ($storage) { + $block = $this->getLayout()->getMessagesBlock(); + $block->addMessages($storage->getMessages(true)); + $block->setEscapeMessageFlag($storage->getEscapeMessages(true)); + $block->addStorageType($storageName); + } else { + Mage::throwException( + Mage::helper('Mage_Core_Helper_Data')->__('Invalid messages storage "%s" for layout messages initialization', (string)$storageName) + ); + } + } + return $this; + } + + /** + * Initializing layout messages by message storage(s), loading and adding messages to layout messages block + * + * @param string|array $messagesStorage + * @return Mage_Core_Controller_Varien_Action + */ + public function initLayoutMessages($messagesStorage) + { + return $this->_initLayoutMessages($messagesStorage); + } + + /** + * Set redirect url into response + * + * @param string $url + * @return Mage_Core_Controller_Varien_Action + */ + protected function _redirectUrl($url) + { + $this->getResponse()->setRedirect($url); + return $this; + } + + /** + * Set redirect into response + * + * @param string $path + * @param array $arguments + * @return Mage_Core_Controller_Varien_Action + */ + protected function _redirect($path, $arguments = array()) + { + return $this->setRedirectWithCookieCheck($path, $arguments); + } + + /** + * Set redirect into response with session id in URL if it is enabled. + * It allows to distinguish primordial request from browser with cookies disabled. + * + * @param string $path + * @param array $arguments + * @return Mage_Core_Controller_Varien_Action + */ + public function setRedirectWithCookieCheck($path, array $arguments = array()) + { + /** @var $session Mage_Core_Model_Session */ + $session = Mage::getSingleton('Mage_Core_Model_Session'); + if ($session->getCookieShouldBeReceived() && Mage::app()->getUseSessionInUrl() + && $this->_sessionNamespace != Mage_Backend_Controller_ActionAbstract::SESSION_NAMESPACE + ) { + $arguments += array('_query' => array( + $session->getSessionIdQueryParam() => $session->getSessionId() + )); + } + $this->getResponse()->setRedirect(Mage::getUrl($path, $arguments)); + return $this; + } + + + /** + * Redirect to success page + * + * @param string $defaultUrl + * @return Mage_Core_Controller_Varien_Action + */ + protected function _redirectSuccess($defaultUrl) + { + $successUrl = $this->getRequest()->getParam(self::PARAM_NAME_SUCCESS_URL); + if (empty($successUrl)) { + $successUrl = $defaultUrl; + } + if (!$this->_isUrlInternal($successUrl)) { + $successUrl = Mage::app()->getStore()->getBaseUrl(); + } + $this->getResponse()->setRedirect($successUrl); + return $this; + } + + /** + * Redirect to error page + * + * @param string $defaultUrl + * @return Mage_Core_Controller_Varien_Action + */ + protected function _redirectError($defaultUrl) + { + $errorUrl = $this->getRequest()->getParam(self::PARAM_NAME_ERROR_URL); + if (empty($errorUrl)) { + $errorUrl = $defaultUrl; + } + if (!$this->_isUrlInternal($errorUrl)) { + $errorUrl = Mage::app()->getStore()->getBaseUrl(); + } + $this->getResponse()->setRedirect($errorUrl); + return $this; + } + + /** + * Set referer url for redirect in response + * + * @param string $defaultUrl + * @return Mage_Core_Controller_Varien_Action + */ + protected function _redirectReferer($defaultUrl=null) + { + + $refererUrl = $this->_getRefererUrl(); + if (empty($refererUrl)) { + $refererUrl = empty($defaultUrl) ? Mage::getBaseUrl() : $defaultUrl; + } + + $this->getResponse()->setRedirect($refererUrl); + return $this; + } + + /** + * Identify referer url via all accepted methods (HTTP_REFERER, regular or base64-encoded request param) + * + * @return string + */ + protected function _getRefererUrl() + { + $refererUrl = $this->getRequest()->getServer('HTTP_REFERER'); + $url = $this->getRequest()->getParam(self::PARAM_NAME_REFERER_URL); + if ($url) { + $refererUrl = $url; + } + $url = $this->getRequest()->getParam(self::PARAM_NAME_BASE64_URL); + if ($url) { + $refererUrl = Mage::helper('Mage_Core_Helper_Data')->urlDecode($url); + } + $url = $this->getRequest()->getParam(self::PARAM_NAME_URL_ENCODED); + if ($url) { + $refererUrl = Mage::helper('Mage_Core_Helper_Data')->urlDecode($url); + } + + if (!$this->_isUrlInternal($refererUrl)) { + $refererUrl = Mage::app()->getStore()->getBaseUrl(); + } + return $refererUrl; + } + + /** + * Check url to be used as internal + * + * @param string $url + * @return bool + */ + protected function _isUrlInternal($url) + { + if (strpos($url, 'http') !== false) { + /** + * Url must start from base secure or base unsecure url + */ + if ((strpos($url, Mage::app()->getStore()->getBaseUrl()) === 0) + || (strpos($url, Mage::app()->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true)) === 0) + ) { + return true; + } + } + return false; + } + + /** + * Get real module name (like 'Mage_Module') + * + * @return string + */ + protected function _getRealModuleName() + { + if (empty($this->_realModuleName)) { + $class = get_class($this); + $this->_realModuleName = substr( + $class, + 0, + strpos(strtolower($class), '_' . strtolower($this->getRequest()->getControllerName() . 'Controller')) + ); + } + return $this->_realModuleName; + } + + /** + * Support for controllers rewrites + * + * Example of configuration: + * + * + * + * + * + * new_route/new_controller + * true + * + * new_module/new_controller/new_action + * + * + * + * + * + * + * + * This will override: + * 1. core_module/core_controller/core_action to new_module/new_controller/new_action + * 2. all other actions of core_module/core_controller to new_module/new_controller + * + * @return boolean true if rewrite happened + */ + protected function _rewrite() + { + $route = $this->getRequest()->getRouteName(); + $controller = $this->getRequest()->getControllerName(); + $action = $this->getRequest()->getActionName(); + + $rewrite = Mage::getConfig()->getNode('global/routers/' . $route . '/rewrite/' . $controller); + if (!$rewrite) { + return false; + } + + if (!($rewrite->actions && $rewrite->actions->$action) || $rewrite->is('override_actions')) { + $t = explode('/', (string)$rewrite->to); + if (sizeof($t) !== 2 || empty($t[0]) || empty($t[1])) { + return false; + } + $t[2] = $action; + } else { + $t = explode('/', (string)$rewrite->actions->$action->to); + if (sizeof($t) !== 3 || empty($t[0]) || empty($t[1]) || empty($t[2])) { + return false; + } + } + + $this->_forward( + $t[2] === '*' ? $action : $t[2], + $t[1] === '*' ? $controller : $t[1], + $t[0] === '*' ? $route : $t[0] + ); + + return true; + } + + /** + * Validate Form Key + * + * @return bool + */ + protected function _validateFormKey() + { + if (!($formKey = $this->getRequest()->getParam('form_key', null)) + || $formKey != Mage::getSingleton('Mage_Core_Model_Session')->getFormKey() + ) { + return false; + } + return true; + } + + /** + * Add an extra title to the end or one from the end, or remove all + * + * Usage examples: + * $this->_title('foo')->_title('bar'); + * => bar / foo / + * + * $this->_title()->_title('foo')->_title('bar'); + * => bar / foo + * + * $this->_title('foo')->_title(false)->_title('bar'); + * bar / + * + * @see self::_renderTitles() + * @param string|false|-1|null $text + * @param bool $resetIfExists + * @return Mage_Core_Controller_Varien_Action + */ + protected function _title($text = null, $resetIfExists = true) + { + if (is_string($text)) { + $this->_titles[] = $text; + } elseif (-1 === $text) { + if (empty($this->_titles)) { + $this->_removeDefaultTitle = true; + } else { + array_pop($this->_titles); + } + } elseif (empty($this->_titles) || $resetIfExists) { + if (false === $text) { + $this->_removeDefaultTitle = false; + $this->_titles = array(); + } elseif (null === $text) { + $this->_removeDefaultTitle = true; + $this->_titles = array(); + } + } + return $this; + } + + /** + * Prepare titles in the 'head' layout block + * Supposed to work only in actions where layout is rendered + * Falls back to the default logic if there are no titles eventually + * + * @see self::loadLayout() + * @see self::renderLayout() + */ + protected function _renderTitles() + { + if ($this->_isLayoutLoaded && $this->_titles) { + $titleBlock = $this->getLayout()->getBlock('head'); + if ($titleBlock) { + if (!$this->_removeDefaultTitle) { + $title = trim($titleBlock->getTitle()); + if ($title) { + array_unshift($this->_titles, $title); + } + } + $titleBlock->setTitle(array_reverse($this->_titles)); + } + } + } + + /** + * Convert dates in array from localized to internal format + * + * @param array $array + * @param array $dateFields + * @return array + */ + protected function _filterDates($array, $dateFields) + { + if (empty($dateFields)) { + return $array; + } + $filterInput = new Zend_Filter_LocalizedToNormalized(array( + 'date_format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) + )); + $filterInternal = new Zend_Filter_NormalizedToLocalized(array( + 'date_format' => Varien_Date::DATE_INTERNAL_FORMAT + )); + + foreach ($dateFields as $dateField) { + if (array_key_exists($dateField, $array) && !empty($dateField)) { + $array[$dateField] = $filterInput->filter($array[$dateField]); + $array[$dateField] = $filterInternal->filter($array[$dateField]); + } + } + return $array; + } + + /** + * Convert dates with time in array from localized to internal format + * + * @param array $array + * @param array $dateFields + * @return array + */ + protected function _filterDateTime($array, $dateFields) + { + if (empty($dateFields)) { + return $array; + } + $filterInput = new Zend_Filter_LocalizedToNormalized(array( + 'date_format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) + )); + $filterInternal = new Zend_Filter_NormalizedToLocalized(array( + 'date_format' => Varien_Date::DATETIME_INTERNAL_FORMAT + )); + + foreach ($dateFields as $dateField) { + if (array_key_exists($dateField, $array) && !empty($dateField)) { + $array[$dateField] = $filterInput->filter($array[$dateField]); + $array[$dateField] = $filterInternal->filter($array[$dateField]); + } + } + return $array; + } + + /** + * Declare headers and content file in response for file download + * + * @param string $fileName + * @param string|array $content set to null to avoid starting output, $contentLength should be set explicitly in + * that case + * @param string $contentType + * @param int $contentLength explicit content length, if strlen($content) isn't applicable + * @return Mage_Core_Controller_Varien_Action + */ + protected function _prepareDownloadResponse( + $fileName, + $content, + $contentType = 'application/octet-stream', + $contentLength = null) + { + /** @var Magento_Filesystem $filesystem */ + $filesystem = $this->_objectManager->create('Magento_Filesystem'); + $isFile = false; + $file = null; + if (is_array($content)) { + if (!isset($content['type']) || !isset($content['value'])) { + return $this; + } + if ($content['type'] == 'filename') { + $isFile = true; + $file = $content['value']; + $contentLength = $filesystem->getFileSize($file); + } + } + + $this->getResponse() + ->setHttpResponseCode(200) + ->setHeader('Pragma', 'public', true) + ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true) + ->setHeader('Content-type', $contentType, true) + ->setHeader('Content-Length', is_null($contentLength) ? strlen($content) : $contentLength, true) + ->setHeader('Content-Disposition', 'attachment; filename="'.$fileName.'"', true) + ->setHeader('Last-Modified', date('r'), true); + + if (!is_null($content)) { + if ($isFile) { + $this->getResponse()->clearBody(); + $this->getResponse()->sendHeaders(); + + if (!$filesystem->isFile($file)) { + Mage::throwException(Mage::helper('Mage_Core_Helper_Data')->__('File not found')); + } + $stream = $filesystem->createAndOpenStream($file, 'r'); + while ($buffer = $stream->read(1024)) { + print $buffer; + } + flush(); + $stream->close(); + if (!empty($content['rm'])) { + $filesystem->delete($file); + } + + exit(0); + } else { + $this->getResponse()->setBody($content); + } + } + return $this; + } +} diff --git a/app/code/core/Mage/Core/Controller/Varien/Action/Factory.php b/app/code/Mage/Core/Controller/Varien/Action/Factory.php similarity index 100% rename from app/code/core/Mage/Core/Controller/Varien/Action/Factory.php rename to app/code/Mage/Core/Controller/Varien/Action/Factory.php diff --git a/app/code/core/Mage/Core/Controller/Varien/Action/Forward.php b/app/code/Mage/Core/Controller/Varien/Action/Forward.php similarity index 100% rename from app/code/core/Mage/Core/Controller/Varien/Action/Forward.php rename to app/code/Mage/Core/Controller/Varien/Action/Forward.php diff --git a/app/code/core/Mage/Core/Controller/Varien/Action/Redirect.php b/app/code/Mage/Core/Controller/Varien/Action/Redirect.php similarity index 100% rename from app/code/core/Mage/Core/Controller/Varien/Action/Redirect.php rename to app/code/Mage/Core/Controller/Varien/Action/Redirect.php diff --git a/app/code/core/Mage/Core/Controller/Varien/ActionAbstract.php b/app/code/Mage/Core/Controller/Varien/ActionAbstract.php similarity index 100% rename from app/code/core/Mage/Core/Controller/Varien/ActionAbstract.php rename to app/code/Mage/Core/Controller/Varien/ActionAbstract.php diff --git a/app/code/core/Mage/Core/Controller/Varien/DispatchableInterface.php b/app/code/Mage/Core/Controller/Varien/DispatchableInterface.php similarity index 100% rename from app/code/core/Mage/Core/Controller/Varien/DispatchableInterface.php rename to app/code/Mage/Core/Controller/Varien/DispatchableInterface.php diff --git a/app/code/core/Mage/Core/Controller/Varien/Exception.php b/app/code/Mage/Core/Controller/Varien/Exception.php similarity index 100% rename from app/code/core/Mage/Core/Controller/Varien/Exception.php rename to app/code/Mage/Core/Controller/Varien/Exception.php diff --git a/app/code/core/Mage/Core/Controller/Varien/Front.php b/app/code/Mage/Core/Controller/Varien/Front.php similarity index 98% rename from app/code/core/Mage/Core/Controller/Varien/Front.php rename to app/code/Mage/Core/Controller/Varien/Front.php index 5bb5e60a820d9..6b8ae1c49b2ec 100644 --- a/app/code/core/Mage/Core/Controller/Varien/Front.php +++ b/app/code/Mage/Core/Controller/Varien/Front.php @@ -215,12 +215,12 @@ public function dispatch() Mage::throwException('Front controller reached 100 router match iterations'); } // This event gives possibility to launch something before sending output (allow cookie setting) - Mage::dispatchEvent('controller_front_send_response_before', array('front'=>$this)); + Mage::dispatchEvent('controller_front_send_response_before', array('front' => $this)); Magento_Profiler::start('send_response'); - Mage::dispatchEvent('http_response_send_before', array('response'=>$this)); + Mage::dispatchEvent('http_response_send_before', array('response' => $this)); $this->getResponse()->sendResponse(); Magento_Profiler::stop('send_response'); - Mage::dispatchEvent('controller_front_send_response_after', array('front'=>$this)); + Mage::dispatchEvent('controller_front_send_response_after', array('front' => $this)); return $this; } @@ -235,7 +235,7 @@ public function applyRewrites(Mage_Core_Controller_Request_Http $request) if (!$request->isStraight()) { Magento_Profiler::start('db_url_rewrite'); /** @var $urlRewrite Mage_Core_Model_Url_Rewrite */ - $urlRewrite = $this->_rewriteFactory->createFromArray(); + $urlRewrite = $this->_rewriteFactory->create(); $urlRewrite->rewrite($request); Magento_Profiler::stop('db_url_rewrite'); } diff --git a/app/code/core/Mage/Core/Controller/Varien/Router/Abstract.php b/app/code/Mage/Core/Controller/Varien/Router/Abstract.php similarity index 100% rename from app/code/core/Mage/Core/Controller/Varien/Router/Abstract.php rename to app/code/Mage/Core/Controller/Varien/Router/Abstract.php diff --git a/app/code/Mage/Core/Controller/Varien/Router/Base.php b/app/code/Mage/Core/Controller/Varien/Router/Base.php new file mode 100644 index 0000000000000..d1ada24fe4a2c --- /dev/null +++ b/app/code/Mage/Core/Controller/Varien/Router/Base.php @@ -0,0 +1,665 @@ +_app = $app; + $this->_filesystem = $filesystem; + $this->_areaCode = $areaCode; + $this->_baseController = $baseController; + + if (is_null($this->_areaCode) || is_null($this->_baseController)) { + throw new InvalidArgumentException("Not enough options to initialize router."); + } + } + + public function collectRoutes($configArea, $useRouterName) + { + $routers = array(); + $routersConfigNode = Mage::getConfig()->getNode($configArea . '/routers'); + if ($routersConfigNode) { + $routers = $routersConfigNode->children(); + } + foreach ($routers as $routerName => $routerConfig) { + $use = (string)$routerConfig->use; + if ($use == $useRouterName) { + $modules = array((string)$routerConfig->args->module); + if ($routerConfig->args->modules) { + foreach ($routerConfig->args->modules->children() as $customModule) { + if ((string)$customModule) { + if ($before = $customModule->getAttribute('before')) { + $position = array_search($before, $modules); + if ($position === false) { + $position = 0; + } + array_splice($modules, $position, 0, (string)$customModule); + } elseif ($after = $customModule->getAttribute('after')) { + $position = array_search($after, $modules); + if ($position === false) { + $position = count($modules); + } + array_splice($modules, $position+1, 0, (string)$customModule); + } else { + $modules[] = (string)$customModule; + } + } + } + } + + $frontName = (string)$routerConfig->args->frontName; + $this->addModule($frontName, $modules, $routerName); + } + } + } + + public function fetchDefault() + { + $this->getFront()->setDefault(array( + 'module' => 'core', + 'controller' => 'index', + 'action' => 'index' + )); + } + + /** + * checking if this admin if yes then we don't use this router + * + * @return bool + */ + protected function _beforeModuleMatch() + { + if (Mage::app()->getStore()->isAdmin()) { + return false; + } + return true; + } + + /** + * dummy call to pass through checking + * + * @return bool + */ + protected function _afterModuleMatch() + { + return true; + } + + /** + * Match provided request and if matched - return corresponding controller + * + * @param Mage_Core_Controller_Request_Http $request + * @return Mage_Core_Controller_Front_Action|null + */ + public function match(Mage_Core_Controller_Request_Http $request) + { + //checking before even try to find out that current module + //should use this router + if (!$this->_beforeModuleMatch()) { + return null; + } + + $params = $this->_parseRequest($request); + + if (false == $this->_canProcess($params)) { + return null; + } + + $this->_app->loadAreaPart($this->_areaCode, Mage_Core_Model_App_Area::PART_CONFIG); + + return $this->_matchController($request, $params); + } + + /** + * Check if router can process provided request + * + * @param array $params + * @return bool + */ + protected function _canProcess(array $params) + { + return true; + } + + /** + * Parse request URL params + * + * @param Mage_Core_Controller_Request_Http $request + * @return array + */ + protected function _parseRequest(Mage_Core_Controller_Request_Http $request) + { + $output = array(); + + $path = trim($request->getPathInfo(), '/'); + + $params = explode('/', ($path ? $path : $this->_getDefaultPath())); + foreach ($this->_requiredParams as $paramName) { + $output[$paramName] = array_shift($params); + } + + for ($i = 0, $l = sizeof($params); $i < $l; $i += 2) { + $output['variables'][$params[$i]] = isset($params[$i+1]) ? urldecode($params[$i + 1]) : ''; + } + return $output; + } + + /** + * Match module front name + * + * @param Mage_Core_Controller_Request_Http $request + * @param string $param + * @return string|null + */ + protected function _matchModuleFrontName(Mage_Core_Controller_Request_Http $request, $param) + { + // get module name + if ($request->getModuleName()) { + $moduleFrontName = $request->getModuleName(); + } else { + if (!empty($param)) { + $moduleFrontName = $param; + } else { + $moduleFrontName = $this->getFront()->getDefault('module'); + $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, ''); + } + } + if (!$moduleFrontName) { + return null; + } + return $moduleFrontName; + } + + /** + * Match controller name + * + * @param Mage_Core_Controller_Request_Http $request + * @param string $param + * @return string + */ + protected function _matchControllerName(Mage_Core_Controller_Request_Http $request, $param) + { + if ($request->getControllerName()) { + $controller = $request->getControllerName(); + } else { + if (!empty($param)) { + $controller = $param; + } else { + $controller = $this->getFront()->getDefault('controller'); + $request->setAlias( + Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, + ltrim($request->getOriginalPathInfo(), '/') + ); + } + } + return $controller; + } + + /** + * Match controller name + * + * @param Mage_Core_Controller_Request_Http $request + * @param string $param + * @return string + */ + protected function _matchActionName(Mage_Core_Controller_Request_Http $request, $param) + { + if (empty($action)) { + if ($request->getActionName()) { + $action = $request->getActionName(); + } else { + $action = !empty($param) ? $param : $this->getFront()->getDefault('action'); + } + } else { + $action = $param; + } + + return $action; + } + + /** + * Get not found controller instance + * + * @param $currentModuleName + * @param Mage_Core_Controller_Request_Http $request + * @return Mage_Core_Controller_Varien_Action|null + */ + protected function _getNotFoundControllerInstance($currentModuleName, Mage_Core_Controller_Request_Http $request) + { + $controllerInstance = null; + + if ($this->_noRouteShouldBeApplied()) { + $controller = 'index'; + $action = 'noroute'; + + $controllerClassName = $this->_validateControllerClassName($currentModuleName, $controller); + if (false == $controllerClassName) { + return null; + } + + if (false == $this->_validateControllerAction($controllerClassName, $action)) { + return null; + } + + // instantiate controller class + $controllerInstance = $this->_controllerFactory->createController($controllerClassName, + array('request' => $request, 'areaCode' => $this->_areaCode) + ); + } else { + return null; + } + + return $controllerInstance; + } + + /** + * Check whether action handler exists for provided handler + * + * @param string $controllerClassName + * @param string $action + * @return bool + */ + protected function _validateControllerAction($controllerClassName, $action) + { + return method_exists($controllerClassName, $action . 'Action'); + } + + /** + * Create matched controller instance + * + * @param Mage_Core_Controller_Request_Http $request + * @param array $params + * @return Mage_Core_Controller_Front_Action|null + */ + protected function _matchController(Mage_Core_Controller_Request_Http $request, array $params) + { + $this->fetchDefault(); + + $moduleFrontName = $this->_matchModuleFrontName($request, $params['moduleFrontName']); + if (empty($moduleFrontName)) { + return null; + } + + /** + * Searching router args by module name from route using it as key + */ + $modules = $this->getModulesByFrontName($moduleFrontName); + + if (empty($modules) === true) { + return null; + } + + // checks after we found out that this router should be used for current module + if (!$this->_afterModuleMatch()) { + return null; + } + + /** + * Going through modules to find appropriate controller + */ + $found = false; + $currentModuleName = null; + $controller = null; + $action = null; + $controllerInstance = null; + + foreach ($modules as $moduleName) { + $currentModuleName = $moduleName; + + $request->setRouteName($this->getRouteByFrontName($moduleFrontName)); + + $controller = $this->_matchControllerName($request, $params['controllerName']); + + $action = $this->_matchActionName($request, $params['actionName']); + + //checking if this place should be secure + $this->_checkShouldBeSecure($request, '/' . $moduleFrontName . '/' . $controller . '/' . $action); + + $controllerClassName = $this->_validateControllerClassName($moduleName, $controller); + if (false == $controllerClassName) { + continue; + } + + if (false === $this->_validateControllerAction($controllerClassName, $action)) { + continue; + } + + Mage::getConfig()->setCurrentAreaCode($this->_areaCode); + // instantiate controller class + $controllerInstance = $this->_controllerFactory->createController($controllerClassName, + array('request' => $request, 'areaCode' => $this->_areaCode) + ); + + $found = true; + break; + } + + /** + * if we did not found any suitable + */ + if (false == $found) { + $controllerInstance = $this->_getNotFoundControllerInstance($currentModuleName, $request); + if (is_null($controllerInstance)) { + return null; + } + } + + // set values only after all the checks are done + $request->setModuleName($moduleFrontName); + $request->setControllerName($controller); + $request->setActionName($action); + $request->setControllerModule($currentModuleName); + if (isset($params['variables'])) { + $request->setParams($params['variables']); + } + return $controllerInstance; + } + + /** + * Get router default request path + * @return string + */ + protected function _getDefaultPath() + { + return Mage::getStoreConfig('web/default/front'); + } + + /** + * Allow to control if we need to enable no route functionality in current router + * + * @return bool + */ + protected function _noRouteShouldBeApplied() + { + return false; + } + + /** + * Generating and validating class file name, + * class and if everything ok do include if needed and return of class name + * + * @param $realModule + * @param $controller + * @return bool|string + */ + protected function _validateControllerClassName($realModule, $controller) + { + $controllerFileName = $this->getControllerFileName($realModule, $controller); + if (!$this->validateControllerFileName($controllerFileName)) { + return false; + } + + $controllerClassName = $this->getControllerClassName($realModule, $controller); + if (!$controllerClassName) { + return false; + } + + // include controller file if needed + if (!$this->_includeControllerClass($controllerFileName, $controllerClassName)) { + return false; + } + + return $controllerClassName; + } + + /** + * Include the file containing controller class if this class is not defined yet + * + * @param $controllerFileName + * @param $controllerClassName + * @return bool + * @throws Mage_Core_Exception + */ + protected function _includeControllerClass($controllerFileName, $controllerClassName) + { + if (!class_exists($controllerClassName, false)) { + if (!$this->_filesystem->isFile($controllerFileName)) { + return false; + } + include $controllerFileName; + + if (!class_exists($controllerClassName, false)) { + throw Mage::exception('Mage_Core', + Mage::helper('Mage_Core_Helper_Data')->__('Controller file was loaded but class does not exist') + ); + } + } + return true; + } + + public function addModule($frontName, $moduleName, $routeName) + { + $this->_modules[$frontName] = $moduleName; + $this->_routes[$routeName] = $frontName; + return $this; + } + + /** + * Retrieve list of modules subscribed to given frontName + * + * @param string $frontName + * @return array + */ + public function getModulesByFrontName($frontName) + { + $modules = array(); + if (isset($this->_modules[$frontName])) { + if (false === is_array($this->_modules[$frontName])) { + $modules = array($this->_modules[$frontName]); + } else { + $modules = $this->_modules[$frontName]; + } + } + return $modules; + } + + public function getModuleByName($moduleName, $modules) + { + foreach ($modules as $module) { + if ($moduleName === $module || (is_array($module) + && $this->getModuleByName($moduleName, $module))) { + return true; + } + } + return false; + } + + public function getFrontNameByRoute($routeName) + { + if (isset($this->_routes[$routeName])) { + return $this->_routes[$routeName]; + } + return false; + } + + public function getRouteByFrontName($frontName) + { + return array_search($frontName, $this->_routes); + } + + public function getControllerFileName($realModule, $controller) + { + $parts = explode('_', $realModule); + $realModule = implode('_', array_splice($parts, 0, 2)); + $file = Mage::getModuleDir('controllers', $realModule); + if (count($parts)) { + $file .= DS . implode(DS, $parts); + } + $file .= DS . uc_words($controller, DS) . 'Controller.php'; + return $file; + } + + public function validateControllerFileName($fileName) + { + if ($fileName + && $this->_filesystem->isFile($fileName) + && $this->_filesystem->isReadable($fileName) + && false === strpos($fileName, '//') + ) { + return true; + } + return false; + } + + public function getControllerClassName($realModule, $controller) + { + $class = $realModule . '_' . uc_words($controller) . 'Controller'; + return $class; + } + + public function rewrite(array $p) + { + $rewrite = Mage::getConfig()->getNode('global/rewrite'); + if ($module = $rewrite->{$p[0]}) { + if (!$module->children()) { + $p[0] = trim((string)$module); + } + } + if (isset($p[1]) && ($controller = $rewrite->{$p[0]}->{$p[1]})) { + if (!$controller->children()) { + $p[1] = trim((string)$controller); + } + } + if (isset($p[2]) && ($action = $rewrite->{$p[0]}->{$p[1]}->{$p[2]})) { + if (!$action->children()) { + $p[2] = trim((string)$action); + } + } + + return $p; + } + + /** + * Check that request uses https protocol if it should. + * Function redirects user to correct URL if needed. + * + * @param Zend_Controller_Request_Http $request + * @param string $path + * @return void + */ + protected function _checkShouldBeSecure(Zend_Controller_Request_Http $request, $path = '') + { + if (!Mage::isInstalled() || $request->getPost()) { + return; + } + + if ($this->_shouldBeSecure($path) && !$request->isSecure()) { + $url = $this->_getCurrentSecureUrl($request); + if ($this->_shouldRedirectToSecure()) { + $url = Mage::getSingleton('Mage_Core_Model_Url')->getRedirectUrl($url); + } + + Mage::app()->getFrontController()->getResponse() + ->setRedirect($url) + ->sendResponse(); + exit; + } + } + + /** + * Check whether redirect url should be used for secure routes + * + * @return bool + */ + protected function _shouldRedirectToSecure() + { + return Mage::app()->getUseSessionInUrl(); + } + + protected function _getCurrentSecureUrl($request) + { + $alias = $request->getAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS); + if ($alias) { + return Mage::getBaseUrl('link', true) . ltrim($alias, '/'); + } + + return Mage::getBaseUrl('link', true) . ltrim($request->getPathInfo(), '/'); + } + + /** + * Check whether URL for corresponding path should use https protocol + * + * @param string $path + * @return bool + */ + protected function _shouldBeSecure($path) + { + return substr(Mage::getStoreConfig('web/unsecure/base_url'), 0, 5) === 'https' + || Mage::getStoreConfigFlag('web/secure/use_in_frontend') + && substr(Mage::getStoreConfig('web/secure/base_url'), 0, 5) == 'https' + && Mage::getConfig()->shouldUrlBeSecure($path); + } +} diff --git a/app/code/core/Mage/Core/Controller/Varien/Router/Default.php b/app/code/Mage/Core/Controller/Varien/Router/Default.php similarity index 100% rename from app/code/core/Mage/Core/Controller/Varien/Router/Default.php rename to app/code/Mage/Core/Controller/Varien/Router/Default.php diff --git a/app/code/Mage/Core/Controller/Varien/Router/Factory.php b/app/code/Mage/Core/Controller/Varien/Router/Factory.php new file mode 100644 index 0000000000000..7b5ce43192b94 --- /dev/null +++ b/app/code/Mage/Core/Controller/Varien/Router/Factory.php @@ -0,0 +1,62 @@ +_objectManager = $objectManager; + } + + /** + * @param string $className + * @param array $routerInfo + * @return Mage_Core_Controller_Varien_Router_Abstract + */ + public function createRouter($className, array $routerInfo = array()) + { + $arguments = array( + 'areaCode' => null, + 'baseController' => null, + ); + if (isset($routerInfo['area'])) { + $arguments['areaCode'] = $routerInfo['area']; + } + if (isset($routerInfo['base_controller'])) { + $arguments['baseController'] = $routerInfo['base_controller']; + } + + return $this->_objectManager->create($className, $arguments); + } +} diff --git a/app/code/core/Mage/Core/Exception.php b/app/code/Mage/Core/Exception.php similarity index 100% rename from app/code/core/Mage/Core/Exception.php rename to app/code/Mage/Core/Exception.php diff --git a/app/code/Mage/Core/Helper/Abstract.php b/app/code/Mage/Core/Helper/Abstract.php new file mode 100644 index 0000000000000..f95a60a5493ba --- /dev/null +++ b/app/code/Mage/Core/Helper/Abstract.php @@ -0,0 +1,387 @@ +_translator = $context->getTranslator(); + } + + /** + * Retrieve request object + * + * @return Zend_Controller_Request_Http + * @return Zend_Controller_Request_Http + */ + protected function _getRequest() + { + if (!$this->_request) { + $this->_request = Mage::getObjectManager()->get('Mage_Core_Controller_Request_Http'); + } + return $this->_request; + } + + /** + * Loading cache data + * + * @param string $cacheId + * @return mixed + */ + protected function _loadCache($cacheId) + { + return Mage::app()->loadCache($cacheId); + } + + /** + * Saving cache + * + * @param mixed $data + * @param string $cacheId + * @param array $tags + * @param bool $lifeTime + * @return Mage_Core_Helper_Abstract + */ + protected function _saveCache($data, $cacheId, $tags = array(), $lifeTime = false) + { + Mage::app()->saveCache($data, $cacheId, $tags, $lifeTime); + return $this; + } + + /** + * Removing cache + * + * @param string $cacheId + * @return Mage_Core_Helper_Abstract + */ + protected function _removeCache($cacheId) + { + Mage::app()->removeCache($cacheId); + return $this; + } + + /** + * Cleaning cache + * + * @param array $tags + * @return Mage_Core_Helper_Abstract + */ + protected function _cleanCache($tags=array()) + { + Mage::app()->cleanCache($tags); + return $this; + } + + /** + * Retrieve helper module name + * + * @return string + */ + protected function _getModuleName() + { + if (!$this->_moduleName) { + $class = get_class($this); + $this->_moduleName = substr($class, 0, strpos($class, '_Helper')); + } + return $this->_moduleName; + } + + /** + * Check whether or not the module output is enabled in Configuration + * + * @param string $moduleName Full module name + * @return boolean + */ + public function isModuleOutputEnabled($moduleName = null) + { + if ($moduleName === null) { + $moduleName = $this->_getModuleName(); + } + + if (!$this->isModuleEnabled($moduleName)) { + return false; + } + + if (Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $moduleName)) { + return false; + } + return true; + } + + /** + * Check is module exists and enabled in global config. + * + * @param string $moduleName the full module name, example Mage_Core + * @return boolean + */ + public function isModuleEnabled($moduleName = null) + { + if ($moduleName === null) { + $moduleName = $this->_getModuleName(); + } + + if (!Mage::getConfig()->getNode('modules/' . $moduleName)) { + return false; + } + + $isActive = Mage::getConfig()->getNode('modules/' . $moduleName . '/active'); + if (!$isActive || !in_array((string)$isActive, array('true', '1'))) { + return false; + } + return true; + } + + /** + * Translate + * + * @SuppressWarnings(PHPMD.ShortMethodName) + * @return string + */ + public function __() + { + $args = func_get_args(); + $expr = new Mage_Core_Model_Translate_Expr(array_shift($args), $this->_getModuleName()); + array_unshift($args, $expr); + return $this->_translator->translate($args); + } + + /** + * Escape html entities + * + * @param string|array $data + * @param array $allowedTags + * @return mixed + */ + public function escapeHtml($data, $allowedTags = null) + { + if (is_array($data)) { + $result = array(); + foreach ($data as $item) { + $result[] = $this->escapeHtml($item); + } + } else { + // process single item + if (strlen($data)) { + if (is_array($allowedTags) and !empty($allowedTags)) { + $allowed = implode('|', $allowedTags); + $result = preg_replace('/<([\/\s\r\n]*)(' . $allowed . ')([\/\s\r\n]*)>/si', '##$1$2$3##', $data); + $result = htmlspecialchars($result, ENT_COMPAT, 'UTF-8', false); + $result = preg_replace('/##([\/\s\r\n]*)(' . $allowed . ')([\/\s\r\n]*)##/si', '<$1$2$3>', $result); + } else { + $result = htmlspecialchars($data, ENT_COMPAT, 'UTF-8', false); + } + } else { + $result = $data; + } + } + return $result; + } + + /** + * Remove html tags, but leave "<" and ">" signs + * + * @param string $html + * @return string + */ + public function removeTags($html) + { + $html = preg_replace("# <(?![/a-z]) | (?<=\s)>(?![a-z]) #exi", "htmlentities('$0')", $html); + $html = strip_tags($html); + return htmlspecialchars_decode($html); + } + + /** + * Wrapper for standard strip_tags() function with extra functionality for html entities + * + * @param string $data + * @param string $allowableTags + * @param bool $escape + * @return string + */ + public function stripTags($data, $allowableTags = null, $escape = false) + { + $result = strip_tags($data, $allowableTags); + return $escape ? $this->escapeHtml($result, $allowableTags) : $result; + } + + /** + * Escape html entities in url + * + * @param string $data + * @return string + */ + public function escapeUrl($data) + { + return htmlspecialchars($data); + } + + /** + * Escape quotes in java script + * + * @param mixed $data + * @param string $quote + * @return mixed + */ + public function jsQuoteEscape($data, $quote = '\'') + { + if (is_array($data)) { + $result = array(); + foreach ($data as $item) { + $result[] = str_replace($quote, '\\' . $quote, $item); + } + return $result; + } + return str_replace($quote, '\\' . $quote, $data); + } + + /** + * Escape quotes inside html attributes + * Use $addSlashes = false for escaping js that inside html attribute (onClick, onSubmit etc) + * + * @param string $data + * @param bool $addSlashes + * @return string + */ + public function quoteEscape($data, $addSlashes = false) + { + if ($addSlashes === true) { + $data = addslashes($data); + } + return htmlspecialchars($data, ENT_QUOTES, null, false); + } + + /** + * Retrieve url + * + * @param string $route + * @param array $params + * @return string + */ + protected function _getUrl($route, $params = array()) + { + return Mage::getUrl($route, $params); + } + + /** + * Declare layout + * + * @param Mage_Core_Model_Layout $layout + * @return Mage_Core_Helper_Abstract + */ + public function setLayout($layout) + { + $this->_layout = $layout; + return $this; + } + + /** + * Retrieve layout model object + * + * @return Mage_Core_Model_Layout + */ + public function getLayout() + { + return $this->_layout; + } + + /** + * base64_encode() for URLs encoding + * + * @param string $url + * @return string + */ + public function urlEncode($url) + { + return strtr(base64_encode($url), '+/=', '-_,'); + } + + /** + * base64_decode() for URLs decoding + * + * @param string $url + * @return string + */ + public function urlDecode($url) + { + $url = base64_decode(strtr($url, '-_,', '+/=')); + /** @var $urlModel Mage_Core_Model_Url */ + $urlModel = Mage::getSingleton('Mage_Core_Model_Url'); + return $urlModel->sessionUrlVar($url); + } + + /** + * Translate array + * + * @param array $arr + * @return array + */ + public function translateArray($arr = array()) + { + foreach ($arr as $k => $v) { + if (is_array($v)) { + $v = self::translateArray($v); + } elseif ($k === 'label') { + $v = self::__($v); + } + $arr[$k] = $v; + } + return $arr; + } +} diff --git a/app/code/Mage/Core/Helper/Context.php b/app/code/Mage/Core/Helper/Context.php new file mode 100644 index 0000000000000..87b48461a547a --- /dev/null +++ b/app/code/Mage/Core/Helper/Context.php @@ -0,0 +1,48 @@ +_translator = $translator; + } + + /** + * @return \Mage_Core_Model_Translate + */ + public function getTranslator() + { + return $this->_translator; + } +} diff --git a/app/code/core/Mage/Core/Helper/Cookie.php b/app/code/Mage/Core/Helper/Cookie.php similarity index 95% rename from app/code/core/Mage/Core/Helper/Cookie.php rename to app/code/Mage/Core/Helper/Cookie.php index 52628789c0866..4645831260004 100644 --- a/app/code/core/Mage/Core/Helper/Cookie.php +++ b/app/code/Mage/Core/Helper/Cookie.php @@ -64,13 +64,13 @@ class Mage_Core_Helper_Cookie extends Mage_Core_Helper_Abstract protected $_website; /** - * @param Mage_Core_Model_Translate $translator + * @param Mage_Core_Helper_Context $context * @param array $data * @throws InvalidArgumentException */ - public function __construct(Mage_Core_Model_Translate $translator, array $data = array()) + public function __construct(Mage_Core_Helper_Context $context, array $data = array()) { - parent::__construct($translator); + parent::__construct($context); $this->_currentStore = isset($data['current_store']) ? $data['current_store'] : Mage::app()->getStore(); if (!($this->_currentStore instanceof Mage_Core_Model_Store)) { diff --git a/app/code/Mage/Core/Helper/Data.php b/app/code/Mage/Core/Helper/Data.php new file mode 100644 index 0000000000000..e56b8cbcc99b8 --- /dev/null +++ b/app/code/Mage/Core/Helper/Data.php @@ -0,0 +1,835 @@ + + */ +class Mage_Core_Helper_Data extends Mage_Core_Helper_Abstract +{ + const XML_PATH_DEFAULT_COUNTRY = 'general/country/default'; + const XML_PATH_PROTECTED_FILE_EXTENSIONS = 'general/file/protected_extensions'; + const XML_PATH_PUBLIC_FILES_VALID_PATHS = 'general/file/public_files_valid_paths'; + const XML_PATH_ENCRYPTION_MODEL = 'global/helpers/core/encryption_model'; + const XML_PATH_DEV_ALLOW_IPS = 'dev/restrict/allow_ips'; + const XML_PATH_CONNECTION_TYPE = 'global/resources/default_setup/connection/type'; + const XML_PATH_IMAGE_ADAPTER = 'dev/image/adapter'; + const XML_PATH_STATIC_FILE_SIGNATURE = 'dev/static/sign'; + + const CHARS_LOWERS = 'abcdefghijklmnopqrstuvwxyz'; + const CHARS_UPPERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + const CHARS_DIGITS = '0123456789'; + const CHARS_SPECIALS = '!$*+-.=?@^_|~'; + const CHARS_PASSWORD_LOWERS = 'abcdefghjkmnpqrstuvwxyz'; + const CHARS_PASSWORD_UPPERS = 'ABCDEFGHJKLMNPQRSTUVWXYZ'; + const CHARS_PASSWORD_DIGITS = '23456789'; + const CHARS_PASSWORD_SPECIALS = '!$*-.=?@_'; + + /** + * Config pathes to merchant country code and merchant VAT number + */ + const XML_PATH_MERCHANT_COUNTRY_CODE = 'general/store_information/country_id'; + const XML_PATH_MERCHANT_VAT_NUMBER = 'general/store_information/merchant_vat_number'; + const XML_PATH_EU_COUNTRIES_LIST = 'general/country/eu_countries'; + + const XML_PATH_SINGLE_STORE_MODE_ENABLED = 'general/single_store_mode/enabled'; + + /** + * Const for correct dividing decimal values + */ + const DIVIDE_EPSILON = 10000; + + /** + * Config path to mail sending setting that shows if email communications are disabled + */ + const XML_PATH_SYSTEM_SMTP_DISABLE = 'system/smtp/disable'; + + /** + * @var Mage_Core_Model_Encryption + */ + protected $_encryptor = null; + + protected $_allowedFormats = array( + Mage_Core_Model_Locale::FORMAT_TYPE_FULL, + Mage_Core_Model_Locale::FORMAT_TYPE_LONG, + Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, + Mage_Core_Model_Locale::FORMAT_TYPE_SHORT + ); + + /** + * @var Mage_Core_Model_Config_Modules + */ + protected $_config; + + /** + * @param Mage_Core_Helper_Context $context + * @param Mage_Core_Model_Config_Modules $config + */ + public function __construct(Mage_Core_Helper_Context $context, Mage_Core_Model_Config_Modules $config) + { + parent::__construct($context); + $this->_config = $config; + } + + /** + * @return Mage_Core_Model_Encryption + */ + public function getEncryptor() + { + if ($this->_encryptor === null) { + $encryptionModel = (string)$this->_config->getNode(self::XML_PATH_ENCRYPTION_MODEL); + + if (!$encryptionModel) { + $encryptionModel = 'Mage_Core_Model_Encryption'; + } + + $this->_encryptor = Mage::getObjectManager()->create($encryptionModel); + + $this->_encryptor->setHelper($this); + } + return $this->_encryptor; + } + + /** + * Convert and format price value for current application store + * + * @param float $value + * @param bool $format + * @param bool $includeContainer + * @return mixed + */ + public static function currency($value, $format = true, $includeContainer = true) + { + return self::currencyByStore($value, null, $format, $includeContainer); + } + + /** + * Convert and format price value for specified store + * + * @param float $value + * @param int|Mage_Core_Model_Store $store + * @param bool $format + * @param bool $includeContainer + * @return mixed + */ + public static function currencyByStore($value, $store = null, $format = true, $includeContainer = true) + { + try { + if (!($store instanceof Mage_Core_Model_Store)) { + $store = Mage::app()->getStore($store); + } + + $value = $store->convertPrice($value, $format, $includeContainer); + } + catch (Exception $e){ + $value = $e->getMessage(); + } + + return $value; + } + + /** + * Format and convert currency using current store option + * + * @param float $value + * @param bool $includeContainer + * @return string + */ + public function formatCurrency($value, $includeContainer = true) + { + return $this->currency($value, true, $includeContainer); + } + + /** + * Formats price + * + * @param float $price + * @param bool $includeContainer + * @return string + */ + public function formatPrice($price, $includeContainer = true) + { + return Mage::app()->getStore()->formatPrice($price, $includeContainer); + } + + /** + * Format date using current locale options and time zone. + * + * @param date|Zend_Date|null $date + * @param string $format See Mage_Core_Model_Locale::FORMAT_TYPE_* constants + * @param bool $showTime Whether to include time + * @return string + */ + public function formatDate($date = null, $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, $showTime = false) + { + if (!in_array($format, $this->_allowedFormats, true)) { + return $date; + } + if (!($date instanceof Zend_Date) && $date && !strtotime($date)) { + return ''; + } + if (is_null($date)) { + $date = Mage::app()->getLocale()->date( + Mage::getSingleton('Mage_Core_Model_Date')->gmtTimestamp(), + null, + null + ); + } else if (!$date instanceof Zend_Date) { + $date = Mage::app()->getLocale()->date(strtotime($date), null, null); + } + + if ($showTime) { + $format = Mage::app()->getLocale()->getDateTimeFormat($format); + } else { + $format = Mage::app()->getLocale()->getDateFormat($format); + } + + return $date->toString($format); + } + + /** + * Format time using current locale options + * + * @param date|Zend_Date|null $time + * @param string $format + * @param bool $showDate + * @return string + */ + public function formatTime($time = null, $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, $showDate = false) + { + if (!in_array($format, $this->_allowedFormats, true)) { + return $time; + } + + if (is_null($time)) { + $date = Mage::app()->getLocale()->date(time()); + } else if ($time instanceof Zend_Date) { + $date = $time; + } else { + $date = Mage::app()->getLocale()->date(strtotime($time)); + } + + if ($showDate) { + $format = Mage::app()->getLocale()->getDateTimeFormat($format); + } else { + $format = Mage::app()->getLocale()->getTimeFormat($format); + } + + return $date->toString($format); + } + + /** + * Encrypt data using application key + * + * @param string $data + * @return string + */ + public function encrypt($data) + { + if (!Mage::isInstalled()) { + return $data; + } + return $this->getEncryptor()->encrypt($data); + } + + /** + * Decrypt data using application key + * + * @param string $data + * @return string + */ + public function decrypt($data) + { + if (!Mage::isInstalled()) { + return $data; + } + return $this->getEncryptor()->decrypt($data); + } + + public function validateKey($key) + { + return $this->getEncryptor()->validateKey($key); + } + + public function getRandomString($len, $chars = null) + { + if (is_null($chars)) { + $chars = self::CHARS_LOWERS . self::CHARS_UPPERS . self::CHARS_DIGITS; + } + mt_srand(10000000*(double)microtime()); + for ($i = 0, $str = '', $lc = strlen($chars)-1; $i < $len; $i++) { + $str .= $chars[mt_rand(0, $lc)]; + } + return $str; + } + + /** + * Generate salted hash from password + * + * @param string $password + * @param string|integer|boolean $salt + */ + public function getHash($password, $salt = false) + { + return $this->getEncryptor()->getHash($password, $salt); + } + + public function validateHash($password, $hash) + { + return $this->getEncryptor()->validateHash($password, $hash); + } + + /** + * Retrieve store identifier + * + * @param mixed $store + * @return int + */ + public function getStoreId($store=null) + { + return Mage::app()->getStore($store)->getId(); + } + + public function removeAccents($string, $german=false) + { + static $replacements; + + if (empty($replacements[$german])) { + $subst = array( + // single ISO-8859-1 letters + 192=>'A', 193=>'A', 194=>'A', 195=>'A', 196=>'A', 197=>'A', 199=>'C', + 208=>'D', 200=>'E', 201=>'E', 202=>'E', 203=>'E', 204=>'I', 205=>'I', + 206=>'I', 207=>'I', 209=>'N', 210=>'O', 211=>'O', 212=>'O', 213=>'O', + 214=>'O', 216=>'O', 138=>'S', 217=>'U', 218=>'U', 219=>'U', 220=>'U', + 221=>'Y', 142=>'Z', 224=>'a', 225=>'a', 226=>'a', 227=>'a', 228=>'a', + 229=>'a', 231=>'c', 232=>'e', 233=>'e', 234=>'e', 235=>'e', 236=>'i', + 237=>'i', 238=>'i', 239=>'i', 241=>'n', 240=>'o', 242=>'o', 243=>'o', + 244=>'o', 245=>'o', 246=>'o', 248=>'o', 154=>'s', 249=>'u', 250=>'u', + 251=>'u', 252=>'u', 253=>'y', 255=>'y', 158=>'z', + // HTML entities + 258=>'A', 260=>'A', 262=>'C', 268=>'C', 270=>'D', 272=>'D', 280=>'E', + 282=>'E', 286=>'G', 304=>'I', 313=>'L', 317=>'L', 321=>'L', 323=>'N', + 327=>'N', 336=>'O', 340=>'R', 344=>'R', 346=>'S', 350=>'S', 354=>'T', + 356=>'T', 366=>'U', 368=>'U', 377=>'Z', 379=>'Z', 259=>'a', 261=>'a', + 263=>'c', 269=>'c', 271=>'d', 273=>'d', 281=>'e', 283=>'e', 287=>'g', + 305=>'i', 322=>'l', 314=>'l', 318=>'l', 324=>'n', 328=>'n', 337=>'o', + 341=>'r', 345=>'r', 347=>'s', 351=>'s', 357=>'t', 355=>'t', 367=>'u', + 369=>'u', 378=>'z', 380=>'z', + // ligatures + 198=>'Ae', 230=>'ae', 140=>'Oe', 156=>'oe', 223=>'ss', + ); + + if ($german) { + // umlauts + $subst = array_merge($subst, array( + 196=>'Ae', 228=>'ae', 214=>'Oe', 246=>'oe', 220=>'Ue', 252=>'ue' + )); + } + + $replacements[$german] = array(); + foreach ($subst as $k=>$v) { + $replacements[$german][$k<256 ? chr($k) : '&#'.$k.';'] = $v; + } + } + + // convert string from default database format (UTF-8) + // to encoding which replacement arrays made with (ISO-8859-1) + if ($s = @iconv('UTF-8', 'ISO-8859-1', $string)) { + $string = $s; + } + + // Replace + $string = strtr($string, $replacements[$german]); + + return $string; + } + + public function isDevAllowed($storeId=null) + { + $allow = true; + + $allowedIps = Mage::getStoreConfig(self::XML_PATH_DEV_ALLOW_IPS, $storeId); + $remoteAddr = Mage::helper('Mage_Core_Helper_Http')->getRemoteAddr(); + if (!empty($allowedIps) && !empty($remoteAddr)) { + $allowedIps = preg_split('#\s*,\s*#', $allowedIps, null, PREG_SPLIT_NO_EMPTY); + if (array_search($remoteAddr, $allowedIps) === false + && array_search(Mage::helper('Mage_Core_Helper_Http')->getHttpHost(), $allowedIps) === false) { + $allow = false; + } + } + + return $allow; + } + + /** + * Get information about available cache types + * + * @return array + */ + public function getCacheTypes() + { + $types = array(); + $config = Mage::getConfig()->getNode(Mage_Core_Model_Cache::XML_PATH_TYPES); + foreach ($config->children() as $type=>$node) { + $types[$type] = (string)$node->label; + } + return $types; + } + + /** + * Copy data from object|array to object|array containing fields + * from fieldset matching an aspect. + * + * Contents of $aspect are a field name in target object or array. + * If '*' - will be used the same name as in the source object or array. + * + * @param string $fieldset + * @param string $aspect + * @param array|Varien_Object $source + * @param array|Varien_Object $target + * @param string $root + * @return boolean + */ + public function copyFieldset($fieldset, $aspect, $source, $target, $root='global') + { + if (!(is_array($source) || $source instanceof Varien_Object) + || !(is_array($target) || $target instanceof Varien_Object)) { + + return false; + } + $fields = Mage::getConfig()->getFieldset($fieldset, $root); + if (!$fields) { + return false; + } + + $sourceIsArray = is_array($source); + $targetIsArray = is_array($target); + + $result = false; + foreach ($fields as $code=>$node) { + if (empty($node->$aspect)) { + continue; + } + + if ($sourceIsArray) { + $value = isset($source[$code]) ? $source[$code] : null; + } else { + $value = $source->getDataUsingMethod($code); + } + + $targetCode = (string)$node->$aspect; + $targetCode = $targetCode == '*' ? $code : $targetCode; + + if ($targetIsArray) { + $target[$targetCode] = $value; + } else { + $target->setDataUsingMethod($targetCode, $value); + } + + $result = true; + } + + $eventName = sprintf('core_copy_fieldset_%s_%s', $fieldset, $aspect); + Mage::dispatchEvent($eventName, array( + 'target' => $target, + 'source' => $source, + 'root' => $root + )); + + return $result; + } + + /** + * Decorate a plain array of arrays or objects + * The array actually can be an object with Iterator interface + * + * Keys with prefix_* will be set: + * *_is_first - if the element is first + * *_is_odd / *_is_even - for odd/even elements + * *_is_last - if the element is last + * + * The respective key/attribute will be set to element, depending on object it is or array. + * Varien_Object is supported. + * + * $forceSetAll true will cause to set all possible values for all elements. + * When false (default), only non-empty values will be set. + * + * @param mixed $array + * @param string $prefix + * @param bool $forceSetAll + * @return mixed + */ + public function decorateArray($array, $prefix = 'decorated_', $forceSetAll = false) + { + // check if array or an object to be iterated given + if (!(is_array($array) || is_object($array))) { + return $array; + } + + $keyIsFirst = "{$prefix}is_first"; + $keyIsOdd = "{$prefix}is_odd"; + $keyIsEven = "{$prefix}is_even"; + $keyIsLast = "{$prefix}is_last"; + + $count = count($array); // this will force Iterator to load + $i = 0; + $isEven = false; + foreach ($array as $key => $element) { + if (is_object($element)) { + $this->_decorateArrayObject($element, $keyIsFirst, (0 === $i), $forceSetAll || (0 === $i)); + $this->_decorateArrayObject($element, $keyIsOdd, !$isEven, $forceSetAll || !$isEven); + $this->_decorateArrayObject($element, $keyIsEven, $isEven, $forceSetAll || $isEven); + $isEven = !$isEven; + $i++; + $this->_decorateArrayObject($element, $keyIsLast, ($i === $count), $forceSetAll || ($i === $count)); + } + elseif (is_array($element)) { + if ($forceSetAll || (0 === $i)) { + $array[$key][$keyIsFirst] = (0 === $i); + } + if ($forceSetAll || !$isEven) { + $array[$key][$keyIsOdd] = !$isEven; + } + if ($forceSetAll || $isEven) { + $array[$key][$keyIsEven] = $isEven; + } + $isEven = !$isEven; + $i++; + if ($forceSetAll || ($i === $count)) { + $array[$key][$keyIsLast] = ($i === $count); + } + } + } + + return $array; + } + + /** + * Mark passed object with specified flag and appropriate value. + * + * @param Varien_Object $element + * @param string $key + * @param mixed $value + * @param bool $dontSkip + */ + private function _decorateArrayObject($element, $key, $value, $dontSkip) { + if ($dontSkip && $element instanceof Varien_Object) { + $element->setData($key, $value); + } + } + + /** + * Transform an assoc array to SimpleXMLElement object + * Array has some limitations. Appropriate exceptions will be thrown + * + * @param array $array + * @param string $rootName + * @return SimpleXMLElement + * @throws Magento_Exception + */ + public function assocToXml(array $array, $rootName = '_') + { + if (empty($rootName) || is_numeric($rootName)) { + throw new Magento_Exception('Root element must not be empty or numeric'); + } + + $xmlstr = << +<$rootName> +XML; + $xml = new SimpleXMLElement($xmlstr); + foreach ($array as $key => $value) { + if (is_numeric($key)) { + throw new Magento_Exception('Array root keys must not be numeric.'); + } + } + return self::_assocToXml($array, $rootName, $xml); + } + + /** + * Function, that actually recursively transforms array to xml + * + * @param array $array + * @param string $rootName + * @param SimpleXMLElement $xml + * @return SimpleXMLElement + * @throws Magento_Exception + */ + private function _assocToXml(array $array, $rootName, SimpleXMLElement &$xml) + { + $hasNumericKey = false; + $hasStringKey = false; + foreach ($array as $key => $value) { + if (!is_array($value)) { + if (is_string($key)) { + if ($key === $rootName) { + throw new Magento_Exception( + 'Associative key must not be the same as its parent associative key.' + ); + } + $hasStringKey = true; + $xml->$key = $value; + } + elseif (is_int($key)) { + $hasNumericKey = true; + $xml->{$rootName}[$key] = $value; + } + } + else { + self::_assocToXml($value, $key, $xml->$key); + } + } + if ($hasNumericKey && $hasStringKey) { + throw new Magento_Exception('Associative and numeric keys must not be mixed at one level.'); + } + return $xml; + } + + /** + * Transform SimpleXMLElement to associative array + * SimpleXMLElement must be conform structure, generated by assocToXml() + * + * @param SimpleXMLElement $xml + * @return array + */ + public function xmlToAssoc(SimpleXMLElement $xml) + { + $array = array(); + foreach ($xml as $key => $value) { + if (isset($value->$key)) { + $i = 0; + foreach ($value->$key as $v) { + $array[$key][$i++] = (string)$v; + } + } + else { + // try to transform it into string value, trimming spaces between elements + $array[$key] = trim((string)$value); + if (empty($array[$key]) && !empty($value)) { + $array[$key] = self::xmlToAssoc($value); + } + // untrim strings values + else { + $array[$key] = (string)$value; + } + } + } + return $array; + } + + /** + * Encode the mixed $valueToEncode into the JSON format + * + * @param mixed $valueToEncode + * @param boolean $cycleCheck Optional; whether or not to check for object recursion; off by default + * @param array $options Additional options used during encoding + * @return string + */ + public function jsonEncode($valueToEncode, $cycleCheck = false, $options = array()) + { + $json = Zend_Json::encode($valueToEncode, $cycleCheck, $options); + /* @var $inline Mage_Core_Model_Translate_Inline */ + $inline = Mage::getSingleton('Mage_Core_Model_Translate_Inline'); + if ($inline->isAllowed()) { + $inline->setIsJson(true); + $inline->processResponseBody($json); + $inline->setIsJson(false); + } + + return $json; + } + + /** + * Decodes the given $encodedValue string which is + * encoded in the JSON format + * + * @param string $encodedValue + * @return mixed + */ + public function jsonDecode($encodedValue, $objectDecodeType = Zend_Json::TYPE_ARRAY) + { + return Zend_Json::decode($encodedValue, $objectDecodeType); + } + + /** + * Generate a hash from unique ID + * @param $prefix + * @return string + */ + public function uniqHash($prefix = '') + { + return $prefix . md5(uniqid(microtime().mt_rand(), true)); + } + + /** + * Return default country code + * + * @param Mage_Core_Model_Store|string|int $store + * @return string + */ + public function getDefaultCountry($store = null) + { + return Mage::getStoreConfig(self::XML_PATH_DEFAULT_COUNTRY, $store); + } + + /** + * Return list with protected file extensions + * + * @param Mage_Core_Model_Store|string|int $store + * @return array + */ + public function getProtectedFileExtensions($store = null) + { + return Mage::getStoreConfig(self::XML_PATH_PROTECTED_FILE_EXTENSIONS, $store); + } + + /** + * Return list with public files valid paths + * + * @return array + */ + public function getPublicFilesValidPath() + { + return Mage::getStoreConfig(self::XML_PATH_PUBLIC_FILES_VALID_PATHS); + } + + /** + * Check LFI protection + * + * @throws Mage_Core_Exception + * @param string $name + * @return bool + */ + public function checkLfiProtection($name) + { + if (preg_match('#\.\.[\\\/]#', $name)) { + throw new Mage_Core_Exception($this->__('Requested file may not include parent directory traversal ("../", "..\\" notation)')); + } + return true; + } + + /** + * Check whether database compatible mode is used (configs enable it for MySQL by default). + * + * @return bool + */ + public function useDbCompatibleMode() + { + /** @var $resourceConfig Mage_Core_Model_Config_Resource */ + $resourceConfig = Mage::getSingleton('Mage_Core_Model_Config_Resource'); + $connType = (string) $resourceConfig->getResourceConnectionConfig('default_setup')->type; + $value = (string) $resourceConfig->getResourceTypeConfig($connType)->compatibleMode; + return (bool) $value; + } + + /** + * Retrieve merchant country code + * + * @param Mage_Core_Model_Store|string|int|null $store + * @return string + */ + public function getMerchantCountryCode($store = null) + { + return (string) Mage::getStoreConfig(self::XML_PATH_MERCHANT_COUNTRY_CODE, $store); + } + + /** + * Retrieve merchant VAT number + * + * @param Mage_Core_Model_Store|string|int|null $store + * @return string + */ + public function getMerchantVatNumber($store = null) + { + return (string) Mage::getStoreConfig(self::XML_PATH_MERCHANT_VAT_NUMBER, $store); + } + + /** + * Check whether specified country is in EU countries list + * + * @param string $countryCode + * @param null|int $storeId + * @return bool + */ + public function isCountryInEU($countryCode, $storeId = null) + { + $euCountries = explode(',', Mage::getStoreConfig(self::XML_PATH_EU_COUNTRIES_LIST, $storeId)); + return in_array($countryCode, $euCountries); + } + + /** + * Returns the floating point remainder (modulo) of the division of the arguments + * + * @param float|int $dividend + * @param float|int $divisor + * @return float|int + */ + public function getExactDivision($dividend, $divisor) + { + $epsilon = $divisor / self::DIVIDE_EPSILON; + + $remainder = fmod($dividend, $divisor); + if (abs($remainder - $divisor) < $epsilon || abs($remainder) < $epsilon) { + $remainder = 0; + } + + return $remainder; + } + + /** + * Returns image adapter type + * + * @return string + */ + public function getImageAdapterType() + { + return Mage::getStoreConfig(self::XML_PATH_IMAGE_ADAPTER); + } + + /** + * Check if static files have to be signed + * + * @return bool + */ + public function isStaticFilesSigned() + { + return (bool) Mage::getStoreConfig(self::XML_PATH_STATIC_FILE_SIGNATURE); + } + + /** + * Check if Single-Store mode is enabled in configuration + * + * This flag only shows that admin does not want to show certain UI components at backend (like store switchers etc) + * if Magento has only one store view but it does not check the store view collection + * + * @return bool + */ + public function isSingleStoreModeEnabled() + { + return (bool) Mage::getStoreConfig(self::XML_PATH_SINGLE_STORE_MODE_ENABLED); + } +} diff --git a/app/code/core/Mage/Core/Helper/File/Storage.php b/app/code/Mage/Core/Helper/File/Storage.php similarity index 100% rename from app/code/core/Mage/Core/Helper/File/Storage.php rename to app/code/Mage/Core/Helper/File/Storage.php diff --git a/app/code/core/Mage/Core/Helper/File/Storage/Database.php b/app/code/Mage/Core/Helper/File/Storage/Database.php similarity index 98% rename from app/code/core/Mage/Core/Helper/File/Storage/Database.php rename to app/code/Mage/Core/Helper/File/Storage/Database.php index dd88d7651e5bf..f39aff3e8dedb 100644 --- a/app/code/core/Mage/Core/Helper/File/Storage/Database.php +++ b/app/code/Mage/Core/Helper/File/Storage/Database.php @@ -65,10 +65,12 @@ class Mage_Core_Helper_File_Storage_Database extends Mage_Core_Helper_Abstract protected $_filesystem; /** + * @param Mage_Core_Helper_Context $context * @param Magento_Filesystem $filesystem */ - public function __construct(Magento_Filesystem $filesystem) + public function __construct(Mage_Core_Helper_Context $context, Magento_Filesystem $filesystem) { + parent::__construct($context); $this->_filesystem = $filesystem; } diff --git a/app/code/core/Mage/Core/Helper/Hint.php b/app/code/Mage/Core/Helper/Hint.php similarity index 100% rename from app/code/core/Mage/Core/Helper/Hint.php rename to app/code/Mage/Core/Helper/Hint.php diff --git a/app/code/core/Mage/Core/Helper/Http.php b/app/code/Mage/Core/Helper/Http.php similarity index 100% rename from app/code/core/Mage/Core/Helper/Http.php rename to app/code/Mage/Core/Helper/Http.php diff --git a/app/code/Mage/Core/Helper/Js.php b/app/code/Mage/Core/Helper/Js.php new file mode 100644 index 0000000000000..964be73e7fda1 --- /dev/null +++ b/app/code/Mage/Core/Helper/Js.php @@ -0,0 +1,178 @@ + + */ +class Mage_Core_Helper_Js extends Mage_Core_Helper_Abstract +{ + /** + * Key for cache + */ + const JAVASCRIPT_TRANSLATE_CONFIG_KEY = 'javascript_translate_config'; + + /** + * Translate file name + */ + const JAVASCRIPT_TRANSLATE_CONFIG_FILENAME = 'jstranslator.xml'; + + /** + * Array of senteces of JS translations + * + * @var array + */ + protected $_translateData = null; + + /** + * Translate config + * + * @var Varien_Simplexml_Config + */ + protected $_config = null; + + /** + * Modules configuration reader + * + * @var Mage_Core_Model_Config_Modules_Reader + */ + protected $_configReader; + + /** + * @var Mage_Core_Model_Cache_Type_Config + */ + protected $_configCacheType; + + /** + * @param Mage_Core_Helper_Context $context + * @param Mage_Core_Model_Config_Modules_Reader $configReader + * @param Mage_Core_Model_Cache_Type_Config $configCacheType + */ + public function __construct( + Mage_Core_Helper_Context $context, + Mage_Core_Model_Config_Modules_Reader $configReader, + Mage_Core_Model_Cache_Type_Config $configCacheType + ) { + parent::__construct($context); + $this->_configReader = $configReader; + $this->_configCacheType = $configCacheType; + } + + /** + * Retrieve JSON of JS sentences translation + * + * @return string + */ + public function getTranslateJson() + { + return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($this->_getTranslateData()); + } + + /** + * Retrieve JS translator initialization javascript + * + * @return string + */ + public function getTranslatorScript() + { + $script = '(function($) {$.mage.translate.add(' . $this->getTranslateJson() . ')})(jQuery);'; + return $this->getScript($script); + } + + /** + * Retrieve framed javascript + * + * @param string $script + * @return script + */ + public function getScript($script) + { + return ''; + } + + /** + * Retrieve javascript include code + * + * @param string $file + * @return string + */ + public function includeScript($file) + { + return '' . "\n"; + } + + /** + * Retrieve JS translation array + * + * @return array + */ + protected function _getTranslateData() + { + if ($this->_translateData === null) { + $this->_translateData = array(); + $messages = $this->_getXmlConfig()->getXpath('*/message'); + if (!empty($messages)) { + foreach ($messages as $message) { + $messageText = (string)$message; + $module = $message->getParent()->getAttribute("module"); + $this->_translateData[$messageText] = Mage::helper( + empty($module) ? 'Mage_Core' : $module + )->__($messageText); + } + } + + foreach ($this->_translateData as $key => $value) { + if ($key == $value) { + unset($this->_translateData[$key]); + } + } + } + return $this->_translateData; + } + + /** + * Load config from files and try to cache it + * + * @return Varien_Simplexml_Config + */ + protected function _getXmlConfig() + { + if (is_null($this->_config)) { + $cachedXml = $this->_configCacheType->load(self::JAVASCRIPT_TRANSLATE_CONFIG_KEY); + if ($cachedXml) { + $xmlConfig = new Varien_Simplexml_Config($cachedXml); + } else { + $xmlConfig = new Varien_Simplexml_Config(); + $xmlConfig->loadString(''); + $this->_configReader->loadModulesConfiguration(self::JAVASCRIPT_TRANSLATE_CONFIG_FILENAME, $xmlConfig); + $this->_configCacheType->save($xmlConfig->getXmlString(), self::JAVASCRIPT_TRANSLATE_CONFIG_KEY); + } + $this->_config = $xmlConfig; + } + return $this->_config; + } +} diff --git a/app/code/core/Mage/Core/Helper/String.php b/app/code/Mage/Core/Helper/String.php similarity index 100% rename from app/code/core/Mage/Core/Helper/String.php rename to app/code/Mage/Core/Helper/String.php diff --git a/app/code/Mage/Core/Helper/Theme.php b/app/code/Mage/Core/Helper/Theme.php new file mode 100644 index 0000000000000..7166422f79a95 --- /dev/null +++ b/app/code/Mage/Core/Helper/Theme.php @@ -0,0 +1,449 @@ +_design = $design; + $this->_dirs = $dirs; + $this->_layoutMergeFactory = $layoutMergeFactory; + $this->_themeCollection = $themeCollection; + $this->_themeFactory = $themeFactory; + parent::__construct($context); + } + + /** + * Get CSS files of a given theme + * + * Returned array has a structure + * array( + * 'Mage_Catalog::widgets.css' => 'http://mage2.com/pub/static/frontend/_theme15/en_US/Mage_Cms/widgets.css' + * ) + * + * @param Mage_Core_Model_Theme $theme + * @return array + */ + public function getCssFiles($theme) + { + $arguments = array( + 'area' => $theme->getArea(), + 'theme' => $theme->getThemeId() + ); + /** @var $layoutMerge Mage_Core_Model_Layout_Merge */ + $layoutMerge = $this->_layoutMergeFactory->create(array('arguments' => $arguments)); + $layoutElement = $layoutMerge->getFileLayoutUpdatesXml(); + + $elements = array_merge( + $layoutElement->xpath(self::XPATH_SELECTOR_REFS) ?: array(), + $layoutElement->xpath(self::XPATH_SELECTOR_BLOCKS) ?: array() + ); + + $params = array( + 'area' => $theme->getArea(), + 'themeModel' => $theme, + 'skipProxy' => true + ); + + $basePath = $this->_dirs->getDir(Mage_Core_Model_Dir::ROOT); + $files = array(); + foreach ($elements as $fileId) { + $fileId = (string)$fileId; + $path = $this->_design->getViewFile($fileId, $params); + $file = array( + 'id' => $fileId, + 'path' => Magento_Filesystem::fixSeparator($path), + ); + $file['safePath'] = $this->getSafePath($file['path'], $basePath); + + //keys are used also to remove duplicates + $files[$fileId] = $file; + } + + return $files; + } + + /** + * Get CSS files by group + * + * @param Mage_Core_Model_Theme $theme + * @return array + * @throws LogicException + */ + public function getGroupedCssFiles($theme) + { + $jsDir = Magento_Filesystem::fixSeparator($this->_dirs->getDir(Mage_Core_Model_Dir::PUB_LIB)); + $codeDir = Magento_Filesystem::fixSeparator($this->_dirs->getDir(Mage_Core_Model_Dir::MODULES)); + $designDir = Magento_Filesystem::fixSeparator($this->_dirs->getDir(Mage_Core_Model_Dir::THEMES)); + + $groups = array(); + $themes = array(); + foreach ($this->getCssFiles($theme) as $file) { + $this->_detectTheme($file, $designDir); + $this->_detectGroup($file, $designDir, $jsDir, $codeDir); + + if (isset($file['theme']) && $file['theme']->getThemeId()) { + $themes[$file['theme']->getThemeId()] = $file['theme']; + } + + if (!isset($file['group'])) { + throw new LogicException($this->__('Group is missed for file "%s"', $file['safePath'])); + } + $group = $file['group']; + unset($file['theme']); + unset($file['group']); + + if (!isset($groups[$group])) { + $groups[$group] = array(); + } + $groups[$group][] = $file; + } + + if (count($themes) > 1) { + $themes = $this->_sortThemesByHierarchy($themes); + } + + $order = array_merge(array($codeDir, $jsDir), array_map(function ($fileTheme) { + /** @var $fileTheme Mage_Core_Model_Theme */ + return $fileTheme->getThemeId(); + }, $themes)); + $groups = $this->_sortArrayByArray($groups, $order); + + $labels = $this->_getGroupLabels($themes, $jsDir, $codeDir); + foreach ($groups as $key => $group) { + usort($group, array($this, '_sortGroupFilesCallback')); + $groups[$labels[$key]] = $group; + unset($groups[$key]); + } + return $groups; + } + + /** + * Detect theme view file belongs to and set it to file data under "theme" key + * + * @param array $file + * @param string $designDir + * @return Mage_Core_Helper_Theme + * @throws LogicException + */ + protected function _detectTheme(&$file, $designDir) + { + //TODO use cache here, so files of the same theme share one model + + $isInsideDesignDir = substr($file['path'], 0, strlen($designDir)) == $designDir; + if (!$isInsideDesignDir) { + return $this; + } + + $relativePath = substr($file['path'], strlen($designDir)); + + $area = strtok($relativePath, Magento_Filesystem::DIRECTORY_SEPARATOR); + $package = strtok(Magento_Filesystem::DIRECTORY_SEPARATOR); + $theme = strtok(Magento_Filesystem::DIRECTORY_SEPARATOR); + + if ($area === false || $package === false || $theme === false) { + throw new LogicException($this->__('Theme path "%s/%s/%s" is incorrect', $area, $package, $theme)); + } + $themeModel = $this->_themeCollection->getThemeByFullPath($area . '/' . $package . '/' . $theme); + + if (!$themeModel || !$themeModel->getThemeId()) { + throw new LogicException( + $this->__('Invalid theme loaded by theme path "%s/%s/%s"', $area, $package, $theme) + ); + } + + $file['theme'] = $themeModel; + + return $this; + } + + /** + * Detect group where file should be placed and set it to file data under "group" key + * + * @param array $file + * @param string $designDir + * @param string $jsDir + * @param string $codeDir + * @return Mage_Core_Helper_Theme + * @throws LogicException + */ + protected function _detectGroup(&$file, $designDir, $jsDir, $codeDir) + { + $group = null; + if (substr($file['path'], 0, strlen($designDir)) == $designDir) { + if (!isset($file['theme']) || !$file['theme']->getThemeId()) { + throw new LogicException($this->__('Theme is missed for file "%s"', $file['safePath'])); + } + $group = $file['theme']->getThemeId(); + } elseif (substr($file['path'], 0, strlen($jsDir)) == $jsDir) { + $group = $jsDir; + } elseif (substr($file['path'], 0, strlen($codeDir)) == $codeDir) { + $group = $codeDir; + } else { + throw new LogicException($this->__('Invalid view file directory "%s"', $file['safePath'])); + } + $file['group'] = $group; + + return $this; + } + + /** + * Sort themes according to their hierarchy + * + * @param array $themes + * @return array + */ + protected function _sortThemesByHierarchy(array $themes) + { + uasort($themes, array($this, '_sortThemesByHierarchyCallback')); + return $themes; + } + + /** + * Sort one associative array according to another array + * + * $groups = array( + * b => item2, + * a => item1, + * c => item3, + * ); + * $order = array(a,b,c); + * result: array( + * a => item1, + * b => item2, + * c => item3, + * ) + * + * @param array $groups + * @param array $order + * @return array + */ + protected function _sortArrayByArray(array $groups, array $order) + { + $ordered = array(); + foreach ($order as $key) { + if (array_key_exists($key, $groups)) { + $ordered[$key] = $groups[$key]; + unset($groups[$key]); + } + } + return $ordered + $groups; + } + + /** + * Get group labels + * + * @param array $themes + * @param string $jsDir + * @param string $codeDir + * @return array + */ + protected function _getGroupLabels(array $themes, $jsDir, $codeDir) + { + $labels = array( + $jsDir => $this->__('Library files'), + $codeDir => $this->__('Framework files') + ); + foreach ($themes as $theme) { + /** @var $theme Mage_Core_Model_Theme */ + $labels[$theme->getThemeId()] = $this->__('"%s" Theme files', $theme->getThemeTitle()); + } + return $labels; + } + + /** + * Callback for sorting files inside group + * + * Return "1" if $firstFile should go before $secondFile, otherwise return "-1" + * + * @param array $firstFile + * @param array $secondFile + * @return int + */ + protected function _sortGroupFilesCallback(array $firstFile, array $secondFile) + { + $hasContextFirst = strpos($firstFile['id'], '::') !== false; + $hasContextSecond = strpos($secondFile['id'], '::') !== false; + + if ($hasContextFirst && $hasContextSecond) { + $result = strcmp($firstFile['id'], $secondFile['id']); + } elseif (!$hasContextFirst && !$hasContextSecond) { + $result = strcmp($firstFile['id'], $secondFile['id']); + } elseif ($hasContextFirst) { + //case when first item has module context and second item doesn't + $result = 1; + } else { + //case when second item has module context and first item doesn't + $result = -1; + } + return $result; + } + + /** + * Sort themes by hierarchy callback + * + * @param Mage_Core_Model_Theme $firstTheme + * @param Mage_Core_Model_Theme $secondTheme + * @return int + */ + protected function _sortThemesByHierarchyCallback($firstTheme, $secondTheme) + { + $parentTheme = $firstTheme->getParentTheme(); + while ($parentTheme) { + if ($parentTheme->getThemeId() == $secondTheme->getThemeId()) { + return -1; + } + $parentTheme = $parentTheme->getParentTheme(); + } + return 1; + } + + /** + * Get relative file path cut to be safe for public sharing + * + * Path is considered from the base Magento directory + * + * @param string $filePath + * @param string $basePath + * @return string + */ + public function getSafePath($filePath, $basePath) + { + return ltrim(str_ireplace($basePath, '', $filePath), '\\/'); + } + + /** + * Load theme by theme id + * Method also checks if theme actually loaded and if theme is editable + * + * @param int $themeId + * @return Mage_Core_Model_Theme + * @throws Mage_Core_Exception + */ + public function loadEditableTheme($themeId) + { + $theme = $this->_loadTheme($themeId); + if (!$theme->isEditable()) { + throw new Mage_Core_Exception($this->__('Theme "%s" is not editable.', $themeId)); + } + return $theme; + } + + /** + * Load theme by theme id + * Method also checks if theme actually loaded and if theme is visible + * + * @param int $themeId + * @return Mage_Core_Model_Theme + * @throws Mage_Core_Exception + */ + public function loadVisibleTheme($themeId) + { + $theme = $this->_loadTheme($themeId); + if (!$theme->isVisible()) { + throw new Mage_Core_Exception($this->__('Theme "%s" is not visible.', $themeId)); + } + return $theme; + } + + /** + * Load theme by theme id and checks if theme actually loaded + * + * @param $themeId + * @return Mage_Core_Model_Theme + * @throws Mage_Core_Exception + */ + protected function _loadTheme($themeId) + { + $theme = $this->_themeFactory->create(); + if (!($themeId && $theme->load($themeId)->getId())) { + throw new Mage_Core_Exception($this->__('Theme "%s" was not found.', $themeId)); + } + return $theme; + } +} diff --git a/app/code/core/Mage/Core/Helper/Translate.php b/app/code/Mage/Core/Helper/Translate.php similarity index 100% rename from app/code/core/Mage/Core/Helper/Translate.php rename to app/code/Mage/Core/Helper/Translate.php diff --git a/app/code/Mage/Core/Helper/Url.php b/app/code/Mage/Core/Helper/Url.php new file mode 100644 index 0000000000000..83d518657293f --- /dev/null +++ b/app/code/Mage/Core/Helper/Url.php @@ -0,0 +1,144 @@ + + */ +class Mage_Core_Helper_Url extends Mage_Core_Helper_Abstract +{ + /** + * Retrieve current url + * + * @return string + */ + public function getCurrentUrl() + { + $request = $this->_getRequest(); + $port = $this->_getRequest()->getServer('SERVER_PORT'); + if ($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; + } + + /** + * Retrieve current url in base64 encoding + * + * @return string + */ + public function getCurrentBase64Url() + { + return $this->urlEncode($this->getCurrentUrl()); + } + + public function getEncodedUrl($url = null) + { + if (!$url) { + $url = $this->getCurrentUrl(); + } + return $this->urlEncode($url); + } + + /** + * Retrieve homepage url + * + * @return string + */ + public function getHomeUrl() + { + return Mage::getBaseUrl(); + } + + protected function _prepareString($string) + { + $string = preg_replace('#[^0-9a-z]+#i', '-', $string); + $string = strtolower($string); + $string = trim($string, '-'); + + return $string; + } + + /** + * Add request parameter into url + * + * @param $url string + * @param $param array( 'key' => value ) + * @return string + */ + public function addRequestParam($url, $param) + { + $startDelimiter = (false === strpos($url,'?'))? '?' : '&'; + + $arrQueryParams = array(); + foreach($param as $key=>$value) { + if (is_numeric($key) || is_object($value)) { + continue; + } + + if (is_array($value)) { + // $key[]=$value1&$key[]=$value2 ... + $arrQueryParams[] = $key . '[]=' . implode('&' . $key . '[]=', $value); + } elseif (is_null($value)) { + $arrQueryParams[] = $key; + } else { + $arrQueryParams[] = $key . '=' . $value; + } + } + $url .= $startDelimiter . implode('&', $arrQueryParams); + + return $url; + } + + /** + * Remove request parameter from url + * @param string $url + * @param string $paramKey + * @param bool $caseSensitive + * @return string + */ + public function removeRequestParam($url, $paramKey, $caseSensitive = false) + { + $regExpression = '/\\?[^#]*?(' . preg_quote($paramKey, '/') . '\\=[^#&]*&?)/' . ($caseSensitive ? '' : 'i'); + while (preg_match($regExpression, $url, $mathes) != 0) { + $paramString = $mathes[1]; + if (preg_match('/&$/', $paramString) == 0) { + $url = preg_replace('/(&|\\?)?' . preg_quote($paramString, '/') . '/', '', $url); + } else { + $url = str_replace($paramString, '', $url); + } + } + return $url; + } +} diff --git a/app/code/core/Mage/Core/Helper/Url/Rewrite.php b/app/code/Mage/Core/Helper/Url/Rewrite.php similarity index 100% rename from app/code/core/Mage/Core/Helper/Url/Rewrite.php rename to app/code/Mage/Core/Helper/Url/Rewrite.php diff --git a/app/code/Mage/Core/Model/Abstract.php b/app/code/Mage/Core/Model/Abstract.php new file mode 100644 index 0000000000000..921bff675916b --- /dev/null +++ b/app/code/Mage/Core/Model/Abstract.php @@ -0,0 +1,701 @@ +getEvent()->getObject() in this case + * + * @var string + */ + protected $_eventObject = 'object'; + + /** + * Resource model instance + * + * @var Mage_Core_Model_Resource_Db_Abstract + */ + protected $_resource; + + /** + * Resource collection + * + * @var Mage_Core_Model_Resource_Db_Collection_Abstract + */ + protected $_resourceCollection; + /** + * Name of the resource model + * + * @var string + */ + protected $_resourceName; + + /** + * Name of the resource collection model + * + * @var string + */ + protected $_collectionName; + + /** + * Model cache tag for clear cache in after save and after delete + * + * When you use true - all cache will be clean + * + * @var string|array|true + */ + protected $_cacheTag = false; + + /** + * Flag which can stop data saving after before save + * Can be used for next sequence: we check data in _beforeSave, if data are + * not valid - we can set this flag to false value and save process will be stopped + * + * @var bool + */ + protected $_dataSaveAllowed = true; + + /** + * Flag which allow detect object state: is it new object (without id) or existing one (with id) + * + * @var bool + */ + protected $_isObjectNew = null; + + /** + * Validator for checking the model state before saving it + * + * @var Zend_Validate_Interface|bool|null + */ + protected $_validatorBeforeSave = null; + + /** + * Application Event Dispatcher + * + * @var Mage_Core_Model_Event_Manager + */ + protected $_eventDispatcher; + + /** + * Application Cache Manager + * + * @var Mage_Core_Model_CacheInterface + */ + protected $_cacheManager; + + /** + * @param Mage_Core_Model_Context $context + * @param Mage_Core_Model_Resource_Abstract $resource + * @param Varien_Data_Collection_Db $resourceCollection + * @param array $data + */ + public function __construct( + Mage_Core_Model_Context $context, + Mage_Core_Model_Resource_Abstract $resource = null, + Varien_Data_Collection_Db $resourceCollection = null, + array $data = array() + ) { + $this->_eventDispatcher = $context->getEventDispatcher(); + $this->_cacheManager = $context->getCacheManager(); + $this->_resource = $resource; + $this->_resourceCollection = $resourceCollection; + + if ($this->_resource) { + $this->_idFieldName = $this->_getResource()->getIdFieldName(); + } + + parent::__construct($data); + $this->_construct(); + } + + /** + * Model construct that should be used for object initialization + */ + protected function _construct() + { + } + + /** + * Standard model initialization + * + * @param string $resourceModel + * @return Mage_Core_Model_Abstract + */ + protected function _init($resourceModel) + { + $this->_setResourceModel($resourceModel); + $this->_idFieldName = $this->_getResource()->getIdFieldName(); + } + + /** + * Remove not serializable fields + * + * @return array + */ + public function __sleep() + { + $properties = array_keys(get_object_vars($this)); + if (Mage::getIsSerializable()) { + $properties = array_diff($properties, array('_eventDispatcher', '_cacheManager')); + } + return $properties; + } + + /** + * Init not serializable fields + */ + public function __wakeup() + { + if (Mage::getIsSerializable()) { + $this->_eventDispatcher = Mage::getSingleton('Mage_Core_Model_Event_Manager'); + $this->_cacheManager = Mage::getSingleton('Mage_Core_Model_CacheInterface'); + } + } + + /** + * Set resource names + * + * If collection name is omitted, resource name will be used with _collection appended + * + * @param string $resourceName + * @param string|null $collectionName + */ + protected function _setResourceModel($resourceName, $collectionName = null) + { + $this->_resourceName = $resourceName; + if (is_null($collectionName)) { + $collectionName = $resourceName . '_Collection'; + } + $this->_collectionName = $collectionName; + } + + /** + * Get resource instance + * + * @return Mage_Core_Model_Resource_Db_Abstract + */ + protected function _getResource() + { + if (empty($this->_resourceName) && empty($this->_resource)) { + Mage::throwException(Mage::helper('Mage_Core_Helper_Data')->__('Resource is not set.')); + } + + return $this->_resource ?: Mage::getResourceSingleton($this->_resourceName); + } + + /** + * Retrieve model resource name + * + * @return string + */ + public function getResourceName() + { + return ($this->_resource) ? get_class($this->_resource) : ($this->_resourceName ? $this->_resourceName : null); + } + + /** + * Get collection instance + * + * @return Mage_Core_Model_Resource_Db_Collection_Abstract + */ + public function getResourceCollection() + { + if (empty($this->_resourceCollection) && empty($this->_collectionName)) { + Mage::throwException( + Mage::helper('Mage_Core_Helper_Data')->__('Model collection resource name is not defined.') + ); + } + return $this->_resourceCollection ? + clone $this->_resourceCollection : + Mage::getResourceModel($this->_collectionName, array('resource' => $this->_getResource())); + } + + /** + * Retrieve collection instance + * + * @return Mage_Core_Model_Resource_Db_Collection_Abstract + */ + public function getCollection() + { + return $this->getResourceCollection(); + } + + /** + * Load object data + * + * @param integer $modelId + * @param null|string $field + * @return Mage_Core_Model_Abstract + */ + public function load($modelId, $field = null) + { + $this->_beforeLoad($modelId, $field); + $this->_getResource()->load($this, $modelId, $field); + $this->_afterLoad(); + $this->setOrigData(); + $this->_hasDataChanges = false; + return $this; + } + + /** + * Get array of objects transferred to default events processing + * + * @return array + */ + protected function _getEventData() + { + return array( + 'data_object' => $this, + $this->_eventObject => $this, + ); + } + + /** + * Processing object before load data + * + * @param int $modelId + * @param null|string $field + * @return Mage_Core_Model_Abstract + */ + protected function _beforeLoad($modelId, $field = null) + { + $params = array('object' => $this, 'field' => $field, 'value' => $modelId); + $this->_eventDispatcher->dispatch('model_load_before', $params); + $params = array_merge($params, $this->_getEventData()); + $this->_eventDispatcher->dispatch($this->_eventPrefix . '_load_before', $params); + return $this; + } + + /** + * Processing object after load data + * + * @return Mage_Core_Model_Abstract + */ + protected function _afterLoad() + { + $this->_eventDispatcher->dispatch('model_load_after', array('object' => $this)); + $this->_eventDispatcher->dispatch($this->_eventPrefix . '_load_after', $this->_getEventData()); + return $this; + } + + /** + * Object after load processing. Implemented as public interface for supporting objects after load in collections + * + * @return Mage_Core_Model_Abstract + */ + public function afterLoad() + { + $this->getResource()->afterLoad($this); + $this->_afterLoad(); + return $this; + } + + /** + * Check whether model has changed data. + * Can be overloaded in child classes to perform advanced check whether model needs to be saved + * e.g. usign resouceModel->hasDataChanged() or any other technique + * + * @return boolean + */ + protected function _hasModelChanged() + { + return $this->hasDataChanges(); + } + + /** + * Save object data + * + * @return Mage_Core_Model_Abstract + * @throws Exception + */ + public function save() + { + /** + * Direct deleted items to delete method + */ + if ($this->isDeleted()) { + return $this->delete(); + } + if (!$this->_hasModelChanged()) { + return $this; + } + $this->_getResource()->beginTransaction(); + try { + $this->_validateBeforeSave(); + $this->_beforeSave(); + if ($this->_dataSaveAllowed) { + $this->_getResource()->save($this); + $this->_afterSave(); + } + $this->_getResource()->addCommitCallback(array($this, 'afterCommitCallback')) + ->commit(); + $this->_hasDataChanges = false; + } catch (Exception $e) { + $this->_getResource()->rollBack(); + $this->_hasDataChanges = true; + throw $e; + } + return $this; + } + + /** + * Callback function which called after transaction commit in resource model + * + * @return Mage_Core_Model_Abstract + */ + public function afterCommitCallback() + { + $this->_eventDispatcher->dispatch('model_save_commit_after', array('object' => $this)); + $this->_eventDispatcher->dispatch($this->_eventPrefix . '_save_commit_after', $this->_getEventData()); + return $this; + } + + /** + * Check object state (true - if it is object without id on object just created) + * This method can help detect if object just created in _afterSave method + * problem is what in after save object has id and we can't detect what object was + * created in this transaction + * + * @param bool|null $flag + * @return bool + */ + public function isObjectNew($flag = null) + { + if ($flag !== null) { + $this->_isObjectNew = $flag; + } + if ($this->_isObjectNew !== null) { + return $this->_isObjectNew; + } + return !(bool)$this->getId(); + } + + /** + * Processing object before save data + * + * @return Mage_Core_Model_Abstract + */ + protected function _beforeSave() + { + if (!$this->getId()) { + $this->isObjectNew(true); + } + $this->_eventDispatcher->dispatch('model_save_before', array('object' => $this)); + $this->_eventDispatcher->dispatch($this->_eventPrefix . '_save_before', $this->_getEventData()); + return $this; + } + + /** + * Validate model before saving it + * + * @return Mage_Core_Model_Abstract + * @throws Mage_Core_Exception + */ + protected function _validateBeforeSave() + { + $validator = $this->_getValidatorBeforeSave(); + if ($validator && !$validator->isValid($this)) { + $errors = $validator->getMessages(); + $exception = new Mage_Core_Exception(implode(PHP_EOL, $errors)); + foreach ($errors as $errorMessage) { + $exception->addMessage(new Mage_Core_Model_Message_Error($errorMessage)); + } + throw $exception; + } + return $this; + } + + /** + * Returns validator, which contains all rules to validate this model. + * Returns FALSE, if no validation rules exist. + * + * @return Zend_Validate_Interface|false + */ + protected function _getValidatorBeforeSave() + { + if ($this->_validatorBeforeSave === null) { + $this->_validatorBeforeSave = $this->_createValidatorBeforeSave(); + } + return $this->_validatorBeforeSave; + } + + /** + * Creates validator for the model with all validation rules in it. + * Returns FALSE, if no validation rules exist. + * + * @return Zend_Validate_Interface|bool + */ + protected function _createValidatorBeforeSave() + { + $modelRules = $this->_getValidationRulesBeforeSave(); + $resourceRules = $this->_getResource()->getValidationRulesBeforeSave(); + if (!$modelRules && !$resourceRules) { + return false; + } + + if ($modelRules && $resourceRules) { + $validator = new Zend_Validate(); + $validator->addValidator($modelRules); + $validator->addValidator($resourceRules); + } elseif ($modelRules) { + $validator = $modelRules; + } else { + $validator = $resourceRules; + } + + return $validator; + } + + /** + * Template method to return validate rules for the entity + * + * @return Zend_Validate_Interface|null + */ + protected function _getValidationRulesBeforeSave() + { + return null; + } + + /** + * Get list of cache tags applied to model object. + * Return false if cache tags are not supported by model + * + * @return array|bool + */ + public function getCacheTags() + { + $tags = false; + if ($this->_cacheTag) { + if ($this->_cacheTag === true) { + $tags = array(); + } else { + if (is_array($this->_cacheTag)) { + $tags = $this->_cacheTag; + } else { + $tags = array($this->_cacheTag); + } + $idTags = $this->getCacheIdTags(); + if ($idTags) { + $tags = array_merge($tags, $idTags); + } + } + } + return $tags; + } + + /** + * Get cache tags associated with object id + * + * @return array + */ + public function getCacheIdTags() + { + $tags = false; + if ($this->getId() && $this->_cacheTag) { + $tags = array(); + if (is_array($this->_cacheTag)) { + foreach ($this->_cacheTag as $_tag) { + $tags[] = $_tag . '_' . $this->getId(); + } + } else { + $tags[] = $this->_cacheTag . '_' . $this->getId(); + } + } + return $tags; + } + + /** + * Remove model object related cache + * + * @return Mage_Core_Model_Abstract + */ + public function cleanModelCache() + { + $tags = $this->getCacheTags(); + if ($tags !== false) { + $this->_cacheManager->clean($tags); + } + return $this; + } + + /** + * Processing object after save data + * + * @return Mage_Core_Model_Abstract + */ + protected function _afterSave() + { + $this->cleanModelCache(); + $this->_eventDispatcher->dispatch('model_save_after', array('object' => $this)); + $this->_eventDispatcher->dispatch($this->_eventPrefix . '_save_after', $this->_getEventData()); + return $this; + } + + /** + * Delete object from database + * + * @return Mage_Core_Model_Abstract + * @throws Exception + */ + public function delete() + { + $this->_getResource()->beginTransaction(); + try { + $this->_beforeDelete(); + $this->_getResource()->delete($this); + $this->_afterDelete(); + + $this->_getResource()->commit(); + $this->_afterDeleteCommit(); + } catch (Exception $e) { + $this->_getResource()->rollBack(); + throw $e; + } + return $this; + } + + /** + * Processing object before delete data + * + * @return Mage_Core_Model_Abstract + */ + protected function _beforeDelete() + { + $this->_eventDispatcher->dispatch('model_delete_before', array('object' => $this)); + $this->_eventDispatcher->dispatch($this->_eventPrefix . '_delete_before', $this->_getEventData()); + $this->cleanModelCache(); + return $this; + } + + /** + * Safeguard func that will check, if we are in admin area + * + * @throws Mage_Core_Exception + */ + protected function _protectFromNonAdmin() + { + if (Mage::registry('isSecureArea')) { + return; + } + if (!Mage::app()->getStore()->isAdmin()) { + Mage::throwException(Mage::helper('Mage_Core_Helper_Data') + ->__('Cannot complete this operation from non-admin area.')); + } + } + + /** + * Processing object after delete data + * + * @return Mage_Core_Model_Abstract + */ + protected function _afterDelete() + { + $this->_eventDispatcher->dispatch('model_delete_after', array('object' => $this)); + $this->_eventDispatcher->dispatch($this->_eventPrefix . '_delete_after', $this->_getEventData()); + return $this; + } + + /** + * Processing manipulation after main transaction commit + * + * @return Mage_Core_Model_Abstract + */ + protected function _afterDeleteCommit() + { + $this->_eventDispatcher->dispatch('model_delete_commit_after', array('object' => $this)); + $this->_eventDispatcher->dispatch($this->_eventPrefix . '_delete_commit_after', $this->_getEventData()); + return $this; + } + + /** + * Retrieve model resource + * + * @return Mage_Core_Model_Resource_Db_Abstract + */ + public function getResource() + { + return $this->_getResource(); + } + + /** + * Retreive entity id + * + * @return mixed + */ + public function getEntityId() + { + return $this->_getData('entity_id'); + } + + /** + * Clearing object for correct deleting by garbage collector + * + * @return Mage_Core_Model_Abstract + */ + final public function clearInstance() + { + $this->_clearReferences(); + $this->_eventDispatcher->dispatch($this->_eventPrefix . '_clear', $this->_getEventData()); + $this->_clearData(); + return $this; + } + + /** + * Clearing cyclic references + * + * @return Mage_Core_Model_Abstract + */ + protected function _clearReferences() + { + return $this; + } + + /** + * Clearing object's data + * + * @return Mage_Core_Model_Abstract + */ + protected function _clearData() + { + return $this; + } + +} diff --git a/app/code/Mage/Core/Model/Acl/Builder.php b/app/code/Mage/Core/Model/Acl/Builder.php new file mode 100644 index 0000000000000..0842638472896 --- /dev/null +++ b/app/code/Mage/Core/Model/Acl/Builder.php @@ -0,0 +1,80 @@ +_aclFactory = $aclFactory; + $this->_loaderPool = $loaderPool; + } + + /** + * Build Access Control List + * + * @param string areaCode + * @return Magento_Acl + * @throws LogicException + */ + public function getAcl($areaCode) + { + if (!isset($this->_aclPool[$areaCode])) { + try { + $this->_aclPool[$areaCode] = $this->_aclFactory->create(); + /** @var $loader Magento_Acl_Loader */ + foreach ($this->_loaderPool->getLoadersByArea($areaCode) as $loader) { + $loader->populateAcl($this->_aclPool[$areaCode]); + } + } catch (Exception $e) { + throw new LogicException('Could not create acl object: ' . $e->getMessage()); + } + } + return $this->_aclPool[$areaCode]; + } +} diff --git a/app/code/core/Mage/Core/Model/Acl/Config/ConfigInterface.php b/app/code/Mage/Core/Model/Acl/Config/ConfigInterface.php similarity index 100% rename from app/code/core/Mage/Core/Model/Acl/Config/ConfigInterface.php rename to app/code/Mage/Core/Model/Acl/Config/ConfigInterface.php diff --git a/app/code/core/Mage/Core/Model/Acl/Loader/Resource/ResourceAbstract.php b/app/code/Mage/Core/Model/Acl/Loader/Resource/ResourceAbstract.php similarity index 100% rename from app/code/core/Mage/Core/Model/Acl/Loader/Resource/ResourceAbstract.php rename to app/code/Mage/Core/Model/Acl/Loader/Resource/ResourceAbstract.php diff --git a/app/code/Mage/Core/Model/Acl/LoaderPool.php b/app/code/Mage/Core/Model/Acl/LoaderPool.php new file mode 100644 index 0000000000000..4c345de8b2271 --- /dev/null +++ b/app/code/Mage/Core/Model/Acl/LoaderPool.php @@ -0,0 +1,82 @@ +_config = $config; + $this->_objectManager = $objectManager; + } + + /** + * Retrieve ACL loader class from config or NullLoader if not defined + * + * @param string $areaCode + * @param string $loaderType + * @return string + * @throws LogicException + */ + protected function _getLoaderClass($areaCode, $loaderType) + { + $areaConfig = $this->_config->getAreaConfig($areaCode); + if (!isset($areaConfig['acl'])) { + throw new LogicException('No acl configuration is specified'); + } + + return (string) (isset($areaConfig['acl'][$loaderType . 'Loader']) + ? $areaConfig['acl'][$loaderType . 'Loader'] + : 'Magento_Acl_Loader_Default'); + } + + /** + * Retrieve acl loaders by area + * + * @param string $areaCode + * @return ArrayIterator|Traversable + */ + public function getLoadersByArea($areaCode) + { + return new ArrayIterator(array( + $this->_objectManager->get($this->_getLoaderClass($areaCode, 'resource')), + $this->_objectManager->get($this->_getLoaderClass($areaCode, 'role')), + $this->_objectManager->get($this->_getLoaderClass($areaCode, 'rule')), + )); + } +} diff --git a/app/code/core/Mage/Core/Model/App.php b/app/code/Mage/Core/Model/App.php similarity index 97% rename from app/code/core/Mage/Core/Model/App.php rename to app/code/Mage/Core/Model/App.php index 0ca4989bed04b..754164fe70fe0 100644 --- a/app/code/core/Mage/Core/Model/App.php +++ b/app/code/Mage/Core/Model/App.php @@ -73,7 +73,7 @@ class Mage_Core_Model_App implements Mage_Core_Model_AppInterface /** * Cache object * - * @var Mage_Core_Model_Cache + * @var Mage_Core_Model_CacheInterface */ protected $_cache; @@ -122,7 +122,7 @@ class Mage_Core_Model_App implements Mage_Core_Model_AppInterface /** * Store list manager - * + * * @var Mage_Core_Model_StoreManager */ protected $_storeManager; @@ -140,7 +140,7 @@ class Mage_Core_Model_App implements Mage_Core_Model_AppInterface /** * @param Mage_Core_Model_Config $config * @param Mage_Core_Controller_Varien_Front $frontController - * @param Mage_Core_Model_Cache $cache + * @param Mage_Core_Model_CacheInterface $cache * @param Magento_ObjectManager $objectManager * @param Mage_Core_Model_Db_UpdaterInterface $dbUpdater * @param Mage_Core_Model_StoreManager $storeManager @@ -150,7 +150,7 @@ class Mage_Core_Model_App implements Mage_Core_Model_AppInterface public function __construct( Mage_Core_Model_Config $config, Mage_Core_Controller_Varien_Front $frontController, - Mage_Core_Model_Cache $cache, + Mage_Core_Model_CacheInterface $cache, Magento_ObjectManager $objectManager, Mage_Core_Model_Db_UpdaterInterface $dbUpdater, Mage_Core_Model_StoreManager $storeManager, @@ -263,7 +263,7 @@ protected function _getFrontControllerByCurrentArea() } } } - return $this->_objectManager->create($frontControllerClass); + return $this->_objectManager->get($frontControllerClass); } /** @@ -396,7 +396,7 @@ public function getFrontController() /** * Get core cache model * - * @return Mage_Core_Model_Cache + * @return Mage_Core_Model_CacheInterface */ public function getCacheInstance() { @@ -406,7 +406,7 @@ public function getCacheInstance() /** * Retrieve cache object * - * @return Zend_Cache_Core + * @return Magento_Cache_FrontendInterface */ public function getCache() { @@ -469,24 +469,13 @@ public function cleanCache($tags = array()) * * @param null|string $type * @return boolean + * @deprecated deprecated after 2.0.0.0-dev42 in favour of Mage_Core_Model_Cache_Types::isEnabled() */ public function useCache($type = null) { return $this->_cache->canUse($type); } - /** - * Save cache usage settings - * - * @param array $data - * @return Mage_Core_Model_App - */ - public function saveUseCache($data) - { - $this->_cache->saveOptions($data); - return $this; - } - /** * Deletes all session files * @@ -600,12 +589,12 @@ public function getUseSessionInUrl() /** * Check if developer mode is enabled - * + * * @return bool */ public function isDeveloperMode() { - return $this->_appState->isDeveloperMode(); + return $this->_appState->getMode() == Mage_Core_Model_App_State::MODE_DEVELOPER; } /** diff --git a/app/code/core/Mage/Core/Model/App/Area.php b/app/code/Mage/Core/Model/App/Area.php similarity index 98% rename from app/code/core/Mage/Core/Model/App/Area.php rename to app/code/Mage/Core/Model/App/Area.php index 8c5fc44420687..df0c0419d65cf 100644 --- a/app/code/core/Mage/Core/Model/App/Area.php +++ b/app/code/Mage/Core/Model/App/Area.php @@ -226,7 +226,7 @@ protected function _initConfig() $configurationNode = $this->_config->getNode($this->_code . '/di'); if ($configurationNode) { $configuration = $configurationNode->asArray(); - $this->_objectManager->setConfiguration($configuration); + $this->_objectManager->configure($configuration); } } diff --git a/app/code/core/Mage/Core/Model/App/Emulation.php b/app/code/Mage/Core/Model/App/Emulation.php similarity index 100% rename from app/code/core/Mage/Core/Model/App/Emulation.php rename to app/code/Mage/Core/Model/App/Emulation.php diff --git a/app/code/core/Mage/Core/Model/App/Handler.php b/app/code/Mage/Core/Model/App/Handler.php similarity index 100% rename from app/code/core/Mage/Core/Model/App/Handler.php rename to app/code/Mage/Core/Model/App/Handler.php diff --git a/app/code/Mage/Core/Model/App/Proxy.php b/app/code/Mage/Core/Model/App/Proxy.php new file mode 100644 index 0000000000000..23a25c25e5051 --- /dev/null +++ b/app/code/Mage/Core/Model/App/Proxy.php @@ -0,0 +1,570 @@ +_objectManager = $objectManager; + } + + /** + * Get application model + * + * @return Mage_Core_Model_App + */ + protected function _getApp() + { + if (null === $this->_app) { + $this->_app = $this->_objectManager->get('Mage_Core_Model_App'); + } + + return $this->_app; + } + + /** + * Run application. Run process responsible for request processing and sending response. + * + * @return Mage_Core_Model_AppInterface + */ + public function run() + { + return $this->_getApp()->run(); + } + + /** + * Throw an exception, if the application has not been installed yet + * + * @throws Magento_Exception + */ + public function requireInstalledInstance() + { + $this->_getApp()->requireInstalledInstance(); + } + + /** + * Retrieve cookie object + * + * @return Mage_Core_Model_Cookie + */ + public function getCookie() + { + return $this->_getApp()->getCookie(); + } + + /** + * Reinitialize stores + * + * @return void + */ + public function reinitStores() + { + $this->_getApp()->reinitStores(); + } + + /** + * Check if system is run in the single store mode + * + * @return bool + */ + public function isSingleStoreMode() + { + return $this->_getApp()->isSingleStoreMode(); + } + + /** + * Check if store has only one store view + * + * @return bool + */ + public function hasSingleStore() + { + return $this->_getApp()->hasSingleStore(); + } + + /** + * Set current default store + * + * @param string $store + */ + public function setCurrentStore($store) + { + $this->_getApp()->setCurrentStore($store); + } + + /** + * Get current store code + * + * @return string + */ + public function getCurrentStore() + { + return $this->_getApp()->getCurrentStore(); + } + + /** + * Re-declare custom error handler + * + * @param string $handler + * @return Mage_Core_Model_AppInterface + */ + public function setErrorHandler($handler) + { + return $this->_getApp()->setErrorHandler($handler); + } + + /** + * Loading application area + * + * @param string $code + * @return Mage_Core_Model_AppInterface + */ + public function loadArea($code) + { + return $this->_getApp()->loadArea($code); + } + + /** + * Loading part of area data + * + * @param string $area + * @param string $part + * @return Mage_Core_Model_AppInterface + */ + public function loadAreaPart($area, $part) + { + return $this->_getApp()->loadAreaPart($area, $part); + } + + /** + * Retrieve application area + * + * @param string $code + * @return Mage_Core_Model_App_Area + */ + public function getArea($code) + { + return $this->_getApp()->getArea($code); + } + + /** + * Retrieve application store object + * + * @param null|string|bool|int|Mage_Core_Model_Store $id + * @return Mage_Core_Model_Store + * @throws Mage_Core_Model_Store_Exception + */ + public function getStore($id = null) + { + return $this->_getApp()->getStore($id); + } + + /** + * Retrieve application store object without Store_Exception + * + * @param string|int|Mage_Core_Model_Store $id + * @return Mage_Core_Model_Store + */ + public function getSafeStore($id = null) + { + return $this->_getApp()->getSafeStore($id); + } + + /** + * Retrieve stores array + * + * @param bool $withDefault + * @param bool $codeKey + * @return array + */ + public function getStores($withDefault = false, $codeKey = false) + { + return $this->_getApp()->getStores($withDefault, $codeKey); + } + + /** + * Retrieve default store for default group and website + * + * @return Mage_Core_Model_Store + */ + public function getDefaultStoreView() + { + return $this->_getApp()->getDefaultStoreView(); + } + + /** + * Get distributive locale code + * + * @return string + */ + public function getDistroLocaleCode() + { + return $this->_getApp()->getDistroLocaleCode(); + } + + /** + * Retrieve application website object + * + * @param null|bool|int|string|Mage_Core_Model_Website $id + * @return Mage_Core_Model_Website + * @throws Mage_Core_Exception + */ + public function getWebsite($id = null) + { + return $this->_getApp()->getWebsite($id); + } + + /** + * Get websites + * + * @param bool $withDefault + * @param bool $codeKey + * @return array + */ + public function getWebsites($withDefault = false, $codeKey = false) + { + return $this->_getApp()->getWebsites($withDefault, $codeKey); + } + + /** + * Retrieve application store group object + * + * @param null|Mage_Core_Model_Store_Group|string $id + * @return Mage_Core_Model_Store_Group + * @throws Mage_Core_Exception + */ + public function getGroup($id = null) + { + return $this->_getApp()->getGroup($id); + } + + /** + * Retrieve application locale object + * + * @return Mage_Core_Model_Locale + */ + public function getLocale() + { + return $this->_getApp()->getLocale(); + } + + /** + * Retrieve layout object + * + * @return Mage_Core_Model_Layout + */ + public function getLayout() + { + return $this->_getApp()->getLayout(); + } + + /** + * Retrieve helper object + * + * @param string $name + * @return Mage_Core_Helper_Abstract + */ + public function getHelper($name) + { + return $this->_getApp()->getHelper($name); + } + + /** + * Retrieve application base currency code + * + * @return string + */ + public function getBaseCurrencyCode() + { + return $this->_getApp()->getBaseCurrencyCode(); + } + + /** + * Retrieve configuration object + * + * @return Mage_Core_Model_Config + */ + public function getConfig() + { + return $this->_getApp()->getConfig(); + } + + /** + * Retrieve front controller object + * + * @return Mage_Core_Controller_Varien_Front + */ + public function getFrontController() + { + return $this->_getApp()->getFrontController(); + } + + /** + * Get core cache model + * + * @return Mage_Core_Model_CacheInterface + */ + public function getCacheInstance() + { + return $this->_getApp()->getCacheInstance(); + } + + /** + * Retrieve cache object + * + * @return Zend_Cache_Core + */ + public function getCache() + { + return $this->_getApp()->getCache(); + } + + /** + * Loading cache data + * + * @param string $id + * @return mixed + */ + public function loadCache($id) + { + return $this->_getApp()->loadCache($id); + } + + /** + * Saving cache data + * + * @param mixed $data + * @param string $id + * @param array $tags + * @param bool $lifeTime + * @return Mage_Core_Model_AppInterface + */ + public function saveCache($data, $id, $tags = array(), $lifeTime = false) + { + return $this->_getApp()->saveCache($data, $id, $tags, $lifeTime); + } + + /** + * Remove cache + * + * @param string $id + * @return Mage_Core_Model_AppInterface + */ + public function removeCache($id) + { + return $this->_getApp()->removeCache($id); + } + + /** + * Cleaning cache + * + * @param array $tags + * @return Mage_Core_Model_AppInterface + */ + public function cleanCache($tags = array()) + { + return $this->_getApp()->cleanCache($tags); + } + + /** + * Check whether to use cache for specific component + * + * @param null|string $type + * @return boolean + */ + public function useCache($type = null) + { + return $this->_getApp()->useCache($type); + } + + /** + * Deletes all session files + * + * @return Mage_Core_Model_AppInterface + */ + public function cleanAllSessions() + { + return $this->_getApp()->cleanAllSessions(); + } + + /** + * Retrieve request object + * + * @return Mage_Core_Controller_Request_Http + */ + public function getRequest() + { + return $this->_getApp()->getRequest(); + } + + /** + * Request setter + * + * @param Mage_Core_Controller_Request_Http $request + * @return Mage_Core_Model_AppInterface + */ + public function setRequest(Mage_Core_Controller_Request_Http $request) + { + return $this->_getApp()->setRequest($request); + } + + /** + * Retrieve response object + * + * @return Zend_Controller_Response_Http + */ + public function getResponse() + { + return $this->_getApp()->getResponse(); + } + + /** + * Response setter + * + * @param Mage_Core_Controller_Response_Http $response + * @return Mage_Core_Model_AppInterface + */ + public function setResponse(Mage_Core_Controller_Response_Http $response) + { + return $this->_getApp()->setResponse($response); + } + + /** + * @throws Mage_Core_Model_Store_Exception + */ + public function throwStoreException() + { + $this->_getApp()->throwStoreException(); + } + + /** + * Set use session var instead of SID for URL + * + * @param bool $var + * @return Mage_Core_Model_AppInterface + */ + public function setUseSessionVar($var) + { + return $this->_getApp()->setUseSessionVar($var); + } + + /** + * Retrieve use flag session var instead of SID for URL + * + * @return bool + */ + public function getUseSessionVar() + { + return $this->_getApp()->getUseSessionVar(); + } + + /** + * Get either default or any store view + * + * @return Mage_Core_Model_Store + */ + public function getAnyStoreView() + { + return $this->_getApp()->getAnyStoreView(); + } + + /** + * Set Use session in URL flag + * + * @param bool $flag + * @return Mage_Core_Model_AppInterface + */ + public function setUseSessionInUrl($flag = true) + { + return $this->_getApp()->setUseSessionInUrl($flag); + } + + /** + * Retrieve use session in URL flag + * + * @return bool + */ + public function getUseSessionInUrl() + { + return $this->_getApp()->getUseSessionInUrl(); + } + + /** + * Allow or disallow single store mode + * + * @param bool $value + */ + public function setIsSingleStoreModeAllowed($value) + { + $this->_getApp()->setIsSingleStoreModeAllowed($value); + } + + /** + * Prepare array of store groups + * can be filtered to contain default store group or not by $withDefault flag + * depending on flag $codeKey array keys can be group id or group code + * + * @param bool $withDefault + * @param bool $codeKey + * @return array + */ + public function getGroups($withDefault = false, $codeKey = false) + { + return $this->_getApp()->getGroups($withDefault, $codeKey); + } + + /** + * Unset website by id from app cache + * + * @param null|bool|int|string|Mage_Core_Model_Website $id + */ + public function clearWebsiteCache($id = null) + { + $this->_getApp()->clearWebsiteCache($id); + } + + /** + * Check if developer mode is enabled. + * + * @return bool + */ + public function isDeveloperMode() + { + return $this->_getApp()->isDeveloperMode(); + } +} diff --git a/app/code/Mage/Core/Model/App/State.php b/app/code/Mage/Core/Model/App/State.php new file mode 100644 index 0000000000000..88d6799834554 --- /dev/null +++ b/app/code/Mage/Core/Model/App/State.php @@ -0,0 +1,130 @@ +_appMode = $mode; + break; + default: + throw new Mage_Core_Exception("Unknown application mode: {$mode}"); + } + } + + /** + * Check if application is installed + * + * @return bool + */ + public function isInstalled() + { + return Mage::isInstalled(); + } + + /** + * Return current app mode + * + * @return string + */ + public function getMode() + { + return $this->_appMode; + } + + /** + * Set update mode flag + * + * @param bool $value + */ + public function setUpdateMode($value) + { + Mage::setUpdateMode($value); + } + + /** + * Get update mode flag + * + * @return bool + */ + public function getUpdateMode() + { + return Mage::getUpdateMode(); + } + + /** + * Set is downloader flag + * + * @param bool $flag + */ + public function setIsDownloader($flag = true) + { + Mage::setIsDownloader($flag); + } + + /** + * Set is serializable flag + * + * @param bool $value + */ + public function setIsSerializable($value = true) + { + Mage::setIsSerializable($value); + } + + /** + * Get is serializable flag + * + * @return bool + */ + public function getIsSerializable() + { + return Mage::getIsSerializable(); + } +} diff --git a/app/code/core/Mage/Core/Model/AppInterface.php b/app/code/Mage/Core/Model/AppInterface.php similarity index 96% rename from app/code/core/Mage/Core/Model/AppInterface.php rename to app/code/Mage/Core/Model/AppInterface.php index 44dfe562d4e34..e4ef06fa43568 100644 --- a/app/code/core/Mage/Core/Model/AppInterface.php +++ b/app/code/Mage/Core/Model/AppInterface.php @@ -166,7 +166,7 @@ public function getFrontController(); /** * Get core cache model * - * @return Mage_Core_Model_Cache + * @return Mage_Core_Model_CacheInterface */ public function getCacheInstance(); @@ -221,14 +221,6 @@ public function cleanCache($tags = array()); */ public function useCache($type = null); - /** - * Save cache usage settings - * - * @param array $data - * @return Mage_Core_Model_AppInterface - */ - public function saveUseCache($data); - /** * Deletes all session files * diff --git a/app/code/core/Mage/Core/Model/Authorization.php b/app/code/Mage/Core/Model/Authorization.php similarity index 96% rename from app/code/core/Mage/Core/Model/Authorization.php rename to app/code/Mage/Core/Model/Authorization.php index bb07f8a62c00b..e065700876494 100644 --- a/app/code/core/Mage/Core/Model/Authorization.php +++ b/app/code/Mage/Core/Model/Authorization.php @@ -66,12 +66,10 @@ protected function _getAclPolicy() 'Magento_Authorization_Policy_Default'; /** @var $aclBuilder Mage_Core_Model_Acl_Builder */ - $aclBuilder = Mage::getSingleton('Mage_Core_Model_Acl_Builder', array( - 'data' => array('areaConfig' => Mage::getConfig()->getAreaConfig(), 'objectFactory' => Mage::getConfig()) - )); + $aclBuilder = Mage::getSingleton('Mage_Core_Model_Acl_Builder'); /** @var $policyObject Magento_Authorization_Policy **/ - $policyObject = new $policyClassName($aclBuilder->getAcl()); + $policyObject = new $policyClassName($aclBuilder->getAcl(Mage::getConfig()->getCurrentAreaCode())); if (false == ($policyObject instanceof Magento_Authorization_Policy)) { throw new InvalidArgumentException($policyClassName . ' is not instance of Magento_Authorization_Policy'); } diff --git a/app/code/core/Mage/Core/Model/BlockFactory.php b/app/code/Mage/Core/Model/BlockFactory.php similarity index 99% rename from app/code/core/Mage/Core/Model/BlockFactory.php rename to app/code/Mage/Core/Model/BlockFactory.php index 0326ee82d8b25..d2616020c5cd7 100644 --- a/app/code/core/Mage/Core/Model/BlockFactory.php +++ b/app/code/Mage/Core/Model/BlockFactory.php @@ -46,6 +46,6 @@ public function __construct(Magento_ObjectManager $objectManager) */ public function createBlock($blockName, array $arguments = array()) { - return $this->_objectManager->create($blockName, $arguments, false); + return $this->_objectManager->create($blockName, $arguments); } } diff --git a/app/code/Mage/Core/Model/Cache.php b/app/code/Mage/Core/Model/Cache.php new file mode 100644 index 0000000000000..add13325a66f8 --- /dev/null +++ b/app/code/Mage/Core/Model/Cache.php @@ -0,0 +1,340 @@ +_objectManager = $objectManager; + $this->_frontendPool = $frontendPool; + $this->_frontend = $frontendPool->get($this->_frontendIdentifier); + $this->_cacheTypes = $cacheTypes; + $this->_config = $config; + $this->_helperFactory = $helperFactory; + } + + /** + * Get cache frontend API object + * + * @return Magento_Cache_FrontendInterface + */ + public function getFrontend() + { + return $this->_frontend; + } + + /** + * Load data from cache by id + * + * @param string $identifier + * @return string + */ + public function load($identifier) + { + return $this->_frontend->load($identifier); + } + + /** + * Save data + * + * @param string $data + * @param string $identifier + * @param array $tags + * @param int $lifeTime + * @return bool + */ + public function save($data, $identifier, $tags=array(), $lifeTime=null) + { + return $this->_frontend->save((string)$data, $identifier, $tags, $lifeTime); + } + + /** + * Remove cached data by identifier + * + * @param string $identifier + * @return bool + */ + public function remove($identifier) + { + return $this->_frontend->remove($identifier); + } + + /** + * Clean cached data by specific tag + * + * @param array $tags + * @return bool + */ + public function clean($tags = array()) + { + if ($tags) { + $result = $this->_frontend->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, (array)$tags); + } else { + /** @deprecated special case of cleaning by empty tags is deprecated after 2.0.0.0-dev42 */ + $result = false; + $markerCacheTag = Mage_Core_Model_AppInterface::CACHE_TAG; + /** @var $cacheFrontend Magento_Cache_FrontendInterface */ + foreach ($this->_frontendPool as $cacheFrontend) { + if ($cacheFrontend->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array($markerCacheTag))) { + $result = true; + } + } + } + return $result; + } + + /** + * Check if cache can be used for specific data type + * + * @param string $typeCode + * @return bool + * @deprecated deprecated after 2.0.0.0-dev42 in favour of Mage_Core_Model_Cache_Types::isEnabled() + */ + public function canUse($typeCode) + { + return $this->_cacheTypes->isEnabled($typeCode); + } + + /** + * Disable cache usage for specific data type + * + * @param string $typeCode + * @return Mage_Core_Model_CacheInterface + * @deprecated deprecated after 2.0.0.0-dev42 in favour of Mage_Core_Model_Cache_Types::setEnabled() + */ + public function banUse($typeCode) + { + $this->_cacheTypes->setEnabled($typeCode, false); + return $this; + } + + /** + * Enable cache usage for specific data type + * + * @param string $typeCode + * @return Mage_Core_Model_CacheInterface + * @deprecated deprecated after 2.0.0.0-dev42 in favour of Mage_Core_Model_Cache_Types::setEnabled() + */ + public function allowUse($typeCode) + { + $this->_cacheTypes->setEnabled($typeCode, true); + return $this; + } + + /** + * Get cache class by cache type from configuration + * + * @param string $type + * @return Magento_Cache_FrontendInterface + * @throws UnexpectedValueException + */ + protected function _getTypeInstance($type) + { + $path = self::XML_PATH_TYPES . '/' . $type . '/class'; + $class = $this->_config->getNode($path); + if (!$class) { + return null; + } + $class = (string)$class; + $instance = $this->_objectManager->get($class); + if (!($instance instanceof Magento_Cache_FrontendInterface)) { + throw new UnexpectedValueException("Cache type class '$class' has to be a cache frontend."); + } + return $instance; + } + + /** + * Get information about all declared cache types + * + * @return array + */ + public function getTypes() + { + $types = array(); + $config = $this->_config->getNode(self::XML_PATH_TYPES); + if ($config) { + /** @var $helper Mage_Core_Helper_Data*/ + $helper = $this->_helperFactory->get('Mage_Core_Helper_Data'); + foreach ($config->children() as $type => $node) { + $typeInstance = $this->_getTypeInstance($type); + if ($typeInstance instanceof Magento_Cache_Frontend_Decorator_TagMarker) { + $typeTags = $typeInstance->getTag(); + } else { + $typeTags = ''; + } + $types[$type] = new Varien_Object(array( + 'id' => $type, + 'cache_type' => $helper->__((string)$node->label), + 'description' => $helper->__((string)$node->description), + 'tags' => $typeTags, + 'status' => (int)$this->canUse($type), + )); + } + } + return $types; + } + + /** + * Get invalidate types codes + * + * @return array + */ + protected function _getInvalidatedTypes() + { + $types = $this->load(self::INVALIDATED_TYPES); + if ($types) { + $types = unserialize($types); + } else { + $types = array(); + } + return $types; + } + + /** + * Save invalidated cache types + * + * @param array $types + * @return Mage_Core_Model_Cache + */ + protected function _saveInvalidatedTypes($types) + { + $this->save(serialize($types), self::INVALIDATED_TYPES); + return $this; + } + + /** + * Get array of all invalidated cache types + * + * @return array + */ + public function getInvalidatedTypes() + { + $invalidatedTypes = array(); + $types = $this->_getInvalidatedTypes(); + if ($types) { + $allTypes = $this->getTypes(); + foreach ($types as $type => $flag) { + if (isset($allTypes[$type]) && $this->canUse($type)) { + $invalidatedTypes[$type] = $allTypes[$type]; + } + } + } + return $invalidatedTypes; + } + + /** + * Mark specific cache type(s) as invalidated + * + * @param string|array $typeCode + * @return Mage_Core_Model_CacheInterface + */ + public function invalidateType($typeCode) + { + $types = $this->_getInvalidatedTypes(); + if (!is_array($typeCode)) { + $typeCode = array($typeCode); + } + foreach ($typeCode as $code) { + $types[$code] = 1; + } + $this->_saveInvalidatedTypes($types); + return $this; + } + + /** + * Clean cached data for specific cache type + * + * @param string $typeCode + * @return Mage_Core_Model_CacheInterface + */ + public function cleanType($typeCode) + { + $this->_getTypeInstance($typeCode)->clean(); + $types = $this->_getInvalidatedTypes(); + unset($types[$typeCode]); + $this->_saveInvalidatedTypes($types); + return $this; + } +} diff --git a/app/code/Mage/Core/Model/Cache/Frontend/Factory.php b/app/code/Mage/Core/Model/Cache/Frontend/Factory.php new file mode 100644 index 0000000000000..d4d2da1e2f022 --- /dev/null +++ b/app/code/Mage/Core/Model/Cache/Frontend/Factory.php @@ -0,0 +1,380 @@ + '', 'arguments' => array()), + * ... + * ) + * + * @var array + */ + private $_decorators = array(); + + /** + * Default cache backend type + * + * @var string + */ + protected $_defaultBackend = 'File'; + + /** + * Options for default backend + * + * @var array + */ + protected $_backendOptions = array( + 'hashed_directory_level' => 1, + 'hashed_directory_umask' => 0777, + 'file_name_prefix' => 'mage', + ); + + /** + * @param Magento_ObjectManager $objectManager + * @param Magento_Filesystem $filesystem + * @param Mage_Core_Model_Dir $dirs + * @param array $enforcedOptions + * @param array $decorators + */ + public function __construct( + Magento_ObjectManager $objectManager, + Magento_Filesystem $filesystem, + Mage_Core_Model_Dir $dirs, + array $enforcedOptions = array(), + array $decorators = array() + ) { + $this->_objectManager = $objectManager; + $this->_filesystem = $filesystem; + $this->_dirs = $dirs; + $this->_enforcedOptions = $enforcedOptions; + $this->_decorators = $decorators; + } + + /** + * Return newly created cache frontend instance + * + * @param array $options + * @return Magento_Cache_FrontendInterface + */ + public function create(array $options) + { + $options = $this->_getExpandedOptions($options); + + foreach (array('backend_options', 'slow_backend_options') as $section) { + if (!empty($options[$section]['cache_dir'])) { + $dir = $this->_dirs->getDir(Mage_Core_Model_Dir::VAR_DIR) . DS . $options[$section]['cache_dir']; + $this->_filesystem->setIsAllowCreateDirectories(true); + $this->_filesystem->ensureDirectoryExists($dir, 0777); + $options[$section]['cache_dir'] = $dir; + } + } + + $this->_backendOptions['cache_dir'] = $this->_dirs->getDir(Mage_Core_Model_Dir::CACHE); + + $idPrefix = isset($options['id_prefix']) ? $options['id_prefix'] : ''; + if (!$idPrefix && isset($options['prefix'])) { + $idPrefix = $options['prefix']; + } + if (empty($idPrefix)) { + $idPrefix = substr(md5($this->_dirs->getDir(Mage_Core_Model_Dir::CONFIG)), 0, 3) . '_'; + } + $options['frontend_options']['cache_id_prefix'] = $idPrefix; + + $backend = $this->_getBackendOptions($options); + $frontend = $this->_getFrontendOptions($options); + + // Start profiling + $profilerTags = array( + 'group' => 'cache', + 'operation' => 'cache:create', + 'frontend_type' => $frontend['type'], + 'backend_type' => $backend['type'], + ); + Magento_Profiler::start('cache_frontend_create', $profilerTags); + + /** @var $result Magento_Cache_Frontend_Adapter_Zend */ + $result = $this->_objectManager->create('Magento_Cache_Frontend_Adapter_Zend', array( + 'frontend' => Zend_Cache::factory( + $frontend['type'], $backend['type'], $frontend, $backend['options'], true, true, true + ), + )); + $result = $this->_applyDecorators($result); + + // stop profiling + Magento_Profiler::stop('cache_frontend_create'); + return $result; + } + + /** + * Return options expanded with enforced values + * + * @param array $options + * @return array + */ + private function _getExpandedOptions(array $options) + { + return array_replace_recursive($options, $this->_enforcedOptions); + } + + /** + * Apply decorators to a cache frontend instance and return the topmost one + * + * @param Magento_Cache_FrontendInterface $frontend + * @return Magento_Cache_FrontendInterface + * @throws LogicException + * @throws UnexpectedValueException + */ + private function _applyDecorators(Magento_Cache_FrontendInterface $frontend) + { + foreach ($this->_decorators as $decoratorConfig) { + if (!isset($decoratorConfig['class'])) { + throw new LogicException('Class has to be specified for a cache frontend decorator.'); + } + $decoratorClass = $decoratorConfig['class']; + $decoratorParams = isset($decoratorConfig['parameters']) ? $decoratorConfig['parameters'] : array(); + $decoratorParams[0] = $frontend; // conventionally, first argument is a decoration subject + $frontend = $this->_objectManager->create($decoratorClass, $decoratorParams); + if (!($frontend instanceof Magento_Cache_FrontendInterface)) { + throw new UnexpectedValueException('Decorator has to implement the cache frontend interface.'); + } + } + return $frontend; + } + + /** + * Get cache backend options. Result array contain backend type ('type' key) and backend options ('options') + * + * @param array $cacheOptions + * @return array + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) + */ + protected function _getBackendOptions(array $cacheOptions) + { + $enableTwoLevels = false; + $type = isset($cacheOptions['backend']) ? $cacheOptions['backend'] : $this->_defaultBackend; + if (isset($cacheOptions['backend_options']) && is_array($cacheOptions['backend_options'])) { + $options = $cacheOptions['backend_options']; + } else { + $options = array(); + } + + $backendType = false; + switch (strtolower($type)) { + case 'sqlite': + if (extension_loaded('sqlite') && isset($options['cache_db_complete_path'])) { + $backendType = 'Sqlite'; + } + break; + case 'memcached': + if (extension_loaded('memcached')) { + if (isset($cacheOptions['memcached'])) { + $options = $cacheOptions['memcached']; + } + $enableTwoLevels = true; + $backendType = 'Libmemcached'; + } elseif (extension_loaded('memcache')) { + if (isset($cacheOptions['memcached'])) { + $options = $cacheOptions['memcached']; + } + $enableTwoLevels = true; + $backendType = 'Memcached'; + } + break; + case 'apc': + if (extension_loaded('apc') && ini_get('apc.enabled')) { + $enableTwoLevels = true; + $backendType = 'Apc'; + } + break; + case 'xcache': + if (extension_loaded('xcache')) { + $enableTwoLevels = true; + $backendType = 'Xcache'; + } + break; + case 'eaccelerator': + case 'varien_cache_backend_eaccelerator': + if (extension_loaded('eaccelerator') && ini_get('eaccelerator.enable')) { + $enableTwoLevels = true; + $backendType = 'Varien_Cache_Backend_Eaccelerator'; + } + break; + case 'database': + $backendType = 'Varien_Cache_Backend_Database'; + $options = $this->_getDbAdapterOptions(); + break; + default: + if ($type != $this->_defaultBackend) { + try { + if (class_exists($type, true)) { + $implements = class_implements($type, true); + if (in_array('Zend_Cache_Backend_Interface', $implements)) { + $backendType = $type; + } + } + } catch (Exception $e) { + } + } + } + + if (!$backendType) { + $backendType = $this->_defaultBackend; + foreach ($this->_backendOptions as $option => $value) { + if (!array_key_exists($option, $options)) { + $options[$option] = $value; + } + } + } + + $backendOptions = array('type' => $backendType, 'options' => $options); + if ($enableTwoLevels) { + $backendOptions = $this->_getTwoLevelsBackendOptions($backendOptions, $cacheOptions); + } + return $backendOptions; + } + + /** + * Get options for database backend type + * + * @return array + */ + protected function _getDbAdapterOptions() + { + $options['adapter_callback'] = function () { + return Mage::getSingleton('Mage_Core_Model_Resource')->getConnection('core_write'); + }; + $options['data_table'] = Mage::getSingleton('Mage_Core_Model_Resource')->getTableName('core_cache'); + $options['tags_table'] = Mage::getSingleton('Mage_Core_Model_Resource')->getTableName('core_cache_tag'); + return $options; + } + + /** + * Initialize two levels backend model options + * + * @param array $fastOptions fast level backend type and options + * @param array $cacheOptions all cache options + * @return array + */ + protected function _getTwoLevelsBackendOptions($fastOptions, $cacheOptions) + { + $options = array(); + $options['fast_backend'] = $fastOptions['type']; + $options['fast_backend_options'] = $fastOptions['options']; + $options['fast_backend_custom_naming'] = true; + $options['fast_backend_autoload'] = true; + $options['slow_backend_custom_naming'] = true; + $options['slow_backend_autoload'] = true; + + if (isset($cacheOptions['auto_refresh_fast_cache'])) { + $options['auto_refresh_fast_cache'] = (bool)$cacheOptions['auto_refresh_fast_cache']; + } else { + $options['auto_refresh_fast_cache'] = false; + } + if (isset($cacheOptions['slow_backend'])) { + $options['slow_backend'] = $cacheOptions['slow_backend']; + } else { + $options['slow_backend'] = $this->_defaultBackend; + } + if (isset($cacheOptions['slow_backend_options'])) { + $options['slow_backend_options'] = $cacheOptions['slow_backend_options']; + } else { + $options['slow_backend_options'] = $this->_backendOptions; + } + if ($options['slow_backend'] == 'database') { + $options['slow_backend'] = 'Varien_Cache_Backend_Database'; + $options['slow_backend_options'] = $this->_getDbAdapterOptions(); + if (isset($cacheOptions['slow_backend_store_data'])) { + $options['slow_backend_options']['store_data'] = (bool)$cacheOptions['slow_backend_store_data']; + } else { + $options['slow_backend_options']['store_data'] = false; + } + } + + $backend = array( + 'type' => 'TwoLevels', + 'options' => $options + ); + return $backend; + } + + /** + * Get options of cache frontend (options of Zend_Cache_Core) + * + * @param array $cacheOptions + * @return array + * @SuppressWarnings(PHPMD.NPathComplexity) + */ + protected function _getFrontendOptions(array $cacheOptions) + { + $options = isset($cacheOptions['frontend_options']) ? $cacheOptions['frontend_options'] : array(); + if (!array_key_exists('caching', $options)) { + $options['caching'] = true; + } + if (!array_key_exists('lifetime', $options)) { + $options['lifetime'] = isset($cacheOptions['lifetime']) ? $cacheOptions['lifetime'] + : self::DEFAULT_LIFETIME; + } + if (!array_key_exists('automatic_cleaning_factor', $options)) { + $options['automatic_cleaning_factor'] = 0; + } + $options['type'] = isset($cacheOptions['frontend']) ? $cacheOptions['frontend'] : 'Varien_Cache_Core'; + return $options; + } +} diff --git a/app/code/Mage/Core/Model/Cache/Frontend/Pool.php b/app/code/Mage/Core/Model/Cache/Frontend/Pool.php new file mode 100644 index 0000000000000..ec15c2adf8e9a --- /dev/null +++ b/app/code/Mage/Core/Model/Cache/Frontend/Pool.php @@ -0,0 +1,158 @@ +_config = $cacheConfig; + $this->_factory = $frontendFactory; + } + + /** + * Load frontend instances from the configuration, to be used for delayed initialization + */ + protected function _initialize() + { + if ($this->_instances === null) { + $this->_instances = array(); + // default front-end + $frontendNode = $this->_config->getNode(self::XML_PATH_SETTINGS_DEFAULT); + $frontendOptions = $frontendNode ? $frontendNode->asArray() : array(); + $this->_instances[self::DEFAULT_FRONTEND_ID] = $this->_factory->create($frontendOptions); + // additional front-ends + $frontendNodes = $this->_config->getNode(self::XML_PATH_SETTINGS_CUSTOM); + if ($frontendNodes) { + /** @var $frontendNode Varien_Simplexml_Element */ + foreach ($frontendNodes->children() as $frontendNode) { + $frontendId = $frontendNode->getName(); + $frontendOptions = $frontendNode->asArray(); + $this->_instances[$frontendId] = $this->_factory->create($frontendOptions); + } + } + } + } + + /** + * {@inheritdoc} + * + * @return Magento_Cache_FrontendInterface + */ + public function current() + { + $this->_initialize(); + return current($this->_instances); + } + + /** + * {@inheritdoc} + */ + public function key() + { + $this->_initialize(); + return key($this->_instances); + } + + /** + * {@inheritdoc} + */ + public function next() + { + $this->_initialize(); + next($this->_instances); + } + + /** + * {@inheritdoc} + */ + public function rewind() + { + $this->_initialize(); + reset($this->_instances); + } + + /** + * {@inheritdoc} + */ + public function valid() + { + $this->_initialize(); + return (bool)current($this->_instances); + } + + /** + * Retrieve frontend instance by its unique identifier, or return NULL, if identifier is not recognized + * + * @param string $identifier Cache frontend identifier + * @return Magento_Cache_FrontendInterface Cache frontend instance + */ + public function get($identifier) + { + $this->_initialize(); + if (isset($this->_instances[$identifier])) { + return $this->_instances[$identifier]; + } + return null; + } +} diff --git a/app/code/Mage/Core/Model/Cache/Proxy.php b/app/code/Mage/Core/Model/Cache/Proxy.php new file mode 100644 index 0000000000000..cd29a23ac202b --- /dev/null +++ b/app/code/Mage/Core/Model/Cache/Proxy.php @@ -0,0 +1,194 @@ +_objectManager = $objectManager; + } + + /** + * Create cache model + * + * @return Mage_Core_Model_CacheInterface|mixed + */ + protected function _getCache() + { + if (null == $this->_cache) { + $this->_cache = $this->_objectManager->get('Mage_Core_Model_Cache'); + } + return $this->_cache; + } + + /** + * Get cache frontend API object + * + * @return Zend_Cache_Core + */ + public function getFrontend() + { + return $this->_getCache()->getFrontend(); + } + + /** + * Load data from cache by id + * + * @param string $identifier + * @return string + */ + public function load($identifier) + { + return $this->_getCache()->load($identifier); + } + + /** + * Save data + * + * @param string $data + * @param string $identifier + * @param array $tags + * @param int $lifeTime + * @return bool + */ + public function save($data, $identifier, $tags = array(), $lifeTime = null) + { + return $this->_getCache()->save($data, $identifier, $tags, $lifeTime); + } + + /** + * Remove cached data by identifier + * + * @param string $identifier + * @return bool + */ + public function remove($identifier) + { + return $this->_getCache()->remove($identifier); + } + + /** + * Clean cached data by specific tag + * + * @param array $tags + * @return bool + */ + public function clean($tags = array()) + { + return $this->_getCache()->clean($tags); + } + + /** + * Check if cache can be used for specific data type + * + * @param string $typeCode + * @return bool + */ + public function canUse($typeCode) + { + return $this->_getCache()->canUse($typeCode); + } + + /** + * Disable cache usage for specific data type + * + * @param string $typeCode + * @return Mage_Core_Model_CacheInterface + */ + public function banUse($typeCode) + { + return $this->_getCache()->banUse($typeCode); + } + + /** + * Enable cache usage for specific data type + * + * @param string $typeCode + * @return Mage_Core_Model_CacheInterface + */ + public function allowUse($typeCode) + { + return $this->_getCache()->allowUse($typeCode); + } + + /** + * Get information about all declared cache types + * + * @return array + */ + public function getTypes() + { + return $this->_getCache()->getTypes(); + } + + /** + * Get array of all invalidated cache types + * + * @return array + */ + public function getInvalidatedTypes() + { + return $this->_getCache()->getInvalidatedTypes(); + } + + /** + * Mark specific cache type(s) as invalidated + * + * @param string|array $typeCode + * @return Mage_Core_Model_CacheInterface + */ + public function invalidateType($typeCode) + { + return $this->_getCache()->invalidateType($typeCode); + } + + /** + * Clean cached data for specific cache type + * + * @param string $typeCode + * @return Mage_Core_Model_CacheInterface + */ + public function cleanType($typeCode) + { + return $this->_getCache()->cleanType($typeCode); + } +} diff --git a/app/code/Mage/Core/Model/Cache/Type/AccessProxy.php b/app/code/Mage/Core/Model/Cache/Type/AccessProxy.php new file mode 100644 index 0000000000000..d093e16efcdcf --- /dev/null +++ b/app/code/Mage/Core/Model/Cache/Type/AccessProxy.php @@ -0,0 +1,127 @@ +_cacheTypes = $cacheTypes; + $this->_identifier = $identifier; + } + + /** + * Whether a cache type is enabled at the moment or not + * + * @return bool + */ + protected function _isEnabled() + { + return $this->_cacheTypes->isEnabled($this->_identifier); + } + + /** + * {@inheritdoc} + */ + public function test($identifier) + { + if (!$this->_isEnabled()) { + return false; + } + return parent::test($identifier); + } + + /** + * {@inheritdoc} + */ + public function load($identifier) + { + if (!$this->_isEnabled()) { + return false; + } + return parent::load($identifier); + } + + /** + * {@inheritdoc} + */ + public function save($data, $identifier, array $tags = array(), $lifeTime = null) + { + if (!$this->_isEnabled()) { + return true; + } + return parent::save($data, $identifier, $tags, $lifeTime); + } + + /** + * {@inheritdoc} + */ + public function remove($identifier) + { + if (!$this->_isEnabled()) { + return true; + } + return parent::remove($identifier); + } + + /** + * {@inheritdoc} + */ + public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, array $tags = array()) + { + if (!$this->_isEnabled()) { + return true; + } + return parent::clean($mode, $tags); + } +} diff --git a/app/code/Mage/Core/Model/Cache/Type/Block.php b/app/code/Mage/Core/Model/Cache/Type/Block.php new file mode 100644 index 0000000000000..7833896afcb1b --- /dev/null +++ b/app/code/Mage/Core/Model/Cache/Type/Block.php @@ -0,0 +1,51 @@ +get(self::TYPE_IDENTIFIER), self::CACHE_TAG); + } +} diff --git a/app/code/Mage/Core/Model/Cache/Type/Collection.php b/app/code/Mage/Core/Model/Cache/Type/Collection.php new file mode 100644 index 0000000000000..579aff989b3f7 --- /dev/null +++ b/app/code/Mage/Core/Model/Cache/Type/Collection.php @@ -0,0 +1,51 @@ +get(self::TYPE_IDENTIFIER), self::CACHE_TAG); + } +} diff --git a/app/code/Mage/Core/Model/Cache/Type/Config.php b/app/code/Mage/Core/Model/Cache/Type/Config.php new file mode 100644 index 0000000000000..8d202e9bb9685 --- /dev/null +++ b/app/code/Mage/Core/Model/Cache/Type/Config.php @@ -0,0 +1,49 @@ +get(self::TYPE_IDENTIFIER), self::CACHE_TAG); + } +} diff --git a/app/code/Mage/Core/Model/Cache/Type/FrontendPool.php b/app/code/Mage/Core/Model/Cache/Type/FrontendPool.php new file mode 100644 index 0000000000000..0fafaed5e1d7e --- /dev/null +++ b/app/code/Mage/Core/Model/Cache/Type/FrontendPool.php @@ -0,0 +1,83 @@ +_objectManager = $objectManager; + $this->_frontendPool = $frontendPool; + } + + /** + * Retrieve cache frontend instance by its unique identifier, enforcing identifier-scoped access control + * + * @param string $identifier Cache frontend identifier + * @return Magento_Cache_FrontendInterface Cache frontend instance + */ + public function get($identifier) + { + if (!isset($this->_instances[$identifier])) { + $frontendInstance = $this->_frontendPool->get($identifier); + if (!$frontendInstance) { + $frontendInstance = $this->_frontendPool->get(Mage_Core_Model_Cache_Frontend_Pool::DEFAULT_FRONTEND_ID); + } + /** @var $frontendInstance Mage_Core_Model_Cache_Type_AccessProxy */ + $frontendInstance = $this->_objectManager->create( + 'Mage_Core_Model_Cache_Type_AccessProxy', array( + 'frontend' => $frontendInstance, + 'identifier' => $identifier, + ) + ); + $this->_instances[$identifier] = $frontendInstance; + } + return $this->_instances[$identifier]; + } +} diff --git a/app/code/Mage/Core/Model/Cache/Type/Layout.php b/app/code/Mage/Core/Model/Cache/Type/Layout.php new file mode 100644 index 0000000000000..e921aee338f99 --- /dev/null +++ b/app/code/Mage/Core/Model/Cache/Type/Layout.php @@ -0,0 +1,51 @@ +get(self::TYPE_IDENTIFIER), self::CACHE_TAG); + } +} diff --git a/app/code/Mage/Core/Model/Cache/Type/Translate.php b/app/code/Mage/Core/Model/Cache/Type/Translate.php new file mode 100644 index 0000000000000..f510dd6175d58 --- /dev/null +++ b/app/code/Mage/Core/Model/Cache/Type/Translate.php @@ -0,0 +1,51 @@ +get(self::TYPE_IDENTIFIER), self::CACHE_TAG); + } +} diff --git a/app/code/Mage/Core/Model/Cache/Types.php b/app/code/Mage/Core/Model/Cache/Types.php new file mode 100644 index 0000000000000..6578cba2c5596 --- /dev/null +++ b/app/code/Mage/Core/Model/Cache/Types.php @@ -0,0 +1,130 @@ +_resource = $resource; + $this->_cacheFrontend = $cacheFrontendPool->get(Mage_Core_Model_Cache_Frontend_Pool::DEFAULT_FRONTEND_ID); + if ($appState->isInstalled()) { + $this->_loadTypeStatuses($banAll); + } + } + + /** + * Load statuses (enabled/disabled) of cache types + * + * @param bool $forceDisableAll + */ + private function _loadTypeStatuses($forceDisableAll = false) + { + $typeOptions = $this->_cacheFrontend->load(self::CACHE_ID); + if ($typeOptions !== false) { + $typeOptions = unserialize($typeOptions); + } else { + $typeOptions = $this->_resource->getAllOptions(); + if ($typeOptions !== false) { + $this->_cacheFrontend->save(serialize($typeOptions), self::CACHE_ID); + } + } + if ($typeOptions) { + foreach ($typeOptions as $cacheType => $isTypeEnabled) { + $this->setEnabled($cacheType, $isTypeEnabled && !$forceDisableAll); + } + } + } + + /** + * Whether a cache type is enabled or not at the moment + * + * @param string $cacheType + * @return bool + */ + public function isEnabled($cacheType) + { + return isset($this->_typeStatuses[$cacheType]) ? (bool)$this->_typeStatuses[$cacheType] : false; + } + + /** + * Enable/disable a cache type in run-time + * + * @param string $cacheType + * @param bool $isEnabled + */ + public function setEnabled($cacheType, $isEnabled) + { + $this->_typeStatuses[$cacheType] = (int)$isEnabled; + } + + /** + * Save the current statuses (enabled/disabled) of cache types to the persistent storage + */ + public function persist() + { + $this->_resource->saveAllOptions($this->_typeStatuses); + $this->_cacheFrontend->remove(self::CACHE_ID); + } +} diff --git a/app/code/core/Mage/Core/Model/CacheInterface.php b/app/code/Mage/Core/Model/CacheInterface.php similarity index 76% rename from app/code/core/Mage/Core/Model/CacheInterface.php rename to app/code/Mage/Core/Model/CacheInterface.php index 5b700190c8b1f..14463bb3cb499 100644 --- a/app/code/core/Mage/Core/Model/CacheInterface.php +++ b/app/code/Mage/Core/Model/CacheInterface.php @@ -39,29 +39,29 @@ public function getFrontend(); /** * Load data from cache by id * - * @param string $id - * @return string + * @param string $identifier + * @return string */ - public function load($id); + public function load($identifier); /** * Save data * * @param string $data - * @param string $id + * @param string $identifier * @param array $tags * @param int $lifeTime * @return bool */ - public function save($data, $id, $tags = array(), $lifeTime = null); + public function save($data, $identifier, $tags = array(), $lifeTime = null); /** * Remove cached data by identifier * - * @param string $id + * @param string $identifier * @return bool */ - public function remove($id); + public function remove($identifier); /** * Clean cached data by specific tag @@ -71,28 +71,6 @@ public function remove($id); */ public function clean($tags = array()); - /** - * Clean cached data by specific tag - * - * @return bool - */ - public function flush(); - - /** - * Get adapter for database cache backend model - * - * @return Zend_Db_Adapter_Abstract - */ - public function getDbAdapter(); - - /** - * Save cache usage options - * - * @param array $options - * @return Mage_Core_Model_CacheInterface - */ - public function saveOptions($options); - /** * Check if cache can be used for specific data type * @@ -117,14 +95,6 @@ public function banUse($typeCode); */ public function allowUse($typeCode); - /** - * Get cache tags by cache type from configuration - * - * @param string $type - * @return array - */ - public function getTagsByType($type); - /** * Get information about all declared cache types * diff --git a/app/code/core/Mage/Core/Model/Calculator.php b/app/code/Mage/Core/Model/Calculator.php similarity index 100% rename from app/code/core/Mage/Core/Model/Calculator.php rename to app/code/Mage/Core/Model/Calculator.php diff --git a/app/code/Mage/Core/Model/Config.php b/app/code/Mage/Core/Model/Config.php new file mode 100644 index 0000000000000..745fe963f0b40 --- /dev/null +++ b/app/code/Mage/Core/Model/Config.php @@ -0,0 +1,685 @@ +_objectManager = $objectManager; + $this->_app = $app; + $this->_storage = $storage; + $this->_config = $this->_storage->getConfiguration(); + $this->_moduleReader = $moduleReader; + $this->_invalidator = $invalidator; + $this->_objectManager->configure($this->getNode('global/di')->asArray()); + Magento_Profiler::stop('config_load'); + } + + /** + * Load allowed areas from config + * + * @return Mage_Core_Model_Config + */ + protected function _loadAreas() + { + $this->_allowedAreas = array(); + $nodeAreas = $this->getNode('global/areas'); + if (is_object($nodeAreas)) { + foreach ($nodeAreas->asArray() as $areaCode => $areaInfo) { + if (empty($areaCode) + || (!isset($areaInfo['base_controller']) || empty($areaInfo['base_controller'])) + ) { + continue; + } + /** + * TODO: Check of 'routers' nodes existance is excessive: + * TODO: 'routers' check is moved Mage_Core_Model_Config::getRouters() + */ + + /** + * TODO: Routers are not required in API. + * TODO: That is why Check for empty router class moved to Mage_Core_Model_Config::getRouters() + */ + $this->_allowedAreas[$areaCode] = $areaInfo; + } + } + + return $this; + } + + /** + * Returns nodes found by xpath expression + * + * @param string $xpath + * @return array + */ + public function getXpath($xpath) + { + return $this->_config->getXpath($xpath); + } + + /** + * Returns node found by the $path and scope info + * + * @param string $path + * @param string $scope + * @param string|int $scopeCode + * @return Mage_Core_Model_Config_Element + */ + public function getNode($path = null, $scope = '', $scopeCode = null) + { + if ($scope !== '') { + if (('store' === $scope) || ('website' === $scope)) { + $scope .= 's'; + } + if (('default' !== $scope) && is_int($scopeCode)) { + if ('stores' == $scope) { + $scopeCode = $this->_app->getStore($scopeCode)->getCode(); + } elseif ('websites' == $scope) { + $scopeCode = $this->_app->getWebsite($scopeCode)->getCode(); + } else { + Mage::throwException( + $this->_objectManager->get('Mage_Core_Helper_Data') + ->__('Unknown scope "%s".', $scope) + ); + } + } + $path = $scope . ($scopeCode ? '/' . $scopeCode : '' ) . (empty($path) ? '' : '/' . $path); + } + try { + return $this->_config->getNode($path); + } catch (Mage_Core_Model_Config_Cache_Exception $e) { + $this->reinit(); + return $this->_config->getNode($path); + } + } + + /** + * Create node by $path and set its value. + * + * @param string $path separated by slashes + * @param string $value + * @param bool $overwrite + */ + public function setNode($path, $value, $overwrite = true) + { + try { + $this->_config->setNode($path, $value, $overwrite); + } catch (Mage_Core_Model_Config_Cache_Exception $e) { + $this->reinit(); + $this->_config->setNode($path, $value, $overwrite); + } + } + + /** + * Get currently used area code + * @return string|null + */ + public function getCurrentAreaCode() + { + return $this->_currentAreaCode; + } + + /** + * Set currently used area code + * + * @param $areaCode + * @return Mage_Core_Model_Config + */ + public function setCurrentAreaCode($areaCode) + { + $this->_currentAreaCode = $areaCode; + return $this; + } + + /** + * Get allowed areas + * + * @return array + */ + public function getAreas() + { + if (is_null($this->_allowedAreas) ) { + $this->_loadAreas(); + } + return $this->_allowedAreas; + } + + /** + * Retrieve area config by area code + * + * @param string|null $areaCode + * @throws InvalidArgumentException + * @return array + */ + public function getAreaConfig($areaCode = null) + { + $areaCode = empty($areaCode) ? $this->getCurrentAreaCode() : $areaCode; + $areas = $this->getAreas(); + if (!isset($areas[$areaCode])) { + throw new InvalidArgumentException('Requested area (' . $areaCode . ') doesn\'t exist'); + } + return $areas[$areaCode]; + } + + /** + * Identify front name of the requested area. Return current area front name if area code is not specified. + * + * @param string|null $areaCode + * @return string + * @throws LogicException If front name is not defined. + */ + public function getAreaFrontName($areaCode = null) + { + $areaCode = empty($areaCode) ? $this->getCurrentAreaCode() : $areaCode; + $areaConfig = $this->getAreaConfig($areaCode); + if (!isset($areaConfig['frontName'])) { + throw new LogicException(sprintf( + 'Area "%s" must have front name defined in the application config.', + $areaCode + )); + } + return $areaConfig['frontName']; + } + + /** + * Get routers from config + * + * @return array + */ + public function getRouters() + { + $routers = array(); + foreach ($this->getAreas() as $areaCode => $areaInfo) { + if (isset($areaInfo['routers']) && is_array($areaInfo['routers'])) { + foreach ($areaInfo['routers'] as $routerKey => $routerInfo ) { + if (!isset($routerInfo['class']) || empty($routerInfo['class'])) { + continue; + } + $routerInfo = array_merge($routerInfo, $areaInfo); + unset($routerInfo['routers']); + $routerInfo['area'] = $areaCode; + $routers[$routerKey] = $routerInfo; + } + } + } + return $routers; + } + + /** + * Get module config node + * + * @param string $moduleName + * @return Varien_Simplexml_Element + */ + public function getModuleConfig($moduleName = '') + { + $modules = $this->getNode('modules'); + if ('' === $moduleName) { + return $modules; + } else { + return $modules->$moduleName; + } + } + + /** + * Check if specified module is enabled + * + * @param string $moduleName + * @return bool + */ + public function isModuleEnabled($moduleName) + { + if (!$this->getNode('modules/' . $moduleName)) { + return false; + } + + $isActive = $this->getNode('modules/' . $moduleName . '/active'); + if (!$isActive || !in_array((string)$isActive, array('true', '1'))) { + return false; + } + return true; + } + + /** + * Get module directory by directory type + * + * @param string $type + * @param string $moduleName + * @return string + */ + public function getModuleDir($type, $moduleName) + { + return $this->_moduleReader->getModuleDir($type, $moduleName); + } + + /** + * Set path to the corresponding module directory + * + * @param string $moduleName + * @param string $type directory type (etc, controllers, locale etc) + * @param string $path + * @return Mage_Core_Model_Config + */ + public function setModuleDir($moduleName, $type, $path) + { + $this->_moduleReader->setModuleDir($moduleName, $type, $path); + return $this; + } + + /** + * Retrieve store Ids for $path with checking + * + * if empty $allowValues then retrieve all stores values + * + * return array($storeId => $pathValue) + * + * @param string $path + * @param array $allowValues + * @param string $useAsKey + * @return array + */ + public function getStoresConfigByPath($path, $allowValues = array(), $useAsKey = 'id') + { + $storeValues = array(); + $stores = $this->getNode('stores'); + /** @var $store Varien_Simplexml_Element */ + foreach ($stores->children() as $code => $store) { + switch ($useAsKey) { + case 'id': + $key = (int) $store->descend('system/store/id'); + break; + + case 'code': + $key = $code; + break; + + case 'name': + $key = (string) $store->descend('system/store/name'); + break; + + default: + $key = false; + break; + } + + if ($key === false) { + continue; + } + + $pathValue = (string) $store->descend($path); + + if (empty($allowValues)) { + $storeValues[$key] = $pathValue; + } elseif (in_array($pathValue, $allowValues)) { + $storeValues[$key] = $pathValue; + } + } + + return $storeValues; + } + + /** + * Get fieldset from configuration + * + * @param string $name fieldset name + * @param string $root fieldset area, could be 'admin' + * @return null|array + */ + public function getFieldset($name, $root = 'global') + { + /** @var $config Mage_Core_Model_Config_Base */ + $config = $this->_objectManager->get('Mage_Core_Model_Config_Fieldset'); + $rootNode = $config->getNode($root . '/fieldsets'); + if (!$rootNode) { + return null; + } + return $rootNode->$name ? $rootNode->$name->children() : null; + } + + /** + * Get standard path variables. + * + * To be used in blocks, templates, etc. + * + * @return array + */ + public function getPathVars() + { + $path = array(); + $path['baseUrl'] = Mage::getBaseUrl(); + $path['baseSecureUrl'] = Mage::getBaseUrl('link', true); + return $path; + } + + /** + * Check whether given path should be secure according to configuration security requirements for URL + * "Secure" should not be confused with https protocol, it is about web/secure/*_url settings usage only + * + * @param string $url + * @return bool + */ + public function shouldUrlBeSecure($url) + { + if (!Mage::getStoreConfigFlag(Mage_Core_Model_Store::XML_PATH_SECURE_IN_FRONTEND)) { + return false; + } + + if (!isset($this->_secureUrlCache[$url])) { + $this->_secureUrlCache[$url] = false; + $secureUrls = $this->getNode('frontend/secure_url'); + foreach ($secureUrls->children() as $match) { + if (strpos($url, (string)$match) === 0) { + $this->_secureUrlCache[$url] = true; + break; + } + } + } + return $this->_secureUrlCache[$url]; + } + + /** + * Get default server variables values + * + * @return array + */ + public function getDistroBaseUrl() + { + if (isset($_SERVER['SCRIPT_NAME']) && isset($_SERVER['HTTP_HOST'])) { + $secure = (!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] != 'off')) + || (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443'); + $scheme = ($secure ? 'https' : 'http') . '://' ; + + $hostArr = explode(':', $_SERVER['HTTP_HOST']); + $host = $hostArr[0]; + $port = isset($hostArr[1]) && (!$secure && $hostArr[1] != 80 || $secure && $hostArr[1] != 443) + ? ':'. $hostArr[1] + : ''; + $path = Mage::getObjectManager()->get('Mage_Core_Controller_Request_Http')->getBasePath(); + + return $scheme . $host . $port . rtrim($path, '/') . '/'; + } + return 'http://localhost/'; + } + + /** + * Determine whether provided name begins from any available modules, according to namespaces priority + * If matched, returns as the matched module "factory" name or a fully qualified module name + * + * @param string $name + * @param bool $asFullModuleName + * @return string + */ + public function determineOmittedNamespace($name, $asFullModuleName = false) + { + if (null === $this->_moduleNamespaces) { + $this->_moduleNamespaces = array(); + /** @var $moduleConfig Varien_Simplexml_Element */ + foreach ($this->getXpath('modules/*') as $moduleConfig) { + if ((string)$moduleConfig->active == 'true') { + $moduleName = $moduleConfig->getName(); + $module = strtolower($moduleName); + $this->_moduleNamespaces[substr($module, 0, strpos($module, '_'))][$module] = $moduleName; + } + } + } + + $name = explode('_', strtolower($name)); + $partsNum = count($name); + $defaultNamespaceFlag = false; + foreach ($this->_moduleNamespaces as $namespaceName => $namespace) { + // assume the namespace is omitted (default namespace only, which comes first) + if ($defaultNamespaceFlag === false) { + $defaultNamespaceFlag = true; + $defaultNS = $namespaceName . '_' . $name[0]; + if (isset($namespace[$defaultNS])) { + return $asFullModuleName ? $namespace[$defaultNS] : $name[0]; // return omitted as well + } + } + // assume namespace is qualified + if (isset($name[1])) { + $fullNS = $name[0] . '_' . $name[1]; + if (2 <= $partsNum && isset($namespace[$fullNS])) { + return $asFullModuleName ? $namespace[$fullNS] : $fullNS; + } + } + } + return ''; + } + + /** + * Reinitialize configuration + * + * @return Mage_Core_Model_Config + */ + public function reinit() + { + $this->removeCache(); + $this->_invalidator->invalidate(); + $this->_config = $this->_storage->getConfiguration(); + $this->_cacheInstanceId = null; + } + + /** + * Get model class instance. + * + * Example: + * $config->getModelInstance('Mage_Catalog_Model_Resource_Product') + * + * Will instantiate Mage_Catalog_Model_Resource_Product + * + * @param string $modelClass + * @param array|object $constructArguments + * @return Mage_Core_Model_Abstract|bool + */ + public function getModelInstance($modelClass = '', $constructArguments = array()) + { + if (class_exists($modelClass)) { + Magento_Profiler::start('FACTORY:' . $modelClass); + $obj = $this->_objectManager->create($modelClass, $constructArguments); + Magento_Profiler::stop('FACTORY:' . $modelClass); + return $obj; + } else { + return false; + } + } + + /** + * Get resource model object by alias + * + * @param string $modelClass + * @param array $constructArguments + * @return object + */ + public function getResourceModelInstance($modelClass='', $constructArguments=array()) + { + return $this->getModelInstance($modelClass, $constructArguments); + } + + /** + * Remove configuration cache + */ + public function removeCache() + { + /** @var $eventManager Mage_Core_Model_Event_Manager */ + $eventManager = $this->_objectManager->get('Mage_Core_Model_Event_Manager'); + $eventManager->dispatch('application_clean_cache', array('tags' => array(self::CACHE_TAG))); + $this->_storage->removeCache(); + } +} diff --git a/app/code/Mage/Core/Model/Config/Base.php b/app/code/Mage/Core/Model/Config/Base.php new file mode 100644 index 0000000000000..14a9acfb12e8c --- /dev/null +++ b/app/code/Mage/Core/Model/Config/Base.php @@ -0,0 +1,77 @@ + + */ + +class Mage_Core_Model_Config_Base extends Varien_Simplexml_Config implements Mage_Core_Model_ConfigInterface +{ + /** + * List of instances + * + * @var array + */ + public static $instances = array(); + + /** + * @param string|Varien_Simplexml_Element $sourceData $sourceData + */ + public function __construct($sourceData = null) + { + $this->_elementClass = 'Mage_Core_Model_Config_Element'; + parent::__construct($sourceData); + self::$instances[] = $this; + } + + /** + * Reinitialize config object + */ + public function reinit() + { + + } + + /** + * Cleanup objects because of simplexml memory leak + */ + public static function destroy() + { + if (is_array(self::$instances)) { + foreach (self::$instances as $instance) { + $instance->_xml = null; + } + } + self::$instances = array(); + } +} diff --git a/app/code/core/Mage/Core/Model/Config/BaseFactory.php b/app/code/Mage/Core/Model/Config/BaseFactory.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/BaseFactory.php rename to app/code/Mage/Core/Model/Config/BaseFactory.php diff --git a/app/code/Mage/Core/Model/Config/Cache.php b/app/code/Mage/Core/Model/Config/Cache.php new file mode 100644 index 0000000000000..c7fdbdd062896 --- /dev/null +++ b/app/code/Mage/Core/Model/Config/Cache.php @@ -0,0 +1,243 @@ +_containerFactory = $containerFactory; + $this->_configCacheType = $configCacheType; + $this->_configSections = $configSections; + $this->_cacheLockId = $this->_cacheId . '.lock'; + $this->_baseFactory = $baseFactory; + } + + /** + * Save cache of specified + * + * @param string $idPrefix cache id prefix + * @param string $sectionName + * @param Varien_Simplexml_Element $source + * @param int $recursionLevel + * @SuppressWarnings(PHPMD.UnusedLocalVariable) + */ + protected function _saveSectionCache($idPrefix, $sectionName, $source, $recursionLevel = 0) + { + if ($source && $source->$sectionName) { + $cacheId = $idPrefix . '_' . $sectionName; + if ($recursionLevel > 0) { + foreach ($source->$sectionName->children() as $subSectionName => $node) { + $this->_saveSectionCache($cacheId, $subSectionName, $source->$sectionName, $recursionLevel-1); + } + } + $this->_cachePartsForSave[$cacheId] = $source->$sectionName->asNiceXml('', false); + } + } + + /** + * Lock caching to prevent concurrent cache writes + */ + protected function _lock() + { + $this->_configCacheType->save((string)time(), $this->_cacheLockId, array(), 60); + } + + /** + * Unlock caching + */ + protected function _unlock() + { + $this->_configCacheType->remove($this->_cacheLockId); + } + + /** + * Check whether caching is locked + * + * @return bool + */ + protected function _isLocked() + { + return (bool)$this->_configCacheType->load($this->_cacheLockId); + } + + /** + * Set cache lifetime + * + * @param int $lifetime + */ + public function setCacheLifetime($lifetime) + { + $this->_cacheLifetime = $lifetime; + } + + /** + * Retrieve cache lifetime + * + * @return int + */ + public function getCacheLifeTime() + { + return $this->_cacheLifetime; + } + + /** + * @return Mage_Core_Model_ConfigInterface|bool + */ + public function load() + { + if (!$this->_loadedConfig) { + $config = (false == $this->_isLocked()) ? $this->_configCacheType->load($this->_cacheId) : false; + if ($config) { + $this->_loadedConfig = $this->_containerFactory->create(array('sourceData' => $config)); + } + } + return $this->_loadedConfig ? $this->_loadedConfig : false; + } + + /** + * Save config cache + * + * @param Mage_Core_Model_Config_Base $config + */ + public function save(Mage_Core_Model_Config_Base $config) + { + if (false == $this->_isLocked()) { + $cacheSections = $this->_configSections->getSections(); + $xml = clone $config->getNode(); + if (!empty($cacheSections)) { + foreach ($cacheSections as $sectionName => $level) { + $this->_saveSectionCache($this->_cacheId, $sectionName, $xml, $level); + unset($xml->$sectionName); + } + } + $this->_cachePartsForSave[$this->_cacheId] = $xml->asNiceXml('', false); + $this->_lock(); + $this->clean(); + foreach ($this->_cachePartsForSave as $cacheId => $cacheData) { + $this->_configCacheType->save((string)$cacheData, $cacheId, array(), $this->_cacheLifetime); + } + unset($this->_cachePartsForSave); + $this->_unlock(); + } + } + + /** + * Clean cached data + * + * @return bool + */ + public function clean() + { + $this->_loadedConfig = null; + return $this->_configCacheType->clean(); + } + + /** + * Load config section cached data + * + * @param string $sectionKey + * @return Mage_Core_Model_Config_Base|bool + * @throws Mage_Core_Model_Config_Cache_Exception + */ + public function getSection($sectionKey) + { + $cacheId = $this->_cacheId . '_' . $sectionKey; + $xmlString = $this->_configCacheType->load($cacheId); + if ($xmlString) { + return $this->_baseFactory->create($xmlString); + } + throw new Mage_Core_Model_Config_Cache_Exception(); + } +} diff --git a/app/code/core/Mage/Core/Model/Config/Cache/Exception.php b/app/code/Mage/Core/Model/Config/Cache/Exception.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Cache/Exception.php rename to app/code/Mage/Core/Model/Config/Cache/Exception.php diff --git a/app/code/core/Mage/Core/Model/Config/Container.php b/app/code/Mage/Core/Model/Config/Container.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Container.php rename to app/code/Mage/Core/Model/Config/Container.php diff --git a/app/code/core/Mage/Core/Model/Config/ContainerFactory.php b/app/code/Mage/Core/Model/Config/ContainerFactory.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/ContainerFactory.php rename to app/code/Mage/Core/Model/Config/ContainerFactory.php diff --git a/app/code/core/Mage/Core/Model/Config/Data.php b/app/code/Mage/Core/Model/Config/Data.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Data.php rename to app/code/Mage/Core/Model/Config/Data.php diff --git a/app/code/core/Mage/Core/Model/Config/Data/Factory.php b/app/code/Mage/Core/Model/Config/Data/Factory.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Data/Factory.php rename to app/code/Mage/Core/Model/Config/Data/Factory.php diff --git a/app/code/core/Mage/Core/Model/Config/Element.php b/app/code/Mage/Core/Model/Config/Element.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Element.php rename to app/code/Mage/Core/Model/Config/Element.php diff --git a/app/code/Mage/Core/Model/Config/Fieldset.php b/app/code/Mage/Core/Model/Config/Fieldset.php new file mode 100644 index 0000000000000..033bc2c66c72d --- /dev/null +++ b/app/code/Mage/Core/Model/Config/Fieldset.php @@ -0,0 +1,54 @@ +load($cacheId); + if ($cachedXml) { + $this->loadString($cachedXml); + } else { + $config = $configReader->loadModulesConfiguration('fieldset.xml'); + $xmlConfig = $config->getNode(); + $configCacheType->save($xmlConfig->asXML(), $cacheId); + $this->setXml($xmlConfig); + } + } +} diff --git a/app/code/core/Mage/Core/Model/Config/Invalidator.php b/app/code/Mage/Core/Model/Config/Invalidator.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Invalidator.php rename to app/code/Mage/Core/Model/Config/Invalidator.php diff --git a/app/code/core/Mage/Core/Model/Config/Invalidator/Proxy.php b/app/code/Mage/Core/Model/Config/Invalidator/Proxy.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Invalidator/Proxy.php rename to app/code/Mage/Core/Model/Config/Invalidator/Proxy.php diff --git a/app/code/core/Mage/Core/Model/Config/InvalidatorInterface.php b/app/code/Mage/Core/Model/Config/InvalidatorInterface.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/InvalidatorInterface.php rename to app/code/Mage/Core/Model/Config/InvalidatorInterface.php diff --git a/app/code/core/Mage/Core/Model/Config/Loader.php b/app/code/Mage/Core/Model/Config/Loader.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Loader.php rename to app/code/Mage/Core/Model/Config/Loader.php diff --git a/app/code/core/Mage/Core/Model/Config/Loader/Db.php b/app/code/Mage/Core/Model/Config/Loader/Db.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Loader/Db.php rename to app/code/Mage/Core/Model/Config/Loader/Db.php diff --git a/app/code/Mage/Core/Model/Config/Loader/Local.php b/app/code/Mage/Core/Model/Config/Loader/Local.php new file mode 100644 index 0000000000000..41204368b3a6a --- /dev/null +++ b/app/code/Mage/Core/Model/Config/Loader/Local.php @@ -0,0 +1,104 @@ +_dir = $configDirectory; + $this->_customFile = $customFile; + $this->_customConfig = $customConfig; + } + + /** + * Populate configuration object + * + * @param Mage_Core_Model_Config_Base $config + */ + public function load(Mage_Core_Model_Config_Base $config) + { + $localConfigParts = array(); + + $localConfigFile = $this->_dir . DIRECTORY_SEPARATOR . self::LOCAL_CONFIG_FILE; + if (file_exists($localConfigFile)) { + // 1. app/etc/local.xml + $localConfig = new Mage_Core_Model_Config_Base(''); + $localConfig->loadFile($localConfigFile); + $localConfigParts[] = $localConfig; + + // 2. app/etc//.xml + if (preg_match('/^[a-z\d_-]+(\/|\\\)+[a-z\d_-]+\.xml$/', $this->_customFile)) { + $localConfigExtraFile = $this->_dir . DIRECTORY_SEPARATOR . $this->_customFile; + $localConfig = new Mage_Core_Model_Config_Base(''); + $localConfig->loadFile($localConfigExtraFile); + $localConfigParts[] = $localConfig; + } + } + + // 3. extra local configuration string + if ($this->_customConfig) { + $localConfig = new Mage_Core_Model_Config_Base(''); + $localConfig->loadString($this->_customConfig); + $localConfigParts[] = $localConfig; + } + + if ($localConfigParts) { + foreach ($localConfigParts as $oneConfigPart) { + $config->extend($oneConfigPart); + } + } + } +} diff --git a/app/code/core/Mage/Core/Model/Config/Loader/Locales.php b/app/code/Mage/Core/Model/Config/Loader/Locales.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Loader/Locales.php rename to app/code/Mage/Core/Model/Config/Loader/Locales.php diff --git a/app/code/core/Mage/Core/Model/Config/Loader/Locales/Proxy.php b/app/code/Mage/Core/Model/Config/Loader/Locales/Proxy.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Loader/Locales/Proxy.php rename to app/code/Mage/Core/Model/Config/Loader/Locales/Proxy.php diff --git a/app/code/core/Mage/Core/Model/Config/Loader/Modules.php b/app/code/Mage/Core/Model/Config/Loader/Modules.php similarity index 98% rename from app/code/core/Mage/Core/Model/Config/Loader/Modules.php rename to app/code/Mage/Core/Model/Config/Loader/Modules.php index 0e0b93b91d35a..ff8b7e0b1dba0 100644 --- a/app/code/core/Mage/Core/Model/Config/Loader/Modules.php +++ b/app/code/Mage/Core/Model/Config/Loader/Modules.php @@ -137,7 +137,7 @@ public function load(Mage_Core_Model_Config_Base $config) Magento_Profiler::stop('load_modules'); Magento_Profiler::stop('config'); $this->_resourceConfig->setConfig($config); - $this->_objectManager->setConfiguration($config->getNode('global/di')->asArray()); + $this->_objectManager->configure($config->getNode('global/di')->asArray()); $this->_modulesCache = array(); } @@ -206,7 +206,7 @@ protected function _loadDeclaredModules(Mage_Core_Model_Config_Base $mergeToConf protected function _getDeclaredModuleFiles() { $codeDir = $this->_dirs->getDir(Mage_Core_Model_Dir::MODULES); - $moduleFiles = glob($codeDir . DS . '*' . DS . '*' . DS . '*' . DS . 'etc' . DS . 'config.xml'); + $moduleFiles = glob($codeDir . DS . '*' . DS . '*' . DS . 'etc' . DS . 'config.xml'); if (!$moduleFiles) { return false; diff --git a/app/code/Mage/Core/Model/Config/Loader/Modules/File.php b/app/code/Mage/Core/Model/Config/Loader/Modules/File.php new file mode 100644 index 0000000000000..e7e19c30641dc --- /dev/null +++ b/app/code/Mage/Core/Model/Config/Loader/Modules/File.php @@ -0,0 +1,199 @@ +_dirs = $dirs; + $this->_prototypeFactory = $prototypeFactory; + } + + /** + * Iterate all active modules "etc" folders and combine data from + * specidied xml file name to one object + * + * @param Mage_Core_Model_ConfigInterface $modulesConfig + * @param string $fileName + * @param Mage_Core_Model_Config_Base|null $mergeToObject + * @param Mage_Core_Model_Config_Base|null $mergeModel + * @param array $configCache + * @return Mage_Core_Model_Config_Base|null + */ + public function loadConfigurationFromFile( + Mage_Core_Model_ConfigInterface $modulesConfig, + $fileName, + $mergeToObject = null, + $mergeModel = null, + $configCache = array() + ) { + $mergeToObject = null === $mergeToObject ? $this->_prototypeFactory->create('') : $mergeToObject; + $mergeModel = null === $mergeModel ? $mergeModel = $this->_prototypeFactory->create(''): $mergeModel; + + $modules = $modulesConfig->getNode('modules')->children(); + /** @var $module Mage_Core_Model_Config_Element */ + foreach ($modules as $modName => $module) { + if ($module->is('active')) { + if (!is_array($fileName)) { + $fileName = array($fileName); + } + foreach ($fileName as $configFile) { + $this->_loadFileConfig($configFile, $configCache, $modName, $mergeToObject, $mergeModel); + } + } + } + return $mergeToObject; + } + + /** + * Load configuration from single file + * + * @param string $configFile + * @param array $configCache + * @param string $modName + * @param Mage_Core_Model_Config_Base $mergeToObject + * @param Mage_Core_Model_Config_Base $mergeModel + */ + public function _loadFileConfig($configFile, $configCache, $modName, $mergeToObject, $mergeModel) + { + if ($configFile == 'config.xml' && isset($configCache[$modName])) { + $mergeToObject->extend($configCache[$modName], true); + //Prevent overriding node of module if it was redefined in etc/modules + $mergeToObject->extend( + $this->_prototypeFactory->create( + "<{$modName}>true" + ), + true + ); + } else { + $configFilePath = $this->getModuleDir('etc', $modName) . DS . $configFile; + if ($mergeModel->loadFile($configFilePath)) { + $mergeToObject->extend($mergeModel, true); + } + } + } + + /** + * Go through all modules and find configuration files of active modules + * + * @param Mage_Core_Model_ConfigInterface $modulesConfig + * @param $filename + * @return array + */ + public function getConfigurationFiles(Mage_Core_Model_ConfigInterface $modulesConfig, $filename) + { + $result = array(); + $modules = $modulesConfig->getNode('modules')->children(); + /** @var $module Mage_Core_Model_Config_Element */ + foreach ($modules as $moduleName => $module) { + if ((!$module->is('active'))) { + continue; + } + $file = $this->getModuleDir('etc', $moduleName) . DIRECTORY_SEPARATOR . $filename; + if (file_exists($file)) { + $result[] = $file; + } + } + return $result; + } + + /** + * Get module directory by directory type + * + * @param string $type + * @param string $moduleName + * @return string + */ + public function getModuleDir($type, $moduleName) + { + if (isset($this->_moduleDirs[$moduleName][$type])) { + return $this->_moduleDirs[$moduleName][$type]; + } + + $dir = $this->_dirs->getDir(Mage_Core_Model_Dir::MODULES) . DIRECTORY_SEPARATOR + . uc_words($moduleName, DIRECTORY_SEPARATOR); + + switch ($type) { + case 'etc': + case 'controllers': + case 'sql': + case 'data': + case 'locale': + case 'view': + $dir .= DS . $type; + break; + } + + $dir = str_replace('/', DS, $dir); + return $dir; + } + + /** + * Set path to the corresponding module directory + * + * @param string $moduleName + * @param string $type directory type (etc, controllers, locale etc) + * @param string $path + */ + public function setModuleDir($moduleName, $type, $path) + { + if (!isset($this->_moduleDirs[$moduleName])) { + $this->_moduleDirs[$moduleName] = array(); + } + $this->_moduleDirs[$moduleName][$type] = $path; + } +} diff --git a/app/code/core/Mage/Core/Model/Config/Loader/Modules/Proxy.php b/app/code/Mage/Core/Model/Config/Loader/Modules/Proxy.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Loader/Modules/Proxy.php rename to app/code/Mage/Core/Model/Config/Loader/Modules/Proxy.php diff --git a/app/code/Mage/Core/Model/Config/Loader/Primary.php b/app/code/Mage/Core/Model/Config/Loader/Primary.php new file mode 100644 index 0000000000000..b0ebbf40ee940 --- /dev/null +++ b/app/code/Mage/Core/Model/Config/Loader/Primary.php @@ -0,0 +1,83 @@ +_localLoader = $localLoader; + $this->_dir = $dir; + } + + /** + * Load primary configuration + * + * @param Mage_Core_Model_Config_Base $config + */ + public function load(Mage_Core_Model_Config_Base $config) + { + $etcDir = $this->_dir; + if (!$config->getNode()) { + $config->loadString(''); + } + // 1. app/etc/*.xml (except local config) + foreach (scandir($etcDir) as $filename) { + if ('.' == $filename || '..' == $filename || '.xml' != substr($filename, -4) + || Mage_Core_Model_Config_Loader_Local::LOCAL_CONFIG_FILE == $filename + ) { + continue; + } + $baseConfigFile = $etcDir . DIRECTORY_SEPARATOR . $filename; + $baseConfig = new Mage_Core_Model_Config_Base(''); + $baseConfig->loadFile($baseConfigFile); + $config->extend($baseConfig); + } + // 2. local configuration + $this->_localLoader->load($config); + } +} diff --git a/app/code/core/Mage/Core/Model/Config/Loader/Proxy.php b/app/code/Mage/Core/Model/Config/Loader/Proxy.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Loader/Proxy.php rename to app/code/Mage/Core/Model/Config/Loader/Proxy.php diff --git a/app/code/core/Mage/Core/Model/Config/LoaderInterface.php b/app/code/Mage/Core/Model/Config/LoaderInterface.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/LoaderInterface.php rename to app/code/Mage/Core/Model/Config/LoaderInterface.php diff --git a/app/code/core/Mage/Core/Model/Config/Locales.php b/app/code/Mage/Core/Model/Config/Locales.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Locales.php rename to app/code/Mage/Core/Model/Config/Locales.php diff --git a/app/code/core/Mage/Core/Model/Config/Modules.php b/app/code/Mage/Core/Model/Config/Modules.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Modules.php rename to app/code/Mage/Core/Model/Config/Modules.php diff --git a/app/code/Mage/Core/Model/Config/Modules/Reader.php b/app/code/Mage/Core/Model/Config/Modules/Reader.php new file mode 100644 index 0000000000000..470398751affa --- /dev/null +++ b/app/code/Mage/Core/Model/Config/Modules/Reader.php @@ -0,0 +1,102 @@ +_config = $modulesConfig; + $this->_fileReader = $fileReader; + } + + /** + * Iterate all active modules "etc" folders and combine data from + * specidied xml file name to one object + * + * @param string $fileName + * @param null|Mage_Core_Model_Config_Base $mergeToObject + * @param null|Mage_Core_Model_Config_Base $mergeModel + * @return Mage_Core_Model_Config_Base + */ + public function loadModulesConfiguration($fileName, $mergeToObject = null, $mergeModel = null) + { + return $this->_fileReader->loadConfigurationFromFile($this->_config, $fileName, $mergeToObject, $mergeModel); + } + + /** + * Go through all modules and find configuration files of active modules + * + * @param string $filename + * @return array + */ + public function getModuleConfigurationFiles($filename) + { + return $this->_fileReader->getConfigurationFiles($this->_config, $filename); + } + + /** + * Get module directory by directory type + * + * @param string $type + * @param string $moduleName + * @return string + */ + public function getModuleDir($type, $moduleName) + { + return $this->_fileReader->getModuleDir($type, $moduleName); + } + + /** + * Set path to the corresponding module directory + * + * @param string $moduleName + * @param string $type directory type (etc, controllers, locale etc) + * @param string $path + */ + public function setModuleDir($moduleName, $type, $path) + { + $this->_fileReader->setModuleDir($moduleName, $type, $path); + } +} diff --git a/app/code/core/Mage/Core/Model/Config/Modules/Sorted.php b/app/code/Mage/Core/Model/Config/Modules/Sorted.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Modules/Sorted.php rename to app/code/Mage/Core/Model/Config/Modules/Sorted.php diff --git a/app/code/core/Mage/Core/Model/Config/ModulesInterface.php b/app/code/Mage/Core/Model/Config/ModulesInterface.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/ModulesInterface.php rename to app/code/Mage/Core/Model/Config/ModulesInterface.php diff --git a/app/code/Mage/Core/Model/Config/Primary.php b/app/code/Mage/Core/Model/Config/Primary.php new file mode 100644 index 0000000000000..75458a25ea324 --- /dev/null +++ b/app/code/Mage/Core/Model/Config/Primary.php @@ -0,0 +1,259 @@ +%s'; + + /** + * Application installation timestamp + * + * @var int|null + */ + protected $_installDate; + + /** + * @var Mage_Core_Model_Config_Loader_Primary + */ + protected $_loader; + + /** + * Application parameter list + * + * @var array + */ + protected $_params; + + /** + * Directory list + * + * @var Mage_Core_Model_Dir + */ + protected $_dir; + + /** + * @param string $baseDir + * @param array $params + * @param Mage_Core_Model_Dir $dir + * @param Mage_Core_Model_Config_LoaderInterface $loader + */ + public function __construct( + $baseDir, array $params, Mage_Core_Model_Dir $dir = null, Mage_Core_Model_Config_LoaderInterface $loader = null + ) { + parent::__construct(''); + $this->_params = $params; + $this->_dir = $dir ?: new Mage_Core_Model_Dir( + new Magento_Filesystem(new Magento_Filesystem_Adapter_Local()), + $baseDir, + $this->getParam(Mage::PARAM_APP_URIS, array()), + $this->getParam(Mage::PARAM_APP_DIRS, array()) + ); + $this->_loader = $loader ?: new Mage_Core_Model_Config_Loader_Primary( + new Mage_Core_Model_Config_Loader_Local( + $this->_dir->getDir(Mage_Core_Model_Dir::CONFIG), + $this->getParam(Mage::PARAM_CUSTOM_LOCAL_CONFIG), + $this->getParam(Mage::PARAM_CUSTOM_LOCAL_FILE) + ), + $this->_dir->getDir(Mage_Core_Model_Dir::CONFIG) + ); + $this->_loader->load($this); + $this->_loadInstallDate(); + } + + /** + * Get init param + * + * @param string $name + * @param mixed $defaultValue + * @return mixed + */ + public function getParam($name, $defaultValue = null) + { + return isset($this->_params[$name]) ? $this->_params[$name] : $defaultValue; + } + + /** + * Load application installation date + */ + protected function _loadInstallDate() + { + $installDateNode = $this->getNode(self::XML_PATH_INSTALL_DATE); + if ($installDateNode) { + $this->_installDate = strtotime((string)$installDateNode); + } + } + + /** + * Retrieve application installation date as a timestamp or NULL, if it has not been installed yet + * + * @return int|null + */ + public function getInstallDate() + { + return $this->_installDate; + } + + /** + * Retrieve directories + * + * @return Mage_Core_Model_Dir + */ + public function getDirectories() + { + return $this->_dir; + } + + /** + * Reinitialize primary configuration + */ + public function reinit() + { + $this->loadString(''); + $this->_loader->load($this); + $this->_loadInstallDate(); + } + + /** + * Retrieve class definition config + * + * @return string + */ + public function getDefinitionPath() + { + $pathInfo = (array) $this->getNode('global/di/definitions'); + if (isset($pathInfo['path'])) { + return $pathInfo['path']; + } else if (isset($pathInfo['relativePath'])) { + return $this->_dir->getDir(Mage_Core_Model_Dir::ROOT) . DIRECTORY_SEPARATOR . $pathInfo['relativePath']; + } else { + return $this->_dir->getDir(Mage_Core_Model_Dir::DI) . DIRECTORY_SEPARATOR . 'definitions.php'; + } + } + + /** + * Retrieve definition format + * + * @return string + */ + public function getDefinitionFormat() + { + return (string) $this->getNode('global/di/definitions/format'); + } + + /** + * Configure object manager + * + * @param Magento_ObjectManager $objectManager + */ + public function configure(Magento_ObjectManager $objectManager) + { + Magento_Profiler::start('initial'); + $objectManager->configure(array( + 'Mage_Core_Model_App_State' => array( + 'parameters' => array( + 'mode' => $this->getParam(Mage::PARAM_MODE, Mage_Core_Model_App_State::MODE_DEFAULT), + ), + ), + 'Mage_Core_Model_Config_Loader_Local' => array( + 'parameters' => array( + 'customFile' => $this->getParam(Mage::PARAM_CUSTOM_LOCAL_FILE), + 'customConfig' => $this->getParam(Mage::PARAM_CUSTOM_LOCAL_CONFIG) + ) + ), + 'Mage_Core_Model_Config_Loader_Modules' => array( + 'parameters' => array( + 'allowedModules' => $this->getParam(Mage::PARAM_ALLOWED_MODULES, array()) + ) + ), + 'Mage_Core_Model_Cache_Frontend_Factory' => array( + 'parameters' => array( + 'enforcedOptions' => $this->getParam(Mage::PARAM_CACHE_OPTIONS, array()), + 'decorators' => $this->_getCacheFrontendDecorators(), + ) + ), + 'Mage_Core_Model_Cache_Types' => array( + 'parameters' => array( + 'banAll' => $this->getParam(Mage::PARAM_BAN_CACHE, false), + ) + ), + 'Mage_Core_Model_StoreManager' => array( + 'parameters' => array( + 'scopeCode' => $this->getParam(Mage::PARAM_RUN_CODE, ''), + 'scopeType' => $this->getParam(Mage::PARAM_RUN_TYPE, 'store'), + ) + ) + )); + + $configurators = $this->getNode('global/configurators'); + if ($configurators) { + $configurators = $configurators->asArray(); + if (count($configurators)) { + foreach ($configurators as $configuratorClass) { + /** @var $configurator Magento_ObjectManager_Configuration*/ + $configurator = $objectManager->create($configuratorClass, array('params' => $this->_params)); + $configurator->configure($objectManager); + } + } + } + Magento_Profiler::stop('initial'); + Magento_Profiler::start('global_primary'); + $diConfig = $this->getNode('global/di'); + if ($diConfig) { + $objectManager->configure($diConfig->asArray()); + } + + Magento_Profiler::stop('global_primary'); + } + + /** + * Retrieve cache frontend decorators configuration + * + * @return array + */ + protected function _getCacheFrontendDecorators() + { + $result = array(); + // mark all cache entries with a special tag to be able to clean only cache belonging to the application + $result[] = array( + 'class' => 'Magento_Cache_Frontend_Decorator_TagMarker', + 'parameters' => array('tag' => Mage_Core_Model_AppInterface::CACHE_TAG), + ); + if (Magento_Profiler::isEnabled()) { + $result[] = array( + 'class' => 'Magento_Cache_Frontend_Decorator_Profiler', + 'parameters' => array('backendPrefixes' => array('Zend_Cache_Backend_', 'Varien_Cache_Backend_')), + ); + } + return $result; + } +} diff --git a/app/code/core/Mage/Core/Model/Config/Resource.php b/app/code/Mage/Core/Model/Config/Resource.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Resource.php rename to app/code/Mage/Core/Model/Config/Resource.php diff --git a/app/code/core/Mage/Core/Model/Config/Sections.php b/app/code/Mage/Core/Model/Config/Sections.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Sections.php rename to app/code/Mage/Core/Model/Config/Sections.php diff --git a/app/code/core/Mage/Core/Model/Config/Storage.php b/app/code/Mage/Core/Model/Config/Storage.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Storage.php rename to app/code/Mage/Core/Model/Config/Storage.php diff --git a/app/code/core/Mage/Core/Model/Config/Storage/Locales.php b/app/code/Mage/Core/Model/Config/Storage/Locales.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Storage/Locales.php rename to app/code/Mage/Core/Model/Config/Storage/Locales.php diff --git a/app/code/core/Mage/Core/Model/Config/Storage/Modules.php b/app/code/Mage/Core/Model/Config/Storage/Modules.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Storage/Modules.php rename to app/code/Mage/Core/Model/Config/Storage/Modules.php diff --git a/app/code/core/Mage/Core/Model/Config/Storage/Writer/Db.php b/app/code/Mage/Core/Model/Config/Storage/Writer/Db.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Storage/Writer/Db.php rename to app/code/Mage/Core/Model/Config/Storage/Writer/Db.php diff --git a/app/code/core/Mage/Core/Model/Config/Storage/WriterInterface.php b/app/code/Mage/Core/Model/Config/Storage/WriterInterface.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/Storage/WriterInterface.php rename to app/code/Mage/Core/Model/Config/Storage/WriterInterface.php diff --git a/app/code/core/Mage/Core/Model/Config/StorageAbstract.php b/app/code/Mage/Core/Model/Config/StorageAbstract.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/StorageAbstract.php rename to app/code/Mage/Core/Model/Config/StorageAbstract.php diff --git a/app/code/core/Mage/Core/Model/Config/StorageInterface.php b/app/code/Mage/Core/Model/Config/StorageInterface.php similarity index 100% rename from app/code/core/Mage/Core/Model/Config/StorageInterface.php rename to app/code/Mage/Core/Model/Config/StorageInterface.php diff --git a/app/code/core/Mage/Core/Model/ConfigInterface.php b/app/code/Mage/Core/Model/ConfigInterface.php similarity index 100% rename from app/code/core/Mage/Core/Model/ConfigInterface.php rename to app/code/Mage/Core/Model/ConfigInterface.php diff --git a/app/code/Mage/Core/Model/Context.php b/app/code/Mage/Core/Model/Context.php new file mode 100644 index 0000000000000..982484ac71c7a --- /dev/null +++ b/app/code/Mage/Core/Model/Context.php @@ -0,0 +1,65 @@ +_eventDispatcher = $eventDispatcher; + $this->_cacheManager = $cacheManager; + } + + /** + * @return \Mage_Core_Model_CacheInterface + */ + public function getCacheManager() + { + return $this->_cacheManager; + } + + /** + * @return \Mage_Core_Model_Event_Manager + */ + public function getEventDispatcher() + { + return $this->_eventDispatcher; + } +} diff --git a/app/code/core/Mage/Core/Model/Cookie.php b/app/code/Mage/Core/Model/Cookie.php similarity index 100% rename from app/code/core/Mage/Core/Model/Cookie.php rename to app/code/Mage/Core/Model/Cookie.php diff --git a/app/code/Mage/Core/Model/Datasource/Config.php b/app/code/Mage/Core/Model/Datasource/Config.php new file mode 100644 index 0000000000000..d85f04a3b71fd --- /dev/null +++ b/app/code/Mage/Core/Model/Datasource/Config.php @@ -0,0 +1,156 @@ +_config = $config; + $this->init(); + } + + /** + * @param $alias + * @return array + * @throws Mage_Core_Exception + */ + public function getClassByAlias($alias) + { + $node = $this->_simpleXml->xpath("//service-call[@name='" . $alias . "']"); + + if (count($node) == 0) { + throw Mage::exception('Mage_Core', 'Service call with name "' . $alias . '" doesn\'t exist'); + } + + /** @var $node Mage_Core_Model_Config_Element */ + $node = current($node); + + $methodArguments = array(); + foreach ($node[0] as $child) { + if ($child->getName() == 'arg') { + $methodArguments[$child->getAttribute('name')] = (string)$child; + } + } + + $result = array( + 'class' => $node->getAttribute('service'), + 'retrieveMethod' => $node->getAttribute('method'), + 'methodArguments' => $methodArguments, + ); + + if (!$result['class']) { + throw Mage::exception('Mage_Core', 'Invalid Service call ' . $alias . ', service type must be defined in the "service" attribute'); + } + + return $result; + } + + /** + * @return SimpleXMLElement + */ + public function init() + { + $updatesRootPath = self::CONFIG_AREA . '/' . self::CONFIG_NODE; + $sourcesRoot = Mage::app()->getConfig()->getNode($updatesRootPath); + + /* Layout update files declared in configuration */ + $callsStr = ''; + if ($sourcesRoot) { + $callsStr = $this->_getServiceCallConfig($sourcesRoot); + } + + $this->_simpleXml = simplexml_load_string($callsStr, $this->_elementClass); + return $this->_simpleXml; + } + + /** + * @param Mage_Core_Model_Config_Element $sourcesRoot + * @return string + */ + public function _getServiceCallConfig($sourcesRoot) + { + $sourceFiles = array(); + foreach ($sourcesRoot->children() as $sourceNode) { + $sourceFiles[] = $this->_getServiceCallsFile($sourceNode); + } + + $callsStr = ''; + foreach ($sourceFiles as $filename) { + $fileStr = file_get_contents($filename); + + /** @var $fileXml Mage_Core_Model_Layout_Element */ + $fileXml = simplexml_load_string($fileStr, $this->_elementClass); + $callsStr .= $fileXml->innerXml(); + } + return '' . $callsStr . ''; + } + + /** + * @param Mage_Core_Model_Config_Element $sourceNode + * @return string + * @throws Magento_Exception + */ + protected function _getServiceCallsFile($sourceNode) + { + $file = (string)$sourceNode->file; + if (!$file) { + $sourceNodePath = $sourceNode->getName(); + throw new Magento_Exception( + "Service calls instruction '{$sourceNodePath}' must specify file." + ); + } + + $nameParts = array(); + if (strpos($file, '/') !== false) { + $nameParts = explode('/', $file); + } else { + throw new Magento_Exception("Module is missing in Service calls configuration: '{$file}'"); + } + $filename = $this->_config->getModuleDir('etc', $nameParts[0]) . '/' . $nameParts[1]; + if (!is_readable($filename)) { + throw new Magento_Exception("Service calls configuration file '{$filename}' doesn't exist or isn't readable."); + } + return $filename; + } +} diff --git a/app/code/Mage/Core/Model/Datasource/Request/Visitor.php b/app/code/Mage/Core/Model/Datasource/Request/Visitor.php new file mode 100644 index 0000000000000..2747662a06db5 --- /dev/null +++ b/app/code/Mage/Core/Model/Datasource/Request/Visitor.php @@ -0,0 +1,42 @@ +_request = $request; + } + + public function visit(Magento_Datasource_Path_Visitor $visitor) + { + $target = $visitor->getCurrentPathElement(); + switch ($target) { + case 'params': + return $this->_request->getParams(); + } + } +} \ No newline at end of file diff --git a/app/code/core/Mage/Core/Model/Date.php b/app/code/Mage/Core/Model/Date.php similarity index 100% rename from app/code/core/Mage/Core/Model/Date.php rename to app/code/Mage/Core/Model/Date.php diff --git a/app/code/Mage/Core/Model/Db/Updater.php b/app/code/Mage/Core/Model/Db/Updater.php new file mode 100644 index 0000000000000..b97425ff7fcb9 --- /dev/null +++ b/app/code/Mage/Core/Model/Db/Updater.php @@ -0,0 +1,160 @@ +_config = $modulesConfig; + $this->_factory = $factory; + $this->_appState = $appState; + } + + /** + * Check whether modules updates processing should be skipped + * + * @return bool + */ + protected function _shouldSkipProcessModulesUpdates() + { + if (!$this->_appState->isInstalled()) { + return false; + } + + $ignoreDevelopmentMode = (bool)(string)$this->_config->getNode(self::XML_PATH_IGNORE_DEV_MODE); + if (($this->_appState->getMode() == Mage_Core_Model_App_State::MODE_DEVELOPER) + && false == $ignoreDevelopmentMode + ) { + return false; + } + + return (bool)(string)$this->_config->getNode(self::XML_PATH_SKIP_PROCESS_MODULES_UPDATES); + } + + /** + * Apply database scheme updates whenever needed + */ + public function updateScheme() + { + if (true == $this->_shouldSkipProcessModulesUpdates()) { + return; + } + + Magento_Profiler::start('apply_db_schema_updates'); + $this->_appState->setUpdateMode(true); + + $resources = $this->_config->getNode('global/resources')->children(); + $afterApplyUpdates = array(); + foreach ($resources as $resName => $resource) { + if (!$resource->setup) { + continue; + } + $className = $this->_defaultClass; + if (isset($resource->setup->class)) { + $className = $resource->setup->getClassName(); + } + + $setupClass = $this->_factory->create($className, array('resourceName' => $resName)); + $setupClass->applyUpdates(); + + if ($setupClass->getCallAfterApplyAllUpdates()) { + $afterApplyUpdates[] = $setupClass; + } + } + + /** @var $setupClass Mage_Core_Model_Resource_SetupInterface*/ + foreach ($afterApplyUpdates as $setupClass) { + $setupClass->afterApplyAllUpdates(); + } + + $this->_appState->setUpdateMode(false); + $this->_schemaUpdatesChecked = true; + Magento_Profiler::stop('apply_db_schema_updates'); + } + + /** + * Apply database data updates whenever needed + */ + public function updateData() + { + if (!$this->_schemaUpdatesChecked) { + return; + } + $resources = $this->_config->getNode('global/resources')->children(); + foreach ($resources as $resName => $resource) { + if (!$resource->setup) { + continue; + } + $className = $this->_defaultClass; + if (isset($resource->setup->class)) { + $className = $resource->setup->getClassName(); + } + $setupClass = $this->_factory->create($className, array('resourceName' => $resName)); + $setupClass->applyDataUpdates(); + } + } +} diff --git a/app/code/core/Mage/Core/Model/Db/UpdaterInterface.php b/app/code/Mage/Core/Model/Db/UpdaterInterface.php similarity index 100% rename from app/code/core/Mage/Core/Model/Db/UpdaterInterface.php rename to app/code/Mage/Core/Model/Db/UpdaterInterface.php diff --git a/app/code/core/Mage/Core/Model/Design.php b/app/code/Mage/Core/Model/Design.php similarity index 100% rename from app/code/core/Mage/Core/Model/Design.php rename to app/code/Mage/Core/Model/Design.php diff --git a/app/code/core/Mage/Core/Model/Design/Backend/Exceptions.php b/app/code/Mage/Core/Model/Design/Backend/Exceptions.php similarity index 100% rename from app/code/core/Mage/Core/Model/Design/Backend/Exceptions.php rename to app/code/Mage/Core/Model/Design/Backend/Exceptions.php diff --git a/app/code/core/Mage/Core/Model/Design/Backend/Theme.php b/app/code/Mage/Core/Model/Design/Backend/Theme.php similarity index 100% rename from app/code/core/Mage/Core/Model/Design/Backend/Theme.php rename to app/code/Mage/Core/Model/Design/Backend/Theme.php diff --git a/app/code/Mage/Core/Model/Design/Fallback/List/File.php b/app/code/Mage/Core/Model/Design/Fallback/List/File.php new file mode 100644 index 0000000000000..c240ca2b8331e --- /dev/null +++ b/app/code/Mage/Core/Model/Design/Fallback/List/File.php @@ -0,0 +1,55 @@ +_dir->getDir(Mage_Core_Model_Dir::THEMES) . '//' + ), + new Mage_Core_Model_Design_Fallback_Rule_Simple( + $this->_dir->getDir(Mage_Core_Model_Dir::THEMES) . '///_', + array('namespace', 'module') + ), + )), + new Mage_Core_Model_Design_Fallback_Rule_Simple( + $this->_dir->getDir(Mage_Core_Model_Dir::MODULES) . '///view/', + array('namespace', 'module') + ) + ); + } +} diff --git a/app/code/Mage/Core/Model/Design/Fallback/List/ListAbstract.php b/app/code/Mage/Core/Model/Design/Fallback/List/ListAbstract.php new file mode 100644 index 0000000000000..cd0b697a47d91 --- /dev/null +++ b/app/code/Mage/Core/Model/Design/Fallback/List/ListAbstract.php @@ -0,0 +1,75 @@ +_dir = $dir; + $this->_rules = $this->_getFallbackRules(); + } + + /** + * Set rules in proper order for specific fallback procedure + * + * @return array of rules Mage_Core_Model_Design_Fallback_Rule_RuleInterface + */ + abstract protected function _getFallbackRules(); + + /** + * Get ordered list of folders to search for a file + * + * @param array $params - array of parameters + * @return array of folders to perform a search + */ + public function getPatternDirs(array $params) + { + $dirs = array(); + foreach ($this->_rules as $rule) { + $dirs = array_merge($dirs, $rule->getPatternDirs($params)); + } + return $dirs; + } +} diff --git a/app/code/Mage/Core/Model/Design/Fallback/List/Locale.php b/app/code/Mage/Core/Model/Design/Fallback/List/Locale.php new file mode 100644 index 0000000000000..fc8fdb474d5d6 --- /dev/null +++ b/app/code/Mage/Core/Model/Design/Fallback/List/Locale.php @@ -0,0 +1,47 @@ +_dir->getDir(Mage_Core_Model_Dir::THEMES) . '///locale/' + ) + )) + ); + } +} diff --git a/app/code/Mage/Core/Model/Design/Fallback/List/View.php b/app/code/Mage/Core/Model/Design/Fallback/List/View.php new file mode 100644 index 0000000000000..937e07653e36e --- /dev/null +++ b/app/code/Mage/Core/Model/Design/Fallback/List/View.php @@ -0,0 +1,76 @@ +_dir->getDir(Mage_Core_Model_Dir::THEMES); + $return[] = new Mage_Core_Model_Design_Fallback_Rule_Theme( + array( + new Mage_Core_Model_Design_Fallback_Rule_Simple( + $themeDir . '///locale/', + array('locale') + ), + new Mage_Core_Model_Design_Fallback_Rule_Simple( + $themeDir . '//' + ), + new Mage_Core_Model_Design_Fallback_Rule_Simple( + $themeDir . '///locale//_', + array('namespace', 'module', 'locale') + ), + new Mage_Core_Model_Design_Fallback_Rule_Simple( + $themeDir . '///_', + array('namespace', 'module') + ) + ) + ); + + $moduleDir = $this->_dir->getDir(Mage_Core_Model_Dir::MODULES); + $return[] = new Mage_Core_Model_Design_Fallback_Rule_Simple( + $moduleDir . '///view//locale/', + array('namespace', 'module', 'locale') + ); + $return[] = new Mage_Core_Model_Design_Fallback_Rule_Simple( + $moduleDir . '///view/', + array('namespace', 'module') + ); + + $return[] = new Mage_Core_Model_Design_Fallback_Rule_Simple( + $this->_dir->getDir(Mage_Core_Model_Dir::PUB_LIB) + ); + return $return; + } +} diff --git a/app/code/Mage/Core/Model/Design/Fallback/Rule/RuleInterface.php b/app/code/Mage/Core/Model/Design/Fallback/Rule/RuleInterface.php new file mode 100644 index 0000000000000..029f2985fb449 --- /dev/null +++ b/app/code/Mage/Core/Model/Design/Fallback/Rule/RuleInterface.php @@ -0,0 +1,39 @@ +_pattern = $pattern; + $this->_optionalParams = $optionalParams; + } + + /** + * Get ordered list of folders to search for a file + * + * @param array $params array of parameters + * @return array folders to perform a search + * @throws InvalidArgumentException + */ + public function getPatternDirs(array $params) + { + $pattern = $this->_pattern; + if (preg_match_all('/<([a-zA-Z\_]+)>/', $pattern, $matches)) { + foreach ($matches[1] as $placeholder) { + if (empty($params[$placeholder])) { + if (in_array($placeholder, $this->_optionalParams)) { + return array(); + } else { + throw new InvalidArgumentException("Required parameter '$placeholder' was not passed"); + } + } + $pattern = str_replace('<' . $placeholder . '>', $params[$placeholder], $pattern); + } + } + return array($pattern); + } +} diff --git a/app/code/Mage/Core/Model/Design/Fallback/Rule/Theme.php b/app/code/Mage/Core/Model/Design/Fallback/Rule/Theme.php new file mode 100644 index 0000000000000..7155b58cf16bb --- /dev/null +++ b/app/code/Mage/Core/Model/Design/Fallback/Rule/Theme.php @@ -0,0 +1,83 @@ +_rules = $rules; + } + + /** + * Get ordered list of folders to search for a file + * + * @param array $params - array of parameters + * @return array of folders to perform a search + * @throws InvalidArgumentException + */ + public function getPatternDirs(array $params) + { + if (!array_key_exists('theme', $params) || !($params['theme'] instanceof Mage_Core_Model_ThemeInterface)) { + throw new InvalidArgumentException( + '$params["theme"] should be passed and should implement Mage_Core_Model_ThemeInterface' + ); + } + $result = array(); + /** @var $theme Mage_Core_Model_ThemeInterface */ + $theme = $params['theme']; + while ($theme) { + if ($theme->getThemePath()) { + $params['theme_path'] = $theme->getThemePath(); + foreach ($this->_rules as $rule) { + $result = array_merge($result, $rule->getPatternDirs($params)); + } + } + $theme = $theme->getParentTheme(); + } + return $result; + } +} diff --git a/app/code/Mage/Core/Model/Design/FileResolution/Strategy/Fallback.php b/app/code/Mage/Core/Model/Design/FileResolution/Strategy/Fallback.php new file mode 100644 index 0000000000000..dbf8bb32ab1ef --- /dev/null +++ b/app/code/Mage/Core/Model/Design/FileResolution/Strategy/Fallback.php @@ -0,0 +1,170 @@ +_dirs = $dirs; + $this->_objectManager = $objectManager; + $this->_filesystem = $filesystem; + $this->_fallbackFile = $fallbackFile; + $this->_fallbackLocale = $fallbackLocale; + $this->_fallbackViewFile = $fallbackViewFile; + } + + /** + * Get existing file name, using fallback mechanism + * + * @param string $area + * @param Mage_Core_Model_Theme $themeModel + * @param string $file + * @param string|null $module + * @return string + */ + public function getFile($area, Mage_Core_Model_Theme $themeModel, $file, $module = null) + { + $params = array(); + if ($module) { + list($params['namespace'], $params['module']) = explode('_', $module); + } else { + $params['namespace'] = null; + $params['module'] = null; + } + return $this->_getFallbackFile($area, $themeModel, $file, $this->_fallbackFile, $params); + } + + /** + * Get locale file name, using fallback mechanism + * + * @param string $area + * @param Mage_Core_Model_Theme $themeModel + * @param string $locale + * @param string $file + * @return string + */ + public function getLocaleFile($area, Mage_Core_Model_Theme $themeModel, $locale, $file) + { + $params = array('locale' => $locale); + + return $this->_getFallbackFile($area, $themeModel, $file, $this->_fallbackLocale, $params); + } + + /** + * Get theme file name, using fallback mechanism + * + * @param string $area + * @param Mage_Core_Model_Theme $themeModel + * @param string $locale + * @param string $file + * @param string|null $module + * @return string + */ + public function getViewFile($area, Mage_Core_Model_Theme $themeModel, $locale, $file, $module = null) + { + $params = array(); + if ($module) { + list($params['namespace'], $params['module']) = explode('_', $module); + } else { + $params['namespace'] = null; + $params['module'] = null; + } + $params['locale'] = $locale; + + return $this->_getFallbackFile($area, $themeModel, $file, $this->_fallbackViewFile, $params); + } + + /** + * Get path of file after using fallback rules + * + * @param string $area + * @param Mage_Core_Model_Theme $themeModel + * @param string $file + * @param Mage_Core_Model_Design_Fallback_Rule_RuleInterface $fallbackList + * @param array $specificParams + * @return string + */ + protected function _getFallbackFile($area, Mage_Core_Model_Theme $themeModel, $file, + Mage_Core_Model_Design_Fallback_Rule_RuleInterface $fallbackList, $specificParams = array() + ) { + $params = array( + 'area' => $area, + 'theme' => $themeModel, + ); + $params = array_merge($params, $specificParams); + $path = ''; + + foreach ($fallbackList->getPatternDirs($params) as $dir) { + $path = str_replace('/', DIRECTORY_SEPARATOR, "{$dir}/{$file}"); + if ($this->_filesystem->has($path)) { + return $path; + } + } + return $path; + } +} diff --git a/app/code/Mage/Core/Model/Design/FileResolution/Strategy/Fallback/CachingProxy.php b/app/code/Mage/Core/Model/Design/FileResolution/Strategy/Fallback/CachingProxy.php new file mode 100644 index 0000000000000..e9d2a632731b6 --- /dev/null +++ b/app/code/Mage/Core/Model/Design/FileResolution/Strategy/Fallback/CachingProxy.php @@ -0,0 +1,288 @@ +_fallback = $fallback; + $this->_filesystem = $filesystem; + if (!$filesystem->isDirectory($baseDir)) { + throw new InvalidArgumentException("Wrong base directory specified: '{$baseDir}'"); + } + $this->_baseDir = $baseDir; + $this->_mapDir = $mapDir; + $this->_canSaveMap = $canSaveMap; + } + + /** + * Write the serialized map to the section files + */ + public function __destruct() + { + if (!$this->_canSaveMap) { + return; + } + if (!$this->_filesystem->isDirectory($this->_mapDir)) { + $this->_filesystem->createDirectory($this->_mapDir, 0777); + } + foreach ($this->_sections as $sectionFile => $section) { + if (!$section['is_changed']) { + continue; + } + $filePath = $this->_mapDir . DIRECTORY_SEPARATOR . $sectionFile; + $this->_filesystem->write($filePath, serialize($section['data'])); + } + } + + /** + * Proxy to Mage_Core_Model_Design_FileResolution_Strategy_Fallback::getFile() + * + * @param string $area + * @param Mage_Core_Model_Theme $themeModel + * @param string $file + * @param string|null $module + * @return string + */ + public function getFile($area, Mage_Core_Model_Theme $themeModel, $file, $module = null) + { + $result = $this->_getFromMap('file', $area, $themeModel, null, $module, $file); + if (!$result) { + $result = $this->_fallback->getFile($area, $themeModel, $file, $module); + $this->_setToMap('file', $area, $themeModel, null, $module, $file, $result); + } + return $result; + } + + /** + * Proxy to Mage_Core_Model_Design_FileResolution_Strategy_Fallback::getLocaleFile() + * + * @param string $area + * @param Mage_Core_Model_Theme $themeModel + * @param string $locale + * @param string $file + * @return string + */ + public function getLocaleFile($area, Mage_Core_Model_Theme $themeModel, $locale, $file) + { + $result = $this->_getFromMap('locale', $area, $themeModel, $locale, null, $file); + if (!$result) { + $result = $this->_fallback->getLocaleFile($area, $themeModel, $locale, $file); + $this->_getFromMap('locale', $area, $themeModel, $locale, null, $file, $result); + } + return $result; + } + + /** + * Proxy to Mage_Core_Model_Design_FileResolution_Strategy_Fallback::getViewFile() + * + * @param string $area + * @param Mage_Core_Model_Theme $themeModel + * @param string $locale + * @param string $file + * @param string|null $module + * @return string + */ + public function getViewFile($area, Mage_Core_Model_Theme $themeModel, $locale, $file, $module = null) + { + $result = $this->_getFromMap('view', $area, $themeModel, $locale, $module, $file); + if (!$result) { + $result = $this->_fallback->getViewFile($area, $themeModel, $locale, $file, $module); + $this->_getFromMap('view', $area, $themeModel, $locale, $module, $file, $result); + } + return $result; + } + + /** + * Get stored full file path + * + * @param string $fileType + * @param string $area + * @param Mage_Core_Model_Theme $theme + * @param string|null $locale + * @param string|null $module + * @param string $file + * @return null|string + */ + protected function _getFromMap($fileType, $area, Mage_Core_Model_Theme $theme, $locale, $module, $file) + { + $sectionKey = $this->_loadSection($area, $theme, $locale); + $fileKey = "$fileType|$file|$module"; + if (isset($this->_sections[$sectionKey]['data'][$fileKey])) { + $value = $this->_sections[$sectionKey]['data'][$fileKey]; + if ('' !== (string)$value) { + $value = $this->_baseDir . DIRECTORY_SEPARATOR . $value; + } + return $value; + } + return null; + } + + /** + * Set stored full file path + * + * @param string $fileType + * @param string $area + * @param Mage_Core_Model_Theme $theme + * @param string|null $locale + * @param string|null $module + * @param string $file + * @param string $filePath + * @throws Magento_Exception + */ + protected function _setToMap($fileType, $area, Mage_Core_Model_Theme $theme, $locale, $module, $file, $filePath) + { + $pattern = $this->_baseDir . DIRECTORY_SEPARATOR; + if (0 !== strpos($filePath, $pattern)) { + throw new Magento_Exception( + "Attempt to store fallback path '{$filePath}', which is not within '{$pattern}'" + ); + } + $value = substr($filePath, strlen($pattern)); + + $sectionKey = $this->_loadSection($area, $theme, $locale); + $fileKey = "$fileType|$file|$module"; + $this->_sections[$sectionKey]['data'][$fileKey] = $value; + $this->_sections[$sectionKey]['is_changed'] = true; + } + + /** + * Compose section file name + * + * @param string $area + * @param Mage_Core_Model_Theme $themeModel + * @param string|null $locale + * @return string + */ + protected function _getSectionFile($area, Mage_Core_Model_Theme $themeModel, $locale) + { + $theme = $themeModel->getId() ?: md5($themeModel->getThemePath()); + return "{$area}_{$theme}_{$locale}.ser"; + } + + /** + * Load section and return its key + * + * @param string $area + * @param Mage_Core_Model_Theme $themeModel + * @param string|null $locale + * @return string + */ + protected function _loadSection($area, Mage_Core_Model_Theme $themeModel, $locale) + { + $sectionFile = $this->_getSectionFile($area, $themeModel, $locale); + if (!isset($this->_sections[$sectionFile])) { + $filePath = $this->_mapDir . DIRECTORY_SEPARATOR . $sectionFile; + $this->_sections[$sectionFile] = array( + 'data' => array(), + 'is_changed' => false, + ); + if ($this->_filesystem->isFile($filePath)) { + $this->_sections[$sectionFile]['data'] = unserialize($this->_filesystem->read($filePath)); + } + } + return $sectionFile; + } + + /** + * Set file path to map. + * + * @param string $area + * @param Mage_Core_Model_Theme $themeModel + * @param string $locale + * @param string|null $module + * @param string $file + * @param string $newFilePath + * @return Mage_Core_Model_Design_FileResolution_Strategy_Fallback_CachingProxy + */ + public function setViewFilePathToMap($area, Mage_Core_Model_Theme $themeModel, $locale, $module, $file, + $newFilePath + ) { + $this->_setToMap('view', $area, $themeModel, $locale, $module, $file, $newFilePath); + return $this; + } +} diff --git a/app/code/Mage/Core/Model/Design/FileResolution/Strategy/FileInterface.php b/app/code/Mage/Core/Model/Design/FileResolution/Strategy/FileInterface.php new file mode 100644 index 0000000000000..aac4969abaf7d --- /dev/null +++ b/app/code/Mage/Core/Model/Design/FileResolution/Strategy/FileInterface.php @@ -0,0 +1,42 @@ + array( + 'file' => 'Mage_Core_Model_Design_FileResolution_Strategy_Fallback_CachingProxy', + 'locale' => 'Mage_Core_Model_Design_FileResolution_Strategy_Fallback', + 'view' => 'Mage_Core_Model_Design_FileResolution_Strategy_Fallback', + ), + 'caching_map' => array( + 'file' => 'Mage_Core_Model_Design_FileResolution_Strategy_Fallback_CachingProxy', + 'locale' => 'Mage_Core_Model_Design_FileResolution_Strategy_Fallback_CachingProxy', + 'view' => 'Mage_Core_Model_Design_FileResolution_Strategy_Fallback_CachingProxy', + ), + 'full_check' => array( + 'file' => 'Mage_Core_Model_Design_FileResolution_Strategy_Fallback', + 'locale' => 'Mage_Core_Model_Design_FileResolution_Strategy_Fallback', + 'view' => 'Mage_Core_Model_Design_FileResolution_Strategy_Fallback', + ), + ); + + /** + * @param Magento_ObjectManager $objectManager + * @param Mage_Core_Model_App_State $appState + * @param Mage_Core_Model_Dir $dirs + * @param Magento_Filesystem $filesystem + */ + public function __construct( + Magento_ObjectManager $objectManager, + Mage_Core_Model_App_State $appState, + Mage_Core_Model_Dir $dirs, + Magento_Filesystem $filesystem + ) { + $this->_objectManager = $objectManager; + $this->_appState = $appState; + $this->_filesystem = $filesystem; + $this->_dirs = $dirs; + } + + /** + * Get strategy to resolve dynamic files (e.g. templates) + * + * @param bool $skipProxy + * @return Mage_Core_Model_Design_FileResolution_Strategy_FileInterface + */ + public function getFileStrategy($skipProxy = false) + { + return $this->_getStrategy('file', $skipProxy); + } + + /** + * * Get strategy to resolve locale files (e.g. locale settings) + * + * @param bool $skipProxy + * @return Mage_Core_Model_Design_FileResolution_Strategy_LocaleInterface + */ + public function getLocaleStrategy($skipProxy = false) + { + return $this->_getStrategy('locale', $skipProxy); + } + + /** + * Get strategy to resolve static view files (e.g. javascripts) + * + * @param bool $skipProxy + * @return Mage_Core_Model_Design_FileResolution_Strategy_ViewInterface + */ + public function getViewStrategy($skipProxy = false) + { + return $this->_getStrategy('view', $skipProxy); + } + + /** + * Determine the strategy to be used. Create or get it from the pool. + * + * @param string $fileType + * @param bool $skipProxy + * @return mixed + */ + protected function _getStrategy($fileType, $skipProxy = false) + { + $strategyClass = $this->_getStrategyClass($fileType, $skipProxy); + if (!isset($this->_strategyPool[$strategyClass])) { + $this->_strategyPool[$strategyClass] = $this->_createStrategy($strategyClass); + } + return $this->_strategyPool[$strategyClass]; + } + + /** + * Find the class of strategy, that must be used to resolve files of $fileType + * + * @param string $fileType + * @param bool $skipProxy + * @return string + * @throws Mage_Core_Exception + */ + protected function _getStrategyClass($fileType, $skipProxy = false) + { + $mode = $this->_appState->getMode(); + if ($mode == Mage_Core_Model_App_State::MODE_PRODUCTION) { + $strategyClasses = $this->_strategies['production_mode']; + } else if (($mode == Mage_Core_Model_App_State::MODE_DEVELOPER) || $skipProxy) { + $strategyClasses = $this->_strategies['full_check']; + } else if ($mode == Mage_Core_Model_App_State::MODE_DEFAULT) { + $strategyClasses = $this->_strategies['caching_map']; + } else { + throw new Mage_Core_Exception("Unknown mode to choose strategy: {$mode}"); + } + return $strategyClasses[$fileType]; + } + + /** + * Create strategy by its class name + * + * @param string $className + * @return mixed + */ + protected function _createStrategy($className) + { + switch ($className) { + case 'Mage_Core_Model_Design_FileResolution_Strategy_Fallback_CachingProxy': + $mapDir = $this->_dirs->getDir(Mage_Core_Model_Dir::VAR_DIR) . DIRECTORY_SEPARATOR + . self::FALLBACK_MAP_DIR; + $arguments = array( + 'mapDir' => str_replace('/', DIRECTORY_SEPARATOR, $mapDir), + 'baseDir' => $this->_dirs->getDir(Mage_Core_Model_Dir::ROOT), + 'canSaveMap' => (bool)(string)$this->_objectManager->get('Mage_Core_Model_Config') + ->getNode(self::XML_PATH_ALLOW_MAP_UPDATE), + ); + break; + default: + $arguments = array(); + break; + } + return $this->_objectManager->create($className, $arguments); + } +} diff --git a/app/code/core/Mage/Core/Model/Design/Package.php b/app/code/Mage/Core/Model/Design/Package.php similarity index 78% rename from app/code/core/Mage/Core/Model/Design/Package.php rename to app/code/Mage/Core/Model/Design/Package.php index c9a37e27eaee8..2fb3419087555 100644 --- a/app/code/core/Mage/Core/Model/Design/Package.php +++ b/app/code/Mage/Core/Model/Design/Package.php @@ -27,7 +27,18 @@ class Mage_Core_Model_Design_Package implements Mage_Core_Model_Design_PackageInterface { + /** + * Regular expressions matches cache + * + * @var array + */ private static $_regexMatchCache = array(); + + /** + * Custom theme type cache + * + * @var array + */ private static $_customThemeTypeCache = array(); /** @@ -54,6 +65,7 @@ class Mage_Core_Model_Design_Package implements Mage_Core_Model_Design_PackageIn /** * Directory of the css file * Using only to transmit additional parameter in callback functions + * * @var string */ protected $_callbackFileDir; @@ -66,19 +78,11 @@ class Mage_Core_Model_Design_Package implements Mage_Core_Model_Design_PackageIn protected $_viewConfigs = array(); /** - * Published file cache storage + * Model, used to resolve the file paths * - * @var array + * @var Mage_Core_Model_Design_FileResolution_StrategyPool */ - protected $_publicCache = array(); - - /** - * Array of fallback model, controlling rules of fallback and inheritance for appropriate - * area, package, theme, locale - * - * @var array - */ - protected $_fallback = array(); + protected $_resolutionPool = null; /** * Array of theme model used for fallback mechanism @@ -99,16 +103,29 @@ class Mage_Core_Model_Design_Package implements Mage_Core_Model_Design_PackageIn */ protected $_filesystem; + /** + * @var Mage_Core_Model_App_State + */ + protected $_appState; + /** * @param Mage_Core_Model_Config_Modules_Reader $moduleReader * @param Magento_Filesystem $filesystem + * @param Mage_Core_Model_Design_FileResolution_StrategyPool $resolutionPool + * @param Mage_Core_Model_App_State $appState */ - public function __construct(Mage_Core_Model_Config_Modules_Reader $moduleReader, Magento_Filesystem $filesystem) - { + public function __construct( + Mage_Core_Model_Config_Modules_Reader $moduleReader, + Magento_Filesystem $filesystem, + Mage_Core_Model_Design_FileResolution_StrategyPool $resolutionPool, + Mage_Core_Model_App_State $appState + ) { $this->_moduleReader = $moduleReader; $this->_filesystem = $filesystem; + $this->_resolutionPool = $resolutionPool; + $this->_appState = $appState; } - + /** * Set package area * @@ -144,8 +161,9 @@ public function getArea() */ protected function _getLoadDesignTheme($themeId, $area = self::DEFAULT_AREA) { - if (isset($this->_themes[$themeId])) { - return $this->_themes[$themeId]; + $key = sprintf('%s/%s', $area, $themeId); + if (isset($this->_themes[$key])) { + return $this->_themes[$key]; } if (is_numeric($themeId)) { @@ -156,7 +174,7 @@ protected function _getLoadDesignTheme($themeId, $area = self::DEFAULT_AREA) $collection = $this->getDesignTheme()->getCollection(); $themeModel = $collection->getThemeByFullPath($area . '/' . $themeId); } - $this->_themes[$themeId] = $themeModel; + $this->_themes[$key] = $themeModel; return $themeModel; } @@ -285,7 +303,9 @@ public function getFilename($file, array $params = array()) { $file = $this->_extractScope($file, $params); $this->_updateParamDefaults($params); - return $this->_getFallback($params)->getFile($file, $params['module']); + $skipProxy = isset($params['skipProxy']) && $params['skipProxy']; + return $this->_resolutionPool->getFileStrategy($skipProxy)->getFile($params['area'], $params['themeModel'], + $file, $params['module']); } /** @@ -298,7 +318,9 @@ public function getFilename($file, array $params = array()) public function getLocaleFileName($file, array $params = array()) { $this->_updateParamDefaults($params); - return $this->_getFallback($params)->getLocaleFile($file); + $skipProxy = isset($params['skipProxy']) && $params['skipProxy']; + return $this->_resolutionPool->getLocaleStrategy($skipProxy)->getLocaleFile($params['area'], + $params['themeModel'], $params['locale'], $file); } /** @@ -312,7 +334,9 @@ public function getViewFile($file, array $params = array()) { $file = $this->_extractScope($file, $params); $this->_updateParamDefaults($params); - return $this->_getFallback($params)->getViewFile($file, $params['module']); + $skipProxy = isset($params['skipProxy']) && $params['skipProxy']; + return $this->_resolutionPool->getViewStrategy($skipProxy)->getViewFile($params['area'], + $params['themeModel'], $params['locale'], $file, $params['module']); } /** @@ -340,90 +364,44 @@ protected function _extractScope($file, array &$params) } /** - * Update file path in map while we use caching mechanism + * Notify that view file resolved path was changed (i.e. it was published to a public directory) * - * @param string $targetPath - * @param string $themeFile * @param array $params * @return Mage_Core_Model_Design_Package */ - public function updateFilePathInMap($targetPath, $themeFile, $params) + protected function _notifyViewFileLocationChanged($targetPath, $themeFile, $params) { - $themeFile = $this->_extractScope($themeFile, $params); - $this->_updateParamDefaults($params); - $fallback = $this->_getFallback($params); - /** @var $fallback Mage_Core_Model_Design_Fallback_CachingProxy */ - if ($fallback instanceof Mage_Core_Model_Design_Fallback_CachingProxy) { - $fallback->setFilePathToMap($targetPath, $themeFile, $params['module']); + $skipProxy = isset($params['skipProxy']) && $params['skipProxy']; + $strategy = $this->_resolutionPool->getViewStrategy($skipProxy); + if ($strategy instanceof Mage_Core_Model_Design_FileResolution_Strategy_View_NotifiableInterface) { + /** @var $strategy Mage_Core_Model_Design_FileResolution_Strategy_View_NotifiableInterface */ + $themeFile = $this->_extractScope($themeFile, $params); + $this->_updateParamDefaults($params); + $strategy->setViewFilePathToMap($params['area'], $params['themeModel'], $params['locale'], + $params['module'], $themeFile, $targetPath); } - return $this; - } - /** - * Return most appropriate model to perform fallback - * - * @param array $params - * @return Mage_Core_Model_Design_FallbackInterface - */ - protected function _getFallback($params) - { - $skipProxy = (isset($params['skipProxy']) && $params['skipProxy']) ?: $this->_isDeveloperMode(); - - $cacheKey = join('|', array( - $params['area'], - $params['themeModel']->getCacheKey(), - $params['locale'], - $skipProxy - )); - if (!isset($this->_fallback[$cacheKey])) { - $fallback = Mage::getObjectManager()->create('Mage_Core_Model_Design_Fallback', array('params' => $params)); - if ($skipProxy) { - $this->_fallback[$cacheKey] = $fallback; - } else { - /** @var $dirs Mage_Core_Model_Dir */ - $dirs = Mage::getObjectManager()->get('Mage_Core_Model_Dir'); - $proxy = new Mage_Core_Model_Design_Fallback_CachingProxy( - $fallback, - $this->_filesystem, - $dirs->getDir(Mage_Core_Model_Dir::VAR_DIR) . DIRECTORY_SEPARATOR . self::FALLBACK_MAP_DIR, - $dirs->getDir(Mage_Core_Model_Dir::ROOT), - (bool)(string)Mage::app()->getConfig()->getNode(self::XML_PATH_ALLOW_MAP_UPDATE) - ); - $this->_fallback[$cacheKey] = $proxy; - } - } - return $this->_fallback[$cacheKey]; + return $this; } /** - * Create fallback model + * Return whether developer mode is turned on * - * @param array $params - * @return Mage_Core_Model_Design_Fallback|Mage_Core_Model_Design_Fallback_CachingProxy + * @return bool */ - protected function _createFallback($params) + protected function _getAppMode() { - $model = 'Mage_Core_Model_Design_Fallback_CachingProxy'; - if (isset($params['skipProxy']) && $params['skipProxy']) { - $model = 'Mage_Core_Model_Design_Fallback'; - } - - $params['canSaveMap'] = (bool) (string) Mage::app()->getConfig() - ->getNode('global/dev/design_fallback/allow_map_update'); - $params['mapDir'] = Mage::getConfig()->getTempVarDir() . '/maps/fallback'; - $params['baseDir'] = Mage::getBaseDir(); - - return Mage::getModel($model, array('data' => $params)); + return $this->_appState->getMode(); } /** - * Return whether developer mode is turned on + * Verify whether we should work with files * * @return bool */ - protected function _isDeveloperMode() + protected function _isViewFileOperationAllowed() { - return Mage::getIsDeveloperMode(); + return $this->_getAppMode() != Mage_Core_Model_App_State::MODE_PRODUCTION; } /** @@ -457,9 +435,14 @@ public static function getPackageByUserAgent(array $rules, $regexpsConfigPath = * Remove all merged js/css files * * @return bool + * @throws Magento_Exception */ public function cleanMergedJsCss() { + if (!$this->isMergingViewFilesAllowed()) { + throw new Magento_Exception('Cleaning of merged view files is not allowed'); + } + $dir = $this->_buildPublicViewFilename(self::PUBLIC_MERGE_DIR); try { $this->_filesystem->delete($dir); @@ -483,16 +466,31 @@ public function getViewFileUrl($file, array $params = array()) $isSecure = isset($params['_secure']) ? (bool) $params['_secure'] : null; unset($params['_secure']); $this->_updateParamDefaults($params); - /* Identify public file */ - $publicFile = $this->_publishViewFile($file, $params); - /* Build url to public file */ - if (Mage::helper('Mage_Core_Helper_Data')->isStaticFilesSigned()) { - $fileMTime = $this->_filesystem->getMTime($publicFile); - $url = $this->_getPublicFileUrl($publicFile, $isSecure); - $url .= '?' . $fileMTime; + $file = $this->_extractScope($file, $params); + + // Build public url to it + if ($this->_isViewFileOperationAllowed()) { + /* Identify public file */ + $publicFile = $this->_publishViewFile($file, $params); + /* Build url to public file */ + $url = $this->getPublicFileUrl($publicFile, $isSecure); + if (Mage::helper('Mage_Core_Helper_Data')->isStaticFilesSigned()) { + $fileMTime = $this->_filesystem->getMTime($publicFile); + $url .= '?' . $fileMTime; + } } else { - $url = $this->_getPublicFileUrl($publicFile, $isSecure); + /** @var $themeModel Mage_Core_Model_Theme */ + $themeModel = $params['themeModel']; + $themePath = $themeModel->getThemePath(); + if (!$themePath) { + // For virtual themes we get path from the parent + $themePath = $themeModel->getParentTheme()->getThemePath(); + } + $subPath = self::getPublishedViewFileRelPath($params['area'], $themePath, $params['locale'], $file, + $params['module']); + $url = $this->getPublicFileUrl($this->getPublicDir() . DIRECTORY_SEPARATOR . $subPath, $isSecure); } + return $url; } @@ -504,12 +502,14 @@ public function getViewFileUrl($file, array $params = array()) * @return string * @throws Magento_Exception */ - protected function _getPublicFileUrl($file, $isSecure = null) + public function getPublicFileUrl($file, $isSecure = null) { foreach (array( - Mage_Core_Model_Store::URL_TYPE_LIB => Mage_Core_Model_Dir::PUB_LIB, - Mage_Core_Model_Store::URL_TYPE_MEDIA => Mage_Core_Model_Dir::MEDIA - ) as $urlType => $dirType) { + Mage_Core_Model_Store::URL_TYPE_LIB => Mage_Core_Model_Dir::PUB_LIB, + Mage_Core_Model_Store::URL_TYPE_MEDIA => Mage_Core_Model_Dir::MEDIA, + Mage_Core_Model_Store::URL_TYPE_STATIC => Mage_Core_Model_Dir::STATIC_VIEW + ) as $urlType => $dirType + ) { $dir = Mage::getBaseDir($dirType); if (strpos($file, $dir) === 0) { $relativePath = ltrim(substr($file, strlen($dir)), DIRECTORY_SEPARATOR); @@ -522,63 +522,6 @@ protected function _getPublicFileUrl($file, $isSecure = null) ); } - /** - * Get URLs to CSS files optimized based on configuration settings - * - * @param array $files - * @return array - */ - public function getOptimalCssUrls($files) - { - return $this->_getOptimalUrls( - $files, - self::CONTENT_TYPE_CSS, - Mage::getStoreConfigFlag('dev/css/merge_css_files') - ); - } - - /** - * Get URLs to JS files optimized based on configuration settings - * - * @param array $files - * @return array - */ - public function getOptimalJsUrls($files) - { - return $this->_getOptimalUrls( - $files, - self::CONTENT_TYPE_JS, - Mage::getStoreConfigFlag('dev/js/merge_files') - ); - } - - /** - * Prepare urls to files based on files type and merging option value - * - * @param array $files - * @param string $type - * @param bool $doMerge - * @return array - */ - protected function _getOptimalUrls($files, $type, $doMerge) - { - $urls = array(); - if ($doMerge && count($files) > 1) { - $file = $this->_mergeFiles($files, $type); - if (Mage::helper('Mage_Core_Helper_Data')->isStaticFilesSigned()) { - $fileMTime = $this->_filesystem->getMTime($file); - $urls[] = $this->_getPublicFileUrl($file) . '?' . $fileMTime; - } else { - $urls[] = $this->_getPublicFileUrl($file); - } - } else { - foreach ($files as $file) { - $urls[] = $this->getViewFileUrl($file); - } - } - return $urls; - } - /** * Check, if requested theme file has public access, and move it to public folder, if the file has no public access * @@ -589,11 +532,16 @@ protected function _getOptimalUrls($files, $type, $doMerge) */ protected function _publishViewFile($themeFile, $params) { - $themeFile = $this->_extractScope($themeFile, $params); + if (!$this->_isViewFileOperationAllowed()) { + throw new Magento_Exception('Filesystem operations are not permitted for view files'); + } + $sourcePath = $this->getViewFile($themeFile, $params); $minifiedSourcePath = $this->_minifiedPathForStaticFiles($sourcePath); - if ($minifiedSourcePath && !Mage::getIsDeveloperMode() && $this->_filesystem->has($minifiedSourcePath)) { + if ($minifiedSourcePath && ($this->_getAppMode() != Mage_Core_Model_App_State::MODE_DEVELOPER) + && $this->_filesystem->has($minifiedSourcePath) + ) { $sourcePath = $minifiedSourcePath; $themeFile = $this->_minifiedPathForStaticFiles($themeFile); } @@ -610,7 +558,6 @@ protected function _publishViewFile($themeFile, $params) $targetPath = $this->_buildPublicViewRedundantFilename($themeFile, $params); } else { $targetPath = $this->_buildPublicViewSufficientFilename($sourcePath, $params); - $this->_setPublicFileIntoCache($themeFile, $params, $targetPath); } $targetPath = $this->_buildPublicViewFilename($targetPath); @@ -637,7 +584,7 @@ protected function _publishViewFile($themeFile, $params) } } - $this->updateFilePathInMap($targetPath, $themeFile, $params); + $this->_notifyViewFileLocationChanged($targetPath, $themeFile, $params); return $targetPath; } @@ -680,7 +627,8 @@ protected function _needToProcessFile($filePath) return true; } - return $this->_isDeveloperMode() && $this->_getExtension($filePath) == self::CONTENT_TYPE_CSS; + return ($this->_getAppMode() == Mage_Core_Model_App_State::MODE_DEVELOPER) + && $this->_getExtension($filePath) == self::CONTENT_TYPE_CSS; } /** @@ -713,7 +661,7 @@ protected function _buildPublicViewFilename($file) */ public function getPublicDir() { - return Mage::getBaseDir(Mage_Core_Model_Dir::THEME) . DIRECTORY_SEPARATOR . self::PUBLIC_BASE_THEME_DIR; + return Mage::getBaseDir(Mage_Core_Model_Dir::STATIC_VIEW); } /** @@ -819,7 +767,7 @@ protected function _getPublicCssContent($filePath, $publicDir, $fileName, $param protected function _publishRelatedViewFile($fileUrl, $parentFilePath, $parentFileName, $params) { if (strpos($fileUrl, self::SCOPE_SEPARATOR)) { - $relativeThemeFile = $fileUrl; + $relativeThemeFile = $this->_extractScope($fileUrl, $params); } else { /* Check if module file overridden on theme level based on _module property and file path */ if ($params['module'] && strpos($parentFilePath, Mage::getBaseDir(Mage_Core_Model_Dir::THEMES)) === 0) { @@ -877,6 +825,25 @@ protected function _canonize($filename, $isRelative = false) return $prefix . implode('/', $result); } + /** + * Build a relative path to a static view file, if published with duplication. + * + * Just concatenates all context arguments. + * Note: despite $locale is specified, it is currently ignored. + * + * @param string $area + * @param string $themePath + * @param string $locale + * @param string $file + * @param string|null $module + * @return string + */ + public static function getPublishedViewFileRelPath($area, $themePath, $locale, $file, $module = null) + { + return $area . DIRECTORY_SEPARATOR . $themePath . DIRECTORY_SEPARATOR + . ($module ? $module . DIRECTORY_SEPARATOR : '') . $file; + } + /** * Merge files, located under the same folder, into one and return file name of merged file * @@ -885,8 +852,12 @@ protected function _canonize($filename, $isRelative = false) * @return string * @throws Magento_Exception if not existing file requested for merge */ - protected function _mergeFiles($files, $contentType) + public function mergeFiles($files, $contentType) { + if (!$this->isMergingViewFilesAllowed()) { + throw new Magento_Exception('Merging of view files is not allowed'); + } + $filesToMerge = array(); $mergedFile = array(); $jsDir = Mage::getBaseDir(Mage_Core_Model_Dir::PUB_LIB); @@ -929,11 +900,22 @@ protected function _mergeFiles($files, $contentType) if ($contentType == self::CONTENT_TYPE_CSS) { $result = $this->_popCssImportsUp($result); } + $this->_filesystem->write($mergedFile, $result); $this->_filesystem->write($mergedMTimeFile, $filesMTimeData); return $mergedFile; } + /** + * Return whether view files merging is allowed or not + * + * @return bool + */ + public function isMergingViewFilesAllowed() + { + return $this->_isViewFileOperationAllowed(); + } + /** * Replace relative URLs in the CSS content with ones shifted by the directories offset * @@ -1017,77 +999,27 @@ protected function _popCssImportsUp($contents) return $result; } - /** - * Get hash key for requested file and parameters - * - * @param string $file - * @param array $params - * @return string - */ - protected function _getRequestedFileKey($file, $params) - { - ksort($params); - return md5($this->_getRequestedFileCacheKey($params) . '|' . $file); - } - - /** - * Get cache key for parameters - * - * @param array $params - * @return string - */ - protected function _getRequestedFileCacheKey($params) - { - return implode('|', array($params['area'], $params['themeModel']->getId(), $params['locale'])); - } - - /** - * Save published file path in cache storage - * - * @param string $file - * @param array $params - * @param string $publicFile - */ - protected function _setPublicFileIntoCache($file, $params, $publicFile) - { - $cacheKey = $this->_getRequestedFileCacheKey($params); - $this->_loadPublicCache($cacheKey); - $fileKey = $this->_getRequestedFileKey($file, $params); - $this->_publicCache[$cacheKey][$fileKey] = $publicFile; - Mage::app()->saveCache(serialize($this->_publicCache[$cacheKey]), $cacheKey, array(self::PUBLIC_CACHE_TAG)); - } - - /** - * Load published file cache storage from cache - * - * @param string $cacheKey - */ - protected function _loadPublicCache($cacheKey) - { - if (!isset($this->_publicCache[$cacheKey])) { - $cache = Mage::app()->loadCache($cacheKey); - if ($cache) { - $this->_publicCache[$cacheKey] = unserialize($cache); - } else { - $this->_publicCache[$cacheKey] = array(); - } - } - } - /** * Render view config object for current package and theme * + * @param array $params * @return Magento_Config_View */ - public function getViewConfig() + public function getViewConfig(array $params = array()) { - $key = $this->getDesignTheme()->getId(); + $this->_updateParamDefaults($params); + /** @var $currentTheme Mage_Core_Model_Theme */ + $currentTheme = $params['themeModel']; + $key = $currentTheme->getId(); if (isset($this->_viewConfigs[$key])) { return $this->_viewConfigs[$key]; } - $configFiles = $this->_moduleReader->getModuleConfigurationFiles('view.xml'); - $themeConfigFile = $this->getFilename('view.xml', array()); + $configFiles = $this->_moduleReader->getModuleConfigurationFiles(Mage_Core_Model_Theme::FILENAME_VIEW_CONFIG); + $themeConfigFile = $currentTheme->getCustomViewConfigPath(); + if (empty($themeConfigFile) || !$this->_filesystem->has($themeConfigFile)) { + $themeConfigFile = $this->getFilename(Mage_Core_Model_Theme::FILENAME_VIEW_CONFIG, $params); + } if ($themeConfigFile && $this->_filesystem->has($themeConfigFile)) { $configFiles[] = $themeConfigFile; } diff --git a/app/code/Mage/Core/Model/Design/Package/Proxy.php b/app/code/Mage/Core/Model/Design/Package/Proxy.php new file mode 100644 index 0000000000000..300001f26cc00 --- /dev/null +++ b/app/code/Mage/Core/Model/Design/Package/Proxy.php @@ -0,0 +1,239 @@ +_objectManager = $objectManager; + } + + /** + * @return Mage_Core_Model_Design_Package + */ + protected function _getInstance() + { + if (null === $this->_model) { + $this->_model = $this->_objectManager->get('Mage_Core_Model_Design_Package'); + } + return $this->_model; + } + + /** + * Set package area + * + * @param string $area + * @return Mage_Core_Model_Design_PackageInterface + */ + public function setArea($area) + { + return $this->_getInstance()->setArea($area); + } + + /** + * Retrieve package area + * + * @return string + */ + public function getArea() + { + return $this->_getInstance()->getArea(); + } + + + /** + * Set theme path + * + * @param Mage_Core_Model_Theme|int|string $theme + * @param string $area + * @return Mage_Core_Model_Design_PackageInterface + */ + public function setDesignTheme($theme, $area = null) + { + return $this->_getInstance()->setDesignTheme($theme, $area); + } + + + /** + * Get default theme which declared in configuration + * + * @param string $area + * @param array $params + * @return string|int + */ + public function getConfigurationDesignTheme($area = null, array $params = array()) + { + return $this->_getInstance()->getConfigurationDesignTheme($area, $params); + } + + /** + * Set default design theme + * + * @return Mage_Core_Model_Design_PackageInterface + */ + public function setDefaultDesignTheme() + { + return $this->_getInstance()->setDefaultDesignTheme(); + } + + /** + * Design theme model getter + * + * @return Mage_Core_Model_Theme + */ + public function getDesignTheme() + { + return $this->_getInstance()->getDesignTheme(); + } + + /** + * Get existing file name with fallback to default + * + * @param string $file + * @param array $params + * @return string + */ + public function getFilename($file, array $params = array()) + { + return $this->_getInstance()->getFilename($file, $params); + } + + /** + * Get a locale file + * + * @param string $file + * @param array $params + * @return string + */ + public function getLocaleFileName($file, array $params = array()) + { + return $this->_getInstance()->getLocaleFileName($file, $params); + } + + /** + * Find a view file using fallback mechanism + * + * @param string $file + * @param array $params + * @return string + */ + public function getViewFile($file, array $params = array()) + { + return $this->_getInstance()->getViewFile($file, $params); + } + + /** + * Remove all merged js/css files + * + * @return bool + */ + public function cleanMergedJsCss() + { + return $this->_getInstance()->cleanMergedJsCss(); + } + + /** + * Get url to file base on theme file identifier. + * Publishes file there, if needed. + * + * @param string $file + * @param array $params + * @return string + */ + public function getViewFileUrl($file, array $params = array()) + { + return $this->_getInstance()->getViewFileUrl($file, $params); + } + + /** + * Get url to public file + * + * @param string $file + * @param bool|null $isSecure + * @return string + * @throws Magento_Exception + */ + public function getPublicFileUrl($file, $isSecure = null) + { + return $this->_getInstance()->getPublicFileUrl($file, $isSecure); + } + + /** + * Return directory for theme files publication + * + * @return string + */ + public function getPublicDir() + { + return $this->_getInstance()->getPublicDir(); + } + + /** + * Return whether view files merging is allowed or not + * + * @return bool + */ + public function isMergingViewFilesAllowed() + { + return $this->_getInstance()->isMergingViewFilesAllowed(); + } + + /** + * Merge files, located under the same folder, into one and return file name of merged file + * + * @param array $files list of names relative to the same folder + * @param string $contentType + * @return string + * @throws Magento_Exception if not existing file requested for merge + */ + public function mergeFiles($files, $contentType) + { + return $this->_getInstance()->mergeFiles($files, $contentType); + } + + /** + * Render view config object for current package and theme + * + * @return Magento_Config_View + */ + public function getViewConfig() + { + return $this->_getInstance()->getViewConfig(); + } +} diff --git a/app/code/core/Mage/Core/Model/Design/PackageInterface.php b/app/code/Mage/Core/Model/Design/PackageInterface.php similarity index 87% rename from app/code/core/Mage/Core/Model/Design/PackageInterface.php rename to app/code/Mage/Core/Model/Design/PackageInterface.php index 96a9eefdede45..0200131d926a0 100644 --- a/app/code/core/Mage/Core/Model/Design/PackageInterface.php +++ b/app/code/Mage/Core/Model/Design/PackageInterface.php @@ -45,11 +45,6 @@ interface Mage_Core_Model_Design_PackageInterface const PUBLIC_THEME_DIR = '_theme'; /**#@-*/ - /** - * Public directory which contain theme files - */ - const PUBLIC_BASE_THEME_DIR = 'static'; - /**#@+ * Extensions group for static files */ @@ -87,16 +82,6 @@ interface Mage_Core_Model_Design_PackageInterface */ const XML_PATH_ALLOW_DUPLICATION = 'global/design/theme/allow_view_files_duplication'; - /** - * Path to config node that allows automatically updating map files in runtime - */ - const XML_PATH_ALLOW_MAP_UPDATE = 'global/dev/design_fallback/allow_map_update'; - - /** - * Sub-directory where to store maps of view files fallback (if used) - */ - const FALLBACK_MAP_DIR = 'maps/fallback'; - /** * PCRE that matches non-absolute URLs in CSS content */ @@ -197,27 +182,38 @@ public function cleanMergedJsCss(); public function getViewFileUrl($file, array $params = array()); /** - * Get URLs to CSS files optimized based on configuration settings + * Get url to public file * - * @param array $files - * @return array + * @param string $file + * @param bool|null $isSecure + * @return string + * @throws Magento_Exception */ - public function getOptimalCssUrls($files); + public function getPublicFileUrl($file, $isSecure = null); /** - * Get URLs to JS files optimized based on configuration settings + * Return directory for theme files publication * - * @param array $files - * @return array + * @return string */ - public function getOptimalJsUrls($files); + public function getPublicDir(); /** - * Return directory for theme files publication + * Return whether view files merging is allowed or not + * + * @return bool + */ + public function isMergingViewFilesAllowed(); + + /** + * Merge files, located under the same folder, into one and return file name of merged file * + * @param array $files list of names relative to the same folder + * @param string $contentType * @return string + * @throws Magento_Exception if not existing file requested for merge */ - public function getPublicDir(); + public function mergeFiles($files, $contentType); /** * Render view config object for current package and theme diff --git a/app/code/core/Mage/Core/Model/Design/Source/Design.php b/app/code/Mage/Core/Model/Design/Source/Design.php similarity index 100% rename from app/code/core/Mage/Core/Model/Design/Source/Design.php rename to app/code/Mage/Core/Model/Design/Source/Design.php diff --git a/app/code/core/Mage/Core/Model/Dir.php b/app/code/Mage/Core/Model/Dir.php similarity index 88% rename from app/code/core/Mage/Core/Model/Dir.php rename to app/code/Mage/Core/Model/Dir.php index f9dfae0aa188e..b8dc62b4e6584 100644 --- a/app/code/core/Mage/Core/Model/Dir.php +++ b/app/code/Mage/Core/Model/Dir.php @@ -78,6 +78,11 @@ class Mage_Core_Model_Dir */ const MEDIA = 'media'; + /** + * Storage of static view files that are needed on HTML-pages, emails or similar content + */ + const STATIC_VIEW = 'static'; + /** * Various files generated by the system in runtime */ @@ -99,14 +104,15 @@ class Mage_Core_Model_Dir const LOG = 'log'; /** - * Theme customization files + * File system session directory (if file system session storage is used) */ - const THEME = 'theme'; + const SESSION = 'session'; /** - * File system session directory (if file system session storage is used) + * Dependency injection related file directory + * */ - const SESSION = 'session'; + const DI = 'di'; /** * Temporary directory for uploading files by end-user @@ -121,23 +127,24 @@ class Mage_Core_Model_Dir * @var array */ private static $_defaults = array( - self::ROOT => '', - self::APP => 'app', - self::MODULES => 'app/code', - self::THEMES => 'app/design', - self::CONFIG => 'app/etc', - self::LIB => 'lib', - self::LOCALE => 'app/locale', - self::VAR_DIR => 'var', - self::TMP => 'var/tmp', - self::CACHE => 'var/cache', - self::LOG => 'var/log', - self::SESSION => 'var/session', - self::PUB => 'pub', - self::PUB_LIB => 'pub/lib', - self::MEDIA => 'pub/media', - self::UPLOAD => 'pub/media/upload', - self::THEME => 'pub/media/theme' + self::ROOT => '', + self::APP => 'app', + self::MODULES => 'app/code', + self::THEMES => 'app/design', + self::CONFIG => 'app/etc', + self::LIB => 'lib', + self::LOCALE => 'app/locale', + self::VAR_DIR => 'var', + self::TMP => 'var/tmp', + self::CACHE => 'var/cache', + self::LOG => 'var/log', + self::SESSION => 'var/session', + self::DI => 'var/di', + self::PUB => 'pub', + self::PUB_LIB => 'pub/lib', + self::MEDIA => 'pub/media', + self::UPLOAD => 'pub/media/upload', + self::STATIC_VIEW => 'pub/static' ); /** @@ -146,7 +153,7 @@ class Mage_Core_Model_Dir * @var array */ private static $_writableDirCodes = array( - self::MEDIA, self::VAR_DIR, self::TMP, self::CACHE, self::LOG, self::SESSION + self::MEDIA, self::STATIC_VIEW, self::VAR_DIR, self::TMP, self::CACHE, self::LOG, self::SESSION ); /** @@ -158,10 +165,11 @@ class Mage_Core_Model_Dir * @var array */ private $_uris = array( - self::PUB => '', - self::PUB_LIB => '', - self::MEDIA => '', - self::UPLOAD => '', + self::PUB => '', + self::PUB_LIB => '', + self::MEDIA => '', + self::STATIC_VIEW => '', + self::UPLOAD => '', ); /** diff --git a/app/code/core/Mage/Core/Model/Email.php b/app/code/Mage/Core/Model/Email.php similarity index 100% rename from app/code/core/Mage/Core/Model/Email.php rename to app/code/Mage/Core/Model/Email.php diff --git a/app/code/core/Mage/Core/Model/Email/Info.php b/app/code/Mage/Core/Model/Email/Info.php similarity index 100% rename from app/code/core/Mage/Core/Model/Email/Info.php rename to app/code/Mage/Core/Model/Email/Info.php diff --git a/app/code/Mage/Core/Model/Email/Template.php b/app/code/Mage/Core/Model/Email/Template.php new file mode 100644 index 0000000000000..d3a0fc8dc47b5 --- /dev/null +++ b/app/code/Mage/Core/Model/Email/Template.php @@ -0,0 +1,704 @@ +load(Mage::getStoreConfig('path_to_email_template_id_config')); + * $variables = array( + * 'someObject' => Mage::getSingleton('Mage_Core_Model_Resource_Email_Template') + * 'someString' => 'Some string value' + * ); + * $emailTemplate->send('some@domain.com', 'Name Of User', $variables); + * + * @method Mage_Core_Model_Resource_Email_Template _getResource() + * @method Mage_Core_Model_Resource_Email_Template getResource() + * @method string getTemplateCode() + * @method Mage_Core_Model_Email_Template setTemplateCode(string $value) + * @method string getTemplateText() + * @method Mage_Core_Model_Email_Template setTemplateText(string $value) + * @method string getTemplateStyles() + * @method Mage_Core_Model_Email_Template setTemplateStyles(string $value) + * @method int getTemplateType() + * @method Mage_Core_Model_Email_Template setTemplateType(int $value) + * @method string getTemplateSubject() + * @method Mage_Core_Model_Email_Template setTemplateSubject(string $value) + * @method string getTemplateSenderName() + * @method Mage_Core_Model_Email_Template setTemplateSenderName(string $value) + * @method string getTemplateSenderEmail() + * @method Mage_Core_Model_Email_Template setTemplateSenderEmail(string $value) + * @method string getAddedAt() + * @method Mage_Core_Model_Email_Template setAddedAt(string $value) + * @method string getModifiedAt() + * @method Mage_Core_Model_Email_Template setModifiedAt(string $value) + * @method string getOrigTemplateCode() + * @method Mage_Core_Model_Email_Template setOrigTemplateCode(string $value) + * @method string getOrigTemplateVariables() + * @method Mage_Core_Model_Email_Template setOrigTemplateVariables(string $value) + * + * @category Mage + * @package Mage_Core + * @author Magento Core Team + */ +class Mage_Core_Model_Email_Template extends Mage_Core_Model_Template +{ + /** + * Configuration path for default email templates + */ + const XML_PATH_TEMPLATE_EMAIL = 'global/template/email'; + const XML_PATH_SENDING_SET_RETURN_PATH = 'system/smtp/set_return_path'; + const XML_PATH_SENDING_RETURN_PATH_EMAIL = 'system/smtp/return_path_email'; + const XML_PATH_DESIGN_EMAIL_LOGO = 'design/email/logo'; + const XML_PATH_DESIGN_EMAIL_LOGO_ALT = 'design/email/logo_alt'; + + protected $_templateFilter; + protected $_preprocessFlag = false; + protected $_bcc = array(); + protected $_returnPath = ''; + protected $_replyTo = ''; + + /** + * @var Exception|null + */ + protected $_sendingException = null; + + /** + * @var Magento_Filesystem + */ + protected $_filesystem; + + static protected $_defaultTemplates; + + /** + * @param Mage_Core_Model_Context $context + * @param Magento_Filesystem $filesystem + * @param array $data + */ + public function __construct( + Mage_Core_Model_Context $context, + Magento_Filesystem $filesystem, + array $data = array() + ) { + $this->_filesystem = $filesystem; + parent::__construct($context); + } + + /** + * Initialize email template model + */ + protected function _construct() + { + $this->_init('Mage_Core_Model_Resource_Email_Template'); + } + + /** + * Return logo URL for emails + * Take logo from theme if custom logo is undefined + * + * @param Mage_Core_Model_Store|int|string $store + * @return string + */ + protected function _getLogoUrl($store) + { + $store = Mage::app()->getStore($store); + $fileName = $store->getConfig(self::XML_PATH_DESIGN_EMAIL_LOGO); + if ($fileName) { + $uploadDir = Mage_Backend_Model_Config_Backend_Email_Logo::UPLOAD_DIR; + $fullFileName = Mage::getBaseDir('media') . DS . $uploadDir . DS . $fileName; + if ($this->_filesystem->isFile($fullFileName)) { + return Mage::getBaseUrl('media') . $uploadDir . '/' . $fileName; + } + } + return Mage::getDesign()->getViewFileUrl('Mage_Core::logo_email.gif'); + } + + /** + * Return logo alt for emails + * + * @param Mage_Core_Model_Store|int|string $store + * @return string + */ + protected function _getLogoAlt($store) + { + $store = Mage::app()->getStore($store); + $alt = $store->getConfig(self::XML_PATH_DESIGN_EMAIL_LOGO_ALT); + if ($alt) { + return $alt; + } + return $store->getFrontendName(); + } + + /** + * Retrieve mail object instance + * + * @return Zend_Mail + */ + protected function _getMail() + { + return new Zend_Mail('utf-8'); + } + + /** + * Declare template processing filter + * + * @param Varien_Filter_Template $filter + * @return Mage_Core_Model_Email_Template + */ + public function setTemplateFilter(Varien_Filter_Template $filter) + { + $this->_templateFilter = $filter; + return $this; + } + + /** + * Get filter object for template processing log + * + * @return Mage_Core_Model_Email_Template_Filter + */ + public function getTemplateFilter() + { + if (empty($this->_templateFilter)) { + $this->_templateFilter = Mage::getModel('Mage_Core_Model_Email_Template_Filter'); + $this->_templateFilter->setUseAbsoluteLinks($this->getUseAbsoluteLinks()) + ->setStoreId($this->getDesignConfig()->getStore()); + } + return $this->_templateFilter; + } + + /** + * Load template by code + * + * @param string $templateCode + * @return Mage_Core_Model_Email_Template + */ + public function loadByCode($templateCode) + { + $this->addData($this->getResource()->loadByCode($templateCode)); + return $this; + } + + /** + * Load default email template + * + * @param string $templateId + * @return Mage_Core_Model_Email_Template + */ + public function loadDefault($templateId) + { + $defaultTemplates = self::getDefaultTemplates(); + if (!isset($defaultTemplates[$templateId])) { + return $this; + } + + $data = &$defaultTemplates[$templateId]; + $this->setTemplateType($data['type'] == 'html' ? self::TYPE_HTML : self::TYPE_TEXT); + + $module = Mage::getConfig()->determineOmittedNamespace($data['@']['module'], true); + $templateText = $this->loadBaseContents($module, $data['file']); + + if (preg_match('//u', $templateText, $matches)) { + $this->setTemplateSubject($matches[1]); + $templateText = str_replace($matches[0], '', $templateText); + } + + if (preg_match('//us', $templateText, $matches)) { + $this->setData('orig_template_variables', str_replace("\n", '', $matches[1])); + $templateText = str_replace($matches[0], '', $templateText); + } + + if (preg_match('//s', $templateText, $matches)) { + $this->setTemplateStyles($matches[1]); + $templateText = str_replace($matches[0], '', $templateText); + } + + /** + * Remove comment lines + */ + $templateText = preg_replace('#\{\*.*\*\}#suU', '', $templateText); + + $this->setTemplateText($templateText); + $this->setId($templateId); + + return $this; + } + + /** + * Look for base template and read its contents + * + * @param string $module A fully qualified module name (_) + * @param string $filename File path relative to module/view folder + * @return string + * @throws Exception if the requested filename is not found + */ + public function loadBaseContents($module, $filename) + { + $includeFilename = Mage::getConfig()->getModuleDir('view', $module) . DIRECTORY_SEPARATOR . $filename; + $contents = $this->_filesystem->read($includeFilename); + if (!$contents) { + throw new Exception(sprintf('Failed to include file "%s".', $includeFilename)); + } + return $contents; + } + + /** + * Retrieve default templates from config + * + * @return array + */ + static public function getDefaultTemplates() + { + if (is_null(self::$_defaultTemplates)) { + self::$_defaultTemplates = Mage::getConfig()->getNode(self::XML_PATH_TEMPLATE_EMAIL)->asArray(); + } + + return self::$_defaultTemplates; + } + + /** + * Get default templates as options array + * + * @return array + */ + static public function getDefaultTemplatesAsOptionsArray() + { + $options = array(array('value'=> '', 'label'=> '', 'group' => '')); + $groups = array(); + foreach (self::getDefaultTemplates() as $templateId => $row) { + $module = $row['@']['module']; + $moduleFullName = Mage::getConfig()->determineOmittedNamespace($module, true); + $options[] = array( + 'value' => $templateId, + 'label' => Mage::helper($module)->__($row['label']), + 'group' => $moduleFullName, + ); + $groups[$module] = 1; + } + uasort($options, function($a, $b) { + $key = 'label'; + if ($a[$key] == $b[$key]) { + return 0; + } + return ($a[$key] < $b[$key]) ? -1 : 1; + }); + + return $options; + } + + /** + * Return template id + * + * return int|null + */ + public function getId() + { + return $this->getTemplateId(); + } + + /** + * Set id of template + * + * @param int $value + * @return Mage_Core_Model_Email_Template + */ + public function setId($value) + { + return $this->setTemplateId($value); + } + + /** + * Return true if this template can be used for sending queue as main template + * + * @return boolean + */ + public function isValidForSend() + { + return !Mage::getStoreConfigFlag('system/smtp/disable') + && $this->getSenderName() + && $this->getSenderEmail() + && $this->getTemplateSubject(); + } + + /** + * Getter for template type + * + * @return int|string + */ + public function getType(){ + return $this->getTemplateType(); + } + + /** + * Process email template code + * + * @param array $variables + * @return string + * @throws Exception + */ + public function getProcessedTemplate(array $variables = array()) + { + $processor = $this->getTemplateFilter(); + $processor->setUseSessionInUrl(false) + ->setPlainTemplateMode($this->isPlain()); + + if (!$this->_preprocessFlag) { + $variables['this'] = $this; + } + + if (isset($variables['subscriber']) && ($variables['subscriber'] instanceof Mage_Newsletter_Model_Subscriber)) { + $processor->setStoreId($variables['subscriber']->getStoreId()); + } + + if (!isset($variables['logo_url'])) { + $variables['logo_url'] = $this->_getLogoUrl($processor->getStoreId()); + } + if (!isset($variables['logo_alt'])) { + $variables['logo_alt'] = $this->_getLogoAlt($processor->getStoreId()); + } + + $processor->setIncludeProcessor(array($this, 'getInclude')) + ->setVariables($variables); + + $this->_applyDesignConfig(); + $storeId = $this->getDesignConfig()->getStore(); + try { + $processedResult = $processor->setStoreId($storeId) + ->filter($this->getPreparedTemplateText()); + } catch (Exception $e) { + $this->_cancelDesignConfig(); + throw $e; + } + $this->_cancelDesignConfig(); + return $processedResult; + } + + /** + * Makes additional text preparations for HTML templates + * + * @return string + */ + public function getPreparedTemplateText() + { + if ($this->isPlain() || !$this->getTemplateStyles()) { + return $this->getTemplateText(); + } + // wrap styles into style tag + $html = "\n%s"; + return sprintf($html, $this->getTemplateStyles(), $this->getTemplateText()); + } + + /** + * Get template code for include directive + * + * @param string $template + * @param array $variables + * @return string + */ + public function getInclude($template, array $variables) + { + $thisClass = __CLASS__; + $includeTemplate = new $thisClass(); + + $includeTemplate->loadByCode($template); + + return $includeTemplate->getProcessedTemplate($variables); + } + + /** + * Send mail to recipient + * + * @param array|string $email E-mail(s) + * @param array|string|null $name receiver name(s) + * @param array $variables template variables + * @return boolean + **/ + public function send($email, $name = null, array $variables = array()) + { + if (!$this->isValidForSend()) { + Mage::logException(new Exception('This letter cannot be sent.')); // translation is intentionally omitted + return false; + } + + $emails = array_values((array)$email); + $names = is_array($name) ? $name : (array)$name; + $names = array_values($names); + foreach ($emails as $key => $email) { + if (!isset($names[$key])) { + $names[$key] = substr($email, 0, strpos($email, '@')); + } + } + + $variables['email'] = reset($emails); + $variables['name'] = reset($names); + + ini_set('SMTP', Mage::getStoreConfig('system/smtp/host')); + ini_set('smtp_port', Mage::getStoreConfig('system/smtp/port')); + + $mail = $this->_getMail(); + foreach ($this->_bcc as $bcc) { + $mail->addBcc($bcc); + } + if ($this->_returnPath) { + $mail->setReturnPath($this->_returnPath); + } + if ($this->_replyTo) { + $mail->setReplyTo($this->_replyTo); + } + + $setReturnPath = Mage::getStoreConfig(self::XML_PATH_SENDING_SET_RETURN_PATH); + switch ($setReturnPath) { + case 1: + $returnPathEmail = $this->getSenderEmail(); + break; + case 2: + $returnPathEmail = Mage::getStoreConfig(self::XML_PATH_SENDING_RETURN_PATH_EMAIL); + break; + default: + $returnPathEmail = null; + break; + } + + if ($returnPathEmail !== null) { + $mailTransport = new Zend_Mail_Transport_Sendmail("-f" . $returnPathEmail); + Zend_Mail::setDefaultTransport($mailTransport); + } + + foreach ($emails as $key => $email) { + $mail->addTo($email, '=?utf-8?B?' . base64_encode($names[$key]) . '?='); + } + + $this->setUseAbsoluteLinks(true); + $text = $this->getProcessedTemplate($variables, true); + + if ($this->isPlain()) { + $mail->setBodyText($text); + } else { + $mail->setBodyHTML($text); + } + + $mail->setSubject('=?utf-8?B?' . base64_encode($this->getProcessedTemplateSubject($variables)) . '?='); + $mail->setFrom($this->getSenderEmail(), $this->getSenderName()); + + $result = false; + $this->_sendingException = null; + try { + $mail->send(); + $result = true; + } catch (Exception $e) { + Mage::logException($e); + $this->_sendingException = $e; + } + $this->_bcc = array(); + $this->_returnPath = ''; + $this->_replyTo = ''; + + return $result; + } + + /** + * Get exception, generated during send() method + * + * @return Exception|null + */ + public function getSendingException() + { + return $this->_sendingException; + } + + /** + * Send transactional email to recipient + * + * @param int|string $templateId + * @param string|array $sender sender information, can be declared as part of config path + * @param string $email recipient email + * @param string $name recipient name + * @param array $vars variables which can be used in template + * @param int|null $storeId + * @return Mage_Core_Model_Email_Template + * @throws Mage_Core_Exception + */ + public function sendTransactional($templateId, $sender, $email, $name, $vars = array(), $storeId = null) + { + $this->setSentSuccess(false); + if (($storeId === null) && $this->getDesignConfig()->getStore()) { + $storeId = $this->getDesignConfig()->getStore(); + } + + if (is_numeric($templateId)) { + $this->load($templateId); + } else { + $this->loadDefault($templateId); + } + + if (!$this->getId()) { + throw Mage::exception('Mage_Core', + Mage::helper('Mage_Core_Helper_Data')->__('Invalid transactional email code: %s', $templateId)); + } + + if (!is_array($sender)) { + $this->setSenderName(Mage::getStoreConfig('trans_email/ident_' . $sender . '/name', $storeId)); + $this->setSenderEmail(Mage::getStoreConfig('trans_email/ident_' . $sender . '/email', $storeId)); + } else { + $this->setSenderName($sender['name']); + $this->setSenderEmail($sender['email']); + } + + if (!isset($vars['store'])) { + $vars['store'] = Mage::app()->getStore($storeId); + } + $this->setSentSuccess($this->send($email, $name, $vars)); + return $this; + } + + /** + * Process email subject + * + * @param array $variables + * @return string + * @throws Exception + */ + public function getProcessedTemplateSubject(array $variables) + { + $processor = $this->getTemplateFilter(); + + if (!$this->_preprocessFlag) { + $variables['this'] = $this; + } + + $processor->setVariables($variables); + + $this->_applyDesignConfig(); + $storeId = $this->getDesignConfig()->getStore(); + try { + $processedResult = $processor->setStoreId($storeId) + ->filter($this->getTemplateSubject()); + } catch (Exception $e) { + $this->_cancelDesignConfig(); + throw $e; + } + $this->_cancelDesignConfig(); + return $processedResult; + } + + /** + * Add email BCC + * + * @param string|array $bcc + * @return Mage_Core_Model_Email_Template + */ + public function addBcc($bcc) + { + $this->_bcc[] = $bcc; + return $this; + } + + /** + * Set Return Path + * + * @param string $email + * @return Mage_Core_Model_Email_Template + */ + public function setReturnPath($email) + { + $this->_returnPath = $email; + return $this; + } + + /** + * Add Reply-To header + * + * @param string $email + * @return Mage_Core_Model_Email_Template + */ + public function setReplyTo($email) + { + $this->_replyTo = $email; + return $this; + } + + /** + * Parse variables string into array of variables + * + * @param string $variablesString + * @return array + */ + protected function _parseVariablesString($variablesString) + { + $variables = array(); + if ($variablesString && is_string($variablesString)) { + $variablesString = str_replace("\n", '', $variablesString); + $variables = Zend_Json::decode($variablesString); + } + return $variables; + } + + /** + * Retrieve option array of variables + * + * @param boolean $withGroup if true wrap variable options in group + * @return array + */ + public function getVariablesOptionArray($withGroup = false) + { + $optionArray = array(); + $variables = $this->_parseVariablesString($this->getData('orig_template_variables')); + if ($variables) { + foreach ($variables as $value => $label) { + $optionArray[] = array( + 'value' => '{{' . $value . '}}', + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('%s', $label) + ); + } + if ($withGroup) { + $optionArray = array( + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Template Variables'), + 'value' => $optionArray + ); + } + } + return $optionArray; + } + + /** + * Validate email template code + * + * @return Mage_Core_Model_Email_Template + */ + protected function _beforeSave() + { + $code = $this->getTemplateCode(); + if (empty($code)) { + Mage::throwException(Mage::helper('Mage_Core_Helper_Data')->__('The template Name must not be empty.')); + } + if ($this->_getResource()->checkCodeUsage($this)) { + Mage::throwException(Mage::helper('Mage_Core_Helper_Data')->__('Duplicate Of Template Name')); + } + return parent::_beforeSave(); + } +} diff --git a/app/code/Mage/Core/Model/Email/Template/Filter.php b/app/code/Mage/Core/Model/Email/Template/Filter.php new file mode 100644 index 0000000000000..c0750a919552b --- /dev/null +++ b/app/code/Mage/Core/Model/Email/Template/Filter.php @@ -0,0 +1,502 @@ + + */ +class Mage_Core_Model_Email_Template_Filter extends Varien_Filter_Template +{ + /** + * Use absolute links flag + * + * @var bool + */ + protected $_useAbsoluteLinks = false; + + /** + * Whether to allow SID in store directive: NO + * + * @var bool + */ + protected $_useSessionInUrl = false; + + /** + * Modifier Callbacks + * + * @var array + */ + protected $_modifiers = array('nl2br' => ''); + + protected $_storeId = null; + + protected $_plainTemplateMode = false; + + /** + * Setup callbacks for filters + * + */ + public function __construct() + { + $this->_modifiers['escape'] = array($this, 'modifierEscape'); + } + + /** + * Set use absolute links flag + * + * @param bool $flag + * @return Mage_Core_Model_Email_Template_Filter + */ + public function setUseAbsoluteLinks($flag) + { + $this->_useAbsoluteLinks = $flag; + return $this; + } + + /** + * Setter whether SID is allowed in store directive + * Doesn't set anything intentionally, since SID is not allowed in any kind of emails + * + * @param bool $flag + * @return Mage_Core_Model_Email_Template_Filter + */ + public function setUseSessionInUrl($flag) + { + $this->_useSessionInUrl = $flag; + return $this; + } + + /** + * Setter + * + * @param boolean $plainTemplateMode + * @return Mage_Core_Model_Email_Template_Filter + */ + public function setPlainTemplateMode($plainTemplateMode) + { + $this->_plainTemplateMode = (bool)$plainTemplateMode; + return $this; + } + + /** + * Getter + * + * @return boolean + */ + public function getPlainTemplateMode() + { + return $this->_plainTemplateMode; + } + + /** + * Setter + * + * @param integer $storeId + * @return Mage_Core_Model_Email_Template_Filter + */ + public function setStoreId($storeId) + { + $this->_storeId = $storeId; + return $this; + } + + /** + * Getter + * if $_storeId is null return Design store id + * + * @return integer + */ + public function getStoreId() + { + if (null === $this->_storeId) { + $this->_storeId = Mage::app()->getStore()->getId(); + } + return $this->_storeId; + } + + /** + * Retrieve Block html directive + * + * @param array $construction + * @return string + */ + public function blockDirective($construction) + { + $skipParams = array('type', 'id', 'output'); + $blockParameters = $this->_getIncludeParameters($construction[2]); + $layout = Mage::app()->getLayout(); + + if (isset($blockParameters['type'])) { + $type = $blockParameters['type']; + $block = $layout->createBlock($type, null, array('data' => $blockParameters)); + } elseif (isset($blockParameters['id'])) { + $block = $layout->createBlock('Mage_Cms_Block_Block'); + if ($block) { + $block->setBlockId($blockParameters['id']); + } + } + + if ($block) { + $block->setBlockParams($blockParameters); + foreach ($blockParameters as $k => $v) { + if (in_array($k, $skipParams)) { + continue; + } + $block->setDataUsingMethod($k, $v); + } + } + + if (!$block) { + return ''; + } + if (isset($blockParameters['output'])) { + $method = $blockParameters['output']; + } + if (!isset($method) || !is_string($method) || !method_exists($block, $method)) { + $method = 'toHtml'; + } + return $block->$method(); + } + + /** + * Retrieve layout html directive + * + * @param array $construction + * @return string + */ + public function layoutDirective($construction) + { + $skipParams = array('handle', 'area'); + + $params = $this->_getIncludeParameters($construction[2]); + $layoutParams = array(); + if (isset($params['area'])) { + $layoutParams['area'] = $params['area']; + } + /** @var $layout Mage_Core_Model_Layout */ + $layout = Mage::getModel('Mage_Core_Model_Layout', $layoutParams); + + $layout->getUpdate()->addHandle($params['handle']); + $layout->getUpdate()->load(); + + $layout->generateXml(); + $layout->generateElements(); + + foreach ($layout->getAllBlocks() as $block) { + /* @var $block Mage_Core_Block_Abstract */ + foreach ($params as $k => $v) { + if (in_array($k, $skipParams)) { + continue; + } + + $block->setDataUsingMethod($k, $v); + } + } + + /** + * Add output method for first block + */ + $allBlocks = $layout->getAllBlocks(); + $firstBlock = reset($allBlocks); + if ($firstBlock) { + $layout->addOutputElement($firstBlock->getNameInLayout()); + } + + $layout->setDirectOutput(false); + $result = $layout->getOutput(); + $layout->__destruct(); // To overcome bug with SimpleXML memory leak (https://bugs.php.net/bug.php?id=62468) + return $result; + } + + /** + * Retrieve block parameters + * + * @param mixed $value + * @return array + */ + protected function _getBlockParameters($value) + { + $tokenizer = new Varien_Filter_Template_Tokenizer_Parameter(); + $tokenizer->setString($value); + + return $tokenizer->tokenize(); + } + + /** + * Retrieve View URL directive + * + * @param array $construction + * @return string + */ + public function viewDirective($construction) + { + $params = $this->_getIncludeParameters($construction[2]); + $url = Mage::getDesign()->getViewFileUrl($params['url'], $params); + return $url; + } + + /** + * Retrieve media file URL directive + * + * @param array $construction + * @return string + */ + public function mediaDirective($construction) + { + $params = $this->_getIncludeParameters($construction[2]); + return Mage::getBaseUrl('media') . $params['url']; + } + + /** + * Retrieve store URL directive + * Support url and direct_url properties + * + * @param array $construction + * @return string + */ + public function storeDirective($construction) + { + $params = $this->_getIncludeParameters($construction[2]); + if (!isset($params['_query'])) { + $params['_query'] = array(); + } + foreach ($params as $k => $v) { + if (strpos($k, '_query_') === 0) { + $params['_query'][substr($k, 7)] = $v; + unset($params[$k]); + } + } + $params['_absolute'] = $this->_useAbsoluteLinks; + + if ($this->_useSessionInUrl === false) { + $params['_nosid'] = true; + } + + if (isset($params['direct_url'])) { + $path = ''; + $params['_direct'] = $params['direct_url']; + unset($params['direct_url']); + } + else { + $path = isset($params['url']) ? $params['url'] : ''; + unset($params['url']); + } + + return Mage::app()->getStore($this->getStoreId())->getUrl($path, $params); + } + + /** + * Directive for converting special characters to HTML entities + * Supported options: + * allowed_tags - Comma separated html tags that have not to be converted + * + * @param array $construction + * @return string + */ + public function escapehtmlDirective($construction) + { + $params = $this->_getIncludeParameters($construction[2]); + if (!isset($params['var'])) { + return ''; + } + + $allowedTags = null; + if (isset($params['allowed_tags'])) { + $allowedTags = preg_split('/\s*\,\s*/', $params['allowed_tags'], 0, PREG_SPLIT_NO_EMPTY); + } + + return Mage::helper('Mage_Core_Helper_Data')->escapeHtml($params['var'], $allowedTags); + } + + /** + * Var directive with modifiers support + * + * @param array $construction + * @return string + */ + public function varDirective($construction) + { + if (count($this->_templateVars)==0) { + // If template preprocessing + return $construction[0]; + } + + $parts = explode('|', $construction[2], 2); + if (2 === count($parts)) { + list($variableName, $modifiersString) = $parts; + return $this->_amplifyModifiers($this->_getVariable($variableName, ''), $modifiersString); + } + return $this->_getVariable($construction[2], ''); + } + + /** + * Apply modifiers one by one, with specified params + * + * Modifier syntax: modifier1[:param1:param2:...][|modifier2:...] + * + * @param string $value + * @param string $modifiers + * @return string + */ + protected function _amplifyModifiers($value, $modifiers) + { + foreach (explode('|', $modifiers) as $part) { + if (empty($part)) { + continue; + } + $params = explode(':', $part); + $modifier = array_shift($params); + if (isset($this->_modifiers[$modifier])) { + $callback = $this->_modifiers[$modifier]; + if (!$callback) { + $callback = $modifier; + } + array_unshift($params, $value); + $value = call_user_func_array($callback, $params); + } + } + return $value; + } + + /** + * Escape specified string + * + * @param string $value + * @param string $type + * @return string + */ + public function modifierEscape($value, $type = 'html') + { + switch ($type) { + case 'html': + return htmlspecialchars($value, ENT_QUOTES); + + case 'htmlentities': + return htmlentities($value, ENT_QUOTES); + + case 'url': + return rawurlencode($value); + } + return $value; + } + + /** + * HTTP Protocol directive + * + * Using: + * {{protocol}} - current protocol http or https + * {{protocol url="www.domain.com/"}} domain URL with current protocol + * {{protocol http="http://url" https="https://url"} + * also allow additional parameter "store" + * + * @param array $construction + * @return string + */ + public function protocolDirective($construction) + { + $params = $this->_getIncludeParameters($construction[2]); + $store = null; + if (isset($params['store'])) { + $store = Mage::app()->getSafeStore($params['store']); + } + $isSecure = Mage::app()->getStore($store)->isCurrentlySecure(); + $protocol = $isSecure ? 'https' : 'http'; + if (isset($params['url'])) { + return $protocol . '://' . $params['url']; + } + elseif (isset($params['http']) && isset($params['https'])) { + if ($isSecure) { + return $params['https']; + } + return $params['http']; + } + + return $protocol; + } + + /** + * Store config directive + * + * @param array $construction + * @return string + */ + public function configDirective($construction) + { + $configValue = ''; + $params = $this->_getIncludeParameters($construction[2]); + $storeId = $this->getStoreId(); + if (isset($params['path'])) { + $configValue = Mage::getStoreConfig($params['path'], $storeId); + } + return $configValue; + } + + /** + * Custom Variable directive + * + * @param array $construction + * @return string + */ + public function customvarDirective($construction) + { + $customVarValue = ''; + $params = $this->_getIncludeParameters($construction[2]); + if (isset($params['code'])) { + $variable = Mage::getModel('Mage_Core_Model_Variable') + ->setStoreId($this->getStoreId()) + ->loadByCode($params['code']); + $mode = $this->getPlainTemplateMode() + ? Mage_Core_Model_Variable::TYPE_TEXT + : Mage_Core_Model_Variable::TYPE_HTML; + if ($value = $variable->getValue($mode)) { + $customVarValue = $value; + } + } + return $customVarValue; + } + + /** + * Filter the string as template. + * Rewrited for logging exceptions + * + * @param string $value + * @return string + */ + public function filter($value) + { + try { + $value = parent::filter($value); + } catch (Exception $e) { + $value = ''; + Mage::logException($e); + } + return $value; + } +} diff --git a/app/code/core/Mage/Core/Model/Email/Template/Mailer.php b/app/code/Mage/Core/Model/Email/Template/Mailer.php similarity index 100% rename from app/code/core/Mage/Core/Model/Email/Template/Mailer.php rename to app/code/Mage/Core/Model/Email/Template/Mailer.php diff --git a/app/code/core/Mage/Core/Model/Email/Transport.php b/app/code/Mage/Core/Model/Email/Transport.php similarity index 100% rename from app/code/core/Mage/Core/Model/Email/Transport.php rename to app/code/Mage/Core/Model/Email/Transport.php diff --git a/app/code/core/Mage/Core/Model/Encryption.php b/app/code/Mage/Core/Model/Encryption.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Core/Model/Encryption.php rename to app/code/Mage/Core/Model/Encryption.php diff --git a/app/code/core/Mage/Core/Model/EntryPoint/Cron.php b/app/code/Mage/Core/Model/EntryPoint/Cron.php similarity index 100% rename from app/code/core/Mage/Core/Model/EntryPoint/Cron.php rename to app/code/Mage/Core/Model/EntryPoint/Cron.php diff --git a/app/code/Mage/Core/Model/EntryPoint/Http.php b/app/code/Mage/Core/Model/EntryPoint/Http.php new file mode 100644 index 0000000000000..a3d0b094f8f7f --- /dev/null +++ b/app/code/Mage/Core/Model/EntryPoint/Http.php @@ -0,0 +1,65 @@ +getMessage(); + throw $e; + } + } + + /** + * Run http application + */ + public function processRequest() + { + try { + $request = $this->_objectManager->get('Mage_Core_Controller_Request_Http'); + $response = $this->_objectManager->get('Mage_Core_Controller_Response_Http'); + $handler = $this->_objectManager->get('Magento_Http_Handler_Composite'); + $handler->handle($request, $response); + } catch (Mage_Core_Model_Session_Exception $e) { + header('Location: ' . Mage::getBaseUrl()); + } catch (Mage_Core_Model_Store_Exception $e) { + require Mage::getBaseDir(Mage_Core_Model_Dir::PUB) . DS . 'errors' . DS . '404.php'; + } catch (Magento_BootstrapException $e) { + header('Content-Type: text/plain', true, 503); + echo $e->getMessage(); + } catch (Exception $e) { + Mage::printException($e); + } + } +} diff --git a/app/code/Mage/Core/Model/EntryPoint/Media.php b/app/code/Mage/Core/Model/EntryPoint/Media.php new file mode 100644 index 0000000000000..ba03119ff999f --- /dev/null +++ b/app/code/Mage/Core/Model/EntryPoint/Media.php @@ -0,0 +1,35 @@ +create($config); + $objectManager = new Mage_Core_Model_ObjectManager($definitions, $config); + } + $this->_objectManager = $objectManager; + Mage::setObjectManager($objectManager); + } + + /** + * Process request to application + */ + public abstract function processRequest(); +} + diff --git a/app/code/core/Mage/Core/Model/Event/Config.php b/app/code/Mage/Core/Model/Event/Config.php similarity index 100% rename from app/code/core/Mage/Core/Model/Event/Config.php rename to app/code/Mage/Core/Model/Event/Config.php diff --git a/app/code/core/Mage/Core/Model/Event/Manager.php b/app/code/Mage/Core/Model/Event/Manager.php similarity index 100% rename from app/code/core/Mage/Core/Model/Event/Manager.php rename to app/code/Mage/Core/Model/Event/Manager.php diff --git a/app/code/core/Mage/Core/Model/Factory/Helper.php b/app/code/Mage/Core/Model/Factory/Helper.php similarity index 100% rename from app/code/core/Mage/Core/Model/Factory/Helper.php rename to app/code/Mage/Core/Model/Factory/Helper.php diff --git a/app/code/Mage/Core/Model/Factory/Simple.php b/app/code/Mage/Core/Model/Factory/Simple.php new file mode 100644 index 0000000000000..825ca49858922 --- /dev/null +++ b/app/code/Mage/Core/Model/Factory/Simple.php @@ -0,0 +1,58 @@ +_objectManager = $objectManager; + } + + /** + * Create class + * + * @param array $arguments + * @return Object + */ + public function create(array $arguments = array()) + { + return $this->_objectManager->create($this->getClassName(), $arguments); + } + + /** + * Returns the class name of the class that this factory should be producing. + * @return string class name + */ + public abstract function getClassName(); +} \ No newline at end of file diff --git a/app/code/core/Mage/Core/Model/File/Storage.php b/app/code/Mage/Core/Model/File/Storage.php similarity index 100% rename from app/code/core/Mage/Core/Model/File/Storage.php rename to app/code/Mage/Core/Model/File/Storage.php diff --git a/app/code/core/Mage/Core/Model/File/Storage/Abstract.php b/app/code/Mage/Core/Model/File/Storage/Abstract.php similarity index 100% rename from app/code/core/Mage/Core/Model/File/Storage/Abstract.php rename to app/code/Mage/Core/Model/File/Storage/Abstract.php diff --git a/app/code/core/Mage/Core/Model/File/Storage/Database.php b/app/code/Mage/Core/Model/File/Storage/Database.php similarity index 100% rename from app/code/core/Mage/Core/Model/File/Storage/Database.php rename to app/code/Mage/Core/Model/File/Storage/Database.php diff --git a/app/code/core/Mage/Core/Model/File/Storage/Database/Abstract.php b/app/code/Mage/Core/Model/File/Storage/Database/Abstract.php similarity index 100% rename from app/code/core/Mage/Core/Model/File/Storage/Database/Abstract.php rename to app/code/Mage/Core/Model/File/Storage/Database/Abstract.php diff --git a/app/code/core/Mage/Core/Model/File/Storage/Directory/Database.php b/app/code/Mage/Core/Model/File/Storage/Directory/Database.php similarity index 100% rename from app/code/core/Mage/Core/Model/File/Storage/Directory/Database.php rename to app/code/Mage/Core/Model/File/Storage/Directory/Database.php diff --git a/app/code/core/Mage/Core/Model/File/Storage/File.php b/app/code/Mage/Core/Model/File/Storage/File.php similarity index 100% rename from app/code/core/Mage/Core/Model/File/Storage/File.php rename to app/code/Mage/Core/Model/File/Storage/File.php diff --git a/app/code/core/Mage/Core/Model/File/Storage/Flag.php b/app/code/Mage/Core/Model/File/Storage/Flag.php similarity index 100% rename from app/code/core/Mage/Core/Model/File/Storage/Flag.php rename to app/code/Mage/Core/Model/File/Storage/Flag.php diff --git a/app/code/core/Mage/Core/Model/File/Uploader.php b/app/code/Mage/Core/Model/File/Uploader.php similarity index 100% rename from app/code/core/Mage/Core/Model/File/Uploader.php rename to app/code/Mage/Core/Model/File/Uploader.php diff --git a/app/code/core/Mage/Core/Model/File/Validator/AvailablePath.php b/app/code/Mage/Core/Model/File/Validator/AvailablePath.php similarity index 100% rename from app/code/core/Mage/Core/Model/File/Validator/AvailablePath.php rename to app/code/Mage/Core/Model/File/Validator/AvailablePath.php diff --git a/app/code/core/Mage/Core/Model/File/Validator/NotProtectedExtension.php b/app/code/Mage/Core/Model/File/Validator/NotProtectedExtension.php similarity index 100% rename from app/code/core/Mage/Core/Model/File/Validator/NotProtectedExtension.php rename to app/code/Mage/Core/Model/File/Validator/NotProtectedExtension.php diff --git a/app/code/core/Mage/Core/Model/Flag.php b/app/code/Mage/Core/Model/Flag.php similarity index 100% rename from app/code/core/Mage/Core/Model/Flag.php rename to app/code/Mage/Core/Model/Flag.php diff --git a/app/code/core/Mage/Core/Model/Input/Filter.php b/app/code/Mage/Core/Model/Input/Filter.php similarity index 100% rename from app/code/core/Mage/Core/Model/Input/Filter.php rename to app/code/Mage/Core/Model/Input/Filter.php diff --git a/app/code/core/Mage/Core/Model/Input/Filter/MaliciousCode.php b/app/code/Mage/Core/Model/Input/Filter/MaliciousCode.php similarity index 100% rename from app/code/core/Mage/Core/Model/Input/Filter/MaliciousCode.php rename to app/code/Mage/Core/Model/Input/Filter/MaliciousCode.php diff --git a/app/code/Mage/Core/Model/Layout.php b/app/code/Mage/Core/Model/Layout.php new file mode 100644 index 0000000000000..9b919ba6be2bd --- /dev/null +++ b/app/code/Mage/Core/Model/Layout.php @@ -0,0 +1,1599 @@ +_blockFactory = $blockFactory; + $this->_area = $area; + $this->_structure = $structure; + $this->_argumentProcessor = $argumentProcessor; + $this->_translator = $translator; + $this->_elementClass = 'Mage_Core_Model_Layout_Element'; + $this->setXml(simplexml_load_string('', $this->_elementClass)); + $this->_renderingOutput = new Varien_Object; + $this->_scheduledStructure = $scheduledStructure; + $this->_dataSourceFactory = $dataSourceFactory; + } + + /** + * Cleanup circular references between layout & blocks + * + * Destructor should be called explicitly in order to work around the PHP bug + * https://bugs.php.net/bug.php?id=62468 + */ + public function __destruct() + { + if (isset($this->_update) && is_object($this->_update)) { + $this->_update->__destruct(); + $this->_update = null; + } + $this->_blocks = array(); + $this->_xml = null; + } + + /** + * Retrieve the layout update instance + * + * @return Mage_Core_Model_Layout_Merge + */ + public function getUpdate() + { + if (!$this->_update) { + $arguments = array('area' => $this->getArea()); + $this->_update = Mage::getModel('Mage_Core_Model_Layout_Merge', array('arguments' => $arguments)); + } + return $this->_update; + } + + /** + * Retrieve layout area + * + * @return string + */ + public function getArea() + { + return $this->_area; + } + + /** + * Declaring layout direct output flag + * + * @param bool $flag + * @return Mage_Core_Model_Layout + */ + public function setDirectOutput($flag) + { + $this->_directOutput = $flag; + return $this; + } + + /** + * Retrieve direct output flag + * + * @return bool + */ + public function isDirectOutput() + { + return $this->_directOutput; + } + + /** + * Layout xml generation + * + * @return Mage_Core_Model_Layout + */ + public function generateXml() + { + $xml = $this->getUpdate()->asSimplexml(); + $this->setXml($xml); + $this->_structure->importElements(array()); + return $this; + } + + /** + * Create structure of elements from the loaded XML configuration + */ + public function generateElements() + { + Magento_Profiler::start(__CLASS__ . '::' . __METHOD__); + Magento_Profiler::start('build_structure'); + + $this->_scheduledStructure->flushScheduledStructure(); + + $this->_readStructure($this->getNode()); + + $this->_dataSourceFactory + ->init($this->getDatasources()); + + while (false === $this->_scheduledStructure->isStructureEmpty()) { + $this->_scheduleElement(key($this->_scheduledStructure->getStructure())); + }; + $this->_scheduledStructure->flushPaths(); + + foreach ($this->_scheduledStructure->getListToMove() as $elementToMove) { + $this->_moveElementInStructure($elementToMove); + } + + foreach ($this->_scheduledStructure->getListToRemove() as $elementToRemove) { + $this->_removeElement($elementToRemove); + } + + Magento_Profiler::stop('build_structure'); + + Magento_Profiler::start('generate_elements'); + + while (false === $this->_scheduledStructure->isElementsEmpty()) { + list($type, $node) = current($this->_scheduledStructure->getElements()); + $elementName = key($this->_scheduledStructure->getElements()); + + if (isset($node['output'])) { + $this->addOutputElement($elementName); + } + if ($type == self::TYPE_BLOCK) { + $this->_generateBlock($elementName); + } else { + $this->_generateContainer($elementName, (string)$node[self::CONTAINER_OPT_LABEL], array( + self::CONTAINER_OPT_HTML_TAG => (string)$node[self::CONTAINER_OPT_HTML_TAG], + self::CONTAINER_OPT_HTML_ID => (string)$node[self::CONTAINER_OPT_HTML_ID], + self::CONTAINER_OPT_HTML_CLASS => (string)$node[self::CONTAINER_OPT_HTML_CLASS] + )); + $this->_scheduledStructure->unsetElement($elementName); + } + } + Magento_Profiler::stop('generate_elements'); + Magento_Profiler::stop(__CLASS__ . '::' . __METHOD__); + } + + /** + * Remove scheduled element + * + * @param string $elementName + * @param bool $isChild + * @return Mage_Core_Model_Layout + */ + protected function _removeElement($elementName, $isChild = false) + { + $elementsToRemove = array_keys($this->_structure->getChildren($elementName)); + $this->_scheduledStructure->unsetElement($elementName); + + foreach ($elementsToRemove as $element) { + $this->_removeElement($element, true); + } + + if (!$isChild) { + $this->_structure->unsetElement($elementName); + $this->_scheduledStructure->unsetElementFromListToRemove($elementName); + } + return $this; + } + + /** + * Move element in scheduled structure + * + * @param string $element + * @return Mage_Core_Model_Layout + */ + protected function _moveElementInStructure($element) + { + list ($destination, $siblingName, $isAfter, $alias) = $this->_scheduledStructure->getElementToMove($element); + if (!$alias && false === $this->_structure->getChildId($destination, $this->getElementAlias($element))) { + $alias = $this->getElementAlias($element); + } + $this->_structure->unsetChild($element, $alias)->setAsChild($element, $destination, $alias); + $this->reorderChild($destination, $element, $siblingName, $isAfter); + return $this; + } + + /** + * Traverse through all elements of specified XML-node and schedule structural elements of it + * + * @param Mage_Core_Model_Layout_Element $parent + */ + protected function _readStructure($parent) + { + foreach ($parent as $node) { + /** @var $node Mage_Core_Model_Layout_Element */ + switch ($node->getName()) { + case self::TYPE_CONTAINER: + case self::TYPE_BLOCK: + $this->_initDataSources($node); + $this->_scheduleStructure($node, $parent); + $this->_readStructure($node); + break; + + case self::TYPE_REFERENCE: + $this->_readStructure($node); + break; + + case self::TYPE_ACTION: + $referenceName = $parent->getAttribute('name'); + $element = $this->_scheduledStructure->getStructureElement($referenceName, array()); + $element['actions'][] = array($node, $parent); + $this->_scheduledStructure->setStructureElement($referenceName, $element); + break; + + case self::TYPE_ARGUMENTS: + $referenceName = $parent->getAttribute('name'); + $element = $this->_scheduledStructure->getStructureElement($referenceName, array()); + $args = $this->_readArguments($node); + $element['arguments'] = $this->_mergeArguments($element, $args); + + $this->_scheduledStructure->setStructureElement($referenceName, $element); + break; + + case self::TYPE_MOVE: + $this->_scheduleMove($node); + break; + + case self::TYPE_REMOVE: + $this->_scheduledStructure->setElementToRemoveList((string)$node->getAttribute('name')); + break; + } + } + } + + /** + * Grab information about data source from the node + * + * @param Mage_Core_Model_Layout_Element $node + * @return Mage_Core_Model_Layout + */ + protected function _initDataSources($node) + { + if (!$dataSources = $node->xpath('data')) { + return $this; + } + $nodeName = $node->getAttribute('name'); + foreach ($dataSources as $dataSourceNode) { + $dataSourceName = $dataSourceNode->getAttribute('service-call'); + if (isset($this->_datasources[$dataSourceName])) { + $this->_datasources[$dataSourceName]['namespaces'][$nodeName] = + $dataSourceNode->getAttribute('alias'); + } else { + $this->_datasources[$dataSourceName] = array( + 'namespaces' => array($nodeName => $dataSourceNode->getAttribute('alias')) + ); + } + } + return $this; + } + + /** + * Merge element arguments + * + * @param array $element + * @param array $arguments + * @return array + */ + protected function _mergeArguments(array $element, array $arguments) + { + $output = $arguments; + if (isset($element['arguments'])) { + $output = array_replace_recursive($element['arguments'], $arguments); + } + return $output; + } + + /** + * Read arguments node and create prepared array of them + * + * @param Mage_Core_Model_Layout_Element $node + * @return array + */ + protected function _readArguments(Mage_Core_Model_Layout_Element $node) + { + $arguments = array(); + $moduleName = isset($node['module']) ? (string)$node['module'] : null; + + foreach ($node->children() as $argument) { + /** @var $argument Mage_Core_Model_Layout_Element */ + + $type = $argument->getAttribute('type'); + if (null !== $type) { + $arguments[$argument->getName()]['type'] = $type; + } + + if ($argument->hasChildren()) { + $value = array(); + $this->_fillArgumentsArray($argument, $value, $moduleName); + unset($value['updater']); + unset($value['@']); + + $updaters = $this->_getArgumentUpdaters($argument); + + if (false === empty($updaters)) { + $arguments[$argument->getName()]['updater'] = $updaters; + } + + if (is_array($value) && !empty($value)) { + $arguments[$argument->getName()]['value'] = $value; + } + } else { + $value = $this->_translator->translateArgument($argument, $moduleName); + if ('' !== $value) { + $arguments[$argument->getName()]['value'] = $value; + } + } + } + return $arguments; + } + + protected function _fillArgumentsArray(Mage_Core_Model_Layout_Element $node, &$argumentsArray, $moduleName) + { + $moduleName = isset($node['module']) ? (string)$node['module'] : $moduleName; + + /** @var $childNode Mage_Core_Model_Layout_Element */ + foreach ($node->children() as $childNode) { + $nodeName = $childNode->getName(); + if ($childNode->hasChildren()) { + $this->_fillArgumentsArray($childNode, $argumentsArray[$nodeName], $moduleName); + } else { + $argumentsArray[$nodeName] = $this->_translator->translateArgument($childNode, $moduleName); + } + } + } + + /** + * Get argument updaters list + * + * @param Mage_Core_Model_Layout_Element $argument + * @return array + */ + protected function _getArgumentUpdaters(Mage_Core_Model_Layout_Element $argument) + { + $updaters = array(); + foreach ($argument->children() as $argumentChild) { + /** @var $argumentChild Mage_Core_Model_Layout_Element */ + if ('updater' == $argumentChild->getName()) { + $updaters[uniqid()] = trim((string)$argumentChild); + } + } + return $updaters; + } + + /** + * Schedule structural changes for move directive + * + * @param Mage_Core_Model_Layout_Element $node + * @throws Magento_Exception + * @return Mage_Core_Model_Layout + */ + protected function _scheduleMove($node) + { + $elementName = (string)$node->getAttribute('element'); + $destination = (string)$node->getAttribute('destination'); + $alias = (string)$node->getAttribute('as') ?: ''; + if ($elementName && $destination) { + list($siblingName, $isAfter) = $this->_beforeAfterToSibling($node); + $this->_scheduledStructure->setElementToMove( + $elementName, + array($destination, $siblingName, $isAfter, $alias) + ); + } else { + throw new Magento_Exception('Element name and destination must be specified.'); + } + return $this; + } + + /** + * Populate queue for generating structural elements + * + * @param Mage_Core_Model_Layout_Element $node + * @param Mage_Core_Model_Layout_Element $parent + * @see _scheduleElement() where the _scheduledStructure is used + */ + protected function _scheduleStructure($node, $parent) + { + if ((string)$node->getAttribute('name')) { + $name = (string)$node->getAttribute('name'); + } else { + $name = $this->_generateAnonymousName($parent->getElementName() . '_schedule_block'); + $node->addAttribute('name', $name); + } + $path = $name; + + // type, alias, parentName, siblingName, isAfter, node + $row = array( + self::SCHEDULED_STRUCTURE_INDEX_NAME => $node->getName(), + self::SCHEDULED_STRUCTURE_INDEX_ALIAS => '', + self::SCHEDULED_STRUCTURE_INDEX_PARENT_NAME => '', + self::SCHEDULED_STRUCTURE_INDEX_SIBLING_NAME => null, + self::SCHEDULED_STRUCTURE_INDEX_IS_AFTER => true, + self::SCHEDULED_STRUCTURE_INDEX_LAYOUT_ELEMENT => $node + ); + + $parentName = $parent->getElementName(); + if ($parentName) { + $row[self::SCHEDULED_STRUCTURE_INDEX_ALIAS] = (string)$node->getAttribute('as'); + $row[self::SCHEDULED_STRUCTURE_INDEX_PARENT_NAME] = $parentName; + + list( + $row[self::SCHEDULED_STRUCTURE_INDEX_SIBLING_NAME], + $row[self::SCHEDULED_STRUCTURE_INDEX_IS_AFTER] + ) = $this->_beforeAfterToSibling($node); + + // materialized path for referencing nodes in the plain array of _scheduledStructure + if ($this->_scheduledStructure->hasPath($parentName)) { + $path = $this->_scheduledStructure->getPath($parentName) . '/' . $path; + } + } + + $this->_overrideElementWorkaround($name, $path); + $this->_scheduledStructure->setPathElement($name, $path); + if ($this->_scheduledStructure->hasStructureElement($name)) { + // union of arrays + $this->_scheduledStructure->setStructureElement( + $name, + $row + $this->_scheduledStructure->getStructureElement($name) + ); + } else { + $this->_scheduledStructure->setStructureElement($name, $row); + } + } + + /** + * Analyze "before" and "after" information in the node and return sibling name and whether "after" or "before" + * + * @param Mage_Core_Model_Layout_Element $node + * @return array + */ + protected function _beforeAfterToSibling($node) + { + $result = array(null, true); + if (isset($node['after'])) { + $result[0] = (string)$node['after']; + } elseif (isset($node['before'])) { + $result[0] = (string)$node['before']; + $result[1] = false; + } + return $result; + } + + /** + * Destroy previous element with same name and all its children, if new element overrides it + * + * This is a workaround to handle situation, when an element emerges with name of element that already exists. + * In this case we destroy entire structure of the former element and replace with the new one. + * + * @param string $name + * @param string $path + */ + protected function _overrideElementWorkaround($name, $path) + { + if ($this->_scheduledStructure->hasStructureElement($name)) { + foreach ($this->_scheduledStructure->getPaths() as $potentialChild => $childPath) { + if (0 === strpos($childPath, "{$path}/")) { + $this->_scheduledStructure->unsetPathElement($potentialChild); + $this->_scheduledStructure->unsetStructureElement($potentialChild); + } + } + } + } + + /** + * Process queue of structural elements and actually add them to structure, and schedule elements for generation + * + * The catch is to populate parents first, if they are not in the structure yet. + * Since layout updates could come in arbitrary order, a case is possible where an element is declared in reference, + * while referenced element itself is not declared yet. + * + * @SuppressWarnings(PHPMD.NPathComplexity) + * @param string $key in _scheduledStructure represent element name + */ + protected function _scheduleElement($key) + { + $row = $this->_scheduledStructure->getStructureElement($key); + + if (!isset($row[self::SCHEDULED_STRUCTURE_INDEX_LAYOUT_ELEMENT])) { + Mage::log("Broken reference: missing declaration of the element '{$key}'.", Zend_Log::CRIT); + $this->_scheduledStructure->unsetPathElement($key); + $this->_scheduledStructure->unsetStructureElement($key); + return; + } + list($type, $alias, $parentName, $siblingName, $isAfter, $node) = $row; + $name = $this->_createStructuralElement($key, $type, $parentName . $alias); + if ($parentName) { + // recursively populate parent first + if ($this->_scheduledStructure->hasStructureElement($parentName)) { + $this->_scheduleElement($parentName, $this->_scheduledStructure->getStructureElement($parentName)); + } + if ($this->_structure->hasElement($parentName)) { + $this->_structure->setAsChild($name, $parentName, $alias); + } else { + Mage::log("Broken reference: the '{$name}' element cannot be added as child to '{$parentName}, " + . 'because the latter doesn\'t exist', Zend_Log::CRIT + ); + } + } + $this->_scheduledStructure->unsetStructureElement($key); + $data = array( + $type, + $node, + isset($row['actions']) ? $row['actions'] : array(), + isset($row['arguments']) ? $row['arguments'] : array() + ); + $this->_scheduledStructure->setElement($name, $data); + + /** + * Some elements provide info "after" or "before" which sibling they are supposed to go + * Make sure to populate these siblings as well and order them correctly + */ + if ($siblingName) { + if ($this->_scheduledStructure->hasStructureElement($siblingName)) { + $this->_scheduleElement($siblingName); + } + $this->reorderChild($parentName, $name, $siblingName, $isAfter); + } + } + + /** + * Register an element in structure + * + * Will assign an "anonymous" name to the element, if provided with an empty name + * + * @param string $name + * @param string $type + * @param string $class + * @return string + */ + protected function _createStructuralElement($name, $type, $class) + { + if (empty($name)) { + $name = $this->_generateAnonymousName($class); + } + $this->_structure->createElement($name, array('type' => $type)); + return $name; + } + + /** + * Generate anonymous element name for structure + * + * @param string $class + * @return string + */ + protected function _generateAnonymousName($class) + { + $position = strpos($class, 'Block'); + $key = $position !== false ? substr($class, $position + 6) : $class; + $key = strtolower(trim($key, '_')); + + if (!isset($this->_nameIncrement[$key])) { + $this->_nameIncrement[$key] = 0; + } + + if ($this->_nameIncrement[$key] == 0 && !$this->_structure->hasElement($key)) { + $this->_nameIncrement[$key]++; + return $key; + } + + do { + $name = $key . '_' . $this->_nameIncrement[$key]++; + } while ($this->_structure->hasElement($name)); + + return $name; + } + + /** + * Creates block object based on xml node data and add it to the layout + * + * @param string $elementName + * @return Mage_Core_Block_Abstract + * @throws Magento_Exception + */ + protected function _generateBlock($elementName) + { + list($type, $node, $actions, $arguments) = $this->_scheduledStructure->getElement($elementName); + if ($type !== self::TYPE_BLOCK) { + throw new Magento_Exception("Unexpected element type specified for generating block: {$type}."); + } + + // create block + if (!empty($node['class'])) { + $className = (string)$node['class']; + } else { + $className = (string)$node['type']; + } + + $arguments = $this->_argumentProcessor->process($arguments); + $dictionary = $this->_dataSourceFactory->getByNamespace((string)$node['name']); + + $block = $this->_createBlock($className, $elementName, + array('data' => $arguments, 'dictionary' => $dictionary)); + + if (!empty($node['module'])) { + $block->setModuleName((string)$node['module']); + } + + // TODO: is the instanceof check below the right thing to do? + if (!empty($node['template'])) { + $templateFileName = (string)$node['template']; + if ($block instanceof Mage_Core_Block_Template) { + $block->assign($dictionary); + } + $block->setTemplate($templateFileName); + } + + $this->_scheduledStructure->unsetElement($elementName); + + // execute block methods + foreach ($actions as $action) { + list($actionNode, $parent) = $action; + $this->_generateAction($actionNode, $parent); + } + + return $block; + } + + public function getDatasources() + { + return $this->_datasources; + } + + /** + * Set container-specific data to structure element + * + * @param string $name + * @param string $label + * @param array $options + * @throws Magento_Exception if any of arguments are invalid + */ + protected function _generateContainer($name, $label, array $options) + { + if (empty($label)) { + throw new Magento_Exception('Container requires a label.'); + } + $this->_structure->setAttribute($name, self::CONTAINER_OPT_LABEL, $label); + unset($options[self::CONTAINER_OPT_LABEL]); + unset($options['type']); + if (empty($options[self::CONTAINER_OPT_HTML_TAG]) + && (!empty($options[self::CONTAINER_OPT_HTML_ID]) || !empty($options[self::CONTAINER_OPT_HTML_CLASS])) + ) { + throw new Magento_Exception('HTML ID or class will not have effect, if HTML tag is not specified.'); + } + foreach ($options as $key => $value) { + $this->_structure->setAttribute($name, $key, $value); + } + } + + /** + * Run action defined in layout update + * + * @param Mage_Core_Model_Layout_Element $node + * @param Mage_Core_Model_Layout_Element $parent + */ + protected function _generateAction($node, $parent) + { + $configPath = $node->getAttribute('ifconfig'); + if ($configPath && !Mage::getStoreConfigFlag($configPath)) { + return; + } + + $method = $node->getAttribute('method'); + $parentName = $node->getAttribute('block'); + if (empty($parentName)) { + $parentName = $parent->getElementName(); + } + + $profilerKey = 'BLOCK_ACTION:' . $parentName . '>' . $method; + Magento_Profiler::start($profilerKey); + + $block = $this->getBlock($parentName); + if (!empty($block)) { + $args = $this->_extractArgs($node); + $this->_translator->translateActionParameters($node, $args); + call_user_func_array(array($block, $method), $args); + } + + Magento_Profiler::stop($profilerKey); + } + + /** + * Get child block if exists + * + * @param string $parentName + * @param string $alias + * @return bool|Mage_Core_Block_Abstract + */ + public function getChildBlock($parentName, $alias) + { + $name = $this->_structure->getChildId($parentName, $alias); + if ($this->isBlock($name)) { + return $this->getBlock($name); + } + return false; + } + + /** + * Set child element into layout structure + * + * @param string $parentName + * @param string $elementName + * @param string $alias + * @return Mage_Core_Model_Layout + */ + public function setChild($parentName, $elementName, $alias) + { + $this->_structure->setAsChild($elementName, $parentName, $alias); + return $this; + } + + /** + * Reorder a child of a specified element + * + * If $offsetOrSibling is null, it will put the element to the end + * If $offsetOrSibling is numeric (integer) value, it will put the element after/before specified position + * Otherwise -- after/before specified sibling + * + * @param string $parentName + * @param string $childName + * @param string|int|null $offsetOrSibling + * @param bool $after + */ + public function reorderChild($parentName, $childName, $offsetOrSibling, $after = true) + { + if (is_numeric($offsetOrSibling)) { + $offset = (int)abs($offsetOrSibling) * ($after ? 1 : -1); + $this->_structure->reorderChild($parentName, $childName, $offset); + } elseif (null === $offsetOrSibling) { + $this->_structure->reorderChild($parentName, $childName, null); + } else { + $children = $this->getChildNames($parentName); + $sibling = $this->_filterSearchMinus($offsetOrSibling, $children, $after); + if ($childName !== $sibling) { + $siblingParentName = $this->_structure->getParentId($sibling); + if ($parentName !== $siblingParentName) { + Mage::log( + "Broken reference: the '{$childName}' tries to reorder itself towards '{$sibling}', " + . "but their parents are different: '{$parentName}' and '{$siblingParentName}' respectively.", + Zend_Log::CRIT + ); + return; + } + $this->_structure->reorderToSibling($parentName, $childName, $sibling, $after ? 1 : -1); + } + } + } + + /** + * Search for an array element using needle, but needle may be '-', which means "first" or "last" element + * + * Returns first or last element in the haystack, or the $needle argument + * + * @param string $needle + * @param array $haystack + * @param bool $isLast + * @return string + */ + protected function _filterSearchMinus($needle, array $haystack, $isLast) + { + if ('-' === $needle) { + if ($isLast) { + return array_pop($haystack); + } + return array_shift($haystack); + } + return $needle; + } + + /** + * Remove child element from parent + * + * @param string $parentName + * @param string $alias + * @return Mage_Core_Model_Layout + */ + public function unsetChild($parentName, $alias) + { + $this->_structure->unsetChild($parentName, $alias); + return $this; + } + + /** + * Get list of child names + * + * @param string $parentName + * @return array + */ + public function getChildNames($parentName) + { + return array_keys($this->_structure->getChildren($parentName)); + } + + /** + * Get list of child blocks + * + * Returns associative array of => + * + * @param string $parentName + * @return array + */ + public function getChildBlocks($parentName) + { + $blocks = array(); + foreach ($this->_structure->getChildren($parentName) as $childName => $alias) { + $block = $this->getBlock($childName); + if ($block) { + $blocks[$alias] = $block; + } + } + return $blocks; + } + + /** + * Get child name by alias + * + * @param string $parentName + * @param string $alias + * @return bool|string + */ + public function getChildName($parentName, $alias) + { + return $this->_structure->getChildId($parentName, $alias); + } + + /** + * Find an element in layout, render it and return string with its output + * + * @param string $name + * @param bool $useCache + * @return string + */ + public function renderElement($name, $useCache = true) + { + if (!isset($this->_renderElementCache[$name]) || !$useCache) { + if ($this->isBlock($name)) { + $result = $this->_renderBlock($name); + } else { + $result = $this->_renderContainer($name); + } + $this->_renderElementCache[$name] = $result; + } + $this->_renderingOutput->setData('output', $this->_renderElementCache[$name]); + Mage::dispatchEvent('core_layout_render_element', array( + 'element_name' => $name, + 'layout' => $this, + 'transport' => $this->_renderingOutput, + )); + return $this->_renderingOutput->getData('output'); + } + + /** + * Gets HTML of block element + * + * @param string $name + * @return string + * @throws Magento_Exception + */ + protected function _renderBlock($name) + { + $block = $this->getBlock($name); + return $block ? $block->toHtml() : ''; + } + + /** + * Gets HTML of container element + * + * @param string $name + * @return string + */ + protected function _renderContainer($name) + { + $html = ''; + $children = $this->getChildNames($name); + foreach ($children as $child) { + $html .= $this->renderElement($child); + } + if ($html == '' || !$this->_structure->getAttribute($name, self::CONTAINER_OPT_HTML_TAG)) { + return $html; + } + + $htmlId = $this->_structure->getAttribute($name, self::CONTAINER_OPT_HTML_ID); + if ($htmlId) { + $htmlId = ' id="' . $htmlId . '"'; + } + + $htmlClass = $this->_structure->getAttribute($name, self::CONTAINER_OPT_HTML_CLASS); + if ($htmlClass) { + $htmlClass = ' class="'. $htmlClass . '"'; + } + + $htmlTag = $this->_structure->getAttribute($name, self::CONTAINER_OPT_HTML_TAG); + + $html = sprintf('<%1$s%2$s%3$s>%4$s', $htmlTag, $htmlId, $htmlClass, $html); + + return $html; + } + + /** + * Add element to parent group + * + * @param string $blockName + * @param string $parentGroupName + * @return bool + */ + public function addToParentGroup($blockName, $parentGroupName) + { + return $this->_structure->addToParentGroup($blockName, $parentGroupName); + } + + /** + * Get element names for specified group + * + * @param string $blockName + * @param string $groupName + * @return array + */ + public function getGroupChildNames($blockName, $groupName) + { + return $this->_structure->getGroupChildNames($blockName, $groupName); + } + + /** + * Update args according to its type + * + * @param Mage_Core_Model_Layout_Element $node + * @return array + */ + protected function _extractArgs($node) + { + $args = (array)$node->children(); + unset($args['@attributes']); + + foreach ($args as $key => $arg) { + $matches = array(); + if (($arg instanceof Mage_Core_Model_Layout_Element)) { + if (isset($arg['helper'])) { + $args[$key] = $this->_getArgsByHelper($arg); + } else { + /** + * if there is no helper we hope that this is assoc array + */ + $arr = $this->_getArgsFromAssoc($arg); + if (!empty($arr)) { + $args[$key] = $arr; + } + } + } else if (preg_match('/\{\{([a-zA-Z\.]*)\}\}/', $arg, $matches)) { + $args[$key] = $this->_dataSourceFactory->getArgumentValue($matches[1]); + } + } + + if (isset($node['json'])) { + $json = explode(' ', (string)$node['json']); + foreach ($json as $arg) { + $args[$arg] = Mage::helper('Mage_Core_Helper_Data')->jsonDecode($args[$arg]); + } + } + + return $args; + } + + /** + * Gets arguments using helper method + * + * @param Mage_Core_Model_Layout_Element $arg + * @return mixed + */ + protected function _getArgsByHelper(Mage_Core_Model_Layout_Element $arg) + { + $helper = (string)$arg['helper']; + list($helperName, $helperMethod) = explode('::', $helper); + $arg = $arg->asArray(); + unset($arg['@']); + return call_user_func_array(array(Mage::helper($helperName), $helperMethod), $arg); + } + + /** + * Converts input array to arguments array + * + * @param array $array + * @return array + */ + protected function _getArgsFromAssoc($array) + { + $arr = array(); + foreach ($array as $key => $value) { + $arr[(string)$key] = $value->asArray(); + } + return $arr; + } + + /** + * Check if element exists in layout structure + * + * @param string $name + * @return bool + */ + public function hasElement($name) + { + return $this->_structure->hasElement($name); + } + + /** + * Get property value of an element + * + * @param string $name + * @param string $attribute + * @return mixed + */ + public function getElementProperty($name, $attribute) + { + return $this->_structure->getAttribute($name, $attribute); + } + + /** + * Whether specified element is a block + * + * @param string $name + * @return bool + */ + public function isBlock($name) + { + if ($this->_structure->hasElement($name)) { + return self::TYPE_BLOCK === $this->_structure->getAttribute($name, 'type'); + } + return false; + } + + /** + * Checks if element with specified name is container + * + * @param string $name + * @return bool + */ + public function isContainer($name) + { + if ($this->_structure->hasElement($name)) { + return self::TYPE_CONTAINER === $this->_structure->getAttribute($name, 'type'); + } + return false; + } + + /** + * Whether the specified element may be manipulated externally + * + * @param string $name + * @return bool + */ + public function isManipulationAllowed($name) + { + $parentName = $this->_structure->getParentId($name); + return $parentName && $this->isContainer($parentName); + } + + /** + * Save block in blocks registry + * + * @param string $name + * @param Mage_Core_Block_Abstract $block + * @return Mage_Core_Model_Layout + */ + public function setBlock($name, $block) + { + $this->_blocks[$name] = $block; + return $this; + } + + /** + * Remove block from registry + * + * @param string $name + * @return Mage_Core_Model_Layout + */ + public function unsetElement($name) + { + if (isset($this->_blocks[$name])) { + $this->_blocks[$name] = null; + unset($this->_blocks[$name]); + } + $this->_structure->unsetElement($name); + + return $this; + } + + /** + * Block Factory + * + * @param string $type + * @param string $name + * @param array $attributes + * @return Mage_Core_Block_Abstract + */ + public function createBlock($type, $name = '', array $attributes = array()) + { + $name = $this->_createStructuralElement($name, self::TYPE_BLOCK, $type); + $block = $this->_createBlock($type, $name, $attributes); + return $block; + } + + /** + * Create block and add to layout + * + * @param string|Mage_Core_Block_Abstract $block + * @param string $name + * @param array $attributes + * @return Mage_Core_Block_Abstract + */ + protected function _createBlock($block, $name, array $attributes = array()) + { + $block = $this->_getBlockInstance($block, $attributes); + + $block->setType(get_class($block)); + $block->setNameInLayout($name); + $block->addData(isset($attributes['data']) ? $attributes['data'] : array()); + $block->setLayout($this); + + $this->_blocks[$name] = $block; + Mage::dispatchEvent('core_layout_block_create_after', array('block' => $block)); + return $this->_blocks[$name]; + } + + /** + * Add a block to registry, create new object if needed + * + * @param string|Mage_Core_Block_Abstract $block + * @param string $name + * @param string $parent + * @param string $alias + * @return Mage_Core_Block_Abstract + */ + public function addBlock($block, $name = '', $parent = '', $alias = '') + { + if (empty($name) && $block instanceof Mage_Core_Block_Abstract) { + $name = $block->getNameInLayout(); + } + $name = $this->_createStructuralElement( + $name, + self::TYPE_BLOCK, + $name ?: (is_object($block) ? get_class($block) : $block) + ); + if ($parent) { + $this->_structure->setAsChild($name, $parent, $alias); + } + return $this->_createBlock($block, $name); + } + + /** + * Insert container into layout structure + * + * @param string $name + * @param string $label + * @param array $options + * @param string $parent + * @param string $alias + */ + public function addContainer($name, $label, array $options = array(), $parent = '', $alias = '') + { + $name = $this->_createStructuralElement($name, self::TYPE_CONTAINER, $alias); + $this->_generateContainer($name, $label, $options); + if ($parent) { + $this->_structure->setAsChild($name, $parent, $alias); + } + } + + /** + * Rename element in layout and layout structure + * + * @param string $oldName + * @param string $newName + * @return bool + */ + public function renameElement($oldName, $newName) + { + if (isset($this->_blocks[$oldName])) { + $block = $this->_blocks[$oldName]; + $this->_blocks[$oldName] = null; + unset($this->_blocks[$oldName]); + $this->_blocks[$newName] = $block; + } + $this->_structure->renameElement($oldName, $newName); + + return $this; + } + + /** + * Create block object instance based on block type + * + * @param string|Mage_Core_Block_Abstract $block + * @param array $attributes + * @return Mage_Core_Block_Abstract + */ + protected function _getBlockInstance($block, array $attributes = array()) + { + if ($block && is_string($block)) { + if (class_exists($block)) { + $block = $this->_blockFactory->createBlock($block, $attributes); + } + } + if (!$block instanceof Mage_Core_Block_Abstract) { + Mage::throwException(Mage::helper('Mage_Core_Helper_Data')->__('Invalid block type: %s', $block)); + } + return $block; + } + + + /** + * Retrieve all blocks from registry as array + * + * @return array + */ + public function getAllBlocks() + { + return $this->_blocks; + } + + /** + * Get block object by name + * + * @param string $name + * @return Mage_Core_Block_Abstract|bool + */ + public function getBlock($name) + { + if ($this->_scheduledStructure->hasElement($name)) { + $this->_generateBlock($name); + } + if (isset($this->_blocks[$name])) { + return $this->_blocks[$name]; + } else { + return false; + } + } + + /** + * Gets parent name of an element with specified name + * + * @param string $childName + * @return bool|string + */ + public function getParentName($childName) + { + return $this->_structure->getParentId($childName); + } + + /** + * Get element alias by name + * + * @param string $name + * @return bool|string + */ + public function getElementAlias($name) + { + return $this->_structure->getChildAlias($this->_structure->getParentId($name), $name); + } + + /** + * Add an element to output + * + * @param string $name + * @return Mage_Core_Model_Layout + */ + public function addOutputElement($name) + { + $this->_output[$name] = $name; + return $this; + } + + /** + * Remove an element from output + * + * @param string $name + * @return Mage_Core_Model_Layout + */ + public function removeOutputElement($name) + { + if (isset($this->_output[$name])) { + unset($this->_output[$name]); + } + return $this; + } + + /** + * Get all blocks marked for output + * + * @return string + */ + public function getOutput() + { + $out = ''; + foreach ($this->_output as $name) { + $out .= $this->renderElement($name); + } + + return $out; + } + + /** + * Retrieve messages block + * + * @return Mage_Core_Block_Messages + */ + public function getMessagesBlock() + { + $block = $this->getBlock('messages'); + if ($block) { + return $block; + } + return $this->createBlock('Mage_Core_Block_Messages', 'messages'); + } + + /** + * Get block singleton + * + * @param string $type + * @return Mage_Core_Helper_Abstract + */ + public function getBlockSingleton($type) + { + if (!isset($this->_helpers[$type])) { + if (!$type) { + Mage::throwException(Mage::helper('Mage_Core_Helper_Data')->__('Invalid block type: %s', $type)); + } + + $helper = Mage::getModel($type); + if ($helper) { + if ($helper instanceof Mage_Core_Block_Abstract) { + $helper->setLayout($this); + } + $this->_helpers[$type] = $helper; + } + } + return $this->_helpers[$type]; + } + + /** + * Retrieve helper object + * + * @param string $name + * @return Mage_Core_Helper_Abstract + */ + public function helper($name) + { + $helper = Mage::helper($name); + if (!$helper) { + return false; + } + return $helper->setLayout($this); + } + + /** + * Lookup module name for translation from current specified layout node + * + * Priorities: + * 1) "module" attribute in the element + * 2) "module" attribute in any ancestor element + * 3) layout handle name - first 1 or 2 parts (namespace is determined automatically) + * + * @param Varien_Simplexml_Element $node + * @return string + */ + public static function findTranslationModuleName(Varien_Simplexml_Element $node) + { + // Commented out code uses not yet implemented functionality. + $result = (string) $node->getAttribute('module'); + if ($result) { + //return Mage::getConfig()->getModuleConfig($result) ? $result : 'core'; + return $result; + } + foreach (array_reverse($node->xpath('ancestor::*[@module]')) as $element) { + $result = (string)$element->getAttribute('module'); + if ($result) { + //return Mage::getConfig()->getModuleConfig($result) ? $result : 'core'; + return $result; + } + } + foreach ($node->xpath('ancestor-or-self::*[last()-1]') as $handle) { + $name = Mage::getConfig()->determineOmittedNamespace($handle->getName(), true); + if ($name) { + //return Mage::getConfig()->getModuleConfig($name) ? $name : 'core'; + return $name; + } + } + return 'Mage_Core'; + } + + /** + * Retrieve block factory + * + * @return Mage_Core_Model_BlockFactory + */ + public function getBlockFactory() + { + return $this->_blockFactory; + } +} diff --git a/app/code/core/Mage/Core/Model/Layout/Argument/Handler/Object.php b/app/code/Mage/Core/Model/Layout/Argument/Handler/Object.php similarity index 98% rename from app/code/core/Mage/Core/Model/Layout/Argument/Handler/Object.php rename to app/code/Mage/Core/Model/Layout/Argument/Handler/Object.php index 00f8b3665c0dd..27a4026a31ed2 100644 --- a/app/code/core/Mage/Core/Model/Layout/Argument/Handler/Object.php +++ b/app/code/Mage/Core/Model/Layout/Argument/Handler/Object.php @@ -40,7 +40,7 @@ class Mage_Core_Model_Layout_Argument_Handler_Object extends Mage_Core_Model_Lay */ public function process($value) { - $valueInstance = $this->_objectManager->create($value, array(), false); + $valueInstance = $this->_objectManager->create($value, array()); return $valueInstance; } } diff --git a/app/code/core/Mage/Core/Model/Layout/Argument/Handler/ObjectFactory.php b/app/code/Mage/Core/Model/Layout/Argument/Handler/ObjectFactory.php similarity index 94% rename from app/code/core/Mage/Core/Model/Layout/Argument/Handler/ObjectFactory.php rename to app/code/Mage/Core/Model/Layout/Argument/Handler/ObjectFactory.php index d7fd065e41312..ab1afe384c266 100644 --- a/app/code/core/Mage/Core/Model/Layout/Argument/Handler/ObjectFactory.php +++ b/app/code/Mage/Core/Model/Layout/Argument/Handler/ObjectFactory.php @@ -40,8 +40,6 @@ class Mage_Core_Model_Layout_Argument_Handler_ObjectFactory */ public function createHandler() { - return Mage::getModel('Mage_Core_Model_Layout_Argument_Handler_Object', array( - 'objectFactory' => Mage::app()->getConfig() - )); + return Mage::getModel('Mage_Core_Model_Layout_Argument_Handler_Object'); } } diff --git a/app/code/Mage/Core/Model/Layout/Argument/Handler/Options.php b/app/code/Mage/Core/Model/Layout/Argument/Handler/Options.php new file mode 100644 index 0000000000000..ec200d179a77f --- /dev/null +++ b/app/code/Mage/Core/Model/Layout/Argument/Handler/Options.php @@ -0,0 +1,51 @@ + + */ +class Mage_Core_Model_Layout_Argument_Handler_Options extends Mage_Core_Model_Layout_Argument_HandlerAbstract +{ + /** + * Return option array of given option model + * @param string $value + * @throws InvalidArgumentException + * @return Mage_Core_Model_Abstract|boolean + */ + public function process($value) + { + /** @var $valueInstance Mage_Core_Model_Option_ArrayInterface */ + $valueInstance = $this->_objectManager->create($value, array()); + if (false === ($valueInstance instanceof Mage_Core_Model_Option_ArrayInterface)) { + throw new InvalidArgumentException('Incorrect option model'); + } + return $valueInstance->toOptionArray(); + } +} diff --git a/app/code/core/Mage/Core/Model/Layout/Argument/Handler/OptionsFactory.php b/app/code/Mage/Core/Model/Layout/Argument/Handler/OptionsFactory.php similarity index 94% rename from app/code/core/Mage/Core/Model/Layout/Argument/Handler/OptionsFactory.php rename to app/code/Mage/Core/Model/Layout/Argument/Handler/OptionsFactory.php index 52e60b08bf4d4..cfeb97ee64f96 100644 --- a/app/code/core/Mage/Core/Model/Layout/Argument/Handler/OptionsFactory.php +++ b/app/code/Mage/Core/Model/Layout/Argument/Handler/OptionsFactory.php @@ -40,8 +40,6 @@ class Mage_Core_Model_Layout_Argument_Handler_OptionsFactory */ public function createHandler() { - return Mage::getModel('Mage_Core_Model_Layout_Argument_Handler_Options', array( - 'objectFactory' => Mage::app()->getConfig() - )); + return Mage::getModel('Mage_Core_Model_Layout_Argument_Handler_Options'); } } diff --git a/app/code/Mage/Core/Model/Layout/Argument/Handler/Url.php b/app/code/Mage/Core/Model/Layout/Argument/Handler/Url.php new file mode 100644 index 0000000000000..c022d28a7d29a --- /dev/null +++ b/app/code/Mage/Core/Model/Layout/Argument/Handler/Url.php @@ -0,0 +1,67 @@ + + */ +class Mage_Core_Model_Layout_Argument_Handler_Url extends Mage_Core_Model_Layout_Argument_HandlerAbstract +{ + /** + * @var Mage_Core_Model_UrlInterface + */ + protected $_urlModel; + + /** + * @param Magento_ObjectManager $objectManager + * @param Mage_Core_Model_UrlInterface $urlModel + */ + public function __construct(Magento_ObjectManager $objectManager, Mage_Core_Model_UrlInterface $urlModel) + { + parent::__construct($objectManager); + + $this->_urlModel = $urlModel; + } + + /** + * Generate url + * @param string $value + * @throws InvalidArgumentException + * @return Mage_Core_Model_Abstract|boolean + */ + public function process($value) + { + if (false === is_array($value) || (!isset($value['path']))) { + throw new InvalidArgumentException('Passed value has incorrect format'); + } + + $params = array_key_exists('params', $value) ? $value['params'] : null; + return $this->_urlModel->getUrl($value['path'], $params); + } +} diff --git a/app/code/core/Mage/Core/Model/Layout/Argument/Handler/UrlFactory.php b/app/code/Mage/Core/Model/Layout/Argument/Handler/UrlFactory.php similarity index 96% rename from app/code/core/Mage/Core/Model/Layout/Argument/Handler/UrlFactory.php rename to app/code/Mage/Core/Model/Layout/Argument/Handler/UrlFactory.php index 02dde9296598e..9bb3fe66bf9d7 100644 --- a/app/code/core/Mage/Core/Model/Layout/Argument/Handler/UrlFactory.php +++ b/app/code/Mage/Core/Model/Layout/Argument/Handler/UrlFactory.php @@ -41,7 +41,6 @@ class Mage_Core_Model_Layout_Argument_Handler_UrlFactory public function createHandler() { return Mage::getModel('Mage_Core_Model_Layout_Argument_Handler_Url', array( - 'objectFactory' => Mage::app()->getConfig(), 'urlModel' => Mage::app()->getStore()->getUrlModel() )); } diff --git a/app/code/core/Mage/Core/Model/Layout/Argument/HandlerAbstract.php b/app/code/Mage/Core/Model/Layout/Argument/HandlerAbstract.php similarity index 100% rename from app/code/core/Mage/Core/Model/Layout/Argument/HandlerAbstract.php rename to app/code/Mage/Core/Model/Layout/Argument/HandlerAbstract.php diff --git a/app/code/core/Mage/Core/Model/Layout/Argument/HandlerFactory.php b/app/code/Mage/Core/Model/Layout/Argument/HandlerFactory.php similarity index 98% rename from app/code/core/Mage/Core/Model/Layout/Argument/HandlerFactory.php rename to app/code/Mage/Core/Model/Layout/Argument/HandlerFactory.php index 100a8e042cdd7..0bf10fa15da9e 100644 --- a/app/code/core/Mage/Core/Model/Layout/Argument/HandlerFactory.php +++ b/app/code/Mage/Core/Model/Layout/Argument/HandlerFactory.php @@ -76,6 +76,6 @@ public function getArgumentHandlerByType($type) throw new InvalidArgumentException('Argument handler ' . $type . ' is not exists'); } - return $this->_objectManager->create($this->_handlerFactories[$type], array(), false); + return $this->_objectManager->create($this->_handlerFactories[$type], array()); } } diff --git a/app/code/core/Mage/Core/Model/Layout/Argument/HandlerFactoryInterface.php b/app/code/Mage/Core/Model/Layout/Argument/HandlerFactoryInterface.php similarity index 100% rename from app/code/core/Mage/Core/Model/Layout/Argument/HandlerFactoryInterface.php rename to app/code/Mage/Core/Model/Layout/Argument/HandlerFactoryInterface.php diff --git a/app/code/core/Mage/Core/Model/Layout/Argument/HandlerInterface.php b/app/code/Mage/Core/Model/Layout/Argument/HandlerInterface.php similarity index 100% rename from app/code/core/Mage/Core/Model/Layout/Argument/HandlerInterface.php rename to app/code/Mage/Core/Model/Layout/Argument/HandlerInterface.php diff --git a/app/code/core/Mage/Core/Model/Layout/Argument/Processor.php b/app/code/Mage/Core/Model/Layout/Argument/Processor.php similarity index 100% rename from app/code/core/Mage/Core/Model/Layout/Argument/Processor.php rename to app/code/Mage/Core/Model/Layout/Argument/Processor.php diff --git a/app/code/core/Mage/Core/Model/Layout/Argument/ProcessorConfig.php b/app/code/Mage/Core/Model/Layout/Argument/ProcessorConfig.php similarity index 100% rename from app/code/core/Mage/Core/Model/Layout/Argument/ProcessorConfig.php rename to app/code/Mage/Core/Model/Layout/Argument/ProcessorConfig.php diff --git a/app/code/Mage/Core/Model/Layout/Argument/Updater.php b/app/code/Mage/Core/Model/Layout/Argument/Updater.php new file mode 100644 index 0000000000000..1730572b489c3 --- /dev/null +++ b/app/code/Mage/Core/Model/Layout/Argument/Updater.php @@ -0,0 +1,71 @@ + + */ +class Mage_Core_Model_Layout_Argument_Updater +{ + /** + * @var Magento_ObjectManager + */ + protected $_objectManager; + + /** + * @param Magento_ObjectManager $objectManager + */ + public function __construct(Magento_ObjectManager $objectManager) + { + $this->_objectManager = $objectManager; + } + + /** + * Apply all updater to value + * + * @param mixed $value + * @param array $updaters + * @throws InvalidArgumentException + * @return mixed + */ + public function applyUpdaters($value, array $updaters = array()) + { + foreach ($updaters as $updater) { + /** @var Mage_Core_Model_Layout_Argument_UpdaterInterface $updaterInstance */ + $updaterInstance = $this->_objectManager->create($updater, array()); + if (false === ($updaterInstance instanceof Mage_Core_Model_Layout_Argument_UpdaterInterface)) { + throw new InvalidArgumentException($updater + . ' should implement Mage_Core_Model_Layout_Argument_UpdaterInterface' + ); + } + $value = $updaterInstance->update($value); + } + return $value; + } +} diff --git a/app/code/core/Mage/Core/Model/Layout/Argument/UpdaterInterface.php b/app/code/Mage/Core/Model/Layout/Argument/UpdaterInterface.php similarity index 100% rename from app/code/core/Mage/Core/Model/Layout/Argument/UpdaterInterface.php rename to app/code/Mage/Core/Model/Layout/Argument/UpdaterInterface.php diff --git a/app/code/core/Mage/Core/Model/Layout/Element.php b/app/code/Mage/Core/Model/Layout/Element.php similarity index 100% rename from app/code/core/Mage/Core/Model/Layout/Element.php rename to app/code/Mage/Core/Model/Layout/Element.php diff --git a/app/code/Mage/Core/Model/Layout/Factory.php b/app/code/Mage/Core/Model/Layout/Factory.php new file mode 100644 index 0000000000000..26774095aede3 --- /dev/null +++ b/app/code/Mage/Core/Model/Layout/Factory.php @@ -0,0 +1,67 @@ +_objectManager = $objectManager; + } + + /** + * @param array $arguments + * @param string $className + * @return Mage_Core_Model_Layout + */ + public function createLayout(array $arguments = array(), $className = self::CLASS_NAME) + { + $configuration = array( + $className => array( + 'parameters' => $arguments + ) + ); + if ($className != self::CLASS_NAME) { + $configuration['preferences'] = array( + self::CLASS_NAME => $className, + ); + } + $this->_objectManager->configure($configuration); + return $this->_objectManager->get(self::CLASS_NAME); + } +} diff --git a/app/code/core/Mage/Core/Model/Layout/Link.php b/app/code/Mage/Core/Model/Layout/Link.php similarity index 100% rename from app/code/core/Mage/Core/Model/Layout/Link.php rename to app/code/Mage/Core/Model/Layout/Link.php diff --git a/app/code/core/Mage/Core/Model/Layout/Merge.php b/app/code/Mage/Core/Model/Layout/Merge.php similarity index 99% rename from app/code/core/Mage/Core/Model/Layout/Merge.php rename to app/code/Mage/Core/Model/Layout/Merge.php index 3bd70c94b2ce9..8c03e2018908a 100644 --- a/app/code/core/Mage/Core/Model/Layout/Merge.php +++ b/app/code/Mage/Core/Model/Layout/Merge.php @@ -32,7 +32,7 @@ class Mage_Core_Model_Layout_Merge /** * Additional tag for cleaning layout cache convenience */ - const LAYOUT_GENERAL_CACHE_TAG = 'LAYOUT_GENERAL_CACHE_TAG'; + const LAYOUT_GENERAL_CACHE_TAG = Mage_Core_Model_Cache_Type_Layout::CACHE_TAG; /**#@+ * Available item type names diff --git a/app/code/core/Mage/Core/Model/Layout/Merge/Factory.php b/app/code/Mage/Core/Model/Layout/Merge/Factory.php similarity index 100% rename from app/code/core/Mage/Core/Model/Layout/Merge/Factory.php rename to app/code/Mage/Core/Model/Layout/Merge/Factory.php diff --git a/app/code/core/Mage/Core/Model/Layout/ScheduledStructure.php b/app/code/Mage/Core/Model/Layout/ScheduledStructure.php similarity index 100% rename from app/code/core/Mage/Core/Model/Layout/ScheduledStructure.php rename to app/code/Mage/Core/Model/Layout/ScheduledStructure.php diff --git a/app/code/core/Mage/Core/Model/Layout/Translator.php b/app/code/Mage/Core/Model/Layout/Translator.php similarity index 100% rename from app/code/core/Mage/Core/Model/Layout/Translator.php rename to app/code/Mage/Core/Model/Layout/Translator.php diff --git a/app/code/core/Mage/Core/Model/Layout/Update.php b/app/code/Mage/Core/Model/Layout/Update.php similarity index 100% rename from app/code/core/Mage/Core/Model/Layout/Update.php rename to app/code/Mage/Core/Model/Layout/Update.php diff --git a/app/code/Mage/Core/Model/Locale.php b/app/code/Mage/Core/Model/Locale.php new file mode 100644 index 0000000000000..a865db385998f --- /dev/null +++ b/app/code/Mage/Core/Model/Locale.php @@ -0,0 +1,781 @@ + + */ +class Mage_Core_Model_Locale +{ + /** + * Default locale name + */ + const DEFAULT_LOCALE = 'en_US'; + const DEFAULT_TIMEZONE = 'UTC'; + const DEFAULT_CURRENCY = 'USD'; + + /** + * XML path constants + */ + const XML_PATH_DEFAULT_LOCALE = 'general/locale/code'; + const XML_PATH_DEFAULT_TIMEZONE = 'general/locale/timezone'; + const XML_PATH_ALLOW_CODES = 'global/locale/allow/codes'; + const XML_PATH_ALLOW_CURRENCIES = 'global/locale/allow/currencies'; + const XML_PATH_ALLOW_CURRENCIES_INSTALLED = 'system/currency/installed'; + + /** + * Date and time format codes + */ + const FORMAT_TYPE_FULL = 'full'; + const FORMAT_TYPE_LONG = 'long'; + const FORMAT_TYPE_MEDIUM= 'medium'; + const FORMAT_TYPE_SHORT = 'short'; + + /** + * Default locale code + * + * @var string + */ + protected $_defaultLocale; + + /** + * Locale object + * + * @var Zend_Locale + */ + protected $_locale; + + /** + * Locale code + * + * @var string + */ + protected $_localeCode; + + /** + * Emulated locales stack + * + * @var array + */ + protected $_emulatedLocales = array(); + + protected static $_currencyCache = array(); + + public function __construct($locale = null) + { + $this->setLocale($locale); + } + + /** + * Set default locale code + * + * @param string $locale + * @return Mage_Core_Model_Locale + */ + public function setDefaultLocale($locale) + { + $this->_defaultLocale = $locale; + return $this; + } + + /** + * REtrieve default locale code + * + * @return string + */ + public function getDefaultLocale() + { + if (!$this->_defaultLocale) { + $locale = Mage::getStoreConfig(self::XML_PATH_DEFAULT_LOCALE); + if (!$locale) { + $locale = self::DEFAULT_LOCALE; + } + $this->_defaultLocale = $locale; + } + return $this->_defaultLocale; + } + + /** + * Set locale + * + * @param string $locale + * @return Mage_Core_Model_Locale + */ + public function setLocale($locale = null) + { + if (($locale !== null) && is_string($locale)) { + $this->_localeCode = $locale; + } else { + $this->_localeCode = $this->getDefaultLocale(); + } + Mage::dispatchEvent('core_locale_set_locale', array('locale'=>$this)); + return $this; + } + + /** + * Retrieve timezone code + * + * @return string + */ + public function getTimezone() + { + return self::DEFAULT_TIMEZONE; + } + + /** + * Retrieve currency code + * + * @return string + */ + public function getCurrency() + { + return self::DEFAULT_CURRENCY; + } + + /** + * Retrieve locale object + * + * @return Zend_Locale + */ + public function getLocale() + { + if (!$this->_locale) { + Zend_Locale_Data::setCache(Mage::app()->getCache()->getLowLevelFrontend()); + $this->_locale = new Zend_Locale($this->getLocaleCode()); + } elseif ($this->_locale->__toString() != $this->_localeCode) { + $this->setLocale($this->_localeCode); + } + + return $this->_locale; + } + + /** + * Retrieve locale code + * + * @return string + */ + public function getLocaleCode() + { + if ($this->_localeCode === null) { + $this->setLocale(); + } + return $this->_localeCode; + } + + /** + * Specify current locale code + * + * @param string $code + * @return Mage_Core_Model_Locale + */ + public function setLocaleCode($code) + { + $this->_localeCode = $code; + $this->_locale = null; + return $this; + } + + /** + * Get options array for locale dropdown in currunt locale + * + * @return array + */ + public function getOptionLocales() + { + return $this->_getOptionLocales(); + } + + /** + * Get translated to original locale options array for locale dropdown + * + * @return array + */ + public function getTranslatedOptionLocales() + { + return $this->_getOptionLocales(true); + } + + /** + * Get options array for locale dropdown + * + * @param bool $translatedName translation flag + * @return array + */ + protected function _getOptionLocales($translatedName=false) + { + $options = array(); + $locales = $this->getLocale()->getLocaleList(); + $languages = $this->getLocale()->getTranslationList('language', $this->getLocale()); + $countries = $this->getCountryTranslationList(); + + $allowed = $this->getAllowLocales(); + foreach ($locales as $code=>$active) { + if (strstr($code, '_')) { + if (!in_array($code, $allowed)) { + continue; + } + $data = explode('_', $code); + if (!isset($languages[$data[0]]) || !isset($countries[$data[1]])) { + continue; + } + if ($translatedName) { + $label = ucwords($this->getLocale()->getTranslation($data[0], 'language', $code)) + . ' (' . $this->getLocale()->getTranslation($data[1], 'country', $code) . ') / ' + . $languages[$data[0]] . ' (' . $countries[$data[1]] . ')'; + } else { + $label = $languages[$data[0]] . ' (' . $countries[$data[1]] . ')'; + } + $options[] = array( + 'value' => $code, + 'label' => $label + ); + } + } + return $this->_sortOptionArray($options); + } + + /** + * Retrieve timezone option list + * + * @return array + */ + public function getOptionTimezones() + { + $options= array(); + $zones = $this->getTranslationList('windowstotimezone'); + ksort($zones); + foreach ($zones as $code=>$name) { + $name = trim($name); + $options[] = array( + 'label' => empty($name) ? $code : $name . ' (' . $code . ')', + 'value' => $code, + ); + } + return $this->_sortOptionArray($options); + } + + /** + * Retrieve days of week option list + * + * @return array + */ + public function getOptionWeekdays() + { + $options= array(); + $days = $this->getTranslationList('days'); + foreach (array_values($days['format']['wide']) as $code => $name) { + $options[] = array( + 'label' => $name, + 'value' => $code, + ); + } + return $options; + } + + /** + * Retrieve country option list + * + * @return array + */ + public function getOptionCountries() + { + $options = array(); + $countries = $this->getCountryTranslationList(); + + foreach ($countries as $code=>$name) { + $options[] = array( + 'label' => $name, + 'value' => $code, + ); + } + return $this->_sortOptionArray($options); + } + + /** + * Retrieve currency option list + * + * @return unknown + */ + public function getOptionCurrencies() + { + $currencies = $this->getTranslationList('currencytoname'); + $options = array(); + $allowed = $this->getAllowCurrencies(); + + foreach ($currencies as $name=>$code) { + if (!in_array($code, $allowed)) { + continue; + } + + $options[] = array( + 'label' => $name, + 'value' => $code, + ); + } + return $this->_sortOptionArray($options); + } + + /** + * Retrieve all currency option list + * + * @return unknown + */ + public function getOptionAllCurrencies() + { + $currencies = $this->getTranslationList('currencytoname'); + $options = array(); + foreach ($currencies as $name=>$code) { + $options[] = array( + 'label' => $name, + 'value' => $code, + ); + } + return $this->_sortOptionArray($options); + } + + protected function _sortOptionArray($option) + { + $data = array(); + foreach ($option as $item) { + $data[$item['value']] = $item['label']; + } + asort($data); + $option = array(); + foreach ($data as $key => $label) { + $option[] = array( + 'value' => $key, + 'label' => $label + ); + } + return $option; + } + + /** + * Retrieve array of allowed locales + * + * @return array + */ + public function getAllowLocales() + { + return Mage::getSingleton('Mage_Core_Model_Locale_Config')->getAllowedLocales(); + } + + /** + * Retrieve array of allowed currencies + * + * @return unknown + */ + public function getAllowCurrencies() + { + $data = array(); + if (Mage::isInstalled()) { + $data = Mage::app()->getStore()->getConfig(self::XML_PATH_ALLOW_CURRENCIES_INSTALLED); + return explode(',', $data); + } else { + $data = Mage::getSingleton('Mage_Core_Model_Locale_Config')->getAllowedCurrencies(); + } + return $data; + } + + /** + * Retrieve ISO date format + * + * @param string $type + * @return string + */ + public function getDateFormat($type=null) + { + return $this->getTranslation($type, 'date'); + } + + /** + * Retrieve short date format with 4-digit year + * + * @return string + */ + public function getDateFormatWithLongYear() + { + return preg_replace('/(?getTranslation(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, 'date')); + } + + + /** + * Retrieve ISO time format + * + * @param string $type + * @return string + */ + public function getTimeFormat($type=null) + { + return $this->getTranslation($type, 'time'); + } + + /** + * Retrieve ISO datetime format + * + * @param string $type + * @return string + */ + public function getDateTimeFormat($type) + { + return $this->getDateFormat($type) . ' ' . $this->getTimeFormat($type); + } + + /** + * Create Zend_Date object for current locale + * + * @param mixed $date + * @param string $part + * @param string|Zend_Locale $locale + * @param bool $useTimezone + * @return Zend_Date + */ + public function date($date = null, $part = null, $locale = null, $useTimezone = true) + { + if (is_null($locale)) { + $locale = $this->getLocale(); + } + + if (empty($date)) { + // $date may be false, but Zend_Date uses strict compare + $date = null; + } + $date = new Zend_Date($date, $part, $locale); + if ($useTimezone) { + if ($timezone = Mage::app()->getStore()->getConfig(self::XML_PATH_DEFAULT_TIMEZONE)) { + $date->setTimezone($timezone); + } + } + + return $date; + } + + /** + * Create Zend_Date object with date converted to store timezone and store Locale + * + * @param mixed $store Information about store + * @param string|integer|Zend_Date|array|null $date date in UTC + * @param boolean $includeTime flag for including time to date + * @return Zend_Date + */ + public function storeDate($store=null, $date=null, $includeTime=false) + { + $timezone = Mage::app()->getStore($store)->getConfig(self::XML_PATH_DEFAULT_TIMEZONE); + $date = new Zend_Date($date, null, $this->getLocale()); + $date->setTimezone($timezone); + if (!$includeTime) { + $date->setHour(0) + ->setMinute(0) + ->setSecond(0); + } + return $date; + } + + /** + * Create Zend_Date object with date converted from store's timezone + * to UTC time zone. Date can be passed in format of store's locale + * or in format which was passed as parameter. + * + * @param mixed $store Information about store + * @param string|integer|Zend_Date|array|null $date date in store's timezone + * @param boolean $includeTime flag for including time to date + * @param null|string $format + * @return Zend_Date + */ + public function utcDate($store, $date, $includeTime = false, $format = null) + { + $dateObj = $this->storeDate($store, $date, $includeTime); + $dateObj->set($date, $format); + $dateObj->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE); + return $dateObj; + } + + /** + * Get store timestamp + * Timstamp will be builded with store timezone settings + * + * @param mixed $store + * @return int + */ + public function storeTimeStamp($store=null) + { + $timezone = Mage::app()->getStore($store)->getConfig(self::XML_PATH_DEFAULT_TIMEZONE); + $currentTimezone = @date_default_timezone_get(); + @date_default_timezone_set($timezone); + $date = date('Y-m-d H:i:s'); + @date_default_timezone_set($currentTimezone); + return strtotime($date); + } + + /** + * Create Zend_Currency object for current locale + * + * @param string $currency + * @return Zend_Currency + */ + public function currency($currency) + { + Magento_Profiler::start('locale/currency'); + if (!isset(self::$_currencyCache[$this->getLocaleCode()][$currency])) { + $options = array(); + try { + $currencyObject = new Zend_Currency($currency, $this->getLocale()); + } catch (Exception $e) { + $currencyObject = new Zend_Currency($this->getCurrency(), $this->getLocale()); + $options['name'] = $currency; + $options['currency'] = $currency; + $options['symbol'] = $currency; + } + + $options = new Varien_Object($options); + Mage::dispatchEvent('currency_display_options_forming', array( + 'currency_options' => $options, + 'base_code' => $currency + )); + + $currencyObject->setFormat($options->toArray()); + self::$_currencyCache[$this->getLocaleCode()][$currency] = $currencyObject; + } + Magento_Profiler::stop('locale/currency'); + return self::$_currencyCache[$this->getLocaleCode()][$currency]; + } + + /** + * Returns the first found number from an string + * Parsing depends on given locale (grouping and decimal) + * + * Examples for input: + * ' 2345.4356,1234' = 23455456.1234 + * '+23,3452.123' = 233452.123 + * ' 12343 ' = 12343 + * '-9456km' = -9456 + * '0' = 0 + * '2 054,10' = 2054.1 + * '2'054.52' = 2054.52 + * '2,46 GB' = 2.46 + * + * @param string|float|int $value + * @return float|null + */ + public function getNumber($value) + { + if (is_null($value)) { + return null; + } + + if (!is_string($value)) { + return floatval($value); + } + + //trim spaces and apostrophes + $value = str_replace(array('\'', ' '), '', $value); + + $separatorComa = strpos($value, ','); + $separatorDot = strpos($value, '.'); + + if ($separatorComa !== false && $separatorDot !== false) { + if ($separatorComa > $separatorDot) { + $value = str_replace('.', '', $value); + $value = str_replace(',', '.', $value); + } + else { + $value = str_replace(',', '', $value); + } + } + elseif ($separatorComa !== false) { + $value = str_replace(',', '.', $value); + } + + return floatval($value); + } + + /** + * Functions returns array with price formatting info for js function + * formatCurrency in js/varien/js.js + * + * @return array + */ + public function getJsPriceFormat() + { + $format = Zend_Locale_Data::getContent($this->getLocaleCode(), 'currencynumber'); + $symbols = Zend_Locale_Data::getList($this->getLocaleCode(), 'symbols'); + + $pos = strpos($format, ';'); + if ($pos !== false){ + $format = substr($format, 0, $pos); + } + $format = preg_replace("/[^0\#\.,]/", "", $format); + $totalPrecision = 0; + $decimalPoint = strpos($format, '.'); + if ($decimalPoint !== false) { + $totalPrecision = (strlen($format) - (strrpos($format, '.')+1)); + } else { + $decimalPoint = strlen($format); + } + $requiredPrecision = $totalPrecision; + $t = substr($format, $decimalPoint); + $pos = strpos($t, '#'); + if ($pos !== false){ + $requiredPrecision = strlen($t) - $pos - $totalPrecision; + } + $group = 0; + if (strrpos($format, ',') !== false) { + $group = ($decimalPoint - strrpos($format, ',') - 1); + } else { + $group = strrpos($format, '.'); + } + $integerRequired = (strpos($format, '.') - strpos($format, '0')); + + $result = array( + 'pattern' => Mage::app()->getStore()->getCurrentCurrency()->getOutputFormat(), + 'precision' => $totalPrecision, + 'requiredPrecision' => $requiredPrecision, + 'decimalSymbol' => $symbols['decimal'], + 'groupSymbol' => $symbols['group'], + 'groupLength' => $group, + 'integerRequired' => $integerRequired + ); + + return $result; + } + + /** + * Push current locale to stack and replace with locale from specified store + * Event is not dispatched. + * + * @param int $storeId + */ + public function emulate($storeId) + { + if ($storeId) { + $this->_emulatedLocales[] = clone $this->getLocale(); + $this->_locale = new Zend_Locale(Mage::getStoreConfig(self::XML_PATH_DEFAULT_LOCALE, $storeId)); + $this->_localeCode = $this->_locale->toString(); + Mage::getSingleton('Mage_Core_Model_Translate')->setLocale($this->_localeCode)->init('frontend', true); + } + else { + $this->_emulatedLocales[] = false; + } + } + + /** + * Get last locale, used before last emulation + * + */ + public function revert() + { + $locale = array_pop($this->_emulatedLocales); + if ($locale) { + $this->_locale = $locale; + $this->_localeCode = $this->_locale->toString(); + Mage::getSingleton('Mage_Core_Model_Translate')->setLocale($this->_localeCode)->init('adminhtml', true); + } + } + + /** + * Returns localized informations as array, supported are several + * types of informations. + * For detailed information about the types look into the documentation + * + * @param string $path (Optional) Type of information to return + * @param string $value (Optional) Value for detail list + * @return array Array with the wished information in the given language + */ + public function getTranslationList($path = null, $value = null) + { + return $this->getLocale()->getTranslationList($path, $this->getLocale(), $value); + } + + /** + * Returns a localized information string, supported are several types of informations. + * For detailed information about the types look into the documentation + * + * @param string $value Name to get detailed information about + * @param string $path (Optional) Type of information to return + * @return string|false The wished information in the given language + */ + public function getTranslation($value = null, $path = null) + { + return $this->getLocale()->getTranslation($value, $path, $this->getLocale()); + } + +/** + * Returns the localized country name + * + * @param string $value Name to get detailed information about + * @return array + */ + public function getCountryTranslation($value) + { + return $this->getLocale()->getTranslation($value, 'country', $this->getLocale()); + } + + /** + * Returns an array with the name of all countries translated to the given language + * + * @return array + */ + public function getCountryTranslationList() + { + return $this->getLocale()->getTranslationList('territory', $this->getLocale(), 2); + } + + /** + * Checks if current date of the given store (in the store timezone) is within the range + * + * @param int|string|Mage_Core_Model_Store $store + * @param string|null $dateFrom + * @param string|null $dateTo + * @return bool + */ + public function isStoreDateInInterval($store, $dateFrom = null, $dateTo = null) + { + if (!$store instanceof Mage_Core_Model_Store) { + $store = Mage::app()->getStore($store); + } + + $storeTimeStamp = $this->storeTimeStamp($store); + $fromTimeStamp = strtotime($dateFrom); + $toTimeStamp = strtotime($dateTo); + if ($dateTo) { + // fix date YYYY-MM-DD 00:00:00 to YYYY-MM-DD 23:59:59 + $toTimeStamp += 86400; + } + + $result = false; + if (!is_empty_date($dateFrom) && $storeTimeStamp < $fromTimeStamp) { + } + elseif (!is_empty_date($dateTo) && $storeTimeStamp > $toTimeStamp) { + } + else { + $result = true; + } + + return $result; + } +} diff --git a/app/code/core/Mage/Core/Model/Locale/Config.php b/app/code/Mage/Core/Model/Locale/Config.php similarity index 100% rename from app/code/core/Mage/Core/Model/Locale/Config.php rename to app/code/Mage/Core/Model/Locale/Config.php diff --git a/app/code/core/Mage/Core/Model/Locale/Hierarchy/Loader.php b/app/code/Mage/Core/Model/Locale/Hierarchy/Loader.php similarity index 100% rename from app/code/core/Mage/Core/Model/Locale/Hierarchy/Loader.php rename to app/code/Mage/Core/Model/Locale/Hierarchy/Loader.php diff --git a/app/code/core/Mage/Core/Model/Log/Adapter.php b/app/code/Mage/Core/Model/Log/Adapter.php similarity index 100% rename from app/code/core/Mage/Core/Model/Log/Adapter.php rename to app/code/Mage/Core/Model/Log/Adapter.php diff --git a/app/code/core/Mage/Core/Model/Logger.php b/app/code/Mage/Core/Model/Logger.php similarity index 100% rename from app/code/core/Mage/Core/Model/Logger.php rename to app/code/Mage/Core/Model/Logger.php diff --git a/app/code/core/Mage/Core/Model/Magento/Api.php b/app/code/Mage/Core/Model/Magento/Api.php similarity index 100% rename from app/code/core/Mage/Core/Model/Magento/Api.php rename to app/code/Mage/Core/Model/Magento/Api.php diff --git a/app/code/core/Mage/Core/Model/Magento/Api/V2.php b/app/code/Mage/Core/Model/Magento/Api/V2.php similarity index 100% rename from app/code/core/Mage/Core/Model/Magento/Api/V2.php rename to app/code/Mage/Core/Model/Magento/Api/V2.php diff --git a/app/code/core/Mage/Core/Model/Message.php b/app/code/Mage/Core/Model/Message.php similarity index 100% rename from app/code/core/Mage/Core/Model/Message.php rename to app/code/Mage/Core/Model/Message.php diff --git a/app/code/core/Mage/Core/Model/Message/Abstract.php b/app/code/Mage/Core/Model/Message/Abstract.php similarity index 100% rename from app/code/core/Mage/Core/Model/Message/Abstract.php rename to app/code/Mage/Core/Model/Message/Abstract.php diff --git a/app/code/core/Mage/Core/Model/Message/Collection.php b/app/code/Mage/Core/Model/Message/Collection.php similarity index 100% rename from app/code/core/Mage/Core/Model/Message/Collection.php rename to app/code/Mage/Core/Model/Message/Collection.php diff --git a/app/code/core/Mage/Core/Model/Message/Error.php b/app/code/Mage/Core/Model/Message/Error.php similarity index 100% rename from app/code/core/Mage/Core/Model/Message/Error.php rename to app/code/Mage/Core/Model/Message/Error.php diff --git a/app/code/core/Mage/Core/Model/Message/Notice.php b/app/code/Mage/Core/Model/Message/Notice.php similarity index 100% rename from app/code/core/Mage/Core/Model/Message/Notice.php rename to app/code/Mage/Core/Model/Message/Notice.php diff --git a/app/code/core/Mage/Core/Model/Message/Success.php b/app/code/Mage/Core/Model/Message/Success.php similarity index 100% rename from app/code/core/Mage/Core/Model/Message/Success.php rename to app/code/Mage/Core/Model/Message/Success.php diff --git a/app/code/core/Mage/Core/Model/Message/Warning.php b/app/code/Mage/Core/Model/Message/Warning.php similarity index 100% rename from app/code/core/Mage/Core/Model/Message/Warning.php rename to app/code/Mage/Core/Model/Message/Warning.php diff --git a/app/code/Mage/Core/Model/ObjectManager.php b/app/code/Mage/Core/Model/ObjectManager.php new file mode 100644 index 0000000000000..ac79062b2b7c4 --- /dev/null +++ b/app/code/Mage/Core/Model/ObjectManager.php @@ -0,0 +1,40 @@ + $config, + 'Mage_Core_Model_Dir' => $config->getDirectories() + )); + $config->configure($this); + } +} diff --git a/app/code/core/Mage/Core/Model/ObjectManager/ConfigAbstract.php b/app/code/Mage/Core/Model/ObjectManager/ConfigAbstract.php similarity index 100% rename from app/code/core/Mage/Core/Model/ObjectManager/ConfigAbstract.php rename to app/code/Mage/Core/Model/ObjectManager/ConfigAbstract.php diff --git a/app/code/Mage/Core/Model/ObjectManager/DefinitionFactory.php b/app/code/Mage/Core/Model/ObjectManager/DefinitionFactory.php new file mode 100644 index 0000000000000..d88d56c84a0af --- /dev/null +++ b/app/code/Mage/Core/Model/ObjectManager/DefinitionFactory.php @@ -0,0 +1,83 @@ +getParam('definitions', false); + if (!$definitions) { // check whether definitions were provided as application init param + $path = $config->getDefinitionPath(); + if (is_readable($path)) { + $definitions = file_get_contents($path); + } + } + if ($definitions) { + $format = $config->getDefinitionFormat(); + if (is_string($definitions)) { + $extractor = $format == 'igbinary' ? 'igbinary_unserialize' : 'unserialize'; + $definitions = $extractor($definitions); + } + $definitionModel = $this->_getDefinitionModel($format); + $output = new $definitionModel($definitions); + } else { + $genDir = $config->getDirectories()->getDir(Mage_Core_Model_Dir::VAR_DIR) . '/generation'; + $autoloader = new Magento_Autoload_IncludePath(); + $generatorIo = new Magento_Code_Generator_Io(new Varien_Io_File(), $autoloader, $genDir); + $generator = new Magento_Code_Generator_Class( + new Magento_Code_Generator(null, $autoloader, $generatorIo) + ); + $definition = new Magento_ObjectManager_Definition_Runtime(); + $output = new Magento_Code_Generator_DefinitionDecorator($definition, $generator); + } + Magento_Profiler::stop('di_definitions_create'); + return $output; + } +} diff --git a/app/code/Mage/Core/Model/Observer.php b/app/code/Mage/Core/Model/Observer.php new file mode 100644 index 0000000000000..01a24646ced6d --- /dev/null +++ b/app/code/Mage/Core/Model/Observer.php @@ -0,0 +1,174 @@ + + */ +class Mage_Core_Model_Observer +{ + /** + * @var Mage_Core_Model_Cache_Frontend_Pool + */ + private $_cacheFrontendPool; + + /** + * @var Mage_Core_Model_Theme + */ + private $_currentTheme; + + /** + * @var Mage_Core_Model_Page_Asset_Collection + */ + private $_pageAssets; + + /** + * @param Mage_Core_Model_Cache_Frontend_Pool $cacheFrontendPool + * @param Mage_Core_Model_Design_Package $designPackage + * @param Mage_Core_Model_Page $page + */ + public function __construct( + Mage_Core_Model_Cache_Frontend_Pool $cacheFrontendPool, + Mage_Core_Model_Design_Package $designPackage, + Mage_Core_Model_Page $page + ) { + $this->_cacheFrontendPool = $cacheFrontendPool; + $this->_currentTheme = $designPackage->getDesignTheme(); + $this->_pageAssets = $page->getAssets(); + } + + /** + * Check if synchronize process is finished and generate notification message + * + * @param Varien_Event_Observer $observer + * @return Mage_Core_Model_Observer + */ + public function addSynchronizeNotification(Varien_Event_Observer $observer) + { + $adminSession = Mage::getSingleton('Mage_Backend_Model_Auth_Session'); + if (!$adminSession->hasSyncProcessStopWatch()) { + $flag = Mage::getSingleton('Mage_Core_Model_File_Storage')->getSyncFlag(); + $state = $flag->getState(); + if ($state == Mage_Core_Model_File_Storage_Flag::STATE_RUNNING) { + $syncProcessStopWatch = true; + } else { + $syncProcessStopWatch = false; + } + + $adminSession->setSyncProcessStopWatch($syncProcessStopWatch); + } + $adminSession->setSyncProcessStopWatch(false); + + if (!$adminSession->getSyncProcessStopWatch()) { + if (!isset($flag)) { + $flag = Mage::getSingleton('Mage_Core_Model_File_Storage')->getSyncFlag(); + } + + $state = $flag->getState(); + if ($state == Mage_Core_Model_File_Storage_Flag::STATE_FINISHED) { + $flagData = $flag->getFlagData(); + if (isset($flagData['has_errors']) && $flagData['has_errors']) { + $severity = Mage_AdminNotification_Model_Inbox::SEVERITY_MAJOR; + $title = Mage::helper('Mage_Adminhtml_Helper_Data')->__('An error has occured while syncronizing media storages.'); + $description = Mage::helper('Mage_Adminhtml_Helper_Data')->__('One or more media files failed to be synchronized during the media storages syncronization process. Refer to the log file for details.'); + } else { + $severity = Mage_AdminNotification_Model_Inbox::SEVERITY_NOTICE; + $title = Mage::helper('Mage_Adminhtml_Helper_Data')->__('Media storages synchronization has completed!'); + $description = Mage::helper('Mage_Adminhtml_Helper_Data')->__('Synchronization of media storages has been successfully completed.'); + } + + $date = date('Y-m-d H:i:s'); + Mage::getModel('Mage_AdminNotification_Model_Inbox')->parse(array( + array( + 'severity' => $severity, + 'date_added' => $date, + 'title' => $title, + 'description' => $description, + 'url' => '', + 'internal' => true + ) + )); + + $flag->setState(Mage_Core_Model_File_Storage_Flag::STATE_NOTIFIED)->save(); + } + + $adminSession->setSyncProcessStopWatch(false); + } + + return $this; + } + + /** + * Cron job method to clean old cache resources + * + * @param Mage_Cron_Model_Schedule $schedule + */ + public function cleanCache(Mage_Cron_Model_Schedule $schedule) + { + /** @var $cacheFrontend Magento_Cache_FrontendInterface */ + foreach ($this->_cacheFrontendPool as $cacheFrontend) { + // Magento cache frontend does not support the 'old' cleaning mode, that's why backend is used directly + $cacheFrontend->getBackend()->clean(Zend_Cache::CLEANING_MODE_OLD); + } + } + + /** + * Theme registration + * + * @param Varien_Event_Observer $observer + * @return Mage_Core_Model_Observer + */ + public function themeRegistration(Varien_Event_Observer $observer) + { + $baseDir = $observer->getEvent()->getBaseDir(); + $pathPattern = $observer->getEvent()->getPathPattern(); + try { + Mage::getObjectManager()->get('Mage_Core_Model_Theme_Registration')->register($baseDir, $pathPattern); + } catch (Mage_Core_Exception $e) { + Mage::logException($e); + } + return $this; + } + + /** + * @param Varien_Event_Observer $observer + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function applyThemeCustomization(Varien_Event_Observer $observer) + { + /** @var $themeFile Mage_Core_Model_Theme_File */ + foreach ($this->_currentTheme->getFiles() as $themeFile) { + $asset = $themeFile->getAsset(); + if ($asset) { + $this->_pageAssets->add($themeFile->getFilePath(), $asset); + } + } + } +} diff --git a/app/code/core/Mage/Core/Model/ObserverFactory.php b/app/code/Mage/Core/Model/ObserverFactory.php similarity index 91% rename from app/code/core/Mage/Core/Model/ObserverFactory.php rename to app/code/Mage/Core/Model/ObserverFactory.php index 8f0834935be42..b05452eb76059 100644 --- a/app/code/core/Mage/Core/Model/ObserverFactory.php +++ b/app/code/Mage/Core/Model/ObserverFactory.php @@ -43,12 +43,11 @@ public function __construct(Magento_ObjectManager $objectManager) * Get observer model instance * * @param string $className - * @param array $arguments * @return Mage_Core_Model_Abstract|bool */ - public function get($className, array $arguments = array()) + public function get($className) { - return $this->_objectManager->get($className, $arguments); + return $this->_objectManager->get($className); } /** diff --git a/app/code/core/Mage/Core/Model/Option/ArrayInterface.php b/app/code/Mage/Core/Model/Option/ArrayInterface.php similarity index 100% rename from app/code/core/Mage/Core/Model/Option/ArrayInterface.php rename to app/code/Mage/Core/Model/Option/ArrayInterface.php diff --git a/app/code/Mage/Core/Model/Page.php b/app/code/Mage/Core/Model/Page.php new file mode 100644 index 0000000000000..2ea9a20b97ccc --- /dev/null +++ b/app/code/Mage/Core/Model/Page.php @@ -0,0 +1,54 @@ +_assets = $assets; + } + + /** + * Retrieve collection of assets linked to a page + * + * @return Mage_Core_Model_Page_Asset_Collection + */ + public function getAssets() + { + return $this->_assets; + } +} diff --git a/app/code/Mage/Core/Model/Page/Asset/AssetInterface.php b/app/code/Mage/Core/Model/Page/Asset/AssetInterface.php new file mode 100644 index 0000000000000..18f927edc2aa6 --- /dev/null +++ b/app/code/Mage/Core/Model/Page/Asset/AssetInterface.php @@ -0,0 +1,45 @@ +_assets[$identifier] = $asset; + } + + /** + * Whether an item belongs to a collection or not + * + * @param string $identifier + * @return bool + */ + public function has($identifier) + { + return isset($this->_assets[$identifier]); + } + + /** + * Remove an item from the list + * + * @param string $identifier + */ + public function remove($identifier) + { + unset($this->_assets[$identifier]); + } + + /** + * Retrieve all items in the collection + * + * @return Mage_Core_Model_Page_Asset_AssetInterface[] + */ + public function getAll() + { + return $this->_assets; + } +} diff --git a/app/code/Mage/Core/Model/Page/Asset/MergeService.php b/app/code/Mage/Core/Model/Page/Asset/MergeService.php new file mode 100644 index 0000000000000..a96674a2c4c1d --- /dev/null +++ b/app/code/Mage/Core/Model/Page/Asset/MergeService.php @@ -0,0 +1,95 @@ +_objectManager = $objectManager; + $this->_storeConfig = $storeConfig; + $this->_designPackage = $designPackage; + } + + /** + * Return merged assets, if merging is enabled for a given content type + * + * @param array $assets + * @param string $contentType + * @return array + * @throws InvalidArgumentException + */ + public function getMergedAssets(array $assets, $contentType) + { + $isCss = $contentType == Mage_Core_Model_Design_Package::CONTENT_TYPE_CSS; + $isJs = $contentType == Mage_Core_Model_Design_Package::CONTENT_TYPE_JS; + if (!$isCss && !$isJs) { + throw new InvalidArgumentException("Merge for content type '$contentType' is not supported."); + } + + if ($this->_designPackage->isMergingViewFilesAllowed()) { + $isCssMergeEnabled = $this->_storeConfig->getConfigFlag(self::XML_PATH_MERGE_CSS_FILES); + $isJsMergeEnabled = $this->_storeConfig->getConfigFlag(self::XML_PATH_MERGE_JS_FILES); + if (($isCss && $isCssMergeEnabled) || ($isJs && $isJsMergeEnabled)) { + $assets = array( + $this->_objectManager->create('Mage_Core_Model_Page_Asset_Merged', array('assets' => $assets)) + ); + } + } + + return $assets; + } +} diff --git a/app/code/Mage/Core/Model/Page/Asset/MergeableInterface.php b/app/code/Mage/Core/Model/Page/Asset/MergeableInterface.php new file mode 100644 index 0000000000000..a743b28d28368 --- /dev/null +++ b/app/code/Mage/Core/Model/Page/Asset/MergeableInterface.php @@ -0,0 +1,38 @@ +_designPackage = $designPackage; + $this->_coreHelper = $coreHelper; + $this->_filesystem = $filesystem; + if (!$assets) { + throw new InvalidArgumentException('At least one asset has to be passed for merging.'); + } + /** @var $asset Mage_Core_Model_Page_Asset_MergeableInterface */ + foreach ($assets as $asset) { + if (!($asset instanceof Mage_Core_Model_Page_Asset_MergeableInterface)) { + throw new InvalidArgumentException( + 'Asset has to implement Mage_Core_Model_Page_Asset_MergeableInterface.' + ); + } + if (!$this->_contentType) { + $this->_contentType = $asset->getContentType(); + } else if ($asset->getContentType() != $this->_contentType) { + throw new InvalidArgumentException( + "Content type '{$asset->getContentType()}' cannot be merged with '{$this->_contentType}'." + ); + } + $this->_files[] = $asset->getSourceFile(); + } + } + + /** + * {@inheritdoc} + */ + public function getUrl() + { + if (!$this->_url) { + $file = $this->_designPackage->mergeFiles($this->_files, $this->_contentType); + $this->_url = $this->_designPackage->getPublicFileUrl($file); + if ($this->_coreHelper->isStaticFilesSigned()) { + $fileMTime = $this->_filesystem->getMTime($file()); + $this->_url .= '?' . $fileMTime; + } + } + return $this->_url; + } + + /** + * {@inheritdoc} + */ + public function getContentType() + { + return $this->_contentType; + } +} diff --git a/app/code/Mage/Core/Model/Page/Asset/PublicFile.php b/app/code/Mage/Core/Model/Page/Asset/PublicFile.php new file mode 100644 index 0000000000000..6cd6b4778d10f --- /dev/null +++ b/app/code/Mage/Core/Model/Page/Asset/PublicFile.php @@ -0,0 +1,74 @@ +_designPackage = $designPackage; + $this->_file = $file; + $this->_contentType = $contentType; + } + + /** + * {@inheritdoc} + */ + public function getUrl() + { + return $this->_designPackage->getPublicFileUrl($this->_file); + } + + /** + * {@inheritdoc} + */ + public function getContentType() + { + return $this->_contentType; + } +} diff --git a/app/code/Mage/Core/Model/Page/Asset/Remote.php b/app/code/Mage/Core/Model/Page/Asset/Remote.php new file mode 100644 index 0000000000000..58dc4b2186d52 --- /dev/null +++ b/app/code/Mage/Core/Model/Page/Asset/Remote.php @@ -0,0 +1,67 @@ +_url = $url; + $this->_contentType = $contentType; + } + + /** + * {@inheritdoc} + */ + public function getUrl() + { + return $this->_url; + } + + /** + * {@inheritdoc} + */ + public function getContentType() + { + return $this->_contentType; + } +} diff --git a/app/code/Mage/Core/Model/Page/Asset/ViewFile.php b/app/code/Mage/Core/Model/Page/Asset/ViewFile.php new file mode 100644 index 0000000000000..af20cf9504cd6 --- /dev/null +++ b/app/code/Mage/Core/Model/Page/Asset/ViewFile.php @@ -0,0 +1,86 @@ +_designPackage = $designPackage; + $this->_file = $file; + $this->_contentType = $contentType; + } + + /** + * {@inheritdoc} + */ + public function getUrl() + { + return $this->_designPackage->getViewFileUrl($this->_file); + } + + /** + * {@inheritdoc} + */ + public function getContentType() + { + return $this->_contentType; + } + + /** + * {@inheritdoc} + */ + public function getSourceFile() + { + return $this->_file; + } +} diff --git a/app/code/core/Mage/Core/Model/Registry.php b/app/code/Mage/Core/Model/Registry.php similarity index 100% rename from app/code/core/Mage/Core/Model/Registry.php rename to app/code/Mage/Core/Model/Registry.php diff --git a/app/code/Mage/Core/Model/Resource.php b/app/code/Mage/Core/Model/Resource.php new file mode 100644 index 0000000000000..52cb81255aea9 --- /dev/null +++ b/app/code/Mage/Core/Model/Resource.php @@ -0,0 +1,388 @@ +_resourceConfig = $resourceConfig; + $this->_cache = $cache; + } + + /** + * Set resource configuration + * + * @param Mage_Core_Model_Config_Resource $resourceConfig + */ + public function setResourceConfig(Mage_Core_Model_Config_Resource $resourceConfig) + { + $this->_resourceConfig = $resourceConfig; + } + + /** + * Set cache instance + * + * @param Mage_Core_Model_CacheInterface $cache + */ + public function setCache(Mage_Core_Model_CacheInterface $cache) + { + $this->_cache = $cache; + } + + /** + * Creates a connection to resource whenever needed + * + * @param string $name + * @return Varien_Db_Adapter_Interface + */ + public function getConnection($name) + { + if (isset($this->_connections[$name])) { + $connection = $this->_connections[$name]; + if (isset($this->_skippedConnections[$name])) { + $connection->setCacheAdapter(Mage::app()->getCache()); + unset($this->_skippedConnections[$name]); + } + return $connection; + } + $connConfig = $this->_resourceConfig->getResourceConnectionConfig($name); + + if (!$connConfig) { + $this->_connections[$name] = $this->_getDefaultConnection($name); + return $this->_connections[$name]; + } + if (!$connConfig->is('active', 1)) { + return false; + } + + $origName = $connConfig->getParent()->getName(); + if (isset($this->_connections[$origName])) { + $this->_connections[$name] = $this->_connections[$origName]; + return $this->_connections[$origName]; + } + + $connection = $this->_newConnection((string)$connConfig->type, $connConfig); + if ($connection) { + $connection->setCacheAdapter($this->_cache->getFrontend()); + } + + $this->_connections[$name] = $connection; + if ($origName !== $name) { + $this->_connections[$origName] = $connection; + } + + return $connection; + } + + /** + * Retrieve connection adapter class name by connection type + * + * @param string $type the connection type + * @return string|false + */ + protected function _getConnectionAdapterClassName($type) + { + $config = $this->_resourceConfig->getResourceTypeConfig($type); + if (!empty($config->adapter)) { + return (string)$config->adapter; + } + return false; + } + + /** + * Create new connection adapter instance by connection type and config + * + * @param string $type the connection type + * @param Mage_Core_Model_Config_Element|array $config the connection configuration + * @return Varien_Db_Adapter_Interface|false + */ + protected function _newConnection($type, $config) + { + if ($config instanceof Mage_Core_Model_Config_Element) { + $config = $config->asArray(); + } + if (!is_array($config)) { + return false; + } + + $connection = false; + // try to get adapter and create connection + $className = $this->_getConnectionAdapterClassName($type); + if ($className) { + $connection = new $className($config); + if ($connection instanceof Varien_Db_Adapter_Interface) { + /** @var Zend_Db_Adapter_Abstract $connection */ + + // Set additional params for Magento profiling tool + $profiler = $connection->getProfiler(); + if ($profiler instanceof Varien_Db_Profiler) { + /** @var Varien_Db_Profiler $profiler */ + $profiler->setType($type); + + $host = !empty($config['host']) ? $config['host'] : ''; + $profiler->setHost($host); + } + + // run after initialization statements + if (!empty($config['initStatements'])) { + $connection->query($config['initStatements']); + } + } else { + $connection = false; + } + } + + // try to get connection from type + if (!$connection) { + $typeInstance = $this->getConnectionTypeInstance($type); + /** @var Mage_Core_Model_Resource_Type_Abstract $typeInstance */ + $connection = $typeInstance->getConnection($config); + if (!$connection instanceof Varien_Db_Adapter_Interface) { + $connection = false; + } + } + + return $connection; + } + + /** + * Retrieve default connection name by required connection name + * + * @param string $requiredConnectionName + * @return string + */ + protected function _getDefaultConnection($requiredConnectionName) + { + if (strpos($requiredConnectionName, 'read') !== false) { + return $this->getConnection(self::DEFAULT_READ_RESOURCE); + } + return $this->getConnection(self::DEFAULT_WRITE_RESOURCE); + } + + /** + * Get connection type instance + * + * Creates new if doesn't exist + * + * @param string $type + * @return Mage_Core_Model_Resource_Type_Abstract + */ + public function getConnectionTypeInstance($type) + { + if (!isset($this->_connectionTypes[$type])) { + $config = $this->_resourceConfig->getResourceTypeConfig($type); + $typeClass = $config->getClassName(); + $this->_connectionTypes[$type] = new $typeClass(); + } + return $this->_connectionTypes[$type]; + } + + /** + * Get resource table name, validated by db adapter + * + * @param string|array $modelEntity + * @return string + */ + public function getTableName($modelEntity) + { + $tableSuffix = null; + if (is_array($modelEntity)) { + list($modelEntity, $tableSuffix) = $modelEntity; + } + + $tableName = $modelEntity; + + $mappedTableName = $this->getMappedTableName($tableName); + if ($mappedTableName) { + $tableName = $mappedTableName; + } else { + $tablePrefix = (string)$this->_resourceConfig->getTablePrefix(); + if ($tablePrefix && strpos($tableName, $tablePrefix) !== 0) { + $tableName = $tablePrefix . $tableName; + } + } + + if ($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])) { + return $this->_mappedTableNames[$tableName]; + } else { + return false; + } + } + + /** + * Create new connection with custom config + * + * @param string $name + * @param string $type + * @param array $config + * @return unknown + */ + public function createConnection($name, $type, $config) + { + if (!isset($this->_connections[$name])) { + $connection = $this->_newConnection($type, $config); + + $this->_connections[$name] = $connection; + } + return $this->_connections[$name]; + } + + public function checkDbConnection() + { + if (!$this->getConnection('core_read')) { + //Mage::app()->getResponse()->setRedirect(Mage::getUrl('install')); + } + } + + public function getAutoUpdate() + { + return self::AUTO_UPDATE_ALWAYS; + #return Mage::app()->loadCache(self::AUTO_UPDATE_CACHE_KEY); + } + + public function setAutoUpdate($value) + { + #Mage::app()->saveCache($value, self::AUTO_UPDATE_CACHE_KEY); + return $this; + } + /** + * Retrieve 32bit UNIQUE HASH for a Table index + * + * @param string $tableName + * @param array|string $fields + * @param string $indexType + * @return string + */ + public function getIdxName($tableName, $fields, $indexType = Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX) + { + return $this->getConnection(self::DEFAULT_READ_RESOURCE) + ->getIndexName($this->getTableName($tableName), $fields, $indexType); + } + + /** + * Retrieve 32bit UNIQUE HASH for a Table foreign key + * + * @param string $priTableName the target table name + * @param string $priColumnName the target table column name + * @param string $refTableName the reference table name + * @param string $refColumnName the reference table column name + * @return string + */ + public function getFkName($priTableName, $priColumnName, $refTableName, $refColumnName) + { + return $this->getConnection(self::DEFAULT_READ_RESOURCE) + ->getForeignKeyName($this->getTableName($priTableName), $priColumnName, + $this->getTableName($refTableName), $refColumnName); + } +} diff --git a/app/code/Mage/Core/Model/Resource/Abstract.php b/app/code/Mage/Core/Model/Resource/Abstract.php new file mode 100644 index 0000000000000..13e6a61aed6c1 --- /dev/null +++ b/app/code/Mage/Core/Model/Resource/Abstract.php @@ -0,0 +1,255 @@ + + */ +abstract class Mage_Core_Model_Resource_Abstract +{ + /** + * @var Varien_Db_Adapter_Interface + */ + protected $_writeAdapter; + + /** + * Main constructor + */ + public function __construct() + { + /** + * Please override this one instead of overriding real __construct constructor + */ + $this->_construct(); + } + + /** + * Array of callbacks subscribed to commit transaction commit + * + * @var array + */ + static protected $_commitCallbacks = array(); + + /** + * Resource initialization + */ + abstract protected function _construct(); + + /** + * Retrieve connection for read data + */ + abstract protected function _getReadAdapter(); + + /** + * Retrieve connection for write data + */ + abstract protected function _getWriteAdapter(); + + /** + * Start resource transaction + * + * @return Mage_Core_Model_Resource_Abstract + */ + public function beginTransaction() + { + $this->_getWriteAdapter()->beginTransaction(); + return $this; + } + + /** + * Subscribe some callback to transaction commit + * + * @param callback $callback + * @return Mage_Core_Model_Resource_Abstract + */ + public function addCommitCallback($callback) + { + $adapterKey = spl_object_hash($this->_getWriteAdapter()); + self::$_commitCallbacks[$adapterKey][] = $callback; + return $this; + } + + /** + * Commit resource transaction + * + * @return Mage_Core_Model_Resource_Abstract + */ + public function commit() + { + $this->_getWriteAdapter()->commit(); + /** + * Process after commit callbacks + */ + if ($this->_getWriteAdapter()->getTransactionLevel() === 0) { + $adapterKey = spl_object_hash($this->_getWriteAdapter()); + if (isset(self::$_commitCallbacks[$adapterKey])) { + $callbacks = self::$_commitCallbacks[$adapterKey]; + self::$_commitCallbacks[$adapterKey] = array(); + foreach ($callbacks as $callback) { + call_user_func($callback); + } + } + } + return $this; + } + + /** + * Roll back resource transaction + * + * @return Mage_Core_Model_Resource_Abstract + */ + public function rollBack() + { + $this->_getWriteAdapter()->rollBack(); + return $this; + } + + /** + * Format date to internal format + * + * @param string|Zend_Date $date + * @param bool $includeTime + * @return string + */ + public function formatDate($date, $includeTime=true) + { + return Varien_Date::formatDate($date, $includeTime); + } + + /** + * Convert internal date to UNIX timestamp + * + * @param string $str + * @return int + */ + public function mktime($str) + { + return Varien_Date::toTimestamp($str); + } + + /** + * Serialize specified field in an object + * + * @param Varien_Object $object + * @param string $field + * @param mixed $defaultValue + * @param bool $unsetEmpty + * @return Mage_Core_Model_Resource_Abstract + */ + protected function _serializeField(Varien_Object $object, $field, $defaultValue = null, $unsetEmpty = false) + { + $value = $object->getData($field); + if (empty($value)) { + if ($unsetEmpty) { + $object->unsetData($field); + } else { + if (is_object($defaultValue) || is_array($defaultValue)) { + $defaultValue = serialize($defaultValue); + } + $object->setData($field, $defaultValue); + } + } elseif (is_array($value) || is_object($value)) { + $object->setData($field, serialize($value)); + } + + return $this; + } + + /** + * Unserialize Varien_Object field in an object + * + * @param Mage_Core_Model_Abstract $object + * @param string $field + * @param mixed $defaultValue + */ + protected function _unserializeField(Varien_Object $object, $field, $defaultValue = null) + { + $value = $object->getData($field); + if (empty($value)) { + $object->setData($field, $defaultValue); + } elseif (!is_array($value) && !is_object($value)) { + $object->setData($field, unserialize($value)); + } + } + + /** + * Prepare data for passed table + * + * @param Varien_Object $object + * @param string $table + * @return array + */ + protected function _prepareDataForTable(Varien_Object $object, $table) + { + $data = array(); + $fields = $this->_getWriteAdapter()->describeTable($table); + foreach (array_keys($fields) as $field) { + if ($object->hasData($field)) { + $fieldValue = $object->getData($field); + if ($fieldValue instanceof Zend_Db_Expr) { + $data[$field] = $fieldValue; + } else { + if (null !== $fieldValue) { + $fieldValue = $this->_prepareTableValueForSave($fieldValue, $fields[$field]['DATA_TYPE']); + $data[$field] = $this->_getWriteAdapter()->prepareColumnValue($fields[$field], $fieldValue); + } else if (!empty($fields[$field]['NULLABLE'])) { + $data[$field] = null; + } + } + } + } + return $data; + } + + /** + * Prepare value for save + * + * @param mixed $value + * @param string $type + * @return mixed + */ + protected function _prepareTableValueForSave($value, $type) + { + $type = strtolower($type); + if ($type == 'decimal' || $type == 'numeric' || $type == 'float') { + $value = Mage::app()->getLocale()->getNumber($value); + } + return $value; + } + + /** + * Template method to return validate rules to be executed before entity is saved + * + * @return Zend_Validate_Interface|null + */ + public function getValidationRulesBeforeSave() + { + return null; + } +} diff --git a/app/code/core/Mage/Core/Model/Resource/Cache.php b/app/code/Mage/Core/Model/Resource/Cache.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Cache.php rename to app/code/Mage/Core/Model/Resource/Cache.php diff --git a/app/code/core/Mage/Core/Model/Resource/Config.php b/app/code/Mage/Core/Model/Resource/Config.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Config.php rename to app/code/Mage/Core/Model/Resource/Config.php diff --git a/app/code/core/Mage/Core/Model/Resource/Config/Data.php b/app/code/Mage/Core/Model/Resource/Config/Data.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Config/Data.php rename to app/code/Mage/Core/Model/Resource/Config/Data.php diff --git a/app/code/core/Mage/Core/Model/Resource/Config/Data/Collection.php b/app/code/Mage/Core/Model/Resource/Config/Data/Collection.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Config/Data/Collection.php rename to app/code/Mage/Core/Model/Resource/Config/Data/Collection.php diff --git a/app/code/Mage/Core/Model/Resource/Db/Abstract.php b/app/code/Mage/Core/Model/Resource/Db/Abstract.php new file mode 100644 index 0000000000000..02bc2b726d439 --- /dev/null +++ b/app/code/Mage/Core/Model/Resource/Db/Abstract.php @@ -0,0 +1,728 @@ + + */ +abstract class Mage_Core_Model_Resource_Db_Abstract extends Mage_Core_Model_Resource_Abstract +{ + /** + * Cached resources singleton + * + * @var Mage_Core_Model_Resource + */ + protected $_resources; + + /** + * Prefix for resources that will be used in this resource model + * + * @var string + */ + protected $_resourcePrefix = 'core'; + + /** + * Connections cache for this resource model + * + * @var array + */ + protected $_connections = array(); + + /** + * Resource model name that contains entities (names of tables) + * + * @var string + */ + protected $_resourceModel; + + /** + * Tables used in this resource model + * + * @var array + */ + protected $_tables = array(); + + /** + * Main table name + * + * @var string + */ + protected $_mainTable; + + /** + * Main table primary key field name + * + * @var string + */ + protected $_idFieldName; + + /** + * Primery key auto increment flag + * + * @var bool + */ + protected $_isPkAutoIncrement = true; + + /** + * Use is object new method for save of object + * + * @var boolean + */ + protected $_useIsObjectNew = false; + + /** + * Fields of main table + * + * @var array + */ + protected $_mainTableFields; + + /** + * Main table unique keys field names + * could array( + * array('field' => 'db_field_name1', 'title' => 'Field 1 should be unique') + * array('field' => 'db_field_name2', 'title' => 'Field 2 should be unique') + * array( + * 'field' => array('db_field_name3', 'db_field_name3'), + * 'title' => 'Field 3 and Field 4 combination should be unique' + * ) + * ) + * or string 'my_field_name' - will be autoconverted to + * array( array( 'field' => 'my_field_name', 'title' => 'my_field_name' ) ) + * + * @var array + */ + protected $_uniqueFields = null; + + /** + * Serializable fields declaration + * Structure: array( + * => array( + * , + * , + * // optional parameter + * ), + * ) + * + * @var array + */ + protected $_serializableFields = array(); + + /** + * Class constructor + * + * @param Mage_Core_Model_Resource $resource + */ + public function __construct(Mage_Core_Model_Resource $resource) + { + $this->_resources = $resource; + parent::__construct(); + } + + /** + * Provide variables to serialize + * + * @return array + */ + public function __sleep() + { + $properties = array_keys(get_object_vars($this)); + if (Mage::getIsSerializable()) { + $properties = array_diff($properties, array('_resources', '_connections')); + } + return $properties; + } + + /** + * Restore global dependencies + */ + public function __wakeup() + { + if (Mage::getIsSerializable()) { + $this->_resources = Mage::getSingleton('Mage_Core_Model_Resource'); + } + } + + /** + * Standard resource model initialization + * + * @param string $mainTable + * @param string $idFieldName + * @return Mage_Core_Model_Resource_Abstract + */ + protected function _init($mainTable, $idFieldName) + { + $this->_setMainTable($mainTable, $idFieldName); + } + + /** + * Initialize connections and tables for this resource model + * If one or both arguments are string, will be used as prefix + * If $tables is null and $connections is string, $tables will be the same + * + * @param string|array $connections + * @param string|array|null $tables + * @return Mage_Core_Model_Resource_Abstract + */ + protected function _setResource($connections, $tables = null) + { + if (is_array($connections)) { + foreach ($connections as $key => $value) { + $this->_connections[$key] = $this->_resources->getConnection($value); + } + } else if (is_string($connections)) { + $this->_resourcePrefix = $connections; + } + + if (is_null($tables) && is_string($connections)) { + $this->_resourceModel = $this->_resourcePrefix; + } else if (is_array($tables)) { + foreach ($tables as $key => $value) { + $this->_tables[$key] = $this->_resources->getTableName($value); + } + } else if (is_string($tables)) { + $this->_resourceModel = $tables; + } + return $this; + } + + /** + * Set main entity table name and primary key field name + * If field name is omitted {table_name}_id will be used + * + * @param string $mainTable + * @param string|null $idFieldName + * @return Mage_Core_Model_Resource_Db_Abstract + */ + protected function _setMainTable($mainTable, $idFieldName = null) + { + $this->_mainTable = $mainTable; + if (null === $idFieldName) { + $idFieldName = $mainTable . '_id'; + } + + $this->_idFieldName = $idFieldName; + return $this; + } + + /** + * Get primary key field name + * + * @return string + */ + public function getIdFieldName() + { + if (empty($this->_idFieldName)) { + Mage::throwException(Mage::helper('Mage_Core_Helper_Data')->__('Empty identifier field name')); + } + return $this->_idFieldName; + } + + /** + * Returns main table name - extracted from "module/table" style and + * validated by db adapter + * + * @return string + */ + public function getMainTable() + { + if (empty($this->_mainTable)) { + Mage::throwException(Mage::helper('Mage_Core_Helper_Data')->__('Empty main table name')); + } + return $this->getTable($this->_mainTable); + } + + /** + * Get real table name for db table, validated by db adapter + * + * @param string $tableName + * @return string + */ + public function getTable($tableName) + { + if (is_array($tableName)) { + $cacheName = join('@', $tableName); + list($tableName, $entitySuffix) = $tableName; + } else { + $cacheName = $tableName; + $entitySuffix = null; + } + + if (!is_null($entitySuffix)) { + $tableName .= '_' . $entitySuffix; + } + + if (!isset($this->_tables[$cacheName])) { + $this->_tables[$cacheName] = $this->_resources->getTableName($tableName); + } + return $this->_tables[$cacheName]; + } + + /** + * Get connection by name or type + * + * @param string $connectionName + * @return Varien_Db_Adapter_Interface|bool + */ + protected function _getConnection($connectionName) + { + if (isset($this->_connections[$connectionName])) { + return $this->_connections[$connectionName]; + } + $connectionNameFull = ($this->_resourcePrefix ? $this->_resourcePrefix . '_' : '') . $connectionName; + $connectionInstance = $this->_resources->getConnection($connectionNameFull); + // cache only active connections to detect inactive ones as soon as they become active + if ($connectionInstance) { + $this->_connections[$connectionName] = $connectionInstance; + } + return $connectionInstance; + } + + /** + * Retrieve connection for read data + * + * @return Varien_Db_Adapter_Interface + */ + protected function _getReadAdapter() + { + $writeAdapter = $this->_getWriteAdapter(); + if ($writeAdapter && $writeAdapter->getTransactionLevel() > 0) { + // if transaction is started we should use write connection for reading + return $writeAdapter; + } + return $this->_getConnection('read'); + } + + /** + * Retrieve connection for write data + * + * @return Varien_Db_Adapter_Interface + */ + protected function _getWriteAdapter() + { + return $this->_getConnection('write'); + } + + /** + * Temporary resolving collection compatibility + * + * @return Varien_Db_Adapter_Interface + */ + public function getReadConnection() + { + return $this->_getReadAdapter(); + } + + /** + * Load an object + * + * @param Mage_Core_Model_Abstract $object + * @param mixed $value + * @param string $field field to load by (defaults to model id) + * @return Mage_Core_Model_Resource_Db_Abstract + */ + public function load(Mage_Core_Model_Abstract $object, $value, $field = null) + { + if (is_null($field)) { + $field = $this->getIdFieldName(); + } + + $read = $this->_getReadAdapter(); + if ($read && !is_null($value)) { + $select = $this->_getLoadSelect($field, $value, $object); + $data = $read->fetchRow($select); + + if ($data) { + $object->setData($data); + } + } + + $this->unserializeFields($object); + $this->_afterLoad($object); + + return $this; + } + + /** + * Retrieve select object for load object data + * + * @param string $field + * @param mixed $value + * @param Mage_Core_Model_Abstract $object + * @return Zend_Db_Select + */ + protected function _getLoadSelect($field, $value, $object) + { + $field = $this->_getReadAdapter()->quoteIdentifier(sprintf('%s.%s', $this->getMainTable(), $field)); + $select = $this->_getReadAdapter()->select() + ->from($this->getMainTable()) + ->where($field . '=?', $value); + return $select; + } + + /** + * Save object object data + * + * @param Mage_Core_Model_Abstract $object + * @return Mage_Core_Model_Resource_Db_Abstract + */ + public function save(Mage_Core_Model_Abstract $object) + { + if ($object->isDeleted()) { + return $this->delete($object); + } + + $this->_serializeFields($object); + $this->_beforeSave($object); + $this->_checkUnique($object); + if (!is_null($object->getId()) && (!$this->_useIsObjectNew || !$object->isObjectNew())) { + $condition = $this->_getWriteAdapter()->quoteInto($this->getIdFieldName().'=?', $object->getId()); + /** + * Not auto increment primary key support + */ + if ($this->_isPkAutoIncrement) { + $data = $this->_prepareDataForSave($object); + unset($data[$this->getIdFieldName()]); + $this->_getWriteAdapter()->update($this->getMainTable(), $data, $condition); + } else { + $select = $this->_getWriteAdapter()->select() + ->from($this->getMainTable(), array($this->getIdFieldName())) + ->where($condition); + if ($this->_getWriteAdapter()->fetchOne($select) !== false) { + $data = $this->_prepareDataForSave($object); + unset($data[$this->getIdFieldName()]); + if (!empty($data)) { + $this->_getWriteAdapter()->update($this->getMainTable(), $data, $condition); + } + } else { + $this->_getWriteAdapter()->insert($this->getMainTable(), $this->_prepareDataForSave($object)); + } + } + } else { + $bind = $this->_prepareDataForSave($object); + if ($this->_isPkAutoIncrement) { + unset($bind[$this->getIdFieldName()]); + } + $this->_getWriteAdapter()->insert($this->getMainTable(), $bind); + + $object->setId($this->_getWriteAdapter()->lastInsertId($this->getMainTable())); + + if ($this->_useIsObjectNew) { + $object->isObjectNew(false); + } + } + + $this->unserializeFields($object); + $this->_afterSave($object); + + return $this; + } + + /** + * Delete the object + * + * @param Mage_Core_Model_Abstract $object + * @return Mage_Core_Model_Resource_Db_Abstract + */ + public function delete(Mage_Core_Model_Abstract $object) + { + $this->_beforeDelete($object); + $this->_getWriteAdapter()->delete( + $this->getMainTable(), + $this->_getWriteAdapter()->quoteInto($this->getIdFieldName() . '=?', $object->getId()) + ); + $this->_afterDelete($object); + return $this; + } + + /** + * Add unique field restriction + * + * @param array|string $field + * @return Mage_Core_Model_Resource_Db_Abstract + */ + public function addUniqueField($field) + { + if (is_null($this->_uniqueFields)) { + $this->_initUniqueFields(); + } + if (is_array($this->_uniqueFields) ) { + $this->_uniqueFields[] = $field; + } + return $this; + } + + /** + * Reset unique fields restrictions + * + * @return Mage_Core_Model_Resource_Db_Abstract + */ + public function resetUniqueField() + { + $this->_uniqueFields = array(); + return $this; + } + + /** + * Unserialize serializeable object fields + * + * @param Mage_Core_Model_Abstract $object + */ + public function unserializeFields(Mage_Core_Model_Abstract $object) + { + foreach ($this->_serializableFields as $field => $parameters) { + list($serializeDefault, $unserializeDefault) = $parameters; + $this->_unserializeField($object, $field, $unserializeDefault); + } + } + + /** + * Initialize unique fields + * + * @return Mage_Core_Model_Resource_Db_Abstract + */ + protected function _initUniqueFields() + { + $this->_uniqueFields = array(); + return $this; + } + + /** + * Get configuration of all unique fields + * + * @return array + */ + public function getUniqueFields() + { + if (is_null($this->_uniqueFields)) { + $this->_initUniqueFields(); + } + return $this->_uniqueFields; + } + + /** + * Prepare data for save + * + * @param Mage_Core_Model_Abstract $object + * @return array + */ + protected function _prepareDataForSave(Mage_Core_Model_Abstract $object) + { + return $this->_prepareDataForTable($object, $this->getMainTable()); + } + + /** + * Check that model data fields that can be saved + * has really changed comparing with origData + * + * @param Mage_Core_Model_Abstract $object + * @return boolean + */ + public function hasDataChanged($object) + { + if (!$object->getOrigData()) { + return true; + } + + $fields = $this->_getWriteAdapter()->describeTable($this->getMainTable()); + foreach (array_keys($fields) as $field) { + if ($object->getOrigData($field) != $object->getData($field)) { + return true; + } + } + + return false; + } + + /** + * Prepare value for save + * + * @param mixed $value + * @param string $type + * @return mixed + */ + protected function _prepareValueForSave($value, $type) + { + return $this->_prepareTableValueForSave($value, $type); + } + + /** + * Check for unique values existence + * + * @param Mage_Core_Model_Abstract $object + * @return Mage_Core_Model_Resource_Db_Abstract + * @throws Mage_Core_Exception + */ + protected function _checkUnique(Mage_Core_Model_Abstract $object) + { + $existent = array(); + $fields = $this->getUniqueFields(); + if (!empty($fields)) { + if (!is_array($fields)) { + $this->_uniqueFields = array( + array( + 'field' => $fields, + 'title' => $fields + )); + } + + $data = new Varien_Object($this->_prepareDataForSave($object)); + $select = $this->_getWriteAdapter()->select() + ->from($this->getMainTable()); + + foreach ($fields as $unique) { + $select->reset(Zend_Db_Select::WHERE); + + if (is_array($unique['field'])) { + foreach ($unique['field'] as $field) { + $select->where($field . '=?', trim($data->getData($field))); + } + } else { + $select->where($unique['field'] . '=?', trim($data->getData($unique['field']))); + } + + if ($object->getId() || $object->getId() === '0') { + $select->where($this->getIdFieldName() . '!=?', $object->getId()); + } + + $test = $this->_getWriteAdapter()->fetchRow($select); + if ($test) { + $existent[] = $unique['title']; + } + } + } + + if (!empty($existent)) { + if (count($existent) == 1 ) { + $error = Mage::helper('Mage_Core_Helper_Data')->__('%s already exists.', $existent[0]); + } else { + $error = Mage::helper('Mage_Core_Helper_Data')->__('%s already exist.', implode(', ', $existent)); + } + Mage::throwException($error); + } + return $this; + } + + /** + * After load + * + * @param Mage_Core_Model_Abstract $object + */ + public function afterLoad(Mage_Core_Model_Abstract $object) + { + $this->_afterLoad($object); + } + + /** + * Perform actions after object load + * + * @param Varien_Object $object + * @return Mage_Core_Model_Resource_Db_Abstract + */ + protected function _afterLoad(Mage_Core_Model_Abstract $object) + { + return $this; + } + + /** + * Perform actions before object save + * + * @param Varien_Object $object + * @return Mage_Core_Model_Resource_Db_Abstract + */ + protected function _beforeSave(Mage_Core_Model_Abstract $object) + { + return $this; + } + + /** + * Perform actions after object save + * + * @param Varien_Object $object + * @return Mage_Core_Model_Resource_Db_Abstract + */ + protected function _afterSave(Mage_Core_Model_Abstract $object) + { + return $this; + } + + /** + * Perform actions before object delete + * + * @param Varien_Object $object + * @return Mage_Core_Model_Resource_Db_Abstract + */ + protected function _beforeDelete(Mage_Core_Model_Abstract $object) + { + return $this; + } + + /** + * Perform actions after object delete + * + * @param Varien_Object $object + * @return Mage_Core_Model_Resource_Db_Abstract + */ + protected function _afterDelete(Mage_Core_Model_Abstract $object) + { + return $this; + } + + /** + * Serialize serializeable fields of the object + * + * @param Mage_Core_Model_Abstract $object + */ + protected function _serializeFields(Mage_Core_Model_Abstract $object) + { + foreach ($this->_serializableFields as $field => $parameters) { + list($serializeDefault, $unserializeDefault) = $parameters; + $this->_serializeField($object, $field, $serializeDefault, isset($parameters[2])); + } + } + + /** + * Retrieve table checksum + * + * @param string|array $table + * @return int|array + */ + public function getChecksum($table) + { + if (!$this->_getReadAdapter()) { + return false; + } + $checksum = $this->_getReadAdapter()->getTablesChecksum($table); + if (count($checksum) == 1) { + return $checksum[$table]; + } + return $checksum; + } +} diff --git a/app/code/Mage/Core/Model/Resource/Db/Collection/Abstract.php b/app/code/Mage/Core/Model/Resource/Db/Collection/Abstract.php new file mode 100644 index 0000000000000..886aa5c8564b1 --- /dev/null +++ b/app/code/Mage/Core/Model/Resource/Db/Collection/Abstract.php @@ -0,0 +1,708 @@ + + */ +abstract class Mage_Core_Model_Resource_Db_Collection_Abstract extends Varien_Data_Collection_Db +{ + /** + * Model name + * + * @var string + */ + protected $_model; + + /** + * Resource model name + * + * @var string + */ + protected $_resourceModel; + + /** + * Resource instance + * + * @var Mage_Core_Model_Resource_Db_Abstract + */ + protected $_resource; + + /** + * Fields to select in query + * + * @var array|null + */ + protected $_fieldsToSelect = null; + + /** + * Fields initial fields to select like id_field + * + * @var array|null + */ + protected $_initialFieldsToSelect = null; + + /** + * Fields to select changed flag + * + * @var boolean + */ + protected $_fieldsToSelectChanged = false; + + /** + * Store joined tables here + * + * @var array + */ + protected $_joinedTables = array(); + + /** + * Collection main table + * + * @var string + */ + protected $_mainTable = null; + + /** + * Reset items data changed flag + * + * @var boolean + */ + protected $_resetItemsDataChanged = false; + + /** + * Name prefix of events that are dispatched by model + * + * @var string + */ + protected $_eventPrefix = ''; + + /** + * Name of event parameter + * + * @var string + */ + protected $_eventObject = ''; + + /** + * Use analytic function flag + * If true - allows to prepare final select with analytic function + * + * @var bool + */ + protected $_useAnalyticFunction = false; + + /** + * Collection constructor + * + * @param Mage_Core_Model_Resource_Db_Abstract $resource + */ + public function __construct($resource = null) + { + parent::__construct(); + $this->_construct(); + $this->_resource = $resource; + $this->setConnection($this->getResource()->getReadConnection()); + $this->_initSelect(); + } + + /** + * Initialization here + * + */ + protected function _construct() + { + + } + + /** + * Retrieve main table + * + * @return string + */ + public function getMainTable() + { + if ($this->_mainTable === null) { + $this->setMainTable($this->getResource()->getMainTable()); + } + + return $this->_mainTable; + } + + /** + * Set main collection table + * + * @param string $table + * @return Mage_Core_Model_Resource_Db_Collection_Abstract + */ + public function setMainTable($table) + { + $table = $this->getTable($table); + if ($this->_mainTable !== null && $table !== $this->_mainTable && $this->getSelect() !== null) { + $from = $this->getSelect()->getPart(Zend_Db_Select::FROM); + if (isset($from['main_table'])) { + $from['main_table']['tableName'] = $table; + } + $this->getSelect()->setPart(Zend_Db_Select::FROM, $from); + } + + $this->_mainTable = $table; + return $this; + } + + /** + * Init collection select + * + * @return Mage_Core_Model_Resource_Db_Collection_Abstract + */ + protected function _initSelect() + { + $this->getSelect()->from(array('main_table' => $this->getMainTable())); + return $this; + } + + /** + * Get Zend_Db_Select instance and applies fields to select if needed + * + * @return Varien_Db_Select + */ + public function getSelect() + { + if ($this->_select && $this->_fieldsToSelectChanged) { + $this->_fieldsToSelectChanged = false; + $this->_initSelectFields(); + } + return parent::getSelect(); + } + + /** + * Init fields for select + * + * @return Mage_Core_Model_Resource_Db_Collection_Abstract + */ + protected function _initSelectFields() + { + $columns = $this->_select->getPart(Zend_Db_Select::COLUMNS); + $columnsToSelect = array(); + foreach ($columns as $columnEntry) { + list($correlationName, $column, $alias) = $columnEntry; + if ($correlationName !== 'main_table') { // Add joined fields to select + if ($column instanceof Zend_Db_Expr) { + $column = $column->__toString(); + } + $key = ($alias !== null ? $alias : $column); + $columnsToSelect[$key] = $columnEntry; + } + } + + $columns = $columnsToSelect; + + $columnsToSelect = array_keys($columnsToSelect); + + if ($this->_fieldsToSelect !== null) { + $insertIndex = 0; + foreach ($this->_fieldsToSelect as $alias => $field) { + if (!is_string($alias)) { + $alias = null; + } + + if ($field instanceof Zend_Db_Expr) { + $column = $field->__toString(); + } else { + $column = $field; + } + + if (($alias !== null && in_array($alias, $columnsToSelect)) || + // If field already joined from another table + ($alias === null && isset($alias, $columnsToSelect))) { + continue; + } + + $columnEntry = array('main_table', $field, $alias); + array_splice($columns, $insertIndex, 0, array($columnEntry)); // Insert column + $insertIndex ++; + + } + } else { + array_unshift($columns, array('main_table', '*', null)); + } + + $this->_select->setPart(Zend_Db_Select::COLUMNS, $columns); + + return $this; + } + + /** + * Retrieve initial fields to select like id field + * + * @return array + */ + protected function _getInitialFieldsToSelect() + { + if ($this->_initialFieldsToSelect === null) { + $this->_initialFieldsToSelect = array(); + $this->_initInitialFieldsToSelect(); + } + + return $this->_initialFieldsToSelect; + } + + /** + * Initialize initial fields to select like id field + * + * @return Mage_Core_Model_Resource_Db_Collection_Abstract + */ + protected function _initInitialFieldsToSelect() + { + $idFieldName = $this->getResource()->getIdFieldName(); + if ($idFieldName) { + $this->_initialFieldsToSelect[] = $idFieldName; + } + return $this; + } + + /** + * Add field to select + * + * @param string|array $field + * @param string|null $alias + * @return Mage_Core_Model_Resource_Db_Collection_Abstract + */ + public function addFieldToSelect($field, $alias = null) + { + if ($field === '*') { // If we will select all fields + $this->_fieldsToSelect = null; + $this->_fieldsToSelectChanged = true; + return $this; + } + + if (is_array($field)) { + if ($this->_fieldsToSelect === null) { + $this->_fieldsToSelect = $this->_getInitialFieldsToSelect(); + } + + foreach ($field as $key => $value) { + $this->addFieldToSelect( + $value, + (is_string($key) ? $key : null), + false + ); + } + + $this->_fieldsToSelectChanged = true; + return $this; + } + + if ($alias === null) { + $this->_fieldsToSelect[] = $field; + } else { + $this->_fieldsToSelect[$alias] = $field; + } + + $this->_fieldsToSelectChanged = true; + return $this; + } + + /** + * Add attribute expression (SUM, COUNT, etc) + * Example: ('sub_total', 'SUM({{attribute}})', 'revenue') + * Example: ('sub_total', 'SUM({{revenue}})', 'revenue') + * For some functions like SUM use groupByAttribute. + * + * @param string $alias + * @param string $expression + * @param array|string $fields + * @return Mage_Core_Model_Resource_Db_Collection_Abstract + */ + public function addExpressionFieldToSelect($alias, $expression, $fields) + { + // validate alias + if (!is_array($fields)) { + $fields = array($fields => $fields); + } + + $fullExpression = $expression; + foreach ($fields as $fieldKey=>$fieldItem) { + $fullExpression = str_replace('{{' . $fieldKey . '}}', $fieldItem, $fullExpression); + } + + $this->getSelect()->columns(array($alias=>$fullExpression)); + + return $this; + } + + /** + * Removes field from select + * + * @param string|null $field + * @param boolean $isAlias Alias identifier + * @return Mage_Core_Model_Resource_Db_Collection_Abstract + */ + public function removeFieldFromSelect($field, $isAlias = false) + { + if ($isAlias) { + if (isset($this->_fieldsToSelect[$field])) { + unset($this->_fieldsToSelect[$field]); + } + } else { + foreach ($this->_fieldsToSelect as $key => $value) { + if ($value === $field) { + unset($this->_fieldsToSelect[$key]); + break; + } + } + } + + $this->_fieldsToSelectChanged = true; + return $this; + } + + /** + * Removes all fields from select + * + * @return Mage_Core_Model_Resource_Db_Collection_Abstract + */ + public function removeAllFieldsFromSelect() + { + $this->_fieldsToSelect = $this->_getInitialFieldsToSelect(); + $this->_fieldsToSelectChanged = true; + return $this; + } + + /** + * Standard resource collection initialization + * + * @param string $model + * @param string $resourceModel + * @return Mage_Core_Model_Resource_Db_Collection_Abstract + */ + protected function _init($model, $resourceModel) + { + $this->setModel($model); + $this->setResourceModel($resourceModel); + return $this; + } + + /** + * Set model name for collection items + * + * @param string $model + * @return Mage_Core_Model_Resource_Db_Collection_Abstract + */ + public function setModel($model) + { + if (is_string($model)) { + $this->_model = $model; + $this->setItemObjectClass($model); + } + return $this; + } + + /** + * Get model instance + * + * @param array $args + * @return Varien_Object + */ + public function getModelName($args = array()) + { + return $this->_model; + } + + /** + * Set resource model name for collection items + * + * @param string $model + */ + public function setResourceModel($model) + { + $this->_resourceModel = $model; + } + + /** + * Retrieve resource model name + * + * @return string + */ + public function getResourceModelName() + { + return $this->_resourceModel; + } + + /** + * Get resource instance + * + * @return Mage_Core_Model_Resource_Db_Abstract + */ + public function getResource() + { + if (empty($this->_resource)) { + $this->_resource = Mage::getResourceModel($this->getResourceModelName()); + } + return $this->_resource; + } + + /** + * Retrieve table name + * + * @param string $table + * @return string + */ + public function getTable($table) + { + return $this->getResource()->getTable($table); + } + + /** + * Retrieve all ids for collection + * + * @return array + */ + public function getAllIds() + { + $idsSelect = clone $this->getSelect(); + $idsSelect->reset(Zend_Db_Select::ORDER); + $idsSelect->reset(Zend_Db_Select::LIMIT_COUNT); + $idsSelect->reset(Zend_Db_Select::LIMIT_OFFSET); + $idsSelect->reset(Zend_Db_Select::COLUMNS); + + $idsSelect->columns($this->getResource()->getIdFieldName(), 'main_table'); + return $this->getConnection()->fetchCol($idsSelect, $this->_bindParams); + } + + public function getData() + { + if ($this->_data === null) { + $this->_renderFilters() + ->_renderOrders() + ->_renderLimit(); + /** + * Prepare select for execute + * @var string $query + */ + $query = $this->_prepareSelect($this->getSelect()); + $this->_data = $this->_fetchAll($query, $this->_bindParams); + $this->_afterLoadData(); + } + return $this->_data; + } + + /** + * Prepare select for load + * + * @return string + */ + protected function _prepareSelect(Varien_Db_Select $select) + { + $helper = Mage::getResourceHelper('Mage_Core'); + + $unionParts = $select->getPart(Zend_Db_Select::UNION); + if (!empty($unionParts)) { + $select = $helper->limitUnion($select); + } + + if ($this->_useAnalyticFunction) { + return $helper->getQueryUsingAnalyticFunction($select); + } + + return (string)$select; + } + /** + * Join table to collection select + * + * @param string $table + * @param string $cond + * @param string $cols + * @return Mage_Core_Model_Resource_Db_Collection_Abstract + */ + public function join($table, $cond, $cols = '*') + { + if (is_array($table)) { + foreach ($table as $k => $v) { + $alias = $k; + $table = $v; + break; + } + } else { + $alias = $table; + } + + if (!isset($this->_joinedTables[$table])) { + $this->getSelect()->join( + array($alias => $this->getTable($table)), + $cond, + $cols + ); + $this->_joinedTables[$alias] = true; + } + return $this; + } + + /** + * Redeclare before load method for adding event + * + * @return Mage_Core_Model_Resource_Db_Collection_Abstract + */ + protected function _beforeLoad() + { + parent::_beforeLoad(); + Mage::dispatchEvent('core_collection_abstract_load_before', array('collection' => $this)); + if ($this->_eventPrefix && $this->_eventObject) { + Mage::dispatchEvent($this->_eventPrefix.'_load_before', array( + $this->_eventObject => $this + )); + } + return $this; + } + + /** + * Set reset items data changed flag + * + * @param boolean $flag + * @return Mage_Core_Model_Resource_Db_Collection_Abstract + */ + public function setResetItemsDataChanged($flag) + { + $this->_resetItemsDataChanged = (bool)$flag; + return $this; + } + + /** + * Set flag data has changed to all collection items + * + * @return Mage_Core_Model_Resource_Db_Collection_Abstract + */ + public function resetItemsDataChanged() + { + foreach ($this->_items as $item) { + $item->setDataChanges(false); + } + + return $this; + } + + /** + * Redeclare after load method for specifying collection items original data + * + * @return Mage_Core_Model_Resource_Db_Collection_Abstract + */ + protected function _afterLoad() + { + parent::_afterLoad(); + foreach ($this->_items as $item) { + $item->setOrigData(); + if ($this->_resetItemsDataChanged) { + $item->setDataChanges(false); + } + } + Mage::dispatchEvent('core_collection_abstract_load_after', array('collection' => $this)); + if ($this->_eventPrefix && $this->_eventObject) { + Mage::dispatchEvent($this->_eventPrefix.'_load_after', array( + $this->_eventObject => $this + )); + } + return $this; + } + + /** + * Save all the entities in the collection + * + * @return Mage_Core_Model_Resource_Db_Collection_Abstract + */ + public function save() + { + foreach ($this->getItems() as $item) { + $item->save(); + } + return $this; + } + + /** + * Check if cache can be used for collection + * + * @return bool + */ + protected function _canUseCache() + { + return Mage::getObjectManager()->get('Mage_Core_Model_CacheInterface')->canUse('collections') + && !empty($this->_cacheConf); + } + + /** + * Load cached data for select + * + * @param Zend_Db_Select $select + * @return string | false + */ + protected function _loadCache($select) + { + $data = Mage::getObjectManager()->get('Mage_Core_Model_CacheInterface')->load($this->_getSelectCacheId($select)); + return $data; + } + + /** + * Save collection data to cache + * + * @param array $data + * @param Zend_Db_Select $select + * @return Mage_Core_Model_Resource_Db_Collection_Abstract + */ + protected function _saveCache($data, $select) + { + Mage::getObjectManager()->get('Mage_Core_Model_CacheInterface')->save( + serialize($data), $this->_getSelectCacheId($select), $this->_getCacheTags(), false + ); + return $this; + } + + /** + * Redeclared for processing cache tags throw application object + * + * @return array + */ + protected function _getCacheTags() + { + $tags = parent::_getCacheTags(); + $tags[] = Mage_Core_Model_Cache_Type_Collection::CACHE_TAG; + return $tags; + } + + /** + * Format Date to internal database date format + * + * @param int|string|Zend_Date $date + * @param boolean $includeTime + * @return string + */ + public function formatDate($date, $includeTime = true) + { + return Varien_Date::formatDate($date, $includeTime); + } +} diff --git a/app/code/core/Mage/Core/Model/Resource/Db/Profiler.php b/app/code/Mage/Core/Model/Resource/Db/Profiler.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Db/Profiler.php rename to app/code/Mage/Core/Model/Resource/Db/Profiler.php diff --git a/app/code/core/Mage/Core/Model/Resource/Design.php b/app/code/Mage/Core/Model/Resource/Design.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Design.php rename to app/code/Mage/Core/Model/Resource/Design.php diff --git a/app/code/core/Mage/Core/Model/Resource/Design/Collection.php b/app/code/Mage/Core/Model/Resource/Design/Collection.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Design/Collection.php rename to app/code/Mage/Core/Model/Resource/Design/Collection.php diff --git a/app/code/core/Mage/Core/Model/Resource/Email/Template.php b/app/code/Mage/Core/Model/Resource/Email/Template.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Email/Template.php rename to app/code/Mage/Core/Model/Resource/Email/Template.php diff --git a/app/code/core/Mage/Core/Model/Resource/Email/Template/Collection.php b/app/code/Mage/Core/Model/Resource/Email/Template/Collection.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Email/Template/Collection.php rename to app/code/Mage/Core/Model/Resource/Email/Template/Collection.php diff --git a/app/code/core/Mage/Core/Model/Resource/Entity/Abstract.php b/app/code/Mage/Core/Model/Resource/Entity/Abstract.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Entity/Abstract.php rename to app/code/Mage/Core/Model/Resource/Entity/Abstract.php diff --git a/app/code/core/Mage/Core/Model/Resource/Entity/Table.php b/app/code/Mage/Core/Model/Resource/Entity/Table.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Entity/Table.php rename to app/code/Mage/Core/Model/Resource/Entity/Table.php diff --git a/app/code/core/Mage/Core/Model/Resource/File/Storage/Abstract.php b/app/code/Mage/Core/Model/Resource/File/Storage/Abstract.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/File/Storage/Abstract.php rename to app/code/Mage/Core/Model/Resource/File/Storage/Abstract.php diff --git a/app/code/core/Mage/Core/Model/Resource/File/Storage/Database.php b/app/code/Mage/Core/Model/Resource/File/Storage/Database.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/File/Storage/Database.php rename to app/code/Mage/Core/Model/Resource/File/Storage/Database.php diff --git a/app/code/core/Mage/Core/Model/Resource/File/Storage/Directory/Database.php b/app/code/Mage/Core/Model/Resource/File/Storage/Directory/Database.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/File/Storage/Directory/Database.php rename to app/code/Mage/Core/Model/Resource/File/Storage/Directory/Database.php diff --git a/app/code/core/Mage/Core/Model/Resource/File/Storage/File.php b/app/code/Mage/Core/Model/Resource/File/Storage/File.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/File/Storage/File.php rename to app/code/Mage/Core/Model/Resource/File/Storage/File.php diff --git a/app/code/core/Mage/Core/Model/Resource/Flag.php b/app/code/Mage/Core/Model/Resource/Flag.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Flag.php rename to app/code/Mage/Core/Model/Resource/Flag.php diff --git a/app/code/core/Mage/Core/Model/Resource/Helper/Abstract.php b/app/code/Mage/Core/Model/Resource/Helper/Abstract.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Helper/Abstract.php rename to app/code/Mage/Core/Model/Resource/Helper/Abstract.php diff --git a/app/code/core/Mage/Core/Model/Resource/Helper/Mysql4.php b/app/code/Mage/Core/Model/Resource/Helper/Mysql4.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Helper/Mysql4.php rename to app/code/Mage/Core/Model/Resource/Helper/Mysql4.php diff --git a/app/code/core/Mage/Core/Model/Resource/Iterator.php b/app/code/Mage/Core/Model/Resource/Iterator.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Iterator.php rename to app/code/Mage/Core/Model/Resource/Iterator.php diff --git a/app/code/core/Mage/Core/Model/Resource/Layout/Link.php b/app/code/Mage/Core/Model/Resource/Layout/Link.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Layout/Link.php rename to app/code/Mage/Core/Model/Resource/Layout/Link.php diff --git a/app/code/Mage/Core/Model/Resource/Layout/Link/Collection.php b/app/code/Mage/Core/Model/Resource/Layout/Link/Collection.php new file mode 100644 index 0000000000000..08954e728ad89 --- /dev/null +++ b/app/code/Mage/Core/Model/Resource/Layout/Link/Collection.php @@ -0,0 +1,94 @@ +_init('Mage_Core_Model_Layout_Link', 'Mage_Core_Model_Resource_Layout_Link'); + } + + /** + * Join with layout update table + * + * @param array $fields + * @return Mage_Core_Model_Resource_Layout_Link_Collection + */ + protected function _joinWithUpdate($fields = array()) + { + $flagName = 'joined_with_update_table'; + if (!$this->getFlag($flagName)) { + $this->getSelect() + ->join( + array('update' => $this->getTable('core_layout_update')), + 'update.layout_update_id = main_table.layout_update_id', + array($fields) + ); + $this->setFlag($flagName, true); + } + + return $this; + } + + /** + * Filter by temporary flag + * + * @param bool $isTemporary + * @return Mage_Core_Model_Resource_Layout_Link_Collection + */ + public function addTemporaryFilter($isTemporary) + { + $this->addFieldToFilter('main_table.is_temporary', $isTemporary ? 1 : 0); + return $this; + } + + /** + * Get links for layouts that are older then specified number of days + * + * @param $days + * @return Mage_Core_Model_Resource_Layout_Link_Collection + */ + public function addUpdatedDaysBeforeFilter($days) + { + $datetime = new DateTime(); + $storeInterval = new DateInterval('P' . $days . 'D'); + $datetime->sub($storeInterval); + $formattedDate = $this->formatDate($datetime->getTimestamp()); + + $this->_joinWithUpdate(); + $this->addFieldToFilter('update.updated_at', array('notnull' => true)) + ->addFieldToFilter('update.updated_at', array('lt' => $formattedDate)); + + return $this; + } +} diff --git a/app/code/Mage/Core/Model/Resource/Layout/Update.php b/app/code/Mage/Core/Model/Resource/Layout/Update.php new file mode 100644 index 0000000000000..b2b52704a2c2e --- /dev/null +++ b/app/code/Mage/Core/Model/Resource/Layout/Update.php @@ -0,0 +1,118 @@ +_init('core_layout_update', 'layout_update_id'); + } + + /** + * Retrieve layout updates by handle + * + * @param string $handle + * @param array $params + * @return string + */ + public function fetchUpdatesByHandle($handle, $params = array()) + { + $bind = array( + 'store_id' => Mage::app()->getStore()->getId(), + 'theme_id' => Mage::getDesign()->getDesignTheme()->getThemeId(), + ); + + foreach ($params as $key => $value) { + if (isset($bind[$key])) { + $bind[$key] = $value; + } + } + $bind['layout_update_handle'] = $handle; + $result = ''; + + $readAdapter = $this->_getReadAdapter(); + if ($readAdapter) { + $select = $this->_getFetchUpdatesByHandleSelect(); + $result = join('', $readAdapter->fetchCol($select, $bind)); + } + return $result; + } + + /** + * Get select to fetch updates by handle + * + * @param bool $loadAllUpdates + * @return Varien_Db_Select + */ + protected function _getFetchUpdatesByHandleSelect($loadAllUpdates = false) + { + //TODO Why it also loads layout updates for store_id=0, isn't it Admin Store View? + //If 0 means 'all stores' why it then refers by foreign key to Admin in `core_store` and not to something named + // 'All Stores'? + + $select = $this->_getReadAdapter()->select() + ->from(array('layout_update' => $this->getMainTable()), array('xml')) + ->join(array('link' => $this->getTable('core_layout_link')), + 'link.layout_update_id=layout_update.layout_update_id', '') + ->where('link.store_id IN (0, :store_id)') + ->where('link.theme_id = :theme_id') + ->where('layout_update.handle = :layout_update_handle') + ->order('layout_update.sort_order ' . Varien_Db_Select::SQL_ASC); + + if (!$loadAllUpdates) { + $select->where('link.is_temporary = 0'); + } + + return $select; + } + + /** + * Update a "layout update link" if relevant data is provided + * + * @param Mage_Core_Model_Layout_Update|Mage_Core_Model_Abstract $object + * @return Mage_Core_Model_Resource_Layout_Update + */ + protected function _afterSave(Mage_Core_Model_Abstract $object) + { + $data = $object->getData(); + if (isset($data['store_id']) && isset($data['theme_id'])) { + $this->_getWriteAdapter()->insertOnDuplicate($this->getTable('core_layout_link'), array( + 'store_id' => $data['store_id'], + 'theme_id' => $data['theme_id'], + 'layout_update_id' => $object->getId(), + 'is_temporary' => (int)$object->getIsTemporary(), + )); + } + Mage::app()->cleanCache(array('layout', Mage_Core_Model_Layout_Merge::LAYOUT_GENERAL_CACHE_TAG)); + return parent::_afterSave($object); + } +} diff --git a/app/code/core/Mage/Core/Model/Resource/Layout/Update/Collection.php b/app/code/Mage/Core/Model/Resource/Layout/Update/Collection.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Layout/Update/Collection.php rename to app/code/Mage/Core/Model/Resource/Layout/Update/Collection.php diff --git a/app/code/core/Mage/Core/Model/Resource/Resource.php b/app/code/Mage/Core/Model/Resource/Resource.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Resource.php rename to app/code/Mage/Core/Model/Resource/Resource.php diff --git a/app/code/core/Mage/Core/Model/Resource/Session.php b/app/code/Mage/Core/Model/Resource/Session.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Session.php rename to app/code/Mage/Core/Model/Resource/Session.php diff --git a/app/code/Mage/Core/Model/Resource/Setup.php b/app/code/Mage/Core/Model/Resource/Setup.php new file mode 100644 index 0000000000000..e9a8b9ff6dd79 --- /dev/null +++ b/app/code/Mage/Core/Model/Resource/Setup.php @@ -0,0 +1,842 @@ + + */ +class Mage_Core_Model_Resource_Setup implements Mage_Core_Model_Resource_SetupInterface +{ + /** + * Setup resource name + * @var string + */ + protected $_resourceName; + + /** + * Setup resource configuration object + * + * @var Varien_Simplexml_Element + */ + protected $_resourceConfig; + + /** + * Connection configuration object + * + * @var Varien_Simplexml_Element + */ + protected $_connectionConfig; + + /** + * Setup module configuration object + * + * @var Varien_Simplexml_Element + */ + protected $_moduleConfig; + + /** + * Call afterApplyAllUpdates method flag + * + * @var boolean + */ + protected $_callAfterApplyAllUpdates = false; + + /** + * Setup Connection + * + * @var Varien_Db_Adapter_Pdo_Mysql + */ + protected $_conn; + /** + * Tables cache array + * + * @var array + */ + protected $_tables = array(); + /** + * Tables data cache array + * + * @var array + */ + protected $_setupCache = array(); + + /** + * Flag which shows, that setup has hooked queries from DB adapter + * + * @var bool + */ + protected $_queriesHooked = false; + + /** + * Modules configuration + * + * @var Mage_Core_Model_Resource + */ + protected $_resourceModel; + + /** + * Modules configuration reader + * + * @var Mage_Core_Model_Config_Modules_Reader + */ + protected $_modulesReader; + + /** + * @var Mage_Core_Model_Config_Modules + */ + protected $_config; + + /** + * Initialize resource configurations, setup connection, etc + * + * @param Mage_Core_Model_Config_Resource $resourcesConfig + * @param Mage_Core_Model_Config_Modules $modulesConfig + * @param Mage_Core_Model_Resource $resource + * @param Mage_Core_Model_Config_Modules_Reader $modulesReader + * @param string $resourceName + */ + public function __construct( + Mage_Core_Model_Config_Resource $resourcesConfig, + Mage_Core_Model_Config_Modules $modulesConfig, + Mage_Core_Model_Resource $resource, + Mage_Core_Model_Config_Modules_Reader $modulesReader, + $resourceName + ) { + $resourcesConfig->setConfig($modulesConfig); + $this->_config = $modulesConfig; + $this->_resourceModel = $resource; + $this->_resourceName = $resourceName; + $this->_modulesReader = $modulesReader; + $this->_resourceConfig = $resourcesConfig->getResourceConfig($resourceName); + $connection = $resourcesConfig->getResourceConnectionConfig($resourceName); + if ($connection) { + $this->_connectionConfig = $connection; + } else { + $this->_connectionConfig = $resourcesConfig->getResourceConnectionConfig(self::DEFAULT_SETUP_CONNECTION); + } + + $modName = (string)$this->_resourceConfig->setup->module; + $this->_moduleConfig = $this->_config->getModuleConfig($modName); + $connection = $this->_resourceModel->getConnection($this->_resourceName); + /** + * If module setup configuration wasn't loaded + */ + if (!$connection) { + $connection = $this->_resourceModel->getConnection($this->_resourceName); + } + $this->_conn = $connection; + } + + /** + * Get connection object + * + * @return Varien_Db_Adapter_Interface + */ + public function getConnection() + { + return $this->_conn; + } + + /** + * Add table placeholder/table name relation + * + * @param string $tableName + * @param string $realTableName + * @return Mage_Core_Model_Resource_Setup + */ + public function setTable($tableName, $realTableName) + { + $this->_tables[$tableName] = $realTableName; + return $this; + } + + /** + * Get table name (validated by db adapter) by table placeholder + * + * @param string|array $tableName + * @return string + */ + public function getTable($tableName) + { + $cacheKey = $this->_getTableCacheName($tableName); + if (!isset($this->_tables[$cacheKey])) { + $this->_tables[$cacheKey] = $this->_resourceModel->getTableName($tableName); + } + return $this->_tables[$cacheKey]; + } + + /** + * Retrieve table name for cache + * + * @param string|array $tableName + * @return string + */ + protected function _getTableCacheName($tableName) + { + if (is_array($tableName)) { + return join('_', $tableName); + + } + return $tableName; + } + + /** + * Get core resource resource model + * + * @return Mage_Core_Model_Resource_Resource + */ + protected function _getResource() + { + return Mage::getResourceSingleton('Mage_Core_Model_Resource_Resource'); + } + + /** + * Apply data updates to the system after upgrading. + * + * @return Mage_Core_Model_Resource_Setup + */ + public function applyDataUpdates() + { + $dataVer= $this->_getResource()->getDataVersion($this->_resourceName); + $configVer = (string)$this->_moduleConfig->version; + if ($dataVer !== false) { + $status = version_compare($configVer, $dataVer); + if ($status == self::VERSION_COMPARE_GREATER) { + $this->_upgradeData($dataVer, $configVer); + } + } elseif ($configVer) { + $this->_installData($configVer); + } + return $this; + } + + /** + * Apply module resource install, upgrade and data scripts + * + * @return Mage_Core_Model_Resource_Setup + */ + public function applyUpdates() + { + $dbVer = $this->_getResource()->getDbVersion($this->_resourceName); + $configVer = (string)$this->_moduleConfig->version; + + // Module is installed + if ($dbVer !== false) { + $status = version_compare($configVer, $dbVer); + switch ($status) { + case self::VERSION_COMPARE_LOWER: + $this->_rollbackResourceDb($configVer, $dbVer); + break; + case self::VERSION_COMPARE_GREATER: + $this->_upgradeResourceDb($dbVer, $configVer); + break; + default: + return true; + break; + } + } elseif ($configVer) { + $this->_installResourceDb($configVer); + } + + return $this; + } + + /** + * Run data install scripts + * + * @param string $newVersion + * @return Mage_Core_Model_Resource_Setup + */ + protected function _installData($newVersion) + { + $oldVersion = $this->_modifyResourceDb(self::TYPE_DATA_INSTALL, '', $newVersion); + $this->_modifyResourceDb(self::TYPE_DATA_UPGRADE, $oldVersion, $newVersion); + $this->_getResource()->setDataVersion($this->_resourceName, $newVersion); + + return $this; + } + + /** + * Run data upgrade scripts + * + * @param string $oldVersion + * @param string $newVersion + * @return Mage_Core_Model_Resource_Setup + */ + protected function _upgradeData($oldVersion, $newVersion) + { + $this->_modifyResourceDb('data-upgrade', $oldVersion, $newVersion); + $this->_getResource()->setDataVersion($this->_resourceName, $newVersion); + + return $this; + } + + /** + * Run resource installation file + * + * @param string $newVersion + * @return Mage_Core_Model_Resource_Setup + */ + protected function _installResourceDb($newVersion) + { + $oldVersion = $this->_modifyResourceDb(self::TYPE_DB_INSTALL, '', $newVersion); + $this->_modifyResourceDb(self::TYPE_DB_UPGRADE, $oldVersion, $newVersion); + $this->_getResource()->setDbVersion($this->_resourceName, $newVersion); + + return $this; + } + + /** + * Run resource upgrade files from $oldVersion to $newVersion + * + * @param string $oldVersion + * @param string $newVersion + * @return Mage_Core_Model_Resource_Setup + */ + protected function _upgradeResourceDb($oldVersion, $newVersion) + { + $this->_modifyResourceDb(self::TYPE_DB_UPGRADE, $oldVersion, $newVersion); + $this->_getResource()->setDbVersion($this->_resourceName, $newVersion); + + return $this; + } + + /** + * Roll back resource + * + * @param string $newVersion + * @param string $oldVersion + * @return Mage_Core_Model_Resource_Setup + */ + protected function _rollbackResourceDb($newVersion, $oldVersion) + { + $this->_modifyResourceDb(self::TYPE_DB_ROLLBACK, $newVersion, $oldVersion); + return $this; + } + + /** + * Uninstall resource + * + * @param string $version existing resource version + * @return Mage_Core_Model_Resource_Setup + */ + protected function _uninstallResourceDb($version) + { + $this->_modifyResourceDb(self::TYPE_DB_UNINSTALL, $version, ''); + return $this; + } + + /** + * Retrieve available Database install/upgrade files for current module + * + * @param string $actionType + * @param string $fromVersion + * @param string $toVersion + * @return array + */ + protected function _getAvailableDbFiles($actionType, $fromVersion, $toVersion) + { + $resModel = (string)$this->_connectionConfig->model; + $modName = (string)$this->_moduleConfig[0]->getName(); + + $filesDir = $this->_modulesReader->getModuleDir('sql', $modName) . DS . $this->_resourceName; + if (!is_dir($filesDir) || !is_readable($filesDir)) { + return array(); + } + + $dbFiles = array(); + $typeFiles = array(); + $regExpDb = sprintf('#^%s-(.*)\.(php|sql)$#i', $actionType); + $regExpType = sprintf('#^%s-%s-(.*)\.(php|sql)$#i', $resModel, $actionType); + $handlerDir = dir($filesDir); + while (false !== ($file = $handlerDir->read())) { + $matches = array(); + if (preg_match($regExpDb, $file, $matches)) { + $dbFiles[$matches[1]] = $filesDir . DS . $file; + } else if (preg_match($regExpType, $file, $matches)) { + $typeFiles[$matches[1]] = $filesDir . DS . $file; + } + } + $handlerDir->close(); + + if (empty($typeFiles) && empty($dbFiles)) { + return array(); + } + + foreach ($typeFiles as $version => $file) { + $dbFiles[$version] = $file; + } + + return $this->_getModifySqlFiles($actionType, $fromVersion, $toVersion, $dbFiles); + } + + /** + * Retrieve available Data install/upgrade files for current module + * + * @param string $actionType + * @param string $fromVersion + * @param string $toVersion + * @return array + */ + protected function _getAvailableDataFiles($actionType, $fromVersion, $toVersion) + { + $modName = (string)$this->_moduleConfig[0]->getName(); + $files = array(); + + $filesDir = Mage::getModuleDir('data', $modName) . DS . $this->_resourceName; + if (is_dir($filesDir) && is_readable($filesDir)) { + $regExp = sprintf('#^%s-(.*)\.php$#i', $actionType); + $handlerDir = dir($filesDir); + while (false !== ($file = $handlerDir->read())) { + $matches = array(); + if (preg_match($regExp, $file, $matches)) { + $files[$matches[1]] = $filesDir . DS . $file; + } + + } + $handlerDir->close(); + } + + // search data files in old location + $filesDir = Mage::getModuleDir('sql', $modName) . DS . $this->_resourceName; + if (is_dir($filesDir) && is_readable($filesDir)) { + $regExp = sprintf('#^%s-%s-(.*)\.php$#i', $this->_connectionConfig->model, $actionType); + $handlerDir = dir($filesDir); + + while (false !== ($file = $handlerDir->read())) { + $matches = array(); + if (preg_match($regExp, $file, $matches)) { + $files[$matches[1]] = $filesDir . DS . $file; + } + } + $handlerDir->close(); + } + + if (empty($files)) { + return array(); + } + + return $this->_getModifySqlFiles($actionType, $fromVersion, $toVersion, $files); + } + + /** + * Save resource version + * + * @param string $actionType + * @param string $version + * @return Mage_Core_Model_Resource_Setup + */ + protected function _setResourceVersion($actionType, $version) + { + switch ($actionType) { + case self::TYPE_DB_INSTALL: + case self::TYPE_DB_UPGRADE: + $this->_getResource()->setDbVersion($this->_resourceName, $version); + break; + case self::TYPE_DATA_INSTALL: + case self::TYPE_DATA_UPGRADE: + $this->_getResource()->setDataVersion($this->_resourceName, $version); + break; + default: + break; + } + + return $this; + } + + /** + * Run module modification files. Return version of last applied upgrade (false if no upgrades applied) + * @param string $actionType + * @param string $fromVersion + * @param string $toVersion + * @return bool|string + * @throws Magento_Exception + */ + protected function _modifyResourceDb($actionType, $fromVersion, $toVersion) + { + switch ($actionType) { + case self::TYPE_DB_INSTALL: + case self::TYPE_DB_UPGRADE: + $files = $this->_getAvailableDbFiles($actionType, $fromVersion, $toVersion); + break; + case self::TYPE_DATA_INSTALL: + case self::TYPE_DATA_UPGRADE: + $files = $this->_getAvailableDataFiles($actionType, $fromVersion, $toVersion); + break; + default: + $files = array(); + break; + } + if (empty($files) || !$this->getConnection()) { + return false; + } + + $version = false; + + foreach ($files as $file) { + $fileName = $file['fileName']; + $fileType = pathinfo($fileName, PATHINFO_EXTENSION); + $this->getConnection()->disallowDdlCache(); + try { + switch ($fileType) { + case 'php': + $conn = $this->getConnection(); + $result = include $fileName; + break; + case 'sql': + $sql = file_get_contents($fileName); + if (!empty($sql)) { + + $result = $this->run($sql); + } else { + $result = true; + } + break; + default: + $result = false; + break; + } + + if ($result) { + $this->_setResourceVersion($actionType, $file['toVersion']); + Mage::log($fileName); + } else { + Mage::log("Failed resource setup: {$fileName}"); + } + } catch (Exception $e) { + throw new Magento_Exception(sprintf('Error in file: "%s" - %s', $fileName, $e->getMessage()), 0, $e); + } + $version = $file['toVersion']; + $this->getConnection()->allowDdlCache(); + } + return $version; + } + + /** + * Get data files for modifications + * + * @param string $actionType + * @param string $fromVersion + * @param string $toVersion + * @param array $arrFiles + * @return array + */ + protected function _getModifySqlFiles($actionType, $fromVersion, $toVersion, $arrFiles) + { + $arrRes = array(); + switch ($actionType) { + case self::TYPE_DB_INSTALL: + case self::TYPE_DATA_INSTALL: + uksort($arrFiles, 'version_compare'); + foreach ($arrFiles as $version => $file) { + if (version_compare($version, $toVersion) !== self::VERSION_COMPARE_GREATER) { + $arrRes[0] = array( + 'toVersion' => $version, + 'fileName' => $file + ); + } + } + break; + + case self::TYPE_DB_UPGRADE: + case self::TYPE_DATA_UPGRADE: + uksort($arrFiles, 'version_compare'); + foreach ($arrFiles as $version => $file) { + $versionInfo = explode('-', $version); + + // In array must be 2 elements: 0 => version from, 1 => version to + if (count($versionInfo)!=2) { + break; + } + $infoFrom = $versionInfo[0]; + $infoTo = $versionInfo[1]; + if (version_compare($infoFrom, $fromVersion) !== self::VERSION_COMPARE_LOWER + && version_compare($infoTo, $toVersion) !== self::VERSION_COMPARE_GREATER) { + $arrRes[] = array( + 'toVersion' => $infoTo, + 'fileName' => $file + ); + } + } + break; + + case self::TYPE_DB_ROLLBACK: + break; + + case self::TYPE_DB_UNINSTALL: + break; + default: + break; + } + return $arrRes; + } + + +/******************* UTILITY METHODS *****************/ + + /** + * Retrieve row or field from table by id or string and parent id + * + * @param string $table + * @param string $idField + * @param string|integer $id + * @param string $field + * @param string $parentField + * @param string|integer $parentId + * @return mixed|boolean + */ + public function getTableRow($table, $idField, $id, $field = null, $parentField = null, $parentId = 0) + { + $table = $this->getTable($table); + if (empty($this->_setupCache[$table][$parentId][$id])) { + $adapter = $this->getConnection(); + $bind = array('id_field' => $id); + $select = $adapter->select() + ->from($table) + ->where($adapter->quoteIdentifier($idField) . '= :id_field'); + if (!is_null($parentField)) { + $select->where($adapter->quoteIdentifier($parentField) . '= :parent_id'); + $bind['parent_id'] = $parentId; + } + $this->_setupCache[$table][$parentId][$id] = $adapter->fetchRow($select, $bind); + } + + if (is_null($field)) { + return $this->_setupCache[$table][$parentId][$id]; + } + return isset($this->_setupCache[$table][$parentId][$id][$field]) + ? $this->_setupCache[$table][$parentId][$id][$field] + : false; + } + + + /** + * Delete table row + * + * @param string $table + * @param string $idField + * @param string|int $id + * @param null|string $parentField + * @param int|string $parentId + * @return Mage_Core_Model_Resource_Setup + */ + public function deleteTableRow($table, $idField, $id, $parentField = null, $parentId = 0) + { + $table = $this->getTable($table); + $adapter = $this->getConnection(); + $where = array($adapter->quoteIdentifier($idField) . '=?' => $id); + if (!is_null($parentField)) { + $where[$adapter->quoteIdentifier($parentField) . '=?'] = $parentId; + } + + $adapter->delete($table, $where); + + if (isset($this->_setupCache[$table][$parentId][$id])) { + unset($this->_setupCache[$table][$parentId][$id]); + } + + return $this; + } + + /** + * Update one or more fields of table row + * + * @param string $table + * @param string $idField + * @param string|integer $id + * @param string|array $field + * @param mixed|null $value + * @param string $parentField + * @param string|integer $parentId + * @return Mage_Eav_Model_Entity_Setup + */ + public function updateTableRow($table, $idField, $id, $field, $value = null, $parentField = null, $parentId = 0) + { + $table = $this->getTable($table); + if (is_array($field)) { + $data = $field; + } else { + $data = array($field => $value); + } + + $adapter = $this->getConnection(); + $where = array($adapter->quoteIdentifier($idField) . '=?' => $id); + $adapter->update($table, $data, $where); + + if (isset($this->_setupCache[$table][$parentId][$id])) { + if (is_array($field)) { + $this->_setupCache[$table][$parentId][$id] = + array_merge($this->_setupCache[$table][$parentId][$id], $field); + } else { + $this->_setupCache[$table][$parentId][$id][$field] = $value; + } + } + + return $this; + } + + /** + * Check is table exists + * + * @param string $table + * @return bool + */ + public function tableExists($table) + { + $table = $this->getTable($table); + return $this->getConnection()->isTableExists($table); + } + +/******************* CONFIG *****************/ + + /** + * Save configuration data + * + * @param string $path + * @param string $value + * @param int|string $scope + * @param int $scopeId + * @return Mage_Core_Model_Resource_Setup + */ + public function setConfigData($path, $value, $scope = Mage_Core_Model_Store::DEFAULT_CODE, $scopeId = 0) + { + $table = $this->getTable('core_config_data'); + // this is a fix for mysql 4.1 + $this->getConnection()->showTableStatus($table); + + $data = array( + 'scope' => $scope, + 'scope_id' => $scopeId, + 'path' => $path, + 'value' => $value + ); + $this->getConnection()->insertOnDuplicate($table, $data, array('value')); + return $this; + } + + /** + * Delete config field values + * + * @param string $path + * @param string $scope (default|stores|websites|config) + * @return Mage_Core_Model_Resource_Setup + */ + public function deleteConfigData($path, $scope = null) + { + $where = array('path = ?' => $path); + if (!is_null($scope)) { + $where['scope = ?'] = $scope; + } + $this->getConnection()->delete($this->getTable('core_config_data'), $where); + return $this; + } + + /** + * Run plain SQL query(ies) + * + * @param string $sql + * @return Mage_Core_Model_Resource_Setup + */ + public function run($sql) + { + $this->getConnection()->multiQuery($sql); + return $this; + } + + /** + * Prepare database before install/upgrade + * + * @return Mage_Core_Model_Resource_Setup + */ + public function startSetup() + { + $this->getConnection()->startSetup(); + return $this; + } + + /** + * Prepare database after install/upgrade + * + * @return Mage_Core_Model_Resource_Setup + */ + public function endSetup() + { + $this->getConnection()->endSetup(); + return $this; + } + + /** + * Retrieve 32bit UNIQUE HASH for a Table index + * + * @param string $tableName + * @param array|string $fields + * @param string $indexType + * @return string + */ + public function getIdxName($tableName, $fields, $indexType = '') + { + return $this->_resourceModel->getIdxName($tableName, $fields, $indexType); + } + + /** + * Retrieve 32bit UNIQUE HASH for a Table foreign key + * + * @param string $priTableName the target table name + * @param string $priColumnName the target table column name + * @param string $refTableName the reference table name + * @param string $refColumnName the reference table column name + * @return string + */ + public function getFkName($priTableName, $priColumnName, $refTableName, $refColumnName) + { + return $this->_resourceModel + ->getFkName($priTableName, $priColumnName, $refTableName, $refColumnName); + } + + /** + * Check call afterApplyAllUpdates method for setup class + * + * @return boolean + */ + public function getCallAfterApplyAllUpdates() + { + return $this->_callAfterApplyAllUpdates; + } + + /** + * Run each time after applying of all updates, + * if setup model setted $_callAfterApplyAllUpdates flag to true + * + * @return Mage_Core_Model_Resource_Setup + */ + public function afterApplyAllUpdates() + { + return $this; + } +} diff --git a/app/code/core/Mage/Core/Model/Resource/Setup/Migration.php b/app/code/Mage/Core/Model/Resource/Setup/Migration.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Setup/Migration.php rename to app/code/Mage/Core/Model/Resource/Setup/Migration.php diff --git a/app/code/core/Mage/Core/Model/Resource/SetupFactory.php b/app/code/Mage/Core/Model/Resource/SetupFactory.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/SetupFactory.php rename to app/code/Mage/Core/Model/Resource/SetupFactory.php diff --git a/app/code/core/Mage/Core/Model/Resource/SetupInterface.php b/app/code/Mage/Core/Model/Resource/SetupInterface.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/SetupInterface.php rename to app/code/Mage/Core/Model/Resource/SetupInterface.php diff --git a/app/code/core/Mage/Core/Model/Resource/Store.php b/app/code/Mage/Core/Model/Resource/Store.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Store.php rename to app/code/Mage/Core/Model/Resource/Store.php diff --git a/app/code/core/Mage/Core/Model/Resource/Store/Collection.php b/app/code/Mage/Core/Model/Resource/Store/Collection.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Store/Collection.php rename to app/code/Mage/Core/Model/Resource/Store/Collection.php diff --git a/app/code/core/Mage/Core/Model/Resource/Store/Group.php b/app/code/Mage/Core/Model/Resource/Store/Group.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Store/Group.php rename to app/code/Mage/Core/Model/Resource/Store/Group.php diff --git a/app/code/core/Mage/Core/Model/Resource/Store/Group/Collection.php b/app/code/Mage/Core/Model/Resource/Store/Group/Collection.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Store/Group/Collection.php rename to app/code/Mage/Core/Model/Resource/Store/Group/Collection.php diff --git a/app/code/core/Mage/Core/Model/Resource/Theme.php b/app/code/Mage/Core/Model/Resource/Theme.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Theme.php rename to app/code/Mage/Core/Model/Resource/Theme.php diff --git a/app/code/Mage/Core/Model/Resource/Theme/Collection.php b/app/code/Mage/Core/Model/Resource/Theme/Collection.php new file mode 100644 index 0000000000000..0d2f475ea2a62 --- /dev/null +++ b/app/code/Mage/Core/Model/Resource/Theme/Collection.php @@ -0,0 +1,176 @@ +_init('Mage_Core_Model_Theme', 'Mage_Core_Model_Resource_Theme'); + } + + /** + * Add title for parent themes + * + * @return Mage_Core_Model_Resource_Theme_Collection + */ + public function addParentTitle() + { + $this->getSelect()->joinLeft( + array('parent' => $this->getMainTable()), + 'main_table.parent_id = parent.theme_id', + array('parent_theme_title' => 'parent.theme_title') + ); + return $this; + } + + /** + * Add area filter + * + * @param string $area + * @return Mage_Core_Model_Resource_Theme_Collection + */ + public function addAreaFilter($area = Mage_Core_Model_App_Area::AREA_FRONTEND) + { + $this->getSelect()->where('main_table.area=?', $area); + return $this; + } + + /** + * Add type filter in relations + * + * @param int $typeParent + * @param int $typeChild + * @return Mage_Core_Model_Resource_Theme_Collection + */ + public function addTypeRelationFilter($typeParent, $typeChild) + { + $this->getSelect()->join( + array('parent' => $this->getMainTable()), + 'main_table.parent_id = parent.theme_id', + array('parent_type' => 'parent.type') + )->where('parent.type = ?', $typeParent)->where('main_table.type = ?', $typeChild); + return $this; + } + + /** + * Add type filter + * + * @param string|array $type + * @return Mage_Core_Model_Resource_Theme_Collection + */ + public function addTypeFilter($type) + { + $this->addFieldToFilter('main_table.type', array('in' => $type)); + return $this; + } + + /** + * Filter visible themes in backend (physical and virtual only) + * + * @return Mage_Core_Model_Resource_Theme_Collection + */ + public function filterVisibleThemes() + { + $this->addTypeFilter(array(Mage_Core_Model_Theme::TYPE_PHYSICAL, Mage_Core_Model_Theme::TYPE_VIRTUAL)); + return $this; + } + + /** + * Return array for select field + * + * @return array + */ + public function toOptionArray() + { + return $this->_toOptionArray('theme_id', 'theme_title'); + } + + /** + * Return array for grid column + * + * @return array + */ + public function toOptionHash() + { + return $this->_toOptionHash('theme_id', 'theme_title'); + } + + /** + * Get theme from DB by area and theme_path + * + * @param string $fullPath + * @return Mage_Core_Model_Theme + */ + public function getThemeByFullPath($fullPath) + { + $this->_reset()->clear(); + list($area, $themePath) = explode('/', $fullPath, 2); + $this->addFieldToFilter('area', $area); + $this->addFieldToFilter('theme_path', $themePath); + + return $this->getFirstItem(); + } + + /** + * Set page size + * + * @param int $size + * @return Mage_Core_Model_Resource_Theme_Collection + */ + public function setPageSize($size = self::DEFAULT_PAGE_SIZE) + { + return parent::setPageSize($size); + } + + /** + * Update all child themes relations + * + * @param Mage_Core_Model_Theme $themeModel + * @return Mage_Core_Model_Resource_Theme_Collection + */ + public function updateChildRelations(Mage_Core_Model_Theme $themeModel) + { + $parentThemeId = $themeModel->getParentId(); + $this->addFieldToFilter('parent_id', array('eq' => $themeModel->getId()))->load(); + + /** @var $theme Mage_Core_Model_Theme */ + foreach ($this->getItems() as $theme) { + $theme->setParentId($parentThemeId)->save(); + } + return $this; + } +} diff --git a/app/code/Mage/Core/Model/Resource/Theme/Customization/Update.php b/app/code/Mage/Core/Model/Resource/Theme/Customization/Update.php new file mode 100644 index 0000000000000..d804e57fb48b1 --- /dev/null +++ b/app/code/Mage/Core/Model/Resource/Theme/Customization/Update.php @@ -0,0 +1,39 @@ +_init('core_theme_file_update', 'file_update_id'); + } +} diff --git a/app/code/Mage/Core/Model/Resource/Theme/File.php b/app/code/Mage/Core/Model/Resource/Theme/File.php new file mode 100644 index 0000000000000..c41bdb1f7e672 --- /dev/null +++ b/app/code/Mage/Core/Model/Resource/Theme/File.php @@ -0,0 +1,39 @@ +_init('core_theme_file', 'theme_files_id'); + } +} diff --git a/app/code/Mage/Core/Model/Resource/Theme/File/Collection.php b/app/code/Mage/Core/Model/Resource/Theme/File/Collection.php new file mode 100644 index 0000000000000..e72ea9b11a650 --- /dev/null +++ b/app/code/Mage/Core/Model/Resource/Theme/File/Collection.php @@ -0,0 +1,76 @@ +_init('Mage_Core_Model_Theme_File', 'Mage_Core_Model_Resource_Theme_File'); + } + + /** + * Add select order + * + * $field is properly quoted, lately it was treated field "order" as special SQL word and was not working + * + * @param string $field + * @param string $direction + * @return Mage_Core_Model_Resource_Theme_File_Collection|Varien_Data_Collection|Varien_Data_Collection_Db + */ + public function setOrder($field, $direction = self::SORT_ORDER_DESC) + { + return parent::setOrder($this->getConnection()->quoteIdentifier($field), $direction); + } + + /** + * Set default order + * + * @param string $direction + * @return Mage_Core_Model_Resource_Theme_File_Collection + */ + public function setDefaultOrder($direction) + { + return $this->setOrder('sort_order', $direction); + } + + /** + * Filter out files that do not belong to a theme + * + * @param Mage_Core_Model_Theme $theme + * @return Mage_Core_Model_Resource_Theme_File_Collection + */ + public function addThemeFilter(Mage_Core_Model_Theme $theme) + { + $this->addFieldToFilter('theme_id', $theme->getId()); + return $this; + } +} diff --git a/app/code/Mage/Core/Model/Resource/Theme/Grid/Collection.php b/app/code/Mage/Core/Model/Resource/Theme/Grid/Collection.php new file mode 100644 index 0000000000000..341245c53326a --- /dev/null +++ b/app/code/Mage/Core/Model/Resource/Theme/Grid/Collection.php @@ -0,0 +1,43 @@ +filterVisibleThemes()->addAreaFilter(Mage_Core_Model_App_Area::AREA_FRONTEND)->addParentTitle(); + return $this; + } +} diff --git a/app/code/core/Mage/Core/Model/Resource/Transaction.php b/app/code/Mage/Core/Model/Resource/Transaction.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Transaction.php rename to app/code/Mage/Core/Model/Resource/Transaction.php diff --git a/app/code/core/Mage/Core/Model/Resource/Transaction/Factory.php b/app/code/Mage/Core/Model/Resource/Transaction/Factory.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Transaction/Factory.php rename to app/code/Mage/Core/Model/Resource/Transaction/Factory.php diff --git a/app/code/core/Mage/Core/Model/Resource/Translate.php b/app/code/Mage/Core/Model/Resource/Translate.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Translate.php rename to app/code/Mage/Core/Model/Resource/Translate.php diff --git a/app/code/core/Mage/Core/Model/Resource/Translate/String.php b/app/code/Mage/Core/Model/Resource/Translate/String.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Translate/String.php rename to app/code/Mage/Core/Model/Resource/Translate/String.php diff --git a/app/code/core/Mage/Core/Model/Resource/Type/Abstract.php b/app/code/Mage/Core/Model/Resource/Type/Abstract.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Type/Abstract.php rename to app/code/Mage/Core/Model/Resource/Type/Abstract.php diff --git a/app/code/core/Mage/Core/Model/Resource/Type/Db.php b/app/code/Mage/Core/Model/Resource/Type/Db.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Type/Db.php rename to app/code/Mage/Core/Model/Resource/Type/Db.php diff --git a/app/code/core/Mage/Core/Model/Resource/Type/Db/Mysqli.php b/app/code/Mage/Core/Model/Resource/Type/Db/Mysqli.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Type/Db/Mysqli.php rename to app/code/Mage/Core/Model/Resource/Type/Db/Mysqli.php diff --git a/app/code/core/Mage/Core/Model/Resource/Type/Db/Mysqli/Setup.php b/app/code/Mage/Core/Model/Resource/Type/Db/Mysqli/Setup.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Type/Db/Mysqli/Setup.php rename to app/code/Mage/Core/Model/Resource/Type/Db/Mysqli/Setup.php diff --git a/app/code/core/Mage/Core/Model/Resource/Type/Db/Pdo/Mysql.php b/app/code/Mage/Core/Model/Resource/Type/Db/Pdo/Mysql.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Type/Db/Pdo/Mysql.php rename to app/code/Mage/Core/Model/Resource/Type/Db/Pdo/Mysql.php diff --git a/app/code/core/Mage/Core/Model/Resource/Url/Rewrite.php b/app/code/Mage/Core/Model/Resource/Url/Rewrite.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Url/Rewrite.php rename to app/code/Mage/Core/Model/Resource/Url/Rewrite.php diff --git a/app/code/core/Mage/Core/Model/Resource/Url/Rewrite/Collection.php b/app/code/Mage/Core/Model/Resource/Url/Rewrite/Collection.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Url/Rewrite/Collection.php rename to app/code/Mage/Core/Model/Resource/Url/Rewrite/Collection.php diff --git a/app/code/core/Mage/Core/Model/Resource/Variable.php b/app/code/Mage/Core/Model/Resource/Variable.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Variable.php rename to app/code/Mage/Core/Model/Resource/Variable.php diff --git a/app/code/core/Mage/Core/Model/Resource/Variable/Collection.php b/app/code/Mage/Core/Model/Resource/Variable/Collection.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Variable/Collection.php rename to app/code/Mage/Core/Model/Resource/Variable/Collection.php diff --git a/app/code/core/Mage/Core/Model/Resource/Website.php b/app/code/Mage/Core/Model/Resource/Website.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Website.php rename to app/code/Mage/Core/Model/Resource/Website.php diff --git a/app/code/core/Mage/Core/Model/Resource/Website/Collection.php b/app/code/Mage/Core/Model/Resource/Website/Collection.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Website/Collection.php rename to app/code/Mage/Core/Model/Resource/Website/Collection.php diff --git a/app/code/core/Mage/Core/Model/Resource/Website/Grid/Collection.php b/app/code/Mage/Core/Model/Resource/Website/Grid/Collection.php similarity index 100% rename from app/code/core/Mage/Core/Model/Resource/Website/Grid/Collection.php rename to app/code/Mage/Core/Model/Resource/Website/Grid/Collection.php diff --git a/app/code/Mage/Core/Model/Session.php b/app/code/Mage/Core/Model/Session.php new file mode 100644 index 0000000000000..d7ea10f05d97e --- /dev/null +++ b/app/code/Mage/Core/Model/Session.php @@ -0,0 +1,59 @@ +init('core', $sessionName); + } + + /** + * Retrieve Session Form Key + * + * @return string A 16 bit unique key for forms + */ + public function getFormKey() + { + if (!$this->getData('_form_key')) { + $this->setData('_form_key', Mage::helper('Mage_Core_Helper_Data')->getRandomString(16)); + } + return $this->getData('_form_key'); + } +} diff --git a/app/code/core/Mage/Core/Model/Session/Abstract.php b/app/code/Mage/Core/Model/Session/Abstract.php similarity index 100% rename from app/code/core/Mage/Core/Model/Session/Abstract.php rename to app/code/Mage/Core/Model/Session/Abstract.php diff --git a/app/code/core/Mage/Core/Model/Session/Exception.php b/app/code/Mage/Core/Model/Session/Exception.php similarity index 100% rename from app/code/core/Mage/Core/Model/Session/Exception.php rename to app/code/Mage/Core/Model/Session/Exception.php diff --git a/app/code/core/Mage/Core/Model/ShellAbstract.php b/app/code/Mage/Core/Model/ShellAbstract.php similarity index 100% rename from app/code/core/Mage/Core/Model/ShellAbstract.php rename to app/code/Mage/Core/Model/ShellAbstract.php diff --git a/app/code/core/Mage/Core/Model/Source/Email/Variables.php b/app/code/Mage/Core/Model/Source/Email/Variables.php similarity index 81% rename from app/code/core/Mage/Core/Model/Source/Email/Variables.php rename to app/code/Mage/Core/Model/Source/Email/Variables.php index f25b36150bc14..4063abcff3886 100644 --- a/app/code/core/Mage/Core/Model/Source/Email/Variables.php +++ b/app/code/Mage/Core/Model/Source/Email/Variables.php @@ -94,11 +94,31 @@ public function __construct() ), array( 'value' => 'general/store_information/phone', - 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Store Contact Telephone') + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Store Phone Number') ), array( - 'value' => 'general/store_information/address', - 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Store Contact Address') + 'value' => 'general/store_information/country_id', + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Country') + ), + array( + 'value' => 'general/store_information/region_id', + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Region/State') + ), + array( + 'value' => 'general/store_information/postcode', + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Zip/Postal Code') + ), + array( + 'value' => 'general/store_information/city', + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('City') + ), + array( + 'value' => 'general/store_information/street_line1', + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Street Address 1') + ), + array( + 'value' => 'general/store_information/street_line2', + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Street Address 2') ) ); } diff --git a/app/code/core/Mage/Core/Model/Source/Urlrewrite/Options.php b/app/code/Mage/Core/Model/Source/Urlrewrite/Options.php similarity index 100% rename from app/code/core/Mage/Core/Model/Source/Urlrewrite/Options.php rename to app/code/Mage/Core/Model/Source/Urlrewrite/Options.php diff --git a/app/code/core/Mage/Core/Model/Source/Urlrewrite/Types.php b/app/code/Mage/Core/Model/Source/Urlrewrite/Types.php similarity index 100% rename from app/code/core/Mage/Core/Model/Source/Urlrewrite/Types.php rename to app/code/Mage/Core/Model/Source/Urlrewrite/Types.php diff --git a/app/code/core/Mage/Core/Model/Store.php b/app/code/Mage/Core/Model/Store.php similarity index 90% rename from app/code/core/Mage/Core/Model/Store.php rename to app/code/Mage/Core/Model/Store.php index ac0751ef09d49..6fd93e60e5e6d 100644 --- a/app/code/core/Mage/Core/Model/Store.php +++ b/app/code/Mage/Core/Model/Store.php @@ -53,22 +53,24 @@ class Mage_Core_Model_Store extends Mage_Core_Model_Abstract /**#@+ * Configuration paths */ - 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'; - const XML_PATH_UNSECURE_BASE_URL = 'web/unsecure/base_url'; - const XML_PATH_SECURE_BASE_URL = 'web/secure/base_url'; - const XML_PATH_SECURE_IN_FRONTEND = 'web/secure/use_in_frontend'; - const XML_PATH_SECURE_IN_ADMINHTML = 'web/secure/use_in_adminhtml'; - const XML_PATH_SECURE_BASE_LINK_URL = 'web/secure/base_link_url'; - const XML_PATH_UNSECURE_BASE_LINK_URL = 'web/unsecure/base_link_url'; - const XML_PATH_SECURE_BASE_LIB_URL = 'web/secure/base_lib_url'; - const XML_PATH_UNSECURE_BASE_LIB_URL = 'web/unsecure/base_lib_url'; - const XML_PATH_SECURE_BASE_MEDIA_URL = 'web/secure/base_media_url'; - const XML_PATH_UNSECURE_BASE_MEDIA_URL = 'web/unsecure/base_media_url'; - const XML_PATH_OFFLOADER_HEADER = 'web/secure/offloader_header'; - const XML_PATH_PRICE_SCOPE = 'catalog/price/scope'; + 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'; + const XML_PATH_UNSECURE_BASE_URL = 'web/unsecure/base_url'; + const XML_PATH_SECURE_BASE_URL = 'web/secure/base_url'; + const XML_PATH_SECURE_IN_FRONTEND = 'web/secure/use_in_frontend'; + const XML_PATH_SECURE_IN_ADMINHTML = 'web/secure/use_in_adminhtml'; + const XML_PATH_SECURE_BASE_LINK_URL = 'web/secure/base_link_url'; + const XML_PATH_UNSECURE_BASE_LINK_URL = 'web/unsecure/base_link_url'; + const XML_PATH_SECURE_BASE_LIB_URL = 'web/secure/base_lib_url'; + const XML_PATH_UNSECURE_BASE_LIB_URL = 'web/unsecure/base_lib_url'; + const XML_PATH_SECURE_BASE_STATIC_URL = 'web/secure/base_static_url'; + const XML_PATH_UNSECURE_BASE_STATIC_URL = 'web/unsecure/base_static_url'; + const XML_PATH_SECURE_BASE_MEDIA_URL = 'web/secure/base_media_url'; + const XML_PATH_UNSECURE_BASE_MEDIA_URL = 'web/unsecure/base_media_url'; + const XML_PATH_OFFLOADER_HEADER = 'web/secure/offloader_header'; + const XML_PATH_PRICE_SCOPE = 'catalog/price/scope'; /**#@- */ /** @@ -77,7 +79,7 @@ class Mage_Core_Model_Store extends Mage_Core_Model_Abstract const PRICE_SCOPE_GLOBAL = 0; const PRICE_SCOPE_WEBSITE = 1; - /** + /**#@+ * Possible URL types */ const URL_TYPE_LINK = 'link'; @@ -85,6 +87,8 @@ class Mage_Core_Model_Store extends Mage_Core_Model_Abstract const URL_TYPE_WEB = 'web'; const URL_TYPE_LIB = 'lib'; const URL_TYPE_MEDIA = 'media'; + const URL_TYPE_STATIC = 'static'; + /**#@-*/ /** * Code constants @@ -117,6 +121,11 @@ class Mage_Core_Model_Store extends Mage_Core_Model_Abstract */ const BASE_URL_PLACEHOLDER = '{{base_url}}'; + /** + * @var Mage_Core_Model_Cache_Type_Config + */ + protected $_configCacheType; + /** * Cache flag * @@ -225,19 +234,30 @@ class Mage_Core_Model_Store extends Mage_Core_Model_Abstract /** * Url model for current store * - * @var Mage_Core_Model_Url - */ - protected $_urlModel = null; - - /** - * Url class name for current store - * - * @var bool - */ - protected $_urlClassName = null; - - /** Default url class name for current store */ - const DEFAULT_URL_MODEL_NAME = 'Mage_Core_Model_Url'; + * @var Mage_Core_Model_UrlInterface + */ + protected $_urlModel; + + /** + * @param Mage_Core_Model_Context $context + * @param Mage_Core_Model_Cache_Type_Config $configCacheType + * @param Mage_Core_Model_Url $urlModel + * @param Mage_Core_Model_Resource_Abstract $resource + * @param Varien_Data_Collection_Db $resourceCollection + * @param array $data + */ + public function __construct( + Mage_Core_Model_Context $context, + Mage_Core_Model_Cache_Type_Config $configCacheType, + Mage_Core_Model_Url $urlModel, + Mage_Core_Model_Resource_Abstract $resource = null, + Varien_Data_Collection_Db $resourceCollection = null, + array $data = array() + ) { + $this->_urlModel = $urlModel; + $this->_configCacheType = $configCacheType; + parent::__construct($context, $resource, $resourceCollection, $data); + } /** * Initialize object @@ -409,24 +429,18 @@ public function initConfigCache() if ($this->_configCache === null) { $code = $this->getCode(); if ($code) { - $cache = Mage::getObjectManager()->get('Mage_Core_Model_Cache'); - if ($cache->canUse('config')) { - $cacheId = 'store_' . $code . '_config_cache'; - $data = $cache->load($cacheId); - if ($data) { - $data = unserialize($data); - } else { - $data = array(); - foreach ($this->_configCacheBaseNodes as $node) { - $data[$node] = $this->getConfig($node); - } - $cache->save(serialize($data), $cacheId, array( - self::CACHE_TAG, - Mage_Core_Model_Config::CACHE_TAG - ), false); + $cacheId = 'store_' . $code . '_config_cache'; + $data = $this->_configCacheType->load($cacheId); + if ($data) { + $data = unserialize($data); + } else { + $data = array(); + foreach ($this->_configCacheBaseNodes as $node) { + $data[$node] = $this->getConfig($node); } - $this->_configCache = $data; + $this->_configCacheType->save(serialize($data), $cacheId, array(self::CACHE_TAG), false); } + $this->_configCache = $data; } } return $this; @@ -589,6 +603,15 @@ public function getBaseUrl($type = self::URL_TYPE_LINK, $secure = null) } break; + case self::URL_TYPE_STATIC: + $path = $secure ? self::XML_PATH_SECURE_BASE_STATIC_URL : self::XML_PATH_UNSECURE_BASE_STATIC_URL; + $url = $this->getConfig($path); + if (!$url) { + $url = $this->getBaseUrl(self::URL_TYPE_WEB, $secure) + . $dirs->getUri(Mage_Core_Model_Dir::STATIC_VIEW); + } + break; + case self::URL_TYPE_MEDIA: $url = $this->_getMediaScriptUrl($dirs, $secure); if (!$url) { @@ -1194,7 +1217,7 @@ protected function _beforeDelete() protected function _afterDelete() { parent::_afterDelete(); - Mage::getConfig()->removeCache(); + $this->_configCacheType->clean(); return $this; } @@ -1255,14 +1278,14 @@ public function getFrontendName() } /** - * Set url class name for current store + * Set url model for current store * - * @param string $urlClassName + * @param Mage_Core_Model_Url $urlModel * @return Mage_Core_Model_Store */ - public function setUrlClassName($urlClassName) + public function setUrlModel($urlModel) { - $this->_urlClassName = $urlClassName; + $this->_urlModel = $urlModel; return $this; } @@ -1273,13 +1296,6 @@ public function setUrlClassName($urlClassName) */ public function getUrlModel() { - if (null === $this->_urlModel) { - if (null === $this->_urlClassName) { - $this->_urlClassName = self::DEFAULT_URL_MODEL_NAME; - } - $this->_urlModel = Mage::getModel($this->_urlClassName); - } - return $this->_urlModel; } } diff --git a/app/code/core/Mage/Core/Model/Store/Api.php b/app/code/Mage/Core/Model/Store/Api.php similarity index 100% rename from app/code/core/Mage/Core/Model/Store/Api.php rename to app/code/Mage/Core/Model/Store/Api.php diff --git a/app/code/core/Mage/Core/Model/Store/Api/V2.php b/app/code/Mage/Core/Model/Store/Api/V2.php similarity index 100% rename from app/code/core/Mage/Core/Model/Store/Api/V2.php rename to app/code/Mage/Core/Model/Store/Api/V2.php diff --git a/app/code/core/Mage/Core/Model/Store/Config.php b/app/code/Mage/Core/Model/Store/Config.php similarity index 100% rename from app/code/core/Mage/Core/Model/Store/Config.php rename to app/code/Mage/Core/Model/Store/Config.php diff --git a/app/code/core/Mage/Core/Model/Store/Exception.php b/app/code/Mage/Core/Model/Store/Exception.php similarity index 100% rename from app/code/core/Mage/Core/Model/Store/Exception.php rename to app/code/Mage/Core/Model/Store/Exception.php diff --git a/app/code/core/Mage/Core/Model/Store/Group.php b/app/code/Mage/Core/Model/Store/Group.php similarity index 100% rename from app/code/core/Mage/Core/Model/Store/Group.php rename to app/code/Mage/Core/Model/Store/Group.php diff --git a/app/code/Mage/Core/Model/Store/Group/Factory.php b/app/code/Mage/Core/Model/Store/Group/Factory.php new file mode 100644 index 0000000000000..a359f90235788 --- /dev/null +++ b/app/code/Mage/Core/Model/Store/Group/Factory.php @@ -0,0 +1,60 @@ +_objectManager = $objectManager; + } + + /** + * @param array $arguments + * @return mixed + */ + public function create(array $arguments = array()) + { + return $this->_objectManager->create(self::CLASS_NAME, $arguments); + } +} diff --git a/app/code/core/Mage/Core/Model/Store/Limitation.php b/app/code/Mage/Core/Model/Store/Limitation.php similarity index 100% rename from app/code/core/Mage/Core/Model/Store/Limitation.php rename to app/code/Mage/Core/Model/Store/Limitation.php diff --git a/app/code/core/Mage/Core/Model/Store/ListInterface.php b/app/code/Mage/Core/Model/Store/ListInterface.php similarity index 100% rename from app/code/core/Mage/Core/Model/Store/ListInterface.php rename to app/code/Mage/Core/Model/Store/ListInterface.php diff --git a/app/code/core/Mage/Core/Model/Store/Storage/Db.php b/app/code/Mage/Core/Model/Store/Storage/Db.php similarity index 97% rename from app/code/core/Mage/Core/Model/Store/Storage/Db.php rename to app/code/Mage/Core/Model/Store/Storage/Db.php index 3f300e3cb1fbc..abd6c667a17d1 100644 --- a/app/code/core/Mage/Core/Model/Store/Storage/Db.php +++ b/app/code/Mage/Core/Model/Store/Storage/Db.php @@ -91,7 +91,7 @@ class Mage_Core_Model_Store_Storage_Db implements Mage_Core_Model_Store_StorageI /** * Application cache model * - * @var Mage_Core_Model_Cache + * @var Mage_Core_Model_CacheInterface */ protected $_cache; @@ -148,7 +148,7 @@ class Mage_Core_Model_Store_Storage_Db implements Mage_Core_Model_Store_StorageI * @param Mage_Core_Model_StoreFactory $storeFactory * @param Mage_Core_Model_Website_Factory $websiteFactory * @param Mage_Core_Model_Store_Group_Factory $groupFactory - * @param Mage_Core_Model_Cache $cache + * @param Mage_Core_Model_CacheInterface $cache * @param Mage_Core_Model_Config $config * @param Mage_Core_Model_Cookie $cookie * @param Mage_Core_Model_App_State $appState @@ -161,7 +161,7 @@ public function __construct( Mage_Core_Model_StoreFactory $storeFactory, Mage_Core_Model_Website_Factory $websiteFactory, Mage_Core_Model_Store_Group_Factory $groupFactory, - Mage_Core_Model_Cache $cache, + Mage_Core_Model_CacheInterface $cache, Mage_Core_Model_Config $config, Mage_Core_Model_Cookie $cookie, Mage_Core_Model_App_State $appState, @@ -355,6 +355,7 @@ protected function _getStoreByWebsite($website) */ protected function _initStores() { + $this->_store = null; $this->_stores = array(); $this->_groups = array(); $this->_websites = array(); @@ -367,7 +368,7 @@ protected function _initStores() $websiteCollection->setLoadDefault(true); /** @var $groupCollection Mage_Core_Model_Resource_Store_Group_Collection */ - $groupCollection = $this->_groupFactory->createFromArray()->getCollection(); + $groupCollection = $this->_groupFactory->create()->getCollection(); $groupCollection->initCache($this->_cache, 'app', array(Mage_Core_Model_Store_Group::CACHE_TAG)); $groupCollection->setLoadDefault(true); @@ -400,6 +401,10 @@ protected function _initStores() if (is_null($this->_store) && $store->getId()) { $this->_store = $store; } + + if (0 == $store->getId()) { + $store->setUrlModel(Mage::getSingleton('Mage_Backend_Model_Url_Proxy')); + } } foreach ($groupCollection as $group) { @@ -599,7 +604,7 @@ public function getGroup($id = null) return $id; } if (empty($this->_groups[$id])) { - $group = $this->_groupFactory->createFromArray(); + $group = $this->_groupFactory->create(); if (is_numeric($id)) { $group->load($id); if (!$group->hasGroupId()) { diff --git a/app/code/Mage/Core/Model/Store/Storage/Default.php b/app/code/Mage/Core/Model/Store/Storage/Default.php new file mode 100644 index 0000000000000..dad23a07cdf76 --- /dev/null +++ b/app/code/Mage/Core/Model/Store/Storage/Default.php @@ -0,0 +1,254 @@ +_store = $storeFactory->create(); + $this->_store->setId(Mage_Core_Model_AppInterface::DISTRO_STORE_ID); + $this->_store->setCode(Mage_Core_Model_AppInterface::DISTRO_STORE_CODE); + $this->_website = $websiteFactory->create(); + $this->_group = $groupFactory->create(); + } + + /** + * Initialize current applicaition store + */ + public function initCurrentStore() + { + //not applicable for default storage + } + + /** + * Allow or disallow single store mode + * + * @param bool $value + */ + public function setIsSingleStoreModeAllowed($value) + { + //not applicable for default storage + } + + /** + * Check if store has only one store view + * + * @return bool + */ + public function hasSingleStore() + { + return false; + } + + /** + * Retrieve application store object + * + * @param null|string|bool|int|Mage_Core_Model_Store $id + * @return Mage_Core_Model_Store + */ + public function getStore($id = null) + { + return $this->_store; + } + + /** + * Retrieve stores array + * + * @param bool $withDefault + * @param bool $codeKey + * @return Mage_Core_Model_Store[] + */ + public function getStores($withDefault = false, $codeKey = false) + { + return array(); + } + + /** + * Retrieve application website object + * + * @param null|bool|int|string|Mage_Core_Model_Website $id + * @return Mage_Core_Model_Website + * @throws Mage_Core_Exception + */ + public function getWebsite($id = null) + { + if ($id instanceof Mage_Core_Model_Website) { + return $id; + } + + return $this->_website; + } + + /** + * Get loaded websites + * + * @param bool $withDefault + * @param bool|string $codeKey + * @return Mage_Core_Model_Website[] + */ + public function getWebsites($withDefault = false, $codeKey = false) + { + $websites = array(); + + if ($withDefault) { + $key = $codeKey ? $this->_website->getCode() : $this->_website->getId(); + $websites[$key] = $this->_website; + } + + return $websites; + } + + /** + * Retrieve application store group object + * + * @param null|Mage_Core_Model_Store_Group|string $id + * @return Mage_Core_Model_Store_Group + * @throws Mage_Core_Exception + */ + public function getGroup($id = null) + { + if ($id instanceof Mage_Core_Model_Store_Group) { + return $id; + } + + return $this->_group; + } + + /** + * Prepare array of store groups + * can be filtered to contain default store group or not by $withDefault flag + * depending on flag $codeKey array keys can be group id or group code + * + * @param bool $withDefault + * @param bool $codeKey + * @return Mage_Core_Model_Store_Group[] + */ + public function getGroups($withDefault = false, $codeKey = false) + { + $groups = array(); + + if ($withDefault) { + $key = $codeKey ? $this->_group->getCode() : $this->_group->getId(); + $groups[$key] = $this->_group; + } + return $groups; + } + + /** + * Reinitialize store list + */ + public function reinitStores() + { + //not applicable for default storage + } + + /** + * Retrieve default store for default group and website + * + * @return Mage_Core_Model_Store + */ + public function getDefaultStoreView() + { + return null; + } + + /** + * Unset website by id from app cache + * + * @param null|bool|int|string|Mage_Core_Model_Website $id + */ + public function clearWebsiteCache($id = null) + { + //not applicable for default storage + } + + /** + * Get either default or any store view + * + * @return Mage_Core_Model_Store + */ + public function getAnyStoreView() + { + return null; + } + + /** + * Set current default store + * + * @param string $store + */ + public function setCurrentStore($store) + { + + } + + /** + * @throws Mage_Core_Model_Store_Exception + */ + public function throwStoreException() + { + //not applicable for default storage + } + + /** + * Get current store code + * + * @return string + */ + public function getCurrentStore() + { + return $this->_store->getCode(); + } +} diff --git a/app/code/core/Mage/Core/Model/Store/StorageFactory.php b/app/code/Mage/Core/Model/Store/StorageFactory.php similarity index 98% rename from app/code/core/Mage/Core/Model/Store/StorageFactory.php rename to app/code/Mage/Core/Model/Store/StorageFactory.php index c9f07ea0bd569..007254b6179d9 100644 --- a/app/code/core/Mage/Core/Model/Store/StorageFactory.php +++ b/app/code/Mage/Core/Model/Store/StorageFactory.php @@ -117,7 +117,7 @@ public function get(array $arguments = array()) if (false == isset($this->_cache[$className])) { /** @var $instance Mage_Core_Model_Store_StorageInterface */ - $instance = $this->_objectManager->get($className, $arguments); + $instance = $this->_objectManager->create($className, $arguments); if (false === ($instance instanceof Mage_Core_Model_Store_StorageInterface)) { throw new InvalidArgumentException($className diff --git a/app/code/core/Mage/Core/Model/Store/StorageInterface.php b/app/code/Mage/Core/Model/Store/StorageInterface.php similarity index 100% rename from app/code/core/Mage/Core/Model/Store/StorageInterface.php rename to app/code/Mage/Core/Model/Store/StorageInterface.php diff --git a/app/code/core/Mage/Core/Model/StoreFactory.php b/app/code/Mage/Core/Model/StoreFactory.php similarity index 100% rename from app/code/core/Mage/Core/Model/StoreFactory.php rename to app/code/Mage/Core/Model/StoreFactory.php diff --git a/app/code/core/Mage/Core/Model/StoreManager.php b/app/code/Mage/Core/Model/StoreManager.php similarity index 100% rename from app/code/core/Mage/Core/Model/StoreManager.php rename to app/code/Mage/Core/Model/StoreManager.php diff --git a/app/code/core/Mage/Core/Model/StoreManagerInterface.php b/app/code/Mage/Core/Model/StoreManagerInterface.php similarity index 100% rename from app/code/core/Mage/Core/Model/StoreManagerInterface.php rename to app/code/Mage/Core/Model/StoreManagerInterface.php diff --git a/app/code/core/Mage/Core/Model/System/Store.php b/app/code/Mage/Core/Model/System/Store.php similarity index 100% rename from app/code/core/Mage/Core/Model/System/Store.php rename to app/code/Mage/Core/Model/System/Store.php diff --git a/app/code/Mage/Core/Model/Template.php b/app/code/Mage/Core/Model/Template.php new file mode 100644 index 0000000000000..8a6f7ce0a6410 --- /dev/null +++ b/app/code/Mage/Core/Model/Template.php @@ -0,0 +1,220 @@ + + */ +abstract class Mage_Core_Model_Template extends Mage_Core_Model_Abstract +{ + /** + * Types of template + */ + const TYPE_TEXT = 1; + const TYPE_HTML = 2; + + /** + * Default design area for emulation + */ + const DEFAULT_DESIGN_AREA = 'frontend'; + + /** + * Configuration of desing package for template + * + * @var Varien_Object + */ + protected $_designConfig; + + + /** + * Configuration of emulated desing package. + * + * @var Varien_Object|boolean + */ + protected $_emulatedDesignConfig = false; + + /** + * Initial environment information + * @see self::_applyDesignConfig() + * + * @var Varien_Object|null + */ + protected $_initialEnvironmentInfo = null; + + /** + * Package area + * + * @var string + */ + protected $_area; + + /** + * Store id + * + * @var int + */ + protected $_store; + + /** + * @param Mage_Core_Model_Context $context + * @param array $data + */ + public function __construct( + Mage_Core_Model_Context $context, + array $data = array() + ) { + $this->_area = isset($data['area']) ? $data['area'] : null; + $this->_store = isset($data['store']) ? $data['store'] : null; + parent::__construct($context, null, null, $data); + } + + /** + * Applying of design config + * + * @return Mage_Core_Model_Template + */ + protected function _applyDesignConfig() + { + $designConfig = $this->getDesignConfig(); + $store = $designConfig->getStore(); + $storeId = is_object($store) ? $store->getId() : $store; + $area = $designConfig->getArea(); + if (!is_null($storeId)) { + /** @var $appEmulation Mage_Core_Model_App_Emulation */ + $appEmulation = Mage::getSingleton('Mage_Core_Model_App_Emulation'); + $this->_initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId, $area); + } + return $this; + } + + /** + * Revert design settings to previous + * + * @return Mage_Core_Model_Template + */ + protected function _cancelDesignConfig() + { + if (!empty($this->_initialEnvironmentInfo)) { + $appEmulation = Mage::getSingleton('Mage_Core_Model_App_Emulation'); + $appEmulation->stopEnvironmentEmulation($this->_initialEnvironmentInfo); + $this->_initialEnvironmentInfo = null; + } + return $this; + } + + /** + * Get design configuration data + * + * @return Varien_Object + */ + public function getDesignConfig() + { + if ($this->_designConfig === null) { + if ($this->_area === null) { + $this->_area = Mage::getDesign()->getArea(); + } + if ($this->_store === null) { + $this->_store = Mage::app()->getStore()->getId(); + } + $this->_designConfig = new Varien_Object(array( + 'area' => $this->_area, + 'store' => $this->_store + )); + } + return $this->_designConfig; + } + + /** + * Initialize design information for template processing + * + * @param array $config + * @return Mage_Core_Model_Template + * @throws Magento_Exception + */ + public function setDesignConfig(array $config) + { + if (!isset($config['area']) || !isset($config['store'])) { + throw new Magento_Exception('Design config must have area and store.'); + } + $this->getDesignConfig()->setData($config); + return $this; + } + + /** + * Save current design config and replace with design config from specified store + * Event is not dispatched. + * + * @param int|string $storeId + * @param string $area + */ + public function emulateDesign($storeId, $area=self::DEFAULT_DESIGN_AREA) + { + if ($storeId) { + // save current design settings + $this->_emulatedDesignConfig = clone $this->getDesignConfig(); + if ($this->getDesignConfig()->getStore() != $storeId) { + $this->setDesignConfig(array('area' => $area, 'store' => $storeId)); + $this->_applyDesignConfig(); + } + } else { + $this->_emulatedDesignConfig = false; + } + } + + /** + * Revert to last design config, used before emulation + * + */ + public function revertDesign() + { + if ($this->_emulatedDesignConfig) { + $this->setDesignConfig($this->_emulatedDesignConfig->getData()); + $this->_cancelDesignConfig(); + $this->_emulatedDesignConfig = false; + } + } + + /** + * Return true if template type eq text + * + * @return boolean + */ + public function isPlain() + { + return $this->getType() == self::TYPE_TEXT; + } + + /** + * Getter for template type + * + * @return int|string + */ + abstract public function getType(); +} diff --git a/app/code/Mage/Core/Model/Theme.php b/app/code/Mage/Core/Model/Theme.php new file mode 100644 index 0000000000000..56d5328eaa8c8 --- /dev/null +++ b/app/code/Mage/Core/Model/Theme.php @@ -0,0 +1,684 @@ +_objectManager = $objectManager; + $this->_themeFactory = $themeFactory; + $this->_helper = $helper; + $this->_domainFactory = $domainFactory; + $this->_dirs = $dirs; + $this->_themeImage = $themeImage->setTheme($this); + } + + /** + * Theme model initialization + */ + protected function _construct() + { + $this->_init('Mage_Core_Model_Resource_Theme'); + } + + /** + * Get theme image model + * + * @return Mage_Core_Model_Theme_Image + */ + public function getThemeImage() + { + return $this->_themeImage; + } + + /** + * Themes collection loaded from file system configurations + * + * @return Mage_Core_Model_Theme_Collection + */ + public function getCollectionFromFilesystem() + { + return $this->_objectManager->get('Mage_Core_Model_Theme_Collection'); + } + + /** + * Validate theme data + * + * @return Mage_Core_Model_Theme + * @throws Mage_Core_Exception + */ + protected function _validate() + { + /** @var $validator Mage_Core_Model_Theme_Validator */ + $validator = $this->_objectManager->get('Mage_Core_Model_Theme_Validator'); + if (!$validator->validate($this)) { + $messages = $validator->getErrorMessages(); + throw new Mage_Core_Exception(implode(PHP_EOL, reset($messages))); + } + return $this; + } + + /** + * Check if theme is deletable + * + * @return bool + */ + public function isDeletable() + { + return $this->isEditable(); + } + + /** + * Check if theme is editable + * + * @return bool + */ + public function isEditable() + { + return self::TYPE_PHYSICAL != $this->getType(); + } + + /** + * Check if theme is virtual + * + * @return bool + */ + public function isVirtual() + { + return $this->getType() == self::TYPE_VIRTUAL; + } + + /** + * Check if theme is physical + * + * @return bool + */ + public function isPhysical() + { + return $this->getType() == self::TYPE_PHYSICAL; + } + + /** + * Check theme is visible in backend + * + * @return bool + */ + public function isVisible() + { + return in_array($this->getType(), array(self::TYPE_PHYSICAL, self::TYPE_VIRTUAL)); + } + + /** + * Check theme is existing in filesystem + * + * @return bool + */ + public function isPresentInFilesystem() + { + $collection = $this->getCollectionFromFilesystem()->addDefaultPattern('*')->getItems(); + return $this->getThemePath() && isset($collection[$this->getFullPath()]); + } + + /** + * Check is theme has child virtual themes + * + * @return bool + */ + public function hasChildThemes() + { + return (bool)$this->getCollection() + ->addTypeFilter(Mage_Core_Model_Theme::TYPE_VIRTUAL) + ->addFieldToFilter('parent_id', array('eq' => $this->getId())) + ->getSize(); + } + + /** + * Get directory where themes files are stored + * + * @return string + */ + public function getThemeFilesPath() + { + if ($this->getType() == self::TYPE_PHYSICAL) { + $physicalThemesDir = $this->_dirs->getDir(Mage_Core_Model_Dir::THEMES); + $dir = sprintf('%s/%s', $physicalThemesDir, $this->getFullPath()); + } else { + $dir = $this->getCustomizationPath(); + } + return $dir; + } + + /** + * Return path to customized theme files + * + * @return string|null + */ + public function getCustomizationPath() + { + $customPath = $this->getData('customization_path'); + if ($this->getId() && empty($customPath)) { + $customPath = $this->_dirs->getDir(Mage_Core_Model_Dir::MEDIA) + . Magento_Filesystem::DIRECTORY_SEPARATOR . 'theme_customization' + . Magento_Filesystem::DIRECTORY_SEPARATOR . $this->getId(); + $this->setData('customization_path', $customPath); + } + return $customPath; + } + + /** + * Retrieve collection of files that belong to a theme + * + * @return Mage_Core_Model_Resource_Theme_File_Collection + */ + public function getFiles() + { + if (!$this->_themeFiles) { + $this->_themeFiles = $this->_objectManager->create('Mage_Core_Model_Resource_Theme_File_Collection'); + $this->_themeFiles->addThemeFilter($this); + } + return $this->_themeFiles; + } + + /** + * Retrieve theme instance representing the latest changes to a theme + * + * @return Mage_Core_Model_Theme|null + */ + public function getStagingVersion() + { + if ($this->getId()) { + $collection = $this->getCollection(); + $collection->addFieldToFilter('parent_id', $this->getId()); + $collection->addFieldToFilter('type', self::TYPE_STAGING); + $stagingTheme = $collection->getFirstItem(); + if ($stagingTheme->getId()) { + return $stagingTheme; + } + } + return null; + } + + /** + * Return theme customization collection by type + * + * @param string $type + * @return Varien_Data_Collection + * @throws InvalidArgumentException + */ + public function getCustomizationData($type) + { + if (!isset($this->_themeCustomizations[$type])) { + throw new InvalidArgumentException('Customization is not present'); + } + return $this->_themeCustomizations[$type]->getCollectionByTheme($this); + } + + /** + * Add theme customization + * + * @param Mage_Core_Model_Theme_Customization_CustomizationInterface $customization + * @return Mage_Core_Model_Theme + */ + public function setCustomization(Mage_Core_Model_Theme_Customization_CustomizationInterface $customization) + { + $this->_themeCustomizations[$customization->getType()] = $customization; + return $this; + } + + /** + * Save all theme customization object + * + * @return Mage_Core_Model_Theme + */ + public function saveThemeCustomization() + { + /** @var $file Mage_Core_Model_Theme_Customization_CustomizationInterface */ + foreach ($this->_themeCustomizations as $file) { + $file->saveData($this); + } + return $this; + } + + /** + * Check if theme object data was changed. + * + * @return bool + */ + public function hasDataChanges() + { + return parent::hasDataChanges() || $this->isCustomized(); + } + + /** + * Check whether present customization objects + * + * @return bool + */ + public function isCustomized() + { + return !empty($this->_themeCustomizations); + } + + /** + * Update all relations after deleting theme + * + * @return Mage_Core_Model_Theme + */ + protected function _afterSave() + { + $this->saveThemeCustomization(); + $this->_checkAssignedThemeChanged(); + return parent::_afterSave(); + } + + /** + * Before theme save + * + * @return Mage_Core_Model_Theme + */ + protected function _beforeSave() + { + $this->_validate(); + return parent::_beforeSave(); + } + + /** + * Processing theme before deleting data + * + * @return Mage_Core_Model_Theme + * @throws Mage_Core_Exception + */ + protected function _beforeDelete() + { + if (!$this->isDeletable()) { + throw new Mage_Core_Exception($this->_helper->__('Theme isn\'t deletable.')); + } + $this->getThemeImage()->removePreviewImage(); + return parent::_beforeDelete(); + } + + /** + * Check is theme assigned to store and dispatch event if that was changed + * + * @return Mage_Core_Model_Theme + */ + protected function _checkAssignedThemeChanged() + { + /** @var $service Mage_Core_Model_Theme_Service */ + $service = $this->_objectManager->get('Mage_Core_Model_Theme_Service'); + if ($service->isThemeAssignedToStore($this)) { + $this->_eventDispatcher->dispatch('assigned_theme_changed', array('theme' => $this)); + } + return $this; + } + + /** + * Update all relations after deleting theme + * + * @return Mage_Core_Model_Theme + */ + protected function _afterDelete() + { + $this->getCollection()->updateChildRelations($this); + return parent::_afterDelete(); + } + + /** + * {@inheritdoc} + */ + public function getParentTheme() + { + if ($this->hasData('parent_theme')) { + return $this->getData('parent_theme'); + } + + $theme = null; + if ($this->getParentId()) { + $theme = $this->_themeFactory->create()->load($this->getParentId()); + } + $this->setParentTheme($theme); + return $theme; + } + + /** + * Save data from form + * + * @param array $themeData + * @return Mage_Core_Model_Theme + */ + public function saveFormData($themeData) + { + if (isset($themeData['theme_id'])) { + $this->load($themeData['theme_id']); + if ($this->getId() && !$this->isEditable()) { + Mage::throwException($this->_helper->__('Theme isn\'t editable.')); + } + } + $previewImageData = array(); + if (isset($themeData['preview_image'])) { + $previewImageData = $themeData['preview_image']; + unset($themeData['preview_image']); + } + $this->addData($themeData); + + if (isset($previewImageData['delete'])) { + $this->getThemeImage()->removePreviewImage(); + } + + $this->getThemeImage()->uploadPreviewImage('preview_image'); + $this->setType(self::TYPE_VIRTUAL)->setArea(Mage_Core_Model_App_Area::AREA_FRONTEND)->save(); + return $this; + } + + /** + * Return cache key for current theme + * + * @return string + */ + public function getCacheKey() + { + if (!$this->getId()) { + return self::CACHE_TAG_NO_THEME . $this->getThemePath(); + } + + return $this->getId() . $this->getThemePath(); + } + + /** + * {@inheritdoc} + */ + public function getArea() + { + return $this->getData('area'); + } + + /** + * {@inheritdoc} + */ + public function getThemePath() + { + return $this->getData('theme_path'); + } + + /** + * Retrieve theme full path which is used to distinguish themes if they are not in DB yet + * + * Alternative id looks like "//". + * Used as id in file-system theme collection + * + * @return string + */ + public function getFullPath() + { + return $this->getArea() . self::PATH_SEPARATOR . $this->getThemePath(); + } + + /** + * Check if the theme is compatible with Magento version + * + * @return bool + */ + public function isThemeCompatible() + { + $magentoVersion = Mage::getVersion(); + if (version_compare($magentoVersion, $this->getMagentoVersionFrom(), '>=')) { + if ($this->getMagentoVersionTo() == '*' + || version_compare($magentoVersion, $this->getMagentoVersionFrom(), '<=') + ) { + return true; + } + } + return false; + } + + /** + * Check if the theme is compatible with Magento version and mark theme label if not compatible + * + * @return Mage_Core_Model_Theme + */ + public function checkThemeCompatible() + { + if (!$this->isThemeCompatible()) { + $this->setThemeTitle($this->_helper->__('%s (incompatible version)', $this->getThemeTitle())); + } + return $this; + } + + /** + * Return labels collection array + * + * @param bool|string $label add empty values to result with specific label + * @return array + */ + public function getLabelsCollection($label = false) + { + if (!$this->_labelsCollection) { + /** @var $themeCollection Mage_Core_Model_Resource_Theme_Collection */ + $themeCollection = $this->getCollection(); + $themeCollection->setOrder('theme_title', Varien_Data_Collection::SORT_ORDER_ASC) + ->filterVisibleThemes() + ->addAreaFilter(Mage_Core_Model_App_Area::AREA_FRONTEND) + ->walk('checkThemeCompatible'); + $this->_labelsCollection = $themeCollection->toOptionArray(); + } + $options = $this->_labelsCollection; + if ($label) { + array_unshift($options, array('value' => '', 'label' => $label)); + } + return $options; + } + + /** + * Return labels collection for backend system configuration with empty value "No Theme" + * + * @return array + */ + public function getLabelsCollectionForSystemConfiguration() + { + return $this->getLabelsCollection($this->_helper->__('-- No Theme --')); + } + + /** + * Clear data for clone + */ + public function __clone() + { + $this->unsetData()->setOrigData(); + } + + /** + * Get one of theme domain models + * + * @param int|null $type + * @return Mage_Core_Model_Theme_Domain_Physical|Mage_Core_Model_Theme_Domain_Virtual| + * Mage_Core_Model_Theme_Domain_Staging + * @throws Mage_Core_Exception + */ + public function getDomainModel($type = null) + { + if ($type !== null && $type != $this->getType()) { + throw new Mage_Core_Exception($this->_helper->__( + 'Invalid domain model "%s" requested for theme "%s" of type "%s"', + $type, + $this->getId(), + $this->getType() + )); + } + + return $this->_domainFactory->create($this); + } + + /** + * Get path to custom view configuration file + * + * @return string + */ + public function getCustomViewConfigPath() + { + $config = $this->getCustomizationPath(); + if (!empty($config)) { + $config .= Magento_Filesystem::DIRECTORY_SEPARATOR . self::FILENAME_VIEW_CONFIG; + } + return $config; + } +} diff --git a/app/code/Mage/Core/Model/Theme/Collection.php b/app/code/Mage/Core/Model/Theme/Collection.php new file mode 100644 index 0000000000000..b6fd874dcf839 --- /dev/null +++ b/app/code/Mage/Core/Model/Theme/Collection.php @@ -0,0 +1,355 @@ +_filesystem = $filesystem; + $this->_objectManager = $objectManager; + $this->setBaseDir($dirs->getDir(Mage_Core_Model_Dir::THEMES)); + parent::__construct(); + } + + /** + * Retrieve collection empty item + * + * @return Varien_Object|Mage_Core_Model_ThemeInterface + */ + public function getNewEmptyItem() + { + return $this->_objectManager->create($this->_itemObjectClass); + } + + /** + * Set base directory path of design + * + * @param string $path + * @return Mage_Core_Model_Theme_Collection + */ + public function setBaseDir($path) + { + if ($this->isLoaded() && $this->_baseDir) { + $this->clearTargetPatterns()->clear(); + } + $this->_baseDir = rtrim($path, DIRECTORY_SEPARATOR); + return $this; + } + + /** + * Get base directory path + * + * @return string + */ + public function getBaseDir() + { + return $this->_baseDir; + } + + /** + * Add default pattern to themes configuration + * + * @param string $area + * @return Mage_Core_Model_Theme_Collection + */ + public function addDefaultPattern($area = Mage_Core_Model_App_Area::AREA_FRONTEND) + { + $this->addTargetPattern(implode(DIRECTORY_SEPARATOR, array($area, '*', '*', 'theme.xml'))); + return $this; + } + + /** + * Target directory setter. Adds directory to be scanned + * + * @param string $relativeTarget + * @return Mage_Core_Model_Theme_Collection + */ + public function addTargetPattern($relativeTarget) + { + if ($this->isLoaded()) { + $this->clear(); + } + $this->_targetDirs[] = $relativeTarget; + return $this; + } + + /** + * Clear target patterns + * + * @return Mage_Core_Model_Theme_Collection + */ + public function clearTargetPatterns() + { + $this->_targetDirs = array(); + return $this; + } + + /** + * Return target dir for themes with theme configuration file + * + * @throws Magento_Exception + * @return array|string + */ + public function getTargetPatterns() + { + if (empty($this->_targetDirs)) { + throw new Magento_Exception('Please specify at least one target pattern to theme config file.'); + } + return $this->_targetDirs; + } + + /** + * Fill collection with theme model loaded from filesystem + * + * @param bool $printQuery + * @param bool $logQuery + * @return Mage_Core_Model_Theme_Collection + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function loadData($printQuery = false, $logQuery = false) + { + if ($this->isLoaded()) { + return $this; + } + + $pathsToThemeConfig = array(); + foreach ($this->getTargetPatterns() as $directoryPath) { + $pathsToThemeConfig = array_merge( + $pathsToThemeConfig, + str_replace('/', DIRECTORY_SEPARATOR, + $this->_filesystem->searchKeys($this->getBaseDir(), $directoryPath) + ) + ); + } + + $this->_loadFromFilesystem($pathsToThemeConfig) + ->clearTargetPatterns() + ->_updateRelations() + ->_renderFilters() + ->_clearFilters(); + + return $this; + } + + /** + * Set all parent themes + * + * @return Mage_Core_Model_Theme_Collection + */ + protected function _updateRelations() + { + $themeItems = $this->getItems(); + /** @var $theme Varien_Object|Mage_Core_Model_ThemeInterface */ + foreach ($themeItems as $theme) { + $parentThemePath = $theme->getParentThemePath(); + if ($parentThemePath) { + $id = $theme->getArea() . Mage_Core_Model_Theme::PATH_SEPARATOR . $parentThemePath; + if (isset($themeItems[$id])) { + $theme->setParentTheme($themeItems[$id]); + } + } + } + return $this; + } + + /** + * Load themes collection from file system by file list + * + * @param array $themeConfigPaths + * @return Mage_Core_Model_Theme_Collection + */ + protected function _loadFromFilesystem(array $themeConfigPaths) + { + foreach ($themeConfigPaths as $themeConfigPath) { + $theme = $this->getNewEmptyItem() + ->addData($this->_preparePathData($themeConfigPath)) + ->addData($this->_prepareConfigurationData($themeConfigPath)); + $this->addItem($theme); + } + $this->_setIsLoaded(); + + return $this; + } + + /** + * Return default path related data + * + * @param string $configPath + * @return array + */ + protected function _preparePathData($configPath) + { + $themeDirectory = dirname($configPath); + $fullPath = trim(substr($themeDirectory, strlen($this->getBaseDir())), DIRECTORY_SEPARATOR); + $pathPieces = explode(DIRECTORY_SEPARATOR, $fullPath); + $area = array_shift($pathPieces); + $themePath = implode(Mage_Core_Model_Theme::PATH_SEPARATOR, $pathPieces); + return array('area' => $area, 'theme_path' => $themePath, 'theme_directory' => $themeDirectory); + } + + /** + * Return default configuration data + * + * @param string $configPath + * @return array + */ + public function _prepareConfigurationData($configPath) + { + $themeConfig = $this->_getConfigModel(array($configPath)); + + $packageCodes = $themeConfig->getPackageCodes(); + $packageCode = reset($packageCodes); + + $themeCodes = $themeConfig->getPackageThemeCodes($packageCode); + $themeCode = reset($themeCodes); + + $themeVersions = $themeConfig->getCompatibleVersions($packageCode, $themeCode); + $media = $themeConfig->getMedia($packageCode, $themeCode); + $parentTheme = $themeConfig->getParentTheme($packageCode, $themeCode); + + return array( + 'parent_id' => null, + 'theme_version' => $themeConfig->getThemeVersion($packageCode, $themeCode), + 'theme_title' => $themeConfig->getThemeTitle($packageCode, $themeCode), + 'preview_image' => $media['preview_image'] ? $media['preview_image'] : null, + 'magento_version_from' => $themeVersions['from'], + 'magento_version_to' => $themeVersions['to'], + 'is_featured' => $themeConfig->isFeatured($packageCode, $themeCode), + 'parent_theme_path' => $parentTheme ? implode('/', $parentTheme) : null + ); + } + + /** + * Apply set field filters + * + * @return Mage_Core_Model_Theme_Collection + */ + protected function _renderFilters() + { + $filters = $this->getFilter(array()); + /** @var $theme Mage_Core_Model_Theme */ + foreach ($this->getItems() as $itemKey => $theme) { + $removeItem = false; + foreach ($filters as $filter) { + if ($filter['type'] == 'and' && $theme->getDataUsingMethod($filter['field']) != $filter['value']) { + $removeItem = true; + } + } + if ($removeItem) { + $this->removeItemByKey($itemKey); + } + } + return $this; + } + + /** + * Clear all added filters + * + * @return Mage_Core_Model_Theme_Collection + */ + protected function _clearFilters() + { + $this->_filters = array(); + return $this; + } + + /** + * Return configuration model for themes + * + * @param array $configPaths + * @return Magento_Config_Theme + */ + protected function _getConfigModel(array $configPaths) + { + return new Magento_Config_Theme($configPaths); + } + + /** + * Retrieve item id + * + * @param Mage_Core_Model_Theme|Varien_Object $item + * @return string + */ + protected function _getItemId(Varien_Object $item) + { + return $item->getFullPath(); + } + + /** + * Return array for select field + * + * @param bool $addEmptyField + * @return array + */ + public function toOptionArray($addEmptyField = false) + { + $optionArray = $addEmptyField ? array('' => '') : array(); + return $optionArray + $this->_toOptionArray('theme_id', 'theme_title'); + } +} diff --git a/app/code/Mage/Core/Model/Theme/CopyService.php b/app/code/Mage/Core/Model/Theme/CopyService.php new file mode 100644 index 0000000000000..1fdb243fa7afc --- /dev/null +++ b/app/code/Mage/Core/Model/Theme/CopyService.php @@ -0,0 +1,125 @@ +_objectManager = $objectManager; + $this->_filesystem = $filesystem; + } + + /** + * Copy customizations from one theme to another + * + * @param Mage_Core_Model_Theme $source + * @param Mage_Core_Model_Theme $target + */ + public function copy(Mage_Core_Model_Theme $source, Mage_Core_Model_Theme $target) + { + $this->_copyDatabaseCustomization($source, $target); + $this->_copyFilesystemCustomization($source, $target); + } + + /** + * Copy customizations stored in a database from one theme to another, overriding existing data + * + * @param Mage_Core_Model_Theme $source + * @param Mage_Core_Model_Theme $target + */ + protected function _copyDatabaseCustomization(Mage_Core_Model_Theme $source, Mage_Core_Model_Theme $target) + { + /** @var $themeFile Mage_Core_Model_Theme_File */ + foreach ($target->getFiles() as $themeFile) { + $themeFile->delete(); + } + /** @var $newFile Mage_Core_Model_Theme_File */ + foreach ($source->getFiles() as $themeFile) { + /** @var $newThemeFile Mage_Core_Model_Theme_File */ + $newThemeFile = $this->_objectManager->create('Mage_Core_Model_Theme_File'); + $newThemeFile->setData(array( + 'theme_id' => $target->getId(), + 'file_path' => $themeFile->getFilePath(), + 'file_type' => $themeFile->getFileType(), + 'content' => $themeFile->getContent(), + 'sort_order' => $themeFile->getData('sort_order'), + )); + $newThemeFile->save(); + } + } + + /** + * Copy customizations stored in a file system from one theme to another, overriding existing data + * + * @param $source + * @param $target + */ + protected function _copyFilesystemCustomization(Mage_Core_Model_Theme $source, Mage_Core_Model_Theme $target) + { + $sourcePath = $source->getCustomizationPath(); + $targetPath = $target->getCustomizationPath(); + if ($sourcePath && $targetPath && $this->_filesystem->isDirectory($sourcePath)) { + $this->_copyFilesRecursively($sourcePath, $sourcePath, $targetPath); + } + } + + /** + * Copies all files in a directory recursively + * + * @param string $baseDir + * @param string $sourceDir + * @param string $targetDir + */ + protected function _copyFilesRecursively($baseDir, $sourceDir, $targetDir) + { + $this->_filesystem->setIsAllowCreateDirectories(true); + foreach ($this->_filesystem->searchKeys($sourceDir, '*') as $path) { + if ($this->_filesystem->isDirectory($path)) { + $this->_copyFilesRecursively($baseDir, $path, $targetDir); + } else { + $filePath = substr($path, strlen($baseDir) + 1); + $this->_filesystem->copy($path, $targetDir . '/' . $filePath, $baseDir, $targetDir); + } + } + } +} diff --git a/app/code/core/Mage/Core/Model/Theme/Customization/CustomizationInterface.php b/app/code/Mage/Core/Model/Theme/Customization/CustomizationInterface.php similarity index 100% rename from app/code/core/Mage/Core/Model/Theme/Customization/CustomizationInterface.php rename to app/code/Mage/Core/Model/Theme/Customization/CustomizationInterface.php diff --git a/app/code/core/Mage/Core/Model/Theme/Customization/CustomizedInterface.php b/app/code/Mage/Core/Model/Theme/Customization/CustomizedInterface.php similarity index 100% rename from app/code/core/Mage/Core/Model/Theme/Customization/CustomizedInterface.php rename to app/code/Mage/Core/Model/Theme/Customization/CustomizedInterface.php diff --git a/app/code/Mage/Core/Model/Theme/Customization/Files/Css.php b/app/code/Mage/Core/Model/Theme/Customization/Files/Css.php new file mode 100644 index 0000000000000..490c587230ea2 --- /dev/null +++ b/app/code/Mage/Core/Model/Theme/Customization/Files/Css.php @@ -0,0 +1,130 @@ + 'css/custom.css', + self::QUICK_STYLE_CSS => 'css/quick_style.css' + ); + + /** + * Return css file customization type + * + * @return string + */ + public function getType() + { + return self::TYPE; + } + + /** + * Return file type + * + * @return string + */ + protected function _getFileType() + { + return Mage_Core_Model_Theme_File::TYPE_CSS; + } + + /** + * Get CSS file name by type + * + * @param string $type + * @return string + * @throws InvalidArgumentException + */ + public function getFilePathByType($type) + { + if (!array_key_exists($type, $this->_cssFiles)) { + throw new InvalidArgumentException('Invalid CSS file type'); + } + return $this->_cssFiles[$type]; + } + + /** + * Save data + * + * @param $theme Mage_Core_Model_Theme + * @return Mage_Core_Model_Theme_Customization_Files_Css + */ + protected function _save($theme) + { + foreach ($this->_dataForSave as $type => $cssFileContent) { + /** @var $cssFiles Mage_Core_Model_Theme_File */ + $cssFile = $this->getCollectionByTheme($theme, $type)->getFirstItem(); + + $cssFile->addData(array( + 'theme_id' => $theme->getId(), + 'file_path' => $this->getFilePathByType($type), + 'file_type' => $this->_getFileType(), + 'content' => $cssFileContent + ))->save(); + } + + return $this; + } + + /** + * Get theme collection + * + * @param Mage_Core_Model_Theme_Customization_CustomizedInterface $theme + * @param null|string $type + * @return Mage_Core_Model_Resource_Theme_File_Collection + */ + public function getCollectionByTheme( + Mage_Core_Model_Theme_Customization_CustomizedInterface $theme, + $type = Mage_Core_Model_Theme_Customization_Files_Css::CUSTOM_CSS + ) { + return (null === $type) + ? parent::getCollectionByTheme($theme) + : parent::getCollectionByTheme($theme)->addFilter('file_path', $this->getFilePathByType($type)); + } +} diff --git a/app/code/core/Mage/Core/Model/Theme/Customization/Files/FilesAbstract.php b/app/code/Mage/Core/Model/Theme/Customization/Files/FilesAbstract.php similarity index 91% rename from app/code/core/Mage/Core/Model/Theme/Customization/Files/FilesAbstract.php rename to app/code/Mage/Core/Model/Theme/Customization/Files/FilesAbstract.php index c0650eb61bd08..a45899dba8433 100644 --- a/app/code/core/Mage/Core/Model/Theme/Customization/Files/FilesAbstract.php +++ b/app/code/Mage/Core/Model/Theme/Customization/Files/FilesAbstract.php @@ -31,7 +31,7 @@ abstract class Mage_Core_Model_Theme_Customization_Files_FilesAbstract extends V implements Mage_Core_Model_Theme_Customization_CustomizationInterface { /** - * @var Mage_Core_Model_Theme_Files + * @var Mage_Core_Model_Theme_File */ protected $_themeFiles; @@ -43,9 +43,9 @@ abstract class Mage_Core_Model_Theme_Customization_Files_FilesAbstract extends V protected $_dataForSave; /** - * @param Mage_Core_Model_Theme_Files $themeFiles + * @param Mage_Core_Model_Theme_File $themeFiles */ - public function __construct(Mage_Core_Model_Theme_Files $themeFiles) + public function __construct(Mage_Core_Model_Theme_File $themeFiles) { $this->_themeFiles = $themeFiles; } @@ -80,11 +80,11 @@ public function saveData(Mage_Core_Model_Theme_Customization_CustomizedInterface * Save data * * @param Mage_Core_Model_Theme_Customization_CustomizedInterface $theme - * @return Mage_Core_Model_Resource_Theme_Files_Collection + * @return Mage_Core_Model_Resource_Theme_File_Collection */ public function getCollectionByTheme(Mage_Core_Model_Theme_Customization_CustomizedInterface $theme) { - /** @var $filesCollection Mage_Core_Model_Resource_Theme_Files_Collection */ + /** @var $filesCollection Mage_Core_Model_Resource_Theme_File_Collection */ $filesCollection = $this->_themeFiles->getCollection()->addFilter('theme_id', $theme->getId()) ->addFilter('file_type', $this->_getFileType()); diff --git a/app/code/Mage/Core/Model/Theme/Customization/Files/Js.php b/app/code/Mage/Core/Model/Theme/Customization/Files/Js.php new file mode 100644 index 0000000000000..7821eaee705b9 --- /dev/null +++ b/app/code/Mage/Core/Model/Theme/Customization/Files/Js.php @@ -0,0 +1,252 @@ +_dataForDelete = $data; + return $this; + } + + /** + * Save data + * + * @param Mage_Core_Model_Theme_Customization_CustomizedInterface $theme + * @return Mage_Core_Model_Theme_Customization_Files_FilesAbstract + */ + public function saveData(Mage_Core_Model_Theme_Customization_CustomizedInterface $theme) + { + if (null !== $this->_dataForDelete) { + $this->_delete($theme); + } + parent::saveData($theme); + if ($this->hasJsOrderData()) { + $this->_reorder($theme, $this->getJsOrderData()); + } + + return $this; + } + + /** + * Delete js files from theme + * + * @param $theme Mage_Core_Model_Theme + * @return Mage_Core_Model_Theme_Customization_Files_Js + */ + protected function _delete(Mage_Core_Model_Theme $theme) + { + /** @var $jsCollection Mage_Core_Model_Resource_Theme_File_Collection */ + $jsCollection = $this->getCollectionByTheme($theme); + /** @var $jsFile Mage_Core_Model_Theme_File */ + foreach ($jsCollection as $jsFile) { + if (in_array($jsFile->getId(), $this->_dataForDelete)) { + $jsFile->delete(); + } + } + + return $this; + } + + /** + * Remove temporary files + * + * @param Mage_Core_Model_Theme $theme + * @return Mage_Core_Model_Theme_Customization_Files_Js + */ + public function removeTemporaryFiles($theme) + { + /** @var $jsFiles Mage_Core_Model_Resource_Theme_File_Collection */ + $jsFiles = $this->_themeFiles->getCollection() + ->addFilter('is_temporary', true) + ->addFilter('theme_id', $theme->getId()) + ->addFilter('file_type', Mage_Core_Model_Theme_File::TYPE_JS); + + /** @var $file Mage_Core_Model_Theme_File */ + foreach ($jsFiles as $file) { + $file->delete(); + } + + return $this; + } + + /** + * Save form data + * + * @param Mage_Core_Model_Theme $theme + * @return Mage_Core_Model_Theme_Customization_Files_Js + */ + protected function _save($theme) + { + $themeFile = $this->_themeFiles; + $themeJsFiles = (array)$this->_dataForSave; + foreach ($themeJsFiles as $fileId) { + $themeFile->load($fileId); + if ($themeFile->getId() && ($themeFile->getThemeId() == $theme->getId())) { + $themeFile->setIsTemporary(false)->save(); + } + } + return $this; + } + + /** + * Save js file + * + * @param Mage_Core_Model_Theme $theme + * @param array $file + * @param bool $temporary + * @return Mage_Core_Model_Theme_File + */ + public function saveJsFile($theme, $file, $temporary = true) + { + $newFileModel = $this->_themeFiles->unsetData(); + return $newFileModel->addData(array( + 'theme_id' => $theme->getId(), + 'file_path' => 'js/' . $this->_prepareFileName($theme, $file['name']), + 'file_type' => Mage_Core_Model_Theme_File::TYPE_JS, + 'content' => $file['content'], + 'is_temporary' => $temporary + ))->save(); + } + + /** + * Prepare file name + * + * @param Mage_Core_Model_Theme $theme + * @param string $newFileName + * @return string + */ + protected function _prepareFileName($theme, $newFileName) + { + $fileInfo = pathinfo($newFileName); + $index = 1; + while ($this->_getThemeFileByName($theme, $newFileName)->getId()) { + $newFileName = $fileInfo['filename'] . '_' . $index . '.' . $fileInfo['extension']; + $index++; + } + + return $newFileName; + } + + /** + * Get theme js files by name + * + * @param Mage_Core_Model_Theme $theme + * @param string $fileName + * @return Mage_Core_Model_Resource_Theme_File_Collection + */ + protected function _getThemeFileByName($theme, $fileName) + { + /** @var $jsFile Mage_Core_Model_Resource_Theme_File_Collection */ + $jsFile = parent::getCollectionByTheme($theme) + ->addFieldToFilter('file_path', array('like' => "%{$fileName}")) + ->getFirstItem(); + + return $jsFile; + } + + /** + * Save data + * + * @param Mage_Core_Model_Theme_Customization_CustomizedInterface $theme + * @param string $order + * @return Mage_Core_Model_Resource_Theme_File_Collection|Mage_Core_Model_Resource_Db_Collection_Abstract + */ + public function getCollectionByTheme( + Mage_Core_Model_Theme_Customization_CustomizedInterface $theme, + $order = Varien_Data_Collection::SORT_ORDER_ASC + ) { + return parent::getCollectionByTheme($theme)->setDefaultOrder($order); + } + + /** + * Reorder theme JS files + * + * @param Mage_Core_Model_Theme $theme + * @param array $orderData + * @return Mage_Core_Model_Theme_Customization_Files_Js + */ + public function _reorder(Mage_Core_Model_Theme $theme, $orderData) + { + /** @var $collection Mage_Core_Model_Resource_Theme_File_Collection */ + $collection = $this->getCollectionByTheme($theme); + /** @var $file Mage_Core_Model_Theme_File */ + foreach ($collection as $file) { + $position = array_search($file->getId(), $orderData); + if ($position === false) { + //uploaded files will be on top + $file->setSortOrder(0); + } + $file->setSortOrder($position + 1); + } + $collection->save(); + + return $this; + } +} diff --git a/app/code/Mage/Core/Model/Theme/Domain/Factory.php b/app/code/Mage/Core/Model/Theme/Domain/Factory.php new file mode 100644 index 0000000000000..25d783c6ac9af --- /dev/null +++ b/app/code/Mage/Core/Model/Theme/Domain/Factory.php @@ -0,0 +1,70 @@ + 'Mage_Core_Model_Theme_Domain_Physical', + Mage_Core_Model_Theme::TYPE_VIRTUAL => 'Mage_Core_Model_Theme_Domain_Virtual', + Mage_Core_Model_Theme::TYPE_STAGING => 'Mage_Core_Model_Theme_Domain_Staging', + ); + + /** + * @param Magento_ObjectManager $objectManager + */ + public function __construct(Magento_ObjectManager $objectManager) + { + $this->_objectManager = $objectManager; + } + + /** + * Create new config object + * + * @param Mage_Core_Model_Theme $theme + * @return Mage_Core_Model_Theme_Domain_Physical|Mage_Core_Model_Theme_Domain_Virtual| + * Mage_Core_Model_Theme_Domain_Staging + * @throws Mage_Core_Exception + */ + public function create(Mage_Core_Model_Theme $theme) + { + if (!isset($this->_types[$theme->getType()])) { + throw new Mage_Core_Exception(sprintf('Invalid type of theme domain model "%s"', $theme->getType())); + } + $class = $this->_types[$theme->getType()]; + return $this->_objectManager->create($class, array('theme' => $theme)); + } +} diff --git a/app/code/Mage/Core/Model/Theme/Domain/Physical.php b/app/code/Mage/Core/Model/Theme/Domain/Physical.php new file mode 100644 index 0000000000000..4dd799e8429bb --- /dev/null +++ b/app/code/Mage/Core/Model/Theme/Domain/Physical.php @@ -0,0 +1,46 @@ +_theme = $theme; + } +} diff --git a/app/code/Mage/Core/Model/Theme/Domain/Staging.php b/app/code/Mage/Core/Model/Theme/Domain/Staging.php new file mode 100644 index 0000000000000..d97bf29274c12 --- /dev/null +++ b/app/code/Mage/Core/Model/Theme/Domain/Staging.php @@ -0,0 +1,66 @@ +_theme = $theme; + $this->_themeCopyService = $themeCopyService; + } + + /** + * Copy changes from 'staging' theme + * + * @return Mage_Core_Model_Theme_Domain_Virtual + */ + public function updateFromStagingTheme() + { + $this->_themeCopyService->copy($this->_theme, $this->_theme->getParentTheme()); + return $this; + } +} diff --git a/app/code/Mage/Core/Model/Theme/Domain/Virtual.php b/app/code/Mage/Core/Model/Theme/Domain/Virtual.php new file mode 100644 index 0000000000000..f29fe6b874db0 --- /dev/null +++ b/app/code/Mage/Core/Model/Theme/Domain/Virtual.php @@ -0,0 +1,131 @@ +_theme = $theme; + $this->_themeFactory = $themeFactory; + $this->_themeCopyService = $themeCopyService; + $this->_service = $service; + } + + /** + * Get 'staging' theme + * + * @return Mage_Core_Model_Theme + */ + public function getStagingTheme() + { + if (!$this->_stagingTheme) { + $this->_stagingTheme = $this->_theme->getStagingVersion(); + if (!$this->_stagingTheme) { + $this->_stagingTheme = $this->_createStagingTheme(); + $this->_themeCopyService->copy($this->_theme, $this->_stagingTheme); + } + } + return $this->_stagingTheme; + } + + /** + * Check if theme is assigned to ANY store + * + * @return bool + */ + public function isAssigned() + { + return $this->_service->isThemeAssignedToStore($this->_theme); + } + + /** + * Create 'staging' theme associated with current 'virtual' theme + * + * @return Mage_Core_Model_Theme + */ + protected function _createStagingTheme() + { + $stagingTheme = $this->_themeFactory->create(); + $stagingTheme->setData(array( + 'parent_id' => $this->_theme->getId(), + 'theme_path' => null, + 'theme_version' => $this->_theme->getThemeVersion(), + 'theme_title' => sprintf('%s - Staging', $this->_theme->getThemeTitle()), + 'preview_image' => $this->_theme->getPreviewImage(), + 'magento_version_from' => $this->_theme->getMagentoVersionFrom(), + 'magento_version_to' => $this->_theme->getMagentoVersionTo(), + 'is_featured' => $this->_theme->getIsFeatured(), + 'area' => $this->_theme->getArea(), + 'type' => Mage_Core_Model_Theme::TYPE_STAGING + )); + $stagingTheme->save(); + return $stagingTheme; + } +} diff --git a/app/code/Mage/Core/Model/Theme/Factory.php b/app/code/Mage/Core/Model/Theme/Factory.php new file mode 100644 index 0000000000000..df14a76d90d0b --- /dev/null +++ b/app/code/Mage/Core/Model/Theme/Factory.php @@ -0,0 +1,57 @@ +_objectManager = $objectManager; + } + + /** + * Create new instance + * + * @param array $data + * @return Mage_Core_Model_Theme + */ + public function create(array $data = array()) + { + return $this->_objectManager->create('Mage_Core_Model_Theme', $data); + } +} diff --git a/app/code/Mage/Core/Model/Theme/File.php b/app/code/Mage/Core/Model/Theme/File.php new file mode 100644 index 0000000000000..89652cdfcf4ee --- /dev/null +++ b/app/code/Mage/Core/Model/Theme/File.php @@ -0,0 +1,221 @@ +_ioFile = $ioFile; + $this->_objectManager = $objectManager; + } + + /** + * Theme files model initialization + */ + protected function _construct() + { + $this->_init('Mage_Core_Model_Resource_Theme_File'); + } + + /** + * Get theme model + * + * @return Mage_Core_Model_Theme + * @throws Magento_Exception + */ + public function getTheme() + { + if ($this->hasData('theme')) { + return $this->getData('theme'); + } + + /** @var $theme Mage_Core_Model_Theme */ + $theme = $this->_objectManager->create('Mage_Core_Model_Theme'); + $themeId = $this->getData('theme_id'); + if ($themeId && $theme->load($themeId)->getId()) { + $this->setData('theme', $theme); + } else { + throw new Magento_Exception('Theme id should be set'); + } + return $theme; + } + + /** + * Create/update/delete file after save + * Delete file if only file is empty + * + * @return Mage_Core_Model_Theme_File + */ + protected function _afterSave() + { + if ($this->hasContent()) { + $this->_saveFile(); + } else { + $this->delete(); + } + return parent::_afterSave(); + } + + /** + * Delete file form file system after delete form db + * + * @return Mage_Core_Model_Theme_File + */ + protected function _afterDelete() + { + $this->_deleteFile(); + return parent::_afterDelete(); + } + + /** + * Create/update file in file system + * + * @return bool|int + */ + protected function _saveFile() + { + $filePath = $this->getFullPath(); + $this->_ioFile->checkAndCreateFolder(dirname($filePath)); + $result = $this->_ioFile->write($filePath, $this->getContent()); + return $result; + } + + /** + * Delete file form file system + * + * @return bool + */ + protected function _deleteFile() + { + $result = $this->_ioFile->rm($this->getFullPath()); + return $result; + } + + /** + * Check if file has content + * + * @return bool + */ + public function hasContent() + { + return (bool)trim($this->getContent()); + } + + /** + * Get file name of customization file + * + * @return string + */ + public function getFileName() + { + return basename($this->getFilePath()); + } + + /** + * Return absolute path to file of customization + * + * @return null|string + */ + public function getFullPath() + { + $path = null; + if ($this->getId()) { + $path = $this->getTheme()->getCustomizationPath() . DIRECTORY_SEPARATOR . $this->getFilePath(); + $path = str_replace('/', DIRECTORY_SEPARATOR, $path); + } + return $path; + } + + /** + * Retrieve a page asset representing a theme file + * + * @return Mage_Core_Model_Page_Asset_AssetInterface|null + */ + public function getAsset() + { + if ($this->hasContent()) { + return $this->_objectManager->create( + 'Mage_Core_Model_Page_Asset_PublicFile', + array('file' => $this->getFullPath(), 'contentType' => $this->getFileType()) + ); + } + return null; + } +} diff --git a/app/code/Mage/Core/Model/Theme/Image.php b/app/code/Mage/Core/Model/Theme/Image.php new file mode 100644 index 0000000000000..6ce74339ab306 --- /dev/null +++ b/app/code/Mage/Core/Model/Theme/Image.php @@ -0,0 +1,299 @@ +_objectManager = $objectManager; + $this->_helper = $helper; + $this->_filesystem = $filesystem; + } + + /** + * Setter for theme object + * + * @param Mage_Core_Model_Theme $theme + * @return Mage_Core_Model_Theme_Image + */ + public function setTheme($theme) + { + $this->_theme = $theme; + return $this; + } + + /** + * Getter for theme object + * + * @return Mage_Core_Model_Theme + * @throws BadMethodCallException + */ + public function getTheme() + { + if (null === $this->_theme) { + throw new BadMethodCallException('Theme was not set'); + } + return $this->_theme; + } + + /** + * Getter for theme preview image + * + * @return string + */ + public function getPreviewImage() + { + return $this->getTheme()->getPreviewImage(); + } + + /** + * Setter for theme preview image + * + * @param string $imageName + * @return Mage_Core_Model_Theme_Image + */ + public function setPreviewImage($imageName) + { + $this->getTheme()->setPreviewImage($imageName); + return $this; + } + + /** + * Save preview image + * + * @return Mage_Core_Model_Theme_Image + */ + public function savePreviewImage() + { + if (!$this->getPreviewImage() || !$this->getTheme()->getThemeDirectory()) { + return $this; + } + $currentWorkingDir = getcwd(); + + chdir($this->getTheme()->getThemeDirectory()); + + $imagePath = realpath($this->getPreviewImage()); + + if (0 === strpos($imagePath, $this->getTheme()->getThemeDirectory())) { + $this->createPreviewImage($imagePath); + } + + chdir($currentWorkingDir); + + return $this; + } + + /** + * Get preview image directory url + * + * @return string + */ + public function getPreviewImageDirectoryUrl() + { + /** @var $app Mage_Core_Model_App */ + $app = $this->_objectManager->get('Mage_Core_Model_App'); + return $app->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . $this->_getPreviewPath() . '/'; + } + + /** + * Get path for preview images + * + * @return string + */ + private function _getPreviewPath() + { + return 'theme/preview'; + } + + /** + * Upload and create preview image + * + * @param string $scope the request key for file + * @return bool + * @throws Mage_Core_Exception + */ + public function uploadPreviewImage($scope) + { + $adapter = new Zend_File_Transfer_Adapter_Http(); + if (!$adapter->isUploaded($scope)) { + return false; + } + if (!$adapter->isValid($scope)) { + Mage::throwException($this->_helper->__('Uploaded image is not valid')); + } + $upload = new Varien_File_Uploader($scope); + $upload->setAllowCreateFolders(true); + $upload->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png', 'xbm', 'wbmp')); + $upload->setAllowRenameFiles(true); + $upload->setFilesDispersion(false); + + /** @var $dir Mage_Core_Model_Dir */ + $dir = $this->_objectManager->get('Mage_Core_Model_Dir'); + $tmpDir = $dir->getDir(Mage_Core_Model_Dir::MEDIA) + . DIRECTORY_SEPARATOR . 'theme' . DIRECTORY_SEPARATOR . 'origin'; + + if (!$upload->save($tmpDir)) { + Mage::throwException($this->_helper->__('Image can not be saved.')); + } + + $fileName = $tmpDir . DIRECTORY_SEPARATOR . $upload->getUploadedFileName(); + $this->removePreviewImage()->createPreviewImage($fileName); + $this->_filesystem->delete($fileName); + return true; + } + + /** + * Create preview image + * + * @param string $imagePath + * @return string + */ + public function createPreviewImage($imagePath) + { + $adapter = $this->_helper->getImageAdapterType(); + $image = new Varien_Image($imagePath, $adapter); + $image->keepTransparency(true); + $image->constrainOnly(true); + $image->keepFrame(true); + $image->keepAspectRatio(true); + $image->backgroundColor(array(255, 255, 255)); + $image->resize(self::PREVIEW_IMAGE_WIDTH, self::PREVIEW_IMAGE_HEIGHT); + + $imageName = uniqid('preview_image_') . image_type_to_extension($image->getMimeType()); + $image->save($this->_getImagePathPreview(), $imageName); + + $this->setPreviewImage($imageName); + + return $imageName; + } + + /** + * Get directory path for preview image + * + * @return string + */ + protected function _getImagePathPreview() + { + /** @var $dir Mage_Core_Model_Dir */ + $dir = $this->_objectManager->get('Mage_Core_Model_Dir'); + return $dir->getDir(Mage_Core_Model_Dir::MEDIA) . DIRECTORY_SEPARATOR + . str_replace('/', DIRECTORY_SEPARATOR, $this->_getPreviewPath()); + } + + /** + * Create preview image copy + * + * @return Mage_Core_Model_Theme_Image + */ + public function createPreviewImageCopy() + { + $filePath = $this->_getImagePathPreview() . DIRECTORY_SEPARATOR . $this->getPreviewImage(); + $destinationFileName = Varien_File_Uploader::getNewFileName($filePath); + $this->_filesystem->copy( + $this->_getImagePathPreview() . DIRECTORY_SEPARATOR . $this->getPreviewImage(), + $this->_getImagePathPreview() . DIRECTORY_SEPARATOR . $destinationFileName + ); + $this->setPreviewImage($destinationFileName); + return $this; + } + + /** + * Delete preview image + * + * @return Mage_Core_Model_Theme_Image + */ + public function removePreviewImage() + { + $previewImage = $this->getPreviewImage(); + $this->setPreviewImage(''); + if ($previewImage) { + $this->_filesystem->delete($this->_getImagePathPreview() . DIRECTORY_SEPARATOR . $previewImage); + } + return $this; + } + + /** + * Get url for themes preview image + * + * @return string + */ + public function getPreviewImageUrl() + { + if (!$this->getPreviewImage()) { + return $this->_getPreviewImageDefaultUrl(); + } + return $this->getPreviewImageDirectoryUrl() . $this->getPreviewImage(); + } + + /** + * Return default themes preview image url + * + * @return string + */ + protected function _getPreviewImageDefaultUrl() + { + return $this->_objectManager->get('Mage_Core_Model_Design_Package') + ->getViewFileUrl('Mage_Core::theme/default_preview.jpg'); + } +} diff --git a/app/code/Mage/Core/Model/Theme/Registration.php b/app/code/Mage/Core/Model/Theme/Registration.php new file mode 100644 index 0000000000000..c72b3623420e8 --- /dev/null +++ b/app/code/Mage/Core/Model/Theme/Registration.php @@ -0,0 +1,212 @@ +_theme = $theme; + $this->_collection = $this->_theme->getCollectionFromFilesystem(); + } + + /** + * Theme registration + * + * @param string $baseDir + * @param string $pathPattern + * @return Mage_Core_Model_Theme + */ + public function register($baseDir = '', $pathPattern = '') + { + if (!empty($baseDir)) { + $this->_collection->setBaseDir($baseDir); + } + + if (empty($pathPattern)) { + $this->_collection->addDefaultPattern('*'); + } else { + $this->_collection->addTargetPattern($pathPattern); + } + + foreach ($this->_collection as $theme) { + $this->_registerThemeRecursively($theme); + } + + $this->checkPhysicalThemes()->checkAllowedThemeRelations(); + + return $this; + } + + /** + * Register theme and recursively all its ascendants + * Second param is optional and is used to prevent circular references in inheritance chain + * + * @param Mage_Core_Model_Theme $theme + * @param array $inheritanceChain + * @return Mage_Core_Model_Theme_Collection + * @throws Mage_Core_Exception + */ + protected function _registerThemeRecursively(&$theme, $inheritanceChain = array()) + { + if ($theme->getId()) { + return $this; + } + $themeModel = $this->getThemeFromDb($theme->getFullPath()); + if ($themeModel->getId()) { + $theme = $themeModel; + return $this; + } + + $tempId = $theme->getFullPath(); + if (in_array($tempId, $inheritanceChain)) { + Mage::throwException(Mage::helper('Mage_Core_Helper_Data') + ->__('Circular-reference in theme inheritance detected for "%s"', $tempId)); + } + array_push($inheritanceChain, $tempId); + $parentTheme = $theme->getParentTheme(); + if ($parentTheme) { + $this->_registerThemeRecursively($parentTheme, $inheritanceChain); + $theme->setParentId($parentTheme->getId()); + } + + $theme->getThemeImage()->savePreviewImage(); + $theme->setType(Mage_Core_Model_Theme::TYPE_PHYSICAL); + $theme->save(); + + return $this; + } + + /** + * Get theme from DB by full path + * + * @param string $fullPath + * @return Mage_Core_Model_Theme + */ + public function getThemeFromDb($fullPath) + { + return $this->_theme->getCollection()->getThemeByFullPath($fullPath); + } + + /** + * Checks all physical themes that they were not deleted + * + * @return Mage_Core_Model_Theme_Registration + */ + public function checkPhysicalThemes() + { + $themes = $this->_theme->getCollection()->addFieldToFilter('type', Mage_Core_Model_Theme::TYPE_PHYSICAL); + /** @var $theme Mage_Core_Model_Theme */ + foreach ($themes as $theme) { + if (!$theme->isPresentInFilesystem()) { + $theme->setType(Mage_Core_Model_Theme::TYPE_VIRTUAL)->save(); + } + } + return $this; + } + + /** + * Check whether all themes have correct parent theme by type + * + * @return Mage_Core_Model_Resource_Theme_Collection + */ + public function checkAllowedThemeRelations() + { + foreach ($this->_forbiddenRelations as $typesSequence) { + list($parentType, $childType) = $typesSequence; + $collection = $this->_theme->getCollection(); + $collection->addTypeRelationFilter($parentType, $childType); + /** @var $theme Mage_Core_Model_Theme */ + foreach ($collection as $theme) { + $parentId = $this->_getResetParentId($theme); + if ($theme->getParentId() != $parentId) { + $theme->setParentId($parentId)->save(); + } + } + } + return $this; + } + + /** + * Reset parent themes by type + * + * @param Mage_Core_Model_Theme $theme + * @return int|null + */ + protected function _getResetParentId(Mage_Core_Model_Theme $theme) + { + $parentTheme = $theme->getParentTheme(); + while ($parentTheme) { + foreach ($this->_allowedRelations as $typesSequence) { + list($parentType, $childType) = $typesSequence; + if ($theme->getType() == $childType && $parentTheme->getType() == $parentType) { + return $parentTheme->getId(); + } + } + $parentTheme = $parentTheme->getParentTheme(); + } + return null; + } +} diff --git a/app/code/Mage/Core/Model/Theme/Service.php b/app/code/Mage/Core/Model/Theme/Service.php new file mode 100644 index 0000000000000..dc19d27787a8f --- /dev/null +++ b/app/code/Mage/Core/Model/Theme/Service.php @@ -0,0 +1,461 @@ +_themeFactory = $themeFactory; + $this->_themeCopyService = $themeCopyService; + $this->_design = $design; + $this->_app = $app; + $this->_helper = $helper; + $this->_layoutUpdate = $layoutUpdate; + $this->_eventManager = $eventManager; + $this->_configWriter = $configWriter; + $this->_configCacheType = $configCacheType; + } + + /** + * Assign theme to the stores + * + * @param int $themeId + * @param array $stores + * @param string $scope + * @return Mage_Core_Model_Theme + * @throws UnexpectedValueException + */ + public function assignThemeToStores( + $themeId, + array $stores = array(), + $scope = Mage_Core_Model_Config::SCOPE_STORES + ) { + /** @var $theme Mage_Core_Model_Theme */ + $theme = $this->_themeFactory->create()->load($themeId); + if (!$theme->getId()) { + throw new UnexpectedValueException('Theme is not recognized. Requested id: ' . $themeId); + } + + $stagingVersion = $theme->getStagingVersion(); + if ($stagingVersion) { + $this->_themeCopyService->copy($stagingVersion, $theme); + } + + $themeCustomization = $theme->isVirtual() ? $theme : $this->createThemeCustomization($theme); + + $isUnassigned = false; + $this->_unassignThemeFormStores($themeId, $stores, $scope, $isUnassigned); + $this->_assignThemeToStores($themeCustomization->getId(), $stores, $scope, $isUnassigned); + + if ($isUnassigned) { + $this->_configCacheType->clean(); + } + + $this->_makeTemporaryLayoutUpdatesPermanent($themeId, $stores); + $this->_app->cleanCache(array('layout', Mage_Core_Model_Layout_Merge::LAYOUT_GENERAL_CACHE_TAG)); + + $this->_eventManager->dispatch('assign_theme_to_stores_after', + array( + 'themeService' => $this, + 'themeId' => $themeId, + 'stores' => $stores, + 'scope' => $scope, + 'theme' => $theme, + 'themeCustomization' => $themeCustomization, + ) + ); + + return $themeCustomization; + } + + /** + * Unassign given theme from stores that were unchecked + * + * @param int $themeId + * @param array $stores + * @param string $scope + * @param bool $isUnassigned + * @return Mage_Core_Model_Theme_Service + */ + protected function _unassignThemeFormStores($themeId, $stores, $scope, &$isUnassigned) + { + $configPath = Mage_Core_Model_Design_Package::XML_PATH_THEME_ID; + /** @var $config Mage_Core_Model_Config_Data */ + foreach ($this->_getAssignedScopesCollection($scope, $configPath) as $config) { + if ($config->getValue() == $themeId && !in_array($config->getScopeId(), $stores)) { + $this->_configWriter->delete($configPath, $scope, $config->getScopeId()); + $isUnassigned = true; + } + } + return $this; + } + + /** + * Assign given theme to stores + * + * @param int $themeId + * @param array $stores + * @param string $scope + * @param bool $isUnassigned + * @return Mage_Core_Model_Theme_Service + */ + protected function _assignThemeToStores($themeId, $stores, $scope, &$isUnassigned) + { + $configPath = Mage_Core_Model_Design_Package::XML_PATH_THEME_ID; + if (count($stores) > 0) { + foreach ($stores as $storeId) { + $this->_configWriter->save($configPath, $themeId, $scope, $storeId); + $isUnassigned = true; + } + } + return $this; + } + + /** + * Create theme customization + * + * @param Mage_Core_Model_Theme $theme + * @return Mage_Core_Model_Theme + */ + public function createThemeCustomization($theme) + { + $themeCopyCount = $this->_getThemeCustomizations()->addFilter('parent_id', $theme->getId())->count(); + + $themeData = $theme->getData(); + $themeData['parent_id'] = $theme->getId(); + $themeData['theme_id'] = null; + $themeData['theme_path'] = null; + $themeData['theme_title'] = $theme->getThemeTitle() . ' - ' . $this->_helper->__('Copy') . ' #' + . ($themeCopyCount + 1); + $themeData['type'] = Mage_Core_Model_Theme::TYPE_VIRTUAL; + + /** @var $themeCustomization Mage_Core_Model_Theme */ + $themeCustomization = $this->_themeFactory->create()->setData($themeData); + $themeCustomization->getThemeImage()->createPreviewImageCopy(); + $themeCustomization->save(); + + $this->_themeCopyService->copy($theme, $themeCustomization); + + return $themeCustomization; + } + + /** + * Get assigned scopes collection of a theme + * + * @param string $scope + * @param string $configPath + * @return Mage_Core_Model_Resource_Config_Data_Collection + */ + protected function _getAssignedScopesCollection($scope, $configPath) + { + return Mage::getSingleton('Mage_Core_Model_Config_Data')->getCollection() + ->addFieldToFilter('scope', $scope) + ->addFieldToFilter('path', $configPath); + } + + /** + * Make temporary updates for given theme and given stores permanent + * + * @param int $themeId + * @param array $storeIds + */ + protected function _makeTemporaryLayoutUpdatesPermanent($themeId, array $storeIds) + { + // currently all layout updates are related to theme only + $storeIds = array_merge($storeIds, array(Mage_Core_Model_AppInterface::ADMIN_STORE_ID)); + + $this->_layoutUpdate->makeTemporaryLayoutUpdatesPermanent($themeId, $storeIds); + } + + /** + * Check whether theme customizations exist in Magento + * + * @return bool + */ + public function isCustomizationsExist() + { + if ($this->_isCustomized === null) { + $this->_isCustomized = (bool)$this->_themeFactory->create()->getCollection() + ->addTypeFilter(Mage_Core_Model_Theme::TYPE_VIRTUAL) + ->getSize(); + } + return $this->_isCustomized; + } + + /** + * Return frontend physical theme collection. + * All themes or per page if set page and page size (page size is optional) + * + * @param int $page + * @param int $pageSize + * @return Mage_Core_Model_Resource_Theme_Collection + */ + public function getPhysicalThemes( + $page = null, + $pageSize = Mage_Core_Model_Resource_Theme_Collection::DEFAULT_PAGE_SIZE + ) { + /** @var $collection Mage_Core_Model_Resource_Theme_Collection */ + $collection = $this->_themeFactory->create()->getCollection(); + $collection->addAreaFilter(Mage_Core_Model_App_Area::AREA_FRONTEND) + ->addTypeFilter(Mage_Core_Model_Theme::TYPE_PHYSICAL); + if ($page) { + $collection->setPageSize($pageSize)->setCurPage($page); + } + return $collection; + } + + /** + * Check if current theme has assigned to any store + * + * @param Mage_Core_Model_Theme $theme + * @return bool + */ + public function isThemeAssignedToStore(Mage_Core_Model_Theme $theme) + { + $assignedThemes = $this->getAssignedThemeCustomizations(); + return isset($assignedThemes[$theme->getId()]); + } + + /** + * Return theme customizations which are assigned to store views + * + * @see self::_prepareThemeCustomizations() + * @return array + */ + public function getAssignedThemeCustomizations() + { + if (is_null($this->_assignedThemeC)) { + $this->_prepareThemeCustomizations(); + } + return $this->_assignedThemeC; + } + + /** + * Return theme customizations which are not assigned to store views. + * + * @see self::_prepareThemeCustomizations() + * @return array + */ + public function getUnassignedThemeCustomizations() + { + if (is_null($this->_unassignedThemeC)) { + $this->_prepareThemeCustomizations(); + } + return $this->_unassignedThemeC; + } + + /** + * Get theme by id + * + * @param int $themeId + * @return Mage_Core_Model_Theme + */ + public function getThemeById($themeId) + { + return $this->_themeFactory->create()->load($themeId); + } + + /** + * Fetch theme customization and sort them out to arrays: + * self::_assignedThemeCustomizations and self::_unassignedThemeCustomizations. + * + * NOTE: To get into "assigned" list theme customization not necessary should be assigned to store-view directly. + * It can be set to website or as default theme and be used by store-view via config fallback mechanism. + * + * @return Mage_Core_Model_Theme_Service + */ + protected function _prepareThemeCustomizations() + { + /** @var $themeCustomizations Mage_Core_Model_Resource_Theme_Collection */ + $themeCustomizations = $this->_getThemeCustomizations(); + $assignedThemes = $this->getStoresByThemes(); + + $this->_assignedThemeC = array(); + $this->_unassignedThemeC = array(); + /** @var $theme Mage_Core_Model_Theme */ + foreach ($themeCustomizations as $theme) { + if (isset($assignedThemes[$theme->getId()])) { + $theme->setAssignedStores($assignedThemes[$theme->getId()]); + $this->_assignedThemeC[$theme->getId()] = $theme; + } else { + $this->_unassignedThemeC[$theme->getId()] = $theme; + } + } + return $this; + } + + /** + * Return theme customizations collection + * + * @return Mage_Core_Model_Resource_Theme_Collection + */ + protected function _getThemeCustomizations() + { + /** @var $collection Mage_Core_Model_Resource_Theme_Collection */ + $collection = $this->_themeFactory->create()->getCollection(); + $collection->addAreaFilter(Mage_Core_Model_App_Area::AREA_FRONTEND) + ->addTypeFilter(Mage_Core_Model_Theme::TYPE_VIRTUAL); + return $collection; + } + + /** + * Return stores grouped by assigned themes + * + * @return array + */ + public function getStoresByThemes() + { + $storesByThemes = array(); + $stores = $this->_app->getStores(); + /** @var $store Mage_Core_Model_Store */ + foreach ($stores as $store) { + $themeId = $this->_design->getConfigurationDesignTheme( + Mage_Core_Model_App_Area::AREA_FRONTEND, + array('store' => $store) + ); + if (!isset($storesByThemes[$themeId])) { + $storesByThemes[$themeId] = array(); + } + $storesByThemes[$themeId][] = $store; + } + + return $storesByThemes; + } + + /** + * Is theme assigned to specific store + * + * @param Mage_Core_Model_Theme $theme + * @param Mage_Core_Model_Store $store + * @return bool + */ + public function isThemeAssignedToSpecificStore($theme, $store) + { + $themeId = $this->_design->getConfigurationDesignTheme( + Mage_Core_Model_App_Area::AREA_FRONTEND, + array('store' => $store) + ); + + return $theme->getId() == $themeId; + } +} diff --git a/app/code/Mage/Core/Model/Theme/Validator.php b/app/code/Mage/Core/Model/Theme/Validator.php new file mode 100644 index 0000000000000..34c2dab0ef8db --- /dev/null +++ b/app/code/Mage/Core/Model/Theme/Validator.php @@ -0,0 +1,206 @@ + array('validator_name' => [validators], ...), ...) + * + * @var array + */ + protected $_dataValidators = array(); + + /** + * List of errors after validation process + * + * array('dataKey' => 'Error message') + * + * @var array + */ + protected $_errorMessages = array(); + + /** + * Initialize validators + */ + public function __construct(Mage_Core_Helper_Data $helper) + { + $this->_helper = $helper; + $this->_setVersionValidators(); + $this->_setTypeValidators(); + } + + /** + * Set version validators + * + * @return Mage_Core_Model_Theme_Validator + */ + protected function _setVersionValidators() + { + $versionValidators = array( + array('name' => 'not_empty', 'class' => 'Zend_Validate_NotEmpty', 'break' => true, 'options' => array(), + 'message' => $this->_helper->__('Field can\'t be empty')), + array('name' => 'available', 'class' => 'Zend_Validate_Regex', 'break' => true, + 'options' => array('pattern' => '/^(\d+\.\d+\.\d+\.\d+(\-[a-zA-Z0-9]+)?)$|^\*$/'), + 'message' => $this->_helper->__('Theme version has not compatible format')) + ); + + $this->addDataValidators('theme_version', $versionValidators) + ->addDataValidators('magento_version_to', $versionValidators) + ->addDataValidators('magento_version_from', $versionValidators); + + return $this; + } + + /** + * Set theme type validators + * + * @return Mage_Core_Model_Theme_Validator + */ + protected function _setTypeValidators() + { + $typeValidators = array( + array( + 'name' => 'not_empty', + 'class' => 'Zend_Validate_NotEmpty', + 'break' => true, + 'options' => array(), + 'message' => $this->_helper->__('Field can\'t be empty') + ), + array( + 'name' => 'available', + 'class' => 'Zend_Validate_InArray', + 'break' => true, + 'options' => array('haystack' => Mage_Core_Model_Theme::$types), + 'message' => $this->_helper->__('Theme type is invalid') + ) + ); + + $this->addDataValidators('type', $typeValidators); + + return $this; + } + + /** + * Add validators + * + * @param string $dataKey + * @param array $validators + * @return Mage_Core_Model_Theme_Validator + */ + public function addDataValidators($dataKey, $validators) + { + if (!isset($this->_dataValidators[$dataKey])) { + $this->_dataValidators[$dataKey] = array(); + } + foreach ($validators as $validator) { + $this->_dataValidators[$dataKey][$validator['name']] = $validator; + } + return $this; + } + + /** + * Return error messages for items + * + * @param string|null $dataKey + * @return array + */ + public function getErrorMessages($dataKey = null) + { + if ($dataKey) { + return isset($this->_errorMessages[$dataKey]) ? $this->_errorMessages[$dataKey] : array(); + } + return $this->_errorMessages; + } + + /** + * Instantiate class validator + * + * @param array $validators + * @return Mage_Core_Model_Theme_Validator + */ + protected function _instantiateValidators(array &$validators) + { + foreach ($validators as &$validator) { + if (is_string($validator['class'])) { + $validator['class'] = new $validator['class']($validator['options']); + $validator['class']->setDisableTranslator(true); + } + } + return $this; + } + + /** + * Validate one data item + * + * @param array $validator + * @param string $dataKey + * @param mixed $dataValue + * @return bool + */ + protected function _validateDataItem($validator, $dataKey, $dataValue) + { + if ($validator['class'] instanceof Zend_Validate_NotEmpty && !$validator['class']->isValid($dataValue) + || !empty($dataValue) && !$validator['class']->isValid($dataValue) + ) { + $this->_errorMessages[$dataKey][] = $validator['message']; + if ($validator['break']) { + return false; + } + } + return true; + } + + /** + * Validate all data items + * + * @param Varien_Object $data + * @return bool + */ + public function validate(Varien_Object $data) + { + foreach ($this->_dataValidators as $dataKey => $validators) { + if (!isset($data[$dataKey]) || !$data->dataHasChangedFor($dataKey)) { + continue; + } + + $this->_instantiateValidators($validators); + foreach ($validators as $validator) { + if (!$this->_validateDataItem($validator, $dataKey, $data[$dataKey])) { + break; + } + } + } + return empty($this->_errorMessages); + } +} diff --git a/app/code/Mage/Core/Model/ThemeInterface.php b/app/code/Mage/Core/Model/ThemeInterface.php new file mode 100644 index 0000000000000..8a55d7fd4ee43 --- /dev/null +++ b/app/code/Mage/Core/Model/ThemeInterface.php @@ -0,0 +1,59 @@ +_designPackage = $designPackage; + $this->_localeHierarchy = $loader->load(); + } + + /** + * Initialization translation data + * + * @param string $area + * @param bool $forceReload + * @return Mage_Core_Model_Translate + */ + public function init($area, $forceReload = false) + { + $this->setConfig(array(self::CONFIG_KEY_AREA => $area)); + + $this->_translateInline = Mage::getSingleton('Mage_Core_Model_Translate_Inline') + ->isAllowed($area == 'adminhtml' ? 'admin' : null); + + if (!$forceReload) { + if ($this->_canUseCache()) { + $this->_data = $this->_loadCache(); + if ($this->_data !== false) { + return $this; + } + } + Mage::app()->removeCache($this->getCacheId()); + } + + $this->_data = array(); + + foreach ($this->getModulesConfig() as $moduleName => $info) { + $info = $info->asArray(); + $this->_loadModuleTranslation($moduleName, $info['files'], $forceReload); + } + + $this->_loadThemeTranslation($forceReload); + $this->_loadDbTranslation($forceReload); + + if (!$forceReload && $this->_canUseCache()) { + $this->_saveCache(); + } + + return $this; + } + + /** + * Retrieve modules configuration by translation + * + * @return Mage_Core_Model_Config_Element + */ + public function getModulesConfig() + { + if (!Mage::getConfig()->getNode($this->getConfig(self::CONFIG_KEY_AREA) . '/translate/modules')) { + return array(); + } + + $config = Mage::getConfig()->getNode($this->getConfig(self::CONFIG_KEY_AREA) + . '/translate/modules')->children(); + if (!$config) { + return array(); + } + return $config; + } + + /** + * Initialize configuration + * + * @param array $config + * @return Mage_Core_Model_Translate + */ + public function setConfig($config) + { + $this->_config = $config; + if (!isset($this->_config[self::CONFIG_KEY_LOCALE])) { + $this->_config[self::CONFIG_KEY_LOCALE] = $this->getLocale(); + } + if (!isset($this->_config[self::CONFIG_KEY_STORE])) { + $this->_config[self::CONFIG_KEY_STORE] = Mage::app()->getStore()->getId(); + } + if (!isset($this->_config[self::CONFIG_KEY_DESIGN_THEME])) { + $this->_config[self::CONFIG_KEY_DESIGN_THEME] = $this->_designPackage->getDesignTheme()->getId(); + } + return $this; + } + + /** + * Retrieve config value by key + * + * @param string $key + * @return mixed + */ + public function getConfig($key) + { + if (isset($this->_config[$key])) { + return $this->_config[$key]; + } + return null; + } + + /** + * Load data from module translation files + * + * @param string $moduleName + * @param array $files + * @param boolean $forceReload + * @return Mage_Core_Model_Translate + */ + protected function _loadModuleTranslation($moduleName, $files, $forceReload = false) + { + $requiredLocaleList = $this->_composeRequiredLocaleList($this->getLocale()); + foreach ($files as $file) { + foreach ($requiredLocaleList as $locale) { + $moduleFilePath = $this->_getModuleFilePath($moduleName, $file, $locale); + $this->_addData($this->_getFileData($moduleFilePath), $moduleName, $forceReload); + } + } + return $this; + } + + /** + * Compose the list of locales which are required to translate text entity based on given locale + * + * @param string $locale + * @return array + */ + protected function _composeRequiredLocaleList($locale) + { + $requiredLocaleList = array($locale); + if (isset($this->_localeHierarchy[$locale])) { + $requiredLocaleList = array_merge($this->_localeHierarchy[$locale], $requiredLocaleList); + } + return $requiredLocaleList; + } + + /** + * Adding translation data + * + * @param array $data + * @param string $scope + * @param boolean $forceReload + * @return Mage_Core_Model_Translate + */ + protected function _addData($data, $scope, $forceReload = false) + { + foreach ($data as $key => $value) { + if ($key === $value) { + continue; + } + $key = $this->_prepareDataString($key); + $value = $this->_prepareDataString($value); + if ($scope && isset($this->_dataScope[$key]) && !$forceReload ) { + /** + * Checking previous value + */ + $scopeKey = $this->_dataScope[$key] . self::SCOPE_SEPARATOR . $key; + if (!isset($this->_data[$scopeKey])) { + if (isset($this->_data[$key])) { + $this->_data[$scopeKey] = $this->_data[$key]; + unset($this->_data[$key]); + } + } + $scopeKey = $scope . self::SCOPE_SEPARATOR . $key; + $this->_data[$scopeKey] = $value; + } else { + $this->_data[$key] = $value; + $this->_dataScope[$key]= $scope; + } + } + return $this; + } + + /** + * Prepare data string + * + * @param string $string + * @return string + */ + protected function _prepareDataString($string) + { + return str_replace('""', '"', $string); + } + + /** + * Load current theme translation + * + * @param boolean $forceReload + * @return Mage_Core_Model_Translate + */ + protected function _loadThemeTranslation($forceReload = false) + { + if (!$this->_config[self::CONFIG_KEY_DESIGN_THEME]) { + return $this; + } + + $requiredLocaleList = $this->_composeRequiredLocaleList($this->getLocale()); + foreach ($requiredLocaleList as $locale) { + $file = $this->_designPackage->getLocaleFileName('translate.csv', array('locale' => $locale)); + $this->_addData( + $this->_getFileData($file), + self::CONFIG_KEY_DESIGN_THEME . $this->_config[self::CONFIG_KEY_DESIGN_THEME], + $forceReload + ); + } + return $this; + } + + /** + * Loading current store translation from DB + * + * @param boolean $forceReload + * @return Mage_Core_Model_Translate + */ + protected function _loadDbTranslation($forceReload = false) + { + $requiredLocaleList = $this->_composeRequiredLocaleList($this->getLocale()); + foreach ($requiredLocaleList as $locale) { + $arr = $this->getResource()->getTranslationArray(null, $locale); + $this->_addData($arr, $this->getConfig(self::CONFIG_KEY_STORE), $forceReload); + } + return $this; + } + + /** + * Retrieve translation file for module + * + * @param string $module + * @param string $fileName + * @param string $locale + * @return string + */ + protected function _getModuleFilePath($module, $fileName, $locale) + { + $file = Mage::getModuleDir('locale', $module); + $file .= DS . $locale . DS . $fileName; + return $file; + } + + /** + * Retrieve data from file + * + * @param string $file + * @return array + */ + protected function _getFileData($file) + { + $data = array(); + if (file_exists($file)) { + $parser = new Varien_File_Csv(); + $parser->setDelimiter(self::CSV_SEPARATOR); + $data = $parser->getDataPairs($file); + } + return $data; + } + + /** + * Retrieve translation data + * + * @return array + */ + public function getData() + { + if (is_null($this->_data)) { + return array(); + } + return $this->_data; + } + + /** + * Retrieve locale + * + * @return string + */ + public function getLocale() + { + if (is_null($this->_locale)) { + $this->_locale = Mage::app()->getLocale()->getLocaleCode(); + } + return $this->_locale; + } + + /** + * Set locale + * + * @param string $locale + * @return Mage_Core_Model_Translate + */ + public function setLocale($locale) + { + $this->_locale = $locale; + return $this; + } + + /** + * Retrieve DB resource model + * + * @return Mage_Core_Model_Resource_Translate + */ + public function getResource() + { + return Mage::getResourceSingleton('Mage_Core_Model_Resource_Translate'); + } + + /** + * Retrieve translation object + * + * @return Zend_Translate_Adapter + */ + public function getTranslate() + { + if (is_null($this->_translate)) { + $this->_translate = new Zend_Translate('array', $this->getData(), $this->getLocale()); + } + return $this->_translate; + } + + /** + * Translate + * + * @param array $args + * @return string + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) + */ + public function translate($args) + { + $text = array_shift($args); + + if ($this->_isEmptyTranslateArg($text)) { + return ''; + } + + if ($text instanceof Mage_Core_Model_Translate_Expr) { + $code = $text->getCode(self::SCOPE_SEPARATOR); + $module = $text->getModule(); + $text = $text->getText(); + $translated = $this->_getTranslatedString($text, $code); + } else { + if (!empty($_REQUEST['theme'])) { + $module = self::CONFIG_KEY_DESIGN_THEME . $_REQUEST['theme']; + } else { + $module = self::CONFIG_KEY_DESIGN_THEME . $this->_config[self::CONFIG_KEY_DESIGN_THEME]; + } + $code = $module . self::SCOPE_SEPARATOR . $text; + $translated = $this->_getTranslatedString($text, $code); + } + + $result = @vsprintf($translated, $args); + if ($result === false) { + $result = $translated; + } + + if ($this->_translateInline && $this->getTranslateInline()) { + if (strpos($result, '{{{') === false + || strpos($result, '}}}') === false + || strpos($result, '}}{{') === false + ) { + $result = '{{{' . $result . '}}{{' . $translated . '}}{{' . $text . '}}{{' . $module . '}}}'; + } + } + + return $result; + } + + /** + * Check is empty translate argument + * + * @param mixed $text + * @return bool + */ + protected function _isEmptyTranslateArg($text) + { + if (is_string($text) && '' == $text + || is_null($text) + || is_bool($text) && false === $text + || is_object($text) && '' == $text->getText() + ) { + return true; + } + return false; + } + + /** + * Set Translate inline mode + * + * @param bool $flag + * @return Mage_Core_Model_Translate + */ + public function setTranslateInline($flag = null) + { + $this->_canUseInline = (bool)$flag; + return $this; + } + + /** + * Retrieve active translate mode + * + * @return bool + * @SuppressWarnings(PHPMD.BooleanGetMethodName) + */ + public function getTranslateInline() + { + return $this->_canUseInline; + } + + /** + * Retrieve cache identifier + * + * @return string + */ + public function getCacheId() + { + if (is_null($this->_cacheId)) { + $this->_cacheId = 'translate'; + if (isset($this->_config[self::CONFIG_KEY_LOCALE])) { + $this->_cacheId .= '_' . $this->_config[self::CONFIG_KEY_LOCALE]; + } + if (isset($this->_config[self::CONFIG_KEY_AREA])) { + $this->_cacheId .= '_' . $this->_config[self::CONFIG_KEY_AREA]; + } + if (isset($this->_config[self::CONFIG_KEY_STORE])) { + $this->_cacheId .= '_' . $this->_config[self::CONFIG_KEY_STORE]; + } + if (isset($this->_config[self::CONFIG_KEY_DESIGN_THEME])) { + $this->_cacheId .= '_' . $this->_config[self::CONFIG_KEY_DESIGN_THEME]; + } + } + return $this->_cacheId; + } + + /** + * Loading data cache + * + * @return array | false + */ + protected function _loadCache() + { + if (!$this->_canUseCache()) { + return false; + } + $data = Mage::app()->loadCache($this->getCacheId()); + $data = unserialize($data); + return $data; + } + + /** + * Saving data cache + * + * @return Mage_Core_Model_Translate + */ + protected function _saveCache() + { + if (!$this->_canUseCache()) { + return $this; + } + Mage::app()->saveCache(serialize($this->getData()), $this->getCacheId(), array(self::CACHE_TAG), false); + return $this; + } + + /** + * Check cache usage availability + * + * @return bool + */ + protected function _canUseCache() + { + return Mage::app()->useCache(Mage_Core_Model_Cache_Type_Translate::TYPE_IDENTIFIER); + } + + /** + * Return translated string from text. + * + * @param string $text + * @param string $code + * @return string + */ + protected function _getTranslatedString($text, $code) + { + if (array_key_exists($code, $this->getData())) { + $translated = $this->_data[$code]; + } elseif (array_key_exists($text, $this->getData())) { + $translated = $this->_data[$text]; + } else { + $translated = $text; + } + return $translated; + } +} diff --git a/app/code/core/Mage/Core/Model/Translate/Expr.php b/app/code/Mage/Core/Model/Translate/Expr.php similarity index 100% rename from app/code/core/Mage/Core/Model/Translate/Expr.php rename to app/code/Mage/Core/Model/Translate/Expr.php diff --git a/app/code/core/Mage/Core/Model/Translate/Inline.php b/app/code/Mage/Core/Model/Translate/Inline.php similarity index 100% rename from app/code/core/Mage/Core/Model/Translate/Inline.php rename to app/code/Mage/Core/Model/Translate/Inline.php diff --git a/app/code/core/Mage/Core/Model/Translate/String.php b/app/code/Mage/Core/Model/Translate/String.php similarity index 100% rename from app/code/core/Mage/Core/Model/Translate/String.php rename to app/code/Mage/Core/Model/Translate/String.php diff --git a/app/code/Mage/Core/Model/Url.php b/app/code/Mage/Core/Model/Url.php new file mode 100644 index 0000000000000..b4dcec34e87fa --- /dev/null +++ b/app/code/Mage/Core/Model/Url.php @@ -0,0 +1,1213 @@ +'value1', 'param2'=>'value2') + * + * - query: (?)'param1=value1¶m2=value2' + * - query_array: array('param1'=>'value1', 'param2'=>'value2') + * - fragment: (#)'fragment-anchor' + * + * URL structure: + * + * https://user:password@host:443/base_path/[base_script][storeview_path]route_name/controller_name/action_name/param1/value1?query_param=query_value#fragment + * \__________A___________/\____________________________________B_____________________________________/ + * \__________________C___________________/ \__________________D_________________/ \_____E_____/ + * \_____________F______________/ \___________________________G______________________/ + * \___________________________________________________H____________________________________________________/ + * + * - A: authority + * - B: path + * - C: absolute_base_url + * - D: action_path + * - E: route_params + * - F: host_url + * - G: route_path + * - H: route_url + * + * @category Mage + * @package Mage_Core + * @author Magento Core Team + */ +class Mage_Core_Model_Url extends Varien_Object implements Mage_Core_Model_UrlInterface +{ + /** + * Configuration data cache + * + * @var array + */ + static protected $_configDataCache; + + /** + * Encrypted session identifier + * + * @var string|null + */ + static protected $_encryptedSessionId; + + /** + * Reserved Route parameter keys + * + * @var array + */ + protected $_reservedRouteParams = array( + '_store', '_type', '_secure', '_forced_secure', '_use_rewrite', '_nosid', + '_absolute', '_current', '_direct', '_fragment', '_escape', '_query', + '_store_to_url' + ); + + /** + * Controller request object + * + * @var Zend_Controller_Request_Http + */ + protected $_request; + + /** + * Use Session ID for generate URL + * + * @var bool + */ + protected $_useSession; + + /** + * Initialize object + */ + protected function _construct() + { + $this->setStore(null); + } + + /** + * Get default url type + * + * @return string + */ + protected function _getDefaultUrlType() + { + return Mage_Core_Model_Store::URL_TYPE_LINK; + } + + /** + * Initialize object data from retrieved url + * + * @param string $url + * @return Mage_Core_Model_Url + */ + public function parseUrl($url) + { + $data = parse_url($url); + $parts = array( + 'scheme' => 'setScheme', + 'host' => 'setHost', + 'port' => 'setPort', + 'user' => 'setUser', + 'pass' => 'setPassword', + 'path' => 'setPath', + 'query' => 'setQuery', + 'fragment' => 'setFragment'); + + foreach ($parts as $component => $method) { + if (isset($data[$component])) { + $this->$method($data[$component]); + } + } + return $this; + } + + /** + * Retrieve default controller name + * + * @return string + */ + public function getDefaultControllerName() + { + return self::DEFAULT_CONTROLLER_NAME; + } + + /** + * Set use_url_cache flag + * + * @param boolean $flag + * @return Mage_Core_Model_Url + */ + public function setUseUrlCache($flag) + { + $this->setData('use_url_cache', $flag); + return $this; + } + + /** + * Set use session rule + * + * @param bool $useSession + * @return Mage_Core_Model_Url + */ + public function setUseSession($useSession) + { + $this->_useSession = (bool) $useSession; + return $this; + } + + /** + * Set route front name + * + * @param string $name + * @return Mage_Core_Model_Url + */ + public function setRouteFrontName($name) + { + $this->setData('route_front_name', $name); + return $this; + } + + /** + * Retrieve use session rule + * + * @return bool + */ + public function getUseSession() + { + if (is_null($this->_useSession)) { + $this->_useSession = Mage::app()->getUseSessionInUrl(); + } + return $this->_useSession; + } + + /** + * Retrieve default action name + * + * @return string + */ + public function getDefaultActionName() + { + return self::DEFAULT_ACTION_NAME; + } + + /** + * Retrieve configuration data + * + * @param string $key + * @param string|null $prefix + * @return string + */ + public function getConfigData($key, $prefix = null) + { + if (is_null($prefix)) { + $prefix = 'web/' . ($this->isSecure() ? 'secure' : 'unsecure').'/'; + } + $path = $prefix . $key; + + $cacheId = $this->getStore()->getCode() . '/' . $path; + if (!isset(self::$_configDataCache[$cacheId])) { + $data = $this->getStore()->getConfig($path); + self::$_configDataCache[$cacheId] = $data; + } + + return self::$_configDataCache[$cacheId]; + } + + /** + * Set request + * + * @param Zend_Controller_Request_Http $request + * @return Mage_Core_Model_Url + */ + public function setRequest(Zend_Controller_Request_Http $request) + { + $this->_request = $request; + return $this; + } + + /** + * Zend request object + * + * @return Mage_Core_Controller_Request_Http + */ + public function getRequest() + { + if (!$this->_request) { + $this->_request = Mage::app()->getRequest(); + } + return $this->_request; + } + + /** + * Retrieve URL type + * + * @return string + */ + public function getType() + { + if (!$this->hasData('type')) { + $this->setData('type', $this->_getDefaultUrlType()); + } + return $this->_getData('type'); + } + + /** + * Retrieve is secure mode URL + * + * @return bool + */ + public function isSecure() + { + if ($this->hasData('secure_is_forced')) { + return (bool)$this->getData('secure'); + } + + $store = $this->getStore(); + + if ($store->isAdmin() && !$store->isAdminUrlSecure()) { + return false; + } + if (!$store->isAdmin() && !$store->isFrontUrlSecure()) { + return false; + } + + if (!$this->hasData('secure')) { + if ($this->getType() == Mage_Core_Model_Store::URL_TYPE_LINK && !$store->isAdmin()) { + $pathSecure = Mage::getConfig()->shouldUrlBeSecure('/' . $this->getActionPath()); + $this->setData('secure', $pathSecure); + } else { + $this->setData('secure', true); + } + } + return $this->getData('secure'); + } + + /** + * Set store entity + * + * @param mixed $params + * @return Mage_Core_Model_Url + */ + public function setStore($params) + { + $this->setData('store', Mage::app()->getStore($params)); + return $this; + } + + /** + * Get current store for the url instance + * + * @return Mage_Core_Model_Store + */ + public function getStore() + { + if (!$this->hasData('store')) { + $this->setStore(null); + } + return $this->_getData('store'); + } + + /** + * Retrieve Base URL + * + * @param array $params + * @return string + */ + public function getBaseUrl($params = array()) + { + if (isset($params['_store'])) { + $this->setStore($params['_store']); + } + if (isset($params['_type'])) { + $this->setType($params['_type']); + } + + if (isset($params['_secure'])) { + $this->setSecure($params['_secure']); + } + + /** + * Add availability support urls without store code + */ + if ($this->getType() == Mage_Core_Model_Store::URL_TYPE_LINK + && $this->getRequest()->isDirectAccessFrontendName($this->getRouteFrontName())) { + $this->setType(Mage_Core_Model_Store::URL_TYPE_DIRECT_LINK); + } + + $result = $this->getStore()->getBaseUrl($this->getType(), $this->isSecure()); + $this->setType($this->_getDefaultUrlType()); + return $result; + } + + /** + * Set Route Parameters + * + * @param array $data + * @return Mage_Core_Model_Url + */ + public function setRoutePath($data) + { + if ($this->_getData('route_path') == $data) { + return $this; + } + + $this->unsetData('route_path'); + $a = explode('/', $data); + + $route = array_shift($a); + if ('*' === $route) { + $route = $this->getRequest()->getRequestedRouteName(); + } + $this->setRouteName($route); + + $controller = ''; + if (!empty($a)) { + $controller = array_shift($a); + if ('*' === $controller) { + $controller = $this->getRequest()->getRequestedControllerName(); + } + } + $this->setControllerName($controller); + + $action = ''; + if (!empty($a)) { + $action = array_shift($a); + if ('*' === $action) { + $action = $this->getRequest()->getRequestedActionName(); + } + } + $this->setActionName($action); + + if (!empty($a)) { + while (!empty($a)) { + $key = array_shift($a); + if (!empty($a)) { + $value = array_shift($a); + $this->setRouteParam($key, $value); + } + } + } + + return $this; + } + + /** + * Retrieve action path + * + * @return string + */ + public function getActionPath() + { + if (!$this->getRouteName()) { + return ''; + } + + $hasParams = (bool) $this->getRouteParams(); + $path = $this->getRouteFrontName() . '/'; + + if ($this->getControllerName()) { + $path .= $this->getControllerName() . '/'; + } elseif ($hasParams) { + $path .= $this->getDefaultControllerName() . '/'; + } + if ($this->getActionName()) { + $path .= $this->getActionName() . '/'; + } elseif ($hasParams) { + $path .= $this->getDefaultActionName() . '/'; + } + + return $path; + } + + /** + * Retrieve route path + * + * @param array $routeParams + * @return string + */ + public function getRoutePath($routeParams = array()) + { + if (!$this->hasData('route_path')) { + $routePath = $this->getRequest()->getAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS); + if (!empty($routeParams['_use_rewrite']) && ($routePath !== null)) { + $this->setData('route_path', $routePath); + return $routePath; + } + $routePath = $this->getActionPath(); + if ($this->getRouteParams()) { + foreach ($this->getRouteParams() as $key=>$value) { + if (is_null($value) || false === $value || '' === $value || !is_scalar($value)) { + continue; + } + $routePath .= $key . '/' . $value . '/'; + } + } + if ($routePath != '' && substr($routePath, -1, 1) !== '/') { + $routePath .= '/'; + } + $this->setData('route_path', $routePath); + } + return $this->_getData('route_path'); + } + + /** + * Set route name + * + * @param string $data + * @return Mage_Core_Model_Url + */ + public function setRouteName($data) + { + if ($this->_getData('route_name') == $data) { + return $this; + } + $this->unsetData('route_front_name') + ->unsetData('route_path') + ->unsetData('controller_name') + ->unsetData('action_name') + ->unsetData('secure'); + return $this->setData('route_name', $data); + } + + /** + * Retrieve route front name + * + * @return string + */ + public function getRouteFrontName() + { + if (!$this->hasData('route_front_name')) { + $routeName = $this->getRouteName(); + $route = Mage::app()->getFrontController()->getRouterByRoute($routeName); + $frontName = $route->getFrontNameByRoute($routeName); + + $this->setRouteFrontName($frontName); + } + + return $this->_getData('route_front_name'); + } + + /** + * Retrieve route name + * + * @param mixed $default + * @return string|null + */ + public function getRouteName($default = null) + { + return $this->_getData('route_name') ? $this->_getData('route_name') : $default; + } + + /** + * Set Controller Name + * + * Reset action name and route path if has change + * + * @param string $data + * @return Mage_Core_Model_Url + */ + public function setControllerName($data) + { + if ($this->_getData('controller_name') == $data) { + return $this; + } + $this->unsetData('route_path')->unsetData('action_name')->unsetData('secure'); + return $this->setData('controller_name', $data); + } + + /** + * Retrieve controller name + * + * @param mixed $default + * @return string|null + */ + public function getControllerName($default = null) + { + return $this->_getData('controller_name') ? $this->_getData('controller_name') : null; + } + + /** + * Set Action name + * Reseted route path if action name has change + * + * @param string $data + * @return Mage_Core_Model_Url + */ + public function setActionName($data) + { + if ($this->_getData('action_name') == $data) { + return $this; + } + $this->unsetData('route_path'); + return $this->setData('action_name', $data)->unsetData('secure'); + } + + /** + * Retrieve action name + * + * @param mixed $default + * @return string|null + */ + public function getActionName($default = null) + { + return $this->_getData('action_name') ? $this->_getData('action_name') : $default; + } + + /** + * Set route params + * + * @param array $data + * @param boolean $unsetOldParams + * @return Mage_Core_Model_Url + */ + public function setRouteParams(array $data, $unsetOldParams = true) + { + if (isset($data['_type'])) { + $this->setType($data['_type']); + unset($data['_type']); + } + + if (isset($data['_store'])) { + $this->setStore($data['_store']); + unset($data['_store']); + } + + if (isset($data['_forced_secure'])) { + $this->setSecure((bool)$data['_forced_secure']); + $this->setSecureIsForced(true); + unset($data['_forced_secure']); + } elseif (isset($data['_secure'])) { + $this->setSecure((bool)$data['_secure']); + unset($data['_secure']); + } + + if (isset($data['_absolute'])) { + unset($data['_absolute']); + } + + if ($unsetOldParams) { + $this->unsetData('route_params'); + } + + $this->setUseUrlCache(true); + if (isset($data['_current'])) { + if (is_array($data['_current'])) { + foreach ($data['_current'] as $key) { + if (array_key_exists($key, $data) || !$this->getRequest()->getUserParam($key)) { + continue; + } + $data[$key] = $this->getRequest()->getUserParam($key); + } + } elseif ($data['_current']) { + foreach ($this->getRequest()->getUserParams() as $key => $value) { + if (array_key_exists($key, $data) || $this->getRouteParam($key)) { + continue; + } + $data[$key] = $value; + } + foreach ($this->getRequest()->getQuery() as $key => $value) { + $this->setQueryParam($key, $value); + } + $this->setUseUrlCache(false); + } + unset($data['_current']); + } + + if (isset($data['_use_rewrite'])) { + unset($data['_use_rewrite']); + } + + if (isset($data['_store_to_url']) && (bool)$data['_store_to_url'] === true) { + if (!Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_STORE_IN_URL, $this->getStore()) + && !Mage::app()->hasSingleStore() + ) { + $this->setQueryParam('___store', $this->getStore()->getCode()); + } + } + unset($data['_store_to_url']); + + foreach ($data as $k => $v) { + $this->setRouteParam($k, $v); + } + + return $this; + } + + /** + * Retrieve route params + * + * @return array + */ + public function getRouteParams() + { + return $this->_getData('route_params'); + } + + /** + * Set route param + * + * @param string $key + * @param mixed $data + * @return Mage_Core_Model_Url + */ + public function setRouteParam($key, $data) + { + $params = $this->_getData('route_params'); + if (isset($params[$key]) && $params[$key] == $data) { + return $this; + } + $params[$key] = $data; + $this->unsetData('route_path'); + return $this->setData('route_params', $params); + } + + /** + * Retrieve route params + * + * @param string $key + * @return mixed + */ + public function getRouteParam($key) + { + return $this->getData('route_params', $key); + } + + /** + * Retrieve route URL + * + * @param string $routePath + * @param array $routeParams + * @return string + */ + public function getRouteUrl($routePath = null, $routeParams = null) + { + if (filter_var($routePath, FILTER_VALIDATE_URL)) { + return $routePath; + } + + $this->unsetData('route_params'); + + if (isset($routeParams['_direct'])) { + if (is_array($routeParams)) { + $this->setRouteParams($routeParams, false); + } + return $this->getBaseUrl() . $routeParams['_direct']; + } + + $this->setRoutePath($routePath); + if (is_array($routeParams)) { + $this->setRouteParams($routeParams, false); + } + + $url = $this->getBaseUrl() . $this->getRoutePath($routeParams); + return $url; + } + + /** + * If the host was switched but session cookie won't recognize it - add session id to query + * + * @return Mage_Core_Model_Url + */ + public function checkCookieDomains() + { + $hostArr = explode(':', $this->getRequest()->getServer('HTTP_HOST')); + if ($hostArr[0] !== $this->getHost()) { + $session = Mage::getSingleton('Mage_Core_Model_Session'); + if (!$session->isValidForHost($this->getHost())) { + if (!self::$_encryptedSessionId) { + $helper = Mage::helper('Mage_Core_Helper_Data'); + if (!$helper) { + return $this; + } + self::$_encryptedSessionId = $session->getEncryptedSessionId(); + } + $this->setQueryParam($session->getSessionIdQueryParam(), self::$_encryptedSessionId); + } + } + return $this; + } + + /** + * Add session param + * + * @return Mage_Core_Model_Url + */ + public function addSessionParam() + { + $session = Mage::getSingleton('Mage_Core_Model_Session'); + + if (!self::$_encryptedSessionId) { + $helper = Mage::helper('Mage_Core_Helper_Data'); + if (!$helper) { + return $this; + } + self::$_encryptedSessionId = $session->getEncryptedSessionId(); + } + $this->setQueryParam($session->getSessionIdQueryParam(), self::$_encryptedSessionId); + return $this; + } + + /** + * Set URL query param(s) + * + * @param mixed $data + * @return Mage_Core_Model_Url + */ + public function setQuery($data) + { + if ($this->_getData('query') == $data) { + return $this; + } + $this->unsetData('query_params'); + return $this->setData('query', $data); + } + + /** + * Get query params part of url + * + * @param bool $escape "&" escape flag + * @return string + */ + public function getQuery($escape = false) + { + if (!$this->hasData('query')) { + $query = ''; + $params = $this->getQueryParams(); + if (is_array($params)) { + ksort($params); + $query = http_build_query($params, '', $escape ? '&' : '&'); + } + $this->setData('query', $query); + } + return $this->_getData('query'); + } + + /** + * Set query Params as array + * + * @param array $data + * @return Mage_Core_Model_Url + */ + public function setQueryParams(array $data) + { + $this->unsetData('query'); + + if ($this->_getData('query_params') == $data) { + return $this; + } + + $params = $this->_getData('query_params'); + if (!is_array($params)) { + $params = array(); + } + foreach ($data as $param => $value) { + $params[$param] = $value; + } + $this->setData('query_params', $params); + + return $this; + } + + /** + * Purge Query params array + * + * @return Mage_Core_Model_Url + */ + public function purgeQueryParams() + { + $this->setData('query_params', array()); + return $this; + } + + /** + * Return Query Params + * + * @return array + */ + public function getQueryParams() + { + if (!$this->hasData('query_params')) { + $params = array(); + if ($this->_getData('query')) { + foreach (explode('&', $this->_getData('query')) as $param) { + $paramArr = explode('=', $param); + $params[$paramArr[0]] = urldecode($paramArr[1]); + } + } + $this->setData('query_params', $params); + } + return $this->_getData('query_params'); + } + + /** + * Set query param + * + * @param string $key + * @param mixed $data + * @return Mage_Core_Model_Url + */ + public function setQueryParam($key, $data) + { + $params = $this->getQueryParams(); + if (isset($params[$key]) && $params[$key] == $data) { + return $this; + } + $params[$key] = $data; + $this->unsetData('query'); + return $this->setData('query_params', $params); + } + + /** + * Retrieve query param + * + * @param string $key + * @return mixed + */ + public function getQueryParam($key) + { + if (!$this->hasData('query_params')) { + $this->getQueryParams(); + } + return $this->getData('query_params', $key); + } + + /** + * Set fragment to URL + * + * @param string $data + * @return Mage_Core_Model_Url + */ + public function setFragment($data) + { + return $this->setData('fragment', $data); + } + + /** + * Retrieve URL fragment + * + * @return string|null + */ + public function getFragment() + { + return $this->_getData('fragment'); + } + + /** + * Build url by requested path and parameters + * + * @param string|null $routePath + * @param array|null $routeParams + * @return string + */ + public function getUrl($routePath = null, $routeParams = null) + { + if (filter_var($routePath, FILTER_VALIDATE_URL)) { + return $routePath; + } + + $escapeQuery = false; + + /** + * All system params should be unset before we call getRouteUrl + * this method has condition for adding default controller and action names + * in case when we have params + */ + $fragment = null; + if (isset($routeParams['_fragment'])) { + $fragment = $routeParams['_fragment']; + unset($routeParams['_fragment']); + } + + if (isset($routeParams['_escape'])) { + $escapeQuery = $routeParams['_escape']; + unset($routeParams['_escape']); + } + + $query = null; + if (isset($routeParams['_query'])) { + $this->purgeQueryParams(); + $query = $routeParams['_query']; + unset($routeParams['_query']); + } + + $noSid = null; + if (isset($routeParams['_nosid'])) { + $noSid = (bool)$routeParams['_nosid']; + unset($routeParams['_nosid']); + } + $url = $this->getRouteUrl($routePath, $routeParams); + /** + * Apply query params, need call after getRouteUrl for rewrite _current values + */ + if ($query !== null) { + if (is_string($query)) { + $this->setQuery($query); + } elseif (is_array($query)) { + $this->setQueryParams($query, !empty($routeParams['_current'])); + } + if ($query === false) { + $this->setQueryParams(array()); + } + } + + if ($noSid !== true) { + $this->_prepareSessionUrl($url); + } + + $query = $this->getQuery($escapeQuery); + if ($query) { + $mark = (strpos($url, '?') === false) ? '?' : ($escapeQuery ? '&' : '&'); + $url .= $mark . $query; + $this->unsetData('query'); + $this->unsetData('query_params'); + } + + if (!is_null($fragment)) { + $url .= '#' . $fragment; + } + + return $this->escape($url); + } + + /** + * Check and add session id to URL + * + * @param string $url + * + * @return Mage_Core_Model_Url + */ + protected function _prepareSessionUrl($url) + { + return $this->_prepareSessionUrlWithParams($url, array()); + } + + /** + * Check and add session id to URL, session is obtained with parameters + * + * @param string $url + * @param array $params + * + * @return Mage_Core_Model_Url + */ + protected function _prepareSessionUrlWithParams($url, array $params) + { + if (!$this->getUseSession()) { + return $this; + } + /** @var $session Mage_Core_Model_Session */ + $session = Mage::getSingleton('Mage_Core_Model_Session'); + $sessionId = $session->getSessionIdForHost($url); + if (Mage::app()->getUseSessionVar() && !$sessionId) { + $this->setQueryParam('___SID', $this->isSecure() ? 'S' : 'U'); // Secure/Unsecure + } else if ($sessionId) { + $this->setQueryParam($session->getSessionIdQueryParam(), $sessionId); + } + return $this; + } + + /** + * Rebuild URL to handle the case when session ID was changed + * + * @param string $url + * @return string + */ + public function getRebuiltUrl($url) + { + $this->parseUrl($url); + $port = $this->getPort(); + if ($port) { + $port = ':' . $port; + } else { + $port = ''; + } + $url = $this->getScheme() . '://' . $this->getHost() . $port . $this->getPath(); + + $this->_prepareSessionUrl($url); + + $query = $this->getQuery(); + if ($query) { + $url .= '?' . $query; + } + + $fragment = $this->getFragment(); + if ($fragment) { + $url .= '#' . $fragment; + } + + return $this->escape($url); + } + + /** + * Escape (enclosure) URL string + * + * @param string $value + * @return string + */ + public function escape($value) + { + $value = str_replace('"', '%22', $value); + $value = str_replace("'", '%27', $value); + $value = str_replace('>', '%3E', $value); + $value = str_replace('<', '%3C', $value); + return $value; + } + + /** + * Build url by direct url and parameters + * + * @param string $url + * @param array $params + * @return string + */ + public function getDirectUrl($url, $params = array()) + { + $params['_direct'] = $url; + return $this->getUrl('', $params); + } + + /** + * Replace Session ID value in URL + * + * @param string $html + * @return string + */ + public function sessionUrlVar($html) + { + return preg_replace_callback('#(\?|&|&)___SID=([SU])(&|&)?#', + array($this, "sessionVarCallback"), $html); + } + + /** + * Check and return use SID for URL + * + * @param bool $secure + * @return bool + */ + public function useSessionIdForUrl($secure = false) + { + $key = 'use_session_id_for_url_' . (int) $secure; + if (is_null($this->getData($key))) { + $httpHost = Mage::app()->getFrontController()->getRequest()->getHttpHost(); + $urlHost = parse_url($this->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, $secure), + PHP_URL_HOST); + + if ($httpHost != $urlHost) { + $this->setData($key, true); + } else { + $this->setData($key, false); + } + } + return $this->getData($key); + } + + /** + * Callback function for session replace + * + * @param array $match + * @return string + */ + public function sessionVarCallback($match) + { + if ($this->useSessionIdForUrl($match[2] == 'S' ? true : false)) { + $session = Mage::getSingleton('Mage_Core_Model_Session'); + /* @var $session Mage_Core_Model_Session */ + return $match[1] + . $session->getSessionIdQueryParam() + . '=' . $session->getEncryptedSessionId() + . (isset($match[3]) ? $match[3] : ''); + } else { + if ($match[1] == '?' && isset($match[3])) { + return '?'; + } elseif ($match[1] == '?' && !isset($match[3])) { + return ''; + } elseif (($match[1] == '&' || $match[1] == '&') && !isset($match[3])) { + return ''; + } elseif (($match[1] == '&' || $match[1] == '&') && isset($match[3])) { + return $match[3]; + } + } + return ''; + } + + /** + * Check if users originated URL is one of the domain URLs assigned to stores + * + * @return boolean + */ + public function isOwnOriginUrl() + { + $storeDomains = array(); + $referer = parse_url(Mage::app()->getRequest()->getServer('HTTP_REFERER'), PHP_URL_HOST); + foreach (Mage::app()->getStores() as $store) { + $storeDomains[] = parse_url($store->getBaseUrl(), PHP_URL_HOST); + $storeDomains[] = parse_url($store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true), PHP_URL_HOST); + } + $storeDomains = array_unique($storeDomains); + if (empty($referer) || in_array($referer, $storeDomains)) { + return true; + } + return false; + } + + /** + * Return frontend redirect URL with SID and other session parameters if any + * + * @param string $url + * + * @return string + */ + public function getRedirectUrl($url) + { + $this->_prepareSessionUrlWithParams($url, array( + 'name' => Mage_Core_Controller_Front_Action::SESSION_NAMESPACE + )); + + $query = $this->getQuery(false); + if ($query) { + $url .= (strpos($url, '?') === false ? '?' : '&') . $query; + } + + return $url; + } +} diff --git a/app/code/core/Mage/Core/Model/Url/Rewrite.php b/app/code/Mage/Core/Model/Url/Rewrite.php similarity index 100% rename from app/code/core/Mage/Core/Model/Url/Rewrite.php rename to app/code/Mage/Core/Model/Url/Rewrite.php diff --git a/app/code/core/Mage/Core/Model/Url/RewriteFactory.php b/app/code/Mage/Core/Model/Url/RewriteFactory.php similarity index 90% rename from app/code/core/Mage/Core/Model/Url/RewriteFactory.php rename to app/code/Mage/Core/Model/Url/RewriteFactory.php index a67be9ab1b56b..af7f237e8e5be 100644 --- a/app/code/core/Mage/Core/Model/Url/RewriteFactory.php +++ b/app/code/Mage/Core/Model/Url/RewriteFactory.php @@ -24,7 +24,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Core_Model_Url_RewriteFactory implements Magento_ObjectManager_Factory +class Mage_Core_Model_Url_RewriteFactory { /** * Entity class name @@ -48,8 +48,8 @@ public function __construct(Magento_ObjectManager $objectManager) * @param array $arguments * @return Mage_Core_Model_Url_Rewrite */ - public function createFromArray(array $arguments = array()) + public function create(array $arguments = array()) { - return $this->_objectManager->create(self::CLASS_NAME, $arguments, false); + return $this->_objectManager->create(self::CLASS_NAME, $arguments); } } diff --git a/app/code/core/Mage/Core/Model/Url/Validator.php b/app/code/Mage/Core/Model/Url/Validator.php similarity index 100% rename from app/code/core/Mage/Core/Model/Url/Validator.php rename to app/code/Mage/Core/Model/Url/Validator.php diff --git a/app/code/Mage/Core/Model/UrlInterface.php b/app/code/Mage/Core/Model/UrlInterface.php new file mode 100644 index 0000000000000..101747f297353 --- /dev/null +++ b/app/code/Mage/Core/Model/UrlInterface.php @@ -0,0 +1,440 @@ +_objectManager = $objectManager; + $this->_translator = $translator; + + $this->_configFiles = $moduleReader->getModuleConfigurationFiles('validation.xml'); + $this->_initializeDefaultTranslator(); + } + + /** + * Create and set default translator to Magento_Validator_ValidatorAbstract. + */ + protected function _initializeDefaultTranslator() + { + $translateAdapter = $this->_translator; + $objectManager = $this->_objectManager; + // Pass translations to Mage_Core_Model_Translate from validators + $translatorCallback = function () use ($translateAdapter, $objectManager) { + /** @var Mage_Core_Model_Translate $translateAdapter */ + $args = func_get_args(); + $expr = $objectManager->create('Mage_Core_Model_Translate_Expr'); + $expr->setText($args[0]); + array_unshift($args, $expr); + return $translateAdapter->translate($args); + }; + /** @var Magento_Translate_Adapter $translator */ + $translator = $this->_objectManager->create('Magento_Translate_Adapter'); + $translator->setOptions(array('translator' => $translatorCallback)); + Magento_Validator_ValidatorAbstract::setDefaultTranslator($translator); + } + + /** + * Get validator config object. + * + * Will instantiate Magento_Validator_Config + * + * @return Magento_Validator_Config + */ + public function getValidatorConfig() + { + return $this->_objectManager->create('Magento_Validator_Config', array('configFiles' => $this->_configFiles)); + } + + /** + * Create validator builder instance based on entity and group. + * + * @param string $entityName + * @param string $groupName + * @param array|null $builderConfig + * @return Magento_Validator_Builder + */ + public function createValidatorBuilder($entityName, $groupName, array $builderConfig = null) + { + return $this->getValidatorConfig()->createValidatorBuilder($entityName, $groupName, $builderConfig); + } + + /** + * Create validator based on entity and group. + * + * @param string $entityName + * @param string $groupName + * @param array|null $builderConfig + * @return Magento_Validator + */ + public function createValidator($entityName, $groupName, array $builderConfig = null) + { + return $this->getValidatorConfig()->createValidator($entityName, $groupName, $builderConfig); + } +} diff --git a/app/code/core/Mage/Core/Model/Variable.php b/app/code/Mage/Core/Model/Variable.php similarity index 100% rename from app/code/core/Mage/Core/Model/Variable.php rename to app/code/Mage/Core/Model/Variable.php diff --git a/app/code/core/Mage/Core/Model/Variable/Config.php b/app/code/Mage/Core/Model/Variable/Config.php similarity index 100% rename from app/code/core/Mage/Core/Model/Variable/Config.php rename to app/code/Mage/Core/Model/Variable/Config.php diff --git a/app/code/core/Mage/Core/Model/Variable/Observer.php b/app/code/Mage/Core/Model/Variable/Observer.php similarity index 100% rename from app/code/core/Mage/Core/Model/Variable/Observer.php rename to app/code/Mage/Core/Model/Variable/Observer.php diff --git a/app/code/core/Mage/Core/Model/Website.php b/app/code/Mage/Core/Model/Website.php similarity index 100% rename from app/code/core/Mage/Core/Model/Website.php rename to app/code/Mage/Core/Model/Website.php diff --git a/app/code/core/Mage/Core/Model/Website/Factory.php b/app/code/Mage/Core/Model/Website/Factory.php similarity index 100% rename from app/code/core/Mage/Core/Model/Website/Factory.php rename to app/code/Mage/Core/Model/Website/Factory.php diff --git a/app/code/Mage/Core/Service/Entity/Abstract.php b/app/code/Mage/Core/Service/Entity/Abstract.php new file mode 100644 index 0000000000000..d0b0cf59258e9 --- /dev/null +++ b/app/code/Mage/Core/Service/Entity/Abstract.php @@ -0,0 +1,115 @@ +_getObject($objectId, $fieldSetId); + + if ($object->getId()) { + $data = $this->_getObjectData($object); + $data = $this->_applySchema($data, $object); + } + + return $data; + } + + /** + * Extract data from the loaded object and make it conform with schema. + * + * @param Varien_Object $object + * @return array + */ + protected function _getObjectData(Varien_Object $object) + { + $data = $object->getData(); + + // Make camelCase out of underscore + foreach ($data as $key => $value) { + $camelCase = preg_replace_callback( + '/_(.)/', + function ($matches) { return strtoupper($matches[1]);}, + $key + ); + + if ($camelCase !== $key) { + $data[$camelCase] = $data[$key]; + unset($data[$key]); + } + } + + $data = $this->_formatObjectData($data); + + return $data; + } + + + /** + * Formats object's data so it represents an array on all levels. + * + * @param array $data + * @return array + */ + protected function _formatObjectData(array $data) + { + foreach ($data as $key => $value) { + if (is_object($value)) { + //skip + $data[$key] = null; + } else if (is_array($value)) { + $data[$key] = $this->_formatObjectData($value); + } + } + + return $data; + } +} diff --git a/app/code/Mage/Core/Service/Entity/Exception.php b/app/code/Mage/Core/Service/Entity/Exception.php new file mode 100644 index 0000000000000..f17c23e7a1070 --- /dev/null +++ b/app/code/Mage/Core/Service/Entity/Exception.php @@ -0,0 +1,29 @@ +isPresentInFilesystem() + ? Mage_Core_Model_Theme::TYPE_PHYSICAL + : Mage_Core_Model_Theme::TYPE_VIRTUAL; + $theme->setType($themeType)->save(); +} diff --git a/app/code/core/Mage/Core/data/core_setup/data-upgrade-1.6.0.3-1.6.0.4.php b/app/code/Mage/Core/data/core_setup/data-upgrade-1.6.0.3-1.6.0.4.php similarity index 100% rename from app/code/core/Mage/Core/data/core_setup/data-upgrade-1.6.0.3-1.6.0.4.php rename to app/code/Mage/Core/data/core_setup/data-upgrade-1.6.0.3-1.6.0.4.php diff --git a/app/code/core/Mage/Core/data/core_setup/data-upgrade-1.6.0.4-1.6.0.5.php b/app/code/Mage/Core/data/core_setup/data-upgrade-1.6.0.4-1.6.0.5.php similarity index 100% rename from app/code/core/Mage/Core/data/core_setup/data-upgrade-1.6.0.4-1.6.0.5.php rename to app/code/Mage/Core/data/core_setup/data-upgrade-1.6.0.4-1.6.0.5.php diff --git a/app/code/core/Mage/Core/data/core_setup/data-upgrade-1.6.0.5-1.6.0.6.php b/app/code/Mage/Core/data/core_setup/data-upgrade-1.6.0.5-1.6.0.6.php similarity index 100% rename from app/code/core/Mage/Core/data/core_setup/data-upgrade-1.6.0.5-1.6.0.6.php rename to app/code/Mage/Core/data/core_setup/data-upgrade-1.6.0.5-1.6.0.6.php diff --git a/app/code/core/Mage/Core/etc/api.xml b/app/code/Mage/Core/etc/api.xml similarity index 100% rename from app/code/core/Mage/Core/etc/api.xml rename to app/code/Mage/Core/etc/api.xml diff --git a/app/code/Mage/Core/etc/config.xml b/app/code/Mage/Core/etc/config.xml new file mode 100644 index 0000000000000..ef953d2904cf2 --- /dev/null +++ b/app/code/Mage/Core/etc/config.xml @@ -0,0 +1,433 @@ + + + + + + 1.6.0.12 + true + + + + + + Mage_Core_Model_Encryption + + + + + + + + System(config.xml, local.xml) and modules configuration files(config.xml). + Mage_Core_Model_Cache_Type_Config + + + + Layout building instructions. + Mage_Core_Model_Cache_Type_Layout + + + + Page blocks HTML. + Mage_Core_Model_Cache_Type_Block + + + + Translation files. + Mage_Core_Model_Cache_Type_Translate + + + + Collection data files. + Mage_Core_Model_Cache_Type_Collection + + + + + + 1 + + + + + + Shockwave Flash + + + + + + + + + + 0 + + + 1 + + + + app/etc/aliases_to_classes_map.json + + + + + + Mage_Core_Model_Observer + themeRegistration + + + + + + + Mage_Core_Model_Session + Mage_Core_Model_Datasource_Config + + + 0 + + + + Mage_Core_Model_Config_Proxy + + + + 0 + + + 0 + + + 0 + + + + + + + + frontend + + + + + + default/demo + + + + + standard + + Mage_Core + core + + + + + + + + Mage_Core.csv + + + + + + + + layout.xml + + + + + + + + Mage_Core_Model_Observer + applyThemeCustomization + + + + + + + + + + + Mage_Core.csv + + + + + + + + + Mage_Core_Model_Variable_Observer + prepareWysiwygPluginConfig + + + + + + + Mage_Core_Model_Observer + addSynchronizeNotification + + + + + + + Mage_Core_Model_Observer + addSynchronizeNotification + + + + + + + default/backend + + + + + + + + + Mage_Core.csv + + + + + + + default/basic + + + + + + + 1 + 5 + + + + + + + + 0 + + + 0 + 0 + + + + + + 0 + system.log + exception.log + + + 0 + + + + + 0 + localhost + 25 + + + 0 + default_setup + 3600 + + css + css_secure + js + theme + + + + + + custom1@example.com + Custom 1 + + + custom2@example.com + Custom 2 + + + owner@example.com + Owner + + + sales@example.com + Sales + + + support@example.com + CustomerSupport + + + + + + frontend + Mage_Core_Controller_Varien_Router_Base + Mage_Core_Controller_Varien_Action + + + + 0 + 1 + + + 0 + + + {{base_url}} + {{unsecure_base_url}} + {{unsecure_base_url}} + + + {{unsecure_base_url}} + {{secure_base_url}} + {{secure_base_url}} + 0 + 0 + SSL_OFFLOADED + + + 3600 + 1 + 0 + 31536000 + + + 0 + 0 + 0 + 0 + 1 + + + 1 + 1 + + + + + dashboard + + + 0 + + + + 1 + + + + + AT,BE,BG,CY,CZ,DK,EE,FI,FR,DE,GR,HU,IE,IT,LV,LT,LU,MT,NL,PL,PT,RO,SK,SI,ES,SE,GB + + + 0 + 0,6 + + + + php + htaccess + jsp + pl + py + asp + sh + cgi + htm + html + phtml + shtml + + + + /app/*/* + + + + + 0 + + + + + GD2 + + + + + + + + + frontend + Mage_Core_Controller_Varien_Router_Base + Mage_Core_Controller_Varien_Action + + + + + + + + + + 30 2 * * * + + + Mage_Core_Model_Observer::cleanCache + + + + + diff --git a/app/code/core/Mage/Core/etc/jstranslator.xml b/app/code/Mage/Core/etc/jstranslator.xml similarity index 100% rename from app/code/core/Mage/Core/etc/jstranslator.xml rename to app/code/Mage/Core/etc/jstranslator.xml diff --git a/app/code/core/Mage/Core/etc/wsdl.xml b/app/code/Mage/Core/etc/wsdl.xml similarity index 100% rename from app/code/core/Mage/Core/etc/wsdl.xml rename to app/code/Mage/Core/etc/wsdl.xml diff --git a/app/code/core/Mage/Core/etc/wsi.xml b/app/code/Mage/Core/etc/wsi.xml similarity index 100% rename from app/code/core/Mage/Core/etc/wsi.xml rename to app/code/Mage/Core/etc/wsi.xml diff --git a/app/code/core/Mage/Core/functions.php b/app/code/Mage/Core/functions.php similarity index 100% rename from app/code/core/Mage/Core/functions.php rename to app/code/Mage/Core/functions.php diff --git a/app/code/core/Mage/Core/locale/de_DE/Mage_Core.csv b/app/code/Mage/Core/locale/de_DE/Mage_Core.csv similarity index 100% rename from app/code/core/Mage/Core/locale/de_DE/Mage_Core.csv rename to app/code/Mage/Core/locale/de_DE/Mage_Core.csv diff --git a/app/code/core/Mage/Core/locale/en_US/Mage_Core.csv b/app/code/Mage/Core/locale/en_US/Mage_Core.csv similarity index 100% rename from app/code/core/Mage/Core/locale/en_US/Mage_Core.csv rename to app/code/Mage/Core/locale/en_US/Mage_Core.csv diff --git a/app/code/core/Mage/Core/locale/es_ES/Mage_Core.csv b/app/code/Mage/Core/locale/es_ES/Mage_Core.csv similarity index 100% rename from app/code/core/Mage/Core/locale/es_ES/Mage_Core.csv rename to app/code/Mage/Core/locale/es_ES/Mage_Core.csv diff --git a/app/code/core/Mage/Core/locale/fr_FR/Mage_Core.csv b/app/code/Mage/Core/locale/fr_FR/Mage_Core.csv similarity index 100% rename from app/code/core/Mage/Core/locale/fr_FR/Mage_Core.csv rename to app/code/Mage/Core/locale/fr_FR/Mage_Core.csv diff --git a/app/code/core/Mage/Core/locale/nl_NL/Mage_Core.csv b/app/code/Mage/Core/locale/nl_NL/Mage_Core.csv similarity index 100% rename from app/code/core/Mage/Core/locale/nl_NL/Mage_Core.csv rename to app/code/Mage/Core/locale/nl_NL/Mage_Core.csv diff --git a/app/code/core/Mage/Core/locale/pt_BR/Mage_Core.csv b/app/code/Mage/Core/locale/pt_BR/Mage_Core.csv similarity index 100% rename from app/code/core/Mage/Core/locale/pt_BR/Mage_Core.csv rename to app/code/Mage/Core/locale/pt_BR/Mage_Core.csv diff --git a/app/code/core/Mage/Core/locale/zh_CN/Mage_Core.csv b/app/code/Mage/Core/locale/zh_CN/Mage_Core.csv similarity index 100% rename from app/code/core/Mage/Core/locale/zh_CN/Mage_Core.csv rename to app/code/Mage/Core/locale/zh_CN/Mage_Core.csv diff --git a/app/code/core/Mage/Core/sql/core_setup/install-1.6.0.0.php b/app/code/Mage/Core/sql/core_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Core/sql/core_setup/install-1.6.0.0.php rename to app/code/Mage/Core/sql/core_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Core/sql/core_setup/mysql4-data-upgrade-1.6.0.2-1.6.0.3.php b/app/code/Mage/Core/sql/core_setup/mysql4-data-upgrade-1.6.0.2-1.6.0.3.php similarity index 100% rename from app/code/core/Mage/Core/sql/core_setup/mysql4-data-upgrade-1.6.0.2-1.6.0.3.php rename to app/code/Mage/Core/sql/core_setup/mysql4-data-upgrade-1.6.0.2-1.6.0.3.php diff --git a/app/code/core/Mage/Core/sql/core_setup/upgrade-1.6.0.1-1.6.0.2.php b/app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.1-1.6.0.2.php similarity index 100% rename from app/code/core/Mage/Core/sql/core_setup/upgrade-1.6.0.1-1.6.0.2.php rename to app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.1-1.6.0.2.php diff --git a/app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.10-1.6.0.11.php b/app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.10-1.6.0.11.php new file mode 100644 index 0000000000000..5ada0d39eb6bb --- /dev/null +++ b/app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.10-1.6.0.11.php @@ -0,0 +1,51 @@ +startSetup(); +$connection = $installer->getConnection(); + +/** + * Add column 'type' to 'core_theme' + */ +$connection->addColumn($installer->getTable('core_theme'), 'type', array( + 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT, + 'nullable' => false, + 'comment' => 'Theme type: 0:physical, 1:virtual, 2:staging' +)); + +/** + * Rename table + */ +$wrongName = 'core_theme_files'; +$rightName = 'core_theme_file'; +if ($installer->tableExists($wrongName)) { + $connection->renameTable($installer->getTable($wrongName), $installer->getTable($rightName)); +} + +$installer->endSetup(); diff --git a/app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.11-1.6.0.12.php b/app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.11-1.6.0.12.php new file mode 100644 index 0000000000000..b9ca845587827 --- /dev/null +++ b/app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.11-1.6.0.12.php @@ -0,0 +1,134 @@ +startSetup(); +$connection = $installer->getConnection(); + +$oldName = 'core_theme_files_link'; +$newName = 'core_theme_file_update'; + +$oldTableName = $installer->getTable($oldName); + +/** + * Drop foreign key and index + */ +$connection->dropForeignKey( + $oldTableName, + $installer->getFkName($oldName, 'theme_id', 'core_theme', 'theme_id') +); +$connection->dropIndex( + $oldTableName, + $installer->getFkName($oldName, 'theme_id', 'core_theme', 'theme_id') +); + +/** + * Rename table + */ +if ($installer->tableExists($oldName)) { + $connection->renameTable($installer->getTable($oldName), $installer->getTable($newName)); +} + +$newTableName = $installer->getTable($newName); + +/** + * Rename column + */ +$oldColumn = 'files_link_id'; +$newColumn = 'file_update_id'; +$connection->changeColumn($newTableName, $oldColumn, $newColumn, array( + 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, + 'primary' => true, + 'nullable' => false, + 'unsigned' => true, + 'comment' => 'Customization file update id' +)); + +/** + * Rename column + */ +$oldColumn = 'layout_link_id'; +$newColumn = 'layout_update_id'; +$connection->changeColumn($newTableName, $oldColumn, $newColumn, array( + 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, + 'nullable' => false, + 'unsigned' => true, + 'comment' => 'Theme layout update id' +)); + +/** + * Add foreign keys and indexes + */ +$connection->addIndex( + $newTableName, + $installer->getIdxName($newTableName, 'theme_id', Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE), + 'theme_id', + Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE +); +$connection->addForeignKey( + $installer->getFkName($newTableName, 'theme_id', 'core_theme', 'theme_id'), + $newTableName, + 'theme_id', + $installer->getTable('core_theme'), + 'theme_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE +); +$connection->addIndex( + $newTableName, + $installer->getIdxName($newTableName, 'layout_update_id', Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX), + 'layout_update_id', + Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX +); +$connection->addForeignKey( + $installer->getFkName($newTableName, 'layout_update_id', 'core_layout_update', 'layout_update_id'), + $newTableName, + 'layout_update_id', + $installer->getTable('core_layout_update'), + 'layout_update_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE +); + +/** + * Change data + */ +$select = $connection->select() + ->from($newTableName) + ->join( + array('link' => $installer->getTable('core_layout_link')), + sprintf('link.layout_link_id = %s.layout_update_id', $newTableName) + ); +$rows = $connection->fetchAll($select); +foreach ($rows as $row) { + $connection->update( + $newTableName, + array('layout_update_id' => $row['layout_update_id']), + 'file_update_id = ' . $row['file_update_id'] + ); +} + +$installer->endSetup(); diff --git a/app/code/core/Mage/Core/sql/core_setup/upgrade-1.6.0.2-1.6.0.3.php b/app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.2-1.6.0.3.php similarity index 100% rename from app/code/core/Mage/Core/sql/core_setup/upgrade-1.6.0.2-1.6.0.3.php rename to app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.2-1.6.0.3.php diff --git a/app/code/core/Mage/Core/sql/core_setup/upgrade-1.6.0.3-1.6.0.4.php b/app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.3-1.6.0.4.php similarity index 100% rename from app/code/core/Mage/Core/sql/core_setup/upgrade-1.6.0.3-1.6.0.4.php rename to app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.3-1.6.0.4.php diff --git a/app/code/core/Mage/Core/sql/core_setup/upgrade-1.6.0.5-1.6.0.6.php b/app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.5-1.6.0.6.php similarity index 100% rename from app/code/core/Mage/Core/sql/core_setup/upgrade-1.6.0.5-1.6.0.6.php rename to app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.5-1.6.0.6.php diff --git a/app/code/core/Mage/Core/sql/core_setup/upgrade-1.6.0.6-1.6.0.7.php b/app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.6-1.6.0.7.php similarity index 100% rename from app/code/core/Mage/Core/sql/core_setup/upgrade-1.6.0.6-1.6.0.7.php rename to app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.6-1.6.0.7.php diff --git a/app/code/core/Mage/Core/sql/core_setup/upgrade-1.6.0.7-1.6.0.8.php b/app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.7-1.6.0.8.php similarity index 100% rename from app/code/core/Mage/Core/sql/core_setup/upgrade-1.6.0.7-1.6.0.8.php rename to app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.7-1.6.0.8.php diff --git a/app/code/core/Mage/Core/sql/core_setup/upgrade-1.6.0.8-1.6.0.9.php b/app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.8-1.6.0.9.php similarity index 100% rename from app/code/core/Mage/Core/sql/core_setup/upgrade-1.6.0.8-1.6.0.9.php rename to app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.8-1.6.0.9.php diff --git a/app/code/core/Mage/Core/sql/core_setup/upgrade-1.6.0.9-1.6.0.10.php b/app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.9-1.6.0.10.php similarity index 100% rename from app/code/core/Mage/Core/sql/core_setup/upgrade-1.6.0.9-1.6.0.10.php rename to app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.9-1.6.0.10.php diff --git a/app/code/core/Mage/Core/view/adminhtml/calendar.gif b/app/code/Mage/Core/view/adminhtml/calendar.gif similarity index 100% rename from app/code/core/Mage/Core/view/adminhtml/calendar.gif rename to app/code/Mage/Core/view/adminhtml/calendar.gif diff --git a/app/code/core/Mage/Core/view/adminhtml/fam_book_open.png b/app/code/Mage/Core/view/adminhtml/fam_book_open.png similarity index 100% rename from app/code/core/Mage/Core/view/adminhtml/fam_book_open.png rename to app/code/Mage/Core/view/adminhtml/fam_book_open.png diff --git a/app/code/core/Mage/Core/view/adminhtml/logo_email.gif b/app/code/Mage/Core/view/adminhtml/logo_email.gif similarity index 100% rename from app/code/core/Mage/Core/view/adminhtml/logo_email.gif rename to app/code/Mage/Core/view/adminhtml/logo_email.gif diff --git a/app/code/Mage/Core/view/adminhtml/prototype/magento.css b/app/code/Mage/Core/view/adminhtml/prototype/magento.css new file mode 100644 index 0000000000000..cd204542c3449 --- /dev/null +++ b/app/code/Mage/Core/view/adminhtml/prototype/magento.css @@ -0,0 +1,587 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Core + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +/* TODO: remove these styles after re-factoring prototype popups to jquery UI */ +.dialog .bot { + display: none !important; +} + +.overlay_magento { + background-color: #000; + filter: alpha(opacity = 44); + -moz-opacity: .44; + -webkit-opacity: .44; + opacity: .44; +} + +.top.table_window td, +.top.table_window td:hover { + background: #f3efea; + border: 0; +} + +.mid.table_window td, +.mid.table_window td:hover { + background: #fff; + border: 0; +} + +.magento_nw, +.magento_ne, +.magento_w, +.magento_e, +.magento_sw, +.magento_se { + display: none; +} + +.magento_sizer { + background: #deebf0; + width: 5px; + height: 3px; +} + +.magento_sizer { + cursor: se-resize; +} + +.magento_close { + background: none; + cursor: pointer; + margin: 0; + padding: 0; + position: absolute; + top: 18px; + right: 16px; + height: 16px; + width: 16px; + z-index: 1000; + text-decoration: none; +} + +.magento_close:before { + color: #676056; + content: "\e07d"; + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; +} + +.magento_title { + color: #676056; + font: 20px/1 'CallunaSans', Arial, Helvetica, sans-serif; + padding: 20px 0 19px 20px; +} + +.magento_content { + height: auto !important; + margin: 0 auto; +} + +.magento_buttons { + padding: 10px; + text-align: right; +} + +.popup-window .main-col, +.popup-window .side-col { + float: left; +} + +.popup-window .main-col:after, +.popup-window .side-col:after { + display: none; +} + +.popup-window .main-col { + padding-right: 0; +} + +.magento_message { + padding: 19px; + position: relative; +} +.magento_message > .page-actions { + padding-top: 0; +} + +.popup-window .magento_message .fieldset { + border: 0; +} + +.popup-window .magento_message .fieldset select { + border-radius: 4px; +} + +.popup-window .magento_message .fieldset select { + border-radius: 4px; +} + +.popup-window .magento_message .fieldset .addon select { + display: block; +} + +.popup-window .magento_message .fieldset .addon .addafter { + border: 0; + color: #666; + display: block; +} + +.popup-window .magento_message .fieldset .nm { + margin: 4px 0 0; +} + +.popup-window .magento_message .fieldset .nm small { + font-size: 11px; + font-weight: normal; +} + +.popup-window .magento_message .fieldset .widget-option-label { + padding: 5px 0 0; +} + +.popup-window [id$="_focus_anchor"]:focus { + outline: none; +} + +.popup-window .page-actions { + padding: 0; + position: absolute; + right: 19px; + top: 29px; + z-index: 2; +} + +.popup-window label.mage-error { + display: block; + margin: -29px 0 5px; +} + +.popup-window .select + .mage-error { + margin: 5px 0 0; +} + +/* + Styles for tables in popup window +-------------------------------------- */ + +.popup-window .data { + border-collapse: inherit; /* do not remove this! without this rule in FF when table has only 1 row bottom and side borders disappear */ + width: 100%; +} + +.popup-window .grid .data { + border-left: 1px solid #c0bbaf; + border-right: 1px solid #c0bbaf; +} + +.popup-window .grid .data tr:last-child td { + border-bottom-color: #c0bbaf; +} + +.popup-window .grid tr.headings th, +.popup-window .grid tr.filter th { + background: #fff; + border-color: #c9c2b8; + border-width: 0 0 1px; + color: #666; + padding: 3px 7px; +} + +.popup-window .grid tr.headings th a { + color: #666; +} + +.popup-window .data tr.headings th:hover > span { + border-color: #cac2b5; +} + +.popup-window .grid tr.headings th a:after { + color: #dbd6ce; +} + +.popup-window .grid tr.headings th a:hover:after { + color: #cac2b5; +} + +.popup-window .grid .filter input.input-text, +.popup-window .grid .filter select { + background: #fff; + border: 1px solid #ccc; + color: #666; +} + +.popup-window .grid tr th:first-child { + border: 0; +} + +.popup-window .grid tbody tr:first-child td { + border-top: 1px solid #eae8e4; +} + +.popup-window .grid tbody tr td, +.popup-window .grid tbody tr td:hover { + border-bottom: 1px solid #eae8e4; + padding: 3px 7px; +} + +.popup-window .grid tbody tr:nth-child(odd) td, +.popup-window .grid tbody tr:nth-child(odd):hover td { + background: #fbfaf6; +} + +.popup-window .grid tr.on-mouse td, +.popup-window .grid table tbody tr.on-mouse:hover td, +.popup-window .grid table tbody tr.on-mouse:nth-child(odd):hover td { + background-color: #f3efea; +} + +.popup-window .data .col-id { + width: 35px; +} + +.popup-window .data .col-sku { + width: 27%; +} + +/* + WYSIWYG insert file +-------------------------------------- */ + +.insert-title-inner { + border-bottom: 1px solid #ededed; + margin: 0 0 18px; +} + +.insert-actions, +.insert-actions .action-.delete, +.insert-actions .action-delete { + float: right; +} + +.insert-title-inner > .title { + color: #666; + display: inline-block; + font-family: 'CallunaSans', Arial, sans-serif; + font-size: 18px; + font-weight: normal; + padding: 7px 0 10px; +} + +/* + Upload images +-------------------------------------- */ +.magento_message .main-col-inner .uploader { + background: #fbfaf6; + border: 1px solid #cac2b5; + margin: 0 0 10px; + padding: 5px; +} + +.magento_message .breadcrumbs { + padding-left: 0; +} + +.magento_message .breadcrumbs li:after { + content: ""; + margin: 0 5px 0 0; +} + +.magento_message .fileinput-button { + display: inline-block; + cursor: pointer; + float: none; + vertical-align: middle; +} + +.magento_message .file-row { + background: #fff; + border: 1px solid #cac2b5; + margin: 5px 0; + padding: 2px; +} + +.magento_message .filecnt { + border: 1px solid #cac2b5; + display: inline-block; + margin: 0 4px 15px 0; + padding: 3px; + width: 100px; + overflow: hidden; +} + +.magento_message .filecnt.selected { + border-color: #19a3d1; +} + +.magento_message .filecnt p { + text-align: center; +} + +.magento_message #contents-uploader:after, +.magento_message #contents-uploader:before { + content: ""; + display: table; +} + +.magento_message #contents-uploader:after { + clear: both; +} + +.magento_message .x-tree { + margin-bottom: 20px; +} + +/* + Block 'Insert variable' +-------------------------------------- */ +.insert-variable { + list-style: none; + margin: 0; + padding: 0 0 25px; +} + +.insert-variable li { + padding-left: 20px; +} + +.insert-variable li b { + margin-left: -20px; + margin-top: 5px; + display: inline-block; +} + +/* + Jquery UI +-------------------------------------- */ +.ui-dialog { + background: #fff; + -webkit-box-shadow: 0 3px 6px rgba(0, 0, 0, .4); + box-shadow: 0 3px 6px rgba(0, 0, 0, .4); +} + +.dialog.ui-dialog { + border: 1px solid #555; + display: none; + padding: 0; +} + +.ui-widget-overlay { + background: #000; + filter: alpha(opacity = 60); + -moz-opacity: .44; + -webkit-opacity: .44; + opacity: .44; + position: absolute; + left: 0; + top: 0; +} + +.ui-dialog .ui-dialog-titlebar { + background: #f3efea; + height: 58px; +} + +.ui-dialog .ui-dialog-title { + color: #676056; + font: normal 20px/1 'CallunaSans'; + display: block; + padding: 19px 0 19px 20px; + cursor: move; +} + +.ui-dialog .ui-icon { + text-indent: -99999px; +} + +.ui-dialog .ui-dialog-titlebar-close { + background: none; + cursor: pointer; + margin: 0px; + padding: 0; + position: absolute; + top: 18px; + right: 16px; + height: 16px; + width: 16px; + z-index: 1000; + text-decoration: none; +} + +.ui-dialog .ui-dialog-titlebar-close:before { + color: #676056; + content: "\e07d"; + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; +} + +.ui-dialog .ui-dialog-titlebar-close .ui-icon { + display: none; +} + +.ui-dialog .ui-dialog-titlebar-close.ui-state-hover { + border: none; +} + +.ui-dialog .ui-dialog-content { + padding: 10px 10px 0; +} + +.ui-dialog .ui-dialog-content .fieldset { + border-radius: 0; + border: none; +} + +.ui-dialog .ui-dialog-content { + overflow: auto; + padding: 25px 25px 0; +} + +.ui-dialog .ui-dialog-content label.mage-error { + margin: 0; +} + +.ui-dialog .ui-dialog-content form { + display: block; + overflow: hidden; +} + +.ui-dialog .ui-dialog-buttonpane { + margin: 0; + padding: 25px; + border: none; +} + +.ui-dialog .ui-dialog-buttonset { + text-align: right; +} + +.ui-dialog .ui-dialog-buttonset button { + margin-left: 10px; +} + +.ui-resizable { + position: relative; +} + +.ui-resizable-handle { + position: absolute; + font-size: 0.1px; + display: block; +} + +.ui-resizable-disabled .ui-resizable-handle, +.ui-resizable-autohide .ui-resizable-handle { + display: none; +} + +.ui-resizable-n { + cursor: n-resize; + height: 7px; + width: 100%; + top: -5px; + left: 0; +} + +.ui-resizable-s { + cursor: s-resize; + height: 7px; + width: 100%; + bottom: 0; + left: 0; +} + +.ui-resizable-e { + cursor: e-resize; + width: 7px; + right: 0; + top: 0; + height: 100%; +} + +.ui-resizable-w { + cursor: w-resize; + width: 7px; + left: -7px; + top: 0; + height: 100%; +} + +.ui-resizable-se { + cursor: se-resize; + width: 12px; + height: 12px; + right: 1px; + bottom: 1px; +} + +.ui-resizable-sw { + cursor: sw-resize; + width: 9px; + height: 9px; + left: -5px; + bottom: 0; +} + +.ui-resizable-nw { + cursor: nw-resize; + width: 9px; + height: 9px; + left: -5px; + top: -5px; +} + +.ui-resizable-ne { + cursor: ne-resize; + width: 9px; + height: 9px; + right: 0; + top: -5px; +} + +.ui-dialog ul.form-list, +.ui-dialog ul.options-list { + list-style: none; + padding: 0; +} + +/* + Clearfix +-------------------------------------- */ + +.insert-title-inner:before, +.insert-title-inner:after { + content: ""; + display: table; +} + +.insert-title-inner:after { + clear: both; +} \ No newline at end of file diff --git a/app/code/core/Mage/Core/view/adminhtml/prototype/magento/btn_bg.gif b/app/code/Mage/Core/view/adminhtml/prototype/magento/btn_bg.gif similarity index 100% rename from app/code/core/Mage/Core/view/adminhtml/prototype/magento/btn_bg.gif rename to app/code/Mage/Core/view/adminhtml/prototype/magento/btn_bg.gif diff --git a/app/code/core/Mage/Core/view/adminhtml/prototype/magento/content_bg.gif b/app/code/Mage/Core/view/adminhtml/prototype/magento/content_bg.gif similarity index 100% rename from app/code/core/Mage/Core/view/adminhtml/prototype/magento/content_bg.gif rename to app/code/Mage/Core/view/adminhtml/prototype/magento/content_bg.gif diff --git a/app/code/core/Mage/Core/view/adminhtml/prototype/magento/top_bg.gif b/app/code/Mage/Core/view/adminhtml/prototype/magento/top_bg.gif similarity index 100% rename from app/code/core/Mage/Core/view/adminhtml/prototype/magento/top_bg.gif rename to app/code/Mage/Core/view/adminhtml/prototype/magento/top_bg.gif diff --git a/app/code/core/Mage/Core/view/adminhtml/prototype/magento/window_close.png b/app/code/Mage/Core/view/adminhtml/prototype/magento/window_close.png similarity index 100% rename from app/code/core/Mage/Core/view/adminhtml/prototype/magento/window_close.png rename to app/code/Mage/Core/view/adminhtml/prototype/magento/window_close.png diff --git a/app/code/core/Mage/Core/view/adminhtml/theme/default_preview.jpg b/app/code/Mage/Core/view/adminhtml/theme/default_preview.jpg similarity index 100% rename from app/code/core/Mage/Core/view/adminhtml/theme/default_preview.jpg rename to app/code/Mage/Core/view/adminhtml/theme/default_preview.jpg diff --git a/app/code/core/Mage/Core/view/frontend/calendar.gif b/app/code/Mage/Core/view/frontend/calendar.gif similarity index 100% rename from app/code/core/Mage/Core/view/frontend/calendar.gif rename to app/code/Mage/Core/view/frontend/calendar.gif diff --git a/app/code/core/Mage/Core/view/frontend/fam_book_open.png b/app/code/Mage/Core/view/frontend/fam_book_open.png similarity index 100% rename from app/code/core/Mage/Core/view/frontend/fam_book_open.png rename to app/code/Mage/Core/view/frontend/fam_book_open.png diff --git a/app/code/core/Mage/Core/view/frontend/formkey.phtml b/app/code/Mage/Core/view/frontend/formkey.phtml similarity index 100% rename from app/code/core/Mage/Core/view/frontend/formkey.phtml rename to app/code/Mage/Core/view/frontend/formkey.phtml diff --git a/app/code/core/Mage/Core/view/frontend/layout.xml b/app/code/Mage/Core/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/Core/view/frontend/layout.xml rename to app/code/Mage/Core/view/frontend/layout.xml diff --git a/app/code/core/Mage/Core/view/frontend/link.phtml b/app/code/Mage/Core/view/frontend/link.phtml similarity index 100% rename from app/code/core/Mage/Core/view/frontend/link.phtml rename to app/code/Mage/Core/view/frontend/link.phtml diff --git a/app/code/core/Mage/Core/view/frontend/logo_email.gif b/app/code/Mage/Core/view/frontend/logo_email.gif similarity index 100% rename from app/code/core/Mage/Core/view/frontend/logo_email.gif rename to app/code/Mage/Core/view/frontend/logo_email.gif diff --git a/app/code/core/Mage/Core/view/frontend/messages.phtml b/app/code/Mage/Core/view/frontend/messages.phtml similarity index 100% rename from app/code/core/Mage/Core/view/frontend/messages.phtml rename to app/code/Mage/Core/view/frontend/messages.phtml diff --git a/app/code/core/Mage/Core/view/frontend/prototype/magento.css b/app/code/Mage/Core/view/frontend/prototype/magento.css similarity index 100% rename from app/code/core/Mage/Core/view/frontend/prototype/magento.css rename to app/code/Mage/Core/view/frontend/prototype/magento.css diff --git a/app/code/core/Mage/Core/view/frontend/prototype/magento/btn_bg.gif b/app/code/Mage/Core/view/frontend/prototype/magento/btn_bg.gif similarity index 100% rename from app/code/core/Mage/Core/view/frontend/prototype/magento/btn_bg.gif rename to app/code/Mage/Core/view/frontend/prototype/magento/btn_bg.gif diff --git a/app/code/core/Mage/Core/view/frontend/prototype/magento/content_bg.gif b/app/code/Mage/Core/view/frontend/prototype/magento/content_bg.gif similarity index 100% rename from app/code/core/Mage/Core/view/frontend/prototype/magento/content_bg.gif rename to app/code/Mage/Core/view/frontend/prototype/magento/content_bg.gif diff --git a/app/code/core/Mage/Core/view/frontend/prototype/magento/top_bg.gif b/app/code/Mage/Core/view/frontend/prototype/magento/top_bg.gif similarity index 100% rename from app/code/core/Mage/Core/view/frontend/prototype/magento/top_bg.gif rename to app/code/Mage/Core/view/frontend/prototype/magento/top_bg.gif diff --git a/app/code/core/Mage/Core/view/frontend/prototype/magento/window_close.png b/app/code/Mage/Core/view/frontend/prototype/magento/window_close.png similarity index 100% rename from app/code/core/Mage/Core/view/frontend/prototype/magento/window_close.png rename to app/code/Mage/Core/view/frontend/prototype/magento/window_close.png diff --git a/app/code/core/Mage/Cron/Exception.php b/app/code/Mage/Cron/Exception.php similarity index 100% rename from app/code/core/Mage/Cron/Exception.php rename to app/code/Mage/Cron/Exception.php diff --git a/app/code/core/Mage/Cron/Helper/Data.php b/app/code/Mage/Cron/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Cron/Helper/Data.php rename to app/code/Mage/Cron/Helper/Data.php diff --git a/app/code/core/Mage/Cron/Model/Config/Backend/Product/Alert.php b/app/code/Mage/Cron/Model/Config/Backend/Product/Alert.php similarity index 100% rename from app/code/core/Mage/Cron/Model/Config/Backend/Product/Alert.php rename to app/code/Mage/Cron/Model/Config/Backend/Product/Alert.php diff --git a/app/code/core/Mage/Cron/Model/Config/Backend/Sitemap.php b/app/code/Mage/Cron/Model/Config/Backend/Sitemap.php similarity index 100% rename from app/code/core/Mage/Cron/Model/Config/Backend/Sitemap.php rename to app/code/Mage/Cron/Model/Config/Backend/Sitemap.php diff --git a/app/code/core/Mage/Cron/Model/Config/Source/Frequency.php b/app/code/Mage/Cron/Model/Config/Source/Frequency.php similarity index 100% rename from app/code/core/Mage/Cron/Model/Config/Source/Frequency.php rename to app/code/Mage/Cron/Model/Config/Source/Frequency.php diff --git a/app/code/core/Mage/Cron/Model/Observer.php b/app/code/Mage/Cron/Model/Observer.php similarity index 100% rename from app/code/core/Mage/Cron/Model/Observer.php rename to app/code/Mage/Cron/Model/Observer.php diff --git a/app/code/core/Mage/Cron/Model/Resource/Schedule.php b/app/code/Mage/Cron/Model/Resource/Schedule.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Cron/Model/Resource/Schedule.php rename to app/code/Mage/Cron/Model/Resource/Schedule.php diff --git a/app/code/core/Mage/Cron/Model/Resource/Schedule/Collection.php b/app/code/Mage/Cron/Model/Resource/Schedule/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Cron/Model/Resource/Schedule/Collection.php rename to app/code/Mage/Cron/Model/Resource/Schedule/Collection.php diff --git a/app/code/core/Mage/Cron/Model/Schedule.php b/app/code/Mage/Cron/Model/Schedule.php similarity index 100% rename from app/code/core/Mage/Cron/Model/Schedule.php rename to app/code/Mage/Cron/Model/Schedule.php diff --git a/app/code/core/Mage/Cron/etc/adminhtml/system.xml b/app/code/Mage/Cron/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Cron/etc/adminhtml/system.xml rename to app/code/Mage/Cron/etc/adminhtml/system.xml diff --git a/app/code/Mage/Cron/etc/config.xml b/app/code/Mage/Cron/etc/config.xml new file mode 100644 index 0000000000000..e644aa63db387 --- /dev/null +++ b/app/code/Mage/Cron/etc/config.xml @@ -0,0 +1,82 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + Mage_Cron + + + + + + + + + + Mage_Cron_Model_Observer + dispatch + + + + + + + + + 15 + 20 + 15 + 10 + 60 + 600 + + + + + + + + + Mage_Cron.csv + + + + + + diff --git a/app/code/core/Mage/Cron/locale/de_DE/Mage_Cron.csv b/app/code/Mage/Cron/locale/de_DE/Mage_Cron.csv similarity index 100% rename from app/code/core/Mage/Cron/locale/de_DE/Mage_Cron.csv rename to app/code/Mage/Cron/locale/de_DE/Mage_Cron.csv diff --git a/app/code/core/Mage/Cron/locale/en_US/Mage_Cron.csv b/app/code/Mage/Cron/locale/en_US/Mage_Cron.csv similarity index 100% rename from app/code/core/Mage/Cron/locale/en_US/Mage_Cron.csv rename to app/code/Mage/Cron/locale/en_US/Mage_Cron.csv diff --git a/app/code/core/Mage/Cron/locale/es_ES/Mage_Cron.csv b/app/code/Mage/Cron/locale/es_ES/Mage_Cron.csv similarity index 100% rename from app/code/core/Mage/Cron/locale/es_ES/Mage_Cron.csv rename to app/code/Mage/Cron/locale/es_ES/Mage_Cron.csv diff --git a/app/code/core/Mage/Cron/locale/fr_FR/Mage_Cron.csv b/app/code/Mage/Cron/locale/fr_FR/Mage_Cron.csv similarity index 100% rename from app/code/core/Mage/Cron/locale/fr_FR/Mage_Cron.csv rename to app/code/Mage/Cron/locale/fr_FR/Mage_Cron.csv diff --git a/app/code/core/Mage/Cron/locale/nl_NL/Mage_Cron.csv b/app/code/Mage/Cron/locale/nl_NL/Mage_Cron.csv similarity index 100% rename from app/code/core/Mage/Cron/locale/nl_NL/Mage_Cron.csv rename to app/code/Mage/Cron/locale/nl_NL/Mage_Cron.csv diff --git a/app/code/core/Mage/Cron/locale/pt_BR/Mage_Cron.csv b/app/code/Mage/Cron/locale/pt_BR/Mage_Cron.csv similarity index 100% rename from app/code/core/Mage/Cron/locale/pt_BR/Mage_Cron.csv rename to app/code/Mage/Cron/locale/pt_BR/Mage_Cron.csv diff --git a/app/code/core/Mage/Cron/locale/zh_CN/Mage_Cron.csv b/app/code/Mage/Cron/locale/zh_CN/Mage_Cron.csv similarity index 100% rename from app/code/core/Mage/Cron/locale/zh_CN/Mage_Cron.csv rename to app/code/Mage/Cron/locale/zh_CN/Mage_Cron.csv diff --git a/app/code/core/Mage/Cron/sql/cron_setup/install-1.6.0.0.php b/app/code/Mage/Cron/sql/cron_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Cron/sql/cron_setup/install-1.6.0.0.php rename to app/code/Mage/Cron/sql/cron_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/CurrencySymbol/Block/Adminhtml/System/Currencysymbol.php b/app/code/Mage/CurrencySymbol/Block/Adminhtml/System/Currencysymbol.php similarity index 100% rename from app/code/core/Mage/CurrencySymbol/Block/Adminhtml/System/Currencysymbol.php rename to app/code/Mage/CurrencySymbol/Block/Adminhtml/System/Currencysymbol.php diff --git a/app/code/core/Mage/CurrencySymbol/Helper/Data.php b/app/code/Mage/CurrencySymbol/Helper/Data.php similarity index 100% rename from app/code/core/Mage/CurrencySymbol/Helper/Data.php rename to app/code/Mage/CurrencySymbol/Helper/Data.php diff --git a/app/code/core/Mage/CurrencySymbol/Model/Observer.php b/app/code/Mage/CurrencySymbol/Model/Observer.php similarity index 100% rename from app/code/core/Mage/CurrencySymbol/Model/Observer.php rename to app/code/Mage/CurrencySymbol/Model/Observer.php diff --git a/app/code/core/Mage/CurrencySymbol/Model/System/Currencysymbol.php b/app/code/Mage/CurrencySymbol/Model/System/Currencysymbol.php similarity index 97% rename from app/code/core/Mage/CurrencySymbol/Model/System/Currencysymbol.php rename to app/code/Mage/CurrencySymbol/Model/System/Currencysymbol.php index e90d41931fa0d..d2f1ec44774a9 100644 --- a/app/code/core/Mage/CurrencySymbol/Model/System/Currencysymbol.php +++ b/app/code/Mage/CurrencySymbol/Model/System/Currencysymbol.php @@ -59,9 +59,9 @@ class Mage_CurrencySymbol_Model_System_Currencysymbol * @var array */ protected $_cacheTypes = array( - 'config', - 'block_html', - 'layout' + Mage_Core_Model_Cache_Type_Config::TYPE_IDENTIFIER, + Mage_Core_Model_Cache_Type_Block::TYPE_IDENTIFIER, + Mage_Core_Model_Cache_Type_Layout::TYPE_IDENTIFIER, ); /** diff --git a/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php b/app/code/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php similarity index 97% rename from app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php rename to app/code/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php index 4d4ac6a005a74..48683d996dcc1 100644 --- a/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php +++ b/app/code/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php @@ -40,7 +40,7 @@ public function indexAction() { // set active menu and breadcrumbs $this->loadLayout() - ->_setActiveMenu('Mage_Adminhtml::system_currency') + ->_setActiveMenu('Mage_CurrencySymbol::system_currency_symbols') ->_addBreadcrumb( Mage::helper('Mage_CurrencySymbol_Helper_Data')->__('System'), Mage::helper('Mage_CurrencySymbol_Helper_Data')->__('System') diff --git a/app/code/Mage/CurrencySymbol/etc/adminhtml/acl.xml b/app/code/Mage/CurrencySymbol/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..529ba9e33d334 --- /dev/null +++ b/app/code/Mage/CurrencySymbol/etc/adminhtml/acl.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + diff --git a/app/code/Mage/CurrencySymbol/etc/adminhtml/menu.xml b/app/code/Mage/CurrencySymbol/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..55062a760a745 --- /dev/null +++ b/app/code/Mage/CurrencySymbol/etc/adminhtml/menu.xml @@ -0,0 +1,35 @@ + + + + + + + + + + diff --git a/app/code/Mage/CurrencySymbol/etc/config.xml b/app/code/Mage/CurrencySymbol/etc/config.xml new file mode 100644 index 0000000000000..3e91ded23436e --- /dev/null +++ b/app/code/Mage/CurrencySymbol/etc/config.xml @@ -0,0 +1,82 @@ + + + + + + 1.0.0.0.0 + true + + + + + + + + + + + + Mage_CurrencySymbol_Model_Observer + currencyDisplayOptions + + + + + + + + + + + + Mage_CurrencySymbol_Adminhtml + + + + + + + + + + + layout.xml + + + + + + + + Mage_CurrencySymbol.csv + + + + + + diff --git a/app/code/core/Mage/CurrencySymbol/locale/de_DE/Mage_CurrencySymbol.csv b/app/code/Mage/CurrencySymbol/locale/de_DE/Mage_CurrencySymbol.csv similarity index 100% rename from app/code/core/Mage/CurrencySymbol/locale/de_DE/Mage_CurrencySymbol.csv rename to app/code/Mage/CurrencySymbol/locale/de_DE/Mage_CurrencySymbol.csv diff --git a/app/code/core/Mage/CurrencySymbol/locale/en_US/Mage_CurrencySymbol.csv b/app/code/Mage/CurrencySymbol/locale/en_US/Mage_CurrencySymbol.csv similarity index 100% rename from app/code/core/Mage/CurrencySymbol/locale/en_US/Mage_CurrencySymbol.csv rename to app/code/Mage/CurrencySymbol/locale/en_US/Mage_CurrencySymbol.csv diff --git a/app/code/core/Mage/CurrencySymbol/locale/es_ES/Mage_CurrencySymbol.csv b/app/code/Mage/CurrencySymbol/locale/es_ES/Mage_CurrencySymbol.csv similarity index 100% rename from app/code/core/Mage/CurrencySymbol/locale/es_ES/Mage_CurrencySymbol.csv rename to app/code/Mage/CurrencySymbol/locale/es_ES/Mage_CurrencySymbol.csv diff --git a/app/code/core/Mage/CurrencySymbol/locale/fr_FR/Mage_CurrencySymbol.csv b/app/code/Mage/CurrencySymbol/locale/fr_FR/Mage_CurrencySymbol.csv similarity index 100% rename from app/code/core/Mage/CurrencySymbol/locale/fr_FR/Mage_CurrencySymbol.csv rename to app/code/Mage/CurrencySymbol/locale/fr_FR/Mage_CurrencySymbol.csv diff --git a/app/code/core/Mage/CurrencySymbol/locale/nl_NL/Mage_CurrencySymbol.csv b/app/code/Mage/CurrencySymbol/locale/nl_NL/Mage_CurrencySymbol.csv similarity index 100% rename from app/code/core/Mage/CurrencySymbol/locale/nl_NL/Mage_CurrencySymbol.csv rename to app/code/Mage/CurrencySymbol/locale/nl_NL/Mage_CurrencySymbol.csv diff --git a/app/code/core/Mage/CurrencySymbol/locale/pt_BR/Mage_CurrencySymbol.csv b/app/code/Mage/CurrencySymbol/locale/pt_BR/Mage_CurrencySymbol.csv similarity index 100% rename from app/code/core/Mage/CurrencySymbol/locale/pt_BR/Mage_CurrencySymbol.csv rename to app/code/Mage/CurrencySymbol/locale/pt_BR/Mage_CurrencySymbol.csv diff --git a/app/code/core/Mage/CurrencySymbol/locale/zh_CN/Mage_CurrencySymbol.csv b/app/code/Mage/CurrencySymbol/locale/zh_CN/Mage_CurrencySymbol.csv similarity index 100% rename from app/code/core/Mage/CurrencySymbol/locale/zh_CN/Mage_CurrencySymbol.csv rename to app/code/Mage/CurrencySymbol/locale/zh_CN/Mage_CurrencySymbol.csv diff --git a/app/code/core/Mage/CurrencySymbol/view/adminhtml/grid.phtml b/app/code/Mage/CurrencySymbol/view/adminhtml/grid.phtml similarity index 100% rename from app/code/core/Mage/CurrencySymbol/view/adminhtml/grid.phtml rename to app/code/Mage/CurrencySymbol/view/adminhtml/grid.phtml diff --git a/app/code/core/Mage/CurrencySymbol/view/adminhtml/layout.xml b/app/code/Mage/CurrencySymbol/view/adminhtml/layout.xml similarity index 100% rename from app/code/core/Mage/CurrencySymbol/view/adminhtml/layout.xml rename to app/code/Mage/CurrencySymbol/view/adminhtml/layout.xml diff --git a/app/code/core/Mage/Customer/Block/Account/Dashboard.php b/app/code/Mage/Customer/Block/Account/Dashboard.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Account/Dashboard.php rename to app/code/Mage/Customer/Block/Account/Dashboard.php diff --git a/app/code/core/Mage/Customer/Block/Account/Dashboard/Address.php b/app/code/Mage/Customer/Block/Account/Dashboard/Address.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Account/Dashboard/Address.php rename to app/code/Mage/Customer/Block/Account/Dashboard/Address.php diff --git a/app/code/core/Mage/Customer/Block/Account/Dashboard/Block.php b/app/code/Mage/Customer/Block/Account/Dashboard/Block.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Account/Dashboard/Block.php rename to app/code/Mage/Customer/Block/Account/Dashboard/Block.php diff --git a/app/code/core/Mage/Customer/Block/Account/Dashboard/Hello.php b/app/code/Mage/Customer/Block/Account/Dashboard/Hello.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Account/Dashboard/Hello.php rename to app/code/Mage/Customer/Block/Account/Dashboard/Hello.php diff --git a/app/code/core/Mage/Customer/Block/Account/Dashboard/Info.php b/app/code/Mage/Customer/Block/Account/Dashboard/Info.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Account/Dashboard/Info.php rename to app/code/Mage/Customer/Block/Account/Dashboard/Info.php diff --git a/app/code/core/Mage/Customer/Block/Account/Dashboard/Newsletter.php b/app/code/Mage/Customer/Block/Account/Dashboard/Newsletter.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Account/Dashboard/Newsletter.php rename to app/code/Mage/Customer/Block/Account/Dashboard/Newsletter.php diff --git a/app/code/core/Mage/Customer/Block/Account/Dashboard/Sidebar.php b/app/code/Mage/Customer/Block/Account/Dashboard/Sidebar.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Account/Dashboard/Sidebar.php rename to app/code/Mage/Customer/Block/Account/Dashboard/Sidebar.php diff --git a/app/code/core/Mage/Customer/Block/Account/Forgotpassword.php b/app/code/Mage/Customer/Block/Account/Forgotpassword.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Account/Forgotpassword.php rename to app/code/Mage/Customer/Block/Account/Forgotpassword.php diff --git a/app/code/core/Mage/Customer/Block/Account/Link.php b/app/code/Mage/Customer/Block/Account/Link.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Account/Link.php rename to app/code/Mage/Customer/Block/Account/Link.php diff --git a/app/code/core/Mage/Customer/Block/Account/Navigation.php b/app/code/Mage/Customer/Block/Account/Navigation.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Account/Navigation.php rename to app/code/Mage/Customer/Block/Account/Navigation.php diff --git a/app/code/core/Mage/Customer/Block/Account/Resetpassword.php b/app/code/Mage/Customer/Block/Account/Resetpassword.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Account/Resetpassword.php rename to app/code/Mage/Customer/Block/Account/Resetpassword.php diff --git a/app/code/core/Mage/Customer/Block/Address/Book.php b/app/code/Mage/Customer/Block/Address/Book.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Address/Book.php rename to app/code/Mage/Customer/Block/Address/Book.php diff --git a/app/code/core/Mage/Customer/Block/Address/Edit.php b/app/code/Mage/Customer/Block/Address/Edit.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Address/Edit.php rename to app/code/Mage/Customer/Block/Address/Edit.php diff --git a/app/code/core/Mage/Customer/Block/Address/Renderer/Default.php b/app/code/Mage/Customer/Block/Address/Renderer/Default.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Address/Renderer/Default.php rename to app/code/Mage/Customer/Block/Address/Renderer/Default.php diff --git a/app/code/core/Mage/Customer/Block/Address/Renderer/Interface.php b/app/code/Mage/Customer/Block/Address/Renderer/Interface.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Address/Renderer/Interface.php rename to app/code/Mage/Customer/Block/Address/Renderer/Interface.php diff --git a/app/code/core/Mage/Customer/Block/Form/Edit.php b/app/code/Mage/Customer/Block/Form/Edit.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Form/Edit.php rename to app/code/Mage/Customer/Block/Form/Edit.php diff --git a/app/code/core/Mage/Customer/Block/Form/Login.php b/app/code/Mage/Customer/Block/Form/Login.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Form/Login.php rename to app/code/Mage/Customer/Block/Form/Login.php diff --git a/app/code/core/Mage/Customer/Block/Form/Register.php b/app/code/Mage/Customer/Block/Form/Register.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Form/Register.php rename to app/code/Mage/Customer/Block/Form/Register.php diff --git a/app/code/core/Mage/Customer/Block/Newsletter.php b/app/code/Mage/Customer/Block/Newsletter.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Newsletter.php rename to app/code/Mage/Customer/Block/Newsletter.php diff --git a/app/code/core/Mage/Customer/Block/Widget/Abstract.php b/app/code/Mage/Customer/Block/Widget/Abstract.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Widget/Abstract.php rename to app/code/Mage/Customer/Block/Widget/Abstract.php diff --git a/app/code/core/Mage/Customer/Block/Widget/Dob.php b/app/code/Mage/Customer/Block/Widget/Dob.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Widget/Dob.php rename to app/code/Mage/Customer/Block/Widget/Dob.php diff --git a/app/code/core/Mage/Customer/Block/Widget/Gender.php b/app/code/Mage/Customer/Block/Widget/Gender.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Widget/Gender.php rename to app/code/Mage/Customer/Block/Widget/Gender.php diff --git a/app/code/core/Mage/Customer/Block/Widget/Name.php b/app/code/Mage/Customer/Block/Widget/Name.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Widget/Name.php rename to app/code/Mage/Customer/Block/Widget/Name.php diff --git a/app/code/core/Mage/Customer/Block/Widget/Taxvat.php b/app/code/Mage/Customer/Block/Widget/Taxvat.php similarity index 100% rename from app/code/core/Mage/Customer/Block/Widget/Taxvat.php rename to app/code/Mage/Customer/Block/Widget/Taxvat.php diff --git a/app/code/core/Mage/Customer/Exception.php b/app/code/Mage/Customer/Exception.php similarity index 100% rename from app/code/core/Mage/Customer/Exception.php rename to app/code/Mage/Customer/Exception.php diff --git a/app/code/Mage/Customer/Helper/Address.php b/app/code/Mage/Customer/Helper/Address.php new file mode 100644 index 0000000000000..9cedf9e30470a --- /dev/null +++ b/app/code/Mage/Customer/Helper/Address.php @@ -0,0 +1,311 @@ + + */ +class Mage_Customer_Helper_Address extends Mage_Core_Helper_Abstract +{ + /** + * VAT Validation parameters XML paths + */ + const XML_PATH_VIV_DISABLE_AUTO_ASSIGN_DEFAULT = 'customer/create_account/viv_disable_auto_group_assign_default'; + const XML_PATH_VIV_ON_EACH_TRANSACTION = 'customer/create_account/viv_on_each_transaction'; + const XML_PATH_VAT_VALIDATION_ENABLED = 'customer/create_account/auto_group_assign'; + const XML_PATH_VIV_TAX_CALCULATION_ADDRESS_TYPE = 'customer/create_account/tax_calculation_address_type'; + const XML_PATH_VAT_FRONTEND_VISIBILITY = 'customer/create_account/vat_frontend_visibility'; + + /** + * Array of Customer Address Attributes + * + * @var array + */ + protected $_attributes; + + /** + * Customer address config node per website + * + * @var array + */ + protected $_config = array(); + + /** + * Customer Number of Lines in a Street Address per website + * + * @var array + */ + protected $_streetLines = array(); + protected $_formatTemplate = array(); + + /** + * Block factory + * + * @var Mage_Core_Model_BlockFactory + */ + protected $_blockFactory; + + /** + * @param Mage_Core_Helper_Context $context + * @param Mage_Core_Model_BlockFactory $blockFactory + */ + public function __construct(Mage_Core_Helper_Context $context, Mage_Core_Model_BlockFactory $blockFactory) + { + parent::__construct($context); + $this->_blockFactory = $blockFactory; + } + + /** + * Addresses url + */ + public function getBookUrl() + { + + } + + public function getEditUrl() + { + + } + + public function getDeleteUrl() + { + + } + + public function getCreateUrl() + { + + } + + public function getRenderer($renderer) + { + if (is_string($renderer) && $renderer) { + return $this->_blockFactory->createBlock($renderer, array()); + } else { + return $renderer; + } + } + + /** + * Return customer address config value by key and store + * + * @param string $key + * @param Mage_Core_Model_Store|int|string $store + * @return string|null + */ + public function getConfig($key, $store = null) + { + /** @var $storeManager Mage_Core_Model_StoreManager */ + $storeManager = Mage::getObjectManager()->get('Mage_Core_Model_StoreManager'); + /** @var $store Mage_Core_Model_Store */ + $store = $storeManager->getStore($store); + + $websiteId = $store->getWebsiteId(); + if (!isset($this->_config[$websiteId])) { + $this->_config[$websiteId] = $store->getConfig('customer/address', $store); + } + return isset($this->_config[$websiteId][$key]) ? (string)$this->_config[$websiteId][$key] : null; + } + + /** + * Return Number of Lines in a Street Address for store + * + * @param Mage_Core_Model_Store|int|string $store + * @return int + */ + public function getStreetLines($store = null) + { + $websiteId = Mage::app()->getStore($store)->getWebsiteId(); + if (!isset($this->_streetLines[$websiteId])) { + $attribute = Mage::getSingleton('Mage_Eav_Model_Config')->getAttribute('customer_address', 'street'); + $lines = (int)$attribute->getMultilineCount(); + if ($lines <= 0) { + $lines = 2; + } + $this->_streetLines[$websiteId] = min(4, $lines); + } + + return $this->_streetLines[$websiteId]; + } + + public function getFormat($code) + { + $format = Mage::getSingleton('Mage_Customer_Model_Address_Config')->getFormatByCode($code); + return $format->getRenderer() ? $format->getRenderer()->getFormat() : ''; + } + + /** + * Determine if specified address config value can be shown + * + * @param string $key + * @return bool + */ + public function canShowConfig($key) + { + return (bool)$this->getConfig($key); + } + + /** + * Return array of Customer Address Attributes + * + * @return array + */ + public function getAttributes() + { + if (is_null($this->_attributes)) { + $this->_attributes = array(); + /* @var $config Mage_Eav_Model_Config */ + $config = Mage::getSingleton('Mage_Eav_Model_Config'); + foreach ($config->getEntityAttributeCodes('customer_address') as $attributeCode) { + $this->_attributes[$attributeCode] = $config->getAttribute('customer_address', $attributeCode); + } + } + return $this->_attributes; + } + + /** + * Get string with frontend validation classes for attribute + * + * @param string $attributeCode + * @return string + */ + public function getAttributeValidationClass($attributeCode) + { + /** @var $attribute Mage_Customer_Model_Attribute */ + $attribute = isset($this->_attributes[$attributeCode]) ? $this->_attributes[$attributeCode] + : Mage::getSingleton('Mage_Eav_Model_Config')->getAttribute('customer_address', $attributeCode); + $class = $attribute ? $attribute->getFrontend()->getClass() : ''; + + if (in_array($attributeCode, array('firstname', 'middlename', 'lastname', 'prefix', 'suffix', 'taxvat'))) { + if ($class && !$attribute->getIsVisible()) { + $class = ''; // address attribute is not visible thus its validation rules are not applied + } + + /** @var $customerAttribute Mage_Customer_Model_Attribute */ + $customerAttribute = Mage::getSingleton('Mage_Eav_Model_Config')->getAttribute('customer', $attributeCode); + $class .= $customerAttribute && $customerAttribute->getIsVisible() + ? $customerAttribute->getFrontend()->getClass() : ''; + $class = implode(' ', array_unique(array_filter(explode(' ', $class)))); + } + + return $class; + } + + /** + * Convert streets array to new street lines count + * Examples of use: + * $origStreets = array('street1', 'street2', 'street3', 'street4') + * $toCount = 3 + * Result: + * array('street1 street2', 'street3', 'street4') + * $toCount = 2 + * Result: + * array('street1 street2', 'street3 street4') + * + * @param array $origStreets + * @param int $toCount + * @return array + */ + public function convertStreetLines($origStreets, $toCount) + { + $lines = array(); + if (!empty($origStreets) && $toCount > 0) { + $countArgs = (int)floor(count($origStreets)/$toCount); + $modulo = count($origStreets) % $toCount; + $offset = 0; + $neededLinesCount = 0; + for ($i = 0; $i < $toCount; $i++) { + $offset += $neededLinesCount; + $neededLinesCount = $countArgs; + if ($modulo > 0) { + ++$neededLinesCount; + --$modulo; + } + $values = array_slice($origStreets, $offset, $neededLinesCount); + if (is_array($values)) { + $lines[] = implode(' ', $values); + } + } + } + + return $lines; + } + + /** + * Check whether VAT ID validation is enabled + * + * @param Mage_Core_Model_Store|string|int $store + * @return bool + */ + public function isVatValidationEnabled($store = null) + { + return (bool)Mage::getStoreConfig(self::XML_PATH_VAT_VALIDATION_ENABLED, $store); + } + + /** + * Retrieve disable auto group assign default value + * + * @return bool + */ + public function getDisableAutoGroupAssignDefaultValue() + { + return (bool)Mage::getStoreConfig(self::XML_PATH_VIV_DISABLE_AUTO_ASSIGN_DEFAULT); + } + + /** + * Retrieve 'validate on each transaction' value + * + * @param Mage_Core_Model_Store|string|int $store + * @return bool + */ + public function getValidateOnEachTransaction($store = null) + { + return (bool)Mage::getStoreConfig(self::XML_PATH_VIV_ON_EACH_TRANSACTION, $store); + } + + /** + * Retrieve customer address type on which tax calculation must be based + * + * @param Mage_Core_Model_Store|string|int|null $store + * @return string + */ + public function getTaxCalculationAddressType($store = null) + { + return (string)Mage::getStoreConfig(self::XML_PATH_VIV_TAX_CALCULATION_ADDRESS_TYPE, $store); + } + + /** + * Check if VAT ID address attribute has to be shown on frontend (on Customer Address management forms) + * + * @return boolean + */ + public function isVatAttributeVisible() + { + return (bool)Mage::getStoreConfig(self::XML_PATH_VAT_FRONTEND_VISIBILITY); + } +} diff --git a/app/code/core/Mage/Customer/Helper/Data.php b/app/code/Mage/Customer/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Customer/Helper/Data.php rename to app/code/Mage/Customer/Helper/Data.php diff --git a/app/code/core/Mage/Customer/Model/Address.php b/app/code/Mage/Customer/Model/Address.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Address.php rename to app/code/Mage/Customer/Model/Address.php diff --git a/app/code/core/Mage/Customer/Model/Address/Abstract.php b/app/code/Mage/Customer/Model/Address/Abstract.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Address/Abstract.php rename to app/code/Mage/Customer/Model/Address/Abstract.php diff --git a/app/code/core/Mage/Customer/Model/Address/Api.php b/app/code/Mage/Customer/Model/Address/Api.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Address/Api.php rename to app/code/Mage/Customer/Model/Address/Api.php diff --git a/app/code/core/Mage/Customer/Model/Address/Api/V2.php b/app/code/Mage/Customer/Model/Address/Api/V2.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Address/Api/V2.php rename to app/code/Mage/Customer/Model/Address/Api/V2.php diff --git a/app/code/core/Mage/Customer/Model/Address/Config.php b/app/code/Mage/Customer/Model/Address/Config.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Address/Config.php rename to app/code/Mage/Customer/Model/Address/Config.php diff --git a/app/code/Mage/Customer/Model/Address/Factory.php b/app/code/Mage/Customer/Model/Address/Factory.php new file mode 100644 index 0000000000000..a324206bab4df --- /dev/null +++ b/app/code/Mage/Customer/Model/Address/Factory.php @@ -0,0 +1,53 @@ +_objectManager = $objectManager; + } + + /** + * Create customer address model instance. + * + * @param array $arguments + * @return Mage_Customer_Model_Address + */ + public function create(array $arguments = array()) + { + return $this->_objectManager->create(self::ADDRESS_CLASS_NAME, $arguments); + } +} diff --git a/app/code/core/Mage/Customer/Model/Address/Form.php b/app/code/Mage/Customer/Model/Address/Form.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Address/Form.php rename to app/code/Mage/Customer/Model/Address/Form.php diff --git a/app/code/core/Mage/Customer/Model/Api/Resource.php b/app/code/Mage/Customer/Model/Api/Resource.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Api/Resource.php rename to app/code/Mage/Customer/Model/Api/Resource.php diff --git a/app/code/core/Mage/Customer/Model/Attribute.php b/app/code/Mage/Customer/Model/Attribute.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Attribute.php rename to app/code/Mage/Customer/Model/Attribute.php diff --git a/app/code/core/Mage/Customer/Model/Attribute/Backend/Data/Boolean.php b/app/code/Mage/Customer/Model/Attribute/Backend/Data/Boolean.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Attribute/Backend/Data/Boolean.php rename to app/code/Mage/Customer/Model/Attribute/Backend/Data/Boolean.php diff --git a/app/code/core/Mage/Customer/Model/Attribute/Data.php b/app/code/Mage/Customer/Model/Attribute/Data.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Attribute/Data.php rename to app/code/Mage/Customer/Model/Attribute/Data.php diff --git a/app/code/core/Mage/Customer/Model/Attribute/Data/Abstract.php b/app/code/Mage/Customer/Model/Attribute/Data/Abstract.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Attribute/Data/Abstract.php rename to app/code/Mage/Customer/Model/Attribute/Data/Abstract.php diff --git a/app/code/core/Mage/Customer/Model/Attribute/Data/Boolean.php b/app/code/Mage/Customer/Model/Attribute/Data/Boolean.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Attribute/Data/Boolean.php rename to app/code/Mage/Customer/Model/Attribute/Data/Boolean.php diff --git a/app/code/core/Mage/Customer/Model/Attribute/Data/Date.php b/app/code/Mage/Customer/Model/Attribute/Data/Date.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Attribute/Data/Date.php rename to app/code/Mage/Customer/Model/Attribute/Data/Date.php diff --git a/app/code/core/Mage/Customer/Model/Attribute/Data/File.php b/app/code/Mage/Customer/Model/Attribute/Data/File.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Attribute/Data/File.php rename to app/code/Mage/Customer/Model/Attribute/Data/File.php diff --git a/app/code/core/Mage/Customer/Model/Attribute/Data/Hidden.php b/app/code/Mage/Customer/Model/Attribute/Data/Hidden.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Attribute/Data/Hidden.php rename to app/code/Mage/Customer/Model/Attribute/Data/Hidden.php diff --git a/app/code/core/Mage/Customer/Model/Attribute/Data/Image.php b/app/code/Mage/Customer/Model/Attribute/Data/Image.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Attribute/Data/Image.php rename to app/code/Mage/Customer/Model/Attribute/Data/Image.php diff --git a/app/code/core/Mage/Customer/Model/Attribute/Data/Multiline.php b/app/code/Mage/Customer/Model/Attribute/Data/Multiline.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Attribute/Data/Multiline.php rename to app/code/Mage/Customer/Model/Attribute/Data/Multiline.php diff --git a/app/code/core/Mage/Customer/Model/Attribute/Data/Multiselect.php b/app/code/Mage/Customer/Model/Attribute/Data/Multiselect.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Attribute/Data/Multiselect.php rename to app/code/Mage/Customer/Model/Attribute/Data/Multiselect.php diff --git a/app/code/core/Mage/Customer/Model/Attribute/Data/Postcode.php b/app/code/Mage/Customer/Model/Attribute/Data/Postcode.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Attribute/Data/Postcode.php rename to app/code/Mage/Customer/Model/Attribute/Data/Postcode.php diff --git a/app/code/core/Mage/Customer/Model/Attribute/Data/Select.php b/app/code/Mage/Customer/Model/Attribute/Data/Select.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Attribute/Data/Select.php rename to app/code/Mage/Customer/Model/Attribute/Data/Select.php diff --git a/app/code/core/Mage/Customer/Model/Attribute/Data/Text.php b/app/code/Mage/Customer/Model/Attribute/Data/Text.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Attribute/Data/Text.php rename to app/code/Mage/Customer/Model/Attribute/Data/Text.php diff --git a/app/code/core/Mage/Customer/Model/Attribute/Data/Textarea.php b/app/code/Mage/Customer/Model/Attribute/Data/Textarea.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Attribute/Data/Textarea.php rename to app/code/Mage/Customer/Model/Attribute/Data/Textarea.php diff --git a/app/code/core/Mage/Customer/Model/Config/Backend/Address/Street.php b/app/code/Mage/Customer/Model/Config/Backend/Address/Street.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Config/Backend/Address/Street.php rename to app/code/Mage/Customer/Model/Config/Backend/Address/Street.php diff --git a/app/code/core/Mage/Customer/Model/Config/Backend/Password/Link/Expirationperiod.php b/app/code/Mage/Customer/Model/Config/Backend/Password/Link/Expirationperiod.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Config/Backend/Password/Link/Expirationperiod.php rename to app/code/Mage/Customer/Model/Config/Backend/Password/Link/Expirationperiod.php diff --git a/app/code/core/Mage/Customer/Model/Config/Backend/Show/Address.php b/app/code/Mage/Customer/Model/Config/Backend/Show/Address.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Config/Backend/Show/Address.php rename to app/code/Mage/Customer/Model/Config/Backend/Show/Address.php diff --git a/app/code/core/Mage/Customer/Model/Config/Backend/Show/Customer.php b/app/code/Mage/Customer/Model/Config/Backend/Show/Customer.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Config/Backend/Show/Customer.php rename to app/code/Mage/Customer/Model/Config/Backend/Show/Customer.php diff --git a/app/code/core/Mage/Customer/Model/Config/Share.php b/app/code/Mage/Customer/Model/Config/Share.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Config/Share.php rename to app/code/Mage/Customer/Model/Config/Share.php diff --git a/app/code/core/Mage/Customer/Model/Config/Source/Address/Type.php b/app/code/Mage/Customer/Model/Config/Source/Address/Type.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Config/Source/Address/Type.php rename to app/code/Mage/Customer/Model/Config/Source/Address/Type.php diff --git a/app/code/core/Mage/Customer/Model/Config/Source/Group.php b/app/code/Mage/Customer/Model/Config/Source/Group.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Config/Source/Group.php rename to app/code/Mage/Customer/Model/Config/Source/Group.php diff --git a/app/code/core/Mage/Customer/Model/Config/Source/Group/Multiselect.php b/app/code/Mage/Customer/Model/Config/Source/Group/Multiselect.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Config/Source/Group/Multiselect.php rename to app/code/Mage/Customer/Model/Config/Source/Group/Multiselect.php diff --git a/app/code/core/Mage/Customer/Model/Customer.php b/app/code/Mage/Customer/Model/Customer.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Customer.php rename to app/code/Mage/Customer/Model/Customer.php diff --git a/app/code/core/Mage/Customer/Model/Customer/Api.php b/app/code/Mage/Customer/Model/Customer/Api.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Customer/Api.php rename to app/code/Mage/Customer/Model/Customer/Api.php diff --git a/app/code/core/Mage/Customer/Model/Customer/Api/V2.php b/app/code/Mage/Customer/Model/Customer/Api/V2.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Customer/Api/V2.php rename to app/code/Mage/Customer/Model/Customer/Api/V2.php diff --git a/app/code/core/Mage/Customer/Model/Customer/Attribute/Backend/Billing.php b/app/code/Mage/Customer/Model/Customer/Attribute/Backend/Billing.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Customer/Attribute/Backend/Billing.php rename to app/code/Mage/Customer/Model/Customer/Attribute/Backend/Billing.php diff --git a/app/code/core/Mage/Customer/Model/Customer/Attribute/Backend/Password.php b/app/code/Mage/Customer/Model/Customer/Attribute/Backend/Password.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Customer/Attribute/Backend/Password.php rename to app/code/Mage/Customer/Model/Customer/Attribute/Backend/Password.php diff --git a/app/code/core/Mage/Customer/Model/Customer/Attribute/Backend/Shipping.php b/app/code/Mage/Customer/Model/Customer/Attribute/Backend/Shipping.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Customer/Attribute/Backend/Shipping.php rename to app/code/Mage/Customer/Model/Customer/Attribute/Backend/Shipping.php diff --git a/app/code/core/Mage/Customer/Model/Customer/Attribute/Backend/Store.php b/app/code/Mage/Customer/Model/Customer/Attribute/Backend/Store.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Customer/Attribute/Backend/Store.php rename to app/code/Mage/Customer/Model/Customer/Attribute/Backend/Store.php diff --git a/app/code/core/Mage/Customer/Model/Customer/Attribute/Backend/Website.php b/app/code/Mage/Customer/Model/Customer/Attribute/Backend/Website.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Customer/Attribute/Backend/Website.php rename to app/code/Mage/Customer/Model/Customer/Attribute/Backend/Website.php diff --git a/app/code/core/Mage/Customer/Model/Customer/Attribute/Source/Group.php b/app/code/Mage/Customer/Model/Customer/Attribute/Source/Group.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Customer/Attribute/Source/Group.php rename to app/code/Mage/Customer/Model/Customer/Attribute/Source/Group.php diff --git a/app/code/core/Mage/Customer/Model/Customer/Attribute/Source/Store.php b/app/code/Mage/Customer/Model/Customer/Attribute/Source/Store.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Customer/Attribute/Source/Store.php rename to app/code/Mage/Customer/Model/Customer/Attribute/Source/Store.php diff --git a/app/code/core/Mage/Customer/Model/Customer/Attribute/Source/Website.php b/app/code/Mage/Customer/Model/Customer/Attribute/Source/Website.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Customer/Attribute/Source/Website.php rename to app/code/Mage/Customer/Model/Customer/Attribute/Source/Website.php diff --git a/app/code/Mage/Customer/Model/Customer/Factory.php b/app/code/Mage/Customer/Model/Customer/Factory.php new file mode 100644 index 0000000000000..7ae19a6690fb6 --- /dev/null +++ b/app/code/Mage/Customer/Model/Customer/Factory.php @@ -0,0 +1,53 @@ +_objectManager = $objectManager; + } + + /** + * Create customer model instance. + * + * @param array $arguments + * @return Mage_Customer_Model_Customer + */ + public function create(array $arguments = array()) + { + return $this->_objectManager->create(self::CUSTOMER_CLASS_NAME, $arguments); + } +} diff --git a/app/code/Mage/Customer/Model/Customer/Webhook/Observer.php b/app/code/Mage/Customer/Model/Customer/Webhook/Observer.php new file mode 100644 index 0000000000000..9f490024ecfd7 --- /dev/null +++ b/app/code/Mage/Customer/Model/Customer/Webhook/Observer.php @@ -0,0 +1,60 @@ +getEvent()->getCustomer(); + + try { + if ($customer->getUpdatedAt() === $customer->getCreatedAt()) { + Mage::helper('Mage_Webhook_Helper_Data') + ->dispatchEvent('customer/created', array('object' => $customer)); + } else if ($customer->hasDataChanges()) { + Mage::helper('Mage_Webhook_Helper_Data') + ->dispatchEvent('customer/updated', array('object' => $customer)); + } + } catch (Exception $e) { + Mage::logException($e); + } + } + + public function dispatchCustomerDeletedEvent($observer) + { + $customer = $observer->getEvent()->getCustomer(); + + try { + Mage::helper('Mage_Webhook_Helper_Data')->dispatchEvent('customer/deleted', array('customer' => $customer)); + } catch (Exception $e) { + Mage::logException($e); + } + } +} diff --git a/app/code/core/Mage/Customer/Model/Form.php b/app/code/Mage/Customer/Model/Form.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Form.php rename to app/code/Mage/Customer/Model/Form.php diff --git a/app/code/core/Mage/Customer/Model/Group.php b/app/code/Mage/Customer/Model/Group.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Group.php rename to app/code/Mage/Customer/Model/Group.php diff --git a/app/code/core/Mage/Customer/Model/Group/Api.php b/app/code/Mage/Customer/Model/Group/Api.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Group/Api.php rename to app/code/Mage/Customer/Model/Group/Api.php diff --git a/app/code/core/Mage/Customer/Model/Group/Api/V2.php b/app/code/Mage/Customer/Model/Group/Api/V2.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Group/Api/V2.php rename to app/code/Mage/Customer/Model/Group/Api/V2.php diff --git a/app/code/core/Mage/Customer/Model/Observer.php b/app/code/Mage/Customer/Model/Observer.php similarity index 100% rename from app/code/core/Mage/Customer/Model/Observer.php rename to app/code/Mage/Customer/Model/Observer.php diff --git a/app/code/core/Mage/Customer/Model/Resource/Address.php b/app/code/Mage/Customer/Model/Resource/Address.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Customer/Model/Resource/Address.php rename to app/code/Mage/Customer/Model/Resource/Address.php diff --git a/app/code/core/Mage/Customer/Model/Resource/Address/Attribute/Backend/Region.php b/app/code/Mage/Customer/Model/Resource/Address/Attribute/Backend/Region.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Customer/Model/Resource/Address/Attribute/Backend/Region.php rename to app/code/Mage/Customer/Model/Resource/Address/Attribute/Backend/Region.php diff --git a/app/code/core/Mage/Customer/Model/Resource/Address/Attribute/Backend/Street.php b/app/code/Mage/Customer/Model/Resource/Address/Attribute/Backend/Street.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Customer/Model/Resource/Address/Attribute/Backend/Street.php rename to app/code/Mage/Customer/Model/Resource/Address/Attribute/Backend/Street.php diff --git a/app/code/core/Mage/Customer/Model/Resource/Address/Attribute/Collection.php b/app/code/Mage/Customer/Model/Resource/Address/Attribute/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Customer/Model/Resource/Address/Attribute/Collection.php rename to app/code/Mage/Customer/Model/Resource/Address/Attribute/Collection.php diff --git a/app/code/core/Mage/Customer/Model/Resource/Address/Attribute/Source/Country.php b/app/code/Mage/Customer/Model/Resource/Address/Attribute/Source/Country.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Customer/Model/Resource/Address/Attribute/Source/Country.php rename to app/code/Mage/Customer/Model/Resource/Address/Attribute/Source/Country.php diff --git a/app/code/core/Mage/Customer/Model/Resource/Address/Attribute/Source/Region.php b/app/code/Mage/Customer/Model/Resource/Address/Attribute/Source/Region.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Customer/Model/Resource/Address/Attribute/Source/Region.php rename to app/code/Mage/Customer/Model/Resource/Address/Attribute/Source/Region.php diff --git a/app/code/core/Mage/Customer/Model/Resource/Address/Collection.php b/app/code/Mage/Customer/Model/Resource/Address/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Customer/Model/Resource/Address/Collection.php rename to app/code/Mage/Customer/Model/Resource/Address/Collection.php diff --git a/app/code/core/Mage/Customer/Model/Resource/Attribute.php b/app/code/Mage/Customer/Model/Resource/Attribute.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Customer/Model/Resource/Attribute.php rename to app/code/Mage/Customer/Model/Resource/Attribute.php diff --git a/app/code/core/Mage/Customer/Model/Resource/Attribute/Collection.php b/app/code/Mage/Customer/Model/Resource/Attribute/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Customer/Model/Resource/Attribute/Collection.php rename to app/code/Mage/Customer/Model/Resource/Attribute/Collection.php diff --git a/app/code/core/Mage/Customer/Model/Resource/Customer.php b/app/code/Mage/Customer/Model/Resource/Customer.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Customer/Model/Resource/Customer.php rename to app/code/Mage/Customer/Model/Resource/Customer.php diff --git a/app/code/core/Mage/Customer/Model/Resource/Customer/Collection.php b/app/code/Mage/Customer/Model/Resource/Customer/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Customer/Model/Resource/Customer/Collection.php rename to app/code/Mage/Customer/Model/Resource/Customer/Collection.php diff --git a/app/code/core/Mage/Customer/Model/Resource/Form/Attribute.php b/app/code/Mage/Customer/Model/Resource/Form/Attribute.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Customer/Model/Resource/Form/Attribute.php rename to app/code/Mage/Customer/Model/Resource/Form/Attribute.php diff --git a/app/code/core/Mage/Customer/Model/Resource/Form/Attribute/Collection.php b/app/code/Mage/Customer/Model/Resource/Form/Attribute/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Customer/Model/Resource/Form/Attribute/Collection.php rename to app/code/Mage/Customer/Model/Resource/Form/Attribute/Collection.php diff --git a/app/code/core/Mage/Customer/Model/Resource/Group.php b/app/code/Mage/Customer/Model/Resource/Group.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Customer/Model/Resource/Group.php rename to app/code/Mage/Customer/Model/Resource/Group.php diff --git a/app/code/core/Mage/Customer/Model/Resource/Group/Collection.php b/app/code/Mage/Customer/Model/Resource/Group/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Customer/Model/Resource/Group/Collection.php rename to app/code/Mage/Customer/Model/Resource/Group/Collection.php diff --git a/app/code/core/Mage/Customer/Model/Resource/Setup.php b/app/code/Mage/Customer/Model/Resource/Setup.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Customer/Model/Resource/Setup.php rename to app/code/Mage/Customer/Model/Resource/Setup.php diff --git a/app/code/Mage/Customer/Model/Session.php b/app/code/Mage/Customer/Model/Session.php new file mode 100644 index 0000000000000..42da91708c64d --- /dev/null +++ b/app/code/Mage/Customer/Model/Session.php @@ -0,0 +1,340 @@ + + */ +class Mage_Customer_Model_Session extends Mage_Core_Model_Session_Abstract +{ + /** + * Customer object + * + * @var Mage_Customer_Model_Customer + */ + protected $_customer; + + /** + * Flag with customer id validations result + * + * @var bool + */ + protected $_isCustomerIdChecked = null; + + /** + * Retrieve customer sharing configuration model + * + * @return Mage_Customer_Model_Config_Share + */ + public function getCustomerConfigShare() + { + return Mage::getSingleton('Mage_Customer_Model_Config_Share'); + } + + public function __construct() + { + $namespace = 'customer'; + if ($this->getCustomerConfigShare()->isWebsiteScope()) { + $namespace .= '_' . (Mage::app()->getStore()->getWebsite()->getCode()); + } + + $this->init($namespace); + Mage::dispatchEvent('customer_session_init', array('customer_session'=>$this)); + } + + /** + * Set customer object and setting customer id in session + * + * @param Mage_Customer_Model_Customer $customer + * @return Mage_Customer_Model_Session + */ + public function setCustomer(Mage_Customer_Model_Customer $customer) + { + // check if customer is not confirmed + if ($customer->isConfirmationRequired()) { + if ($customer->getConfirmation()) { + return $this->_logout(); + } + } + $this->_customer = $customer; + $this->setId($customer->getId()); + // save customer as confirmed, if it is not + if ((!$customer->isConfirmationRequired()) && $customer->getConfirmation()) { + $customer->setConfirmation(null)->save(); + $customer->setIsJustConfirmed(true); + } + return $this; + } + + /** + * Retrieve customer model object + * + * @return Mage_Customer_Model_Customer + */ + public function getCustomer() + { + if ($this->_customer instanceof Mage_Customer_Model_Customer) { + return $this->_customer; + } + + $customer = Mage::getModel('Mage_Customer_Model_Customer') + ->setWebsiteId(Mage::app()->getStore()->getWebsiteId()); + if ($this->getId()) { + $customer->load($this->getId()); + } + + $this->setCustomer($customer); + return $this->_customer; + } + + /** + * Set customer id + * + * @param int|null $id + * @return Mage_Customer_Model_Session + */ + public function setCustomerId($id) + { + $this->setData('customer_id', $id); + return $this; + } + + /** + * Retrieve customer id from current session + * + * @return int|null + */ + public function getCustomerId() + { + if ($this->getData('customer_id')) { + return $this->getData('customer_id'); + } + return ($this->isLoggedIn()) ? $this->getId() : null; + } + + /** + * Set customer group id + * + * @param int|null $id + * @return Mage_Customer_Model_Session + */ + public function setCustomerGroupId($id) + { + $this->setData('customer_group_id', $id); + return $this; + } + + /** + * Get customer group id + * If customer is not logged in system, 'not logged in' group id will be returned + * + * @return int + */ + public function getCustomerGroupId() + { + if ($this->getData('customer_group_id')) { + return $this->getData('customer_group_id'); + } + if ($this->isLoggedIn() && $this->getCustomer()) { + return $this->getCustomer()->getGroupId(); + } + return Mage_Customer_Model_Group::NOT_LOGGED_IN_ID; + } + + /** + * Checking customer login status + * + * @return bool + */ + public function isLoggedIn() + { + return (bool)$this->getId() && (bool)$this->checkCustomerId($this->getId()); + } + + /** + * Check exists customer (light check) + * + * @param int $customerId + * @return bool + */ + public function checkCustomerId($customerId) + { + if ($this->_isCustomerIdChecked === null) { + $this->_isCustomerIdChecked = Mage::getResourceSingleton('Mage_Customer_Model_Resource_Customer') + ->checkCustomerId($customerId); + } + return $this->_isCustomerIdChecked; + } + + /** + * Customer authorization + * + * @param string $username + * @param string $password + * @return bool + */ + public function login($username, $password) + { + /** @var $customer Mage_Customer_Model_Customer */ + $customer = Mage::getModel('Mage_Customer_Model_Customer') + ->setWebsiteId(Mage::app()->getStore()->getWebsiteId()); + + if ($customer->authenticate($username, $password)) { + $this->setCustomerAsLoggedIn($customer); + $this->renewSession(); + return true; + } + return false; + } + + public function setCustomerAsLoggedIn($customer) + { + $this->setCustomer($customer); + Mage::dispatchEvent('customer_login', array('customer'=>$customer)); + return $this; + } + + /** + * Authorization customer by identifier + * + * @param int $customerId + * @return bool + */ + public function loginById($customerId) + { + $customer = Mage::getModel('Mage_Customer_Model_Customer')->load($customerId); + if ($customer->getId()) { + $this->setCustomerAsLoggedIn($customer); + return true; + } + return false; + } + + /** + * Logout customer + * + * @return Mage_Customer_Model_Session + */ + public function logout() + { + if ($this->isLoggedIn()) { + Mage::dispatchEvent('customer_logout', array('customer' => $this->getCustomer()) ); + $this->_logout(); + } + return $this; + } + + /** + * Authenticate controller action by login customer + * + * @param Mage_Core_Controller_Varien_Action $action + * @param bool $loginUrl + * @return bool + */ + public function authenticate(Mage_Core_Controller_Varien_Action $action, $loginUrl = null) + { + if ($this->isLoggedIn()) { + return true; + } + + $this->setBeforeAuthUrl(Mage::getUrl('*/*/*', array('_current' => true))); + if (isset($loginUrl)) { + $action->getResponse()->setRedirect($loginUrl); + } else { + $action->setRedirectWithCookieCheck(Mage_Customer_Helper_Data::ROUTE_ACCOUNT_LOGIN, + Mage::helper('Mage_Customer_Helper_Data')->getLoginUrlParams() + ); + } + + return false; + } + + /** + * Set auth url + * + * @param string $key + * @param string $url + * @return Mage_Customer_Model_Session + */ + protected function _setAuthUrl($key, $url) + { + $url = Mage::helper('Mage_Core_Helper_Url') + ->removeRequestParam($url, Mage::getSingleton('Mage_Core_Model_Session')->getSessionIdQueryParam()); + // Add correct session ID to URL if needed + $url = Mage::getModel('Mage_Core_Model_Url')->getRebuiltUrl($url); + return $this->setData($key, $url); + } + + /** + * Logout without dispatching event + * + * @return Mage_Customer_Model_Session + */ + protected function _logout() + { + $this->setId(null); + $this->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID); + $this->getCookie()->delete($this->getSessionName()); + return $this; + } + + /** + * Set Before auth url + * + * @param string $url + * @return Mage_Customer_Model_Session + */ + public function setBeforeAuthUrl($url) + { + return $this->_setAuthUrl('before_auth_url', $url); + } + + /** + * Set After auth url + * + * @param string $url + * @return Mage_Customer_Model_Session + */ + public function setAfterAuthUrl($url) + { + return $this->_setAuthUrl('after_auth_url', $url); + } + + /** + * Reset core session hosts after reseting session ID + * + * @return Mage_Customer_Model_Session + */ + public function renewSession() + { + parent::renewSession(); + $this->_cleanHosts(); + return $this; + } +} diff --git a/app/code/Mage/Customer/Service/Customer.php b/app/code/Mage/Customer/Service/Customer.php new file mode 100644 index 0000000000000..a3eaaaf54aaf5 --- /dev/null +++ b/app/code/Mage/Customer/Service/Customer.php @@ -0,0 +1,424 @@ +_translateHelper = $helper; + $this->_customerFactory = $customerFactory; + $this->_addressFactory = $addressFactory; + $this->_isAdminStore = $isAdminStore; + } + + /** + * @return array + */ + public function getCustomerGroups() + { + $optionsResource = new Mage_Customer_Model_Resource_Group_Collection(); + $groups = array(); + foreach ($optionsResource->setRealGroupsFilter()->loadData() as $group) { + $groups[] = $group->getData(); + } + return $groups; + } + + /** + * Set is admin store flag. + * + * @param bool $isAdminStore + * @return Mage_Customer_Service_Customer + */ + public function setIsAdminStore($isAdminStore) + { + $this->_isAdminStore = $isAdminStore; + return $this; + } + + /** + * Set flag if send remainder email + * + * @param bool $flag + * @return Mage_Customer_Service_Customer + */ + public function setSendRemainderEmail($flag) + { + // todo: drop next string as soon as front controller of webapi will be able to return routers + $this->_sendRemainderEmail = (bool)$flag; + return $this; + } + + /** + * Set before save callback. + * + * @param callable $callback + * @return Mage_Customer_Service_Customer + */ + public function setBeforeSaveCallback($callback) + { + $this->_beforeSaveCallback = $callback; + return $this; + } + + /** + * Set after save callback. + * + * @param callable $callback + * @return Mage_Customer_Service_Customer + */ + public function setAfterSaveCallback($callback) + { + $this->_afterSaveCallback = $callback; + return $this; + } + + /** + * Create customer with optional ability of adding addresses. + * + * @param array $customerData + * @param array|null $addressesData array of addresses + * @return Mage_Customer_Model_Customer + */ + public function create(array $customerData, array $addressesData = null) + { + $customer = $this->_customerFactory->create(); + $this->_preparePasswordForSave($customer, $customerData); + $this->_save($customer, $customerData, $addressesData); + + return $customer; + } + + /** + * Update customer entity. + * + * Update customer with optional ability to update customer addresses. + * Addresses that are not in $addressesData array but present in customer addresses collection will be removed. + * New address is created in case when no entity_id is present, otherwise corresponding address will be updated + * with data provided. + * + * @param string|int $customerId + * @param array $customerData + * @param array|null $addressesData array of addresses + * @return Mage_Customer_Model_Customer + */ + public function update($customerId, array $customerData, array $addressesData = null) + { + /** @var Mage_Customer_Model_Customer $customer */ + $customer = $this->_loadCustomerById($customerId); + + $this->_save($customer, $customerData, $addressesData); + if ($customerData) { + $this->_changePassword($customer, $customerData); + } + + return $customer; + } + + /** + * Save customer entity. Perform supplementary business workflow actions + * + * @param Mage_Customer_Model_Customer $customer + * @param array $customerData + * @param array|null $addressesData + * @return Mage_Customer_Service_Customer + */ + protected function _save($customer, array $customerData, array $addressesData = null) + { + if ($customerData) { + $this->_setDataUsingMethods($customer, $customerData); + } + $this->_beforeSave($customer, $customerData, $addressesData); + $customer->save(); + $this->_afterSave($customer, $customerData, $addressesData); + + return $this; + } + + /** + * Sets each value from data to entity Varien_Object using setter method. + * + * @param Varien_Object $entity + * @param array $data + */ + protected function _setDataUsingMethods($entity, array $data) + { + foreach ($data as $property => $value) { + $entity->setDataUsingMethod($property, $value); + } + } + + /** + * Trigger before save logic + * + * @param Mage_Customer_Model_Customer $customer + * @param array $customerData + * @param array $addressesData + */ + protected function _beforeSave($customer, array $customerData, array $addressesData = null) + { + if (!is_null($addressesData)) { + $this->_prepareCustomerAddressesForSave($customer, $addressesData); + } + if (is_callable($this->_beforeSaveCallback)) { + call_user_func_array($this->_beforeSaveCallback, array($customer, $customerData, $addressesData)); + } + } + + /** + * Trigger before save logic + * + * @param Mage_Customer_Model_Customer $customer + * @param array $customerData + * @param array $addressesData + */ + protected function _afterSave($customer, array $customerData, array $addressesData = null) + { + if (is_callable($this->_afterSaveCallback)) { + call_user_func_array($this->_afterSaveCallback, array($customer, $customerData, $addressesData)); + } + $this->_sendWelcomeEmail($customer, $customerData); + } + + /** + * Set customer password + * + * @param Mage_Customer_Model_Customer $customer + * @param array $customerData + */ + protected function _preparePasswordForSave($customer, array $customerData) + { + $password = $this->_getCustomerPassword($customer, $customerData); + if (!is_null($password)) { + // 'force_confirmed' should be set in admin area only + if ($this->_isAdminStore) { + $customer->setForceConfirmed(true); + } + $customer->setPassword($password); + } + } + + /** + * Get customer password + * + * @param Mage_Customer_Model_Customer $customer + * @param array $customerData + * @return string|null + */ + protected function _getCustomerPassword($customer, array $customerData) + { + $password = null; + + if ($this->_isAutogeneratePassword($customerData)) { + $password = $customer->generatePassword(); + } elseif (isset($customerData['password'])) { + $password = $customerData['password']; + } + + return $password; + } + + /** + * Change customer password + * + * @param Mage_Customer_Model_Customer $customer + * @param array $customerData + * @return Mage_Customer_Service_Customer + */ + protected function _changePassword($customer, array $customerData) + { + if (!empty($customerData['password']) || $this->_isAutogeneratePassword($customerData)) { + $newPassword = $this->_getCustomerPassword($customer, $customerData); + $customer->changePassword($newPassword); + if ($this->_sendRemainderEmail) { + $customer->sendPasswordReminderEmail(); + } + } + + return $this; + } + + /** + * Check if password should be generated automatically + * + * @param array $customerData + * @return bool + */ + protected function _isAutogeneratePassword(array $customerData) + { + return isset($customerData['autogenerate_password']) && $customerData['autogenerate_password']; + } + + /** + * Retrieve send email flag + * + * @param array $customerData + * @return bool + */ + protected function _isSendEmail(array $customerData) + { + return isset($customerData['sendemail']) && $customerData['sendemail']; + } + + /** + * Send welcome email to customer + * + * @param Mage_Customer_Model_Customer $customer + * @param array $customerData + * @return Mage_Customer_Service_Customer + */ + protected function _sendWelcomeEmail($customer, array $customerData) + { + if ($customer->getWebsiteId() + && ($this->_isSendEmail($customerData) || $this->_isAutogeneratePassword($customerData)) + ) { + $isNewCustomer = !(bool)$customer->getOrigData($customer->getIdFieldName()); + $storeId = $customer->getSendemailStoreId(); + + if ($isNewCustomer) { + $customer->sendNewAccountEmail('registered', '', $storeId); + } elseif (!$customer->getConfirmation()) { + // Confirm not confirmed customer + $customer->sendNewAccountEmail('confirmed', '', $storeId); + } + } + return $this; + } + + /** + * Load customer by its ID + * + * @param int|string $customerId + * @return Mage_Customer_Model_Customer + * @throws Mage_Core_Exception + */ + protected function _loadCustomerById($customerId) + { + $customer = $this->_customerFactory->create(); + $customer->load($customerId); + if (!$customer->getId()) { + throw new Mage_Core_Exception($this->_translateHelper->__("The customer with the specified ID not found.")); + } + + return $customer; + } + + /** + * Save customer addresses. + * + * @param Mage_Customer_Model_Customer $customer + * @param array $addressesData + * @throws Mage_Core_Exception + */ + protected function _prepareCustomerAddressesForSave($customer, array $addressesData) + { + $hasChanges = $customer->hasDataChanges(); + $actualAddressesIds = array(); + foreach ($addressesData as $addressData) { + $addressId = null; + if (array_key_exists('entity_id', $addressData)) { + $addressId = $addressData['entity_id']; + unset($addressData['entity_id']); + } + + if (null !== $addressId) { + $address = $customer->getAddressItemById($addressId); + if (!$address || !$address->getId()) { + throw new Mage_Core_Exception( + $this->_translateHelper->__('The address with the specified ID not found.')); + } + } else { + $address = $this->_addressFactory->create(); + $address->setCustomerId($customer->getId()); + // Add customer address into addresses collection + $customer->addAddress($address); + } + $address->addData($addressData); + $hasChanges = $hasChanges || $address->hasDataChanges(); + + // Set post_index for detect default billing and shipping addresses + $address->setPostIndex($addressId); + + $actualAddressesIds[] = $address->getId(); + } + + /** @var Mage_Customer_Model_Address $address */ + foreach ($customer->getAddressesCollection() as $address) { + if (!in_array($address->getId(), $actualAddressesIds)) { + $address->setData('_deleted', true); + $hasChanges = true; + } + } + $customer->setDataChanges($hasChanges); + } +} diff --git a/app/code/Mage/Customer/controllers/AccountController.php b/app/code/Mage/Customer/controllers/AccountController.php new file mode 100644 index 0000000000000..1adbc156c0da0 --- /dev/null +++ b/app/code/Mage/Customer/controllers/AccountController.php @@ -0,0 +1,862 @@ + + */ +class Mage_Customer_AccountController extends Mage_Core_Controller_Front_Action +{ + /** + * Action list where need check enabled cookie + * + * @var array + */ + protected $_cookieCheckActions = array('loginPost', 'createpost'); + + /** + * Retrieve customer session model object + * + * @return Mage_Customer_Model_Session + */ + protected function _getSession() + { + return Mage::getSingleton('Mage_Customer_Model_Session'); + } + + /** + * Action predispatch + * + * Check customer authentication for some actions + */ + public function preDispatch() + { + // a brute-force protection here would be nice + + parent::preDispatch(); + + if (!$this->getRequest()->isDispatched()) { + return; + } + + $action = $this->getRequest()->getActionName(); + $openActions = array( + 'create', + 'login', + 'logoutsuccess', + 'forgotpassword', + 'forgotpasswordpost', + 'resetpassword', + 'resetpasswordpost', + 'confirm', + 'confirmation' + ); + $pattern = '/^(' . implode('|', $openActions) . ')/i'; + + if (!preg_match($pattern, $action)) { + if (!$this->_getSession()->authenticate($this)) { + $this->setFlag('', 'no-dispatch', true); + } + } else { + $this->_getSession()->setNoReferer(true); + } + } + + /** + * Action postdispatch + * + * Remove No-referer flag from customer session after each action + */ + public function postDispatch() + { + parent::postDispatch(); + $this->_getSession()->unsNoReferer(false); + } + + /** + * Default customer account page + */ + public function indexAction() + { + $this->loadLayout(); + $this->_initLayoutMessages('Mage_Customer_Model_Session'); + $this->_initLayoutMessages('Mage_Catalog_Model_Session'); + $this->getLayout()->getBlock('head')->setTitle($this->__('My Account')); + $this->renderLayout(); + } + + /** + * Customer login form page + */ + public function loginAction() + { + if ($this->_getSession()->isLoggedIn()) { + $this->_redirect('*/*/'); + return; + } + $this->getResponse()->setHeader('Login-Required', 'true'); + $this->loadLayout(); + $this->_initLayoutMessages('Mage_Customer_Model_Session'); + $this->_initLayoutMessages('Mage_Catalog_Model_Session'); + $this->renderLayout(); + } + + /** + * Login post action + */ + public function loginPostAction() + { + if ($this->_getSession()->isLoggedIn()) { + $this->_redirect('*/*/'); + return; + } + $session = $this->_getSession(); + + if ($this->getRequest()->isPost()) { + $login = $this->getRequest()->getPost('login'); + if (!empty($login['username']) && !empty($login['password'])) { + try { + $session->login($login['username'], $login['password']); + if ($session->getCustomer()->getIsJustConfirmed()) { + $this->_welcomeCustomer($session->getCustomer(), true); + } + } catch (Mage_Core_Exception $e) { + switch ($e->getCode()) { + case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED: + $value = $this->_objectManager->get('Mage_Customer_Helper_Data') + ->getEmailConfirmationUrl($login['username']); + $message = $this->_objectManager->get('Mage_Customer_Helper_Data') + ->__('This account is not confirmed.' + . ' Click here to resend confirmation email.', $value); + break; + case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD: + $message = $e->getMessage(); + break; + default: + $message = $e->getMessage(); + break; + } + $session->addError($message); + $session->setUsername($login['username']); + } catch (Exception $e) { + // Mage::logException($e); // PA DSS violation: this exception log can disclose customer password + } + } else { + $session->addError($this->__('Login and password are required.')); + } + } + + $this->_loginPostRedirect(); + } + + /** + * Define target URL and redirect customer after logging in + */ + protected function _loginPostRedirect() + { + $session = $this->_getSession(); + + if (!$session->getBeforeAuthUrl() || $session->getBeforeAuthUrl() == Mage::getBaseUrl()) { + // Set default URL to redirect customer to + $session->setBeforeAuthUrl(Mage::helper('Mage_Customer_Helper_Data')->getAccountUrl()); + // Redirect customer to the last page visited after logging in + if ($session->isLoggedIn()) { + if (!Mage::getStoreConfigFlag( + Mage_Customer_Helper_Data::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD + )) { + $referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME); + if ($referer) { + $referer = Mage::helper('Mage_Core_Helper_Data')->urlDecode($referer); + if ($this->_isUrlInternal($referer)) { + $session->setBeforeAuthUrl($referer); + } + } + } else if ($session->getAfterAuthUrl()) { + $session->setBeforeAuthUrl($session->getAfterAuthUrl(true)); + } + } else { + $session->setBeforeAuthUrl(Mage::helper('Mage_Customer_Helper_Data')->getLoginUrl()); + } + } else if ($session->getBeforeAuthUrl() == Mage::helper('Mage_Customer_Helper_Data')->getLogoutUrl()) { + $session->setBeforeAuthUrl(Mage::helper('Mage_Customer_Helper_Data')->getDashboardUrl()); + } else { + if (!$session->getAfterAuthUrl()) { + $session->setAfterAuthUrl($session->getBeforeAuthUrl()); + } + if ($session->isLoggedIn()) { + $session->setBeforeAuthUrl($session->getAfterAuthUrl(true)); + } + } + $this->_redirectUrl($session->getBeforeAuthUrl(true)); + } + + /** + * Customer logout action + */ + public function logoutAction() + { + $this->_getSession()->logout() + ->renewSession() + ->setBeforeAuthUrl($this->_getRefererUrl()); + + $this->_redirect('*/*/logoutSuccess'); + } + + /** + * Logout success page + */ + public function logoutSuccessAction() + { + $this->loadLayout(); + $this->renderLayout(); + } + + /** + * Customer register form page + */ + public function createAction() + { + if ($this->_getSession()->isLoggedIn()) { + $this->_redirect('*/*'); + return; + } + + $this->loadLayout(); + $this->_initLayoutMessages('Mage_Customer_Model_Session'); + $this->renderLayout(); + } + + /** + * Create customer account action + */ + public function createPostAction() + { + $session = $this->_getSession(); + if ($session->isLoggedIn()) { + $this->_redirect('*/*/'); + return; + } + $session->setEscapeMessages(true); // prevent XSS injection in user input + + if (!$this->getRequest()->isPost()) { + $this->_redirectError(Mage::getUrl('*/*/create', array('_secure' => true))); + return; + } + + try { + $customer = $this->_extractCustomer(); + $address = $this->_extractAddress($customer); + $this->_validateCustomer($customer, $address); + + $customer->save()->setOrigData(); + Mage::dispatchEvent('customer_register_success', + array('account_controller' => $this, 'customer' => $customer) + ); + + if ($customer->isConfirmationRequired()) { + $customer->sendNewAccountEmail( + 'confirmation', + $session->getBeforeAuthUrl(), + Mage::app()->getStore()->getId() + ); + $session->addSuccess($this->__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please click here.', Mage::helper('Mage_Customer_Helper_Data')->getEmailConfirmationUrl($customer->getEmail()))); + $this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure' => true))); + } else { + $session->setCustomerAsLoggedIn($customer); + $url = $this->_welcomeCustomer($customer); + $this->_redirectSuccess($url); + } + return; + } catch (Mage_Core_Exception $e) { + if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) { + $url = Mage::getUrl('customer/account/forgotpassword'); + $message = $this->__('There is already an account with this email address. If you are sure that it is your email address, click here to get your password and access your account.', $url); + $session->setEscapeMessages(false); + } else { + $message = $e->getMessage(); + } + $session->addError($message); + } catch (Magento_Validator_Exception $e) { + foreach ($e->getMessages() as $messages) { + foreach ($messages as $message) { + $session->addError($message); + } + } + } catch (Exception $e) { + $session->addException($e, $this->__('Cannot save the customer.')); + } + + $session->setCustomerFormData($this->getRequest()->getPost()); + $this->_redirectError(Mage::getUrl('*/*/create', array('_secure' => true))); + } + + /** + * Do validation of customer and its address using validate methods in models + * + * @param Mage_Customer_Model_Customer $customer + * @param Mage_Customer_Model_Address|null $address + * @throws Magento_Validator_Exception + */ + protected function _validateCustomer($customer, $address = null) + { + $errors = array(); + if ($address) { + $addressErrors = $address->validate(); + if (is_array($addressErrors)) { + $errors = array_merge($errors, $addressErrors); + } + } + $customerErrors = $customer->validate(); + if (is_array($customerErrors)) { + $errors = array_merge($errors, $customerErrors); + } + if (count($errors) > 0) { + throw new Magento_Validator_Exception(array($errors)); + } + // Empty password confirmation data (it is needed only for validation purposes and is not meant to be stored) + $customer->setConfirmation(null); + } + + /** + * Add address to customer during create account + * + * @param Mage_Customer_Model_Customer $customer + * @return Mage_Customer_Model_Address|null + */ + protected function _extractAddress($customer) + { + if (!$this->getRequest()->getPost('create_address')) { + return null; + } + /* @var Mage_Customer_Model_Address $address */ + $address = Mage::getModel('Mage_Customer_Model_Address'); + /* @var Mage_Customer_Model_Form $addressForm */ + $addressForm = Mage::getModel('Mage_Customer_Model_Form'); + $addressForm->setFormCode('customer_register_address') + ->setEntity($address); + + $addressData = $addressForm->extractData($this->getRequest(), 'address', false); + $address->setId(null) + ->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false)) + ->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false)); + $addressForm->compactData($addressData); + $customer->addAddress($address); + return $address; + } + + /** + * Extract customer entity from request + * + * @return Mage_Customer_Model_Customer + */ + protected function _extractCustomer() + { + /** @var Mage_Customer_Model_Customer $customer */ + if (!$customer = Mage::registry('current_customer')) { + $customer = Mage::getModel('Mage_Customer_Model_Customer')->setId(null); + } + /* @var Mage_Customer_Model_Form $customerForm */ + $customerForm = Mage::getModel('Mage_Customer_Model_Form'); + $customerForm->setFormCode('customer_account_create') + ->setEntity($customer); + + $customerData = $customerForm->extractData($this->getRequest()); + // Initialize customer group id + $customer->getGroupId(); + $customerForm->compactData($customerData); + $customer->setPassword($this->getRequest()->getPost('password')); + $customer->setConfirmation($this->getRequest()->getPost('confirmation')); + if ($this->getRequest()->getParam('is_subscribed', false)) { + $customer->setIsSubscribed(1); + } + return $customer; + } + + /** + * Add welcome message and send new account email. + * Returns success URL + * + * @param Mage_Customer_Model_Customer $customer + * @param bool $isJustConfirmed + * @return string + */ + protected function _welcomeCustomer(Mage_Customer_Model_Customer $customer, $isJustConfirmed = false) + { + $this->_getSession()->addSuccess( + $this->__('Thank you for registering with %s.', Mage::app()->getStore()->getFrontendName()) + ); + if ($this->_isVatValidationEnabled()) { + // Show corresponding VAT message to customer + $configAddressType = Mage::helper('Mage_Customer_Helper_Address')->getTaxCalculationAddressType(); + $userPrompt = ''; + switch ($configAddressType) { + case Mage_Customer_Model_Address_Abstract::TYPE_SHIPPING: + $userPrompt = $this->__('If you are a registered VAT customer, please click here to enter you shipping address for proper VAT calculation', Mage::getUrl('customer/address/edit')); + break; + default: + $userPrompt = $this->__('If you are a registered VAT customer, please click here to enter you billing address for proper VAT calculation', Mage::getUrl('customer/address/edit')); + } + $this->_getSession()->addSuccess($userPrompt); + } + + $customer->sendNewAccountEmail( + $isJustConfirmed ? 'confirmed' : 'registered', + '', + Mage::app()->getStore()->getId() + ); + + $successUrl = Mage::getUrl('*/*/index', array('_secure' => true)); + if (!Mage::getStoreConfigFlag(Mage_Customer_Helper_Data::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD) + && $this->_getSession()->getBeforeAuthUrl() + ) { + $successUrl = $this->_getSession()->getBeforeAuthUrl(true); + } + return $successUrl; + } + + /** + * Confirm customer account by id and confirmation key + */ + public function confirmAction() + { + if ($this->_getSession()->isLoggedIn()) { + $this->_redirect('*/*/'); + return; + } + try { + $id = $this->getRequest()->getParam('id', false); + $key = $this->getRequest()->getParam('key', false); + $backUrl = $this->getRequest()->getParam('back_url', false); + if (empty($id) || empty($key)) { + throw new Exception($this->__('Bad request.')); + } + + // load customer by id (try/catch in case if it throws exceptions) + try { + $customer = Mage::getModel('Mage_Customer_Model_Customer')->load($id); + if ((!$customer) || (!$customer->getId())) { + throw new Exception('Failed to load customer by id.'); + } + } + catch (Exception $e) { + throw new Exception($this->__('Wrong customer account specified.')); + } + + // check if it is inactive + if ($customer->getConfirmation()) { + if ($customer->getConfirmation() !== $key) { + throw new Exception($this->__('Wrong confirmation key.')); + } + + // activate customer + try { + $customer->setConfirmation(null); + $customer->save(); + } + catch (Exception $e) { + throw new Exception($this->__('Failed to confirm customer account.')); + } + + // log in and send greeting email, then die happy + $this->_getSession()->setCustomerAsLoggedIn($customer); + $successUrl = $this->_welcomeCustomer($customer, true); + $this->_redirectSuccess($backUrl ? $backUrl : $successUrl); + return; + } + + // die happy + $this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure'=>true))); + return; + } + catch (Exception $e) { + // die unhappy + $this->_getSession()->addError($e->getMessage()); + $this->_redirectError(Mage::getUrl('*/*/index', array('_secure'=>true))); + return; + } + } + + /** + * Send confirmation link to specified email + */ + public function confirmationAction() + { + $customer = Mage::getModel('Mage_Customer_Model_Customer'); + if ($this->_getSession()->isLoggedIn()) { + $this->_redirect('*/*/'); + return; + } + + // try to confirm by email + $email = $this->getRequest()->getPost('email'); + if ($email) { + try { + $customer->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($email); + if (!$customer->getId()) { + throw new Exception(''); + } + if ($customer->getConfirmation()) { + $customer->sendNewAccountEmail('confirmation', '', Mage::app()->getStore()->getId()); + $this->_getSession()->addSuccess($this->__('Please, check your email for confirmation key.')); + } else { + $this->_getSession()->addSuccess($this->__('This email does not require confirmation.')); + } + $this->_getSession()->setUsername($email); + $this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure' => true))); + } catch (Exception $e) { + $this->_getSession()->addException($e, $this->__('Wrong email.')); + $this->_redirectError(Mage::getUrl('*/*/*', array('email' => $email, '_secure' => true))); + } + return; + } + + // output form + $this->loadLayout(); + + $this->getLayout()->getBlock('accountConfirmation') + ->setEmail($this->getRequest()->getParam('email', $email)); + + $this->_initLayoutMessages('Mage_Customer_Model_Session'); + $this->renderLayout(); + } + + /** + * Forgot customer password page + */ + public function forgotPasswordAction() + { + $this->loadLayout(); + + $this->getLayout()->getBlock('forgotPassword')->setEmailValue( + $this->_getSession()->getForgottenEmail() + ); + $this->_getSession()->unsForgottenEmail(); + + $this->_initLayoutMessages('Mage_Customer_Model_Session'); + $this->renderLayout(); + } + + /** + * Forgot customer password action + */ + public function forgotPasswordPostAction() + { + $email = (string) $this->getRequest()->getPost('email'); + if ($email) { + if (!Zend_Validate::is($email, 'EmailAddress')) { + $this->_getSession()->setForgottenEmail($email); + $this->_getSession()->addError($this->__('Invalid email address.')); + $this->_redirect('*/*/forgotpassword'); + return; + } + + /** @var $customer Mage_Customer_Model_Customer */ + $customer = Mage::getModel('Mage_Customer_Model_Customer') + ->setWebsiteId(Mage::app()->getStore()->getWebsiteId()) + ->loadByEmail($email); + + if ($customer->getId()) { + try { + $newResetPasswordLinkToken = Mage::helper('Mage_Customer_Helper_Data')->generateResetPasswordLinkToken(); + $customer->changeResetPasswordLinkToken($newResetPasswordLinkToken); + $customer->sendPasswordResetConfirmationEmail(); + } catch (Exception $exception) { + $this->_getSession()->addError($exception->getMessage()); + $this->_redirect('*/*/forgotpassword'); + return; + } + } + $this->_getSession() + ->addSuccess(Mage::helper('Mage_Customer_Helper_Data')->__('If there is an account associated with %s you will receive an email with a link to reset your password.', Mage::helper('Mage_Customer_Helper_Data')->escapeHtml($email))); + $this->_redirect('*/*/'); + return; + } else { + $this->_getSession()->addError($this->__('Please enter your email.')); + $this->_redirect('*/*/forgotpassword'); + return; + } + } + + /** + * Display reset forgotten password form + * + * User is redirected on this action when he clicks on the corresponding link in password reset confirmation email + * + */ + public function resetPasswordAction() + { + $resetPasswordLinkToken = (string) $this->getRequest()->getQuery('token'); + $customerId = (int) $this->getRequest()->getQuery('id'); + try { + $this->_validateResetPasswordLinkToken($customerId, $resetPasswordLinkToken); + $this->loadLayout(); + // Pass received parameters to the reset forgotten password form + $this->getLayout()->getBlock('resetPassword') + ->setCustomerId($customerId) + ->setResetPasswordLinkToken($resetPasswordLinkToken); + $this->renderLayout(); + } catch (Exception $exception) { + $this->_getSession()->addError(Mage::helper('Mage_Customer_Helper_Data')->__('Your password reset link has expired.')); + $this->_redirect('*/*/forgotpassword'); + } + } + + /** + * Reset forgotten password + * + * Used to handle data recieved from reset forgotten password form + * + */ + public function resetPasswordPostAction() + { + $resetPasswordLinkToken = (string) $this->getRequest()->getQuery('token'); + $customerId = (int) $this->getRequest()->getQuery('id'); + $password = (string) $this->getRequest()->getPost('password'); + $passwordConfirmation = (string) $this->getRequest()->getPost('confirmation'); + + try { + $this->_validateResetPasswordLinkToken($customerId, $resetPasswordLinkToken); + } catch (Exception $exception) { + $this->_getSession()->addError(Mage::helper('Mage_Customer_Helper_Data')->__('Your password reset link has expired.')); + $this->_redirect('*/*/'); + return; + } + + $errorMessages = array(); + if (iconv_strlen($password) <= 0) { + array_push($errorMessages, Mage::helper('Mage_Customer_Helper_Data')->__('New password field cannot be empty.')); + } + /** @var $customer Mage_Customer_Model_Customer */ + $customer = Mage::getModel('Mage_Customer_Model_Customer')->load($customerId); + + $customer->setPassword($password); + $customer->setConfirmation($passwordConfirmation); + $validationErrorMessages = $customer->validate(); + if (is_array($validationErrorMessages)) { + $errorMessages = array_merge($errorMessages, $validationErrorMessages); + } + + if (!empty($errorMessages)) { + $this->_getSession()->setCustomerFormData($this->getRequest()->getPost()); + foreach ($errorMessages as $errorMessage) { + $this->_getSession()->addError($errorMessage); + } + $this->_redirect('*/*/resetpassword', array( + 'id' => $customerId, + 'token' => $resetPasswordLinkToken + )); + return; + } + + try { + // Empty current reset password token i.e. invalidate it + $customer->setRpToken(null); + $customer->setRpTokenCreatedAt(null); + $customer->setConfirmation(null); + $customer->save(); + $this->_getSession()->addSuccess(Mage::helper('Mage_Customer_Helper_Data')->__('Your password has been updated.')); + $this->_redirect('*/*/login'); + } catch (Exception $exception) { + $this->_getSession()->addException($exception, $this->__('Cannot save a new password.')); + $this->_redirect('*/*/resetpassword', array( + 'id' => $customerId, + 'token' => $resetPasswordLinkToken + )); + return; + } + } + + /** + * Check if password reset token is valid + * + * @param int $customerId + * @param string $resetPasswordLinkToken + * @throws Mage_Core_Exception + */ + protected function _validateResetPasswordLinkToken($customerId, $resetPasswordLinkToken) + { + if (!is_int($customerId) + || !is_string($resetPasswordLinkToken) + || empty($resetPasswordLinkToken) + || empty($customerId) + || $customerId < 0 + ) { + throw Mage::exception('Mage_Core', Mage::helper('Mage_Customer_Helper_Data')->__('Invalid password reset token.')); + } + + /** @var $customer Mage_Customer_Model_Customer */ + $customer = Mage::getModel('Mage_Customer_Model_Customer')->load($customerId); + if (!$customer || !$customer->getId()) { + throw Mage::exception('Mage_Core', Mage::helper('Mage_Customer_Helper_Data')->__('Wrong customer account specified.')); + } + + $customerToken = $customer->getRpToken(); + if (strcmp($customerToken, $resetPasswordLinkToken) != 0 || $customer->isResetPasswordLinkTokenExpired()) { + throw Mage::exception('Mage_Core', Mage::helper('Mage_Customer_Helper_Data')->__('Your password reset link has expired.')); + } + } + + /** + * Forgot customer account information page + */ + public function editAction() + { + $this->loadLayout(); + $this->_initLayoutMessages('Mage_Customer_Model_Session'); + $this->_initLayoutMessages('Mage_Catalog_Model_Session'); + + $block = $this->getLayout()->getBlock('customer_edit'); + if ($block) { + $block->setRefererUrl($this->_getRefererUrl()); + } + $data = $this->_getSession()->getCustomerFormData(true); + $customer = $this->_getSession()->getCustomer(); + if (!empty($data)) { + $customer->addData($data); + } + if ($this->getRequest()->getParam('changepass')==1){ + $customer->setChangePassword(1); + } + + $this->getLayout()->getBlock('head')->setTitle($this->__('Account Information')); + $this->getLayout()->getBlock('messages')->setEscapeMessageFlag(true); + $this->renderLayout(); + } + + /** + * Change customer password action + */ + public function editPostAction() + { + if (!$this->_validateFormKey()) { + $this->_redirect('*/*/edit'); + return; + } + + if ($this->getRequest()->isPost()) { + /** @var $customer Mage_Customer_Model_Customer */ + $customer = $this->_getSession()->getCustomer(); + + /** @var $customerForm Mage_Customer_Model_Form */ + $customerForm = Mage::getModel('Mage_Customer_Model_Form'); + $customerForm->setFormCode('customer_account_edit') + ->setEntity($customer); + + $customerData = $customerForm->extractData($this->getRequest()); + + $customerForm->compactData($customerData); + $errors = array(); + + // If password change was requested then add it to common validation scheme + if ($this->getRequest()->getParam('change_password')) { + $currPass = $this->getRequest()->getPost('current_password'); + $newPass = $this->getRequest()->getPost('password'); + $confPass = $this->getRequest()->getPost('confirmation'); + + $oldPass = $this->_getSession()->getCustomer()->getPasswordHash(); + if (Mage::helper('Mage_Core_Helper_String')->strpos($oldPass, ':')) { + list($_salt, $salt) = explode(':', $oldPass); + } else { + $salt = false; + } + + if ($customer->hashPassword($currPass, $salt) == $oldPass) { + if (strlen($newPass)) { + /** + * Set entered password and its confirmation - they + * will be validated later to match each other and be of right length + */ + $customer->setPassword($newPass); + $customer->setConfirmation($confPass); + } else { + $errors[] = $this->__('New password field cannot be empty.'); + } + } else { + $errors[] = $this->__('Invalid current password'); + } + } + + // Validate account and compose list of errors if any + $customerErrors = $customer->validate(); + if (is_array($customerErrors)) { + $errors = array_merge($errors, $customerErrors); + } + + if (!empty($errors)) { + $this->_getSession()->setCustomerFormData($this->getRequest()->getPost()); + foreach ($errors as $message) { + $this->_getSession()->addError($message); + } + $this->_redirect('*/*/edit'); + return; + } + + try { + $customer->setConfirmation(null); + $customer->save(); + $this->_getSession()->setCustomer($customer) + ->addSuccess($this->__('The account information has been saved.')); + + $this->_redirect('customer/account'); + return; + } catch (Mage_Core_Exception $e) { + $this->_getSession()->setCustomerFormData($this->getRequest()->getPost()) + ->addError($e->getMessage()); + } catch (Exception $e) { + $this->_getSession()->setCustomerFormData($this->getRequest()->getPost()) + ->addException($e, $this->__('Cannot save the customer.')); + } + } + + $this->_redirect('*/*/edit'); + } + + /** + * Filtering posted data. Converting localized data if needed + * + * @param array + * @return array + */ + protected function _filterPostData($data) + { + $data = $this->_filterDates($data, array('dob')); + return $data; + } + + /** + * Check whether VAT ID validation is enabled + * + * @param Mage_Core_Model_Store|string|int $store + * @return bool + */ + protected function _isVatValidationEnabled($store = null) + { + return Mage::helper('Mage_Customer_Helper_Address')->isVatValidationEnabled($store); + } +} diff --git a/app/code/core/Mage/Customer/controllers/AddressController.php b/app/code/Mage/Customer/controllers/AddressController.php similarity index 100% rename from app/code/core/Mage/Customer/controllers/AddressController.php rename to app/code/Mage/Customer/controllers/AddressController.php diff --git a/app/code/core/Mage/Customer/controllers/ReviewController.php b/app/code/Mage/Customer/controllers/ReviewController.php similarity index 100% rename from app/code/core/Mage/Customer/controllers/ReviewController.php rename to app/code/Mage/Customer/controllers/ReviewController.php diff --git a/app/code/core/Mage/Customer/data/customer_setup/data-upgrade-1.6.1.0-1.6.2.0.php b/app/code/Mage/Customer/data/customer_setup/data-upgrade-1.6.1.0-1.6.2.0.php similarity index 100% rename from app/code/core/Mage/Customer/data/customer_setup/data-upgrade-1.6.1.0-1.6.2.0.php rename to app/code/Mage/Customer/data/customer_setup/data-upgrade-1.6.1.0-1.6.2.0.php diff --git a/app/code/core/Mage/Customer/data/customer_setup/data-upgrade-1.6.2.0.1-1.6.2.0.2.php b/app/code/Mage/Customer/data/customer_setup/data-upgrade-1.6.2.0.1-1.6.2.0.2.php similarity index 100% rename from app/code/core/Mage/Customer/data/customer_setup/data-upgrade-1.6.2.0.1-1.6.2.0.2.php rename to app/code/Mage/Customer/data/customer_setup/data-upgrade-1.6.2.0.1-1.6.2.0.2.php diff --git a/app/code/Mage/Customer/etc/adminhtml/acl.xml b/app/code/Mage/Customer/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..820a3c4682db4 --- /dev/null +++ b/app/code/Mage/Customer/etc/adminhtml/acl.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Mage/Customer/etc/adminhtml/menu.xml b/app/code/Mage/Customer/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..aac4a34eeb2bd --- /dev/null +++ b/app/code/Mage/Customer/etc/adminhtml/menu.xml @@ -0,0 +1,35 @@ + + + + + + + + + + diff --git a/app/code/Mage/Customer/etc/adminhtml/system.xml b/app/code/Mage/Customer/etc/adminhtml/system.xml new file mode 100644 index 0000000000000..fbc1c07dcffbf --- /dev/null +++ b/app/code/Mage/Customer/etc/adminhtml/system.xml @@ -0,0 +1,264 @@ + + + + + + + +
    + separator-top + + customer + Mage_Customer::config_customer + + + 1 + + + Mage_Customer_Model_Config_Share + Mage_Customer_Model_Config_Share + + + + + + + Leave empty for default (15 minutes). + + + + + + + To show VAT number on frontend, set Show VAT Number on Frontend option to Yes. + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + 1 + + + + + Mage_Customer_Model_Config_Source_Group + + 1 + + + + + Mage_Customer_Model_Config_Source_Group + + 1 + + + + + Mage_Customer_Model_Config_Source_Group + + 1 + + + + + Mage_Backend_Model_Config_Source_Yesno + + 1 + + + + + Mage_Backend_Model_Config_Source_Yesno + + + + Mage_Backend_Model_Config_Source_Yesno + + + + + + + Mage_Backend_Model_Config_Source_Email_Template + + + + Mage_Backend_Model_Config_Source_Email_Identity + + + + Mage_Backend_Model_Config_Source_Yesno + + + + Mage_Backend_Model_Config_Source_Email_Template + + + + This email will be sent instead of default welcome email, after account confirmation. + Mage_Backend_Model_Config_Source_Email_Template + + + + Mage_Backend_Model_Config_Source_Yesno + + + + + + + Mage_Backend_Model_Config_Source_Email_Template + + + + Mage_Backend_Model_Config_Source_Email_Template + + + + Mage_Backend_Model_Config_Source_Email_Identity + + + + Please enter a number 1 or greater in this field. + required-entry validate-digits validate-digits-range digits-range-1- + Mage_Customer_Model_Config_Backend_Password_Link_Expirationperiod + + + + + + + Mage_Customer_Model_Config_Backend_Address_Street + Leave empty for default (2). Valid range: 1-4 + + + + Mage_Backend_Model_Config_Source_Nooptreq + Mage_Customer_Model_Config_Backend_Show_Address + The title that goes before name (Mr., Mrs., etc.) + + + + + Put semicolon in the beginning for empty first option.
    Leave empty for open text field.]]> +
    +
    + + + Mage_Backend_Model_Config_Source_Yesno + Always optional. + Mage_Customer_Model_Config_Backend_Show_Address + + + + Mage_Backend_Model_Config_Source_Nooptreq + The suffix that goes after name (Jr., Sr., etc.) + Mage_Customer_Model_Config_Backend_Show_Address + + + + + Put semicolon in the beginning for empty first option.
    Leave empty for open text field.]]> +
    +
    + + + Mage_Backend_Model_Config_Source_Nooptreq + Mage_Customer_Model_Config_Backend_Show_Customer + + + + Mage_Backend_Model_Config_Source_Nooptreq + Mage_Customer_Model_Config_Backend_Show_Customer + + + + Mage_Backend_Model_Config_Source_Nooptreq + Mage_Customer_Model_Config_Backend_Show_Customer + +
    + + + + + Mage_Backend_Model_Config_Source_Yesno + Customer will stay on the current page if "No" is selected. + + + + + + + + + + + + + + + + + + + + +
    +
    + + + Validate VAT Number + Mage_Adminhtml_Block_Customer_System_Config_Validatevat + + +
    +
    +
    diff --git a/app/code/core/Mage/Customer/etc/api.xml b/app/code/Mage/Customer/etc/api.xml similarity index 100% rename from app/code/core/Mage/Customer/etc/api.xml rename to app/code/Mage/Customer/etc/api.xml diff --git a/app/code/Mage/Customer/etc/config.xml b/app/code/Mage/Customer/etc/config.xml new file mode 100644 index 0000000000000..0a945ca99d490 --- /dev/null +++ b/app/code/Mage/Customer/etc/config.xml @@ -0,0 +1,292 @@ + + + + + + 1.6.2.0.3 + true + + + + + + + + + + Mage_Customer/service-calls.xml + + + +
    + + + Text + + + Text One Line + + + HTML + true + + + PDF + + + JavaScript Template + + +
    +
    + + + + Mage_Customer + Mage_Customer_Model_Resource_Setup + + + + + + + + + Mage_Customer_Model_Observer + beforeAddressSave + + + + + + + Mage_Customer_Model_Observer + afterAddressSave + + + + + + + Mage_Customer_Model_Customer_Webhook_Observer + dispatchCustomerEvent + + + + + + + Mage_Customer_Model_Customer_Webhook_Observer + dispatchCustomerDeletedEvent + + + + + + + + + + inform + + + + inform + + + + inform + + + + + inform + + + +
    + + + + + + Mage_Customer.csv + + + + + + + + /customer/ + + + + + + Mage_Customer_Model_Observer + quoteSubmitAfter + + + + + + + standard + + Mage_Customer + customer + + + + + + + + Mage_Customer.csv + + + + + + + + layout.xml + + + + + + + + 1 + + + 0 + 1 + billing + example.com + general + customer_create_account_email_template + customer_create_account_email_confirmation_template + customer_create_account_email_confirmed_template + 0 + + + 1 + + + support + customer_password_forgot_email_template + customer_password_remind_email_template + 1 + +
    + 2 + + + + + + + +
    + + 1 + + + {{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}} +{{depend company}}{{var company}}{{/depend}} +{{if street1}}{{var street1}} +{{/if}} +{{depend street2}}{{var street2}}{{/depend}} +{{depend street3}}{{var street3}}{{/depend}} +{{depend street4}}{{var street4}}{{/depend}} +{{if city}}{{var city}}, {{/if}}{{if region}}{{var region}}, {{/if}}{{if postcode}}{{var postcode}}{{/if}} +{{var country}} +T: {{var telephone}} +{{depend fax}}F: {{var fax}}{{/depend}} +{{depend vat_id}}VAT: {{var vat_id}}{{/depend}} + {{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}}, {{var street}}, {{var city}}, {{var region}} {{var postcode}}, {{var country}} + +{{depend company}}{{var company}}
    {{/depend}} +{{if street1}}{{var street1}}
    {{/if}} +{{depend street2}}{{var street2}}
    {{/depend}} +{{depend street3}}{{var street3}}
    {{/depend}} +{{depend street4}}{{var street4}}
    {{/depend}} +{{if city}}{{var city}}, {{/if}}{{if region}}{{var region}}, {{/if}}{{if postcode}}{{var postcode}}{{/if}}
    +{{var country}}
    +{{depend telephone}}T: {{var telephone}}{{/depend}} +{{depend fax}}
    F: {{var fax}}{{/depend}} +{{depend vat_id}}
    VAT: {{var vat_id}}{{/depend}}]]> + F: {{var fax}}{{/depend}}| +{{depend vat_id}}
    VAT: {{var vat_id}}{{/depend}}|]]>
    + #{company}
    #{street0}
    #{street1}
    #{street2}
    #{street3}
    #{city}, #{region}, #{postcode}
    #{country_id}
    T: #{telephone}
    F: #{fax}
    VAT: #{vat_id}]]>
    +
    +
    +
    +
    diff --git a/app/code/core/Mage/Customer/etc/fieldset.xml b/app/code/Mage/Customer/etc/fieldset.xml similarity index 100% rename from app/code/core/Mage/Customer/etc/fieldset.xml rename to app/code/Mage/Customer/etc/fieldset.xml diff --git a/app/code/Mage/Customer/etc/service-calls.xml b/app/code/Mage/Customer/etc/service-calls.xml new file mode 100644 index 0000000000000..ca2271c03b064 --- /dev/null +++ b/app/code/Mage/Customer/etc/service-calls.xml @@ -0,0 +1,28 @@ + + + + + \ No newline at end of file diff --git a/app/code/core/Mage/Customer/etc/validation.xml b/app/code/Mage/Customer/etc/validation.xml similarity index 100% rename from app/code/core/Mage/Customer/etc/validation.xml rename to app/code/Mage/Customer/etc/validation.xml diff --git a/app/code/Mage/Customer/etc/webapi/acl.xml b/app/code/Mage/Customer/etc/webapi/acl.xml new file mode 100644 index 0000000000000..a380c9cab6d8d --- /dev/null +++ b/app/code/Mage/Customer/etc/webapi/acl.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/code/Mage/Customer/etc/webhook/acl.xml b/app/code/Mage/Customer/etc/webhook/acl.xml new file mode 100644 index 0000000000000..29df308e934b3 --- /dev/null +++ b/app/code/Mage/Customer/etc/webhook/acl.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + diff --git a/app/code/core/Mage/Customer/etc/wsdl.xml b/app/code/Mage/Customer/etc/wsdl.xml similarity index 100% rename from app/code/core/Mage/Customer/etc/wsdl.xml rename to app/code/Mage/Customer/etc/wsdl.xml diff --git a/app/code/core/Mage/Customer/etc/wsi.xml b/app/code/Mage/Customer/etc/wsi.xml similarity index 100% rename from app/code/core/Mage/Customer/etc/wsi.xml rename to app/code/Mage/Customer/etc/wsi.xml diff --git a/app/code/core/Mage/Customer/locale/de_DE/Mage_Customer.csv b/app/code/Mage/Customer/locale/de_DE/Mage_Customer.csv similarity index 100% rename from app/code/core/Mage/Customer/locale/de_DE/Mage_Customer.csv rename to app/code/Mage/Customer/locale/de_DE/Mage_Customer.csv diff --git a/app/code/core/Mage/Customer/locale/en_US/Mage_Customer.csv b/app/code/Mage/Customer/locale/en_US/Mage_Customer.csv similarity index 100% rename from app/code/core/Mage/Customer/locale/en_US/Mage_Customer.csv rename to app/code/Mage/Customer/locale/en_US/Mage_Customer.csv diff --git a/app/code/core/Mage/Customer/locale/es_ES/Mage_Customer.csv b/app/code/Mage/Customer/locale/es_ES/Mage_Customer.csv similarity index 100% rename from app/code/core/Mage/Customer/locale/es_ES/Mage_Customer.csv rename to app/code/Mage/Customer/locale/es_ES/Mage_Customer.csv diff --git a/app/code/core/Mage/Customer/locale/fr_FR/Mage_Customer.csv b/app/code/Mage/Customer/locale/fr_FR/Mage_Customer.csv similarity index 100% rename from app/code/core/Mage/Customer/locale/fr_FR/Mage_Customer.csv rename to app/code/Mage/Customer/locale/fr_FR/Mage_Customer.csv diff --git a/app/code/core/Mage/Customer/locale/nl_NL/Mage_Customer.csv b/app/code/Mage/Customer/locale/nl_NL/Mage_Customer.csv similarity index 100% rename from app/code/core/Mage/Customer/locale/nl_NL/Mage_Customer.csv rename to app/code/Mage/Customer/locale/nl_NL/Mage_Customer.csv diff --git a/app/code/core/Mage/Customer/locale/pt_BR/Mage_Customer.csv b/app/code/Mage/Customer/locale/pt_BR/Mage_Customer.csv similarity index 100% rename from app/code/core/Mage/Customer/locale/pt_BR/Mage_Customer.csv rename to app/code/Mage/Customer/locale/pt_BR/Mage_Customer.csv diff --git a/app/code/core/Mage/Customer/locale/zh_CN/Mage_Customer.csv b/app/code/Mage/Customer/locale/zh_CN/Mage_Customer.csv similarity index 100% rename from app/code/core/Mage/Customer/locale/zh_CN/Mage_Customer.csv rename to app/code/Mage/Customer/locale/zh_CN/Mage_Customer.csv diff --git a/app/code/core/Mage/Customer/sql/customer_setup/install-1.6.0.0.php b/app/code/Mage/Customer/sql/customer_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Customer/sql/customer_setup/install-1.6.0.0.php rename to app/code/Mage/Customer/sql/customer_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Customer/sql/customer_setup/mysql4-upgrade-1.6.0.0-1.6.1.0.php b/app/code/Mage/Customer/sql/customer_setup/mysql4-upgrade-1.6.0.0-1.6.1.0.php similarity index 100% rename from app/code/core/Mage/Customer/sql/customer_setup/mysql4-upgrade-1.6.0.0-1.6.1.0.php rename to app/code/Mage/Customer/sql/customer_setup/mysql4-upgrade-1.6.0.0-1.6.1.0.php diff --git a/app/code/core/Mage/Customer/sql/customer_setup/upgrade-1.6.0.0-1.6.1.0.php b/app/code/Mage/Customer/sql/customer_setup/upgrade-1.6.0.0-1.6.1.0.php similarity index 100% rename from app/code/core/Mage/Customer/sql/customer_setup/upgrade-1.6.0.0-1.6.1.0.php rename to app/code/Mage/Customer/sql/customer_setup/upgrade-1.6.0.0-1.6.1.0.php diff --git a/app/code/core/Mage/Customer/sql/customer_setup/upgrade-1.6.1.0-1.6.2.0.php b/app/code/Mage/Customer/sql/customer_setup/upgrade-1.6.1.0-1.6.2.0.php similarity index 100% rename from app/code/core/Mage/Customer/sql/customer_setup/upgrade-1.6.1.0-1.6.2.0.php rename to app/code/Mage/Customer/sql/customer_setup/upgrade-1.6.1.0-1.6.2.0.php diff --git a/app/code/core/Mage/Customer/sql/customer_setup/upgrade-1.6.2.0-1.6.2.0.1.php b/app/code/Mage/Customer/sql/customer_setup/upgrade-1.6.2.0-1.6.2.0.1.php similarity index 100% rename from app/code/core/Mage/Customer/sql/customer_setup/upgrade-1.6.2.0-1.6.2.0.1.php rename to app/code/Mage/Customer/sql/customer_setup/upgrade-1.6.2.0-1.6.2.0.1.php diff --git a/app/code/core/Mage/Customer/sql/customer_setup/upgrade-1.6.2.0.1-1.6.2.0.3.php b/app/code/Mage/Customer/sql/customer_setup/upgrade-1.6.2.0.1-1.6.2.0.3.php similarity index 100% rename from app/code/core/Mage/Customer/sql/customer_setup/upgrade-1.6.2.0.1-1.6.2.0.3.php rename to app/code/Mage/Customer/sql/customer_setup/upgrade-1.6.2.0.1-1.6.2.0.3.php diff --git a/app/code/core/Mage/Customer/view/email/account_new.html b/app/code/Mage/Customer/view/email/account_new.html similarity index 100% rename from app/code/core/Mage/Customer/view/email/account_new.html rename to app/code/Mage/Customer/view/email/account_new.html diff --git a/app/code/core/Mage/Customer/view/email/account_new_confirmation.html b/app/code/Mage/Customer/view/email/account_new_confirmation.html similarity index 100% rename from app/code/core/Mage/Customer/view/email/account_new_confirmation.html rename to app/code/Mage/Customer/view/email/account_new_confirmation.html diff --git a/app/code/core/Mage/Customer/view/email/account_new_confirmed.html b/app/code/Mage/Customer/view/email/account_new_confirmed.html similarity index 100% rename from app/code/core/Mage/Customer/view/email/account_new_confirmed.html rename to app/code/Mage/Customer/view/email/account_new_confirmed.html diff --git a/app/code/core/Mage/Customer/view/email/password_new.html b/app/code/Mage/Customer/view/email/password_new.html similarity index 100% rename from app/code/core/Mage/Customer/view/email/password_new.html rename to app/code/Mage/Customer/view/email/password_new.html diff --git a/app/code/core/Mage/Customer/view/email/password_reset_confirmation.html b/app/code/Mage/Customer/view/email/password_reset_confirmation.html similarity index 100% rename from app/code/core/Mage/Customer/view/email/password_reset_confirmation.html rename to app/code/Mage/Customer/view/email/password_reset_confirmation.html diff --git a/app/code/core/Mage/Customer/view/frontend/account/dashboard.phtml b/app/code/Mage/Customer/view/frontend/account/dashboard.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/account/dashboard.phtml rename to app/code/Mage/Customer/view/frontend/account/dashboard.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/account/dashboard/address.phtml b/app/code/Mage/Customer/view/frontend/account/dashboard/address.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/account/dashboard/address.phtml rename to app/code/Mage/Customer/view/frontend/account/dashboard/address.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/account/dashboard/hello.phtml b/app/code/Mage/Customer/view/frontend/account/dashboard/hello.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/account/dashboard/hello.phtml rename to app/code/Mage/Customer/view/frontend/account/dashboard/hello.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/account/dashboard/info.phtml b/app/code/Mage/Customer/view/frontend/account/dashboard/info.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/account/dashboard/info.phtml rename to app/code/Mage/Customer/view/frontend/account/dashboard/info.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/account/dashboard/newsletter.phtml b/app/code/Mage/Customer/view/frontend/account/dashboard/newsletter.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/account/dashboard/newsletter.phtml rename to app/code/Mage/Customer/view/frontend/account/dashboard/newsletter.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/account/link/back.phtml b/app/code/Mage/Customer/view/frontend/account/link/back.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/account/link/back.phtml rename to app/code/Mage/Customer/view/frontend/account/link/back.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/account/navigation.phtml b/app/code/Mage/Customer/view/frontend/account/navigation.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/account/navigation.phtml rename to app/code/Mage/Customer/view/frontend/account/navigation.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/address.js b/app/code/Mage/Customer/view/frontend/address.js similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/address.js rename to app/code/Mage/Customer/view/frontend/address.js diff --git a/app/code/core/Mage/Customer/view/frontend/address.phtml b/app/code/Mage/Customer/view/frontend/address.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/address.phtml rename to app/code/Mage/Customer/view/frontend/address.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/address/book.phtml b/app/code/Mage/Customer/view/frontend/address/book.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/address/book.phtml rename to app/code/Mage/Customer/view/frontend/address/book.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/address/edit.phtml b/app/code/Mage/Customer/view/frontend/address/edit.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/address/edit.phtml rename to app/code/Mage/Customer/view/frontend/address/edit.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/balance.phtml b/app/code/Mage/Customer/view/frontend/balance.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/balance.phtml rename to app/code/Mage/Customer/view/frontend/balance.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/form/address.phtml b/app/code/Mage/Customer/view/frontend/form/address.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/form/address.phtml rename to app/code/Mage/Customer/view/frontend/form/address.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/form/changepassword.phtml b/app/code/Mage/Customer/view/frontend/form/changepassword.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/form/changepassword.phtml rename to app/code/Mage/Customer/view/frontend/form/changepassword.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/form/confirmation.phtml b/app/code/Mage/Customer/view/frontend/form/confirmation.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/form/confirmation.phtml rename to app/code/Mage/Customer/view/frontend/form/confirmation.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/form/edit.phtml b/app/code/Mage/Customer/view/frontend/form/edit.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/form/edit.phtml rename to app/code/Mage/Customer/view/frontend/form/edit.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/form/forgotpassword.phtml b/app/code/Mage/Customer/view/frontend/form/forgotpassword.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/form/forgotpassword.phtml rename to app/code/Mage/Customer/view/frontend/form/forgotpassword.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/form/login.phtml b/app/code/Mage/Customer/view/frontend/form/login.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/form/login.phtml rename to app/code/Mage/Customer/view/frontend/form/login.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/form/mini.login.phtml b/app/code/Mage/Customer/view/frontend/form/mini.login.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/form/mini.login.phtml rename to app/code/Mage/Customer/view/frontend/form/mini.login.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/form/newsletter.phtml b/app/code/Mage/Customer/view/frontend/form/newsletter.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/form/newsletter.phtml rename to app/code/Mage/Customer/view/frontend/form/newsletter.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/form/register.phtml b/app/code/Mage/Customer/view/frontend/form/register.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/form/register.phtml rename to app/code/Mage/Customer/view/frontend/form/register.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/form/resetforgottenpassword.phtml b/app/code/Mage/Customer/view/frontend/form/resetforgottenpassword.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/form/resetforgottenpassword.phtml rename to app/code/Mage/Customer/view/frontend/form/resetforgottenpassword.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/layout.xml b/app/code/Mage/Customer/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/layout.xml rename to app/code/Mage/Customer/view/frontend/layout.xml diff --git a/app/code/core/Mage/Customer/view/frontend/logout.phtml b/app/code/Mage/Customer/view/frontend/logout.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/logout.phtml rename to app/code/Mage/Customer/view/frontend/logout.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/set-password.js b/app/code/Mage/Customer/view/frontend/set-password.js similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/set-password.js rename to app/code/Mage/Customer/view/frontend/set-password.js diff --git a/app/code/core/Mage/Customer/view/frontend/widget/dob.phtml b/app/code/Mage/Customer/view/frontend/widget/dob.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/widget/dob.phtml rename to app/code/Mage/Customer/view/frontend/widget/dob.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/widget/gender.phtml b/app/code/Mage/Customer/view/frontend/widget/gender.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/widget/gender.phtml rename to app/code/Mage/Customer/view/frontend/widget/gender.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/widget/name.phtml b/app/code/Mage/Customer/view/frontend/widget/name.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/widget/name.phtml rename to app/code/Mage/Customer/view/frontend/widget/name.phtml diff --git a/app/code/core/Mage/Customer/view/frontend/widget/taxvat.phtml b/app/code/Mage/Customer/view/frontend/widget/taxvat.phtml similarity index 100% rename from app/code/core/Mage/Customer/view/frontend/widget/taxvat.phtml rename to app/code/Mage/Customer/view/frontend/widget/taxvat.phtml diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Container.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Container.php new file mode 100644 index 0000000000000..ce2b426b891b8 --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Container.php @@ -0,0 +1,95 @@ +addButton('back_button', array( + 'label' => $this->_helperFactory->get('Mage_Catalog_Helper_Data')->__('Back'), + 'onclick' => 'setLocation(\'' . $this->getUrl('*/*') . '\')', + 'class' => 'back' + )); + + parent::_prepareLayout(); + } + + /** + * Get header text + * + * @return string + */ + public function getHeaderText() + { + return $this->_helperFactory->get('Mage_DesignEditor_Helper_Data')->__('Visual Design Editor'); + } + + /** + * @param string $url + * + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Container + */ + public function setFrameUrl($url) + { + $this->_frameUrl = $url; + return $this; + } + + /** + * Retrieve frame url + * + * @return string + */ + public function getFrameUrl() + { + return $this->_frameUrl; + } + + /** + * Get virtual theme url + * + * @return string + */ + public function getVirtualThemeCreationUrl() + { + return $this->getUrl('*/*/createVirtualTheme', array('theme_id' => $this->getTheme()->getId())); + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/Background.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/Background.php new file mode 100644 index 0000000000000..db6280cb7f8c2 --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/Background.php @@ -0,0 +1,85 @@ +getComponent('color-picker'); + $uploaderData = $this->getComponent('background-uploader'); + + $colorTitle = sprintf("%s {%s: %s}", + $colorData['selector'], + $colorData['attribute'], + $colorData['value'] + ); + $colorHtmlId = $this->getComponentId('color-picker'); + $this->addField($colorHtmlId, 'color-picker', array( + 'name' => $colorHtmlId, + 'value' => $colorData['value'], + 'title' => $colorTitle, + 'label' => null, + )); + + $uploaderId = $this->getComponentId('background-uploader'); + $this->addField($uploaderId, 'background-uploader', array( + 'components' => $uploaderData['components'], + 'name' => $uploaderId, + 'label' => null + )); + + return $this; + } + + /** + * Add element types used in composite font element + * + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Background + */ + protected function _addElementTypes() + { + $this->addType('color-picker', 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_ColorPicker'); + $this->addType('background-uploader', + 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_BackgroundUploader' + ); + + return $this; + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/BackgroundUploader.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/BackgroundUploader.php new file mode 100644 index 0000000000000..b67bd5da693ff --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/BackgroundUploader.php @@ -0,0 +1,133 @@ +getComponent('image-uploader'); + $checkboxData = $this->getComponent('tile'); + + $uploaderTitle = sprintf('%s {%s: url(%s)}', + $uploaderData['selector'], + $uploaderData['attribute'], + $uploaderData['value'] + ); + $uploaderId = $this->getComponentId('image-uploader'); + $this->addField($uploaderId, 'image-uploader', array( + 'name' => $uploaderId, + 'title' => $uploaderTitle, + 'label' => null, + 'value' => $uploaderData['value'] == $uploaderData['default'] ? '' : $uploaderData['value'], + )); + + $checkboxTitle = sprintf('%s {%s: %s}', + $checkboxData['selector'], + $checkboxData['attribute'], + $checkboxData['value'] + ); + $checkboxHtmlId = $this->getComponentId('tile'); + $this->addField($checkboxHtmlId, 'checkbox', array( + 'name' => $checkboxHtmlId, + 'title' => $checkboxTitle, + 'label' => 'Tile Background', + 'class' => 'element-checkbox', + 'value' => 'repeat', + 'checked' => $checkboxData['value'] == 'repeat' + ))->setUncheckedValue('no-repeat'); + + return $this; + } + + /** + * Add element types used in composite font element + * + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_BackgroundUploader + */ + protected function _addElementTypes() + { + $this->addType('image-uploader', 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_ImageUploader'); + + return $this; + } + + /** + * Get component of 'checkbox' type (actually 'tile') + * + * @return Varien_Data_Form_Element_Checkbox + * @throws Mage_Core_Exception + */ + public function getCheckboxElement() + { + $checkboxId = $this->getComponentId('tile'); + + /** @var $element Varien_Data_Form_Element_Abstract */ + foreach ($this->getElements() as $element) { + if ($element->getData('name') == $checkboxId) { + return $element; + } + } + + throw new Mage_Core_Exception( + $this->_helper->__('Element "%s" is not found in "%s"', $checkboxId, $this->getData('name')) + ); + } + + /** + * Get component of 'image-uploader' type + * + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_ImageUploader + * @throws Mage_Core_Exception + */ + public function getImageUploaderElement() + { + $imageUploaderId = $this->getComponentId('image-uploader'); + /** @var $e Varien_Data_Form_Element_Abstract */ + foreach ($this->getElements() as $e) { + if ($e->getData('name') == $imageUploaderId) { + return $e; + } + } + throw new Mage_Core_Exception( + $this->_helper->__('Element "%s" is not found in "%s"', $imageUploaderId, $this->getData('name')) + ); + } +} + diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/Button.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/Button.php new file mode 100644 index 0000000000000..9b00dbd1561a7 --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/Button.php @@ -0,0 +1,78 @@ +getBeforeElementHtml()) { + $html .= sprintf( + '', $this->getHtmlId(), $this->getBeforeElementHtml() + ); + } + $html .= sprintf( + '', + $this->getHtmlId(), + $this->_getUiId(), + $this->serialize($this->getHtmlAttributes()), + $this->getEscapedValue() + ); + + if ($this->getAfterElementHtml()) { + $html .= sprintf( + '', $this->getHtmlId(), $this->getBeforeElementHtml() + ); + } + return $html; + } + + /** + * Html attributes + * + * @return array + */ + public function getHtmlAttributes() + { + $attributes = parent::getHtmlAttributes(); + return array_merge($attributes, $this->_htmlAttributes); + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/ColorPicker.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/ColorPicker.php new file mode 100644 index 0000000000000..b8c93e2f532c2 --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/ColorPicker.php @@ -0,0 +1,53 @@ +setCssClass('element-' . self::CONTROL_TYPE); + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/Column.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/Column.php new file mode 100644 index 0000000000000..8ec70132c22ef --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/Column.php @@ -0,0 +1,159 @@ +_addElementTypes(); + $this->addClass(self::CONTROL_TYPE); + } + + /** + * Add element types that can be added to 'column' element + * + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Column + */ + protected function _addElementTypes() + { + //contains composite font element and logo uploader + $this->addType('logo', 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Logo'); + + //contains font picker, color picker + $this->addType('font', 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Font'); + + //contains color picker and bg uploader + $this->addType('background', 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Background'); + + $this->addType('color-picker', 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_ColorPicker'); + $this->addType('font-picker', 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_FontPicker'); + $this->addType('logo-uploader', 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_LogoUploader'); + $this->addType('background-uploader', + 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_BackgroundUploader' + ); + + return $this; + } + + /** + * @param Mage_DesignEditor_Model_Editor_Tools_QuickStyles_Form_Renderer_Factory $factory + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Column + */ + public function setRendererFactory($factory) + { + $this->_rendererFactory = $factory; + return $this; + } + + /** + * @return Mage_DesignEditor_Model_Editor_Tools_QuickStyles_Form_Renderer_Factory + * @throws Mage_Core_Exception + */ + public function getRendererFactory() + { + if (!$this->_rendererFactory) { + throw new Mage_Core_Exception('Renderer factory was not set'); + } + return $this->_rendererFactory; + } + + /** + * @param Mage_DesignEditor_Model_Editor_Tools_QuickStyles_Form_Element_Factory $factory + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Column + */ + public function setElementsFactory($factory) + { + $this->_elementsFactory = $factory; + return $this; + } + + /** + * @return Mage_DesignEditor_Model_Editor_Tools_QuickStyles_Form_Element_Factory + * @throws Mage_Core_Exception + */ + public function getElementsFactory() + { + if (!$this->_elementsFactory) { + throw new Mage_Core_Exception('Form elements factory was not set'); + } + return $this->_elementsFactory; + } + + /** + * Add fields to column element + * + * @param string $elementId + * @param string $type + * @param array $config + * @param boolean $after + * @param boolean $isAdvanced + * @return Varien_Data_Form_Element_Abstract + */ + public function addField($elementId, $type, $config, $after = false, $isAdvanced = false) + { + if (isset($this->_types[$type])) { + $className = $this->_types[$type]; + } else { + $className = 'Varien_Data_Form_Element_' . ucfirst(strtolower($type)); + } + $element = $this->getElementsFactory()->create($className, $config); + $element->setId($elementId); + $this->addElement($element, $after); + + $layoutName = $element->getId() . '-renderer'; + $renderer = $this->getRendererFactory()->create($className, $layoutName); + $element->setRenderer($renderer); + $element->setAdvanced($isAdvanced); + return $element; + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/Composite/Abstract.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/Composite/Abstract.php new file mode 100644 index 0000000000000..1bb11b431cbef --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/Composite/Abstract.php @@ -0,0 +1,196 @@ +_elementsFactory = $elementsFactory; + $this->_rendererFactory = $rendererFactory; + $this->_helper = $helper; + + parent::__construct($attributes); + } + + /** + * Constructor helper + */ + protected function _construct() + { + parent::_construct(); + $this->setLegend($this->getLabel()); + + $this->_addElementTypes(); + $this->_addFields(); + + $this->addClass('element-' . static::CONTROL_TYPE); + } + + /** + * Add fields to composite composite element + * + * @param string $elementId + * @param string $type + * @param array $config + * @param boolean $after + * @param boolean $isAdvanced + * @return Varien_Data_Form_Element_Abstract + */ + public function addField($elementId, $type, $config, $after = false, $isAdvanced = false) + { + if (isset($this->_types[$type])) { + $className = $this->_types[$type]; + } else { + $className = 'Varien_Data_Form_Element_' . ucfirst(strtolower($type)); + } + $element = $this->_elementsFactory->create($className, $config); + $element->setId($elementId); + $this->addElement($element, $after); + + $layoutName = $element->getId() . '-renderer'; + try { + $renderer = $this->_rendererFactory->create($className, $layoutName); + } catch (Mage_Core_Exception $e) { + $renderer = null; + } + if ($renderer) { + $element->setRenderer($renderer); + } + $element->setAdvanced($isAdvanced); + return $element; + } + + /** + * Get controls component of given type + * + * @param string $type + * @param string|null $subtype + * @return array + * @throws Mage_Core_Exception + */ + public function getComponent($type, $subtype = null) + { + $components = $this->getComponents(); + $componentId = $this->getComponentId($type); + if (!isset($components[$componentId])) { + throw new Mage_Core_Exception($this->_helper->__( + 'Component of the type "%s" is not found between elements of "%s"', $type, $this->getData('name') + )); + } + $component = $components[$componentId]; + + if ($subtype) { + $subComponentId = $this->getComponentId($subtype); + $component = $component['components'][$subComponentId]; + } + + return $component; + } + + /** + * Get id that component of given type should have + * + * @param string $type + * @return string + */ + public function getComponentId($type) + { + $names = explode(self::CONTROL_NAME_DELIMITER, $this->getData('name')); + return join('', array(array_shift($names), self::CONTROL_NAME_DELIMITER, $type)); + } + + /** + * Add form elements + * + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Composite_Abstract + */ + abstract protected function _addFields(); + + /** + * Add element types used in composite font element + * + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Composite_Abstract + */ + abstract protected function _addElementTypes(); +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/ContainerInterface.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/ContainerInterface.php new file mode 100644 index 0000000000000..4f7dab4c01c4d --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/ContainerInterface.php @@ -0,0 +1,43 @@ +getComponent('font-picker'); + $colorData = $this->getComponent('color-picker'); + + $fontHtmlId = $this->getComponentId('font-picker'); + $fontTitle = sprintf("%s {%s: %s}", + $fontData['selector'], + $fontData['attribute'], + $fontData['value'] + ); + $this->addField($fontHtmlId, 'font-picker', array( + 'name' => $fontHtmlId, + 'value' => $fontData['value'], + 'title' => $fontTitle, + 'options' => array_combine($fontData['options'], $fontData['options']), + 'label' => null, + )); + + $colorTitle = sprintf("%s {%s: %s}", + $colorData['selector'], + $colorData['attribute'], + $colorData['value'] + ); + $colorHtmlId = $this->getComponentId('color-picker'); + $this->addField($colorHtmlId, 'color-picker', array( + 'name' => $colorHtmlId, + 'value' => $colorData['value'], + 'title' => $colorTitle, + 'label' => null, + )); + + return $this; + } + + /** + * Add element types used in composite font element + * + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Font + */ + protected function _addElementTypes() + { + $this->addType('color-picker', 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_ColorPicker'); + $this->addType('font-picker', 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_FontPicker'); + + return $this; + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/FontPicker.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/FontPicker.php new file mode 100644 index 0000000000000..455b704f228a0 --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/FontPicker.php @@ -0,0 +1,66 @@ +_defaultOptions, $this->_defaultOptions), $this->getOptions()); + $this->setOptions($options); + + $this->setCssClass('element-' . self::CONTROL_TYPE); + } +} + diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/ImageUploader.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/ImageUploader.php new file mode 100644 index 0000000000000..c011971c6e718 --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/ImageUploader.php @@ -0,0 +1,60 @@ +setAccept($this->_acceptTypesDefault); + $this->setMultiple($this->_multipleFiles); + + $this->addClass('element-' . self::CONTROL_TYPE); + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/Logo.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/Logo.php new file mode 100644 index 0000000000000..17119d125b070 --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/Logo.php @@ -0,0 +1,71 @@ +getComponent('logo-uploader'); + $uploaderTitle = sprintf('%s {%s: url(%s)}', + $uploaderData['selector'], + $uploaderData['attribute'], + $uploaderData['value'] + ); + $uploaderId = $this->getComponentId('logo-uploader'); + $this->addField($uploaderId, 'logo-uploader', array( + 'name' => $uploaderId, + 'title' => $uploaderTitle, + 'label' => null + )); + + return $this; + } + + /** + * Add element types used in composite font element + * + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Logo + */ + protected function _addElementTypes() + { + $this->addType('logo-uploader', 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_LogoUploader'); + return $this; + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/LogoUploader.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/LogoUploader.php new file mode 100644 index 0000000000000..f05c70b6903da --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/LogoUploader.php @@ -0,0 +1,44 @@ +_htmlAttributes); + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer.php new file mode 100644 index 0000000000000..b5e37fd70b3da --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer.php @@ -0,0 +1,68 @@ +_element; + } + + /** + * Render form element as HTML + * + * @param Varien_Data_Form_Element_Abstract $element + * @return string + */ + public function render(Varien_Data_Form_Element_Abstract $element) + { + $this->_element = $element; + return $this->toHtml(); + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/BackgroundUploader.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/BackgroundUploader.php new file mode 100644 index 0000000000000..62e303b7fca7b --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/BackgroundUploader.php @@ -0,0 +1,75 @@ +_helperFactory->get('Mage_DesignEditor_Helper_Data'); + return $helper->getEditableThemeId(); + } + + /** + * Get URL of image upload action + * + * @return string + */ + public function getImageUploadUrl() + { + return $this->getUrl('*/system_design_editor_tools/uploadQuickStyleImage', + array('theme_id' => $this->getThemeId()) + ); + } + + /** + * Get URL of remove image action + * + * @return string + */ + public function getImageRemoveUrl() + { + return $this->getUrl('*/system_design_editor_tools/removeQuickStyleImage', + array('theme_id' => $this->getThemeId()) + ); + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Checkbox.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Checkbox.php new file mode 100644 index 0000000000000..ac48f831fbb1e --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Checkbox.php @@ -0,0 +1,46 @@ +getHtml() ?> + * + * @var array + */ + protected $_templates = array( + 'Mage_DesignEditor::editor/form/renderer/element/input.phtml', + 'Mage_DesignEditor::editor/form/renderer/checkbox-utility.phtml', + 'Mage_DesignEditor::editor/form/renderer/element/wrapper.phtml', + 'Mage_DesignEditor::editor/form/renderer/template.phtml', + ); +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/ColorPicker.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/ColorPicker.php new file mode 100644 index 0000000000000..53ed12526985b --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/ColorPicker.php @@ -0,0 +1,105 @@ +getHtml() ?> + * Templates used are based fieldset/element.phtml but split into several templates + * + * @var array + */ + protected $_templates = array( + 'Mage_DesignEditor::editor/form/renderer/element/input.phtml', + 'Mage_DesignEditor::editor/form/renderer/color-picker.phtml', + 'Mage_DesignEditor::editor/form/renderer/element/wrapper.phtml', + 'Mage_DesignEditor::editor/form/renderer/simple.phtml' + ); + + /** + * Get HTMl class of a field + * + * Actually it will be added to a field wrapper + * + * @return array + */ + public function getFieldClass() + { + /** @var $element Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_ColorPicker */ + $element = $this->getElement(); + + $elementBeforeLabel = $element->getExtType() == 'checkbox' || $element->getExtType() == 'radio'; + $addOn = $element->getBeforeElementHtml() || $element->getAfterElementHtml(); + + //@TODO add class that show the control type 'color-picker' for this one + $classes = array(); + $classes[] = 'field'; + $classes[] = 'field-' . $element->getId(); + $classes[] = $element->getCssClass(); + if ($elementBeforeLabel) { + $classes[] = 'choice'; + } + if ($addOn) { + $classes[] = 'with-addon'; + } + if ($element->getRequired()) { + $classes[] = 'required'; + } + if ($element->getNote()) { + $classes[] = 'with-note'; + } + + return $classes; + } + + /** + * Get field attributes string + * + * Actually it will be added to a field wrapper + * + * @see Mage_DesignEditor::editor/form/renderer/simple.phtml + * @return string + */ + public function getFieldAttributes() + { + $element = $this->getElement(); + + $fieldAttributes = array(); + if ($element->getHtmlContainerId()) { + $fieldAttributes[] = sprintf('id="%s"', $element->getHtmlContainerId()); + } + $fieldAttributes[] = sprintf('class="%s"', join(' ', $this->getFieldClass())); + $fieldAttributes[] = $this->getUiId('form-field', $element->getId()); + + return join(' ', $fieldAttributes); + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Column.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Column.php new file mode 100644 index 0000000000000..49b816b437ced --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Column.php @@ -0,0 +1,33 @@ +getHtml() ?> + * This templates are made of fieldset.phtml but split into several templates + * + * @var array + */ + protected $_templates = array( + 'Mage_DesignEditor::editor/form/renderer/composite/children.phtml', + 'Mage_DesignEditor::editor/form/renderer/composite.phtml', + 'Mage_DesignEditor::editor/form/renderer/composite/wrapper.phtml', + ); + + /** + * Get CSS classes for element + * + * Used in composite.phtml + * + * @return array + */ + public function getCssClasses() + { + /** @var $element Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Composite_Abstract */ + $element = $this->getElement(); + $isField = $element->getFieldsetType() == 'field'; + + $cssClasses = array(); + $cssClasses[] = ($isField) ? 'field' : 'fieldset'; + if ($element->getClass()) { + $cssClasses[] = $element->getClass(); + } + if ($isField && $element->hasAdvanced()) { + $cssClasses[] = 'complex'; + } + + return $cssClasses; + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Font.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Font.php new file mode 100644 index 0000000000000..be6c71978d673 --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Font.php @@ -0,0 +1,58 @@ +getElement(); + + $classes = array(); + $classes[] = 'fieldset'; + if ($element->getClass()) { + $classes[] = $element->getClass(); + } + + return $classes; + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/ImageUploader.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/ImageUploader.php new file mode 100644 index 0000000000000..5af4c815923f6 --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/ImageUploader.php @@ -0,0 +1,33 @@ +getHtml() ?> + * + * @var array + */ + protected $_templates = array( + 'Mage_DesignEditor::editor/form/renderer/element/input.phtml', + 'Mage_DesignEditor::editor/form/renderer/logo-uploader.phtml', + ); + + /** + * Return theme identification number + * + * @return int|null + */ + protected function getThemeId() + { + /** @var $helper Mage_DesignEditor_Helper_Data */ + $helper = $this->_helperFactory->get('Mage_DesignEditor_Helper_Data'); + return $helper->getVirtualThemeId(); + } + + /** + * Get logo upload url + * + * @param Mage_Core_Model_Store $store + * @return string + */ + public function getLogoUploadUrl($store) + { + return $this->getUrl('*/system_design_editor_tools/uploadStoreLogo', + array('theme_id' => $this->getThemeId(), 'store_id' => $store->getId()) + ); + } + + /** + * Get logo upload url + * + * @param Mage_Core_Model_Store $store + * @return string + */ + public function getLogoRemoveUrl($store) + { + return $this->getUrl('*/system_design_editor_tools/removeStoreLogo', + array('theme_id' => $this->getThemeId(), 'store_id' => $store->getId()) + ); + } + + /** + * Get logo image + * + * @param Mage_Core_Model_Store $store + * @return string|bool + */ + public function getLogoImage($store) + { + return (null !== $store) ? $this->_storeConfig->getConfig('design/header/logo_src', $store->getId()) : null; + } + + /** + * Get stores list + * + * @return mixed + */ + public function getStoresList() + { + $stores = Mage::getObjectManager()->get('Mage_Core_Model_Theme_Service')->getStoresByThemes(); + return isset($stores[$this->getThemeId()]) + ? $stores[$this->getThemeId()] + : null; + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Recursive.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Recursive.php new file mode 100644 index 0000000000000..11c8b0198751c --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Recursive.php @@ -0,0 +1,88 @@ +getHtml() ?> + * + * @var array + */ + protected $_templates = array(); + + /** + * Get element renderer bound to + * + * @return Varien_Data_Form_Element_Abstract + */ + public function getElement() + { + return $this->_element; + } + + /** + * Render form element as HTML + * + * @param Varien_Data_Form_Element_Abstract $element + * @return string + */ + public function render(Varien_Data_Form_Element_Abstract $element) + { + $this->_element = $element; + + foreach ($this->_templates as $template) { + $this->setTemplate($template); + $this->setHtml($this->toHtml()); + } + + return $this->getHtml(); + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Uploader.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Uploader.php new file mode 100644 index 0000000000000..c5cd39bc8499b --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Uploader.php @@ -0,0 +1,43 @@ +getHtml() ?> + * + * @var array + */ + protected $_templates = array( + 'Mage_DesignEditor::editor/form/renderer/element/input.phtml', + ); +} diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/BlockAbstract.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/BlockAbstract.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/BlockAbstract.php rename to app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/BlockAbstract.php diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons.php new file mode 100644 index 0000000000000..6f1a97a40296a --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons.php @@ -0,0 +1,229 @@ +_themeId; + } + + /** + * Get current theme id + * + * @param int $themeId + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Toolbar_Buttons + */ + public function setThemeId($themeId) + { + $this->_themeId = $themeId; + + return $this; + } + + /** + * Get "View Layout" button URL + * + * @return string + */ + public function getViewLayoutUrl() + { + return $this->getUrl('*/*/getLayoutUpdate'); + } + + /** + * Get "Quit" button URL + * + * @return string + */ + public function getQuitUrl() + { + return $this->getUrl('*/*/quit'); + } + + /** + * Get "Navigation Mode" button URL + * + * @return string + */ + public function getNavigationModeUrl() + { + return $this->getUrl('*/*/launch', array( + 'theme_id' => $this->getVirtualThemeId(), + 'mode' => Mage_DesignEditor_Model_State::MODE_NAVIGATION + )); + } + + /** + * Get "Design Mode" button URL + * + * @return string + */ + public function getDesignModeUrl() + { + return $this->getUrl('*/*/launch', array( + 'theme_id' => $this->getVirtualThemeId(), + 'mode' => Mage_DesignEditor_Model_State::MODE_DESIGN + )); + } + + /** + * Get assign to storeview button + * + * @return string + */ + public function getAssignButtonHtml() + { + $message = "You are about to change this theme for your live store, are you sure want to do this?\n\n" . + 'Note: copy of the current theme will be created automatically and assigned to your store, ' . + 'so you can change your copy later as you wish'; + + /** @var $assignButton Mage_Backend_Block_Widget_Button */ + $assignButton = $this->getLayout()->createBlock('Mage_Backend_Block_Widget_Button'); + $assignButton->setData(array( + 'label' => $this->__('Assign this Theme'), + 'data_attribute' => array( + 'mage-init' => array( + 'button' => array( + 'event' => 'assign', + 'target' => 'body', + 'eventData' => array( + 'theme_id' => $this->getThemeId(), + 'confirm_message' => $this->__($message) + ) + ), + ), + ), + 'class' => 'save action-theme-assign', + 'target' => '_blank' + )); + + return $assignButton->toHtml(); + } + + /** + * Get switch mode button init data + * + * @return string + */ + public function getSwitchModeButtonInitData() + { + $eventData = array( + 'theme_id' => $this->getVirtualThemeId(), + ); + + if ($this->isNavigationMode()) { + $eventData['mode_url'] = $this->getDesignModeUrl(); + } else { + $eventData['mode_url'] = $this->getNavigationModeUrl(); + $eventData['save_changes_url'] = $this->getSaveTemporaryLayoutUpdateUrl(); + } + + $data = array( + 'button' => array( + 'event' => 'switchMode', + 'target' => 'body', + 'eventData' => $eventData + ), + ); + + return $this->helper('Mage_Backend_Helper_Data')->escapeHtml(json_encode($data)); + } + + /** + * Get save temporary layout changes url + * + * @return string + */ + public function getSaveTemporaryLayoutUpdateUrl() + { + return $this->getUrl('*/*/saveTemporaryLayoutUpdate'); + } + + /** + * Get button HTML + * + * @return string + */ + public function getViewLayoutButtonHtml() + { + //TODO If this link is clicked before event handler is assigned - it will result in opening a url + //intended for AJAX + + $button = sprintf('%s', + $this->getViewLayoutUrl(), + $this->__('View Layout'), + $this->__('View Layout') + ); + + return $button; + } + + /** + * Get Quit button HTML + * + * @return string + */ + public function getQuitButtonHtml() + { + $button = sprintf('%s', + $this->getQuitUrl(), + $this->__('Quit'), + $this->__('Quit') + ); + + return $button; + } + + /** + * Get admin panel home page URL + * + * @return string + */ + public function getHomeLink() + { + return $this->helper('Mage_Backend_Helper_Data')->getHomePageUrl(); + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/Save.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/Save.php new file mode 100644 index 0000000000000..258c4025350e6 --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/Save.php @@ -0,0 +1,265 @@ +getTheme(); + $themeType = $theme->getType(); + if ($themeType == Mage_Core_Model_Theme::TYPE_PHYSICAL) { + $this->_initPhysical(); + } else if ($themeType == Mage_Core_Model_Theme::TYPE_VIRTUAL) { + if ($theme->getDomainModel(Mage_Core_Model_Theme::TYPE_VIRTUAL)->isAssigned()) { + $this->_initAssigned(); + } else { + $this->_initUnAssigned(); + } + } else { + throw new InvalidArgumentException( + sprintf('Invalid theme of a "%s" type passed to save button block', $themeType) + ); + } + + return $this; + } + + /** + * Get current theme + * + * @return Mage_Core_Model_Theme + * @throws InvalidArgumentException + */ + public function getTheme() + { + if (null === $this->_theme) { + throw new InvalidArgumentException('Current theme was not passed to save button'); + } + return $this->_theme; + } + + /** + * Set current theme + * + * @param Mage_Core_Model_Theme $theme + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Toolbar_Buttons + */ + public function setTheme($theme) + { + $this->_theme = $theme; + + return $this; + } + + /** + * Whether button is disabled + * + * @return mixed + */ + public function getDisabled() + { + return false; + } + + /** + * Disable actions-split functionality if no options provided + * + * + * @return bool + */ + public function hasSplit() + { + $options = $this->getOptions(); + return is_array($options) && count($options) > 0; + } + + /** + * Get URL to apply changes from 'staging' theme to 'virtual' theme + * + * @return string + */ + public function getSaveUrl() + { + return $this->getUrl('*/system_design_editor/save', array('theme_id' => $this->getTheme()->getId())); + } + + /** + * Init 'Save' button for 'physical' theme + * + * @return $this + */ + protected function _initPhysical() + { + $this->setData(array( + 'label' => $this->__('Assign'), + 'data_attribute' => array('mage-init' => $this->_getAssignInitData()), + 'options' => array() + )); + + return $this; + } + + /** + * Init 'Save' button for 'virtual' theme assigned to a store + * + * @return $this + */ + protected function _initAssigned() + { + $this->setData(array( + 'label' => $this->__('Save'), + 'data_attribute' => array('mage-init' => $this->_getSaveAndAssignInitData()), + 'options' => array() + )); + + return $this; + } + + /** + * Init 'Save' button for 'virtual' theme assigned to a store + * + * @return $this + */ + protected function _initUnAssigned() + { + $this->setData(array( + 'label' => $this->__('Save'), + 'data_attribute' => array('mage-init' => $this->_getSaveInitData()), + 'options' => array( + array( + 'label' => $this->__('Save'), + 'data_attribute' => array('mage-init' => $this->_getSaveInitData()), + 'disabled' => true + ), + array( + 'label' => $this->__('Save and Assign'), + 'data_attribute' => array('mage-init' => $this->_getSaveAndAssignInitData()) + ), + ) + )); + + return $this; + } + + /** + * Get 'data-mage-init' attribute value for 'Save' button + * + * @return string + */ + protected function _getSaveInitData() + { + $message = "You are about to apply current changes for your live store, are you sure want to do this?"; + $data = array( + 'button' => array( + 'event' => 'save', + 'target' => 'body', + 'eventData' => array( + 'theme_id' => $this->getTheme()->getId(), + 'save_url' => $this->getSaveUrl(), + 'confirm_message' => $this->__($message) + ) + ), + ); + + return $this->_encode($data); + } + + /** + * Get 'data-mage-init' attribute value for 'Save' button + * + * @return string + */ + protected function _getAssignInitData() + { + $message = "You are about to apply this theme for your live store, are you sure want to do this?\n\n" . + 'Note: copy of the current theme will be created automatically and assigned to your store, ' . + 'so you can change your copy as you wish'; + $data = array( + 'button' => array( + 'event' => 'assign', + 'target' => 'body', + 'eventData' => array( + 'theme_id' => $this->getTheme()->getId(), + 'confirm_message' => $this->__($message) + ) + ), + ); + + return $this->_encode($data); + } + + /** + * Get 'data-mage-init' attribute value for 'Save and Assign' button + * + * @return string + */ + protected function _getSaveAndAssignInitData() + { + $message = "You are about to apply current changes for your live store, are you sure want to do this?"; + + $data = array( + 'button' => array( + 'event' => 'save-and-assign', + 'target' => 'body', + 'eventData' => array( + 'theme_id' => $this->getTheme()->getId(), + 'save_url' => $this->getSaveUrl(), + 'confirm_message' => $this->__($message) + ) + ), + ); + + return $this->_encode($data); + } + + /** + * Get encoded data string + * + * @param array $data + * @return string + */ + protected function _encode($data) + { + return $this->helper('Mage_Backend_Helper_Data')->escapeHtml(json_encode($data)); + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/HandlesHierarchy.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/HandlesHierarchy.php new file mode 100644 index 0000000000000..934b15e91b864 --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/HandlesHierarchy.php @@ -0,0 +1,140 @@ +_vdeUrlBuilder = $vdeUrlBuilder; + parent::__construct($context, $data); + } + + /** + * Recursively render each level of the page handles hierarchy + * + * @param array $hierarchy + * @return string + */ + protected function _renderHierarchy(array $hierarchy) + { + if (!$hierarchy) { + return ''; + } + $result = '
      '; + foreach ($hierarchy as $name => $info) { + $linkUrl = $this->_vdeUrlBuilder->getUrl('design/page/type', array('handle' => $name)); + $class = $info['type'] == Mage_Core_Model_Layout_Merge::TYPE_FRAGMENT + ? ' class="vde_option_fragment"' + : ''; + $result .= '
    • '; + $result .= ''; + $result .= $this->escapeHtml($info['label']); + $result .= ''; + $result .= $this->_renderHierarchy($info['children']); + $result .= '
    • '; + } + $result .= '
    '; + return $result; + } + + /** + * Render page handles hierarchy as an HTML list + * + * @return string + */ + public function renderHierarchy() + { + return $this->_renderHierarchy($this->getHierarchy()); + } + + /** + * Retrieve the name of the currently selected page handle + * + * @return string|null + */ + public function getSelectedHandle() + { + if ($this->_selectedHandle === null) { + $pageHandles = $this->getHierarchy(); + $defaultHandle = reset($pageHandles); + if ($defaultHandle !== false) { + $this->_selectedHandle = $defaultHandle['name']; + } + } + return $this->_selectedHandle; + } + + /** + * Retrieve label for the currently selected page handle + * + * @return string|null + */ + public function getSelectedHandleLabel() + { + return $this->escapeHtml($this->getLayout()->getUpdate()->getPageHandleLabel($this->getSelectedHandle())); + } + + /** + * Set the name of the currently selected page handle + * + * @param string $handleName Page handle name + */ + public function setSelectedHandle($handleName) + { + $this->_selectedHandle = $handleName; + } +} diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/ViewOptions.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/ViewOptions.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/ViewOptions.php rename to app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/ViewOptions.php diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools.php new file mode 100644 index 0000000000000..4e3e7da518b92 --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools.php @@ -0,0 +1,145 @@ +getMode() == Mage_DesignEditor_Model_State::MODE_NAVIGATION; + return array( + array( + 'is_hidden' => false, + 'is_disabled' => $isDisabled, + 'id' => 'vde-tab-quick-styles', + 'label' => $this->__('Quick Styles'), + 'content_block' => 'design_editor_tools_quick-styles', + 'class' => 'item-design' + ), + array( + 'is_hidden' => true, + 'is_disabled' => $isDisabled, + 'id' => 'vde-tab-block', + 'label' => $this->__('Block'), + 'content_block' => 'design_editor_tools_block', + 'class' => 'item-block' + ), + array( + 'is_hidden' => true, + 'is_disabled' => $isDisabled, + 'id' => 'vde-tab-settings', + 'label' => $this->__('Settings'), + 'content_block' => 'design_editor_tools_settings', + 'class' => 'item-settings' + ), + array( + 'is_hidden' => false, + 'is_disabled' => $isDisabled, + 'id' => 'vde-tab-code', + 'label' => $this->__('Code'), + 'content_block' => 'design_editor_tools_code', + 'class' => 'item-code' + ), + ); + } + + /** + * Get tabs html + * + * @return array + */ + public function getTabContents() + { + $contents = array(); + foreach ($this->getTabs() as $tab) { + $contents[] = $this->getChildHtml($tab['content_block']); + } + return $contents; + } + + /** + * Get tabs handles + * + * @return array + */ + public function getTabHandles() + { + /** @var $tabHandleBlock Mage_Backend_Block_Template */ + $tabHandleBlock = $this->getChildBlock(self::TAB_HANDLE_BLOCK_ALIAS); + $handles = array(); + foreach ($this->getTabs() as $tab) { + $href = '#' . $tab['id']; + $handles[] = $tabHandleBlock->setIsHidden($tab['is_hidden']) + ->setIsDisabled($tab['is_disabled']) + ->setHref($href) + ->setClass($tab['class']) + ->setTitle($tab['label']) + ->setLabel($tab['label']) + ->toHtml(); + } + + return $handles; + } + + /** + * Return theme identification number + * + * @return int|null + */ + protected function getThemeId() + { + /** @var $helper Mage_DesignEditor_Helper_Data */ + $helper = $this->_helperFactory->get('Mage_DesignEditor_Helper_Data'); + return $helper->getEditableThemeId(); + } + + /** + * Get save url + * + * @return string + */ + public function getSaveUrl() + { + return $this->getUrl('*/system_design_editor_tools/saveQuickStyles', + array('theme_id' => $this->getThemeId()) + ); + } +} diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Block.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Block.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Block.php rename to app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Block.php diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code.php new file mode 100644 index 0000000000000..fb935250d323f --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code.php @@ -0,0 +1,77 @@ + true, + 'id' => 'vde-tab-css', + 'title' => strtoupper($this->__('CSS')), + 'content_block' => 'design_editor_tools_code_css' + ), + array( + 'is_active' => false, + 'id' => 'vde-tab-js', + 'title' => strtoupper($this->__('JS')), + 'content_block' => 'design_editor_tools_code_js' + ), + array( + 'is_active' => false, + 'id' => 'vde-tab-custom', + 'title' => strtoupper($this->__('Custom CSS')), + 'content_block' => 'design_editor_tools_code_custom' + ), + array( + 'is_active' => false, + 'id' => 'vde-tab-image-sizing', + 'title' => strtoupper($this->__('Image Sizing')), + 'content_block' => 'design_editor_tools_code_image_sizing' + ), + ); + } +} diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Css.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Css.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Css.php rename to app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Css.php diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Css/Group.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Css/Group.php new file mode 100644 index 0000000000000..e96ee20980957 --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Css/Group.php @@ -0,0 +1,66 @@ +getUrl('*/system_design_theme/downloadCss', array( + 'theme_id' => $themeId, + 'file' => $this->_helperFactory->get('Mage_DesignEditor_Helper_Data')->urlEncode($fileId) + )); + } + + /** + * Check if files group needs "add" button + * + * @return bool + */ + public function hasAddButton() + { + return false; + } + + /** + * Check if files group needs download buttons next to each file + * + * @return bool + */ + public function hasDownloadButton() + { + return true; + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Custom.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Custom.php new file mode 100644 index 0000000000000..6462d2fbcc236 --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Custom.php @@ -0,0 +1,120 @@ + '#', + 'method' => 'post' + )); + $this->setForm($form); + $form->setUseContainer(true); + + $form->addType('css_file', 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Uploader'); + + $form->addField($this->getFileElementName(), 'css_file', array( + 'name' => $this->getFileElementName(), + 'accept' => 'text/css', + 'no_span' => true + )); + + parent::_prepareForm(); + return $this; + } + + /** + * Get url to download custom CSS file + * + * @param Mage_Core_Model_Theme $theme + * @return string + */ + public function getDownloadCustomCssUrl($theme) + { + return $this->getUrl('*/system_design_theme/downloadCustomCss', array('theme_id' => $theme->getThemeId())); + } + + /** + * Get url to save custom CSS file + * + * @param Mage_Core_Model_Theme $theme + * @return string + */ + public function getSaveCustomCssUrl($theme) + { + return $this->getUrl('*/system_design_editor_tools/saveCssContent', array('theme_id' => $theme->getThemeId())); + } + + /** + * Get theme custom css content + * + * @param Mage_Core_Model_Theme $theme + * @return string + */ + public function getCustomCssContent($theme) + { + /** @var $cssFile Mage_Core_Model_Theme_File */ + $cssFile = $theme->getCustomizationData(Mage_Core_Model_Theme_Customization_Files_Css::TYPE)->getFirstItem(); + return $cssFile->getContent(); + } + + /** + * Get custom CSS file name + * + * @return string + */ + public function getCustomFileName() + { + return pathinfo(Mage_Core_Model_Theme_Customization_Files_Css::CUSTOM_CSS, PATHINFO_BASENAME); + } + + /** + * Get file element name + * + * @return string + */ + public function getFileElementName() + { + return self::FILE_ELEMENT_NAME; + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/ImageSizing.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/ImageSizing.php new file mode 100644 index 0000000000000..5ef598c60a713 --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/ImageSizing.php @@ -0,0 +1,367 @@ +_eavConfig = $eavConfig; + $this->_controlFactory = $controlFactory; + parent::__construct($context, $data); + } + + /** + * Create a form element with necessary controls + * + * @return Mage_Theme_Block_Adminhtml_System_Design_Theme_Edit_Tab_Css + */ + protected function _prepareForm() + { + $form = new Varien_Data_Form(array( + 'action' => '#', + 'method' => 'post' + )); + $form->setId('product_image_sizing_form'); + $this->setForm($form); + $form->setUseContainer(true); + $form->setFieldNameSuffix('imagesizing'); + $form->addType('button_button', 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Button'); + + try{ + /** @var $controlsConfig Mage_DesignEditor_Model_Editor_Tools_Controls_Configuration */ + $controlsConfig = $this->_controlFactory->create( + Mage_DesignEditor_Model_Editor_Tools_Controls_Factory::TYPE_IMAGE_SIZING, + $this->getTheme() + ); + + $whiteBorder = $controlsConfig->getControlData('product_image_border'); + $controls = $controlsConfig->getAllControlsData(); + } catch (Magento_Exception $e) { + $whiteBorder = array(); + $controls = array(); + } + + if ($whiteBorder) { + $this->_addWhiteBorderElement($whiteBorder); + } + + foreach ($controls as $name => $control ) { + if ($control['type'] != 'image-sizing') { + continue; + } + $this->_addImageSizeFieldset($name, $control); + } + + $fieldset = $form->addFieldset('save_image_sizing_fieldset', array( + 'name' => 'save_image_sizing_fieldset', + 'fieldset_type' => 'field', + 'class' => 'save_image_sizing' + )); + $this->_addElementTypes($fieldset); + + $fieldset->addField('save_image_sizing', 'button_button', array( + 'name' => 'save_image_sizing', + 'title' => $this->__('Update'), + 'value' => $this->__('Update'), + 'data-mage-init' => $this->helper('Mage_Backend_Helper_Data')->escapeHtml(json_encode(array( + 'button' => array( + 'event' => 'saveForm', + 'target' => 'body' + ) + ))) + )); + + parent::_prepareForm(); + return parent::_prepareForm(); + } + + /** + * Add white border checkbox to form + * + * @param array $control + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Tools_Code_ImageSizing + */ + protected function _addWhiteBorderElement($control) + { + /** @var $form Varien_Data_Form */ + $form = $this->getForm(); + $fieldMessage = $this->__('Add the white borders to the images that do not match the container size.'); + foreach ($control['components'] as $name => $component) { + $form->addField('add_white_borders_hidden', 'hidden', array( + 'name' => $name, + 'value' => '0' + )); + $form->addField('add_white_borders', 'checkbox', array( + 'name' => $name, + 'checked' => !empty($component['value']), + 'value' => '1', + 'after_element_html' => $fieldMessage + )); + } + /** @todo Get valid message from PO */ + $hintMessage = $this->__('If an image goes beyond the container edges,' + . ' it will be re-scaled to match the container size.' + . ' By default, the white borders will be added to an image to fill in the container space'); + $form->addField('add_white_borders_hint', 'note', array( + 'after_element_html' => '

    ' . $hintMessage . '

    ')); + + return $this; + } + + /** + * Add one image sizing item to form + * + * @param string $name + * @param array $control + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Tools_Code_ImageSizing + */ + protected function _addImageSizeFieldset($name, $control) + { + /** @var $form Varien_Data_Form */ + $form = $this->getForm(); + $fieldset = $form->addFieldset($name, array( + 'name' => $name, + 'fieldset_type' => 'field', + 'legend' => $control['layoutParams']['title'] + )); + $this->_addElementTypes($fieldset); + + $defaultValues = array(); + foreach ($control['components'] as $componentName => $component) { + $defaultValues[$componentName] = $component['default']; + $this->_addFormElement($fieldset, $component, $componentName); + } + $this-> _addResetButton($fieldset, $defaultValues, $name); + + return $this; + } + + /** + * Add image size form element by component type + * + * @param Varien_Data_Form_Element_Fieldset $fieldset + * @param array $component + * @param string $componentName + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Tools_Code_ImageSizing + */ + protected function _addFormElement($fieldset, $component, $componentName) + { + switch ($component['type']) { + case 'image-type': + $this->_addImageTypeElement($fieldset, $component, $componentName); + break; + case 'image-width': + $this->_addImageWidthElement($fieldset, $component, $componentName); + break; + case 'image-ratio': + $this->_addImageRatioElement($fieldset, $component, $componentName); + break; + case 'image-height': + $this->_addImageHeightElement($fieldset, $component, $componentName); + break; + } + return $this; + } + + /** + * Add image type form element to fieldset + * + * @param Varien_Data_Form_Element_Fieldset $fieldset + * @param array $component + * @param string $componentName + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Tools_Code_ImageSizing + */ + protected function _addImageTypeElement($fieldset, $component, $componentName) + { + $fieldset->addField($componentName, 'select', array( + 'name' => $componentName, + 'values' => $this->_getSelectOptions(), + 'value' => $this->_getValue($component) + )); + return $this; + } + + /** + * Add image width form element to fieldset + * + * @param Varien_Data_Form_Element_Fieldset $fieldset + * @param array $component + * @param string $componentName + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Tools_Code_ImageSizing + */ + protected function _addImageWidthElement($fieldset, $component, $componentName) + { + $fieldset->addField($componentName, 'text', array( + 'name' => $componentName, + 'class' => 'image-width', + 'value' => $this->_getValue($component), + 'before_element_html' => 'W' + )); + return $this; + } + + /** + * Add image height form element to fieldset + * + * @param Varien_Data_Form_Element_Fieldset $fieldset + * @param array $component + * @param string $componentName + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Tools_Code_ImageSizing + */ + protected function _addImageHeightElement($fieldset, $component, $componentName) + { + $fieldset->addField($componentName, 'text', array( + 'name' => $componentName, + 'class' => 'image-height', + 'value' => $this->_getValue($component), + 'before_element_html' => 'H' + )); + return $this; + } + + /** + * Add image ratio form element to fieldset + * + * @param Varien_Data_Form_Element_Fieldset $fieldset + * @param array $component + * @param string $componentName + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Tools_Code_ImageSizing + */ + protected function _addImageRatioElement($fieldset, $component, $componentName) + { + $fieldset->addField($componentName . '-hidden', 'hidden', array( + 'name' => $componentName, + 'value' => '0' + )); + $fieldset->addField($componentName, 'checkbox', array( + 'checked'=> $this->_getValue($component) ? 'checked' : false, + 'name' => $componentName, + 'class' => 'image-ratio', + 'value' => '1', + 'after_element_html' => '' + )); + return $this; + } + + /** + * Add reset button to fieldset + * + * @param Varien_Data_Form_Element_Fieldset $fieldset + * @param array $defaultValues + * @param string $name + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Tools_Code_ImageSizing + */ + protected function _addResetButton($fieldset, $defaultValues, $name) + { + $fieldset->addField($name . '_reset', 'button_button', array( + 'name' => $name . '_reset', + 'title' => $this->__('Reset to Original'), + 'value' => $this->__('Reset to Original'), + 'class' => 'action-reset', + 'data-mage-init' => $this->helper('Mage_Backend_Helper_Data')->escapeHtml(json_encode(array( + 'button' => array( + 'event' => 'restoreDefaultData', + 'target' => 'body', + 'eventData' => $defaultValues + )))))); + return $this; + } + + /** + * Get value + * + * @param array $component + * @return array + */ + protected function _getValue($component) + { + return $component['value'] !== false ? $component['value'] : $component['default']; + } + + /** + * Return values for select element + * + * @return array + */ + protected function _getSelectOptions() + { + $options = array(); + foreach ($this->getImageTypes() as $imageType) { + $attribute = $this->_eavConfig->getAttribute('catalog_product', $imageType); + $options[] = array( + 'value' => $imageType, + 'label' => $attribute->getFrontendLabel() + ); + } + return $options; + } + + /** + * Return product image types + * + * @return array + */ + public function getImageTypes() + { + return array('image', 'small_image', 'thumbnail'); + } + + /** + * Set additional form button + * + * @return array + */ + protected function _getAdditionalElementTypes() + { + return array('button_button' => 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Button'); + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Js.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Js.php new file mode 100644 index 0000000000000..9097c35d74eff --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Js.php @@ -0,0 +1,159 @@ +_service = $service; + } + + /** + * Create a form element with necessary controls + * + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Tools_Code_Js + */ + protected function _prepareForm() + { + $form = new Varien_Data_Form(array( + 'action' => '#', + 'method' => 'post' + )); + $this->setForm($form); + $form->setUseContainer(true); + + $form->addType('js_files', 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Uploader'); + + $jsConfig = array( + 'name' => 'js_files_uploader', + 'title' => $this->__('Select JS Files to Upload'), + 'accept' => 'application/x-javascript', + 'multiple' => '', + ); + if ($this->_service->isThemeAssignedToStore($this->getTheme())) { + $confirmMessage = $this->__('You are about to upload JavaScript files. ' + . 'This will take effect immediately and might affect the design of your store if your theme ' + . 'is assigned to the store front. Are you sure you want to do this?'); + $jsConfig['onclick'] = "return confirm('{$confirmMessage}');"; + } + $form->addField('js_files_uploader', 'js_files', $jsConfig); + + parent::_prepareForm(); + return $this; + } + + /** + * Return confirmation message for delete action + * + * @return string + */ + public function getConfirmMessageDelete() + { + if ($this->_service->isThemeAssignedToStore($this->getTheme())) { + $confirmMessage = $this->__('Are you sure you want to delete the selected JavaScript file? This operation' + . ' cannot be undone. It will affect the theme and frontend design if the theme is currently assigned' + . ' to the store front'); + } else { + $confirmMessage = $this->__('Are you sure you want to delete the selected JavaScript file? This operation' + . 'cannot be undone. It will affect the theme.'); + } + return $confirmMessage; + } + + /** + * Get upload js url + * + * @return string + */ + public function getJsUploadUrl() + { + return $this->getUrl('*/system_design_editor_tools/uploadjs', array('id' => $this->getTheme()->getId())); + } + + /** + * Get reorder js url + * + * @return string + */ + public function getJsReorderUrl() + { + return $this->getUrl('*/system_design_editor_tools/reorderjs', array('id' => $this->getTheme()->getId())); + } + + /** + * Get delete js url + * + * @return string + */ + public function getJsDeleteUrl() + { + return $this->getUrl('*/system_design_editor_tools/deleteCustomFiles', array( + 'id' => $this->getTheme()->getId() + )); + } + + /** + * Get custom js files + * + * @return Mage_Core_Model_Resource_Theme_File_Collection + */ + public function getJsFiles() + { + return $this->getTheme()->getCustomizationData(Mage_Core_Model_Theme_Customization_Files_Js::TYPE); + } + + /** + * Get js tab title + * + * @return string + */ + public function getTitle() + { + return $this->__('Custom javascript files'); + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles.php new file mode 100644 index 0000000000000..32d9d26ff4cd7 --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles.php @@ -0,0 +1,98 @@ + true, + 'id' => 'vde-tab-header', + 'title' => strtoupper($this->__('Header')), + 'content_block' => 'design_editor_tools_quick-styles_header' + ), + array( + 'is_active' => false, + 'id' => 'vde-tab-bgs', + 'title' => strtoupper($this->__('Backgrounds')), + 'content_block' => 'design_editor_tools_quick-styles_backgrounds' + ), + array( + 'is_active' => false, + 'id' => 'vde-tab-buttons', + 'title' => strtoupper($this->__('Buttons & Icons')), + 'content_block' => 'design_editor_tools_quick-styles_buttons' + ), + array( + 'is_active' => false, + 'id' => 'vde-tab-tips', + 'title' => strtoupper($this->__('Tips & Messages')), + 'content_block' => 'design_editor_tools_quick-styles_tips' + ), + array( + 'is_active' => false, + 'id' => 'vde-tab-fonts', + 'title' => strtoupper($this->__('Fonts')), + 'content_block' => 'design_editor_tools_quick-styles_fonts' + ), + + ); + } + + /** + * Get the tab state + * + * Active tab is showed, while inactive tabs are hidden + * + * @return bool + * + * @SuppressWarnings(PHPMD.BooleanGetMethodName) + */ + public function getIsActive() + { + return true; + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles/AbstractTab.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles/AbstractTab.php new file mode 100644 index 0000000000000..d9c37b46d2da4 --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles/AbstractTab.php @@ -0,0 +1,100 @@ +_formBuilder = $formBuilder; + } + + /** + * Create a form element with necessary controls + * + * @return Mage_DesignEditor_Block_Adminhtml_Editor_Tools_QuickStyles_Header + * @throws Mage_Core_Exception + */ + protected function _prepareForm() + { + if (!$this->_formId || !$this->_tab) { + throw new Mage_Core_Exception( + $this->__('Invalid block of class "%s". Not all required properties are defined', get_class($this)) + ); + } + $form = $this->_formBuilder->create(array( + 'id' => $this->_formId, + 'action' => '#', + 'method' => 'post', + 'tab' => $this->_tab, + 'theme' => $this->getTheme(), + )); + $form->setUseContainer(true); + + $this->setForm($form); + + parent::_prepareForm(); + return $this; + } +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles/Backgrounds.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles/Backgrounds.php new file mode 100644 index 0000000000000..aab9bf77f774f --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles/Backgrounds.php @@ -0,0 +1,52 @@ + Backgrounds tab + * + * @method Mage_Core_Model_Theme getTheme() + * @method setTheme($theme) + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings(PHPMD.DepthOfInheritance) + */ +class Mage_DesignEditor_Block_Adminhtml_Editor_Tools_QuickStyles_Backgrounds + extends Mage_DesignEditor_Block_Adminhtml_Editor_Tools_QuickStyles_AbstractTab +{ + /** + * Tab form HTML identifier + * + * @var string + */ + protected $_formId = 'quick-styles-form-backgrounds'; + + /** + * Controls group which will be rendered on the tab form + * + * @var string + */ + protected $_tab = 'backgrounds'; +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles/Buttons.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles/Buttons.php new file mode 100644 index 0000000000000..45cd4664076f2 --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles/Buttons.php @@ -0,0 +1,53 @@ + Buttons & Icons tab + * + * @method Mage_Core_Model_Theme getTheme() + * @method setTheme($theme) + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings(PHPMD.DepthOfInheritance) + */ +class Mage_DesignEditor_Block_Adminhtml_Editor_Tools_QuickStyles_Buttons + extends Mage_DesignEditor_Block_Adminhtml_Editor_Tools_QuickStyles_AbstractTab +{ + /** + * Tab form HTML identifier + * + * @var string + */ + protected $_formId = 'quick-styles-form-buttons'; + + /** + * Controls group which will be rendered on the tab form + * + * @var string + */ + protected $_tab = 'buttons'; + +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles/Fonts.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles/Fonts.php new file mode 100644 index 0000000000000..a28451ee77c98 --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles/Fonts.php @@ -0,0 +1,52 @@ + Fonts tab + * + * @method Mage_Core_Model_Theme getTheme() + * @method setTheme($theme) + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings(PHPMD.DepthOfInheritance) + */ +class Mage_DesignEditor_Block_Adminhtml_Editor_Tools_QuickStyles_Fonts + extends Mage_DesignEditor_Block_Adminhtml_Editor_Tools_QuickStyles_AbstractTab +{ + /** + * Tab form HTML identifier + * + * @var string + */ + protected $_formId = 'quick-styles-form-fonts'; + + /** + * Controls group which will be rendered on the tab form + * + * @var string + */ + protected $_tab = 'fonts'; +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles/Header.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles/Header.php new file mode 100644 index 0000000000000..fa93cfd48ae87 --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles/Header.php @@ -0,0 +1,52 @@ +_htmlId; + } + + /** + * Get translated title + * + * @return string + */ + public function getTitle() + { + return $this->__($this->_title); + } + + /** + * Get tabs html + * + * @return array + */ + public function getTabContents() + { + $contents = array(); + /** @var $tabBodyBlock Mage_DesignEditor_Block_Adminhtml_Editor_Tools_Tabs_Body */ + $tabBodyBlock = $this->getChildBlock(self::TAB_BODY_BLOCK_ALIAS); + foreach ($this->getTabs() as $tab) { + $contents[] = $tabBodyBlock->setContentBlock($tab['content_block']) + ->setIsActive($tab['is_active']) + ->setTabId($tab['id']) + ->toHtml(); + } + return $contents; + } + + /** + * Get tabs handles + * + * @return array + */ + public function getTabHandles() + { + /** @var $tabHandleBlock Mage_Backend_Block_Template */ + $tabHandleBlock = $this->getChildBlock(self::TAB_HANDLE_BLOCK_ALIAS); + $handles = array(); + foreach ($this->getTabs() as $tab) { + $href = '#' . $tab['id']; + $handles[] = $tabHandleBlock->setIsActive($tab['is_active']) + ->setHref($href) + ->setTitle($tab['title']) + ->toHtml(); + } + + return $handles; + } + + /** + * Get tabs data + * + * @return array + */ + abstract public function getTabs(); +} diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Tabs/Body.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Tabs/Body.php new file mode 100644 index 0000000000000..376a183fb7767 --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Tabs/Body.php @@ -0,0 +1,54 @@ +getContentBlock(); + if ($alias) { + $content = $this->getParentBlock()->getChildHtml($alias); + } + + return $content; + } +} diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Theme.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Theme.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Block/Adminhtml/Theme.php rename to app/code/Mage/DesignEditor/Block/Adminhtml/Theme.php diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/List/Abstract.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/List/Abstract.php new file mode 100644 index 0000000000000..a77b97465a9cb --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/List/Abstract.php @@ -0,0 +1,224 @@ +_app = $app; + parent::__construct($context, $data); + } + + /** + * Get tab title + * + * @return string + */ + abstract public function getTabTitle(); + + /** + * Add theme buttons + * + * @param Mage_DesignEditor_Block_Adminhtml_Theme $themeBlock + * @return Mage_DesignEditor_Block_Adminhtml_Theme_Selector_List_Abstract + */ + protected function _addThemeButtons($themeBlock) + { + $themeBlock->clearButtons(); + return $this; + } + + /** + * Get list items of themes + * + * @return array + */ + public function getListItems() + { + /** @var $itemBlock Mage_DesignEditor_Block_Adminhtml_Theme */ + $itemBlock = $this->getChildBlock('theme'); + + $themeCollection = $this->getCollection(); + + $items = array(); + /** @var $theme Mage_Core_Model_Theme */ + foreach ($themeCollection as $theme) { + $itemBlock->setTheme($theme); + $this->_addThemeButtons($itemBlock); + $items[] = $this->getChildHtml('theme', false); + } + + return $items; + } + + /** + * Get assign to storeview button + * + * @param Mage_DesignEditor_Block_Adminhtml_Theme $themeBlock + * @return Mage_DesignEditor_Block_Adminhtml_Theme_Selector_List_Abstract + */ + protected function _addAssignButtonHtml($themeBlock) + { + $themeId = $themeBlock->getTheme()->getId(); + $message = $this->__('You are about to apply this theme for your live store, are you really want to do this?'); + + /** @var $assignButton Mage_Backend_Block_Widget_Button */ + $assignButton = $this->getLayout()->createBlock('Mage_Backend_Block_Widget_Button'); + $assignButton->setData(array( + 'label' => $this->__('Assign to a Storeview'), + 'data_attribute' => array( + 'mage-init' => array( + 'button' => array( + 'event' => 'assign', + 'target' => 'body', + 'eventData' => array( + 'theme_id' => $themeId, + 'confirm_message' => $message + ) + ), + ), + ), + 'class' => 'save action-theme-assign primary', + 'target' => '_blank' + )); + + $themeBlock->addButton($assignButton); + return $this; + } + + /** + * Get preview button + * + * @param Mage_DesignEditor_Block_Adminhtml_Theme $themeBlock + * @return Mage_DesignEditor_Block_Adminhtml_Theme_Selector_List_Abstract + */ + protected function _addPreviewButtonHtml($themeBlock) + { + /** @var $previewButton Mage_Backend_Block_Widget_Button */ + $previewButton = $this->getLayout()->createBlock('Mage_Backend_Block_Widget_Button'); + $previewButton->setData(array( + 'id' => 'theme-preview-' . $themeBlock->getTheme()->getId(), + 'label' => $this->__('Preview Theme'), + 'class' => 'action-theme-preview', + 'data_attribute' => array( + 'mage-init' => array( + 'button' => array( + 'event' => 'preview', + 'target' => 'body', + 'eventData' => array( + 'preview_url' => $this->_getPreviewUrl($themeBlock->getTheme()->getId()) + ) + ), + ), + ) + )); + + $themeBlock->addButton($previewButton); + return $this; + } + + /** + * Get edit button + * + * @param Mage_DesignEditor_Block_Adminhtml_Theme $themeBlock + * @return Mage_DesignEditor_Block_Adminhtml_Theme_Selector_List_Abstract + */ + protected function _addEditButtonHtml($themeBlock) + { + /** @var $editButton Mage_Backend_Block_Widget_Button */ + $editButton = $this->getLayout()->createBlock('Mage_Backend_Block_Widget_Button'); + $editButton->setData(array( + 'label' => $this->__('Edit'), + 'class' => 'add action-edit', + 'data_attribute' => array( + 'mage-init' => array( + 'button' => array( + 'event' => 'preview', + 'target' => 'body', + 'eventData' => array( + 'preview_url' => $this->_getEditUrl($themeBlock->getTheme()->getId()) + ) + ), + ), + ) + )); + + $themeBlock->addButton($editButton); + return $this; + } + + /** + * Get preview url for selected theme + * + * @param int $themeId + * @return string + */ + protected function _getPreviewUrl($themeId) + { + return $this->getUrl('*/*/launch', array( + 'theme_id' => $themeId, + 'mode' => Mage_DesignEditor_Model_State::MODE_NAVIGATION + )); + } + + /** + * Get edit theme url for selected theme + * + * @param int $themeId + * @return string + */ + protected function _getEditUrl($themeId) + { + return $this->getUrl('*/*/launch', array( + 'theme_id' => $themeId, + 'mode' => Mage_DesignEditor_Model_State::MODE_DESIGN + )); + } +} diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/List/Assigned.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/List/Assigned.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/List/Assigned.php rename to app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/List/Assigned.php diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/List/Available.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/List/Available.php new file mode 100644 index 0000000000000..29d18050ee01d --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/List/Available.php @@ -0,0 +1,141 @@ +_serviceModel = $serviceModel; + + parent::__construct($context, $app, $data + ); + } + + /** + * Get service model + * + * @return Mage_Core_Model_Theme_Service + */ + protected function _getServiceModel() + { + return $this->_serviceModel; + } + + /** + * Get tab title + * + * @return string + */ + public function getTabTitle() + { + return $this->__('Available theme list'); + } + + /** + * Get next page url + * + * @return string + */ + public function getNextPageUrl() + { + return $this->getNextPage() <= $this->getCollection()->getLastPageNumber() + ? $this->getUrl('*/*/*', array('page' => $this->getNextPage())) + : ''; + } + + /** + * Get demo button + * + * @param Mage_DesignEditor_Block_Adminhtml_Theme $themeBlock + * @return Mage_DesignEditor_Block_Adminhtml_Theme_Selector_List_Available + */ + protected function _addDemoButtonHtml($themeBlock) + { + /** @var $demoButton Mage_Backend_Block_Widget_Button */ + $demoButton = $this->getLayout()->createBlock('Mage_Backend_Block_Widget_Button'); + $demoButton->setData(array( + 'label' => $this->__('Theme Demo'), + 'class' => 'action-theme-preview', + 'data_attribute' => array( + 'mage-init' => array( + 'button' => array( + 'event' => 'preview', + 'target' => 'body', + 'eventData' => array( + 'preview_url' => $this->_getPreviewUrl($themeBlock->getTheme()->getId()) + ) + ), + ), + ) + )); + + $themeBlock->addButton($demoButton); + return $this; + } + + /** + * Add theme buttons + * + * @param Mage_DesignEditor_Block_Adminhtml_Theme $themeBlock + * @return Mage_DesignEditor_Block_Adminhtml_Theme_Selector_List_Abstract + */ + protected function _addThemeButtons($themeBlock) + { + parent::_addThemeButtons($themeBlock); + + $this->_addDemoButtonHtml($themeBlock)->_addAssignButtonHtml($themeBlock); + + if ($this->_getServiceModel()->isCustomizationsExist()) { + $this->_addEditButtonHtml($themeBlock); + } + + return $this; + } +} diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/List/Unassigned.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/List/Unassigned.php similarity index 97% rename from app/code/core/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/List/Unassigned.php rename to app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/List/Unassigned.php index 72043fbe5f486..450b497da9143 100644 --- a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/List/Unassigned.php +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/List/Unassigned.php @@ -37,7 +37,7 @@ class Mage_DesignEditor_Block_Adminhtml_Theme_Selector_List_Unassigned */ public function getTabTitle() { - return $this->__('Unassigned Themes'); + return $this->__('Customized themes not assigned to a storeview'); } /** diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/StoreView.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/StoreView.php similarity index 75% rename from app/code/core/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/StoreView.php rename to app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/StoreView.php index 9412bfe74bdb0..acd95f24cab62 100644 --- a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/StoreView.php +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/StoreView.php @@ -27,6 +27,8 @@ /** * Theme selectors tabs container * + * @method int getThemeId() + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Mage_DesignEditor_Block_Adminhtml_Theme_Selector_StoreView extends Mage_Backend_Block_Template @@ -44,41 +46,13 @@ class Mage_DesignEditor_Block_Adminhtml_Theme_Selector_StoreView extends Mage_Ba protected $_serviceModel; /** - * @param Mage_Core_Controller_Request_Http $request - * @param Mage_Core_Model_Layout $layout - * @param Mage_Core_Model_Event_Manager $eventManager - * @param Mage_Backend_Model_Url $urlBuilder - * @param Mage_Core_Model_Translate $translator - * @param Mage_Core_Model_Cache $cache - * @param Mage_Core_Model_Design_Package $designPackage - * @param Mage_Core_Model_Session $session - * @param Mage_Core_Model_Store_Config $storeConfig - * @param Mage_Core_Controller_Varien_Front $frontController - * @param Mage_Core_Model_Factory_Helper $helperFactory - * @param Mage_Core_Model_Dir $dirs - * @param Mage_Core_Model_Logger $logger - * @param Magento_Filesystem $filesystem + * @param Mage_Core_Block_Template_Context $context * @param Mage_Core_Model_Resource_Website_Collection $websiteCollection * @param Mage_Core_Model_Theme_Service $serviceModel * @param array $data - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - Mage_Core_Controller_Request_Http $request, - Mage_Core_Model_Layout $layout, - Mage_Core_Model_Event_Manager $eventManager, - Mage_Backend_Model_Url $urlBuilder, - Mage_Core_Model_Translate $translator, - Mage_Core_Model_Cache $cache, - Mage_Core_Model_Design_Package $designPackage, - Mage_Core_Model_Session $session, - Mage_Core_Model_Store_Config $storeConfig, - Mage_Core_Controller_Varien_Front $frontController, - Mage_Core_Model_Factory_Helper $helperFactory, - Mage_Core_Model_Dir $dirs, - Mage_Core_Model_Logger $logger, - Magento_Filesystem $filesystem, + Mage_Core_Block_Template_Context $context, Mage_Core_Model_Resource_Website_Collection $websiteCollection, Mage_Core_Model_Theme_Service $serviceModel, array $data = array() @@ -86,9 +60,7 @@ public function __construct( $this->_websiteCollection = $websiteCollection; $this->_serviceModel = $serviceModel; - parent::__construct($request, $layout, $eventManager, $urlBuilder, $translator, $cache, $designPackage, - $session, $storeConfig, $frontController, $helperFactory, $dirs, $logger, $filesystem, $data - ); + parent::__construct($context, $data); } /** @@ -134,7 +106,7 @@ public function getWebsiteStructure() * * @return string */ - public function getAssignSaveButtonHtml() + public function getAssignNextButtonHtml() { /** @var $assignSaveButton Mage_Backend_Block_Widget_Button */ $assignSaveButton = $this->getLayout()->createBlock('Mage_Backend_Block_Widget_Button'); @@ -144,7 +116,7 @@ public function getAssignSaveButtonHtml() 'data_attribute' => array( 'mage-init' => array( 'button' => array( - 'event' => 'assign-save', + 'event' => 'assign-next', 'target' => 'body', 'eventData' => array() ), @@ -220,17 +192,23 @@ protected function _isMultipleStoreViewMode() } /** - * Get options for JS widget vde.themeSelector + * Get options for JS widget vde.storeSelector * * @return string */ public function getOptionsJson() { $options = array(); - $options['storesByThemes'] = $this->_getStoresByThemes(); - $options['assignSaveUrl'] = $this->getUrl('*/*/assignThemeToStore'); - $options['afterAssignSaveUrl'] = $this->getUrl('*/*/launch'); + $options['storesByThemes'] = $this->_getStoresByThemes(); + $options['assignUrl'] = $this->getUrl('*/*/assignThemeToStore', array( + 'theme_id' => $this->getThemeId() + )); + $options['afterAssignUrl'] = $this->getUrl('*/*/launch'); $options['isMultipleStoreViewMode'] = $this->_isMultipleStoreViewMode(); + $options['redirectOnAssign'] = $this->getData('redirectOnAssign'); + if ($this->hasData('openNewOnAssign')) { + $options['openNewOnAssign'] = $this->getData('openNewOnAssign'); + } /** @var $helper Mage_Core_Helper_Data */ $helper = $this->helper('Mage_Core_Helper_Data'); diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/Tab/Available.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/Tab/Available.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/Tab/Available.php rename to app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/Tab/Available.php diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/Tab/Customizations.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/Tab/Customizations.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/Tab/Customizations.php rename to app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/Tab/Customizations.php diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/Tab/TabAbstract.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/Tab/TabAbstract.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/Tab/TabAbstract.php rename to app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/Tab/TabAbstract.php diff --git a/app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/Tabs.php b/app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/Tabs.php new file mode 100644 index 0000000000000..5c016780a802a --- /dev/null +++ b/app/code/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/Tabs.php @@ -0,0 +1,69 @@ +setId('theme_selector_tabs'); + $this->setDestElementId('theme_selector'); + $this->setIsHoriz(true); + } + + /** + * Add content container to template + * + * @return string + */ + protected function _toHtml() + { + return parent::_toHtml() . '
    ' . + $this->_getScript(); + } + + /** + * Get additional script for tabs block + * + * @return string + */ + protected function _getScript() + { + $script = sprintf(" + (function ($) { + $('.themes-customizations .theme').themeControl({url: '%s'}); + })(jQuery);", + $this->getUrl('*/*/quickEdit') + ); + return sprintf('', $script); + } +} diff --git a/app/code/core/Mage/DesignEditor/Block/Container.php b/app/code/Mage/DesignEditor/Block/Container.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Block/Container.php rename to app/code/Mage/DesignEditor/Block/Container.php diff --git a/app/code/core/Mage/DesignEditor/Block/Template.php b/app/code/Mage/DesignEditor/Block/Template.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Block/Template.php rename to app/code/Mage/DesignEditor/Block/Template.php diff --git a/app/code/core/Mage/DesignEditor/Block/Toolbar/History.php b/app/code/Mage/DesignEditor/Block/Toolbar/History.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Block/Toolbar/History.php rename to app/code/Mage/DesignEditor/Block/Toolbar/History.php diff --git a/app/code/core/Mage/DesignEditor/Block/Wrapper/Remove.php b/app/code/Mage/DesignEditor/Block/Wrapper/Remove.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Block/Wrapper/Remove.php rename to app/code/Mage/DesignEditor/Block/Wrapper/Remove.php diff --git a/app/code/core/Mage/DesignEditor/Controller/Varien/Router/Standard.php b/app/code/Mage/DesignEditor/Controller/Varien/Router/Standard.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Controller/Varien/Router/Standard.php rename to app/code/Mage/DesignEditor/Controller/Varien/Router/Standard.php diff --git a/app/code/Mage/DesignEditor/Helper/Data.php b/app/code/Mage/DesignEditor/Helper/Data.php new file mode 100644 index 0000000000000..50dfa0a1406a1 --- /dev/null +++ b/app/code/Mage/DesignEditor/Helper/Data.php @@ -0,0 +1,178 @@ +_configuration = $configuration; + $this->_backendSession = $backendSession; + } + + /** + * Get VDE front name prefix + * + * @return string + */ + public function getFrontName() + { + return (string)$this->_configuration->getNode(self::XML_PATH_FRONT_NAME); + } + + /** + * Get VDE default handle name + * + * @return string + */ + public function getDefaultHandle() + { + return (string)$this->_configuration->getNode(self::XML_PATH_DEFAULT_HANDLE); + } + + /** + * Get disabled cache types in VDE mode + * + * @return array + */ + public function getDisabledCacheTypes() + { + $cacheTypes = $this->_configuration->getNode(self::XML_PATH_DISABLED_CACHE_TYPES)->asArray(); + return array_keys($cacheTypes); + } + + /** + * Get list of configuration element values + * + * @param string $xmlPath + * @return array + */ + protected function _getElementsList($xmlPath) + { + $elements = array(); + $node = $this->_configuration->getNode($xmlPath); + if ($node) { + $data = $node->asArray(); + if (is_array($data)) { + $elements = array_values($data); + } + } + return $elements; + } + + /** + * Get list of allowed blocks + * + * @return array + */ + public function getBlockWhiteList() + { + return $this->_getElementsList(self::XML_PATH_BLOCK_WHITE_LIST); + } + + /** + * Get list of not allowed blocks + * + * @return array + */ + public function getBlockBlackList() + { + return $this->_getElementsList(self::XML_PATH_BLOCK_BLACK_LIST); + } + + /** + * Get list of allowed blocks + * + * @return array + */ + public function getContainerWhiteList() + { + return $this->_getElementsList(self::XML_PATH_CONTAINER_WHITE_LIST); + } + + /** + * Get expiration days count + * + * @return string + */ + public function getDaysToExpire() + { + return (int)$this->_configuration->getNode(self::XML_PATH_DAYS_TO_EXPIRE); + } + + /** + * Get staging theme id which was launched in editor + * + * @return int|null + */ + public function getEditableThemeId() + { + return $this->_backendSession->getData(Mage_DesignEditor_Model_State::CURRENT_THEME_SESSION_KEY); + } + + /** + * Get theme id which was launched in editor + * + * @return int|null + */ + public function getVirtualThemeId() + { + return $this->_backendSession->getData(Mage_DesignEditor_Model_State::VIRTUAL_THEME_SESSION_KEY); + } +} diff --git a/app/code/core/Mage/DesignEditor/Model/Area.php b/app/code/Mage/DesignEditor/Model/Area.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Model/Area.php rename to app/code/Mage/DesignEditor/Model/Area.php diff --git a/app/code/core/Mage/DesignEditor/Model/Change/Collection.php b/app/code/Mage/DesignEditor/Model/Change/Collection.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Model/Change/Collection.php rename to app/code/Mage/DesignEditor/Model/Change/Collection.php diff --git a/app/code/core/Mage/DesignEditor/Model/Change/Factory.php b/app/code/Mage/DesignEditor/Model/Change/Factory.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Model/Change/Factory.php rename to app/code/Mage/DesignEditor/Model/Change/Factory.php diff --git a/app/code/core/Mage/DesignEditor/Model/Change/Layout/Move.php b/app/code/Mage/DesignEditor/Model/Change/Layout/Move.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Model/Change/Layout/Move.php rename to app/code/Mage/DesignEditor/Model/Change/Layout/Move.php diff --git a/app/code/core/Mage/DesignEditor/Model/Change/Layout/Remove.php b/app/code/Mage/DesignEditor/Model/Change/Layout/Remove.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Model/Change/Layout/Remove.php rename to app/code/Mage/DesignEditor/Model/Change/Layout/Remove.php diff --git a/app/code/core/Mage/DesignEditor/Model/Change/LayoutAbstract.php b/app/code/Mage/DesignEditor/Model/Change/LayoutAbstract.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Model/Change/LayoutAbstract.php rename to app/code/Mage/DesignEditor/Model/Change/LayoutAbstract.php diff --git a/app/code/core/Mage/DesignEditor/Model/ChangeAbstract.php b/app/code/Mage/DesignEditor/Model/ChangeAbstract.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Model/ChangeAbstract.php rename to app/code/Mage/DesignEditor/Model/ChangeAbstract.php diff --git a/app/code/Mage/DesignEditor/Model/Config/Backend/File/RequestData.php b/app/code/Mage/DesignEditor/Model/Config/Backend/File/RequestData.php new file mode 100644 index 0000000000000..b4c300d12b20b --- /dev/null +++ b/app/code/Mage/DesignEditor/Model/Config/Backend/File/RequestData.php @@ -0,0 +1,69 @@ +_getParam('tmp_name', $path); + } + + /** + * Retrieve uploaded file name by path + * + * @param string $path + * @return string + */ + public function getName($path) + { + return $this->_getParam('name', $path); + } + + /** + * Get $_FILES superglobal value by path + * + * @param string $paramName + * @return string + */ + protected function _getParam($paramName) + { + $logoImage = reset($_FILES); + if (empty($logoImage)) { + return null; + } + return $logoImage[$paramName]; + } +} diff --git a/app/code/Mage/DesignEditor/Model/Config/Control/Abstract.php b/app/code/Mage/DesignEditor/Model/Config/Control/Abstract.php new file mode 100644 index 0000000000000..21b051b63baab --- /dev/null +++ b/app/code/Mage/DesignEditor/Model/Config/Control/Abstract.php @@ -0,0 +1,169 @@ +_extractControls($dom->childNodes->item(0)->childNodes); + } + + /** + * Extract all controls + * + * @param DOMNodeList $controls + * @return array + */ + protected function _extractControls(DOMNodeList $controls) + { + $result = array(); + /** @var $control DOMElement */ + foreach ($controls as $control) { + if (!$control instanceof DOMElement) { + continue; + } + $controlName = $control->getAttribute('name'); + $result[$controlName]['type'] = $control->getElementsByTagName('type')->item(0)->nodeValue; + /** @var $components DOMElement */ + $components = $control->getElementsByTagName('components')->item(0); + if ($components && $components->childNodes->length) { + $result[$controlName]['components'] = $this->_extractControls($components->childNodes); + } else { + $result[$controlName] = $this->_extractParams($control); + } + $controlLayoutParams = $this->_extractLayoutParams($control); + if (!empty($controlLayoutParams)) { + $result[$controlName]['layoutParams'] = $controlLayoutParams; + } + } + return $result; + } + + /** + * Extract layout parameters which declare position of controls in layout + * + * @param DOMElement $control + * @return array + */ + protected function _extractLayoutParams(DOMElement $control) + { + $layoutParams = array(); + foreach ($this->_controlAttributes as $attributeName) { + $controlTitle = $control->getAttribute($attributeName); + if (!empty($controlTitle)) { + $layoutParams[$attributeName] = $controlTitle; + } + } + return $layoutParams; + } + + /** + * Extract params data + * + * @param DOMElement $control + * @param bool $useKeyIdentifier + * @return array + */ + protected function _extractParams(DOMElement $control, $useKeyIdentifier = true) + { + $result = array(); + /** @var $paramNode DOMElement */ + foreach ($control->childNodes as $paramNode) { + if (!$paramNode instanceof DOMElement) { + continue; + } + $param = $paramNode->childNodes->length > 1 ? $this->_extractParams($paramNode, false) + : trim($paramNode->nodeValue); + if ($useKeyIdentifier) { + $result[$paramNode->nodeName] = $param; + } else { + $result[] = $param; + } + } + return $result; + } + + /** + * Return control data + * + * @param string $controlName + * @return array + * @throws Magento_Exception + */ + public function getControlData($controlName) + { + if (!isset($this->_data[$controlName])) { + throw new Magento_Exception("Unknown control: \"{$controlName}\""); + } + return $this->_data[$controlName]; + } + + /** + * Return all controls data + * + * @return array + */ + public function getAllControlsData() + { + return $this->_data; + } + + /** + * Getter for initial view.xml contents + * + * @return string + */ + protected function _getInitialXml() + { + return ''; + } + + /** + * Variables are identified by module and name + * + * @return array + */ + protected function _getIdAttributes() + { + return array('/controls/control' => 'name', '/controls/control/components/control' => 'name'); + } +} diff --git a/app/code/Mage/DesignEditor/Model/Config/Control/ImageSizing.php b/app/code/Mage/DesignEditor/Model/Config/Control/ImageSizing.php new file mode 100644 index 0000000000000..f50af66186492 --- /dev/null +++ b/app/code/Mage/DesignEditor/Model/Config/Control/ImageSizing.php @@ -0,0 +1,64 @@ +_moduleReader = $moduleReader; + parent::__construct($configFiles); + } + + /** + * Path to quick_styles.xsd + * + * @return string + */ + public function getSchemaFile() + { + return $this->_moduleReader->getModuleDir('etc', 'Mage_DesignEditor') . DIRECTORY_SEPARATOR + . 'image_sizing.xsd'; + } +} diff --git a/app/code/Mage/DesignEditor/Model/Config/Control/QuickStyles.php b/app/code/Mage/DesignEditor/Model/Config/Control/QuickStyles.php new file mode 100644 index 0000000000000..76295b848af86 --- /dev/null +++ b/app/code/Mage/DesignEditor/Model/Config/Control/QuickStyles.php @@ -0,0 +1,64 @@ +_moduleReader = $moduleReader; + parent::__construct($configFiles); + } + + /** + * Path to quick_styles.xsd + * + * @return string + */ + public function getSchemaFile() + { + return $this->_moduleReader->getModuleDir('etc', 'Mage_DesignEditor') . Magento_Filesystem::DIRECTORY_SEPARATOR + . 'quick_styles.xsd'; + } +} diff --git a/app/code/Mage/DesignEditor/Model/Editor/Tools/Controls/Configuration.php b/app/code/Mage/DesignEditor/Model/Editor/Tools/Controls/Configuration.php new file mode 100644 index 0000000000000..9b51ee4d3978f --- /dev/null +++ b/app/code/Mage/DesignEditor/Model/Editor/Tools/Controls/Configuration.php @@ -0,0 +1,300 @@ +_configuration = $configuration; + $this->_theme = $theme; + $this->_design = $design; + $this->_filesystem = $filesystem; + $this->_eventDispatcher = $eventDispatcher; + $this->_initViewConfigs()->_loadControlsData(); + } + + /** + * Initialize view configurations + * + * @return Mage_DesignEditor_Model_Editor_Tools_Controls_Configuration + */ + protected function _initViewConfigs() + { + $this->_viewConfig = $this->_design->getViewConfig(array( + 'area' => Mage_Core_Model_Design_Package::DEFAULT_AREA, + 'themeModel' => $this->_theme + )); + $this->_viewConfigParent = $this->_design->getViewConfig(array( + 'area' => Mage_Core_Model_Design_Package::DEFAULT_AREA, + 'themeModel' => $this->_theme->getParentTheme() + )); + return $this; + } + + /** + * Load all control values + * + * @return Mage_DesignEditor_Model_Editor_Tools_Controls_Configuration + */ + protected function _loadControlsData() + { + $this->_data = $this->_configuration->getAllControlsData(); + $this->_prepareControlList($this->_data); + foreach ($this->_controlList as &$control) { + $this->_loadControlData($control, 'value', $this->_viewConfig); + $this->_loadControlData($control, 'default', $this->_viewConfigParent); + } + return $this; + } + + /** + * Prepare list of control links + * + * @param array $controls + * @return Mage_DesignEditor_Model_Editor_Tools_Controls_Configuration + */ + protected function _prepareControlList(array &$controls) + { + foreach ($controls as $controlName => &$control) { + if (!empty($control['components'])) { + $this->_prepareControlList($control['components']); + } + $this->_controlList[$controlName] = &$control; + } + return $this; + } + + /** + * Load data item values and default values from the view configuration + * + * @param array $control + * @param string $paramName + * @param Magento_Config_View $viewConfiguration + * @return Mage_DesignEditor_Model_Editor_Tools_Controls_Configuration + */ + protected function _loadControlData(array &$control, $paramName, Magento_Config_View $viewConfiguration) + { + if (!empty($control['var'])) { + list($module, $varKey) = $this->_extractModuleKey($control['var']); + $control[$paramName] = $viewConfiguration->getVarValue($module, $varKey); + } + return $this; + } + + /** + * Load control data + * + * @return array + */ + public function getAllControlsData() + { + return $this->_data; + } + + /** + * Get control data + * + * @param string $controlName + * @return array + * @throws Mage_Core_Exception + */ + public function getControlData($controlName) + { + if (!isset($this->_controlList[$controlName])) { + throw new Mage_Core_Exception("Unknown control: \"{$controlName}\""); + } + return $this->_controlList[$controlName]; + } + + /** + * Extract module and key name + * + * @param string $value + * @return array + */ + protected function _extractModuleKey($value) + { + return explode(self::SEPARATOR_MODULE, $value); + } + + /** + * Extract var data keys for current controls configuration + * array(module => array(varKey => array(controlName, controlValue))) + * + * @param array $controlsData + * @param array $controls + * @return array + */ + protected function _prepareVarData(array $controlsData, array $controls) + { + $result = array(); + foreach ($controlsData as $controlName => $controlValue) { + if (isset($controls[$controlName])) { + list($module, $varKey) = $this->_extractModuleKey($controls[$controlName]['var']); + $result[$module][$varKey] = array($controlName, $controlValue); + } + } + return $result; + } + + /** + * Save control values data + * + * @param array $controlsData + * @return Mage_DesignEditor_Model_Editor_Tools_Controls_Configuration + */ + public function saveData(array $controlsData) + { + $configDom = $this->_viewConfig->getDomConfigCopy()->getDom(); + $varData = $this->_prepareVarData($controlsData, $this->_controlList); + + /** @var $varsNode DOMElement */ + foreach ($configDom->childNodes->item(0)->childNodes as $varsNode) { + $moduleName = $varsNode->getAttribute('module'); + if (!isset($varData[$moduleName])) { + continue; + } + /** @var $varNode DOMElement */ + foreach ($varsNode->getElementsByTagName('var') as $varNode) { + $varName = $varNode->getAttribute('name'); + if (isset($varData[$moduleName][$varName])) { + list($controlName, $controlValue) = $varData[$moduleName][$varName]; + $varNode->nodeValue = $controlValue; + $this->_controlList[$controlName]['value'] = $controlValue; + } + } + } + $this->_saveViewConfiguration($configDom); + $this->_eventDispatcher->dispatch('save_xml_configuration', array('configuration' => $this)); + return $this; + } + + /** + * Get control configuration + * + * @return Mage_DesignEditor_Model_Config_Control_Abstract + */ + public function getControlConfig() + { + return $this->_configuration; + } + + /** + * Get theme + * + * @return Mage_Core_Model_Theme + */ + public function getTheme() + { + return $this->_theme; + } + + /** + * Save customized DOM of view configuration + * + * @param DOMDocument $config + * @return Mage_DesignEditor_Model_Editor_Tools_Controls_Configuration + */ + protected function _saveViewConfiguration(DOMDocument $config) + { + $targetPath = $this->_theme->getCustomViewConfigPath(); + $this->_filesystem->setIsAllowCreateDirectories(true)->write($targetPath, $config->saveXML()); + return $this; + } +} diff --git a/app/code/Mage/DesignEditor/Model/Editor/Tools/Controls/Factory.php b/app/code/Mage/DesignEditor/Model/Editor/Tools/Controls/Factory.php new file mode 100644 index 0000000000000..0136e19e0eb7e --- /dev/null +++ b/app/code/Mage/DesignEditor/Model/Editor/Tools/Controls/Factory.php @@ -0,0 +1,120 @@ + 'Mage_DesignEditor::controls/quick_styles.xml', + self::TYPE_IMAGE_SIZING => 'Mage_DesignEditor::controls/image_sizing.xml' + ); + + /** + * @var Magento_ObjectManager + */ + protected $_objectManager; + + /** + * @var Mage_Core_Model_Design_Package + */ + protected $_design; + + /* + * Initialize dependencies + */ + public function __construct( + Magento_ObjectManager $objectManager, + Mage_Core_Model_Design_Package $package + ) { + $this->_objectManager = $objectManager; + $this->_design = $package; + } + + /** + * Get file path by type + * + * @param string $type + * @param Mage_Core_Model_Theme $theme + * @return string + * @throws Magento_Exception + */ + protected function _getFilePathByType($type, $theme) + { + if (!isset($this->_fileNames[$type])) { + throw new Magento_Exception("Unknown control configuration type: \"{$type}\""); + } + return $this->_design->getFilename($this->_fileNames[$type], array( + 'area' => Mage_Core_Model_Design_Package::DEFAULT_AREA, + 'themeModel' => $theme + )); + } + + /** + * Create new instance + * + * @param string $type + * @param Mage_Core_Model_Theme $theme + * @param array $files + * @return Mage_DesignEditor_Model_Editor_Tools_Controls_Configuration + * @throws Magento_Exception + */ + public function create($type, Mage_Core_Model_Theme $theme = null, array $files = array()) + { + $files[] = $this->_getFilePathByType($type, $theme); + switch ($type) { + case self::TYPE_QUICK_STYLES: + $class = 'Mage_DesignEditor_Model_Config_Control_QuickStyles'; + break; + case self::TYPE_IMAGE_SIZING: + $class = 'Mage_DesignEditor_Model_Config_Control_ImageSizing'; + break; + default: + throw new Magento_Exception("Unknown control configuration type: \"{$type}\""); + break; + } + /** @var $config Mage_DesignEditor_Model_Config_Control_Abstract */ + $config = $this->_objectManager->create($class, array('configFiles' => $files)); + return Mage::getObjectManager()->create( + 'Mage_DesignEditor_Model_Editor_Tools_Controls_Configuration', array( + 'configuration' => $config, + 'theme' => $theme + )); + } +} diff --git a/app/code/Mage/DesignEditor/Model/Editor/Tools/ImageSizing/Validator.php b/app/code/Mage/DesignEditor/Model/Editor/Tools/ImageSizing/Validator.php new file mode 100644 index 0000000000000..09a4855542d6b --- /dev/null +++ b/app/code/Mage/DesignEditor/Model/Editor/Tools/ImageSizing/Validator.php @@ -0,0 +1,219 @@ +_initFieldByTypes($controls); + + $this->_cleanData = array(); + foreach ($this->_allowedTypes as $type) { + if (isset($this->_fields[$type])) { + $validators = $this->_getValidators($type); + $this->_validate($validators, $this->_fields[$type], $data); + } + } + return $this->_cleanData; + } + + /** + * Initialize list of controls for validation + * + * @param array $controls + * @return Mage_DesignEditor_Model_Editor_Tools_ImageSizing_Validator + */ + protected function _initFieldByTypes(array $controls) + { + $this->_fields = array(); + foreach ($controls as $control) { + foreach ($control['components'] as $name => $component) { + if (in_array($component['type'], $this->_allowedTypes)) { + $this->_fields[$component['type']][] = $name; + } + } + } + return $this; + } + + /** + * Validate fields + * + * @param array $validators + * @param array $fields + * @param array $data + * @return Mage_DesignEditor_Model_Editor_Tools_ImageSizing_Validator + */ + protected function _validate(array $validators, array $fields, array $data) + { + foreach ($fields as $field) { + if (isset($data[$field]) && $this->_validateField($validators, $data[$field])) { + $this->_cleanData[$field] = $data[$field]; + } + } + return $this; + } + + /** + * Validate field value + * + * @param array $validators + * @param string $filedData + * @return bool + */ + protected function _validateField(array $validators, $filedData) + { + /** @var $validator Zend_Validate_Abstract */ + foreach ($validators as $validator) { + if (!$validator->isValid($filedData)) { + return false; + } + } + return true; + } + + /** + * Get validators by type + * + * @param string $type + * @return array + */ + protected function _getValidators($type) + { + $validators = array(); + switch ($type) { + case self::FIELD_WHITE_BORDER: + $validators = array( + array('class' => 'Zend_Validate_Int', 'options' => array()), + array('class' => 'Zend_Validate_Between', 'options' => array( + 'min' => 0, 'max' => 1, 'inclusive' => true + ))); + break; + case self::FIELD_IMAGE_WIDTH: + case self::FIELD_IMAGE_HEIGHT: + $validators = array( + array('class' => 'Zend_Validate_Regex', 'options' => array('pattern' => '/[0-9]*/')), + array('class' => 'Zend_Validate_Between', 'options' => array( + 'min' => 0, 'max' => self::MAX_SIZE_VALUE, 'inclusive' => true + ))); + break; + case self::FIELD_IMAGE_RATIO: + $validators = array( + array('class' => 'Zend_Validate_InArray', 'options' => array('haystack' => array('0', '1')))); + break; + case self::FIELD_IMAGE_TYPE: + $validators = array( + array('class' => 'Zend_Validate_InArray', 'options' => array('haystack' => array( + 'image', 'small_image', 'thumbnail' + )))); + break; + } + $this->_instantiateValidators($validators); + return $validators; + } + + /** + * Instantiate class validator + * + * @param array $validators + * @return Mage_DesignEditor_Model_Editor_Tools_ImageSizing_Validator + */ + protected function _instantiateValidators(array &$validators) + { + foreach ($validators as &$validator) { + $validator = new $validator['class']($validator['options']); + $validator->setDisableTranslator(true); + } + return $this; + } +} diff --git a/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Builder.php b/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Builder.php new file mode 100644 index 0000000000000..d3c26bf62931f --- /dev/null +++ b/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Builder.php @@ -0,0 +1,224 @@ +_formFactory = $formFactory; + $this->_configFactory = $configFactory; + $this->_rendererFactory = $rendererFactory; + $this->_elementsFactory = $elementsFactory; + $this->_translator = $translator; + } + + /** + * Create varien data form with provided params + * + * @param array $data + * @return Varien_Data_Form + * @throws InvalidArgumentException + */ + public function create(array $data = array()) + { + $this->_config = $this->_configFactory->create( + Mage_DesignEditor_Model_Editor_Tools_Controls_Factory::TYPE_QUICK_STYLES, + $data['theme'] + ); + + /** @var $form Varien_Data_Form */ + $form = $this->_formFactory->create($data); + + $this->_addElementTypes($form); + + if (!isset($data['tab'])) { + throw new InvalidArgumentException((sprintf('Invalid controls tab "%s".', $data['tab']))); + } + + $columns = $this->_initColumns($form, $data['tab']); + $this->_populateColumns($columns, $data['tab']); + + return $form; + } + + /** + * Add column elements to form + * + * @param Varien_Data_Form $form + * @param string $tab + * @return array + */ + protected function _initColumns($form, $tab) + { + /** @var $columnLeft Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Column */ + $columnLeft = $form->addField('column-left-' . $tab, 'column', array()); + $columnLeft->setRendererFactory($this->_rendererFactory) + ->setElementsFactory($this->_elementsFactory); + + /** @var $columnMiddle Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Column */ + $columnMiddle = $form->addField('column-middle-' . $tab, 'column', array()); + $columnMiddle->setRendererFactory($this->_rendererFactory) + ->setElementsFactory($this->_elementsFactory); + + /** @var $columnRight Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Column */ + $columnRight = $form->addField('column-right-' . $tab, 'column', array()); + $columnRight->setRendererFactory($this->_rendererFactory) + ->setElementsFactory($this->_elementsFactory); + + $columns = array( + 'left' => $columnLeft, + 'middle' => $columnMiddle, + 'right' => $columnRight + ); + + return $columns; + } + + /** + * Populate columns with fields + * + * @param array $columns + * @param string $tab + */ + protected function _populateColumns($columns, $tab) + { + foreach ($this->_config->getAllControlsData() as $id => $control) { + $positionData = $control['layoutParams']; + unset($control['layoutParams']); + + if ($positionData['tab'] != $tab) { + continue; + } + + $config = $this->_buildElementConfig($id, $positionData, $control); + + /** @var $column Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Column */ + $column = $columns[$positionData['column']]; + $column->addField($id, $control['type'], $config); + } + } + + /** + * Create form element config + * + * @param string $htmlId + * @param array $positionData + * @param array $control + * @return array + */ + protected function _buildElementConfig($htmlId, $positionData, $control) + { + $label = $this->__($positionData['title']); + + $config = array( + 'name' => $htmlId, + 'label' => $label, + ); + if (isset($control['components'])) { + $config['components'] = $control['components']; + $config['title'] = $label; + } else { + $config['value'] = $control['value']; + $config['title'] = sprintf('%s {%s: %s}', + $control['selector'], + $control['attribute'], + $control['value'] + ); + if (isset($control['options'])) { + $config['options'] = $control['options']; + } + } + + return $config; + } + + /** + * Add custom element types + * + * @param Varien_Data_Form $form + */ + protected function _addElementTypes($form) + { + $form->addType('column', 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Column'); + } + + /** + * Translate sentence + * + * @return string + * @SuppressWarnings(PHPMD.ShortMethodName) + */ + protected function __() + { + $args = func_get_args(); + $expr = new Mage_Core_Model_Translate_Expr(array_shift($args), 'Mage_DesignEditor'); + array_unshift($args, $expr); + return $this->_translator->translate($args); + } +} diff --git a/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Element/Factory.php b/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Element/Factory.php new file mode 100644 index 0000000000000..e4a6a5a28e9af --- /dev/null +++ b/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Element/Factory.php @@ -0,0 +1,51 @@ +_objectManager = $objectManager; + } + + /** + * Create form element with provided params + * + * @param string $className + * @param array $data + * @return Varien_Data_Form_Element_Abstract + */ + public function create($className, array $data = array()) + { + return $this->_objectManager->create($className, array('attributes' => $data)); + } +} diff --git a/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php b/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php new file mode 100644 index 0000000000000..89d5ce49107c5 --- /dev/null +++ b/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php @@ -0,0 +1,139 @@ + 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Renderer_Column', + + 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_ColorPicker' + => 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Renderer_ColorPicker', + + 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Logo' + => 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Renderer_Composite', + + 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Font' + => 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Renderer_Font', + + 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_LogoUploader' + => 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Renderer_LogoUploader', + + 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_Background' + => 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Renderer_Composite', + + 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_FontPicker' + => 'Mage_Backend_Block_Widget_Form_Renderer_Fieldset_Element', + + 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_BackgroundUploader' + => 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Renderer_BackgroundUploader', + + 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_ImageUploader' + => 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Renderer_ImageUploader', + + 'Varien_Data_Form_Element_Checkbox' + => 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Renderer_Checkbox' + ); + + /** + * Storage of renderers that could be shared between elements + * + * @see self::create() + * @var array + */ + protected $_sharedRenderers = array(); + + /** + * @param Mage_Core_Model_Layout $layout + */ + public function __construct(Mage_Core_Model_Layout $layout) + { + $this->_layout = $layout; + } + + /** + * Get renderer for element + * + * @param string $elementClassName + * @param string $rendererName + * @return Varien_Data_Form_Element_Renderer_Interface + * @throws Mage_Core_Exception + */ + public function create($elementClassName, $rendererName) + { + if (!isset($this->_rendererByElement[$elementClassName])) { + throw new Mage_Core_Exception( + sprintf('No renderer registered for elements of class "%s"', $elementClassName) + ); + } + $rendererClass = $this->_rendererByElement[$elementClassName]; + $renderer = $this->_layout->createBlock($rendererClass, $rendererName); + + return $renderer; + } + + /** + * Renderer can be shared if it's guaranteed that no nested elements that use this renderer again. + * For example: + * If Renderer01 used to render Element01 that should render some other Element02 using same Renderer01 it will + * cause an error. Cause internal Renderer01 property '_element' will be overwritten with Element02 during + * reuse of renderer and then will not be restored. + */ + public function getSharedInstance($elementClassName, $rendererName = null) + { + $rendererClass = $this->_rendererByElement[$elementClassName]; + if (isset($this->_sharedRenderers[$rendererClass])) { + $renderer = $this->_sharedRenderers[$rendererClass]; + } else { + if ($rendererName === null) { + $rendererName = uniqid('renderer-'); + } + $renderer = $this->create($elementClassName, $rendererName); + } + + return $renderer; + } +} diff --git a/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/ImageUploader.php b/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/ImageUploader.php new file mode 100644 index 0000000000000..123f2bd521425 --- /dev/null +++ b/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/ImageUploader.php @@ -0,0 +1,167 @@ +_objectManager = $objectManager; + $this->_filesystem = $filesystem; + parent::__construct($data); + } + + /** + * Get storage folder + * + * @return string + */ + public function getStoragePath() + { + if (null === $this->_storagePath) { + $this->_storagePath = implode(Magento_Filesystem::DIRECTORY_SEPARATOR, array( + Magento_Filesystem::fixSeparator($this->_getTheme()->getCustomizationPath()), + self::PATH_PREFIX_QUICK_STYLE, + )); + } + return $this->_storagePath; + } + + /** + * Set storage path + * + * @param string $path + * @return Mage_DesignEditor_Model_Editor_Tools_QuickStyles_ImageUploader + */ + public function setStoragePath($path) + { + $this->_storagePath = $path; + return $this; + } + + /** + * Get theme + * + * @return Mage_Core_Model_Theme + * @throws InvalidArgumentException + */ + protected function _getTheme() + { + /** @var $theme Mage_Core_Model_Theme */ + $theme = $this->getTheme(); + if (!$theme->getId()) { + throw new InvalidArgumentException('Theme was not found.'); + } + return $theme; + } + + /** + * Upload image file + * + * @param string $key + * @return array + */ + public function uploadFile($key) + { + $result = array(); + /** @var $uploader Mage_Core_Model_File_Uploader */ + $uploader = $this->_objectManager->create('Mage_Core_Model_File_Uploader', array('fileId' => $key)); + $uploader->setAllowedExtensions($this->_allowedExtensions); + $uploader->setAllowRenameFiles(true); + $uploader->setAllowCreateFolders(true); + + if (!$uploader->save($this->getStoragePath())) { + /** @todo add translator */ + Mage::throwException('Cannot upload file.'); + } + $result['css_path'] = implode( + '/', array('..', self::PATH_PREFIX_QUICK_STYLE, $uploader->getUploadedFileName()) + ); + $result['name'] = $uploader->getUploadedFileName(); + return $result; + } + + /** + * Remove file + * + * @param string $file + * @return Mage_DesignEditor_Model_Editor_Tools_QuickStyles_ImageUploader + */ + public function removeFile($file) + { + $path = $this->getStoragePath(); + $_filePath = $this->_filesystem->getAbsolutePath($path . Magento_Filesystem::DIRECTORY_SEPARATOR . $file); + + if ($this->_filesystem->isPathInDirectory($_filePath, $path) + && $this->_filesystem->isPathInDirectory($_filePath, $this->getStoragePath()) + ) { + $this->_filesystem->delete($_filePath); + } + + return $this; + } +} diff --git a/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/LogoUploader.php b/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/LogoUploader.php new file mode 100644 index 0000000000000..22900fb942689 --- /dev/null +++ b/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/LogoUploader.php @@ -0,0 +1,57 @@ + + */ +class Mage_DesignEditor_Model_Editor_Tools_QuickStyles_LogoUploader extends Mage_Backend_Model_Config_Backend_Image_Logo +{ + /** + * @param Mage_Core_Model_Context $context + * @param Mage_DesignEditor_Model_Config_Backend_File_RequestData $requestData + * @param Magento_Filesystem $filesystem + * @param Mage_Core_Model_Resource_Abstract $resource + * @param Varien_Data_Collection_Db $resourceCollection + * @param array $data + */ + public function __construct( + Mage_Core_Model_Context $context, + Mage_DesignEditor_Model_Config_Backend_File_RequestData $requestData, + Magento_Filesystem $filesystem, + Mage_Core_Model_Resource_Abstract $resource = null, + Varien_Data_Collection_Db $resourceCollection = null, + array $data = array() + ) { + parent::__construct( + $context, $requestData, $filesystem, $resource, $resourceCollection, $data + ); + } +} diff --git a/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer.php b/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer.php new file mode 100644 index 0000000000000..a4114a17e6062 --- /dev/null +++ b/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer.php @@ -0,0 +1,80 @@ +_quickStyleFactory = $factory; + } + + /** + * Render Quick Style CSS + * + * @param array $data + * @return string + */ + public function render($data) + { + $content = ''; + foreach ($data as $element) { + $this->_rendererCssRecursively($element, $content); + } + return $content; + } + + /** + * Render CSS recursively + * + * @param array $data + * @param string $content + * @return Mage_DesignEditor_Model_Editor_Tools_QuickStyles_Renderer + */ + protected function _rendererCssRecursively($data, &$content) + { + if (isset($data['components'])) { + foreach ($data['components'] as $component) { + $this->_rendererCssRecursively($component, $content); + } + } elseif (!empty($data['value']) && $data['value'] != $data['default'] && !empty($data['attribute'])) { + $content .= $this->_quickStyleFactory->get($data['attribute'])->toCss($data) . "\r\n"; + } + return $this; + } +} diff --git a/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer/Abstract.php b/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer/Abstract.php new file mode 100644 index 0000000000000..83f51180c1c65 --- /dev/null +++ b/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer/Abstract.php @@ -0,0 +1,50 @@ +_render($data); + } + + /** + * Render concrete element + * + * @param array $data + * @return string + */ + abstract protected function _render($data); +} diff --git a/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer/BackgroundImage.php b/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer/BackgroundImage.php new file mode 100644 index 0000000000000..643bdcad7b16b --- /dev/null +++ b/app/code/Mage/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer/BackgroundImage.php @@ -0,0 +1,48 @@ + 'Mage_DesignEditor_Model_Editor_Tools_QuickStyles_Renderer_BackgroundImage', + ); + + /** + * @param Magento_ObjectManager $objectManager + */ + public function __construct(Magento_ObjectManager $objectManager) + { + $this->_objectManager = $objectManager; + } + + /** + * Create new instance + * + * @param string $attribute + * @return Mage_DesignEditor_Model_Editor_Tools_QuickStyles_Renderer_Abstract + */ + public function get($attribute) + { + $renderer = array_key_exists($attribute, $this->_specificRenderer) + ? $this->_specificRenderer[$attribute] + : 'Mage_DesignEditor_Model_Editor_Tools_QuickStyles_Renderer_Default'; + + return $this->_objectManager->create($renderer); + } +} diff --git a/app/code/core/Mage/DesignEditor/Model/History.php b/app/code/Mage/DesignEditor/Model/History.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Model/History.php rename to app/code/Mage/DesignEditor/Model/History.php diff --git a/app/code/core/Mage/DesignEditor/Model/History/Compact.php b/app/code/Mage/DesignEditor/Model/History/Compact.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Model/History/Compact.php rename to app/code/Mage/DesignEditor/Model/History/Compact.php diff --git a/app/code/core/Mage/DesignEditor/Model/History/Compact/Layout.php b/app/code/Mage/DesignEditor/Model/History/Compact/Layout.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Model/History/Compact/Layout.php rename to app/code/Mage/DesignEditor/Model/History/Compact/Layout.php diff --git a/app/code/core/Mage/DesignEditor/Model/History/CompactAbstract.php b/app/code/Mage/DesignEditor/Model/History/CompactAbstract.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Model/History/CompactAbstract.php rename to app/code/Mage/DesignEditor/Model/History/CompactAbstract.php diff --git a/app/code/core/Mage/DesignEditor/Model/History/CompactInterface.php b/app/code/Mage/DesignEditor/Model/History/CompactInterface.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Model/History/CompactInterface.php rename to app/code/Mage/DesignEditor/Model/History/CompactInterface.php diff --git a/app/code/core/Mage/DesignEditor/Model/History/Renderer/LayoutUpdate.php b/app/code/Mage/DesignEditor/Model/History/Renderer/LayoutUpdate.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Model/History/Renderer/LayoutUpdate.php rename to app/code/Mage/DesignEditor/Model/History/Renderer/LayoutUpdate.php diff --git a/app/code/core/Mage/DesignEditor/Model/History/RendererInterface.php b/app/code/Mage/DesignEditor/Model/History/RendererInterface.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Model/History/RendererInterface.php rename to app/code/Mage/DesignEditor/Model/History/RendererInterface.php diff --git a/app/code/Mage/DesignEditor/Model/Layout.php b/app/code/Mage/DesignEditor/Model/Layout.php new file mode 100644 index 0000000000000..dca8db2eef583 --- /dev/null +++ b/app/code/Mage/DesignEditor/Model/Layout.php @@ -0,0 +1,435 @@ +_helper = $helper; + parent::__construct($blockFactory, $structure, $argumentProcessor, $translator, $scheduledStructure, + $dataSourceFactory, $area); + } + + /** + * Set sanitizing flag + * + * @param bool $flag + */ + public function setSanitizing($flag) + { + $this->_sanitationEnabled = $flag; + } + + /** + * Set wrapping flag + * + * @param bool $flag + */ + public function setWrapping($flag) + { + $this->_wrappingEnabled = $flag; + } + + /** + * Replace all inline JavaScript + * + * @return string + */ + public function getOutput() + { + $output = parent::getOutput(); + if (preg_match('/]*>.*<\/body>/is', $output, $body)) { + $oldBody = $body[0]; + // Replace script tags + $newBody = preg_replace('/]*>.*?<\/script>/is', '', $oldBody); + // Replace JS events + foreach ($this->_jsEvents as $event) { + $newBody = preg_replace("/(<[^>]+){$event}\\s*=\\s*(['\"])/is", "$1{$event}-vde=$2", $newBody); + } + // Replace href JS + $newBody = preg_replace('/(<[^>]+)href\s*=\s*([\'"])javascript:/is', '$1href-vde=$2', $newBody); + $output = str_replace($oldBody, $newBody, $output); + } + return $output; + } + + /** + * Replace all potentially dangerous blocks in layout into stubs + * + * It is important to sanitize the references first, because they refer to blocks to check whether they are safe. + * But if the blocks were sanitized before references, then they ALL will be considered safe. + * + * @param Varien_Simplexml_Element $node + */ + public function sanitizeLayout(Varien_Simplexml_Element $node) + { + $this->_sanitizeLayout($node, 'reference'); // it is important to sanitize references first + $this->_sanitizeLayout($node, 'block'); + } + + /** + * Sanitize nodes which names match the specified one + * + * Recursively goes through all underlying nodes + * + * @param Varien_Simplexml_Element $node + * @param string $nodeName + */ + protected function _sanitizeLayout(Varien_Simplexml_Element $node, $nodeName) + { + if ($node->getName() == $nodeName) { + switch ($nodeName) { + case 'block': + $this->_sanitizeBlock($node); + break; + case 'reference': + $this->_sanitizeReference($node); + break; + } + } + foreach ($node->children() as $child) { + $this->_sanitizeLayout($child, $nodeName); + } + } + + /** + * Replace "unsafe" types of blocks into Mage_Core_Block_Template and cut all their actions + * + * A "stub" template will be assigned for the blocks + * + * @param Varien_Simplexml_Element $node + */ + protected function _sanitizeBlock(Varien_Simplexml_Element $node) + { + $type = $node->getAttribute('type'); + if (!$type) { + return; // we encountered a node with name "block", however it doesn't actually define any block... + } + if ($this->_isParentSafe($node) || $this->_isTypeSafe($type)) { + return; + } + $this->_overrideAttribute($node, 'template', 'Mage_DesignEditor::stub.phtml'); + $this->_overrideAttribute($node, 'type', 'Mage_Core_Block_Template'); + $this->_deleteNodes($node, 'action'); + } + + /** + * Get list of allowed containers + * + * @return array + */ + protected function _getContainerWhiteList() + { + if ($this->_containerWhiteList === null) { + $this->_containerWhiteList = $this->_helper->getContainerWhiteList(); + } + return $this->_containerWhiteList; + } + + /** + * Whether parent node of specified node can be considered a safe container + * + * @param Varien_Simplexml_Element $node + * @return bool + */ + protected function _isParentSafe(Varien_Simplexml_Element $node) + { + $parentAttributes = $node->getParent()->attributes(); + if (isset($parentAttributes['name'])) { + if (!in_array($parentAttributes['name'], $this->_getContainerWhiteList())) { + return false; + } + } + return true; + } + + /** + * Get list of allowed blocks + * + * @return array + */ + protected function _getBlockWhiteList() + { + if ($this->_blockWhiteList === null) { + $this->_blockWhiteList = $this->_helper->getBlockWhiteList(); + } + return $this->_blockWhiteList; + } + + /** + * Get list of not allowed blocks + * + * @return array + */ + protected function _getBlockBlackList() + { + if ($this->_blockBlackList === null) { + $this->_blockBlackList = $this->_helper->getBlockBlackList(); + } + return $this->_blockBlackList; + } + + /** + * Check whether the specified type of block can be safely used in layout without required context + * + * @param string $type + * @return bool + */ + protected function _isTypeSafe($type) + { + if (in_array($type, $this->_getBlockBlackList())) { + return false; + } + foreach ($this->_getBlockWhiteList() as $safeType) { + if ('_' !== substr($safeType, -1, 1)) { + if ($type === $safeType) { + return true; + } + } elseif (0 === strpos($type, $safeType)) { + return true; + } + } + return false; + } + + /** + * Add or update specified attribute of a node with specified value + * + * @param Varien_Simplexml_Element $node + * @param string $name + * @param string $value + */ + protected function _overrideAttribute(Varien_Simplexml_Element $node, $name, $value) + { + $attributes = $node->attributes(); + if (isset($attributes[$name])) { + $attributes[$name] = $value; + } else { + $attributes->addAttribute($name, $value); + } + } + + /** + * Delete child nodes by specified name + * + * @param Varien_Simplexml_Element $node + * @param string $name + */ + protected function _deleteNodes(Varien_Simplexml_Element $node, $name) + { + $count = count($node->{$name}); + for ($i = $count; $i >= 0; $i--) { + unset($node->{$name}[$i]); + } + } + + /** + * Cleanup reference node according to the block it refers to + * + * Look for the block by reference name and if the block is "unsafe", cleanup the reference node from actions + * + * @param Varien_Simplexml_Element $node + */ + protected function _sanitizeReference(Varien_Simplexml_Element $node) + { + $attributes = $node->attributes(); + $name = $attributes['name']; + $result = $node->xpath("//block[@name='{$name}']") ?: array(); + /** @var $block Varien_Simplexml_Element */ + foreach ($result as $block) { + $isTypeSafe = $this->_isTypeSafe($block->getAttribute('type')); + if (!$isTypeSafe || !$this->_isParentSafe($block)) { + $this->_deleteNodes($node, 'action'); + } + break; + } + } + + /** + * Create structure of elements from the loaded XML configuration + */ + public function generateElements() + { + if ($this->_sanitationEnabled) { + $this->sanitizeLayout($this->getNode()); + } + + parent::generateElements(); + } + + /** + * Gets HTML of block element + * + * @param string $name + * @return string + * @throws Magento_Exception + */ + protected function _renderBlock($name) + { + $result = parent::_renderBlock($name); + + if ($this->_wrappingEnabled) { + $block = $this->getBlock($name); + if (strpos(get_class($block), 'Mage_DesignEditor_Block_') !== 0 && $this->isManipulationAllowed($name)) { + $result = $this->_wrapElement($result, $name, false, true); + } + } + + return $result; + } + + /** + * Gets HTML of container element + * + * @param string $name + * @return string + */ + protected function _renderContainer($name) + { + $result = parent::_renderContainer($name); + + if ($this->_wrappingEnabled && $this->hasElement($name)) { + $result = $this->_wrapElement($result, $name, true); + } + + return $result; + } + + /** + * Wrap layout element + * + * @param string $elementContent + * @param string $elementName + * @param bool $isContainer + * @param bool $canManipulate + * @return string + */ + protected function _wrapElement($elementContent, $elementName, $isContainer = false, $canManipulate = false) + { + $elementId = 'vde_element_' . rtrim(strtr(base64_encode($elementName), '+/', '-_'), '='); + if (!$this->_wrapperBlock) { + $this->_wrapperBlock = $this->_blockFactory->createBlock('Mage_DesignEditor_Block_Template'); + } + $this->_wrapperBlock->setData(array( + 'element_id' => $elementId, + 'element_title' => $this->getElementProperty($elementName, 'label') ?: $elementName, + 'element_html' => $elementContent, + 'is_manipulation_allowed' => $canManipulate, + 'is_container' => $isContainer, + 'element_name' => $elementName, + )); + return $this->_wrapperBlock->toHtml(); + } +} diff --git a/app/code/core/Mage/DesignEditor/Model/Layout/Update.php b/app/code/Mage/DesignEditor/Model/Layout/Update.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Model/Layout/Update.php rename to app/code/Mage/DesignEditor/Model/Layout/Update.php diff --git a/app/code/Mage/DesignEditor/Model/Observer.php b/app/code/Mage/DesignEditor/Model/Observer.php new file mode 100644 index 0000000000000..6d6510338156b --- /dev/null +++ b/app/code/Mage/DesignEditor/Model/Observer.php @@ -0,0 +1,144 @@ +_objectManager = $objectManager; + $this->_helper = $helper; + } + + /** + * Clear temporary layout updates and layout links + */ + public function clearLayoutUpdates() + { + $daysToExpire = $this->_helper->getDaysToExpire(); + + // remove expired links + /** @var $linkCollection Mage_Core_Model_Resource_Layout_Link_Collection */ + $linkCollection = $this->_objectManager->create('Mage_Core_Model_Resource_Layout_Link_Collection'); + $linkCollection->addTemporaryFilter(true) + ->addUpdatedDaysBeforeFilter($daysToExpire); + + /** @var $layoutLink Mage_Core_Model_Layout_Link */ + foreach ($linkCollection as $layoutLink) { + $layoutLink->delete(); + } + + // remove expired updates without links + /** @var $layoutCollection Mage_Core_Model_Resource_Layout_Update_Collection */ + $layoutCollection = $this->_objectManager->create('Mage_Core_Model_Resource_Layout_Update_Collection'); + $layoutCollection->addNoLinksFilter() + ->addUpdatedDaysBeforeFilter($daysToExpire); + + /** @var $layoutUpdate Mage_Core_Model_Layout_Update */ + foreach ($layoutCollection as $layoutUpdate) { + $layoutUpdate->delete(); + } + } + + /** + * Remove non-VDE JavaScript assets in design mode + * Applicable in combination with enabled 'vde_design_mode' flag for 'head' block + * + * @param Varien_Event_Observer $event + */ + public function clearJs(Varien_Event_Observer $event) + { + /** @var $layout Mage_Core_Model_Layout */ + $layout = $event->getEvent()->getLayout(); + $blockHead = $layout->getBlock('head'); + if (!$blockHead || !$blockHead->getData('vde_design_mode')) { + return; + } + + /** @var $page Mage_Core_Model_Page */ + $page = $this->_objectManager->get('Mage_Core_Model_Page'); + + /** @var $pageAssets Mage_Page_Model_Asset_GroupedCollection */ + $pageAssets = $page->getAssets(); + + $vdeAssets = array(); + foreach ($pageAssets->getGroups() as $group) { + if ($group->getProperty('flag_name') == 'vde_design_mode') { + $vdeAssets = array_merge($vdeAssets, $group->getAll()); + } + } + + /** @var $nonVdeAssets Mage_Core_Model_Page_Asset_AssetInterface[] */ + $nonVdeAssets = array_diff_key($pageAssets->getAll(), $vdeAssets); + + foreach ($nonVdeAssets as $assetId => $asset) { + if ($asset->getContentType() == Mage_Core_Model_Design_Package::CONTENT_TYPE_JS) { + $pageAssets->remove($assetId); + } + } + } + + /** + * Save quick styles + * + * @param Varien_Event_Observer $event + */ + public function saveQuickStyles($event) + { + /** @var $configuration Mage_DesignEditor_Model_Editor_Tools_Controls_Configuration */ + $configuration = $event->getData('configuration'); + if ($configuration->getControlConfig() instanceof Mage_DesignEditor_Model_Config_Control_QuickStyles) { + /** @var $renderer Mage_DesignEditor_Model_Editor_Tools_QuickStyles_Renderer */ + $renderer = $this->_objectManager->create('Mage_DesignEditor_Model_Editor_Tools_QuickStyles_Renderer'); + $content = $renderer->render($configuration->getAllControlsData()); + + /** @var $themeCss Mage_Core_Model_Theme_Customization_Files_Css */ + $themeCss = $this->_objectManager->create('Mage_Core_Model_Theme_Customization_Files_Css'); + $themeCss->setDataForSave(array( + Mage_Core_Model_Theme_Customization_Files_Css::QUICK_STYLE_CSS => $content + )); + $configuration->getTheme()->setCustomization($themeCss)->save(); + } + } +} diff --git a/app/code/core/Mage/DesignEditor/Model/Resource/Layout/Update.php b/app/code/Mage/DesignEditor/Model/Resource/Layout/Update.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Model/Resource/Layout/Update.php rename to app/code/Mage/DesignEditor/Model/Resource/Layout/Update.php diff --git a/app/code/core/Mage/DesignEditor/Model/Resource/Layout/Update/Collection.php b/app/code/Mage/DesignEditor/Model/Resource/Layout/Update/Collection.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Model/Resource/Layout/Update/Collection.php rename to app/code/Mage/DesignEditor/Model/Resource/Layout/Update/Collection.php diff --git a/app/code/Mage/DesignEditor/Model/State.php b/app/code/Mage/DesignEditor/Model/State.php new file mode 100644 index 0000000000000..87e3d9bc139b2 --- /dev/null +++ b/app/code/Mage/DesignEditor/Model/State.php @@ -0,0 +1,267 @@ +_backendSession = $backendSession; + $this->_layoutFactory = $layoutFactory; + $this->_urlModelFactory = $urlModelFactory; + $this->_cacheManager = $cacheManager; + $this->_dataHelper = $dataHelper; + $this->_objectManager = $objectManager; + $this->_design = $design; + $this->_application = $application; + } + + /** + * Update system data for current VDE environment + * + * @param string $areaCode + * @param Mage_Core_Controller_Request_Http $request + * @param Mage_Core_Controller_Varien_ActionAbstract $controller + */ + public function update( + $areaCode, + Mage_Core_Controller_Request_Http $request, + Mage_Core_Controller_Varien_ActionAbstract $controller + ) { + $handle = $request->getParam('handle', ''); + if (empty($handle)) { + $mode = self::MODE_NAVIGATION; + + if (!$request->isAjax()) { + $this->_backendSession->setData(self::CURRENT_HANDLE_SESSION_KEY, $controller->getFullActionName()); + $this->_backendSession->setData(self::CURRENT_URL_SESSION_KEY, $request->getPathInfo()); + } + } else { + $mode = self::MODE_DESIGN; + } + + $this->_backendSession->setData(self::CURRENT_MODE_SESSION_KEY, $mode); + $this->_injectUrlModel($mode); + $this->_injectLayout($mode, $areaCode); + $this->_injectLayoutUpdateResourceModel(); + $this->_setTheme(); + $this->_disableCache(); + } + + /** + * Reset VDE state data + * + * @return Mage_DesignEditor_Model_State + */ + public function reset() + { + $this->_backendSession->unsetData(self::CURRENT_HANDLE_SESSION_KEY) + ->unsetData(self::CURRENT_URL_SESSION_KEY) + ->unsetData(self::CURRENT_MODE_SESSION_KEY) + ->unsetData(self::VIRTUAL_THEME_SESSION_KEY) + ->unsetData(self::CURRENT_THEME_SESSION_KEY); + + return $this; + } + + /** + * Create layout instance that will be used as main layout for whole system + * + * @param string $mode + * @param string $areaCode + */ + protected function _injectLayout($mode, $areaCode) + { + switch ($mode) { + case self::MODE_DESIGN: + $this->_layoutFactory->createLayout(array('area' => $areaCode), self::LAYOUT_DESIGN_CLASS_NAME); + break; + case self::MODE_NAVIGATION: + default: + $this->_layoutFactory->createLayout(array('area' => $areaCode), self::LAYOUT_NAVIGATION_CLASS_NAME); + break; + } + } + + /** + * Create url model instance that will be used instead of Mage_Core_Model_Url in navigation mode + */ + protected function _injectUrlModel($mode) + { + switch ($mode) { + case self::MODE_DESIGN: + $this->_urlModelFactory->replaceClassName(self::URL_MODEL_DESIGN_MODE_CLASS_NAME); + break; + case self::MODE_NAVIGATION: + default: + $this->_urlModelFactory->replaceClassName(self::URL_MODEL_NAVIGATION_MODE_CLASS_NAME); + break; + } + } + + /** + * Replace layout update resource model with custom vde one + */ + protected function _injectLayoutUpdateResourceModel() + { + $this->_objectManager->configure(array( + 'preferences' => array( + self::LAYOUT_UPDATE_RESOURCE_MODEL_CORE_CLASS_NAME => self::LAYOUT_UPDATE_RESOURCE_MODEL_VDE_CLASS_NAME + ) + )); + } + + /** + * Set current VDE theme + */ + protected function _setTheme() + { + $themeId = $this->_backendSession->getData(self::CURRENT_THEME_SESSION_KEY); + if ($themeId !== null) { + $this->_application->getStore()->setConfig(Mage_Core_Model_Design_Package::XML_PATH_THEME_ID, $themeId); + } + } + + /** + * Disable some cache types in VDE mode + */ + protected function _disableCache() + { + foreach ($this->_dataHelper->getDisabledCacheTypes() as $cacheCode) { + if ($this->_cacheManager->canUse($cacheCode)) { + $this->_cacheManager->banUse($cacheCode); + } + } + } +} diff --git a/app/code/core/Mage/DesignEditor/Model/Url/DesignMode.php b/app/code/Mage/DesignEditor/Model/Url/DesignMode.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Model/Url/DesignMode.php rename to app/code/Mage/DesignEditor/Model/Url/DesignMode.php diff --git a/app/code/Mage/DesignEditor/Model/Url/Factory.php b/app/code/Mage/DesignEditor/Model/Url/Factory.php new file mode 100644 index 0000000000000..a29c0a02fc3e8 --- /dev/null +++ b/app/code/Mage/DesignEditor/Model/Url/Factory.php @@ -0,0 +1,70 @@ +_objectManager = $objectManager; + } + + /** + * Replace name of url model + * + * @param string $className + * @return Mage_DesignEditor_Model_Url_Factory + */ + public function replaceClassName($className) + { + $this->_objectManager->configure(array('preferences' => array(self::CLASS_NAME => $className))); + + return $this; + } + + /** + * Create url model new instance + * + * @param array $arguments + * @return Mage_Core_Model_Url + */ + public function create(array $arguments = array()) + { + return $this->_objectManager->create(self::CLASS_NAME, $arguments); + } +} diff --git a/app/code/core/Mage/DesignEditor/Model/Url/Handle.php b/app/code/Mage/DesignEditor/Model/Url/Handle.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Model/Url/Handle.php rename to app/code/Mage/DesignEditor/Model/Url/Handle.php diff --git a/app/code/core/Mage/DesignEditor/Model/Url/NavigationMode.php b/app/code/Mage/DesignEditor/Model/Url/NavigationMode.php similarity index 100% rename from app/code/core/Mage/DesignEditor/Model/Url/NavigationMode.php rename to app/code/Mage/DesignEditor/Model/Url/NavigationMode.php diff --git a/app/code/Mage/DesignEditor/controllers/Adminhtml/System/Design/Editor/ToolsController.php b/app/code/Mage/DesignEditor/controllers/Adminhtml/System/Design/Editor/ToolsController.php new file mode 100644 index 0000000000000..8fed026b6d4cd --- /dev/null +++ b/app/code/Mage/DesignEditor/controllers/Adminhtml/System/Design/Editor/ToolsController.php @@ -0,0 +1,421 @@ +_objectManager->create('Mage_Core_Model_Theme_Customization_Files_Css'); + /** @var $serviceModel Mage_Theme_Model_Uploader_Service */ + $serviceModel = $this->_objectManager->get('Mage_Theme_Model_Uploader_Service'); + try { + $theme = $this->_getEditableTheme(); + $cssFileContent = $serviceModel->uploadCssFile( + Mage_DesignEditor_Block_Adminhtml_Editor_Tools_Code_Custom::FILE_ELEMENT_NAME + )->getFileContent(); + $themeCss->setDataForSave( + array(Mage_Core_Model_Theme_Customization_Files_Css::CUSTOM_CSS => $cssFileContent) + ); + $themeCss->saveData($theme); + $response = array('error' => false, 'content' => $cssFileContent); + $this->_session->addSuccess($this->__('Success: Theme custom css was saved.')); + } catch (Mage_Core_Exception $e) { + $this->_session->addError($e->getMessage()); + $response = array('error' => true, 'message' => $e->getMessage()); + } catch (Exception $e) { + $errorMessage = $this->__('Cannot upload css file'); + $this->_session->addError($errorMessage); + $response = array('error' => true, 'message' => $errorMessage); + $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); + } + $this->loadLayout(); + $response['message_html'] = $this->getLayout()->getMessagesBlock()->toHtml(); + $this->getResponse()->setBody($this->_objectManager->get('Mage_Core_Helper_Data')->jsonEncode($response)); + } + + /** + * Save custom css file + */ + public function saveCssContentAction() + { + $customCssContent = (string)$this->getRequest()->getParam('custom_css_content', ''); + try { + $theme = $this->_getEditableTheme(); + /** @var $themeCss Mage_Core_Model_Theme_Customization_Files_Css */ + $themeCss = $this->_objectManager->create('Mage_Core_Model_Theme_Customization_Files_Css'); + $themeCss->setDataForSave( + array(Mage_Core_Model_Theme_Customization_Files_Css::CUSTOM_CSS => $customCssContent) + ); + $theme->setCustomization($themeCss)->save(); + $response = array('error' => false); + $this->_session->addSuccess($this->__('Theme custom css was saved.')); + } catch (Mage_Core_Exception $e) { + $this->_session->addError($e->getMessage()); + $response = array('error' => true, 'message' => $e->getMessage()); + } catch (Exception $e) { + $errorMessage = $this->__('Cannot save custom css'); + $this->_session->addError($errorMessage); + $response = array('error' => true, 'message' => $errorMessage); + $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); + } + $this->loadLayout(); + $response['message_html'] = $this->getLayout()->getMessagesBlock()->toHtml(); + $this->getResponse()->setBody($this->_objectManager->get('Mage_Core_Helper_Data')->jsonEncode($response)); + } + + /** + * Ajax list of existing javascript files + */ + public function jsListAction() + { + try { + $theme = $this->_getEditableTheme(); + $this->loadLayout(); + + /** @var $filesJs Mage_Core_Model_Theme_Customization_Files_Js */ + $filesJs = $this->_objectManager->create('Mage_Core_Model_Theme_Customization_Files_Js'); + $customJsFiles = $theme->setCustomization($filesJs) + ->getCustomizationData(Mage_Core_Model_Theme_Customization_Files_Js::TYPE); + + $jsItemsBlock = $this->getLayout()->getBlock('design_editor_tools_code_js_items'); + $jsItemsBlock->setJsFiles($customJsFiles); + + $result = array('error' => false, 'content' => $jsItemsBlock->toHtml()); + $this->getResponse()->setBody($this->_objectManager->get('Mage_Core_Helper_Data')->jsonEncode($result)); + } catch (Exception $e) { + $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); + } + } + + /** + * Upload js file + */ + public function uploadJsAction() + { + /** @var $serviceModel Mage_Theme_Model_Uploader_Service */ + $serviceModel = $this->_objectManager->get('Mage_Theme_Model_Uploader_Service'); + try { + $theme = $this->_getEditableTheme(); + $serviceModel->uploadJsFile('js_files_uploader', $theme, false); + $theme->setCustomization($serviceModel->getJsFiles())->save(); + $this->_forward('jsList'); + return; + } catch (Mage_Core_Exception $e) { + $this->_getSession()->addError($e->getMessage()); + $response = array('error' => true, 'message' => $e->getMessage()); + } catch (Exception $e) { + $errorMessage = $this->__('Cannot upload js file'); + $this->_getSession()->addError($errorMessage); + $response = array('error' => true, 'message' => $errorMessage); + $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); + } + $this->loadLayout(); + $response['message_html'] = $this->getLayout()->getMessagesBlock()->toHtml(); + $this->getResponse()->setBody($this->_objectManager->get('Mage_Core_Helper_Data')->jsonEncode($response)); + } + + /** + * Delete custom file action + */ + public function deleteCustomFilesAction() + { + $removeJsFiles = (array)$this->getRequest()->getParam('js_removed_files'); + try { + $theme = $this->_getEditableTheme(); + + /** @var $themeJs Mage_Core_Model_Theme_Customization_Files_Js */ + $themeJs = $this->_objectManager->create('Mage_Core_Model_Theme_Customization_Files_Js'); + $theme->setCustomization($themeJs); + + $themeJs->setDataForDelete($removeJsFiles); + $theme->save(); + + $this->_forward('jsList'); + } catch (Exception $e) { + $this->_redirectUrl($this->_getRefererUrl()); + $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); + } + } + + /** + * Reorder js file + */ + public function reorderJsAction() + { + $reorderJsFiles = (array)$this->getRequest()->getParam('js_order', array()); + /** @var $themeJs Mage_Core_Model_Theme_Customization_Files_Js */ + $themeJs = $this->_objectManager->create('Mage_Core_Model_Theme_Customization_Files_Js'); + try { + $theme = $this->_getEditableTheme(); + $themeJs->setJsOrderData($reorderJsFiles); + $theme->setCustomization($themeJs); + $theme->save(); + + $result = array('success' => true); + } catch (Mage_Core_Exception $e) { + $this->_session->addError($e->getMessage()); + $result = array('error' => true, 'message' => $e->getMessage()); + } catch (Exception $e) { + $errorMessage = $this->__('Cannot upload css file'); + $this->_session->addError($errorMessage); + $result = array('error' => true, 'message' => $errorMessage); + $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); + } + $this->loadLayout(); + $result['message_html'] = $this->getLayout()->getMessagesBlock()->toHtml(); + $this->getResponse()->setBody($this->_objectManager->get('Mage_Core_Helper_Data')->jsonEncode($result)); + } + + /** + * Save image sizes + */ + public function saveImageSizingAction() + { + $imageSizing = $this->getRequest()->getParam('imagesizing'); + /** @var $configFactory Mage_DesignEditor_Model_Editor_Tools_Controls_Factory */ + $configFactory = $this->_objectManager->create('Mage_DesignEditor_Model_Editor_Tools_Controls_Factory'); + /** @var $imageSizingValidator Mage_DesignEditor_Model_Editor_Tools_ImageSizing_Validator */ + $imageSizingValidator = $this->_objectManager->get( + 'Mage_DesignEditor_Model_Editor_Tools_ImageSizing_Validator' + ); + try { + $configuration = $configFactory->create( + Mage_DesignEditor_Model_Editor_Tools_Controls_Factory::TYPE_IMAGE_SIZING, $this->_getEditableTheme() + ); + $imageSizing = $imageSizingValidator->validate($configuration->getAllControlsData(), $imageSizing); + $configuration->saveData($imageSizing); + $this->_session->addSuccess('Image sizes are saved.'); + $result = array('success' => true); + } catch (Mage_Core_Exception $e) { + $this->_session->addError($e->getMessage()); + $result = array('error' => true, 'message' => $e->getMessage()); + } catch (Exception $e) { + $errorMessage = $this->__('Cannot save image sizes.'); + $this->_session->addError($errorMessage); + $result = array('error' => true, 'message' => $errorMessage); + $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); + } + $this->loadLayout(); + $result['message_html'] = $this->getLayout()->getMessagesBlock()->toHtml(); + $this->getResponse()->setBody($this->_objectManager->get('Mage_Core_Helper_Data')->jsonEncode($result)); + + } + + /** + * Upload quick style image + */ + public function uploadQuickStyleImageAction() + { + /** @var $uploaderModel Mage_DesignEditor_Model_Editor_Tools_QuickStyles_ImageUploader */ + $uploaderModel = $this->_objectManager->get('Mage_DesignEditor_Model_Editor_Tools_QuickStyles_ImageUploader'); + /** @var $configFactory Mage_DesignEditor_Model_Editor_Tools_Controls_Factory */ + $configFactory = $this->_objectManager->create('Mage_DesignEditor_Model_Editor_Tools_Controls_Factory'); + try { + $theme = $this->_getEditableTheme(); + $keys = array_keys($this->getRequest()->getFiles()); + $result = $uploaderModel->setTheme($theme)->uploadFile($keys[0]); + + $configuration = $configFactory->create( + Mage_DesignEditor_Model_Editor_Tools_Controls_Factory::TYPE_QUICK_STYLES, $theme + ); + $configuration->saveData(array($keys[0] => $result['css_path'])); + + $response = array('error' => false, 'content' => $result); + } catch (Mage_Core_Exception $e) { + $this->_session->addError($e->getMessage()); + $response = array('error' => true, 'message' => $e->getMessage()); + } catch (Exception $e) { + $errorMessage = $this->__('Cannot upload image file'); + $response = array('error' => true, 'message' => $errorMessage); + $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); + } + $this->getResponse()->setBody($this->_objectManager->get('Mage_Core_Helper_Data')->jsonEncode($response)); + } + + /** + * Remove quick style image + */ + public function removeQuickStyleImageAction() + { + $fileName = $this->getRequest()->getParam('file_name', false); + $elementName = $this->getRequest()->getParam('element', false); + + /** @var $uploaderModel Mage_DesignEditor_Model_Editor_Tools_QuickStyles_ImageUploader */ + $uploaderModel = $this->_objectManager->get('Mage_DesignEditor_Model_Editor_Tools_QuickStyles_ImageUploader'); + try { + $theme = $this->_getEditableTheme(); + $result = $uploaderModel->setTheme($theme)->removeFile($fileName); + + /** @var $configFactory Mage_DesignEditor_Model_Editor_Tools_Controls_Factory */ + $configFactory = $this->_objectManager->create('Mage_DesignEditor_Model_Editor_Tools_Controls_Factory'); + + $configuration = $configFactory->create( + Mage_DesignEditor_Model_Editor_Tools_Controls_Factory::TYPE_QUICK_STYLES, $theme + ); + $configuration->saveData(array($elementName => '')); + + $response = array('error' => false, 'content' => $result); + } catch (Mage_Core_Exception $e) { + $response = array('error' => true, 'message' => $e->getMessage()); + } catch (Exception $e) { + $errorMessage = $this->__('Cannot upload image file'); + $response = array('error' => true, 'message' => $errorMessage); + $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); + } + $this->getResponse()->setBody($this->_objectManager->get('Mage_Core_Helper_Data')->jsonEncode($response)); + } + + /** + * Upload store logo + * + * @throws Mage_Core_Exception + */ + public function uploadStoreLogoAction() + { + $storeId = (int)$this->getRequest()->getParam('store_id'); + $themeId = (int)$this->getRequest()->getParam('theme_id'); + /** @var $helper Mage_Core_Helper_Theme */ + $helper = $this->_objectManager->get('Mage_Core_Helper_Theme'); + try { + $theme = $helper->loadVisibleTheme($themeId); + if (!$theme->getId() || ($theme->getType() != Mage_Core_Model_Theme::TYPE_VIRTUAL)) { + throw new Mage_Core_Exception($this->__('Theme "%s" was not found.', $theme->getId())); + } + + /** @var $themeService Mage_Core_Model_Theme_Service */ + $themeService = $this->_objectManager->get('Mage_Core_Model_Theme_Service'); + $store = $this->_objectManager->get('Mage_Core_Model_Store')->load($storeId); + + if (!$themeService->isThemeAssignedToSpecificStore($theme, $store)) { + throw new Mage_Core_Exception($this->__('Theme is not assigned to any store.', $theme->getId())); + } + /** @var $storeLogo Mage_DesignEditor_Model_Editor_Tools_QuickStyles_LogoUploader */ + $storeLogo = $this->_objectManager->get('Mage_DesignEditor_Model_Editor_Tools_QuickStyles_LogoUploader'); + $storeLogo->setScope('stores')->setScopeId($store->getId())->setPath('design/header/logo_src')->save(); + + $response = array('error' => false, 'content' => array('name' => $storeLogo->getValue())); + } catch (Mage_Core_Exception $e) { + $response = array('error' => true, 'message' => $e->getMessage()); + } catch (Exception $e) { + $errorMessage = $this->__('Cannot upload image file'); + $response = array('error' => true, 'message' => $errorMessage); + $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); + } + $this->getResponse()->setBody($this->_objectManager->get('Mage_Core_Helper_Data')->jsonEncode($response)); + } + + /** + * Remove store logo + * + * @throws Mage_Core_Exception + */ + public function removeStoreLogoAction() + { + $storeId = (int)$this->getRequest()->getParam('store_id'); + $themeId = (int)$this->getRequest()->getParam('theme_id'); + /** @var $helper Mage_Core_Helper_Theme */ + $helper = $this->_objectManager->get('Mage_Core_Helper_Theme'); + try { + $theme = $helper->loadVisibleTheme($themeId); + if (!$theme->getId() || ($theme->getType() != Mage_Core_Model_Theme::TYPE_VIRTUAL)) { + throw new Mage_Core_Exception($this->__('Theme "%s" was not found.', $theme->getId())); + } + + /** @var $themeService Mage_Core_Model_Theme_Service */ + $themeService = $this->_objectManager->get('Mage_Core_Model_Theme_Service'); + $store = $this->_objectManager->get('Mage_Core_Model_Store')->load($storeId); + + if (!$themeService->isThemeAssignedToSpecificStore($theme, $store)) { + throw new Mage_Core_Exception($this->__('Theme is not assigned to any store.', $theme->getId())); + } + + $this->_objectManager->get('Mage_Backend_Model_Config_Backend_Store') + ->setScope('stores')->setScopeId($store->getId())->setPath('design/header/logo_src') + ->setValue('')->save(); + + $response = array('error' => false, 'content' => array()); + } catch (Mage_Core_Exception $e) { + $response = array('error' => true, 'message' => $e->getMessage()); + } catch (Exception $e) { + $errorMessage = $this->__('Cannot upload image file'); + $response = array('error' => true, 'message' => $errorMessage); + $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); + } + $this->getResponse()->setBody($this->_objectManager->get('Mage_Core_Helper_Data')->jsonEncode($response)); + } + + /** + * Save quick styles data + */ + public function saveQuickStylesAction() + { + $controlId = $this->getRequest()->getParam('id'); + $controlValue = $this->getRequest()->getParam('value'); + try { + /** @var $configFactory Mage_DesignEditor_Model_Editor_Tools_Controls_Factory */ + $configFactory = $this->_objectManager->create('Mage_DesignEditor_Model_Editor_Tools_Controls_Factory'); + $configuration = $configFactory->create( + Mage_DesignEditor_Model_Editor_Tools_Controls_Factory::TYPE_QUICK_STYLES, + $this->_getEditableTheme() + ); + $configuration->saveData(array($controlId => $controlValue)); + $response = array('success' => true); + } catch (Mage_Core_Exception $e) { + $this->_session->addError($e->getMessage()); + $response = array('error' => true, 'message' => $e->getMessage()); + } catch (Exception $e) { + $errorMessage = $this->__('Error while saving quick style "%s"', 'some_style_id'); + $this->_session->addError($errorMessage); + $response = array('error' => true, 'message' => $errorMessage); + $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); + } + + $this->loadLayout(); + $response['message_html'] = $this->getLayout()->getMessagesBlock()->toHtml(); + $this->getResponse()->setBody($this->_objectManager->get('Mage_Core_Helper_Data')->jsonEncode($response)); + } + + /** + * Get theme launched in editor + * + * @return Mage_Core_Model_Theme + */ + protected function _getEditableTheme() + { + /** @var $dataHelper Mage_DesignEditor_Helper_Data */ + $dataHelper = $this->_objectManager->get('Mage_DesignEditor_Helper_Data'); + /** @var $helper Mage_Core_Helper_Theme */ + $helper = $this->_objectManager->get('Mage_Core_Helper_Theme'); + return $helper->loadEditableTheme($dataHelper->getEditableThemeId()); + } +} diff --git a/app/code/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorController.php b/app/code/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorController.php new file mode 100644 index 0000000000000..420fd8577d2b8 --- /dev/null +++ b/app/code/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorController.php @@ -0,0 +1,676 @@ +_doSelectionTheme('firstEntrance'); + } + + /** + * Ajax loading available themes + */ + public function loadThemeListAction() + { + /** @var $coreHelper Mage_Core_Helper_Data */ + $coreHelper = $this->_objectManager->get('Mage_Core_Helper_Data'); + + $page = $this->getRequest()->getParam('page', 1); + $pageSize = $this->getRequest() + ->getParam('page_size', Mage_Core_Model_Resource_Theme_Collection::DEFAULT_PAGE_SIZE); + + try { + $this->loadLayout(); + /** @var $service Mage_Core_Model_Theme_Service */ + $service = $this->_objectManager->get('Mage_Core_Model_Theme_Service'); + + /** @var $collection Mage_Core_Model_Resource_Theme_Collection */ + $collection = $service->getPhysicalThemes($page, $pageSize); + $this->getLayout()->getBlock('available.theme.list')->setCollection($collection)->setNextPage(++$page); + $response = array('content' => $this->getLayout()->getOutput()); + } catch (Exception $e) { + $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); + $response = array('error' => $this->_helper->__('Theme list can not be loaded')); + } + $this->getResponse()->setBody($coreHelper->jsonEncode($response)); + } + + /** + * Activate the design editor in the session and redirect to the frontend of the selected store + */ + public function launchAction() + { + $themeId = (int)$this->getRequest()->getParam('theme_id', $this->_getSession()->getData('theme_id')); + $mode = (string)$this->getRequest()->getParam('mode', Mage_DesignEditor_Model_State::MODE_DESIGN); + /** @var $helper Mage_Core_Helper_Theme */ + $helper = $this->_objectManager->get('Mage_Core_Helper_Theme'); + try { + $theme = $helper->loadVisibleTheme($themeId); + $editableTheme = $theme->isVirtual() ? $theme->getDomainModel()->getStagingTheme() : $theme; + $this->_getSession()->setData(Mage_DesignEditor_Model_State::VIRTUAL_THEME_SESSION_KEY, $themeId); + $this->_getSession()->setData( + Mage_DesignEditor_Model_State::CURRENT_THEME_SESSION_KEY, $editableTheme->getId() + ); + + /** @var $eventDispatcher Mage_Core_Model_Event_Manager */ + $eventDispatcher = $this->_objectManager->get('Mage_Core_Model_Event_Manager'); + $eventDispatcher->dispatch('design_editor_activate'); + + $this->_setTitle(); + $this->loadLayout(); + + $this->_configureToolbarBlocks($theme, $editableTheme, $mode); //top panel + $this->_configureToolsBlocks($editableTheme, $mode); //bottom panel + $this->_configureEditorBlock($editableTheme, $mode); //editor container + + $redirectOnAssign = $theme->isPhysical(); + /** @var $storeViewBlock Mage_DesignEditor_Block_Adminhtml_Theme_Selector_StoreView */ + $storeViewBlock = $this->getLayout()->getBlock('theme.selector.storeview'); + $storeViewBlock->setData(array( + 'redirectOnAssign' => $redirectOnAssign, + 'openNewOnAssign' => false, + 'theme_id' => $theme->getId() + )); + + $this->renderLayout(); + } catch (Mage_Core_Exception $e) { + $this->_getSession()->addException($e, $e->getMessage()); + $this->_redirect('*/*/'); + return; + } catch (Exception $e) { + $this->_getSession()->addException($e, $this->__('Unknown error')); + $this->_redirect('*/*/'); + return; + } + } + + /** + * Create virtual theme action + */ + public function createVirtualThemeAction() + { + $themeId = (int)$this->getRequest()->getParam('theme_id', false); + /** @var $helper Mage_Core_Helper_Theme */ + $helper = $this->_objectManager->get('Mage_Core_Helper_Theme'); + try { + $theme = $helper->loadVisibleTheme($themeId); + if (!$theme->getId() || ($theme->getType() != Mage_Core_Model_Theme::TYPE_PHYSICAL)) { + throw new Mage_Core_Exception($this->__('Theme "%s" was not found.', $theme->getId())); + } + $virtualTheme = $this->_getThemeCustomization($theme); + $response = array( + 'error' => false, + 'redirect_url' => $this->getUrl('*/*/launch', array('theme_id' => $virtualTheme->getId())) + ); + } catch (Mage_Core_Exception $e) { + $this->_getSession()->addException($e, $e->getMessage()); + $response = array('error' => true, 'message' => $e->getMessage()); + } catch (Exception $e) { + $errorMessage = $this->__('Unknown error.'); + $this->_getSession()->addException($e, $errorMessage); + $response = array('error' => true, 'message' => $errorMessage); + } + $this->getResponse()->setBody($this->_objectManager->get('Mage_Core_Helper_Data')->jsonEncode($response)); + } + + /** + * VDE quit action + */ + public function quitAction() + { + /** @var $state Mage_DesignEditor_Model_State */ + $state = $this->_objectManager->get('Mage_DesignEditor_Model_State'); + $state->reset(); + + /** @var $eventDispatcher Mage_Core_Model_Event_Manager */ + $eventDispatcher = $this->_objectManager->get('Mage_Core_Model_Event_Manager'); + $eventDispatcher->dispatch('design_editor_deactivate'); + + $this->_redirect('*/*/'); + } + + /** + * Assign theme to list of store views + */ + public function assignThemeToStoreAction() + { + $themeId = $this->getRequest()->getParam('theme_id'); + $stores = $this->getRequest()->getParam('stores'); + + /** @var $coreHelper Mage_Core_Helper_Data */ + $coreHelper = $this->_objectManager->get('Mage_Core_Helper_Data'); + + try { + if (!is_numeric($themeId)) { + throw new InvalidArgumentException('Theme id is not valid'); + } + + //TODO used until we find a way to convert array to JSON on JS side + $defaultStore = -1; + $emptyStores = -2; + if ($stores == $defaultStore) { + $ids = array_keys(Mage::app()->getStores()); + $stores = array(array_shift($ids)); + } elseif ($stores == $emptyStores) { + $stores = array(); + } + + if (!is_array($stores)) { + throw new InvalidArgumentException('Param "stores" is not valid'); + } + + /** @var $themeService Mage_Core_Model_Theme_Service */ + $themeService = $this->_objectManager->get('Mage_Core_Model_Theme_Service'); + /** @var $themeCustomization Mage_Core_Model_Theme */ + $themeCustomization = $themeService->assignThemeToStores($themeId, $stores); + + $message = $coreHelper->__('Theme successfully assigned'); + $response = array( + 'success' => $message, + 'themeId' => $themeCustomization->getId() + ); + $this->getResponse()->setBody($coreHelper->jsonEncode(array('success' => $message))); + } catch (Exception $e) { + $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); + $this->getResponse()->setBody($coreHelper->jsonEncode( + array('error' => $this->_helper->__('Theme is not assigned')) + )); + $response = array( + 'error' => true, + 'message' => $this->_helper->__('Theme is not assigned') + ); + } + $this->getResponse()->setBody($coreHelper->jsonEncode($response)); + } + + /** + * Rename title action + */ + public function quickEditAction() + { + $themeId = (int)$this->getRequest()->getParam('theme_id'); + $themeTitle = (string)$this->getRequest()->getParam('theme_title'); + + /** @var $coreHelper Mage_Core_Helper_Data */ + $coreHelper = $this->_objectManager->get('Mage_Core_Helper_Data'); + /** @var $helper Mage_Core_Helper_Theme */ + $helper = $this->_objectManager->get('Mage_Core_Helper_Theme'); + try { + /** @var $theme Mage_Core_Model_Theme */ + $theme = $helper->loadEditableTheme($themeId); + $theme->setThemeTitle($themeTitle); + $theme->save(); + $response = array('success' => true); + } catch (Mage_Core_Exception $e) { + $response = array('error' => true, 'message' => $e->getMessage()); + } catch (Exception $e) { + $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); + $response = array('error' => true, 'message' => $this->__('Theme is not saved')); + } + $this->getResponse()->setBody($coreHelper->jsonEncode($response)); + } + + /** + * Get layout xml + */ + public function getLayoutUpdateAction() + { + $historyData = Mage::app()->getRequest()->getPost('historyData'); + if (!$historyData) { + $this->getResponse()->setBody(Mage::helper('Mage_Core_Helper_Data')->jsonEncode( + array(Mage_Core_Model_Message::ERROR => array($this->__('Invalid post data'))) + )); + return; + } + + /** @var $coreHelper Mage_Core_Helper_Data */ + $coreHelper = $this->_objectManager->get('Mage_Core_Helper_Data'); + + try { + $layoutUpdate = $this->_compactHistory($historyData); + $response = array(Mage_Core_Model_Message::SUCCESS => array($layoutUpdate)); + } catch (Mage_Core_Exception $e) { + $response = array(Mage_Core_Model_Message::ERROR => array($e->getMessage())); + } + $this->getResponse()->setBody($coreHelper->jsonEncode($response)); + } + + /** + * Save temporary layout update + */ + public function saveTemporaryLayoutUpdateAction() + { + $themeId = (int)$this->_getSession()->getData('theme_id'); + /** @var $coreHelper Mage_Core_Helper_Data */ + $coreHelper = $this->_objectManager->get('Mage_Core_Helper_Data'); + + try { + if (!is_numeric($themeId)) { + throw new InvalidArgumentException('Theme id is not valid'); + } + + if ($this->getRequest()->has('layoutUpdate')) { + $this->_saveLayoutUpdate( + $this->getRequest()->getParam('layoutUpdate'), + $this->getRequest()->getParam('handle'), + $themeId, + true + ); + } + $response = array('success' => $this->__('Temporary layout update saved')); + } catch (Exception $e) { + $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); + $response = array('error' => $this->__('Temporary layout update not saved')); + } + $this->getResponse()->setBody($coreHelper->jsonEncode($response)); + } + + /** + * Display available theme list. Only when no customized themes + */ + public function firstEntranceAction() + { + $this->_doSelectionTheme('index'); + } + + /** + * Simple Theme preview + */ + public function previewAction() + { + $this->launchAction(); + } + + /** + * Apply changes from 'staging' theme to 'virtual' theme + */ + public function saveAction() + { + $themeId = (int)$this->getRequest()->getParam('theme_id'); + /** @var $coreHelper Mage_Core_Helper_Data */ + $coreHelper = $this->_objectManager->get('Mage_Core_Helper_Data'); + /** @var $helper Mage_Core_Helper_Theme */ + $helper = $this->_objectManager->get('Mage_Core_Helper_Theme'); + try { + $theme = $helper->loadEditableTheme($themeId) + ->getDomainModel(Mage_Core_Model_Theme::TYPE_VIRTUAL) + ->getStagingTheme(); + $this->_saveLayoutUpdate( + $this->getRequest()->getParam('layoutUpdate', array()), + $this->getRequest()->getParam('handle'), + $theme->getId() + ); + $theme->getDomainModel(Mage_Core_Model_Theme::TYPE_STAGING)->updateFromStagingTheme(); + $response = array('message' => $this->_helper->__('All changes applied')); + } catch (Exception $e) { + $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); + $response = array('error' => true, 'message' => $this->_helper->__('Unknown error')); + } + $this->getResponse()->setBody($coreHelper->jsonEncode($response)); + } + + /** + * Set page title + */ + protected function _setTitle() + { + $this->_title($this->__('System'))->_title($this->__('Design'))->_title($this->__('Editor')); + } + + /** + * Whether the current user has enough permissions to execute an action + * + * @return bool + */ + protected function _isAllowed() + { + return $this->_objectManager->get('Mage_Core_Model_Authorization')->isAllowed('Mage_DesignEditor::editor'); + } + + /** + * Compact history + * + * @param array $layoutUpdate + * @param string|null $xml + * @return string + */ + protected function _compactHistory($layoutUpdate, $xml = null) + { + /** @var $historyModel Mage_DesignEditor_Model_History */ + $historyModel = $this->_objectManager->create('Mage_DesignEditor_Model_History'); + /** @var $historyCompactModel Mage_DesignEditor_Model_History_Compact */ + $historyCompactModel = $this->_objectManager->create('Mage_DesignEditor_Model_History_Compact'); + /** @var $layoutRenderer Mage_DesignEditor_Model_History_Renderer_LayoutUpdate */ + $layoutRenderer = $this->_objectManager->create('Mage_DesignEditor_Model_History_Renderer_LayoutUpdate'); + /** @var $collection Mage_DesignEditor_Model_Change_Collection */ + $collection = $historyModel->addXmlChanges($xml) + ->addChanges($layoutUpdate) + ->getChanges(); + $historyCompactModel->compact($collection); + $layoutUpdate = $historyModel->output($layoutRenderer, + Mage_DesignEditor_Model_History_Renderer_LayoutUpdate::DEFAULT_HANDLE + ); + + return $layoutUpdate; + } + + /** + * Save layout update + * + * @param array $layoutUpdate + * @param string $handle + * @param int $themeId + * @param bool $isTemporary + */ + protected function _saveLayoutUpdate($layoutUpdate, $handle, $themeId, $isTemporary = false) + { + /** @var $layoutCollection Mage_DesignEditor_Model_Resource_Layout_Update_Collection */ + $layoutCollection = $this->_objectManager + ->create('Mage_DesignEditor_Model_Resource_Layout_Update_Collection'); + $layoutCollection->addStoreFilter(Mage_Core_Model_AppInterface::ADMIN_STORE_ID) + ->addThemeFilter($themeId) + ->addFieldToFilter('handle', $handle) + ->addFieldToFilter('is_vde', true) + ->setOrder('sort_order', Varien_Data_Collection_Db::SORT_ORDER_ASC); + + $xml = ''; + if (!$isTemporary) { + /** @var $item Mage_DesignEditor_Model_Layout_Update */ + foreach ($layoutCollection as $item) { + $xml .= $item->getXml(); + } + } + + if ($xml || $layoutUpdate) { + $layoutUpdateData = array( + 'store_id' => Mage_Core_Model_AppInterface::ADMIN_STORE_ID, + 'theme_id' => $themeId, + 'handle' => $handle, + 'xml' => $this->_compactHistory($layoutUpdate, $xml), + 'is_temporary' => $isTemporary + ); + + if ($isTemporary) { + /** @var $layoutUpdateModel Mage_DesignEditor_Model_Layout_Update */ + $layoutUpdateModel = $layoutCollection->getLastItem(); + $sortOrder = 0; + if ($layoutUpdateModel->getId()) { + $sortOrder = $layoutUpdateModel->getSortOrder() + 1; + } + $layoutUpdateData['sort_order'] = $sortOrder; + $layoutUpdateModel->setData($layoutUpdateData); + } else { + /** @var $layoutUpdateModel Mage_DesignEditor_Model_Layout_Update */ + $layoutUpdateModel = $layoutCollection->getFirstItem(); + $layoutUpdateModel->addData($layoutUpdateData); + + /** @var @item Mage_DesignEditor_Model_Layout_Update */ + foreach ($layoutCollection as $item) { + if ($item->getId() != $layoutUpdateModel->getId()) { + $item->delete(); + } + } + } + $layoutUpdateModel->save(); + } + } + + /** + * Get theme customization + * + * @param Mage_Core_Model_Theme $theme + * @return Mage_Core_Model_Theme + */ + protected function _getThemeCustomization($theme) + { + /** @var $service Mage_Core_Model_Theme_Service */ + $service = $this->_objectManager->get('Mage_Core_Model_Theme_Service'); + return $service->createThemeCustomization($theme); + } + + /** + * Pass data to the Tools panel blocks that is needed it for rendering + * + * @param Mage_Core_Model_Theme $theme + * @param int $mode + * @return Mage_DesignEditor_Adminhtml_System_Design_EditorController + */ + protected function _configureToolsBlocks($theme, $mode) + { + /** @var $toolsBlock Mage_DesignEditor_Block_Adminhtml_Editor_Tools */ + $toolsBlock = $this->getLayout()->getBlock('design_editor_tools'); + if ($toolsBlock) { + $toolsBlock->setMode($mode); + } + + /** @var $customTabBlock Mage_DesignEditor_Block_Adminhtml_Editor_Tools_Code_Custom */ + $customTabBlock = $this->getLayout()->getBlock('design_editor_tools_code_custom'); + if ($customTabBlock) { + $theme->setCustomization($this->_objectManager->create('Mage_Core_Model_Theme_Customization_Files_Css')); + $customTabBlock->setTheme($theme); + } + + /** @var $customTabBlock Mage_DesignEditor_Block_Adminhtml_Editor_Tools_Code_Custom */ + $customTabBlock = $this->getLayout()->getBlock('design_editor_tools_code_custom'); + if ($customTabBlock) { + $theme->setCustomization($this->_objectManager->create('Mage_Core_Model_Theme_Customization_Files_Css')); + $customTabBlock->setTheme($theme); + } + + /** @var $cssTabBlock Mage_DesignEditor_Block_Adminhtml_Editor_Tools_Code_Css */ + $cssTabBlock = $this->getLayout()->getBlock('design_editor_tools_code_css'); + if ($cssTabBlock) { + /** @var $helper Mage_Core_Helper_Theme */ + $helper = $this->_objectManager->get('Mage_Core_Helper_Theme'); + $cssFiles = $helper->getGroupedCssFiles($theme); + $cssTabBlock->setCssFiles($cssFiles) + ->setThemeId($theme->getId()); + } + + /** @var $jsTabBlock Mage_DesignEditor_Block_Adminhtml_Editor_Tools_Code_Js */ + $jsTabBlock = $this->getLayout()->getBlock('design_editor_tools_code_js'); + if ($jsTabBlock) { + /** @var $jsFileModel Mage_Core_Model_Theme_Customization_Files_Js */ + $jsFileModel = $this->_objectManager->create('Mage_Core_Model_Theme_Customization_Files_Js'); + $theme->setCustomization($jsFileModel); + + $jsTabBlock->setTheme($theme); + } + + $blocks = array( + 'design_editor_tools_code_image_sizing', + 'design_editor_tools_quick-styles_header', + 'design_editor_tools_quick-styles_backgrounds', + 'design_editor_tools_quick-styles_buttons', + 'design_editor_tools_quick-styles_tips', + 'design_editor_tools_quick-styles_fonts', + ); + foreach ($blocks as $blockName) { + /** @var $block Mage_Core_Block_Abstract */ + $block = $this->getLayout()->getBlock($blockName); + if ($block) { + $block->setTheme($theme); + } + } + + return $this; + } + + /** + * Pass data to the Toolbar panel blocks that is needed for rendering + * + * @param Mage_Core_Model_Theme $theme + * @param Mage_Core_Model_Theme $editableTheme + * @param int $mode + * @return Mage_DesignEditor_Adminhtml_System_Design_EditorController + */ + protected function _configureToolbarBlocks($theme, $editableTheme, $mode) + { + /** @var $toolbarBlock Mage_DesignEditor_Block_Adminhtml_Editor_Toolbar_Buttons */ + $toolbarBlock = $this->getLayout()->getBlock('design_editor_toolbar_buttons'); + $toolbarBlock->setThemeId($editableTheme->getId())->setVirtualThemeId($theme->getId()) + ->setMode($mode); + + /** @var $saveButtonBlock Mage_DesignEditor_Block_Adminhtml_Editor_Toolbar_Buttons_Save */ + $saveButtonBlock = $this->getLayout()->getBlock('design_editor_toolbar_buttons_save'); + if ($saveButtonBlock) { + $saveButtonBlock->setTheme($theme) + ->setMode($mode); + } + + /** @var $hierarchyBlock Mage_DesignEditor_Block_Adminhtml_Editor_Toolbar_HandlesHierarchy */ + $hierarchyBlock = $this->getLayout()->getBlock('design_editor_toolbar_handles_hierarchy'); + if ($hierarchyBlock) { + $customLayoutParams = array('area' => Mage_Core_Model_App_Area::AREA_FRONTEND); + + /** @var $customFrontLayout Mage_Core_Model_Layout_Merge */ + $customFrontLayout = $this->_objectManager->create('Mage_Core_Model_Layout_Merge', + array('arguments' => $customLayoutParams) + ); + $pageTypes = $customFrontLayout->getPageHandlesHierarchy(); + $hierarchyBlock->setHierarchy($pageTypes) + ->setMode($mode); + } + + /** @var $viewOptionsBlock Mage_DesignEditor_Block_Adminhtml_Editor_Toolbar_ViewOptions */ + $viewOptionsBlock = $this->getLayout()->getBlock('design_editor_toolbar_view_options'); + if ($viewOptionsBlock) { + $viewOptionsBlock->setMode($mode); + } + + return $this; + } + + /** + * @param Mage_Core_Model_Theme $editableTheme + * @param int $mode + * @return Mage_DesignEditor_Adminhtml_System_Design_EditorController + */ + protected function _configureEditorBlock($editableTheme, $mode) + { + /** @var $editorBlock Mage_DesignEditor_Block_Adminhtml_Editor_Container */ + $editorBlock = $this->getLayout()->getBlock('design_editor'); + if ($mode == Mage_DesignEditor_Model_State::MODE_NAVIGATION) { + $currentUrl = $this->_getCurrentUrl(); + } else { + $currentUrl = $this->_getCurrentHandleUrl(); + } + $editorBlock->setFrameUrl($currentUrl); + $editorBlock->setTheme($editableTheme); + + return $this; + } + + /** + * Check whether is customized themes in database + * + * @return bool + */ + protected function _isFirstEntrance() + { + /** @var $themeService Mage_Core_Model_Theme_Service */ + $themeService = $this->_objectManager->get('Mage_Core_Model_Theme_Service'); + return !$themeService->isCustomizationsExist(); + } + + /** + * Load layout + * + * @param string $forwardAction + */ + protected function _doSelectionTheme($forwardAction) + { + if ($forwardAction == 'index' xor $this->_isFirstEntrance()) { + $this->_forward($forwardAction); + return; + } + + try { + $this->_setTitle(); + $this->loadLayout(); + $this->_setActiveMenu('Mage_DesignEditor::system_design_editor'); + if (!$this->_isFirstEntrance()) { + /** @var $themeService Mage_Core_Model_Theme_Service */ + $themeService = $this->_objectManager->get('Mage_Core_Model_Theme_Service'); + $this->getLayout()->getBlock('assigned.theme.list')->setCollection( + $themeService->getAssignedThemeCustomizations() + ); + $this->getLayout()->getBlock('unassigned.theme.list')->setCollection( + $themeService->getUnassignedThemeCustomizations() + ); + } + /** @var $storeViewBlock Mage_DesignEditor_Block_Adminhtml_Theme_Selector_StoreView */ + $storeViewBlock = $this->getLayout()->getBlock('theme.selector.storeview'); + $storeViewBlock->setData('redirectOnAssign', true); + $this->renderLayout(); + } catch (Exception $e) { + $this->_getSession()->addError($this->__('Cannot load list of themes.')); + $this->_redirectUrl($this->_getRefererUrl()); + $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); + } + } + + /** + * Get current handle + * + * @return string + */ + protected function _getCurrentHandleUrl() + { + /** @var $vdeUrlModel Mage_DesignEditor_Model_Url_Handle */ + $vdeUrlModel = $this->_objectManager->get('Mage_DesignEditor_Model_Url_Handle'); + $handle = $this->_getSession()->getData(Mage_DesignEditor_Model_State::CURRENT_HANDLE_SESSION_KEY); + if (empty($handle)) { + $handle = 'default'; + } + + return $vdeUrlModel->getUrl('design/page/type', array('handle' => $handle)); + } + + /** + * Get current url + * + * @return string + */ + protected function _getCurrentUrl() + { + /** @var $vdeUrlModel Mage_DesignEditor_Model_Url_NavigationMode */ + $vdeUrlModel = $this->_objectManager->get('Mage_DesignEditor_Model_Url_NavigationMode'); + $url = $this->_getSession()->getData(Mage_DesignEditor_Model_State::CURRENT_URL_SESSION_KEY); + if (empty($url)) { + $url = ''; + } + + return $vdeUrlModel->getUrl(ltrim($url, '/')); + } +} diff --git a/app/code/core/Mage/DesignEditor/controllers/PageController.php b/app/code/Mage/DesignEditor/controllers/PageController.php similarity index 100% rename from app/code/core/Mage/DesignEditor/controllers/PageController.php rename to app/code/Mage/DesignEditor/controllers/PageController.php diff --git a/app/code/Mage/DesignEditor/etc/adminhtml/acl.xml b/app/code/Mage/DesignEditor/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..b2f921c7431fe --- /dev/null +++ b/app/code/Mage/DesignEditor/etc/adminhtml/acl.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + diff --git a/app/code/Mage/DesignEditor/etc/adminhtml/menu.xml b/app/code/Mage/DesignEditor/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..be865c098168b --- /dev/null +++ b/app/code/Mage/DesignEditor/etc/adminhtml/menu.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/app/code/Mage/DesignEditor/etc/config.xml b/app/code/Mage/DesignEditor/etc/config.xml new file mode 100644 index 0000000000000..f1089b8730e75 --- /dev/null +++ b/app/code/Mage/DesignEditor/etc/config.xml @@ -0,0 +1,180 @@ + + + + + + 1.0.0.1 + true + + + + + + + + + + + Mage_DesignEditor + Mage_Core_Model_Resource_Setup + + + + + + + + Mage_DesignEditor_Model_Observer + saveQuickStyles + + + + + + + + + + frontend + Mage_DesignEditor_Controller_Varien_Router_Standard + Mage_Core_Controller_Varien_Action + + + + + + + + + layout.xml + + + + + + standard + + Mage_DesignEditor + design + + + + + + + + + layout.xml + + + + + + + vde + default + + + + + + + 5 + + + + Mage_Core_Block_Template + Mage_Page_Block_ + Mage_DesignEditor_Block_ + Mage_Checkout_Block_Onepage_ + Mage_Customer_Block_Account_Navigation + Mage_Paypal_Block_Express_Review_Details + Mage_Poll_Block_ActivePoll + Mage_Sales_Block_Guest_Links + Mage_Catalog_Block_Product_Compare_Sidebar + Mage_Checkout_Block_Cart_Sidebar + Mage_Wishlist_Block_Customer_Sidebar + Mage_Reports_Block_Product_Viewed + Mage_Reports_Block_Product_Compared + Mage_Sales_Block_Reorder_Sidebar + Mage_Paypal_Block_Express_Shortcut + Mage_PaypalUk_Block_Express_Shortcut + + + Mage_Page_Block_Html_Pager + Mage_Page_Block_Switch + + + + + root + head + after_body_start +
    header
    +
    footer
    + before_body_end + top.links + top.menu +
    +
    +
    + + + + + Mage_DesignEditor_Model_Observer + clearJs + + + + +
    + + + + + + Mage_DesignEditor_Adminhtml + + + + + + + + + + 0 0 * * * + + + Mage_DesignEditor_Model_Observer::clearLayoutUpdates + + + + +
    diff --git a/app/code/Mage/DesignEditor/etc/image_sizing.xsd b/app/code/Mage/DesignEditor/etc/image_sizing.xsd new file mode 100644 index 0000000000000..cecf6f1a2d4ef --- /dev/null +++ b/app/code/Mage/DesignEditor/etc/image_sizing.xsd @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/core/Mage/DesignEditor/etc/jstranslator.xml b/app/code/Mage/DesignEditor/etc/jstranslator.xml similarity index 100% rename from app/code/core/Mage/DesignEditor/etc/jstranslator.xml rename to app/code/Mage/DesignEditor/etc/jstranslator.xml diff --git a/app/code/Mage/DesignEditor/etc/quick_styles.xsd b/app/code/Mage/DesignEditor/etc/quick_styles.xsd new file mode 100644 index 0000000000000..b0b0d963265d9 --- /dev/null +++ b/app/code/Mage/DesignEditor/etc/quick_styles.xsd @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/core/Mage/DesignEditor/sql/designeditor_setup/install-1.0.0.1.php b/app/code/Mage/DesignEditor/sql/designeditor_setup/install-1.0.0.1.php similarity index 100% rename from app/code/core/Mage/DesignEditor/sql/designeditor_setup/install-1.0.0.1.php rename to app/code/Mage/DesignEditor/sql/designeditor_setup/install-1.0.0.1.php diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/MUI-Icons.eot b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/MUI-Icons.eot old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/MUI-Icons.eot rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/MUI-Icons.eot diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/MUI-Icons.svg b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/MUI-Icons.svg old mode 100755 new mode 100644 similarity index 99% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/MUI-Icons.svg rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/MUI-Icons.svg index 316f9b877c05d..3ec05eb706881 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/MUI-Icons.svg +++ b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/MUI-Icons.svg @@ -1,671 +1,671 @@ - - - - -This is a custom SVG font generated by IcoMoon. -0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + +This is a custom SVG font generated by IcoMoon. +0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/MUI-Icons.ttf b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/MUI-Icons.ttf old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/MUI-Icons.ttf rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/MUI-Icons.ttf diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/MUI-Icons.woff b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/MUI-Icons.woff old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/MUI-Icons.woff rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/MUI-Icons.woff diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBlack-webfont.eot b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBlack-webfont.eot old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBlack-webfont.eot rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBlack-webfont.eot diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansBlack-webfont.svg b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBlack-webfont.svg similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansBlack-webfont.svg rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBlack-webfont.svg diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBlack-webfont.ttf b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBlack-webfont.ttf old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBlack-webfont.ttf rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBlack-webfont.ttf diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBlack-webfont.woff b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBlack-webfont.woff old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBlack-webfont.woff rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBlack-webfont.woff diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBold-webfont.eot b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBold-webfont.eot old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBold-webfont.eot rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBold-webfont.eot diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansBold-webfont.svg b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBold-webfont.svg similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansBold-webfont.svg rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBold-webfont.svg diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBold-webfont.ttf b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBold-webfont.ttf old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBold-webfont.ttf rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBold-webfont.ttf diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBold-webfont.woff b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBold-webfont.woff old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBold-webfont.woff rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBold-webfont.woff diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansLight-webfont.eot b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansLight-webfont.eot old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansLight-webfont.eot rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansLight-webfont.eot diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansLight-webfont.svg b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansLight-webfont.svg similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansLight-webfont.svg rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansLight-webfont.svg diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansLight-webfont.ttf b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansLight-webfont.ttf old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansLight-webfont.ttf rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansLight-webfont.ttf diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansLight-webfont.woff b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansLight-webfont.woff old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansLight-webfont.woff rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansLight-webfont.woff diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansRegular-webfont.eot b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansRegular-webfont.eot old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansRegular-webfont.eot rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansRegular-webfont.eot diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansRegular-webfont.svg b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansRegular-webfont.svg similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansRegular-webfont.svg rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansRegular-webfont.svg diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansRegular-webfont.ttf b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansRegular-webfont.ttf old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansRegular-webfont.ttf rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansRegular-webfont.ttf diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansRegular-webfont.woff b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansRegular-webfont.woff old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansRegular-webfont.woff rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansRegular-webfont.woff diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansSemiBold-webfont.eot b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansSemiBold-webfont.eot old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansSemiBold-webfont.eot rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansSemiBold-webfont.eot diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansSemiBold-webfont.svg b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansSemiBold-webfont.svg similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansSemiBold-webfont.svg rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansSemiBold-webfont.svg diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansSemiBold-webfont.ttf b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansSemiBold-webfont.ttf old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansSemiBold-webfont.ttf rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansSemiBold-webfont.ttf diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansSemiBold-webfont.woff b/app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansSemiBold-webfont.woff old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansSemiBold-webfont.woff rename to app/code/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansSemiBold-webfont.woff diff --git a/app/code/Mage/DesignEditor/view/adminhtml/css/styles.css b/app/code/Mage/DesignEditor/view/adminhtml/css/styles.css new file mode 100644 index 0000000000000..2412df46b9df1 --- /dev/null +++ b/app/code/Mage/DesignEditor/view/adminhtml/css/styles.css @@ -0,0 +1,1977 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category design + * @package Mage_DesignEditor + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +/* + Actions look like links +-------------------------------------- */ +#store-view-window .action-close { + background: none; + border: none; + color: #6d665e; + font-weight: normal; + font-size: 12px; + cursor: pointer; + border-bottom: 1px solid #b5b3af; +} + +#store-view-window .action-close:hover { + color: #000; + border-bottom: 1px solid #000; +} + +/* + Themes Inputs +-------------------------------------- */ +.theme input[type=text] { + font: 13px/18px Arial, Helvetica, sans-serif; + display: inline-block; + height: 28px; + padding: 4px 4px; + margin: 0 0 8px; + color: #333; + background-color: #fff; + border: 1px solid #ccc; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; + border-radius: 3px; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -webkit-transition: border linear 0.2s, box-shadow linear 0.2s; + -moz-transition: border linear 0.2s, box-shadow linear 0.2s; + -ms-transition: border linear 0.2s, box-shadow linear 0.2s; + -o-transition: border linear 0.2s, box-shadow linear 0.2s; + transition: border linear 0.2s, box-shadow linear 0.2s; +} + +.theme input[type=text]:focus { + border-color: rgba(82, 168, 236, 0.8); + outline: 0; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6); +} + +/* + Popups +-------------------------------------- */ +.fade { + display: none; + position: fixed; + left: 0; + top: 0; + right: 0; + bottom: 0; + background-color: rgba(0, 0, 0, .45); + padding: 15%; + z-index: 999; +} + +.no-rgba .fade { + background-color: #afafaf; +} + +.fade .popup { + position: absolute; + left: 35%; + right: 35%; + display: inline-block; + padding: 0; + background: #fff; + font-size: 13px; + min-width: 440px; + box-shadow: 0 2px 10px 0 #333; + border: 0; + border-radius: 0; +} + +.fade .popup-header { + color: #676056; + padding: 18px 50px 18px 24px; + background: #f3efea; +} + +.fade .popup .popup-title { + font: 20px/1 'CallunaSans', Arial, sans-serif; + font-weight: 300; + padding-left: 0; +} + +.fade .popup .actions { + margin: 15px 0 0; +} + +.fade .popup .actions button, +.fade .popup .actions [class^="action-"] { + margin-right: 10px; + vertical-align: baseline; +} + +.fade .popup-footer { + padding: 24px; +} + +.action-close-popup { + position: absolute; + top: 20px; + right: 15px; + width: 20px; + height: 20px; + overflow: hidden; + text-indent: -999em; + cursor: pointer; +} + +.action-close-popup:before { + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: '\e07d'; /* close icon */ + font-size: 16px; + color: #676056; + position: absolute; + right: 0; + top: 0; + text-indent: 0; +} + +.action-close-popup:hover:before { + color: #000; +} + +/* + Infinite Scroll +-------------------------------------- */ +.infinite_scroll { + position: relative; + max-width: 1300px; + height: 100%; + margin: 0 auto; +} + +/* + Theme Loader +-------------------------------------- */ +.theme-loader { + width: 75px; + height: 75px; + border: 1px solid #f98e4e; + position: fixed; + left: 50%; + top: 50%; + margin: -50px 0 0 -50px; + background-color: rgba(255, 255, 255, .8); + text-align: center; + line-height: 100px; +} + +.eq-ie8 .theme-loader { + background: #fff; +} + +[class^=' adminhtml-system-design-editor'] .col-1-layout { + padding: 0; + min-width: 960px; + max-width: 1300px; +} + +.eq-ie8 [class^=' adminhtml-system-design-editor'] .col-1-layout { + border-top: 0; + border-bottom: 0; +} + +.eq-ie8 [class^=' adminhtml-system-design-editor'] .ui-tabs-panel { + border-bottom: 1px solid #b7b2a6; +} + +.eq-ie8 [class^=' adminhtml-system-design-editor'] #theme_selector_tabs { + border-top: 1px solid #b7b2a6; +} + +/* + Themes Tabs +-------------------------------------- */ + +#theme_selector_tabs { +} + +#theme_selector_tabs .tabs-horiz { + background: none; + border: 0; + padding: 9px 9px 0; + border-bottom: 1px solid #beb8af; +} + +#theme_selector_tabs .tabs-horiz > li { + margin-right: 4px; + border: 1px solid #beb8af; + border-bottom-width: 0; + border-radius: 5px 5px 0 0; +} + +#theme_selector_tabs .tabs-horiz > li a { + background: #dbd6ce; + font-size: 15px; + color: #524c44; + border-radius: 5px 5px 0 0; + padding: 10px 18px 11px; +} + +#theme_selector_tabs .tabs-horiz > .ui-state-active { + border-bottom: 1px solid #fff; + margin-bottom: -1px; +} + +#theme_selector_tabs .tabs-horiz > .ui-state-active a { + background: #fff; + border: 0; + box-shadow: none; +} + +/* + Themes Tabs Panel +-------------------------------------- */ +.theme-selector { + overflow: auto; +} + +.theme-selector .ui-tabs-panel { + padding: 60px 40px 20px; + background: #fff; + border-radius: 0 0 5px 5px; + min-height: 500px; +} + +/* + Themes +-------------------------------------- */ +.themes { + padding: 0; + list-style: none; + overflow: hidden; +} + +.theme { + position: relative; + width: 47%; + float: left; + margin: 0 6% 6% 0; +} + +.theme:nth-child(even) { + margin-right: 0; +} + +.eq-ie8 .theme { + margin-right: 3%; +} + +.theme-content { + position: relative; + border: 1px solid #c1beb7; + background: #f8f8f8; + text-align: center; + min-height: 325px; + overflow: hidden; +} + +.theme-content .theme-preview-image { + width: 100%; + margin-bottom: -20%; +} + +.theme-data { + position: absolute; + left: 0; + top: 0; + right: 0; + bottom: 0; + opacity: 0; + text-align: left; + color: #f2ebde; + padding: 10% 40px 0; + background: #242320; + background: -moz-linear-gradient(top, #31302b 0%, #1f1e1c 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #31302b), color-stop(100%, #1f1e1c)); + background: -webkit-linear-gradient(top, #31302b 0%, #1f1e1c 100%); + background: -ms-linear-gradient(top, #31302b 0%, #1f1e1c 100%); + background: linear-gradient(to bottom, #31302b 0%, #1f1e1c 100%); +} + +.theme-data:hover { + -webkit-transition: opacity .35s ease; + -moz-transition: opacity .35s ease; + -ms-transition: opacity .35s ease; + transition: opacity .35s ease; + opacity: 1; +} + +.eq-ie8 .theme-data, +.eq-ie8 .themes-assigned .theme-content:hover .theme-data { + display: none; +} + +.eq-ie8 .theme-content:hover .theme-data { + display: block; +} + +.theme-title { + margin: 0; + color: #f2ebde; + font-family: 'CallunaSans', Arial, sans-serif; + font-weight: 200; + font-size: 24px; +} + +.theme-data p { + max-height: 50%; + margin: 20px 0 30px 0; + font: 14px/1.5 Arial, Helvetica, sans-serif; + color: #B9B4AA; + overflow: hidden; +} + +.theme-data .actions { + text-align: right; + position: absolute; + bottom: 30px; + left: 40px; + right: 40px; + white-space: nowrap; +} + +.theme-data .actions [class^='action-'] { + margin-left: 5px; +} + +.theme-data .action-edit, +.theme-data .action-delete, +.theme-data .action-edit:active, +.theme-data .action-delete:active { + background: none; + border: none; + text-decoration: none; + display: inline-block; + box-shadow: none; + color: #fff; + font-size: 16px; + vertical-align: middle; + padding: 5px; +} + +.theme-data .action-edit:before, +.theme-data .action-delete:before { + display: inline-block; + text-indent: 0; + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: "\e05b"; + color: #fff; +} + +.theme-data .actions .action-delete { + margin-left: 0; +} + +.theme-data .action-delete:before { + content: "\e07f"; +} + +.theme-data .action-edit > span, +.theme-data .action-delete > span { + display: none; +} + +/* + My Customizations Tab +-------------------------------------- */ +.themes-customizations h3 { + font-size: 24px; + margin-bottom: 30px; + border-bottom: 1px solid #ededed; + padding-bottom: 8px; +} + +.themes-customizations .action-theme-assign { + background: #dbd6ce; + color: #322e2a; +} + +.themes-customizations .action-theme-assign:hover { + background: #cac2b5; + color: #322e2a; + text-shadow: none; +} + +.themes-customizations .action-theme-assign:active { + box-shadow: 0 1px 5px #aaa59b inset; +} + +/* + Assigned Themes +-------------------------------------- */ +.themes-assigned .theme { + float: none; + width: 100%; +} + +.themes-assigned .theme-content, +.themes-assigned .theme-assigned-data { + float: left; + width: 47%; +} + +.themes-assigned .theme-assigned-data { + width: 45%; + width: 45%; +} + +.themes-assigned .theme-content { + margin-right: 5%; +} + +.themes-assigned .theme-data { + display: none; +} + +.theme-assigned-data { + position: relative; + margin: 10% 0 0 2%; +} + +.theme-assigned-data .theme-title { + font: 24px/1 Arial, Verdans, sans-serif; + color: #676056; + margin-bottom: 11px; +} + +.theme-assigned-data .edit-theme-title { + font-size: 14px; + color: #19a3d1; + cursor: pointer; +} + +.theme-assigned-to-storeview { + font-size: 14px; + color: #676056; + margin: 22px 0 26px; +} + +.theme-assigned-to-storeview span { + color: #959393; +} + +.theme-assigned-data .action-edit { + background: #f47b20; + color: #fff; +} + +.theme-assigned-data .action-edit:hover { + background: #e2701a; + color: #fff; + text-shadow: 0 -1px 2px #955326; +} + +.theme-assigned-data .action-edit:active { + box-shadow: 0 1px 5px #955326 inset; +} + +/* + Theme Title Quick Save Form +-------------------------------------- */ +.edit-theme-title-form { + display: none; +} + +.edit-theme-title-form > input[type="text"] { + width: 238px; +} + +.themes-assigned .edit-theme-title-form { + margin-bottom: -1px; +} + +/* + Websites/Stores/Storeviews List in Popup +-------------------------------------- */ +.websites, +.stores, +.storeviews { + margin: 0; + padding: 0; + list-style: none; +} + +.website { + padding: 10px 0 0; +} + +.website-title, +.store-title { + border-bottom: 1px solid #dfdfdf; + padding: 0 24px 5px; +} + +.store-title { + padding-left: 40px; +} + +.storeview { + padding-left: 60px; + margin: 0 0 5px 0; +} + +.storeview-selector-control { + margin: -3px 3px 0 0; +} + +/* + Tools Panel +-------------------------------------- */ +.vde-tools { + background: #060708; + color: #fff; + position: fixed; + left: 0; + bottom: 0; + right: 0; + padding: 0 0 52px; + z-index: 900; +} + +.vde-tools-header { + position: absolute; + left: 0; + right: 0; + top: 0; + height: 52px; + background: #32312C; +} + +.vde-tools-header-inner, +.vde-tab-data, +.vde-tab-content-header, +.vde-tools-handler-container, +.vde-tools-footer-inner { + min-width: 1000px; + max-width: 1300px; + margin: 0 auto; +} + +.vde-tools-header-inner, +.vde-tools-footer-inner { + position: relative; +} + +.vde-tools.opened .vde-tools-header:before, +.vde-tools.opened .vde-tools-footer:before, +.custom-code .textarea-container:before, +.custom-code .textarea-container:after { + position: absolute; + left: 0; + top: 52px; + right: 20px; + height: 10px; + background: url(Mage_DesignEditor::images/vde-panel-top-shadow.png) repeat-x; + content: ''; + z-index: 6; +} + +.vde-tools.opened .vde-tools-footer:before, +.custom-code .textarea-container:after { + top: -10px; + background-position: 0 -10px; +} + +.vde-tools-header .action-close { + position: absolute; + top: 17px; + right: 0; + background: none; + border: none; + font-weight: normal; + cursor: pointer; + color: #f2ebde; + z-index: 2; +} + +.eq-ie8 .vde-tools-header .action-close { + top: 12px; +} + +.vde-tools-header .action-close:hover { + color: #fff; +} + +.vde-tools-header .action-close span { + display: none; +} + +.vde-tools-header .action-close:before { + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: '\e061'; /* close icon */ + font-size: 20px; +} + +.vde-tools-content { + position: relative; + width: auto !important; + left: 0; + right: 0; + height: 0; + overflow: hidden; +} + +.vde-tools-footer { + position: absolute; + bottom: 0; + left: 0; + right: 0; + background: #32312C; + height: 52px; + z-index: 1001; +} + +.vde-tab-content-inner.hasScroll { + overflow-y: scroll; +} + +.vde-tab-content-inner.hasScroll .vde-tab-data { + left: 9px; +} + +.vde-tools .ui-resizable-handle { + position: absolute; + font-size: 0.1px; + display: block; +} + +.vde-tools .ui-resizable-n { + cursor: n-resize; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: url(Mage_DesignEditor::images/vde-tools-panel-draggable-handler-bg.png) no-repeat 0 50%; + z-index: 1 !important; +} + +.vde-tools input[type='text'] { + height: 30px; + line-height: 16px; + font-size: 14px; + padding: 0 7px; + border: 1px solid #30312c; + background: transparent; + color: #9f978c; +} + +.eq-ie8 .vde-tools input[type='text'] { + height: 30px; + line-height: 26px; +} + +.vde-tools input[type='text']:focus { + border: 1px solid #30312c; + box-shadow: none; +} + +.vde-tools select { + border: 1px solid #30312c; + background: #000; +} + +.vde-tools .field.with-addon .addbefore { + background: transparent; + border-color: #30312c; + color: #f2eadd; +} + +.vde-tools .field.with-addon input[type='text'] { + border-left: 0; +} + +.vde-tab-controls { + margin: 0; + padding: 0; + list-style: none; +} + +.vde-tab-controls > .item { + display: inline-block; +} + +.vde-tab-controls > .item.disabled { + opacity: 0.4; + filter:progid:DXImageTransform.Microsoft.Alpha(opacity=40); +} + +.vde-tools-footer .vde-tab-controls > .item > a { + display: inline-block; + width: 52px; + height: 52px; + line-height: 52px; + text-align: center; + -moz-transition: background-color .3s ease; + -webkit-transition: background-color .3s ease; + transition: background-color .3s ease; +} + +.vde-tools-footer .vde-tab-controls > .item.disabled > a { + cursor: not-allowed; +} + +.vde-tab-controls > .item > a span { + display: block; + overflow: hidden; + text-indent: -999em; + width: 30px; + height: 27px; + background: url(Mage_DesignEditor::images/vde-tools-main-tabs-icons-sprite.png) no-repeat; + margin: 12px auto 0; +} + +.vde-tab-controls > .item-design > a span { + background-position: 2px 0; +} + +.vde-tab-controls > .item-block > a span { + background-position: -28px 0; +} + +.vde-tab-controls > .item-settings > a span { + background-position: -58px 0; +} + +.vde-tab-controls > .item.hidden { + display: none; +} + +.vde-tab-controls > .item-code > a span { + background-position: -88px 0; +} + +.vde-tab-controls > .item-design > a:hover span { + background-position: 2px -27px; +} + +.vde-tab-controls > .item-block > a:hover span { + background-position: -28px -27px; +} + +.vde-tab-controls > .item-settings > a:hover span { + background-position: -58px -27px; +} + +.vde-tab-controls > .item-code > a:hover span { + background-position: -88px -27px; +} + +.vde-tab-controls > .item.active > a { + background-color: #000; +} + +.tab-panel { + position: relative; + display: none; +} + +.tab-panel.active { + display: block; +} + +.vde-tools-content-inner { + position: relative; +} + +.vde-tools-handler-container { + position: absolute; + left: 0; + right: 0; + height: 52px; +} + +.vde-tools-tabs { + position: relative; + z-index: 2; +} + +.vde-tab-content-title { + font: 20px/52px "CallunaSans", Arial, sans-serif; + font-weight: 400; + color: #f2ebde; + text-shadow: 0 -1px 1px #000; + float: left; + margin: 0 28px 0 22px; +} + +.vde-tab-content-inner { + position: relative; + height: 348px; + background: #000; +} + +.vde-tab-data { + position: relative; + padding: 50px 0; + color: #f2ebde; +} + +.vde-tab-data .title { + font: 24px/1.333 "CallunaSans", Arial, sans-serif; + font-weight: 500; + color: #f2ebde; + margin: 0; +} + +.vde-tab-data .action-download, +.vde-tab-data .action-delete, +.vde-tab-data .action-edit { + display: inline-block; + margin-left: 10px; + float: right; + color: #9f978b; + background: none; + border: none; + padding: 0; + text-decoration: none; + -moz-transition: color .5s ease; + -webkit-transition: color .5s ease; + transition: color .5s ease; +} + +.vde-tab-data .action-download:hover, +.vde-tab-data .action-download:focus, +.vde-tab-data .action-delete:hover, +.vde-tab-data .action-delete:focus, +.vde-tab-data .action-edit:hover, +.vde-tab-data .action-edit:focus { + color: #fff; +} + +.vde-tab-data .action-download:before, +.vde-tab-data .action-delete:before, +.vde-tab-data .action-edit:before { + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: '\e073'; /* download icon (arrow down) */ + font-size: 16px; +} + +.vde-tab-data .action-download span, +.vde-tab-data .action-delete span, +.vde-tab-data .action-edit span { + display: none; +} + +.vde-tab-data .action-delete:before { + content: '\e07f'; /* trash icon */ +} + +.vde-tab-data .action-edit:before { + content: '\e05b'; /* edit icon */ +} + +.vde-tab-content-header .vde-tab-controls > .item { + float: left; + margin: 8px 3px 0 0; +} + +.vde-tab-content-header .vde-tab-controls > .item > a { + display: inline-block; + font: 13px "CallunaSans", Arial, sans-serif; + font-weight: 600; + line-height: 40px; + text-align: center; + height: 40px; + padding: 0 22px; + background: #000; + border-radius: 5px; + color: #ccc; + text-transform: uppercase; + text-decoration: none; +} + +.vde-tab-content-header .vde-tab-controls > .item.active > a { + height: 44px; + border-radius: 5px 5px 0 0; +} + +/* + Files List Block +-------------------------------------- */ +.files-list { + display: block; + float: left; + margin-left: 14.127659574%; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + -ms-box-sizing: border-box; + box-sizing: border-box; + width: 23.914893614%; + min-height: 250px; +} + +.files-wrapper .files-list:first-child, +.files-wrapper .files-list:nth-child(3n+1) { + margin-left: 0; +} + +.eq-ie8 .files-wrapper .files-list:first-child { + margin-left: 0; +} + +.files-list-header { + position: relative; + margin: 0 0 13px; + padding-right: 20px; +} + +.files-list-header > .title { + margin: 0; +} + +.custom-file .action-add, +.files-list-header > .action-add { + display: inline-block; + position: absolute; + top: 3px; + right: 0; + margin: 6px 0 0 0; + padding: 0; + width: 16px; + height: 16px; + line-height: 16px; + text-align: center; + color: #000; + background: #9f978b; + border-radius: 4px; + text-decoration: none; + -moz-transition: background .5s ease; + -webkit-transition: background .5s ease; + transition: background .5s ease; + overflow: hidden; +} + +.custom-file > .action-add .field-row, +.files-list-header > .action-add .field-row { + display: block; +} + +.custom-file .action-add input[type="file"], +.files-list-header > .action-add input[type="file"] { + position: absolute; + left: 0; + right: 0; + top: 0; + bottom: 0; + opacity: 0; + width: 16px; + height: 16px; +} + +.eq-ie8 .custom-file .action-add input[type="file"], +.eq-ie8 .files-list-header > .action-add input[type="file"] { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; +} + +.custom-file .action-add:hover, +.custom-file .action-add:focus, +.files-list-header > .action-add:hover, +.files-list-header > .action-add:focus { + background: #fff; + border-radius: 4px; +} + +.custom-file .action-add:before, +.files-list-header > .action-add:before { + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: '\e02d'; /* plus icon */ + font-size: 16px; +} + +.eq-ie9 .custom-file .action-add:before, +.eq-ie9 .files-list-header > .action-add:before { + line-height: 18px !important; +} + +.custom-file .action-add span, +.files-list-header > .action-add span { + display: none; +} + +.custom-file .action-add { + position: relative; +} + +.custom-file > .action-download { + top: 2px; +} + +.custom-file .action-add:before { + font-size: 16px !important; +} + +.files-list-content .items { + margin: 0; + padding: 0; + list-style: none; +} + +.files-list-content .item { + position: relative; + padding: 10px 50px 8px 0; + border-bottom: 1px solid #31302b; + white-space: nowrap; +} + +.files-list-content .item [class^="action-"] { + position: absolute; + top: 10px; + right: 0; +} + +.files-list-content .item .action-edit { + right: 30px; +} + +.files-list-content .item .filename { + display: block; + width: 100%; + text-overflow: ellipsis; + overflow: hidden; +} + +.vde-tab-content-inner .filename { + font: bold 16px/1.333 "Helvetica", Arial, sans-serif; + vertical-align: middle; +} + +/* + JS Tabs +-------------------------------------- */ +#vde-tab-js .title { + display: inline; + margin-right: 10px; +} + +#vde-tab-js .files-list-header .action-add { + position: relative; +} + +#vde-tab-js .files-list { + width: 100%; + margin: 0; +} + +#vde-tab-js .files-list .items .item { + display: inline-block; + width: 26%; + margin-right: 3%; +} + +/* + VDE Messages +-------------------------------------- */ +.vde-message { + margin: -40px 0 46px; + background: url(Mage_DesignEditor::images/vde-message-bg.gif); + border-bottom: 1px solid #43423D; + border-radius: 5px; + font: 14px/1.666 Helvetica, Arial, sans-serif; +} + +.vde-message > .message-inner { + position: relative; + padding: 20px 45px 15px 20px; +} + +.vde-message .action-close { + padding: 0; + display: inline-block; + position: absolute; + top: 17px; + right: 20px; + width: 16px; + height: 16px; + line-height: 16px; + background: #201f1c; + border-radius: 4px; + color: #8b857b; + text-align: center; + border: none; + -moz-transition: all .5s ease; + -webkit-transition: all .5s ease; + transition: all .5s ease; +} + +@-moz-document url-prefix() { + .vde-message .action-close { + line-height: 14px; + } +} + +.vde-message .action-close:hover { + color: #fff; + background: #000; +} + +.vde-message .action-close:before { + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: '\e061'; /* close icon */ + font-size: 10px; +} + +.vde-message .action-close span { + display: none; +} + +/* + Custom Code +-------------------------------------- */ +[class^="custom-code"] { + display: block; + float: left; + margin-left: 2.127659574%; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + -ms-box-sizing: border-box; + box-sizing: border-box; +} + +.custom-code-description { + width: 31.914893614%; + margin-left: 0; +} + +.custom-code-description .custom-file { + position: relative; +} + +.custom-code-description .title, +.custom-code-description p { + margin-bottom: 20px; +} + +.custom-code-description p { + font: 14px/18px Helvetica, Arial, sans-serif; + color: #8d857a; +} + +.custom-code-description [class^="action-"] { + position: relative; + float: right; + margin: 0 0 0 10px; +} + +.custom-code-description [class^="action-"]:before { + font-size: 18px; +} + +.custom-code { + width: 65.95744680199999%; +} + +.custom-code .textarea-container { + position: relative; + border: 1px solid #31302b; + border-radius: 5px; +} + +.custom-code .textarea-container:before, +.custom-code .textarea-container:after { + left: 30px; + right: 20px; +} + +.custom-code .textarea-container:before { + top: 0; +} + +.custom-code .textarea-container:after { + top: auto; + bottom: 5px; +} + +.custom-code textarea { + width: 100%; + background: none; + border: none; + resize: vertical; + font: 14px/18px Helvetica, Arial, sans-serif; + color: #f2ebde; + padding: 20px 0 20px 20px; +} + +.custom-code textarea:focus { + outline: none; +} + +@-moz-document url-prefix() { + .custom-code textarea { + padding-bottom: 3px; + } +} + +.custom-code .action-update { + float: right; + margin: 7px 0 0 0; +} + +.custom-code .action-update, +.custom-code .action-update:visited { + font: 14px/18px 'CallunaSans', Arial, Helvetica, sans-serif; + font-weight: 500; + color: #322e2a; + background: #dbd6ce; + display: inline-block; + padding: 5px 14px; + text-align: center; + text-decoration: none; + vertical-align: top; + cursor: pointer; + border: transparent; + border-radius: 5px; + -webkit-touch-callout: none; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.custom-code .action-update:hover, +.custom-code .action-update:focus { + background: #cac2b5; + color: #322e2a; +} + +.custom-code .action-update:active, +.custom-code .action-update.active { + box-shadow: 0 1px 5px #aaa59b inset; +} + +.custom-code .action-update[disabled], +.custom-code .action-update.disabled, +.custom-code .action-update[disabled]:hover, +.custom-code .action-update.disabled:hover, +.custom-code .action-update[disabled]:focus, +.custom-code .action-update.disabled:focus, +.custom-code .action-update[disabled]:active, +.custom-code .action-update.disabled:active, +.custom-code .action-update[disabled].active, +.custom-code .action-update.disabled.active { + cursor: not-allowed; + opacity: 0.65; + background: #d9d6cf; + box-shadow: none; + text-shadow: none; +} + +/* + VDE +-------------------------------------- */ +/* TODO #vde_toolbar is not used at all */ +/* TODO .vde_breadcrumbs is not used */ +#vde_toolbar { + position: fixed; + margin-top: -54pt; + width: 100%; + z-index: 997; + font: 10pt Arial, Helvetica, sans-serif; + color: #555; + text-align: left; + box-shadow: 0 0 4pt 1pt #cbcbcb; +} +.vde_breadcrumbs, #vde_toolbar_row { + padding: 0 0 0 1em; + height: 26pt; + line-height: 26pt; + vertical-align: middle; +} + +.vde_breadcrumbs { + text-transform: uppercase; + background: white; +} + +#vde_toolbar_row { + background: #f0efe9; + border-top: 1pt solid #dddcd8; + border-bottom: 1pt solid #dddcd8; + position: relative; + z-index: 991; +} + +#vde_toolbar_row .vde_toolbar_row_inner { + min-width: 1000px; + max-width: 1300px; + margin: 0 auto; +} + +#vde_toolbar_row .vde_toolbar_cell { + float: left; + margin-left: -11pt; + margin-right: 10pt; + border-right: 1pt solid transparent; + border-left: 1pt solid transparent; + padding: 0 10pt; + position: relative; +} + +#vde_toolbar_row .vde_toolbar_cell:hover, #vde_toolbar_row .vde_toolbar_cell.active { + background-color: white; + border-right: 1pt solid #deddd9; + border-left: 1pt solid #deddd9; +} + +#vde_toolbar_buttons { + float: right; + z-index: 998; + position: relative; + line-height: 21pt; + padding: 2pt 0; +} + +.action-switch-mode { + float: left; + background: none; + border: 0; + height: 30px; + line-height: 30px; + font-weight: normal; +} + +#vde_toolbar_buttons a.vde_button, +.action-switch-mode { + display: block; + border: 1px solid #c9c6be; + box-shadow: 0 0 1pt 0 #c9c6be; + border-radius: 3pt; + padding: 0 1.7em; + color: #555; + text-decoration: none; + background-image: url(../images/button.png); + background-size: contain; + background-color: #f4f3f1 !important; + float: left; + margin-right: 3px; +} + +#vde_toolbar_buttons a.vde_button:hover, +.action-switch-mode:hover { + box-shadow: 0 0 1pt 1pt #c9c6be; + background-image: url(../images/button_hover.png); +} + +#vde_toolbar_buttons .action-theme-assign { + float: left; + margin-right: 10px; + height: 30px; +} + +#vde_toolbar_buttons .actions-split { + margin: 0 20px 0 0; +} + +#vde_toolbar_buttons .actions-split > [class^='action-'] { + line-height: 20px; +} + +.store-launcher-theme-preview .action-theme-assign { + color: #fff; + background: #f47b20; + text-shadow: none; +} + +.store-launcher-theme-preview .action-theme-assign:hover, +.store-launcher-theme-preview .action-theme-assign:focus { + background: #e2701a; + color: #fff; + text-shadow: 0 -1px 2px #955326; +} + +.store-launcher-theme-preview .action-theme-assign:active { + box-shadow: 0 1px 5px #955326 inset; +} + +#vde_toolbar .item-msg { + border-style: solid; + border-width: 1px; + padding: 4px; +} + +#vde_toolbar .error { + border-color: red; + color: red; +} + +.vde_toolbar_cell_title { + font-weight: bold; + cursor: pointer; + padding-right: 12pt; + background: url(../images/arrow_down.png) right center no-repeat; +} + +.vde_toolbar_cell.active .vde_toolbar_cell_title { + background-image: url(../images/arrow_up.png); +} + +.vde_toolbar_cell_value { + font-weight: normal; +} + +#vde_toolbar_row .vde_toolbar_cell_content, +#vde_toolbar_row .vde_toolbar_cell_content * { + color: #f0efe9; +} + +#vde_toolbar_row .switcher-label:after { + vertical-align: middle; + margin-top: -3px; +} + +.vde_toolbar_cell_content { + display: none; + position: absolute; + top: 2.5em; + left: 0; + background: #494949; + padding: .5em 0; + z-index: 190; + min-width: 20em; + margin-top: 1pt; + border-radius: 0 0 5pt 5pt; + -moz-box-shadow: 0 1pt 2pt 1pt #6c6c6c; + -webkit-box-shadow: 0 1pt 2pt 1pt #6c6c6c; + box-shadow: 0 1pt 2pt 1pt #6c6c6c; +} + +.vde_toolbar_cell.active .vde_toolbar_cell_content { + display: block; +} + +.vde_toolbar_cell_content > div { + white-space: nowrap; + vertical-align: middle; + padding: 0 10px; +} + +.vde_toolbar_cell_content .vde_cell_list_item { + padding-left: 18pt; + cursor: pointer; +} + +.vde_toolbar_cell_content .vde_cell_list_group { + padding-left: 5pt; + font-style: italic; + cursor: default; +} + +.vde_toolbar_cell_content .vde_cell_list_item:hover, #vde_handles_tree .jstree-clicked, #vde_handles_tree .jstree-hovered { + background-color: #7b7b7b; +} + +.vde_toolbar_cell_content .checked { + background: url(../images/checked.png) no-repeat 5pt center; +} + +.vde_breadcrumbs a { + font-weight: bold; + text-decoration: none; + color: #2483c7; +} + +.vde_breadcrumbs a:hover { + text-decoration: underline; +} + +.vde_breadcrumbs .vde_breadcrumbs_separator { + margin: 0 .3em; +} + +#visual_design_editor_theme a { + display: block; + text-decoration: none; +} + +#vde_handles_hierarchy .vde_toolbar_cell_content { + padding: 1em .5em 1em 0; +} + +#vde_handles_tree { + max-height: 30em; /* max allowed height */ + overflow: hidden; /* don't display native scrollbars */ + padding-right: .5em; + text-align: left; + background-color: transparent; +} + +#vde_handles_tree li { + overflow: hidden; +} + +#vde_handles_tree a { + margin-left: .5em; + padding: .5em; + width: 100%; +} + +#vde_handles_tree .jstree-clicked, #vde_handles_tree .jstree-hovered { + border: none; +} + +#vde_handles_tree .jstree-closed > .jstree-icon { + background: url(../images/jstree_plus_minus.png) top left no-repeat; +} + +#vde_handles_tree .jstree-open > .jstree-icon { + background: url(../images/jstree_plus_minus.png) top right no-repeat; +} + +#vde_handles_tree .vde_option_fragment a { + color: #eea243; +} + +.vde_container_frame { + border: none; + margin-top: 0; + width: 100%; +} + +/* Quick Styles */ +.fieldset.column { + background: transparent; + border: none; + display: block; + float: left; + margin: 0 0 0 10.6%; + padding: 0; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + -ms-box-sizing: border-box; + box-sizing: border-box; + width: 26.26%; + min-height: 250px; +} + +.tab-panel form > div:first-child + .fieldset.column, +.fieldset.column:first-child { + margin-left: 0; +} + +.fieldset.column .legend { + border: none; + margin: 0; + float: none; +} + +.fieldset.column .fieldset { + margin: 0; + padding: 0; +} + +.fieldset.column .legend span, +.fieldset .label { + font: bold 16px/1.333 "Helvetica", Arial, sans-serif; + color: #f2ebde; + margin: 0 0 10px; + padding: 0; +} + +.fieldset.column .fieldset.element-logo { + margin: 0 0 50px 0; +} + +.element-logo .custom-file .action-add, +.element-background .custom-file .action-add { + top: 0; + margin: 0 5px 0 0; +} + +.element-logo .custom-file label, +.element-background .custom-file label { + color: #9f978b; +} + +.element-logo .custom-file-for-store-view { + margin: 5px 0; +} + +.fieldset.column .element-color-picker { + margin-bottom: 5px; +} + +.fieldset.element-background .element-color-picker { + margin-bottom: 10px; +} + +.element-font .element-font-picker, +.element-color-picker .label, +.fieldset.element-background .legend { + display: inline-block; + vertical-align: top; + width: 55%; + margin-top: 4px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + float: left; +} + +.element-font .element-color-picker, +.element-color-picker .control { + display: inline-block; + width: 43%; + white-space: nowrap; + float: right; + text-align: right; +} + +.element-font .element-font-picker { + width: 63%; +} + +.element-font .element-color-picker { + width: 35%; +} + +.element-color-picker .control input { + width: 80px; + vertical-align: top; + text-transform: uppercase; +} + +.element-color-picker .color-box { + display: inline-block; + width: 28px; + height: 28px; + border: 1px solid #30312c; + border-radius: 3px; +} + +.element-color-picker .color-box.active { + border-color: #19a3d1; + box-shadow: 0 0 8px #19a3d1; +} + +.uploaded-file-wrapper { + background: #201f1b; + border-radius: 5px; + margin: 10px 0 20px; +} + +.uploaded-file-wrapper .file-row, +.uploaded-file-wrapper .tile-background { + padding: 9px 10px; +} + +.uploaded-file-wrapper .uploaded-image ~ .tile-background { + border-top: 1px solid #000; + box-shadow: 0 1px 0 #2f302a inset; +} + +.uploaded-file-wrapper .file-row { + position: relative; +} + +.uploaded-file-wrapper .file-row .label, +.uploaded-file-wrapper .field-row .label span { + font-size: 13px; + color: #70695f; +} + +.uploaded-file-wrapper .file-row .action-delete { + position: absolute; + top: 8px; + right: 8px; +} + +.uploaded-file-wrapper .file-row .action-delete:before { + color: #fff; + font-size: 18px; +} + +.uploaded-file-wrapper .tile-background > .field-row > .label { + margin-bottom: 0; +} + +.uploaded-file-wrapper .tile-background .element-checkbox { + float: left; + margin: 5px 5px 0 0; +} + +.element-font { + white-space: nowrap; +} + +.element-font .element-font-picker { + margin-top: 0; +} + +.element-font .element-font-picker select { + width: 100%; +} + +.element-font .element-color-picker .control { + width: auto; +} + +#quick-styles-form-backgrounds .element-background .element-color-picker { + border-bottom: 1px solid #31302b; + padding-bottom: 5px; + margin-bottom: 13px; +} + +/* + Image Sizing +-------------------------------------- */ +.vde-image-sizing fieldset.field { + border: solid #31302b; + border-width: 0 0 1px; + margin-bottom: 2px; + padding: 8px 0; +} + +.vde-image-sizing fieldset.field > .label { + text-align: left; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + width: 30%; +} + +.vde-image-sizing fieldset.field > .label span { + font-size: 15px; +} + +.vde-image-sizing fieldset.field > .control { + float: right; + text-align: right; +} + +.vde-image-sizing .field-row > .note { + margin-bottom: 30px; +} + +.vde-image-sizing .action-connect { + font-size: 18px; + color: #9f978c; +} + +.vde-image-sizing .action-connect:before { + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: '\e03f'; /* unlink icon */ +} + +.vde-image-sizing .control .control-value { + padding-top: 0; +} + +.vde-image-sizing .choice { + margin: 6px -11px 0 9px; +} + +.vde-image-sizing .choice > input { + display: none; +} + +.vde-image-sizing .choice > input:checked + .addafter > .action-connect:before { + content: '\e040'; +} + +.vde-image-sizing .field.with-addon .addbefore { + padding-left: 8px; + font-size: 13px; + line-height: 20px; +} + +.vde-image-sizing .field .input-text { + width: 52px; + text-align: right; +} + +.vde-tools-image-settings .note { + border-bottom: 1px solid #31302b; + padding-bottom: 10px; +} + +.vde-image-sizing .description { + position: relative; + padding: 17px 0 17px 70px; + background: url(../images/vde-tools-image-settings-fill-frame.png) no-repeat; +} + +.vde-image-sizing .explain { + position: absolute; + left: 0; + top: 0; +} + +.vde-image-sizing .action-reset, +.vde-image-sizing .action-reset:hover, +.vde-image-sizing .action-reset:active, +.vde-image-sizing .action-reset[disabled] { + margin-top: 5px; + color: #9f978c; +} + +.vde-image-sizing .action-reset:before { + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: '\e010'; /* reload icon */ + margin-right: 5px; + vertical-align: text-bottom; +} + +#add_white_borders { + margin-right: 8px; +} + +.save_image_sizing { + display: none; + border: none !important; + background: #000; + position: fixed; + left: 0; + right: 30px; + bottom: 51px; + height: 44px; + z-index: 2; +} + +.vde-image-sizing fieldset.save_image_sizing > .control { + float: none; + min-width: 1000px; + max-width: 1300px; + margin: 0 auto; +} + +.vde-tools.opened .save_image_sizing { + display: block; +} + +.field-save_image_sizing.no-label > .control { + margin: 0; + width: 100%; +} + +#save_image_sizing { + position: relative; + right: -15px; +} + +/* + Color Picker +-------------------------------------- */ +.farbtastic { + background: #31302b; + border: 1px solid #3e3d37; + border-radius: 3px; + right: -40px; + top: -84px; + z-index: 6; + box-shadow: 0 0 5px #000; +} + +.hasScroll .farbtastic { + z-index: 4; +} + +.farbtastic:before { + position: absolute; + left: -13px; + top: 50%; + margin-top: -13px; + width: 20px; + height: 20px; + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: '\e02b'; /* user icon */ + color: #31302b; + font-size: 20px; + text-shadow: -1px 0 0 #555; +} + +/* + Clearfix +-------------------------------------- */ +.theme:before, +.theme:after, +.themes:before, +.themes:after, +.files-list-header:before, +.files-list-header:after, +.element-color-picker:before, +.element-color-picker:after, +.vde-tab-data > .tab-panel:before, +.vde-tab-data > .tab-panel:after, +.vde-tab-content-header:before, +.vde-tab-content-header:after, +.clearfix:before, +.clearfix:after { + content: ""; + display: table; +} + +.theme:after, +.themes:after, +.files-list-header:after, +.element-color-picker:after, +.vde-tab-data > .tab-panel:after, +.vde-tab-content-header:after, +.clearfix:after { + clear: both; +} diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/editor.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor.phtml similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/editor.phtml rename to app/code/Mage/DesignEditor/view/adminhtml/editor.phtml diff --git a/app/code/Mage/DesignEditor/view/adminhtml/editor/container.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor/container.phtml new file mode 100644 index 0000000000000..14d76e4a2ceeb --- /dev/null +++ b/app/code/Mage/DesignEditor/view/adminhtml/editor/container.phtml @@ -0,0 +1,40 @@ + + + +getChildHtml('design_editor_toolbar'); ?> +getChildHtml('theme.selector.storeview'); ?> + +getChildHtml('design_editor_tools'); ?> + diff --git a/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/background-uploader.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/background-uploader.phtml new file mode 100644 index 0000000000000..303edc6a93c60 --- /dev/null +++ b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/background-uploader.phtml @@ -0,0 +1,68 @@ + + +getElement(); +?> + +getImageUploaderElement(); ?> +
    +
    +
    +
    + toHtml() ?> +
    + +
    +
    +
    +
    + {{name}} + +
    +
    +
    + getCheckboxElement()->toHtml() ?> +
    +
    +
    + + +
    diff --git a/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/checkbox-utility.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/checkbox-utility.phtml new file mode 100644 index 0000000000000..982155bd742d2 --- /dev/null +++ b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/checkbox-utility.phtml @@ -0,0 +1,47 @@ + + +getElement(); +?> + +getHtml() ?> + + diff --git a/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/color-picker.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/color-picker.phtml new file mode 100644 index 0000000000000..1f9d0fc1523c9 --- /dev/null +++ b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/color-picker.phtml @@ -0,0 +1,33 @@ + + + + +getElement(); ?> + +
    +getHtml() ?> diff --git a/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/composite.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/composite.phtml new file mode 100644 index 0000000000000..99aafec04d43b --- /dev/null +++ b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/composite.phtml @@ -0,0 +1,95 @@ + + +getElement(); +$containerId = $element->getFieldsetContainerId(); +$id = $element->getHtmlId(); +$isCollapsable = $element->getCollapsable(); +$isWrapped = $containerId || $element->getHeaderBar() || $isCollapsable; +$isField = $element->getFieldsetType() == 'field'; +$advancedAfter = $element->getAdvancedPosition() == 'after'; // To place advanced options inside or after fieldset +?> + + getNoContainer()): ?> +
    + getLegend() && !$isWrapped): ?> + + getLegend() ?> + + + + + getComment() && !$isField): ?> +
    escapeHtml($element->getComment()) ?>
    + + + ' : ''; ?> + + hasHtmlContent() && !$isField): ?> + getHtmlContent(); ?> + + + getCountBasicChildren(); ?> + + 1):?> +
    + + + getHtml(); ?> + + 1) ? '
    ' : '' ?> + + getComment() && $isField): ?> +
    escapeHtml($element->getComment()) ?>
    + + + hasAdvanced() && !$isField): ?> + getNoContainer() && $advancedAfter) ? '
    ' : ''?> +
    + + getAdvancedLabel() ?> + +
    + getAdvancedChildrenHtml(); ?> +
    +
    + hasAdvanced() && $isField): ?> +
    + getAdvancedChildrenHtml(); ?> +
    + + + ' : ''; ?> + + + + + getNoContainer() && !$advancedAfter): ?> + + diff --git a/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/composite/children.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/composite/children.phtml new file mode 100644 index 0000000000000..33ac2be8de006 --- /dev/null +++ b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/composite/children.phtml @@ -0,0 +1,37 @@ + + +getElement(); +?> + + +getSortedElements() as $child): ?> + toHtml(); ?> + + diff --git a/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/composite/wrapper.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/composite/wrapper.phtml new file mode 100644 index 0000000000000..ef1f2c37904aa --- /dev/null +++ b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/composite/wrapper.phtml @@ -0,0 +1,56 @@ + + +getElement(); + +$containerId = $element->getFieldsetContainerId(); +$id = $element->getHtmlId(); +$isCollapsable = $element->getCollapsable(); +$isWrapped = $containerId || $element->getHeaderBar() || $isCollapsable; +$titleActions = $element->getHeaderBar() ? '
    ' . $element->getHeaderBar() . '
    ' : ''; +?> + + +
    +
    + > + getLegend() ?> + + +
    +
    + + +getHtml() ?> + + +
    +
    + + diff --git a/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/element/input.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/element/input.phtml new file mode 100644 index 0000000000000..9de6d6480b9c7 --- /dev/null +++ b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/element/input.phtml @@ -0,0 +1,38 @@ + + +getElement(); +?> + +getUiId($element->getType(), $element->getName()) ?> + value="getEscapedValue() ?>" + type="getType() ? $element->getType() : 'text' ?>" + serialize($element->getHtmlAttributes()) ?> /> diff --git a/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/element/wrapper.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/element/wrapper.phtml new file mode 100644 index 0000000000000..5c271db57d741 --- /dev/null +++ b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/element/wrapper.phtml @@ -0,0 +1,45 @@ + + + + + + +getElement(); ?> + +getBeforeElementHtml()): ?> + + + +getHtml() ?> + +getAfterElementHtml()): ?> + + + + + diff --git a/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/font.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/font.phtml new file mode 100644 index 0000000000000..a68671a75a9ce --- /dev/null +++ b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/font.phtml @@ -0,0 +1,39 @@ + + +getElement(); +?> + +
    + + getLegend(); ?> + + getChildrenHtml(); ?> +
    + diff --git a/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/logo-uploader.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/logo-uploader.phtml new file mode 100644 index 0000000000000..0f6083695844c --- /dev/null +++ b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/logo-uploader.phtml @@ -0,0 +1,70 @@ + + + +getElement(); ?> +getStoresList(); ?> + + + __('Please assign theme to specific store. And then upload store logo.'); ?> + + + getHtmlId() . '-' . $store->getId(); ?> +
    +
    getName(); ?>:
    + +
    + getHtml(); ?> +
    + + +
    +
    +
    + {{name}} + +
    +
    +
    +
    + + + + diff --git a/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/simple.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/simple.phtml new file mode 100644 index 0000000000000..2c7e35942c104 --- /dev/null +++ b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/simple.phtml @@ -0,0 +1,60 @@ + + + + +getElement(); +$note = $element->getNote() ? '
    ' . $element->getNote() . '
    ' : ''; +$elementBeforeLabel = $element->getExtType() == 'checkbox' || $element->getExtType() == 'radio'; +$addOn = $element->getBeforeElementHtml() || $element->getAfterElementHtml(); +?> + +getNoDisplay()): ?> + getType() == 'hidden'): ?> + getHtml() ?> + +
    getFieldAttributes() ?>> + + getHtml() ?> + getLabelHtml() ?> + + + getLabelHtml() ?> +
    + ' . $this->getHtml() . '
    ' : $this->getHtml(); ?> + +
    + + getScopeLabel()): ?> +
    +
    + +
    + + diff --git a/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/template.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/template.phtml new file mode 100644 index 0000000000000..fd376fa7db933 --- /dev/null +++ b/app/code/Mage/DesignEditor/view/adminhtml/editor/form/renderer/template.phtml @@ -0,0 +1,43 @@ + + + + +getElement(); +?> + + +getNoSpan() !== true): ?> + + + getLabelHtml() ?> + getHtml() ?> +getNoSpan() !== true): ?> + + diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/toolbar.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor/toolbar.phtml similarity index 89% rename from app/code/core/Mage/DesignEditor/view/adminhtml/editor/toolbar.phtml rename to app/code/Mage/DesignEditor/view/adminhtml/editor/toolbar.phtml index 11ae67d0f156e..743f5e1043835 100644 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/toolbar.phtml +++ b/app/code/Mage/DesignEditor/view/adminhtml/editor/toolbar.phtml @@ -25,8 +25,10 @@ */ ?> -
    - getChildHtml(); ?> +
    +
    + getChildHtml(); ?> +
    diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/block.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor/tools/block.phtml similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/block.phtml rename to app/code/Mage/DesignEditor/view/adminhtml/editor/tools/block.phtml diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/code/css.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor/tools/code/css.phtml similarity index 87% rename from app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/code/css.phtml rename to app/code/Mage/DesignEditor/view/adminhtml/editor/tools/code/css.phtml index e132fb22c1e75..7da8837cda724 100644 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/code/css.phtml +++ b/app/code/Mage/DesignEditor/view/adminhtml/editor/tools/code/css.phtml @@ -25,8 +25,6 @@ */ ?> -
    -
    - getFileGroups()) ?> -
    +
    + getFileGroups()) ?>
    diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/code/css/group.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor/tools/code/css/group.phtml similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/code/css/group.phtml rename to app/code/Mage/DesignEditor/view/adminhtml/editor/tools/code/css/group.phtml diff --git a/app/code/Mage/DesignEditor/view/adminhtml/editor/tools/code/custom.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor/tools/code/custom.phtml new file mode 100644 index 0000000000000..6969188929369 --- /dev/null +++ b/app/code/Mage/DesignEditor/view/adminhtml/editor/tools/code/custom.phtml @@ -0,0 +1,105 @@ + + +
    + getChildHtml('messages') ?> +
    +
    +
    __('Custom CSS'); ?>
    +

    __('Update the custom.css file to right in order to overwrite the default styles.'); ?>

    +

    __('Or, replace, delete or download the file:'); ?>

    +
    + getCustomFileName() ?> + + + + __('Upload File'); ?> + getFormHtml() ?> + +
    +
    +
    +
    + +
    + +
    + + + diff --git a/app/code/Mage/DesignEditor/view/adminhtml/editor/tools/code/image-sizing.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor/tools/code/image-sizing.phtml new file mode 100644 index 0000000000000..a7ef93754c243 --- /dev/null +++ b/app/code/Mage/DesignEditor/view/adminhtml/editor/tools/code/image-sizing.phtml @@ -0,0 +1,63 @@ + + +
    +
    + getChildHtml('messages') ?> +
    + +

    + __('Width is a required field. If only width is specified, the image will be re-sized proportionally. If both width and height are specified, the image will be re-sized exactly.'); ?> + __('You will need to update your custom CSS in order to have the resized images displayed correctly in your store.'); ?> +

    +
    +
    +getFormHtml(); ?> +
    + diff --git a/app/code/Mage/DesignEditor/view/adminhtml/editor/tools/code/js.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor/tools/code/js.phtml new file mode 100644 index 0000000000000..f40f3d5bba038 --- /dev/null +++ b/app/code/Mage/DesignEditor/view/adminhtml/editor/tools/code/js.phtml @@ -0,0 +1,188 @@ + + +
    + getChildHtml('messages') ?> +
    +
    +
    +
    +
    getTitle() ?>
    + + __('Add Files'); ?> + getFormHtml() ?> + +
    +
    +
    +
      + getChildBlock('design.editor.tools.code.js.items')->setJsFiles($this->getJsFiles())->toHtml(); ?> +
    +
    +
    +
    + +
    +
    + {{name}} ({{size}}) +
    +
    +
    +
    +
    +
    + diff --git a/app/code/Mage/DesignEditor/view/adminhtml/editor/tools/code/js/items.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor/tools/code/js/items.phtml new file mode 100644 index 0000000000000..29fa2891502c9 --- /dev/null +++ b/app/code/Mage/DesignEditor/view/adminhtml/editor/tools/code/js/items.phtml @@ -0,0 +1,43 @@ + + + +getJsFiles()->count()): ?> +
  • + __('No files found') ?> +
  • + + + getJsFiles() as $file): ?> +
  • + getFileName() ?> + + __('Delete file'); ?> + +
  • + + diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/code/message.phtml b/app/code/Mage/DesignEditor/view/adminhtml/editor/tools/code/message.phtml similarity index 89% rename from app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/code/message.phtml rename to app/code/Mage/DesignEditor/view/adminhtml/editor/tools/code/message.phtml index 2909fe84f571a..8444aba574184 100644 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/code/message.phtml +++ b/app/code/Mage/DesignEditor/view/adminhtml/editor/tools/code/message.phtml @@ -27,13 +27,13 @@ -_getMessageTypes() as $type): ?> +getMessageTypes() as $type): ?> getMessages($type) as $message):?> getText()): ?>
    - _escapeMessageFlag ? $this->escapeHtml($message->getText()) : $message->getText() ?> + shouldEscapeMessage() ? $this->escapeHtml($message->getText()) : $message->getText() ?>
    + getButtonsHtml() ?> +
    + +
    + getTheme()->getAssignedStores()): ?> +
    +
    + + getQuickSaveButton()->toHtml() ?> +
    +

    + __('Edit Theme Name'); ?> +

    + __('Assigned to: ')?> + getStoresTitles()) ?> +

    +
    + + getButtonsHtml() ?> +
    +
    + + diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/theme/list/available.phtml b/app/code/Mage/DesignEditor/view/adminhtml/theme/list/available.phtml similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/theme/list/available.phtml rename to app/code/Mage/DesignEditor/view/adminhtml/theme/list/available.phtml diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/theme/list/available_ajax.phtml b/app/code/Mage/DesignEditor/view/adminhtml/theme/list/available_ajax.phtml similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/theme/list/available_ajax.phtml rename to app/code/Mage/DesignEditor/view/adminhtml/theme/list/available_ajax.phtml diff --git a/app/code/Mage/DesignEditor/view/adminhtml/theme/list/customized.phtml b/app/code/Mage/DesignEditor/view/adminhtml/theme/list/customized.phtml new file mode 100644 index 0000000000000..5e48cc90501a2 --- /dev/null +++ b/app/code/Mage/DesignEditor/view/adminhtml/theme/list/customized.phtml @@ -0,0 +1,42 @@ + + + +
    + getTabTitle()): ?> +

    getTabTitle() ?>

    + + +
      + getListItems(); ?> + + + +
    • __('There are no items here') ?>
    • + +
    +
    diff --git a/app/code/Mage/DesignEditor/view/adminhtml/theme/selector/first_entrance.phtml b/app/code/Mage/DesignEditor/view/adminhtml/theme/selector/first_entrance.phtml new file mode 100644 index 0000000000000..0983c2833ffab --- /dev/null +++ b/app/code/Mage/DesignEditor/view/adminhtml/theme/selector/first_entrance.phtml @@ -0,0 +1,47 @@ + + + + +
    +
    +

    __('Choose a theme to start with') ?>

    + getChildHtml('available.theme.list') ?> +
    +
    + + diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/theme/selector/my_customizations_tab.phtml b/app/code/Mage/DesignEditor/view/adminhtml/theme/selector/my_customizations_tab.phtml similarity index 100% rename from app/code/core/Mage/DesignEditor/view/adminhtml/theme/selector/my_customizations_tab.phtml rename to app/code/Mage/DesignEditor/view/adminhtml/theme/selector/my_customizations_tab.phtml diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/theme/selector/storeview.phtml b/app/code/Mage/DesignEditor/view/adminhtml/theme/selector/storeview.phtml similarity index 89% rename from app/code/core/Mage/DesignEditor/view/adminhtml/theme/selector/storeview.phtml rename to app/code/Mage/DesignEditor/view/adminhtml/theme/selector/storeview.phtml index a56552bf1517c..ac1fdfa665359 100644 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/theme/selector/storeview.phtml +++ b/app/code/Mage/DesignEditor/view/adminhtml/theme/selector/storeview.phtml @@ -64,19 +64,18 @@
    - getAssignSaveButtonHtml(); ?> + getAssignNextButtonHtml(); ?> __('Close') ?>
    - __('Close Popup') ?> + __('Close Popup') ?>
    diff --git a/app/code/Mage/DesignEditor/view/frontend/controls/quick_styles.xml b/app/code/Mage/DesignEditor/view/frontend/controls/quick_styles.xml new file mode 100644 index 0000000000000..8d40d1a08bae5 --- /dev/null +++ b/app/code/Mage/DesignEditor/view/frontend/controls/quick_styles.xml @@ -0,0 +1,549 @@ + + + + + logo + + + font + + + font-picker + .logo + font-family + + + + + + Mage_DesignEditor::store-name:font-picker + + + color-picker + .logo + color + Mage_DesignEditor::store-name:color-picker + + + + + logo-uploader + + + Mage_DesignEditor::store-name:logo-uploader + + + + + background + + + color-picker + .header + background-color + Mage_DesignEditor::header-background:color-picker + + + background-uploader + + + image-uploader + .header + background-image + Mage_DesignEditor::header-background:image-uploader + + + checkbox + .header + background-repeat + + + + + + + + Mage_DesignEditor::header-background:tile + + + + + + + + color-picker + .menu + background-color + Mage_DesignEditor::menu-background + + + color-picker + .menu + color + Mage_DesignEditor::menu-stroke + + + color-picker + .menu a + color + Mage_DesignEditor::menu-links + + + color-picker + .menu a:hover + color + Mage_DesignEditor::menu-links-hover + + + + color-picker + .header a + color + Mage_DesignEditor::header-links + + + color-picker + .header a:hover, .header a:active + color + Mage_DesignEditor::header-links-hover + + + color-picker + .scroll + background-color + Mage_DesignEditor::header-scroll-bar-background + + + color-picker + .scroll .handle + background-color + Mage_DesignEditor::header-scroll-bar-handle + + + color-picker + .search + background-color + Mage_DesignEditor::search-field + + + color-picker + .search + color + Mage_DesignEditor::search-field-stroke + + + + + background + + + color-picker + .wrapper + background-color + Mage_DesignEditor::page-background:color-picker + + + background-uploader + + + image-uploader + .wrapper + background-image + Mage_DesignEditor::page-background:image-uploader + + + checkbox + .wrapper + background-repeat + + + + + + + + Mage_DesignEditor::page-background:tile + + + + + + + + color-picker + .menu a:hover + color + Mage_DesignEditor::form-background + + + color-picker + .menu a:hover + color + Mage_DesignEditor::form-stroke + + + color-picker + .menu a:hover + color + Mage_DesignEditor::form2-background + + + color-picker + .menu a:hover + color + Mage_DesignEditor::form2-stroke + + + + color-picker + .menu a:hover + color + Mage_DesignEditor::form-field-stroke + + + color-picker + .menu a:hover + color + Mage_DesignEditor::form-field-stroke-clicked + + + color-picker + .menu a:hover + color + Mage_DesignEditor::image-stroke-keylines + + + color-picker + .menu a:hover + color + Mage_DesignEditor::scroll-bar-background + + + color-picker + .menu a:hover + color + Mage_DesignEditor::scroll-bar-handle + + + + + color-picker + .menu a:hover + color + Mage_DesignEditor::radio-checkbox-icon + + + color-picker + .menu a:hover + color + Mage_DesignEditor::radio-checkbox-background + + + color-picker + .menu a:hover + color + Mage_DesignEditor::radio-checkbox-stroke + + + + color-picker + .menu a:hover + color + Mage_DesignEditor::button-background + + + color-picker + .menu a:hover + color + Mage_DesignEditor::button-text + + + color-picker + .menu a:hover + color + Mage_DesignEditor::button-color + + + color-picker + .menu a:hover + color + Mage_DesignEditor::icons + + + color-picker + .menu a:hover + color + Mage_DesignEditor::icons-hover + + + color-picker + .menu a:hover + color + Mage_DesignEditor::icons2 + + + + color-picker + .menu a:hover + color + Mage_DesignEditor::accents + + + color-picker + .menu a:hover + color + Mage_DesignEditor::size-swatches + + + color-picker + .menu a:hover + color + Mage_DesignEditor::size-swatches-unavailable + + + color-picker + .menu a:hover + color + Mage_DesignEditor::size-swatches-hover + + + + + color-picker + .menu a:hover + color + Mage_DesignEditor::tooltip-text + + + color-picker + .menu a:hover + color + Mage_DesignEditor::tooltip-box + + + color-picker + .menu a:hover + color + Mage_DesignEditor::tooltip-stroke + + + color-picker + .menu a:hover + color + Mage_DesignEditor::tooltip2-text + + + color-picker + .menu a:hover + color + Mage_DesignEditor::tooltip2-box + + + color-picker + .menu a:hover + color + Mage_DesignEditor::tooltip2-stroke + + + + color-picker + .menu a:hover + color + Mage_DesignEditor::error-box + + + color-picker + .menu a:hover + color + Mage_DesignEditor::error-icon + + + + color-picker + .menu a:hover + color + Mage_DesignEditor::success-box + + + color-picker + .menu a:hover + color + Mage_DesignEditor::success-icon + + + + + font + + + font-picker + body + font-family + + + + + + Mage_DesignEditor::banner-text:font-picker + + + color-picker + body + color + Mage_DesignEditor::banner-text:color-picker + + + + + font + + + font-picker + .logo + font-family + + + + + + Mage_DesignEditor::page-headings:font-picker + + + color-picker + .logo + color + Mage_DesignEditor::page-headings:color-picker + + + + + font + + + font-picker + .logo + font-family + + + + + + Mage_DesignEditor::menu:font-picker + + + color-picker + .logo + color + Mage_DesignEditor::menu:color-picker + + + + + + font + + + font-picker + .logo + font-family + + + + + + Mage_DesignEditor::body-text:font-picker + + + color-picker + .logo + color + Mage_DesignEditor::body-text:color-picker + + + + + font + + + font-picker + .logo + font-family + + + + + + Mage_DesignEditor::buttons:font-picker + + + color-picker + .logo + color + Mage_DesignEditor::buttons:color-picker + + + + + + color-picker + .menu a:hover + color + Mage_DesignEditor::text-links + + + color-picker + .menu a:hover + color + Mage_DesignEditor::text-links-hover + + + color-picker + .menu a:hover + color + Mage_DesignEditor::text-links-active + + + color-picker + .menu a:hover + color + Mage_DesignEditor::text-links-product + + + color-picker + .menu a:hover + color + Mage_DesignEditor::small-links + + + color-picker + .menu a:hover + color + Mage_DesignEditor::small-links-hover + + diff --git a/app/code/core/Mage/DesignEditor/view/frontend/css/design.css b/app/code/Mage/DesignEditor/view/frontend/css/design.css similarity index 100% rename from app/code/core/Mage/DesignEditor/view/frontend/css/design.css rename to app/code/Mage/DesignEditor/view/frontend/css/design.css diff --git a/app/code/core/Mage/DesignEditor/view/frontend/images/arrow_down.png b/app/code/Mage/DesignEditor/view/frontend/images/arrow_down.png similarity index 100% rename from app/code/core/Mage/DesignEditor/view/frontend/images/arrow_down.png rename to app/code/Mage/DesignEditor/view/frontend/images/arrow_down.png diff --git a/app/code/core/Mage/DesignEditor/view/frontend/images/arrow_up.png b/app/code/Mage/DesignEditor/view/frontend/images/arrow_up.png similarity index 100% rename from app/code/core/Mage/DesignEditor/view/frontend/images/arrow_up.png rename to app/code/Mage/DesignEditor/view/frontend/images/arrow_up.png diff --git a/app/code/core/Mage/DesignEditor/view/frontend/images/block-placeholder.png b/app/code/Mage/DesignEditor/view/frontend/images/block-placeholder.png similarity index 100% rename from app/code/core/Mage/DesignEditor/view/frontend/images/block-placeholder.png rename to app/code/Mage/DesignEditor/view/frontend/images/block-placeholder.png diff --git a/app/code/core/Mage/DesignEditor/view/frontend/images/block.png b/app/code/Mage/DesignEditor/view/frontend/images/block.png similarity index 100% rename from app/code/core/Mage/DesignEditor/view/frontend/images/block.png rename to app/code/Mage/DesignEditor/view/frontend/images/block.png diff --git a/app/code/core/Mage/DesignEditor/view/frontend/images/button.png b/app/code/Mage/DesignEditor/view/frontend/images/button.png similarity index 100% rename from app/code/core/Mage/DesignEditor/view/frontend/images/button.png rename to app/code/Mage/DesignEditor/view/frontend/images/button.png diff --git a/app/code/core/Mage/DesignEditor/view/frontend/images/button_hover.png b/app/code/Mage/DesignEditor/view/frontend/images/button_hover.png similarity index 100% rename from app/code/core/Mage/DesignEditor/view/frontend/images/button_hover.png rename to app/code/Mage/DesignEditor/view/frontend/images/button_hover.png diff --git a/app/code/core/Mage/DesignEditor/view/frontend/images/checked.png b/app/code/Mage/DesignEditor/view/frontend/images/checked.png similarity index 100% rename from app/code/core/Mage/DesignEditor/view/frontend/images/checked.png rename to app/code/Mage/DesignEditor/view/frontend/images/checked.png diff --git a/app/code/core/Mage/DesignEditor/view/frontend/images/container.png b/app/code/Mage/DesignEditor/view/frontend/images/container.png similarity index 100% rename from app/code/core/Mage/DesignEditor/view/frontend/images/container.png rename to app/code/Mage/DesignEditor/view/frontend/images/container.png diff --git a/app/code/core/Mage/DesignEditor/view/frontend/images/container_hover.png b/app/code/Mage/DesignEditor/view/frontend/images/container_hover.png similarity index 100% rename from app/code/core/Mage/DesignEditor/view/frontend/images/container_hover.png rename to app/code/Mage/DesignEditor/view/frontend/images/container_hover.png diff --git a/app/code/core/Mage/DesignEditor/view/frontend/images/jstree_plus_minus.png b/app/code/Mage/DesignEditor/view/frontend/images/jstree_plus_minus.png similarity index 100% rename from app/code/core/Mage/DesignEditor/view/frontend/images/jstree_plus_minus.png rename to app/code/Mage/DesignEditor/view/frontend/images/jstree_plus_minus.png diff --git a/app/code/core/Mage/DesignEditor/view/frontend/images/stub.png b/app/code/Mage/DesignEditor/view/frontend/images/stub.png similarity index 100% rename from app/code/core/Mage/DesignEditor/view/frontend/images/stub.png rename to app/code/Mage/DesignEditor/view/frontend/images/stub.png diff --git a/app/code/core/Mage/DesignEditor/view/frontend/js/change/layout.js b/app/code/Mage/DesignEditor/view/frontend/js/change/layout.js similarity index 100% rename from app/code/core/Mage/DesignEditor/view/frontend/js/change/layout.js rename to app/code/Mage/DesignEditor/view/frontend/js/change/layout.js diff --git a/app/code/Mage/DesignEditor/view/frontend/js/design_editor.js b/app/code/Mage/DesignEditor/view/frontend/js/design_editor.js new file mode 100644 index 0000000000000..da37ebb8c6bb9 --- /dev/null +++ b/app/code/Mage/DesignEditor/view/frontend/js/design_editor.js @@ -0,0 +1,396 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_DesignEditor + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +(function($) { + /** + * Widget block + */ + $.widget( "vde.block", { _create: function() {}} ); + + /** + * Widget container + */ + $.widget('vde.vde_container', $.ui.sortable, { + options: { + tolerance: 'pointer', + revert: true, + connectWithSelector: '.vde_element_wrapper.vde_container', + placeholder: 'vde_placeholder', + forcePlaceholderSize: true, + hoverClass: 'vde_container_hover', + items: '.vde_element_wrapper.vde_draggable', + helper: 'clone', + appendTo: 'body', + containerSelector: '.vde_container', + highlightClass: 'vde_highlight', + opacityClass: 'vde_opacity_enabled' + }, + _create: function() { + var self = this; + this.element.data('sortable', this); + self.options = $.extend({}, self.options, { + start: function(event, ui) { + self._highlightEmptyContainers(ui.helper); + self.element.vde_container('option', 'connectWith', $(self.options.connectWithSelector) + .not(ui.item)).vde_container('refresh'); + + self.element.addClass(self.options.hoverClass).addClass(self.options.highlightClass); + $(self.options.items).addClass(self.options.opacityClass); + ui.helper.removeClass(self.options.opacityClass); + }, + over: function(event, ui) { + $(self.options.containerSelector).removeClass(self.options.hoverClass); + self.element.addClass(self.options.hoverClass); + + self._highlightEmptyContainers(ui.helper); + }, + stop: function(event, ui) { + $(self.options.containerSelector).removeClass(self.options.hoverClass); + $('.' + self.options.highlightClass).removeClass(self.options.highlightClass); + $(self.options.items).removeClass(self.options.opacityClass); + + self._disableEmptyContainers(); + } + }); + $.ui.sortable.prototype._create.apply(this, arguments); + }, + _highlightEmptyContainers: function(originalElement) { + var self = this; + $(this.options.containerSelector).each(function (index, element) { + if ($(element).find(self.options.items + ':visible').length == 0) { + $(element).addClass(self.options.highlightClass) + .css('min-height', originalElement.outerHeight(true)); + } + }) + }, + _disableEmptyContainers: function(originalElement) { + var self = this; + $(this.options.containerSelector).each(function (index, element) { + if ($(element).find(':visible').length == 0) { + $(element).removeClass(self.options.highlightClass).css('min-height', '0px'); + } + }) + } + }); + + /** + * Widget container with ability to log "move" operations + */ + var containerBasePrototype = $.vde.vde_container.prototype; + $.widget( "vde.vde_container", $.extend({}, containerBasePrototype, { + history: null, + _onDragElementStart: function(event, ui) { + var block = ui.item; + if (this._isBlockDeeplyNested(block)) { + return; + } + + if (this._getContainer(block).data('name') != this.element.data('name')) { + throw Error('Invalid container. Event "start" should be handled only for closest container'); + } + + this.element.bind( this.getEventName('stop', 'history'), { + position: block.index() + }, $.proxy(this._onDragElementStop, this)); + }, + _onDragElementStop: function(event, ui) { + var block = ui.item; + var originContainer = this.element.data('name'); + var originPosition = event.data.position - 1; + var destinationContainer = this._getContainer(block).data('name'); + var destinationPosition = block.index() - 1; + + var containerChanged = destinationContainer != originContainer; + var sortingOrderChanged = destinationPosition != originPosition; + if (containerChanged || sortingOrderChanged) { + var change = $.fn.changeFactory.getInstance('layout'); + change.setData({ + action: 'move', + block: block.data('name'), + origin: { + container: originContainer, + order: originPosition + }, + destination: { + container: destinationContainer, + order: destinationPosition + } + }); + + // This is the dependency of Container on History + this.getHistory().addItem(change); + } + + this.element.unbind( this.getEventName('stop', 'history'), $.proxy(this._onDragElementStop, this)); + }, + _getContainer: function(item) { + return item.parent().closest(this.options.containerSelector); + }, + _isBlockDeeplyNested: function(block) { + return this._getContainer(block).attr('id') != this.element.attr('id'); + }, + getEventName: function(type, namespace) { + var name = this.widgetEventPrefix + type; + if (namespace) { + name = name + '.' + namespace; + } + return name; + }, + setHistory: function(history) { + this.history = history; + this.element.bind( this.getEventName('start', 'history'), $.proxy(this._onDragElementStart, this)); + }, + getHistory: function() { + if (!this.history) { + throw Error('History element should be set before usage'); + } + return this.history; + } + })); + + /** + * Widget history + * + * @TODO can we make this not a widget but global object? + */ + $.widget( "vde.vde_history" , { + widgetEventPrefix: 'history/', + options:{}, + items: [], + _create: function() {}, + getEventName: function(type, namespace) { + var name = this.widgetEventPrefix + type; + if (namespace) { + name = name + '.' + namespace; + } + return name; + }, + addItem: function(change) { + this.items.push(change); + this._trigger('add', null, change); + }, + getItems: function() { + return this.items; + }, + deleteItems: function() { + this.items = []; + } + }); + + /** + * Widget history toolbar + * + * @todo move out from history toolbar send POST data functionality + */ + $.widget( "vde.vde_historyToolbar" , { + options: {}, + _history: null, + _create: function() { + this._initToolbar(); + }, + _initToolbar : function() {}, + _initEventObservers: function() { + this._history.element.bind( + this._history.getEventName('add'), + $.proxy(this._onHistoryAddItem, this) + ); + }, + _onHistoryAddItem: function(e, change) { + this.addItem(change); + }, + setHistory: function(history) { + this._history = history; + this._initEventObservers(); + }, + setItems: function(items) { + //this.deleteItems(); + $.each(items, function(index, item){this.addItem(item)}); + }, + deleteItems: function() { + this.element.find('ul').empty(); + }, + addItem: function(change) { + this.element.find('ul').append('
  • ' + change.getTitle() + '
  • '); + }, + _preparePostItems: function(items) { + var postData = {}; + $.each(items, function(index, item){ + postData[index] = item.getPostData(); + }); + return postData; + }, + _post: function(action, data) { + var postResult; + $.ajax({ + url: action, + type: 'POST', + dataType: 'JSON', + data: data, + async: false, + success: function(data) { + if (data.error) { + /** @todo add error validator */ + throw Error($.mage.__('Some problem with save action')); + } + postResult = data.success; + }, + error: function() { + throw Error($.mage.__('Some problem with save action')); + } + }); + return postResult; + } + }); + + /** + * Widget page + */ + $.widget('vde.vde_connector', { + options: { + containerSelector: '.vde_element_wrapper.vde_container', + highlightElementSelector: '.vde_element_wrapper', + highlightElementTitleSelector: '.vde_element_title', + highlightCheckboxSelector: '#vde_highlighting', + historyToolbarSelector: '.vde_history_toolbar' + }, + _create: function () { + this._initContainers(); + }, + _initContainers: function () { + $(this.options.containerSelector) + .vde_container().disableSelection(); + } + }); + + /** + * Widget page history init + */ + var pagePrototype = $.vde.vde_connector.prototype; + $.widget( "vde.vde_connector", $.extend({}, pagePrototype, { + _create: function() { + pagePrototype._create.apply(this, arguments); + var history = this._initHistory(); + this._initHistoryToolbar(history); + this._initRemoveOperation(history); + this._setHistoryForContainers(history); + }, + _initHistory: function() { + // @TODO can we make this not a widget but global object? + window.vdeHistoryObject = $( window ).vde_history().data('vde_history'); + return window.vdeHistoryObject; + }, + _initHistoryToolbar: function(history) { + if (!history) { + throw new Error('History object is not set'); + } + if ($( this.options.historyToolbarSelector )) { + var toolbar = $( this.options.historyToolbarSelector).vde_historyToolbar().data('vde_historyToolbar'); + if (toolbar) { + toolbar.setHistory(history); + } + } + }, + _initRemoveOperation : function(history) { + $( this.options.highlightElementSelector ).each(function(i, element) { + var widget = $(element).vde_removable().data('vde_removable'); + widget.setHistory(history); + }); + }, + _setHistoryForContainers: function(history) { + $( this.options.containerSelector ).each(function(i, element) { + var widget = $(element).data('vde_container'); + widget.setHistory(history); + }); + }, + _destroy: function() { + //DOM structure can be missed when test executed + var toolbarContainer = $(this.options.historyToolbarSelector); + if (toolbarContainer.length) { + toolbarContainer.vde_historyToolbar('destroy'); + } + $(window).vde_history('destroy'); + if($(this.options.highlightElementSelector).is(':vde-vde_removable')) { + $(this.options.highlightElementSelector).vde_removable('destroy'); + } + if($(this.options.containerSelector).is(':vde-vde_container')) { + $(this.options.containerSelector).vde_container('destroy'); + } + pagePrototype._destroy.call(this); + } + })); + + /** + * Widget removable + */ + $.widget( "vde.vde_removable", { + options: { + relativeButtonSelector: '.vde_element_remove', + containerSelector: '.vde_container' + }, + history: null, + _create: function() { + this._initButtons(); + }, + _initButtons: function() { + var self = this; + // Remember that container can have block inside with their own remove buttons + this.element.children(this.options.relativeButtonSelector) + .css('display', 'block') + .find('a').bind('click', $.proxy(self._onRemoveButtonClick, self)); + }, + _onRemoveButtonClick: function() { + var change = $.fn.changeFactory.getInstance('layout'); + change.setData({ + action: 'remove', + block: this.element.data('name'), + container: this.element.parent().closest(this.options.containerSelector) + }); + + // This is the dependency of Removable on History + this.history.addItem(change); + this.remove(); + }, + setHistory: function(history) { + this.history = history; + }, + remove: function () { + this.element.remove(); + } + }); + + $(document).ready(function() { + $(window).vde_connector(); + + if (window.parent) { + (function($) { + var eventData = { + content: 'iframe', + elements: {mousedown: ['.vde_removable .vde_element_remove img', '.vde_draggable']} + }; + $('body').trigger('registerElements', eventData); + })(window.parent.jQuery); + } + }); +})( jQuery ); diff --git a/app/code/core/Mage/DesignEditor/view/frontend/js/form_deactivation.js b/app/code/Mage/DesignEditor/view/frontend/js/form_deactivation.js similarity index 100% rename from app/code/core/Mage/DesignEditor/view/frontend/js/form_deactivation.js rename to app/code/Mage/DesignEditor/view/frontend/js/form_deactivation.js diff --git a/app/code/Mage/DesignEditor/view/frontend/layout.xml b/app/code/Mage/DesignEditor/view/frontend/layout.xml new file mode 100644 index 0000000000000..97be83ac9aa73 --- /dev/null +++ b/app/code/Mage/DesignEditor/view/frontend/layout.xml @@ -0,0 +1,53 @@ + + + + + + + 1 + jquery/jquery.jsvde_design_mode + jquery/jquery-ui.jsvde_design_mode + mage/jquery-no-conflict.jsvde_design_mode + head.load.min.jsvde_design_mode + mage/mage.jsvde_design_mode + mage/decorate.jsvde_design_mode + mage/translate.jsvde_design_mode + jquery/jquery.tmpl.min.jsvde_design_mode + Mage_DesignEditor::js/design_editor.jsvde_design_mode + Mage_DesignEditor::js/form_deactivation.jsvde_design_mode + Mage_DesignEditor::js/change/layout.jsvde_design_mode + Mage_DesignEditor::css/design.cssvde_design_mode + + + + + + + + + diff --git a/app/code/core/Mage/DesignEditor/view/frontend/stub.phtml b/app/code/Mage/DesignEditor/view/frontend/stub.phtml similarity index 100% rename from app/code/core/Mage/DesignEditor/view/frontend/stub.phtml rename to app/code/Mage/DesignEditor/view/frontend/stub.phtml diff --git a/app/code/core/Mage/DesignEditor/view/frontend/toolbar/history.phtml b/app/code/Mage/DesignEditor/view/frontend/toolbar/history.phtml similarity index 100% rename from app/code/core/Mage/DesignEditor/view/frontend/toolbar/history.phtml rename to app/code/Mage/DesignEditor/view/frontend/toolbar/history.phtml diff --git a/app/code/core/Mage/DesignEditor/view/frontend/wrapper/remove.phtml b/app/code/Mage/DesignEditor/view/frontend/wrapper/remove.phtml similarity index 100% rename from app/code/core/Mage/DesignEditor/view/frontend/wrapper/remove.phtml rename to app/code/Mage/DesignEditor/view/frontend/wrapper/remove.phtml diff --git a/app/code/core/Mage/DesignEditor/view/frontend/wrapping.phtml b/app/code/Mage/DesignEditor/view/frontend/wrapping.phtml similarity index 100% rename from app/code/core/Mage/DesignEditor/view/frontend/wrapping.phtml rename to app/code/Mage/DesignEditor/view/frontend/wrapping.phtml diff --git a/app/code/core/Mage/Directory/Block/Adminhtml/Frontend/Currency/Base.php b/app/code/Mage/Directory/Block/Adminhtml/Frontend/Currency/Base.php similarity index 100% rename from app/code/core/Mage/Directory/Block/Adminhtml/Frontend/Currency/Base.php rename to app/code/Mage/Directory/Block/Adminhtml/Frontend/Currency/Base.php diff --git a/app/code/core/Mage/Directory/Block/Adminhtml/Frontend/Region/Updater.php b/app/code/Mage/Directory/Block/Adminhtml/Frontend/Region/Updater.php similarity index 100% rename from app/code/core/Mage/Directory/Block/Adminhtml/Frontend/Region/Updater.php rename to app/code/Mage/Directory/Block/Adminhtml/Frontend/Region/Updater.php diff --git a/app/code/core/Mage/Directory/Block/Currency.php b/app/code/Mage/Directory/Block/Currency.php similarity index 100% rename from app/code/core/Mage/Directory/Block/Currency.php rename to app/code/Mage/Directory/Block/Currency.php diff --git a/app/code/Mage/Directory/Block/Data.php b/app/code/Mage/Directory/Block/Data.php new file mode 100644 index 0000000000000..24d68b25818d7 --- /dev/null +++ b/app/code/Mage/Directory/Block/Data.php @@ -0,0 +1,170 @@ + + */ +class Mage_Directory_Block_Data extends Mage_Core_Block_Template +{ + /** + * @var Mage_Core_Model_Cache_Type_Config + */ + protected $_configCacheType; + + /** + * @param Mage_Core_Block_Template_Context $context + * @param Mage_Core_Model_Cache_Type_Config $configCacheType + * @param array $data + */ + public function __construct( + Mage_Core_Block_Template_Context $context, + Mage_Core_Model_Cache_Type_Config $configCacheType, + array $data = array() + ) { + parent::__construct($context, $data); + $this->_configCacheType = $configCacheType; + } + + public function getLoadrRegionUrl() + { + return $this->getUrl('directory/json/childRegion'); + } + + public function getCountryCollection() + { + $collection = $this->getData('country_collection'); + if (is_null($collection)) { + $collection = Mage::getModel('Mage_Directory_Model_Country')->getResourceCollection() + ->loadByStore(); + $this->setData('country_collection', $collection); + } + + return $collection; + } + + public function getCountryHtmlSelect($defValue=null, $name='country_id', $id='country', $title='Country') + { + Magento_Profiler::start('TEST: '.__METHOD__, array('group' => 'TEST', 'method' => __METHOD__)); + if (is_null($defValue)) { + $defValue = $this->getCountryId(); + } + $cacheKey = 'DIRECTORY_COUNTRY_SELECT_STORE_' . Mage::app()->getStore()->getCode(); + if ($cache = $this->_configCacheType->load($cacheKey)) { + $options = unserialize($cache); + } else { + $options = $this->getCountryCollection()->toOptionArray(); + $this->_configCacheType->save(serialize($options), $cacheKey); + } + $html = $this->getLayout()->createBlock('Mage_Core_Block_Html_Select') + ->setName($name) + ->setId($id) + ->setTitle(Mage::helper('Mage_Directory_Helper_Data')->__($title)) + ->setClass('validate-select') + ->setValue($defValue) + ->setOptions($options) + ->getHtml(); + + Magento_Profiler::stop('TEST: '.__METHOD__); + return $html; + } + + public function getRegionCollection() + { + $collection = $this->getData('region_collection'); + if (is_null($collection)) { + $collection = Mage::getModel('Mage_Directory_Model_Region')->getResourceCollection() + ->addCountryFilter($this->getCountryId()) + ->load(); + + $this->setData('region_collection', $collection); + } + return $collection; + } + + + public function getRegionHtmlSelect() + { + Magento_Profiler::start('TEST: '.__METHOD__, array('group' => 'TEST', 'method' => __METHOD__)); + $cacheKey = 'DIRECTORY_REGION_SELECT_STORE' . Mage::app()->getStore()->getId(); + if ($cache = $this->_configCacheType->load($cacheKey)) { + $options = unserialize($cache); + } else { + $options = $this->getRegionCollection()->toOptionArray(); + $this->_configCacheType->save(serialize($options), $cacheKey); + } + $html = $this->getLayout()->createBlock('Mage_Core_Block_Html_Select') + ->setName('region') + ->setTitle(Mage::helper('Mage_Directory_Helper_Data')->__('State/Province')) + ->setId('state') + ->setClass('required-entry validate-state') + ->setValue(intval($this->getRegionId())) + ->setOptions($options) + ->getHtml(); + Magento_Profiler::start('TEST: '.__METHOD__, array('group' => 'TEST', 'method' => __METHOD__)); + return $html; + } + + public function getCountryId() + { + $countryId = $this->getData('country_id'); + if (is_null($countryId)) { + $countryId = Mage::helper('Mage_Core_Helper_Data')->getDefaultCountry(); + } + return $countryId; + } + + public function getRegionsJs() + { + Magento_Profiler::start('TEST: '.__METHOD__, array('group' => 'TEST', 'method' => __METHOD__)); + $regionsJs = $this->getData('regions_js'); + if (!$regionsJs) { + $countryIds = array(); + foreach ($this->getCountryCollection() as $country) { + $countryIds[] = $country->getCountryId(); + } + $collection = Mage::getModel('Mage_Directory_Model_Region')->getResourceCollection() + ->addCountryFilter($countryIds) + ->load(); + $regions = array(); + foreach ($collection as $region) { + if (!$region->getRegionId()) { + continue; + } + $regions[$region->getCountryId()][$region->getRegionId()] = array( + 'code'=>$region->getCode(), + 'name'=>$region->getName() + ); + } + $regionsJs = Mage::helper('Mage_Core_Helper_Data')->jsonEncode($regions); + } + Magento_Profiler::stop('TEST: '.__METHOD__); + return $regionsJs; + } +} diff --git a/app/code/core/Mage/Directory/Exception.php b/app/code/Mage/Directory/Exception.php similarity index 100% rename from app/code/core/Mage/Directory/Exception.php rename to app/code/Mage/Directory/Exception.php diff --git a/app/code/Mage/Directory/Helper/Data.php b/app/code/Mage/Directory/Helper/Data.php new file mode 100644 index 0000000000000..62782f1511d7d --- /dev/null +++ b/app/code/Mage/Directory/Helper/Data.php @@ -0,0 +1,263 @@ + + */ +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'; + + /* + * Path to config value, which lists countries, for which state is required. + */ + const XML_PATH_STATES_REQUIRED = 'general/region/state_required'; + + /* + * Path to config value, which detects whether or not display the state for the country, if it is not required + */ + const XML_PATH_DISPLAY_ALL_STATES = 'general/region/display_all'; + + /** + * 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; + + /** + * @var Mage_Core_Model_Cache_Type_Config + */ + protected $_configCacheType; + + /** + * @param Mage_Core_Helper_Context $context + * @param Mage_Core_Model_Cache_Type_Config $configCacheType + */ + public function __construct(Mage_Core_Helper_Context $context, Mage_Core_Model_Cache_Type_Config $configCacheType) + { + parent::__construct($context); + $this->_configCacheType = $configCacheType; + } + + /** + * Retrieve region collection + * + * @return Mage_Directory_Model_Resource_Region_Collection + */ + public function getRegionCollection() + { + if (!$this->_regionCollection) { + $this->_regionCollection = Mage::getModel('Mage_Directory_Model_Region')->getResourceCollection() + ->addCountryFilter($this->getAddress()->getCountryId()) + ->load(); + } + return $this->_regionCollection; + } + + /** + * Retrieve country collection + * + * @return Mage_Directory_Model_Resource_Country_Collection + */ + public function getCountryCollection() + { + if (!$this->_countryCollection) { + $this->_countryCollection = Mage::getModel('Mage_Directory_Model_Country')->getResourceCollection() + ->loadByStore(); + } + return $this->_countryCollection; + } + + /** + * Retrieve regions data json + * + * @return string + */ + public function getRegionJson() + { + + Magento_Profiler::start('TEST: '.__METHOD__, array('group' => 'TEST', 'method' => __METHOD__)); + if (!$this->_regionJson) { + $cacheKey = 'DIRECTORY_REGIONS_JSON_STORE' . Mage::app()->getStore()->getId(); + $json = $this->_configCacheType->load($cacheKey); + if (empty($json)) { + $countryIds = array(); + foreach ($this->getCountryCollection() as $country) { + $countryIds[] = $country->getCountryId(); + } + $collection = Mage::getModel('Mage_Directory_Model_Region')->getResourceCollection() + ->addCountryFilter($countryIds) + ->load(); + $regions = array( + 'config' => array( + 'show_all_regions' => $this->getShowNonRequiredState(), + 'regions_required' => $this->getCountriesWithStatesRequired() + ) + ); + foreach ($collection as $region) { + if (!$region->getRegionId()) { + continue; + } + $regions[$region->getCountryId()][$region->getRegionId()] = array( + 'code' => $region->getCode(), + 'name' => $this->__($region->getName()) + ); + } + $json = Mage::helper('Mage_Core_Helper_Data')->jsonEncode($regions); + + $this->_configCacheType->save($json, $cacheKey); + } + $this->_regionJson = $json; + } + + Magento_Profiler::stop('TEST: '.__METHOD__); + return $this->_regionJson; + } + + /** + * 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('Mage_Directory_Model_Currency')->load($from); + } + if (is_null($to)) { + $to = Mage::app()->getStore()->getCurrentCurrencyCode(); + } + $converted = $this->_currencyCache[$from]->convert($amount, $to); + return $converted; + } + + /** + * Return ISO2 country codes, which have optional Zip/Postal pre-configured + * + * @param bool $asJson + * @return array|string + */ + public function getCountriesWithOptionalZip($asJson = false) + { + if (null === $this->_optionalZipCountries) { + $this->_optionalZipCountries = preg_split('/\,/', + Mage::getStoreConfig(self::OPTIONAL_ZIP_COUNTRIES_CONFIG_PATH), 0, PREG_SPLIT_NO_EMPTY); + } + if ($asJson) { + return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($this->_optionalZipCountries); + } + return $this->_optionalZipCountries; + } + + /** + * Check whether zip code is optional for specified country code + * + * @param string $countryCode + * @return boolean + */ + public function isZipCodeOptional($countryCode) + { + $this->getCountriesWithOptionalZip(); + return in_array($countryCode, $this->_optionalZipCountries); + } + + /** + * Returns the list of countries, for which region is required + * + * @param boolean $asJson + * @return array + */ + public function getCountriesWithStatesRequired($asJson = false) + { + $countryList = explode(',', Mage::getStoreConfig(self::XML_PATH_STATES_REQUIRED)); + if ($asJson) { + return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($countryList); + } + return $countryList; + } + + /** + * Return flag, which indicates whether or not non required state should be shown + * + * @return bool + */ + public function getShowNonRequiredState() + { + return (boolean)Mage::getStoreConfig(self::XML_PATH_DISPLAY_ALL_STATES); + } + + /** + * Returns flag, which indicates whether region is required for specified country + * + * @param string $countryId + * @return bool + */ + public function isRegionRequired($countryId) + { + $countyList = $this->getCountriesWithStatesRequired(); + if(!is_array($countyList)) { + return false; + } + return in_array($countryId, $countyList); + } +} diff --git a/app/code/core/Mage/Directory/Helper/Url.php b/app/code/Mage/Directory/Helper/Url.php similarity index 100% rename from app/code/core/Mage/Directory/Helper/Url.php rename to app/code/Mage/Directory/Helper/Url.php diff --git a/app/code/core/Mage/Directory/Model/Config/Source/Allregion.php b/app/code/Mage/Directory/Model/Config/Source/Allregion.php similarity index 100% rename from app/code/core/Mage/Directory/Model/Config/Source/Allregion.php rename to app/code/Mage/Directory/Model/Config/Source/Allregion.php diff --git a/app/code/core/Mage/Directory/Model/Config/Source/Country.php b/app/code/Mage/Directory/Model/Config/Source/Country.php similarity index 100% rename from app/code/core/Mage/Directory/Model/Config/Source/Country.php rename to app/code/Mage/Directory/Model/Config/Source/Country.php diff --git a/app/code/core/Mage/Directory/Model/Config/Source/Country/Full.php b/app/code/Mage/Directory/Model/Config/Source/Country/Full.php similarity index 100% rename from app/code/core/Mage/Directory/Model/Config/Source/Country/Full.php rename to app/code/Mage/Directory/Model/Config/Source/Country/Full.php diff --git a/app/code/core/Mage/Directory/Model/Country.php b/app/code/Mage/Directory/Model/Country.php similarity index 100% rename from app/code/core/Mage/Directory/Model/Country.php rename to app/code/Mage/Directory/Model/Country.php diff --git a/app/code/core/Mage/Directory/Model/Country/Api.php b/app/code/Mage/Directory/Model/Country/Api.php similarity index 100% rename from app/code/core/Mage/Directory/Model/Country/Api.php rename to app/code/Mage/Directory/Model/Country/Api.php diff --git a/app/code/core/Mage/Directory/Model/Country/Api/V2.php b/app/code/Mage/Directory/Model/Country/Api/V2.php similarity index 100% rename from app/code/core/Mage/Directory/Model/Country/Api/V2.php rename to app/code/Mage/Directory/Model/Country/Api/V2.php diff --git a/app/code/core/Mage/Directory/Model/Country/Format.php b/app/code/Mage/Directory/Model/Country/Format.php similarity index 100% rename from app/code/core/Mage/Directory/Model/Country/Format.php rename to app/code/Mage/Directory/Model/Country/Format.php diff --git a/app/code/core/Mage/Directory/Model/Currency.php b/app/code/Mage/Directory/Model/Currency.php similarity index 100% rename from app/code/core/Mage/Directory/Model/Currency.php rename to app/code/Mage/Directory/Model/Currency.php diff --git a/app/code/core/Mage/Directory/Model/Currency/DefaultLocator.php b/app/code/Mage/Directory/Model/Currency/DefaultLocator.php similarity index 100% rename from app/code/core/Mage/Directory/Model/Currency/DefaultLocator.php rename to app/code/Mage/Directory/Model/Currency/DefaultLocator.php diff --git a/app/code/core/Mage/Directory/Model/Currency/Filter.php b/app/code/Mage/Directory/Model/Currency/Filter.php similarity index 100% rename from app/code/core/Mage/Directory/Model/Currency/Filter.php rename to app/code/Mage/Directory/Model/Currency/Filter.php diff --git a/app/code/core/Mage/Directory/Model/Currency/Import/Abstract.php b/app/code/Mage/Directory/Model/Currency/Import/Abstract.php similarity index 100% rename from app/code/core/Mage/Directory/Model/Currency/Import/Abstract.php rename to app/code/Mage/Directory/Model/Currency/Import/Abstract.php diff --git a/app/code/core/Mage/Directory/Model/Currency/Import/Webservicex.php b/app/code/Mage/Directory/Model/Currency/Import/Webservicex.php similarity index 100% rename from app/code/core/Mage/Directory/Model/Currency/Import/Webservicex.php rename to app/code/Mage/Directory/Model/Currency/Import/Webservicex.php diff --git a/app/code/core/Mage/Directory/Model/Observer.php b/app/code/Mage/Directory/Model/Observer.php similarity index 100% rename from app/code/core/Mage/Directory/Model/Observer.php rename to app/code/Mage/Directory/Model/Observer.php diff --git a/app/code/core/Mage/Directory/Model/Region.php b/app/code/Mage/Directory/Model/Region.php similarity index 100% rename from app/code/core/Mage/Directory/Model/Region.php rename to app/code/Mage/Directory/Model/Region.php diff --git a/app/code/core/Mage/Directory/Model/Region/Api.php b/app/code/Mage/Directory/Model/Region/Api.php similarity index 100% rename from app/code/core/Mage/Directory/Model/Region/Api.php rename to app/code/Mage/Directory/Model/Region/Api.php diff --git a/app/code/core/Mage/Directory/Model/Region/Api/V2.php b/app/code/Mage/Directory/Model/Region/Api/V2.php similarity index 100% rename from app/code/core/Mage/Directory/Model/Region/Api/V2.php rename to app/code/Mage/Directory/Model/Region/Api/V2.php diff --git a/app/code/core/Mage/Directory/Model/RegionFactory.php b/app/code/Mage/Directory/Model/RegionFactory.php similarity index 98% rename from app/code/core/Mage/Directory/Model/RegionFactory.php rename to app/code/Mage/Directory/Model/RegionFactory.php index 27438b543c144..69bb29570d9ed 100644 --- a/app/code/core/Mage/Directory/Model/RegionFactory.php +++ b/app/code/Mage/Directory/Model/RegionFactory.php @@ -54,6 +54,6 @@ public function __construct(Magento_ObjectManager $objectManager) */ public function create(array $arguments = array()) { - return $this->_objectManager->create('Mage_Directory_Model_Region', $arguments, false); + return $this->_objectManager->create('Mage_Directory_Model_Region', $arguments); } } diff --git a/app/code/core/Mage/Directory/Model/Resource/Country.php b/app/code/Mage/Directory/Model/Resource/Country.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Directory/Model/Resource/Country.php rename to app/code/Mage/Directory/Model/Resource/Country.php diff --git a/app/code/core/Mage/Directory/Model/Resource/Country/Collection.php b/app/code/Mage/Directory/Model/Resource/Country/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Directory/Model/Resource/Country/Collection.php rename to app/code/Mage/Directory/Model/Resource/Country/Collection.php diff --git a/app/code/core/Mage/Directory/Model/Resource/Country/Format.php b/app/code/Mage/Directory/Model/Resource/Country/Format.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Directory/Model/Resource/Country/Format.php rename to app/code/Mage/Directory/Model/Resource/Country/Format.php diff --git a/app/code/core/Mage/Directory/Model/Resource/Country/Format/Collection.php b/app/code/Mage/Directory/Model/Resource/Country/Format/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Directory/Model/Resource/Country/Format/Collection.php rename to app/code/Mage/Directory/Model/Resource/Country/Format/Collection.php diff --git a/app/code/core/Mage/Directory/Model/Resource/Currency.php b/app/code/Mage/Directory/Model/Resource/Currency.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Directory/Model/Resource/Currency.php rename to app/code/Mage/Directory/Model/Resource/Currency.php diff --git a/app/code/core/Mage/Directory/Model/Resource/Region.php b/app/code/Mage/Directory/Model/Resource/Region.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Directory/Model/Resource/Region.php rename to app/code/Mage/Directory/Model/Resource/Region.php diff --git a/app/code/core/Mage/Directory/Model/Resource/Region/Collection.php b/app/code/Mage/Directory/Model/Resource/Region/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Directory/Model/Resource/Region/Collection.php rename to app/code/Mage/Directory/Model/Resource/Region/Collection.php diff --git a/app/code/core/Mage/Directory/controllers/CurrencyController.php b/app/code/Mage/Directory/controllers/CurrencyController.php similarity index 100% rename from app/code/core/Mage/Directory/controllers/CurrencyController.php rename to app/code/Mage/Directory/controllers/CurrencyController.php diff --git a/app/code/core/Mage/Directory/data/directory_setup/data-install-1.6.0.0.php b/app/code/Mage/Directory/data/directory_setup/data-install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Directory/data/directory_setup/data-install-1.6.0.0.php rename to app/code/Mage/Directory/data/directory_setup/data-install-1.6.0.0.php diff --git a/app/code/core/Mage/Directory/data/directory_setup/data-upgrade-1.6.0.0-1.6.0.1.php b/app/code/Mage/Directory/data/directory_setup/data-upgrade-1.6.0.0-1.6.0.1.php similarity index 100% rename from app/code/core/Mage/Directory/data/directory_setup/data-upgrade-1.6.0.0-1.6.0.1.php rename to app/code/Mage/Directory/data/directory_setup/data-upgrade-1.6.0.0-1.6.0.1.php diff --git a/app/code/core/Mage/Directory/etc/adminhtml/system.xml b/app/code/Mage/Directory/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Directory/etc/adminhtml/system.xml rename to app/code/Mage/Directory/etc/adminhtml/system.xml diff --git a/app/code/core/Mage/Directory/etc/api.xml b/app/code/Mage/Directory/etc/api.xml similarity index 100% rename from app/code/core/Mage/Directory/etc/api.xml rename to app/code/Mage/Directory/etc/api.xml diff --git a/app/code/Mage/Directory/etc/config.xml b/app/code/Mage/Directory/etc/config.xml new file mode 100644 index 0000000000000..5a4b54d71eda1 --- /dev/null +++ b/app/code/Mage/Directory/etc/config.xml @@ -0,0 +1,152 @@ + + + + + + 1.6.0.1 + true + + + + + + + + + + + Webservicex + Mage_Directory_Model_Currency_Import_Webservicex + + + + + + + + Mage_Directory + + + + + + + + + standard + + Mage_Directory + directory + + + + + + + + Mage_Directory.csv + + + + + + + + layout.xml + + + + + + + + + + Mage_Directory.csv + + + + + + + + + AZN,AZM,AFN,ALL,DZD,AOA,ARS,AMD,AWG,AUD,BSD,BHD,BDT,BBD,BYR,BZD,BMD,BTN,BOB,BAM,BWP,BRL,GBP,BND,BGN,BUK,BIF,KHR,CAD,CVE,CZK,KYD,CLP,CNY,COP,KMF,CDF,CRC,HRK,CUP,DKK,DJF,DOP,XCD,EGP,SVC,GQE,ERN,EEK,ETB,EUR,FKP,FJD,GMD,GEK,GEL,GHS,GIP,GTQ,GNF,GYD,HTG,HNL,HKD,HUF,ISK,INR,IDR,IRR,IQD,ILS,JMD,JPY,JOD,KZT,KES,KWD,KGS,LAK,LVL,LBP,LSL,LRD,LYD,LTL,MOP,MKD,MGA,MWK,MYR,MVR,LSM,MRO,MUR,MXN,MDL,MNT,MAD,MZN,MMK,NAD,NPR,ANG,TRL,TRY,NZD,NIC,NGN,KPW,NOK,OMR,PKR,PAB,PGK,PYG,PEN,PHP,PLN,QAR,RHD,RON,ROL,RUB,RWF,SHP,STD,SAR,RSD,SCR,SLL,SGD,SKK,SBD,SOS,ZAR,KRW,LKR,SDG,SRD,SZL,SEK,CHF,SYP,TWD,TJS,TZS,THB,TOP,TTD,TND,TMM,USD,UGX,UAH,AED,UYU,UZS,VUV,VEB,VEF,VND,CHE,CHW,XOF,XPF,WST,YER,ZMK,ZWD + + + + + USD,EUR + USD + USD + + + 100 + + + 0 + + general + currency_import_error_email_template + + + + + HK,IE,MO,PA + AF,AL,DZ,AS,AD,AO,AI,AQ,AG,AR,AM,AW,AU,AT,AX,AZ,BS,BH,BD,BB,BY,BE,BZ,BJ,BM,BL,BT,BO,BA,BW,BV,BR,IO,VG,BN,BG,BF,BI,KH,CM,CA,CD,CV,KY,CF,TD,CL,CN,CX,CC,CO,KM,CG,CK,CR,HR,CU,CY,CZ,DK,DJ,DM,DO,EC,EG,SV,GQ,ER,EE,ET,FK,FO,FJ,FI,FR,GF,PF,TF,GA,GM,GE,DE,GG,GH,GI,GR,GL,GD,GP,GU,GT,GN,GW,GY,HT,HM,HN,HK,HU,IS,IM,IN,ID,IR,IQ,IE,IL,IT,CI,JE,JM,JP,JO,KZ,KE,KI,KW,KG,LA,LV,LB,LS,LR,LY,LI,LT,LU,ME,MF,MO,MK,MG,MW,MY,MV,ML,MT,MH,MQ,MR,MU,YT,FX,MX,FM,MD,MC,MN,MS,MA,MZ,MM,NA,NR,NP,NL,AN,NC,NZ,NI,NE,NG,NU,NF,KP,MP,NO,OM,PK,PW,PA,PG,PY,PE,PH,PN,PL,PS,PT,PR,QA,RE,RO,RS,RU,RW,SH,KN,LC,PM,VC,WS,SM,ST,SA,SN,SC,SL,SG,SK,SI,SB,SO,ZA,GS,KR,ES,LK,SD,SR,SJ,SZ,SE,CH,SY,TL,TW,TJ,TZ,TH,TG,TK,TO,TT,TN,TR,TM,TC,TV,VI,UG,UA,AE,GB,US,UM,UY,UZ,VU,VA,VE,VN,WF,EH,YE,ZM,ZW + US + + + %A, %B %e %Y [%I:%M %p] + %a, %b %e %Y [%I:%M %p] + %m/%d/%y [%I:%M %p] + %A, %B %e %Y + %a, %b %e %Y + %m/%d/%y + en + + + + + + + + Mage_Directory_Model_Observer::scheduledUpdateCurrencyRates + + + + + diff --git a/app/code/core/Mage/Directory/etc/wsdl.xml b/app/code/Mage/Directory/etc/wsdl.xml similarity index 100% rename from app/code/core/Mage/Directory/etc/wsdl.xml rename to app/code/Mage/Directory/etc/wsdl.xml diff --git a/app/code/core/Mage/Directory/etc/wsi.xml b/app/code/Mage/Directory/etc/wsi.xml similarity index 100% rename from app/code/core/Mage/Directory/etc/wsi.xml rename to app/code/Mage/Directory/etc/wsi.xml diff --git a/app/code/core/Mage/Directory/locale/de_DE/Mage_Directory.csv b/app/code/Mage/Directory/locale/de_DE/Mage_Directory.csv similarity index 100% rename from app/code/core/Mage/Directory/locale/de_DE/Mage_Directory.csv rename to app/code/Mage/Directory/locale/de_DE/Mage_Directory.csv diff --git a/app/code/core/Mage/Directory/locale/en_US/Mage_Directory.csv b/app/code/Mage/Directory/locale/en_US/Mage_Directory.csv similarity index 100% rename from app/code/core/Mage/Directory/locale/en_US/Mage_Directory.csv rename to app/code/Mage/Directory/locale/en_US/Mage_Directory.csv diff --git a/app/code/core/Mage/Directory/locale/es_ES/Mage_Directory.csv b/app/code/Mage/Directory/locale/es_ES/Mage_Directory.csv similarity index 100% rename from app/code/core/Mage/Directory/locale/es_ES/Mage_Directory.csv rename to app/code/Mage/Directory/locale/es_ES/Mage_Directory.csv diff --git a/app/code/core/Mage/Directory/locale/fr_FR/Mage_Directory.csv b/app/code/Mage/Directory/locale/fr_FR/Mage_Directory.csv similarity index 100% rename from app/code/core/Mage/Directory/locale/fr_FR/Mage_Directory.csv rename to app/code/Mage/Directory/locale/fr_FR/Mage_Directory.csv diff --git a/app/code/core/Mage/Directory/locale/nl_NL/Mage_Directory.csv b/app/code/Mage/Directory/locale/nl_NL/Mage_Directory.csv similarity index 100% rename from app/code/core/Mage/Directory/locale/nl_NL/Mage_Directory.csv rename to app/code/Mage/Directory/locale/nl_NL/Mage_Directory.csv diff --git a/app/code/core/Mage/Directory/locale/pt_BR/Mage_Directory.csv b/app/code/Mage/Directory/locale/pt_BR/Mage_Directory.csv similarity index 100% rename from app/code/core/Mage/Directory/locale/pt_BR/Mage_Directory.csv rename to app/code/Mage/Directory/locale/pt_BR/Mage_Directory.csv diff --git a/app/code/core/Mage/Directory/locale/zh_CN/Mage_Directory.csv b/app/code/Mage/Directory/locale/zh_CN/Mage_Directory.csv similarity index 100% rename from app/code/core/Mage/Directory/locale/zh_CN/Mage_Directory.csv rename to app/code/Mage/Directory/locale/zh_CN/Mage_Directory.csv diff --git a/app/code/core/Mage/Directory/sql/directory_setup/install-1.6.0.0.php b/app/code/Mage/Directory/sql/directory_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Directory/sql/directory_setup/install-1.6.0.0.php rename to app/code/Mage/Directory/sql/directory_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Directory/view/adminhtml/js/optional_zip_countries.phtml b/app/code/Mage/Directory/view/adminhtml/js/optional_zip_countries.phtml similarity index 100% rename from app/code/core/Mage/Directory/view/adminhtml/js/optional_zip_countries.phtml rename to app/code/Mage/Directory/view/adminhtml/js/optional_zip_countries.phtml diff --git a/app/code/core/Mage/Directory/view/email/currency_update_notification.html b/app/code/Mage/Directory/view/email/currency_update_notification.html similarity index 100% rename from app/code/core/Mage/Directory/view/email/currency_update_notification.html rename to app/code/Mage/Directory/view/email/currency_update_notification.html diff --git a/app/code/core/Mage/Directory/view/frontend/currency.phtml b/app/code/Mage/Directory/view/frontend/currency.phtml similarity index 100% rename from app/code/core/Mage/Directory/view/frontend/currency.phtml rename to app/code/Mage/Directory/view/frontend/currency.phtml diff --git a/app/code/core/Mage/Directory/view/frontend/currency/switch.phtml b/app/code/Mage/Directory/view/frontend/currency/switch.phtml similarity index 100% rename from app/code/core/Mage/Directory/view/frontend/currency/switch.phtml rename to app/code/Mage/Directory/view/frontend/currency/switch.phtml diff --git a/app/code/core/Mage/Directory/view/frontend/js/optional_zip_countries.phtml b/app/code/Mage/Directory/view/frontend/js/optional_zip_countries.phtml similarity index 100% rename from app/code/core/Mage/Directory/view/frontend/js/optional_zip_countries.phtml rename to app/code/Mage/Directory/view/frontend/js/optional_zip_countries.phtml diff --git a/app/code/core/Mage/Directory/view/frontend/layout.xml b/app/code/Mage/Directory/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/Directory/view/frontend/layout.xml rename to app/code/Mage/Directory/view/frontend/layout.xml diff --git a/app/code/core/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Downloadable.php b/app/code/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Downloadable.php similarity index 100% rename from app/code/core/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Downloadable.php rename to app/code/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Downloadable.php diff --git a/app/code/core/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable.php b/app/code/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable.php similarity index 95% rename from app/code/core/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable.php rename to app/code/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable.php index d1e6846e1666f..dc7c26f338d89 100644 --- a/app/code/core/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable.php +++ b/app/code/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable.php @@ -126,6 +126,14 @@ public function isHidden() return false; } + /** + * @return string + */ + public function getGroupCode() + { + return Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs::ADVANCED_TAB_GROUP_CODE; + } + /** * Render block HTML * diff --git a/app/code/core/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php b/app/code/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php similarity index 100% rename from app/code/core/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php rename to app/code/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php diff --git a/app/code/core/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Samples.php b/app/code/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Samples.php similarity index 100% rename from app/code/core/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Samples.php rename to app/code/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Samples.php diff --git a/app/code/core/Mage/Downloadable/Block/Adminhtml/Sales/Items/Column/Downloadable/Name.php b/app/code/Mage/Downloadable/Block/Adminhtml/Sales/Items/Column/Downloadable/Name.php similarity index 100% rename from app/code/core/Mage/Downloadable/Block/Adminhtml/Sales/Items/Column/Downloadable/Name.php rename to app/code/Mage/Downloadable/Block/Adminhtml/Sales/Items/Column/Downloadable/Name.php diff --git a/app/code/core/Mage/Downloadable/Block/Catalog/Product/Links.php b/app/code/Mage/Downloadable/Block/Catalog/Product/Links.php similarity index 100% rename from app/code/core/Mage/Downloadable/Block/Catalog/Product/Links.php rename to app/code/Mage/Downloadable/Block/Catalog/Product/Links.php diff --git a/app/code/core/Mage/Downloadable/Block/Catalog/Product/Samples.php b/app/code/Mage/Downloadable/Block/Catalog/Product/Samples.php similarity index 100% rename from app/code/core/Mage/Downloadable/Block/Catalog/Product/Samples.php rename to app/code/Mage/Downloadable/Block/Catalog/Product/Samples.php diff --git a/app/code/core/Mage/Downloadable/Block/Catalog/Product/View/Type.php b/app/code/Mage/Downloadable/Block/Catalog/Product/View/Type.php similarity index 100% rename from app/code/core/Mage/Downloadable/Block/Catalog/Product/View/Type.php rename to app/code/Mage/Downloadable/Block/Catalog/Product/View/Type.php diff --git a/app/code/core/Mage/Downloadable/Block/Checkout/Cart/Item/Renderer.php b/app/code/Mage/Downloadable/Block/Checkout/Cart/Item/Renderer.php similarity index 100% rename from app/code/core/Mage/Downloadable/Block/Checkout/Cart/Item/Renderer.php rename to app/code/Mage/Downloadable/Block/Checkout/Cart/Item/Renderer.php diff --git a/app/code/core/Mage/Downloadable/Block/Checkout/Success.php b/app/code/Mage/Downloadable/Block/Checkout/Success.php similarity index 100% rename from app/code/core/Mage/Downloadable/Block/Checkout/Success.php rename to app/code/Mage/Downloadable/Block/Checkout/Success.php diff --git a/app/code/core/Mage/Downloadable/Block/Customer/Products/List.php b/app/code/Mage/Downloadable/Block/Customer/Products/List.php similarity index 100% rename from app/code/core/Mage/Downloadable/Block/Customer/Products/List.php rename to app/code/Mage/Downloadable/Block/Customer/Products/List.php diff --git a/app/code/core/Mage/Downloadable/Block/Sales/Order/Email/Items/Downloadable.php b/app/code/Mage/Downloadable/Block/Sales/Order/Email/Items/Downloadable.php similarity index 100% rename from app/code/core/Mage/Downloadable/Block/Sales/Order/Email/Items/Downloadable.php rename to app/code/Mage/Downloadable/Block/Sales/Order/Email/Items/Downloadable.php diff --git a/app/code/core/Mage/Downloadable/Block/Sales/Order/Email/Items/Order/Downloadable.php b/app/code/Mage/Downloadable/Block/Sales/Order/Email/Items/Order/Downloadable.php similarity index 100% rename from app/code/core/Mage/Downloadable/Block/Sales/Order/Email/Items/Order/Downloadable.php rename to app/code/Mage/Downloadable/Block/Sales/Order/Email/Items/Order/Downloadable.php diff --git a/app/code/core/Mage/Downloadable/Block/Sales/Order/Item/Renderer/Downloadable.php b/app/code/Mage/Downloadable/Block/Sales/Order/Item/Renderer/Downloadable.php similarity index 100% rename from app/code/core/Mage/Downloadable/Block/Sales/Order/Item/Renderer/Downloadable.php rename to app/code/Mage/Downloadable/Block/Sales/Order/Item/Renderer/Downloadable.php diff --git a/app/code/core/Mage/Downloadable/Helper/Catalog/Product/Configuration.php b/app/code/Mage/Downloadable/Helper/Catalog/Product/Configuration.php similarity index 100% rename from app/code/core/Mage/Downloadable/Helper/Catalog/Product/Configuration.php rename to app/code/Mage/Downloadable/Helper/Catalog/Product/Configuration.php diff --git a/app/code/core/Mage/Downloadable/Helper/Data.php b/app/code/Mage/Downloadable/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Downloadable/Helper/Data.php rename to app/code/Mage/Downloadable/Helper/Data.php diff --git a/app/code/core/Mage/Downloadable/Helper/Download.php b/app/code/Mage/Downloadable/Helper/Download.php similarity index 100% rename from app/code/core/Mage/Downloadable/Helper/Download.php rename to app/code/Mage/Downloadable/Helper/Download.php diff --git a/app/code/Mage/Downloadable/Helper/File.php b/app/code/Mage/Downloadable/Helper/File.php new file mode 100644 index 0000000000000..829b73c86a01d --- /dev/null +++ b/app/code/Mage/Downloadable/Helper/File.php @@ -0,0 +1,784 @@ + + */ +class Mage_Downloadable_Helper_File extends Mage_Core_Helper_Abstract +{ + /** + * @param Mage_Core_Helper_Context $context + * @param Mage_Core_Model_Config $config + */ + public function __construct(Mage_Core_Helper_Context $context, Mage_Core_Model_Config $config) + { + parent::__construct($context); + $nodes = $config->getNode('global/mime/types'); + if ($nodes) { + $nodes = (array)$nodes; + foreach ($nodes as $key => $value) { + self::$_mimeTypes[$key] = $value; + } + } + } + + /** + * Checking file for moving and move it + * + * @param string $baseTmpPath + * @param string $basePath + * @param array $file + * @return string + */ + public function moveFileFromTmp($baseTmpPath, $basePath, $file) + { + if (isset($file[0])) { + $fileName = $file[0]['file']; + if ($file[0]['status'] == 'new') { + try { + $fileName = $this->_moveFileFromTmp( + $baseTmpPath, $basePath, $file[0]['file'] + ); + } catch (Exception $e) { + Mage::throwException(Mage::helper('Mage_Downloadable_Helper_Data')->__('An error occurred while saving the file(s).')); + } + } + return $fileName; + } + return ''; + } + + /** + * Move file from tmp path to base path + * + * @param string $baseTmpPath + * @param string $basePath + * @param string $file + * @return string + */ + protected function _moveFileFromTmp($baseTmpPath, $basePath, $file) + { + $ioObject = new Varien_Io_File(); + $destDirectory = dirname($this->getFilePath($basePath, $file)); + try { + $ioObject->open(array('path'=>$destDirectory)); + } catch (Exception $e) { + $ioObject->mkdir($destDirectory, 0777, true); + $ioObject->open(array('path'=>$destDirectory)); + } + + if (strrpos($file, '.tmp') == strlen($file)-4) { + $file = substr($file, 0, strlen($file)-4); + } + + $destFile = dirname($file) . $ioObject->dirsep() + . Mage_Core_Model_File_Uploader::getNewFileName($this->getFilePath($basePath, $file)); + + Mage::helper('Mage_Core_Helper_File_Storage_Database')->copyFile( + $this->getFilePath($baseTmpPath, $file), + $this->getFilePath($basePath, $destFile) + ); + + $result = $ioObject->mv( + $this->getFilePath($baseTmpPath, $file), + $this->getFilePath($basePath, $destFile) + ); + return str_replace($ioObject->dirsep(), '/', $destFile); + } + + /** + * Return full path to file + * + * @param string $path + * @param string $file + * @return string + */ + public function getFilePath($path, $file) + { + $file = $this->_prepareFileForPath($file); + + if(substr($file, 0, 1) == DS) { + return $path . DS . substr($file, 1); + } + + return $path . DS . $file; + } + + /** + * Replace slashes with directory separator + * + * @param string $file + * @return string + */ + protected function _prepareFileForPath($file) + { + return str_replace('/', DS, $file); + } + + /** + * Return file name form file path + * + * @param string $pathFile + * @return string + */ + public function getFileFromPathFile($pathFile) + { + $file = ''; + + $file = substr($pathFile, strrpos($this->_prepareFileForPath($pathFile), DS)+1); + + return $file; + } + + public function getFileType($filePath) + { + $ext = substr($filePath, strrpos($filePath, '.')+1); + return $this->_getFileTypeByExt($ext); + } + + protected function _getFileTypeByExt($ext) + { + $type = 'x' . $ext; + if (isset(self::$_mimeTypes[$type])) { + return self::$_mimeTypes[$type]; + } + return 'application/octet-stream'; + } + + public function getAllFileTypes() + { + return array_values(self::getAllMineTypes()); + } + + public function getAllMineTypes() + { + return self::$_mimeTypes; + } + + protected static $_mimeTypes = + array( + 'x123' => 'application/vnd.lotus-1-2-3', + 'x3dml' => 'text/vnd.in3d.3dml', + 'x3g2' => 'video/3gpp2', + 'x3gp' => 'video/3gpp', + 'xace' => 'application/x-ace-compressed', + 'xacu' => 'application/vnd.acucobol', + 'xaep' => 'application/vnd.audiograph', + 'xai' => 'application/postscript', + 'xaif' => 'audio/x-aiff', + + 'xaifc' => 'audio/x-aiff', + 'xaiff' => 'audio/x-aiff', + 'xami' => 'application/vnd.amiga.ami', + 'xapr' => 'application/vnd.lotus-approach', + 'xasf' => 'video/x-ms-asf', + 'xaso' => 'application/vnd.accpac.simply.aso', + 'xasx' => 'video/x-ms-asf', + 'xatom' => 'application/atom+xml', + 'xatomcat' => 'application/atomcat+xml', + + 'xatomsvc' => 'application/atomsvc+xml', + 'xatx' => 'application/vnd.antix.game-component', + 'xau' => 'audio/basic', + 'xavi' => 'video/x-msvideo', + 'xbat' => 'application/x-msdownload', + 'xbcpio' => 'application/x-bcpio', + 'xbdm' => 'application/vnd.syncml.dm+wbxml', + 'xbh2' => 'application/vnd.fujitsu.oasysprs', + 'xbmi' => 'application/vnd.bmi', + + 'xbmp' => 'image/bmp', + 'xbox' => 'application/vnd.previewsystems.box', + 'xboz' => 'application/x-bzip2', + 'xbtif' => 'image/prs.btif', + 'xbz' => 'application/x-bzip', + 'xbz2' => 'application/x-bzip2', + 'xcab' => 'application/vnd.ms-cab-compressed', + 'xccxml' => 'application/ccxml+xml', + 'xcdbcmsg' => 'application/vnd.contact.cmsg', + + 'xcdkey' => 'application/vnd.mediastation.cdkey', + 'xcdx' => 'chemical/x-cdx', + 'xcdxml' => 'application/vnd.chemdraw+xml', + 'xcdy' => 'application/vnd.cinderella', + 'xcer' => 'application/pkix-cert', + 'xcgm' => 'image/cgm', + 'xchat' => 'application/x-chat', + 'xchm' => 'application/vnd.ms-htmlhelp', + 'xchrt' => 'application/vnd.kde.kchart', + + 'xcif' => 'chemical/x-cif', + 'xcii' => 'application/vnd.anser-web-certificate-issue-initiation', + 'xcil' => 'application/vnd.ms-artgalry', + 'xcla' => 'application/vnd.claymore', + 'xclkk' => 'application/vnd.crick.clicker.keyboard', + 'xclkp' => 'application/vnd.crick.clicker.palette', + 'xclkt' => 'application/vnd.crick.clicker.template', + 'xclkw' => 'application/vnd.crick.clicker.wordbank', + 'xclkx' => 'application/vnd.crick.clicker', + + 'xclp' => 'application/x-msclip', + 'xcmc' => 'application/vnd.cosmocaller', + 'xcmdf' => 'chemical/x-cmdf', + 'xcml' => 'chemical/x-cml', + 'xcmp' => 'application/vnd.yellowriver-custom-menu', + 'xcmx' => 'image/x-cmx', + 'xcom' => 'application/x-msdownload', + 'xconf' => 'text/plain', + 'xcpio' => 'application/x-cpio', + + 'xcpt' => 'application/mac-compactpro', + 'xcrd' => 'application/x-mscardfile', + 'xcrl' => 'application/pkix-crl', + 'xcrt' => 'application/x-x509-ca-cert', + 'xcsh' => 'application/x-csh', + 'xcsml' => 'chemical/x-csml', + 'xcss' => 'text/css', + 'xcsv' => 'text/csv', + 'xcurl' => 'application/vnd.curl', + + 'xcww' => 'application/prs.cww', + 'xdaf' => 'application/vnd.mobius.daf', + 'xdavmount' => 'application/davmount+xml', + 'xdd2' => 'application/vnd.oma.dd2+xml', + 'xddd' => 'application/vnd.fujixerox.ddd', + 'xdef' => 'text/plain', + 'xder' => 'application/x-x509-ca-cert', + 'xdfac' => 'application/vnd.dreamfactory', + 'xdis' => 'application/vnd.mobius.dis', + + 'xdjv' => 'image/vnd.djvu', + 'xdjvu' => 'image/vnd.djvu', + 'xdll' => 'application/x-msdownload', + 'xdna' => 'application/vnd.dna', + 'xdoc' => 'application/msword', + 'xdot' => 'application/msword', + 'xdp' => 'application/vnd.osgi.dp', + 'xdpg' => 'application/vnd.dpgraph', + 'xdsc' => 'text/prs.lines.tag', + + 'xdtd' => 'application/xml-dtd', + 'xdvi' => 'application/x-dvi', + 'xdwf' => 'model/vnd.dwf', + 'xdwg' => 'image/vnd.dwg', + 'xdxf' => 'image/vnd.dxf', + 'xdxp' => 'application/vnd.spotfire.dxp', + 'xecelp4800' => 'audio/vnd.nuera.ecelp4800', + 'xecelp7470' => 'audio/vnd.nuera.ecelp7470', + 'xecelp9600' => 'audio/vnd.nuera.ecelp9600', + + 'xecma' => 'application/ecmascript', + 'xedm' => 'application/vnd.novadigm.edm', + 'xedx' => 'application/vnd.novadigm.edx', + 'xefif' => 'application/vnd.picsel', + 'xei6' => 'application/vnd.pg.osasli', + 'xeml' => 'message/rfc822', + 'xeol' => 'audio/vnd.digital-winds', + 'xeot' => 'application/vnd.ms-fontobject', + 'xeps' => 'application/postscript', + + 'xesf' => 'application/vnd.epson.esf', + 'xetx' => 'text/x-setext', + 'xexe' => 'application/x-msdownload', + 'xext' => 'application/vnd.novadigm.ext', + 'xez' => 'application/andrew-inset', + 'xez2' => 'application/vnd.ezpix-album', + 'xez3' => 'application/vnd.ezpix-package', + 'xfbs' => 'image/vnd.fastbidsheet', + 'xfdf' => 'application/vnd.fdf', + + 'xfe_launch' => 'application/vnd.denovo.fcselayout-link', + 'xfg5' => 'application/vnd.fujitsu.oasysgp', + 'xfli' => 'video/x-fli', + 'xflo' => 'application/vnd.micrografx.flo', + 'xflw' => 'application/vnd.kde.kivio', + 'xflx' => 'text/vnd.fmi.flexstor', + 'xfly' => 'text/vnd.fly', + 'xfnc' => 'application/vnd.frogans.fnc', + 'xfpx' => 'image/vnd.fpx', + + 'xfsc' => 'application/vnd.fsc.weblaunch', + 'xfst' => 'image/vnd.fst', + 'xftc' => 'application/vnd.fluxtime.clip', + 'xfti' => 'application/vnd.anser-web-funds-transfer-initiation', + 'xfvt' => 'video/vnd.fvt', + 'xfzs' => 'application/vnd.fuzzysheet', + 'xg3' => 'image/g3fax', + 'xgac' => 'application/vnd.groove-account', + 'xgdl' => 'model/vnd.gdl', + + 'xghf' => 'application/vnd.groove-help', + 'xgif' => 'image/gif', + 'xgim' => 'application/vnd.groove-identity-message', + 'xgph' => 'application/vnd.flographit', + 'xgram' => 'application/srgs', + 'xgrv' => 'application/vnd.groove-injector', + 'xgrxml' => 'application/srgs+xml', + 'xgtar' => 'application/x-gtar', + 'xgtm' => 'application/vnd.groove-tool-message', + + 'xgtw' => 'model/vnd.gtw', + 'xh261' => 'video/h261', + 'xh263' => 'video/h263', + 'xh264' => 'video/h264', + 'xhbci' => 'application/vnd.hbci', + 'xhdf' => 'application/x-hdf', + 'xhlp' => 'application/winhlp', + 'xhpgl' => 'application/vnd.hp-hpgl', + 'xhpid' => 'application/vnd.hp-hpid', + + 'xhps' => 'application/vnd.hp-hps', + 'xhqx' => 'application/mac-binhex40', + 'xhtke' => 'application/vnd.kenameaapp', + 'xhtm' => 'text/html', + 'xhtml' => 'text/html', + 'xhvd' => 'application/vnd.yamaha.hv-dic', + 'xhvp' => 'application/vnd.yamaha.hv-voice', + 'xhvs' => 'application/vnd.yamaha.hv-script', + 'xice' => '#x-conference/x-cooltalk', + + 'xico' => 'image/x-icon', + 'xics' => 'text/calendar', + 'xief' => 'image/ief', + 'xifb' => 'text/calendar', + 'xifm' => 'application/vnd.shana.informed.formdata', + 'xigl' => 'application/vnd.igloader', + 'xigx' => 'application/vnd.micrografx.igx', + 'xiif' => 'application/vnd.shana.informed.interchange', + 'ximp' => 'application/vnd.accpac.simply.imp', + + 'xims' => 'application/vnd.ms-ims', + 'xin' => 'text/plain', + 'xipk' => 'application/vnd.shana.informed.package', + 'xirm' => 'application/vnd.ibm.rights-management', + 'xirp' => 'application/vnd.irepository.package+xml', + 'xitp' => 'application/vnd.shana.informed.formtemplate', + 'xivp' => 'application/vnd.immervision-ivp', + 'xivu' => 'application/vnd.immervision-ivu', + 'xjad' => 'text/vnd.sun.j2me.app-descriptor', + + 'xjam' => 'application/vnd.jam', + 'xjava' => 'text/x-java-source', + 'xjisp' => 'application/vnd.jisp', + 'xjlt' => 'application/vnd.hp-jlyt', + 'xjoda' => 'application/vnd.joost.joda-archive', + 'xjpe' => 'image/jpeg', + 'xjpeg' => 'image/jpeg', + 'xjpg' => 'image/jpeg', + 'xjpgm' => 'video/jpm', + + 'xjpgv' => 'video/jpeg', + 'xjpm' => 'video/jpm', + 'xjs' => 'application/javascript', + 'xjson' => 'application/json', + 'xkar' => 'audio/midi', + 'xkarbon' => 'application/vnd.kde.karbon', + 'xkfo' => 'application/vnd.kde.kformula', + 'xkia' => 'application/vnd.kidspiration', + 'xkml' => 'application/vnd.google-earth.kml+xml', + + 'xkmz' => 'application/vnd.google-earth.kmz', + 'xkon' => 'application/vnd.kde.kontour', + 'xksp' => 'application/vnd.kde.kspread', + 'xlatex' => 'application/x-latex', + 'xlbd' => 'application/vnd.llamagraphics.life-balance.desktop', + 'xlbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml', + 'xles' => 'application/vnd.hhe.lesson-player', + 'xlist' => 'text/plain', + 'xlog' => 'text/plain', + + 'xlrm' => 'application/vnd.ms-lrm', + 'xltf' => 'application/vnd.frogans.ltf', + 'xlvp' => 'audio/vnd.lucent.voice', + 'xlwp' => 'application/vnd.lotus-wordpro', + 'xm13' => 'application/x-msmediaview', + 'xm14' => 'application/x-msmediaview', + 'xm1v' => 'video/mpeg', + 'xm2a' => 'audio/mpeg', + 'xm3a' => 'audio/mpeg', + + 'xm3u' => 'audio/x-mpegurl', + 'xm4u' => 'video/vnd.mpegurl', + 'xmag' => 'application/vnd.ecowin.chart', + 'xmathml' => 'application/mathml+xml', + 'xmbk' => 'application/vnd.mobius.mbk', + 'xmbox' => 'application/mbox', + 'xmc1' => 'application/vnd.medcalcdata', + 'xmcd' => 'application/vnd.mcd', + 'xmdb' => 'application/x-msaccess', + + 'xmdi' => 'image/vnd.ms-modi', + 'xmesh' => 'model/mesh', + 'xmfm' => 'application/vnd.mfmp', + 'xmgz' => 'application/vnd.proteus.magazine', + 'xmid' => 'audio/midi', + 'xmidi' => 'audio/midi', + 'xmif' => 'application/vnd.mif', + 'xmime' => 'message/rfc822', + 'xmj2' => 'video/mj2', + + 'xmjp2' => 'video/mj2', + 'xmlp' => 'application/vnd.dolby.mlp', + 'xmmd' => 'application/vnd.chipnuts.karaoke-mmd', + 'xmmf' => 'application/vnd.smaf', + 'xmmr' => 'image/vnd.fujixerox.edmics-mmr', + 'xmny' => 'application/x-msmoney', + 'xmov' => 'video/quicktime', + 'xmovie' => 'video/x-sgi-movie', + 'xmp2' => 'audio/mpeg', + + 'xmp2a' => 'audio/mpeg', + 'xmp3' => 'audio/mpeg', + 'xmp4' => 'video/mp4', + 'xmp4a' => 'audio/mp4', + 'xmp4s' => 'application/mp4', + 'xmp4v' => 'video/mp4', + 'xmpc' => 'application/vnd.mophun.certificate', + 'xmpe' => 'video/mpeg', + 'xmpeg' => 'video/mpeg', + + 'xmpg' => 'video/mpeg', + 'xmpg4' => 'video/mp4', + 'xmpga' => 'audio/mpeg', + 'xmpkg' => 'application/vnd.apple.installer+xml', + 'xmpm' => 'application/vnd.blueice.multipass', + 'xmpn' => 'application/vnd.mophun.application', + 'xmpp' => 'application/vnd.ms-project', + 'xmpt' => 'application/vnd.ms-project', + 'xmpy' => 'application/vnd.ibm.minipay', + + 'xmqy' => 'application/vnd.mobius.mqy', + 'xmrc' => 'application/marc', + 'xmscml' => 'application/mediaservercontrol+xml', + 'xmseq' => 'application/vnd.mseq', + 'xmsf' => 'application/vnd.epson.msf', + 'xmsh' => 'model/mesh', + 'xmsi' => 'application/x-msdownload', + 'xmsl' => 'application/vnd.mobius.msl', + 'xmsty' => 'application/vnd.muvee.style', + + 'xmts' => 'model/vnd.mts', + 'xmus' => 'application/vnd.musician', + 'xmvb' => 'application/x-msmediaview', + 'xmwf' => 'application/vnd.mfer', + 'xmxf' => 'application/mxf', + 'xmxl' => 'application/vnd.recordare.musicxml', + 'xmxml' => 'application/xv+xml', + 'xmxs' => 'application/vnd.triscape.mxs', + 'xmxu' => 'video/vnd.mpegurl', + + 'xn-gage' => 'application/vnd.nokia.n-gage.symbian.install', + 'xngdat' => 'application/vnd.nokia.n-gage.data', + 'xnlu' => 'application/vnd.neurolanguage.nlu', + 'xnml' => 'application/vnd.enliven', + 'xnnd' => 'application/vnd.noblenet-directory', + 'xnns' => 'application/vnd.noblenet-sealer', + 'xnnw' => 'application/vnd.noblenet-web', + 'xnpx' => 'image/vnd.net-fpx', + 'xnsf' => 'application/vnd.lotus-notes', + + 'xoa2' => 'application/vnd.fujitsu.oasys2', + 'xoa3' => 'application/vnd.fujitsu.oasys3', + 'xoas' => 'application/vnd.fujitsu.oasys', + 'xobd' => 'application/x-msbinder', + 'xoda' => 'application/oda', + 'xodc' => 'application/vnd.oasis.opendocument.chart', + 'xodf' => 'application/vnd.oasis.opendocument.formula', + 'xodg' => 'application/vnd.oasis.opendocument.graphics', + 'xodi' => 'application/vnd.oasis.opendocument.image', + + 'xodp' => 'application/vnd.oasis.opendocument.presentation', + 'xods' => 'application/vnd.oasis.opendocument.spreadsheet', + 'xodt' => 'application/vnd.oasis.opendocument.text', + 'xogg' => 'application/ogg', + 'xoprc' => 'application/vnd.palm', + 'xorg' => 'application/vnd.lotus-organizer', + 'xotc' => 'application/vnd.oasis.opendocument.chart-template', + 'xotf' => 'application/vnd.oasis.opendocument.formula-template', + 'xotg' => 'application/vnd.oasis.opendocument.graphics-template', + + 'xoth' => 'application/vnd.oasis.opendocument.text-web', + 'xoti' => 'application/vnd.oasis.opendocument.image-template', + 'xotm' => 'application/vnd.oasis.opendocument.text-master', + 'xots' => 'application/vnd.oasis.opendocument.spreadsheet-template', + 'xott' => 'application/vnd.oasis.opendocument.text-template', + 'xoxt' => 'application/vnd.openofficeorg.extension', + 'xp10' => 'application/pkcs10', + 'xp7r' => 'application/x-pkcs7-certreqresp', + 'xp7s' => 'application/pkcs7-signature', + + 'xpbd' => 'application/vnd.powerbuilder6', + 'xpbm' => 'image/x-portable-bitmap', + 'xpcl' => 'application/vnd.hp-pcl', + 'xpclxl' => 'application/vnd.hp-pclxl', + 'xpct' => 'image/x-pict', + 'xpcx' => 'image/x-pcx', + 'xpdb' => 'chemical/x-pdb', + 'xpdf' => 'application/pdf', + 'xpfr' => 'application/font-tdpfr', + + 'xpgm' => 'image/x-portable-graymap', + 'xpgn' => 'application/x-chess-pgn', + 'xpgp' => 'application/pgp-encrypted', + 'xpic' => 'image/x-pict', + 'xpki' => 'application/pkixcmp', + 'xpkipath' => 'application/pkix-pkipath', + 'xplb' => 'application/vnd.3gpp.pic-bw-large', + 'xplc' => 'application/vnd.mobius.plc', + 'xplf' => 'application/vnd.pocketlearn', + + 'xpls' => 'application/pls+xml', + 'xpml' => 'application/vnd.ctc-posml', + 'xpng' => 'image/png', + 'xpnm' => 'image/x-portable-anymap', + 'xportpkg' => 'application/vnd.macports.portpkg', + 'xpot' => 'application/vnd.ms-powerpoint', + 'xppd' => 'application/vnd.cups-ppd', + 'xppm' => 'image/x-portable-pixmap', + 'xpps' => 'application/vnd.ms-powerpoint', + + 'xppt' => 'application/vnd.ms-powerpoint', + 'xpqa' => 'application/vnd.palm', + 'xprc' => 'application/vnd.palm', + 'xpre' => 'application/vnd.lotus-freelance', + 'xprf' => 'application/pics-rules', + 'xps' => 'application/postscript', + 'xpsb' => 'application/vnd.3gpp.pic-bw-small', + 'xpsd' => 'image/vnd.adobe.photoshop', + 'xptid' => 'application/vnd.pvi.ptid1', + + 'xpub' => 'application/x-mspublisher', + 'xpvb' => 'application/vnd.3gpp.pic-bw-var', + 'xpwn' => 'application/vnd.3m.post-it-notes', + 'xqam' => 'application/vnd.epson.quickanime', + 'xqbo' => 'application/vnd.intu.qbo', + 'xqfx' => 'application/vnd.intu.qfx', + 'xqps' => 'application/vnd.publishare-delta-tree', + 'xqt' => 'video/quicktime', + 'xra' => 'audio/x-pn-realaudio', + + 'xram' => 'audio/x-pn-realaudio', + 'xrar' => 'application/x-rar-compressed', + 'xras' => 'image/x-cmu-raster', + 'xrcprofile' => 'application/vnd.ipunplugged.rcprofile', + 'xrdf' => 'application/rdf+xml', + 'xrdz' => 'application/vnd.data-vision.rdz', + 'xrep' => 'application/vnd.businessobjects', + 'xrgb' => 'image/x-rgb', + 'xrif' => 'application/reginfo+xml', + + 'xrl' => 'application/resource-lists+xml', + 'xrlc' => 'image/vnd.fujixerox.edmics-rlc', + 'xrm' => 'application/vnd.rn-realmedia', + 'xrmi' => 'audio/midi', + 'xrmp' => 'audio/x-pn-realaudio-plugin', + 'xrms' => 'application/vnd.jcp.javame.midlet-rms', + 'xrnc' => 'application/relax-ng-compact-syntax', + 'xrpss' => 'application/vnd.nokia.radio-presets', + 'xrpst' => 'application/vnd.nokia.radio-preset', + + 'xrq' => 'application/sparql-query', + 'xrs' => 'application/rls-services+xml', + 'xrsd' => 'application/rsd+xml', + 'xrss' => 'application/rss+xml', + 'xrtf' => 'application/rtf', + 'xrtx' => 'text/richtext', + 'xsaf' => 'application/vnd.yamaha.smaf-audio', + 'xsbml' => 'application/sbml+xml', + 'xsc' => 'application/vnd.ibm.secure-container', + + 'xscd' => 'application/x-msschedule', + 'xscm' => 'application/vnd.lotus-screencam', + 'xscq' => 'application/scvp-cv-request', + 'xscs' => 'application/scvp-cv-response', + 'xsdp' => 'application/sdp', + 'xsee' => 'application/vnd.seemail', + 'xsema' => 'application/vnd.sema', + 'xsemd' => 'application/vnd.semd', + 'xsemf' => 'application/vnd.semf', + + 'xsetpay' => 'application/set-payment-initiation', + 'xsetreg' => 'application/set-registration-initiation', + 'xsfs' => 'application/vnd.spotfire.sfs', + 'xsgm' => 'text/sgml', + 'xsgml' => 'text/sgml', + 'xsh' => 'application/x-sh', + 'xshar' => 'application/x-shar', + 'xshf' => 'application/shf+xml', + 'xsilo' => 'model/mesh', + + 'xsit' => 'application/x-stuffit', + 'xsitx' => 'application/x-stuffitx', + 'xslt' => 'application/vnd.epson.salt', + 'xsnd' => 'audio/basic', + 'xspf' => 'application/vnd.yamaha.smaf-phrase', + 'xspl' => 'application/x-futuresplash', + 'xspot' => 'text/vnd.in3d.spot', + 'xspp' => 'application/scvp-vp-response', + 'xspq' => 'application/scvp-vp-request', + + 'xsrc' => 'application/x-wais-source', + 'xsrx' => 'application/sparql-results+xml', + 'xssf' => 'application/vnd.epson.ssf', + 'xssml' => 'application/ssml+xml', + 'xstf' => 'application/vnd.wt.stf', + 'xstk' => 'application/hyperstudio', + 'xstr' => 'application/vnd.pg.format', + 'xsus' => 'application/vnd.sus-calendar', + 'xsusp' => 'application/vnd.sus-calendar', + + 'xsv4cpio' => 'application/x-sv4cpio', + 'xsv4crc' => 'application/x-sv4crc', + 'xsvd' => 'application/vnd.svd', + 'xswf' => 'application/x-shockwave-flash', + 'xtao' => 'application/vnd.tao.intent-module-archive', + 'xtar' => 'application/x-tar', + 'xtcap' => 'application/vnd.3gpp2.tcap', + 'xtcl' => 'application/x-tcl', + 'xtex' => 'application/x-tex', + + 'xtext' => 'text/plain', + 'xtif' => 'image/tiff', + 'xtiff' => 'image/tiff', + 'xtmo' => 'application/vnd.tmobile-livetv', + 'xtorrent' => 'application/x-bittorrent', + 'xtpl' => 'application/vnd.groove-tool-template', + 'xtpt' => 'application/vnd.trid.tpt', + 'xtra' => 'application/vnd.trueapp', + 'xtrm' => 'application/x-msterminal', + + 'xtsv' => 'text/tab-separated-values', + 'xtxd' => 'application/vnd.genomatix.tuxedo', + 'xtxf' => 'application/vnd.mobius.txf', + 'xtxt' => 'text/plain', + 'xumj' => 'application/vnd.umajin', + 'xunityweb' => 'application/vnd.unity', + 'xuoml' => 'application/vnd.uoml+xml', + 'xuri' => 'text/uri-list', + 'xuris' => 'text/uri-list', + + 'xurls' => 'text/uri-list', + 'xustar' => 'application/x-ustar', + 'xutz' => 'application/vnd.uiq.theme', + 'xuu' => 'text/x-uuencode', + 'xvcd' => 'application/x-cdlink', + 'xvcf' => 'text/x-vcard', + 'xvcg' => 'application/vnd.groove-vcard', + 'xvcs' => 'text/x-vcalendar', + 'xvcx' => 'application/vnd.vcx', + + 'xvis' => 'application/vnd.visionary', + 'xviv' => 'video/vnd.vivo', + 'xvrml' => 'model/vrml', + 'xvsd' => 'application/vnd.visio', + 'xvsf' => 'application/vnd.vsf', + 'xvss' => 'application/vnd.visio', + 'xvst' => 'application/vnd.visio', + 'xvsw' => 'application/vnd.visio', + 'xvtu' => 'model/vnd.vtu', + + 'xvxml' => 'application/voicexml+xml', + 'xwav' => 'audio/x-wav', + 'xwax' => 'audio/x-ms-wax', + 'xwbmp' => 'image/vnd.wap.wbmp', + 'xwbs' => 'application/vnd.criticaltools.wbs+xml', + 'xwbxml' => 'application/vnd.wap.wbxml', + 'xwcm' => 'application/vnd.ms-works', + 'xwdb' => 'application/vnd.ms-works', + 'xwks' => 'application/vnd.ms-works', + + 'xwm' => 'video/x-ms-wm', + 'xwma' => 'audio/x-ms-wma', + 'xwmd' => 'application/x-ms-wmd', + 'xwmf' => 'application/x-msmetafile', + 'xwml' => 'text/vnd.wap.wml', + 'xwmlc' => 'application/vnd.wap.wmlc', + 'xwmls' => 'text/vnd.wap.wmlscript', + 'xwmlsc' => 'application/vnd.wap.wmlscriptc', + 'xwmv' => 'video/x-ms-wmv', + + 'xwmx' => 'video/x-ms-wmx', + 'xwmz' => 'application/x-ms-wmz', + 'xwpd' => 'application/vnd.wordperfect', + 'xwpl' => 'application/vnd.ms-wpl', + 'xwps' => 'application/vnd.ms-works', + 'xwqd' => 'application/vnd.wqd', + 'xwri' => 'application/x-mswrite', + 'xwrl' => 'model/vrml', + 'xwsdl' => 'application/wsdl+xml', + + 'xwspolicy' => 'application/wspolicy+xml', + 'xwtb' => 'application/vnd.webturbo', + 'xwvx' => 'video/x-ms-wvx', + 'xx3d' => 'application/vnd.hzn-3d-crossword', + 'xxar' => 'application/vnd.xara', + 'xxbd' => 'application/vnd.fujixerox.docuworks.binder', + 'xxbm' => 'image/x-xbitmap', + 'xxdm' => 'application/vnd.syncml.dm+xml', + 'xxdp' => 'application/vnd.adobe.xdp+xml', + + 'xxdw' => 'application/vnd.fujixerox.docuworks', + 'xxenc' => 'application/xenc+xml', + 'xxfdf' => 'application/vnd.adobe.xfdf', + 'xxfdl' => 'application/vnd.xfdl', + 'xxht' => 'application/xhtml+xml', + 'xxhtml' => 'application/xhtml+xml', + 'xxhvml' => 'application/xv+xml', + 'xxif' => 'image/vnd.xiff', + 'xxla' => 'application/vnd.ms-excel', + + 'xxlc' => 'application/vnd.ms-excel', + 'xxlm' => 'application/vnd.ms-excel', + 'xxls' => 'application/vnd.ms-excel', + 'xxlt' => 'application/vnd.ms-excel', + 'xxlw' => 'application/vnd.ms-excel', + 'xxml' => 'application/xml', + 'xxo' => 'application/vnd.olpc-sugar', + 'xxop' => 'application/xop+xml', + 'xxpm' => 'image/x-xpixmap', + + 'xxpr' => 'application/vnd.is-xpr', + 'xxps' => 'application/vnd.ms-xpsdocument', + 'xxsl' => 'application/xml', + 'xxslt' => 'application/xslt+xml', + 'xxsm' => 'application/vnd.syncml+xml', + 'xxspf' => 'application/xspf+xml', + 'xxul' => 'application/vnd.mozilla.xul+xml', + 'xxvm' => 'application/xv+xml', + 'xxvml' => 'application/xv+xml', + + 'xxwd' => 'image/x-xwindowdump', + 'xxyz' => 'chemical/x-xyz', + 'xzaz' => 'application/vnd.zzazz.deck+xml', + 'xzip' => 'application/zip', + 'xzmm' => 'application/vnd.handheld-entertainment+xml', + 'xodt' => 'application/x-vnd.oasis.opendocument.spreadsheet' + ); +} diff --git a/app/code/core/Mage/Downloadable/Model/Link.php b/app/code/Mage/Downloadable/Model/Link.php similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Link.php rename to app/code/Mage/Downloadable/Model/Link.php diff --git a/app/code/core/Mage/Downloadable/Model/Link/Api.php b/app/code/Mage/Downloadable/Model/Link/Api.php similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Link/Api.php rename to app/code/Mage/Downloadable/Model/Link/Api.php diff --git a/app/code/core/Mage/Downloadable/Model/Link/Api/Uploader.php b/app/code/Mage/Downloadable/Model/Link/Api/Uploader.php similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Link/Api/Uploader.php rename to app/code/Mage/Downloadable/Model/Link/Api/Uploader.php diff --git a/app/code/core/Mage/Downloadable/Model/Link/Api/V2.php b/app/code/Mage/Downloadable/Model/Link/Api/V2.php similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Link/Api/V2.php rename to app/code/Mage/Downloadable/Model/Link/Api/V2.php diff --git a/app/code/core/Mage/Downloadable/Model/Link/Api/Validator.php b/app/code/Mage/Downloadable/Model/Link/Api/Validator.php similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Link/Api/Validator.php rename to app/code/Mage/Downloadable/Model/Link/Api/Validator.php diff --git a/app/code/core/Mage/Downloadable/Model/Link/Purchased.php b/app/code/Mage/Downloadable/Model/Link/Purchased.php similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Link/Purchased.php rename to app/code/Mage/Downloadable/Model/Link/Purchased.php diff --git a/app/code/core/Mage/Downloadable/Model/Link/Purchased/Item.php b/app/code/Mage/Downloadable/Model/Link/Purchased/Item.php similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Link/Purchased/Item.php rename to app/code/Mage/Downloadable/Model/Link/Purchased/Item.php diff --git a/app/code/core/Mage/Downloadable/Model/Observer.php b/app/code/Mage/Downloadable/Model/Observer.php similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Observer.php rename to app/code/Mage/Downloadable/Model/Observer.php diff --git a/app/code/core/Mage/Downloadable/Model/Product/Price.php b/app/code/Mage/Downloadable/Model/Product/Price.php similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Product/Price.php rename to app/code/Mage/Downloadable/Model/Product/Price.php diff --git a/app/code/core/Mage/Downloadable/Model/Product/Type.php b/app/code/Mage/Downloadable/Model/Product/Type.php similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Product/Type.php rename to app/code/Mage/Downloadable/Model/Product/Type.php diff --git a/app/code/core/Mage/Downloadable/Model/Resource/Indexer/Price.php b/app/code/Mage/Downloadable/Model/Resource/Indexer/Price.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Resource/Indexer/Price.php rename to app/code/Mage/Downloadable/Model/Resource/Indexer/Price.php diff --git a/app/code/core/Mage/Downloadable/Model/Resource/Link.php b/app/code/Mage/Downloadable/Model/Resource/Link.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Resource/Link.php rename to app/code/Mage/Downloadable/Model/Resource/Link.php diff --git a/app/code/core/Mage/Downloadable/Model/Resource/Link/Collection.php b/app/code/Mage/Downloadable/Model/Resource/Link/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Resource/Link/Collection.php rename to app/code/Mage/Downloadable/Model/Resource/Link/Collection.php diff --git a/app/code/core/Mage/Downloadable/Model/Resource/Link/Purchased.php b/app/code/Mage/Downloadable/Model/Resource/Link/Purchased.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Resource/Link/Purchased.php rename to app/code/Mage/Downloadable/Model/Resource/Link/Purchased.php diff --git a/app/code/core/Mage/Downloadable/Model/Resource/Link/Purchased/Collection.php b/app/code/Mage/Downloadable/Model/Resource/Link/Purchased/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Resource/Link/Purchased/Collection.php rename to app/code/Mage/Downloadable/Model/Resource/Link/Purchased/Collection.php diff --git a/app/code/core/Mage/Downloadable/Model/Resource/Link/Purchased/Item.php b/app/code/Mage/Downloadable/Model/Resource/Link/Purchased/Item.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Resource/Link/Purchased/Item.php rename to app/code/Mage/Downloadable/Model/Resource/Link/Purchased/Item.php diff --git a/app/code/core/Mage/Downloadable/Model/Resource/Link/Purchased/Item/Collection.php b/app/code/Mage/Downloadable/Model/Resource/Link/Purchased/Item/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Resource/Link/Purchased/Item/Collection.php rename to app/code/Mage/Downloadable/Model/Resource/Link/Purchased/Item/Collection.php diff --git a/app/code/core/Mage/Downloadable/Model/Resource/Sample.php b/app/code/Mage/Downloadable/Model/Resource/Sample.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Resource/Sample.php rename to app/code/Mage/Downloadable/Model/Resource/Sample.php diff --git a/app/code/core/Mage/Downloadable/Model/Resource/Sample/Collection.php b/app/code/Mage/Downloadable/Model/Resource/Sample/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Resource/Sample/Collection.php rename to app/code/Mage/Downloadable/Model/Resource/Sample/Collection.php diff --git a/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Abstract.php b/app/code/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Abstract.php similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Abstract.php rename to app/code/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Abstract.php diff --git a/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php b/app/code/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php rename to app/code/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php diff --git a/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php b/app/code/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php rename to app/code/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php diff --git a/app/code/core/Mage/Downloadable/Model/Sample.php b/app/code/Mage/Downloadable/Model/Sample.php similarity index 100% rename from app/code/core/Mage/Downloadable/Model/Sample.php rename to app/code/Mage/Downloadable/Model/Sample.php diff --git a/app/code/core/Mage/Downloadable/Model/System/Config/Source/Contentdisposition.php b/app/code/Mage/Downloadable/Model/System/Config/Source/Contentdisposition.php similarity index 100% rename from app/code/core/Mage/Downloadable/Model/System/Config/Source/Contentdisposition.php rename to app/code/Mage/Downloadable/Model/System/Config/Source/Contentdisposition.php diff --git a/app/code/core/Mage/Downloadable/Model/System/Config/Source/Orderitemstatus.php b/app/code/Mage/Downloadable/Model/System/Config/Source/Orderitemstatus.php similarity index 100% rename from app/code/core/Mage/Downloadable/Model/System/Config/Source/Orderitemstatus.php rename to app/code/Mage/Downloadable/Model/System/Config/Source/Orderitemstatus.php diff --git a/app/code/core/Mage/Downloadable/controllers/Adminhtml/Downloadable/FileController.php b/app/code/Mage/Downloadable/controllers/Adminhtml/Downloadable/FileController.php similarity index 100% rename from app/code/core/Mage/Downloadable/controllers/Adminhtml/Downloadable/FileController.php rename to app/code/Mage/Downloadable/controllers/Adminhtml/Downloadable/FileController.php diff --git a/app/code/core/Mage/Downloadable/controllers/Adminhtml/Downloadable/Product/EditController.php b/app/code/Mage/Downloadable/controllers/Adminhtml/Downloadable/Product/EditController.php similarity index 100% rename from app/code/core/Mage/Downloadable/controllers/Adminhtml/Downloadable/Product/EditController.php rename to app/code/Mage/Downloadable/controllers/Adminhtml/Downloadable/Product/EditController.php diff --git a/app/code/core/Mage/Downloadable/controllers/CustomerController.php b/app/code/Mage/Downloadable/controllers/CustomerController.php similarity index 100% rename from app/code/core/Mage/Downloadable/controllers/CustomerController.php rename to app/code/Mage/Downloadable/controllers/CustomerController.php diff --git a/app/code/core/Mage/Downloadable/controllers/DownloadController.php b/app/code/Mage/Downloadable/controllers/DownloadController.php similarity index 100% rename from app/code/core/Mage/Downloadable/controllers/DownloadController.php rename to app/code/Mage/Downloadable/controllers/DownloadController.php diff --git a/app/code/core/Mage/Downloadable/data/downloadable_setup/data-install-1.6.0.0.php b/app/code/Mage/Downloadable/data/downloadable_setup/data-install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Downloadable/data/downloadable_setup/data-install-1.6.0.0.php rename to app/code/Mage/Downloadable/data/downloadable_setup/data-install-1.6.0.0.php diff --git a/app/code/core/Mage/Downloadable/data/downloadable_setup/data-upgrade-1.6.0.0.2-1.6.0.0.3.php b/app/code/Mage/Downloadable/data/downloadable_setup/data-upgrade-1.6.0.0.2-1.6.0.0.3.php similarity index 100% rename from app/code/core/Mage/Downloadable/data/downloadable_setup/data-upgrade-1.6.0.0.2-1.6.0.0.3.php rename to app/code/Mage/Downloadable/data/downloadable_setup/data-upgrade-1.6.0.0.2-1.6.0.0.3.php diff --git a/app/code/Mage/Downloadable/etc/adminhtml/acl.xml b/app/code/Mage/Downloadable/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..a7f15e53e74e0 --- /dev/null +++ b/app/code/Mage/Downloadable/etc/adminhtml/acl.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + diff --git a/app/code/Mage/Downloadable/etc/adminhtml/menu.xml b/app/code/Mage/Downloadable/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..77cc956699f72 --- /dev/null +++ b/app/code/Mage/Downloadable/etc/adminhtml/menu.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/app/code/core/Mage/Downloadable/etc/adminhtml/system.xml b/app/code/Mage/Downloadable/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Downloadable/etc/adminhtml/system.xml rename to app/code/Mage/Downloadable/etc/adminhtml/system.xml diff --git a/app/code/core/Mage/Downloadable/etc/api.xml b/app/code/Mage/Downloadable/etc/api.xml similarity index 100% rename from app/code/core/Mage/Downloadable/etc/api.xml rename to app/code/Mage/Downloadable/etc/api.xml diff --git a/app/code/Mage/Downloadable/etc/config.xml b/app/code/Mage/Downloadable/etc/config.xml new file mode 100644 index 0000000000000..61a84e5307f88 --- /dev/null +++ b/app/code/Mage/Downloadable/etc/config.xml @@ -0,0 +1,273 @@ + + + + + + 1.6.0.0.3 + true + + + + + + + + + + + + + + + + + + + + + Mage_Downloadable + Mage_Catalog_Model_Resource_Setup + + + + + + + + + Mage_Downloadable_Model_Product_Type + 1 + Mage_Downloadable_Model_Product_Price + 0 + Mage_Downloadable_Model_Resource_Indexer_Price + 0 + + + + + + + + + + + + + + + + + + + + + + + + Mage_Downloadable_Model_Sales_Order_Pdf_Items_Invoice + + + Mage_Downloadable_Model_Sales_Order_Pdf_Items_Creditmemo + + + + + + + + + Mage_Downloadable.csv + + + + + + + + + + + + + + + + + layout.xml + + + + + + + + Mage_Downloadable_Model_Observer + prepareProductSave + + + + + + + Mage_Downloadable_Model_Observer + duplicateProduct + + + + + + + Mage_Downloadable_Model_Observer + saveDownloadableOrderItem + + + + + + + Mage_Downloadable_Model_Observer + setLinkStatus + + + + + + + Mage_Downloadable_Model_Observer + transitionProductType + + + + + + + + + standard + + Mage_Downloadable + downloadable + + + + + /downloadable/customer/ + /downloadable/download/ + + + + + + Mage_Downloadable.csv + + + + + + + + layout.xml + + + + + + + + Mage_Downloadable_Model_Observer + saveDownloadableOrderItem + + + + + + + Mage_Downloadable_Model_Observer + setLinkStatus + + + + + + + Mage_Downloadable_Model_Observer + setHasDownloadableProducts + + + + + + + Mage_Downloadable_Model_Observer + setHasDownloadableProducts + + + + + + + Mage_Downloadable_Model_Observer + isAllowedGuestCheckout + + + + + + + Mage_Downloadable_Model_Observer + initOptionRenderer + + + + + + + + + + + Mage_Downloadable_Adminhtml + + + + + + + + + 0 + 9 + Samples + Links + 1 + inline + 1 + + + + diff --git a/app/code/core/Mage/Downloadable/etc/fieldset.xml b/app/code/Mage/Downloadable/etc/fieldset.xml similarity index 100% rename from app/code/core/Mage/Downloadable/etc/fieldset.xml rename to app/code/Mage/Downloadable/etc/fieldset.xml diff --git a/app/code/core/Mage/Downloadable/etc/wsdl.xml b/app/code/Mage/Downloadable/etc/wsdl.xml similarity index 100% rename from app/code/core/Mage/Downloadable/etc/wsdl.xml rename to app/code/Mage/Downloadable/etc/wsdl.xml diff --git a/app/code/core/Mage/Downloadable/etc/wsi.xml b/app/code/Mage/Downloadable/etc/wsi.xml similarity index 100% rename from app/code/core/Mage/Downloadable/etc/wsi.xml rename to app/code/Mage/Downloadable/etc/wsi.xml diff --git a/app/code/core/Mage/Downloadable/locale/de_DE/Mage_Downloadable.csv b/app/code/Mage/Downloadable/locale/de_DE/Mage_Downloadable.csv similarity index 100% rename from app/code/core/Mage/Downloadable/locale/de_DE/Mage_Downloadable.csv rename to app/code/Mage/Downloadable/locale/de_DE/Mage_Downloadable.csv diff --git a/app/code/core/Mage/Downloadable/locale/en_US/Mage_Downloadable.csv b/app/code/Mage/Downloadable/locale/en_US/Mage_Downloadable.csv similarity index 100% rename from app/code/core/Mage/Downloadable/locale/en_US/Mage_Downloadable.csv rename to app/code/Mage/Downloadable/locale/en_US/Mage_Downloadable.csv diff --git a/app/code/core/Mage/Downloadable/locale/es_ES/Mage_Downloadable.csv b/app/code/Mage/Downloadable/locale/es_ES/Mage_Downloadable.csv similarity index 100% rename from app/code/core/Mage/Downloadable/locale/es_ES/Mage_Downloadable.csv rename to app/code/Mage/Downloadable/locale/es_ES/Mage_Downloadable.csv diff --git a/app/code/core/Mage/Downloadable/locale/fr_FR/Mage_Downloadable.csv b/app/code/Mage/Downloadable/locale/fr_FR/Mage_Downloadable.csv similarity index 100% rename from app/code/core/Mage/Downloadable/locale/fr_FR/Mage_Downloadable.csv rename to app/code/Mage/Downloadable/locale/fr_FR/Mage_Downloadable.csv diff --git a/app/code/core/Mage/Downloadable/locale/nl_NL/Mage_Downloadable.csv b/app/code/Mage/Downloadable/locale/nl_NL/Mage_Downloadable.csv similarity index 100% rename from app/code/core/Mage/Downloadable/locale/nl_NL/Mage_Downloadable.csv rename to app/code/Mage/Downloadable/locale/nl_NL/Mage_Downloadable.csv diff --git a/app/code/core/Mage/Downloadable/locale/pt_BR/Mage_Downloadable.csv b/app/code/Mage/Downloadable/locale/pt_BR/Mage_Downloadable.csv similarity index 100% rename from app/code/core/Mage/Downloadable/locale/pt_BR/Mage_Downloadable.csv rename to app/code/Mage/Downloadable/locale/pt_BR/Mage_Downloadable.csv diff --git a/app/code/core/Mage/Downloadable/locale/zh_CN/Mage_Downloadable.csv b/app/code/Mage/Downloadable/locale/zh_CN/Mage_Downloadable.csv similarity index 100% rename from app/code/core/Mage/Downloadable/locale/zh_CN/Mage_Downloadable.csv rename to app/code/Mage/Downloadable/locale/zh_CN/Mage_Downloadable.csv diff --git a/app/code/core/Mage/Downloadable/sql/downloadable_setup/install-1.6.0.0.php b/app/code/Mage/Downloadable/sql/downloadable_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Downloadable/sql/downloadable_setup/install-1.6.0.0.php rename to app/code/Mage/Downloadable/sql/downloadable_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Downloadable/sql/downloadable_setup/mysql4-upgrade-1.6.0.0.1-1.6.0.0.2.php b/app/code/Mage/Downloadable/sql/downloadable_setup/mysql4-upgrade-1.6.0.0.1-1.6.0.0.2.php similarity index 100% rename from app/code/core/Mage/Downloadable/sql/downloadable_setup/mysql4-upgrade-1.6.0.0.1-1.6.0.0.2.php rename to app/code/Mage/Downloadable/sql/downloadable_setup/mysql4-upgrade-1.6.0.0.1-1.6.0.0.2.php diff --git a/app/code/core/Mage/Downloadable/sql/downloadable_setup/upgrade-1.6.0.0-1.6.0.0.1.php b/app/code/Mage/Downloadable/sql/downloadable_setup/upgrade-1.6.0.0-1.6.0.0.1.php similarity index 100% rename from app/code/core/Mage/Downloadable/sql/downloadable_setup/upgrade-1.6.0.0-1.6.0.0.1.php rename to app/code/Mage/Downloadable/sql/downloadable_setup/upgrade-1.6.0.0-1.6.0.0.1.php diff --git a/app/code/core/Mage/Downloadable/sql/downloadable_setup/upgrade-1.6.0.0.1-1.6.0.0.2.php b/app/code/Mage/Downloadable/sql/downloadable_setup/upgrade-1.6.0.0.1-1.6.0.0.2.php similarity index 100% rename from app/code/core/Mage/Downloadable/sql/downloadable_setup/upgrade-1.6.0.0.1-1.6.0.0.2.php rename to app/code/Mage/Downloadable/sql/downloadable_setup/upgrade-1.6.0.0.1-1.6.0.0.2.php diff --git a/app/code/core/Mage/Downloadable/view/adminhtml/layout.xml b/app/code/Mage/Downloadable/view/adminhtml/layout.xml similarity index 100% rename from app/code/core/Mage/Downloadable/view/adminhtml/layout.xml rename to app/code/Mage/Downloadable/view/adminhtml/layout.xml diff --git a/app/code/core/Mage/Downloadable/view/adminhtml/product/composite/fieldset/downloadable.phtml b/app/code/Mage/Downloadable/view/adminhtml/product/composite/fieldset/downloadable.phtml similarity index 100% rename from app/code/core/Mage/Downloadable/view/adminhtml/product/composite/fieldset/downloadable.phtml rename to app/code/Mage/Downloadable/view/adminhtml/product/composite/fieldset/downloadable.phtml diff --git a/app/code/Mage/Downloadable/view/adminhtml/product/edit/downloadable.phtml b/app/code/Mage/Downloadable/view/adminhtml/product/edit/downloadable.phtml new file mode 100644 index 0000000000000..48f9a9b527f26 --- /dev/null +++ b/app/code/Mage/Downloadable/view/adminhtml/product/edit/downloadable.phtml @@ -0,0 +1,232 @@ + + + + + +
    getMessageHtml() ?>
    + +
    +getChildHtml('accordion') ?> +
    +
    +
    +
    +isReadonly()): ?> + + diff --git a/app/code/core/Mage/Downloadable/view/adminhtml/product/edit/downloadable/links.phtml b/app/code/Mage/Downloadable/view/adminhtml/product/edit/downloadable/links.phtml similarity index 96% rename from app/code/core/Mage/Downloadable/view/adminhtml/product/edit/downloadable/links.phtml rename to app/code/Mage/Downloadable/view/adminhtml/product/edit/downloadable/links.phtml index 5878d7e7e5fe0..f2a4ec08f681b 100644 --- a/app/code/core/Mage/Downloadable/view/adminhtml/product/edit/downloadable/links.phtml +++ b/app/code/Mage/Downloadable/view/adminhtml/product/edit/downloadable/links.phtml @@ -411,23 +411,7 @@ if($('add_link_item')) { getLinkData() as $item): ?> linkItems.add(toJson()?>); - -Validation.addAllThese([ - ['validate-downloadable-link-sample-file', 'Please specify File.', function(v,element) { - fileSaveElm = element.up('div').next('input[type="hidden"]'); - if (element.checked && (fileSaveElm.value == '' || fileSaveElm.value == '[]')) { - return false; - } - return true; - }] - ]); -Validation.addAllThese([ - ['validate-downloadable-link-sample-url', 'Please specify Sample URL.', function(v,element) { - if (element.checked && element.up('p').down('input[type="text"]').value == '') { - return false; - } - return true; - }] - ]); +jQuery.mage.extend('validation', 'validation', + 'getViewFileUrl('Mage_Downloadable::product/validation-rules.js'); ?>'); //]]> diff --git a/app/code/core/Mage/Downloadable/view/adminhtml/product/edit/downloadable/samples.phtml b/app/code/Mage/Downloadable/view/adminhtml/product/edit/downloadable/samples.phtml similarity index 100% rename from app/code/core/Mage/Downloadable/view/adminhtml/product/edit/downloadable/samples.phtml rename to app/code/Mage/Downloadable/view/adminhtml/product/edit/downloadable/samples.phtml diff --git a/app/code/Mage/Downloadable/view/adminhtml/product/validation-rules.js b/app/code/Mage/Downloadable/view/adminhtml/product/validation-rules.js new file mode 100644 index 0000000000000..20ac30fb6ab3f --- /dev/null +++ b/app/code/Mage/Downloadable/view/adminhtml/product/validation-rules.js @@ -0,0 +1,62 @@ +/** + * Downloadable client side validation rules + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Downloadable + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +(function ($) { + $.validator.addMethod('validate-downloadable-file', function(v,element) { + var elmParent = $(element).parent(), + linkType = elmParent.find('input[value="file"]'); + if (linkType.is(':checked') && (v === '' || v === '[]')) { + newFileContainer = elmParent.find('.new-file'); + if (!alertAlreadyDisplayed && (newFileContainer.empty() || newFileContainer.is(':visible'))) { + alertAlreadyDisplayed = true; + alert($.mage.__('There are files that were selected but not uploaded yet. ' + + 'Please upload or remove them first')); + } + return false; + } + return true; + }, 'Please upload a file.'); + $.validator.addMethod('validate-downloadable-url', function(v,element) { + linkType = $(element).parent().find('input[value="file"]'); + if (linkType.is(':checked') && v === '') { + return false; + } + return true; + }, 'Please specify Url.'); + $.validator.addMethod('validate-downloadable-link-sample-file', function(v,element) { + var fileSaveElm = $(element).closest('div').next('input[type="hidden"]'); + if ($(element).is(':checked') && (fileSaveElm.val() === '' || fileSaveElm.val() === '[]')) { + return false; + } + return true; + }, 'Please specify File.'); + $.validator.addMethod('validate-downloadable-link-sample-url', function(v,element) { + if ($(element).is(':checked') && $(element).closest('p').find('input[type="text"]').val() === '') { + return false; + } + return true; + }, 'Please specify Sample URL.'); +})(jQuery); diff --git a/app/code/Mage/Downloadable/view/adminhtml/sales/items/column/downloadable/creditmemo/name.phtml b/app/code/Mage/Downloadable/view/adminhtml/sales/items/column/downloadable/creditmemo/name.phtml new file mode 100644 index 0000000000000..89e5b47888e47 --- /dev/null +++ b/app/code/Mage/Downloadable/view/adminhtml/sales/items/column/downloadable/creditmemo/name.phtml @@ -0,0 +1,62 @@ + + +getItem()): ?> +
    getName() ?>
    +
    helper('Mage_Sales_Helper_Data')->__('SKU') ?>: ', Mage::helper('Mage_Catalog_Helper_Data')->splitSku($this->escapeHtml($this->getSku()))); ?>
    + getOrderOptions()): ?> +
    + getOrderOptions() as $_option): ?> +
    +
    + + + + truncate($_option['value'], 55, '', $_remainder);?> + + ... + + + +
    + +
    + + getLinks()): ?> +
    +
    getLinksTitle(); ?>
    + getLinks()->getPurchasedItems() as $_link): ?> +
    escapeHtml($_link->getLinkTitle()); ?>
    + +
    + + escapeHtml($_item->getDescription()) ?> + diff --git a/app/code/Mage/Downloadable/view/adminhtml/sales/items/column/downloadable/invoice/name.phtml b/app/code/Mage/Downloadable/view/adminhtml/sales/items/column/downloadable/invoice/name.phtml new file mode 100644 index 0000000000000..b3f0f9714dea6 --- /dev/null +++ b/app/code/Mage/Downloadable/view/adminhtml/sales/items/column/downloadable/invoice/name.phtml @@ -0,0 +1,62 @@ + + +getItem()): ?> +
    getName() ?>
    +
    helper('Mage_Sales_Helper_Data')->__('SKU') ?>: ', Mage::helper('Mage_Catalog_Helper_Data')->splitSku($this->escapeHtml($this->getSku()))); ?>
    + getOrderOptions()): ?> +
    + getOrderOptions() as $_option): ?> +
    +
    + + + + truncate($_option['value'], 55, '', $_remainder);?> + + ... + + + +
    + +
    + + getLinks()): ?> +
    +
    getLinksTitle(); ?>
    + getLinks()->getPurchasedItems() as $_link): ?> +
    escapeHtml($_link->getLinkTitle()); ?> (getNumberOfDownloadsBought()?$_link->getNumberOfDownloadsBought():Mage::helper('Mage_Downloadable_Helper_Data')->__('Unlimited') ?>)
    + +
    + + escapeHtml($_item->getDescription()) ?> + diff --git a/app/code/Mage/Downloadable/view/adminhtml/sales/items/column/downloadable/name.phtml b/app/code/Mage/Downloadable/view/adminhtml/sales/items/column/downloadable/name.phtml new file mode 100644 index 0000000000000..5ff45a85bce34 --- /dev/null +++ b/app/code/Mage/Downloadable/view/adminhtml/sales/items/column/downloadable/name.phtml @@ -0,0 +1,62 @@ + + +getItem()): ?> +
    getName() ?>
    +
    helper('Mage_Sales_Helper_Data')->__('SKU') ?>: ', Mage::helper('Mage_Catalog_Helper_Data')->splitSku($this->escapeHtml($this->getSku()))); ?>
    + getOrderOptions()): ?> +
    + getOrderOptions() as $_option): ?> +
    +
    + + + + truncate($_option['value'], 55, '', $_remainder);?> + + ... + + + +
    + +
    + + getLinks()): ?> +
    +
    getLinksTitle(); ?>
    + getLinks()->getPurchasedItems() as $_link): ?> +
    escapeHtml($_link->getLinkTitle()) ?> (getNumberOfDownloadsUsed() . ' / ' . ($_link->getNumberOfDownloadsBought()?$_link->getNumberOfDownloadsBought():Mage::helper('Mage_Downloadable_Helper_Data')->__('U')) ?>)
    + +
    + + escapeHtml($_item->getDescription()) ?> + diff --git a/app/code/Mage/Downloadable/view/adminhtml/sales/order/creditmemo/create/items/renderer/downloadable.phtml b/app/code/Mage/Downloadable/view/adminhtml/sales/order/creditmemo/create/items/renderer/downloadable.phtml new file mode 100644 index 0000000000000..eb3021f5099dd --- /dev/null +++ b/app/code/Mage/Downloadable/view/adminhtml/sales/order/creditmemo/create/items/renderer/downloadable.phtml @@ -0,0 +1,137 @@ + +getItem() ?> +setPriceDataObject($_item); ?> + + getColumnHtml($_item, 'downloadable') ?> + + helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + helper('Mage_Tax_Helper_Data')->__('Excl. Tax'); ?>: + + displayPriceAttribute('price') ?> + + + helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + helper('Mage_Tax_Helper_Data')->__('Incl. Tax'); ?>: + + getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 0, 'sales')): // including ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> + getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 1, 'sales')): // incl. + weee ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> +
    + + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)); ?> + getApplied($_item) as $tax): ?> + + : currency($tax['amount'],true,true); ?>
    + +
    + getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 2, 'sales')): // excl. + weee + final ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)); ?> +
    + getApplied($_item) as $tax): ?> + : currency($tax['amount'],true,true); ?>
    + + + __('Total'); ?>: + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> + + + displayPriceInclTax($_item); ?> + +
    + + + getColumnHtml($_item, 'qty') ?> + canParentReturnToStock($_item)) : ?> + + canReturnItemToStock($_item)) : ?> + getBackToStock()):?> checked/> + + + + + canEditQty()) : ?> + + + getQty()*1 ?> + + + + helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + helper('Mage_Tax_Helper_Data')->__('Excl. Tax'); ?>: + + displayPriceAttribute('row_total') ?> + + + helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + helper('Mage_Tax_Helper_Data')->__('Incl. Tax'); ?>: + + + getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 0, 'sales')): // including ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> + getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 1, 'sales')): // incl. + weee ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> +
    + + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)); ?> + getApplied($_item) as $tax): ?> + + : currency($tax['row_amount'],true,true); ?>
    + +
    + getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 2, 'sales')): // excl. + weee + final ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)); ?> +
    + getApplied($_item) as $tax): ?> + : currency($tax['row_amount'],true,true); ?>
    + + + __('Total'); ?>: + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> + + + displaySubtotalInclTax($_item); ?> + + +
    + + displayPriceAttribute('tax_amount') ?> + displayPriceAttribute('discount_amount') ?> + + displayPrices( + $_item->getBaseRowTotal()+$_item->getBaseTaxAmount()-$_item->getBaseDiscountAmount()+$_item->getWeeeTaxAppliedAmount(), + $_item->getRowTotal()+$_item->getTaxAmount()-$_item->getDiscountAmount()+$_item->getWeeeTaxAppliedAmount() + ) ?> + + diff --git a/app/code/Mage/Downloadable/view/adminhtml/sales/order/creditmemo/view/items/renderer/downloadable.phtml b/app/code/Mage/Downloadable/view/adminhtml/sales/order/creditmemo/view/items/renderer/downloadable.phtml new file mode 100644 index 0000000000000..f1a3977779fe1 --- /dev/null +++ b/app/code/Mage/Downloadable/view/adminhtml/sales/order/creditmemo/view/items/renderer/downloadable.phtml @@ -0,0 +1,123 @@ + +getItem() ?> +setPriceDataObject($_item) ?> + + getColumnHtml($_item, 'downloadable') ?> + + helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + helper('Mage_Tax_Helper_Data')->__('Excl. Tax'); ?>: + + displayPriceAttribute('price') ?> + + + helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + helper('Mage_Tax_Helper_Data')->__('Incl. Tax'); ?>: + + getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 0, 'sales')): // including ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> + getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 1, 'sales')): // incl. + weee ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> +
    + + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)); ?> + getApplied($_item) as $tax): ?> + + : currency($tax['amount'],true,true); ?>
    + +
    + getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 2, 'sales')): // excl. + weee + final ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)); ?> +
    + getApplied($_item) as $tax): ?> + : currency($tax['amount'],true,true); ?>
    + + + __('Total'); ?>: + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> + + + displayPriceInclTax($_item); ?> + +
    + + + getQty()*1 ?> + + helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + helper('Mage_Tax_Helper_Data')->__('Excl. Tax'); ?>: + + displayPriceAttribute('row_total') ?> + + + helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + helper('Mage_Tax_Helper_Data')->__('Incl. Tax'); ?>: + + + getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 0, 'sales')): // including ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> + getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 1, 'sales')): // incl. + weee ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> +
    + + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)); ?> + getApplied($_item) as $tax): ?> + + : currency($tax['row_amount'],true,true); ?>
    + +
    + getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 2, 'sales')): // excl. + weee + final ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)); ?> +
    + getApplied($_item) as $tax): ?> + : currency($tax['row_amount'],true,true); ?>
    + + + __('Total'); ?>: + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> + + + displaySubtotalInclTax($_item); ?> + +
    + + + displayPriceAttribute('tax_amount') ?> + displayPriceAttribute('discount_amount') ?> + + displayPrices( + $_item->getBaseRowTotal()-$_item->getBaseDiscountAmount()+$_item->getBaseTaxAmount(), + $_item->getRowTotal()-$_item->getDiscountAmount()+$_item->getTaxAmount()+$_item->getWeeeTaxAppliedAmount() + ) ?> + + diff --git a/app/code/Mage/Downloadable/view/adminhtml/sales/order/invoice/create/items/renderer/downloadable.phtml b/app/code/Mage/Downloadable/view/adminhtml/sales/order/invoice/create/items/renderer/downloadable.phtml new file mode 100644 index 0000000000000..b322db21835cf --- /dev/null +++ b/app/code/Mage/Downloadable/view/adminhtml/sales/order/invoice/create/items/renderer/downloadable.phtml @@ -0,0 +1,130 @@ + +getItem() ?> +setPriceDataObject($_item)?> + + getColumnHtml($_item, 'downloadable') ?> + + helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + helper('Mage_Tax_Helper_Data')->__('Excl. Tax'); ?>: + + displayPriceAttribute('price') ?> + + + helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + helper('Mage_Tax_Helper_Data')->__('Incl. Tax'); ?>: + + getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 0, 'sales')): // including ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> + getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 1, 'sales')): // incl. + weee ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> +
    + + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)); ?> + getApplied($_item) as $tax): ?> + + : currency($tax['amount'],true,true); ?>
    + +
    + getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 2, 'sales')): // excl. + weee + final ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)); ?> +
    + getApplied($_item) as $tax): ?> + : currency($tax['amount'],true,true); ?>
    + + + __('Total'); ?>: + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> + + + displayPriceInclTax($_item); ?> + +
    + + + getColumnHtml($_item, 'qty') ?> + + canEditQty()) : ?> + + + getQty()*1 ?> + + + + helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + helper('Mage_Tax_Helper_Data')->__('Excl. Tax'); ?>: + + displayPriceAttribute('row_total') ?> + + + helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + helper('Mage_Tax_Helper_Data')->__('Incl. Tax'); ?>: + + + getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 0, 'sales')): // including ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> + getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 1, 'sales')): // incl. + weee ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> +
    + + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)); ?> + getApplied($_item) as $tax): ?> + + : currency($tax['row_amount'],true,true); ?>
    + +
    + getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 2, 'sales')): // excl. + weee + final ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)); ?> +
    + getApplied($_item) as $tax): ?> + : currency($tax['row_amount'],true,true); ?>
    + + + __('Total'); ?>: + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> + + + displaySubtotalInclTax($_item); ?> + +
    + + + displayPriceAttribute('tax_amount') ?> + displayPriceAttribute('discount_amount') ?> + + displayPrices( + $_item->getBaseRowTotal()+$_item->getBaseTaxAmount()-$_item->getBaseDiscountAmount(), + $_item->getRowTotal()+$_item->getTaxAmount()-$_item->getDiscountAmount()+$_item->getWeeeTaxAppliedRowAmount() + ) ?> + + diff --git a/app/code/Mage/Downloadable/view/adminhtml/sales/order/invoice/view/items/renderer/downloadable.phtml b/app/code/Mage/Downloadable/view/adminhtml/sales/order/invoice/view/items/renderer/downloadable.phtml new file mode 100644 index 0000000000000..10d35b9b3b7d0 --- /dev/null +++ b/app/code/Mage/Downloadable/view/adminhtml/sales/order/invoice/view/items/renderer/downloadable.phtml @@ -0,0 +1,123 @@ + +getItem() ?> +setPriceDataObject($_item) ?> + + getColumnHtml($_item, 'downloadable') ?> + + helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + helper('Mage_Tax_Helper_Data')->__('Excl. Tax'); ?>: + + displayPriceAttribute('price') ?> + + + helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + helper('Mage_Tax_Helper_Data')->__('Incl. Tax'); ?>: + + getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 0, 'sales')): // including ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> + getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 1, 'sales')): // incl. + weee ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> +
    + + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)); ?> + getApplied($_item) as $tax): ?> + + : currency($tax['amount'],true,true); ?>
    + +
    + getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 2, 'sales')): // excl. + weee + final ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)); ?> +
    + getApplied($_item) as $tax): ?> + : currency($tax['amount'],true,true); ?>
    + + + __('Total'); ?>: + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> + + + displayPriceInclTax($_item); ?> + +
    + + + getQty()*1 ?> + + helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + helper('Mage_Tax_Helper_Data')->__('Excl. Tax'); ?>: + + displayPriceAttribute('row_total') ?> + + + helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + helper('Mage_Tax_Helper_Data')->__('Incl. Tax'); ?>: + + + getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 0, 'sales')): // including ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> + getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 1, 'sales')): // incl. + weee ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> +
    + + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)); ?> + getApplied($_item) as $tax): ?> + + : currency($tax['row_amount'],true,true); ?>
    + +
    + getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 2, 'sales')): // excl. + weee + final ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)); ?> +
    + getApplied($_item) as $tax): ?> + : currency($tax['row_amount'],true,true); ?>
    + + + __('Total'); ?>: + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> + + + displaySubtotalInclTax($_item); ?> + +
    + + + displayPriceAttribute('tax_amount') ?> + displayPriceAttribute('discount_amount') ?> + + displayPrices( + $_item->getBaseRowTotal()+$_item->getBaseTaxAmount()-$_item->getBaseDiscountAmount()+$_item->getWeeeTaxAppliedAmount(), + $_item->getRowTotal()+$_item->getTaxAmount()-$_item->getDiscountAmount()+$_item->getWeeeTaxAppliedAmount() + ) ?> + + diff --git a/app/code/Mage/Downloadable/view/adminhtml/sales/order/view/items/renderer/downloadable.phtml b/app/code/Mage/Downloadable/view/adminhtml/sales/order/view/items/renderer/downloadable.phtml new file mode 100644 index 0000000000000..00896e1dd0eb9 --- /dev/null +++ b/app/code/Mage/Downloadable/view/adminhtml/sales/order/view/items/renderer/downloadable.phtml @@ -0,0 +1,143 @@ + +getItem() ?> +setPriceDataObject($_item) ?> +canDisplayGiftmessage()): ?> class="border"> + + canDisplayContainer()): ?> +
    + +
    + getColumnHtml($_item, 'downloadable') ?> +
    + canDisplayContainer()): ?> +
    + + + getStatus() ?> + displayPriceAttribute('original_price') ?> + + helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + helper('Mage_Tax_Helper_Data')->__('Excl. Tax'); ?>: + + displayPriceAttribute('price') ?> + + + helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + helper('Mage_Tax_Helper_Data')->__('Incl. Tax'); ?>: + + getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 0, 'sales')): // including ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> + getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 1, 'sales')): // incl. + weee ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> +
    + + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)); ?> + getApplied($_item) as $tax): ?> + + : currency($tax['amount'],true,true); ?>
    + +
    + getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 2, 'sales')): // excl. + weee + final ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)); ?> +
    + getApplied($_item) as $tax): ?> + : currency($tax['amount'],true,true); ?>
    + + + __('Total'); ?>: + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> + + + displayPriceInclTax($_item); ?> + +
    + + + getColumnHtml($_item, 'qty') ?> + + helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + helper('Mage_Tax_Helper_Data')->__('Excl. Tax'); ?>: + + displayPriceAttribute('row_total') ?> + + + helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + helper('Mage_Tax_Helper_Data')->__('Incl. Tax'); ?>: + + + getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 0, 'sales')): // including ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> + getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 1, 'sales')): // incl. + weee ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> +
    + + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)); ?> + getApplied($_item) as $tax): ?> + + : currency($tax['row_amount'],true,true); ?>
    + +
    + getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 2, 'sales')): // excl. + weee + final ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)); ?> +
    + getApplied($_item) as $tax): ?> + : currency($tax['row_amount'],true,true); ?>
    + + + __('Total'); ?>: + helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> + + + displaySubtotalInclTax($_item); ?> + + +
    + + + displayPriceAttribute('tax_amount') ?> + displayTaxPercent($_item) ?> + displayPriceAttribute('discount_amount') ?> + + displayPrices( + $_item->getBaseRowTotal() - $_item->getBaseDiscountAmount() + $_item->getBaseTaxAmount(), + $_item->getRowTotal() - $_item->getDiscountAmount() + $_item->getTaxAmount() + $_item->getWeeeTaxAppliedRowAmount() + ); ?> + + diff --git a/app/code/core/Mage/Downloadable/view/frontend/catalog/product/links.phtml b/app/code/Mage/Downloadable/view/frontend/catalog/product/links.phtml similarity index 100% rename from app/code/core/Mage/Downloadable/view/frontend/catalog/product/links.phtml rename to app/code/Mage/Downloadable/view/frontend/catalog/product/links.phtml diff --git a/app/code/core/Mage/Downloadable/view/frontend/catalog/product/samples.phtml b/app/code/Mage/Downloadable/view/frontend/catalog/product/samples.phtml similarity index 100% rename from app/code/core/Mage/Downloadable/view/frontend/catalog/product/samples.phtml rename to app/code/Mage/Downloadable/view/frontend/catalog/product/samples.phtml diff --git a/app/code/core/Mage/Downloadable/view/frontend/catalog/product/type.phtml b/app/code/Mage/Downloadable/view/frontend/catalog/product/type.phtml similarity index 100% rename from app/code/core/Mage/Downloadable/view/frontend/catalog/product/type.phtml rename to app/code/Mage/Downloadable/view/frontend/catalog/product/type.phtml diff --git a/app/code/Mage/Downloadable/view/frontend/checkout/cart/item/default.phtml b/app/code/Mage/Downloadable/view/frontend/checkout/cart/item/default.phtml new file mode 100644 index 0000000000000..031685a4dc80b --- /dev/null +++ b/app/code/Mage/Downloadable/view/frontend/checkout/cart/item/default.phtml @@ -0,0 +1,277 @@ + +getItem(); + $canApplyMsrp = Mage::helper('Mage_Catalog_Helper_Data')->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM); +?> + + <?php echo $this->escapeHtml($this->getProductName()) ?> + +

    escapeHtml($this->getProductName()) ?>

    + getOptionList()):?> +
    + + getFormatedOptionValue($_option) ?> +
    escapeHtml($_option['label']) ?>
    + class="truncated" data-mage-init="{truncateOptions:[]}"> + +
    +
    +
    escapeHtml($_option['label']) ?>
    +
    +
    +
    + + + +
    + + + getLinks()): ?> +
    +
    getLinksTitle() ?>
    + +
    escapeHtml($link->getTitle()) ?>
    + +
    + + + + getMessages()): ?> + +
    + * escapeHtml($message['text']) ?> +
    + + + + + __('Edit') ?> + + helper('Mage_Wishlist_Helper_Data')->isAllowInCart()) : ?> + + __('Move'); ?> + + + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> colspan="2"> + + __('See price before order confirmation.'); ?> + getId(); ?> + __("What's this?"); ?> + + + + + + + helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + +
    + + + typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?> + + helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()) ?> + + +
    + + + getApplied($_item)): ?> + + + + typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + __('Total'); ?>: helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?> +
    + + + + + helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item); ?> + typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + +
    + + + typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?> + + helper('Mage_Checkout_Helper_Data')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?> + + +
    + getApplied($_item)): ?> + + + + typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + __('Total incl. tax'); ?>: helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?> +
    + + + + + + + + + helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()) && !$_item->getNoSubtotal()): ?> + + typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + +
    + + + + -- + + typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> + + helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()) ?> + + + +
    + getApplied($_item)): ?> + + + + typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + __('Total'); ?>: helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> +
    + + + + + helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()) && !$_item->getNoSubtotal()): ?> + + helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item); ?> + typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + +
    + + + + -- + + typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> + + helper('Mage_Checkout_Helper_Data')->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> + + + +
    + + + getApplied($_item)): ?> + + + + typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + __('Total incl. tax'); ?>: helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> +
    + + + + + __('Remove Item') ?> + diff --git a/app/code/Mage/Downloadable/view/frontend/checkout/multishipping/item/downloadable.phtml b/app/code/Mage/Downloadable/view/frontend/checkout/multishipping/item/downloadable.phtml new file mode 100644 index 0000000000000..374f81e2c63ff --- /dev/null +++ b/app/code/Mage/Downloadable/view/frontend/checkout/multishipping/item/downloadable.phtml @@ -0,0 +1,57 @@ + +

    escapeHtml($this->getProductName()) ?>

    + +getOptionList()):?> +
    + + getFormatedOptionValue($_option) ?> +
    escapeHtml($_option['label']) ?>
    + class="truncated" data-mage-init="{truncateOptions:[]}"> + +
    +
    +
    escapeHtml($_option['label']) ?>
    +
    +
    +
    + + + +
    + + + + getLinks()): ?> +
    +
    getLinksTitle() ?>
    + +
    escapeHtml($link->getTitle()); ?>
    + +
    + + diff --git a/app/code/Mage/Downloadable/view/frontend/checkout/onepage/review/item.phtml b/app/code/Mage/Downloadable/view/frontend/checkout/onepage/review/item.phtml new file mode 100644 index 0000000000000..01688a11ecb15 --- /dev/null +++ b/app/code/Mage/Downloadable/view/frontend/checkout/onepage/review/item.phtml @@ -0,0 +1,246 @@ + +getItem()?> + +

    escapeHtml($this->getProductName()) ?>

    + + getOptionList()):?> +
    + + getFormatedOptionValue($_option) ?> +
    escapeHtml($_option['label']) ?>
    + class="truncated" data-mage-init="{truncateOptions:[]}"> + +
    +
    +
    escapeHtml($_option['label']) ?>
    +
    +
    +
    + + + +
    + + getLinks()): ?> +
    +
    getLinksTitle() ?>
    + +
    escapeHtml($link->getTitle()) ?>
    + +
    + + + + helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + +
    + + + typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?> + + helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()) ?> + + +
    + + + getApplied($_item)): ?> + + + + typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + __('Total'); ?>:
    helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>
    +
    + + + + + helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item); ?> + typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + +
    + + + typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?> + + helper('Mage_Checkout_Helper_Data')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?> + + +
    + getApplied($_item)): ?> + + + + typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + __('Total incl. tax'); ?>:
    helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?>
    +
    + + + + + getQty() ?> + helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + +
    + + + typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> + + helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()) ?> + + +
    + getApplied($_item)): ?> + + + + typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + __('Total'); ?>:
    helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?>
    +
    + + + + + helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + + helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item); ?> + typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + +
    + + + typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> + helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> + + helper('Mage_Checkout_Helper_Data')->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> + + +
    + + + getApplied($_item)): ?> + + + + typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> +
    + __('Total incl. tax'); ?>:
    helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
    +
    + + + + + diff --git a/app/code/core/Mage/Downloadable/view/frontend/checkout/success.phtml b/app/code/Mage/Downloadable/view/frontend/checkout/success.phtml similarity index 100% rename from app/code/core/Mage/Downloadable/view/frontend/checkout/success.phtml rename to app/code/Mage/Downloadable/view/frontend/checkout/success.phtml diff --git a/app/code/core/Mage/Downloadable/view/frontend/customer/products/list.phtml b/app/code/Mage/Downloadable/view/frontend/customer/products/list.phtml similarity index 100% rename from app/code/core/Mage/Downloadable/view/frontend/customer/products/list.phtml rename to app/code/Mage/Downloadable/view/frontend/customer/products/list.phtml diff --git a/app/code/core/Mage/Downloadable/view/frontend/downloadable.js b/app/code/Mage/Downloadable/view/frontend/downloadable.js similarity index 100% rename from app/code/core/Mage/Downloadable/view/frontend/downloadable.js rename to app/code/Mage/Downloadable/view/frontend/downloadable.js diff --git a/app/code/core/Mage/Downloadable/view/frontend/email/order/items/creditmemo/downloadable.phtml b/app/code/Mage/Downloadable/view/frontend/email/order/items/creditmemo/downloadable.phtml similarity index 100% rename from app/code/core/Mage/Downloadable/view/frontend/email/order/items/creditmemo/downloadable.phtml rename to app/code/Mage/Downloadable/view/frontend/email/order/items/creditmemo/downloadable.phtml diff --git a/app/code/core/Mage/Downloadable/view/frontend/email/order/items/invoice/downloadable.phtml b/app/code/Mage/Downloadable/view/frontend/email/order/items/invoice/downloadable.phtml similarity index 100% rename from app/code/core/Mage/Downloadable/view/frontend/email/order/items/invoice/downloadable.phtml rename to app/code/Mage/Downloadable/view/frontend/email/order/items/invoice/downloadable.phtml diff --git a/app/code/core/Mage/Downloadable/view/frontend/email/order/items/order/downloadable.phtml b/app/code/Mage/Downloadable/view/frontend/email/order/items/order/downloadable.phtml similarity index 100% rename from app/code/core/Mage/Downloadable/view/frontend/email/order/items/order/downloadable.phtml rename to app/code/Mage/Downloadable/view/frontend/email/order/items/order/downloadable.phtml diff --git a/app/code/core/Mage/Downloadable/view/frontend/layout.xml b/app/code/Mage/Downloadable/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/Downloadable/view/frontend/layout.xml rename to app/code/Mage/Downloadable/view/frontend/layout.xml diff --git a/app/code/Mage/Downloadable/view/frontend/sales/order/creditmemo/items/renderer/downloadable.phtml b/app/code/Mage/Downloadable/view/frontend/sales/order/creditmemo/items/renderer/downloadable.phtml new file mode 100644 index 0000000000000..ef3a97e87a89e --- /dev/null +++ b/app/code/Mage/Downloadable/view/frontend/sales/order/creditmemo/items/renderer/downloadable.phtml @@ -0,0 +1,307 @@ + +getItem() ?> +getItem()->getOrderItem()->getOrder() ?> + +

    escapeHtml($_item->getName()) ?>

    + getItemOptions()): ?> +
    + +
    escapeHtml($_option['label']) ?>
    + getPrintStatus()): ?> + getFormatedOptionValue($_option) ?> + class="truncated" data-mage-init="{truncateOptions:[]}"> + +
    +
    +
    escapeHtml($_option['label']) ?>
    +
    +
    +
    + + + +
    escapeHtml( (isset($_option['print_value']) ? $_option['print_value'] : $_option['value']) ) ?>
    + + +
    + + + + getLinks()): ?> +
    +
    getLinksTitle() ?>
    + getPurchasedItems() as $link): ?> +
    escapeHtml($link->getLinkTitle()); ?>
    + +
    + + + + escapeHtml($_item->getDescription()) ?> + helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $_item->getOrderItem()) && $_item->getGiftMessageId()): ?> +
    __('Gift Message') ?> + + + escapeHtml(Mage::helper('Mage_Core_Helper_String')->splitInjection($this->getSku())) ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Excl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> + + getOrder()->formatPrice($this->getItem()->getPrice()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?>
    +
    + + +
    +
    + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Incl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + helper('Mage_Checkout_Helper_Data')->getPriceInclTax($this->getItem()); ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> + + getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?>
    +
    + + +
    + + + getQty()*1 ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Excl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> + + getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?>
    +
    + + +
    +
    + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Incl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($this->getItem()); ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?> + + getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxRowDisposition()) ?> + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?>
    +
    + + + +
    + + + formatPrice(-$_item->getDiscountAmount()) ?> + + formatPrice($_item->getRowTotal()-$_item->getDiscountAmount()+$_item->getTaxAmount()+$_item->getWeeeTaxAppliedRowAmount()) ?> + + diff --git a/app/code/Mage/Downloadable/view/frontend/sales/order/invoice/items/renderer/downloadable.phtml b/app/code/Mage/Downloadable/view/frontend/sales/order/invoice/items/renderer/downloadable.phtml new file mode 100644 index 0000000000000..90012198217fe --- /dev/null +++ b/app/code/Mage/Downloadable/view/frontend/sales/order/invoice/items/renderer/downloadable.phtml @@ -0,0 +1,307 @@ + +getItem() ?> +getItem()->getOrderItem()->getOrder() ?> + +

    escapeHtml($_item->getName()) ?>

    + getItemOptions()): ?> +
    + +
    escapeHtml($_option['label']) ?>
    + getPrintStatus()): ?> + getFormatedOptionValue($_option) ?> + class="truncated" data-mage-init="{truncateOptions:[]}"> + + +
    +
    +
    escapeHtml($_option['label']) ?>
    +
    +
    +
    + + + +
    escapeHtml( (isset($_option['print_value']) ? $_option['print_value'] : $_option['value']) ) ?>
    + + +
    + + + + getLinks()): ?> +
    +
    getLinksTitle() ?>
    + getPurchasedItems() as $link): ?> +
    escapeHtml($link->getLinkTitle()); ?>
    + +
    + + + + escapeHtml($_item->getDescription()) ?> + helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $_item->getOrderItem()) && $_item->getGiftMessageId()): ?> +
    __('Gift Message') ?> + + + escapeHtml(Mage::helper('Mage_Core_Helper_String')->splitInjection($this->getSku())) ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Excl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> + + getOrder()->formatPrice($this->getItem()->getPrice()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?>
    +
    + + +
    +
    + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Incl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + helper('Mage_Checkout_Helper_Data')->getPriceInclTax($this->getItem()); ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> + + getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?>
    +
    + + +
    + + + getQty()*1 ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Excl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> + + getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?>
    +
    + + +
    +
    + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Incl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($this->getItem()); ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?> + + getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxRowDisposition()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?>
    +
    + + + + + +
    + + + diff --git a/app/code/Mage/Downloadable/view/frontend/sales/order/items/renderer/downloadable.phtml b/app/code/Mage/Downloadable/view/frontend/sales/order/items/renderer/downloadable.phtml new file mode 100644 index 0000000000000..f9f026267b884 --- /dev/null +++ b/app/code/Mage/Downloadable/view/frontend/sales/order/items/renderer/downloadable.phtml @@ -0,0 +1,329 @@ + +getItem() ?> + +

    escapeHtml($_item->getName()) ?>

    + getItemOptions()): ?> +
    + +
    escapeHtml($_option['label']) ?>
    + getPrintStatus()): ?> + getFormatedOptionValue($_option) ?> + class="truncated" data-mage-init="{truncateOptions:[]}"> + + +
    +
    +
    escapeHtml($_option['label']) ?>
    +
    +
    +
    + + + +
    escapeHtml( (isset($_option['print_value']) ? $_option['print_value'] : $_option['value']) ) ?>
    + + +
    + + + + getLinks()): ?> +
    +
    getLinksTitle() ?>
    + getPurchasedItems() as $link): ?> +
    escapeHtml($link->getLinkTitle()); ?>
    + +
    + + + + escapeHtml($_item->getDescription()) ?> + helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $_item) && $_item->getGiftMessageId()): ?> +
    __('Gift Message') ?> + + + escapeHtml(Mage::helper('Mage_Core_Helper_String')->splitInjection($this->getSku())) ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Excl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> + + getOrder()->formatPrice($this->getItem()->getPrice()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?>
    +
    + + +
    +
    + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Incl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + helper('Mage_Checkout_Helper_Data')->getPriceInclTax($this->getItem()); ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> + + getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?>
    +
    + + +
    + + + + + getItem()->getQtyOrdered() > 0): ?> + __('Ordered'); ?>: getItem()->getQtyOrdered()*1 ?>
    + + getItem()->getQtyShipped() > 0): ?> + __('Shipped'); ?>: getItem()->getQtyShipped()*1 ?>
    + + getItem()->getQtyCanceled() > 0): ?> + __('Canceled'); ?>: getItem()->getQtyCanceled()*1 ?>
    + + getItem()->getQtyRefunded() > 0): ?> + __('Refunded'); ?>: getItem()->getQtyRefunded()*1 ?>
    + +
    + + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Excl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> + + getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?>
    +
    + + +
    +
    + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Incl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($this->getItem()); ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?> + + getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxRowDisposition()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?>
    +
    + + + + + +
    + + + + diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Js.php b/app/code/Mage/Eav/Block/Adminhtml/Attribute/Edit/Js.php similarity index 100% rename from app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Js.php rename to app/code/Mage/Eav/Block/Adminhtml/Attribute/Edit/Js.php diff --git a/app/code/Mage/Eav/Block/Adminhtml/Attribute/Edit/Main/Abstract.php b/app/code/Mage/Eav/Block/Adminhtml/Attribute/Edit/Main/Abstract.php new file mode 100644 index 0000000000000..6cecc87751f31 --- /dev/null +++ b/app/code/Mage/Eav/Block/Adminhtml/Attribute/Edit/Main/Abstract.php @@ -0,0 +1,223 @@ + + */ +abstract class Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract extends Mage_Adminhtml_Block_Widget_Form +{ + protected $_attribute = null; + + public function setAttributeObject($attribute) + { + $this->_attribute = $attribute; + return $this; + } + + public function getAttributeObject() + { + if (null === $this->_attribute) { + return Mage::registry('entity_attribute'); + } + return $this->_attribute; + } + + /** + * Preparing default form elements for editing attribute + * + * @return Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract + */ + protected function _prepareForm() + { + $attributeObject = $this->getAttributeObject(); + + $form = new Varien_Data_Form(array( + 'id' => 'edit_form', + 'action' => $this->getData('action'), + 'method' => 'post' + )); + + $fieldset = $form->addFieldset('base_fieldset', + array('legend'=>Mage::helper('Mage_Eav_Helper_Data')->__('Attribute Properties')) + ); + if ($attributeObject->getAttributeId()) { + $fieldset->addField('attribute_id', 'hidden', array( + 'name' => 'attribute_id', + )); + } + + $this->_addElementTypes($fieldset); + + $yesno = Mage::getModel('Mage_Backend_Model_Config_Source_Yesno')->toOptionArray(); + + $validateClass = sprintf('validate-code validate-length maximum-length-%d', + Mage_Eav_Model_Entity_Attribute::ATTRIBUTE_CODE_MAX_LENGTH); + $fieldset->addField('attribute_code', 'text', array( + 'name' => 'attribute_code', + 'label' => Mage::helper('Mage_Eav_Helper_Data')->__('Attribute Code'), + 'title' => Mage::helper('Mage_Eav_Helper_Data')->__('Attribute Code'), + 'note' => Mage::helper('Mage_Eav_Helper_Data')->__('For internal use. Must be unique with no spaces. Maximum length of attribute code must be less than %s symbols', Mage_Eav_Model_Entity_Attribute::ATTRIBUTE_CODE_MAX_LENGTH), + 'class' => $validateClass, + 'required' => true, + )); + + $inputTypes = Mage::getModel('Mage_Eav_Model_Adminhtml_System_Config_Source_Inputtype')->toOptionArray(); + + $fieldset->addField('frontend_input', 'select', array( + 'name' => 'frontend_input', + 'label' => Mage::helper('Mage_Eav_Helper_Data')->__('Catalog Input Type for Store Owner'), + 'title' => Mage::helper('Mage_Eav_Helper_Data')->__('Catalog Input Type for Store Owner'), + 'value' => 'text', + 'values'=> $inputTypes + )); + + $fieldset->addField('default_value_text', 'text', array( + 'name' => 'default_value_text', + 'label' => Mage::helper('Mage_Eav_Helper_Data')->__('Default Value'), + 'title' => Mage::helper('Mage_Eav_Helper_Data')->__('Default Value'), + 'value' => $attributeObject->getDefaultValue(), + )); + + $fieldset->addField('default_value_yesno', 'select', array( + 'name' => 'default_value_yesno', + 'label' => Mage::helper('Mage_Eav_Helper_Data')->__('Default Value'), + 'title' => Mage::helper('Mage_Eav_Helper_Data')->__('Default Value'), + 'values' => $yesno, + 'value' => $attributeObject->getDefaultValue(), + )); + + $dateFormat = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); + $fieldset->addField('default_value_date', 'date', array( + 'name' => 'default_value_date', + 'label' => Mage::helper('Mage_Eav_Helper_Data')->__('Default Value'), + 'title' => Mage::helper('Mage_Eav_Helper_Data')->__('Default Value'), + 'image' => $this->getViewFileUrl('images/grid-cal.gif'), + 'value' => $attributeObject->getDefaultValue(), + 'date_format' => $dateFormat + )); + + $fieldset->addField('default_value_textarea', 'textarea', array( + 'name' => 'default_value_textarea', + 'label' => Mage::helper('Mage_Eav_Helper_Data')->__('Default Value'), + 'title' => Mage::helper('Mage_Eav_Helper_Data')->__('Default Value'), + 'value' => $attributeObject->getDefaultValue(), + )); + + $fieldset->addField('is_unique', 'select', array( + 'name' => 'is_unique', + 'label' => Mage::helper('Mage_Eav_Helper_Data')->__('Unique Value'), + 'title' => Mage::helper('Mage_Eav_Helper_Data')->__('Unique Value (not shared with other products)'), + 'note' => Mage::helper('Mage_Eav_Helper_Data')->__('Not shared with other products'), + 'values' => $yesno, + )); + + $fieldset->addField('is_required', 'select', array( + 'name' => 'is_required', + 'label' => Mage::helper('Mage_Eav_Helper_Data')->__('Values Required'), + 'title' => Mage::helper('Mage_Eav_Helper_Data')->__('Values Required'), + 'values' => $yesno, + )); + + $fieldset->addField('frontend_class', 'select', array( + 'name' => 'frontend_class', + 'label' => Mage::helper('Mage_Eav_Helper_Data')->__('Input Validation for Store Owner'), + 'title' => Mage::helper('Mage_Eav_Helper_Data')->__('Input Validation for Store Owner'), + 'values'=> Mage::helper('Mage_Eav_Helper_Data')->getFrontendClasses( + $attributeObject->getEntityType()->getEntityTypeCode() + ) + )); + + if ($attributeObject->getId()) { + $form->getElement('attribute_code')->setDisabled(1); + $form->getElement('frontend_input')->setDisabled(1); + if (!$attributeObject->getIsUserDefined()) { + $form->getElement('is_unique')->setDisabled(1); + } + } + + $this->setForm($form); + + return parent::_prepareForm(); + } + + /** + * Initialize form fileds values + * + * @return Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract + */ + protected function _initFormValues() + { + Mage::dispatchEvent('adminhtml_block_eav_attribute_edit_form_init', array('form' => $this->getForm())); + $this->getForm() + ->addValues($this->getAttributeObject()->getData()); + return parent::_initFormValues(); + } + + /** + * This method is called before rendering HTML + * + * @return Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract + */ + protected function _beforeToHtml() + { + parent::_beforeToHtml(); + $attributeObject = $this->getAttributeObject(); + if ($attributeObject->getId()) { + $form = $this->getForm(); + $disableAttributeFields = Mage::helper('Mage_Eav_Helper_Data') + ->getAttributeLockedFields($attributeObject->getEntityType()->getEntityTypeCode()); + if (isset($disableAttributeFields[$attributeObject->getAttributeCode()])) { + foreach ($disableAttributeFields[$attributeObject->getAttributeCode()] as $field) { + if ($elm = $form->getElement($field)) { + $elm->setDisabled(1); + $elm->setReadonly(1); + } + } + } + } + return $this; + } + + /** + * Processing block html after rendering + * Adding js block to the end of this block + * + * @param string $html + * @return string + */ + protected function _afterToHtml($html) + { + $jsScripts = $this->getLayout() + ->createBlock('Mage_Eav_Block_Adminhtml_Attribute_Edit_Js')->toHtml(); + return $html.$jsScripts; + } + +} diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Options/Abstract.php b/app/code/Mage/Eav/Block/Adminhtml/Attribute/Edit/Options/Abstract.php similarity index 100% rename from app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Options/Abstract.php rename to app/code/Mage/Eav/Block/Adminhtml/Attribute/Edit/Options/Abstract.php diff --git a/app/code/Mage/Eav/Block/Adminhtml/Attribute/Grid/Abstract.php b/app/code/Mage/Eav/Block/Adminhtml/Attribute/Grid/Abstract.php new file mode 100644 index 0000000000000..9fe5939ac35fb --- /dev/null +++ b/app/code/Mage/Eav/Block/Adminhtml/Attribute/Grid/Abstract.php @@ -0,0 +1,109 @@ + + */ +abstract class Mage_Eav_Block_Adminhtml_Attribute_Grid_Abstract extends Mage_Adminhtml_Block_Widget_Grid +{ + + protected function _construct() + { + parent::_construct(); + $this->setId('attributeGrid'); + $this->setDefaultSort('attribute_code'); + $this->setDefaultDir('ASC'); + } + + /** + * Prepare default grid column + * + * @return Mage_Eav_Block_Adminhtml_Attribute_Grid_Abstract + */ + protected function _prepareColumns() + { + parent::_prepareColumns(); + + $this->addColumn('attribute_code', array( + 'header'=>Mage::helper('Mage_Eav_Helper_Data')->__('Attribute Code'), + 'sortable'=>true, + 'index'=>'attribute_code', + 'header_css_class' => 'col-attr-code', + 'column_css_class' => 'col-attr-code' + )); + + $this->addColumn('frontend_label', array( + 'header'=>Mage::helper('Mage_Eav_Helper_Data')->__('Attribute Label'), + 'sortable'=>true, + 'index'=>'frontend_label', + 'header_css_class' => 'col-label', + 'column_css_class' => 'col-label' + )); + + $this->addColumn('is_required', array( + 'header'=>Mage::helper('Mage_Eav_Helper_Data')->__('Required'), + 'sortable'=>true, + 'index'=>'is_required', + 'type' => 'options', + 'options' => array( + '1' => Mage::helper('Mage_Eav_Helper_Data')->__('Yes'), + '0' => Mage::helper('Mage_Eav_Helper_Data')->__('No'), + ), + 'header_css_class' => 'col-required', + 'column_css_class' => 'col-required' + )); + + $this->addColumn('is_user_defined', array( + 'header'=>Mage::helper('Mage_Eav_Helper_Data')->__('System'), + 'sortable'=>true, + 'index'=>'is_user_defined', + 'type' => 'options', + 'options' => array( + '0' => Mage::helper('Mage_Eav_Helper_Data')->__('Yes'), // intended reverted use + '1' => Mage::helper('Mage_Eav_Helper_Data')->__('No'), // intended reverted use + ), + 'header_css_class' => 'col-system', + 'column_css_class' => 'col-system' + )); + + return $this; + } + + /** + * Return url of given row + * + * @return string + */ + public function getRowUrl($row) + { + return $this->getUrl('*/*/edit', array('attribute_id' => $row->getAttributeId())); + } + +} diff --git a/app/code/core/Mage/Eav/Exception.php b/app/code/Mage/Eav/Exception.php similarity index 100% rename from app/code/core/Mage/Eav/Exception.php rename to app/code/Mage/Eav/Exception.php diff --git a/app/code/core/Mage/Eav/Helper/Data.php b/app/code/Mage/Eav/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Eav/Helper/Data.php rename to app/code/Mage/Eav/Helper/Data.php diff --git a/app/code/core/Mage/Eav/Model/Adminhtml/System/Config/Source/Inputtype.php b/app/code/Mage/Eav/Model/Adminhtml/System/Config/Source/Inputtype.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Adminhtml/System/Config/Source/Inputtype.php rename to app/code/Mage/Eav/Model/Adminhtml/System/Config/Source/Inputtype.php diff --git a/app/code/core/Mage/Eav/Model/Adminhtml/System/Config/Source/Inputtype/Validator.php b/app/code/Mage/Eav/Model/Adminhtml/System/Config/Source/Inputtype/Validator.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Adminhtml/System/Config/Source/Inputtype/Validator.php rename to app/code/Mage/Eav/Model/Adminhtml/System/Config/Source/Inputtype/Validator.php diff --git a/app/code/core/Mage/Eav/Model/Attribute.php b/app/code/Mage/Eav/Model/Attribute.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Attribute.php rename to app/code/Mage/Eav/Model/Attribute.php diff --git a/app/code/core/Mage/Eav/Model/Attribute/Data.php b/app/code/Mage/Eav/Model/Attribute/Data.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Attribute/Data.php rename to app/code/Mage/Eav/Model/Attribute/Data.php diff --git a/app/code/core/Mage/Eav/Model/Attribute/Data/Abstract.php b/app/code/Mage/Eav/Model/Attribute/Data/Abstract.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Attribute/Data/Abstract.php rename to app/code/Mage/Eav/Model/Attribute/Data/Abstract.php diff --git a/app/code/core/Mage/Eav/Model/Attribute/Data/Boolean.php b/app/code/Mage/Eav/Model/Attribute/Data/Boolean.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Attribute/Data/Boolean.php rename to app/code/Mage/Eav/Model/Attribute/Data/Boolean.php diff --git a/app/code/core/Mage/Eav/Model/Attribute/Data/Date.php b/app/code/Mage/Eav/Model/Attribute/Data/Date.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Attribute/Data/Date.php rename to app/code/Mage/Eav/Model/Attribute/Data/Date.php diff --git a/app/code/core/Mage/Eav/Model/Attribute/Data/File.php b/app/code/Mage/Eav/Model/Attribute/Data/File.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Attribute/Data/File.php rename to app/code/Mage/Eav/Model/Attribute/Data/File.php diff --git a/app/code/core/Mage/Eav/Model/Attribute/Data/Hidden.php b/app/code/Mage/Eav/Model/Attribute/Data/Hidden.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Attribute/Data/Hidden.php rename to app/code/Mage/Eav/Model/Attribute/Data/Hidden.php diff --git a/app/code/core/Mage/Eav/Model/Attribute/Data/Image.php b/app/code/Mage/Eav/Model/Attribute/Data/Image.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Attribute/Data/Image.php rename to app/code/Mage/Eav/Model/Attribute/Data/Image.php diff --git a/app/code/core/Mage/Eav/Model/Attribute/Data/Multiline.php b/app/code/Mage/Eav/Model/Attribute/Data/Multiline.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Attribute/Data/Multiline.php rename to app/code/Mage/Eav/Model/Attribute/Data/Multiline.php diff --git a/app/code/core/Mage/Eav/Model/Attribute/Data/Multiselect.php b/app/code/Mage/Eav/Model/Attribute/Data/Multiselect.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Attribute/Data/Multiselect.php rename to app/code/Mage/Eav/Model/Attribute/Data/Multiselect.php diff --git a/app/code/core/Mage/Eav/Model/Attribute/Data/Select.php b/app/code/Mage/Eav/Model/Attribute/Data/Select.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Attribute/Data/Select.php rename to app/code/Mage/Eav/Model/Attribute/Data/Select.php diff --git a/app/code/core/Mage/Eav/Model/Attribute/Data/Text.php b/app/code/Mage/Eav/Model/Attribute/Data/Text.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Attribute/Data/Text.php rename to app/code/Mage/Eav/Model/Attribute/Data/Text.php diff --git a/app/code/core/Mage/Eav/Model/Attribute/Data/Textarea.php b/app/code/Mage/Eav/Model/Attribute/Data/Textarea.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Attribute/Data/Textarea.php rename to app/code/Mage/Eav/Model/Attribute/Data/Textarea.php diff --git a/app/code/core/Mage/Eav/Model/AttributeFactory.php b/app/code/Mage/Eav/Model/AttributeFactory.php similarity index 100% rename from app/code/core/Mage/Eav/Model/AttributeFactory.php rename to app/code/Mage/Eav/Model/AttributeFactory.php diff --git a/app/code/Mage/Eav/Model/Cache/Type.php b/app/code/Mage/Eav/Model/Cache/Type.php new file mode 100644 index 0000000000000..fb0fa33328f8e --- /dev/null +++ b/app/code/Mage/Eav/Model/Cache/Type.php @@ -0,0 +1,51 @@ +get(self::TYPE_IDENTIFIER), self::CACHE_TAG); + } +} diff --git a/app/code/Mage/Eav/Model/Config.php b/app/code/Mage/Eav/Model/Config.php new file mode 100644 index 0000000000000..ba1bbb667486a --- /dev/null +++ b/app/code/Mage/Eav/Model/Config.php @@ -0,0 +1,709 @@ + $object) + * + * @var array + */ + protected $_objects; + + /** + * References between codes and identifiers + * + * array ( + * 'attributes'=> array ($attributeId => $attributeCode), + * 'entities' => array ($entityId => $entityCode) + * ) + * + * @var array + */ + protected $_references; + + /** + * Cache flag + * + * @var unknown_type + */ + protected $_isCacheEnabled = null; + + /** + * Array of attributes objects used in collections + * + * @var array + */ + protected $_collectionAttributes = array(); + + /** + * Reset object state + * + * @return Mage_Eav_Model_Config + */ + public function clear() + { + $this->_entityData = null; + $this->_attributeData = null; + $this->_objects = null; + $this->_references = null; + $this->_preloadedAttributes = array(); + $this->_initializedAttributes = array(); + $this->_attributeCodes = array(); + return $this; + } + + /** + * Get object by identifier + * + * @param mixed $id + * @return mixed + */ + protected function _load($id) + { + return isset($this->_objects[$id]) ? $this->_objects[$id] : null; + } + + /** + * Associate object with identifier + * + * @param mixed $obj + * @param mixed $id + * @return Mage_Eav_Model_Config + */ + protected function _save($obj, $id) + { + $this->_objects[$id] = $obj; + return $this; + } + + /** + * Specify reference for entity type id + * + * @param int $id + * @param string $code + * @return Mage_Eav_Model_Config + */ + protected function _addEntityTypeReference($id, $code) + { + $this->_references['entity'][$id] = $code; + return $this; + } + + /** + * Get entity type code by id + * + * @param int $id + * @return string + */ + protected function _getEntityTypeReference($id) + { + return isset($this->_references['entity'][$id]) ? $this->_references['entity'][$id] : null; + } + + /** + * Specify reference between entity attribute id and attribute code + * + * @param int $id + * @param string $code + * @param string $entityTypeCode + * @return Mage_Eav_Model_Config + */ + protected function _addAttributeReference($id, $code, $entityTypeCode) + { + $this->_references['attribute'][$entityTypeCode][$id] = $code; + return $this; + } + + /** + * Get attribute code by attribute id + * + * @param int $id + * @param string $entityTypeCode + * @return string + */ + protected function _getAttributeReference($id, $entityTypeCode) + { + if (isset($this->_references['attribute'][$entityTypeCode][$id])) { + return $this->_references['attribute'][$entityTypeCode][$id]; + } + return null; + } + + /** + * Get internal cache key for entity type code + * + * @param string $code + * @return string + */ + protected function _getEntityKey($code) + { + return 'ENTITY/' . $code; + } + + /** + * Get internal cache key for attribute object cache + * + * @param string $entityTypeCode + * @param string $attributeCode + * @return string + */ + protected function _getAttributeKey($entityTypeCode, $attributeCode) + { + return 'ATTRIBUTE/' . $entityTypeCode . '/' . $attributeCode; + } + + /** + * Check EAV cache availability + * + * @return bool + */ + protected function _isCacheEnabled() + { + if ($this->_isCacheEnabled === null) { + $this->_isCacheEnabled = Mage::app()->useCache(Mage_Eav_Model_Cache_Type::TYPE_IDENTIFIER); + } + return $this->_isCacheEnabled; + } + + /** + * Initialize all entity types data + * + * @return Mage_Eav_Model_Config + */ + protected function _initEntityTypes() + { + if (is_array($this->_entityData)) { + return $this; + } + Magento_Profiler::start('EAV: '.__METHOD__, array('group' => 'EAV', 'method' => __METHOD__)); + + /** + * try load information about entity types from cache + */ + if ($this->_isCacheEnabled() + && ($cache = Mage::app()->loadCache(self::ENTITIES_CACHE_ID))) { + + $this->_entityData = unserialize($cache); + foreach ($this->_entityData as $typeCode => $data) { + $typeId = $data['entity_type_id']; + $this->_addEntityTypeReference($typeId, $typeCode); + } + Magento_Profiler::stop('EAV: '.__METHOD__); + return $this; + } + + $entityTypesData = Mage::getModel('Mage_Eav_Model_Entity_Type')->getCollection()->getData(); + $types = array(); + + /** + * prepare entity type data + */ + foreach ($entityTypesData as $typeData) { + if (!isset($typeData['attribute_model'])) { + $typeData['attribute_model'] = 'Mage_Eav_Model_Entity_Attribute'; + } + + $typeCode = $typeData['entity_type_code']; + $typeId = $typeData['entity_type_id']; + + $this->_addEntityTypeReference($typeId, $typeCode); + $types[$typeCode] = $typeData; + } + + $this->_entityData = $types; + + if ($this->_isCacheEnabled()) { + Mage::app()->saveCache(serialize($this->_entityData), self::ENTITIES_CACHE_ID, + array(Mage_Eav_Model_Cache_Type::CACHE_TAG, Mage_Eav_Model_Entity_Attribute::CACHE_TAG) + ); + } + Magento_Profiler::stop('EAV: '.__METHOD__); + return $this; + } + + /** + * Get entity type object by entity type code/identifier + * + * @param mixed $code + * @return Mage_Eav_Model_Entity_Type + */ + public function getEntityType($code) + { + if ($code instanceof Mage_Eav_Model_Entity_Type) { + return $code; + } + Magento_Profiler::start('EAV: '.__METHOD__, array('group' => 'EAV', 'method' => __METHOD__)); + + if (is_numeric($code)) { + $entityCode = $this->_getEntityTypeReference($code); + if ($entityCode !== null) { + $code = $entityCode; + } + } + + $entityKey = $this->_getEntityKey($code); + $entityType = $this->_load($entityKey); + if ($entityType) { + Magento_Profiler::stop('EAV: '.__METHOD__); + return $entityType; + } + + + $entityType = Mage::getModel('Mage_Eav_Model_Entity_Type'); + if (isset($this->_entityData[$code])) { + $entityType->setData($this->_entityData[$code]); + } else { + if (is_numeric($code)) { + $entityType->load($code); + } else { + $entityType->loadByCode($code); + } + + if (!$entityType->getId()) { + Mage::throwException(Mage::helper('Mage_Eav_Helper_Data')->__('Invalid entity_type specified: %s', $code)); + } + } + $this->_addEntityTypeReference($entityType->getId(), $entityType->getEntityTypeCode()); + $this->_save($entityType, $entityKey); + + Magento_Profiler::stop('EAV: '.__METHOD__); + return $entityType; + } + + /** + * Initialize all attributes for entity type + * + * @param string $entityType + * @return Mage_Eav_Model_Config + */ + protected function _initAttributes($entityType) + { + $entityType = $this->getEntityType($entityType); + $entityTypeCode = $entityType->getEntityTypeCode(); + + if (isset($this->_initializedAttributes[$entityTypeCode])) { + return $this; + } + Magento_Profiler::start('EAV: '.__METHOD__, array('group' => 'EAV', 'method' => __METHOD__)); + + $attributesInfo = Mage::getResourceModel($entityType->getEntityAttributeCollection()) + ->setEntityTypeFilter($entityType) + ->getData(); + + $codes = array(); + foreach ($attributesInfo as $attribute) { + $this->_createAttribute($entityType, $attribute); + $codes[] = $attribute['attribute_code']; + } + + $entityType->setAttributeCodes($codes); + $this->_initializedAttributes[$entityTypeCode] = true; + + Magento_Profiler::stop('EAV: '.__METHOD__); + return $this; + } + + /** + * Get attribute by code for entity type + * + * @param mixed $entityType + * @param mixed $code + * @return Mage_Eav_Model_Entity_Attribute_Abstract|false + */ + public function getAttribute($entityType, $code) + { + if ($code instanceof Mage_Eav_Model_Entity_Attribute_Interface) { + return $code; + } + + Magento_Profiler::start('EAV: '.__METHOD__, array('group' => 'EAV', 'method' => __METHOD__)); + + $entityTypeCode = $this->getEntityType($entityType)->getEntityTypeCode(); + $entityType = $this->getEntityType($entityType); + + /** + * Validate attribute code + */ + if (is_numeric($code)) { + $attributeCode = $this->_getAttributeReference($code, $entityTypeCode); + if ($attributeCode) { + $code = $attributeCode; + } + } + $attributeKey = $this->_getAttributeKey($entityTypeCode, $code); + + /** + * Try use loaded attribute + */ + $attribute = $this->_load($attributeKey); + if ($attribute) { + Magento_Profiler::stop('EAV: '.__METHOD__); + return $attribute; + } + + if (isset($this->_attributeData[$entityTypeCode][$code])) { + $data = $this->_attributeData[$entityTypeCode][$code]; + unset($this->_attributeData[$entityTypeCode][$code]); + $attribute = Mage::getModel($data['attribute_model'], array('data' => $data)); + } else { + if (is_numeric($code)) { + $attribute = Mage::getModel($entityType->getAttributeModel())->load($code); + if ($attribute->getEntityTypeId() != $entityType->getId()) { + return false; + } + $attributeKey = $this->_getAttributeKey($entityTypeCode, $attribute->getAttributeCode()); + } else { + $attribute = Mage::getModel($entityType->getAttributeModel()) + ->loadByCode($entityType, $code) + ->setAttributeCode($code); + } + } + + if ($attribute) { + $entity = $entityType->getEntity(); + if ($entity && in_array($attribute->getAttributeCode(), $entity->getDefaultAttributes())) { + $attribute->setBackendType(Mage_Eav_Model_Entity_Attribute_Abstract::TYPE_STATIC) + ->setIsGlobal(1); + } + $attribute->setEntityType($entityType) + ->setEntityTypeId($entityType->getId()); + $this->_addAttributeReference($attribute->getId(), $attribute->getAttributeCode(), $entityTypeCode); + $this->_save($attribute, $attributeKey); + } + Magento_Profiler::stop('EAV: '.__METHOD__); + + return $attribute; + } + + /** + * Get codes of all entity type attributes + * + * @param mixed $entityType + * @param Varien_Object $object + * @return array + */ + public function getEntityAttributeCodes($entityType, $object = null) + { + $entityType = $this->getEntityType($entityType); + $attributeSetId = 0; + if (($object instanceof Varien_Object) && $object->getAttributeSetId()) { + $attributeSetId = $object->getAttributeSetId(); + } + $storeId = 0; + if (($object instanceof Varien_Object) && $object->getStoreId()) { + $storeId = $object->getStoreId(); + } + $cacheKey = sprintf('%d-%d', $entityType->getId(), $attributeSetId); + if (isset($this->_attributeCodes[$cacheKey])) { + return $this->_attributeCodes[$cacheKey]; + } + + if ($attributeSetId) { + $attributesInfo = Mage::getResourceModel($entityType->getEntityAttributeCollection()) + ->setEntityTypeFilter($entityType) + ->setAttributeSetFilter($attributeSetId) + ->addStoreLabel($storeId) + ->getData(); + $attributes = array(); + foreach ($attributesInfo as $attributeData) { + $attributes[] = $attributeData['attribute_code']; + $this->_createAttribute($entityType, $attributeData); + } + } else { + $this->_initAttributes($entityType); + $attributes = $this->getEntityType($entityType)->getAttributeCodes(); + } + + $this->_attributeCodes[$cacheKey] = $attributes; + + return $attributes; + } + + /** + * Preload entity type attributes for performance optimization + * + * @param mixed $entityType + * @param mixed $attributes + * @return Mage_Eav_Model_Config + */ + public function preloadAttributes($entityType, $attributes) + { + if (is_string($attributes)) { + $attributes = array($attributes); + } + + $entityType = $this->getEntityType($entityType); + $entityTypeCode = $entityType->getEntityTypeCode(); + + if (!isset($this->_preloadedAttributes[$entityTypeCode])) { + $this->_preloadedAttributes[$entityTypeCode] = $attributes; + } else { + $attributes = array_diff($attributes, $this->_preloadedAttributes[$entityTypeCode]); + $this->_preloadedAttributes[$entityTypeCode] = array_merge($this->_preloadedAttributes[$entityTypeCode], + $attributes + ); + } + + if (empty($attributes)) { + return $this; + } + Magento_Profiler::start('EAV: '.__METHOD__ . ':'.$entityTypeCode, + array('group' => 'EAV', 'method' => __METHOD__, 'entity_type_code' => $entityTypeCode)); + + $attributesInfo = Mage::getResourceModel($entityType->getEntityAttributeCollection()) + ->setEntityTypeFilter($entityType) + ->setCodeFilter($attributes) + ->getData(); + + if (!$attributesInfo) { + Magento_Profiler::stop('EAV: '.__METHOD__ . ':'.$entityTypeCode); + return $this; + } + + $attributesData = $codes = array(); + + foreach ($attributesInfo as $attribute) { + if (empty($attribute['attribute_model'])) { + $attribute['attribute_model'] = $entityType->getAttributeModel(); + } + + $attributeCode = $attribute['attribute_code']; + $attributeId = $attribute['attribute_id']; + + $this->_addAttributeReference($attributeId, $attributeCode, $entityTypeCode); + $attributesData[$attributeCode] = $attribute; + $codes[] = $attributeCode; + } + + $this->_attributeData[$entityTypeCode] = $attributesData; + + Magento_Profiler::stop('EAV: '.__METHOD__ . ':'.$entityTypeCode); + + return $this; + } + + /** + * Get attribute object for colection usage + * + * @param mixed $entityType + * @param string $attribute + * @return Mage_Eav_Model_Entity_Attribute_Abstract|null + */ + public function getCollectionAttribute($entityType, $attribute) + { + $entityType = $this->getEntityType($entityType); + $entityTypeCode = $entityType->getEntityTypeCode(); + + if (is_numeric($attribute)) { + $attribute = $this->_getAttributeReference($attribute, $entityTypeCode); + if (!$attribute) { + return null; + } + } + + $attributeKey = $this->_getAttributeKey($entityTypeCode, $attribute); + $attributeObject = $this->_load($attributeKey); + if ($attributeObject) { + return $attributeObject; + } + + return $this->getAttribute($entityType, $attribute); + } + + /** + * Prepare attributes for usage in EAV collection + * + * @param mixed $entityType + * @param array $attributes + * @return Mage_Eav_Model_Config + */ + public function loadCollectionAttributes($entityType, $attributes) + { + $entityType = $this->getEntityType($entityType); + $entityTypeCode = $entityType->getEntityTypeCode(); + + if (!isset($this->_collectionAttributes[$entityTypeCode])) { + $this->_collectionAttributes[$entityTypeCode] = array(); + } + $loadedAttributes = array_keys($this->_collectionAttributes[$entityTypeCode]); + $attributes = array_diff($attributes, $loadedAttributes); + + foreach ($attributes as $k => $attribute) { + if (is_numeric($attribute)) { + $attribute = $this->_getAttributeReference($attribute, $entityTypeCode); + } + $attributeKey = $this->_getAttributeKey($entityTypeCode, $attribute); + if ($this->_load($attributeKey)) { + unset($attributes[$k]); + } + } + + if (empty($attributes)) { + return $this; + } + $attributeCollection = $entityType->getEntityAttributeCollection(); + $attributesInfo = Mage::getResourceModel($attributeCollection) + ->useLoadDataFields() + ->setEntityTypeFilter($entityType) + ->setCodeFilter($attributes) + ->getData(); + + foreach ($attributesInfo as $attributeData) { + $attribute = $this->_createAttribute($entityType, $attributeData); + $this->_collectionAttributes[$entityTypeCode][$attribute->getAttributeCode()] =$attribute; + } + + return $this; + } + + /** + * Create attribute from attribute data array + * + * @param string $entityType + * @param array $attributeData + * @return Mage_Eav_Model_Entity_Attribute_Abstract + */ + protected function _createAttribute($entityType, $attributeData) + { + $entityType = $this->getEntityType($entityType); + $entityTypeCode = $entityType->getEntityTypeCode(); + + $attributeKey = $this->_getAttributeKey($entityTypeCode, $attributeData['attribute_code']); + $attribute = $this->_load($attributeKey); + if ($attribute) { + $existsFullAttribute = $attribute->hasIsRequired(); + $fullAttributeData = array_key_exists('is_required', $attributeData); + + if ($existsFullAttribute || (!$existsFullAttribute && !$fullAttributeData)) { + return $attribute; + } + } + + if (!empty($attributeData['attribute_model'])) { + $model = $attributeData['attribute_model']; + } else { + $model = $entityType->getAttributeModel(); + } + $attribute = Mage::getModel($model)->setData($attributeData); + $this->_addAttributeReference( + $attributeData['attribute_id'], + $attributeData['attribute_code'], + $entityTypeCode + ); + $attributeKey = $this->_getAttributeKey($entityTypeCode, $attributeData['attribute_code']); + $this->_save($attribute, $attributeKey); + + return $attribute; + } + + /** + * Validate attribute data from import + * + * @param array $attributeData + * @return bool + */ + protected function _validateAttributeData($attributeData = null) + { + if (!is_array($attributeData)) { + return false; + } + $requiredKeys = array( + 'attribute_id', + 'attribute_code', + 'entity_type_id', + 'attribute_model' + ); + foreach ($requiredKeys as $key) { + if (!array_key_exists($key, $attributeData)) { + return false; + } + } + + return true; + } + + /** + * Import attributes data from external source + * + * @param string|Mage_Eav_Model_Entity_Type $entityType + * @param array $attributes + * @return Mage_Eav_Model_Config + */ + public function importAttributesData($entityType, array $attributes) + { + $entityType = $this->getEntityType($entityType); + foreach ($attributes as $attributeData) { + if (!$this->_validateAttributeData($attributeData)) { + continue; + } + $this->_createAttribute($entityType, $attributeData); + } + + return $this; + } +} diff --git a/app/code/core/Mage/Eav/Model/Entity.php b/app/code/Mage/Eav/Model/Entity.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity.php rename to app/code/Mage/Eav/Model/Entity.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Abstract.php b/app/code/Mage/Eav/Model/Entity/Abstract.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Abstract.php rename to app/code/Mage/Eav/Model/Entity/Abstract.php diff --git a/app/code/Mage/Eav/Model/Entity/Attribute.php b/app/code/Mage/Eav/Model/Entity/Attribute.php new file mode 100644 index 0000000000000..fc95fa1b3e56b --- /dev/null +++ b/app/code/Mage/Eav/Model/Entity/Attribute.php @@ -0,0 +1,365 @@ + + */ +class Mage_Eav_Model_Entity_Attribute extends Mage_Eav_Model_Entity_Attribute_Abstract +{ + /** + * Prefix of model events names + * + * @var string + */ + protected $_eventPrefix = 'eav_entity_attribute'; + + CONST ATTRIBUTE_CODE_MAX_LENGTH = 30; + + /** + * Parameter name in event + * + * In observe method you can use $observer->getEvent()->getAttribute() in this case + * + * @var string + */ + protected $_eventObject = 'attribute'; + + const CACHE_TAG = 'EAV_ATTRIBUTE'; + protected $_cacheTag = 'EAV_ATTRIBUTE'; + + /** + * Retrieve default attribute backend model by attribute code + * + * @return string + */ + protected function _getDefaultBackendModel() + { + switch ($this->getAttributeCode()) { + case 'created_at': + return 'Mage_Eav_Model_Entity_Attribute_Backend_Time_Created'; + + case 'updated_at': + return 'Mage_Eav_Model_Entity_Attribute_Backend_Time_Updated'; + + case 'store_id': + return 'Mage_Eav_Model_Entity_Attribute_Backend_Store'; + + case 'increment_id': + return 'Mage_Eav_Model_Entity_Attribute_Backend_Increment'; + } + + return parent::_getDefaultBackendModel(); + } + + /** + * Retrieve default attribute frontend model + * + * @return string + */ + protected function _getDefaultFrontendModel() + { + return parent::_getDefaultFrontendModel(); + } + + /** + * Retrieve default attribute source model + * + * @return string + */ + protected function _getDefaultSourceModel() + { + if ($this->getAttributeCode() == 'store_id') { + return 'Mage_Eav_Model_Entity_Attribute_Source_Store'; + } + return parent::_getDefaultSourceModel(); + } + + /** + * Delete entity + * + * @return Mage_Eav_Model_Resource_Entity_Attribute + */ + public function deleteEntity() + { + return $this->_getResource()->deleteEntity($this); + } + + /** + * Load entity_attribute_id into $this by $this->attribute_set_id + * + * @return Mage_Core_Model_Abstract + */ + public function loadEntityAttributeIdBySet() + { + // load attributes collection filtered by attribute_id and attribute_set_id + $filteredAttributes = $this->getResourceCollection() + ->setAttributeSetFilter($this->getAttributeSetId()) + ->addFieldToFilter('entity_attribute.attribute_id', $this->getId()) + ->load(); + if (count($filteredAttributes) > 0) { + // getFirstItem() can be used as we can have one or zero records in the collection + $this->setEntityAttributeId($filteredAttributes->getFirstItem()->getEntityAttributeId()); + } + return $this; + } + + /** + * Prepare data for save + * + * @return Mage_Eav_Model_Entity_Attribute + */ + protected function _beforeSave() + { + // prevent overriding product data + if (isset($this->_data['attribute_code']) + && Mage::getModel('Mage_Catalog_Model_Product')->isReservedAttribute($this)) + { + throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('The attribute code \'%s\' is reserved by system. Please try another attribute code', $this->_data['attribute_code'])); + } + + /** + * Check for maximum attribute_code length + */ + if(isset($this->_data['attribute_code']) && + !Zend_Validate::is($this->_data['attribute_code'], + 'StringLength', + array('max' => self::ATTRIBUTE_CODE_MAX_LENGTH)) + ) { + throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Maximum length of attribute code must be less than %s symbols', self::ATTRIBUTE_CODE_MAX_LENGTH)); + } + + $defaultValue = $this->getDefaultValue(); + $hasDefaultValue = ((string)$defaultValue != ''); + + if ($this->getBackendType() == 'decimal' && $hasDefaultValue) { + if (!Zend_Locale_Format::isNumber($defaultValue, + array('locale' => Mage::app()->getLocale()->getLocaleCode())) + ) { + throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Invalid default decimal value')); + } + + try { + $filter = new Zend_Filter_LocalizedToNormalized( + array('locale' => Mage::app()->getLocale()->getLocaleCode()) + ); + $this->setDefaultValue($filter->filter($defaultValue)); + } catch (Exception $e) { + throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Invalid default decimal value')); + } + } + + if ($this->getBackendType() == 'datetime') { + if (!$this->getBackendModel()) { + $this->setBackendModel('Mage_Eav_Model_Entity_Attribute_Backend_Datetime'); + } + + if (!$this->getFrontendModel()) { + $this->setFrontendModel('Mage_Eav_Model_Entity_Attribute_Frontend_Datetime'); + } + + // save default date value as timestamp + if ($hasDefaultValue) { + $format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); + try { + $defaultValue = Mage::app()->getLocale()->date($defaultValue, $format, null, false)->toValue(); + $this->setDefaultValue($defaultValue); + } catch (Exception $e) { + throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Invalid default date')); + } + } + } + + if ($this->getBackendType() == 'gallery') { + if (!$this->getBackendModel()) { + $this->setBackendModel('Mage_Eav_Model_Entity_Attribute_Backend_Default'); + } + } + + return parent::_beforeSave(); + } + + /** + * Save additional data + * + * @return Mage_Eav_Model_Entity_Attribute + */ + protected function _afterSave() + { + $this->_getResource()->saveInSetIncluding($this); + return parent::_afterSave(); + } + + /** + * Detect backend storage type using frontend input type + * + * @param string $type frontend_input field value + * @return string backend_type field value + */ + public function getBackendTypeByInput($type) + { + $field = null; + switch ($type) { + case 'text': + case 'gallery': + case 'media_image': + case 'multiselect': + $field = 'varchar'; + break; + + case 'image': + case 'textarea': + $field = 'text'; + break; + + case 'date': + $field = 'datetime'; + break; + + case 'select': + case 'boolean': + $field = 'int'; + break; + + case 'price': + case 'weight': + $field = 'decimal'; + break; + } + + return $field; + } + + /** + * Detect default value using frontend input type + * + * @param string $type frontend_input field name + * @return string default_value field value + */ + public function getDefaultValueByInput($type) + { + $field = ''; + switch ($type) { + case 'select': + case 'gallery': + case 'media_image': + break; + case 'multiselect': + $field = null; + break; + + case 'text': + case 'price': + case 'image': + case 'weight': + $field = 'default_value_text'; + break; + + case 'textarea': + $field = 'default_value_textarea'; + break; + + case 'date': + $field = 'default_value_date'; + break; + + case 'boolean': + $field = 'default_value_yesno'; + break; + } + + return $field; + } + + /** + * Retrieve attribute codes by frontend type + * + * @param string $type + * @return array + */ + public function getAttributeCodesByFrontendType($type) + { + return $this->getResource()->getAttributeCodesByFrontendType($type); + } + + /** + * Return array of labels of stores + * + * @return array + */ + public function getStoreLabels() + { + if (!$this->getData('store_labels')) { + $storeLabel = $this->getResource()->getStoreLabelsByAttributeId($this->getId()); + $this->setData('store_labels', $storeLabel); + } + return $this->getData('store_labels'); + } + + /** + * Return store label of attribute + * + * @return string + */ + public function getStoreLabel($storeId = null) + { + if ($this->hasData('store_label')) { + return $this->getData('store_label'); + } + $store = Mage::app()->getStore($storeId); + $label = false; + if (!$store->isAdmin()) { + $labels = $this->getStoreLabels(); + if (isset($labels[$store->getId()])) { + return $labels[$store->getId()]; + } + } + return $this->getFrontendLabel(); + } + + /** + * Get attribute sort weight + * + * @param int $setId + * @return float + */ + public function getSortWeight($setId) + { + $groupSortWeight = isset($this->_data['attribute_set_info'][$setId]['group_sort']) + ? (float) $this->_data['attribute_set_info'][$setId]['group_sort'] * 1000 + : 0.0; + $sortWeight = isset($this->_data['attribute_set_info'][$setId]['sort']) + ? (float)$this->_data['attribute_set_info'][$setId]['sort'] * 0.0001 + : 0.0; + return $groupSortWeight + $sortWeight; + } +} diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php b/app/code/Mage/Eav/Model/Entity/Attribute/Abstract.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Abstract.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Abstract.php b/app/code/Mage/Eav/Model/Entity/Attribute/Backend/Abstract.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Abstract.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Backend/Abstract.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Array.php b/app/code/Mage/Eav/Model/Entity/Attribute/Backend/Array.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Array.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Backend/Array.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Datetime.php b/app/code/Mage/Eav/Model/Entity/Attribute/Backend/Datetime.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Datetime.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Backend/Datetime.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Default.php b/app/code/Mage/Eav/Model/Entity/Attribute/Backend/Default.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Default.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Backend/Default.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Increment.php b/app/code/Mage/Eav/Model/Entity/Attribute/Backend/Increment.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Increment.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Backend/Increment.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Interface.php b/app/code/Mage/Eav/Model/Entity/Attribute/Backend/Interface.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Interface.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Backend/Interface.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Serialized.php b/app/code/Mage/Eav/Model/Entity/Attribute/Backend/Serialized.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Serialized.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Backend/Serialized.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Store.php b/app/code/Mage/Eav/Model/Entity/Attribute/Backend/Store.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Store.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Backend/Store.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Time/Created.php b/app/code/Mage/Eav/Model/Entity/Attribute/Backend/Time/Created.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Time/Created.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Backend/Time/Created.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Time/Updated.php b/app/code/Mage/Eav/Model/Entity/Attribute/Backend/Time/Updated.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Time/Updated.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Backend/Time/Updated.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Exception.php b/app/code/Mage/Eav/Model/Entity/Attribute/Exception.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Exception.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Exception.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Frontend/Abstract.php b/app/code/Mage/Eav/Model/Entity/Attribute/Frontend/Abstract.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Frontend/Abstract.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Frontend/Abstract.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Frontend/Datetime.php b/app/code/Mage/Eav/Model/Entity/Attribute/Frontend/Datetime.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Frontend/Datetime.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Frontend/Datetime.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Frontend/Default.php b/app/code/Mage/Eav/Model/Entity/Attribute/Frontend/Default.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Frontend/Default.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Frontend/Default.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Frontend/Interface.php b/app/code/Mage/Eav/Model/Entity/Attribute/Frontend/Interface.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Frontend/Interface.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Frontend/Interface.php diff --git a/app/code/Mage/Eav/Model/Entity/Attribute/Group.php b/app/code/Mage/Eav/Model/Entity/Attribute/Group.php new file mode 100644 index 0000000000000..a302c35999caf --- /dev/null +++ b/app/code/Mage/Eav/Model/Entity/Attribute/Group.php @@ -0,0 +1,92 @@ + + * + * @method Mage_Eav_Model_Resource_Entity_Attribute_Group _getResource() + * @method Mage_Eav_Model_Resource_Entity_Attribute_Group getResource() + * @method int getAttributeSetId() + * @method Mage_Eav_Model_Entity_Attribute_Group setAttributeSetId(int $value) + * @method string getAttributeGroupName() + * @method Mage_Eav_Model_Entity_Attribute_Group setAttributeGroupName(string $value) + * @method int getSortOrder() + * @method Mage_Eav_Model_Entity_Attribute_Group setSortOrder(int $value) + * @method int getDefaultId() + * @method Mage_Eav_Model_Entity_Attribute_Group setDefaultId(int $value) + * @method string getAttributeGroupCode() + * @method Mage_Eav_Model_Entity_Attribute_Group setAttributeGroupCode(string $value) + * @method string getTabGroupCode() + * @method Mage_Eav_Model_Entity_Attribute_Group setTabGroupCode(string $value) + */ +class Mage_Eav_Model_Entity_Attribute_Group extends Mage_Core_Model_Abstract +{ + /** + * Resource initialization + */ + protected function _construct() + { + $this->_init('Mage_Eav_Model_Resource_Entity_Attribute_Group'); + } + + /** + * Checks if current attribute group exists + * + * @return boolean + */ + public function itemExists() + { + return $this->_getResource()->itemExists($this); + } + + /** + * Delete groups + * + * @return Mage_Eav_Model_Entity_Attribute_Group + */ + public function deleteGroups() + { + return $this->_getResource()->deleteGroups($this); + } + + /** + * Processing object before save data + * + * @return Mage_Eav_Model_Entity_Attribute_Group + */ + protected function _beforeSave() + { + if (!$this->getAttributeGroupCode()) { + $groupName = $this->getAttributeGroupName(); + if ($groupName) { + $this->setAttributeGroupCode(trim(preg_replace('/[^a-z0-9]+/', '-', strtolower($groupName)), '-')); + } + } + return parent::_beforeSave(); + } +} diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Interface.php b/app/code/Mage/Eav/Model/Entity/Attribute/Interface.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Interface.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Interface.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Option.php b/app/code/Mage/Eav/Model/Entity/Attribute/Option.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Option.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Option.php diff --git a/app/code/Mage/Eav/Model/Entity/Attribute/Set.php b/app/code/Mage/Eav/Model/Entity/Attribute/Set.php new file mode 100644 index 0000000000000..e1043e3ad763e --- /dev/null +++ b/app/code/Mage/Eav/Model/Entity/Attribute/Set.php @@ -0,0 +1,331 @@ + + */ +class Mage_Eav_Model_Entity_Attribute_Set extends Mage_Core_Model_Abstract +{ + /** + * Resource instance + * + * @var Mage_Eav_Model_Resource_Entity_Attribute_Set + */ + protected $_resource; + + /** + * Helper instance + * + * @var Mage_Core_Helper_Abstract + */ + protected $_helperInstance; + + /** + * Prefix of model events names + * @var string + */ + protected $_eventPrefix = 'eav_entity_attribute_set'; + + /** + * @param Mage_Core_Model_Context $context + * @param Mage_Core_Model_Resource_Abstract $resource + * @param Varien_Data_Collection_Db $resourceCollection + * @param array $data + */ + public function __construct( + Mage_Core_Model_Context $context, + Mage_Core_Model_Resource_Abstract $resource = null, + Varien_Data_Collection_Db $resourceCollection = null, + array $data = array() + ) { + if (isset($data['helper'])) { + $this->_helperInstance = $data['helper']; + unset($data['helper']); + } + + parent::__construct($context, $resource, $resourceCollection, $data); + } + + /** + * Initialize resource model + * + */ + protected function _construct() + { + $this->_init('Mage_Eav_Model_Resource_Entity_Attribute_Set'); + } + + /** + * Init attribute set from skeleton (another attribute set) + * + * @param int $skeletonId + * @return Mage_Eav_Model_Entity_Attribute_Set + */ + public function initFromSkeleton($skeletonId) + { + $groups = Mage::getModel('Mage_Eav_Model_Entity_Attribute_Group') + ->getResourceCollection() + ->setAttributeSetFilter($skeletonId) + ->load(); + + $newGroups = array(); + foreach ($groups as $group) { + $newGroup = clone $group; + $newGroup->setId(null) + ->setAttributeSetId($this->getId()) + ->setDefaultId($group->getDefaultId()); + + $groupAttributesCollection = Mage::getModel('Mage_Eav_Model_Entity_Attribute') + ->getResourceCollection() + ->setAttributeGroupFilter($group->getId()) + ->load(); + + $newAttributes = array(); + foreach ($groupAttributesCollection as $attribute) { + $newAttribute = Mage::getModel('Mage_Eav_Model_Entity_Attribute') + ->setId($attribute->getId()) + //->setAttributeGroupId($newGroup->getId()) + ->setAttributeSetId($this->getId()) + ->setEntityTypeId($this->getEntityTypeId()) + ->setSortOrder($attribute->getSortOrder()); + $newAttributes[] = $newAttribute; + } + $newGroup->setAttributes($newAttributes); + $newGroups[] = $newGroup; + } + $this->setGroups($newGroups); + + return $this; + } + + /** + * Collect data for save + * + * @param array $data + * @return Mage_Eav_Model_Entity_Attribute_Set + */ + public function organizeData($data) + { + $modelGroupArray = array(); + $modelAttributeArray = array(); + $attributeIds = array(); + if ($data['attributes']) { + $ids = array(); + foreach ($data['attributes'] as $attribute) { + $ids[] = $attribute[0]; + } + $attributeIds = Mage::getResourceSingleton('Mage_Eav_Model_Resource_Entity_Attribute') + ->getValidAttributeIds($ids); + } + if( $data['groups'] ) { + foreach ($data['groups'] as $group) { + $modelGroup = Mage::getModel('Mage_Eav_Model_Entity_Attribute_Group'); + $modelGroup->setId(is_numeric($group[0]) && $group[0] > 0 ? $group[0] : null) + ->setAttributeGroupName($group[1]) + ->setAttributeSetId($this->getId()) + ->setSortOrder($group[2]); + + if( $data['attributes'] ) { + foreach( $data['attributes'] as $attribute ) { + if( $attribute[1] == $group[0] && in_array($attribute[0], $attributeIds) ) { + $modelAttribute = Mage::getModel('Mage_Eav_Model_Entity_Attribute'); + $modelAttribute->setId($attribute[0]) + ->setAttributeGroupId($attribute[1]) + ->setAttributeSetId($this->getId()) + ->setEntityTypeId($this->getEntityTypeId()) + ->setSortOrder($attribute[2]); + $modelAttributeArray[] = $modelAttribute; + } + } + $modelGroup->setAttributes($modelAttributeArray); + $modelAttributeArray = array(); + } + $modelGroupArray[] = $modelGroup; + } + $this->setGroups($modelGroupArray); + } + + + if( $data['not_attributes'] ) { + $modelAttributeArray = array(); + foreach( $data['not_attributes'] as $attributeId ) { + $modelAttribute = Mage::getModel('Mage_Eav_Model_Entity_Attribute'); + + $modelAttribute->setEntityAttributeId($attributeId); + $modelAttributeArray[] = $modelAttribute; + } + $this->setRemoveAttributes($modelAttributeArray); + } + + if( $data['removeGroups'] ) { + $modelGroupArray = array(); + foreach( $data['removeGroups'] as $groupId ) { + $modelGroup = Mage::getModel('Mage_Eav_Model_Entity_Attribute_Group'); + $modelGroup->setId($groupId); + + $modelGroupArray[] = $modelGroup; + } + $this->setRemoveGroups($modelGroupArray); + } + $this->setAttributeSetName($data['attribute_set_name']) + ->setEntityTypeId($this->getEntityTypeId()); + + return $this; + } + + /** + * Validate attribute set name + * + * @return bool + * @throws Mage_Eav_Exception + */ + public function validate() + { + $attributeSetName = $this->getAttributeSetName(); + if ($attributeSetName == '') { + throw Mage::exception('Mage_Eav', + $this->_helper('Mage_Eav_Helper_Data')->__('Attribute set name is empty.') + ); + } + + if (!$this->_getResource()->validate($this, $attributeSetName)) { + throw Mage::exception('Mage_Eav', + $this->_helper('Mage_Eav_Helper_Data')->__('Attribute set with the "%s" name already exists.', $attributeSetName) + ); + } + + return true; + } + + /** + * Add set info to attributes + * + * @param string|Mage_Eav_Model_Entity_Type $entityType + * @param array $attributes + * @param int $setId + * @return Mage_Eav_Model_Entity_Attribute_Set + */ + public function addSetInfo($entityType, array $attributes, $setId = null) + { + $attributeIds = array(); + $config = Mage::getSingleton('Mage_Eav_Model_Config'); + $entityType = $config->getEntityType($entityType); + foreach ($attributes as $attribute) { + $attribute = $config->getAttribute($entityType, $attribute); + if ($setId && is_array($attribute->getAttributeSetInfo($setId))) { + continue; + } + if (!$attribute->getAttributeId()) { + continue; + } + $attributeIds[] = $attribute->getAttributeId(); + } + + if ($attributeIds) { + $setInfo = $this->_getResource() + ->getSetInfo($attributeIds, $setId); + + foreach ($attributes as $attribute) { + $attribute = $config->getAttribute($entityType, $attribute); + if (!$attribute->getAttributeId()) { + continue; + } + if (!in_array($attribute->getAttributeId(), $attributeIds)) { + continue; + } + if (is_numeric($setId)) { + $attributeSetInfo = $attribute->getAttributeSetInfo(); + if (!is_array($attributeSetInfo)) { + $attributeSetInfo = array(); + } + if (isset($setInfo[$attribute->getAttributeId()][$setId])) { + $attributeSetInfo[$setId] = $setInfo[$attribute->getAttributeId()][$setId]; + } + $attribute->setAttributeSetInfo($attributeSetInfo); + } else { + if (isset($setInfo[$attribute->getAttributeId()])) { + $attribute->setAttributeSetInfo($setInfo[$attribute->getAttributeId()]); + } + else { + $attribute->setAttributeSetInfo(array()); + } + } + } + } + + return $this; + } + + /** + * Return default Group Id for current or defined Attribute Set + * + * @param int $setId + * @return int|null + */ + public function getDefaultGroupId($setId = null) + { + if ($setId === null) { + $setId = $this->getId(); + } + + return $setId ? $this->_getResource()->getDefaultGroupId($setId) : null; + } + + /** + * Retrieve helper instance by specified helper name + * + * @param string $helperName + * @return Mage_Core_Helper_Abstract + */ + protected function _helper($helperName) + { + return $this->_helperInstance instanceof $helperName ? $this->_helperInstance : Mage::helper($helperName); + } + + /** + * Get resource instance + * + * @return Mage_Core_Model_Resource_Db_Abstract + */ + protected function _getResource() + { + return $this->_resource ?: parent::_getResource(); + } +} diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Abstract.php b/app/code/Mage/Eav/Model/Entity/Attribute/Source/Abstract.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Abstract.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Source/Abstract.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Boolean.php b/app/code/Mage/Eav/Model/Entity/Attribute/Source/Boolean.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Boolean.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Source/Boolean.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Config.php b/app/code/Mage/Eav/Model/Entity/Attribute/Source/Config.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Config.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Source/Config.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Interface.php b/app/code/Mage/Eav/Model/Entity/Attribute/Source/Interface.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Interface.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Source/Interface.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Store.php b/app/code/Mage/Eav/Model/Entity/Attribute/Source/Store.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Store.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Source/Store.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Table.php b/app/code/Mage/Eav/Model/Entity/Attribute/Source/Table.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Table.php rename to app/code/Mage/Eav/Model/Entity/Attribute/Source/Table.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Collection.php b/app/code/Mage/Eav/Model/Entity/Collection.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Collection.php rename to app/code/Mage/Eav/Model/Entity/Collection.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php b/app/code/Mage/Eav/Model/Entity/Collection/Abstract.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php rename to app/code/Mage/Eav/Model/Entity/Collection/Abstract.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Increment/Abstract.php b/app/code/Mage/Eav/Model/Entity/Increment/Abstract.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Increment/Abstract.php rename to app/code/Mage/Eav/Model/Entity/Increment/Abstract.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Increment/Alphanum.php b/app/code/Mage/Eav/Model/Entity/Increment/Alphanum.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Increment/Alphanum.php rename to app/code/Mage/Eav/Model/Entity/Increment/Alphanum.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Increment/Interface.php b/app/code/Mage/Eav/Model/Entity/Increment/Interface.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Increment/Interface.php rename to app/code/Mage/Eav/Model/Entity/Increment/Interface.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Increment/Numeric.php b/app/code/Mage/Eav/Model/Entity/Increment/Numeric.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Increment/Numeric.php rename to app/code/Mage/Eav/Model/Entity/Increment/Numeric.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Interface.php b/app/code/Mage/Eav/Model/Entity/Interface.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Interface.php rename to app/code/Mage/Eav/Model/Entity/Interface.php diff --git a/app/code/Mage/Eav/Model/Entity/Setup.php b/app/code/Mage/Eav/Model/Entity/Setup.php new file mode 100644 index 0000000000000..9ff3ea93e0a3c --- /dev/null +++ b/app/code/Mage/Eav/Model/Entity/Setup.php @@ -0,0 +1,1494 @@ + + */ +class Mage_Eav_Model_Entity_Setup extends Mage_Core_Model_Resource_Setup +{ + /** + * Application cache model + * + * @var Mage_Core_Model_CacheInterface + */ + protected $_cache; + + /** + * @param Mage_Core_Model_Config_Resource $resourcesConfig + * @param Mage_Core_Model_Config_Modules $modulesConfig + * @param Mage_Core_Model_Resource $resource + * @param Mage_Core_Model_Config_Modules_Reader $modulesReader + * @param Mage_Core_Model_CacheInterface $cache + * @param string $resourceName + */ + public function __construct( + Mage_Core_Model_Config_Resource $resourcesConfig, + Mage_Core_Model_Config_Modules $modulesConfig, + Mage_Core_Model_Resource $resource, + Mage_Core_Model_Config_Modules_Reader $modulesReader, + Mage_Core_Model_CacheInterface $cache, + $resourceName + ) + { + parent::__construct($resourcesConfig, $modulesConfig, $resource, $modulesReader, $resourceName); + $this->_cache = $cache; + } + + /** + * General Attribute Group Name + * + * @var string + */ + protected $_generalGroupName = 'General'; + + /** + * Default attribute group name to id pairs + * + * @var array + */ + public $defaultGroupIdAssociations = array( + 'General' => 1 + ); + + /** + * Default attribute group name + * + * @var string + */ + protected $_defaultGroupName = 'Default'; + + /** + * Default attribute set name + * + * @var string + */ + protected $_defaultAttributeSetName = 'Default'; + + /** + * Clean cache + * + * @return Mage_Eav_Model_Entity_Setup + */ + public function cleanCache() + { + $this->_cache->clean(array(Mage_Eav_Model_Cache_Type::CACHE_TAG)); + return $this; + } + + /** + * Install Default Group Ids + * + * @return Mage_Eav_Model_Entity_Setup + */ + public function installDefaultGroupIds() + { + $setIds = $this->getAllAttributeSetIds(); + foreach ($this->defaultGroupIdAssociations as $defaultGroupName => $defaultGroupId) { + foreach ($setIds as $set) { + $groupId = $this->getTableRow('eav_attribute_group', + 'attribute_group_name', $defaultGroupName, 'attribute_group_id', 'attribute_set_id', $set + ); + if (!$groupId) { + $groupId = $this->getTableRow('eav_attribute_group', + 'attribute_set_id', $set, 'attribute_group_id' + ); + } + $this->updateTableRow('eav_attribute_group', + 'attribute_group_id', $groupId, 'default_id', $defaultGroupId + ); + } + } + + return $this; + } + + +/******************* ENTITY TYPES *****************/ + + /** + * Add an entity type + * + * If already exists updates the entity type with params data + * + * @param string $code + * @param array $params + * @return Mage_Eav_Model_Entity_Setup + */ + public function addEntityType($code, array $params) + { + $data = array( + 'entity_type_code' => $code, + 'entity_model' => $params['entity_model'], + 'attribute_model' => $this->_getValue($params, 'attribute_model'), + 'entity_table' => $this->_getValue($params, 'table', 'eav_entity'), + 'value_table_prefix' => $this->_getValue($params, 'table_prefix'), + 'entity_id_field' => $this->_getValue($params, 'id_field'), + 'increment_model' => $this->_getValue($params, 'increment_model'), + 'increment_per_store' => $this->_getValue($params, 'increment_per_store', 0), + 'increment_pad_length' => $this->_getValue($params, 'increment_pad_length', 8), + 'increment_pad_char' => $this->_getValue($params, 'increment_pad_char', 0), + 'additional_attribute_table' => $this->_getValue($params, 'additional_attribute_table'), + 'entity_attribute_collection' => $this->_getValue($params, 'entity_attribute_collection'), + ); + + if ($this->getEntityType($code, 'entity_type_id')) { + $this->updateEntityType($code, $data); + } else { + $this->_conn->insert($this->getTable('eav_entity_type'), $data); + } + + if (!empty($params['default_group'])) { + $defaultGroup = $params['default_group']; + } else { + $defaultGroup = $this->_defaultGroupName; + } + + $this->addAttributeSet($code, $this->_defaultAttributeSetName); + $this->addAttributeGroup($code, $this->_defaultGroupName, $this->_generalGroupName); + + return $this; + } + + /** + * Update entity row + * + * @param string $code + * @param string $field + * @param string $value + * @return Mage_Eav_Model_Entity_Setup + */ + public function updateEntityType($code, $field, $value = null) + { + $this->updateTableRow('eav_entity_type', + 'entity_type_id', $this->getEntityTypeId($code), $field, $value + ); + return $this; + } + + /** + * Retrieve Entity Type Data + * + * @param int|string $id + * @param string $field + * @return mixed + */ + public function getEntityType($id, $field = null) + { + return $this->getTableRow('eav_entity_type', + is_numeric($id) ? 'entity_type_id' : 'entity_type_code', $id, $field + ); + } + + /** + * Retrieve Entity Type Id By Id or Code + * + * @param mixed $entityTypeId + * @return int + */ + public function getEntityTypeId($entityTypeId) + { + if (!is_numeric($entityTypeId)) { + $entityTypeId = $this->getEntityType($entityTypeId, 'entity_type_id'); + } + if (!is_numeric($entityTypeId)) { + throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Wrong entity ID')); + } + + return $entityTypeId; + } + + /** + * Remove entity type by Id or Code + * + * @param mixed $id + * @return Mage_Eav_Model_Entity_Setup + */ + public function removeEntityType($id) + { + if (is_numeric($id)) { + $this->deleteTableRow('eav_entity_type', 'entity_type_id', $id); + } else { + $this->deleteTableRow('eav_entity_type', 'entity_type_code', (string)$id); + } + + return $this; + } + +/******************* ATTRIBUTE SETS *****************/ + + /** + * Retrieve Attribute Set Sort order + * + * @param mixed $entityTypeId + * @param int $sortOrder + * @return int + */ + public function getAttributeSetSortOrder($entityTypeId, $sortOrder = null) + { + if (!is_numeric($sortOrder)) { + $bind = array('entity_type_id' => $this->getEntityTypeId($entityTypeId)); + $select = $this->_conn->select() + ->from($this->getTable('eav_attribute_set'), 'MAX(sort_order)') + ->where('entity_type_id = :entity_type_id'); + + $sortOrder = $this->_conn->fetchOne($select, $bind) + 1; + } + + return $sortOrder; + } + + /** + * Add Attribute Set + * + * @param mixed $entityTypeId + * @param string $name + * @param int $sortOrder + * @return Mage_Eav_Model_Entity_Setup + */ + public function addAttributeSet($entityTypeId, $name, $sortOrder = null) + { + $data = array( + 'entity_type_id' => $this->getEntityTypeId($entityTypeId), + 'attribute_set_name' => $name, + 'sort_order' => $this->getAttributeSetSortOrder($entityTypeId, $sortOrder), + ); + + $setId = $this->getAttributeSet($entityTypeId, $name, 'attribute_set_id'); + if ($setId) { + $this->updateAttributeSet($entityTypeId, $setId, $data); + } else { + $this->_conn->insert($this->getTable('eav_attribute_set'), $data); + + $this->addAttributeGroup($entityTypeId, $name, $this->_generalGroupName); + } + + return $this; + } + + /** + * Update attribute set data + * + * @param mixed $entityTypeId + * @param int $id + * @param string $field + * @param mixed $value + * @return Mage_Eav_Model_Entity_Setup + */ + public function updateAttributeSet($entityTypeId, $id, $field, $value = null) + { + $this->updateTableRow('eav_attribute_set', + 'attribute_set_id', $this->getAttributeSetId($entityTypeId, $id), + $field, $value, + 'entity_type_id', $this->getEntityTypeId($entityTypeId) + ); + return $this; + } + + /** + * Retrieve Attribute set data by id or name + * + * @param mixed $entityTypeId + * @param mixed $id + * @param string $field + * @return mixed + */ + public function getAttributeSet($entityTypeId, $id, $field = null) + { + return $this->getTableRow('eav_attribute_set', + is_numeric($id) ? 'attribute_set_id' : 'attribute_set_name', $id, + $field, + 'entity_type_id', $this->getEntityTypeId($entityTypeId) + ); + } + + /** + * Retrieve Attribute Set Id By Id or Name + * + * @throws Mage_Eav_Exception + * @param mixed $entityTypeId + * @param mixed $setId + * @return int + */ + public function getAttributeSetId($entityTypeId, $setId) + { + if (!is_numeric($setId)) { + $setId = $this->getAttributeSet($entityTypeId, $setId, 'attribute_set_id'); + } + if (!is_numeric($setId)) { + throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Wrong attribute set ID')); + } + + return $setId; + } + + /** + * Remove Attribute Set + * + * @param mixed $entityTypeId + * @param mixed $id + * @return Mage_Eav_Model_Entity_Setup + */ + public function removeAttributeSet($entityTypeId, $id) + { + $this->deleteTableRow('eav_attribute_set', 'attribute_set_id', $this->getAttributeSetId($entityTypeId, $id)); + return $this; + } + + /** + * Set Default Attribute Set to Entity Type + * + * @param mixed $entityType + * @return Mage_Eav_Model_Entity_Setup + */ + public function setDefaultSetToEntityType($entityType, $attributeSet = 'Default') + { + $entityTypeId = $this->getEntityTypeId($entityType); + $setId = $this->getAttributeSetId($entityTypeId, $attributeSet); + $this->updateEntityType($entityTypeId, 'default_attribute_set_id', $setId); + return $this; + } + + /** + * Get identifiers of all attribute sets + * + * @return array + */ + public function getAllAttributeSetIds($entityTypeId = null) + { + $select = $this->_conn->select() + ->from($this->getTable('eav_attribute_set'), 'attribute_set_id'); + + $bind = array(); + if ($entityTypeId !== null) { + $bind['entity_type_id'] = $this->getEntityTypeId($entityTypeId); + $select->where('entity_type_id = :entity_type_id'); + } + + return $this->_conn->fetchCol($select, $bind); + } + + /** + * Retrieve Default Attribute Set for Entity Type + * + * @param string|int $entityType + * @return int + */ + public function getDefaultAttributeSetId($entityType) + { + $bind = array('entity_type' => $entityType); + if (is_numeric($entityType)) { + $where = 'entity_type_id = :entity_type'; + } else { + $where = 'entity_type_code = :entity_type'; + } + $select = $this->getConnection()->select() + ->from($this->getTable('eav_entity_type'), 'default_attribute_set_id') + ->where($where); + + return $this->getConnection()->fetchOne($select, $bind); + } + +/******************* ATTRIBUTE GROUPS *****************/ + + /** + * Retrieve Attribute Group Sort order + * + * @param mixed $entityTypeId + * @param mixed $setId + * @param int $sortOrder + * @return int + */ + public function getAttributeGroupSortOrder($entityTypeId, $setId, $sortOrder = null) + { + if (!is_numeric($sortOrder)) { + $bind = array('attribute_set_id' => $this->getAttributeSetId($entityTypeId, $setId)); + $select = $this->_conn->select() + ->from($this->getTable('eav_attribute_group'), 'MAX(sort_order)') + ->where('attribute_set_id = :attribute_set_id'); + + $sortOrder = $this->_conn->fetchOne($select, $bind) + 1; + } + + return $sortOrder; + } + + /** + * Add Attribute Group + * + * @param mixed $entityTypeId + * @param mixed $setId + * @param string $name + * @param int $sortOrder + * @return Mage_Eav_Model_Entity_Setup + */ + public function addAttributeGroup($entityTypeId, $setId, $name, $sortOrder = null) + { + $setId = $this->getAttributeSetId($entityTypeId, $setId); + $data = array( + 'attribute_set_id' => $setId, + 'attribute_group_name' => $name, + ); + + if (isset($this->defaultGroupIdAssociations[$name])) { + $data['default_id'] = $this->defaultGroupIdAssociations[$name]; + } + + if ($sortOrder !== null) { + $data['sort_order'] = $sortOrder; + } + + $groupId = $this->getAttributeGroup($entityTypeId, $setId, $name, 'attribute_group_id'); + if ($groupId) { + $this->updateAttributeGroup($entityTypeId, $setId, $groupId, $data); + } else { + if ($sortOrder === null) { + $data['sort_order'] = $this->getAttributeGroupSortOrder($entityTypeId, $setId, $sortOrder); + } + $this->_conn->insert($this->getTable('eav_attribute_group'), $data); + } + + return $this; + } + + /** + * Update Attribute Group Data + * + * @param mixed $entityTypeId + * @param mixed $setId + * @param mixed $id + * @param string $field + * @param mixed $value + * @return Mage_Eav_Model_Entity_Setup + */ + public function updateAttributeGroup($entityTypeId, $setId, $id, $field, $value = null) + { + $this->updateTableRow('eav_attribute_group', + 'attribute_group_id', $this->getAttributeGroupId($entityTypeId, $setId, $id), + $field, $value, + 'attribute_set_id', $this->getAttributeSetId($entityTypeId, $setId) + ); + + return $this; + } + + /** + * Retrieve Attribute Group Data + * + * @param mixed $entityTypeId + * @param mixed $setId + * @param mixed $id + * @param string $field + * @return mixed + */ + public function getAttributeGroup($entityTypeId, $setId, $id, $field = null) + { + $searchId = $id; + if (is_numeric($id)) { + $searchField = 'attribute_group_id'; + } else { + if (isset($this->defaultGroupIdAssociations[$id])) { + $searchField = 'default_id'; + $searchId = $this->defaultGroupIdAssociations[$id]; + } else { + $searchField = 'attribute_group_name'; + } + } + + return $this->getTableRow('eav_attribute_group', + $searchField, $searchId, $field, + 'attribute_set_id', $this->getAttributeSetId($entityTypeId, $setId) + ); + } + + /** + * Retrieve Attribute Group Id by Id or Name + * + * @param mixed $entityTypeId + * @param mixed $setId + * @param mixed $groupId + * @return Mage_Eav_Model_Entity_Setup + */ + public function getAttributeGroupId($entityTypeId, $setId, $groupId) + { + if (!is_numeric($groupId)) { + $groupId = $this->getAttributeGroup($entityTypeId, $setId, $groupId, 'attribute_group_id'); + } + + if (!is_numeric($groupId)) { + $groupId = $this->getDefaultAttributeGroupId($entityTypeId, $setId); + } + + if (!is_numeric($groupId)) { + throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Wrong attribute group ID')); + } + return $groupId; + } + + /** + * Remove Attribute Group By Id or Name + * + * @param mixed $entityTypeId + * @param mixed $setId + * @param mixed $id + * @return Mage_Eav_Model_Entity_Setup + */ + public function removeAttributeGroup($entityTypeId, $setId, $id) + { + $this->deleteTableRow( + 'eav_attribute_group', + 'attribute_group_id', + $this->getAttributeGroupId($entityTypeId, $setId, $id) + ); + return $this; + } + + /** + * Retrieve Default Attribute Group Id By Entity Type and Attribute Set + * + * @param string|int $entityType + * @param int $attributeSetId + * @return int + */ + public function getDefaultAttributeGroupId($entityType, $attributeSetId = null) + { + $entityType = $this->getEntityTypeId($entityType); + if (!is_numeric($attributeSetId)) { + $attributeSetId = $this->getDefaultAttributeSetId($entityType); + } + $bind = array('attribute_set_id' => $attributeSetId); + $select = $this->getConnection()->select() + ->from($this->getTable('eav_attribute_group'), 'attribute_group_id') + ->where('attribute_set_id = :attribute_set_id') + ->order(array('default_id ' . Varien_Db_Select::SQL_DESC, 'sort_order')) + ->limit(1); + + return $this->getConnection()->fetchOne($select, $bind); + } + + /** + * Get number of all attributes in group + * + * @param int|string $entityTypeId + * @param int|string $setId + * @param int|string $groupId + * + * @return string + */ + public function getAttributesNumberInGroup($entityTypeId, $setId, $groupId) + { + $select = $this->_conn->select() + ->from($this->getTable('eav_entity_attribute'), array('count' => 'COUNT(*)')) + ->where('attribute_group_id = ?', $this->getAttributeGroupId($entityTypeId, $setId, $groupId)) + ->where('entity_type_id = ?', $entityTypeId) + ->where('attribute_set_id = ?', $setId); + + return $this->_conn->fetchOne($select); + } + +/******************* ATTRIBUTES *****************/ + + /** + * Retrieve value from array by key or return default value + * + * @param array $array + * @param string $key + * @param string $default + * @return string + */ + protected function _getValue($array, $key, $default = null) + { + if (isset($array[$key]) && is_bool($array[$key])) { + $array[$key] = (int) $array[$key]; + } + return isset($array[$key]) ? $array[$key] : $default; + } + + /** + * Prepare attribute values to save + * + * @param array $attr + * @return array + */ + protected function _prepareValues($attr) + { + $data = array( + 'backend_model' => $this->_getValue($attr, 'backend'), + 'backend_type' => $this->_getValue($attr, 'type', 'varchar'), + 'backend_table' => $this->_getValue($attr, 'table'), + 'frontend_model' => $this->_getValue($attr, 'frontend'), + 'frontend_input' => $this->_getValue($attr, 'input', 'text'), + 'frontend_label' => $this->_getValue($attr, 'label'), + 'frontend_class' => $this->_getValue($attr, 'frontend_class'), + 'source_model' => $this->_getValue($attr, 'source'), + 'is_required' => $this->_getValue($attr, 'required', 1), + 'is_user_defined' => $this->_getValue($attr, 'user_defined', 0), + 'default_value' => $this->_getValue($attr, 'default'), + 'is_unique' => $this->_getValue($attr, 'unique', 0), + 'note' => $this->_getValue($attr, 'note'), + 'is_global' => $this->_getValue($attr, 'global', + Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL + ), + ); + + return $data; + } + + /** + * Validate attribute data before insert into table + * + * @param array $data + * @throws Mage_Eav_Exception + * @return true + */ + protected function _validateAttributeData($data) + { + $attributeCodeMaxLength = Mage_Eav_Model_Entity_Attribute::ATTRIBUTE_CODE_MAX_LENGTH; + + if (isset($data['attribute_code']) && + !Zend_Validate::is($data['attribute_code'], 'StringLength', array('max' => $attributeCodeMaxLength))) + { + throw Mage::exception('Mage_Eav', + Mage::helper('Mage_Eav_Helper_Data')->__('Maximum length of attribute code must be less than %s symbols', $attributeCodeMaxLength) + ); + } + + return true; + } + + /** + * Add attribute to an entity type + * + * If attribute is system will add to all existing attribute sets + * + * @param string|integer $entityTypeId + * @param string $code + * @param array $attr + * @return Mage_Eav_Model_Entity_Setup + */ + public function addAttribute($entityTypeId, $code, array $attr) + { + $entityTypeId = $this->getEntityTypeId($entityTypeId); + $data = array_merge( + array( + 'entity_type_id' => $entityTypeId, + 'attribute_code' => $code + ), + $this->_prepareValues($attr) + ); + + $this->_validateAttributeData($data); + + $sortOrder = isset($attr['sort_order']) ? $attr['sort_order'] : null; + $attributeId = $this->getAttribute($entityTypeId, $code, 'attribute_id'); + if ($attributeId) { + $this->updateAttribute($entityTypeId, $attributeId, $data, null, $sortOrder); + } else { + $this->_insertAttribute($data); + } + + if (!empty($attr['group']) || empty($attr['user_defined'])) { + $select = $this->_conn->select() + ->from($this->getTable('eav_attribute_set')) + ->where('entity_type_id = :entity_type_id'); + $sets = $this->_conn->fetchAll($select, array('entity_type_id' => $entityTypeId)); + foreach ($sets as $set) { + if (!empty($attr['group'])) { + $this->addAttributeGroup($entityTypeId, $set['attribute_set_id'], + $attr['group']); + $this->addAttributeToSet($entityTypeId, $set['attribute_set_id'], + $attr['group'], $code, $sortOrder); + } else { + $this->addAttributeToSet($entityTypeId, $set['attribute_set_id'], + $this->_generalGroupName, $code, $sortOrder); + } + } + } + + if (isset($attr['option']) && is_array($attr['option'])) { + $option = $attr['option']; + $option['attribute_id'] = $this->getAttributeId($entityTypeId, $code); + $this->addAttributeOption($option); + } + + return $this; + } + + /** + * Add Attribure Option + * + * @param array $option + */ + public function addAttributeOption($option) + { + $optionTable = $this->getTable('eav_attribute_option'); + $optionValueTable = $this->getTable('eav_attribute_option_value'); + + if (isset($option['value'])) { + foreach ($option['value'] as $optionId => $values) { + $intOptionId = (int) $optionId; + if (!empty($option['delete'][$optionId])) { + if ($intOptionId) { + $condition = array('option_id =?' => $intOptionId); + $this->_conn->delete($optionTable, $condition); + } + continue; + } + + if (!$intOptionId) { + $data = array( + 'attribute_id' => $option['attribute_id'], + 'sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0, + ); + $this->_conn->insert($optionTable, $data); + $intOptionId = $this->_conn->lastInsertId($optionTable); + } else { + $data = array( + 'sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0, + ); + $this->_conn->update($optionTable, $data, array('option_id=?' => $intOptionId)); + } + + // Default value + if (!isset($values[0])) { + Mage::throwException(Mage::helper('Mage_Eav_Helper_Data')->__('Default option value is not defined')); + } + $condition = array('option_id =?' => $intOptionId); + $this->_conn->delete($optionValueTable, $condition); + foreach ($values as $storeId => $value) { + $data = array( + 'option_id' => $intOptionId, + 'store_id' => $storeId, + 'value' => $value, + ); + $this->_conn->insert($optionValueTable, $data); + } + } + } else if (isset($option['values'])) { + foreach ($option['values'] as $sortOrder => $label) { + // add option + $data = array( + 'attribute_id' => $option['attribute_id'], + 'sort_order' => $sortOrder, + ); + $this->_conn->insert($optionTable, $data); + $intOptionId = $this->_conn->lastInsertId($optionTable); + + $data = array( + 'option_id' => $intOptionId, + 'store_id' => 0, + 'value' => $label, + ); + $this->_conn->insert($optionValueTable, $data); + } + } + } + + /** + * Update Attribute data and Attribute additional data + * + * @param mixed $entityTypeId + * @param mixed $id + * @param string $field + * @param mixed $value + * @param int $sortOrder + * @return Mage_Eav_Model_Entity_Setup + */ + public function updateAttribute($entityTypeId, $id, $field, $value = null, $sortOrder = null) + { + $this->_updateAttribute($entityTypeId, $id, $field, $value, $sortOrder); + $this->_updateAttributeAdditionalData($entityTypeId, $id, $field, $value); + return $this; + } + + /** + * Update Attribute data + * + * @param mixed $entityTypeId + * @param mixed $id + * @param string $field + * @param mixed $value + * @param int $sortOrder + * @return Mage_Eav_Model_Entity_Setup + */ + protected function _updateAttribute($entityTypeId, $id, $field, $value = null, $sortOrder = null) + { + if ($sortOrder !== null) { + $this->updateTableRow('eav_entity_attribute', + 'attribute_id', $this->getAttributeId($entityTypeId, $id), + 'sort_order', $sortOrder + ); + } + + $attributeFields = $this->_getAttributeTableFields(); + if (is_array($field)) { + $bind = array(); + foreach ($field as $k => $v) { + if (isset($attributeFields[$k])) { + $bind[$k] = $this->getConnection()->prepareColumnValue($attributeFields[$k], $v); + } + } + if (!$bind) { + return $this; + } + $field = $bind; + } else { + if (!isset($attributeFields[$field])) { + return $this; + } + } + + $this->updateTableRow('eav_attribute', + 'attribute_id', $this->getAttributeId($entityTypeId, $id), + $field, $value, + 'entity_type_id', $this->getEntityTypeId($entityTypeId) + ); + + return $this; + } + + /** + * Update Attribute Additional data + * + * @param mixed $entityTypeId + * @param mixed $id + * @param string $field + * @param mixed $value + * @return Mage_Eav_Model_Entity_Setup + */ + protected function _updateAttributeAdditionalData($entityTypeId, $id, $field, $value = null) + { + $additionalTable = $this->getEntityType($entityTypeId, 'additional_attribute_table'); + if (!$additionalTable) { + return $this; + } + $additionalTableExists = $this->getConnection()->isTableExists($this->getTable($additionalTable)); + if ($additionalTable && $additionalTableExists) { + $attributeFields = $this->getConnection()->describeTable($this->getTable($additionalTable)); + if (is_array($field)) { + $bind = array(); + foreach ($field as $k => $v) { + if (isset($attributeFields[$k])) { + $bind[$k] = $this->getConnection()->prepareColumnValue($attributeFields[$k], $v); + } + } + if (!$bind) { + return $this; + } + $field = $bind; + } else { + if (!isset($attributeFields[$field])) { + return $this; + } + } + $this->updateTableRow($this->getTable($additionalTable), + 'attribute_id', $this->getAttributeId($entityTypeId, $id), + $field, $value + ); + } + + return $this; + } + + /** + * Retrieve Attribute Data By Id or Code + * + * @param mixed $entityTypeId + * @param mixed $id + * @param string $field + * @return mixed + */ + public function getAttribute($entityTypeId, $id, $field = null) + { + $additionalTable = $this->getEntityType($entityTypeId, 'additional_attribute_table'); + $entityTypeId = $this->getEntityTypeId($entityTypeId); + $idField = is_numeric($id) ? 'attribute_id' : 'attribute_code'; + if (!$additionalTable) { + return $this->getTableRow('eav_attribute', $idField, $id, $field, 'entity_type_id', $entityTypeId); + } + + $mainTable = $this->getTable('eav_attribute'); + if (empty($this->_setupCache[$mainTable][$entityTypeId][$id])) { + $additionalTable = $this->getTable($additionalTable); + $bind = array( + 'id' => $id, + 'entity_type_id' => $entityTypeId + ); + $select = $this->_conn->select() + ->from(array('main' => $mainTable)) + ->join( + array('additional' => $additionalTable), + 'main.attribute_id = additional.attribute_id') + ->where("main.{$idField} = :id") + ->where('main.entity_type_id = :entity_type_id'); + + $row = $this->_conn->fetchRow($select, $bind); + if (!$row) { + $this->_setupCache[$mainTable][$entityTypeId][$id] = false; + } else { + $this->_setupCache[$mainTable][$entityTypeId][$row['attribute_id']] = $row; + $this->_setupCache[$mainTable][$entityTypeId][$row['attribute_code']] = $row; + } + } + + $row = $this->_setupCache[$mainTable][$entityTypeId][$id]; + if ($field !== null) { + return isset($row[$field]) ? $row[$field] : false; + } + + return $row; + } + + /** + * Retrieve Attribute Id Data By Id or Code + * + * @param mixed $entityTypeId + * @param mixed $id + * @return int + */ + public function getAttributeId($entityTypeId, $id) + { + if (!is_numeric($id)) { + $id = $this->getAttribute($entityTypeId, $id, 'attribute_id'); + } + if (!is_numeric($id)) { + return false; + } + return $id; + } + + /** + * Return table name for eav attribute + * + * @param int|string $entityTypeId Entity Type id or Entity Type code + * @param int|string $id Attribute id or Attribute code + * @return string + */ + public function getAttributeTable($entityTypeId, $id) + { + $entityKeyName = is_numeric($entityTypeId) ? 'entity_type_id' : 'entity_type_code'; + $attributeKeyName = is_numeric($id) ? 'attribute_id' : 'attribute_code'; + + $bind = array( + 'id' => $id, + 'entity_type_id' => $entityTypeId + ); + $select = $this->getConnection()->select() + ->from( + array('entity_type' => $this->getTable('eav_entity_type')), + array('entity_table')) + ->join( + array('attribute' => $this->getTable('eav_attribute')), + 'attribute.entity_type_id = entity_type.entity_type_id', + array('backend_type')) + ->where("entity_type.{$entityKeyName} = :entity_type_id") + ->where("attribute.{$attributeKeyName} = :id") + ->limit(1); + + $result = $this->getConnection()->fetchRow($select, $bind); + if ($result) { + $table = $this->getTable($result['entity_table']); + if ($result['backend_type'] != 'static') { + $table .= '_' . $result['backend_type']; + } + return $table; + } + + return false; + } + + /** + * Remove Attribute + * + * @param mixed $entityTypeId + * @param mixed $code + * @return Mage_Eav_Model_Entity_Setup + */ + public function removeAttribute($entityTypeId, $code) + { + $mainTable = $this->getTable('eav_attribute'); + $attribute = $this->getAttribute($entityTypeId, $code); + if ($attribute) { + $this->deleteTableRow('eav_attribute', 'attribute_id', $attribute['attribute_id']); + if (isset($this->_setupCache[$mainTable][$attribute['entity_type_id']][$attribute['attribute_code']])) { + unset($this->_setupCache[$mainTable][$attribute['entity_type_id']][$attribute['attribute_code']]); + } + } + return $this; + } + + /** + * Retrieve Attribute Sort Order + * + * @param mixed $entityTypeId + * @param mixed $setId + * @param mixed $groupId + * @param int $sortOrder + * @return Mage_Eav_Model_Entity_Setup + */ + public function getAttributeSortOrder($entityTypeId, $setId, $groupId, $sortOrder = null) + { + if (!is_numeric($sortOrder)) { + $bind = array('attribute_group_id' => $this->getAttributeGroupId($entityTypeId, $setId, $groupId)); + $select = $this->_conn->select() + ->from($this->getTable('eav_entity_attribute'), 'MAX(sort_order)') + ->where('attribute_group_id = :attribute_group_id'); + + $sortOrder = $this->_conn->fetchOne($select, $bind) + 1; + } + + return $sortOrder; + } + + /** + * Add Attribute to All Groups on Attribute Set + * + * @param mixed $entityTypeId + * @param mixed $setId + * @param mixed $groupId + * @param mixed $attributeId + * @param int $sortOrder + * @return Mage_Eav_Model_Entity_Setup + */ + public function addAttributeToSet($entityTypeId, $setId, $groupId, $attributeId, $sortOrder=null) + { + $entityTypeId = $this->getEntityTypeId($entityTypeId); + $setId = $this->getAttributeSetId($entityTypeId, $setId); + $groupId = $this->getAttributeGroupId($entityTypeId, $setId, $groupId); + $attributeId = $this->getAttributeId($entityTypeId, $attributeId); + $table = $this->getTable('eav_entity_attribute'); + + $bind = array( + 'attribute_set_id' => $setId, + 'attribute_id' => $attributeId + ); + $select = $this->_conn->select() + ->from($table) + ->where('attribute_set_id = :attribute_set_id') + ->where('attribute_id = :attribute_id'); + $result = $this->_conn->fetchRow($select, $bind); + + if ($result) { + if ($result['attribute_group_id'] != $groupId) { + $where = array('entity_attribute_id =?' => $result['entity_attribute_id']); + $data = array('attribute_group_id' => $groupId); + $this->_conn->update($table, $data, $where); + } + } else { + $data = array( + 'entity_type_id' => $entityTypeId, + 'attribute_set_id' => $setId, + 'attribute_group_id' => $groupId, + 'attribute_id' => $attributeId, + 'sort_order' => $this->getAttributeSortOrder($entityTypeId, $setId, $groupId, $sortOrder), + ); + + $this->_conn->insert($table, $data); + } + + return $this; + } + + /** + * Add or update attribute to group + * + * @param int|string $entityType + * @param int|string $setId + * @param int|string $groupId + * @param int|string $attributeId + * @param int $sortOrder + * @return Mage_Eav_Model_Entity_Setup + */ + public function addAttributeToGroup($entityType, $setId, $groupId, $attributeId, $sortOrder = null) + { + $entityType = $this->getEntityTypeId($entityType); + $setId = $this->getAttributeSetId($entityType, $setId); + $groupId = $this->getAttributeGroupId($entityType, $setId, $groupId); + $attributeId = $this->getAttributeId($entityType, $attributeId); + + $data = array( + 'entity_type_id' => $entityType, + 'attribute_set_id' => $setId, + 'attribute_group_id' => $groupId, + 'attribute_id' => $attributeId, + ); + + $bind = array( + 'entity_type_id' => $entityType, + 'attribute_set_id' => $setId, + 'attribute_id' => $attributeId + ); + $select = $this->getConnection()->select() + ->from($this->getTable('eav_entity_attribute')) + ->where('entity_type_id = :entity_type_id') + ->where('attribute_set_id = :attribute_set_id') + ->where('attribute_id = :attribute_id'); + $row = $this->getConnection()->fetchRow($select, $bind); + if ($row) { + // update + if ($sortOrder !== null) { + $data['sort_order'] = $sortOrder; + } + + $this->getConnection()->update( + $this->getTable('eav_entity_attribute'), + $data, + $this->getConnection()->quoteInto('entity_attribute_id=?', $row['entity_attribute_id']) + ); + } else { + if ($sortOrder === null) { + $select = $this->getConnection()->select() + ->from($this->getTable('eav_entity_attribute'), 'MAX(sort_order)') + ->where('entity_type_id = :entity_type_id') + ->where('attribute_set_id = :attribute_set_id') + ->where('attribute_id = :attribute_id'); + + $sortOrder = $this->getConnection()->fetchOne($select, $bind) + 10; + } + $sortOrder = is_numeric($sortOrder) ? $sortOrder : 1; + $data['sort_order'] = $sortOrder; + $this->getConnection()->insert($this->getTable('eav_entity_attribute'), $data); + } + + return $this; + } + +/******************* BULK INSTALL *****************/ + + /** + * Install entities + * + * @param array $entities + * @return Mage_Eav_Model_Entity_Setup + */ + public function installEntities($entities = null) + { + $this->cleanCache(); + + if ($entities === null) { + $entities = $this->getDefaultEntities(); + } + + foreach ($entities as $entityName=>$entity) { + $this->addEntityType($entityName, $entity); + + $frontendPrefix = isset($entity['frontend_prefix']) ? $entity['frontend_prefix'] : ''; + $backendPrefix = isset($entity['backend_prefix']) ? $entity['backend_prefix'] : ''; + $sourcePrefix = isset($entity['source_prefix']) ? $entity['source_prefix'] : ''; + + if (is_array($entity['attributes']) && !empty($entity['attributes'])) { + foreach ($entity['attributes'] as $attrCode => $attr) { + if (!empty($attr['backend'])) { + if ('_' === $attr['backend']) { + $attr['backend'] = $backendPrefix; + } elseif ('_' === $attr['backend']{0}) { + $attr['backend'] = $backendPrefix.$attr['backend']; + } else { + $attr['backend'] = $attr['backend']; + } + } + if (!empty($attr['frontend'])) { + if ('_' === $attr['frontend']) { + $attr['frontend'] = $frontendPrefix; + } elseif ('_' === $attr['frontend']{0}) { + $attr['frontend'] = $frontendPrefix.$attr['frontend']; + } else { + $attr['frontend'] = $attr['frontend']; + } + } + if (!empty($attr['source'])) { + if ('_' === $attr['source']) { + $attr['source'] = $sourcePrefix; + } elseif ('_' === $attr['source']{0}) { + $attr['source'] = $sourcePrefix . $attr['source']; + } else { + $attr['source'] = $attr['source']; + } + } + + $this->addAttribute($entityName, $attrCode, $attr); + } + } + $this->setDefaultSetToEntityType($entityName); + } + + return $this; + } + + +/****************************** CREATE ENTITY TABLES ***********************************/ + + /** + * Create entity tables + * + * @param string $baseName + * @param array $options + * - no-main + * - no-default-types + * - types + * @return unknown + */ + public function createEntityTables($baseTableName, array $options = array()) + { + $isNoCreateMainTable = $this->_getValue($options, 'no-main', false); + $isNoDefaultTypes = $this->_getValue($options, 'no-default-types', false); + $customTypes = $this->_getValue($options, 'types', array()); + $tables = array(); + + if (!$isNoCreateMainTable) { + /** + * Create table main eav table + */ + $connection = $this->getConnection(); + $mainTable = $connection + ->newTable($this->getTable($baseTableName)) + ->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( + 'identity' => true, + 'nullable' => false, + 'primary' => true, + ), 'Entity Id') + ->addColumn('entity_type_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( + 'unsigned' => true, + 'nullable' => false, + 'default' => '0', + ), 'Entity Type Id') + ->addColumn('attribute_set_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( + 'unsigned' => true, + 'nullable' => false, + 'default' => '0', + ), 'Attribute Set Id') + ->addColumn('increment_id', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array( + 'nullable' => false, + 'default' => '', + ), 'Increment Id') + ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( + 'unsigned' => true, + 'nullable' => false, + 'default' => '0', + ), 'Store Id') + ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array( + 'nullable' => false, + ), 'Created At') + ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array( + 'nullable' => false, + ), 'Updated At') + ->addColumn('is_active', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( + 'unsigned' => true, + 'nullable' => false, + 'default' => '1', + ), 'Defines Is Entity Active') + ->addIndex($this->getIdxName($baseTableName, array('entity_type_id')), + array('entity_type_id')) + ->addIndex($this->getIdxName($baseTableName, array('store_id')), + array('store_id')) + ->addForeignKey($this->getFkName($baseTableName, 'entity_type_id', 'eav_entity_type', 'entity_type_id'), + 'entity_type_id', $this->getTable('eav_entity_type'), 'entity_type_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE) + ->addForeignKey($this->getFkName($baseTableName, 'store_id', 'core_store', 'store_id'), + 'store_id', $this->getTable('core_store'), 'store_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE) + ->setComment('Eav Entity Main Table'); + + $tables[$this->getTable($baseTableName)] = $mainTable; + } + + $types = array(); + if (!$isNoDefaultTypes) { + $types = array( + 'datetime' => array(Varien_Db_Ddl_Table::TYPE_DATETIME, null), + 'decimal' => array(Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4'), + 'int' => array(Varien_Db_Ddl_Table::TYPE_INTEGER, null), + 'text' => array(Varien_Db_Ddl_Table::TYPE_TEXT, '64k'), + 'varchar' => array(Varien_Db_Ddl_Table::TYPE_TEXT, '255'), + 'char' => array(Varien_Db_Ddl_Table::TYPE_TEXT, '255') + ); + } + + if (!empty($customTypes)) { + foreach ($customTypes as $type => $fieldType) { + if (count($fieldType) != 2) { + throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Wrong type definition for %s', $type)); + } + $types[$type] = $fieldType; + } + } + + /** + * Create table array($baseTableName, $type) + */ + foreach ($types as $type => $fieldType) { + $eavTableName = array($baseTableName, $type); + + $eavTable = $connection->newTable($this->getTable($eavTableName)); + $eavTable + ->addColumn('value_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( + 'identity' => true, + 'nullable' => false, + 'primary' => true, + ), 'Value Id') + ->addColumn('entity_type_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( + 'unsigned' => true, + 'nullable' => false, + 'default' => '0', + ), 'Entity Type Id') + ->addColumn('attribute_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( + 'unsigned' => true, + 'nullable' => false, + 'default' => '0', + ), 'Attribute Id') + ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( + 'unsigned' => true, + 'nullable' => false, + 'default' => '0', + ), 'Store Id') + ->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( + 'unsigned' => true, + 'nullable' => false, + 'default' => '0', + ), 'Entity Id') + ->addColumn('value', $fieldType[0], $fieldType[1], array( + 'nullable' => false, + ), 'Attribute Value') + ->addIndex($this->getIdxName($eavTableName, array('entity_type_id')), + array('entity_type_id')) + ->addIndex($this->getIdxName($eavTableName, array('attribute_id')), + array('attribute_id')) + ->addIndex($this->getIdxName($eavTableName, array('store_id')), + array('store_id')) + ->addIndex($this->getIdxName($eavTableName, array('entity_id')), + array('entity_id')); + if ($type !== 'text') { + $eavTable->addIndex($this->getIdxName($eavTableName, array('attribute_id', 'value')), + array('attribute_id', 'value')); + $eavTable->addIndex($this->getIdxName($eavTableName, array('entity_type_id', 'value')), + array('entity_type_id', 'value')); + } + + $eavTable + ->addForeignKey($this->getFkName($eavTableName, 'entity_id', $baseTableName, 'entity_id'), + 'entity_id', $this->getTable($baseTableName), 'entity_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE) + ->addForeignKey($this->getFkName($eavTableName, 'entity_type_id', 'eav_entity_type', 'entity_type_id'), + 'entity_type_id', $this->getTable('eav_entity_type'), 'entity_type_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE) + ->addForeignKey($this->getFkName($eavTableName, 'store_id', 'core_store', 'store_id'), + 'store_id', $this->getTable('core_store'), 'store_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE) + ->setComment('Eav Entity Value Table'); + + $tables[$this->getTable($eavTableName)] = $eavTable; + } + + $connection->beginTransaction(); + try { + foreach ($tables as $tableName => $table) { + $connection->createTable($table); + } + $connection->commit(); + } catch (Exception $e) { + $connection->rollBack(); + throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Can\'t create table: %s', $tableName)); + } + + return $this; + } + + /** + * Retrieve attribute table fields + * + * @return array + */ + protected function _getAttributeTableFields() + { + return $this->getConnection()->describeTable($this->getTable('eav_attribute')); + } + + /** + * Insert attribute and filter data + * + * @param array $data + * @return Mage_Eav_Model_Entity_Setup + */ + protected function _insertAttribute(array $data) + { + $bind = array(); + + $fields = $this->_getAttributeTableFields(); + + foreach ($data as $k => $v) { + if (isset($fields[$k])) { + $bind[$k] = $this->getConnection()->prepareColumnValue($fields[$k], $v); + } + } + if (!$bind) { + return $this; + } + + $this->getConnection()->insert($this->getTable('eav_attribute'), $bind); + $attributeId = $this->getConnection()->lastInsertId($this->getTable('eav_attribute')); + $this->_insertAttributeAdditionalData( + $data['entity_type_id'], + array_merge(array('attribute_id' => $attributeId), $data) + ); + + return $this; + } + + /** + * Insert attribute additional data + * + * @param int $entityTypeId + * @param array $data + * @return Mage_Eav_Model_Entity_Setup + */ + protected function _insertAttributeAdditionalData($entityTypeId, array $data) + { + $additionalTable = $this->getEntityType($entityTypeId, 'additional_attribute_table'); + if (!$additionalTable) { + return $this; + } + $additionalTableExists = $this->getConnection()->isTableExists($this->getTable($additionalTable)); + if ($additionalTable && $additionalTableExists) { + $bind = array(); + $fields = $this->getConnection()->describeTable($this->getTable($additionalTable)); + foreach ($data as $k => $v) { + if (isset($fields[$k])) { + $bind[$k] = $this->getConnection()->prepareColumnValue($fields[$k], $v); + } + } + if (!$bind) { + return $this; + } + $this->getConnection()->insert($this->getTable($additionalTable), $bind); + } + + return $this; + } +} diff --git a/app/code/core/Mage/Eav/Model/Entity/Store.php b/app/code/Mage/Eav/Model/Entity/Store.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Store.php rename to app/code/Mage/Eav/Model/Entity/Store.php diff --git a/app/code/core/Mage/Eav/Model/Entity/Type.php b/app/code/Mage/Eav/Model/Entity/Type.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Entity/Type.php rename to app/code/Mage/Eav/Model/Entity/Type.php diff --git a/app/code/core/Mage/Eav/Model/Form.php b/app/code/Mage/Eav/Model/Form.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Form.php rename to app/code/Mage/Eav/Model/Form.php diff --git a/app/code/core/Mage/Eav/Model/Form/Element.php b/app/code/Mage/Eav/Model/Form/Element.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Form/Element.php rename to app/code/Mage/Eav/Model/Form/Element.php diff --git a/app/code/core/Mage/Eav/Model/Form/Fieldset.php b/app/code/Mage/Eav/Model/Form/Fieldset.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Form/Fieldset.php rename to app/code/Mage/Eav/Model/Form/Fieldset.php diff --git a/app/code/core/Mage/Eav/Model/Form/Type.php b/app/code/Mage/Eav/Model/Form/Type.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Form/Type.php rename to app/code/Mage/Eav/Model/Form/Type.php diff --git a/app/code/core/Mage/Eav/Model/Resource/Attribute.php b/app/code/Mage/Eav/Model/Resource/Attribute.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Attribute.php rename to app/code/Mage/Eav/Model/Resource/Attribute.php diff --git a/app/code/core/Mage/Eav/Model/Resource/Attribute/Collection.php b/app/code/Mage/Eav/Model/Resource/Attribute/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Attribute/Collection.php rename to app/code/Mage/Eav/Model/Resource/Attribute/Collection.php diff --git a/app/code/core/Mage/Eav/Model/Resource/Config.php b/app/code/Mage/Eav/Model/Resource/Config.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Config.php rename to app/code/Mage/Eav/Model/Resource/Config.php diff --git a/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute.php b/app/code/Mage/Eav/Model/Resource/Entity/Attribute.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Entity/Attribute.php rename to app/code/Mage/Eav/Model/Resource/Entity/Attribute.php diff --git a/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Collection.php b/app/code/Mage/Eav/Model/Resource/Entity/Attribute/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Collection.php rename to app/code/Mage/Eav/Model/Resource/Entity/Attribute/Collection.php diff --git a/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Grid/Collection.php b/app/code/Mage/Eav/Model/Resource/Entity/Attribute/Grid/Collection.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Grid/Collection.php rename to app/code/Mage/Eav/Model/Resource/Entity/Attribute/Grid/Collection.php diff --git a/app/code/Mage/Eav/Model/Resource/Entity/Attribute/Group.php b/app/code/Mage/Eav/Model/Resource/Entity/Attribute/Group.php new file mode 100644 index 0000000000000..ed6cfe6cad08d --- /dev/null +++ b/app/code/Mage/Eav/Model/Resource/Entity/Attribute/Group.php @@ -0,0 +1,146 @@ + + */ +class Mage_Eav_Model_Resource_Entity_Attribute_Group extends Mage_Core_Model_Resource_Db_Abstract +{ + /** + * Constants for attribute group codes + */ + const TAB_GENERAL_CODE = 'product-details'; + const TAB_IMAGE_MANAGEMENT_CODE = 'image-management'; + + /** + * Resource initialization + */ + protected function _construct() + { + $this->_init('eav_attribute_group', 'attribute_group_id'); + } + + /** + * Checks if attribute group exists + * + * @param Mage_Eav_Model_Entity_Attribute_Group $object + * @return boolean + */ + public function itemExists($object) + { + $adapter = $this->_getReadAdapter(); + $bind = array( + 'attribute_set_id' => $object->getAttributeSetId(), + 'attribute_group_name' => $object->getAttributeGroupName() + ); + $select = $adapter->select() + ->from($this->getMainTable()) + ->where('attribute_set_id = :attribute_set_id') + ->where('attribute_group_name = :attribute_group_name'); + + return $adapter->fetchRow($select, $bind) > 0; + } + + /** + * Perform actions before object save + * + * @param Mage_Core_Model_Abstract $object + * @return Mage_Core_Model_Resource_Db_Abstract + */ + protected function _beforeSave(Mage_Core_Model_Abstract $object) + { + if (!$object->getSortOrder()) { + $object->setSortOrder($this->_getMaxSortOrder($object) + 1); + } + return parent::_beforeSave($object); + } + + /** + * Perform actions after object save + * + * @param Mage_Core_Model_Abstract $object + * @return Mage_Core_Model_Resource_Db_Abstract + */ + protected function _afterSave(Mage_Core_Model_Abstract $object) + { + if ($object->getAttributes()) { + foreach ($object->getAttributes() as $attribute) { + $attribute->setAttributeGroupId($object->getId()); + $attribute->save(); + } + } + + return parent::_afterSave($object); + } + + /** + * Retreive max sort order + * + * @param Mage_Core_Model_Abstract $object + * @return int + */ + protected function _getMaxSortOrder($object) + { + $adapter = $this->_getReadAdapter(); + $bind = array(':attribute_set_id' => $object->getAttributeSetId()); + $select = $adapter->select() + ->from($this->getMainTable(), new Zend_Db_Expr("MAX(sort_order)")) + ->where('attribute_set_id = :attribute_set_id'); + + return $adapter->fetchOne($select, $bind); + } + + /** + * Set any group default if old one was removed + * + * @param integer $attributeSetId + * @return Mage_Eav_Model_Resource_Entity_Attribute_Group + */ + public function updateDefaultGroup($attributeSetId) + { + $adapter = $this->_getWriteAdapter(); + $bind = array(':attribute_set_id' => $attributeSetId); + $select = $adapter->select() + ->from($this->getMainTable(), $this->getIdFieldName()) + ->where('attribute_set_id = :attribute_set_id') + ->order('default_id ' . Varien_Data_Collection::SORT_ORDER_DESC) + ->limit(1); + + $groupId = $adapter->fetchOne($select, $bind); + + if ($groupId) { + $data = array('default_id' => 1); + $where = array('attribute_group_id =?' => $groupId); + $adapter->update($this->getMainTable(), $data, $where); + } + + return $this; + } +} diff --git a/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Group/Collection.php b/app/code/Mage/Eav/Model/Resource/Entity/Attribute/Group/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Group/Collection.php rename to app/code/Mage/Eav/Model/Resource/Entity/Attribute/Group/Collection.php diff --git a/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Option.php b/app/code/Mage/Eav/Model/Resource/Entity/Attribute/Option.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Option.php rename to app/code/Mage/Eav/Model/Resource/Entity/Attribute/Option.php diff --git a/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Option/Collection.php b/app/code/Mage/Eav/Model/Resource/Entity/Attribute/Option/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Option/Collection.php rename to app/code/Mage/Eav/Model/Resource/Entity/Attribute/Option/Collection.php diff --git a/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Set.php b/app/code/Mage/Eav/Model/Resource/Entity/Attribute/Set.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Set.php rename to app/code/Mage/Eav/Model/Resource/Entity/Attribute/Set.php diff --git a/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Set/Collection.php b/app/code/Mage/Eav/Model/Resource/Entity/Attribute/Set/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Set/Collection.php rename to app/code/Mage/Eav/Model/Resource/Entity/Attribute/Set/Collection.php diff --git a/app/code/core/Mage/Eav/Model/Resource/Entity/Store.php b/app/code/Mage/Eav/Model/Resource/Entity/Store.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Entity/Store.php rename to app/code/Mage/Eav/Model/Resource/Entity/Store.php diff --git a/app/code/core/Mage/Eav/Model/Resource/Entity/Type.php b/app/code/Mage/Eav/Model/Resource/Entity/Type.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Entity/Type.php rename to app/code/Mage/Eav/Model/Resource/Entity/Type.php diff --git a/app/code/core/Mage/Eav/Model/Resource/Entity/Type/Collection.php b/app/code/Mage/Eav/Model/Resource/Entity/Type/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Entity/Type/Collection.php rename to app/code/Mage/Eav/Model/Resource/Entity/Type/Collection.php diff --git a/app/code/core/Mage/Eav/Model/Resource/Form/Attribute.php b/app/code/Mage/Eav/Model/Resource/Form/Attribute.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Form/Attribute.php rename to app/code/Mage/Eav/Model/Resource/Form/Attribute.php diff --git a/app/code/core/Mage/Eav/Model/Resource/Form/Attribute/Collection.php b/app/code/Mage/Eav/Model/Resource/Form/Attribute/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Form/Attribute/Collection.php rename to app/code/Mage/Eav/Model/Resource/Form/Attribute/Collection.php diff --git a/app/code/core/Mage/Eav/Model/Resource/Form/Element.php b/app/code/Mage/Eav/Model/Resource/Form/Element.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Form/Element.php rename to app/code/Mage/Eav/Model/Resource/Form/Element.php diff --git a/app/code/core/Mage/Eav/Model/Resource/Form/Element/Collection.php b/app/code/Mage/Eav/Model/Resource/Form/Element/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Form/Element/Collection.php rename to app/code/Mage/Eav/Model/Resource/Form/Element/Collection.php diff --git a/app/code/core/Mage/Eav/Model/Resource/Form/Fieldset.php b/app/code/Mage/Eav/Model/Resource/Form/Fieldset.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Form/Fieldset.php rename to app/code/Mage/Eav/Model/Resource/Form/Fieldset.php diff --git a/app/code/core/Mage/Eav/Model/Resource/Form/Fieldset/Collection.php b/app/code/Mage/Eav/Model/Resource/Form/Fieldset/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Form/Fieldset/Collection.php rename to app/code/Mage/Eav/Model/Resource/Form/Fieldset/Collection.php diff --git a/app/code/core/Mage/Eav/Model/Resource/Form/Type.php b/app/code/Mage/Eav/Model/Resource/Form/Type.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Form/Type.php rename to app/code/Mage/Eav/Model/Resource/Form/Type.php diff --git a/app/code/core/Mage/Eav/Model/Resource/Form/Type/Collection.php b/app/code/Mage/Eav/Model/Resource/Form/Type/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Form/Type/Collection.php rename to app/code/Mage/Eav/Model/Resource/Form/Type/Collection.php diff --git a/app/code/core/Mage/Eav/Model/Resource/Helper/Mysql4.php b/app/code/Mage/Eav/Model/Resource/Helper/Mysql4.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Resource/Helper/Mysql4.php rename to app/code/Mage/Eav/Model/Resource/Helper/Mysql4.php diff --git a/app/code/core/Mage/Eav/Model/Validator/Attribute/Backend.php b/app/code/Mage/Eav/Model/Validator/Attribute/Backend.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Validator/Attribute/Backend.php rename to app/code/Mage/Eav/Model/Validator/Attribute/Backend.php diff --git a/app/code/core/Mage/Eav/Model/Validator/Attribute/Data.php b/app/code/Mage/Eav/Model/Validator/Attribute/Data.php similarity index 100% rename from app/code/core/Mage/Eav/Model/Validator/Attribute/Data.php rename to app/code/Mage/Eav/Model/Validator/Attribute/Data.php diff --git a/app/code/core/Mage/Eav/data/eav_setup/data-upgrade-1.6.0.0-1.6.0.1.php b/app/code/Mage/Eav/data/eav_setup/data-upgrade-1.6.0.0-1.6.0.1.php similarity index 100% rename from app/code/core/Mage/Eav/data/eav_setup/data-upgrade-1.6.0.0-1.6.0.1.php rename to app/code/Mage/Eav/data/eav_setup/data-upgrade-1.6.0.0-1.6.0.1.php diff --git a/app/code/Mage/Eav/etc/config.xml b/app/code/Mage/Eav/etc/config.xml new file mode 100644 index 0000000000000..76171b4a22c46 --- /dev/null +++ b/app/code/Mage/Eav/etc/config.xml @@ -0,0 +1,97 @@ + + + + + + 1.6.0.2 + true + + + + + + + + + + Mage_Eav + Mage_Eav_Model_Entity_Setup + + + + + + + + Entity types declaration cache. + Mage_Eav_Model_Cache_Type + + + + + + + + + + + + + + Mage_Eav.csv + + + + + + + + + + + Mage_Eav.csv + + + + + + + + + + text + + date + boolean + multiselect + + + + + + diff --git a/app/code/core/Mage/Eav/etc/validation.xml b/app/code/Mage/Eav/etc/validation.xml similarity index 100% rename from app/code/core/Mage/Eav/etc/validation.xml rename to app/code/Mage/Eav/etc/validation.xml diff --git a/app/code/core/Mage/Eav/locale/de_DE/Mage_Eav.csv b/app/code/Mage/Eav/locale/de_DE/Mage_Eav.csv similarity index 100% rename from app/code/core/Mage/Eav/locale/de_DE/Mage_Eav.csv rename to app/code/Mage/Eav/locale/de_DE/Mage_Eav.csv diff --git a/app/code/core/Mage/Eav/locale/en_US/Mage_Eav.csv b/app/code/Mage/Eav/locale/en_US/Mage_Eav.csv similarity index 100% rename from app/code/core/Mage/Eav/locale/en_US/Mage_Eav.csv rename to app/code/Mage/Eav/locale/en_US/Mage_Eav.csv diff --git a/app/code/core/Mage/Eav/locale/es_ES/Mage_Eav.csv b/app/code/Mage/Eav/locale/es_ES/Mage_Eav.csv similarity index 100% rename from app/code/core/Mage/Eav/locale/es_ES/Mage_Eav.csv rename to app/code/Mage/Eav/locale/es_ES/Mage_Eav.csv diff --git a/app/code/core/Mage/Eav/locale/fr_FR/Mage_Eav.csv b/app/code/Mage/Eav/locale/fr_FR/Mage_Eav.csv similarity index 100% rename from app/code/core/Mage/Eav/locale/fr_FR/Mage_Eav.csv rename to app/code/Mage/Eav/locale/fr_FR/Mage_Eav.csv diff --git a/app/code/core/Mage/Eav/locale/nl_NL/Mage_Eav.csv b/app/code/Mage/Eav/locale/nl_NL/Mage_Eav.csv similarity index 100% rename from app/code/core/Mage/Eav/locale/nl_NL/Mage_Eav.csv rename to app/code/Mage/Eav/locale/nl_NL/Mage_Eav.csv diff --git a/app/code/core/Mage/Eav/locale/pt_BR/Mage_Eav.csv b/app/code/Mage/Eav/locale/pt_BR/Mage_Eav.csv similarity index 100% rename from app/code/core/Mage/Eav/locale/pt_BR/Mage_Eav.csv rename to app/code/Mage/Eav/locale/pt_BR/Mage_Eav.csv diff --git a/app/code/core/Mage/Eav/locale/zh_CN/Mage_Eav.csv b/app/code/Mage/Eav/locale/zh_CN/Mage_Eav.csv similarity index 100% rename from app/code/core/Mage/Eav/locale/zh_CN/Mage_Eav.csv rename to app/code/Mage/Eav/locale/zh_CN/Mage_Eav.csv diff --git a/app/code/core/Mage/Eav/sql/eav_setup/install-1.6.0.0.php b/app/code/Mage/Eav/sql/eav_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Eav/sql/eav_setup/install-1.6.0.0.php rename to app/code/Mage/Eav/sql/eav_setup/install-1.6.0.0.php diff --git a/app/code/Mage/Eav/sql/eav_setup/upgrade-1.6.0.1-1.6.0.2.php b/app/code/Mage/Eav/sql/eav_setup/upgrade-1.6.0.1-1.6.0.2.php new file mode 100644 index 0000000000000..787f172b0f6f7 --- /dev/null +++ b/app/code/Mage/Eav/sql/eav_setup/upgrade-1.6.0.1-1.6.0.2.php @@ -0,0 +1,54 @@ +startSetup(); + +$connection = $installer->getConnection(); +$tableName = $installer->getTable('eav_attribute_group'); + +$connection->addColumn($tableName, 'attribute_group_code', array( + 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, + 'length' => '255', + 'comment' => 'Attribute Group Code', +)); + +$connection->addColumn($tableName, 'tab_group_code', array( + 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, + 'length' => '255', + 'comment' => 'Tab Group Code', +)); + +/** @var $groups Mage_Eav_Model_Resource_Entity_Attribute_Group_Collection*/ +$groups = Mage::getResourceModel('Mage_Eav_Model_Resource_Entity_Attribute_Group_Collection'); +foreach ($groups as $group) { + /** @var $group Mage_Eav_Model_Entity_Attribute_Group*/ + $group->save(); +} + +$installer->endSetup(); diff --git a/app/code/core/Mage/Eav/view/adminhtml/attribute/edit/js.phtml b/app/code/Mage/Eav/view/adminhtml/attribute/edit/js.phtml similarity index 100% rename from app/code/core/Mage/Eav/view/adminhtml/attribute/edit/js.phtml rename to app/code/Mage/Eav/view/adminhtml/attribute/edit/js.phtml diff --git a/app/code/core/Mage/GiftMessage/Block/Adminhtml/Product/Helper/Form/Config.php b/app/code/Mage/GiftMessage/Block/Adminhtml/Product/Helper/Form/Config.php similarity index 100% rename from app/code/core/Mage/GiftMessage/Block/Adminhtml/Product/Helper/Form/Config.php rename to app/code/Mage/GiftMessage/Block/Adminhtml/Product/Helper/Form/Config.php diff --git a/app/code/core/Mage/GiftMessage/Block/Adminhtml/Sales/Order/Create/Form.php b/app/code/Mage/GiftMessage/Block/Adminhtml/Sales/Order/Create/Form.php similarity index 100% rename from app/code/core/Mage/GiftMessage/Block/Adminhtml/Sales/Order/Create/Form.php rename to app/code/Mage/GiftMessage/Block/Adminhtml/Sales/Order/Create/Form.php diff --git a/app/code/core/Mage/GiftMessage/Block/Adminhtml/Sales/Order/Create/Giftoptions.php b/app/code/Mage/GiftMessage/Block/Adminhtml/Sales/Order/Create/Giftoptions.php similarity index 100% rename from app/code/core/Mage/GiftMessage/Block/Adminhtml/Sales/Order/Create/Giftoptions.php rename to app/code/Mage/GiftMessage/Block/Adminhtml/Sales/Order/Create/Giftoptions.php diff --git a/app/code/core/Mage/GiftMessage/Block/Adminhtml/Sales/Order/Create/Items.php b/app/code/Mage/GiftMessage/Block/Adminhtml/Sales/Order/Create/Items.php similarity index 100% rename from app/code/core/Mage/GiftMessage/Block/Adminhtml/Sales/Order/Create/Items.php rename to app/code/Mage/GiftMessage/Block/Adminhtml/Sales/Order/Create/Items.php diff --git a/app/code/core/Mage/GiftMessage/Block/Adminhtml/Sales/Order/View/Form.php b/app/code/Mage/GiftMessage/Block/Adminhtml/Sales/Order/View/Form.php similarity index 100% rename from app/code/core/Mage/GiftMessage/Block/Adminhtml/Sales/Order/View/Form.php rename to app/code/Mage/GiftMessage/Block/Adminhtml/Sales/Order/View/Form.php diff --git a/app/code/core/Mage/GiftMessage/Block/Adminhtml/Sales/Order/View/Giftoptions.php b/app/code/Mage/GiftMessage/Block/Adminhtml/Sales/Order/View/Giftoptions.php similarity index 100% rename from app/code/core/Mage/GiftMessage/Block/Adminhtml/Sales/Order/View/Giftoptions.php rename to app/code/Mage/GiftMessage/Block/Adminhtml/Sales/Order/View/Giftoptions.php diff --git a/app/code/core/Mage/GiftMessage/Block/Adminhtml/Sales/Order/View/Items.php b/app/code/Mage/GiftMessage/Block/Adminhtml/Sales/Order/View/Items.php similarity index 100% rename from app/code/core/Mage/GiftMessage/Block/Adminhtml/Sales/Order/View/Items.php rename to app/code/Mage/GiftMessage/Block/Adminhtml/Sales/Order/View/Items.php diff --git a/app/code/Mage/GiftMessage/Block/Message/Inline.php b/app/code/Mage/GiftMessage/Block/Message/Inline.php new file mode 100644 index 0000000000000..db43adef957c4 --- /dev/null +++ b/app/code/Mage/GiftMessage/Block/Message/Inline.php @@ -0,0 +1,298 @@ + + */ +class Mage_GiftMessage_Block_Message_Inline extends Mage_Core_Block_Template +{ + + protected $_entity = null; + protected $_type = null; + protected $_giftMessage = null; + + protected $_template = 'inline.phtml'; + + /** + * Set entity + * + * @return mixed + */ + public function setEntity($entity) + { + $this->_entity = $entity; + return $this; + } + + /** + * Get entity + * + * @return mixed + */ + public function getEntity() + { + return $this->_entity; + } + + /** + * Set type + * + * @param string $type + * @return Mage_GiftMessage_Block_Message_Inline + */ + public function setType($type) + { + $this->_type = $type; + return $this; + } + + /** + * Get type + * + * @return string + */ + public function getType() + { + return $this->_type; + } + + /** + * Check if entity has gift message + * + * @return bool + */ + public function hasGiftMessage() + { + return $this->getEntity()->getGiftMessageId() > 0; + } + + /** + * Init message + * + * @return Mage_GiftMessage_Block_Message_Inline + */ + protected function _initMessage() + { + $this->_giftMessage = $this->helper('Mage_GiftMessage_Helper_Message')->getGiftMessage( + $this->getEntity()->getGiftMessageId() + ); + return $this; + } + + /** + * Get default value for From field + * + * @return string + */ + public function getDefaultFrom() + { + if (Mage::getSingleton('Mage_Customer_Model_Session')->isLoggedIn()) { + return Mage::getSingleton('Mage_Customer_Model_Session')->getCustomer()->getName(); + } else { + return $this->getEntity()->getBillingAddress()->getName(); + } + } + + /** + * Get default value for To field + * + * @return string + */ + public function getDefaultTo() + { + if ($this->getEntity()->getShippingAddress()) { + return $this->getEntity()->getShippingAddress()->getName(); + } else { + return $this->getEntity()->getName(); + } + } + + /** + * Retrieve message + * + * @param mixed $entity + * @return string + */ + public function getMessage($entity=null) + { + if (is_null($this->_giftMessage)) { + $this->_initMessage(); + } + + if ($entity) { + if (!$entity->getGiftMessage()) { + $entity->setGiftMessage( + $this->helper('Mage_GiftMessage_Helper_Message')->getGiftMessage($entity->getGiftMessageId()) + ); + } + return $entity->getGiftMessage(); + } + + return $this->_giftMessage; + } + + /** + * Retrieve items + * + * @return array + */ + public function getItems() + { + if (!$this->getData('items')) { + $items = array(); + + $entityItems = $this->getEntity()->getAllItems(); + Mage::dispatchEvent('gift_options_prepare_items', array('items' => $entityItems)); + + foreach ($entityItems as $item) { + if ($item->getParentItem()) { + continue; + } + if ($this->isItemMessagesAvailable($item) || $item->getIsGiftOptionsAvailable()) { + $items[] = $item; + } + } + $this->setData('items', $items); + } + return $this->getData('items'); + } + + /** + * Retrieve additional url + * + * @return bool + */ + public function getAdditionalUrl() + { + return $this->getUrl('*/*/getAdditional'); + } + + /** + * Check if items are available + * + * @return bool + */ + public function isItemsAvailable() + { + return count($this->getItems()) > 0; + } + + /** + * Return items count + * + * @return int + */ + public function countItems() + { + return count($this->getItems()); + } + + /** + * Check if items has messages + * + * @return bool + */ + public function getItemsHasMesssages() + { + foreach ($this->getItems() as $item) { + if ($item->getGiftMessageId()) { + return true; + } + } + return false; + } + + /** + * Check if entity has message + * + * @return bool + */ + public function getEntityHasMessage() + { + return $this->getEntity()->getGiftMessageId() > 0; + } + + /** + * Return escaped value + * + * @param string $value + * @param string $defaultValue + * @return string + */ + public function getEscaped($value, $defaultValue='') + { + return $this->escapeHtml(trim($value)!='' ? $value : $defaultValue); + } + + /** + * Check availability of giftmessages for specified entity + * + * @return bool + */ + public function isMessagesAvailable() + { + return Mage::helper('Mage_GiftMessage_Helper_Message')->isMessagesAvailable('quote', $this->getEntity()); + } + + /** + * Check availability of giftmessages for specified entity item + * + * @return bool + */ + public function isItemMessagesAvailable($item) + { + $type = substr($this->getType(), 0, 5) == 'multi' ? 'address_item' : 'item'; + return Mage::helper('Mage_GiftMessage_Helper_Message')->isMessagesAvailable($type, $item); + } + + /** + * Product thumbnail image url getter + * + * @param Mage_Catalog_Model_Product $product + * @return string + */ + public function getThumbnailUrl($product) + { + return (string)$this->helper('Mage_Catalog_Helper_Image')->init($product, 'thumbnail') + ->resize($this->getThumbnailSize()); + } + + /** + * Thumbnail image size getter + * + * @return int + */ + public function getThumbnailSize() + { + return $this->getVar('product_thumbnail_image_size', 'Mage_Catalog'); + } + +} diff --git a/app/code/core/Mage/GiftMessage/Helper/Data.php b/app/code/Mage/GiftMessage/Helper/Data.php similarity index 100% rename from app/code/core/Mage/GiftMessage/Helper/Data.php rename to app/code/Mage/GiftMessage/Helper/Data.php diff --git a/app/code/core/Mage/GiftMessage/Helper/Message.php b/app/code/Mage/GiftMessage/Helper/Message.php similarity index 100% rename from app/code/core/Mage/GiftMessage/Helper/Message.php rename to app/code/Mage/GiftMessage/Helper/Message.php diff --git a/app/code/core/Mage/GiftMessage/Helper/Url.php b/app/code/Mage/GiftMessage/Helper/Url.php similarity index 100% rename from app/code/core/Mage/GiftMessage/Helper/Url.php rename to app/code/Mage/GiftMessage/Helper/Url.php diff --git a/app/code/core/Mage/GiftMessage/Model/Api.php b/app/code/Mage/GiftMessage/Model/Api.php similarity index 100% rename from app/code/core/Mage/GiftMessage/Model/Api.php rename to app/code/Mage/GiftMessage/Model/Api.php diff --git a/app/code/core/Mage/GiftMessage/Model/Api/V2.php b/app/code/Mage/GiftMessage/Model/Api/V2.php similarity index 100% rename from app/code/core/Mage/GiftMessage/Model/Api/V2.php rename to app/code/Mage/GiftMessage/Model/Api/V2.php diff --git a/app/code/core/Mage/GiftMessage/Model/Message.php b/app/code/Mage/GiftMessage/Model/Message.php similarity index 100% rename from app/code/core/Mage/GiftMessage/Model/Message.php rename to app/code/Mage/GiftMessage/Model/Message.php diff --git a/app/code/core/Mage/GiftMessage/Model/Observer.php b/app/code/Mage/GiftMessage/Model/Observer.php similarity index 100% rename from app/code/core/Mage/GiftMessage/Model/Observer.php rename to app/code/Mage/GiftMessage/Model/Observer.php diff --git a/app/code/core/Mage/GiftMessage/Model/Resource/Message.php b/app/code/Mage/GiftMessage/Model/Resource/Message.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/GiftMessage/Model/Resource/Message.php rename to app/code/Mage/GiftMessage/Model/Resource/Message.php diff --git a/app/code/core/Mage/GiftMessage/Model/Resource/Message/Collection.php b/app/code/Mage/GiftMessage/Model/Resource/Message/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/GiftMessage/Model/Resource/Message/Collection.php rename to app/code/Mage/GiftMessage/Model/Resource/Message/Collection.php diff --git a/app/code/core/Mage/GiftMessage/Model/Resource/Setup.php b/app/code/Mage/GiftMessage/Model/Resource/Setup.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/GiftMessage/Model/Resource/Setup.php rename to app/code/Mage/GiftMessage/Model/Resource/Setup.php diff --git a/app/code/Mage/GiftMessage/data/giftmessage_setup/data-upgrade-1.6.0.0-1.6.0.1.php b/app/code/Mage/GiftMessage/data/giftmessage_setup/data-upgrade-1.6.0.0-1.6.0.1.php new file mode 100644 index 0000000000000..a33b0fc9a6d78 --- /dev/null +++ b/app/code/Mage/GiftMessage/data/giftmessage_setup/data-upgrade-1.6.0.0-1.6.0.1.php @@ -0,0 +1,40 @@ +getEntityTypeId(Mage_Catalog_Model_Product::ENTITY); +$attributeSetId = $this->getAttributeSetId($entityTypeId, 'Default'); + +$attribute = $this->getAttribute($entityTypeId, 'gift_message_available'); +if ($attribute) { + $this->addAttributeToGroup($entityTypeId, $attributeSetId, $groupName, $attribute['attribute_id'], 60); +} + +if (!$this->getAttributesNumberInGroup($entityTypeId, $attributeSetId, 'Gift Options')) { + $this->removeAttributeGroup($entityTypeId, $attributeSetId, 'Gift Options'); +} diff --git a/app/code/core/Mage/GiftMessage/etc/adminhtml/system.xml b/app/code/Mage/GiftMessage/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/GiftMessage/etc/adminhtml/system.xml rename to app/code/Mage/GiftMessage/etc/adminhtml/system.xml diff --git a/app/code/core/Mage/GiftMessage/etc/api.xml b/app/code/Mage/GiftMessage/etc/api.xml similarity index 100% rename from app/code/core/Mage/GiftMessage/etc/api.xml rename to app/code/Mage/GiftMessage/etc/api.xml diff --git a/app/code/Mage/GiftMessage/etc/config.xml b/app/code/Mage/GiftMessage/etc/config.xml new file mode 100644 index 0000000000000..baf3b0d4f67ce --- /dev/null +++ b/app/code/Mage/GiftMessage/etc/config.xml @@ -0,0 +1,216 @@ + + + + + + 1.6.0.1 + true + + + + + + + + + + + Mage_GiftMessage + Mage_GiftMessage_Model_Resource_Setup + + + + + + + + + + + + + + + + + 0 + 0 + + + + + + + + + Mage_GiftMessage.csv + + + + + + + + + model + Mage_GiftMessage_Model_Observer + salesEventConvertQuoteItemToOrderItem + + + + + + + model + Mage_GiftMessage_Model_Observer + salesEventConvertQuoteAddressToOrder + + + + + + + model + Mage_GiftMessage_Model_Observer + salesEventConvertQuoteToOrder + + + + + + + model + Mage_GiftMessage_Model_Observer + checkoutEventCreateOrder + + + + + + + model + Mage_GiftMessage_Model_Observer + salesEventOrderToQuote + + + + + + + model + Mage_GiftMessage_Model_Observer + salesEventOrderItemToQuoteItem + + + + + + + + layout.xml + + + + + + + + + + model + Mage_GiftMessage_Model_Observer + salesEventConvertQuoteItemToOrderItem + + + + + + + model + Mage_GiftMessage_Model_Observer + salesEventConvertQuoteAddressToOrder + + + + + + + model + Mage_GiftMessage_Model_Observer + salesEventConvertQuoteToOrder + + + + + + + model + Mage_GiftMessage_Model_Observer + checkoutEventCreateGiftMessage + + + + + + + model + Mage_GiftMessage_Model_Observer + checkoutEventCreateGiftMessage + + + + + + + model + Mage_GiftMessage_Model_Observer + salesEventOrderToQuote + + + + + + + standard + + Mage_GiftMessage + giftmessage + + + + + + + + Mage_GiftMessage.csv + + + + + + diff --git a/app/code/core/Mage/GiftMessage/etc/wsdl.xml b/app/code/Mage/GiftMessage/etc/wsdl.xml similarity index 100% rename from app/code/core/Mage/GiftMessage/etc/wsdl.xml rename to app/code/Mage/GiftMessage/etc/wsdl.xml diff --git a/app/code/core/Mage/GiftMessage/etc/wsi.xml b/app/code/Mage/GiftMessage/etc/wsi.xml similarity index 100% rename from app/code/core/Mage/GiftMessage/etc/wsi.xml rename to app/code/Mage/GiftMessage/etc/wsi.xml diff --git a/app/code/core/Mage/GiftMessage/locale/de_DE/Mage_GiftMessage.csv b/app/code/Mage/GiftMessage/locale/de_DE/Mage_GiftMessage.csv similarity index 100% rename from app/code/core/Mage/GiftMessage/locale/de_DE/Mage_GiftMessage.csv rename to app/code/Mage/GiftMessage/locale/de_DE/Mage_GiftMessage.csv diff --git a/app/code/core/Mage/GiftMessage/locale/en_US/Mage_GiftMessage.csv b/app/code/Mage/GiftMessage/locale/en_US/Mage_GiftMessage.csv similarity index 100% rename from app/code/core/Mage/GiftMessage/locale/en_US/Mage_GiftMessage.csv rename to app/code/Mage/GiftMessage/locale/en_US/Mage_GiftMessage.csv diff --git a/app/code/core/Mage/GiftMessage/locale/es_ES/Mage_GiftMessage.csv b/app/code/Mage/GiftMessage/locale/es_ES/Mage_GiftMessage.csv similarity index 100% rename from app/code/core/Mage/GiftMessage/locale/es_ES/Mage_GiftMessage.csv rename to app/code/Mage/GiftMessage/locale/es_ES/Mage_GiftMessage.csv diff --git a/app/code/core/Mage/GiftMessage/locale/fr_FR/Mage_GiftMessage.csv b/app/code/Mage/GiftMessage/locale/fr_FR/Mage_GiftMessage.csv similarity index 100% rename from app/code/core/Mage/GiftMessage/locale/fr_FR/Mage_GiftMessage.csv rename to app/code/Mage/GiftMessage/locale/fr_FR/Mage_GiftMessage.csv diff --git a/app/code/core/Mage/GiftMessage/locale/nl_NL/Mage_GiftMessage.csv b/app/code/Mage/GiftMessage/locale/nl_NL/Mage_GiftMessage.csv similarity index 100% rename from app/code/core/Mage/GiftMessage/locale/nl_NL/Mage_GiftMessage.csv rename to app/code/Mage/GiftMessage/locale/nl_NL/Mage_GiftMessage.csv diff --git a/app/code/core/Mage/GiftMessage/locale/pt_BR/Mage_GiftMessage.csv b/app/code/Mage/GiftMessage/locale/pt_BR/Mage_GiftMessage.csv similarity index 100% rename from app/code/core/Mage/GiftMessage/locale/pt_BR/Mage_GiftMessage.csv rename to app/code/Mage/GiftMessage/locale/pt_BR/Mage_GiftMessage.csv diff --git a/app/code/core/Mage/GiftMessage/locale/zh_CN/Mage_GiftMessage.csv b/app/code/Mage/GiftMessage/locale/zh_CN/Mage_GiftMessage.csv similarity index 100% rename from app/code/core/Mage/GiftMessage/locale/zh_CN/Mage_GiftMessage.csv rename to app/code/Mage/GiftMessage/locale/zh_CN/Mage_GiftMessage.csv diff --git a/app/code/core/Mage/GiftMessage/sql/giftmessage_setup/install-1.6.0.0.php b/app/code/Mage/GiftMessage/sql/giftmessage_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/GiftMessage/sql/giftmessage_setup/install-1.6.0.0.php rename to app/code/Mage/GiftMessage/sql/giftmessage_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/GiftMessage/view/adminhtml/form.phtml b/app/code/Mage/GiftMessage/view/adminhtml/form.phtml similarity index 100% rename from app/code/core/Mage/GiftMessage/view/adminhtml/form.phtml rename to app/code/Mage/GiftMessage/view/adminhtml/form.phtml diff --git a/app/code/core/Mage/GiftMessage/view/adminhtml/giftoptionsform.phtml b/app/code/Mage/GiftMessage/view/adminhtml/giftoptionsform.phtml similarity index 100% rename from app/code/core/Mage/GiftMessage/view/adminhtml/giftoptionsform.phtml rename to app/code/Mage/GiftMessage/view/adminhtml/giftoptionsform.phtml diff --git a/app/code/core/Mage/GiftMessage/view/adminhtml/helper.phtml b/app/code/Mage/GiftMessage/view/adminhtml/helper.phtml similarity index 100% rename from app/code/core/Mage/GiftMessage/view/adminhtml/helper.phtml rename to app/code/Mage/GiftMessage/view/adminhtml/helper.phtml diff --git a/app/code/core/Mage/GiftMessage/view/adminhtml/layout.xml b/app/code/Mage/GiftMessage/view/adminhtml/layout.xml similarity index 100% rename from app/code/core/Mage/GiftMessage/view/adminhtml/layout.xml rename to app/code/Mage/GiftMessage/view/adminhtml/layout.xml diff --git a/app/code/Mage/GiftMessage/view/adminhtml/popup.phtml b/app/code/Mage/GiftMessage/view/adminhtml/popup.phtml new file mode 100644 index 0000000000000..665a7fd6e2f6a --- /dev/null +++ b/app/code/Mage/GiftMessage/view/adminhtml/popup.phtml @@ -0,0 +1,50 @@ + + +getChildHtml()) :?> + + + + + diff --git a/app/code/Mage/GiftMessage/view/adminhtml/sales/order/create/giftoptions.phtml b/app/code/Mage/GiftMessage/view/adminhtml/sales/order/create/giftoptions.phtml new file mode 100644 index 0000000000000..290ee28e51b45 --- /dev/null +++ b/app/code/Mage/GiftMessage/view/adminhtml/sales/order/create/giftoptions.phtml @@ -0,0 +1,44 @@ + + +getItem() ?> + + getChildHtml('', false));?> + + + + __('Gift Options') ?> + +
    + +
    + + + + diff --git a/app/code/core/Mage/GiftMessage/view/adminhtml/sales/order/create/items.phtml b/app/code/Mage/GiftMessage/view/adminhtml/sales/order/create/items.phtml similarity index 100% rename from app/code/core/Mage/GiftMessage/view/adminhtml/sales/order/create/items.phtml rename to app/code/Mage/GiftMessage/view/adminhtml/sales/order/create/items.phtml diff --git a/app/code/Mage/GiftMessage/view/adminhtml/sales/order/view/giftoptions.phtml b/app/code/Mage/GiftMessage/view/adminhtml/sales/order/view/giftoptions.phtml new file mode 100644 index 0000000000000..4d53f910b0fbf --- /dev/null +++ b/app/code/Mage/GiftMessage/view/adminhtml/sales/order/view/giftoptions.phtml @@ -0,0 +1,42 @@ + + +getChildHtml('', false)); ?> + +getItem() ?> + + + __('Gift Options') ?> + +
    + +
    + + + diff --git a/app/code/core/Mage/GiftMessage/view/adminhtml/sales/order/view/items.phtml b/app/code/Mage/GiftMessage/view/adminhtml/sales/order/view/items.phtml similarity index 100% rename from app/code/core/Mage/GiftMessage/view/adminhtml/sales/order/view/items.phtml rename to app/code/Mage/GiftMessage/view/adminhtml/sales/order/view/items.phtml diff --git a/app/code/Mage/GiftMessage/view/frontend/gift-options.js b/app/code/Mage/GiftMessage/view/frontend/gift-options.js new file mode 100644 index 0000000000000..fbb910dd03644 --- /dev/null +++ b/app/code/Mage/GiftMessage/view/frontend/gift-options.js @@ -0,0 +1,96 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category gift message options toggle + * @package mage + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +/*jshint jquery:true*/ +(function($) { + "use strict"; + $.widget('mage.giftOptions', { + options: { + mageError: 'mage-error', + noDisplay: 'no-display', + requiredEntry: 'required-entry' + }, + + /** + * Initial toggle of the various gift options after widget instantiation. + * @private + */ + _init: function() { + this._toggleVisibility(); + }, + + /** + * Bind a click handler to the widget's context element. + * @private + */ + _create: function() { + this.element.on('click', $.proxy(this._toggleVisibility, this)); + $(this.element.data('selector').id).find('.giftmessage-area') + .on('change', $.proxy(this._toggleRequired, this)); + }, + + /** + * Toggle the visibility of the widget's context element's selector(s). + * @private + * @param event {Object} - Click event. Target is a checkbox. + */ + _toggleVisibility: function(event) { + var checkbox = event ? $(event.target) : this.element, + container = $(checkbox.data('selector').id); + if (checkbox.is(':checked')) { + container.show() + .find('.giftmessage-area:not(:visible)').each(function(x, element) { + if ($(element).val().length > 0) { + $(element).change(); + container.find('a').click(); + } + }); + } else { + var _this = this; + container.hide() + .find('.input-text:not(.giftmessage-area)').each(function(x, element) { + $(element).val(element.defaultValue).removeClass(_this.options.mageError) + .next('div.' + _this.options.mageError).remove(); + }).end() + .find('.giftmessage-area').val('').change().end() + .find('.select').val('').change().end() + .find('.checkbox:checked').prop('checked', false).click().prop('checked', false).end() + .find('a').parent().next().addClass(this.options.noDisplay).end() + .find('.price-box').addClass(this.options.noDisplay).end(); + } + }, + + /** + * Make the From and To input fields required if a gift message has been written. + * @private + * @param event {Object} - Change event. Target is a textarea. + */ + _toggleRequired: function(event) { + var textArea = $(event.target), + length = textArea.val().length; + textArea.closest('li').prev('.fields') + .find('.input-text').toggleClass(this.options.requiredEntry, length > 0); + } + }); +})(jQuery); diff --git a/app/code/Mage/GiftMessage/view/frontend/inline.phtml b/app/code/Mage/GiftMessage/view/frontend/inline.phtml new file mode 100644 index 0000000000000..50c799178fb3a --- /dev/null +++ b/app/code/Mage/GiftMessage/view/frontend/inline.phtml @@ -0,0 +1,252 @@ + +isMessagesAvailable() || $this->isItemsAvailable()): ?> +getType()): ?> + +
    +

    __('Do you have any gift items in your order?'); ?>

    +

    + getItemsHasMesssages() || $this->getEntityHasMessage()): ?> checked="checked" class="checkbox" /> + +

    +
    +
    +
    + isMessagesAvailable()): ?> +

    __('Gift Options for the Entire Order.'); ?>

    +

    + getEntityHasMessage()): ?> checked="checked" class="checkbox" /> + +

    + + + isItemsAvailable()): ?> +

    __('Gift Options for Individual Items'); ?>

    +

    + getItemsHasMesssages()): ?> checked="checked" class="checkbox" /> + +

    +
    +

    __('You can leave this box blank if you do not wish to add a gift message for the item.') ?>

    +
      + getItems() as $_index=>$_item): ?> + getProduct() ?> +
    1. +
      +

      + <?php echo $this->escapeHtml($_product->getName()) ?> +

      +

      __('Item %d of %d', $_index+1, $this->countItems()) ?>

      +
      +
      +
      +
      escapeHtml($_product->getName()) ?>
      + +
        +
      • +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
      • +
      • + +
        + +
        +
      • +
      +
      +
      +
    2. + +
    +
    + +
    +
    + + + + + + +
    +

    __('Do you have any gift items in your order?'); ?>

    +

    + getItemsHasMesssages() || $this->getEntityHasMessage()): ?> checked="checked" class="checkbox" /> + +

    +
    +
    +
    + isMessagesAvailable()): ?> +

    __('Gift Options for this address.'); ?>

    +

    + getEntityHasMessage()): ?> checked="checked" class="checkbox" /> + +

    +
    +

    __('You can leave this box blank if you do not wish to add a gift message for this address.') ?>

    + +
      +
    • +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
    • +
    • + +
      + +
      +
    • +
    +
    + + isItemsAvailable()): ?> +

    __('Gift Options for Individual Items'); ?>

    +

    + getItemsHasMesssages()): ?> checked="checked" class="checkbox" /> + +

    +
    +

    __('You can leave this box blank if you do not wish to add a gift message for the item.') ?>

    +
      + getItems() as $_index=>$_item): ?> + getProduct() ?> +
    1. +
      +

      <?php echo $this->escapeHtml($_product->getName()) ?>

      +

      __('Item %d of %d', $_index+1, $this->countItems()) ?>

      +
      +
      +
      + + +
      escapeHtml($_product->getName()) ?>
      +
        +
      • +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
      • +
      • + +
        + +
        +
      • +
      +
      +
      +
    2. + +
    +
    + +
    +
    + + + + + diff --git a/app/code/core/Mage/GoogleAnalytics/Block/Ga.php b/app/code/Mage/GoogleAnalytics/Block/Ga.php similarity index 97% rename from app/code/core/Mage/GoogleAnalytics/Block/Ga.php rename to app/code/Mage/GoogleAnalytics/Block/Ga.php index 99e73295a5f8c..3f74d2a27ca3e 100644 --- a/app/code/core/Mage/GoogleAnalytics/Block/Ga.php +++ b/app/code/Mage/GoogleAnalytics/Block/Ga.php @@ -53,7 +53,7 @@ public function getPageName() * @param string $accountId * @return string */ - protected function _getPageTrackingCode($accountId) + public function getPageTrackingCode($accountId) { $pageName = trim($this->getPageName()); $optPageURL = ''; @@ -72,7 +72,7 @@ protected function _getPageTrackingCode($accountId) * @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEcommerce.html#_gat.GA_Tracker_._addTrans * @return string */ - protected function _getOrdersTrackingCode() + public function getOrdersTrackingCode() { $orderIds = $this->getOrderIds(); if (empty($orderIds) || !is_array($orderIds)) { diff --git a/app/code/core/Mage/GoogleAnalytics/Helper/Data.php b/app/code/Mage/GoogleAnalytics/Helper/Data.php similarity index 100% rename from app/code/core/Mage/GoogleAnalytics/Helper/Data.php rename to app/code/Mage/GoogleAnalytics/Helper/Data.php diff --git a/app/code/core/Mage/GoogleAnalytics/Model/Observer.php b/app/code/Mage/GoogleAnalytics/Model/Observer.php similarity index 100% rename from app/code/core/Mage/GoogleAnalytics/Model/Observer.php rename to app/code/Mage/GoogleAnalytics/Model/Observer.php diff --git a/app/code/Mage/GoogleAnalytics/etc/adminhtml/acl.xml b/app/code/Mage/GoogleAnalytics/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..8db5db147f746 --- /dev/null +++ b/app/code/Mage/GoogleAnalytics/etc/adminhtml/acl.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + diff --git a/app/code/core/Mage/GoogleAnalytics/etc/adminhtml/system.xml b/app/code/Mage/GoogleAnalytics/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/GoogleAnalytics/etc/adminhtml/system.xml rename to app/code/Mage/GoogleAnalytics/etc/adminhtml/system.xml diff --git a/app/code/Mage/GoogleAnalytics/etc/config.xml b/app/code/Mage/GoogleAnalytics/etc/config.xml new file mode 100644 index 0000000000000..95d54eea000ef --- /dev/null +++ b/app/code/Mage/GoogleAnalytics/etc/config.xml @@ -0,0 +1,93 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + + Mage_GoogleAnalytics.csv + + + + + + + + + Mage_GoogleAnalytics_Model_Observer + setGoogleAnalyticsOnOrderSuccessPageView + + + + + + + Mage_GoogleAnalytics_Model_Observer + setGoogleAnalyticsOnOrderSuccessPageView + + + + + + + Mage_GoogleAnalytics_Model_Observer + injectAnalyticsInGoogleCheckoutLink + + + + + + + + layout.xml + + + + + + + + + + Mage_GoogleAnalytics.csv + + + + + + diff --git a/app/code/core/Mage/GoogleAnalytics/locale/de_DE/Mage_GoogleAnalytics.csv b/app/code/Mage/GoogleAnalytics/locale/de_DE/Mage_GoogleAnalytics.csv similarity index 100% rename from app/code/core/Mage/GoogleAnalytics/locale/de_DE/Mage_GoogleAnalytics.csv rename to app/code/Mage/GoogleAnalytics/locale/de_DE/Mage_GoogleAnalytics.csv diff --git a/app/code/core/Mage/GoogleAnalytics/locale/en_US/Mage_GoogleAnalytics.csv b/app/code/Mage/GoogleAnalytics/locale/en_US/Mage_GoogleAnalytics.csv similarity index 100% rename from app/code/core/Mage/GoogleAnalytics/locale/en_US/Mage_GoogleAnalytics.csv rename to app/code/Mage/GoogleAnalytics/locale/en_US/Mage_GoogleAnalytics.csv diff --git a/app/code/core/Mage/GoogleAnalytics/locale/es_ES/Mage_GoogleAnalytics.csv b/app/code/Mage/GoogleAnalytics/locale/es_ES/Mage_GoogleAnalytics.csv similarity index 100% rename from app/code/core/Mage/GoogleAnalytics/locale/es_ES/Mage_GoogleAnalytics.csv rename to app/code/Mage/GoogleAnalytics/locale/es_ES/Mage_GoogleAnalytics.csv diff --git a/app/code/core/Mage/GoogleAnalytics/locale/fr_FR/Mage_GoogleAnalytics.csv b/app/code/Mage/GoogleAnalytics/locale/fr_FR/Mage_GoogleAnalytics.csv similarity index 100% rename from app/code/core/Mage/GoogleAnalytics/locale/fr_FR/Mage_GoogleAnalytics.csv rename to app/code/Mage/GoogleAnalytics/locale/fr_FR/Mage_GoogleAnalytics.csv diff --git a/app/code/core/Mage/GoogleAnalytics/locale/nl_NL/Mage_GoogleAnalytics.csv b/app/code/Mage/GoogleAnalytics/locale/nl_NL/Mage_GoogleAnalytics.csv similarity index 100% rename from app/code/core/Mage/GoogleAnalytics/locale/nl_NL/Mage_GoogleAnalytics.csv rename to app/code/Mage/GoogleAnalytics/locale/nl_NL/Mage_GoogleAnalytics.csv diff --git a/app/code/core/Mage/GoogleAnalytics/locale/pt_BR/Mage_GoogleAnalytics.csv b/app/code/Mage/GoogleAnalytics/locale/pt_BR/Mage_GoogleAnalytics.csv similarity index 100% rename from app/code/core/Mage/GoogleAnalytics/locale/pt_BR/Mage_GoogleAnalytics.csv rename to app/code/Mage/GoogleAnalytics/locale/pt_BR/Mage_GoogleAnalytics.csv diff --git a/app/code/core/Mage/GoogleAnalytics/locale/zh_CN/Mage_GoogleAnalytics.csv b/app/code/Mage/GoogleAnalytics/locale/zh_CN/Mage_GoogleAnalytics.csv similarity index 100% rename from app/code/core/Mage/GoogleAnalytics/locale/zh_CN/Mage_GoogleAnalytics.csv rename to app/code/Mage/GoogleAnalytics/locale/zh_CN/Mage_GoogleAnalytics.csv diff --git a/app/code/core/Mage/GoogleAnalytics/view/frontend/ga.phtml b/app/code/Mage/GoogleAnalytics/view/frontend/ga.phtml similarity index 93% rename from app/code/core/Mage/GoogleAnalytics/view/frontend/ga.phtml rename to app/code/Mage/GoogleAnalytics/view/frontend/ga.phtml index 88d331ae4729e..075dc721240bc 100644 --- a/app/code/core/Mage/GoogleAnalytics/view/frontend/ga.phtml +++ b/app/code/Mage/GoogleAnalytics/view/frontend/ga.phtml @@ -30,8 +30,8 @@ diff --git a/app/code/Mage/GoogleOptimizer/view/adminhtml/layout.xml b/app/code/Mage/GoogleOptimizer/view/adminhtml/layout.xml new file mode 100644 index 0000000000000..962af62184d5b --- /dev/null +++ b/app/code/Mage/GoogleOptimizer/view/adminhtml/layout.xml @@ -0,0 +1,88 @@ + + + + + + + + + + + googleoptimizertab_googleoptimizer + + + + + + + + + + googleoptimizertab_googleoptimizer + + + + + + + + + + + + + + + + + + + cms_page_edit_tabs + addTab + + googleoptimizer_section + Mage_GoogleOptimizer_Block_Adminhtml_Cms_Page_Edit_Tab_Googleoptimizer + + + + js + googleoptimizer_js + Mage_GoogleOptimizer_Block_Js + + + + + + + + + \ No newline at end of file diff --git a/app/code/Mage/GoogleOptimizer/view/adminhtml/validation-rules.js b/app/code/Mage/GoogleOptimizer/view/adminhtml/validation-rules.js new file mode 100644 index 0000000000000..77bb5e60379d2 --- /dev/null +++ b/app/code/Mage/GoogleOptimizer/view/adminhtml/validation-rules.js @@ -0,0 +1,55 @@ +/** + * GoogleOptimizer client side validation rules + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_GoogleOptimizer + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +(function ($) { + $.validator.addMethod('validate-googleoptimizer', function(v,element) { + var fieldEntry = false, + self = false, + validationResult = true, + elements = $('.validate-googleoptimizer'); + + if (elements.length) { + elements.each(function() { + var elm = $(this); + if ((elm.val() != "none") && (elm.val() != null) && (elm.val().length != 0)) { + fieldEntry = true; + if (elm.prop('id') == element.id) { + self = true; + } + } else { + validationResult = false; + } + }); + } + if (fieldEntry && !validationResult && !self) { + return false; + } + return true; + }, 'This is a required field unless all the fields are empty.'); + $.validator.addMethod('validate-googleoptimizer-attributes', function(v,element) { + return googleOptimizerCheckAttributesCount(element); + }, 'Not more than 8 attributes allowed.'); +})(jQuery); diff --git a/app/code/core/Mage/GoogleOptimizer/view/frontend/layout.xml b/app/code/Mage/GoogleOptimizer/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/GoogleOptimizer/view/frontend/layout.xml rename to app/code/Mage/GoogleOptimizer/view/frontend/layout.xml diff --git a/app/code/core/Mage/GoogleShopping/Block/Adminhtml/Captcha.php b/app/code/Mage/GoogleShopping/Block/Adminhtml/Captcha.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Block/Adminhtml/Captcha.php rename to app/code/Mage/GoogleShopping/Block/Adminhtml/Captcha.php diff --git a/app/code/core/Mage/GoogleShopping/Block/Adminhtml/Items.php b/app/code/Mage/GoogleShopping/Block/Adminhtml/Items.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Block/Adminhtml/Items.php rename to app/code/Mage/GoogleShopping/Block/Adminhtml/Items.php diff --git a/app/code/core/Mage/GoogleShopping/Block/Adminhtml/Items/Item.php b/app/code/Mage/GoogleShopping/Block/Adminhtml/Items/Item.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Block/Adminhtml/Items/Item.php rename to app/code/Mage/GoogleShopping/Block/Adminhtml/Items/Item.php diff --git a/app/code/core/Mage/GoogleShopping/Block/Adminhtml/Items/Product.php b/app/code/Mage/GoogleShopping/Block/Adminhtml/Items/Product.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Block/Adminhtml/Items/Product.php rename to app/code/Mage/GoogleShopping/Block/Adminhtml/Items/Product.php diff --git a/app/code/core/Mage/GoogleShopping/Block/Adminhtml/Items/Renderer/Id.php b/app/code/Mage/GoogleShopping/Block/Adminhtml/Items/Renderer/Id.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Block/Adminhtml/Items/Renderer/Id.php rename to app/code/Mage/GoogleShopping/Block/Adminhtml/Items/Renderer/Id.php diff --git a/app/code/core/Mage/GoogleShopping/Block/Adminhtml/Store/Switcher.php b/app/code/Mage/GoogleShopping/Block/Adminhtml/Store/Switcher.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Block/Adminhtml/Store/Switcher.php rename to app/code/Mage/GoogleShopping/Block/Adminhtml/Store/Switcher.php diff --git a/app/code/core/Mage/GoogleShopping/Block/Adminhtml/Types.php b/app/code/Mage/GoogleShopping/Block/Adminhtml/Types.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Block/Adminhtml/Types.php rename to app/code/Mage/GoogleShopping/Block/Adminhtml/Types.php diff --git a/app/code/core/Mage/GoogleShopping/Block/Adminhtml/Types/Edit.php b/app/code/Mage/GoogleShopping/Block/Adminhtml/Types/Edit.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Block/Adminhtml/Types/Edit.php rename to app/code/Mage/GoogleShopping/Block/Adminhtml/Types/Edit.php diff --git a/app/code/Mage/GoogleShopping/Block/Adminhtml/Types/Edit/Attributes.php b/app/code/Mage/GoogleShopping/Block/Adminhtml/Types/Edit/Attributes.php new file mode 100644 index 0000000000000..0ef8514173eed --- /dev/null +++ b/app/code/Mage/GoogleShopping/Block/Adminhtml/Types/Edit/Attributes.php @@ -0,0 +1,198 @@ + + */ +class Mage_GoogleShopping_Block_Adminhtml_Types_Edit_Attributes + extends Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element +{ + + protected $_template = 'types/edit/attributes.phtml'; + + /** + * Preparing global layout + * + * @return Mage_Core_Block_Abstract + */ + protected function _prepareLayout() + { + $this->addChild('add_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_GoogleShopping_Helper_Data')->__('Add New Attribute'), + 'class' => 'add', + 'id' => 'add_new_attribute', + 'on_click' => 'gContentAttribute.add()' + )); + $this->addChild('delete_button', 'Mage_Adminhtml_Block_Widget_Button', array( + 'label' => Mage::helper('Mage_GoogleShopping_Helper_Data')->__('Remove'), + 'class' => 'delete delete-product-option', + 'on_click' => 'gContentAttribute.remove(event)' + )); + + return parent::_prepareLayout(); + } + + /** + * Get attributes select field id + * + * @return string + */ + public function getFieldId() + { + return 'gcontent_attribute'; + } + + /** + * Get attributes select field name + * + * @return string + */ + public function getFieldName () + { + return 'attributes'; + } + + /** + * Build HTML code for select element which contains all available Google's attributes + * + * @return string + */ + public function getGcontentAttributesSelectHtml() + { + $options[] = array('label' => $this->__('Custom attribute, no mapping')); + + $attributesTree = Mage::getSingleton('Mage_GoogleShopping_Model_Config') + ->getAttributesByCountry($this->getTargetCountry()); + + foreach ($attributesTree as $destination => $attributes) { + $options[] = array( + 'label' => $destination, + 'is_group' => true, + ); + foreach ($attributes as $attribute => $params) { + $options[$attribute] = array('label' => $params['name']); + if ((int)$params['required'] == 1) { + $options[$attribute]['style'] = 'color: #940000;'; + } + } + $options[] = array( + 'is_group' => true, + 'is_close' => true + ); + } + + $select = $this->getLayout()->createBlock('Mage_GoogleShopping_Block_Adminhtml_Types_Edit_Select') + ->setId($this->getFieldId().'_{{index}}_gattribute') + ->setName($this->getFieldName().'[{{index}}][gcontent_attribute]') + ->setOptions($options); + + return $this->_toOneLineString($select->toHtml()); + } + + /** + * Build HTML select element of attribute set attributes + * + * @param boolean $escapeJsQuotes + * @return string + */ + public function getAttributesSelectHtml($escapeJsQuotes = false) + { + $select = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Html_Select') + ->setId($this->getFieldId().'_{{index}}_attribute') + ->setName($this->getFieldName().'[{{index}}][attribute_id]') + ->setOptions($this->_getAttributes($this->getAttributeSetId(), $escapeJsQuotes)); + return $select->getHtml(); + } + + /** + * Get HTML code for button "Add New Attribute" + * + * @return string + */ + public function getAddButtonHtml() + { + return $this->getChildHtml('add_button'); + } + + /** + * Get HTML code for button "Remove" + * + * @return string + */ + public function getDeleteButtonHtml() + { + return $this->getChildHtml('delete_button'); + } + + /** + * Get attributes of an attribute set + * Skip attributes not needed for Google Content + * + * @param int $setId + * @param boolean $escapeJsQuotes + * @return array + */ + public function _getAttributes($setId, $escapeJsQuotes = false) + { + $attributes = Mage::getModel('Mage_GoogleShopping_Model_Attribute')->getAllowedAttributes($setId); + $result = array(); + + foreach ($attributes as $attribute) { + /* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */ + $result[$attribute->getAttributeId()] = $escapeJsQuotes + ? $this->jsQuoteEscape($attribute->getFrontendLabel()) + : $attribute->getFrontendLabel(); + } + return $result; + } + + /** + * Encode the mixed $data into the JSON format + * + * @param mixed $data + * @return string + */ + public function toJson($data) + { + return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($data); + } + + /** + * Format string to one line, cut symbols \n and \r + * + * @param string $string + * @return string + */ + protected function _toOneLineString($string) + { + return str_replace(array("\r\n", "\n", "\r"), "", $string); + } + +} diff --git a/app/code/core/Mage/GoogleShopping/Block/Adminhtml/Types/Edit/Form.php b/app/code/Mage/GoogleShopping/Block/Adminhtml/Types/Edit/Form.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Block/Adminhtml/Types/Edit/Form.php rename to app/code/Mage/GoogleShopping/Block/Adminhtml/Types/Edit/Form.php diff --git a/app/code/core/Mage/GoogleShopping/Block/Adminhtml/Types/Edit/Select.php b/app/code/Mage/GoogleShopping/Block/Adminhtml/Types/Edit/Select.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Block/Adminhtml/Types/Edit/Select.php rename to app/code/Mage/GoogleShopping/Block/Adminhtml/Types/Edit/Select.php diff --git a/app/code/core/Mage/GoogleShopping/Block/Adminhtml/Types/Renderer/Country.php b/app/code/Mage/GoogleShopping/Block/Adminhtml/Types/Renderer/Country.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Block/Adminhtml/Types/Renderer/Country.php rename to app/code/Mage/GoogleShopping/Block/Adminhtml/Types/Renderer/Country.php diff --git a/app/code/core/Mage/GoogleShopping/Helper/Category.php b/app/code/Mage/GoogleShopping/Helper/Category.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Helper/Category.php rename to app/code/Mage/GoogleShopping/Helper/Category.php diff --git a/app/code/core/Mage/GoogleShopping/Helper/Data.php b/app/code/Mage/GoogleShopping/Helper/Data.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Helper/Data.php rename to app/code/Mage/GoogleShopping/Helper/Data.php diff --git a/app/code/core/Mage/GoogleShopping/Helper/Price.php b/app/code/Mage/GoogleShopping/Helper/Price.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Helper/Price.php rename to app/code/Mage/GoogleShopping/Helper/Price.php diff --git a/app/code/core/Mage/GoogleShopping/Helper/Product.php b/app/code/Mage/GoogleShopping/Helper/Product.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Helper/Product.php rename to app/code/Mage/GoogleShopping/Helper/Product.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Attribute.php b/app/code/Mage/GoogleShopping/Model/Attribute.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Attribute.php rename to app/code/Mage/GoogleShopping/Model/Attribute.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Attribute/Availability.php b/app/code/Mage/GoogleShopping/Model/Attribute/Availability.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Attribute/Availability.php rename to app/code/Mage/GoogleShopping/Model/Attribute/Availability.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Attribute/Condition.php b/app/code/Mage/GoogleShopping/Model/Attribute/Condition.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Attribute/Condition.php rename to app/code/Mage/GoogleShopping/Model/Attribute/Condition.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Attribute/Content.php b/app/code/Mage/GoogleShopping/Model/Attribute/Content.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Attribute/Content.php rename to app/code/Mage/GoogleShopping/Model/Attribute/Content.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Attribute/ContentLanguage.php b/app/code/Mage/GoogleShopping/Model/Attribute/ContentLanguage.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Attribute/ContentLanguage.php rename to app/code/Mage/GoogleShopping/Model/Attribute/ContentLanguage.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Attribute/Default.php b/app/code/Mage/GoogleShopping/Model/Attribute/Default.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Attribute/Default.php rename to app/code/Mage/GoogleShopping/Model/Attribute/Default.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Attribute/Destinations.php b/app/code/Mage/GoogleShopping/Model/Attribute/Destinations.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Attribute/Destinations.php rename to app/code/Mage/GoogleShopping/Model/Attribute/Destinations.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Attribute/GoogleProductCategory.php b/app/code/Mage/GoogleShopping/Model/Attribute/GoogleProductCategory.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Attribute/GoogleProductCategory.php rename to app/code/Mage/GoogleShopping/Model/Attribute/GoogleProductCategory.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Attribute/Id.php b/app/code/Mage/GoogleShopping/Model/Attribute/Id.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Attribute/Id.php rename to app/code/Mage/GoogleShopping/Model/Attribute/Id.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Attribute/ImageLink.php b/app/code/Mage/GoogleShopping/Model/Attribute/ImageLink.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Attribute/ImageLink.php rename to app/code/Mage/GoogleShopping/Model/Attribute/ImageLink.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Attribute/Link.php b/app/code/Mage/GoogleShopping/Model/Attribute/Link.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Attribute/Link.php rename to app/code/Mage/GoogleShopping/Model/Attribute/Link.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Attribute/Price.php b/app/code/Mage/GoogleShopping/Model/Attribute/Price.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Attribute/Price.php rename to app/code/Mage/GoogleShopping/Model/Attribute/Price.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Attribute/ProductType.php b/app/code/Mage/GoogleShopping/Model/Attribute/ProductType.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Attribute/ProductType.php rename to app/code/Mage/GoogleShopping/Model/Attribute/ProductType.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Attribute/Quantity.php b/app/code/Mage/GoogleShopping/Model/Attribute/Quantity.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Attribute/Quantity.php rename to app/code/Mage/GoogleShopping/Model/Attribute/Quantity.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Attribute/SalePriceEffectiveDate.php b/app/code/Mage/GoogleShopping/Model/Attribute/SalePriceEffectiveDate.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Attribute/SalePriceEffectiveDate.php rename to app/code/Mage/GoogleShopping/Model/Attribute/SalePriceEffectiveDate.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Attribute/ShippingWeight.php b/app/code/Mage/GoogleShopping/Model/Attribute/ShippingWeight.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Attribute/ShippingWeight.php rename to app/code/Mage/GoogleShopping/Model/Attribute/ShippingWeight.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Attribute/TargetCountry.php b/app/code/Mage/GoogleShopping/Model/Attribute/TargetCountry.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Attribute/TargetCountry.php rename to app/code/Mage/GoogleShopping/Model/Attribute/TargetCountry.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Attribute/Tax.php b/app/code/Mage/GoogleShopping/Model/Attribute/Tax.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Attribute/Tax.php rename to app/code/Mage/GoogleShopping/Model/Attribute/Tax.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Attribute/Title.php b/app/code/Mage/GoogleShopping/Model/Attribute/Title.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Attribute/Title.php rename to app/code/Mage/GoogleShopping/Model/Attribute/Title.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Config.php b/app/code/Mage/GoogleShopping/Model/Config.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Config.php rename to app/code/Mage/GoogleShopping/Model/Config.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Flag.php b/app/code/Mage/GoogleShopping/Model/Flag.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Flag.php rename to app/code/Mage/GoogleShopping/Model/Flag.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Item.php b/app/code/Mage/GoogleShopping/Model/Item.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Item.php rename to app/code/Mage/GoogleShopping/Model/Item.php diff --git a/app/code/core/Mage/GoogleShopping/Model/MassOperations.php b/app/code/Mage/GoogleShopping/Model/MassOperations.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/MassOperations.php rename to app/code/Mage/GoogleShopping/Model/MassOperations.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Observer.php b/app/code/Mage/GoogleShopping/Model/Observer.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Observer.php rename to app/code/Mage/GoogleShopping/Model/Observer.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Resource/Attribute.php b/app/code/Mage/GoogleShopping/Model/Resource/Attribute.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Resource/Attribute.php rename to app/code/Mage/GoogleShopping/Model/Resource/Attribute.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Resource/Attribute/Collection.php b/app/code/Mage/GoogleShopping/Model/Resource/Attribute/Collection.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Resource/Attribute/Collection.php rename to app/code/Mage/GoogleShopping/Model/Resource/Attribute/Collection.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Resource/Grid/Collection.php b/app/code/Mage/GoogleShopping/Model/Resource/Grid/Collection.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Resource/Grid/Collection.php rename to app/code/Mage/GoogleShopping/Model/Resource/Grid/Collection.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Resource/Item.php b/app/code/Mage/GoogleShopping/Model/Resource/Item.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Resource/Item.php rename to app/code/Mage/GoogleShopping/Model/Resource/Item.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Resource/Item/Collection.php b/app/code/Mage/GoogleShopping/Model/Resource/Item/Collection.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Resource/Item/Collection.php rename to app/code/Mage/GoogleShopping/Model/Resource/Item/Collection.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Resource/Type.php b/app/code/Mage/GoogleShopping/Model/Resource/Type.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Resource/Type.php rename to app/code/Mage/GoogleShopping/Model/Resource/Type.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Resource/Type/Collection.php b/app/code/Mage/GoogleShopping/Model/Resource/Type/Collection.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Resource/Type/Collection.php rename to app/code/Mage/GoogleShopping/Model/Resource/Type/Collection.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Service.php b/app/code/Mage/GoogleShopping/Model/Service.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Service.php rename to app/code/Mage/GoogleShopping/Model/Service.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Service/Item.php b/app/code/Mage/GoogleShopping/Model/Service/Item.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Service/Item.php rename to app/code/Mage/GoogleShopping/Model/Service/Item.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Source/Accounttype.php b/app/code/Mage/GoogleShopping/Model/Source/Accounttype.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Source/Accounttype.php rename to app/code/Mage/GoogleShopping/Model/Source/Accounttype.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Source/Authtype.php b/app/code/Mage/GoogleShopping/Model/Source/Authtype.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Source/Authtype.php rename to app/code/Mage/GoogleShopping/Model/Source/Authtype.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Source/Country.php b/app/code/Mage/GoogleShopping/Model/Source/Country.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Source/Country.php rename to app/code/Mage/GoogleShopping/Model/Source/Country.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Source/Destinationstates.php b/app/code/Mage/GoogleShopping/Model/Source/Destinationstates.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Source/Destinationstates.php rename to app/code/Mage/GoogleShopping/Model/Source/Destinationstates.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Source/Statuses.php b/app/code/Mage/GoogleShopping/Model/Source/Statuses.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Source/Statuses.php rename to app/code/Mage/GoogleShopping/Model/Source/Statuses.php diff --git a/app/code/core/Mage/GoogleShopping/Model/Type.php b/app/code/Mage/GoogleShopping/Model/Type.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/Model/Type.php rename to app/code/Mage/GoogleShopping/Model/Type.php diff --git a/app/code/core/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/ItemsController.php b/app/code/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/ItemsController.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/ItemsController.php rename to app/code/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/ItemsController.php diff --git a/app/code/core/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/SelectionController.php b/app/code/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/SelectionController.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/SelectionController.php rename to app/code/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/SelectionController.php diff --git a/app/code/core/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/TypesController.php b/app/code/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/TypesController.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/TypesController.php rename to app/code/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/TypesController.php diff --git a/app/code/core/Mage/GoogleShopping/data/googleshopping_setup/data-install-1.6.0.0.php b/app/code/Mage/GoogleShopping/data/googleshopping_setup/data-install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/data/googleshopping_setup/data-install-1.6.0.0.php rename to app/code/Mage/GoogleShopping/data/googleshopping_setup/data-install-1.6.0.0.php diff --git a/app/code/Mage/GoogleShopping/etc/adminhtml/acl.xml b/app/code/Mage/GoogleShopping/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..a7751e0ad3c86 --- /dev/null +++ b/app/code/Mage/GoogleShopping/etc/adminhtml/acl.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + diff --git a/app/code/Mage/GoogleShopping/etc/adminhtml/menu.xml b/app/code/Mage/GoogleShopping/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..3cfee2a4aee58 --- /dev/null +++ b/app/code/Mage/GoogleShopping/etc/adminhtml/menu.xml @@ -0,0 +1,34 @@ + + + + + + + + + diff --git a/app/code/core/Mage/GoogleShopping/etc/adminhtml/system.xml b/app/code/Mage/GoogleShopping/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/GoogleShopping/etc/adminhtml/system.xml rename to app/code/Mage/GoogleShopping/etc/adminhtml/system.xml diff --git a/app/code/Mage/GoogleShopping/etc/config.xml b/app/code/Mage/GoogleShopping/etc/config.xml new file mode 100644 index 0000000000000..49f43b349b823 --- /dev/null +++ b/app/code/Mage/GoogleShopping/etc/config.xml @@ -0,0 +1,382 @@ + + + + + + 1.6.0.0.1 + true + + + + + + + + + + Mage_GoogleShopping + + + + + + + + + + Mage_GoogleShopping_Adminhtml + + + + + + + + + + + Mage_GoogleShopping.csv + + + + + + + + + Mage_GoogleShopping_Model_Observer + saveProductItem + + + + + + + Mage_GoogleShopping_Model_Observer + deleteProductItem + + + + + + + Mage_GoogleShopping_Model_Observer + checkSynchronizationOperations + + + + + + + + layout.xml + + + + + + + + US + HOSTED_OR_GOOGLE + + + + + Australia + en + AUD + Australian Dollar + +
    + Brazil + pt + pt_BR + BRL + Brazilian Real +
    + + China + zh_CN + CNY + Chinese Yuan Renminbi + + + France + fr + EUR + Euro + + + Germany + de + de_DE + EUR + Euro + + + Italy + it + EUR + Euro + + + Japan + ja + JPY + Japanese Yen + + + Netherlands + nl + EUR + Euro + + + Spain + es + EUR + Euro + + + Switzerland + de + de_CH + CHF + Swiss Franc + + + United Kingdom + en + en_GB + GBP + British Pound Sterling + + + United States + en + en_US + USD + US Dollar + +
    + + + ProductSearch + ProductAds + CommerceSearch + + + + + + + <name>Title</name> + <required>1</required> + + + Description + 1 + + + Expiration date + 0 + + + Adult + 0 + + + + + Condition + 1 + + + Price + 1 + + + Sale Price + 0 + US + + + Sale Price Effective From Date + 0 + US + + + Sale Price Effective To Date + 0 + US + + + Age Group + 1 + + + Brand + 1 + + + Color + 1 + + + Gender + 1 + + + Manufacturer\'s Part Number (MPN) + 1 + + + Online Only + 0 + + + GTIN + 1 + + + Product Type (Category) + 0 + + + Product Review Average + 0 + + + Product Review Count + 0 + + + Shipping Weight + 0 + + + Size + 1 + + + Material + 1 + + + Pattern/Graphic + 1 + + + + + Grouping + 0 + + + Labels + 0 + + + Redirect + 0 + + + Query Param + 0 + + + + + + + + + + + + + + + + + <name/> + + + + + + + + + + <link/> + <content/> + <price/> + <image_link/> + <condition/> + <target_country/> + <content_language/> + <destinations/> + <availability/> + <google_product_category/> + <product_type/> + </base_attributes> + </googleshopping> + </google> + </default> +</config> diff --git a/app/code/core/Mage/GoogleShopping/locale/en_US/Mage_GoogleShopping.csv b/app/code/Mage/GoogleShopping/locale/en_US/Mage_GoogleShopping.csv similarity index 100% rename from app/code/core/Mage/GoogleShopping/locale/en_US/Mage_GoogleShopping.csv rename to app/code/Mage/GoogleShopping/locale/en_US/Mage_GoogleShopping.csv diff --git a/app/code/core/Mage/GoogleShopping/sql/googleshopping_setup/install-1.6.0.0.php b/app/code/Mage/GoogleShopping/sql/googleshopping_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/sql/googleshopping_setup/install-1.6.0.0.php rename to app/code/Mage/GoogleShopping/sql/googleshopping_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/GoogleShopping/sql/googleshopping_setup/upgrade-1.6.0.0-1.6.0.0.1.php b/app/code/Mage/GoogleShopping/sql/googleshopping_setup/upgrade-1.6.0.0-1.6.0.0.1.php similarity index 100% rename from app/code/core/Mage/GoogleShopping/sql/googleshopping_setup/upgrade-1.6.0.0-1.6.0.0.1.php rename to app/code/Mage/GoogleShopping/sql/googleshopping_setup/upgrade-1.6.0.0-1.6.0.0.1.php diff --git a/app/code/core/Mage/GoogleShopping/view/adminhtml/captcha.phtml b/app/code/Mage/GoogleShopping/view/adminhtml/captcha.phtml similarity index 100% rename from app/code/core/Mage/GoogleShopping/view/adminhtml/captcha.phtml rename to app/code/Mage/GoogleShopping/view/adminhtml/captcha.phtml diff --git a/app/code/core/Mage/GoogleShopping/view/adminhtml/googleshopping.js b/app/code/Mage/GoogleShopping/view/adminhtml/googleshopping.js similarity index 100% rename from app/code/core/Mage/GoogleShopping/view/adminhtml/googleshopping.js rename to app/code/Mage/GoogleShopping/view/adminhtml/googleshopping.js diff --git a/app/code/core/Mage/GoogleShopping/view/adminhtml/items.phtml b/app/code/Mage/GoogleShopping/view/adminhtml/items.phtml similarity index 100% rename from app/code/core/Mage/GoogleShopping/view/adminhtml/items.phtml rename to app/code/Mage/GoogleShopping/view/adminhtml/items.phtml diff --git a/app/code/core/Mage/GoogleShopping/view/adminhtml/layout.xml b/app/code/Mage/GoogleShopping/view/adminhtml/layout.xml similarity index 100% rename from app/code/core/Mage/GoogleShopping/view/adminhtml/layout.xml rename to app/code/Mage/GoogleShopping/view/adminhtml/layout.xml diff --git a/app/code/core/Mage/GoogleShopping/view/adminhtml/types/edit.phtml b/app/code/Mage/GoogleShopping/view/adminhtml/types/edit.phtml similarity index 100% rename from app/code/core/Mage/GoogleShopping/view/adminhtml/types/edit.phtml rename to app/code/Mage/GoogleShopping/view/adminhtml/types/edit.phtml diff --git a/app/code/Mage/GoogleShopping/view/adminhtml/types/edit/attributes.phtml b/app/code/Mage/GoogleShopping/view/adminhtml/types/edit/attributes.phtml new file mode 100644 index 0000000000000..559b5178a28b0 --- /dev/null +++ b/app/code/Mage/GoogleShopping/view/adminhtml/types/edit/attributes.phtml @@ -0,0 +1,129 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category design + * @package default_default + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> + +<?php if ($this->getAttributeSetSelected()): ?> +<script type="text/javascript"> +//<![CDATA[ +Gcontent = {}; +Gcontent.Attribute = Class.create(); +Gcontent.Attribute.prototype = { + idLabel : '<?php echo $this->getFieldId() ?>', + top : '', + templateSyntax : /(^|.|\r|\n)({{(\w+)}})/, + templateText : '', + itemsCount : 0, + initialize : function(template) { + this.templateText = template; + this.top = $('gcontent_attribute_top'); + }, + + add : function(data) { + if(!data){ + data = {}; + } + this.top = $('gcontent_attribute_top'); + + data.index = this.itemsCount++; + this.template = new Template(this.templateText, this.templateSyntax); + Element.insert(this.top, {'bottom':this.template.evaluate(data)}); + this.top = $(this.idLabel + '_' + data.index); + + //set selected type + if (data.attribute_id) { + $A($(this.idLabel + '_'+data.index+'_attribute').options).each(function(option){ + if (option.value==data.attribute_id) option.selected = true; + }); + } + + //set selected is_require + if (data.gcontent_attribute) { + $A($(this.idLabel + '_'+data.index+'_gattribute').options).each(function(option){ + if (option.value==data.gcontent_attribute) option.selected = true; + }); + } + return data.index; + }, + + remove : function(event) { + var element = $(Event.findElement(event, 'tr')); + if(element){ + Element.select(element, '.delete').each(function(elem){elem.value='1'}); + Element.select(element, ['input', 'select']).each(function(elem){elem.hide(); elem.className = '';}); + Element.hide(element); + } + } +} + +var attributesSelectTemplate = '<tr id="<?php echo $this->getFieldId() ?>_{{index}}">' + + '<td>'+ + '<?php echo $this->getAttributesSelectHtml(true) ?>' + + '<input type="hidden" name="<?php echo $this->getFieldName() ?>[{{index}}][delete]" value="">' + + '</td>' + + '<td><?php echo $this->getGcontentAttributesSelectHtml() ?></td>' + + '<td class="col-delete">' + <?php echo Mage::helper('Mage_Core_Helper_Data')->jsonEncode($this->getDeleteButtonHtml()) ?> + '</td>' + + '</tr>'; + +var optionIndex = 0; +gContentAttribute = new Gcontent.Attribute(attributesSelectTemplate); +//]]> +</script> + +<div id="gcontent_attributes_container"> + <table class="data-table" id="gcontent_attribute"> + <thead> + <tr> + <th class="col-type"><?php echo Mage::helper('Mage_GoogleShopping_Helper_Data')->__('Attribute') ?></th> + <th class="col-req"><?php echo Mage::helper('Mage_GoogleShopping_Helper_Data')->__('Google Content Attribute') ?></th> + <th class="col-actions"><?php echo Mage::helper('Mage_GoogleShopping_Helper_Data')->__('Action') ?></th> + </tr> + </thead> + <tbody id="gcontent_attribute_top"> + + </tbody> + <tfoot> + <tr> + <td colspan="3"> + <?php echo $this->getAddButtonHtml() ?> + </td> + </tr> + </tfoot> + </table> +</div> + +<?php if ($this->getAttributesData()): ?> +<script type="text/javascript"> +//<![CDATA[ + <?php foreach ($this->getAttributesData() as $data): ?> + gContentAttribute.add(<?php echo $this->toJson($data) ?>); + <?php endforeach; ?> +//]]> +</script> +<?php endif; ?> + +<?php else: ?> + <?php echo Mage::helper('Mage_GoogleShopping_Helper_Data')->__("Please, select Attribute Set to load attributes") ?> +<?php endif; ?> diff --git a/app/code/core/Mage/GoogleShopping/view/adminhtml/types/edit/select.phtml b/app/code/Mage/GoogleShopping/view/adminhtml/types/edit/select.phtml similarity index 100% rename from app/code/core/Mage/GoogleShopping/view/adminhtml/types/edit/select.phtml rename to app/code/Mage/GoogleShopping/view/adminhtml/types/edit/select.phtml diff --git a/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Edit.php b/app/code/Mage/ImportExport/Block/Adminhtml/Export/Edit.php similarity index 100% rename from app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Edit.php rename to app/code/Mage/ImportExport/Block/Adminhtml/Export/Edit.php diff --git a/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Edit/Form.php b/app/code/Mage/ImportExport/Block/Adminhtml/Export/Edit/Form.php similarity index 100% rename from app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Edit/Form.php rename to app/code/Mage/ImportExport/Block/Adminhtml/Export/Edit/Form.php diff --git a/app/code/Mage/ImportExport/Block/Adminhtml/Export/Filter.php b/app/code/Mage/ImportExport/Block/Adminhtml/Export/Filter.php new file mode 100644 index 0000000000000..124bf7e4638b9 --- /dev/null +++ b/app/code/Mage/ImportExport/Block/Adminhtml/Export/Filter.php @@ -0,0 +1,354 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_ImportExport + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Export filter block + * + * @category Mage + * @package Mage_ImportExport + * @author Magento Core Team <core@magentocommerce.com> + */ +class Mage_ImportExport_Block_Adminhtml_Export_Filter extends Mage_Adminhtml_Block_Widget_Grid +{ + /** + * Helper object. + * + * @var Mage_Core_Helper_Abstract + */ + protected $_helper; + + /** + * Set grid parameters. + */ + protected function _construct() + { + parent::_construct(); + + $this->_helper = Mage::helper('Mage_ImportExport_Helper_Data'); + + $this->setRowClickCallback(null); + $this->setId('export_filter_grid'); + $this->setDefaultSort('attribute_code'); + $this->setDefaultDir('ASC'); + $this->setPagerVisibility(false); + $this->setDefaultLimit(null); + $this->setUseAjax(true); + } + + /** + * Date 'from-to' filter HTML with values + * + * @param Mage_Eav_Model_Entity_Attribute $attribute + * @param mixed $value + * @return string + */ + protected function _getDateFromToHtmlWithValue(Mage_Eav_Model_Entity_Attribute $attribute, $value) + { + $arguments = array( + 'name' => $this->getFilterElementName($attribute->getAttributeCode()) . '[]', + 'id' => $this->getFilterElementId($attribute->getAttributeCode()), + 'class' => 'input-text input-text-range-date', + 'date_format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT), + 'image' => $this->getViewFileUrl('images/grid-cal.gif') + ); + /** @var $selectBlock Mage_Core_Block_Html_Date */ + $dateBlock = $this->_layout->getBlockFactory()->createBlock( + 'Mage_Core_Block_Html_Date', array('data' => $arguments) + ); + $fromValue = null; + $toValue = null; + if (is_array($value) && count($value) == 2) { + $fromValue = $this->_helper->escapeHtml(reset($value)); + $toValue = $this->_helper->escapeHtml(next($value)); + } + + + return '<strong>' . Mage::helper('Mage_ImportExport_Helper_Data')->__('From') . ':</strong> ' + . $dateBlock->setValue($fromValue)->getHtml() + . ' <strong>' . Mage::helper('Mage_ImportExport_Helper_Data')->__('To') . ':</strong> ' + . $dateBlock->setId($dateBlock->getId() . '_to')->setValue($toValue)->getHtml(); + } + + /** + * Input text filter HTML with value + * + * @param Mage_Eav_Model_Entity_Attribute $attribute + * @param mixed $value + * @return string + */ + protected function _getInputHtmlWithValue(Mage_Eav_Model_Entity_Attribute $attribute, $value) + { + $html = '<input type="text" name="' . $this->getFilterElementName($attribute->getAttributeCode()) + . '" class="input-text input-text-export-filter"'; + if ($value) { + $html .= ' value="' . $this->_helper->escapeHtml($value) . '"'; + } + + return $html . ' />'; + } + + /** + * Multiselect field filter HTML with selected values + * + * @param Mage_Eav_Model_Entity_Attribute $attribute + * @param mixed $value + * @return string + */ + protected function _getMultiSelectHtmlWithValue(Mage_Eav_Model_Entity_Attribute $attribute, $value) + { + if ($attribute->getFilterOptions()) { + $options = $attribute->getFilterOptions(); + } else { + $options = $attribute->getSource()->getAllOptions(false); + + foreach ($options as $key => $optionParams) { + if ('' === $optionParams['value']) { + unset($options[$key]); + break; + } + } + } + if (($size = count($options))) { + $arguments = array( + 'name' => $this->getFilterElementName($attribute->getAttributeCode()). '[]', + 'id' => $this->getFilterElementId($attribute->getAttributeCode()), + 'class' => 'multiselect multiselect-export-filter', + 'extra_params' => 'multiple="multiple" size="' . ($size > 5 ? 5 : ($size < 2 ? 2 : $size)) + ); + /** @var $selectBlock Mage_Core_Block_Html_Select */ + $selectBlock = $this->_layout->getBlockFactory()->createBlock( + 'Mage_Core_Block_Html_Select', array('data' => $arguments) + ); + return $selectBlock->setOptions($options) + ->setValue($value) + ->getHtml(); + } else { + return Mage::helper('Mage_ImportExport_Helper_Data') + ->__('Attribute does not has options, so filtering is impossible'); + } + } + + /** + * Number 'from-to' field filter HTML with selected value. + * + * @param Mage_Eav_Model_Entity_Attribute $attribute + * @param mixed $value + * @return string + */ + protected function _getNumberFromToHtmlWithValue(Mage_Eav_Model_Entity_Attribute $attribute, $value) + { + $fromValue = null; + $toValue = null; + $name = $this->getFilterElementName($attribute->getAttributeCode()); + if (is_array($value) && count($value) == 2) { + $fromValue = $this->_helper->escapeHtml(reset($value)); + $toValue = $this->_helper->escapeHtml(next($value)); + } + + return '<strong>' . Mage::helper('Mage_ImportExport_Helper_Data')->__('From') . ':</strong> ' + . '<input type="text" name="' . $name . '[]" class="input-text input-text-range"' + . ' value="' . $fromValue . '"/> ' + . '<strong>' . Mage::helper('Mage_ImportExport_Helper_Data')->__('To') + . ':</strong> <input type="text" name="' . $name + . '[]" class="input-text input-text-range" value="' . $toValue . '" />'; + } + + /** + * Select field filter HTML with selected value. + * + * @param Mage_Eav_Model_Entity_Attribute $attribute + * @param mixed $value + * @return string + */ + protected function _getSelectHtmlWithValue(Mage_Eav_Model_Entity_Attribute $attribute, $value) + { + if ($attribute->getFilterOptions()) { + $options = array(); + + foreach ($attribute->getFilterOptions() as $value => $label) { + $options[] = array('value' => $value, 'label' => $label); + } + } else { + $options = $attribute->getSource()->getAllOptions(false); + } + if (($size = count($options))) { + // add empty vaue option + $firstOption = reset($options); + + if ('' === $firstOption['value']) { + $options[key($options)]['label'] = ''; + } else { + array_unshift($options, array('value' => '', 'label' => '')); + } + $arguments = array( + 'name' => $this->getFilterElementName($attribute->getAttributeCode()), + 'id' => $this->getFilterElementId($attribute->getAttributeCode()), + 'class' => 'select select-export-filter' + ); + /** @var $selectBlock Mage_Core_Block_Html_Select */ + $selectBlock = $this->_layout->getBlockFactory()->createBlock( + 'Mage_Core_Block_Html_Select', array('data' => $arguments) + ); + return $selectBlock->setOptions($options) + ->setValue($value) + ->getHtml(); + } else { + return Mage::helper('Mage_ImportExport_Helper_Data') + ->__('Attribute does not has options, so filtering is impossible'); + } + } + + /** + * Add columns to grid + * + * @return Mage_ImportExport_Block_Adminhtml_Export_Filter + */ + protected function _prepareColumns() + { + parent::_prepareColumns(); + + $this->addColumn('skip', array( + 'header' => Mage::helper('Mage_ImportExport_Helper_Data')->__('Skip'), + 'type' => 'checkbox', + 'name' => 'skip', + 'field_name' => Mage_ImportExport_Model_Export::FILTER_ELEMENT_SKIP . '[]', + 'filter' => false, + 'sortable' => false, + 'align' => 'center', + 'index' => 'attribute_id' + )); + $this->addColumn('frontend_label', array( + 'header' => Mage::helper('Mage_ImportExport_Helper_Data')->__('Attribute Label'), + 'index' => 'frontend_label', + 'sortable' => false, + )); + $this->addColumn('attribute_code', array( + 'header' => Mage::helper('Mage_ImportExport_Helper_Data')->__('Attribute Code'), + 'index' => 'attribute_code' + )); + $this->addColumn('filter', array( + 'header' => Mage::helper('Mage_ImportExport_Helper_Data')->__('Filter'), + 'sortable' => false, + 'filter' => false, + 'frame_callback' => array($this, 'decorateFilter') + )); + + if ($this->hasOperation()) { + $operation = $this->getOperation(); + $skipAttr = $operation->getSkipAttr(); + if ($skipAttr) { + $this->getColumn('skip') + ->setData('values', $skipAttr); + } + $filter = $operation->getExportFilter(); + if ($filter) { + $this->getColumn('filter') + ->setData('values', $filter); + } + } + + return $this; + } + + /** + * Create filter fields for 'Filter' column. + * + * @param mixed $value + * @param Mage_Eav_Model_Entity_Attribute $row + * @param Varien_Object $column + * @param boolean $isExport + * @return string + */ + public function decorateFilter($value, Mage_Eav_Model_Entity_Attribute $row, Varien_Object $column, $isExport) + { + $value = null; + $values = $column->getValues(); + if (is_array($values) && isset($values[$row->getAttributeCode()])) { + $value = $values[$row->getAttributeCode()]; + } + switch (Mage_ImportExport_Model_Export::getAttributeFilterType($row)) { + case Mage_ImportExport_Model_Export::FILTER_TYPE_SELECT: + $cell = $this->_getSelectHtmlWithValue($row, $value); + break; + case Mage_ImportExport_Model_Export::FILTER_TYPE_INPUT: + $cell = $this->_getInputHtmlWithValue($row, $value); + break; + case Mage_ImportExport_Model_Export::FILTER_TYPE_DATE: + $cell = $this->_getDateFromToHtmlWithValue($row, $value); + break; + case Mage_ImportExport_Model_Export::FILTER_TYPE_NUMBER: + $cell = $this->_getNumberFromToHtmlWithValue($row, $value); + break; + default: + $cell = Mage::helper('Mage_ImportExport_Helper_Data')->__('Unknown attribute filter type'); + } + return $cell; + } + + /** + * Element filter ID getter. + * + * @param string $attributeCode + * @return string + */ + public function getFilterElementId($attributeCode) + { + return Mage_ImportExport_Model_Export::FILTER_ELEMENT_GROUP . "_{$attributeCode}"; + } + + /** + * Element filter full name getter. + * + * @param string $attributeCode + * @return string + */ + public function getFilterElementName($attributeCode) + { + return Mage_ImportExport_Model_Export::FILTER_ELEMENT_GROUP . "[{$attributeCode}]"; + } + + /** + * Get row edit URL. + * + * @return string|boolean + */ + public function getRowUrl($row) + { + return false; + } + + /** + * Prepare collection by setting page number, sorting etc.. + * + * @param Varien_Data_Collection $collection + * @return Mage_Eav_Model_Resource_Entity_Attribute_Collection + */ + public function prepareCollection(Varien_Data_Collection $collection) + { + $this->setCollection($collection); + return $this->getCollection(); + } +} diff --git a/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Edit.php b/app/code/Mage/ImportExport/Block/Adminhtml/Import/Edit.php similarity index 100% rename from app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Edit.php rename to app/code/Mage/ImportExport/Block/Adminhtml/Import/Edit.php diff --git a/app/code/Mage/ImportExport/Block/Adminhtml/Import/Edit/Before.php b/app/code/Mage/ImportExport/Block/Adminhtml/Import/Edit/Before.php new file mode 100644 index 0000000000000..4a0c7e8192e53 --- /dev/null +++ b/app/code/Mage/ImportExport/Block/Adminhtml/Import/Edit/Before.php @@ -0,0 +1,92 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_ImportExport + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Block before edit form + * + * @category Mage + * @package Mage_ImportExport + * @author Magento Core Team <core@magentocommerce.com> + */ +class Mage_ImportExport_Block_Adminhtml_Import_Edit_Before extends Mage_Backend_Block_Template +{ + /** + * Core helper + * + * @var Mage_Core_Helper_Data + */ + protected $_coreHelper; + + /** + * Basic import model + * + * @var Mage_ImportExport_Model_Import + */ + protected $_importModel; + + /** + * @param Mage_Core_Block_Template_Context $context + * @param Mage_Core_Helper_Data $coreHelper + * @param Mage_ImportExport_Model_Import $importModel + * @param array $data + */ + public function __construct( Mage_Core_Block_Template_Context $context, + Mage_Core_Helper_Data $coreHelper, + Mage_ImportExport_Model_Import $importModel, + array $data = array() + ) { + parent::__construct($context, $data); + $this->_coreHelper = $coreHelper; + $this->_importModel = $importModel; + } + + /** + * Returns json-encoded entity behaviors array + * + * @return string + */ + public function getEntityBehaviors() + { + $importModel = $this->_importModel; + $behaviors = $importModel::getEntityBehaviors(); + foreach ($behaviors as $entityCode => $behavior) { + $behaviors[$entityCode] = $behavior['code']; + } + return $this->_coreHelper->jsonEncode($behaviors); + } + + /** + * Return json-encoded list of existing behaviors + * + * @return string + */ + public function getUniqueBehaviors() + { + $importModel = $this->_importModel; + $uniqueBehaviors = $importModel::getUniqueEntityBehaviors(); + return $this->_coreHelper->jsonEncode(array_keys($uniqueBehaviors)); + } +} diff --git a/app/code/Mage/ImportExport/Block/Adminhtml/Import/Edit/Form.php b/app/code/Mage/ImportExport/Block/Adminhtml/Import/Edit/Form.php new file mode 100644 index 0000000000000..efbc05c7ae7d1 --- /dev/null +++ b/app/code/Mage/ImportExport/Block/Adminhtml/Import/Edit/Form.php @@ -0,0 +1,105 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_ImportExport + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Import edit form block + * + * @category Mage + * @package Mage_ImportExport + * @author Magento Core Team <core@magentocommerce.com> + */ +class Mage_ImportExport_Block_Adminhtml_Import_Edit_Form extends Mage_Adminhtml_Block_Widget_Form +{ + /** + * Add fieldsets + * + * @return Mage_ImportExport_Block_Adminhtml_Import_Edit_Form + */ + protected function _prepareForm() + { + $helper = Mage::helper('Mage_ImportExport_Helper_Data'); + $form = new Varien_Data_Form(array( + 'id' => 'edit_form', + 'action' => $this->getUrl('*/*/validate'), + 'method' => 'post', + 'enctype' => 'multipart/form-data' + )); + + // base fieldset + /** @var $importEntity Mage_ImportExport_Model_Source_Import_Entity */ + $importEntity = Mage::getModel('Mage_ImportExport_Model_Source_Import_Entity'); + $fieldsets['base'] = $form->addFieldset('base_fieldset', array('legend' => $helper->__('Import Settings'))); + $fieldsets['base']->addField('entity', 'select', array( + 'name' => 'entity', + 'title' => $helper->__('Entity Type'), + 'label' => $helper->__('Entity Type'), + 'required' => true, + 'onchange' => 'varienImport.handleEntityTypeSelector();', + 'values' => $importEntity->toOptionArray() + )); + + // add behaviour fieldsets + $uniqueBehaviors = Mage_ImportExport_Model_Import::getUniqueEntityBehaviors(); + foreach ($uniqueBehaviors as $behaviorCode => $behaviorClass) { + $fieldsets[$behaviorCode] = $form->addFieldset( + $behaviorCode . '_fieldset', + array( + 'legend' => $helper->__('Import Behavior'), + 'style' => 'display:none', + ) + ); + /** @var $behaviorSource Mage_ImportExport_Model_Source_Import_BehaviorAbstract */ + $behaviorSource = Mage::getModel($behaviorClass); + $fieldsets[$behaviorCode]->addField($behaviorCode, 'select', array( + 'name' => 'behavior', + 'title' => $helper->__('Import Behavior'), + 'label' => $helper->__('Import Behavior'), + 'required' => true, + 'disabled' => true, + 'values' => $behaviorSource->toOptionArray() + )); + } + + // fieldset for file uploading + $fieldsets['upload'] = $form->addFieldset('upload_file_fieldset', + array( + 'legend' => $helper->__('File to Import'), + 'style' => 'display:none' + ) + ); + $fieldsets['upload']->addField(Mage_ImportExport_Model_Import::FIELD_NAME_SOURCE_FILE, 'file', array( + 'name' => Mage_ImportExport_Model_Import::FIELD_NAME_SOURCE_FILE, + 'label' => $helper->__('Select File to Import'), + 'title' => $helper->__('Select File to Import'), + 'required' => true + )); + + $form->setUseContainer(true); + $this->setForm($form); + + return parent::_prepareForm(); + } +} diff --git a/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Frame/Result.php b/app/code/Mage/ImportExport/Block/Adminhtml/Import/Frame/Result.php similarity index 100% rename from app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Frame/Result.php rename to app/code/Mage/ImportExport/Block/Adminhtml/Import/Frame/Result.php diff --git a/app/code/core/Mage/ImportExport/Helper/Data.php b/app/code/Mage/ImportExport/Helper/Data.php similarity index 100% rename from app/code/core/Mage/ImportExport/Helper/Data.php rename to app/code/Mage/ImportExport/Helper/Data.php diff --git a/app/code/core/Mage/ImportExport/Model/Abstract.php b/app/code/Mage/ImportExport/Model/Abstract.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Abstract.php rename to app/code/Mage/ImportExport/Model/Abstract.php diff --git a/app/code/core/Mage/ImportExport/Model/Config.php b/app/code/Mage/ImportExport/Model/Config.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Config.php rename to app/code/Mage/ImportExport/Model/Config.php diff --git a/app/code/core/Mage/ImportExport/Model/Export.php b/app/code/Mage/ImportExport/Model/Export.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Export.php rename to app/code/Mage/ImportExport/Model/Export.php diff --git a/app/code/core/Mage/ImportExport/Model/Export/Adapter/Abstract.php b/app/code/Mage/ImportExport/Model/Export/Adapter/Abstract.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Export/Adapter/Abstract.php rename to app/code/Mage/ImportExport/Model/Export/Adapter/Abstract.php diff --git a/app/code/core/Mage/ImportExport/Model/Export/Adapter/Csv.php b/app/code/Mage/ImportExport/Model/Export/Adapter/Csv.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Export/Adapter/Csv.php rename to app/code/Mage/ImportExport/Model/Export/Adapter/Csv.php diff --git a/app/code/core/Mage/ImportExport/Model/Export/Entity/Abstract.php b/app/code/Mage/ImportExport/Model/Export/Entity/Abstract.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Export/Entity/Abstract.php rename to app/code/Mage/ImportExport/Model/Export/Entity/Abstract.php diff --git a/app/code/core/Mage/ImportExport/Model/Export/Entity/Eav/Customer.php b/app/code/Mage/ImportExport/Model/Export/Entity/Eav/Customer.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Export/Entity/Eav/Customer.php rename to app/code/Mage/ImportExport/Model/Export/Entity/Eav/Customer.php diff --git a/app/code/core/Mage/ImportExport/Model/Export/Entity/Eav/Customer/Address.php b/app/code/Mage/ImportExport/Model/Export/Entity/Eav/Customer/Address.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Export/Entity/Eav/Customer/Address.php rename to app/code/Mage/ImportExport/Model/Export/Entity/Eav/Customer/Address.php diff --git a/app/code/core/Mage/ImportExport/Model/Export/Entity/EavAbstract.php b/app/code/Mage/ImportExport/Model/Export/Entity/EavAbstract.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Export/Entity/EavAbstract.php rename to app/code/Mage/ImportExport/Model/Export/Entity/EavAbstract.php diff --git a/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php b/app/code/Mage/ImportExport/Model/Export/Entity/Product.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php rename to app/code/Mage/ImportExport/Model/Export/Entity/Product.php diff --git a/app/code/core/Mage/ImportExport/Model/Export/Entity/Product/Type/Abstract.php b/app/code/Mage/ImportExport/Model/Export/Entity/Product/Type/Abstract.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Export/Entity/Product/Type/Abstract.php rename to app/code/Mage/ImportExport/Model/Export/Entity/Product/Type/Abstract.php diff --git a/app/code/core/Mage/ImportExport/Model/Export/Entity/Product/Type/Configurable.php b/app/code/Mage/ImportExport/Model/Export/Entity/Product/Type/Configurable.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Export/Entity/Product/Type/Configurable.php rename to app/code/Mage/ImportExport/Model/Export/Entity/Product/Type/Configurable.php diff --git a/app/code/core/Mage/ImportExport/Model/Export/Entity/Product/Type/Grouped.php b/app/code/Mage/ImportExport/Model/Export/Entity/Product/Type/Grouped.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Export/Entity/Product/Type/Grouped.php rename to app/code/Mage/ImportExport/Model/Export/Entity/Product/Type/Grouped.php diff --git a/app/code/core/Mage/ImportExport/Model/Export/Entity/Product/Type/Simple.php b/app/code/Mage/ImportExport/Model/Export/Entity/Product/Type/Simple.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Export/Entity/Product/Type/Simple.php rename to app/code/Mage/ImportExport/Model/Export/Entity/Product/Type/Simple.php diff --git a/app/code/core/Mage/ImportExport/Model/Export/EntityAbstract.php b/app/code/Mage/ImportExport/Model/Export/EntityAbstract.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Export/EntityAbstract.php rename to app/code/Mage/ImportExport/Model/Export/EntityAbstract.php diff --git a/app/code/core/Mage/ImportExport/Model/Import.php b/app/code/Mage/ImportExport/Model/Import.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Import.php rename to app/code/Mage/ImportExport/Model/Import.php diff --git a/app/code/core/Mage/ImportExport/Model/Import/Adapter.php b/app/code/Mage/ImportExport/Model/Import/Adapter.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Import/Adapter.php rename to app/code/Mage/ImportExport/Model/Import/Adapter.php diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Abstract.php b/app/code/Mage/ImportExport/Model/Import/Entity/Abstract.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Import/Entity/Abstract.php rename to app/code/Mage/ImportExport/Model/Import/Entity/Abstract.php diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/CustomerComposite.php b/app/code/Mage/ImportExport/Model/Import/Entity/CustomerComposite.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Import/Entity/CustomerComposite.php rename to app/code/Mage/ImportExport/Model/Import/Entity/CustomerComposite.php diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Eav/Customer.php b/app/code/Mage/ImportExport/Model/Import/Entity/Eav/Customer.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Import/Entity/Eav/Customer.php rename to app/code/Mage/ImportExport/Model/Import/Entity/Eav/Customer.php diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Eav/Customer/Address.php b/app/code/Mage/ImportExport/Model/Import/Entity/Eav/Customer/Address.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Import/Entity/Eav/Customer/Address.php rename to app/code/Mage/ImportExport/Model/Import/Entity/Eav/Customer/Address.php diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Eav/CustomerAbstract.php b/app/code/Mage/ImportExport/Model/Import/Entity/Eav/CustomerAbstract.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Import/Entity/Eav/CustomerAbstract.php rename to app/code/Mage/ImportExport/Model/Import/Entity/Eav/CustomerAbstract.php diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/EavAbstract.php b/app/code/Mage/ImportExport/Model/Import/Entity/EavAbstract.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Import/Entity/EavAbstract.php rename to app/code/Mage/ImportExport/Model/Import/Entity/EavAbstract.php diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php b/app/code/Mage/ImportExport/Model/Import/Entity/Product.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php rename to app/code/Mage/ImportExport/Model/Import/Entity/Product.php diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Option.php b/app/code/Mage/ImportExport/Model/Import/Entity/Product/Option.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Option.php rename to app/code/Mage/ImportExport/Model/Import/Entity/Product/Option.php diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Abstract.php b/app/code/Mage/ImportExport/Model/Import/Entity/Product/Type/Abstract.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Abstract.php rename to app/code/Mage/ImportExport/Model/Import/Entity/Product/Type/Abstract.php diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Configurable.php b/app/code/Mage/ImportExport/Model/Import/Entity/Product/Type/Configurable.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Configurable.php rename to app/code/Mage/ImportExport/Model/Import/Entity/Product/Type/Configurable.php diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Grouped.php b/app/code/Mage/ImportExport/Model/Import/Entity/Product/Type/Grouped.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Grouped.php rename to app/code/Mage/ImportExport/Model/Import/Entity/Product/Type/Grouped.php diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Simple.php b/app/code/Mage/ImportExport/Model/Import/Entity/Product/Type/Simple.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Simple.php rename to app/code/Mage/ImportExport/Model/Import/Entity/Product/Type/Simple.php diff --git a/app/code/core/Mage/ImportExport/Model/Import/EntityAbstract.php b/app/code/Mage/ImportExport/Model/Import/EntityAbstract.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Import/EntityAbstract.php rename to app/code/Mage/ImportExport/Model/Import/EntityAbstract.php diff --git a/app/code/core/Mage/ImportExport/Model/Import/Proxy/Product.php b/app/code/Mage/ImportExport/Model/Import/Proxy/Product.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Import/Proxy/Product.php rename to app/code/Mage/ImportExport/Model/Import/Proxy/Product.php diff --git a/app/code/core/Mage/ImportExport/Model/Import/Proxy/Product/Resource.php b/app/code/Mage/ImportExport/Model/Import/Proxy/Product/Resource.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Import/Proxy/Product/Resource.php rename to app/code/Mage/ImportExport/Model/Import/Proxy/Product/Resource.php diff --git a/app/code/core/Mage/ImportExport/Model/Import/Source/Csv.php b/app/code/Mage/ImportExport/Model/Import/Source/Csv.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Import/Source/Csv.php rename to app/code/Mage/ImportExport/Model/Import/Source/Csv.php diff --git a/app/code/core/Mage/ImportExport/Model/Import/SourceAbstract.php b/app/code/Mage/ImportExport/Model/Import/SourceAbstract.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Import/SourceAbstract.php rename to app/code/Mage/ImportExport/Model/Import/SourceAbstract.php diff --git a/app/code/core/Mage/ImportExport/Model/Import/Uploader.php b/app/code/Mage/ImportExport/Model/Import/Uploader.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Import/Uploader.php rename to app/code/Mage/ImportExport/Model/Import/Uploader.php diff --git a/app/code/core/Mage/ImportExport/Model/Resource/CollectionByPagesIterator.php b/app/code/Mage/ImportExport/Model/Resource/CollectionByPagesIterator.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Resource/CollectionByPagesIterator.php rename to app/code/Mage/ImportExport/Model/Resource/CollectionByPagesIterator.php diff --git a/app/code/core/Mage/ImportExport/Model/Resource/Customer/Storage.php b/app/code/Mage/ImportExport/Model/Resource/Customer/Storage.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Resource/Customer/Storage.php rename to app/code/Mage/ImportExport/Model/Resource/Customer/Storage.php diff --git a/app/code/core/Mage/ImportExport/Model/Resource/Helper/Mysql4.php b/app/code/Mage/ImportExport/Model/Resource/Helper/Mysql4.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Resource/Helper/Mysql4.php rename to app/code/Mage/ImportExport/Model/Resource/Helper/Mysql4.php diff --git a/app/code/core/Mage/ImportExport/Model/Resource/Import/CustomerComposite/Data.php b/app/code/Mage/ImportExport/Model/Resource/Import/CustomerComposite/Data.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Resource/Import/CustomerComposite/Data.php rename to app/code/Mage/ImportExport/Model/Resource/Import/CustomerComposite/Data.php diff --git a/app/code/core/Mage/ImportExport/Model/Resource/Import/Data.php b/app/code/Mage/ImportExport/Model/Resource/Import/Data.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Resource/Import/Data.php rename to app/code/Mage/ImportExport/Model/Resource/Import/Data.php diff --git a/app/code/core/Mage/ImportExport/Model/Resource/Setup.php b/app/code/Mage/ImportExport/Model/Resource/Setup.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Resource/Setup.php rename to app/code/Mage/ImportExport/Model/Resource/Setup.php diff --git a/app/code/core/Mage/ImportExport/Model/Source/Export/Entity.php b/app/code/Mage/ImportExport/Model/Source/Export/Entity.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Source/Export/Entity.php rename to app/code/Mage/ImportExport/Model/Source/Export/Entity.php diff --git a/app/code/core/Mage/ImportExport/Model/Source/Export/Format.php b/app/code/Mage/ImportExport/Model/Source/Export/Format.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Source/Export/Format.php rename to app/code/Mage/ImportExport/Model/Source/Export/Format.php diff --git a/app/code/core/Mage/ImportExport/Model/Source/Import/Behavior/Basic.php b/app/code/Mage/ImportExport/Model/Source/Import/Behavior/Basic.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Source/Import/Behavior/Basic.php rename to app/code/Mage/ImportExport/Model/Source/Import/Behavior/Basic.php diff --git a/app/code/core/Mage/ImportExport/Model/Source/Import/Behavior/Custom.php b/app/code/Mage/ImportExport/Model/Source/Import/Behavior/Custom.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Source/Import/Behavior/Custom.php rename to app/code/Mage/ImportExport/Model/Source/Import/Behavior/Custom.php diff --git a/app/code/core/Mage/ImportExport/Model/Source/Import/BehaviorAbstract.php b/app/code/Mage/ImportExport/Model/Source/Import/BehaviorAbstract.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Source/Import/BehaviorAbstract.php rename to app/code/Mage/ImportExport/Model/Source/Import/BehaviorAbstract.php diff --git a/app/code/core/Mage/ImportExport/Model/Source/Import/Entity.php b/app/code/Mage/ImportExport/Model/Source/Import/Entity.php similarity index 100% rename from app/code/core/Mage/ImportExport/Model/Source/Import/Entity.php rename to app/code/Mage/ImportExport/Model/Source/Import/Entity.php diff --git a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php b/app/code/Mage/ImportExport/controllers/Adminhtml/ExportController.php similarity index 100% rename from app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php rename to app/code/Mage/ImportExport/controllers/Adminhtml/ExportController.php diff --git a/app/code/Mage/ImportExport/controllers/Adminhtml/ImportController.php b/app/code/Mage/ImportExport/controllers/Adminhtml/ImportController.php new file mode 100644 index 0000000000000..1b7d964248356 --- /dev/null +++ b/app/code/Mage/ImportExport/controllers/Adminhtml/ImportController.php @@ -0,0 +1,212 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_ImportExport + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Import controller + * + * @category Mage + * @package Mage_ImportExport + * @author Magento Core Team <core@magentocommerce.com> + */ +class Mage_ImportExport_Adminhtml_ImportController extends Mage_Adminhtml_Controller_Action +{ + /** + * Custom constructor. + */ + protected function _construct() + { + // Define module dependent translate + $this->setUsedModuleName('Mage_ImportExport'); + } + + /** + * Initialize layout. + * + * @return Mage_ImportExport_Adminhtml_ImportController + */ + protected function _initAction() + { + $this->_title($this->__('Import/Export')) + ->loadLayout() + ->_setActiveMenu('Mage_ImportExport::system_convert_import'); + return $this; + } + + /** + * Check access (in the ACL) for current user. + * + * @return bool + */ + protected function _isAllowed() + { + return $this->_objectManager->get('Mage_Core_Model_Authorization')->isAllowed('Mage_ImportExport::import'); + } + + /** + * Index action + */ + public function indexAction() + { + $this->_getSession()->addNotice($this->_objectManager->get('Mage_ImportExport_Helper_Data') + ->getMaxUploadSizeMessage()); + $this->_initAction()->_title($this->__('Import'))->_addBreadcrumb($this->__('Import'), $this->__('Import')); + $this->renderLayout(); + } + + /** + * Start import process action + */ + public function startAction() + { + $data = $this->getRequest()->getPost(); + if ($data) { + $this->loadLayout(false); + + /** @var $resultBlock Mage_ImportExport_Block_Adminhtml_Import_Frame_Result */ + $resultBlock = $this->getLayout()->getBlock('import.frame.result'); + /** @var $importModel Mage_ImportExport_Model_Import */ + $importModel = $this->_objectManager->create('Mage_ImportExport_Model_Import'); + + try { + $importModel->importSource(); + $importModel->invalidateIndex(); + $resultBlock->addAction('show', 'import_validation_container') + ->addAction('innerHTML', 'import_validation_container_header', $this->__('Status')); + } catch (Exception $e) { + $resultBlock->addError($e->getMessage()); + $this->renderLayout(); + return; + } + $resultBlock->addAction('hide', array('edit_form', 'upload_button', 'messages')) + ->addSuccess($this->__('Import successfully done.')); + $this->renderLayout(); + } else { + $this->_redirect('*/*/index'); + } + } + + /** + * Validate uploaded files action + */ + public function validateAction() + { + $data = $this->getRequest()->getPost(); + if ($data) { + $this->loadLayout(false); + /** @var $resultBlock Mage_ImportExport_Block_Adminhtml_Import_Frame_Result */ + $resultBlock = $this->getLayout()->getBlock('import.frame.result'); + // common actions + $resultBlock->addAction('show', 'import_validation_container') + ->addAction('clear', array( + Mage_ImportExport_Model_Import::FIELD_NAME_SOURCE_FILE, + Mage_ImportExport_Model_Import::FIELD_NAME_IMG_ARCHIVE_FILE + )); + + try { + /** @var $import Mage_ImportExport_Model_Import */ + $import = $this->_objectManager->create('Mage_ImportExport_Model_Import')->setData($data); + $source = Mage_ImportExport_Model_Import_Adapter::findAdapterFor($import->uploadSource()); + $validationResult = $import->validateSource($source); + + if (!$import->getProcessedRowsCount()) { + $resultBlock->addError($this->__('File does not contain data. Please upload another one')); + } else { + if (!$validationResult) { + $this->_processValidationError($import, $resultBlock); + } else { + if ($import->isImportAllowed()) { + $resultBlock->addSuccess( + $this->__('File is valid! To start import process press "Import" button'), true + ); + } else { + $resultBlock->addError( + $this->__('File is valid, but import is not possible'), false + ); + } + } + $resultBlock->addNotice($import->getNotices()); + $resultBlock->addNotice( + $this->__('Checked rows: %d, checked entities: %d, invalid rows: %d, total errors: %d', + $import->getProcessedRowsCount(), $import->getProcessedEntitiesCount(), + $import->getInvalidRowsCount(), $import->getErrorsCount() + ) + ); + } + } catch (Exception $e) { + $resultBlock->addNotice($this->__('Please fix errors and re-upload file')) + ->addError($e->getMessage()); + } + $this->renderLayout(); + } elseif ($this->getRequest()->isPost() && empty($_FILES)) { + $this->loadLayout(false); + $resultBlock = $this->getLayout()->getBlock('import.frame.result'); + $resultBlock->addError($this->__('File was not uploaded')); + $this->renderLayout(); + } else { + $this->_getSession()->addError($this->__('Data is invalid or file is not uploaded')); + $this->_redirect('*/*/index'); + } + } + + /** + * Process validation results + * + * @param Mage_ImportExport_Model_Import $import + * @param Mage_ImportExport_Block_Adminhtml_Import_Frame_Result $resultBlock + */ + protected function _processValidationError(Mage_ImportExport_Model_Import $import, + Mage_ImportExport_Block_Adminhtml_Import_Frame_Result $resultBlock + ) { + if ($import->getProcessedRowsCount() == $import->getInvalidRowsCount()) { + $resultBlock->addNotice( + $this->__('File is totally invalid. Please fix errors and re-upload file') + ); + } elseif ($import->getErrorsCount() >= $import->getErrorsLimit()) { + $resultBlock->addNotice( + $this->__('Errors limit (%d) reached. Please fix errors and re-upload file', + $import->getErrorsLimit() + ) + ); + } else { + if ($import->isImportAllowed()) { + $resultBlock->addNotice( + $this->__('Please fix errors and re-upload file or simply press "Import" button' + . ' to skip rows with errors'), + true + ); + } else { + $resultBlock->addNotice( + $this->__('File is partially valid, but import is not possible'), false + ); + } + } + // errors info + foreach ($import->getErrors() as $errorCode => $rows) { + $error = $errorCode . ' ' . $this->__('in rows:') . ' ' . implode(', ', $rows); + $resultBlock->addError($error); + } + } +} diff --git a/app/code/Mage/ImportExport/etc/adminhtml/acl.xml b/app/code/Mage/ImportExport/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..bb792bbbc8ead --- /dev/null +++ b/app/code/Mage/ImportExport/etc/adminhtml/acl.xml @@ -0,0 +1,41 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_ImportExport + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::convert"> + <resource id="Mage_ImportExport::import" module="Mage_ImportExport" title="Import" sortOrder="10" /> + <resource id="Mage_ImportExport::export" module="Mage_ImportExport" title="Export" sortOrder="20" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/ImportExport/etc/adminhtml/menu.xml b/app/code/Mage/ImportExport/etc/adminhtml/menu.xml similarity index 100% rename from app/code/core/Mage/ImportExport/etc/adminhtml/menu.xml rename to app/code/Mage/ImportExport/etc/adminhtml/menu.xml diff --git a/app/code/Mage/ImportExport/etc/config.xml b/app/code/Mage/ImportExport/etc/config.xml new file mode 100644 index 0000000000000..204123380b92a --- /dev/null +++ b/app/code/Mage/ImportExport/etc/config.xml @@ -0,0 +1,163 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_ImportExport + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <modules> + <Mage_ImportExport> + <version>1.6.0.4</version> + <active>true</active> + <depends> + <Mage_Catalog/> + </depends> + </Mage_ImportExport> + </modules> + <global> + <resources> + <importexport_setup> + <setup> + <module>Mage_ImportExport</module> + <class>Mage_ImportExport_Model_Resource_Setup</class> + </setup> + </importexport_setup> + </resources> + <importexport module="Mage_ImportExport"> + <import_entities> + <catalog_product translate="label"> + <model_token>Mage_ImportExport_Model_Import_Entity_Product</model_token> + <label>Products</label> + <behavior_token>Mage_ImportExport_Model_Source_Import_Behavior_Basic</behavior_token> + </catalog_product> + <customer_composite translate="label"> + <model_token>Mage_ImportExport_Model_Import_Entity_CustomerComposite</model_token> + <label>Customers</label> + <behavior_token>Mage_ImportExport_Model_Source_Import_Behavior_Basic</behavior_token> + </customer_composite> + <customer translate="label"> + <model_token>Mage_ImportExport_Model_Import_Entity_Eav_Customer</model_token> + <label>Customers Main File</label> + <behavior_token>Mage_ImportExport_Model_Source_Import_Behavior_Custom</behavior_token> + </customer> + <customer_address translate="label"> + <model_token>Mage_ImportExport_Model_Import_Entity_Eav_Customer_Address</model_token> + <label>Customer Addresses</label> + <behavior_token>Mage_ImportExport_Model_Source_Import_Behavior_Custom</behavior_token> + </customer_address> + </import_entities> + <export_entities> + <catalog_product translate="label"> + <model_token>Mage_ImportExport_Model_Export_Entity_Product</model_token> + <label>Products</label> + </catalog_product> + <customer translate="label"> + <model_token>Mage_ImportExport_Model_Export_Entity_Eav_Customer</model_token> + <label>Customers Main File</label> + </customer> + <customer_address translate="label"> + <model_token>Mage_ImportExport_Model_Export_Entity_Eav_Customer_Address</model_token> + <label>Customer Addresses</label> + </customer_address> + </export_entities> + <export_file_formats> + <csv translate="label"> + <model_token>Mage_ImportExport_Model_Export_Adapter_Csv</model_token> + <label>CSV</label> + </csv> + </export_file_formats> + <import_product_types> + <simple>Mage_ImportExport_Model_Import_Entity_Product_Type_Simple</simple> + <configurable>Mage_ImportExport_Model_Import_Entity_Product_Type_Configurable</configurable> + <virtual>Mage_ImportExport_Model_Import_Entity_Product_Type_Simple</virtual> + <grouped>Mage_ImportExport_Model_Import_Entity_Product_Type_Grouped</grouped> + </import_product_types> + <export_product_types> + <simple>Mage_ImportExport_Model_Export_Entity_Product_Type_Simple</simple> + <configurable>Mage_ImportExport_Model_Export_Entity_Product_Type_Configurable</configurable> + <virtual>Mage_ImportExport_Model_Export_Entity_Product_Type_Simple</virtual> + <grouped>Mage_ImportExport_Model_Export_Entity_Product_Type_Grouped</grouped> + </export_product_types> + </importexport> + </global> + <admin> + <routers> + <adminhtml> + <args> + <modules> + <importexport before="Mage_Adminhtml">Mage_ImportExport_Adminhtml</importexport> + </modules> + </args> + </adminhtml> + </routers> + </admin> + <adminhtml> + <layout> + <updates> + <importexport module="Mage_ImportExport"> + <file>layout.xml</file> + </importexport> + </updates> + </layout> + <translate> + <modules> + <Mage_ImportExport> + <files> + <default>Mage_ImportExport.csv</default> + </files> + </Mage_ImportExport> + </modules> + </translate> + </adminhtml> + <default> + <general> + <file> + <importexport_local_valid_paths> + <available> + <export_xml>var/export/*/*.xml</export_xml> + <export_csv>var/export/*/*.csv</export_csv> + <import_xml>var/import/*/*.xml</import_xml> + <import_csv>var/import/*/*.csv</import_csv> + </available> + </importexport_local_valid_paths> + <bunch_size>100</bunch_size> + </file> + </general> + <export> + <customer_page_size> + <customer>10000</customer> + <address>5000</address> + </customer_page_size> + </export> + <import> + <format_v1> + <page_size>5000</page_size> + </format_v1> + <format_v2> + <page_size>10000</page_size> + <bunch_size>100</bunch_size> + </format_v2> + </import> + </default> +</config> diff --git a/app/code/core/Mage/ImportExport/locale/de_DE/Mage_ImportExport.csv b/app/code/Mage/ImportExport/locale/de_DE/Mage_ImportExport.csv similarity index 100% rename from app/code/core/Mage/ImportExport/locale/de_DE/Mage_ImportExport.csv rename to app/code/Mage/ImportExport/locale/de_DE/Mage_ImportExport.csv diff --git a/app/code/core/Mage/ImportExport/locale/en_US/Mage_ImportExport.csv b/app/code/Mage/ImportExport/locale/en_US/Mage_ImportExport.csv similarity index 100% rename from app/code/core/Mage/ImportExport/locale/en_US/Mage_ImportExport.csv rename to app/code/Mage/ImportExport/locale/en_US/Mage_ImportExport.csv diff --git a/app/code/core/Mage/ImportExport/locale/es_ES/Mage_ImportExport.csv b/app/code/Mage/ImportExport/locale/es_ES/Mage_ImportExport.csv similarity index 100% rename from app/code/core/Mage/ImportExport/locale/es_ES/Mage_ImportExport.csv rename to app/code/Mage/ImportExport/locale/es_ES/Mage_ImportExport.csv diff --git a/app/code/core/Mage/ImportExport/locale/fr_FR/Mage_ImportExport.csv b/app/code/Mage/ImportExport/locale/fr_FR/Mage_ImportExport.csv similarity index 100% rename from app/code/core/Mage/ImportExport/locale/fr_FR/Mage_ImportExport.csv rename to app/code/Mage/ImportExport/locale/fr_FR/Mage_ImportExport.csv diff --git a/app/code/core/Mage/ImportExport/locale/nl_NL/Mage_ImportExport.csv b/app/code/Mage/ImportExport/locale/nl_NL/Mage_ImportExport.csv similarity index 100% rename from app/code/core/Mage/ImportExport/locale/nl_NL/Mage_ImportExport.csv rename to app/code/Mage/ImportExport/locale/nl_NL/Mage_ImportExport.csv diff --git a/app/code/core/Mage/ImportExport/locale/pt_BR/Mage_ImportExport.csv b/app/code/Mage/ImportExport/locale/pt_BR/Mage_ImportExport.csv similarity index 100% rename from app/code/core/Mage/ImportExport/locale/pt_BR/Mage_ImportExport.csv rename to app/code/Mage/ImportExport/locale/pt_BR/Mage_ImportExport.csv diff --git a/app/code/core/Mage/ImportExport/locale/zh_CN/Mage_ImportExport.csv b/app/code/Mage/ImportExport/locale/zh_CN/Mage_ImportExport.csv similarity index 100% rename from app/code/core/Mage/ImportExport/locale/zh_CN/Mage_ImportExport.csv rename to app/code/Mage/ImportExport/locale/zh_CN/Mage_ImportExport.csv diff --git a/app/code/core/Mage/ImportExport/sql/importexport_setup/install-1.6.0.0.php b/app/code/Mage/ImportExport/sql/importexport_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/ImportExport/sql/importexport_setup/install-1.6.0.0.php rename to app/code/Mage/ImportExport/sql/importexport_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/ImportExport/sql/importexport_setup/mysql4-upgrade-1.6.0.1-1.6.0.2.php b/app/code/Mage/ImportExport/sql/importexport_setup/mysql4-upgrade-1.6.0.1-1.6.0.2.php similarity index 100% rename from app/code/core/Mage/ImportExport/sql/importexport_setup/mysql4-upgrade-1.6.0.1-1.6.0.2.php rename to app/code/Mage/ImportExport/sql/importexport_setup/mysql4-upgrade-1.6.0.1-1.6.0.2.php diff --git a/app/code/core/Mage/ImportExport/sql/importexport_setup/upgrade-1.6.0.2-1.6.0.3.php b/app/code/Mage/ImportExport/sql/importexport_setup/upgrade-1.6.0.2-1.6.0.3.php similarity index 100% rename from app/code/core/Mage/ImportExport/sql/importexport_setup/upgrade-1.6.0.2-1.6.0.3.php rename to app/code/Mage/ImportExport/sql/importexport_setup/upgrade-1.6.0.2-1.6.0.3.php diff --git a/app/code/core/Mage/ImportExport/sql/importexport_setup/upgrade-1.6.0.3-1.6.0.4.php b/app/code/Mage/ImportExport/sql/importexport_setup/upgrade-1.6.0.3-1.6.0.4.php similarity index 100% rename from app/code/core/Mage/ImportExport/sql/importexport_setup/upgrade-1.6.0.3-1.6.0.4.php rename to app/code/Mage/ImportExport/sql/importexport_setup/upgrade-1.6.0.3-1.6.0.4.php diff --git a/app/code/core/Mage/ImportExport/view/adminhtml/busy.phtml b/app/code/Mage/ImportExport/view/adminhtml/busy.phtml similarity index 100% rename from app/code/core/Mage/ImportExport/view/adminhtml/busy.phtml rename to app/code/Mage/ImportExport/view/adminhtml/busy.phtml diff --git a/app/code/core/Mage/ImportExport/view/adminhtml/export/form/after.phtml b/app/code/Mage/ImportExport/view/adminhtml/export/form/after.phtml similarity index 100% rename from app/code/core/Mage/ImportExport/view/adminhtml/export/form/after.phtml rename to app/code/Mage/ImportExport/view/adminhtml/export/form/after.phtml diff --git a/app/code/core/Mage/ImportExport/view/adminhtml/export/form/before.phtml b/app/code/Mage/ImportExport/view/adminhtml/export/form/before.phtml similarity index 100% rename from app/code/core/Mage/ImportExport/view/adminhtml/export/form/before.phtml rename to app/code/Mage/ImportExport/view/adminhtml/export/form/before.phtml diff --git a/app/code/core/Mage/ImportExport/view/adminhtml/export/form/filter/after.phtml b/app/code/Mage/ImportExport/view/adminhtml/export/form/filter/after.phtml similarity index 100% rename from app/code/core/Mage/ImportExport/view/adminhtml/export/form/filter/after.phtml rename to app/code/Mage/ImportExport/view/adminhtml/export/form/filter/after.phtml diff --git a/app/code/core/Mage/ImportExport/view/adminhtml/import/form/after.phtml b/app/code/Mage/ImportExport/view/adminhtml/import/form/after.phtml similarity index 100% rename from app/code/core/Mage/ImportExport/view/adminhtml/import/form/after.phtml rename to app/code/Mage/ImportExport/view/adminhtml/import/form/after.phtml diff --git a/app/code/core/Mage/ImportExport/view/adminhtml/import/form/before.phtml b/app/code/Mage/ImportExport/view/adminhtml/import/form/before.phtml similarity index 97% rename from app/code/core/Mage/ImportExport/view/adminhtml/import/form/before.phtml rename to app/code/Mage/ImportExport/view/adminhtml/import/form/before.phtml index 045244d903832..89962093a48a9 100644 --- a/app/code/core/Mage/ImportExport/view/adminhtml/import/form/before.phtml +++ b/app/code/Mage/ImportExport/view/adminhtml/import/form/before.phtml @@ -72,12 +72,10 @@ showBehaviorFieldset: function(behavior, isShow) { var behaviorFieldset = behavior + '_fieldset'; if (isShow) { - $('head-' + behaviorFieldset).show(); $(behaviorFieldset).show(); $(behavior).enable(); $(behavior).addClassName('required-entry'); } else { - $('head-' + behaviorFieldset).hide(); $(behaviorFieldset).hide(); $(behavior).selectedIndex = 0; $(behavior).disable(); @@ -91,10 +89,8 @@ */ showUploadFile: function(isShow) { if (isShow == true) { - $('head-upload_file_fieldset').show(); $('upload_file_fieldset').show(); } else { - $('head-upload_file_fieldset').hide(); $('upload_file_fieldset').hide(); } }, diff --git a/app/code/core/Mage/ImportExport/view/adminhtml/import/frame/result.phtml b/app/code/Mage/ImportExport/view/adminhtml/import/frame/result.phtml similarity index 100% rename from app/code/core/Mage/ImportExport/view/adminhtml/import/frame/result.phtml rename to app/code/Mage/ImportExport/view/adminhtml/import/frame/result.phtml diff --git a/app/code/core/Mage/ImportExport/view/adminhtml/layout.xml b/app/code/Mage/ImportExport/view/adminhtml/layout.xml similarity index 100% rename from app/code/core/Mage/ImportExport/view/adminhtml/layout.xml rename to app/code/Mage/ImportExport/view/adminhtml/layout.xml diff --git a/app/code/core/Mage/Index/Block/Adminhtml/Notifications.php b/app/code/Mage/Index/Block/Adminhtml/Notifications.php similarity index 100% rename from app/code/core/Mage/Index/Block/Adminhtml/Notifications.php rename to app/code/Mage/Index/Block/Adminhtml/Notifications.php diff --git a/app/code/core/Mage/Index/Block/Adminhtml/Process.php b/app/code/Mage/Index/Block/Adminhtml/Process.php similarity index 100% rename from app/code/core/Mage/Index/Block/Adminhtml/Process.php rename to app/code/Mage/Index/Block/Adminhtml/Process.php diff --git a/app/code/core/Mage/Index/Block/Adminhtml/Process/Edit.php b/app/code/Mage/Index/Block/Adminhtml/Process/Edit.php similarity index 100% rename from app/code/core/Mage/Index/Block/Adminhtml/Process/Edit.php rename to app/code/Mage/Index/Block/Adminhtml/Process/Edit.php diff --git a/app/code/core/Mage/Index/Block/Adminhtml/Process/Edit/Form.php b/app/code/Mage/Index/Block/Adminhtml/Process/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Index/Block/Adminhtml/Process/Edit/Form.php rename to app/code/Mage/Index/Block/Adminhtml/Process/Edit/Form.php diff --git a/app/code/core/Mage/Index/Block/Adminhtml/Process/Edit/Tab/Main.php b/app/code/Mage/Index/Block/Adminhtml/Process/Edit/Tab/Main.php similarity index 100% rename from app/code/core/Mage/Index/Block/Adminhtml/Process/Edit/Tab/Main.php rename to app/code/Mage/Index/Block/Adminhtml/Process/Edit/Tab/Main.php diff --git a/app/code/core/Mage/Index/Block/Adminhtml/Process/Edit/Tabs.php b/app/code/Mage/Index/Block/Adminhtml/Process/Edit/Tabs.php similarity index 100% rename from app/code/core/Mage/Index/Block/Adminhtml/Process/Edit/Tabs.php rename to app/code/Mage/Index/Block/Adminhtml/Process/Edit/Tabs.php diff --git a/app/code/core/Mage/Index/Block/Adminhtml/Process/Grid.php b/app/code/Mage/Index/Block/Adminhtml/Process/Grid.php similarity index 100% rename from app/code/core/Mage/Index/Block/Adminhtml/Process/Grid.php rename to app/code/Mage/Index/Block/Adminhtml/Process/Grid.php diff --git a/app/code/core/Mage/Index/Block/Adminhtml/Process/Grid/Massaction.php b/app/code/Mage/Index/Block/Adminhtml/Process/Grid/Massaction.php similarity index 100% rename from app/code/core/Mage/Index/Block/Adminhtml/Process/Grid/Massaction.php rename to app/code/Mage/Index/Block/Adminhtml/Process/Grid/Massaction.php diff --git a/app/code/core/Mage/Index/Helper/Data.php b/app/code/Mage/Index/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Index/Helper/Data.php rename to app/code/Mage/Index/Helper/Data.php diff --git a/app/code/core/Mage/Index/Model/EntryPoint/Indexer.php b/app/code/Mage/Index/Model/EntryPoint/Indexer.php similarity index 100% rename from app/code/core/Mage/Index/Model/EntryPoint/Indexer.php rename to app/code/Mage/Index/Model/EntryPoint/Indexer.php diff --git a/app/code/Mage/Index/Model/EntryPoint/Shell.php b/app/code/Mage/Index/Model/EntryPoint/Shell.php new file mode 100644 index 0000000000000..0bbcbd7a046a1 --- /dev/null +++ b/app/code/Mage/Index/Model/EntryPoint/Shell.php @@ -0,0 +1,58 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +class Mage_Index_Model_EntryPoint_Shell extends Mage_Core_Model_EntryPointAbstract +{ + /** + * @param string $baseDir + * @param array $params + */ + public function __construct($baseDir, array $params = array()) + { + $entryPoint = $params['entryPoint']; + unset($params['entryPoint']); + $config = new Mage_Core_Model_Config_Primary($baseDir, $params); + parent::__construct($config); + $this->_objectManager->configure(array( + 'Mage_Index_Model_Shell' => array( + 'parameters' => array( + 'entryPoint' => $entryPoint, + ) + ) + )); + } + + /** + * Process request to application + */ + public function processRequest() + { + /** @var $shell Mage_Index_Model_Shell */ + $shell = $this->_objectManager->create('Mage_Index_Model_Shell'); + $shell->run(); + if ($shell->hasErrors()) { + exit(1); + } + } +} diff --git a/app/code/core/Mage/Index/Model/Event.php b/app/code/Mage/Index/Model/Event.php similarity index 100% rename from app/code/core/Mage/Index/Model/Event.php rename to app/code/Mage/Index/Model/Event.php diff --git a/app/code/core/Mage/Index/Model/Indexer.php b/app/code/Mage/Index/Model/Indexer.php similarity index 86% rename from app/code/core/Mage/Index/Model/Indexer.php rename to app/code/Mage/Index/Model/Indexer.php index 32a2fe2dd493c..8ee4d95422ef8 100644 --- a/app/code/core/Mage/Index/Model/Indexer.php +++ b/app/code/Mage/Index/Model/Indexer.php @@ -41,7 +41,15 @@ class Mage_Index_Model_Indexer */ public function __construct() { - $this->_processesCollection = Mage::getResourceModel('Mage_Index_Model_Resource_Process_Collection'); + $this->_processesCollection = $this->_createCollection(); + } + + /** + * @return Mage_Index_Model_Resource_Process_Collection + */ + private function _createCollection() + { + return Mage::getResourceModel('Mage_Index_Model_Resource_Process_Collection'); } /** @@ -192,6 +200,37 @@ public function processEntityAction(Varien_Object $entity, $entityType, $eventTy return $this; } + /** + * Reindex all processes + */ + public function reindexAll() + { + $this->_reindexCollection($this->_createCollection()); + } + + /** + * Reindex only processes that are invalidated + */ + public function reindexRequired() + { + $collection = $this->_createCollection(); + $collection->addFieldToFilter('status', Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX); + $this->_reindexCollection($collection); + } + + /** + * Sub-routine for iterating collection and reindexing all processes of specified collection + * + * @param Mage_Index_Model_Resource_Process_Collection $collection + */ + private function _reindexCollection(Mage_Index_Model_Resource_Process_Collection $collection) + { + /** @var $process Mage_Index_Model_Process */ + foreach ($collection as $process) { + $process->reindexEverything(); + } + } + /** * Run all processes method with parameters * Run by depends priority diff --git a/app/code/core/Mage/Index/Model/Indexer/Abstract.php b/app/code/Mage/Index/Model/Indexer/Abstract.php similarity index 100% rename from app/code/core/Mage/Index/Model/Indexer/Abstract.php rename to app/code/Mage/Index/Model/Indexer/Abstract.php diff --git a/app/code/Mage/Index/Model/Lock/Storage.php b/app/code/Mage/Index/Model/Lock/Storage.php new file mode 100644 index 0000000000000..da2f0196dc70a --- /dev/null +++ b/app/code/Mage/Index/Model/Lock/Storage.php @@ -0,0 +1,82 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Index + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Lock file storage for index processes + */ +class Mage_Index_Model_Lock_Storage +{ + /** + * @var Mage_Core_Model_Dir + */ + protected $_dirs; + + /** + * @var Mage_Index_Model_Process_FileFactory + */ + protected $_fileFactory; + + /** + * File handlers by process IDs + * + * @var array + */ + protected $_fileHandlers = array(); + + /** + * @param Mage_Core_Model_Dir $dirs + * @param Mage_Index_Model_Process_FileFactory $fileFactory + */ + public function __construct( + Mage_Core_Model_Dir $dirs, + Mage_Index_Model_Process_FileFactory $fileFactory + ) { + $this->_dirs = $dirs; + $this->_fileFactory = $fileFactory; + } + + /** + * Get file handler by process ID + * + * @param $processId + * @return Mage_Index_Model_Process_File + */ + public function getFile($processId) + { + if (!isset($this->_fileHandlers[$processId])) { + $file = $this->_fileFactory->create(); + $varDirectory = $this->_dirs->getDir(Mage_Core_Model_Dir::VAR_DIR) . DIRECTORY_SEPARATOR . 'locks'; + $file->setAllowCreateFolders(true); + + $file->open(array('path' => $varDirectory)); + $fileName = 'index_process_' . $processId . '.lock'; + $file->streamOpen($fileName); + $file->streamWrite(date('r')); + $this->_fileHandlers[$processId] = $file; + } + return $this->_fileHandlers[$processId]; + } +} diff --git a/app/code/core/Mage/Index/Model/Observer.php b/app/code/Mage/Index/Model/Observer.php similarity index 100% rename from app/code/core/Mage/Index/Model/Observer.php rename to app/code/Mage/Index/Model/Observer.php diff --git a/app/code/core/Mage/Index/Model/Process.php b/app/code/Mage/Index/Model/Process.php similarity index 98% rename from app/code/core/Mage/Index/Model/Process.php rename to app/code/Mage/Index/Model/Process.php index ec96eff5ed812..ded29b6e70a72 100644 --- a/app/code/core/Mage/Index/Model/Process.php +++ b/app/code/Mage/Index/Model/Process.php @@ -91,22 +91,20 @@ class Mage_Index_Model_Process extends Mage_Core_Model_Abstract protected $_processFile; /** - * @param Mage_Core_Model_Event_Manager $eventDispatcher - * @param Mage_Core_Model_Cache $cacheManager + * @param Mage_Core_Model_Context $context + * @param Mage_Index_Model_Lock_Storage $lockStorage * @param Mage_Core_Model_Resource_Abstract $resource * @param Varien_Data_Collection_Db $resourceCollection - * @param Mage_Index_Model_Lock_Storage $lockStorage * @param array $data */ public function __construct( - Mage_Core_Model_Event_Manager $eventDispatcher, - Mage_Core_Model_Cache $cacheManager, + Mage_Core_Model_Context $context, Mage_Index_Model_Lock_Storage $lockStorage, Mage_Core_Model_Resource_Abstract $resource = null, Varien_Data_Collection_Db $resourceCollection = null, array $data = array() ) { - parent::__construct($eventDispatcher, $cacheManager, $resource, $resourceCollection, $data); + parent::__construct($context, $resource, $resourceCollection, $data); $this->_lockStorage = $lockStorage; } diff --git a/app/code/core/Mage/Index/Model/Process/File.php b/app/code/Mage/Index/Model/Process/File.php similarity index 100% rename from app/code/core/Mage/Index/Model/Process/File.php rename to app/code/Mage/Index/Model/Process/File.php diff --git a/app/code/core/Mage/Index/Model/Process/FileFactory.php b/app/code/Mage/Index/Model/Process/FileFactory.php similarity index 90% rename from app/code/core/Mage/Index/Model/Process/FileFactory.php rename to app/code/Mage/Index/Model/Process/FileFactory.php index 3083b8a04b4a7..f1347f8299f62 100644 --- a/app/code/core/Mage/Index/Model/Process/FileFactory.php +++ b/app/code/Mage/Index/Model/Process/FileFactory.php @@ -27,7 +27,7 @@ /** * Process file entity */ -class Mage_Index_Model_Process_FileFactory implements Magento_ObjectManager_Factory +class Mage_Index_Model_Process_FileFactory { /** * Entity class name @@ -51,8 +51,8 @@ public function __construct(Magento_ObjectManager $objectManager) * @param array $arguments * @return Mage_Index_Model_Process_File */ - public function createFromArray(array $arguments = array()) + public function create(array $arguments = array()) { - return $this->_objectManager->create(self::CLASS_NAME, $arguments, false); + return $this->_objectManager->create(self::CLASS_NAME, $arguments); } } diff --git a/app/code/core/Mage/Index/Model/Resource/Abstract.php b/app/code/Mage/Index/Model/Resource/Abstract.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Index/Model/Resource/Abstract.php rename to app/code/Mage/Index/Model/Resource/Abstract.php diff --git a/app/code/core/Mage/Index/Model/Resource/Event.php b/app/code/Mage/Index/Model/Resource/Event.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Index/Model/Resource/Event.php rename to app/code/Mage/Index/Model/Resource/Event.php diff --git a/app/code/core/Mage/Index/Model/Resource/Event/Collection.php b/app/code/Mage/Index/Model/Resource/Event/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Index/Model/Resource/Event/Collection.php rename to app/code/Mage/Index/Model/Resource/Event/Collection.php diff --git a/app/code/core/Mage/Index/Model/Resource/Process.php b/app/code/Mage/Index/Model/Resource/Process.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Index/Model/Resource/Process.php rename to app/code/Mage/Index/Model/Resource/Process.php diff --git a/app/code/core/Mage/Index/Model/Resource/Process/Collection.php b/app/code/Mage/Index/Model/Resource/Process/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Index/Model/Resource/Process/Collection.php rename to app/code/Mage/Index/Model/Resource/Process/Collection.php diff --git a/app/code/core/Mage/Index/Model/Resource/Setup.php b/app/code/Mage/Index/Model/Resource/Setup.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Index/Model/Resource/Setup.php rename to app/code/Mage/Index/Model/Resource/Setup.php diff --git a/app/code/core/Mage/Index/Model/Shell.php b/app/code/Mage/Index/Model/Shell.php similarity index 100% rename from app/code/core/Mage/Index/Model/Shell.php rename to app/code/Mage/Index/Model/Shell.php diff --git a/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php b/app/code/Mage/Index/controllers/Adminhtml/ProcessController.php similarity index 100% rename from app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php rename to app/code/Mage/Index/controllers/Adminhtml/ProcessController.php diff --git a/app/code/Mage/Index/etc/adminhtml/acl.xml b/app/code/Mage/Index/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..dc4644c0dd0c1 --- /dev/null +++ b/app/code/Mage/Index/etc/adminhtml/acl.xml @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Index + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::tools"> + <resource id="Mage_Index::index" title="Index Management" module="Mage_Index" sortOrder="20" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/Mage/Index/etc/adminhtml/menu.xml b/app/code/Mage/Index/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..1afe16c4e2897 --- /dev/null +++ b/app/code/Mage/Index/etc/adminhtml/menu.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Index + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <menu> + <add id="Mage_Index::system_index" title="Index Management" module="Mage_Index" sortOrder="20" parent="Mage_Adminhtml::system_tools" action="adminhtml/process/list" resource="Mage_Index::index"/> + </menu> +</config> diff --git a/app/code/Mage/Index/etc/config.xml b/app/code/Mage/Index/etc/config.xml new file mode 100644 index 0000000000000..4afd184c2e921 --- /dev/null +++ b/app/code/Mage/Index/etc/config.xml @@ -0,0 +1,140 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Index + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <modules> + <Mage_Index> + <version>1.6.0.0</version> + <active>true</active> + <depends> + <Mage_Core/> + </depends> + </Mage_Index> + </modules> + <global> + <resources> + <index_setup> + <setup> + <module>Mage_Index</module> + <class>Mage_Index_Model_Resource_Setup</class> + </setup> + </index_setup> + </resources> + <index> + <indexer> + + </indexer> + </index> + <events> + <store_save_commit_after> + <observers> + <index> + <class>Mage_Index_Model_Observer</class> + <method>processStoreSave</method> + </index> + </observers> + </store_save_commit_after> + <store_group_save_commit_after> + <observers> + <index> + <class>Mage_Index_Model_Observer</class> + <method>processStoreGroupSave</method> + </index> + </observers> + </store_group_save_commit_after> + <website_save_commit_after> + <observers> + <index> + <class>Mage_Index_Model_Observer</class> + <method>processWebsiteSave</method> + </index> + </observers> + </website_save_commit_after> + <store_delete_commit_after> + <observers> + <index> + <class>Mage_Index_Model_Observer</class> + <method>processStoreDelete</method> + </index> + </observers> + </store_delete_commit_after> + <store_group_delete_commit_after> + <observers> + <index> + <class>Mage_Index_Model_Observer</class> + <method>processStoreGroupDelete</method> + </index> + </observers> + </store_group_delete_commit_after> + <website_delete_commit_after> + <observers> + <index> + <class>Mage_Index_Model_Observer</class> + <method>processWebsiteDelete</method> + </index> + </observers> + </website_delete_commit_after> + <core_config_data_save_commit_after> + <observers> + <index> + <class>Mage_Index_Model_Observer</class> + <method>processConfigDataSave</method> + </index> + </observers> + </core_config_data_save_commit_after> + </events> + </global> + <admin> + <routers> + <adminhtml> + <args> + <modules> + <Mage_Index before="Mage_Adminhtml">Mage_Index_Adminhtml</Mage_Index> + </modules> + </args> + </adminhtml> + </routers> + </admin> + <adminhtml> + <layout> + <updates> + <index module="Mage_Index"> + <file>layout.xml</file> + </index> + </updates> + </layout> + <translate> + <modules> + <Mage_Index> + <files> + <default>Mage_Index.csv</default> + </files> + </Mage_Index> + </modules> + </translate> + </adminhtml> +</config> diff --git a/app/code/core/Mage/Index/locale/de_DE/Mage_Index.csv b/app/code/Mage/Index/locale/de_DE/Mage_Index.csv similarity index 100% rename from app/code/core/Mage/Index/locale/de_DE/Mage_Index.csv rename to app/code/Mage/Index/locale/de_DE/Mage_Index.csv diff --git a/app/code/core/Mage/Index/locale/en_US/Mage_Index.csv b/app/code/Mage/Index/locale/en_US/Mage_Index.csv similarity index 100% rename from app/code/core/Mage/Index/locale/en_US/Mage_Index.csv rename to app/code/Mage/Index/locale/en_US/Mage_Index.csv diff --git a/app/code/core/Mage/Index/locale/es_ES/Mage_Index.csv b/app/code/Mage/Index/locale/es_ES/Mage_Index.csv similarity index 100% rename from app/code/core/Mage/Index/locale/es_ES/Mage_Index.csv rename to app/code/Mage/Index/locale/es_ES/Mage_Index.csv diff --git a/app/code/core/Mage/Index/locale/fr_FR/Mage_Index.csv b/app/code/Mage/Index/locale/fr_FR/Mage_Index.csv similarity index 100% rename from app/code/core/Mage/Index/locale/fr_FR/Mage_Index.csv rename to app/code/Mage/Index/locale/fr_FR/Mage_Index.csv diff --git a/app/code/core/Mage/Index/locale/nl_NL/Mage_Index.csv b/app/code/Mage/Index/locale/nl_NL/Mage_Index.csv similarity index 100% rename from app/code/core/Mage/Index/locale/nl_NL/Mage_Index.csv rename to app/code/Mage/Index/locale/nl_NL/Mage_Index.csv diff --git a/app/code/core/Mage/Index/locale/pt_BR/Mage_Index.csv b/app/code/Mage/Index/locale/pt_BR/Mage_Index.csv similarity index 100% rename from app/code/core/Mage/Index/locale/pt_BR/Mage_Index.csv rename to app/code/Mage/Index/locale/pt_BR/Mage_Index.csv diff --git a/app/code/core/Mage/Index/locale/zh_CN/Mage_Index.csv b/app/code/Mage/Index/locale/zh_CN/Mage_Index.csv similarity index 100% rename from app/code/core/Mage/Index/locale/zh_CN/Mage_Index.csv rename to app/code/Mage/Index/locale/zh_CN/Mage_Index.csv diff --git a/app/code/core/Mage/Index/sql/index_setup/install-1.6.0.0.php b/app/code/Mage/Index/sql/index_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Index/sql/index_setup/install-1.6.0.0.php rename to app/code/Mage/Index/sql/index_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Index/view/adminhtml/layout.xml b/app/code/Mage/Index/view/adminhtml/layout.xml similarity index 100% rename from app/code/core/Mage/Index/view/adminhtml/layout.xml rename to app/code/Mage/Index/view/adminhtml/layout.xml diff --git a/app/code/core/Mage/Index/view/adminhtml/notifications.phtml b/app/code/Mage/Index/view/adminhtml/notifications.phtml similarity index 100% rename from app/code/core/Mage/Index/view/adminhtml/notifications.phtml rename to app/code/Mage/Index/view/adminhtml/notifications.phtml diff --git a/app/code/core/Mage/Install/Block/Abstract.php b/app/code/Mage/Install/Block/Abstract.php similarity index 100% rename from app/code/core/Mage/Install/Block/Abstract.php rename to app/code/Mage/Install/Block/Abstract.php diff --git a/app/code/core/Mage/Install/Block/Admin.php b/app/code/Mage/Install/Block/Admin.php similarity index 100% rename from app/code/core/Mage/Install/Block/Admin.php rename to app/code/Mage/Install/Block/Admin.php diff --git a/app/code/core/Mage/Install/Block/Begin.php b/app/code/Mage/Install/Block/Begin.php similarity index 100% rename from app/code/core/Mage/Install/Block/Begin.php rename to app/code/Mage/Install/Block/Begin.php diff --git a/app/code/core/Mage/Install/Block/Config.php b/app/code/Mage/Install/Block/Config.php similarity index 100% rename from app/code/core/Mage/Install/Block/Config.php rename to app/code/Mage/Install/Block/Config.php diff --git a/app/code/core/Mage/Install/Block/Db/Main.php b/app/code/Mage/Install/Block/Db/Main.php similarity index 100% rename from app/code/core/Mage/Install/Block/Db/Main.php rename to app/code/Mage/Install/Block/Db/Main.php diff --git a/app/code/core/Mage/Install/Block/Db/Type.php b/app/code/Mage/Install/Block/Db/Type.php similarity index 100% rename from app/code/core/Mage/Install/Block/Db/Type.php rename to app/code/Mage/Install/Block/Db/Type.php diff --git a/app/code/core/Mage/Install/Block/Db/Type/Mysql4.php b/app/code/Mage/Install/Block/Db/Type/Mysql4.php similarity index 100% rename from app/code/core/Mage/Install/Block/Db/Type/Mysql4.php rename to app/code/Mage/Install/Block/Db/Type/Mysql4.php diff --git a/app/code/core/Mage/Install/Block/Download.php b/app/code/Mage/Install/Block/Download.php similarity index 100% rename from app/code/core/Mage/Install/Block/Download.php rename to app/code/Mage/Install/Block/Download.php diff --git a/app/code/core/Mage/Install/Block/End.php b/app/code/Mage/Install/Block/End.php similarity index 100% rename from app/code/core/Mage/Install/Block/End.php rename to app/code/Mage/Install/Block/End.php diff --git a/app/code/core/Mage/Install/Block/Locale.php b/app/code/Mage/Install/Block/Locale.php similarity index 100% rename from app/code/core/Mage/Install/Block/Locale.php rename to app/code/Mage/Install/Block/Locale.php diff --git a/app/code/core/Mage/Install/Block/State.php b/app/code/Mage/Install/Block/State.php similarity index 100% rename from app/code/core/Mage/Install/Block/State.php rename to app/code/Mage/Install/Block/State.php diff --git a/app/code/core/Mage/Install/Controller/Action.php b/app/code/Mage/Install/Controller/Action.php similarity index 100% rename from app/code/core/Mage/Install/Controller/Action.php rename to app/code/Mage/Install/Controller/Action.php diff --git a/app/code/core/Mage/Install/Helper/Data.php b/app/code/Mage/Install/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Install/Helper/Data.php rename to app/code/Mage/Install/Helper/Data.php diff --git a/app/code/core/Mage/Install/Model/Config.php b/app/code/Mage/Install/Model/Config.php similarity index 100% rename from app/code/core/Mage/Install/Model/Config.php rename to app/code/Mage/Install/Model/Config.php diff --git a/app/code/Mage/Install/Model/EntryPoint/Console.php b/app/code/Mage/Install/Model/EntryPoint/Console.php new file mode 100644 index 0000000000000..4cb448c128094 --- /dev/null +++ b/app/code/Mage/Install/Model/EntryPoint/Console.php @@ -0,0 +1,104 @@ +<?php +/** + * Console entry point + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +class Mage_Install_Model_EntryPoint_Console extends Mage_Core_Model_EntryPointAbstract +{ + /** + * @param string $baseDir + * @param array $params + */ + public function __construct($baseDir, array $params = array()) + { + $this->_params = $this->_buildInitParams($params); + $config = new Mage_Core_Model_Config_Primary($baseDir, $this->_params); + parent::__construct($config); + } + + /** + * Customize application init parameters + * + * @param array $args + * @return array + */ + protected function _buildInitParams(array $args) + { + if (!empty($args[Mage_Install_Model_Installer_Console::OPTION_URIS])) { + $args[MAGE::PARAM_APP_URIS] = + unserialize(base64_decode($args[Mage_Install_Model_Installer_Console::OPTION_URIS])); + } + if (!empty($args[Mage_Install_Model_Installer_Console::OPTION_DIRS])) { + $args[Mage::PARAM_APP_DIRS] = + unserialize(base64_decode($args[Mage_Install_Model_Installer_Console::OPTION_DIRS])); + } + return $args; + } + + /** + * Run http application + */ + public function processRequest() + { + /** + * @var $installer Mage_Install_Model_Installer_Console + */ + $installer = $this->_objectManager->create( + 'Mage_Install_Model_Installer_Console', + array('installArgs' => $this->_params) + ); + if (isset($this->_params['show_locales'])) { + var_export($installer->getAvailableLocales()); + } else if (isset($this->_params['show_currencies'])) { + var_export($installer->getAvailableCurrencies()); + } else if (isset($this->_params['show_timezones'])) { + var_export($installer->getAvailableTimezones()); + } else if (isset($this->_params['show_install_options'])) { + var_export($installer->getAvailableInstallOptions()); + } else { + if (isset($this->_params['config']) && file_exists($this->_params['config'])) { + $config = (array) include($this->_params['config']); + $this->_params = array_merge((array)$config, $this->_params); + } + $isUninstallMode = isset($this->_params['uninstall']); + if ($isUninstallMode) { + $result = $installer->uninstall(); + } else { + $result = $installer->install($this->_params); + } + if (!$installer->hasErrors()) { + if ($isUninstallMode) { + $msg = $result ? + 'Uninstalled successfully' : + 'Ignoring attempt to uninstall non-installed application'; + } else { + $msg = 'Installed successfully' . ($result ? ' (encryption key "' . $result . '")' : ''); + } + echo $msg . PHP_EOL; + } else { + echo implode(PHP_EOL, $installer->getErrors()) . PHP_EOL; + exit(1); + } + } + } +} diff --git a/app/code/Mage/Install/Model/EntryPoint/Upgrade.php b/app/code/Mage/Install/Model/EntryPoint/Upgrade.php new file mode 100644 index 0000000000000..f7194c24b4687 --- /dev/null +++ b/app/code/Mage/Install/Model/EntryPoint/Upgrade.php @@ -0,0 +1,78 @@ +<?php +/** + * Entry point for upgrading application + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +class Mage_Install_Model_EntryPoint_Upgrade extends Mage_Core_Model_EntryPointAbstract +{ + /** + * Key for passing reindexing parameter + */ + const REINDEX = 'reindex'; + + /**@#+ + * Reindexing modes + */ + const REINDEX_INVALID = 1; + const REINDEX_ALL = 2; + /**@#-*/ + + /** + * Apply scheme & data updates + */ + public function processRequest() + { + /** @var $cacheFrontendPool Mage_Core_Model_Cache_Frontend_Pool */ + $cacheFrontendPool = $this->_objectManager->get('Mage_Core_Model_Cache_Frontend_Pool'); + /** @var $cacheFrontend Magento_Cache_FrontendInterface */ + foreach ($cacheFrontendPool as $cacheFrontend) { + $cacheFrontend->clean(); + } + + /** @var $updater \Mage_Core_Model_Db_Updater */ + $updater = $this->_objectManager->get('Mage_Core_Model_Db_Updater'); + $updater->updateScheme(); + $updater->updateData(); + + $this->_reindex(); + } + + /** + * Perform reindexing if requested + */ + private function _reindex() + { + /** @var $config Mage_Core_Model_Config_Primary */ + $config = $this->_objectManager->get('Mage_Core_Model_Config_Primary'); + $reindexMode = $config->getParam(self::REINDEX); + if ($reindexMode) { + /** @var $indexer Mage_Index_Model_Indexer */ + $indexer = $this->_objectManager->get('Mage_Index_Model_Indexer'); + if (self::REINDEX_ALL == $reindexMode) { + $indexer->reindexAll(); + } elseif (self::REINDEX_INVALID == $reindexMode) { + $indexer->reindexRequired(); + } + } + } +} diff --git a/app/code/core/Mage/Install/Model/Installer.php b/app/code/Mage/Install/Model/Installer.php similarity index 94% rename from app/code/core/Mage/Install/Model/Installer.php rename to app/code/Mage/Install/Model/Installer.php index e349aebd72994..b4a99223b1f2a 100644 --- a/app/code/core/Mage/Install/Model/Installer.php +++ b/app/code/Mage/Install/Model/Installer.php @@ -51,7 +51,7 @@ class Mage_Install_Model_Installer extends Varien_Object /** * Application chache model * - * @var Mage_Core_Model_Cache + * @var Mage_Core_Model_CacheInterface */ protected $_cache; @@ -62,21 +62,29 @@ class Mage_Install_Model_Installer extends Varien_Object */ protected $_config; + /** + * @var Mage_Core_Model_Cache_Types + */ + protected $_cacheTypes; + /** * @param Mage_Core_Model_ConfigInterface $config * @param Mage_Core_Model_Db_UpdaterInterface $dbUpdater - * @param Mage_Core_Model_Cache $cache + * @param Mage_Core_Model_CacheInterface $cache + * @param Mage_Core_Model_Cache_Types $cacheTypes * @param array $data */ public function __construct( Mage_Core_Model_ConfigInterface $config, Mage_Core_Model_Db_UpdaterInterface $dbUpdater, - Mage_Core_Model_Cache $cache, + Mage_Core_Model_CacheInterface $cache, + Mage_Core_Model_Cache_Types $cacheTypes, array $data = array() ) { $this->_dbUpdater = $dbUpdater; $this->_config = $config; $this->_cache = $cache; + $this->_cacheTypes = $cacheTypes; parent::__construct($data); } @@ -207,7 +215,7 @@ public function installDb() * Saving host information into DB */ $setupModel = Mage::getObjectManager() - ->get('Mage_Core_Model_Resource_Setup', array('resourceName' => 'core_setup')); + ->create('Mage_Core_Model_Resource_Setup', array('resourceName' => 'core_setup')); if (!empty($data['use_rewrites'])) { $setupModel->setConfigData(Mage_Core_Model_Store::XML_PATH_USE_REWRITES, 1); @@ -336,11 +344,10 @@ public function finish() Mage::getSingleton('Mage_Install_Model_Installer_Config')->replaceTmpInstallDate(); $this->_refreshConfig(); /* Enable all cache types */ - $cacheData = array(); - foreach (Mage::helper('Mage_Core_Helper_Data')->getCacheTypes() as $type => $label) { - $cacheData[$type] = 1; + foreach (array_keys($this->_cache->getTypes()) as $cacheTypeCode) { + $this->_cacheTypes->setEnabled($cacheTypeCode, true); } - $this->_cache->saveOptions($cacheData); + $this->_cacheTypes->persist(); return $this; } diff --git a/app/code/core/Mage/Install/Model/Installer/Abstract.php b/app/code/Mage/Install/Model/Installer/Abstract.php similarity index 100% rename from app/code/core/Mage/Install/Model/Installer/Abstract.php rename to app/code/Mage/Install/Model/Installer/Abstract.php diff --git a/app/code/core/Mage/Install/Model/Installer/Config.php b/app/code/Mage/Install/Model/Installer/Config.php similarity index 100% rename from app/code/core/Mage/Install/Model/Installer/Config.php rename to app/code/Mage/Install/Model/Installer/Config.php diff --git a/app/code/core/Mage/Install/Model/Installer/Console.php b/app/code/Mage/Install/Model/Installer/Console.php similarity index 100% rename from app/code/core/Mage/Install/Model/Installer/Console.php rename to app/code/Mage/Install/Model/Installer/Console.php diff --git a/app/code/core/Mage/Install/Model/Installer/Data.php b/app/code/Mage/Install/Model/Installer/Data.php similarity index 100% rename from app/code/core/Mage/Install/Model/Installer/Data.php rename to app/code/Mage/Install/Model/Installer/Data.php diff --git a/app/code/core/Mage/Install/Model/Installer/Db.php b/app/code/Mage/Install/Model/Installer/Db.php similarity index 100% rename from app/code/core/Mage/Install/Model/Installer/Db.php rename to app/code/Mage/Install/Model/Installer/Db.php diff --git a/app/code/core/Mage/Install/Model/Installer/Db/Abstract.php b/app/code/Mage/Install/Model/Installer/Db/Abstract.php similarity index 100% rename from app/code/core/Mage/Install/Model/Installer/Db/Abstract.php rename to app/code/Mage/Install/Model/Installer/Db/Abstract.php diff --git a/app/code/core/Mage/Install/Model/Installer/Db/Mysql4.php b/app/code/Mage/Install/Model/Installer/Db/Mysql4.php similarity index 100% rename from app/code/core/Mage/Install/Model/Installer/Db/Mysql4.php rename to app/code/Mage/Install/Model/Installer/Db/Mysql4.php diff --git a/app/code/core/Mage/Install/Model/Installer/Env.php b/app/code/Mage/Install/Model/Installer/Env.php similarity index 100% rename from app/code/core/Mage/Install/Model/Installer/Env.php rename to app/code/Mage/Install/Model/Installer/Env.php diff --git a/app/code/core/Mage/Install/Model/Installer/Filesystem.php b/app/code/Mage/Install/Model/Installer/Filesystem.php similarity index 100% rename from app/code/core/Mage/Install/Model/Installer/Filesystem.php rename to app/code/Mage/Install/Model/Installer/Filesystem.php diff --git a/app/code/core/Mage/Install/Model/Installer/Pear.php b/app/code/Mage/Install/Model/Installer/Pear.php similarity index 100% rename from app/code/core/Mage/Install/Model/Installer/Pear.php rename to app/code/Mage/Install/Model/Installer/Pear.php diff --git a/app/code/core/Mage/Install/Model/Observer.php b/app/code/Mage/Install/Model/Observer.php similarity index 100% rename from app/code/core/Mage/Install/Model/Observer.php rename to app/code/Mage/Install/Model/Observer.php diff --git a/app/code/core/Mage/Install/Model/Session.php b/app/code/Mage/Install/Model/Session.php similarity index 100% rename from app/code/core/Mage/Install/Model/Session.php rename to app/code/Mage/Install/Model/Session.php diff --git a/app/code/core/Mage/Install/Model/Wizard.php b/app/code/Mage/Install/Model/Wizard.php similarity index 100% rename from app/code/core/Mage/Install/Model/Wizard.php rename to app/code/Mage/Install/Model/Wizard.php diff --git a/app/code/core/Mage/Install/controllers/IndexController.php b/app/code/Mage/Install/controllers/IndexController.php similarity index 100% rename from app/code/core/Mage/Install/controllers/IndexController.php rename to app/code/Mage/Install/controllers/IndexController.php diff --git a/app/code/core/Mage/Install/controllers/WizardController.php b/app/code/Mage/Install/controllers/WizardController.php similarity index 92% rename from app/code/core/Mage/Install/controllers/WizardController.php rename to app/code/Mage/Install/controllers/WizardController.php index 0c16d6a18bab2..e1d8ea845f86a 100644 --- a/app/code/core/Mage/Install/controllers/WizardController.php +++ b/app/code/Mage/Install/controllers/WizardController.php @@ -29,6 +29,14 @@ */ class Mage_Install_WizardController extends Mage_Install_Controller_Action { + /** + * Perform necessary checks for all actions + * + * Redirect out if system is already installed + * Throw a bootstrap exception if page cannot be displayed due to misconfigured base directories + * + * @throws Magento_BootstrapException + */ public function preDispatch() { if (Mage::isInstalled()) { @@ -37,45 +45,21 @@ public function preDispatch() return; } - if (!$this->_verifyTheme()) { - return; + /** @var $dirs Mage_Core_Model_Dir */ + $dirs = $this->_objectManager->get('Mage_Core_Model_Dir'); + $dir = $dirs->getDir(Mage_Core_Model_Dir::STATIC_VIEW); + /** @var $filesystem Magento_Filesystem */ + $filesystem = $this->_objectManager->get('Magento_Filesystem'); + if (!$filesystem->isDirectory($dir) || !$filesystem->isWritable($dir)) { + throw new Magento_BootstrapException( + "To proceed with installation, ensure that path '{$dir}' is a writable directory." + ); } $this->setFlag('', self::FLAG_NO_CHECK_INSTALLATION, true); return parent::preDispatch(); } - /** - * Verify that the folder for theme publication is writable. Web installation is unable to proceed without write - * permissions. - * - * @return bool - */ - protected function _verifyTheme() - { - /** @var Magento_Filesystem $filesystem */ - $pubTheme = Mage::getDesign()->getPublicDir(); - - try { - $filesystem = $this->_objectManager->get('Magento_Filesystem'); - $filesystem->setIsAllowCreateDirectories(true); - $filesystem->ensureDirectoryExists($pubTheme, 0777); - $isWritable = $filesystem->isWritable($pubTheme); - } catch (Magento_Filesystem_Exception $e) { - $isWritable = false; - } - - if (!$isWritable) { - $this->setFlag('', self::FLAG_NO_DISPATCH, true); - $this->getResponse()->setHeader('Content-Type', 'text/plain;charset=UTF-8') - ->setHttpResponseCode(503) - ->setBody("To proceed with installation, ensure that the path '{$pubTheme}' is writable.") - ; - return false; - } - return true; - } - /** * Retrieve installer object * diff --git a/app/code/Mage/Install/etc/config.xml b/app/code/Mage/Install/etc/config.xml new file mode 100644 index 0000000000000..ec74ff5d5c913 --- /dev/null +++ b/app/code/Mage/Install/etc/config.xml @@ -0,0 +1,99 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Install + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <modules> + <Mage_Install> + <version>0.7.0</version> + <active>true</active> + <depends> + <Mage_Core/> + </depends> + </Mage_Install> + </modules> + <frontend> + <secure_url> + <install>/install/wizard/checkSecureHost</install> + </secure_url> + <routers> + <install> + <use>standard</use> + <args> + <module>Mage_Install</module> + <frontName>install</frontName> + </args> + </install> + </routers> + </frontend> + <install> + <databases> + <mysql4> + <type>pdo_mysql</type> + <initStatements>SET NAMES utf8</initStatements> + <min_version>4.1.20</min_version> + <extensions> + <pdo_mysql>1</pdo_mysql> + </extensions> + </mysql4> + </databases> + <events> + <controller_action_predispatch> + <observers> + <checkConnection> + <class>Mage_Core_Model_Resource</class> + <method>checkDbConnection</method> + </checkConnection> + </observers> + </controller_action_predispatch> + <core_locale_set_locale> + <observers> + <bind_locale> + <class>Mage_Install_Model_Observer</class> + <method>bindLocale</method> + </bind_locale> + </observers> + </core_locale_set_locale> + </events> + <translate> + <modules> + <Mage_Install> + <files> + <default>Mage_Install.csv</default> + </files> + </Mage_Install> + </modules> + </translate> + <layout> + <updates> + <install module="Mage_Install"> + <file>layout.xml</file> + </install> + </updates> + </layout> + <eula_file>LICENSE.html</eula_file> + </install> +</config> diff --git a/app/code/core/Mage/Install/etc/install.xml b/app/code/Mage/Install/etc/install.xml similarity index 100% rename from app/code/core/Mage/Install/etc/install.xml rename to app/code/Mage/Install/etc/install.xml diff --git a/app/code/core/Mage/Install/locale/de_DE/Mage_Install.csv b/app/code/Mage/Install/locale/de_DE/Mage_Install.csv similarity index 100% rename from app/code/core/Mage/Install/locale/de_DE/Mage_Install.csv rename to app/code/Mage/Install/locale/de_DE/Mage_Install.csv diff --git a/app/code/core/Mage/Install/locale/en_US/Mage_Install.csv b/app/code/Mage/Install/locale/en_US/Mage_Install.csv similarity index 100% rename from app/code/core/Mage/Install/locale/en_US/Mage_Install.csv rename to app/code/Mage/Install/locale/en_US/Mage_Install.csv diff --git a/app/code/core/Mage/Install/locale/es_ES/Mage_Install.csv b/app/code/Mage/Install/locale/es_ES/Mage_Install.csv similarity index 100% rename from app/code/core/Mage/Install/locale/es_ES/Mage_Install.csv rename to app/code/Mage/Install/locale/es_ES/Mage_Install.csv diff --git a/app/code/core/Mage/Install/locale/fr_FR/Mage_Install.csv b/app/code/Mage/Install/locale/fr_FR/Mage_Install.csv similarity index 100% rename from app/code/core/Mage/Install/locale/fr_FR/Mage_Install.csv rename to app/code/Mage/Install/locale/fr_FR/Mage_Install.csv diff --git a/app/code/core/Mage/Install/locale/nl_NL/Mage_Install.csv b/app/code/Mage/Install/locale/nl_NL/Mage_Install.csv similarity index 100% rename from app/code/core/Mage/Install/locale/nl_NL/Mage_Install.csv rename to app/code/Mage/Install/locale/nl_NL/Mage_Install.csv diff --git a/app/code/core/Mage/Install/locale/pt_BR/Mage_Install.csv b/app/code/Mage/Install/locale/pt_BR/Mage_Install.csv similarity index 100% rename from app/code/core/Mage/Install/locale/pt_BR/Mage_Install.csv rename to app/code/Mage/Install/locale/pt_BR/Mage_Install.csv diff --git a/app/code/core/Mage/Install/locale/zh_CN/Mage_Install.csv b/app/code/Mage/Install/locale/zh_CN/Mage_Install.csv similarity index 100% rename from app/code/core/Mage/Install/locale/zh_CN/Mage_Install.csv rename to app/code/Mage/Install/locale/zh_CN/Mage_Install.csv diff --git a/app/code/core/Mage/Install/view/install/begin.phtml b/app/code/Mage/Install/view/install/begin.phtml similarity index 100% rename from app/code/core/Mage/Install/view/install/begin.phtml rename to app/code/Mage/Install/view/install/begin.phtml diff --git a/app/code/core/Mage/Install/view/install/config.phtml b/app/code/Mage/Install/view/install/config.phtml similarity index 100% rename from app/code/core/Mage/Install/view/install/config.phtml rename to app/code/Mage/Install/view/install/config.phtml diff --git a/app/code/core/Mage/Install/view/install/create_admin.phtml b/app/code/Mage/Install/view/install/create_admin.phtml similarity index 100% rename from app/code/core/Mage/Install/view/install/create_admin.phtml rename to app/code/Mage/Install/view/install/create_admin.phtml diff --git a/app/code/core/Mage/Install/view/install/css/mage-js-ee-style.css b/app/code/Mage/Install/view/install/css/mage-js-ee-style.css similarity index 100% rename from app/code/core/Mage/Install/view/install/css/mage-js-ee-style.css rename to app/code/Mage/Install/view/install/css/mage-js-ee-style.css diff --git a/app/code/core/Mage/Install/view/install/css/mage-js-style.css b/app/code/Mage/Install/view/install/css/mage-js-style.css similarity index 100% rename from app/code/core/Mage/Install/view/install/css/mage-js-style.css rename to app/code/Mage/Install/view/install/css/mage-js-style.css diff --git a/app/code/core/Mage/Install/view/install/css/validate.css b/app/code/Mage/Install/view/install/css/validate.css similarity index 100% rename from app/code/core/Mage/Install/view/install/css/validate.css rename to app/code/Mage/Install/view/install/css/validate.css diff --git a/app/code/core/Mage/Install/view/install/db/main.phtml b/app/code/Mage/Install/view/install/db/main.phtml similarity index 100% rename from app/code/core/Mage/Install/view/install/db/main.phtml rename to app/code/Mage/Install/view/install/db/main.phtml diff --git a/app/code/core/Mage/Install/view/install/db/mysql4.phtml b/app/code/Mage/Install/view/install/db/mysql4.phtml similarity index 100% rename from app/code/core/Mage/Install/view/install/db/mysql4.phtml rename to app/code/Mage/Install/view/install/db/mysql4.phtml diff --git a/app/code/core/Mage/Install/view/install/download.phtml b/app/code/Mage/Install/view/install/download.phtml similarity index 100% rename from app/code/core/Mage/Install/view/install/download.phtml rename to app/code/Mage/Install/view/install/download.phtml diff --git a/app/code/core/Mage/Install/view/install/end.phtml b/app/code/Mage/Install/view/install/end.phtml similarity index 100% rename from app/code/core/Mage/Install/view/install/end.phtml rename to app/code/Mage/Install/view/install/end.phtml diff --git a/app/code/core/Mage/Install/view/install/images/validation_advice_bg.gif b/app/code/Mage/Install/view/install/images/validation_advice_bg.gif similarity index 100% rename from app/code/core/Mage/Install/view/install/images/validation_advice_bg.gif rename to app/code/Mage/Install/view/install/images/validation_advice_bg.gif diff --git a/app/code/core/Mage/Install/view/install/js/install.js b/app/code/Mage/Install/view/install/js/install.js similarity index 100% rename from app/code/core/Mage/Install/view/install/js/install.js rename to app/code/Mage/Install/view/install/js/install.js diff --git a/app/code/core/Mage/Install/view/install/layout.xml b/app/code/Mage/Install/view/install/layout.xml similarity index 100% rename from app/code/core/Mage/Install/view/install/layout.xml rename to app/code/Mage/Install/view/install/layout.xml diff --git a/app/code/core/Mage/Install/view/install/locale.phtml b/app/code/Mage/Install/view/install/locale.phtml similarity index 100% rename from app/code/core/Mage/Install/view/install/locale.phtml rename to app/code/Mage/Install/view/install/locale.phtml diff --git a/app/code/Mage/Install/view/install/page.phtml b/app/code/Mage/Install/view/install/page.phtml new file mode 100644 index 0000000000000..cbabe2f6823a0 --- /dev/null +++ b/app/code/Mage/Install/view/install/page.phtml @@ -0,0 +1,123 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category design + * @package default_default + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php +/** + * Template for Mage_Page_Block_Html + */ +?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> + <title><?php echo Mage::helper('Mage_Install_Helper_Data')->__('Magento Installation Wizard') ?> + + + + + + + + + + + + + + + + helper('Mage_Core_Helper_Js')->getTranslatorScript() ?> + + + + +
    +
    +
    +

    + <?php echo Mage::helper('Mage_Install_Helper_Data')->__('Magento') ?> +

    + + getChildHtml('topSearch') ?> + +
    + +
    + getChildHtml('topRightLinks') ?> +
    +
    + +
    +
    + getChildHtml('topMenu') ?> +
    + + + +getChildHtml('store') ?> +
    +
    + getChildHtml('breadcrumbs') ?> + + +
    + getChildHtml('left') ?> +
    +
    + + getChildHtml('global_messages') ?> + + + getChildHtml('content') ?> + +
    +
    + +
    + + + + + + + diff --git a/app/code/core/Mage/Install/view/install/state.phtml b/app/code/Mage/Install/view/install/state.phtml similarity index 100% rename from app/code/core/Mage/Install/view/install/state.phtml rename to app/code/Mage/Install/view/install/state.phtml diff --git a/app/code/core/Mage/Log/Helper/Data.php b/app/code/Mage/Log/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Log/Helper/Data.php rename to app/code/Mage/Log/Helper/Data.php diff --git a/app/code/core/Mage/Log/Model/Aggregation.php b/app/code/Mage/Log/Model/Aggregation.php similarity index 100% rename from app/code/core/Mage/Log/Model/Aggregation.php rename to app/code/Mage/Log/Model/Aggregation.php diff --git a/app/code/core/Mage/Log/Model/Cron.php b/app/code/Mage/Log/Model/Cron.php similarity index 100% rename from app/code/core/Mage/Log/Model/Cron.php rename to app/code/Mage/Log/Model/Cron.php diff --git a/app/code/core/Mage/Log/Model/Customer.php b/app/code/Mage/Log/Model/Customer.php similarity index 100% rename from app/code/core/Mage/Log/Model/Customer.php rename to app/code/Mage/Log/Model/Customer.php diff --git a/app/code/Mage/Log/Model/EntryPoint/Shell.php b/app/code/Mage/Log/Model/EntryPoint/Shell.php new file mode 100644 index 0000000000000..1ddee1d034323 --- /dev/null +++ b/app/code/Mage/Log/Model/EntryPoint/Shell.php @@ -0,0 +1,55 @@ +_objectManager->configure(array( + 'Mage_Log_Model_Shell' => array( + 'parameters' => array( + 'entryPoint' => $entryPoint, + ) + ) + )); + } + + /** + * Process request to application + */ + public function processRequest() + { + /** @var $shell Mage_Log_Model_Shell */ + $shell = $this->_objectManager->create('Mage_Log_Model_Shell'); + $shell->run(); + } + +} diff --git a/app/code/core/Mage/Log/Model/Log.php b/app/code/Mage/Log/Model/Log.php similarity index 100% rename from app/code/core/Mage/Log/Model/Log.php rename to app/code/Mage/Log/Model/Log.php diff --git a/app/code/core/Mage/Log/Model/Resource/Aggregation.php b/app/code/Mage/Log/Model/Resource/Aggregation.php similarity index 100% rename from app/code/core/Mage/Log/Model/Resource/Aggregation.php rename to app/code/Mage/Log/Model/Resource/Aggregation.php diff --git a/app/code/core/Mage/Log/Model/Resource/Customer.php b/app/code/Mage/Log/Model/Resource/Customer.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Log/Model/Resource/Customer.php rename to app/code/Mage/Log/Model/Resource/Customer.php diff --git a/app/code/core/Mage/Log/Model/Resource/Helper/Mysql4.php b/app/code/Mage/Log/Model/Resource/Helper/Mysql4.php similarity index 100% rename from app/code/core/Mage/Log/Model/Resource/Helper/Mysql4.php rename to app/code/Mage/Log/Model/Resource/Helper/Mysql4.php diff --git a/app/code/core/Mage/Log/Model/Resource/Log.php b/app/code/Mage/Log/Model/Resource/Log.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Log/Model/Resource/Log.php rename to app/code/Mage/Log/Model/Resource/Log.php diff --git a/app/code/core/Mage/Log/Model/Resource/Shell.php b/app/code/Mage/Log/Model/Resource/Shell.php similarity index 100% rename from app/code/core/Mage/Log/Model/Resource/Shell.php rename to app/code/Mage/Log/Model/Resource/Shell.php diff --git a/app/code/core/Mage/Log/Model/Resource/Visitor.php b/app/code/Mage/Log/Model/Resource/Visitor.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Log/Model/Resource/Visitor.php rename to app/code/Mage/Log/Model/Resource/Visitor.php diff --git a/app/code/core/Mage/Log/Model/Resource/Visitor/Collection.php b/app/code/Mage/Log/Model/Resource/Visitor/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Log/Model/Resource/Visitor/Collection.php rename to app/code/Mage/Log/Model/Resource/Visitor/Collection.php diff --git a/app/code/core/Mage/Log/Model/Resource/Visitor/Online.php b/app/code/Mage/Log/Model/Resource/Visitor/Online.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Log/Model/Resource/Visitor/Online.php rename to app/code/Mage/Log/Model/Resource/Visitor/Online.php diff --git a/app/code/core/Mage/Log/Model/Resource/Visitor/Online/Collection.php b/app/code/Mage/Log/Model/Resource/Visitor/Online/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Log/Model/Resource/Visitor/Online/Collection.php rename to app/code/Mage/Log/Model/Resource/Visitor/Online/Collection.php diff --git a/app/code/core/Mage/Log/Model/Shell.php b/app/code/Mage/Log/Model/Shell.php similarity index 100% rename from app/code/core/Mage/Log/Model/Shell.php rename to app/code/Mage/Log/Model/Shell.php diff --git a/app/code/core/Mage/Log/Model/Visitor.php b/app/code/Mage/Log/Model/Visitor.php similarity index 100% rename from app/code/core/Mage/Log/Model/Visitor.php rename to app/code/Mage/Log/Model/Visitor.php diff --git a/app/code/core/Mage/Log/Model/Visitor/Online.php b/app/code/Mage/Log/Model/Visitor/Online.php similarity index 100% rename from app/code/core/Mage/Log/Model/Visitor/Online.php rename to app/code/Mage/Log/Model/Visitor/Online.php diff --git a/app/code/core/Mage/Log/data/log_setup/data-install-1.6.0.0.php b/app/code/Mage/Log/data/log_setup/data-install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Log/data/log_setup/data-install-1.6.0.0.php rename to app/code/Mage/Log/data/log_setup/data-install-1.6.0.0.php diff --git a/app/code/core/Mage/Log/etc/adminhtml/system.xml b/app/code/Mage/Log/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Log/etc/adminhtml/system.xml rename to app/code/Mage/Log/etc/adminhtml/system.xml diff --git a/app/code/Mage/Log/etc/config.xml b/app/code/Mage/Log/etc/config.xml new file mode 100644 index 0000000000000..ed2f7b7e234e2 --- /dev/null +++ b/app/code/Mage/Log/etc/config.xml @@ -0,0 +1,159 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + + + + + + + Googlebot/1.0 (googlebot@googlebot.com http://googlebot.com/) + Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) + Googlebot/2.1 (+http://www.googlebot.com/bot.html) + + + + + Mage_Log + + + + + + + + + + + Mage_Log_Model_Visitor + initByRequest + + + + + + + Mage_Log_Model_Visitor + saveByRequest + + + + + + + Mage_Log_Model_Visitor + bindCustomerLogin + + + + + + + Mage_Log_Model_Visitor + bindCustomerLogout + + + + + + + Mage_Log_Model_Visitor + bindQuoteCreate + + + + + + + Mage_Log_Model_Visitor + bindQuoteDestroy + + + + + + + + + + + Mage_Log.csv + + + + + + + + + 60 + + + + + 180 + 0 + + + + + + + + Mage_Log_Model_Cron::logClean + + + + + diff --git a/app/code/core/Mage/Log/locale/de_DE/Mage_Log.csv b/app/code/Mage/Log/locale/de_DE/Mage_Log.csv similarity index 100% rename from app/code/core/Mage/Log/locale/de_DE/Mage_Log.csv rename to app/code/Mage/Log/locale/de_DE/Mage_Log.csv diff --git a/app/code/core/Mage/Log/locale/en_US/Mage_Log.csv b/app/code/Mage/Log/locale/en_US/Mage_Log.csv similarity index 100% rename from app/code/core/Mage/Log/locale/en_US/Mage_Log.csv rename to app/code/Mage/Log/locale/en_US/Mage_Log.csv diff --git a/app/code/core/Mage/Log/locale/es_ES/Mage_Log.csv b/app/code/Mage/Log/locale/es_ES/Mage_Log.csv similarity index 100% rename from app/code/core/Mage/Log/locale/es_ES/Mage_Log.csv rename to app/code/Mage/Log/locale/es_ES/Mage_Log.csv diff --git a/app/code/core/Mage/Log/locale/fr_FR/Mage_Log.csv b/app/code/Mage/Log/locale/fr_FR/Mage_Log.csv similarity index 100% rename from app/code/core/Mage/Log/locale/fr_FR/Mage_Log.csv rename to app/code/Mage/Log/locale/fr_FR/Mage_Log.csv diff --git a/app/code/core/Mage/Log/locale/nl_NL/Mage_Log.csv b/app/code/Mage/Log/locale/nl_NL/Mage_Log.csv similarity index 100% rename from app/code/core/Mage/Log/locale/nl_NL/Mage_Log.csv rename to app/code/Mage/Log/locale/nl_NL/Mage_Log.csv diff --git a/app/code/core/Mage/Log/locale/pt_BR/Mage_Log.csv b/app/code/Mage/Log/locale/pt_BR/Mage_Log.csv similarity index 100% rename from app/code/core/Mage/Log/locale/pt_BR/Mage_Log.csv rename to app/code/Mage/Log/locale/pt_BR/Mage_Log.csv diff --git a/app/code/core/Mage/Log/locale/zh_CN/Mage_Log.csv b/app/code/Mage/Log/locale/zh_CN/Mage_Log.csv similarity index 100% rename from app/code/core/Mage/Log/locale/zh_CN/Mage_Log.csv rename to app/code/Mage/Log/locale/zh_CN/Mage_Log.csv diff --git a/app/code/core/Mage/Log/sql/log_setup/install-1.6.0.0.php b/app/code/Mage/Log/sql/log_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Log/sql/log_setup/install-1.6.0.0.php rename to app/code/Mage/Log/sql/log_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Log/view/email/cleanup_warning.html b/app/code/Mage/Log/view/email/cleanup_warning.html similarity index 100% rename from app/code/core/Mage/Log/view/email/cleanup_warning.html rename to app/code/Mage/Log/view/email/cleanup_warning.html diff --git a/app/code/core/Mage/Media/Helper/Data.php b/app/code/Mage/Media/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Media/Helper/Data.php rename to app/code/Mage/Media/Helper/Data.php diff --git a/app/code/core/Mage/Media/Model/File/Image.php b/app/code/Mage/Media/Model/File/Image.php similarity index 100% rename from app/code/core/Mage/Media/Model/File/Image.php rename to app/code/Mage/Media/Model/File/Image.php diff --git a/app/code/core/Mage/Media/Model/Image.php b/app/code/Mage/Media/Model/Image.php similarity index 100% rename from app/code/core/Mage/Media/Model/Image.php rename to app/code/Mage/Media/Model/Image.php diff --git a/app/code/core/Mage/Media/Model/Image/Config/Interface.php b/app/code/Mage/Media/Model/Image/Config/Interface.php similarity index 100% rename from app/code/core/Mage/Media/Model/Image/Config/Interface.php rename to app/code/Mage/Media/Model/Image/Config/Interface.php diff --git a/app/code/Mage/Media/etc/config.xml b/app/code/Mage/Media/etc/config.xml new file mode 100644 index 0000000000000..7dd888f31010f --- /dev/null +++ b/app/code/Mage/Media/etc/config.xml @@ -0,0 +1,69 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + + Mage_Media.csv + + + + + + + + + standard + + Mage_Media + media + + + + + + + + Mage_Media.csv + + + + + + diff --git a/app/code/core/Mage/Media/locale/de_DE/Mage_Media.csv b/app/code/Mage/Media/locale/de_DE/Mage_Media.csv similarity index 100% rename from app/code/core/Mage/Media/locale/de_DE/Mage_Media.csv rename to app/code/Mage/Media/locale/de_DE/Mage_Media.csv diff --git a/app/code/core/Mage/Media/locale/en_US/Mage_Media.csv b/app/code/Mage/Media/locale/en_US/Mage_Media.csv similarity index 100% rename from app/code/core/Mage/Media/locale/en_US/Mage_Media.csv rename to app/code/Mage/Media/locale/en_US/Mage_Media.csv diff --git a/app/code/core/Mage/Media/locale/es_ES/Mage_Media.csv b/app/code/Mage/Media/locale/es_ES/Mage_Media.csv similarity index 100% rename from app/code/core/Mage/Media/locale/es_ES/Mage_Media.csv rename to app/code/Mage/Media/locale/es_ES/Mage_Media.csv diff --git a/app/code/core/Mage/Media/locale/fr_FR/Mage_Media.csv b/app/code/Mage/Media/locale/fr_FR/Mage_Media.csv similarity index 100% rename from app/code/core/Mage/Media/locale/fr_FR/Mage_Media.csv rename to app/code/Mage/Media/locale/fr_FR/Mage_Media.csv diff --git a/app/code/core/Mage/Media/locale/nl_NL/Mage_Media.csv b/app/code/Mage/Media/locale/nl_NL/Mage_Media.csv similarity index 100% rename from app/code/core/Mage/Media/locale/nl_NL/Mage_Media.csv rename to app/code/Mage/Media/locale/nl_NL/Mage_Media.csv diff --git a/app/code/core/Mage/Media/locale/pt_BR/Mage_Media.csv b/app/code/Mage/Media/locale/pt_BR/Mage_Media.csv similarity index 100% rename from app/code/core/Mage/Media/locale/pt_BR/Mage_Media.csv rename to app/code/Mage/Media/locale/pt_BR/Mage_Media.csv diff --git a/app/code/core/Mage/Media/locale/zh_CN/Mage_Media.csv b/app/code/Mage/Media/locale/zh_CN/Mage_Media.csv similarity index 100% rename from app/code/core/Mage/Media/locale/zh_CN/Mage_Media.csv rename to app/code/Mage/Media/locale/zh_CN/Mage_Media.csv diff --git a/app/code/core/Mage/Newsletter/Block/Subscribe.php b/app/code/Mage/Newsletter/Block/Subscribe.php similarity index 100% rename from app/code/core/Mage/Newsletter/Block/Subscribe.php rename to app/code/Mage/Newsletter/Block/Subscribe.php diff --git a/app/code/core/Mage/Newsletter/Helper/Data.php b/app/code/Mage/Newsletter/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Newsletter/Helper/Data.php rename to app/code/Mage/Newsletter/Helper/Data.php diff --git a/app/code/core/Mage/Newsletter/Model/Message.php b/app/code/Mage/Newsletter/Model/Message.php similarity index 100% rename from app/code/core/Mage/Newsletter/Model/Message.php rename to app/code/Mage/Newsletter/Model/Message.php diff --git a/app/code/core/Mage/Newsletter/Model/Observer.php b/app/code/Mage/Newsletter/Model/Observer.php similarity index 100% rename from app/code/core/Mage/Newsletter/Model/Observer.php rename to app/code/Mage/Newsletter/Model/Observer.php diff --git a/app/code/core/Mage/Newsletter/Model/Problem.php b/app/code/Mage/Newsletter/Model/Problem.php similarity index 100% rename from app/code/core/Mage/Newsletter/Model/Problem.php rename to app/code/Mage/Newsletter/Model/Problem.php diff --git a/app/code/core/Mage/Newsletter/Model/Queue.php b/app/code/Mage/Newsletter/Model/Queue.php similarity index 100% rename from app/code/core/Mage/Newsletter/Model/Queue.php rename to app/code/Mage/Newsletter/Model/Queue.php diff --git a/app/code/core/Mage/Newsletter/Model/Queue/Options/Status.php b/app/code/Mage/Newsletter/Model/Queue/Options/Status.php similarity index 100% rename from app/code/core/Mage/Newsletter/Model/Queue/Options/Status.php rename to app/code/Mage/Newsletter/Model/Queue/Options/Status.php diff --git a/app/code/core/Mage/Newsletter/Model/Resource/Grid/Collection.php b/app/code/Mage/Newsletter/Model/Resource/Grid/Collection.php similarity index 100% rename from app/code/core/Mage/Newsletter/Model/Resource/Grid/Collection.php rename to app/code/Mage/Newsletter/Model/Resource/Grid/Collection.php diff --git a/app/code/core/Mage/Newsletter/Model/Resource/Problem.php b/app/code/Mage/Newsletter/Model/Resource/Problem.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Newsletter/Model/Resource/Problem.php rename to app/code/Mage/Newsletter/Model/Resource/Problem.php diff --git a/app/code/core/Mage/Newsletter/Model/Resource/Problem/Collection.php b/app/code/Mage/Newsletter/Model/Resource/Problem/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Newsletter/Model/Resource/Problem/Collection.php rename to app/code/Mage/Newsletter/Model/Resource/Problem/Collection.php diff --git a/app/code/core/Mage/Newsletter/Model/Resource/Queue.php b/app/code/Mage/Newsletter/Model/Resource/Queue.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Newsletter/Model/Resource/Queue.php rename to app/code/Mage/Newsletter/Model/Resource/Queue.php diff --git a/app/code/core/Mage/Newsletter/Model/Resource/Queue/Collection.php b/app/code/Mage/Newsletter/Model/Resource/Queue/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Newsletter/Model/Resource/Queue/Collection.php rename to app/code/Mage/Newsletter/Model/Resource/Queue/Collection.php diff --git a/app/code/core/Mage/Newsletter/Model/Resource/Queue/Grid/Collection.php b/app/code/Mage/Newsletter/Model/Resource/Queue/Grid/Collection.php similarity index 100% rename from app/code/core/Mage/Newsletter/Model/Resource/Queue/Grid/Collection.php rename to app/code/Mage/Newsletter/Model/Resource/Queue/Grid/Collection.php diff --git a/app/code/core/Mage/Newsletter/Model/Resource/Subscriber.php b/app/code/Mage/Newsletter/Model/Resource/Subscriber.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Newsletter/Model/Resource/Subscriber.php rename to app/code/Mage/Newsletter/Model/Resource/Subscriber.php diff --git a/app/code/core/Mage/Newsletter/Model/Resource/Subscriber/Collection.php b/app/code/Mage/Newsletter/Model/Resource/Subscriber/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Newsletter/Model/Resource/Subscriber/Collection.php rename to app/code/Mage/Newsletter/Model/Resource/Subscriber/Collection.php diff --git a/app/code/core/Mage/Newsletter/Model/Resource/Template.php b/app/code/Mage/Newsletter/Model/Resource/Template.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Newsletter/Model/Resource/Template.php rename to app/code/Mage/Newsletter/Model/Resource/Template.php diff --git a/app/code/core/Mage/Newsletter/Model/Resource/Template/Collection.php b/app/code/Mage/Newsletter/Model/Resource/Template/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Newsletter/Model/Resource/Template/Collection.php rename to app/code/Mage/Newsletter/Model/Resource/Template/Collection.php diff --git a/app/code/core/Mage/Newsletter/Model/Session.php b/app/code/Mage/Newsletter/Model/Session.php similarity index 100% rename from app/code/core/Mage/Newsletter/Model/Session.php rename to app/code/Mage/Newsletter/Model/Session.php diff --git a/app/code/core/Mage/Newsletter/Model/Subscriber.php b/app/code/Mage/Newsletter/Model/Subscriber.php similarity index 100% rename from app/code/core/Mage/Newsletter/Model/Subscriber.php rename to app/code/Mage/Newsletter/Model/Subscriber.php diff --git a/app/code/core/Mage/Newsletter/Model/Template.php b/app/code/Mage/Newsletter/Model/Template.php similarity index 100% rename from app/code/core/Mage/Newsletter/Model/Template.php rename to app/code/Mage/Newsletter/Model/Template.php diff --git a/app/code/core/Mage/Newsletter/Model/Template/Filter.php b/app/code/Mage/Newsletter/Model/Template/Filter.php similarity index 100% rename from app/code/core/Mage/Newsletter/Model/Template/Filter.php rename to app/code/Mage/Newsletter/Model/Template/Filter.php diff --git a/app/code/core/Mage/Newsletter/controllers/ManageController.php b/app/code/Mage/Newsletter/controllers/ManageController.php similarity index 100% rename from app/code/core/Mage/Newsletter/controllers/ManageController.php rename to app/code/Mage/Newsletter/controllers/ManageController.php diff --git a/app/code/core/Mage/Newsletter/controllers/SubscriberController.php b/app/code/Mage/Newsletter/controllers/SubscriberController.php similarity index 100% rename from app/code/core/Mage/Newsletter/controllers/SubscriberController.php rename to app/code/Mage/Newsletter/controllers/SubscriberController.php diff --git a/app/code/core/Mage/Newsletter/data/newsletter_setup/data-upgrade-1.6.0.0-1.6.0.1.php b/app/code/Mage/Newsletter/data/newsletter_setup/data-upgrade-1.6.0.0-1.6.0.1.php similarity index 100% rename from app/code/core/Mage/Newsletter/data/newsletter_setup/data-upgrade-1.6.0.0-1.6.0.1.php rename to app/code/Mage/Newsletter/data/newsletter_setup/data-upgrade-1.6.0.0-1.6.0.1.php diff --git a/app/code/core/Mage/Newsletter/data/newsletter_setup/data-upgrade-1.6.0.1-1.6.0.2.php b/app/code/Mage/Newsletter/data/newsletter_setup/data-upgrade-1.6.0.1-1.6.0.2.php similarity index 100% rename from app/code/core/Mage/Newsletter/data/newsletter_setup/data-upgrade-1.6.0.1-1.6.0.2.php rename to app/code/Mage/Newsletter/data/newsletter_setup/data-upgrade-1.6.0.1-1.6.0.2.php diff --git a/app/code/Mage/Newsletter/etc/adminhtml/acl.xml b/app/code/Mage/Newsletter/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..3ddab372f33e9 --- /dev/null +++ b/app/code/Mage/Newsletter/etc/adminhtml/acl.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Mage/Newsletter/etc/adminhtml/menu.xml b/app/code/Mage/Newsletter/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..0d92157ae031b --- /dev/null +++ b/app/code/Mage/Newsletter/etc/adminhtml/menu.xml @@ -0,0 +1,35 @@ + + + + + + + + + + diff --git a/app/code/core/Mage/Newsletter/etc/adminhtml/system.xml b/app/code/Mage/Newsletter/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Newsletter/etc/adminhtml/system.xml rename to app/code/Mage/Newsletter/etc/adminhtml/system.xml diff --git a/app/code/Mage/Newsletter/etc/config.xml b/app/code/Mage/Newsletter/etc/config.xml new file mode 100644 index 0000000000000..3471278420264 --- /dev/null +++ b/app/code/Mage/Newsletter/etc/config.xml @@ -0,0 +1,185 @@ + + + + + + 1.6.0.2 + true + + + + + + + + + + + + + Mage_Newsletter + + + + + + Mage_Newsletter_Model_Template_Filter + + + + + + + + Mage_Newsletter_Model_Observer + subscribeCustomer + + + + + + + Mage_Newsletter_Model_Observer + customerDeleted + + + + + + + + + Mage_Newsletter.csv + + + + + + + + layout.xml + + + + + + + + + + Mage_Newsletter_Model_Observer + subscribeCustomer + + + + + + + Mage_Newsletter_Model_Observer + customerDeleted + + + + + + + standard + + Mage_Newsletter + newsletter + + + + + + + + Mage_Newsletter.csv + + + + + + + + layout.xml + + + + + /newsletter/manage/ + + + + + + 1 + 0 + support + newsletter_subscription_confirm_email_template + general + newsletter_subscription_success_email_template + support + newsletter_subscription_un_email_template + + + 0 + + + + + + + + */5 * * * * + + + Mage_Newsletter_Model_Observer::scheduledSend + + + + + diff --git a/app/code/core/Mage/Newsletter/locale/de_DE/Mage_Newsletter.csv b/app/code/Mage/Newsletter/locale/de_DE/Mage_Newsletter.csv similarity index 100% rename from app/code/core/Mage/Newsletter/locale/de_DE/Mage_Newsletter.csv rename to app/code/Mage/Newsletter/locale/de_DE/Mage_Newsletter.csv diff --git a/app/code/core/Mage/Newsletter/locale/en_US/Mage_Newsletter.csv b/app/code/Mage/Newsletter/locale/en_US/Mage_Newsletter.csv similarity index 100% rename from app/code/core/Mage/Newsletter/locale/en_US/Mage_Newsletter.csv rename to app/code/Mage/Newsletter/locale/en_US/Mage_Newsletter.csv diff --git a/app/code/core/Mage/Newsletter/locale/es_ES/Mage_Newsletter.csv b/app/code/Mage/Newsletter/locale/es_ES/Mage_Newsletter.csv similarity index 100% rename from app/code/core/Mage/Newsletter/locale/es_ES/Mage_Newsletter.csv rename to app/code/Mage/Newsletter/locale/es_ES/Mage_Newsletter.csv diff --git a/app/code/core/Mage/Newsletter/locale/fr_FR/Mage_Newsletter.csv b/app/code/Mage/Newsletter/locale/fr_FR/Mage_Newsletter.csv similarity index 100% rename from app/code/core/Mage/Newsletter/locale/fr_FR/Mage_Newsletter.csv rename to app/code/Mage/Newsletter/locale/fr_FR/Mage_Newsletter.csv diff --git a/app/code/core/Mage/Newsletter/locale/nl_NL/Mage_Newsletter.csv b/app/code/Mage/Newsletter/locale/nl_NL/Mage_Newsletter.csv similarity index 100% rename from app/code/core/Mage/Newsletter/locale/nl_NL/Mage_Newsletter.csv rename to app/code/Mage/Newsletter/locale/nl_NL/Mage_Newsletter.csv diff --git a/app/code/core/Mage/Newsletter/locale/pt_BR/Mage_Newsletter.csv b/app/code/Mage/Newsletter/locale/pt_BR/Mage_Newsletter.csv similarity index 100% rename from app/code/core/Mage/Newsletter/locale/pt_BR/Mage_Newsletter.csv rename to app/code/Mage/Newsletter/locale/pt_BR/Mage_Newsletter.csv diff --git a/app/code/core/Mage/Newsletter/locale/zh_CN/Mage_Newsletter.csv b/app/code/Mage/Newsletter/locale/zh_CN/Mage_Newsletter.csv similarity index 100% rename from app/code/core/Mage/Newsletter/locale/zh_CN/Mage_Newsletter.csv rename to app/code/Mage/Newsletter/locale/zh_CN/Mage_Newsletter.csv diff --git a/app/code/core/Mage/Newsletter/sql/newsletter_setup/install-1.6.0.0.php b/app/code/Mage/Newsletter/sql/newsletter_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Newsletter/sql/newsletter_setup/install-1.6.0.0.php rename to app/code/Mage/Newsletter/sql/newsletter_setup/install-1.6.0.0.php diff --git a/app/code/Mage/Newsletter/view/adminhtml/layout.xml b/app/code/Mage/Newsletter/view/adminhtml/layout.xml new file mode 100644 index 0000000000000..bdc374827cf58 --- /dev/null +++ b/app/code/Mage/Newsletter/view/adminhtml/layout.xml @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + queueGrid + Mage_Newsletter_Model_Resource_Queue_Grid_Collection + start_at + DESC + 1 + 1 + + + + + */*/edit + + getId + + + + + +
    ID
    + queue_id + col-id + col-id +
    +
    + + +
    Queue Start
    + datetime + queue_start_at + 1 + ---- + col-start + col-start +
    +
    + + +
    Queue Finish
    + datetime + queue_finish_at + 1 + ---- + col-finish + col-finish +
    +
    + + +
    Subject
    + newsletter_subject + col-subject + col-subject +
    +
    + + +
    Status
    + queue_status + options + Mage_Newsletter_Model_Queue_Options_Status + col-status + col-status +
    +
    + + + + +
    Processed
    + number + subscribers_sent + col-processed + col-processed +
    +
    + + +
    Recipients
    + number + subscribers_total + col-recipients + col-recipients +
    +
    + + +
    Action
    + 0 + 0 + 1 + Mage_Adminhtml_Block_Newsletter_Queue_Grid_Renderer_Action + col-actions + col-actions +
    +
    +
    +
    +
    +
    +
    diff --git a/app/code/core/Mage/Newsletter/view/adminhtml/queue/list.phtml b/app/code/Mage/Newsletter/view/adminhtml/queue/list.phtml similarity index 100% rename from app/code/core/Mage/Newsletter/view/adminhtml/queue/list.phtml rename to app/code/Mage/Newsletter/view/adminhtml/queue/list.phtml diff --git a/app/code/core/Mage/Newsletter/view/email/subscr_confirm.html b/app/code/Mage/Newsletter/view/email/subscr_confirm.html similarity index 100% rename from app/code/core/Mage/Newsletter/view/email/subscr_confirm.html rename to app/code/Mage/Newsletter/view/email/subscr_confirm.html diff --git a/app/code/core/Mage/Newsletter/view/email/subscr_success.html b/app/code/Mage/Newsletter/view/email/subscr_success.html similarity index 100% rename from app/code/core/Mage/Newsletter/view/email/subscr_success.html rename to app/code/Mage/Newsletter/view/email/subscr_success.html diff --git a/app/code/core/Mage/Newsletter/view/email/unsub_success.html b/app/code/Mage/Newsletter/view/email/unsub_success.html similarity index 100% rename from app/code/core/Mage/Newsletter/view/email/unsub_success.html rename to app/code/Mage/Newsletter/view/email/unsub_success.html diff --git a/app/code/core/Mage/Newsletter/view/frontend/layout.xml b/app/code/Mage/Newsletter/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/Newsletter/view/frontend/layout.xml rename to app/code/Mage/Newsletter/view/frontend/layout.xml diff --git a/app/code/core/Mage/Newsletter/view/frontend/newsletter.js b/app/code/Mage/Newsletter/view/frontend/newsletter.js similarity index 100% rename from app/code/core/Mage/Newsletter/view/frontend/newsletter.js rename to app/code/Mage/Newsletter/view/frontend/newsletter.js diff --git a/app/code/core/Mage/Newsletter/view/frontend/subscribe.phtml b/app/code/Mage/Newsletter/view/frontend/subscribe.phtml similarity index 100% rename from app/code/core/Mage/Newsletter/view/frontend/subscribe.phtml rename to app/code/Mage/Newsletter/view/frontend/subscribe.phtml diff --git a/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Admin/Token.php b/app/code/Mage/Oauth/Block/Adminhtml/Oauth/Admin/Token.php similarity index 100% rename from app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Admin/Token.php rename to app/code/Mage/Oauth/Block/Adminhtml/Oauth/Admin/Token.php diff --git a/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Admin/Token/Grid.php b/app/code/Mage/Oauth/Block/Adminhtml/Oauth/Admin/Token/Grid.php similarity index 100% rename from app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Admin/Token/Grid.php rename to app/code/Mage/Oauth/Block/Adminhtml/Oauth/Admin/Token/Grid.php diff --git a/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Authorize.php b/app/code/Mage/Oauth/Block/Adminhtml/Oauth/Authorize.php similarity index 100% rename from app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Authorize.php rename to app/code/Mage/Oauth/Block/Adminhtml/Oauth/Authorize.php diff --git a/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Authorize/Button.php b/app/code/Mage/Oauth/Block/Adminhtml/Oauth/Authorize/Button.php similarity index 100% rename from app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Authorize/Button.php rename to app/code/Mage/Oauth/Block/Adminhtml/Oauth/Authorize/Button.php diff --git a/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/AuthorizedTokens.php b/app/code/Mage/Oauth/Block/Adminhtml/Oauth/AuthorizedTokens.php similarity index 100% rename from app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/AuthorizedTokens.php rename to app/code/Mage/Oauth/Block/Adminhtml/Oauth/AuthorizedTokens.php diff --git a/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/AuthorizedTokens/Grid.php b/app/code/Mage/Oauth/Block/Adminhtml/Oauth/AuthorizedTokens/Grid.php similarity index 100% rename from app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/AuthorizedTokens/Grid.php rename to app/code/Mage/Oauth/Block/Adminhtml/Oauth/AuthorizedTokens/Grid.php diff --git a/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer.php b/app/code/Mage/Oauth/Block/Adminhtml/Oauth/Consumer.php similarity index 100% rename from app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer.php rename to app/code/Mage/Oauth/Block/Adminhtml/Oauth/Consumer.php diff --git a/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Edit.php b/app/code/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Edit.php similarity index 100% rename from app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Edit.php rename to app/code/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Edit.php diff --git a/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Edit/Form.php b/app/code/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Edit/Form.php rename to app/code/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Edit/Form.php diff --git a/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Grid.php b/app/code/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Grid.php similarity index 100% rename from app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Grid.php rename to app/code/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Grid.php diff --git a/app/code/core/Mage/Oauth/Block/Authorize.php b/app/code/Mage/Oauth/Block/Authorize.php similarity index 100% rename from app/code/core/Mage/Oauth/Block/Authorize.php rename to app/code/Mage/Oauth/Block/Authorize.php diff --git a/app/code/core/Mage/Oauth/Block/Authorize/Abstract.php b/app/code/Mage/Oauth/Block/Authorize/Abstract.php similarity index 100% rename from app/code/core/Mage/Oauth/Block/Authorize/Abstract.php rename to app/code/Mage/Oauth/Block/Authorize/Abstract.php diff --git a/app/code/core/Mage/Oauth/Block/Authorize/Button.php b/app/code/Mage/Oauth/Block/Authorize/Button.php similarity index 100% rename from app/code/core/Mage/Oauth/Block/Authorize/Button.php rename to app/code/Mage/Oauth/Block/Authorize/Button.php diff --git a/app/code/core/Mage/Oauth/Block/Authorize/ButtonBaseAbstract.php b/app/code/Mage/Oauth/Block/Authorize/ButtonBaseAbstract.php similarity index 100% rename from app/code/core/Mage/Oauth/Block/Authorize/ButtonBaseAbstract.php rename to app/code/Mage/Oauth/Block/Authorize/ButtonBaseAbstract.php diff --git a/app/code/core/Mage/Oauth/Block/AuthorizeBaseAbstract.php b/app/code/Mage/Oauth/Block/AuthorizeBaseAbstract.php similarity index 100% rename from app/code/core/Mage/Oauth/Block/AuthorizeBaseAbstract.php rename to app/code/Mage/Oauth/Block/AuthorizeBaseAbstract.php diff --git a/app/code/core/Mage/Oauth/Block/Customer/Token/List.php b/app/code/Mage/Oauth/Block/Customer/Token/List.php similarity index 100% rename from app/code/core/Mage/Oauth/Block/Customer/Token/List.php rename to app/code/Mage/Oauth/Block/Customer/Token/List.php diff --git a/app/code/core/Mage/Oauth/Exception.php b/app/code/Mage/Oauth/Exception.php similarity index 100% rename from app/code/core/Mage/Oauth/Exception.php rename to app/code/Mage/Oauth/Exception.php diff --git a/app/code/core/Mage/Oauth/Helper/Data.php b/app/code/Mage/Oauth/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Oauth/Helper/Data.php rename to app/code/Mage/Oauth/Helper/Data.php diff --git a/app/code/core/Mage/Oauth/Model/Consumer.php b/app/code/Mage/Oauth/Model/Consumer.php similarity index 100% rename from app/code/core/Mage/Oauth/Model/Consumer.php rename to app/code/Mage/Oauth/Model/Consumer.php diff --git a/app/code/core/Mage/Oauth/Model/Consumer/Factory.php b/app/code/Mage/Oauth/Model/Consumer/Factory.php similarity index 100% rename from app/code/core/Mage/Oauth/Model/Consumer/Factory.php rename to app/code/Mage/Oauth/Model/Consumer/Factory.php diff --git a/app/code/core/Mage/Oauth/Model/Consumer/Validator/KeyLength.php b/app/code/Mage/Oauth/Model/Consumer/Validator/KeyLength.php similarity index 100% rename from app/code/core/Mage/Oauth/Model/Consumer/Validator/KeyLength.php rename to app/code/Mage/Oauth/Model/Consumer/Validator/KeyLength.php diff --git a/app/code/core/Mage/Oauth/Model/ConsumerInterface.php b/app/code/Mage/Oauth/Model/ConsumerInterface.php similarity index 100% rename from app/code/core/Mage/Oauth/Model/ConsumerInterface.php rename to app/code/Mage/Oauth/Model/ConsumerInterface.php diff --git a/app/code/core/Mage/Oauth/Model/Nonce.php b/app/code/Mage/Oauth/Model/Nonce.php similarity index 100% rename from app/code/core/Mage/Oauth/Model/Nonce.php rename to app/code/Mage/Oauth/Model/Nonce.php diff --git a/app/code/core/Mage/Oauth/Model/Nonce/Factory.php b/app/code/Mage/Oauth/Model/Nonce/Factory.php similarity index 100% rename from app/code/core/Mage/Oauth/Model/Nonce/Factory.php rename to app/code/Mage/Oauth/Model/Nonce/Factory.php diff --git a/app/code/core/Mage/Oauth/Model/Observer.php b/app/code/Mage/Oauth/Model/Observer.php similarity index 100% rename from app/code/core/Mage/Oauth/Model/Observer.php rename to app/code/Mage/Oauth/Model/Observer.php diff --git a/app/code/core/Mage/Oauth/Model/Resource/Consumer.php b/app/code/Mage/Oauth/Model/Resource/Consumer.php similarity index 100% rename from app/code/core/Mage/Oauth/Model/Resource/Consumer.php rename to app/code/Mage/Oauth/Model/Resource/Consumer.php diff --git a/app/code/core/Mage/Oauth/Model/Resource/Consumer/Collection.php b/app/code/Mage/Oauth/Model/Resource/Consumer/Collection.php similarity index 100% rename from app/code/core/Mage/Oauth/Model/Resource/Consumer/Collection.php rename to app/code/Mage/Oauth/Model/Resource/Consumer/Collection.php diff --git a/app/code/core/Mage/Oauth/Model/Resource/Nonce.php b/app/code/Mage/Oauth/Model/Resource/Nonce.php similarity index 100% rename from app/code/core/Mage/Oauth/Model/Resource/Nonce.php rename to app/code/Mage/Oauth/Model/Resource/Nonce.php diff --git a/app/code/core/Mage/Oauth/Model/Resource/Nonce/Collection.php b/app/code/Mage/Oauth/Model/Resource/Nonce/Collection.php similarity index 100% rename from app/code/core/Mage/Oauth/Model/Resource/Nonce/Collection.php rename to app/code/Mage/Oauth/Model/Resource/Nonce/Collection.php diff --git a/app/code/core/Mage/Oauth/Model/Resource/Setup.php b/app/code/Mage/Oauth/Model/Resource/Setup.php similarity index 100% rename from app/code/core/Mage/Oauth/Model/Resource/Setup.php rename to app/code/Mage/Oauth/Model/Resource/Setup.php diff --git a/app/code/core/Mage/Oauth/Model/Resource/Token.php b/app/code/Mage/Oauth/Model/Resource/Token.php similarity index 100% rename from app/code/core/Mage/Oauth/Model/Resource/Token.php rename to app/code/Mage/Oauth/Model/Resource/Token.php diff --git a/app/code/core/Mage/Oauth/Model/Resource/Token/Collection.php b/app/code/Mage/Oauth/Model/Resource/Token/Collection.php similarity index 100% rename from app/code/core/Mage/Oauth/Model/Resource/Token/Collection.php rename to app/code/Mage/Oauth/Model/Resource/Token/Collection.php diff --git a/app/code/core/Mage/Oauth/Model/Server.php b/app/code/Mage/Oauth/Model/Server.php similarity index 100% rename from app/code/core/Mage/Oauth/Model/Server.php rename to app/code/Mage/Oauth/Model/Server.php diff --git a/app/code/core/Mage/Oauth/Model/Token.php b/app/code/Mage/Oauth/Model/Token.php similarity index 100% rename from app/code/core/Mage/Oauth/Model/Token.php rename to app/code/Mage/Oauth/Model/Token.php diff --git a/app/code/core/Mage/Oauth/Model/Token/Factory.php b/app/code/Mage/Oauth/Model/Token/Factory.php similarity index 100% rename from app/code/core/Mage/Oauth/Model/Token/Factory.php rename to app/code/Mage/Oauth/Model/Token/Factory.php diff --git a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php b/app/code/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php similarity index 99% rename from app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php rename to app/code/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php index 708c1d33b02bf..84451fd4a9f1c 100644 --- a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php +++ b/app/code/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php @@ -19,7 +19,7 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage - * @package Mage_Downloadable + * @package Mage_Oauth * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php b/app/code/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php similarity index 99% rename from app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php rename to app/code/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php index 70a7f90aa31c6..5beb8c7fa8deb 100644 --- a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php +++ b/app/code/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php @@ -19,7 +19,7 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage - * @package Mage_Downloadable + * @package Mage_Oauth * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php b/app/code/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php similarity index 99% rename from app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php rename to app/code/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php index 695971337b8d3..3c6881fff462d 100644 --- a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php +++ b/app/code/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php @@ -19,7 +19,7 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage - * @package Mage_Downloadable + * @package Mage_Oauth * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php b/app/code/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php similarity index 100% rename from app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php rename to app/code/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php diff --git a/app/code/core/Mage/Oauth/controllers/AuthorizeController.php b/app/code/Mage/Oauth/controllers/AuthorizeController.php similarity index 100% rename from app/code/core/Mage/Oauth/controllers/AuthorizeController.php rename to app/code/Mage/Oauth/controllers/AuthorizeController.php diff --git a/app/code/core/Mage/Oauth/controllers/Customer/TokenController.php b/app/code/Mage/Oauth/controllers/Customer/TokenController.php similarity index 100% rename from app/code/core/Mage/Oauth/controllers/Customer/TokenController.php rename to app/code/Mage/Oauth/controllers/Customer/TokenController.php diff --git a/app/code/core/Mage/Oauth/controllers/InitiateController.php b/app/code/Mage/Oauth/controllers/InitiateController.php similarity index 100% rename from app/code/core/Mage/Oauth/controllers/InitiateController.php rename to app/code/Mage/Oauth/controllers/InitiateController.php diff --git a/app/code/core/Mage/Oauth/controllers/TokenController.php b/app/code/Mage/Oauth/controllers/TokenController.php similarity index 100% rename from app/code/core/Mage/Oauth/controllers/TokenController.php rename to app/code/Mage/Oauth/controllers/TokenController.php diff --git a/app/code/core/Mage/Oauth/etc/adminhtml/menu.xml b/app/code/Mage/Oauth/etc/adminhtml/menu.xml similarity index 100% rename from app/code/core/Mage/Oauth/etc/adminhtml/menu.xml rename to app/code/Mage/Oauth/etc/adminhtml/menu.xml diff --git a/app/code/core/Mage/Oauth/etc/adminhtml/system.xml b/app/code/Mage/Oauth/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Oauth/etc/adminhtml/system.xml rename to app/code/Mage/Oauth/etc/adminhtml/system.xml diff --git a/app/code/Mage/Oauth/etc/config.xml b/app/code/Mage/Oauth/etc/config.xml new file mode 100644 index 0000000000000..bacdc606ba365 --- /dev/null +++ b/app/code/Mage/Oauth/etc/config.xml @@ -0,0 +1,154 @@ + + + + + + 1.0.0.0 + true + + + + + + + + + + + + + Mage_Oauth + Mage_Oauth_Model_Resource_Setup + + + + + + + + Mage_Oauth_Model_Observer + afterCustomerLogin + + + + + + + Mage_Oauth_Model_Observer + afterAdminLogin + + + + + + + Mage_Oauth_Model_Observer + afterAdminLoginFailed + + + + + + + + + + + + Mage_Oauth_Adminhtml + + + + + + + + + + + Mage_Oauth.csv + + + + + + + + layout.xml + + + + + + + + standard + + Mage_Oauth + oauth + + + + + + + layout.xml + + + + + + + + Mage_Oauth.csv + + + + + + + + + 100 + 120 + + + general + + + + + diff --git a/app/code/core/Mage/Oauth/locale/de_DE/Mage_Oauth.csv b/app/code/Mage/Oauth/locale/de_DE/Mage_Oauth.csv similarity index 100% rename from app/code/core/Mage/Oauth/locale/de_DE/Mage_Oauth.csv rename to app/code/Mage/Oauth/locale/de_DE/Mage_Oauth.csv diff --git a/app/code/core/Mage/Oauth/locale/en_US/Mage_Oauth.csv b/app/code/Mage/Oauth/locale/en_US/Mage_Oauth.csv similarity index 100% rename from app/code/core/Mage/Oauth/locale/en_US/Mage_Oauth.csv rename to app/code/Mage/Oauth/locale/en_US/Mage_Oauth.csv diff --git a/app/code/core/Mage/Oauth/locale/es_ES/Mage_Oauth.csv b/app/code/Mage/Oauth/locale/es_ES/Mage_Oauth.csv similarity index 100% rename from app/code/core/Mage/Oauth/locale/es_ES/Mage_Oauth.csv rename to app/code/Mage/Oauth/locale/es_ES/Mage_Oauth.csv diff --git a/app/code/core/Mage/Oauth/locale/fr_FR/Mage_Oauth.csv b/app/code/Mage/Oauth/locale/fr_FR/Mage_Oauth.csv similarity index 100% rename from app/code/core/Mage/Oauth/locale/fr_FR/Mage_Oauth.csv rename to app/code/Mage/Oauth/locale/fr_FR/Mage_Oauth.csv diff --git a/app/code/core/Mage/Oauth/locale/nl_NL/Mage_Oauth.csv b/app/code/Mage/Oauth/locale/nl_NL/Mage_Oauth.csv similarity index 100% rename from app/code/core/Mage/Oauth/locale/nl_NL/Mage_Oauth.csv rename to app/code/Mage/Oauth/locale/nl_NL/Mage_Oauth.csv diff --git a/app/code/core/Mage/Oauth/locale/pt_BR/Mage_Oauth.csv b/app/code/Mage/Oauth/locale/pt_BR/Mage_Oauth.csv similarity index 100% rename from app/code/core/Mage/Oauth/locale/pt_BR/Mage_Oauth.csv rename to app/code/Mage/Oauth/locale/pt_BR/Mage_Oauth.csv diff --git a/app/code/core/Mage/Oauth/locale/zh_CN/Mage_Oauth.csv b/app/code/Mage/Oauth/locale/zh_CN/Mage_Oauth.csv similarity index 100% rename from app/code/core/Mage/Oauth/locale/zh_CN/Mage_Oauth.csv rename to app/code/Mage/Oauth/locale/zh_CN/Mage_Oauth.csv diff --git a/app/code/Mage/Oauth/sql/oauth_setup/install-1.0.0.0.php b/app/code/Mage/Oauth/sql/oauth_setup/install-1.0.0.0.php new file mode 100644 index 0000000000000..4b4cd6adf9ad8 --- /dev/null +++ b/app/code/Mage/Oauth/sql/oauth_setup/install-1.0.0.0.php @@ -0,0 +1,198 @@ +startSetup(); + +/** @var $adapter Varien_Db_Adapter_Pdo_Mysql */ +$adapter = $installer->getConnection(); + +/** + * Create table 'oauth_consumer' + */ +$table = $adapter->newTable($installer->getTable('oauth_consumer')) + ->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( + 'identity' => true, + 'unsigned' => true, + 'nullable' => false, + 'primary' => true, + ), 'Entity Id') + ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array( + 'nullable' => false, + 'default' => Varien_Db_Ddl_Table::TIMESTAMP_INIT + ), 'Created At') + ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array( + 'nullable' => true + ), 'Updated At') + ->addColumn('name', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array( + 'nullable' => false + ), 'Name of consumer') + ->addColumn('key', Varien_Db_Ddl_Table::TYPE_TEXT, Mage_Oauth_Model_Consumer::KEY_LENGTH, array( + 'nullable' => false + ), 'Key code') + ->addColumn('secret', Varien_Db_Ddl_Table::TYPE_TEXT, Mage_Oauth_Model_Consumer::SECRET_LENGTH, array( + 'nullable' => false + ), 'Secret code') + ->addColumn('callback_url', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(), 'Callback URL') + ->addColumn('rejected_callback_url', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array( + 'nullable' => false + ), 'Rejected callback URL') + ->addIndex( + $installer->getIdxName( + $installer->getTable('oauth_consumer'), + array('key'), + Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE + ), + array('key'), + array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)) + ->addIndex( + $installer->getIdxName( + $installer->getTable('oauth_consumer'), + array('secret'), + Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE + ), + array('secret'), + array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)) + ->addIndex($installer->getIdxName('oauth_consumer', array('created_at')), array('created_at')) + ->addIndex($installer->getIdxName('oauth_consumer', array('updated_at')), array('updated_at')) + ->setComment('OAuth Consumers'); +$adapter->createTable($table); + +/** + * Create table 'oauth_token' + */ +$table = $adapter->newTable($installer->getTable('oauth_token')) + ->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( + 'identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true, + ), 'Entity ID') + ->addColumn('consumer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( + 'unsigned' => true, + 'nullable' => false + ), 'Consumer ID') + ->addColumn('admin_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( + 'unsigned' => true, + 'nullable' => true + ), 'Admin user ID') + ->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( + 'unsigned' => true, + 'nullable' => true + ), 'Customer user ID') + ->addColumn('type', Varien_Db_Ddl_Table::TYPE_TEXT, 16, array( + 'nullable' => false + ), 'Token Type') + ->addColumn('token', Varien_Db_Ddl_Table::TYPE_TEXT, Mage_Oauth_Model_Token::LENGTH_TOKEN, array( + 'nullable' => false + ), 'Token') + ->addColumn('secret', Varien_Db_Ddl_Table::TYPE_TEXT, Mage_Oauth_Model_Token::LENGTH_SECRET, array( + 'nullable' => false + ), 'Token Secret') + ->addColumn('verifier', Varien_Db_Ddl_Table::TYPE_TEXT, Mage_Oauth_Model_Token::LENGTH_VERIFIER, array( + 'nullable' => true + ), 'Token Verifier') + ->addColumn('callback_url', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array( + 'nullable' => false + ), 'Token Callback URL') + ->addColumn('revoked', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( + 'unsigned' => true, + 'nullable' => false, + 'default' => 0, + ), 'Is Token revoked') + ->addColumn('authorized', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( + 'unsigned' => true, + 'nullable' => false, + 'default' => 0, + ), 'Is Token authorized') + ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array( + 'nullable' => false, + 'default' => Varien_Db_Ddl_Table::TIMESTAMP_INIT + ), 'Token creation timestamp') + ->addIndex( + $installer->getIdxName( + $installer->getTable('oauth_token'), + array('consumer_id'), + Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX + ), + array('consumer_id'), + array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX)) + ->addIndex( + $installer->getIdxName( + $installer->getTable('oauth_token'), + array('token'), + Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE + ), + array('token'), + array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)) + ->addForeignKey( + $installer->getFkName('oauth_token', 'admin_id', $installer->getTable('admin_user'), 'user_id'), + 'admin_id', + $installer->getTable('admin_user'), + 'user_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE) + ->addForeignKey( + $installer->getFkName('oauth_token', 'consumer_id', $installer->getTable('oauth_consumer'), 'entity_id'), + 'consumer_id', + $installer->getTable('oauth_consumer'), + 'entity_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE) + ->addForeignKey( + $installer->getFkName('oauth_token', 'customer_id', $installer->getTable('customer_entity'), 'entity_id'), + 'customer_id', + $installer->getTable('customer_entity'), + 'entity_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE) + ->setComment('OAuth Tokens'); +$adapter->createTable($table); + +/** + * Create table 'oauth_nonce + */ +$table = $adapter->newTable($installer->getTable('oauth_nonce')) + ->addColumn('nonce', Varien_Db_Ddl_Table::TYPE_TEXT, 32, array( + 'nullable' => false + ), 'Nonce String') + ->addColumn('timestamp', Varien_Db_Ddl_Table::TYPE_INTEGER, 10, array( + 'unsigned' => true, + 'nullable' => false + ), 'Nonce Timestamp') + ->addIndex( + $installer->getIdxName( + $installer->getTable('oauth_nonce'), + array('nonce'), + Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE + ), + array('nonce'), + array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)) + ->setOption('type', 'MyISAM'); +$adapter->createTable($table); + +$installer->endSetup(); diff --git a/app/code/core/Mage/Oauth/view/adminhtml/authorize/button-simple.phtml b/app/code/Mage/Oauth/view/adminhtml/authorize/button-simple.phtml similarity index 100% rename from app/code/core/Mage/Oauth/view/adminhtml/authorize/button-simple.phtml rename to app/code/Mage/Oauth/view/adminhtml/authorize/button-simple.phtml diff --git a/app/code/core/Mage/Oauth/view/adminhtml/authorize/button.phtml b/app/code/Mage/Oauth/view/adminhtml/authorize/button.phtml similarity index 100% rename from app/code/core/Mage/Oauth/view/adminhtml/authorize/button.phtml rename to app/code/Mage/Oauth/view/adminhtml/authorize/button.phtml diff --git a/app/code/core/Mage/Oauth/view/adminhtml/authorize/confirm-simple.phtml b/app/code/Mage/Oauth/view/adminhtml/authorize/confirm-simple.phtml similarity index 100% rename from app/code/core/Mage/Oauth/view/adminhtml/authorize/confirm-simple.phtml rename to app/code/Mage/Oauth/view/adminhtml/authorize/confirm-simple.phtml diff --git a/app/code/core/Mage/Oauth/view/adminhtml/authorize/confirm.phtml b/app/code/Mage/Oauth/view/adminhtml/authorize/confirm.phtml similarity index 100% rename from app/code/core/Mage/Oauth/view/adminhtml/authorize/confirm.phtml rename to app/code/Mage/Oauth/view/adminhtml/authorize/confirm.phtml diff --git a/app/code/core/Mage/Oauth/view/adminhtml/authorize/form/login-simple.phtml b/app/code/Mage/Oauth/view/adminhtml/authorize/form/login-simple.phtml similarity index 100% rename from app/code/core/Mage/Oauth/view/adminhtml/authorize/form/login-simple.phtml rename to app/code/Mage/Oauth/view/adminhtml/authorize/form/login-simple.phtml diff --git a/app/code/core/Mage/Oauth/view/adminhtml/authorize/form/login.phtml b/app/code/Mage/Oauth/view/adminhtml/authorize/form/login.phtml similarity index 100% rename from app/code/core/Mage/Oauth/view/adminhtml/authorize/form/login.phtml rename to app/code/Mage/Oauth/view/adminhtml/authorize/form/login.phtml diff --git a/app/code/core/Mage/Oauth/view/adminhtml/authorize/head-simple.phtml b/app/code/Mage/Oauth/view/adminhtml/authorize/head-simple.phtml similarity index 100% rename from app/code/core/Mage/Oauth/view/adminhtml/authorize/head-simple.phtml rename to app/code/Mage/Oauth/view/adminhtml/authorize/head-simple.phtml diff --git a/app/code/core/Mage/Oauth/view/adminhtml/authorize/reject-simple.phtml b/app/code/Mage/Oauth/view/adminhtml/authorize/reject-simple.phtml similarity index 100% rename from app/code/core/Mage/Oauth/view/adminhtml/authorize/reject-simple.phtml rename to app/code/Mage/Oauth/view/adminhtml/authorize/reject-simple.phtml diff --git a/app/code/core/Mage/Oauth/view/adminhtml/authorize/reject.phtml b/app/code/Mage/Oauth/view/adminhtml/authorize/reject.phtml similarity index 100% rename from app/code/core/Mage/Oauth/view/adminhtml/authorize/reject.phtml rename to app/code/Mage/Oauth/view/adminhtml/authorize/reject.phtml diff --git a/app/code/core/Mage/Oauth/view/adminhtml/css/oauth-simple.css b/app/code/Mage/Oauth/view/adminhtml/css/oauth-simple.css similarity index 100% rename from app/code/core/Mage/Oauth/view/adminhtml/css/oauth-simple.css rename to app/code/Mage/Oauth/view/adminhtml/css/oauth-simple.css diff --git a/app/code/core/Mage/Oauth/view/adminhtml/empty.phtml b/app/code/Mage/Oauth/view/adminhtml/empty.phtml similarity index 100% rename from app/code/core/Mage/Oauth/view/adminhtml/empty.phtml rename to app/code/Mage/Oauth/view/adminhtml/empty.phtml diff --git a/app/code/core/Mage/Oauth/view/adminhtml/layout.xml b/app/code/Mage/Oauth/view/adminhtml/layout.xml similarity index 100% rename from app/code/core/Mage/Oauth/view/adminhtml/layout.xml rename to app/code/Mage/Oauth/view/adminhtml/layout.xml diff --git a/app/code/core/Mage/Oauth/view/email/token.html b/app/code/Mage/Oauth/view/email/token.html similarity index 100% rename from app/code/core/Mage/Oauth/view/email/token.html rename to app/code/Mage/Oauth/view/email/token.html diff --git a/app/code/core/Mage/Oauth/view/frontend/authorize/button-simple.phtml b/app/code/Mage/Oauth/view/frontend/authorize/button-simple.phtml similarity index 100% rename from app/code/core/Mage/Oauth/view/frontend/authorize/button-simple.phtml rename to app/code/Mage/Oauth/view/frontend/authorize/button-simple.phtml diff --git a/app/code/core/Mage/Oauth/view/frontend/authorize/button.phtml b/app/code/Mage/Oauth/view/frontend/authorize/button.phtml similarity index 100% rename from app/code/core/Mage/Oauth/view/frontend/authorize/button.phtml rename to app/code/Mage/Oauth/view/frontend/authorize/button.phtml diff --git a/app/code/core/Mage/Oauth/view/frontend/authorize/confirm-simple.phtml b/app/code/Mage/Oauth/view/frontend/authorize/confirm-simple.phtml similarity index 100% rename from app/code/core/Mage/Oauth/view/frontend/authorize/confirm-simple.phtml rename to app/code/Mage/Oauth/view/frontend/authorize/confirm-simple.phtml diff --git a/app/code/core/Mage/Oauth/view/frontend/authorize/confirm.phtml b/app/code/Mage/Oauth/view/frontend/authorize/confirm.phtml similarity index 100% rename from app/code/core/Mage/Oauth/view/frontend/authorize/confirm.phtml rename to app/code/Mage/Oauth/view/frontend/authorize/confirm.phtml diff --git a/app/code/core/Mage/Oauth/view/frontend/authorize/form/login-simple.phtml b/app/code/Mage/Oauth/view/frontend/authorize/form/login-simple.phtml similarity index 100% rename from app/code/core/Mage/Oauth/view/frontend/authorize/form/login-simple.phtml rename to app/code/Mage/Oauth/view/frontend/authorize/form/login-simple.phtml diff --git a/app/code/core/Mage/Oauth/view/frontend/authorize/form/login.phtml b/app/code/Mage/Oauth/view/frontend/authorize/form/login.phtml similarity index 100% rename from app/code/core/Mage/Oauth/view/frontend/authorize/form/login.phtml rename to app/code/Mage/Oauth/view/frontend/authorize/form/login.phtml diff --git a/app/code/core/Mage/Oauth/view/frontend/authorize/head-simple.phtml b/app/code/Mage/Oauth/view/frontend/authorize/head-simple.phtml similarity index 100% rename from app/code/core/Mage/Oauth/view/frontend/authorize/head-simple.phtml rename to app/code/Mage/Oauth/view/frontend/authorize/head-simple.phtml diff --git a/app/code/core/Mage/Oauth/view/frontend/authorize/reject-simple.phtml b/app/code/Mage/Oauth/view/frontend/authorize/reject-simple.phtml similarity index 100% rename from app/code/core/Mage/Oauth/view/frontend/authorize/reject-simple.phtml rename to app/code/Mage/Oauth/view/frontend/authorize/reject-simple.phtml diff --git a/app/code/core/Mage/Oauth/view/frontend/authorize/reject.phtml b/app/code/Mage/Oauth/view/frontend/authorize/reject.phtml similarity index 100% rename from app/code/core/Mage/Oauth/view/frontend/authorize/reject.phtml rename to app/code/Mage/Oauth/view/frontend/authorize/reject.phtml diff --git a/app/code/core/Mage/Oauth/view/frontend/css/oauth-simple.css b/app/code/Mage/Oauth/view/frontend/css/oauth-simple.css similarity index 100% rename from app/code/core/Mage/Oauth/view/frontend/css/oauth-simple.css rename to app/code/Mage/Oauth/view/frontend/css/oauth-simple.css diff --git a/app/code/core/Mage/Oauth/view/frontend/customer/token/list.phtml b/app/code/Mage/Oauth/view/frontend/customer/token/list.phtml similarity index 100% rename from app/code/core/Mage/Oauth/view/frontend/customer/token/list.phtml rename to app/code/Mage/Oauth/view/frontend/customer/token/list.phtml diff --git a/app/code/core/Mage/Oauth/view/frontend/layout.xml b/app/code/Mage/Oauth/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/Oauth/view/frontend/layout.xml rename to app/code/Mage/Oauth/view/frontend/layout.xml diff --git a/app/code/core/Mage/Ogone/Block/Form.php b/app/code/Mage/Ogone/Block/Form.php similarity index 100% rename from app/code/core/Mage/Ogone/Block/Form.php rename to app/code/Mage/Ogone/Block/Form.php diff --git a/app/code/core/Mage/Ogone/Block/Info.php b/app/code/Mage/Ogone/Block/Info.php similarity index 100% rename from app/code/core/Mage/Ogone/Block/Info.php rename to app/code/Mage/Ogone/Block/Info.php diff --git a/app/code/core/Mage/Ogone/Block/Paypage.php b/app/code/Mage/Ogone/Block/Paypage.php similarity index 100% rename from app/code/core/Mage/Ogone/Block/Paypage.php rename to app/code/Mage/Ogone/Block/Paypage.php diff --git a/app/code/core/Mage/Ogone/Block/Placeform.php b/app/code/Mage/Ogone/Block/Placeform.php similarity index 100% rename from app/code/core/Mage/Ogone/Block/Placeform.php rename to app/code/Mage/Ogone/Block/Placeform.php diff --git a/app/code/core/Mage/Ogone/Helper/Data.php b/app/code/Mage/Ogone/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Ogone/Helper/Data.php rename to app/code/Mage/Ogone/Helper/Data.php diff --git a/app/code/core/Mage/Ogone/Model/Api.php b/app/code/Mage/Ogone/Model/Api.php similarity index 100% rename from app/code/core/Mage/Ogone/Model/Api.php rename to app/code/Mage/Ogone/Model/Api.php diff --git a/app/code/core/Mage/Ogone/Model/Config.php b/app/code/Mage/Ogone/Model/Config.php similarity index 100% rename from app/code/core/Mage/Ogone/Model/Config.php rename to app/code/Mage/Ogone/Model/Config.php diff --git a/app/code/core/Mage/Ogone/Model/Source/PaymentAction.php b/app/code/Mage/Ogone/Model/Source/PaymentAction.php similarity index 100% rename from app/code/core/Mage/Ogone/Model/Source/PaymentAction.php rename to app/code/Mage/Ogone/Model/Source/PaymentAction.php diff --git a/app/code/core/Mage/Ogone/Model/Source/Pmlist.php b/app/code/Mage/Ogone/Model/Source/Pmlist.php similarity index 100% rename from app/code/core/Mage/Ogone/Model/Source/Pmlist.php rename to app/code/Mage/Ogone/Model/Source/Pmlist.php diff --git a/app/code/core/Mage/Ogone/Model/Source/Template.php b/app/code/Mage/Ogone/Model/Source/Template.php similarity index 100% rename from app/code/core/Mage/Ogone/Model/Source/Template.php rename to app/code/Mage/Ogone/Model/Source/Template.php diff --git a/app/code/core/Mage/Ogone/controllers/ApiController.php b/app/code/Mage/Ogone/controllers/ApiController.php similarity index 100% rename from app/code/core/Mage/Ogone/controllers/ApiController.php rename to app/code/Mage/Ogone/controllers/ApiController.php diff --git a/app/code/core/Mage/Ogone/etc/adminhtml/system.xml b/app/code/Mage/Ogone/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Ogone/etc/adminhtml/system.xml rename to app/code/Mage/Ogone/etc/adminhtml/system.xml diff --git a/app/code/Mage/Ogone/etc/config.xml b/app/code/Mage/Ogone/etc/config.xml new file mode 100644 index 0000000000000..eea371314b69a --- /dev/null +++ b/app/code/Mage/Ogone/etc/config.xml @@ -0,0 +1,146 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + + Mage_Ogone + + + core_setup + + + + + core_write + + + + + core_read + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + layout.xml + + + + + /ogone/api + + + + standard + + Mage_Ogone + ogone + + + + + + + + Mage_Ogone.csv + + + + + + + + + Mage_Ogone_Model_Api + Ogone + + authorize + sha256 + + https://secure.ogone.com/ncol/test/orderstandard.asp + pending_ogone + cancel_ogone + decline_ogone + processing_ogone + processed_ogone + waiting_authorozation + + + + diff --git a/app/code/core/Mage/Ogone/locale/de_DE/Mage_Ogone.csv b/app/code/Mage/Ogone/locale/de_DE/Mage_Ogone.csv similarity index 100% rename from app/code/core/Mage/Ogone/locale/de_DE/Mage_Ogone.csv rename to app/code/Mage/Ogone/locale/de_DE/Mage_Ogone.csv diff --git a/app/code/core/Mage/Ogone/locale/en_US/Mage_Ogone.csv b/app/code/Mage/Ogone/locale/en_US/Mage_Ogone.csv similarity index 100% rename from app/code/core/Mage/Ogone/locale/en_US/Mage_Ogone.csv rename to app/code/Mage/Ogone/locale/en_US/Mage_Ogone.csv diff --git a/app/code/core/Mage/Ogone/locale/es_ES/Mage_Ogone.csv b/app/code/Mage/Ogone/locale/es_ES/Mage_Ogone.csv similarity index 100% rename from app/code/core/Mage/Ogone/locale/es_ES/Mage_Ogone.csv rename to app/code/Mage/Ogone/locale/es_ES/Mage_Ogone.csv diff --git a/app/code/core/Mage/Ogone/locale/fr_FR/Mage_Ogone.csv b/app/code/Mage/Ogone/locale/fr_FR/Mage_Ogone.csv similarity index 100% rename from app/code/core/Mage/Ogone/locale/fr_FR/Mage_Ogone.csv rename to app/code/Mage/Ogone/locale/fr_FR/Mage_Ogone.csv diff --git a/app/code/core/Mage/Ogone/locale/nl_NL/Mage_Ogone.csv b/app/code/Mage/Ogone/locale/nl_NL/Mage_Ogone.csv similarity index 100% rename from app/code/core/Mage/Ogone/locale/nl_NL/Mage_Ogone.csv rename to app/code/Mage/Ogone/locale/nl_NL/Mage_Ogone.csv diff --git a/app/code/core/Mage/Ogone/locale/pt_BR/Mage_Ogone.csv b/app/code/Mage/Ogone/locale/pt_BR/Mage_Ogone.csv similarity index 100% rename from app/code/core/Mage/Ogone/locale/pt_BR/Mage_Ogone.csv rename to app/code/Mage/Ogone/locale/pt_BR/Mage_Ogone.csv diff --git a/app/code/core/Mage/Ogone/locale/zh_CN/Mage_Ogone.csv b/app/code/Mage/Ogone/locale/zh_CN/Mage_Ogone.csv similarity index 100% rename from app/code/core/Mage/Ogone/locale/zh_CN/Mage_Ogone.csv rename to app/code/Mage/Ogone/locale/zh_CN/Mage_Ogone.csv diff --git a/app/code/core/Mage/Ogone/sql/ogone_setup/install-1.6.0.0.php b/app/code/Mage/Ogone/sql/ogone_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Ogone/sql/ogone_setup/install-1.6.0.0.php rename to app/code/Mage/Ogone/sql/ogone_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Ogone/view/adminhtml/info.phtml b/app/code/Mage/Ogone/view/adminhtml/info.phtml similarity index 100% rename from app/code/core/Mage/Ogone/view/adminhtml/info.phtml rename to app/code/Mage/Ogone/view/adminhtml/info.phtml diff --git a/app/code/core/Mage/Ogone/view/frontend/form.phtml b/app/code/Mage/Ogone/view/frontend/form.phtml similarity index 100% rename from app/code/core/Mage/Ogone/view/frontend/form.phtml rename to app/code/Mage/Ogone/view/frontend/form.phtml diff --git a/app/code/core/Mage/Ogone/view/frontend/info.phtml b/app/code/Mage/Ogone/view/frontend/info.phtml similarity index 100% rename from app/code/core/Mage/Ogone/view/frontend/info.phtml rename to app/code/Mage/Ogone/view/frontend/info.phtml diff --git a/app/code/core/Mage/Ogone/view/frontend/layout.xml b/app/code/Mage/Ogone/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/Ogone/view/frontend/layout.xml rename to app/code/Mage/Ogone/view/frontend/layout.xml diff --git a/app/code/core/Mage/Ogone/view/frontend/paypage.phtml b/app/code/Mage/Ogone/view/frontend/paypage.phtml similarity index 100% rename from app/code/core/Mage/Ogone/view/frontend/paypage.phtml rename to app/code/Mage/Ogone/view/frontend/paypage.phtml diff --git a/app/code/core/Mage/Ogone/view/frontend/placeform.phtml b/app/code/Mage/Ogone/view/frontend/placeform.phtml similarity index 86% rename from app/code/core/Mage/Ogone/view/frontend/placeform.phtml rename to app/code/Mage/Ogone/view/frontend/placeform.phtml index e90c5c4b53f2d..aaa88cdef4cf5 100644 --- a/app/code/core/Mage/Ogone/view/frontend/placeform.phtml +++ b/app/code/Mage/Ogone/view/frontend/placeform.phtml @@ -26,7 +26,7 @@ ?>

    __('Please, wait a moment. This page will transfer your data to Ogone payment gateway in a few seconds.'); ?>

    -
    + getFormData()): ?>
    $value) { ?> @@ -36,10 +36,8 @@ diff --git a/app/code/core/Mage/Page/Block/Html.php b/app/code/Mage/Page/Block/Html.php similarity index 100% rename from app/code/core/Mage/Page/Block/Html.php rename to app/code/Mage/Page/Block/Html.php diff --git a/app/code/core/Mage/Page/Block/Html/Breadcrumbs.php b/app/code/Mage/Page/Block/Html/Breadcrumbs.php similarity index 100% rename from app/code/core/Mage/Page/Block/Html/Breadcrumbs.php rename to app/code/Mage/Page/Block/Html/Breadcrumbs.php diff --git a/app/code/core/Mage/Page/Block/Html/Footer.php b/app/code/Mage/Page/Block/Html/Footer.php similarity index 100% rename from app/code/core/Mage/Page/Block/Html/Footer.php rename to app/code/Mage/Page/Block/Html/Footer.php diff --git a/app/code/Mage/Page/Block/Html/Head.php b/app/code/Mage/Page/Block/Html/Head.php new file mode 100644 index 0000000000000..e346ae81e67ab --- /dev/null +++ b/app/code/Mage/Page/Block/Html/Head.php @@ -0,0 +1,476 @@ + + */ +class Mage_Page_Block_Html_Head extends Mage_Core_Block_Template +{ + /** + * Block template + * + * @var string + */ + protected $_template = 'html/head.phtml'; + + /** + * Chunks of title (necessary for backend) + * + * @var array + */ + protected $_titleChunks; + + /** + * Page title without prefix and suffix when not chunked + * + * @var string + */ + protected $_pureTitle; + + /** + * @var Magento_ObjectManager + */ + protected $_objectManager; + + /** + * @var Mage_Core_Model_Page_Asset_MergeService + */ + private $_assetMergeService; + + /** + * @var Mage_Page_Model_Asset_GroupedCollection + */ + private $_pageAssets; + + public function __construct( + Mage_Core_Block_Template_Context $context, + Magento_ObjectManager $objectManager, + Mage_Core_Model_Page $page, + Mage_Core_Model_Page_Asset_MergeService $assetMergeService, + array $data = array() + ) { + parent::__construct($context, $data); + $this->_objectManager = $objectManager; + $this->_assetMergeService = $assetMergeService; + $this->_pageAssets = $page->getAssets(); + } + + /** + * Add CSS file to HEAD entity + * + * @param string $file + * @param string $attributes + * @param string|null $ieCondition + * @param string|null $flagName + * @return Mage_Page_Block_Html_Head + */ + public function addCss($file, $attributes = '', $ieCondition = null, $flagName = null) + { + $contentType = Mage_Core_Model_Design_Package::CONTENT_TYPE_CSS; + $asset = $this->_objectManager->create( + 'Mage_Core_Model_Page_Asset_ViewFile', array('file' => (string)$file, 'contentType' => $contentType) + ); + $this->_pageAssets->add("$contentType/$file", $asset, array( + 'attributes' => (string)$attributes, + 'ie_condition' => (string)$ieCondition, + 'flag_name' => (string)$flagName, + )); + return $this; + } + + /** + * Add JavaScript file to HEAD entity + * + * @param string $file + * @param string $attributes + * @param string|null $ieCondition + * @param string|null $flagName + * @return Mage_Page_Block_Html_Head + */ + public function addJs($file, $attributes = '', $ieCondition = null, $flagName = null) + { + $contentType = Mage_Core_Model_Design_Package::CONTENT_TYPE_JS; + $asset = $this->_objectManager->create( + 'Mage_Core_Model_Page_Asset_ViewFile', array('file' => (string)$file, 'contentType' => $contentType) + ); + $this->_pageAssets->add("$contentType/$file", $asset, array( + 'attributes' => (string)$attributes, + 'ie_condition' => (string)$ieCondition, + 'flag_name' => (string)$flagName, + )); + return $this; + } + + /** + * Add CSS file for Internet Explorer only to HEAD entity + * + * @param string $file + * @param string $attributes + * @param string|null $flagName + * @return Mage_Page_Block_Html_Head + */ + public function addCssIe($file, $attributes = '', $flagName = null) + { + return $this->addCss($file, $attributes, 'IE', $flagName); + } + + /** + * Add JavaScript file for Internet Explorer only to HEAD entity + * + * @param string $file + * @param string $attributes + * @param string|null $flagName + * @return Mage_Page_Block_Html_Head + */ + public function addJsIe($file, $attributes = '', $flagName = null) + { + return $this->addJs($file, $attributes, 'IE', $flagName); + } + + /** + * Add RSS element to HEAD entity + * + * @param string $title + * @param string $href + * @return Mage_Page_Block_Html_Head + */ + public function addRss($title, $href) + { + $attributes = 'rel="alternate" type="application/rss+xml" title="' . $title . '"'; + $asset = $this->_objectManager->create( + 'Mage_Core_Model_Page_Asset_Remote', array('url' => (string)$href) + ); + $this->_pageAssets->add("link/$href", $asset, array('attributes' => $attributes)); + return $this; + } + + /** + * Add Link element to HEAD entity + * + * @param string $rel forward link types + * @param string $href URI for linked resource + * @return Mage_Page_Block_Html_Head + */ + public function addLinkRel($rel, $href) + { + $asset = $this->_objectManager->create( + 'Mage_Core_Model_Page_Asset_Remote', array('url' => (string)$href) + ); + $this->_pageAssets->add("link/$href", $asset, array('attributes' => 'rel="' . $rel . '"')); + return $this; + } + + /** + * Remove Item from HEAD entity + * + * @param string $type + * @param string $name + * @return Mage_Page_Block_Html_Head + */ + public function removeItem($type, $name) + { + $this->_pageAssets->remove("$type/$name"); + return $this; + } + + /** + * Render HTML for the added head items + * + * @return string + */ + public function getCssJsHtml() + { + $result = ''; + /** @var $group Mage_Page_Model_Asset_PropertyGroup */ + foreach ($this->_pageAssets->getGroups() as $group) { + $contentType = $group->getProperty(Mage_Page_Model_Asset_GroupedCollection::PROPERTY_CONTENT_TYPE); + $canMerge = $group->getProperty(Mage_Page_Model_Asset_GroupedCollection::PROPERTY_CAN_MERGE); + $attributes = $group->getProperty('attributes'); + $ieCondition = $group->getProperty('ie_condition'); + $flagName = $group->getProperty('flag_name'); + + if ($flagName && !$this->getData($flagName)) { + continue; + } + + $groupAssets = $group->getAll(); + if ($canMerge && count($groupAssets) > 1) { + $groupAssets = $this->_assetMergeService->getMergedAssets($groupAssets, $contentType); + } + + if (!empty($attributes)) { + $attributes = ' ' . $attributes; + } + if ($contentType == Mage_Core_Model_Design_Package::CONTENT_TYPE_JS ) { + $groupTemplate = '' . "\n"; + } else { + if ($contentType == Mage_Core_Model_Design_Package::CONTENT_TYPE_CSS) { + $attributes = ' rel="stylesheet" type="text/css"' . ($attributes ?: ' media="all"'); + } + $groupTemplate = '' . "\n"; + } + + $groupHtml = $this->_renderHtml($groupTemplate, $groupAssets); + + if (!empty($ieCondition)) { + $groupHtml = '' . "\n"; + } + + $result .= $groupHtml; + } + return $result; + } + + /** + * Render HTML tags referencing corresponding URLs + * + * @param string $template + * @param array $assets + * @return string + */ + protected function _renderHtml($template, array $assets) + { + $result = ''; + try { + /** @var $asset Mage_Core_Model_Page_Asset_AssetInterface */ + foreach ($assets as $asset) { + $result .= sprintf($template, $asset->getUrl()); + } + } catch (Magento_Exception $e) { + $result .= sprintf($template, $this->_getNotFoundUrl()); + } + return $result; + } + + /** + * Retrieve Content Type + * + * @return string + */ + public function getContentType() + { + if (empty($this->_data['content_type'])) { + $this->_data['content_type'] = $this->getMediaType() . '; charset=' . $this->getCharset(); + } + return $this->_data['content_type']; + } + + /** + * Retrieve Media Type + * + * @return string + */ + public function getMediaType() + { + if (empty($this->_data['media_type'])) { + $this->_data['media_type'] = Mage::getStoreConfig('design/head/default_media_type'); + } + return $this->_data['media_type']; + } + + /** + * Retrieve Charset + * + * @return string + */ + public function getCharset() + { + if (empty($this->_data['charset'])) { + $this->_data['charset'] = Mage::getStoreConfig('design/head/default_charset'); + } + return $this->_data['charset']; + } + + /** + * Set title element text + * + * @param string|array $title + * @return Mage_Page_Block_Html_Head + */ + public function setTitle($title) + { + if (is_array($title)) { + $this->_titleChunks = $title; + $title = implode(' / ', $title); + } else { + $this->_pureTitle = $title; + } + $this->_data['title'] = Mage::getStoreConfig('design/head/title_prefix') . ' ' . $title + . ' ' . Mage::getStoreConfig('design/head/title_suffix'); + return $this; + } + + /** + * Retrieve title element text (encoded) + * + * @return string + */ + public function getTitle() + { + if (empty($this->_data['title'])) { + $this->_data['title'] = $this->getDefaultTitle(); + } + return htmlspecialchars(html_entity_decode(trim($this->_data['title']), ENT_QUOTES, 'UTF-8')); + } + + /** + * Same as getTitle(), but return only first item from chunk for backend pages + * + * @return mixed|string + */ + public function getShortTitle() + { + if (!empty($this->_titleChunks)) { + return reset($this->_titleChunks); + } else { + return $this->_pureTitle; + } + } + + /** + * Retrieve default title text + * + * @return string + */ + public function getDefaultTitle() + { + return Mage::getStoreConfig('design/head/default_title'); + } + + /** + * Retrieve content for description tag + * + * @return string + */ + public function getDescription() + { + if (empty($this->_data['description'])) { + $this->_data['description'] = Mage::getStoreConfig('design/head/default_description'); + } + return $this->_data['description']; + } + + /** + * Retrieve content for keyvords tag + * + * @return string + */ + public function getKeywords() + { + if (empty($this->_data['keywords'])) { + $this->_data['keywords'] = Mage::getStoreConfig('design/head/default_keywords'); + } + return $this->_data['keywords']; + } + + /** + * Retrieve URL to robots file + * + * @return string + */ + public function getRobots() + { + if (empty($this->_data['robots'])) { + $this->_data['robots'] = Mage::getStoreConfig('design/search_engine_robots/default_robots'); + } + return $this->_data['robots']; + } + + /** + * Get miscellaneous scripts/styles to be included in head before head closing tag + * + * @return string + */ + public function getIncludes() + { + if (empty($this->_data['includes'])) { + $this->_data['includes'] = Mage::getStoreConfig('design/head/includes'); + } + return $this->_data['includes']; + } + + /** + * Getter for path to Favicon + * + * @return string + */ + public function getFaviconFile() + { + if (empty($this->_data['favicon_file'])) { + $this->_data['favicon_file'] = $this->_getFaviconFile(); + } + return $this->_data['favicon_file']; + } + + /** + * Retrieve path to Favicon + * + * @return string + */ + protected function _getFaviconFile() + { + $folderName = Mage_Backend_Model_Config_Backend_Image_Favicon::UPLOAD_DIR; + $storeConfig = Mage::getStoreConfig('design/head/shortcut_icon'); + $faviconFile = Mage::getBaseUrl('media') . $folderName . '/' . $storeConfig; + $absolutePath = Mage::getBaseDir('media') . '/' . $folderName . '/' . $storeConfig; + + if (!is_null($storeConfig) && $this->_isFile($absolutePath)) { + $url = $faviconFile; + } else { + $url = $this->getViewFileUrl('Mage_Page::favicon.ico'); + } + return $url; + } + + /** + * If DB file storage is on - find there, otherwise - just file_exists + * + * @param string $filename + * @return bool + */ + protected function _isFile($filename) + { + if (Mage::helper('Mage_Core_Helper_File_Storage_Database')->checkDbUsage() && !is_file($filename)) { + Mage::helper('Mage_Core_Helper_File_Storage_Database')->saveFileToFilesystem($filename); + } + return is_file($filename); + } + + /** + * Retrieve locale code + * + * @return string + */ + public function getLocale() + { + return substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2); + } +} diff --git a/app/code/core/Mage/Page/Block/Html/Header.php b/app/code/Mage/Page/Block/Html/Header.php similarity index 100% rename from app/code/core/Mage/Page/Block/Html/Header.php rename to app/code/Mage/Page/Block/Html/Header.php diff --git a/app/code/core/Mage/Page/Block/Html/Notices.php b/app/code/Mage/Page/Block/Html/Notices.php similarity index 100% rename from app/code/core/Mage/Page/Block/Html/Notices.php rename to app/code/Mage/Page/Block/Html/Notices.php diff --git a/app/code/core/Mage/Page/Block/Html/Pager.php b/app/code/Mage/Page/Block/Html/Pager.php similarity index 100% rename from app/code/core/Mage/Page/Block/Html/Pager.php rename to app/code/Mage/Page/Block/Html/Pager.php diff --git a/app/code/core/Mage/Page/Block/Html/Title.php b/app/code/Mage/Page/Block/Html/Title.php similarity index 100% rename from app/code/core/Mage/Page/Block/Html/Title.php rename to app/code/Mage/Page/Block/Html/Title.php diff --git a/app/code/core/Mage/Page/Block/Html/Topmenu.php b/app/code/Mage/Page/Block/Html/Topmenu.php similarity index 94% rename from app/code/core/Mage/Page/Block/Html/Topmenu.php rename to app/code/Mage/Page/Block/Html/Topmenu.php index 5b110f7dee4f2..dab01591cdb70 100644 --- a/app/code/core/Mage/Page/Block/Html/Topmenu.php +++ b/app/code/Mage/Page/Block/Html/Topmenu.php @@ -57,7 +57,7 @@ public function _construct() */ public function getHtml($outermostClass = '', $childrenWrapClass = '') { - Mage::dispatchEvent('page_block_html_topmenu_gethtml_before', array( + $this->_eventManager->dispatch('page_block_html_topmenu_gethtml_before', array( 'menu' => $this->_menu )); @@ -66,9 +66,10 @@ public function getHtml($outermostClass = '', $childrenWrapClass = '') $html = $this->_getHtml($this->_menu, $childrenWrapClass); - Mage::dispatchEvent('page_block_html_topmenu_gethtml_after', array( - 'menu' => $this->_menu, - 'html' => $html + $transportObject = new Varien_Object(array('html' => $html)); + $this->_eventManager->dispatch('page_block_html_topmenu_gethtml_after', array( + 'menu' => $this->_menu, + 'transportObject' => $transportObject, )); return $html; diff --git a/app/code/core/Mage/Page/Block/Html/Welcome.php b/app/code/Mage/Page/Block/Html/Welcome.php similarity index 100% rename from app/code/core/Mage/Page/Block/Html/Welcome.php rename to app/code/Mage/Page/Block/Html/Welcome.php diff --git a/app/code/core/Mage/Page/Block/Js/Cookie.php b/app/code/Mage/Page/Block/Js/Cookie.php similarity index 100% rename from app/code/core/Mage/Page/Block/Js/Cookie.php rename to app/code/Mage/Page/Block/Js/Cookie.php diff --git a/app/code/core/Mage/Page/Block/Js/Translate.php b/app/code/Mage/Page/Block/Js/Translate.php similarity index 100% rename from app/code/core/Mage/Page/Block/Js/Translate.php rename to app/code/Mage/Page/Block/Js/Translate.php diff --git a/app/code/core/Mage/Page/Block/Redirect.php b/app/code/Mage/Page/Block/Redirect.php similarity index 100% rename from app/code/core/Mage/Page/Block/Redirect.php rename to app/code/Mage/Page/Block/Redirect.php diff --git a/app/code/core/Mage/Page/Block/Switch.php b/app/code/Mage/Page/Block/Switch.php similarity index 100% rename from app/code/core/Mage/Page/Block/Switch.php rename to app/code/Mage/Page/Block/Switch.php diff --git a/app/code/core/Mage/Page/Block/Template/Container.php b/app/code/Mage/Page/Block/Template/Container.php similarity index 100% rename from app/code/core/Mage/Page/Block/Template/Container.php rename to app/code/Mage/Page/Block/Template/Container.php diff --git a/app/code/core/Mage/Page/Block/Template/Links.php b/app/code/Mage/Page/Block/Template/Links.php similarity index 100% rename from app/code/core/Mage/Page/Block/Template/Links.php rename to app/code/Mage/Page/Block/Template/Links.php diff --git a/app/code/core/Mage/Page/Block/Template/Links/Block.php b/app/code/Mage/Page/Block/Template/Links/Block.php similarity index 100% rename from app/code/core/Mage/Page/Block/Template/Links/Block.php rename to app/code/Mage/Page/Block/Template/Links/Block.php diff --git a/app/code/core/Mage/Page/Helper/Data.php b/app/code/Mage/Page/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Page/Helper/Data.php rename to app/code/Mage/Page/Helper/Data.php diff --git a/app/code/core/Mage/Page/Helper/Html.php b/app/code/Mage/Page/Helper/Html.php similarity index 100% rename from app/code/core/Mage/Page/Helper/Html.php rename to app/code/Mage/Page/Helper/Html.php diff --git a/app/code/core/Mage/Page/Helper/Layout.php b/app/code/Mage/Page/Helper/Layout.php similarity index 100% rename from app/code/core/Mage/Page/Helper/Layout.php rename to app/code/Mage/Page/Helper/Layout.php diff --git a/app/code/core/Mage/Page/Helper/Robots.php b/app/code/Mage/Page/Helper/Robots.php similarity index 100% rename from app/code/core/Mage/Page/Helper/Robots.php rename to app/code/Mage/Page/Helper/Robots.php diff --git a/app/code/Mage/Page/Model/Asset/GroupedCollection.php b/app/code/Mage/Page/Model/Asset/GroupedCollection.php new file mode 100644 index 0000000000000..f531fb61a5ca3 --- /dev/null +++ b/app/code/Mage/Page/Model/Asset/GroupedCollection.php @@ -0,0 +1,120 @@ +_objectManager = $objectManager; + } + + /** + * Add an instance, identified by a unique identifier, to the list and to the corresponding group + * + * @param string $identifier + * @param Mage_Core_Model_Page_Asset_AssetInterface $asset + * @param array $properties + */ + public function add($identifier, Mage_Core_Model_Page_Asset_AssetInterface $asset, array $properties = array()) + { + parent::add($identifier, $asset); + $properties[self::PROPERTY_CONTENT_TYPE] = $asset->getContentType(); + $properties[self::PROPERTY_CAN_MERGE] = $asset instanceof Mage_Core_Model_Page_Asset_MergeableInterface; + $this->_getGroupFor($properties)->add($identifier, $asset); + } + + /** + * Retrieve existing or new group matching the properties + * + * @param array $properties + * @return Mage_Page_Model_Asset_PropertyGroup + */ + private function _getGroupFor(array $properties) + { + /** @var $existingGroup Mage_Page_Model_Asset_PropertyGroup */ + foreach ($this->_groups as $existingGroup) { + if ($existingGroup->getProperties() == $properties) { + return $existingGroup; + } + } + /** @var $newGroup Mage_Page_Model_Asset_PropertyGroup */ + $newGroup = $this->_objectManager->create( + 'Mage_Page_Model_Asset_PropertyGroup', array('properties' => $properties) + ); + $this->_groups[] = $newGroup; + return $newGroup; + } + + /** + * Remove an instance from the list and from the corresponding group + * + * @param string $identifier + */ + public function remove($identifier) + { + parent::remove($identifier); + /** @var $group Mage_Page_Model_Asset_PropertyGroup */ + foreach ($this->_groups as $group) { + if ($group->has($identifier)) { + $group->remove($identifier); + return; + } + } + } + + /** + * Retrieve groups, containing assets that have the same properties + * + * @return Mage_Page_Model_Asset_PropertyGroup[] + */ + public function getGroups() + { + return $this->_groups; + } +} diff --git a/app/code/Mage/Page/Model/Asset/PropertyGroup.php b/app/code/Mage/Page/Model/Asset/PropertyGroup.php new file mode 100644 index 0000000000000..1fc56f0a64ef4 --- /dev/null +++ b/app/code/Mage/Page/Model/Asset/PropertyGroup.php @@ -0,0 +1,65 @@ +_properties = $properties; + } + + /** + * Retrieve values of all properties + * + * @return array() + */ + public function getProperties() + { + return $this->_properties; + } + + /** + * Retrieve value of an individual property + * + * @param string $name + * @return mixed + */ + public function getProperty($name) + { + return isset($this->_properties[$name]) ? $this->_properties[$name] : null; + } +} diff --git a/app/code/core/Mage/Page/Model/Config.php b/app/code/Mage/Page/Model/Config.php similarity index 100% rename from app/code/core/Mage/Page/Model/Config.php rename to app/code/Mage/Page/Model/Config.php diff --git a/app/code/core/Mage/Page/Model/Source/Layout.php b/app/code/Mage/Page/Model/Source/Layout.php similarity index 100% rename from app/code/core/Mage/Page/Model/Source/Layout.php rename to app/code/Mage/Page/Model/Source/Layout.php diff --git a/app/code/core/Mage/Page/etc/adminhtml/system.xml b/app/code/Mage/Page/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Page/etc/adminhtml/system.xml rename to app/code/Mage/Page/etc/adminhtml/system.xml diff --git a/app/code/Mage/Page/etc/config.xml b/app/code/Mage/Page/etc/config.xml new file mode 100644 index 0000000000000..71f02d9abfab7 --- /dev/null +++ b/app/code/Mage/Page/etc/config.xml @@ -0,0 +1,174 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + Mage_Page_Model_Asset_GroupedCollection + + + + 0 + + + + + + + + page_empty + + + + + page_one_column + 1 + + + + + page_two_columns_left + + + + + page_two_columns_right + + + + + page_three_columns + + + + + + + + + + Mage_Page.csv + + + + + + + + layout.xml + + + layout_addons.xml + + + + + + + + + + Mage_Page.csv + + + + + + + + + + + Mage_Page.csv + + + + + + + + + Magento Commerce + Default Description + Magento, Varien, E-commerce + text/html + utf-8 + + + INDEX,FOLLOW + + + + +
    + Magento Commerce + Default welcome msg! +
    +
    + &copy; 2012 Magento Demo Store. All Rights Reserved. +
    +
    + + + + favicon + + + +
    +
    diff --git a/app/code/core/Mage/Page/locale/de_DE/Mage_Page.csv b/app/code/Mage/Page/locale/de_DE/Mage_Page.csv similarity index 100% rename from app/code/core/Mage/Page/locale/de_DE/Mage_Page.csv rename to app/code/Mage/Page/locale/de_DE/Mage_Page.csv diff --git a/app/code/core/Mage/Page/locale/en_US/Mage_Page.csv b/app/code/Mage/Page/locale/en_US/Mage_Page.csv similarity index 100% rename from app/code/core/Mage/Page/locale/en_US/Mage_Page.csv rename to app/code/Mage/Page/locale/en_US/Mage_Page.csv diff --git a/app/code/core/Mage/Page/locale/es_ES/Mage_Page.csv b/app/code/Mage/Page/locale/es_ES/Mage_Page.csv similarity index 100% rename from app/code/core/Mage/Page/locale/es_ES/Mage_Page.csv rename to app/code/Mage/Page/locale/es_ES/Mage_Page.csv diff --git a/app/code/core/Mage/Page/locale/fr_FR/Mage_Page.csv b/app/code/Mage/Page/locale/fr_FR/Mage_Page.csv similarity index 100% rename from app/code/core/Mage/Page/locale/fr_FR/Mage_Page.csv rename to app/code/Mage/Page/locale/fr_FR/Mage_Page.csv diff --git a/app/code/core/Mage/Page/locale/nl_NL/Mage_Page.csv b/app/code/Mage/Page/locale/nl_NL/Mage_Page.csv similarity index 100% rename from app/code/core/Mage/Page/locale/nl_NL/Mage_Page.csv rename to app/code/Mage/Page/locale/nl_NL/Mage_Page.csv diff --git a/app/code/core/Mage/Page/locale/pt_BR/Mage_Page.csv b/app/code/Mage/Page/locale/pt_BR/Mage_Page.csv similarity index 100% rename from app/code/core/Mage/Page/locale/pt_BR/Mage_Page.csv rename to app/code/Mage/Page/locale/pt_BR/Mage_Page.csv diff --git a/app/code/core/Mage/Page/locale/zh_CN/Mage_Page.csv b/app/code/Mage/Page/locale/zh_CN/Mage_Page.csv similarity index 100% rename from app/code/core/Mage/Page/locale/zh_CN/Mage_Page.csv rename to app/code/Mage/Page/locale/zh_CN/Mage_Page.csv diff --git a/app/code/core/Mage/Page/view/adminhtml/empty.phtml b/app/code/Mage/Page/view/adminhtml/empty.phtml similarity index 100% rename from app/code/core/Mage/Page/view/adminhtml/empty.phtml rename to app/code/Mage/Page/view/adminhtml/empty.phtml diff --git a/app/code/core/Mage/Page/view/adminhtml/favicon.ico b/app/code/Mage/Page/view/adminhtml/favicon.ico similarity index 100% rename from app/code/core/Mage/Page/view/adminhtml/favicon.ico rename to app/code/Mage/Page/view/adminhtml/favicon.ico diff --git a/app/code/Mage/Page/view/adminhtml/title.phtml b/app/code/Mage/Page/view/adminhtml/title.phtml new file mode 100644 index 0000000000000..e61058ed78f10 --- /dev/null +++ b/app/code/Mage/Page/view/adminhtml/title.phtml @@ -0,0 +1,40 @@ +getTitleId()) ? ' id="' . $this->getTitleId() . '"' : ''; +$titlePrefix = ($this->getTitlePrefix()) ? '' . $this->getTitlePrefix() . ' ' : ''; +$titleSuffix = ($this->getTitleSuffix()) ? ' ' . $this->getTitleSuffix() . '' : ''; +$title = $titlePrefix . $this->escapeHtml($this->getPageTitle()) . $titleSuffix; +?> +
    +
    +

    >

    + getChildHtml(); ?> +
    +
    diff --git a/app/code/core/Mage/Page/view/frontend/1column.phtml b/app/code/Mage/Page/view/frontend/1column.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/1column.phtml rename to app/code/Mage/Page/view/frontend/1column.phtml diff --git a/app/code/core/Mage/Page/view/frontend/2columns-left.phtml b/app/code/Mage/Page/view/frontend/2columns-left.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/2columns-left.phtml rename to app/code/Mage/Page/view/frontend/2columns-left.phtml diff --git a/app/code/core/Mage/Page/view/frontend/2columns-right.phtml b/app/code/Mage/Page/view/frontend/2columns-right.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/2columns-right.phtml rename to app/code/Mage/Page/view/frontend/2columns-right.phtml diff --git a/app/code/core/Mage/Page/view/frontend/3columns.phtml b/app/code/Mage/Page/view/frontend/3columns.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/3columns.phtml rename to app/code/Mage/Page/view/frontend/3columns.phtml diff --git a/app/code/core/Mage/Page/view/frontend/callouts/left_col.phtml b/app/code/Mage/Page/view/frontend/callouts/left_col.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/callouts/left_col.phtml rename to app/code/Mage/Page/view/frontend/callouts/left_col.phtml diff --git a/app/code/core/Mage/Page/view/frontend/callouts/right_col.phtml b/app/code/Mage/Page/view/frontend/callouts/right_col.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/callouts/right_col.phtml rename to app/code/Mage/Page/view/frontend/callouts/right_col.phtml diff --git a/app/code/core/Mage/Page/view/frontend/css/tabs.css b/app/code/Mage/Page/view/frontend/css/tabs.css similarity index 100% rename from app/code/core/Mage/Page/view/frontend/css/tabs.css rename to app/code/Mage/Page/view/frontend/css/tabs.css diff --git a/app/code/core/Mage/Page/view/frontend/css/validate.css b/app/code/Mage/Page/view/frontend/css/validate.css similarity index 100% rename from app/code/core/Mage/Page/view/frontend/css/validate.css rename to app/code/Mage/Page/view/frontend/css/validate.css diff --git a/app/code/core/Mage/Page/view/frontend/empty.phtml b/app/code/Mage/Page/view/frontend/empty.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/empty.phtml rename to app/code/Mage/Page/view/frontend/empty.phtml diff --git a/app/code/core/Mage/Page/view/frontend/favicon.ico b/app/code/Mage/Page/view/frontend/favicon.ico similarity index 100% rename from app/code/core/Mage/Page/view/frontend/favicon.ico rename to app/code/Mage/Page/view/frontend/favicon.ico diff --git a/app/code/core/Mage/Page/view/frontend/html/breadcrumbs.phtml b/app/code/Mage/Page/view/frontend/html/breadcrumbs.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/html/breadcrumbs.phtml rename to app/code/Mage/Page/view/frontend/html/breadcrumbs.phtml diff --git a/app/code/core/Mage/Page/view/frontend/html/footer.phtml b/app/code/Mage/Page/view/frontend/html/footer.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/html/footer.phtml rename to app/code/Mage/Page/view/frontend/html/footer.phtml diff --git a/app/code/core/Mage/Page/view/frontend/html/head.phtml b/app/code/Mage/Page/view/frontend/html/head.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/html/head.phtml rename to app/code/Mage/Page/view/frontend/html/head.phtml diff --git a/app/code/core/Mage/Page/view/frontend/html/header.phtml b/app/code/Mage/Page/view/frontend/html/header.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/html/header.phtml rename to app/code/Mage/Page/view/frontend/html/header.phtml diff --git a/app/code/core/Mage/Page/view/frontend/html/notices.phtml b/app/code/Mage/Page/view/frontend/html/notices.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/html/notices.phtml rename to app/code/Mage/Page/view/frontend/html/notices.phtml diff --git a/app/code/core/Mage/Page/view/frontend/html/pager.phtml b/app/code/Mage/Page/view/frontend/html/pager.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/html/pager.phtml rename to app/code/Mage/Page/view/frontend/html/pager.phtml diff --git a/app/code/core/Mage/Page/view/frontend/html/topmenu.phtml b/app/code/Mage/Page/view/frontend/html/topmenu.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/html/topmenu.phtml rename to app/code/Mage/Page/view/frontend/html/topmenu.phtml diff --git a/app/code/core/Mage/Page/view/frontend/images/validation_advice_bg.gif b/app/code/Mage/Page/view/frontend/images/validation_advice_bg.gif similarity index 100% rename from app/code/core/Mage/Page/view/frontend/images/validation_advice_bg.gif rename to app/code/Mage/Page/view/frontend/images/validation_advice_bg.gif diff --git a/app/code/core/Mage/Page/view/frontend/js/calendar.phtml b/app/code/Mage/Page/view/frontend/js/calendar.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/js/calendar.phtml rename to app/code/Mage/Page/view/frontend/js/calendar.phtml diff --git a/app/code/core/Mage/Page/view/frontend/js/cookie.phtml b/app/code/Mage/Page/view/frontend/js/cookie.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/js/cookie.phtml rename to app/code/Mage/Page/view/frontend/js/cookie.phtml diff --git a/app/code/core/Mage/Page/view/frontend/js/global.js b/app/code/Mage/Page/view/frontend/js/global.js similarity index 100% rename from app/code/core/Mage/Page/view/frontend/js/global.js rename to app/code/Mage/Page/view/frontend/js/global.js diff --git a/app/code/core/Mage/Page/view/frontend/js/menu.js b/app/code/Mage/Page/view/frontend/js/menu.js similarity index 100% rename from app/code/core/Mage/Page/view/frontend/js/menu.js rename to app/code/Mage/Page/view/frontend/js/menu.js diff --git a/app/code/core/Mage/Page/view/frontend/js/notices.js b/app/code/Mage/Page/view/frontend/js/notices.js similarity index 100% rename from app/code/core/Mage/Page/view/frontend/js/notices.js rename to app/code/Mage/Page/view/frontend/js/notices.js diff --git a/app/code/core/Mage/Page/view/frontend/js/popup-menu.js b/app/code/Mage/Page/view/frontend/js/popup-menu.js similarity index 100% rename from app/code/core/Mage/Page/view/frontend/js/popup-menu.js rename to app/code/Mage/Page/view/frontend/js/popup-menu.js diff --git a/app/code/core/Mage/Page/view/frontend/js/row-builder.js b/app/code/Mage/Page/view/frontend/js/row-builder.js similarity index 100% rename from app/code/core/Mage/Page/view/frontend/js/row-builder.js rename to app/code/Mage/Page/view/frontend/js/row-builder.js diff --git a/app/code/Mage/Page/view/frontend/js/truncate.js b/app/code/Mage/Page/view/frontend/js/truncate.js new file mode 100644 index 0000000000000..bed4d462c513b --- /dev/null +++ b/app/code/Mage/Page/view/frontend/js/truncate.js @@ -0,0 +1,53 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage Page + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +/*jshint jquery:true*/ +(function($) { + "use strict"; + $.widget('mage.truncateOptions', { + options: { + detailsLink: 'a.details', + mouseEvents: 'mouseover mouseout', + truncatedFullValue: 'div.truncated_full_value' + }, + + /** + * Establish the event handler for mouse events on the appropriate elements. + * @private + */ + _create: function() { + this.element.on(this.options.mouseEvents, $.proxy(this._toggleShow, this)) + .find(this.options.detailsLink).on(this.options.mouseEvents, $.proxy(this._toggleShow, this)); + }, + + /** + * Toggle the "show" class on the associated element. + * @private + * @param event {Object} - Mouse over/out event. + */ + _toggleShow: function(event) { + $(event.currentTarget).find(this.options.truncatedFullValue).toggleClass('show'); + } + }); +})(jQuery); diff --git a/app/code/core/Mage/Page/view/frontend/layout.xml b/app/code/Mage/Page/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/layout.xml rename to app/code/Mage/Page/view/frontend/layout.xml diff --git a/app/code/core/Mage/Page/view/frontend/layout_addons.xml b/app/code/Mage/Page/view/frontend/layout_addons.xml similarity index 93% rename from app/code/core/Mage/Page/view/frontend/layout_addons.xml rename to app/code/Mage/Page/view/frontend/layout_addons.xml index cddf29c93f914..6284d70acc8d7 100644 --- a/app/code/core/Mage/Page/view/frontend/layout_addons.xml +++ b/app/code/Mage/Page/view/frontend/layout_addons.xml @@ -38,7 +38,7 @@ varien/form.js Mage_Page::menu.js mage/calendar.css - jquery/jquery.min.js + jquery/jquery.js mage/jquery-no-conflict.js head.load.min.js mage/mage.js @@ -47,9 +47,12 @@ mage/cookies.js jquery/jquery-ui.js jquery/jquery.tmpl.min.js + mage/bootstrap.js Mage_Page::js/global.js + Mage_Page::js/truncate.js mage/common.js mage/toggle.js + mage/popup-window.js Mage_Page::css/tabs.css mage/loader.js diff --git a/app/code/core/Mage/Page/view/frontend/menu.js b/app/code/Mage/Page/view/frontend/menu.js similarity index 100% rename from app/code/core/Mage/Page/view/frontend/menu.js rename to app/code/Mage/Page/view/frontend/menu.js diff --git a/app/code/core/Mage/Page/view/frontend/page_fragment.phtml b/app/code/Mage/Page/view/frontend/page_fragment.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/page_fragment.phtml rename to app/code/Mage/Page/view/frontend/page_fragment.phtml diff --git a/app/code/core/Mage/Page/view/frontend/popup.phtml b/app/code/Mage/Page/view/frontend/popup.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/popup.phtml rename to app/code/Mage/Page/view/frontend/popup.phtml diff --git a/app/code/core/Mage/Page/view/frontend/print.phtml b/app/code/Mage/Page/view/frontend/print.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/print.phtml rename to app/code/Mage/Page/view/frontend/print.phtml diff --git a/app/code/core/Mage/Page/view/frontend/redirect.phtml b/app/code/Mage/Page/view/frontend/redirect.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/redirect.phtml rename to app/code/Mage/Page/view/frontend/redirect.phtml diff --git a/app/code/core/Mage/Page/view/frontend/switch/flags.phtml b/app/code/Mage/Page/view/frontend/switch/flags.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/switch/flags.phtml rename to app/code/Mage/Page/view/frontend/switch/flags.phtml diff --git a/app/code/core/Mage/Page/view/frontend/switch/languages.phtml b/app/code/Mage/Page/view/frontend/switch/languages.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/switch/languages.phtml rename to app/code/Mage/Page/view/frontend/switch/languages.phtml diff --git a/app/code/core/Mage/Page/view/frontend/switch/stores.phtml b/app/code/Mage/Page/view/frontend/switch/stores.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/switch/stores.phtml rename to app/code/Mage/Page/view/frontend/switch/stores.phtml diff --git a/app/code/core/Mage/Page/view/frontend/template/container.phtml b/app/code/Mage/Page/view/frontend/template/container.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/template/container.phtml rename to app/code/Mage/Page/view/frontend/template/container.phtml diff --git a/app/code/core/Mage/Page/view/frontend/template/links.phtml b/app/code/Mage/Page/view/frontend/template/links.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/template/links.phtml rename to app/code/Mage/Page/view/frontend/template/links.phtml diff --git a/app/code/core/Mage/Page/view/frontend/template/linksblock.phtml b/app/code/Mage/Page/view/frontend/template/linksblock.phtml similarity index 100% rename from app/code/core/Mage/Page/view/frontend/template/linksblock.phtml rename to app/code/Mage/Page/view/frontend/template/linksblock.phtml diff --git a/app/code/core/Mage/Page/view/install/favicon.ico b/app/code/Mage/Page/view/install/favicon.ico similarity index 100% rename from app/code/core/Mage/Page/view/install/favicon.ico rename to app/code/Mage/Page/view/install/favicon.ico diff --git a/app/code/core/Mage/PageCache/Block/Adminhtml/Cache/Additional.php b/app/code/Mage/PageCache/Block/Adminhtml/Cache/Additional.php similarity index 100% rename from app/code/core/Mage/PageCache/Block/Adminhtml/Cache/Additional.php rename to app/code/Mage/PageCache/Block/Adminhtml/Cache/Additional.php diff --git a/app/code/Mage/PageCache/Helper/Data.php b/app/code/Mage/PageCache/Helper/Data.php new file mode 100644 index 0000000000000..0141cc88160b8 --- /dev/null +++ b/app/code/Mage/PageCache/Helper/Data.php @@ -0,0 +1,190 @@ + + */ +class Mage_PageCache_Helper_Data extends Mage_Core_Helper_Abstract +{ + /** + * Paths to external cache config options + */ + const XML_PATH_EXTERNAL_CACHE_ENABLED = 'system/external_page_cache/enabled'; + const XML_PATH_EXTERNAL_CACHE_LIFETIME = 'system/external_page_cache/cookie_lifetime'; + const XML_PATH_EXTERNAL_CACHE_CONTROL = 'system/external_page_cache/control'; + + /** + * Path to external cache controls + */ + const XML_PATH_EXTERNAL_CACHE_CONTROLS = 'global/external_cache/controls'; + + /** + * Cookie name for disabling external caching + */ + const NO_CACHE_COOKIE = 'external_no_cache'; + + /** + * Cookie name for locking the NO_CACHE_COOKIE for modification + */ + const NO_CACHE_LOCK_COOKIE = 'external_no_cache_cookie_locked'; + + /** + * @var bool + */ + protected $_isNoCacheCookieLocked = false; + + /** + * Initialize 'no cache' cookie locking + * + * @param Mage_Core_Helper_Context $context + */ + function __construct(Mage_Core_Helper_Context $context) + { + parent::__construct($context); + $this->_isNoCacheCookieLocked = (bool)$this->_getCookie()->get(self::NO_CACHE_LOCK_COOKIE); + } + + /** + * Retrieve the cookie model instance + * + * @return Mage_Core_Model_Cookie + */ + protected function _getCookie() + { + return Mage::getSingleton('Mage_Core_Model_Cookie'); + } + + /** + * Check whether external cache is enabled + * + * @return bool + */ + public function isEnabled() + { + return (bool)Mage::getStoreConfig(self::XML_PATH_EXTERNAL_CACHE_ENABLED); + } + + /** + * Return all available external cache controls + * + * @return array + */ + public function getCacheControls() + { + $controls = Mage::app()->getConfig()->getNode(self::XML_PATH_EXTERNAL_CACHE_CONTROLS); + return $controls->asCanonicalArray(); + } + + /** + * Initialize proper external cache control model + * + * @throws Mage_Core_Exception + * @return Mage_PageCache_Model_Control_Interface + */ + public function getCacheControlInstance() + { + $usedControl = Mage::getStoreConfig(self::XML_PATH_EXTERNAL_CACHE_CONTROL); + if ($usedControl) { + foreach ($this->getCacheControls() as $control => $info) { + if ($control == $usedControl && !empty($info['class'])) { + return Mage::getSingleton($info['class']); + } + } + } + Mage::throwException($this->__('Failed to load external cache control')); + } + + /** + * Disable caching on external storage side by setting special cookie, if the cookie has not been locked + * + * @param int|null $lifetime + * @return Mage_PageCache_Helper_Data + */ + public function setNoCacheCookie($lifetime = null) + { + if ($this->_isNoCacheCookieLocked) { + return $this; + } + $lifetime = $lifetime !== null ? $lifetime : Mage::getStoreConfig(self::XML_PATH_EXTERNAL_CACHE_LIFETIME); + if ($this->_getCookie()->get(self::NO_CACHE_COOKIE)) { + $this->_getCookie()->renew(self::NO_CACHE_COOKIE, $lifetime); + } else { + $this->_getCookie()->set(self::NO_CACHE_COOKIE, '1', $lifetime); + } + return $this; + } + + /** + * Remove the 'no cache' cookie, if it has not been locked + * + * @return Mage_PageCache_Helper_Data + */ + public function removeNoCacheCookie() + { + if (!$this->_isNoCacheCookieLocked) { + $this->_getCookie()->delete(self::NO_CACHE_COOKIE); + } + return $this; + } + + /** + * Disable modification of the 'no cache' cookie + * + * @return Mage_PageCache_Helper_Data + */ + public function lockNoCacheCookie() + { + $this->_getCookie()->set(self::NO_CACHE_LOCK_COOKIE, '1', 0); + $this->_isNoCacheCookieLocked = true; + return $this; + } + + /** + * Enable modification of the 'no cache' cookie + * + * @return Mage_PageCache_Helper_Data + */ + public function unlockNoCacheCookie() + { + $this->_getCookie()->delete(self::NO_CACHE_LOCK_COOKIE); + $this->_isNoCacheCookieLocked = false; + return $this; + } + + /** + * Returns a lifetime of cookie for external cache + * + * @return string Time in seconds + */ + public function getNoCacheCookieLifetime() + { + return Mage::getStoreConfig(self::XML_PATH_EXTERNAL_CACHE_LIFETIME); + } +} diff --git a/app/code/core/Mage/PageCache/Model/Control/Interface.php b/app/code/Mage/PageCache/Model/Control/Interface.php similarity index 100% rename from app/code/core/Mage/PageCache/Model/Control/Interface.php rename to app/code/Mage/PageCache/Model/Control/Interface.php diff --git a/app/code/core/Mage/PageCache/Model/Control/Zend.php b/app/code/Mage/PageCache/Model/Control/Zend.php similarity index 100% rename from app/code/core/Mage/PageCache/Model/Control/Zend.php rename to app/code/Mage/PageCache/Model/Control/Zend.php diff --git a/app/code/core/Mage/PageCache/Model/Observer.php b/app/code/Mage/PageCache/Model/Observer.php similarity index 100% rename from app/code/core/Mage/PageCache/Model/Observer.php rename to app/code/Mage/PageCache/Model/Observer.php diff --git a/app/code/core/Mage/PageCache/Model/System/Config/Source/Controls.php b/app/code/Mage/PageCache/Model/System/Config/Source/Controls.php similarity index 100% rename from app/code/core/Mage/PageCache/Model/System/Config/Source/Controls.php rename to app/code/Mage/PageCache/Model/System/Config/Source/Controls.php diff --git a/app/code/core/Mage/PageCache/controllers/Adminhtml/PageCacheController.php b/app/code/Mage/PageCache/controllers/Adminhtml/PageCacheController.php similarity index 100% rename from app/code/core/Mage/PageCache/controllers/Adminhtml/PageCacheController.php rename to app/code/Mage/PageCache/controllers/Adminhtml/PageCacheController.php diff --git a/app/code/core/Mage/PageCache/etc/adminhtml/acl.xml b/app/code/Mage/PageCache/etc/adminhtml/acl.xml similarity index 100% rename from app/code/core/Mage/PageCache/etc/adminhtml/acl.xml rename to app/code/Mage/PageCache/etc/adminhtml/acl.xml diff --git a/app/code/core/Mage/PageCache/etc/adminhtml/system.xml b/app/code/Mage/PageCache/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/PageCache/etc/adminhtml/system.xml rename to app/code/Mage/PageCache/etc/adminhtml/system.xml diff --git a/app/code/Mage/PageCache/etc/config.xml b/app/code/Mage/PageCache/etc/config.xml new file mode 100644 index 0000000000000..ee4c6ee07a7f9 --- /dev/null +++ b/app/code/Mage/PageCache/etc/config.xml @@ -0,0 +1,138 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + + Mage_PageCache_Model_Control_Zend + + + + + + + + Mage_PageCache_Model_Observer + setNoCacheCookie + + + + + + + Mage_PageCache_Model_Observer + deleteNoCacheCookie + + + + + + + + + + layout.xml + + + + + + + + Mage_PageCache.csv + + + + + + + + + + layout.xml + + + + + + + + Mage_PageCache_Model_Observer + processPreDispatch + + + + + + + + + + + + + + + + + + + + + + + + + + Mage_PageCache_Adminhtml + + + + + + + + + 0 + zend_page_cache + 3600 + + + + diff --git a/app/code/core/Mage/PageCache/locale/de_DE/Mage_PageCache.csv b/app/code/Mage/PageCache/locale/de_DE/Mage_PageCache.csv similarity index 100% rename from app/code/core/Mage/PageCache/locale/de_DE/Mage_PageCache.csv rename to app/code/Mage/PageCache/locale/de_DE/Mage_PageCache.csv diff --git a/app/code/core/Mage/PageCache/locale/en_US/Mage_PageCache.csv b/app/code/Mage/PageCache/locale/en_US/Mage_PageCache.csv similarity index 100% rename from app/code/core/Mage/PageCache/locale/en_US/Mage_PageCache.csv rename to app/code/Mage/PageCache/locale/en_US/Mage_PageCache.csv diff --git a/app/code/core/Mage/PageCache/locale/es_ES/Mage_PageCache.csv b/app/code/Mage/PageCache/locale/es_ES/Mage_PageCache.csv similarity index 100% rename from app/code/core/Mage/PageCache/locale/es_ES/Mage_PageCache.csv rename to app/code/Mage/PageCache/locale/es_ES/Mage_PageCache.csv diff --git a/app/code/core/Mage/PageCache/locale/fr_FR/Mage_PageCache.csv b/app/code/Mage/PageCache/locale/fr_FR/Mage_PageCache.csv similarity index 100% rename from app/code/core/Mage/PageCache/locale/fr_FR/Mage_PageCache.csv rename to app/code/Mage/PageCache/locale/fr_FR/Mage_PageCache.csv diff --git a/app/code/core/Mage/PageCache/locale/nl_NL/Mage_PageCache.csv b/app/code/Mage/PageCache/locale/nl_NL/Mage_PageCache.csv similarity index 100% rename from app/code/core/Mage/PageCache/locale/nl_NL/Mage_PageCache.csv rename to app/code/Mage/PageCache/locale/nl_NL/Mage_PageCache.csv diff --git a/app/code/core/Mage/PageCache/locale/pt_BR/Mage_PageCache.csv b/app/code/Mage/PageCache/locale/pt_BR/Mage_PageCache.csv similarity index 100% rename from app/code/core/Mage/PageCache/locale/pt_BR/Mage_PageCache.csv rename to app/code/Mage/PageCache/locale/pt_BR/Mage_PageCache.csv diff --git a/app/code/core/Mage/PageCache/locale/zh_CN/Mage_PageCache.csv b/app/code/Mage/PageCache/locale/zh_CN/Mage_PageCache.csv similarity index 100% rename from app/code/core/Mage/PageCache/locale/zh_CN/Mage_PageCache.csv rename to app/code/Mage/PageCache/locale/zh_CN/Mage_PageCache.csv diff --git a/app/code/core/Mage/PageCache/view/adminhtml/cache/additional.phtml b/app/code/Mage/PageCache/view/adminhtml/cache/additional.phtml similarity index 100% rename from app/code/core/Mage/PageCache/view/adminhtml/cache/additional.phtml rename to app/code/Mage/PageCache/view/adminhtml/cache/additional.phtml diff --git a/app/code/core/Mage/PageCache/view/adminhtml/layout.xml b/app/code/Mage/PageCache/view/adminhtml/layout.xml similarity index 100% rename from app/code/core/Mage/PageCache/view/adminhtml/layout.xml rename to app/code/Mage/PageCache/view/adminhtml/layout.xml diff --git a/app/code/core/Mage/PageCache/view/frontend/cookie.phtml b/app/code/Mage/PageCache/view/frontend/cookie.phtml similarity index 100% rename from app/code/core/Mage/PageCache/view/frontend/cookie.phtml rename to app/code/Mage/PageCache/view/frontend/cookie.phtml diff --git a/app/code/core/Mage/PageCache/view/frontend/layout.xml b/app/code/Mage/PageCache/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/PageCache/view/frontend/layout.xml rename to app/code/Mage/PageCache/view/frontend/layout.xml diff --git a/app/code/core/Mage/Paygate/Block/Authorizenet/Form/Cc.php b/app/code/Mage/Paygate/Block/Authorizenet/Form/Cc.php similarity index 100% rename from app/code/core/Mage/Paygate/Block/Authorizenet/Form/Cc.php rename to app/code/Mage/Paygate/Block/Authorizenet/Form/Cc.php diff --git a/app/code/core/Mage/Paygate/Block/Authorizenet/Info/Cc.php b/app/code/Mage/Paygate/Block/Authorizenet/Info/Cc.php similarity index 100% rename from app/code/core/Mage/Paygate/Block/Authorizenet/Info/Cc.php rename to app/code/Mage/Paygate/Block/Authorizenet/Info/Cc.php diff --git a/app/code/core/Mage/Paygate/Helper/Data.php b/app/code/Mage/Paygate/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Paygate/Helper/Data.php rename to app/code/Mage/Paygate/Helper/Data.php diff --git a/app/code/core/Mage/Paygate/Model/Authorizenet.php b/app/code/Mage/Paygate/Model/Authorizenet.php similarity index 100% rename from app/code/core/Mage/Paygate/Model/Authorizenet.php rename to app/code/Mage/Paygate/Model/Authorizenet.php diff --git a/app/code/core/Mage/Paygate/Model/Authorizenet/Cards.php b/app/code/Mage/Paygate/Model/Authorizenet/Cards.php similarity index 100% rename from app/code/core/Mage/Paygate/Model/Authorizenet/Cards.php rename to app/code/Mage/Paygate/Model/Authorizenet/Cards.php diff --git a/app/code/core/Mage/Paygate/Model/Authorizenet/Debug.php b/app/code/Mage/Paygate/Model/Authorizenet/Debug.php similarity index 100% rename from app/code/core/Mage/Paygate/Model/Authorizenet/Debug.php rename to app/code/Mage/Paygate/Model/Authorizenet/Debug.php diff --git a/app/code/core/Mage/Paygate/Model/Authorizenet/Request.php b/app/code/Mage/Paygate/Model/Authorizenet/Request.php similarity index 100% rename from app/code/core/Mage/Paygate/Model/Authorizenet/Request.php rename to app/code/Mage/Paygate/Model/Authorizenet/Request.php diff --git a/app/code/core/Mage/Paygate/Model/Authorizenet/Result.php b/app/code/Mage/Paygate/Model/Authorizenet/Result.php similarity index 100% rename from app/code/core/Mage/Paygate/Model/Authorizenet/Result.php rename to app/code/Mage/Paygate/Model/Authorizenet/Result.php diff --git a/app/code/core/Mage/Paygate/Model/Authorizenet/Source/Cctype.php b/app/code/Mage/Paygate/Model/Authorizenet/Source/Cctype.php similarity index 100% rename from app/code/core/Mage/Paygate/Model/Authorizenet/Source/Cctype.php rename to app/code/Mage/Paygate/Model/Authorizenet/Source/Cctype.php diff --git a/app/code/core/Mage/Paygate/Model/Authorizenet/Source/PaymentAction.php b/app/code/Mage/Paygate/Model/Authorizenet/Source/PaymentAction.php similarity index 100% rename from app/code/core/Mage/Paygate/Model/Authorizenet/Source/PaymentAction.php rename to app/code/Mage/Paygate/Model/Authorizenet/Source/PaymentAction.php diff --git a/app/code/core/Mage/Paygate/Model/Resource/Authorizenet/Debug.php b/app/code/Mage/Paygate/Model/Resource/Authorizenet/Debug.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Paygate/Model/Resource/Authorizenet/Debug.php rename to app/code/Mage/Paygate/Model/Resource/Authorizenet/Debug.php diff --git a/app/code/core/Mage/Paygate/Model/Resource/Authorizenet/Debug/Collection.php b/app/code/Mage/Paygate/Model/Resource/Authorizenet/Debug/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Paygate/Model/Resource/Authorizenet/Debug/Collection.php rename to app/code/Mage/Paygate/Model/Resource/Authorizenet/Debug/Collection.php diff --git a/app/code/core/Mage/Paygate/controllers/Adminhtml/Paygate/Authorizenet/PaymentController.php b/app/code/Mage/Paygate/controllers/Adminhtml/Paygate/Authorizenet/PaymentController.php similarity index 100% rename from app/code/core/Mage/Paygate/controllers/Adminhtml/Paygate/Authorizenet/PaymentController.php rename to app/code/Mage/Paygate/controllers/Adminhtml/Paygate/Authorizenet/PaymentController.php diff --git a/app/code/core/Mage/Paygate/controllers/Authorizenet/PaymentController.php b/app/code/Mage/Paygate/controllers/Authorizenet/PaymentController.php similarity index 100% rename from app/code/core/Mage/Paygate/controllers/Authorizenet/PaymentController.php rename to app/code/Mage/Paygate/controllers/Authorizenet/PaymentController.php diff --git a/app/code/core/Mage/Paygate/etc/adminhtml/system.xml b/app/code/Mage/Paygate/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Paygate/etc/adminhtml/system.xml rename to app/code/Mage/Paygate/etc/adminhtml/system.xml diff --git a/app/code/Mage/Paygate/etc/config.xml b/app/code/Mage/Paygate/etc/config.xml new file mode 100644 index 0000000000000..010e52c61aefa --- /dev/null +++ b/app/code/Mage/Paygate/etc/config.xml @@ -0,0 +1,114 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + Mage_Paygate + + + + + + + + + + Mage_Paygate.csv + + + + + + + + /paygate/authorizenet_payment + + + + + + Mage_Paygate.csv + + + + + + + standard + + Mage_Paygate + paygate + + + + + + + + + + Mage_Paygate_Adminhtml + + + + + + + + + 0 + AE,VI,MC,DI + https://secure.authorize.net/gateway/transact.dll + 0 + 0 + + + Mage_Paygate_Model_Authorizenet + processing + authorize + 1 + Credit Card (Authorize.net) + + 0 + USD + 1 + + + + diff --git a/app/code/core/Mage/Paygate/locale/de_DE/Mage_Paygate.csv b/app/code/Mage/Paygate/locale/de_DE/Mage_Paygate.csv similarity index 100% rename from app/code/core/Mage/Paygate/locale/de_DE/Mage_Paygate.csv rename to app/code/Mage/Paygate/locale/de_DE/Mage_Paygate.csv diff --git a/app/code/core/Mage/Paygate/locale/en_US/Mage_Paygate.csv b/app/code/Mage/Paygate/locale/en_US/Mage_Paygate.csv similarity index 100% rename from app/code/core/Mage/Paygate/locale/en_US/Mage_Paygate.csv rename to app/code/Mage/Paygate/locale/en_US/Mage_Paygate.csv diff --git a/app/code/core/Mage/Paygate/locale/es_ES/Mage_Paygate.csv b/app/code/Mage/Paygate/locale/es_ES/Mage_Paygate.csv similarity index 100% rename from app/code/core/Mage/Paygate/locale/es_ES/Mage_Paygate.csv rename to app/code/Mage/Paygate/locale/es_ES/Mage_Paygate.csv diff --git a/app/code/core/Mage/Paygate/locale/fr_FR/Mage_Paygate.csv b/app/code/Mage/Paygate/locale/fr_FR/Mage_Paygate.csv similarity index 100% rename from app/code/core/Mage/Paygate/locale/fr_FR/Mage_Paygate.csv rename to app/code/Mage/Paygate/locale/fr_FR/Mage_Paygate.csv diff --git a/app/code/core/Mage/Paygate/locale/nl_NL/Mage_Paygate.csv b/app/code/Mage/Paygate/locale/nl_NL/Mage_Paygate.csv similarity index 100% rename from app/code/core/Mage/Paygate/locale/nl_NL/Mage_Paygate.csv rename to app/code/Mage/Paygate/locale/nl_NL/Mage_Paygate.csv diff --git a/app/code/core/Mage/Paygate/locale/pt_BR/Mage_Paygate.csv b/app/code/Mage/Paygate/locale/pt_BR/Mage_Paygate.csv similarity index 100% rename from app/code/core/Mage/Paygate/locale/pt_BR/Mage_Paygate.csv rename to app/code/Mage/Paygate/locale/pt_BR/Mage_Paygate.csv diff --git a/app/code/core/Mage/Paygate/locale/zh_CN/Mage_Paygate.csv b/app/code/Mage/Paygate/locale/zh_CN/Mage_Paygate.csv similarity index 100% rename from app/code/core/Mage/Paygate/locale/zh_CN/Mage_Paygate.csv rename to app/code/Mage/Paygate/locale/zh_CN/Mage_Paygate.csv diff --git a/app/code/core/Mage/Paygate/sql/paygate_setup/install-1.6.0.0.php b/app/code/Mage/Paygate/sql/paygate_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Paygate/sql/paygate_setup/install-1.6.0.0.php rename to app/code/Mage/Paygate/sql/paygate_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Paygate/view/adminhtml/form/cc.phtml b/app/code/Mage/Paygate/view/adminhtml/form/cc.phtml similarity index 100% rename from app/code/core/Mage/Paygate/view/adminhtml/form/cc.phtml rename to app/code/Mage/Paygate/view/adminhtml/form/cc.phtml diff --git a/app/code/core/Mage/Paygate/view/adminhtml/info/cc.phtml b/app/code/Mage/Paygate/view/adminhtml/info/cc.phtml similarity index 100% rename from app/code/core/Mage/Paygate/view/adminhtml/info/cc.phtml rename to app/code/Mage/Paygate/view/adminhtml/info/cc.phtml diff --git a/app/code/core/Mage/Paygate/view/adminhtml/info/pdf.phtml b/app/code/Mage/Paygate/view/adminhtml/info/pdf.phtml similarity index 100% rename from app/code/core/Mage/Paygate/view/adminhtml/info/pdf.phtml rename to app/code/Mage/Paygate/view/adminhtml/info/pdf.phtml diff --git a/app/code/core/Mage/Paygate/view/frontend/form/cc.phtml b/app/code/Mage/Paygate/view/frontend/form/cc.phtml similarity index 100% rename from app/code/core/Mage/Paygate/view/frontend/form/cc.phtml rename to app/code/Mage/Paygate/view/frontend/form/cc.phtml diff --git a/app/code/core/Mage/Paygate/view/frontend/info/cc.phtml b/app/code/Mage/Paygate/view/frontend/info/cc.phtml similarity index 100% rename from app/code/core/Mage/Paygate/view/frontend/info/cc.phtml rename to app/code/Mage/Paygate/view/frontend/info/cc.phtml diff --git a/app/code/core/Mage/Payment/Block/Catalog/Product/View/Profile.php b/app/code/Mage/Payment/Block/Catalog/Product/View/Profile.php similarity index 100% rename from app/code/core/Mage/Payment/Block/Catalog/Product/View/Profile.php rename to app/code/Mage/Payment/Block/Catalog/Product/View/Profile.php diff --git a/app/code/core/Mage/Payment/Block/Form.php b/app/code/Mage/Payment/Block/Form.php similarity index 100% rename from app/code/core/Mage/Payment/Block/Form.php rename to app/code/Mage/Payment/Block/Form.php diff --git a/app/code/core/Mage/Payment/Block/Form/Banktransfer.php b/app/code/Mage/Payment/Block/Form/Banktransfer.php similarity index 100% rename from app/code/core/Mage/Payment/Block/Form/Banktransfer.php rename to app/code/Mage/Payment/Block/Form/Banktransfer.php diff --git a/app/code/core/Mage/Payment/Block/Form/Cashondelivery.php b/app/code/Mage/Payment/Block/Form/Cashondelivery.php similarity index 100% rename from app/code/core/Mage/Payment/Block/Form/Cashondelivery.php rename to app/code/Mage/Payment/Block/Form/Cashondelivery.php diff --git a/app/code/core/Mage/Payment/Block/Form/Cc.php b/app/code/Mage/Payment/Block/Form/Cc.php similarity index 100% rename from app/code/core/Mage/Payment/Block/Form/Cc.php rename to app/code/Mage/Payment/Block/Form/Cc.php diff --git a/app/code/core/Mage/Payment/Block/Form/Ccsave.php b/app/code/Mage/Payment/Block/Form/Ccsave.php similarity index 100% rename from app/code/core/Mage/Payment/Block/Form/Ccsave.php rename to app/code/Mage/Payment/Block/Form/Ccsave.php diff --git a/app/code/core/Mage/Payment/Block/Form/Checkmo.php b/app/code/Mage/Payment/Block/Form/Checkmo.php similarity index 100% rename from app/code/core/Mage/Payment/Block/Form/Checkmo.php rename to app/code/Mage/Payment/Block/Form/Checkmo.php diff --git a/app/code/core/Mage/Payment/Block/Form/Container.php b/app/code/Mage/Payment/Block/Form/Container.php similarity index 100% rename from app/code/core/Mage/Payment/Block/Form/Container.php rename to app/code/Mage/Payment/Block/Form/Container.php diff --git a/app/code/core/Mage/Payment/Block/Form/Purchaseorder.php b/app/code/Mage/Payment/Block/Form/Purchaseorder.php similarity index 100% rename from app/code/core/Mage/Payment/Block/Form/Purchaseorder.php rename to app/code/Mage/Payment/Block/Form/Purchaseorder.php diff --git a/app/code/core/Mage/Payment/Block/Info.php b/app/code/Mage/Payment/Block/Info.php similarity index 100% rename from app/code/core/Mage/Payment/Block/Info.php rename to app/code/Mage/Payment/Block/Info.php diff --git a/app/code/core/Mage/Payment/Block/Info/Cc.php b/app/code/Mage/Payment/Block/Info/Cc.php similarity index 100% rename from app/code/core/Mage/Payment/Block/Info/Cc.php rename to app/code/Mage/Payment/Block/Info/Cc.php diff --git a/app/code/core/Mage/Payment/Block/Info/Ccsave.php b/app/code/Mage/Payment/Block/Info/Ccsave.php similarity index 100% rename from app/code/core/Mage/Payment/Block/Info/Ccsave.php rename to app/code/Mage/Payment/Block/Info/Ccsave.php diff --git a/app/code/core/Mage/Payment/Block/Info/Checkmo.php b/app/code/Mage/Payment/Block/Info/Checkmo.php similarity index 100% rename from app/code/core/Mage/Payment/Block/Info/Checkmo.php rename to app/code/Mage/Payment/Block/Info/Checkmo.php diff --git a/app/code/core/Mage/Payment/Block/Info/ContainerAbstract.php b/app/code/Mage/Payment/Block/Info/ContainerAbstract.php similarity index 100% rename from app/code/core/Mage/Payment/Block/Info/ContainerAbstract.php rename to app/code/Mage/Payment/Block/Info/ContainerAbstract.php diff --git a/app/code/core/Mage/Payment/Block/Info/Instructions.php b/app/code/Mage/Payment/Block/Info/Instructions.php similarity index 100% rename from app/code/core/Mage/Payment/Block/Info/Instructions.php rename to app/code/Mage/Payment/Block/Info/Instructions.php diff --git a/app/code/core/Mage/Payment/Block/Info/Purchaseorder.php b/app/code/Mage/Payment/Block/Info/Purchaseorder.php similarity index 100% rename from app/code/core/Mage/Payment/Block/Info/Purchaseorder.php rename to app/code/Mage/Payment/Block/Info/Purchaseorder.php diff --git a/app/code/core/Mage/Payment/Exception.php b/app/code/Mage/Payment/Exception.php similarity index 100% rename from app/code/core/Mage/Payment/Exception.php rename to app/code/Mage/Payment/Exception.php diff --git a/app/code/core/Mage/Payment/Helper/Data.php b/app/code/Mage/Payment/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Payment/Helper/Data.php rename to app/code/Mage/Payment/Helper/Data.php diff --git a/app/code/core/Mage/Payment/Model/Billing/Agreement/MethodInterface.php b/app/code/Mage/Payment/Model/Billing/Agreement/MethodInterface.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Billing/Agreement/MethodInterface.php rename to app/code/Mage/Payment/Model/Billing/Agreement/MethodInterface.php diff --git a/app/code/core/Mage/Payment/Model/Billing/AgreementAbstract.php b/app/code/Mage/Payment/Model/Billing/AgreementAbstract.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Billing/AgreementAbstract.php rename to app/code/Mage/Payment/Model/Billing/AgreementAbstract.php diff --git a/app/code/core/Mage/Payment/Model/Config.php b/app/code/Mage/Payment/Model/Config.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Config.php rename to app/code/Mage/Payment/Model/Config.php diff --git a/app/code/core/Mage/Payment/Model/Config/Source/Allmethods.php b/app/code/Mage/Payment/Model/Config/Source/Allmethods.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Config/Source/Allmethods.php rename to app/code/Mage/Payment/Model/Config/Source/Allmethods.php diff --git a/app/code/core/Mage/Payment/Model/Config/Source/Allowedmethods.php b/app/code/Mage/Payment/Model/Config/Source/Allowedmethods.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Config/Source/Allowedmethods.php rename to app/code/Mage/Payment/Model/Config/Source/Allowedmethods.php diff --git a/app/code/core/Mage/Payment/Model/Config/Source/Allspecificcountries.php b/app/code/Mage/Payment/Model/Config/Source/Allspecificcountries.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Config/Source/Allspecificcountries.php rename to app/code/Mage/Payment/Model/Config/Source/Allspecificcountries.php diff --git a/app/code/core/Mage/Payment/Model/Config/Source/Cctype.php b/app/code/Mage/Payment/Model/Config/Source/Cctype.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Config/Source/Cctype.php rename to app/code/Mage/Payment/Model/Config/Source/Cctype.php diff --git a/app/code/core/Mage/Payment/Model/Info.php b/app/code/Mage/Payment/Model/Info.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Info.php rename to app/code/Mage/Payment/Model/Info.php diff --git a/app/code/core/Mage/Payment/Model/Info/Exception.php b/app/code/Mage/Payment/Model/Info/Exception.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Info/Exception.php rename to app/code/Mage/Payment/Model/Info/Exception.php diff --git a/app/code/core/Mage/Payment/Model/Method/Abstract.php b/app/code/Mage/Payment/Model/Method/Abstract.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Method/Abstract.php rename to app/code/Mage/Payment/Model/Method/Abstract.php diff --git a/app/code/core/Mage/Payment/Model/Method/Banktransfer.php b/app/code/Mage/Payment/Model/Method/Banktransfer.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Method/Banktransfer.php rename to app/code/Mage/Payment/Model/Method/Banktransfer.php diff --git a/app/code/core/Mage/Payment/Model/Method/Cashondelivery.php b/app/code/Mage/Payment/Model/Method/Cashondelivery.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Method/Cashondelivery.php rename to app/code/Mage/Payment/Model/Method/Cashondelivery.php diff --git a/app/code/core/Mage/Payment/Model/Method/Cc.php b/app/code/Mage/Payment/Model/Method/Cc.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Method/Cc.php rename to app/code/Mage/Payment/Model/Method/Cc.php diff --git a/app/code/core/Mage/Payment/Model/Method/Ccsave.php b/app/code/Mage/Payment/Model/Method/Ccsave.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Method/Ccsave.php rename to app/code/Mage/Payment/Model/Method/Ccsave.php diff --git a/app/code/core/Mage/Payment/Model/Method/Checkmo.php b/app/code/Mage/Payment/Model/Method/Checkmo.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Method/Checkmo.php rename to app/code/Mage/Payment/Model/Method/Checkmo.php diff --git a/app/code/core/Mage/Payment/Model/Method/Free.php b/app/code/Mage/Payment/Model/Method/Free.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Method/Free.php rename to app/code/Mage/Payment/Model/Method/Free.php diff --git a/app/code/core/Mage/Payment/Model/Method/Purchaseorder.php b/app/code/Mage/Payment/Model/Method/Purchaseorder.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Method/Purchaseorder.php rename to app/code/Mage/Payment/Model/Method/Purchaseorder.php diff --git a/app/code/core/Mage/Payment/Model/Observer.php b/app/code/Mage/Payment/Model/Observer.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Observer.php rename to app/code/Mage/Payment/Model/Observer.php diff --git a/app/code/core/Mage/Payment/Model/Paygate/Result.php b/app/code/Mage/Payment/Model/Paygate/Result.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Paygate/Result.php rename to app/code/Mage/Payment/Model/Paygate/Result.php diff --git a/app/code/core/Mage/Payment/Model/Recurring/Profile.php b/app/code/Mage/Payment/Model/Recurring/Profile.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Recurring/Profile.php rename to app/code/Mage/Payment/Model/Recurring/Profile.php diff --git a/app/code/core/Mage/Payment/Model/Recurring/Profile/MethodInterface.php b/app/code/Mage/Payment/Model/Recurring/Profile/MethodInterface.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Recurring/Profile/MethodInterface.php rename to app/code/Mage/Payment/Model/Recurring/Profile/MethodInterface.php diff --git a/app/code/core/Mage/Payment/Model/Source/Cctype.php b/app/code/Mage/Payment/Model/Source/Cctype.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Source/Cctype.php rename to app/code/Mage/Payment/Model/Source/Cctype.php diff --git a/app/code/core/Mage/Payment/Model/Source/Invoice.php b/app/code/Mage/Payment/Model/Source/Invoice.php similarity index 100% rename from app/code/core/Mage/Payment/Model/Source/Invoice.php rename to app/code/Mage/Payment/Model/Source/Invoice.php diff --git a/app/code/Mage/Payment/etc/adminhtml/acl.xml b/app/code/Mage/Payment/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..42b846660c0b3 --- /dev/null +++ b/app/code/Mage/Payment/etc/adminhtml/acl.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + diff --git a/app/code/core/Mage/Payment/etc/adminhtml/system.xml b/app/code/Mage/Payment/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Payment/etc/adminhtml/system.xml rename to app/code/Mage/Payment/etc/adminhtml/system.xml diff --git a/app/code/Mage/Payment/etc/config.xml b/app/code/Mage/Payment/etc/config.xml new file mode 100644 index 0000000000000..6aa305ba465f9 --- /dev/null +++ b/app/code/Mage/Payment/etc/config.xml @@ -0,0 +1,206 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + + Mage_Payment + + + + + + + + AE + American Express + 0 + + + VI + Visa + 10 + + + MC + MasterCard + 20 + + + DI + Discover + 30 + + + SM + Maestro/Switch + 40 + + + SO + Solo + 45 + + + JCB + JCB + 50 + + + OT + Other + 1000 + + + + + Offline Payment Methods + + + + + + + Mage_Payment_Model_Observer salesOrderBeforeSave + + + + + + + Mage_Payment_Model_Observer + beforeOrderPaymentSave + + + + + + + + + + + Mage_Payment.csv + + + + + + + + + Mage_Payment_Model_Observer prepareProductRecurringProfileOptions + + + + + + + + layout.xml + + + + + + + + + + Mage_Payment.csv + + + + + + + + + 0 + AE,VI,MC,DI + Mage_Payment_Model_Method_Ccsave + pending + Credit Card (saved) + 0 + offline + + + 1 + Mage_Payment_Model_Method_Checkmo + pending + Check / Money order + 0 + offline + + + 1 + Mage_Payment_Model_Method_Free + pending + No Payment Information Required + 0 + 1 + offline + + + 0 + Mage_Payment_Model_Method_Purchaseorder + pending + Purchase Order + 0 + offline + + + 0 + Mage_Payment_Model_Method_Banktransfer + pending + Bank Transfer Payment + 0 + offline + + + 0 + Mage_Payment_Model_Method_Cashondelivery + pending + Cash On Delivery + 0 + offline + + + + diff --git a/app/code/core/Mage/Payment/locale/de_DE/Mage_Payment.csv b/app/code/Mage/Payment/locale/de_DE/Mage_Payment.csv similarity index 100% rename from app/code/core/Mage/Payment/locale/de_DE/Mage_Payment.csv rename to app/code/Mage/Payment/locale/de_DE/Mage_Payment.csv diff --git a/app/code/core/Mage/Payment/locale/en_US/Mage_Payment.csv b/app/code/Mage/Payment/locale/en_US/Mage_Payment.csv similarity index 100% rename from app/code/core/Mage/Payment/locale/en_US/Mage_Payment.csv rename to app/code/Mage/Payment/locale/en_US/Mage_Payment.csv diff --git a/app/code/core/Mage/Payment/locale/es_ES/Mage_Payment.csv b/app/code/Mage/Payment/locale/es_ES/Mage_Payment.csv similarity index 100% rename from app/code/core/Mage/Payment/locale/es_ES/Mage_Payment.csv rename to app/code/Mage/Payment/locale/es_ES/Mage_Payment.csv diff --git a/app/code/core/Mage/Payment/locale/fr_FR/Mage_Payment.csv b/app/code/Mage/Payment/locale/fr_FR/Mage_Payment.csv similarity index 100% rename from app/code/core/Mage/Payment/locale/fr_FR/Mage_Payment.csv rename to app/code/Mage/Payment/locale/fr_FR/Mage_Payment.csv diff --git a/app/code/core/Mage/Payment/locale/nl_NL/Mage_Payment.csv b/app/code/Mage/Payment/locale/nl_NL/Mage_Payment.csv similarity index 100% rename from app/code/core/Mage/Payment/locale/nl_NL/Mage_Payment.csv rename to app/code/Mage/Payment/locale/nl_NL/Mage_Payment.csv diff --git a/app/code/core/Mage/Payment/locale/pt_BR/Mage_Payment.csv b/app/code/Mage/Payment/locale/pt_BR/Mage_Payment.csv similarity index 100% rename from app/code/core/Mage/Payment/locale/pt_BR/Mage_Payment.csv rename to app/code/Mage/Payment/locale/pt_BR/Mage_Payment.csv diff --git a/app/code/core/Mage/Payment/locale/zh_CN/Mage_Payment.csv b/app/code/Mage/Payment/locale/zh_CN/Mage_Payment.csv similarity index 100% rename from app/code/core/Mage/Payment/locale/zh_CN/Mage_Payment.csv rename to app/code/Mage/Payment/locale/zh_CN/Mage_Payment.csv diff --git a/app/code/core/Mage/Payment/view/adminhtml/form/banktransfer.phtml b/app/code/Mage/Payment/view/adminhtml/form/banktransfer.phtml similarity index 100% rename from app/code/core/Mage/Payment/view/adminhtml/form/banktransfer.phtml rename to app/code/Mage/Payment/view/adminhtml/form/banktransfer.phtml diff --git a/app/code/core/Mage/Payment/view/adminhtml/form/cashondelivery.phtml b/app/code/Mage/Payment/view/adminhtml/form/cashondelivery.phtml similarity index 100% rename from app/code/core/Mage/Payment/view/adminhtml/form/cashondelivery.phtml rename to app/code/Mage/Payment/view/adminhtml/form/cashondelivery.phtml diff --git a/app/code/core/Mage/Payment/view/adminhtml/form/cc.phtml b/app/code/Mage/Payment/view/adminhtml/form/cc.phtml similarity index 100% rename from app/code/core/Mage/Payment/view/adminhtml/form/cc.phtml rename to app/code/Mage/Payment/view/adminhtml/form/cc.phtml diff --git a/app/code/core/Mage/Payment/view/adminhtml/form/ccsave.phtml b/app/code/Mage/Payment/view/adminhtml/form/ccsave.phtml similarity index 100% rename from app/code/core/Mage/Payment/view/adminhtml/form/ccsave.phtml rename to app/code/Mage/Payment/view/adminhtml/form/ccsave.phtml diff --git a/app/code/core/Mage/Payment/view/adminhtml/form/checkmo.phtml b/app/code/Mage/Payment/view/adminhtml/form/checkmo.phtml similarity index 100% rename from app/code/core/Mage/Payment/view/adminhtml/form/checkmo.phtml rename to app/code/Mage/Payment/view/adminhtml/form/checkmo.phtml diff --git a/app/code/core/Mage/Payment/view/adminhtml/form/purchaseorder.phtml b/app/code/Mage/Payment/view/adminhtml/form/purchaseorder.phtml similarity index 100% rename from app/code/core/Mage/Payment/view/adminhtml/form/purchaseorder.phtml rename to app/code/Mage/Payment/view/adminhtml/form/purchaseorder.phtml diff --git a/app/code/core/Mage/Payment/view/adminhtml/info/checkmo.phtml b/app/code/Mage/Payment/view/adminhtml/info/checkmo.phtml similarity index 100% rename from app/code/core/Mage/Payment/view/adminhtml/info/checkmo.phtml rename to app/code/Mage/Payment/view/adminhtml/info/checkmo.phtml diff --git a/app/code/Mage/Payment/view/adminhtml/info/default.phtml b/app/code/Mage/Payment/view/adminhtml/info/default.phtml new file mode 100644 index 0000000000000..3f3ec4678588f --- /dev/null +++ b/app/code/Mage/Payment/view/adminhtml/info/default.phtml @@ -0,0 +1,45 @@ + + +escapeHtml($this->getMethod()->getTitle()) ?> + +getSpecificInformation()):?> + + $_value):?> + + + + + +
    escapeHtml($_label)?>:getValueAsArray($_value, true), "\n"))?>
    + + +getChildHtml()?> diff --git a/app/code/core/Mage/Payment/view/adminhtml/info/instructions.phtml b/app/code/Mage/Payment/view/adminhtml/info/instructions.phtml similarity index 100% rename from app/code/core/Mage/Payment/view/adminhtml/info/instructions.phtml rename to app/code/Mage/Payment/view/adminhtml/info/instructions.phtml diff --git a/app/code/core/Mage/Payment/view/adminhtml/info/pdf/checkmo.phtml b/app/code/Mage/Payment/view/adminhtml/info/pdf/checkmo.phtml similarity index 100% rename from app/code/core/Mage/Payment/view/adminhtml/info/pdf/checkmo.phtml rename to app/code/Mage/Payment/view/adminhtml/info/pdf/checkmo.phtml diff --git a/app/code/core/Mage/Payment/view/adminhtml/info/pdf/default.phtml b/app/code/Mage/Payment/view/adminhtml/info/pdf/default.phtml similarity index 100% rename from app/code/core/Mage/Payment/view/adminhtml/info/pdf/default.phtml rename to app/code/Mage/Payment/view/adminhtml/info/pdf/default.phtml diff --git a/app/code/core/Mage/Payment/view/adminhtml/info/pdf/purchaseorder.phtml b/app/code/Mage/Payment/view/adminhtml/info/pdf/purchaseorder.phtml similarity index 100% rename from app/code/core/Mage/Payment/view/adminhtml/info/pdf/purchaseorder.phtml rename to app/code/Mage/Payment/view/adminhtml/info/pdf/purchaseorder.phtml diff --git a/app/code/core/Mage/Payment/view/adminhtml/info/purchaseorder.phtml b/app/code/Mage/Payment/view/adminhtml/info/purchaseorder.phtml similarity index 100% rename from app/code/core/Mage/Payment/view/adminhtml/info/purchaseorder.phtml rename to app/code/Mage/Payment/view/adminhtml/info/purchaseorder.phtml diff --git a/app/code/core/Mage/Payment/view/frontend/catalog/product/view/profile/options.phtml b/app/code/Mage/Payment/view/frontend/catalog/product/view/profile/options.phtml similarity index 100% rename from app/code/core/Mage/Payment/view/frontend/catalog/product/view/profile/options.phtml rename to app/code/Mage/Payment/view/frontend/catalog/product/view/profile/options.phtml diff --git a/app/code/core/Mage/Payment/view/frontend/catalog/product/view/profile/schedule.phtml b/app/code/Mage/Payment/view/frontend/catalog/product/view/profile/schedule.phtml similarity index 100% rename from app/code/core/Mage/Payment/view/frontend/catalog/product/view/profile/schedule.phtml rename to app/code/Mage/Payment/view/frontend/catalog/product/view/profile/schedule.phtml diff --git a/app/code/Mage/Payment/view/frontend/cc-type.js b/app/code/Mage/Payment/view/frontend/cc-type.js new file mode 100644 index 0000000000000..4fc0b878e43f5 --- /dev/null +++ b/app/code/Mage/Payment/view/frontend/cc-type.js @@ -0,0 +1,52 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category credit card type + * @package mage + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +/*jshint jquery:true*/ +(function($) { + "use strict"; + $.widget('mage.creditCardType', { + options: { + typeCodes: ['SS', 'SM', 'SO'] // Type codes for Switch/Maestro/Solo credit cards. + }, + + /** + * Bind change handler to select element and trigger the event to show/hide + * the Switch/Maestro or Solo credit card type container for those credit card types. + * @private + */ + _create: function() { + this.element.on('change', $.proxy(this._toggleCardType, this)).trigger('change'); + }, + + /** + * Toggle the Switch/Maestro and Solo credit card type container depending on which + * credit card type is selected. + * @private + */ + _toggleCardType: function() { + $(this.options.creditCardTypeContainer) + .toggle($.inArray(this.element.val(), this.options.typeCodes) !== -1); + } + }); +})(jQuery); diff --git a/app/code/core/Mage/Payment/view/frontend/form/banktransfer.phtml b/app/code/Mage/Payment/view/frontend/form/banktransfer.phtml similarity index 100% rename from app/code/core/Mage/Payment/view/frontend/form/banktransfer.phtml rename to app/code/Mage/Payment/view/frontend/form/banktransfer.phtml diff --git a/app/code/core/Mage/Payment/view/frontend/form/cashondelivery.phtml b/app/code/Mage/Payment/view/frontend/form/cashondelivery.phtml similarity index 100% rename from app/code/core/Mage/Payment/view/frontend/form/cashondelivery.phtml rename to app/code/Mage/Payment/view/frontend/form/cashondelivery.phtml diff --git a/app/code/core/Mage/Payment/view/frontend/form/cc.phtml b/app/code/Mage/Payment/view/frontend/form/cc.phtml similarity index 77% rename from app/code/core/Mage/Payment/view/frontend/form/cc.phtml rename to app/code/Mage/Payment/view/frontend/form/cc.phtml index 27ced2a8d783d..05a0eb76f6e7d 100644 --- a/app/code/core/Mage/Payment/view/frontend/form/cc.phtml +++ b/app/code/Mage/Payment/view/frontend/form/cc.phtml @@ -37,7 +37,7 @@
  • - getInfoData('cc_type') ?> getCcAvailableTypes() as $_typeCode => $_typeName): ?> @@ -49,14 +49,14 @@
  • - +
  • - getInfoData('cc_exp_month') ?> getCcMonths() as $k=>$v): ?> @@ -65,7 +65,7 @@
    getInfoData('cc_exp_year') ?> - getCcYears() as $k=>$v): ?> @@ -79,9 +79,13 @@
  • @@ -119,19 +123,11 @@
  •  
  • diff --git a/app/code/core/Mage/Payment/view/frontend/form/ccsave.phtml b/app/code/Mage/Payment/view/frontend/form/ccsave.phtml similarity index 77% rename from app/code/core/Mage/Payment/view/frontend/form/ccsave.phtml rename to app/code/Mage/Payment/view/frontend/form/ccsave.phtml index 98581c9d9a2d9..b843d79e8d7cd 100644 --- a/app/code/core/Mage/Payment/view/frontend/form/ccsave.phtml +++ b/app/code/Mage/Payment/view/frontend/form/ccsave.phtml @@ -29,13 +29,13 @@
  • - +
  • - getInfoData('cc_type') ?> getCcAvailableTypes() as $_typeCode => $_typeName): ?> @@ -47,7 +47,7 @@
  • - +
  • @@ -77,9 +77,13 @@
  • @@ -116,19 +120,11 @@
  •  
  • diff --git a/app/code/core/Mage/Payment/view/frontend/form/checkmo.phtml b/app/code/Mage/Payment/view/frontend/form/checkmo.phtml similarity index 100% rename from app/code/core/Mage/Payment/view/frontend/form/checkmo.phtml rename to app/code/Mage/Payment/view/frontend/form/checkmo.phtml diff --git a/app/code/core/Mage/Payment/view/frontend/form/purchaseorder.phtml b/app/code/Mage/Payment/view/frontend/form/purchaseorder.phtml similarity index 100% rename from app/code/core/Mage/Payment/view/frontend/form/purchaseorder.phtml rename to app/code/Mage/Payment/view/frontend/form/purchaseorder.phtml diff --git a/app/code/core/Mage/Payment/view/frontend/info/checkmo.phtml b/app/code/Mage/Payment/view/frontend/info/checkmo.phtml similarity index 100% rename from app/code/core/Mage/Payment/view/frontend/info/checkmo.phtml rename to app/code/Mage/Payment/view/frontend/info/checkmo.phtml diff --git a/app/code/core/Mage/Payment/view/frontend/info/default.phtml b/app/code/Mage/Payment/view/frontend/info/default.phtml similarity index 100% rename from app/code/core/Mage/Payment/view/frontend/info/default.phtml rename to app/code/Mage/Payment/view/frontend/info/default.phtml diff --git a/app/code/core/Mage/Payment/view/frontend/info/instructions.phtml b/app/code/Mage/Payment/view/frontend/info/instructions.phtml similarity index 100% rename from app/code/core/Mage/Payment/view/frontend/info/instructions.phtml rename to app/code/Mage/Payment/view/frontend/info/instructions.phtml diff --git a/app/code/core/Mage/Payment/view/frontend/info/purchaseorder.phtml b/app/code/Mage/Payment/view/frontend/info/purchaseorder.phtml similarity index 100% rename from app/code/core/Mage/Payment/view/frontend/info/purchaseorder.phtml rename to app/code/Mage/Payment/view/frontend/info/purchaseorder.phtml diff --git a/app/code/core/Mage/Payment/view/frontend/layout.xml b/app/code/Mage/Payment/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/Payment/view/frontend/layout.xml rename to app/code/Mage/Payment/view/frontend/layout.xml diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Details.php b/app/code/Mage/Paypal/Block/Adminhtml/Settlement/Details.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Details.php rename to app/code/Mage/Paypal/Block/Adminhtml/Settlement/Details.php diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Details/Form.php b/app/code/Mage/Paypal/Block/Adminhtml/Settlement/Details/Form.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Details/Form.php rename to app/code/Mage/Paypal/Block/Adminhtml/Settlement/Details/Form.php diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Report.php b/app/code/Mage/Paypal/Block/Adminhtml/Settlement/Report.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Report.php rename to app/code/Mage/Paypal/Block/Adminhtml/Settlement/Report.php diff --git a/app/code/Mage/Paypal/Block/Adminhtml/Settlement/Report/Grid.php b/app/code/Mage/Paypal/Block/Adminhtml/Settlement/Report/Grid.php new file mode 100644 index 0000000000000..8de2966699e00 --- /dev/null +++ b/app/code/Mage/Paypal/Block/Adminhtml/Settlement/Report/Grid.php @@ -0,0 +1,164 @@ + + */ +class Mage_Paypal_Block_Adminhtml_Settlement_Report_Grid extends Mage_Adminhtml_Block_Widget_Grid +{ + /** + * Retain filter parameters in session + * + * @var bool + */ + protected $_saveParametersInSession = true; + + /** + * Constructor + * Set main configuration of grid + */ + protected function _construct() + { + parent::_construct(); + $this->setId('settlementGrid'); + $this->setUseAjax(true); + } + + /** + * Prepare collection for grid + * @return Mage_Paypal_Block_Adminhtml_Settlement_Grid + */ + protected function _prepareCollection() + { + $collection = Mage::getResourceModel('Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection'); + $this->setCollection($collection); + if (!$this->getParam($this->getVarNameSort())) { + $collection->setOrder('row_id', 'desc'); + } + return parent::_prepareCollection(); + } + + /** + * Prepare grid columns + * @return Mage_Paypal_Block_Adminhtml_Settlement_Grid + */ + protected function _prepareColumns() + { + $settlement = Mage::getSingleton('Mage_Paypal_Model_Report_Settlement'); + $this->addColumn('report_date', array( + 'header' => $settlement->getFieldLabel('report_date'), + 'index' => 'report_date', + 'type' => 'date', + 'header_css_class' => 'col-date', + 'column_css_class' => 'col-date' + )); + $this->addColumn('account_id', array( + 'header' => $settlement->getFieldLabel('account_id'), + 'index' => 'account_id', + 'header_css_class' => 'col-merchant', + 'column_css_class' => 'col-merchant' + )); + $this->addColumn('transaction_id', array( + 'header' => $settlement->getFieldLabel('transaction_id'), + 'index' => 'transaction_id', + 'header_css_class' => 'col-transaction', + 'column_css_class' => 'col-transaction' + )); + $this->addColumn('invoice_id', array( + 'header' => $settlement->getFieldLabel('invoice_id'), + 'index' => 'invoice_id', + 'header_css_class' => 'col-invoice', + 'column_css_class' => 'col-invoice' + )); + $this->addColumn('paypal_reference_id', array( + 'header' => $settlement->getFieldLabel('paypal_reference_id'), + 'index' => 'paypal_reference_id', + 'header_css_class' => 'col-reference', + 'column_css_class' => 'col-reference' + )); + $this->addColumn('transaction_event_code', array( + 'header' => $settlement->getFieldLabel('transaction_event'), + 'index' => 'transaction_event_code', + 'type' => 'options', + 'options' => Mage::getModel('Mage_Paypal_Model_Report_Settlement_Row')->getTransactionEvents(), + 'header_css_class' => 'col-event', + 'column_css_class' => 'col-event' + )); + $this->addColumn('transaction_initiation_date', array( + 'header' => $settlement->getFieldLabel('transaction_initiation_date'), + 'index' => 'transaction_initiation_date', + 'type' => 'datetime', + 'header_css_class' => 'col-initiation', + 'column_css_class' => 'col-initiation' + )); + $this->addColumn('transaction_completion_date', array( + 'header' => $settlement->getFieldLabel('transaction_completion_date'), + 'index' => 'transaction_completion_date', + 'type' => 'datetime', + 'header_css_class' => 'col-completion', + 'column_css_class' => 'col-completion' + )); + $this->addColumn('gross_transaction_amount', array( + 'header' => $settlement->getFieldLabel('gross_transaction_amount'), + 'index' => 'gross_transaction_amount', + 'type' => 'currency', + 'currency' => 'gross_transaction_currency', + 'header_css_class' => 'col-amount', + 'column_css_class' => 'col-amount' + )); + $this->addColumn('fee_amount', array( + 'header' => $settlement->getFieldLabel('fee_amount'), + 'index' => 'fee_amount', + 'type' => 'currency', + 'currency' => 'gross_transaction_currency', + 'header_css_class' => 'col-fee-amount', + 'column_css_class' => 'col-fee-amount' + )); + return parent::_prepareColumns(); + } + + /** + * Return grid URL + * @return string + */ + public function getGridUrl() + { + return $this->getUrl('*/*/grid'); + } + + /** + * Return item view URL + * @return string + */ + public function getRowUrl($item) + { + return $this->getUrl('*/*/details', array('id' => $item->getId())); + } +} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/ApiWizard.php b/app/code/Mage/Paypal/Block/Adminhtml/System/Config/ApiWizard.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/ApiWizard.php rename to app/code/Mage/Paypal/Block/Adminhtml/System/Config/ApiWizard.php diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Global.php b/app/code/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Global.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Global.php rename to app/code/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Global.php diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Hint.php b/app/code/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Hint.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Hint.php rename to app/code/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Hint.php diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Store.php b/app/code/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Store.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Store.php rename to app/code/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Store.php diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Payflowlink/Advanced.php b/app/code/Mage/Paypal/Block/Adminhtml/System/Config/Payflowlink/Advanced.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Payflowlink/Advanced.php rename to app/code/Mage/Paypal/Block/Adminhtml/System/Config/Payflowlink/Advanced.php diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Payflowlink/Info.php b/app/code/Mage/Paypal/Block/Adminhtml/System/Config/Payflowlink/Info.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Payflowlink/Info.php rename to app/code/Mage/Paypal/Block/Adminhtml/System/Config/Payflowlink/Info.php diff --git a/app/code/core/Mage/Paypal/Block/Express/Form.php b/app/code/Mage/Paypal/Block/Express/Form.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Express/Form.php rename to app/code/Mage/Paypal/Block/Express/Form.php diff --git a/app/code/core/Mage/Paypal/Block/Express/Review.php b/app/code/Mage/Paypal/Block/Express/Review.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Express/Review.php rename to app/code/Mage/Paypal/Block/Express/Review.php diff --git a/app/code/core/Mage/Paypal/Block/Express/Review/Billing.php b/app/code/Mage/Paypal/Block/Express/Review/Billing.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Express/Review/Billing.php rename to app/code/Mage/Paypal/Block/Express/Review/Billing.php diff --git a/app/code/core/Mage/Paypal/Block/Express/Review/Details.php b/app/code/Mage/Paypal/Block/Express/Review/Details.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Express/Review/Details.php rename to app/code/Mage/Paypal/Block/Express/Review/Details.php diff --git a/app/code/core/Mage/Paypal/Block/Express/Review/Shipping.php b/app/code/Mage/Paypal/Block/Express/Review/Shipping.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Express/Review/Shipping.php rename to app/code/Mage/Paypal/Block/Express/Review/Shipping.php diff --git a/app/code/core/Mage/Paypal/Block/Express/Shortcut.php b/app/code/Mage/Paypal/Block/Express/Shortcut.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Express/Shortcut.php rename to app/code/Mage/Paypal/Block/Express/Shortcut.php diff --git a/app/code/core/Mage/Paypal/Block/Hosted/Pro/Form.php b/app/code/Mage/Paypal/Block/Hosted/Pro/Form.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Hosted/Pro/Form.php rename to app/code/Mage/Paypal/Block/Hosted/Pro/Form.php diff --git a/app/code/core/Mage/Paypal/Block/Hosted/Pro/Iframe.php b/app/code/Mage/Paypal/Block/Hosted/Pro/Iframe.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Hosted/Pro/Iframe.php rename to app/code/Mage/Paypal/Block/Hosted/Pro/Iframe.php diff --git a/app/code/core/Mage/Paypal/Block/Hosted/Pro/Info.php b/app/code/Mage/Paypal/Block/Hosted/Pro/Info.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Hosted/Pro/Info.php rename to app/code/Mage/Paypal/Block/Hosted/Pro/Info.php diff --git a/app/code/core/Mage/Paypal/Block/Iframe.php b/app/code/Mage/Paypal/Block/Iframe.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Iframe.php rename to app/code/Mage/Paypal/Block/Iframe.php diff --git a/app/code/core/Mage/Paypal/Block/Logo.php b/app/code/Mage/Paypal/Block/Logo.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Logo.php rename to app/code/Mage/Paypal/Block/Logo.php diff --git a/app/code/core/Mage/Paypal/Block/Payflow/Advanced/Form.php b/app/code/Mage/Paypal/Block/Payflow/Advanced/Form.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Payflow/Advanced/Form.php rename to app/code/Mage/Paypal/Block/Payflow/Advanced/Form.php diff --git a/app/code/core/Mage/Paypal/Block/Payflow/Advanced/Iframe.php b/app/code/Mage/Paypal/Block/Payflow/Advanced/Iframe.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Payflow/Advanced/Iframe.php rename to app/code/Mage/Paypal/Block/Payflow/Advanced/Iframe.php diff --git a/app/code/core/Mage/Paypal/Block/Payflow/Advanced/Info.php b/app/code/Mage/Paypal/Block/Payflow/Advanced/Info.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Payflow/Advanced/Info.php rename to app/code/Mage/Paypal/Block/Payflow/Advanced/Info.php diff --git a/app/code/core/Mage/Paypal/Block/Payflow/Advanced/Review.php b/app/code/Mage/Paypal/Block/Payflow/Advanced/Review.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Payflow/Advanced/Review.php rename to app/code/Mage/Paypal/Block/Payflow/Advanced/Review.php diff --git a/app/code/core/Mage/Paypal/Block/Payflow/Link/Form.php b/app/code/Mage/Paypal/Block/Payflow/Link/Form.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Payflow/Link/Form.php rename to app/code/Mage/Paypal/Block/Payflow/Link/Form.php diff --git a/app/code/core/Mage/Paypal/Block/Payflow/Link/Iframe.php b/app/code/Mage/Paypal/Block/Payflow/Link/Iframe.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Payflow/Link/Iframe.php rename to app/code/Mage/Paypal/Block/Payflow/Link/Iframe.php diff --git a/app/code/core/Mage/Paypal/Block/Payflow/Link/Info.php b/app/code/Mage/Paypal/Block/Payflow/Link/Info.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Payflow/Link/Info.php rename to app/code/Mage/Paypal/Block/Payflow/Link/Info.php diff --git a/app/code/core/Mage/Paypal/Block/Payflow/Link/Review.php b/app/code/Mage/Paypal/Block/Payflow/Link/Review.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Payflow/Link/Review.php rename to app/code/Mage/Paypal/Block/Payflow/Link/Review.php diff --git a/app/code/core/Mage/Paypal/Block/Payment/Info.php b/app/code/Mage/Paypal/Block/Payment/Info.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Payment/Info.php rename to app/code/Mage/Paypal/Block/Payment/Info.php diff --git a/app/code/core/Mage/Paypal/Block/Standard/Form.php b/app/code/Mage/Paypal/Block/Standard/Form.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Standard/Form.php rename to app/code/Mage/Paypal/Block/Standard/Form.php diff --git a/app/code/core/Mage/Paypal/Block/Standard/Redirect.php b/app/code/Mage/Paypal/Block/Standard/Redirect.php similarity index 100% rename from app/code/core/Mage/Paypal/Block/Standard/Redirect.php rename to app/code/Mage/Paypal/Block/Standard/Redirect.php diff --git a/app/code/Mage/Paypal/Controller/Express/Abstract.php b/app/code/Mage/Paypal/Controller/Express/Abstract.php new file mode 100644 index 0000000000000..b896db47f917d --- /dev/null +++ b/app/code/Mage/Paypal/Controller/Express/Abstract.php @@ -0,0 +1,502 @@ + array($this->_configMethod)); + $this->_config = Mage::getModel($this->_configType, $parameters); + } + + /** + * Start Express Checkout by requesting initial token and dispatching customer to PayPal + */ + public function startAction() + { + try { + $this->_initCheckout(); + + if ($this->_getQuote()->getIsMultiShipping()) { + $this->_getQuote()->setIsMultiShipping(false); + $this->_getQuote()->removeAllAddresses(); + } + + $customer = Mage::getSingleton('Mage_Customer_Model_Session')->getCustomer(); + if ($customer && $customer->getId()) { + $this->_checkout->setCustomerWithAddressChange( + $customer, $this->_getQuote()->getBillingAddress(), $this->_getQuote()->getShippingAddress() + ); + } + + // billing agreement + $isBARequested = (bool)$this->getRequest() + ->getParam(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT); + if ($customer && $customer->getId()) { + $this->_checkout->setIsBillingAgreementRequested($isBARequested); + } + + // giropay + $this->_checkout->prepareGiropayUrls( + Mage::getUrl('checkout/onepage/success'), + Mage::getUrl('paypal/express/cancel'), + Mage::getUrl('checkout/onepage/success') + ); + + $token = $this->_checkout->start(Mage::getUrl('*/*/return'), Mage::getUrl('*/*/cancel')); + if ($token && $url = $this->_checkout->getRedirectUrl()) { + $this->_initToken($token); + $this->getResponse()->setRedirect($url); + return; + } + } catch (Mage_Core_Exception $e) { + $this->_getCheckoutSession()->addError($e->getMessage()); + } catch (Exception $e) { + $this->_getCheckoutSession()->addError($this->__('Unable to start Express Checkout.')); + Mage::logException($e); + } + + $this->_redirect('checkout/cart'); + } + + /** + * Return shipping options items for shipping address from request + */ + public function shippingOptionsCallbackAction() + { + try { + $quoteId = $this->getRequest()->getParam('quote_id'); + $this->_quote = Mage::getModel('Mage_Sales_Model_Quote')->load($quoteId); + $this->_initCheckout(); + $response = $this->_checkout->getShippingOptionsCallbackResponse($this->getRequest()->getParams()); + $this->getResponse()->setBody($response); + } catch (Exception $e) { + Mage::logException($e); + } + } + + /** + * Cancel Express Checkout + */ + public function cancelAction() + { + try { + $this->_initToken(false); + // TODO verify if this logic of order cancellation is deprecated + // if there is an order - cancel it + $orderId = $this->_getCheckoutSession()->getLastOrderId(); + $order = ($orderId) ? Mage::getModel('Mage_Sales_Model_Order')->load($orderId) : false; + if ($order && $order->getId() && $order->getQuoteId() == $this->_getCheckoutSession()->getQuoteId()) { + $order->cancel()->save(); + $this->_getCheckoutSession() + ->unsLastQuoteId() + ->unsLastSuccessQuoteId() + ->unsLastOrderId() + ->unsLastRealOrderId() + ->addSuccess($this->__('Express Checkout and Order have been canceled.')) + ; + } else { + $this->_getCheckoutSession()->addSuccess($this->__('Express Checkout has been canceled.')); + } + } catch (Mage_Core_Exception $e) { + $this->_getCheckoutSession()->addError($e->getMessage()); + } catch (Exception $e) { + $this->_getCheckoutSession()->addError($this->__('Unable to cancel Express Checkout.')); + Mage::logException($e); + } + + $this->_redirect('checkout/cart'); + } + + /** + * Return from PayPal and dispatch customer to order review page + */ + public function returnAction() + { + try { + $this->_initCheckout(); + $this->_checkout->returnFromPaypal($this->_initToken()); + $this->_redirect('*/*/review'); + return; + } + catch (Mage_Core_Exception $e) { + Mage::getSingleton('Mage_Checkout_Model_Session')->addError($e->getMessage()); + } + catch (Exception $e) { + Mage::getSingleton('Mage_Checkout_Model_Session')->addError($this->__('Unable to process Express Checkout approval.')); + Mage::logException($e); + } + $this->_redirect('checkout/cart'); + } + + /** + * Review order after returning from PayPal + */ + public function reviewAction() + { + try { + $this->_initCheckout(); + $this->_checkout->prepareOrderReview($this->_initToken()); + $this->loadLayout(); + $this->_initLayoutMessages('Mage_Paypal_Model_Session'); + $reviewBlock = $this->getLayout()->getBlock('paypal.express.review'); + $reviewBlock->setQuote($this->_getQuote()); + $reviewBlock->getChildBlock('details')->setQuote($this->_getQuote()); + if ($reviewBlock->getChildBlock('shipping_method')) { + $reviewBlock->getChildBlock('shipping_method')->setQuote($this->_getQuote()); + } + $this->renderLayout(); + return; + } + catch (Mage_Core_Exception $e) { + Mage::getSingleton('Mage_Checkout_Model_Session')->addError($e->getMessage()); + } + catch (Exception $e) { + Mage::getSingleton('Mage_Checkout_Model_Session')->addError( + $this->__('Unable to initialize Express Checkout review.') + ); + Mage::logException($e); + } + $this->_redirect('checkout/cart'); + } + + /** + * Dispatch customer back to PayPal for editing payment information + */ + public function editAction() + { + try { + $this->getResponse()->setRedirect($this->_config->getExpressCheckoutEditUrl($this->_initToken())); + } + catch (Mage_Core_Exception $e) { + $this->_getSession()->addError($e->getMessage()); + $this->_redirect('*/*/review'); + } + } + + /** + * Update shipping method (combined action for ajax and regular request) + */ + public function saveShippingMethodAction() + { + try { + $isAjax = $this->getRequest()->getParam('isAjax'); + $this->_initCheckout(); + $this->_checkout->updateShippingMethod($this->getRequest()->getParam('shipping_method')); + if ($isAjax) { + $this->loadLayout('paypal_express_review_details'); + $this->getResponse()->setBody($this->getLayout()->getBlock('root') + ->setQuote($this->_getQuote()) + ->toHtml()); + return; + } + } catch (Mage_Core_Exception $e) { + $this->_getSession()->addError($e->getMessage()); + } catch (Exception $e) { + $this->_getSession()->addError($this->__('Unable to update shipping method.')); + Mage::logException($e); + } + if ($isAjax) { + $this->getResponse()->setBody(''); + } else { + $this->_redirect('*/*/review'); + } + } + + /** + * Update Order (combined action for ajax and regular request) + */ + public function updateShippingMethodsAction() + { + try { + $this->_initCheckout(); + $this->_checkout->prepareOrderReview($this->_initToken()); + $this->loadLayout('paypal_express_review'); + + $this->getResponse()->setBody($this->getLayout()->getBlock('express.review.shipping.method') + ->setQuote($this->_getQuote()) + ->toHtml()); + return; + } catch (Mage_Core_Exception $e) { + $this->_getSession()->addError($e->getMessage()); + } catch (Exception $e) { + $this->_getSession()->addError($this->__('Unable to update Order data.')); + Mage::logException($e); + } + $this->getResponse()->setBody(''); + } + + /** + * Update Order (combined action for ajax and regular request) + */ + public function updateOrderAction() + { + try { + $isAjax = $this->getRequest()->getParam('isAjax'); + $this->_initCheckout(); + $this->_checkout->updateOrder($this->getRequest()->getParams()); + if ($isAjax) { + $this->loadLayout('paypal_express_review_details'); + $this->getResponse()->setBody($this->getLayout()->getBlock('root') + ->setQuote($this->_getQuote()) + ->toHtml()); + return; + } + } catch (Mage_Core_Exception $e) { + $this->_getSession()->addError($e->getMessage()); + } catch (Exception $e) { + $this->_getSession()->addError($this->__('Unable to update Order data.')); + Mage::logException($e); + } + if ($isAjax) { + $this->getResponse()->setBody(''); + } else { + $this->_redirect('*/*/review'); + } + } + + /** + * Submit the order + */ + public function placeOrderAction() + { + try { + $requiredAgreements = Mage::helper('Mage_Checkout_Helper_Data')->getRequiredAgreementIds(); + if ($requiredAgreements) { + $postedAgreements = array_keys($this->getRequest()->getPost('agreement', array())); + if (array_diff($requiredAgreements, $postedAgreements)) { + Mage::throwException(Mage::helper('Mage_Paypal_Helper_Data')->__('Please agree to all the terms and conditions before placing the order.')); + } + } + + $this->_initCheckout(); + $this->_checkout->place($this->_initToken()); + + // prepare session to success or cancellation page + $session = $this->_getCheckoutSession(); + $session->clearHelperData(); + + // "last successful quote" + $quoteId = $this->_getQuote()->getId(); + $session->setLastQuoteId($quoteId)->setLastSuccessQuoteId($quoteId); + + // an order may be created + $order = $this->_checkout->getOrder(); + if ($order) { + $session->setLastOrderId($order->getId()) + ->setLastRealOrderId($order->getIncrementId()); + // as well a billing agreement can be created + $agreement = $this->_checkout->getBillingAgreement(); + if ($agreement) { + $session->setLastBillingAgreementId($agreement->getId()); + } + } + + // recurring profiles may be created along with the order or without it + $profiles = $this->_checkout->getRecurringPaymentProfiles(); + if ($profiles) { + $ids = array(); + foreach($profiles as $profile) { + $ids[] = $profile->getId(); + } + $session->setLastRecurringProfileIds($ids); + } + + // redirect if PayPal specified some URL (for example, to Giropay bank) + $url = $this->_checkout->getRedirectUrl(); + if ($url) { + $this->getResponse()->setRedirect($url); + return; + } + $this->_initToken(false); // no need in token anymore + $this->_redirect('checkout/onepage/success'); + return; + } + catch (Mage_Core_Exception $e) { + $this->_getSession()->addError($e->getMessage()); + } + catch (Exception $e) { + $this->_getSession()->addError($this->__('Unable to place the order.')); + Mage::logException($e); + } + $this->_redirect('*/*/review'); + } + + /** + * Instantiate quote and checkout + * @throws Mage_Core_Exception + */ + private function _initCheckout() + { + $quote = $this->_getQuote(); + if (!$quote->hasItems() || $quote->getHasError()) { + $this->getResponse()->setHeader('HTTP/1.1','403 Forbidden'); + Mage::throwException(Mage::helper('Mage_Paypal_Helper_Data')->__('Unable to initialize Express Checkout.')); + } + if (false === isset($this->_checkoutTypes[$this->_checkoutType])) { + $parameters = array( + 'params' => array( + 'quote' => $quote, + 'config' => $this->_config, + ), + ); + $this->_checkoutTypes[$this->_checkoutType] = Mage::getModel($this->_checkoutType, $parameters); + } + $this->_checkout = $this->_checkoutTypes[$this->_checkoutType]; + } + + /** + * Search for proper checkout token in request or session or (un)set specified one + * Combined getter/setter + * + * @param string $setToken + * @return Mage_Paypal_ExpressController|string + */ + protected function _initToken($setToken = null) + { + if (null !== $setToken) { + if (false === $setToken) { + // security measure for avoid unsetting token twice + if (!$this->_getSession()->getExpressCheckoutToken()) { + Mage::throwException($this->__('PayPal Express Checkout Token does not exist.')); + } + $this->_getSession()->unsExpressCheckoutToken(); + } else { + $this->_getSession()->setExpressCheckoutToken($setToken); + } + return $this; + } + if ($setToken = $this->getRequest()->getParam('token')) { + if ($setToken !== $this->_getSession()->getExpressCheckoutToken()) { + Mage::throwException($this->__('Wrong PayPal Express Checkout Token specified.')); + } + } else { + $setToken = $this->_getSession()->getExpressCheckoutToken(); + } + return $setToken; + } + + /** + * PayPal session instance getter + * + * @return Mage_PayPal_Model_Session + */ + private function _getSession() + { + return Mage::getSingleton('Mage_Paypal_Model_Session'); + } + + /** + * Return checkout session object + * + * @return Mage_Checkout_Model_Session + */ + private function _getCheckoutSession() + { + return Mage::getSingleton('Mage_Checkout_Model_Session'); + } + + /** + * Return checkout quote object + * + * @return Mage_Sales_Model_Quote + */ + private function _getQuote() + { + if (!$this->_quote) { + $this->_quote = $this->_getCheckoutSession()->getQuote(); + } + return $this->_quote; + } + + /** + * Redirect to login page + * + */ + public function redirectLogin() + { + $this->setFlag('', 'no-dispatch', true); + $this->getResponse()->setRedirect( + Mage::helper('Mage_Core_Helper_Url')->addRequestParam( + Mage::helper('Mage_Customer_Helper_Data')->getLoginUrl(), + array('context' => 'checkout') + ) + ); + } +} diff --git a/app/code/core/Mage/Paypal/Exception.php b/app/code/Mage/Paypal/Exception.php similarity index 100% rename from app/code/core/Mage/Paypal/Exception.php rename to app/code/Mage/Paypal/Exception.php diff --git a/app/code/core/Mage/Paypal/Helper/Data.php b/app/code/Mage/Paypal/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Paypal/Helper/Data.php rename to app/code/Mage/Paypal/Helper/Data.php diff --git a/app/code/core/Mage/Paypal/Helper/Hss.php b/app/code/Mage/Paypal/Helper/Hss.php similarity index 100% rename from app/code/core/Mage/Paypal/Helper/Hss.php rename to app/code/Mage/Paypal/Helper/Hss.php diff --git a/app/code/core/Mage/Paypal/Model/Api/Abstract.php b/app/code/Mage/Paypal/Model/Api/Abstract.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Api/Abstract.php rename to app/code/Mage/Paypal/Model/Api/Abstract.php diff --git a/app/code/core/Mage/Paypal/Model/Api/Nvp.php b/app/code/Mage/Paypal/Model/Api/Nvp.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Api/Nvp.php rename to app/code/Mage/Paypal/Model/Api/Nvp.php diff --git a/app/code/core/Mage/Paypal/Model/Api/Standard.php b/app/code/Mage/Paypal/Model/Api/Standard.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Api/Standard.php rename to app/code/Mage/Paypal/Model/Api/Standard.php diff --git a/app/code/core/Mage/Paypal/Model/Cart.php b/app/code/Mage/Paypal/Model/Cart.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Cart.php rename to app/code/Mage/Paypal/Model/Cart.php diff --git a/app/code/core/Mage/Paypal/Model/Cert.php b/app/code/Mage/Paypal/Model/Cert.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Cert.php rename to app/code/Mage/Paypal/Model/Cert.php diff --git a/app/code/core/Mage/Paypal/Model/Config.php b/app/code/Mage/Paypal/Model/Config.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Config.php rename to app/code/Mage/Paypal/Model/Config.php diff --git a/app/code/core/Mage/Paypal/Model/Direct.php b/app/code/Mage/Paypal/Model/Direct.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Direct.php rename to app/code/Mage/Paypal/Model/Direct.php diff --git a/app/code/core/Mage/Paypal/Model/Express.php b/app/code/Mage/Paypal/Model/Express.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Express.php rename to app/code/Mage/Paypal/Model/Express.php diff --git a/app/code/core/Mage/Paypal/Model/Express/Checkout.php b/app/code/Mage/Paypal/Model/Express/Checkout.php similarity index 98% rename from app/code/core/Mage/Paypal/Model/Express/Checkout.php rename to app/code/Mage/Paypal/Model/Express/Checkout.php index 58ec500fb19b2..b241e1f7a2a2b 100644 --- a/app/code/core/Mage/Paypal/Model/Express/Checkout.php +++ b/app/code/Mage/Paypal/Model/Express/Checkout.php @@ -130,21 +130,30 @@ class Mage_Paypal_Model_Express_Checkout /** * Order * - * @var Mage_Sales_Model_QuoteMage_Sales_Model_Quote + * @var Mage_Sales_Model_Quote */ protected $_order = null; + /** + * @var Mage_Core_Model_Cache_Type_Config + */ + protected $_configCacheType; + /** * Set config, session and quote instances * * @param Mage_Customer_Model_Session $customerSession + * @param Mage_Core_Model_Cache_Type_Config $configCacheType * @param array $params + * @throws Exception */ public function __construct( Mage_Customer_Model_Session $customerSession, + Mage_Core_Model_Cache_Type_Config $configCacheType, $params = array() ) { $this->_customerSession = $customerSession; + $this->_configCacheType = $configCacheType; if (isset($params['config']) && $params['config'] instanceof Mage_Paypal_Model_Config) { $this->_config = $params['config']; @@ -170,7 +179,7 @@ public function getCheckoutShortcutImageUrl() $pal = null; if ($this->_config->areButtonsDynamic()) { $cacheId = self::PAL_CACHE_ID . Mage::app()->getStore()->getId(); - $pal = Mage::app()->loadCache($cacheId); + $pal = $this->_configCacheType->load($cacheId); if (-1 == $pal) { $pal = null; } elseif (!$pal) { @@ -179,9 +188,9 @@ public function getCheckoutShortcutImageUrl() try { $this->_api->callGetPalDetails(); $pal = $this->_api->getPal(); - Mage::app()->saveCache($pal, $cacheId, array(Mage_Core_Model_Config::CACHE_TAG)); + $this->_configCacheType->save($pal, $cacheId); } catch (Exception $e) { - Mage::app()->saveCache(-1, $cacheId, array(Mage_Core_Model_Config::CACHE_TAG)); + $this->_configCacheType->save(-1, $cacheId); Mage::logException($e); } } diff --git a/app/code/core/Mage/Paypal/Model/Hostedpro.php b/app/code/Mage/Paypal/Model/Hostedpro.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Hostedpro.php rename to app/code/Mage/Paypal/Model/Hostedpro.php diff --git a/app/code/core/Mage/Paypal/Model/Hostedpro/Request.php b/app/code/Mage/Paypal/Model/Hostedpro/Request.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Hostedpro/Request.php rename to app/code/Mage/Paypal/Model/Hostedpro/Request.php diff --git a/app/code/core/Mage/Paypal/Model/Info.php b/app/code/Mage/Paypal/Model/Info.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Info.php rename to app/code/Mage/Paypal/Model/Info.php diff --git a/app/code/core/Mage/Paypal/Model/Ipn.php b/app/code/Mage/Paypal/Model/Ipn.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Ipn.php rename to app/code/Mage/Paypal/Model/Ipn.php diff --git a/app/code/core/Mage/Paypal/Model/Method/Agreement.php b/app/code/Mage/Paypal/Model/Method/Agreement.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Method/Agreement.php rename to app/code/Mage/Paypal/Model/Method/Agreement.php diff --git a/app/code/core/Mage/Paypal/Model/Observer.php b/app/code/Mage/Paypal/Model/Observer.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Observer.php rename to app/code/Mage/Paypal/Model/Observer.php diff --git a/app/code/core/Mage/Paypal/Model/Payflow/Request.php b/app/code/Mage/Paypal/Model/Payflow/Request.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Payflow/Request.php rename to app/code/Mage/Paypal/Model/Payflow/Request.php diff --git a/app/code/core/Mage/Paypal/Model/Payflowadvanced.php b/app/code/Mage/Paypal/Model/Payflowadvanced.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Payflowadvanced.php rename to app/code/Mage/Paypal/Model/Payflowadvanced.php diff --git a/app/code/core/Mage/Paypal/Model/Payflowlink.php b/app/code/Mage/Paypal/Model/Payflowlink.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Payflowlink.php rename to app/code/Mage/Paypal/Model/Payflowlink.php diff --git a/app/code/core/Mage/Paypal/Model/Payflowpro.php b/app/code/Mage/Paypal/Model/Payflowpro.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Payflowpro.php rename to app/code/Mage/Paypal/Model/Payflowpro.php diff --git a/app/code/core/Mage/Paypal/Model/Payment/Transaction.php b/app/code/Mage/Paypal/Model/Payment/Transaction.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Payment/Transaction.php rename to app/code/Mage/Paypal/Model/Payment/Transaction.php diff --git a/app/code/core/Mage/Paypal/Model/Pro.php b/app/code/Mage/Paypal/Model/Pro.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Pro.php rename to app/code/Mage/Paypal/Model/Pro.php diff --git a/app/code/core/Mage/Paypal/Model/Report/Settlement.php b/app/code/Mage/Paypal/Model/Report/Settlement.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Report/Settlement.php rename to app/code/Mage/Paypal/Model/Report/Settlement.php diff --git a/app/code/core/Mage/Paypal/Model/Report/Settlement/Row.php b/app/code/Mage/Paypal/Model/Report/Settlement/Row.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Report/Settlement/Row.php rename to app/code/Mage/Paypal/Model/Report/Settlement/Row.php diff --git a/app/code/core/Mage/Paypal/Model/Resource/Cert.php b/app/code/Mage/Paypal/Model/Resource/Cert.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Resource/Cert.php rename to app/code/Mage/Paypal/Model/Resource/Cert.php diff --git a/app/code/core/Mage/Paypal/Model/Resource/Payment/Transaction.php b/app/code/Mage/Paypal/Model/Resource/Payment/Transaction.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Resource/Payment/Transaction.php rename to app/code/Mage/Paypal/Model/Resource/Payment/Transaction.php diff --git a/app/code/core/Mage/Paypal/Model/Resource/Payment/Transaction/Collection.php b/app/code/Mage/Paypal/Model/Resource/Payment/Transaction/Collection.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Resource/Payment/Transaction/Collection.php rename to app/code/Mage/Paypal/Model/Resource/Payment/Transaction/Collection.php diff --git a/app/code/core/Mage/Paypal/Model/Resource/Report/Settlement.php b/app/code/Mage/Paypal/Model/Resource/Report/Settlement.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Paypal/Model/Resource/Report/Settlement.php rename to app/code/Mage/Paypal/Model/Resource/Report/Settlement.php diff --git a/app/code/core/Mage/Paypal/Model/Resource/Report/Settlement/Row.php b/app/code/Mage/Paypal/Model/Resource/Report/Settlement/Row.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Paypal/Model/Resource/Report/Settlement/Row.php rename to app/code/Mage/Paypal/Model/Resource/Report/Settlement/Row.php diff --git a/app/code/core/Mage/Paypal/Model/Resource/Report/Settlement/Row/Collection.php b/app/code/Mage/Paypal/Model/Resource/Report/Settlement/Row/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Paypal/Model/Resource/Report/Settlement/Row/Collection.php rename to app/code/Mage/Paypal/Model/Resource/Report/Settlement/Row/Collection.php diff --git a/app/code/core/Mage/Paypal/Model/Resource/Setup.php b/app/code/Mage/Paypal/Model/Resource/Setup.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Paypal/Model/Resource/Setup.php rename to app/code/Mage/Paypal/Model/Resource/Setup.php diff --git a/app/code/core/Mage/Paypal/Model/Session.php b/app/code/Mage/Paypal/Model/Session.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Session.php rename to app/code/Mage/Paypal/Model/Session.php diff --git a/app/code/core/Mage/Paypal/Model/Standard.php b/app/code/Mage/Paypal/Model/Standard.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/Standard.php rename to app/code/Mage/Paypal/Model/Standard.php diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Backend/Cert.php b/app/code/Mage/Paypal/Model/System/Config/Backend/Cert.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/System/Config/Backend/Cert.php rename to app/code/Mage/Paypal/Model/System/Config/Backend/Cert.php diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Backend/Cron.php b/app/code/Mage/Paypal/Model/System/Config/Backend/Cron.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/System/Config/Backend/Cron.php rename to app/code/Mage/Paypal/Model/System/Config/Backend/Cron.php diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Backend/MerchantCountry.php b/app/code/Mage/Paypal/Model/System/Config/Backend/MerchantCountry.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/System/Config/Backend/MerchantCountry.php rename to app/code/Mage/Paypal/Model/System/Config/Backend/MerchantCountry.php diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/AuthorizationAmounts.php b/app/code/Mage/Paypal/Model/System/Config/Source/AuthorizationAmounts.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/System/Config/Source/AuthorizationAmounts.php rename to app/code/Mage/Paypal/Model/System/Config/Source/AuthorizationAmounts.php diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/BuyerCountry.php b/app/code/Mage/Paypal/Model/System/Config/Source/BuyerCountry.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/System/Config/Source/BuyerCountry.php rename to app/code/Mage/Paypal/Model/System/Config/Source/BuyerCountry.php diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/FetchingSchedule.php b/app/code/Mage/Paypal/Model/System/Config/Source/FetchingSchedule.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/System/Config/Source/FetchingSchedule.php rename to app/code/Mage/Paypal/Model/System/Config/Source/FetchingSchedule.php diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/Logo.php b/app/code/Mage/Paypal/Model/System/Config/Source/Logo.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/System/Config/Source/Logo.php rename to app/code/Mage/Paypal/Model/System/Config/Source/Logo.php diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/MerchantCountry.php b/app/code/Mage/Paypal/Model/System/Config/Source/MerchantCountry.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/System/Config/Source/MerchantCountry.php rename to app/code/Mage/Paypal/Model/System/Config/Source/MerchantCountry.php diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/PaymentActions.php b/app/code/Mage/Paypal/Model/System/Config/Source/PaymentActions.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/System/Config/Source/PaymentActions.php rename to app/code/Mage/Paypal/Model/System/Config/Source/PaymentActions.php diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/PaymentActions/Express.php b/app/code/Mage/Paypal/Model/System/Config/Source/PaymentActions/Express.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/System/Config/Source/PaymentActions/Express.php rename to app/code/Mage/Paypal/Model/System/Config/Source/PaymentActions/Express.php diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/RequireBillingAddress.php b/app/code/Mage/Paypal/Model/System/Config/Source/RequireBillingAddress.php similarity index 100% rename from app/code/core/Mage/Paypal/Model/System/Config/Source/RequireBillingAddress.php rename to app/code/Mage/Paypal/Model/System/Config/Source/RequireBillingAddress.php diff --git a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/ReportsController.php b/app/code/Mage/Paypal/controllers/Adminhtml/Paypal/ReportsController.php similarity index 100% rename from app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/ReportsController.php rename to app/code/Mage/Paypal/controllers/Adminhtml/Paypal/ReportsController.php diff --git a/app/code/core/Mage/Paypal/controllers/ExpressController.php b/app/code/Mage/Paypal/controllers/ExpressController.php similarity index 100% rename from app/code/core/Mage/Paypal/controllers/ExpressController.php rename to app/code/Mage/Paypal/controllers/ExpressController.php diff --git a/app/code/core/Mage/Paypal/controllers/HostedproController.php b/app/code/Mage/Paypal/controllers/HostedproController.php similarity index 100% rename from app/code/core/Mage/Paypal/controllers/HostedproController.php rename to app/code/Mage/Paypal/controllers/HostedproController.php diff --git a/app/code/core/Mage/Paypal/controllers/IpnController.php b/app/code/Mage/Paypal/controllers/IpnController.php similarity index 100% rename from app/code/core/Mage/Paypal/controllers/IpnController.php rename to app/code/Mage/Paypal/controllers/IpnController.php diff --git a/app/code/core/Mage/Paypal/controllers/PayflowController.php b/app/code/Mage/Paypal/controllers/PayflowController.php similarity index 100% rename from app/code/core/Mage/Paypal/controllers/PayflowController.php rename to app/code/Mage/Paypal/controllers/PayflowController.php diff --git a/app/code/core/Mage/Paypal/controllers/PayflowadvancedController.php b/app/code/Mage/Paypal/controllers/PayflowadvancedController.php similarity index 100% rename from app/code/core/Mage/Paypal/controllers/PayflowadvancedController.php rename to app/code/Mage/Paypal/controllers/PayflowadvancedController.php diff --git a/app/code/core/Mage/Paypal/controllers/StandardController.php b/app/code/Mage/Paypal/controllers/StandardController.php similarity index 100% rename from app/code/core/Mage/Paypal/controllers/StandardController.php rename to app/code/Mage/Paypal/controllers/StandardController.php diff --git a/app/code/Mage/Paypal/etc/adminhtml/acl.xml b/app/code/Mage/Paypal/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..f19626cb75f86 --- /dev/null +++ b/app/code/Mage/Paypal/etc/adminhtml/acl.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Mage/Paypal/etc/adminhtml/menu.xml b/app/code/Mage/Paypal/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..47f30137b1e72 --- /dev/null +++ b/app/code/Mage/Paypal/etc/adminhtml/menu.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/app/code/core/Mage/Paypal/etc/adminhtml/system.xml b/app/code/Mage/Paypal/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Paypal/etc/adminhtml/system.xml rename to app/code/Mage/Paypal/etc/adminhtml/system.xml diff --git a/app/code/Mage/Paypal/etc/config.xml b/app/code/Mage/Paypal/etc/config.xml new file mode 100644 index 0000000000000..305ef34e0d209 --- /dev/null +++ b/app/code/Mage/Paypal/etc/config.xml @@ -0,0 +1,284 @@ + + + + + + 1.6.0.2 + true + + + + + + + + + + + + Mage_Paypal + Mage_Paypal_Model_Resource_Setup + + + + + + + + + + + + + + + + + SM + Switch/Maestro + 60 + + + SO + Solo + 61 + + + + + + + PayPal + + + + + + /paypal/express + /paypal/standard + + + + standard + + Mage_Paypal + paypal + + + + + + + + Mage_Paypal.csv + + + + + + + + layout.xml + + + + + paypal/express/callbackshippingoptions + + + + + + Mage_Paypal_Model_Observer + saveOrderAfterSubmit + + + + + + + Mage_Paypal_Model_Observer + setResponseAfterSaveOrder + + + + + + + + + + + Mage_Paypal.csv + + + + + + + + layout.xml + + + + + + + + + + + + dynamic + + + + + + + + + 1 + + + + + + Mage_Paypal_Model_Express + PayPal Express Checkout + Authorization + Mark + 1 + 1 + 1 + never + paypal + 3 + 29 + 1 + + + Mage_Paypal_Model_Direct + PayPal Direct Payment + Authorization + VI,MC + 1 + paypal + + + Mage_Paypal_Model_Standard + PayPal Website Payments Standard + Sale + 1 + paypal + + + PayPal Express Checkout Payflow Edition + Authorization + 1 + 1 + 1 + paypal + + + PayPal Direct Payment Payflow Edition + Authorization + VI,MC,AE + 1 + paypal + + + Mage_Paypal_Model_Payflowpro + Payflow Pro + Authorization + AE,VI + 1 + C + MEDIUM + + + paypal + + + 1 + 1 + Mage_Paypal_Model_Method_Agreement + PayPal Billing Agreement + paypal + + + Mage_Paypal_Model_Payflowlink + Authorization + HIGH + + paypal + Credit Card + + + Mage_Paypal_Model_Payflowadvanced + Authorization + HIGH + + paypal + Credit Card + PayPal + PayPal + PayPal + + + Mage_Paypal_Model_Hostedpro + Payment by cards or by PayPal account + Authorization + paypal + 0 + + + + + + + + Mage_Paypal_Model_Observer::fetchReports + + + + + + + + + + Mage_Paypal_Adminhtml + + + + + + diff --git a/app/code/core/Mage/Paypal/locale/de_DE/Mage_Paypal.csv b/app/code/Mage/Paypal/locale/de_DE/Mage_Paypal.csv similarity index 100% rename from app/code/core/Mage/Paypal/locale/de_DE/Mage_Paypal.csv rename to app/code/Mage/Paypal/locale/de_DE/Mage_Paypal.csv diff --git a/app/code/core/Mage/Paypal/locale/en_US/Mage_Paypal.csv b/app/code/Mage/Paypal/locale/en_US/Mage_Paypal.csv similarity index 100% rename from app/code/core/Mage/Paypal/locale/en_US/Mage_Paypal.csv rename to app/code/Mage/Paypal/locale/en_US/Mage_Paypal.csv diff --git a/app/code/core/Mage/Paypal/locale/es_ES/Mage_Paypal.csv b/app/code/Mage/Paypal/locale/es_ES/Mage_Paypal.csv similarity index 100% rename from app/code/core/Mage/Paypal/locale/es_ES/Mage_Paypal.csv rename to app/code/Mage/Paypal/locale/es_ES/Mage_Paypal.csv diff --git a/app/code/core/Mage/Paypal/locale/fr_FR/Mage_Paypal.csv b/app/code/Mage/Paypal/locale/fr_FR/Mage_Paypal.csv similarity index 100% rename from app/code/core/Mage/Paypal/locale/fr_FR/Mage_Paypal.csv rename to app/code/Mage/Paypal/locale/fr_FR/Mage_Paypal.csv diff --git a/app/code/core/Mage/Paypal/locale/nl_NL/Mage_Paypal.csv b/app/code/Mage/Paypal/locale/nl_NL/Mage_Paypal.csv similarity index 100% rename from app/code/core/Mage/Paypal/locale/nl_NL/Mage_Paypal.csv rename to app/code/Mage/Paypal/locale/nl_NL/Mage_Paypal.csv diff --git a/app/code/core/Mage/Paypal/locale/pt_BR/Mage_Paypal.csv b/app/code/Mage/Paypal/locale/pt_BR/Mage_Paypal.csv similarity index 100% rename from app/code/core/Mage/Paypal/locale/pt_BR/Mage_Paypal.csv rename to app/code/Mage/Paypal/locale/pt_BR/Mage_Paypal.csv diff --git a/app/code/core/Mage/Paypal/locale/zh_CN/Mage_Paypal.csv b/app/code/Mage/Paypal/locale/zh_CN/Mage_Paypal.csv similarity index 100% rename from app/code/core/Mage/Paypal/locale/zh_CN/Mage_Paypal.csv rename to app/code/Mage/Paypal/locale/zh_CN/Mage_Paypal.csv diff --git a/app/code/core/Mage/Paypal/sql/paypal_setup/install-1.6.0.0.php b/app/code/Mage/Paypal/sql/paypal_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Paypal/sql/paypal_setup/install-1.6.0.0.php rename to app/code/Mage/Paypal/sql/paypal_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Paypal/sql/paypal_setup/upgrade-1.6.0.0-1.6.0.1.php b/app/code/Mage/Paypal/sql/paypal_setup/upgrade-1.6.0.0-1.6.0.1.php similarity index 100% rename from app/code/core/Mage/Paypal/sql/paypal_setup/upgrade-1.6.0.0-1.6.0.1.php rename to app/code/Mage/Paypal/sql/paypal_setup/upgrade-1.6.0.0-1.6.0.1.php diff --git a/app/code/core/Mage/Paypal/sql/paypal_setup/upgrade-1.6.0.1-1.6.0.2.php b/app/code/Mage/Paypal/sql/paypal_setup/upgrade-1.6.0.1-1.6.0.2.php similarity index 100% rename from app/code/core/Mage/Paypal/sql/paypal_setup/upgrade-1.6.0.1-1.6.0.2.php rename to app/code/Mage/Paypal/sql/paypal_setup/upgrade-1.6.0.1-1.6.0.2.php diff --git a/app/code/core/Mage/Paypal/view/adminhtml/boxes.css b/app/code/Mage/Paypal/view/adminhtml/boxes.css similarity index 100% rename from app/code/core/Mage/Paypal/view/adminhtml/boxes.css rename to app/code/Mage/Paypal/view/adminhtml/boxes.css diff --git a/app/code/core/Mage/Paypal/view/adminhtml/layout.xml b/app/code/Mage/Paypal/view/adminhtml/layout.xml similarity index 100% rename from app/code/core/Mage/Paypal/view/adminhtml/layout.xml rename to app/code/Mage/Paypal/view/adminhtml/layout.xml diff --git a/app/code/core/Mage/Paypal/view/adminhtml/logo.gif b/app/code/Mage/Paypal/view/adminhtml/logo.gif similarity index 100% rename from app/code/core/Mage/Paypal/view/adminhtml/logo.gif rename to app/code/Mage/Paypal/view/adminhtml/logo.gif diff --git a/app/code/core/Mage/Paypal/view/adminhtml/section.png b/app/code/Mage/Paypal/view/adminhtml/section.png similarity index 100% rename from app/code/core/Mage/Paypal/view/adminhtml/section.png rename to app/code/Mage/Paypal/view/adminhtml/section.png diff --git a/app/code/core/Mage/Paypal/view/adminhtml/system/config/api_wizard.phtml b/app/code/Mage/Paypal/view/adminhtml/system/config/api_wizard.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/adminhtml/system/config/api_wizard.phtml rename to app/code/Mage/Paypal/view/adminhtml/system/config/api_wizard.phtml diff --git a/app/code/core/Mage/Paypal/view/adminhtml/system/config/fieldset/global.phtml b/app/code/Mage/Paypal/view/adminhtml/system/config/fieldset/global.phtml similarity index 99% rename from app/code/core/Mage/Paypal/view/adminhtml/system/config/fieldset/global.phtml rename to app/code/Mage/Paypal/view/adminhtml/system/config/fieldset/global.phtml index 25547beb03e90..fcf3223638648 100644 --- a/app/code/core/Mage/Paypal/view/adminhtml/system/config/fieldset/global.phtml +++ b/app/code/Mage/Paypal/view/adminhtml/system/config/fieldset/global.phtml @@ -385,7 +385,8 @@ PaypalConfig.prototype = { trackBusinessAccount: function() { var elem = $('paypal_account_business_account'); - if (!Validation.validate(elem) || !elem.value) { + + if (!jQuery.validator.validateElement(elem) || !elem.value) { this.disableMethod('wps', true); this.disableMethod('ec', true); this.disabledMethods.push('wps','ec'); diff --git a/app/code/core/Mage/Paypal/view/adminhtml/system/config/fieldset/hint.phtml b/app/code/Mage/Paypal/view/adminhtml/system/config/fieldset/hint.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/adminhtml/system/config/fieldset/hint.phtml rename to app/code/Mage/Paypal/view/adminhtml/system/config/fieldset/hint.phtml diff --git a/app/code/core/Mage/Paypal/view/adminhtml/system/config/fieldset/store.phtml b/app/code/Mage/Paypal/view/adminhtml/system/config/fieldset/store.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/adminhtml/system/config/fieldset/store.phtml rename to app/code/Mage/Paypal/view/adminhtml/system/config/fieldset/store.phtml diff --git a/app/code/core/Mage/Paypal/view/adminhtml/system/config/payflowlink/advanced.phtml b/app/code/Mage/Paypal/view/adminhtml/system/config/payflowlink/advanced.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/adminhtml/system/config/payflowlink/advanced.phtml rename to app/code/Mage/Paypal/view/adminhtml/system/config/payflowlink/advanced.phtml diff --git a/app/code/core/Mage/Paypal/view/adminhtml/system/config/payflowlink/info.phtml b/app/code/Mage/Paypal/view/adminhtml/system/config/payflowlink/info.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/adminhtml/system/config/payflowlink/info.phtml rename to app/code/Mage/Paypal/view/adminhtml/system/config/payflowlink/info.phtml diff --git a/app/code/core/Mage/Paypal/view/frontend/express/review.phtml b/app/code/Mage/Paypal/view/frontend/express/review.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/frontend/express/review.phtml rename to app/code/Mage/Paypal/view/frontend/express/review.phtml diff --git a/app/code/Mage/Paypal/view/frontend/express/review/address.phtml b/app/code/Mage/Paypal/view/frontend/express/review/address.phtml new file mode 100644 index 0000000000000..a3316e49d974a --- /dev/null +++ b/app/code/Mage/Paypal/view/frontend/express/review/address.phtml @@ -0,0 +1,154 @@ + +getFieldNamePrefix();?> +
    +
      +
    • +
      + +
        +
      • getLayout()->createBlock('Mage_Customer_Block_Widget_Name')->setObject($this->getAddress()->getFirstname() ? $this->getAddress() : $this->getQuote()->getCustomer())->setForceUseCustomerRequiredAttributes(!$this->isCustomerLoggedIn())->setFieldIdFormat($prefix . ':%s')->setFieldNameFormat($prefix . '[%s]')->toHtml() ?>
      • +
      • +
        + +
        + +
        +
        + isCustomerLoggedIn() && !$this->getHideEmailAddress()): ?> +
        + +
        + +
        +
        + +
      • + helper('Mage_Customer_Helper_Address')->getAttributeValidationClass('street'); ?> +
      • + +
        + +
        +
      • + + helper('Mage_Customer_Helper_Address')->getStreetLines(); $_i <= $_n; $_i++): ?> +
      • +
        + +
        +
      • + + helper('Mage_Customer_Helper_Address')->isVatAttributeVisible()) : ?> +
      • + +
        + +
        +
      • + +
      • +
        + +
        + +
        +
        +
        + +
        + + +
        +
        +
      • +
      • +
        + +
        + +
        +
        +
        + +
        + getCountryHtmlSelect($prefix) ?> +
        +
        +
      • +
      • +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
      • + getChildHtml('form.additional.info'); ?> + getShowAsShippingCheckbox()): ?> +
      • +
        +
        + getAddress()->getSameAsBilling()):?>checked="checked"/> +
        + +
        +
      • + +
      +
      +
    • +
    +
    + diff --git a/app/code/core/Mage/Paypal/view/frontend/express/review/details.phtml b/app/code/Mage/Paypal/view/frontend/express/review/details.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/frontend/express/review/details.phtml rename to app/code/Mage/Paypal/view/frontend/express/review/details.phtml diff --git a/app/code/core/Mage/Paypal/view/frontend/express/review/shipping/method.phtml b/app/code/Mage/Paypal/view/frontend/express/review/shipping/method.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/frontend/express/review/shipping/method.phtml rename to app/code/Mage/Paypal/view/frontend/express/review/shipping/method.phtml diff --git a/app/code/core/Mage/Paypal/view/frontend/express/shortcut.phtml b/app/code/Mage/Paypal/view/frontend/express/shortcut.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/frontend/express/shortcut.phtml rename to app/code/Mage/Paypal/view/frontend/express/shortcut.phtml diff --git a/app/code/core/Mage/Paypal/view/frontend/hss/form.phtml b/app/code/Mage/Paypal/view/frontend/hss/form.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/frontend/hss/form.phtml rename to app/code/Mage/Paypal/view/frontend/hss/form.phtml diff --git a/app/code/core/Mage/Paypal/view/frontend/hss/iframe.phtml b/app/code/Mage/Paypal/view/frontend/hss/iframe.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/frontend/hss/iframe.phtml rename to app/code/Mage/Paypal/view/frontend/hss/iframe.phtml diff --git a/app/code/core/Mage/Paypal/view/frontend/hss/info.phtml b/app/code/Mage/Paypal/view/frontend/hss/info.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/frontend/hss/info.phtml rename to app/code/Mage/Paypal/view/frontend/hss/info.phtml diff --git a/app/code/Mage/Paypal/view/frontend/hss/js.phtml b/app/code/Mage/Paypal/view/frontend/hss/js.phtml new file mode 100644 index 0000000000000..ccc7e2d0fc1ae --- /dev/null +++ b/app/code/Mage/Paypal/view/frontend/hss/js.phtml @@ -0,0 +1,32 @@ + +
    + diff --git a/app/code/core/Mage/Paypal/view/frontend/hss/redirect.phtml b/app/code/Mage/Paypal/view/frontend/hss/redirect.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/frontend/hss/redirect.phtml rename to app/code/Mage/Paypal/view/frontend/hss/redirect.phtml diff --git a/app/code/Mage/Paypal/view/frontend/hss/review/button.phtml b/app/code/Mage/Paypal/view/frontend/hss/review/button.phtml new file mode 100644 index 0000000000000..0cb4091719373 --- /dev/null +++ b/app/code/Mage/Paypal/view/frontend/hss/review/button.phtml @@ -0,0 +1,27 @@ + + diff --git a/app/code/Mage/Paypal/view/frontend/layout.xml b/app/code/Mage/Paypal/view/frontend/layout.xml new file mode 100644 index 0000000000000..64b7a29094498 --- /dev/null +++ b/app/code/Mage/Paypal/view/frontend/layout.xml @@ -0,0 +1,240 @@ + + + + + + + 1 + + + + + + 1 + + + + + + + + + + + + + + + + + + defaultMage_Checkout_Block_Cart_Item_Renderer + groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped + configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable + + + + + + + Mage_Paypal::review.js + + + + + + + + + defaultMage_Checkout_Block_Cart_Item_Renderer + groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped + configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + after + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/core/Mage/Paypal/view/frontend/partner/logo.phtml b/app/code/Mage/Paypal/view/frontend/partner/logo.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/frontend/partner/logo.phtml rename to app/code/Mage/Paypal/view/frontend/partner/logo.phtml diff --git a/app/code/core/Mage/Paypal/view/frontend/payflowadvanced/form.phtml b/app/code/Mage/Paypal/view/frontend/payflowadvanced/form.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/frontend/payflowadvanced/form.phtml rename to app/code/Mage/Paypal/view/frontend/payflowadvanced/form.phtml diff --git a/app/code/core/Mage/Paypal/view/frontend/payflowadvanced/iframe.phtml b/app/code/Mage/Paypal/view/frontend/payflowadvanced/iframe.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/frontend/payflowadvanced/iframe.phtml rename to app/code/Mage/Paypal/view/frontend/payflowadvanced/iframe.phtml diff --git a/app/code/core/Mage/Paypal/view/frontend/payflowadvanced/info.phtml b/app/code/Mage/Paypal/view/frontend/payflowadvanced/info.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/frontend/payflowadvanced/info.phtml rename to app/code/Mage/Paypal/view/frontend/payflowadvanced/info.phtml diff --git a/app/code/core/Mage/Paypal/view/frontend/payflowadvanced/redirect.phtml b/app/code/Mage/Paypal/view/frontend/payflowadvanced/redirect.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/frontend/payflowadvanced/redirect.phtml rename to app/code/Mage/Paypal/view/frontend/payflowadvanced/redirect.phtml diff --git a/app/code/core/Mage/Paypal/view/frontend/payflowlink/form.phtml b/app/code/Mage/Paypal/view/frontend/payflowlink/form.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/frontend/payflowlink/form.phtml rename to app/code/Mage/Paypal/view/frontend/payflowlink/form.phtml diff --git a/app/code/core/Mage/Paypal/view/frontend/payflowlink/iframe.phtml b/app/code/Mage/Paypal/view/frontend/payflowlink/iframe.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/frontend/payflowlink/iframe.phtml rename to app/code/Mage/Paypal/view/frontend/payflowlink/iframe.phtml diff --git a/app/code/core/Mage/Paypal/view/frontend/payflowlink/info.phtml b/app/code/Mage/Paypal/view/frontend/payflowlink/info.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/frontend/payflowlink/info.phtml rename to app/code/Mage/Paypal/view/frontend/payflowlink/info.phtml diff --git a/app/code/core/Mage/Paypal/view/frontend/payflowlink/redirect.phtml b/app/code/Mage/Paypal/view/frontend/payflowlink/redirect.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/frontend/payflowlink/redirect.phtml rename to app/code/Mage/Paypal/view/frontend/payflowlink/redirect.phtml diff --git a/app/code/core/Mage/Paypal/view/frontend/payment/mark.phtml b/app/code/Mage/Paypal/view/frontend/payment/mark.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/frontend/payment/mark.phtml rename to app/code/Mage/Paypal/view/frontend/payment/mark.phtml diff --git a/app/code/core/Mage/Paypal/view/frontend/payment/redirect.phtml b/app/code/Mage/Paypal/view/frontend/payment/redirect.phtml similarity index 100% rename from app/code/core/Mage/Paypal/view/frontend/payment/redirect.phtml rename to app/code/Mage/Paypal/view/frontend/payment/redirect.phtml diff --git a/app/code/core/Mage/Paypal/view/frontend/review.js b/app/code/Mage/Paypal/view/frontend/review.js similarity index 100% rename from app/code/core/Mage/Paypal/view/frontend/review.js rename to app/code/Mage/Paypal/view/frontend/review.js diff --git a/app/code/core/Mage/PaypalUk/Block/Express/Form.php b/app/code/Mage/PaypalUk/Block/Express/Form.php similarity index 100% rename from app/code/core/Mage/PaypalUk/Block/Express/Form.php rename to app/code/Mage/PaypalUk/Block/Express/Form.php diff --git a/app/code/core/Mage/PaypalUk/Block/Express/Shortcut.php b/app/code/Mage/PaypalUk/Block/Express/Shortcut.php similarity index 100% rename from app/code/core/Mage/PaypalUk/Block/Express/Shortcut.php rename to app/code/Mage/PaypalUk/Block/Express/Shortcut.php diff --git a/app/code/core/Mage/PaypalUk/Helper/Data.php b/app/code/Mage/PaypalUk/Helper/Data.php similarity index 100% rename from app/code/core/Mage/PaypalUk/Helper/Data.php rename to app/code/Mage/PaypalUk/Helper/Data.php diff --git a/app/code/core/Mage/PaypalUk/Model/Api/Nvp.php b/app/code/Mage/PaypalUk/Model/Api/Nvp.php similarity index 100% rename from app/code/core/Mage/PaypalUk/Model/Api/Nvp.php rename to app/code/Mage/PaypalUk/Model/Api/Nvp.php diff --git a/app/code/core/Mage/PaypalUk/Model/Direct.php b/app/code/Mage/PaypalUk/Model/Direct.php similarity index 100% rename from app/code/core/Mage/PaypalUk/Model/Direct.php rename to app/code/Mage/PaypalUk/Model/Direct.php diff --git a/app/code/core/Mage/PaypalUk/Model/Express.php b/app/code/Mage/PaypalUk/Model/Express.php similarity index 100% rename from app/code/core/Mage/PaypalUk/Model/Express.php rename to app/code/Mage/PaypalUk/Model/Express.php diff --git a/app/code/core/Mage/PaypalUk/Model/Express/Checkout.php b/app/code/Mage/PaypalUk/Model/Express/Checkout.php similarity index 100% rename from app/code/core/Mage/PaypalUk/Model/Express/Checkout.php rename to app/code/Mage/PaypalUk/Model/Express/Checkout.php diff --git a/app/code/core/Mage/PaypalUk/Model/Pro.php b/app/code/Mage/PaypalUk/Model/Pro.php similarity index 100% rename from app/code/core/Mage/PaypalUk/Model/Pro.php rename to app/code/Mage/PaypalUk/Model/Pro.php diff --git a/app/code/core/Mage/PaypalUk/Model/Session.php b/app/code/Mage/PaypalUk/Model/Session.php similarity index 100% rename from app/code/core/Mage/PaypalUk/Model/Session.php rename to app/code/Mage/PaypalUk/Model/Session.php diff --git a/app/code/core/Mage/PaypalUk/controllers/ExpressController.php b/app/code/Mage/PaypalUk/controllers/ExpressController.php similarity index 100% rename from app/code/core/Mage/PaypalUk/controllers/ExpressController.php rename to app/code/Mage/PaypalUk/controllers/ExpressController.php diff --git a/app/code/Mage/PaypalUk/etc/config.xml b/app/code/Mage/PaypalUk/etc/config.xml new file mode 100644 index 0000000000000..14153fe784dce --- /dev/null +++ b/app/code/Mage/PaypalUk/etc/config.xml @@ -0,0 +1,101 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + + + + Mage_PaypalUk + + + + + + + /paypaluk/express + + + + standard + + Mage_PaypalUk + paypaluk + + + + + + + + Mage_PaypalUk.csv + + + + + + + + layout.xml + + + + + + + + + + Mage_PaypalUk.csv + + + + + + + + + Mage_PaypalUk_Model_Express + + + Mage_PaypalUk_Model_Direct + + + + diff --git a/app/code/core/Mage/PaypalUk/locale/de_DE/Mage_PaypalUk.csv b/app/code/Mage/PaypalUk/locale/de_DE/Mage_PaypalUk.csv similarity index 100% rename from app/code/core/Mage/PaypalUk/locale/de_DE/Mage_PaypalUk.csv rename to app/code/Mage/PaypalUk/locale/de_DE/Mage_PaypalUk.csv diff --git a/app/code/core/Mage/PaypalUk/locale/en_US/Mage_PaypalUk.csv b/app/code/Mage/PaypalUk/locale/en_US/Mage_PaypalUk.csv similarity index 100% rename from app/code/core/Mage/PaypalUk/locale/en_US/Mage_PaypalUk.csv rename to app/code/Mage/PaypalUk/locale/en_US/Mage_PaypalUk.csv diff --git a/app/code/core/Mage/PaypalUk/locale/es_ES/Mage_PaypalUk.csv b/app/code/Mage/PaypalUk/locale/es_ES/Mage_PaypalUk.csv similarity index 100% rename from app/code/core/Mage/PaypalUk/locale/es_ES/Mage_PaypalUk.csv rename to app/code/Mage/PaypalUk/locale/es_ES/Mage_PaypalUk.csv diff --git a/app/code/core/Mage/PaypalUk/locale/fr_FR/Mage_PaypalUk.csv b/app/code/Mage/PaypalUk/locale/fr_FR/Mage_PaypalUk.csv similarity index 100% rename from app/code/core/Mage/PaypalUk/locale/fr_FR/Mage_PaypalUk.csv rename to app/code/Mage/PaypalUk/locale/fr_FR/Mage_PaypalUk.csv diff --git a/app/code/core/Mage/PaypalUk/locale/nl_NL/Mage_PaypalUk.csv b/app/code/Mage/PaypalUk/locale/nl_NL/Mage_PaypalUk.csv similarity index 100% rename from app/code/core/Mage/PaypalUk/locale/nl_NL/Mage_PaypalUk.csv rename to app/code/Mage/PaypalUk/locale/nl_NL/Mage_PaypalUk.csv diff --git a/app/code/core/Mage/PaypalUk/locale/pt_BR/Mage_PaypalUk.csv b/app/code/Mage/PaypalUk/locale/pt_BR/Mage_PaypalUk.csv similarity index 100% rename from app/code/core/Mage/PaypalUk/locale/pt_BR/Mage_PaypalUk.csv rename to app/code/Mage/PaypalUk/locale/pt_BR/Mage_PaypalUk.csv diff --git a/app/code/core/Mage/PaypalUk/locale/zh_CN/Mage_PaypalUk.csv b/app/code/Mage/PaypalUk/locale/zh_CN/Mage_PaypalUk.csv similarity index 100% rename from app/code/core/Mage/PaypalUk/locale/zh_CN/Mage_PaypalUk.csv rename to app/code/Mage/PaypalUk/locale/zh_CN/Mage_PaypalUk.csv diff --git a/app/code/core/Mage/PaypalUk/sql/paypaluk_setup/install-1.6.0.0.php b/app/code/Mage/PaypalUk/sql/paypaluk_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/PaypalUk/sql/paypaluk_setup/install-1.6.0.0.php rename to app/code/Mage/PaypalUk/sql/paypaluk_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/PaypalUk/view/frontend/express/review.phtml b/app/code/Mage/PaypalUk/view/frontend/express/review.phtml similarity index 100% rename from app/code/core/Mage/PaypalUk/view/frontend/express/review.phtml rename to app/code/Mage/PaypalUk/view/frontend/express/review.phtml diff --git a/app/code/Mage/PaypalUk/view/frontend/layout.xml b/app/code/Mage/PaypalUk/view/frontend/layout.xml new file mode 100644 index 0000000000000..0c6f2b06e5740 --- /dev/null +++ b/app/code/Mage/PaypalUk/view/frontend/layout.xml @@ -0,0 +1,152 @@ + + + + + + + 1 + + + + + 1 + + + + + + + + + + + + + + paypaluk + + defaultMage_Checkout_Block_Cart_Item_Renderer + groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped + configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable + + + + + + + Mage_Paypal::review.js + + + + + + + defaultMage_Checkout_Block_Cart_Item_Renderer + groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped + configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + after + + + + + + + + + + diff --git a/app/code/core/Mage/Persistent/Block/Form/Remember.php b/app/code/Mage/Persistent/Block/Form/Remember.php similarity index 100% rename from app/code/core/Mage/Persistent/Block/Form/Remember.php rename to app/code/Mage/Persistent/Block/Form/Remember.php diff --git a/app/code/core/Mage/Persistent/Block/Header/Additional.php b/app/code/Mage/Persistent/Block/Header/Additional.php similarity index 100% rename from app/code/core/Mage/Persistent/Block/Header/Additional.php rename to app/code/Mage/Persistent/Block/Header/Additional.php diff --git a/app/code/core/Mage/Persistent/Helper/Data.php b/app/code/Mage/Persistent/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Persistent/Helper/Data.php rename to app/code/Mage/Persistent/Helper/Data.php diff --git a/app/code/core/Mage/Persistent/Helper/Session.php b/app/code/Mage/Persistent/Helper/Session.php similarity index 100% rename from app/code/core/Mage/Persistent/Helper/Session.php rename to app/code/Mage/Persistent/Helper/Session.php diff --git a/app/code/core/Mage/Persistent/Model/Observer.php b/app/code/Mage/Persistent/Model/Observer.php similarity index 100% rename from app/code/core/Mage/Persistent/Model/Observer.php rename to app/code/Mage/Persistent/Model/Observer.php diff --git a/app/code/core/Mage/Persistent/Model/Observer/Session.php b/app/code/Mage/Persistent/Model/Observer/Session.php similarity index 100% rename from app/code/core/Mage/Persistent/Model/Observer/Session.php rename to app/code/Mage/Persistent/Model/Observer/Session.php diff --git a/app/code/core/Mage/Persistent/Model/Persistent/Config.php b/app/code/Mage/Persistent/Model/Persistent/Config.php similarity index 100% rename from app/code/core/Mage/Persistent/Model/Persistent/Config.php rename to app/code/Mage/Persistent/Model/Persistent/Config.php diff --git a/app/code/core/Mage/Persistent/Model/Resource/Session.php b/app/code/Mage/Persistent/Model/Resource/Session.php similarity index 100% rename from app/code/core/Mage/Persistent/Model/Resource/Session.php rename to app/code/Mage/Persistent/Model/Resource/Session.php diff --git a/app/code/core/Mage/Persistent/Model/Session.php b/app/code/Mage/Persistent/Model/Session.php similarity index 100% rename from app/code/core/Mage/Persistent/Model/Session.php rename to app/code/Mage/Persistent/Model/Session.php diff --git a/app/code/core/Mage/Persistent/controllers/IndexController.php b/app/code/Mage/Persistent/controllers/IndexController.php similarity index 100% rename from app/code/core/Mage/Persistent/controllers/IndexController.php rename to app/code/Mage/Persistent/controllers/IndexController.php diff --git a/app/code/Mage/Persistent/etc/adminhtml/acl.xml b/app/code/Mage/Persistent/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..777766bf8be09 --- /dev/null +++ b/app/code/Mage/Persistent/etc/adminhtml/acl.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + diff --git a/app/code/core/Mage/Persistent/etc/adminhtml/system.xml b/app/code/Mage/Persistent/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Persistent/etc/adminhtml/system.xml rename to app/code/Mage/Persistent/etc/adminhtml/system.xml diff --git a/app/code/Mage/Persistent/etc/config.xml b/app/code/Mage/Persistent/etc/config.xml new file mode 100644 index 0000000000000..7c5082b890938 --- /dev/null +++ b/app/code/Mage/Persistent/etc/config.xml @@ -0,0 +1,299 @@ + + + + + + 1.0.0.0 + true + + + + + + + + + + + Mage_Persistent + + + + + + + /persistent/index/saveMethod + + + + standard + + Mage_Persistent + persistent + + + + + + + layout.xml + + + + + + + + Mage_Persistent_Model_Observer_Session + synchronizePersistentOnLogin + + + + + + + Mage_Persistent_Model_Observer_Session + synchronizePersistentOnLogout + + + + + + + Mage_Persistent_Model_Observer_Session + synchronizePersistentInfo + + + + + + + Mage_Persistent_Model_Observer_Session + setRememberMeCheckedStatus + + + + + + + Mage_Persistent_Model_Observer_Session + setRememberMeCheckedStatus + + + Mage_Persistent_Model_Observer + customerAuthenticatedEvent + + + + + + + Mage_Persistent_Model_Observer + applyPersistentData + + + + + + + Mage_Persistent_Model_Observer + emulateQuote + + + Mage_Persistent_Model_Observer_Session + renewCookie + + + Mage_Persistent_Model_Observer + checkExpirePersistentQuote + + + Mage_Persistent_Model_Observer + emulateCustomer + + + + + + + Mage_Persistent_Model_Observer + disableGuestCheckout + + + + + + + Mage_Persistent_Model_Observer + customerAuthenticatedEvent + + + + + + + Mage_Persistent_Model_Observer + preventClearCheckoutSession + + + + + + + Mage_Persistent_Model_Observer + makePersistentQuoteGuest + + + + + + + Mage_Persistent_Model_Observer + setQuotePersistentData + + + + + + + Mage_Persistent_Model_Observer + setLoadPersistentQuote + + + + + + + Mage_Persistent_Model_Observer_Session + setRememberMeCheckedStatus + + + + + + + Mage_Persistent_Model_Observer + removePersistentCookie + + + + + + + Mage_Persistent_Model_Observer + preventExpressCheckout + + + + + + + Mage_Persistent_Model_Observer + preventExpressCheckout + + + + + + + Mage_Persistent_Model_Observer + preventExpressCheckout + + + + + + + Mage_Persistent_Model_Observer + preventExpressCheckout + + + + + + + Mage_Persistent_Model_Observer + applyBlockPersistentData + + + + + + + Mage_Persistent_Model_Observer + updateCustomerCookies + + + + + + + + + Mage_Persistent.csv + + + + + + + + + + + Mage_Persistent.csv + + + + + + + + + 0 + 31536000 + 1 + 1 + 1 + 1 + + + + + + + + 0 0 * * * + + + Mage_Persistent_Model_Observer::clearExpiredCronJob + + + + + diff --git a/app/code/core/Mage/Persistent/etc/persistent.xml b/app/code/Mage/Persistent/etc/persistent.xml similarity index 100% rename from app/code/core/Mage/Persistent/etc/persistent.xml rename to app/code/Mage/Persistent/etc/persistent.xml diff --git a/app/code/core/Mage/Persistent/locale/de_DE/Mage_Persistent.csv b/app/code/Mage/Persistent/locale/de_DE/Mage_Persistent.csv similarity index 100% rename from app/code/core/Mage/Persistent/locale/de_DE/Mage_Persistent.csv rename to app/code/Mage/Persistent/locale/de_DE/Mage_Persistent.csv diff --git a/app/code/core/Mage/Persistent/locale/en_US/Mage_Persistent.csv b/app/code/Mage/Persistent/locale/en_US/Mage_Persistent.csv similarity index 100% rename from app/code/core/Mage/Persistent/locale/en_US/Mage_Persistent.csv rename to app/code/Mage/Persistent/locale/en_US/Mage_Persistent.csv diff --git a/app/code/core/Mage/Persistent/locale/es_ES/Mage_Persistent.csv b/app/code/Mage/Persistent/locale/es_ES/Mage_Persistent.csv similarity index 100% rename from app/code/core/Mage/Persistent/locale/es_ES/Mage_Persistent.csv rename to app/code/Mage/Persistent/locale/es_ES/Mage_Persistent.csv diff --git a/app/code/core/Mage/Persistent/locale/fr_FR/Mage_Persistent.csv b/app/code/Mage/Persistent/locale/fr_FR/Mage_Persistent.csv similarity index 100% rename from app/code/core/Mage/Persistent/locale/fr_FR/Mage_Persistent.csv rename to app/code/Mage/Persistent/locale/fr_FR/Mage_Persistent.csv diff --git a/app/code/core/Mage/Persistent/locale/nl_NL/Mage_Persistent.csv b/app/code/Mage/Persistent/locale/nl_NL/Mage_Persistent.csv similarity index 100% rename from app/code/core/Mage/Persistent/locale/nl_NL/Mage_Persistent.csv rename to app/code/Mage/Persistent/locale/nl_NL/Mage_Persistent.csv diff --git a/app/code/core/Mage/Persistent/locale/pt_BR/Mage_Persistent.csv b/app/code/Mage/Persistent/locale/pt_BR/Mage_Persistent.csv similarity index 100% rename from app/code/core/Mage/Persistent/locale/pt_BR/Mage_Persistent.csv rename to app/code/Mage/Persistent/locale/pt_BR/Mage_Persistent.csv diff --git a/app/code/core/Mage/Persistent/locale/zh_CN/Mage_Persistent.csv b/app/code/Mage/Persistent/locale/zh_CN/Mage_Persistent.csv similarity index 100% rename from app/code/core/Mage/Persistent/locale/zh_CN/Mage_Persistent.csv rename to app/code/Mage/Persistent/locale/zh_CN/Mage_Persistent.csv diff --git a/app/code/core/Mage/Persistent/sql/persistent_setup/install-1.0.0.0.php b/app/code/Mage/Persistent/sql/persistent_setup/install-1.0.0.0.php similarity index 100% rename from app/code/core/Mage/Persistent/sql/persistent_setup/install-1.0.0.0.php rename to app/code/Mage/Persistent/sql/persistent_setup/install-1.0.0.0.php diff --git a/app/code/Mage/Persistent/view/frontend/checkout/onepage/billing.phtml b/app/code/Mage/Persistent/view/frontend/checkout/onepage/billing.phtml new file mode 100644 index 0000000000000..e49690362632a --- /dev/null +++ b/app/code/Mage/Persistent/view/frontend/checkout/onepage/billing.phtml @@ -0,0 +1,214 @@ + +
    +
    +
      + customerHasAddresses()): ?> +
    • + +
      + getAddressesHtmlSelect('billing') ?> +
      +
    • + +
    • customerHasAddresses()): ?> style="display:none;"> +
      + +
        +
      • getLayout()->createBlock('Mage_Customer_Block_Widget_Name')->setObject($this->getAddress()->getFirstname() ? $this->getAddress() : $this->getQuote()->getCustomer())->setForceUseCustomerRequiredAttributes(!$this->isCustomerLoggedIn())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
      • +
      • +
        + +
        + +
        +
        + isCustomerLoggedIn()): ?> +
        + +
        + +
        +
        + +
      • + helper('Mage_Customer_Helper_Address')->getAttributeValidationClass('street'); ?> +
      • + +
        + +
        +
      • + + helper('Mage_Customer_Helper_Address')->getStreetLines(); $_i <= $_n; $_i++): ?> +
      • +
        + +
        +
      • + + helper('Mage_Customer_Helper_Address')->isVatAttributeVisible()) : ?> +
      • + +
        + +
        +
      • + +
      • +
        + +
        + +
        +
        +
        + +
        + + +
        +
        +
      • +
      • +
        + +
        + +
        +
        +
        + +
        + getCountryHtmlSelect('billing') ?> +
        +
        +
      • +
      • +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
      • + isCustomerLoggedIn()): ?> + + getLayout()->createBlock('Mage_Customer_Block_Widget_Dob') ?> + getLayout()->createBlock('Mage_Customer_Block_Widget_Gender') ?> + isEnabled() || $_gender->isEnabled()): ?> +
      • + isEnabled()): ?> +
        + setDate($this->getQuote()->getCustomerDob())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?> +
        + + isEnabled()): ?> +
        + setGender($this->getQuote()->getCustomerGender())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?> +
        + +
      • + + + isTaxvatEnabled()):?> +
      • getTaxvatHtml() ?>
      • + + +
      • +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
      • + getChildHtml('persistent.remember.me'); ?> + + isCustomerLoggedIn() && $this->customerHasAddresses()):?> +
      • + getAddress()->getSaveInAddressBook()):?> checked="checked" class="checkbox" /> +
      • + +
      • + + getChildHtml('form.additional.info'); ?> +
      + getChildHtml('persistent.remember.me.tooltip'); ?> +
      +
    • + canShip()): ?> +
    • + isUseBillingAddressForShipping()) {?> checked="checked" title="__('Ship to this address') ?>" class="radio" />
    • +
    • + isUseBillingAddressForShipping()) {?> checked="checked" title="__('Ship to different address') ?>" class="radio" /> +
    • + +
    + canShip()): ?> + + +
    +

    __('* Required Fields') ?>

    + + +
    +
    +
    + \ No newline at end of file diff --git a/app/code/Mage/Persistent/view/frontend/checkout/onepage/login.phtml b/app/code/Mage/Persistent/view/frontend/checkout/onepage/login.phtml new file mode 100644 index 0000000000000..04ce8344ff83c --- /dev/null +++ b/app/code/Mage/Persistent/view/frontend/checkout/onepage/login.phtml @@ -0,0 +1,136 @@ + + +
    + getChildHtml('login_before')?> +
    +

    isAllowedGuestCheckout() ): ?>__('Checkout as a Guest or Register') ?>__('Register to Create an Account') ?>

    + isAllowedGuestCheckout() ): ?> +

    __('Register with us for future convenience:') ?>

    + +

    __('Register and save time!') ?>
    + __('Register with us for future convenience:') ?>

    +
      +
    • __('Fast and easy check out') ?>
    • +
    • __('Easy access to your order history and status') ?>
    • +
    + + isAllowedGuestCheckout() ): ?> +
      + isAllowedGuestCheckout() ): ?> +
    • + getQuote()->getCheckoutMethod()==Mage_Checkout_Model_Type_Onepage::METHOD_GUEST): ?> checked="checked" class="radio" /> +
    • + +
    • + getQuote()->getCheckoutMethod()==Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER || !$this->isAllowedGuestCheckout()): ?> checked="checked" class="radio" /> +
    • +
    +

    __('Register and save time!') ?>

    +

    __('Register with us for future convenience:') ?>

    +
      +
    • __('Fast and easy check out') ?>
    • +
    • __('Easy access to your order history and status') ?>
    • +
    + + + +
    +
    +

    __('Login') ?>

    + getMessagesBlock()->getGroupedHtml() ?> +
    +
    +

    __('Already registered?') ?>

    +

    __('Please log in below:') ?>

    +
      +
    • + +
      + +
      +
    • +
    • + +
      + +
      +
    • + getChildHtml('login.form.additional.info'); ?> + getChildHtml('persistent.remember.me'); ?> +
    + +
    +
    +
    +
    +
    +
    +
    +

     

    + isAllowedGuestCheckout()): ?> + + helper('Mage_Checkout_Helper_Data')->isCustomerMustBeLogged()): ?> + + +
    + +
    + + +
    +
    +
    +
    +

    __('* Required Fields') ?>

    + __('Forgot your password?') ?> + +
    +
    +
    + diff --git a/app/code/Mage/Persistent/view/frontend/customer/form/login.phtml b/app/code/Mage/Persistent/view/frontend/customer/form/login.phtml new file mode 100644 index 0000000000000..6135d91fcc3ee --- /dev/null +++ b/app/code/Mage/Persistent/view/frontend/customer/form/login.phtml @@ -0,0 +1,103 @@ + + + diff --git a/app/code/core/Mage/Persistent/view/frontend/customer/form/register.phtml b/app/code/Mage/Persistent/view/frontend/customer/form/register.phtml similarity index 99% rename from app/code/core/Mage/Persistent/view/frontend/customer/form/register.phtml rename to app/code/Mage/Persistent/view/frontend/customer/form/register.phtml index 0ff598a383521..453f5cc19739f 100644 --- a/app/code/core/Mage/Persistent/view/frontend/customer/form/register.phtml +++ b/app/code/Mage/Persistent/view/frontend/customer/form/register.phtml @@ -28,7 +28,7 @@ /** * Create account form template * - * @see app/code/core/Mage/Customer/view/frontend/form/register.phtml + * @see app/code/Mage/Customer/view/frontend/form/register.phtml */ /** @var $this Mage_Customer_Block_Form_Register */ ?> diff --git a/app/code/core/Mage/Persistent/view/frontend/layout.xml b/app/code/Mage/Persistent/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/Persistent/view/frontend/layout.xml rename to app/code/Mage/Persistent/view/frontend/layout.xml diff --git a/app/code/core/Mage/Persistent/view/frontend/remember-me-popup.js b/app/code/Mage/Persistent/view/frontend/remember-me-popup.js similarity index 100% rename from app/code/core/Mage/Persistent/view/frontend/remember-me-popup.js rename to app/code/Mage/Persistent/view/frontend/remember-me-popup.js diff --git a/app/code/core/Mage/Persistent/view/frontend/remember_me.phtml b/app/code/Mage/Persistent/view/frontend/remember_me.phtml similarity index 100% rename from app/code/core/Mage/Persistent/view/frontend/remember_me.phtml rename to app/code/Mage/Persistent/view/frontend/remember_me.phtml diff --git a/app/code/core/Mage/Persistent/view/frontend/remember_me_tooltip.phtml b/app/code/Mage/Persistent/view/frontend/remember_me_tooltip.phtml similarity index 100% rename from app/code/core/Mage/Persistent/view/frontend/remember_me_tooltip.phtml rename to app/code/Mage/Persistent/view/frontend/remember_me_tooltip.phtml diff --git a/app/code/core/Mage/Persistent/view/frontend/splitbutton.js b/app/code/Mage/Persistent/view/frontend/splitbutton.js similarity index 100% rename from app/code/core/Mage/Persistent/view/frontend/splitbutton.js rename to app/code/Mage/Persistent/view/frontend/splitbutton.js diff --git a/app/code/core/Mage/Poll/Block/ActivePoll.php b/app/code/Mage/Poll/Block/ActivePoll.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Poll/Block/ActivePoll.php rename to app/code/Mage/Poll/Block/ActivePoll.php diff --git a/app/code/core/Mage/Poll/Helper/Data.php b/app/code/Mage/Poll/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Poll/Helper/Data.php rename to app/code/Mage/Poll/Helper/Data.php diff --git a/app/code/core/Mage/Poll/Model/Poll.php b/app/code/Mage/Poll/Model/Poll.php similarity index 100% rename from app/code/core/Mage/Poll/Model/Poll.php rename to app/code/Mage/Poll/Model/Poll.php diff --git a/app/code/core/Mage/Poll/Model/Poll/Answer.php b/app/code/Mage/Poll/Model/Poll/Answer.php similarity index 100% rename from app/code/core/Mage/Poll/Model/Poll/Answer.php rename to app/code/Mage/Poll/Model/Poll/Answer.php diff --git a/app/code/core/Mage/Poll/Model/Poll/Vote.php b/app/code/Mage/Poll/Model/Poll/Vote.php similarity index 100% rename from app/code/core/Mage/Poll/Model/Poll/Vote.php rename to app/code/Mage/Poll/Model/Poll/Vote.php diff --git a/app/code/core/Mage/Poll/Model/Resource/Poll.php b/app/code/Mage/Poll/Model/Resource/Poll.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Poll/Model/Resource/Poll.php rename to app/code/Mage/Poll/Model/Resource/Poll.php diff --git a/app/code/core/Mage/Poll/Model/Resource/Poll/Answer.php b/app/code/Mage/Poll/Model/Resource/Poll/Answer.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Poll/Model/Resource/Poll/Answer.php rename to app/code/Mage/Poll/Model/Resource/Poll/Answer.php diff --git a/app/code/core/Mage/Poll/Model/Resource/Poll/Answer/Collection.php b/app/code/Mage/Poll/Model/Resource/Poll/Answer/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Poll/Model/Resource/Poll/Answer/Collection.php rename to app/code/Mage/Poll/Model/Resource/Poll/Answer/Collection.php diff --git a/app/code/core/Mage/Poll/Model/Resource/Poll/Collection.php b/app/code/Mage/Poll/Model/Resource/Poll/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Poll/Model/Resource/Poll/Collection.php rename to app/code/Mage/Poll/Model/Resource/Poll/Collection.php diff --git a/app/code/core/Mage/Poll/Model/Resource/Poll/Vote.php b/app/code/Mage/Poll/Model/Resource/Poll/Vote.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Poll/Model/Resource/Poll/Vote.php rename to app/code/Mage/Poll/Model/Resource/Poll/Vote.php diff --git a/app/code/core/Mage/Poll/controllers/VoteController.php b/app/code/Mage/Poll/controllers/VoteController.php similarity index 100% rename from app/code/core/Mage/Poll/controllers/VoteController.php rename to app/code/Mage/Poll/controllers/VoteController.php diff --git a/app/code/core/Mage/Poll/data/poll_setup/data-install-1.6.0.0.php b/app/code/Mage/Poll/data/poll_setup/data-install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Poll/data/poll_setup/data-install-1.6.0.0.php rename to app/code/Mage/Poll/data/poll_setup/data-install-1.6.0.0.php diff --git a/app/code/Mage/Poll/etc/adminhtml/acl.xml b/app/code/Mage/Poll/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..00cc271ab0918 --- /dev/null +++ b/app/code/Mage/Poll/etc/adminhtml/acl.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + diff --git a/app/code/Mage/Poll/etc/adminhtml/menu.xml b/app/code/Mage/Poll/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..b87b410e50229 --- /dev/null +++ b/app/code/Mage/Poll/etc/adminhtml/menu.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/app/code/core/Mage/Poll/etc/adminhtml/system.xml b/app/code/Mage/Poll/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Poll/etc/adminhtml/system.xml rename to app/code/Mage/Poll/etc/adminhtml/system.xml diff --git a/app/code/Mage/Poll/etc/config.xml b/app/code/Mage/Poll/etc/config.xml new file mode 100644 index 0000000000000..c9ec27d93c632 --- /dev/null +++ b/app/code/Mage/Poll/etc/config.xml @@ -0,0 +1,86 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + standard + + Mage_Poll + poll + + + + + + + + Mage_Poll.csv + + + + + + + + layout.xml + + + + + + + + + + Mage_Poll.csv + + + + + + + + + + Mage_Poll + + + + + diff --git a/app/code/core/Mage/Poll/locale/de_DE/Mage_Poll.csv b/app/code/Mage/Poll/locale/de_DE/Mage_Poll.csv similarity index 100% rename from app/code/core/Mage/Poll/locale/de_DE/Mage_Poll.csv rename to app/code/Mage/Poll/locale/de_DE/Mage_Poll.csv diff --git a/app/code/core/Mage/Poll/locale/en_US/Mage_Poll.csv b/app/code/Mage/Poll/locale/en_US/Mage_Poll.csv similarity index 100% rename from app/code/core/Mage/Poll/locale/en_US/Mage_Poll.csv rename to app/code/Mage/Poll/locale/en_US/Mage_Poll.csv diff --git a/app/code/core/Mage/Poll/locale/es_ES/Mage_Poll.csv b/app/code/Mage/Poll/locale/es_ES/Mage_Poll.csv similarity index 100% rename from app/code/core/Mage/Poll/locale/es_ES/Mage_Poll.csv rename to app/code/Mage/Poll/locale/es_ES/Mage_Poll.csv diff --git a/app/code/core/Mage/Poll/locale/fr_FR/Mage_Poll.csv b/app/code/Mage/Poll/locale/fr_FR/Mage_Poll.csv similarity index 100% rename from app/code/core/Mage/Poll/locale/fr_FR/Mage_Poll.csv rename to app/code/Mage/Poll/locale/fr_FR/Mage_Poll.csv diff --git a/app/code/core/Mage/Poll/locale/nl_NL/Mage_Poll.csv b/app/code/Mage/Poll/locale/nl_NL/Mage_Poll.csv similarity index 100% rename from app/code/core/Mage/Poll/locale/nl_NL/Mage_Poll.csv rename to app/code/Mage/Poll/locale/nl_NL/Mage_Poll.csv diff --git a/app/code/core/Mage/Poll/locale/pt_BR/Mage_Poll.csv b/app/code/Mage/Poll/locale/pt_BR/Mage_Poll.csv similarity index 100% rename from app/code/core/Mage/Poll/locale/pt_BR/Mage_Poll.csv rename to app/code/Mage/Poll/locale/pt_BR/Mage_Poll.csv diff --git a/app/code/core/Mage/Poll/locale/zh_CN/Mage_Poll.csv b/app/code/Mage/Poll/locale/zh_CN/Mage_Poll.csv similarity index 100% rename from app/code/core/Mage/Poll/locale/zh_CN/Mage_Poll.csv rename to app/code/Mage/Poll/locale/zh_CN/Mage_Poll.csv diff --git a/app/code/core/Mage/Poll/sql/poll_setup/install-1.6.0.0.php b/app/code/Mage/Poll/sql/poll_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Poll/sql/poll_setup/install-1.6.0.0.php rename to app/code/Mage/Poll/sql/poll_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Poll/view/frontend/active.phtml b/app/code/Mage/Poll/view/frontend/active.phtml similarity index 100% rename from app/code/core/Mage/Poll/view/frontend/active.phtml rename to app/code/Mage/Poll/view/frontend/active.phtml diff --git a/app/code/core/Mage/Poll/view/frontend/layout.xml b/app/code/Mage/Poll/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/Poll/view/frontend/layout.xml rename to app/code/Mage/Poll/view/frontend/layout.xml diff --git a/app/code/core/Mage/Poll/view/frontend/poll.js b/app/code/Mage/Poll/view/frontend/poll.js similarity index 100% rename from app/code/core/Mage/Poll/view/frontend/poll.js rename to app/code/Mage/Poll/view/frontend/poll.js diff --git a/app/code/core/Mage/Poll/view/frontend/result.phtml b/app/code/Mage/Poll/view/frontend/result.phtml similarity index 100% rename from app/code/core/Mage/Poll/view/frontend/result.phtml rename to app/code/Mage/Poll/view/frontend/result.phtml diff --git a/app/code/core/Mage/ProductAlert/Block/Email/Abstract.php b/app/code/Mage/ProductAlert/Block/Email/Abstract.php similarity index 100% rename from app/code/core/Mage/ProductAlert/Block/Email/Abstract.php rename to app/code/Mage/ProductAlert/Block/Email/Abstract.php diff --git a/app/code/core/Mage/ProductAlert/Block/Email/Price.php b/app/code/Mage/ProductAlert/Block/Email/Price.php similarity index 100% rename from app/code/core/Mage/ProductAlert/Block/Email/Price.php rename to app/code/Mage/ProductAlert/Block/Email/Price.php diff --git a/app/code/Mage/ProductAlert/Block/Email/Stock.php b/app/code/Mage/ProductAlert/Block/Email/Stock.php new file mode 100644 index 0000000000000..c1388112392a7 --- /dev/null +++ b/app/code/Mage/ProductAlert/Block/Email/Stock.php @@ -0,0 +1,84 @@ + + */ +class Mage_ProductAlert_Block_Email_Stock extends Mage_ProductAlert_Block_Email_Abstract +{ + + protected $_template = 'email/stock.phtml'; + + /** + * Product thumbnail image url getter + * + * @param Mage_Catalog_Model_Product $product + * @return string + */ + public function getThumbnailUrl($product) + { + return (string)$this->helper('Mage_Catalog_Helper_Image')->init($product, 'thumbnail') + ->resize($this->getThumbnailSize()); + } + + /** + * Thumbnail image size getter + * + * @return int + */ + public function getThumbnailSize() + { + return $this->getVar('product_thumbnail_image_size', 'Mage_Catalog'); + } + + /** + * Retrive unsubscribe url for product + * + * @param int $productId + * @return string + */ + public function getProductUnsubscribeUrl($productId) + { + $params = $this->_getUrlParams(); + $params['product'] = $productId; + return $this->getUrl('productalert/unsubscribe/stock', $params); + } + + /** + * Retrieve unsubscribe url for all products + * + * @return string + */ + public function getUnsubscribeUrl() + { + return $this->getUrl('productalert/unsubscribe/stockAll', $this->_getUrlParams()); + } +} diff --git a/app/code/core/Mage/ProductAlert/Block/Product/View.php b/app/code/Mage/ProductAlert/Block/Product/View.php similarity index 100% rename from app/code/core/Mage/ProductAlert/Block/Product/View.php rename to app/code/Mage/ProductAlert/Block/Product/View.php diff --git a/app/code/core/Mage/ProductAlert/Helper/Data.php b/app/code/Mage/ProductAlert/Helper/Data.php similarity index 100% rename from app/code/core/Mage/ProductAlert/Helper/Data.php rename to app/code/Mage/ProductAlert/Helper/Data.php diff --git a/app/code/core/Mage/ProductAlert/Model/Email.php b/app/code/Mage/ProductAlert/Model/Email.php similarity index 100% rename from app/code/core/Mage/ProductAlert/Model/Email.php rename to app/code/Mage/ProductAlert/Model/Email.php diff --git a/app/code/core/Mage/ProductAlert/Model/Observer.php b/app/code/Mage/ProductAlert/Model/Observer.php similarity index 100% rename from app/code/core/Mage/ProductAlert/Model/Observer.php rename to app/code/Mage/ProductAlert/Model/Observer.php diff --git a/app/code/core/Mage/ProductAlert/Model/Price.php b/app/code/Mage/ProductAlert/Model/Price.php similarity index 100% rename from app/code/core/Mage/ProductAlert/Model/Price.php rename to app/code/Mage/ProductAlert/Model/Price.php diff --git a/app/code/core/Mage/ProductAlert/Model/Resource/Abstract.php b/app/code/Mage/ProductAlert/Model/Resource/Abstract.php similarity index 100% rename from app/code/core/Mage/ProductAlert/Model/Resource/Abstract.php rename to app/code/Mage/ProductAlert/Model/Resource/Abstract.php diff --git a/app/code/core/Mage/ProductAlert/Model/Resource/Price.php b/app/code/Mage/ProductAlert/Model/Resource/Price.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/ProductAlert/Model/Resource/Price.php rename to app/code/Mage/ProductAlert/Model/Resource/Price.php diff --git a/app/code/core/Mage/ProductAlert/Model/Resource/Price/Collection.php b/app/code/Mage/ProductAlert/Model/Resource/Price/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/ProductAlert/Model/Resource/Price/Collection.php rename to app/code/Mage/ProductAlert/Model/Resource/Price/Collection.php diff --git a/app/code/core/Mage/ProductAlert/Model/Resource/Price/Customer/Collection.php b/app/code/Mage/ProductAlert/Model/Resource/Price/Customer/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/ProductAlert/Model/Resource/Price/Customer/Collection.php rename to app/code/Mage/ProductAlert/Model/Resource/Price/Customer/Collection.php diff --git a/app/code/core/Mage/ProductAlert/Model/Resource/Stock.php b/app/code/Mage/ProductAlert/Model/Resource/Stock.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/ProductAlert/Model/Resource/Stock.php rename to app/code/Mage/ProductAlert/Model/Resource/Stock.php diff --git a/app/code/core/Mage/ProductAlert/Model/Resource/Stock/Collection.php b/app/code/Mage/ProductAlert/Model/Resource/Stock/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/ProductAlert/Model/Resource/Stock/Collection.php rename to app/code/Mage/ProductAlert/Model/Resource/Stock/Collection.php diff --git a/app/code/core/Mage/ProductAlert/Model/Resource/Stock/Customer/Collection.php b/app/code/Mage/ProductAlert/Model/Resource/Stock/Customer/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/ProductAlert/Model/Resource/Stock/Customer/Collection.php rename to app/code/Mage/ProductAlert/Model/Resource/Stock/Customer/Collection.php diff --git a/app/code/core/Mage/ProductAlert/Model/Stock.php b/app/code/Mage/ProductAlert/Model/Stock.php similarity index 100% rename from app/code/core/Mage/ProductAlert/Model/Stock.php rename to app/code/Mage/ProductAlert/Model/Stock.php diff --git a/app/code/core/Mage/ProductAlert/controllers/AddController.php b/app/code/Mage/ProductAlert/controllers/AddController.php similarity index 100% rename from app/code/core/Mage/ProductAlert/controllers/AddController.php rename to app/code/Mage/ProductAlert/controllers/AddController.php diff --git a/app/code/core/Mage/ProductAlert/controllers/UnsubscribeController.php b/app/code/Mage/ProductAlert/controllers/UnsubscribeController.php similarity index 100% rename from app/code/core/Mage/ProductAlert/controllers/UnsubscribeController.php rename to app/code/Mage/ProductAlert/controllers/UnsubscribeController.php diff --git a/app/code/core/Mage/ProductAlert/etc/adminhtml/system.xml b/app/code/Mage/ProductAlert/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/ProductAlert/etc/adminhtml/system.xml rename to app/code/Mage/ProductAlert/etc/adminhtml/system.xml diff --git a/app/code/Mage/ProductAlert/etc/config.xml b/app/code/Mage/ProductAlert/etc/config.xml new file mode 100644 index 0000000000000..5c05fad689c4e --- /dev/null +++ b/app/code/Mage/ProductAlert/etc/config.xml @@ -0,0 +1,130 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + + Mage_ProductAlert + + + + + + + + + + + Mage_ProductAlert.csv + + + + + + + + + + + Mage_ProductAlert.csv + + + + + + + + layout.xml + + + + + + standard + + Mage_ProductAlert + productalert + + + + + + + + 0 + 0 + catalog_productalert_email_price_template + catalog_productalert_email_stock_template + general + + + + catalog_productalert_cron_error_email_template + general + + + + + + + + Mage_ProductAlert_Model_Observer::process + + + + + diff --git a/app/code/core/Mage/ProductAlert/locale/de_DE/Mage_ProductAlert.csv b/app/code/Mage/ProductAlert/locale/de_DE/Mage_ProductAlert.csv similarity index 100% rename from app/code/core/Mage/ProductAlert/locale/de_DE/Mage_ProductAlert.csv rename to app/code/Mage/ProductAlert/locale/de_DE/Mage_ProductAlert.csv diff --git a/app/code/core/Mage/ProductAlert/locale/en_US/Mage_ProductAlert.csv b/app/code/Mage/ProductAlert/locale/en_US/Mage_ProductAlert.csv similarity index 100% rename from app/code/core/Mage/ProductAlert/locale/en_US/Mage_ProductAlert.csv rename to app/code/Mage/ProductAlert/locale/en_US/Mage_ProductAlert.csv diff --git a/app/code/core/Mage/ProductAlert/locale/es_ES/Mage_ProductAlert.csv b/app/code/Mage/ProductAlert/locale/es_ES/Mage_ProductAlert.csv similarity index 100% rename from app/code/core/Mage/ProductAlert/locale/es_ES/Mage_ProductAlert.csv rename to app/code/Mage/ProductAlert/locale/es_ES/Mage_ProductAlert.csv diff --git a/app/code/core/Mage/ProductAlert/locale/fr_FR/Mage_ProductAlert.csv b/app/code/Mage/ProductAlert/locale/fr_FR/Mage_ProductAlert.csv similarity index 100% rename from app/code/core/Mage/ProductAlert/locale/fr_FR/Mage_ProductAlert.csv rename to app/code/Mage/ProductAlert/locale/fr_FR/Mage_ProductAlert.csv diff --git a/app/code/core/Mage/ProductAlert/locale/nl_NL/Mage_ProductAlert.csv b/app/code/Mage/ProductAlert/locale/nl_NL/Mage_ProductAlert.csv similarity index 100% rename from app/code/core/Mage/ProductAlert/locale/nl_NL/Mage_ProductAlert.csv rename to app/code/Mage/ProductAlert/locale/nl_NL/Mage_ProductAlert.csv diff --git a/app/code/core/Mage/ProductAlert/locale/pt_BR/Mage_ProductAlert.csv b/app/code/Mage/ProductAlert/locale/pt_BR/Mage_ProductAlert.csv similarity index 100% rename from app/code/core/Mage/ProductAlert/locale/pt_BR/Mage_ProductAlert.csv rename to app/code/Mage/ProductAlert/locale/pt_BR/Mage_ProductAlert.csv diff --git a/app/code/core/Mage/ProductAlert/locale/zh_CN/Mage_ProductAlert.csv b/app/code/Mage/ProductAlert/locale/zh_CN/Mage_ProductAlert.csv similarity index 100% rename from app/code/core/Mage/ProductAlert/locale/zh_CN/Mage_ProductAlert.csv rename to app/code/Mage/ProductAlert/locale/zh_CN/Mage_ProductAlert.csv diff --git a/app/code/core/Mage/ProductAlert/sql/productalert_setup/install-1.6.0.0.php b/app/code/Mage/ProductAlert/sql/productalert_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/ProductAlert/sql/productalert_setup/install-1.6.0.0.php rename to app/code/Mage/ProductAlert/sql/productalert_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/ProductAlert/view/email/cron_error.html b/app/code/Mage/ProductAlert/view/email/cron_error.html similarity index 100% rename from app/code/core/Mage/ProductAlert/view/email/cron_error.html rename to app/code/Mage/ProductAlert/view/email/cron_error.html diff --git a/app/code/core/Mage/ProductAlert/view/email/price_alert.html b/app/code/Mage/ProductAlert/view/email/price_alert.html similarity index 100% rename from app/code/core/Mage/ProductAlert/view/email/price_alert.html rename to app/code/Mage/ProductAlert/view/email/price_alert.html diff --git a/app/code/core/Mage/ProductAlert/view/email/stock_alert.html b/app/code/Mage/ProductAlert/view/email/stock_alert.html similarity index 100% rename from app/code/core/Mage/ProductAlert/view/email/stock_alert.html rename to app/code/Mage/ProductAlert/view/email/stock_alert.html diff --git a/app/code/core/Mage/ProductAlert/view/frontend/email/price.phtml b/app/code/Mage/ProductAlert/view/frontend/email/price.phtml similarity index 100% rename from app/code/core/Mage/ProductAlert/view/frontend/email/price.phtml rename to app/code/Mage/ProductAlert/view/frontend/email/price.phtml diff --git a/app/code/core/Mage/ProductAlert/view/frontend/email/stock.phtml b/app/code/Mage/ProductAlert/view/frontend/email/stock.phtml similarity index 100% rename from app/code/core/Mage/ProductAlert/view/frontend/email/stock.phtml rename to app/code/Mage/ProductAlert/view/frontend/email/stock.phtml diff --git a/app/code/core/Mage/ProductAlert/view/frontend/layout.xml b/app/code/Mage/ProductAlert/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/ProductAlert/view/frontend/layout.xml rename to app/code/Mage/ProductAlert/view/frontend/layout.xml diff --git a/app/code/core/Mage/ProductAlert/view/frontend/product/view.phtml b/app/code/Mage/ProductAlert/view/frontend/product/view.phtml similarity index 100% rename from app/code/core/Mage/ProductAlert/view/frontend/product/view.phtml rename to app/code/Mage/ProductAlert/view/frontend/product/view.phtml diff --git a/app/code/core/Mage/Rating/Block/Entity/Detailed.php b/app/code/Mage/Rating/Block/Entity/Detailed.php similarity index 100% rename from app/code/core/Mage/Rating/Block/Entity/Detailed.php rename to app/code/Mage/Rating/Block/Entity/Detailed.php diff --git a/app/code/core/Mage/Rating/Helper/Data.php b/app/code/Mage/Rating/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Rating/Helper/Data.php rename to app/code/Mage/Rating/Helper/Data.php diff --git a/app/code/core/Mage/Rating/Model/Observer.php b/app/code/Mage/Rating/Model/Observer.php similarity index 100% rename from app/code/core/Mage/Rating/Model/Observer.php rename to app/code/Mage/Rating/Model/Observer.php diff --git a/app/code/core/Mage/Rating/Model/Rating.php b/app/code/Mage/Rating/Model/Rating.php similarity index 100% rename from app/code/core/Mage/Rating/Model/Rating.php rename to app/code/Mage/Rating/Model/Rating.php diff --git a/app/code/core/Mage/Rating/Model/Rating/Entity.php b/app/code/Mage/Rating/Model/Rating/Entity.php similarity index 100% rename from app/code/core/Mage/Rating/Model/Rating/Entity.php rename to app/code/Mage/Rating/Model/Rating/Entity.php diff --git a/app/code/core/Mage/Rating/Model/Rating/Option.php b/app/code/Mage/Rating/Model/Rating/Option.php similarity index 100% rename from app/code/core/Mage/Rating/Model/Rating/Option.php rename to app/code/Mage/Rating/Model/Rating/Option.php diff --git a/app/code/core/Mage/Rating/Model/Rating/Option/Vote.php b/app/code/Mage/Rating/Model/Rating/Option/Vote.php similarity index 97% rename from app/code/core/Mage/Rating/Model/Rating/Option/Vote.php rename to app/code/Mage/Rating/Model/Rating/Option/Vote.php index 4020286c32b26..b2d7706e59103 100644 --- a/app/code/core/Mage/Rating/Model/Rating/Option/Vote.php +++ b/app/code/Mage/Rating/Model/Rating/Option/Vote.php @@ -34,7 +34,7 @@ class Mage_Rating_Model_Rating_Option_Vote extends Mage_Core_Model_Abstract { - public function __construct() + public function _construct() { $this->_init('Mage_Rating_Model_Resource_Rating_Option_Vote'); } diff --git a/app/code/core/Mage/Rating/Model/Resource/Rating.php b/app/code/Mage/Rating/Model/Resource/Rating.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Rating/Model/Resource/Rating.php rename to app/code/Mage/Rating/Model/Resource/Rating.php diff --git a/app/code/core/Mage/Rating/Model/Resource/Rating/Collection.php b/app/code/Mage/Rating/Model/Resource/Rating/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Rating/Model/Resource/Rating/Collection.php rename to app/code/Mage/Rating/Model/Resource/Rating/Collection.php diff --git a/app/code/core/Mage/Rating/Model/Resource/Rating/Entity.php b/app/code/Mage/Rating/Model/Resource/Rating/Entity.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Rating/Model/Resource/Rating/Entity.php rename to app/code/Mage/Rating/Model/Resource/Rating/Entity.php diff --git a/app/code/core/Mage/Rating/Model/Resource/Rating/Grid/Collection.php b/app/code/Mage/Rating/Model/Resource/Rating/Grid/Collection.php similarity index 100% rename from app/code/core/Mage/Rating/Model/Resource/Rating/Grid/Collection.php rename to app/code/Mage/Rating/Model/Resource/Rating/Grid/Collection.php diff --git a/app/code/core/Mage/Rating/Model/Resource/Rating/Grid/Statuses.php b/app/code/Mage/Rating/Model/Resource/Rating/Grid/Statuses.php similarity index 100% rename from app/code/core/Mage/Rating/Model/Resource/Rating/Grid/Statuses.php rename to app/code/Mage/Rating/Model/Resource/Rating/Grid/Statuses.php diff --git a/app/code/core/Mage/Rating/Model/Resource/Rating/Option.php b/app/code/Mage/Rating/Model/Resource/Rating/Option.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Rating/Model/Resource/Rating/Option.php rename to app/code/Mage/Rating/Model/Resource/Rating/Option.php diff --git a/app/code/core/Mage/Rating/Model/Resource/Rating/Option/Collection.php b/app/code/Mage/Rating/Model/Resource/Rating/Option/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Rating/Model/Resource/Rating/Option/Collection.php rename to app/code/Mage/Rating/Model/Resource/Rating/Option/Collection.php diff --git a/app/code/core/Mage/Rating/Model/Resource/Rating/Option/Vote.php b/app/code/Mage/Rating/Model/Resource/Rating/Option/Vote.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Rating/Model/Resource/Rating/Option/Vote.php rename to app/code/Mage/Rating/Model/Resource/Rating/Option/Vote.php diff --git a/app/code/core/Mage/Rating/Model/Resource/Rating/Option/Vote/Collection.php b/app/code/Mage/Rating/Model/Resource/Rating/Option/Vote/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Rating/Model/Resource/Rating/Option/Vote/Collection.php rename to app/code/Mage/Rating/Model/Resource/Rating/Option/Vote/Collection.php diff --git a/app/code/core/Mage/Rating/data/rating_setup/data-install-1.6.0.0.php b/app/code/Mage/Rating/data/rating_setup/data-install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Rating/data/rating_setup/data-install-1.6.0.0.php rename to app/code/Mage/Rating/data/rating_setup/data-install-1.6.0.0.php diff --git a/app/code/Mage/Rating/etc/adminhtml/acl.xml b/app/code/Mage/Rating/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..d02d46ef353cf --- /dev/null +++ b/app/code/Mage/Rating/etc/adminhtml/acl.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + diff --git a/app/code/Mage/Rating/etc/config.xml b/app/code/Mage/Rating/etc/config.xml new file mode 100644 index 0000000000000..3aa1b26d78885 --- /dev/null +++ b/app/code/Mage/Rating/etc/config.xml @@ -0,0 +1,80 @@ + + + + + + 1.6.0.1 + true + + + + + + + + + + + Mage_Rating + + + + + + + + + + Mage_Rating.csv + + + + + + + + + + + Mage_Rating.csv + + + + + + + + + Mage_Rating_Model_Observer + processProductAfterDeleteEvent + + + + + + diff --git a/app/code/core/Mage/Rating/locale/de_DE/Mage_Rating.csv b/app/code/Mage/Rating/locale/de_DE/Mage_Rating.csv similarity index 100% rename from app/code/core/Mage/Rating/locale/de_DE/Mage_Rating.csv rename to app/code/Mage/Rating/locale/de_DE/Mage_Rating.csv diff --git a/app/code/core/Mage/Rating/locale/en_US/Mage_Rating.csv b/app/code/Mage/Rating/locale/en_US/Mage_Rating.csv similarity index 100% rename from app/code/core/Mage/Rating/locale/en_US/Mage_Rating.csv rename to app/code/Mage/Rating/locale/en_US/Mage_Rating.csv diff --git a/app/code/core/Mage/Rating/locale/es_ES/Mage_Rating.csv b/app/code/Mage/Rating/locale/es_ES/Mage_Rating.csv similarity index 100% rename from app/code/core/Mage/Rating/locale/es_ES/Mage_Rating.csv rename to app/code/Mage/Rating/locale/es_ES/Mage_Rating.csv diff --git a/app/code/core/Mage/Rating/locale/fr_FR/Mage_Rating.csv b/app/code/Mage/Rating/locale/fr_FR/Mage_Rating.csv similarity index 100% rename from app/code/core/Mage/Rating/locale/fr_FR/Mage_Rating.csv rename to app/code/Mage/Rating/locale/fr_FR/Mage_Rating.csv diff --git a/app/code/core/Mage/Rating/locale/nl_NL/Mage_Rating.csv b/app/code/Mage/Rating/locale/nl_NL/Mage_Rating.csv similarity index 100% rename from app/code/core/Mage/Rating/locale/nl_NL/Mage_Rating.csv rename to app/code/Mage/Rating/locale/nl_NL/Mage_Rating.csv diff --git a/app/code/core/Mage/Rating/locale/pt_BR/Mage_Rating.csv b/app/code/Mage/Rating/locale/pt_BR/Mage_Rating.csv similarity index 100% rename from app/code/core/Mage/Rating/locale/pt_BR/Mage_Rating.csv rename to app/code/Mage/Rating/locale/pt_BR/Mage_Rating.csv diff --git a/app/code/core/Mage/Rating/locale/zh_CN/Mage_Rating.csv b/app/code/Mage/Rating/locale/zh_CN/Mage_Rating.csv similarity index 100% rename from app/code/core/Mage/Rating/locale/zh_CN/Mage_Rating.csv rename to app/code/Mage/Rating/locale/zh_CN/Mage_Rating.csv diff --git a/app/code/core/Mage/Rating/sql/rating_setup/install-1.6.0.0.php b/app/code/Mage/Rating/sql/rating_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Rating/sql/rating_setup/install-1.6.0.0.php rename to app/code/Mage/Rating/sql/rating_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Rating/sql/rating_setup/upgrade-1.6.0.0-1.6.0.1.php b/app/code/Mage/Rating/sql/rating_setup/upgrade-1.6.0.0-1.6.0.1.php similarity index 100% rename from app/code/core/Mage/Rating/sql/rating_setup/upgrade-1.6.0.0-1.6.0.1.php rename to app/code/Mage/Rating/sql/rating_setup/upgrade-1.6.0.0-1.6.0.1.php diff --git a/app/code/core/Mage/Rating/view/frontend/detailed.phtml b/app/code/Mage/Rating/view/frontend/detailed.phtml similarity index 100% rename from app/code/core/Mage/Rating/view/frontend/detailed.phtml rename to app/code/Mage/Rating/view/frontend/detailed.phtml diff --git a/app/code/core/Mage/Rating/view/frontend/empty.phtml b/app/code/Mage/Rating/view/frontend/empty.phtml similarity index 100% rename from app/code/core/Mage/Rating/view/frontend/empty.phtml rename to app/code/Mage/Rating/view/frontend/empty.phtml diff --git a/app/code/core/Mage/Reports/Block/Adminhtml/Customer/Accounts.php b/app/code/Mage/Reports/Block/Adminhtml/Customer/Accounts.php similarity index 100% rename from app/code/core/Mage/Reports/Block/Adminhtml/Customer/Accounts.php rename to app/code/Mage/Reports/Block/Adminhtml/Customer/Accounts.php diff --git a/app/code/core/Mage/Reports/Block/Adminhtml/Customer/Orders.php b/app/code/Mage/Reports/Block/Adminhtml/Customer/Orders.php similarity index 100% rename from app/code/core/Mage/Reports/Block/Adminhtml/Customer/Orders.php rename to app/code/Mage/Reports/Block/Adminhtml/Customer/Orders.php diff --git a/app/code/core/Mage/Reports/Block/Adminhtml/Customer/Totals.php b/app/code/Mage/Reports/Block/Adminhtml/Customer/Totals.php similarity index 100% rename from app/code/core/Mage/Reports/Block/Adminhtml/Customer/Totals.php rename to app/code/Mage/Reports/Block/Adminhtml/Customer/Totals.php diff --git a/app/code/core/Mage/Reports/Block/Adminhtml/Grid.php b/app/code/Mage/Reports/Block/Adminhtml/Grid.php similarity index 100% rename from app/code/core/Mage/Reports/Block/Adminhtml/Grid.php rename to app/code/Mage/Reports/Block/Adminhtml/Grid.php diff --git a/app/code/core/Mage/Reports/Block/Adminhtml/Product/Sold.php b/app/code/Mage/Reports/Block/Adminhtml/Product/Sold.php similarity index 100% rename from app/code/core/Mage/Reports/Block/Adminhtml/Product/Sold.php rename to app/code/Mage/Reports/Block/Adminhtml/Product/Sold.php diff --git a/app/code/core/Mage/Reports/Block/Adminhtml/Refresh/Statistics.php b/app/code/Mage/Reports/Block/Adminhtml/Refresh/Statistics.php similarity index 100% rename from app/code/core/Mage/Reports/Block/Adminhtml/Refresh/Statistics.php rename to app/code/Mage/Reports/Block/Adminhtml/Refresh/Statistics.php diff --git a/app/code/core/Mage/Reports/Block/Product/Abstract.php b/app/code/Mage/Reports/Block/Product/Abstract.php similarity index 100% rename from app/code/core/Mage/Reports/Block/Product/Abstract.php rename to app/code/Mage/Reports/Block/Product/Abstract.php diff --git a/app/code/core/Mage/Reports/Block/Product/Compared.php b/app/code/Mage/Reports/Block/Product/Compared.php similarity index 100% rename from app/code/core/Mage/Reports/Block/Product/Compared.php rename to app/code/Mage/Reports/Block/Product/Compared.php diff --git a/app/code/core/Mage/Reports/Block/Product/Viewed.php b/app/code/Mage/Reports/Block/Product/Viewed.php similarity index 100% rename from app/code/core/Mage/Reports/Block/Product/Viewed.php rename to app/code/Mage/Reports/Block/Product/Viewed.php diff --git a/app/code/core/Mage/Reports/Block/Product/Widget/Compared.php b/app/code/Mage/Reports/Block/Product/Widget/Compared.php similarity index 100% rename from app/code/core/Mage/Reports/Block/Product/Widget/Compared.php rename to app/code/Mage/Reports/Block/Product/Widget/Compared.php diff --git a/app/code/core/Mage/Reports/Block/Product/Widget/Viewed.php b/app/code/Mage/Reports/Block/Product/Widget/Viewed.php similarity index 100% rename from app/code/core/Mage/Reports/Block/Product/Widget/Viewed.php rename to app/code/Mage/Reports/Block/Product/Widget/Viewed.php diff --git a/app/code/core/Mage/Reports/Exception.php b/app/code/Mage/Reports/Exception.php similarity index 100% rename from app/code/core/Mage/Reports/Exception.php rename to app/code/Mage/Reports/Exception.php diff --git a/app/code/core/Mage/Reports/Helper/Data.php b/app/code/Mage/Reports/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Reports/Helper/Data.php rename to app/code/Mage/Reports/Helper/Data.php diff --git a/app/code/core/Mage/Reports/Model/Config.php b/app/code/Mage/Reports/Model/Config.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Config.php rename to app/code/Mage/Reports/Model/Config.php diff --git a/app/code/core/Mage/Reports/Model/Event.php b/app/code/Mage/Reports/Model/Event.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Event.php rename to app/code/Mage/Reports/Model/Event.php diff --git a/app/code/core/Mage/Reports/Model/Event/Observer.php b/app/code/Mage/Reports/Model/Event/Observer.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Event/Observer.php rename to app/code/Mage/Reports/Model/Event/Observer.php diff --git a/app/code/core/Mage/Reports/Model/Event/Type.php b/app/code/Mage/Reports/Model/Event/Type.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Event/Type.php rename to app/code/Mage/Reports/Model/Event/Type.php diff --git a/app/code/core/Mage/Reports/Model/Flag.php b/app/code/Mage/Reports/Model/Flag.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Flag.php rename to app/code/Mage/Reports/Model/Flag.php diff --git a/app/code/core/Mage/Reports/Model/Grouped/Collection.php b/app/code/Mage/Reports/Model/Grouped/Collection.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Grouped/Collection.php rename to app/code/Mage/Reports/Model/Grouped/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Product/Index/Abstract.php b/app/code/Mage/Reports/Model/Product/Index/Abstract.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Product/Index/Abstract.php rename to app/code/Mage/Reports/Model/Product/Index/Abstract.php diff --git a/app/code/core/Mage/Reports/Model/Product/Index/Compared.php b/app/code/Mage/Reports/Model/Product/Index/Compared.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Product/Index/Compared.php rename to app/code/Mage/Reports/Model/Product/Index/Compared.php diff --git a/app/code/core/Mage/Reports/Model/Product/Index/Viewed.php b/app/code/Mage/Reports/Model/Product/Index/Viewed.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Product/Index/Viewed.php rename to app/code/Mage/Reports/Model/Product/Index/Viewed.php diff --git a/app/code/core/Mage/Reports/Model/Report.php b/app/code/Mage/Reports/Model/Report.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Report.php rename to app/code/Mage/Reports/Model/Report.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Accounts/Collection.php b/app/code/Mage/Reports/Model/Resource/Accounts/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Accounts/Collection.php rename to app/code/Mage/Reports/Model/Resource/Accounts/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Accounts/Collection/Initial.php b/app/code/Mage/Reports/Model/Resource/Accounts/Collection/Initial.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Accounts/Collection/Initial.php rename to app/code/Mage/Reports/Model/Resource/Accounts/Collection/Initial.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Customer/Collection.php b/app/code/Mage/Reports/Model/Resource/Customer/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Customer/Collection.php rename to app/code/Mage/Reports/Model/Resource/Customer/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Customer/Orders/Collection.php b/app/code/Mage/Reports/Model/Resource/Customer/Orders/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Customer/Orders/Collection.php rename to app/code/Mage/Reports/Model/Resource/Customer/Orders/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Customer/Orders/Collection/Initial.php b/app/code/Mage/Reports/Model/Resource/Customer/Orders/Collection/Initial.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Customer/Orders/Collection/Initial.php rename to app/code/Mage/Reports/Model/Resource/Customer/Orders/Collection/Initial.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Customer/Totals/Collection.php b/app/code/Mage/Reports/Model/Resource/Customer/Totals/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Customer/Totals/Collection.php rename to app/code/Mage/Reports/Model/Resource/Customer/Totals/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Customer/Totals/Collection/Initial.php b/app/code/Mage/Reports/Model/Resource/Customer/Totals/Collection/Initial.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Customer/Totals/Collection/Initial.php rename to app/code/Mage/Reports/Model/Resource/Customer/Totals/Collection/Initial.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Entity/Summary/Collection/Abstract.php b/app/code/Mage/Reports/Model/Resource/Entity/Summary/Collection/Abstract.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Entity/Summary/Collection/Abstract.php rename to app/code/Mage/Reports/Model/Resource/Entity/Summary/Collection/Abstract.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Event.php b/app/code/Mage/Reports/Model/Resource/Event.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Event.php rename to app/code/Mage/Reports/Model/Resource/Event.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Event/Collection.php b/app/code/Mage/Reports/Model/Resource/Event/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Event/Collection.php rename to app/code/Mage/Reports/Model/Resource/Event/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Event/Type.php b/app/code/Mage/Reports/Model/Resource/Event/Type.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Event/Type.php rename to app/code/Mage/Reports/Model/Resource/Event/Type.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Event/Type/Collection.php b/app/code/Mage/Reports/Model/Resource/Event/Type/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Event/Type/Collection.php rename to app/code/Mage/Reports/Model/Resource/Event/Type/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Helper/Interface.php b/app/code/Mage/Reports/Model/Resource/Helper/Interface.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Helper/Interface.php rename to app/code/Mage/Reports/Model/Resource/Helper/Interface.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Helper/Mysql4.php b/app/code/Mage/Reports/Model/Resource/Helper/Mysql4.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Helper/Mysql4.php rename to app/code/Mage/Reports/Model/Resource/Helper/Mysql4.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Order/Collection.php b/app/code/Mage/Reports/Model/Resource/Order/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Order/Collection.php rename to app/code/Mage/Reports/Model/Resource/Order/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Product/Collection.php b/app/code/Mage/Reports/Model/Resource/Product/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Product/Collection.php rename to app/code/Mage/Reports/Model/Resource/Product/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Product/Downloads/Collection.php b/app/code/Mage/Reports/Model/Resource/Product/Downloads/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Product/Downloads/Collection.php rename to app/code/Mage/Reports/Model/Resource/Product/Downloads/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Product/Index/Abstract.php b/app/code/Mage/Reports/Model/Resource/Product/Index/Abstract.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Product/Index/Abstract.php rename to app/code/Mage/Reports/Model/Resource/Product/Index/Abstract.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Product/Index/Collection/Abstract.php b/app/code/Mage/Reports/Model/Resource/Product/Index/Collection/Abstract.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Product/Index/Collection/Abstract.php rename to app/code/Mage/Reports/Model/Resource/Product/Index/Collection/Abstract.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Product/Index/Compared.php b/app/code/Mage/Reports/Model/Resource/Product/Index/Compared.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Product/Index/Compared.php rename to app/code/Mage/Reports/Model/Resource/Product/Index/Compared.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Product/Index/Compared/Collection.php b/app/code/Mage/Reports/Model/Resource/Product/Index/Compared/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Product/Index/Compared/Collection.php rename to app/code/Mage/Reports/Model/Resource/Product/Index/Compared/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Product/Index/Viewed.php b/app/code/Mage/Reports/Model/Resource/Product/Index/Viewed.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Product/Index/Viewed.php rename to app/code/Mage/Reports/Model/Resource/Product/Index/Viewed.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Product/Index/Viewed/Collection.php b/app/code/Mage/Reports/Model/Resource/Product/Index/Viewed/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Product/Index/Viewed/Collection.php rename to app/code/Mage/Reports/Model/Resource/Product/Index/Viewed/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Product/Lowstock/Collection.php b/app/code/Mage/Reports/Model/Resource/Product/Lowstock/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Product/Lowstock/Collection.php rename to app/code/Mage/Reports/Model/Resource/Product/Lowstock/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Product/Sold/Collection.php b/app/code/Mage/Reports/Model/Resource/Product/Sold/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Product/Sold/Collection.php rename to app/code/Mage/Reports/Model/Resource/Product/Sold/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Product/Sold/Collection/Initial.php b/app/code/Mage/Reports/Model/Resource/Product/Sold/Collection/Initial.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Product/Sold/Collection/Initial.php rename to app/code/Mage/Reports/Model/Resource/Product/Sold/Collection/Initial.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Quote/Collection.php b/app/code/Mage/Reports/Model/Resource/Quote/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Quote/Collection.php rename to app/code/Mage/Reports/Model/Resource/Quote/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Refresh/Collection.php b/app/code/Mage/Reports/Model/Resource/Refresh/Collection.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Refresh/Collection.php rename to app/code/Mage/Reports/Model/Resource/Refresh/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Report/Abstract.php b/app/code/Mage/Reports/Model/Resource/Report/Abstract.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Report/Abstract.php rename to app/code/Mage/Reports/Model/Resource/Report/Abstract.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Report/Collection.php b/app/code/Mage/Reports/Model/Resource/Report/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Report/Collection.php rename to app/code/Mage/Reports/Model/Resource/Report/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Report/Collection/Abstract.php b/app/code/Mage/Reports/Model/Resource/Report/Collection/Abstract.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Report/Collection/Abstract.php rename to app/code/Mage/Reports/Model/Resource/Report/Collection/Abstract.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Report/Product/Viewed.php b/app/code/Mage/Reports/Model/Resource/Report/Product/Viewed.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Report/Product/Viewed.php rename to app/code/Mage/Reports/Model/Resource/Report/Product/Viewed.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Report/Product/Viewed/Collection.php b/app/code/Mage/Reports/Model/Resource/Report/Product/Viewed/Collection.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Report/Product/Viewed/Collection.php rename to app/code/Mage/Reports/Model/Resource/Report/Product/Viewed/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Review/Collection.php b/app/code/Mage/Reports/Model/Resource/Review/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Review/Collection.php rename to app/code/Mage/Reports/Model/Resource/Review/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Review/Customer/Collection.php b/app/code/Mage/Reports/Model/Resource/Review/Customer/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Review/Customer/Collection.php rename to app/code/Mage/Reports/Model/Resource/Review/Customer/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Review/Product/Collection.php b/app/code/Mage/Reports/Model/Resource/Review/Product/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Review/Product/Collection.php rename to app/code/Mage/Reports/Model/Resource/Review/Product/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Shopcart/Product/Collection.php b/app/code/Mage/Reports/Model/Resource/Shopcart/Product/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Shopcart/Product/Collection.php rename to app/code/Mage/Reports/Model/Resource/Shopcart/Product/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Wishlist/Collection.php b/app/code/Mage/Reports/Model/Resource/Wishlist/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Wishlist/Collection.php rename to app/code/Mage/Reports/Model/Resource/Wishlist/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Resource/Wishlist/Product/Collection.php b/app/code/Mage/Reports/Model/Resource/Wishlist/Product/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Reports/Model/Resource/Wishlist/Product/Collection.php rename to app/code/Mage/Reports/Model/Resource/Wishlist/Product/Collection.php diff --git a/app/code/core/Mage/Reports/Model/Session.php b/app/code/Mage/Reports/Model/Session.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Session.php rename to app/code/Mage/Reports/Model/Session.php diff --git a/app/code/core/Mage/Reports/Model/Test.php b/app/code/Mage/Reports/Model/Test.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Test.php rename to app/code/Mage/Reports/Model/Test.php diff --git a/app/code/core/Mage/Reports/Model/Totals.php b/app/code/Mage/Reports/Model/Totals.php similarity index 100% rename from app/code/core/Mage/Reports/Model/Totals.php rename to app/code/Mage/Reports/Model/Totals.php diff --git a/app/code/core/Mage/Reports/data/reports_setup/data-install-1.6.0.0.php b/app/code/Mage/Reports/data/reports_setup/data-install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Reports/data/reports_setup/data-install-1.6.0.0.php rename to app/code/Mage/Reports/data/reports_setup/data-install-1.6.0.0.php diff --git a/app/code/Mage/Reports/etc/adminhtml/acl.xml b/app/code/Mage/Reports/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..0ceb4e2725159 --- /dev/null +++ b/app/code/Mage/Reports/etc/adminhtml/acl.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Mage/Reports/etc/adminhtml/menu.xml b/app/code/Mage/Reports/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..77e300c1e93e3 --- /dev/null +++ b/app/code/Mage/Reports/etc/adminhtml/menu.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/core/Mage/Reports/etc/adminhtml/system.xml b/app/code/Mage/Reports/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Reports/etc/adminhtml/system.xml rename to app/code/Mage/Reports/etc/adminhtml/system.xml diff --git a/app/code/Mage/Reports/etc/config.xml b/app/code/Mage/Reports/etc/config.xml new file mode 100644 index 0000000000000..26816c62d23f8 --- /dev/null +++ b/app/code/Mage/Reports/etc/config.xml @@ -0,0 +1,193 @@ + + + + + + 1.6.0.0.2 + true + + + + + + + + + + + + + Mage_Reports + + + + + + + + Mage_Reports_Model_Event_Observer + eventClean + + + + + + + + + + layout.xml + + + + + + + + Mage_Reports.csv + + + + + + + + + + + Mage_Reports.csv + + + + + + + + layout.xml + + + + + + + + Mage_Reports_Model_Event_Observer + catalogProductCompareRemoveProduct + + + + + + + Mage_Reports_Model_Event_Observer + customerLogin + + + + + + + Mage_Reports_Model_Event_Observer + customerLogout + + + + + + + Mage_Reports_Model_Event_Observer + catalogProductView + + + + + + + Mage_Reports_Model_Event_Observer + sendfriendProduct + + + + + + + Mage_Reports_Model_Event_Observer + catalogProductCompareAddProduct + + + + + + + Mage_Reports_Model_Event_Observer + catalogProductCompareClear + + + + + + + Mage_Reports_Model_Event_Observer + checkoutCartAddProduct + + + + + + + Mage_Reports_Model_Event_Observer + wishlistAddProduct + + + + + + + Mage_Reports_Model_Event_Observer + wishlistShare + + + + + + + + + website + 5 + 5 + + + + + 1,1 + 1 + + + + diff --git a/app/code/core/Mage/Reports/etc/widget.xml b/app/code/Mage/Reports/etc/widget.xml similarity index 100% rename from app/code/core/Mage/Reports/etc/widget.xml rename to app/code/Mage/Reports/etc/widget.xml diff --git a/app/code/core/Mage/Reports/locale/de_DE/Mage_Reports.csv b/app/code/Mage/Reports/locale/de_DE/Mage_Reports.csv similarity index 100% rename from app/code/core/Mage/Reports/locale/de_DE/Mage_Reports.csv rename to app/code/Mage/Reports/locale/de_DE/Mage_Reports.csv diff --git a/app/code/core/Mage/Reports/locale/en_US/Mage_Reports.csv b/app/code/Mage/Reports/locale/en_US/Mage_Reports.csv similarity index 100% rename from app/code/core/Mage/Reports/locale/en_US/Mage_Reports.csv rename to app/code/Mage/Reports/locale/en_US/Mage_Reports.csv diff --git a/app/code/core/Mage/Reports/locale/es_ES/Mage_Reports.csv b/app/code/Mage/Reports/locale/es_ES/Mage_Reports.csv similarity index 100% rename from app/code/core/Mage/Reports/locale/es_ES/Mage_Reports.csv rename to app/code/Mage/Reports/locale/es_ES/Mage_Reports.csv diff --git a/app/code/core/Mage/Reports/locale/fr_FR/Mage_Reports.csv b/app/code/Mage/Reports/locale/fr_FR/Mage_Reports.csv similarity index 100% rename from app/code/core/Mage/Reports/locale/fr_FR/Mage_Reports.csv rename to app/code/Mage/Reports/locale/fr_FR/Mage_Reports.csv diff --git a/app/code/core/Mage/Reports/locale/nl_NL/Mage_Reports.csv b/app/code/Mage/Reports/locale/nl_NL/Mage_Reports.csv similarity index 100% rename from app/code/core/Mage/Reports/locale/nl_NL/Mage_Reports.csv rename to app/code/Mage/Reports/locale/nl_NL/Mage_Reports.csv diff --git a/app/code/core/Mage/Reports/locale/pt_BR/Mage_Reports.csv b/app/code/Mage/Reports/locale/pt_BR/Mage_Reports.csv similarity index 100% rename from app/code/core/Mage/Reports/locale/pt_BR/Mage_Reports.csv rename to app/code/Mage/Reports/locale/pt_BR/Mage_Reports.csv diff --git a/app/code/core/Mage/Reports/locale/zh_CN/Mage_Reports.csv b/app/code/Mage/Reports/locale/zh_CN/Mage_Reports.csv similarity index 100% rename from app/code/core/Mage/Reports/locale/zh_CN/Mage_Reports.csv rename to app/code/Mage/Reports/locale/zh_CN/Mage_Reports.csv diff --git a/app/code/core/Mage/Reports/sql/reports_setup/install-1.6.0.0.php b/app/code/Mage/Reports/sql/reports_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Reports/sql/reports_setup/install-1.6.0.0.php rename to app/code/Mage/Reports/sql/reports_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Reports/sql/reports_setup/mysql4-install-1.6.0.0.php b/app/code/Mage/Reports/sql/reports_setup/mysql4-install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Reports/sql/reports_setup/mysql4-install-1.6.0.0.php rename to app/code/Mage/Reports/sql/reports_setup/mysql4-install-1.6.0.0.php diff --git a/app/code/core/Mage/Reports/sql/reports_setup/upgrade-1.6.0.0-1.6.0.0.1.php b/app/code/Mage/Reports/sql/reports_setup/upgrade-1.6.0.0-1.6.0.0.1.php similarity index 100% rename from app/code/core/Mage/Reports/sql/reports_setup/upgrade-1.6.0.0-1.6.0.0.1.php rename to app/code/Mage/Reports/sql/reports_setup/upgrade-1.6.0.0-1.6.0.0.1.php diff --git a/app/code/core/Mage/Reports/sql/reports_setup/upgrade-1.6.0.0.1-1.6.0.0.2.php b/app/code/Mage/Reports/sql/reports_setup/upgrade-1.6.0.0.1-1.6.0.0.2.php similarity index 100% rename from app/code/core/Mage/Reports/sql/reports_setup/upgrade-1.6.0.0.1-1.6.0.0.2.php rename to app/code/Mage/Reports/sql/reports_setup/upgrade-1.6.0.0.1-1.6.0.0.2.php diff --git a/app/code/Mage/Reports/view/adminhtml/grid.phtml b/app/code/Mage/Reports/view/adminhtml/grid.phtml new file mode 100644 index 0000000000000..8389a7c13fc62 --- /dev/null +++ b/app/code/Mage/Reports/view/adminhtml/grid.phtml @@ -0,0 +1,154 @@ + +getColumns()); +?> +getCollection()): ?> +canDisplayContainer()): ?> +
    + + getMessagesBlock()->getGroupedHtml() ?> + +getStoreSwitcherVisibility() || $this->getDateFilterVisibility()): ?> + getStoreSwitcherVisibility()): ?> + getStoreSwitcherHtml() ?> + +
    + getChildBlock('grid.export')): ?> +
    + getChildHtml('grid.export');?> +
    + + + getDateFilterVisibility()): ?> +
    +
    + + +
    +
    + +
    + + +
    +
    + +
    + __('Show By') ?>: + + getRefreshButtonHtml() ?> +
    + +
    + +
    + +
    +
    + + + getChildHtml('grid.columnSet'); ?> +
    +
    +
    +
    +canDisplayContainer()): ?> + + + \ No newline at end of file diff --git a/app/code/core/Mage/Reports/view/adminhtml/images/product_widget_compared.gif b/app/code/Mage/Reports/view/adminhtml/images/product_widget_compared.gif similarity index 100% rename from app/code/core/Mage/Reports/view/adminhtml/images/product_widget_compared.gif rename to app/code/Mage/Reports/view/adminhtml/images/product_widget_compared.gif diff --git a/app/code/core/Mage/Reports/view/adminhtml/images/product_widget_viewed.gif b/app/code/Mage/Reports/view/adminhtml/images/product_widget_viewed.gif similarity index 100% rename from app/code/core/Mage/Reports/view/adminhtml/images/product_widget_viewed.gif rename to app/code/Mage/Reports/view/adminhtml/images/product_widget_viewed.gif diff --git a/app/code/Mage/Reports/view/adminhtml/layout.xml b/app/code/Mage/Reports/view/adminhtml/layout.xml new file mode 100644 index 0000000000000..1bf07a0b8c35f --- /dev/null +++ b/app/code/Mage/Reports/view/adminhtml/layout.xml @@ -0,0 +1,635 @@ + + + + + + + + 0 + 0 + gridReport + Mage_Reports_Model_Resource_Report_Collection + + + + 0 + + */*/* + + null + + + + + + + + + */*/exportCsv + + + + */*/exportExcel + + + + + + + + 0 + No records found for this period. + No records found for this period. + + + +
    Period
    + 0 + text + period + period + 1 + Total + col-period + col-period +
    +
    +
    +
    +
    +
    + + + + + + gridOrdersCustomer + Mage_Reports_Model_Resource_Customer_Orders_Collection_Initial + + + + + + + */*/exportOrdersCsv + + + */*/exportOrdersExcel + + + + + + + 1 + + + +
    Customer Name
    + 0 + text + name + name + col-name + col-name +
    +
    + + +
    Number of Orders
    + 0 + number + orders_count + sum + orders_count + col-qty + col-qty +
    +
    + + +
    Average Order Amount
    + 0 + currency + orders_sum_amount/orders_count + orders_avg_amount + orders_avg_amount + col-average + col-average +
    +
    + + +
    Total Order Amount
    + 0 + currency + sum + orders_sum_amount + orders_sum_amount + col-total + col-total +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + gridProductsSold + Mage_Reports_Model_Resource_Product_Sold_Collection_Initial + + + + + + + */*/exportSoldCsv + + + */*/exportSoldExcel + + + + + + + report_product_sold + 1 + + + +
    Product Name
    + text + order_items_name + name + col-product + col-product +
    +
    + + +
    Quantity Ordered
    + sum + number + ordered_qty + ordered_qty + sum + col-qty + col-qty +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + gridTotalsCustomer + Mage_Reports_Model_Resource_Customer_Totals_Collection_Initial + + + + + + + */*/exportTotalsCsv + + + */*/exportTotalsExcel + + + + + + + 1 + gridTotalsCustomerSet + + + + + + + + + + + + + + + + + + + + + + + + + + gridAccounts + Mage_Reports_Model_Resource_Accounts_Collection_Initial + + + + + + + */*/exportAccountsCsv + + + */*/exportAccountsExcel + + + + + + + gridAccounts + 1 + + + +
    Number of New Accounts
    + accounts + sum + number + accounts + col-qty + col-qty +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + customers_grid + review_cnt + desc + Mage_Reports_Model_Resource_Review_Customer_Collection + + + + + + */*/exportCustomerCsv + + + + */*/exportCustomerExcel + + + + + + + + 0 + customers_grid + + */catalog_product_review + + getCustomerId + + + + + +
    Customer Name
    + customer_name + text + customer_name + Guest + col-name + col-name +
    +
    + + +
    Number Of Reviews
    + text + review_cnt + col-qty + col-qty +
    +
    + + +
    Action
    + 0 + 0 + 1 + Mage_Adminhtml_Block_Report_Grid_Column_Renderer_Customer + action + col-actions + col-actions +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + gridProducts + review_cnt + desc + Mage_Reports_Model_Resource_Review_Product_Collection + + + + + + */*/exportProductCsv + + + + */*/exportProductExcel + + + + + + + + 0 + gridProducts + + */catalog_product_review + + getrId + + + + + +
    ID
    + entity_id + text + entity_id + col-id + col-id +
    +
    + + +
    Product Name
    + text + name + col-product + col-product +
    +
    + + +
    Number of Reviews
    + review_cnt + review_cnt + col-qty + col-qty +
    +
    + + +
    Avg. Rating
    + avg_rating + avg_rating + col-rating + col-rating +
    +
    + + +
    Avg. Approved Rating
    + avg_rating_approved + avg_rating_approved + col-avg-rating + col-avg-rating +
    +
    + + +
    Last Review
    + datetime + last_created + last_created + col-date + col-date +
    +
    + + +
    Action
    + center + 0 + 0 + Mage_Adminhtml_Block_Report_Grid_Column_Renderer_Product + action + 1 + col-actions + col-actions +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + gridRefreshStatistics + 0 + 0 + 0 + Mage_Reports_Model_Resource_Refresh_Collection + + + + id + code + 1 + + + + */*/refreshLifetime + Are you sure you want to refresh lifetime statistics? There can be performance impact during this operation. + + + + */*/refreshRecent + Are you sure you want to refresh statistics for last day? + 1 + + + + + + + 0 + gridRefreshStatistics + + + +
    Report
    + string + 0 + report + report + col-report + col-report +
    +
    + + +
    Description
    + string + 0 + comment + comment + col-description + col-description +
    +
    + + +
    Updated At
    + datetime + 0 + updated_at + updated_at + undefined + col-period + col-period +
    +
    +
    +
    +
    +
    +
    +
    diff --git a/app/code/core/Mage/Reports/view/adminhtml/store/switcher.phtml b/app/code/Mage/Reports/view/adminhtml/store/switcher.phtml similarity index 100% rename from app/code/core/Mage/Reports/view/adminhtml/store/switcher.phtml rename to app/code/Mage/Reports/view/adminhtml/store/switcher.phtml diff --git a/app/code/core/Mage/Reports/view/adminhtml/store/switcher/enhanced.phtml b/app/code/Mage/Reports/view/adminhtml/store/switcher/enhanced.phtml similarity index 98% rename from app/code/core/Mage/Reports/view/adminhtml/store/switcher/enhanced.phtml rename to app/code/Mage/Reports/view/adminhtml/store/switcher/enhanced.phtml index 311ac05a02996..8ce8950141cc8 100644 --- a/app/code/core/Mage/Reports/view/adminhtml/store/switcher/enhanced.phtml +++ b/app/code/Mage/Reports/view/adminhtml/store/switcher/enhanced.phtml @@ -28,6 +28,10 @@ /** * @see Mage_Backend_Block_Store_Switcher */ + +/** + * @var $this Mage_Backend_Block_Store_Switcher + */ ?> isShow()): ?> diff --git a/app/code/core/Mage/Reports/view/frontend/home_product_compared.phtml b/app/code/Mage/Reports/view/frontend/home_product_compared.phtml similarity index 100% rename from app/code/core/Mage/Reports/view/frontend/home_product_compared.phtml rename to app/code/Mage/Reports/view/frontend/home_product_compared.phtml diff --git a/app/code/core/Mage/Reports/view/frontend/home_product_viewed.phtml b/app/code/Mage/Reports/view/frontend/home_product_viewed.phtml similarity index 100% rename from app/code/core/Mage/Reports/view/frontend/home_product_viewed.phtml rename to app/code/Mage/Reports/view/frontend/home_product_viewed.phtml diff --git a/app/code/core/Mage/Reports/view/frontend/layout.xml b/app/code/Mage/Reports/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/Reports/view/frontend/layout.xml rename to app/code/Mage/Reports/view/frontend/layout.xml diff --git a/app/code/core/Mage/Reports/view/frontend/product_compared.phtml b/app/code/Mage/Reports/view/frontend/product_compared.phtml similarity index 100% rename from app/code/core/Mage/Reports/view/frontend/product_compared.phtml rename to app/code/Mage/Reports/view/frontend/product_compared.phtml diff --git a/app/code/core/Mage/Reports/view/frontend/product_viewed.phtml b/app/code/Mage/Reports/view/frontend/product_viewed.phtml similarity index 100% rename from app/code/core/Mage/Reports/view/frontend/product_viewed.phtml rename to app/code/Mage/Reports/view/frontend/product_viewed.phtml diff --git a/app/code/core/Mage/Reports/view/frontend/widget/compared/column/compared_default_list.phtml b/app/code/Mage/Reports/view/frontend/widget/compared/column/compared_default_list.phtml similarity index 100% rename from app/code/core/Mage/Reports/view/frontend/widget/compared/column/compared_default_list.phtml rename to app/code/Mage/Reports/view/frontend/widget/compared/column/compared_default_list.phtml diff --git a/app/code/core/Mage/Reports/view/frontend/widget/compared/column/compared_images_list.phtml b/app/code/Mage/Reports/view/frontend/widget/compared/column/compared_images_list.phtml similarity index 100% rename from app/code/core/Mage/Reports/view/frontend/widget/compared/column/compared_images_list.phtml rename to app/code/Mage/Reports/view/frontend/widget/compared/column/compared_images_list.phtml diff --git a/app/code/core/Mage/Reports/view/frontend/widget/compared/column/compared_names_list.phtml b/app/code/Mage/Reports/view/frontend/widget/compared/column/compared_names_list.phtml similarity index 100% rename from app/code/core/Mage/Reports/view/frontend/widget/compared/column/compared_names_list.phtml rename to app/code/Mage/Reports/view/frontend/widget/compared/column/compared_names_list.phtml diff --git a/app/code/core/Mage/Reports/view/frontend/widget/compared/content/compared_grid.phtml b/app/code/Mage/Reports/view/frontend/widget/compared/content/compared_grid.phtml similarity index 100% rename from app/code/core/Mage/Reports/view/frontend/widget/compared/content/compared_grid.phtml rename to app/code/Mage/Reports/view/frontend/widget/compared/content/compared_grid.phtml diff --git a/app/code/core/Mage/Reports/view/frontend/widget/compared/content/compared_list.phtml b/app/code/Mage/Reports/view/frontend/widget/compared/content/compared_list.phtml similarity index 100% rename from app/code/core/Mage/Reports/view/frontend/widget/compared/content/compared_list.phtml rename to app/code/Mage/Reports/view/frontend/widget/compared/content/compared_list.phtml diff --git a/app/code/core/Mage/Reports/view/frontend/widget/viewed/column/viewed_default_list.phtml b/app/code/Mage/Reports/view/frontend/widget/viewed/column/viewed_default_list.phtml similarity index 100% rename from app/code/core/Mage/Reports/view/frontend/widget/viewed/column/viewed_default_list.phtml rename to app/code/Mage/Reports/view/frontend/widget/viewed/column/viewed_default_list.phtml diff --git a/app/code/core/Mage/Reports/view/frontend/widget/viewed/column/viewed_images_list.phtml b/app/code/Mage/Reports/view/frontend/widget/viewed/column/viewed_images_list.phtml similarity index 100% rename from app/code/core/Mage/Reports/view/frontend/widget/viewed/column/viewed_images_list.phtml rename to app/code/Mage/Reports/view/frontend/widget/viewed/column/viewed_images_list.phtml diff --git a/app/code/core/Mage/Reports/view/frontend/widget/viewed/column/viewed_names_list.phtml b/app/code/Mage/Reports/view/frontend/widget/viewed/column/viewed_names_list.phtml similarity index 100% rename from app/code/core/Mage/Reports/view/frontend/widget/viewed/column/viewed_names_list.phtml rename to app/code/Mage/Reports/view/frontend/widget/viewed/column/viewed_names_list.phtml diff --git a/app/code/core/Mage/Reports/view/frontend/widget/viewed/content/viewed_grid.phtml b/app/code/Mage/Reports/view/frontend/widget/viewed/content/viewed_grid.phtml similarity index 100% rename from app/code/core/Mage/Reports/view/frontend/widget/viewed/content/viewed_grid.phtml rename to app/code/Mage/Reports/view/frontend/widget/viewed/content/viewed_grid.phtml diff --git a/app/code/core/Mage/Reports/view/frontend/widget/viewed/content/viewed_list.phtml b/app/code/Mage/Reports/view/frontend/widget/viewed/content/viewed_list.phtml similarity index 100% rename from app/code/core/Mage/Reports/view/frontend/widget/viewed/content/viewed_list.phtml rename to app/code/Mage/Reports/view/frontend/widget/viewed/content/viewed_list.phtml diff --git a/app/code/core/Mage/Reports/view/frontend/widgets.css b/app/code/Mage/Reports/view/frontend/widgets.css similarity index 100% rename from app/code/core/Mage/Reports/view/frontend/widgets.css rename to app/code/Mage/Reports/view/frontend/widgets.css diff --git a/app/code/core/Mage/Review/Block/Customer/List.php b/app/code/Mage/Review/Block/Customer/List.php similarity index 100% rename from app/code/core/Mage/Review/Block/Customer/List.php rename to app/code/Mage/Review/Block/Customer/List.php diff --git a/app/code/core/Mage/Review/Block/Customer/Recent.php b/app/code/Mage/Review/Block/Customer/Recent.php similarity index 100% rename from app/code/core/Mage/Review/Block/Customer/Recent.php rename to app/code/Mage/Review/Block/Customer/Recent.php diff --git a/app/code/core/Mage/Review/Block/Customer/View.php b/app/code/Mage/Review/Block/Customer/View.php similarity index 100% rename from app/code/core/Mage/Review/Block/Customer/View.php rename to app/code/Mage/Review/Block/Customer/View.php diff --git a/app/code/core/Mage/Review/Block/Form.php b/app/code/Mage/Review/Block/Form.php similarity index 100% rename from app/code/core/Mage/Review/Block/Form.php rename to app/code/Mage/Review/Block/Form.php diff --git a/app/code/core/Mage/Review/Block/Helper.php b/app/code/Mage/Review/Block/Helper.php similarity index 100% rename from app/code/core/Mage/Review/Block/Helper.php rename to app/code/Mage/Review/Block/Helper.php diff --git a/app/code/core/Mage/Review/Block/Product/View.php b/app/code/Mage/Review/Block/Product/View.php similarity index 100% rename from app/code/core/Mage/Review/Block/Product/View.php rename to app/code/Mage/Review/Block/Product/View.php diff --git a/app/code/core/Mage/Review/Block/Product/View/List.php b/app/code/Mage/Review/Block/Product/View/List.php similarity index 100% rename from app/code/core/Mage/Review/Block/Product/View/List.php rename to app/code/Mage/Review/Block/Product/View/List.php diff --git a/app/code/core/Mage/Review/Block/View.php b/app/code/Mage/Review/Block/View.php similarity index 100% rename from app/code/core/Mage/Review/Block/View.php rename to app/code/Mage/Review/Block/View.php diff --git a/app/code/core/Mage/Review/Helper/Action/Pager.php b/app/code/Mage/Review/Helper/Action/Pager.php similarity index 100% rename from app/code/core/Mage/Review/Helper/Action/Pager.php rename to app/code/Mage/Review/Helper/Action/Pager.php diff --git a/app/code/core/Mage/Review/Helper/Data.php b/app/code/Mage/Review/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Review/Helper/Data.php rename to app/code/Mage/Review/Helper/Data.php diff --git a/app/code/core/Mage/Review/Model/Observer.php b/app/code/Mage/Review/Model/Observer.php similarity index 100% rename from app/code/core/Mage/Review/Model/Observer.php rename to app/code/Mage/Review/Model/Observer.php diff --git a/app/code/core/Mage/Review/Model/Resource/Review.php b/app/code/Mage/Review/Model/Resource/Review.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Review/Model/Resource/Review.php rename to app/code/Mage/Review/Model/Resource/Review.php diff --git a/app/code/core/Mage/Review/Model/Resource/Review/Collection.php b/app/code/Mage/Review/Model/Resource/Review/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Review/Model/Resource/Review/Collection.php rename to app/code/Mage/Review/Model/Resource/Review/Collection.php diff --git a/app/code/core/Mage/Review/Model/Resource/Review/Product/Collection.php b/app/code/Mage/Review/Model/Resource/Review/Product/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Review/Model/Resource/Review/Product/Collection.php rename to app/code/Mage/Review/Model/Resource/Review/Product/Collection.php diff --git a/app/code/core/Mage/Review/Model/Resource/Review/Status.php b/app/code/Mage/Review/Model/Resource/Review/Status.php similarity index 100% rename from app/code/core/Mage/Review/Model/Resource/Review/Status.php rename to app/code/Mage/Review/Model/Resource/Review/Status.php diff --git a/app/code/core/Mage/Review/Model/Resource/Review/Status/Collection.php b/app/code/Mage/Review/Model/Resource/Review/Status/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Review/Model/Resource/Review/Status/Collection.php rename to app/code/Mage/Review/Model/Resource/Review/Status/Collection.php diff --git a/app/code/core/Mage/Review/Model/Resource/Review/Summary.php b/app/code/Mage/Review/Model/Resource/Review/Summary.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Review/Model/Resource/Review/Summary.php rename to app/code/Mage/Review/Model/Resource/Review/Summary.php diff --git a/app/code/core/Mage/Review/Model/Resource/Review/Summary/Collection.php b/app/code/Mage/Review/Model/Resource/Review/Summary/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Review/Model/Resource/Review/Summary/Collection.php rename to app/code/Mage/Review/Model/Resource/Review/Summary/Collection.php diff --git a/app/code/core/Mage/Review/Model/Review.php b/app/code/Mage/Review/Model/Review.php similarity index 100% rename from app/code/core/Mage/Review/Model/Review.php rename to app/code/Mage/Review/Model/Review.php diff --git a/app/code/core/Mage/Review/Model/Review/Status.php b/app/code/Mage/Review/Model/Review/Status.php similarity index 100% rename from app/code/core/Mage/Review/Model/Review/Status.php rename to app/code/Mage/Review/Model/Review/Status.php diff --git a/app/code/core/Mage/Review/Model/Review/Summary.php b/app/code/Mage/Review/Model/Review/Summary.php similarity index 82% rename from app/code/core/Mage/Review/Model/Review/Summary.php rename to app/code/Mage/Review/Model/Review/Summary.php index 79705a7ce756f..e10f4e63f30b9 100644 --- a/app/code/core/Mage/Review/Model/Review/Summary.php +++ b/app/code/Mage/Review/Model/Review/Summary.php @@ -35,20 +35,18 @@ class Mage_Review_Model_Review_Summary extends Mage_Core_Model_Abstract { /** - * @param Mage_Core_Model_Event_Manager $eventDispatcher - * @param Mage_Core_Model_Cache $cacheManager + * @param Mage_Core_Model_Context $context * @param Mage_Review_Model_Resource_Review_Summary $resource - * @param Mage_Review_Model_Resource_Review_Summary $resourceCollection + * @param Mage_Review_Model_Resource_Review_Summary_Collection $resourceCollection * @param array $data */ public function __construct( - Mage_Core_Model_Event_Manager $eventDispatcher, - Mage_Core_Model_Cache $cacheManager, + Mage_Core_Model_Context $context, Mage_Review_Model_Resource_Review_Summary $resource, Mage_Review_Model_Resource_Review_Summary_Collection $resourceCollection, array $data = array() ) { - parent::__construct($eventDispatcher, $cacheManager, $resource, $resourceCollection, $data); + parent::__construct($context, $resource, $resourceCollection, $data); } public function getEntityPkValue() diff --git a/app/code/core/Mage/Review/Model/Session.php b/app/code/Mage/Review/Model/Session.php similarity index 100% rename from app/code/core/Mage/Review/Model/Session.php rename to app/code/Mage/Review/Model/Session.php diff --git a/app/code/Mage/Review/Service/Product.php b/app/code/Mage/Review/Service/Product.php new file mode 100644 index 0000000000000..98710477b2905 --- /dev/null +++ b/app/code/Mage/Review/Service/Product.php @@ -0,0 +1,71 @@ + + */ + +class Mage_Review_Service_Product +{ + protected $_product; + + protected $_storageManager; + + protected $_objectManager; + + protected $_review; + + public function __construct(Magento_ObjectManager $objectManager, Mage_Review_Model_Review $review, + Mage_Core_Model_StoreManager $storeManager) + { + $this->_objectManager = $objectManager; + $this->_review = $review; + $this->_storageManager = $storeManager; + } + + public function getDictionary($productId) + { + $this->_product = $this->_objectManager->create('Mage_Catalog_Model_Product'); + $this->_product->load($productId); + $this->_review->getEntitySummary($this->_product, $this->_storageManager->getStore()->getId()); + + $dictionary = array( + 'ratingSummary' => $this->_product->getRatingSummary() + ->getRatingSummary(), + 'reviewsCount' => $this->_product->getRatingSummary()->getReviewsCount(), + 'reviewsUrl' => Mage::getUrl('review/product/list', + array( + 'id' => $this->_product->getId(), + 'category' => $this->_product->getCategoryId() + )) + ); + return $dictionary; + } +} \ No newline at end of file diff --git a/app/code/core/Mage/Review/controllers/CustomerController.php b/app/code/Mage/Review/controllers/CustomerController.php similarity index 100% rename from app/code/core/Mage/Review/controllers/CustomerController.php rename to app/code/Mage/Review/controllers/CustomerController.php diff --git a/app/code/core/Mage/Review/controllers/ProductController.php b/app/code/Mage/Review/controllers/ProductController.php similarity index 100% rename from app/code/core/Mage/Review/controllers/ProductController.php rename to app/code/Mage/Review/controllers/ProductController.php diff --git a/app/code/core/Mage/Review/data/review_setup/data-install-1.6.0.0.php b/app/code/Mage/Review/data/review_setup/data-install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Review/data/review_setup/data-install-1.6.0.0.php rename to app/code/Mage/Review/data/review_setup/data-install-1.6.0.0.php diff --git a/app/code/Mage/Review/etc/adminhtml/acl.xml b/app/code/Mage/Review/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..b515b1a9ca238 --- /dev/null +++ b/app/code/Mage/Review/etc/adminhtml/acl.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + diff --git a/app/code/Mage/Review/etc/adminhtml/menu.xml b/app/code/Mage/Review/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..a3a3ebb355f93 --- /dev/null +++ b/app/code/Mage/Review/etc/adminhtml/menu.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + diff --git a/app/code/core/Mage/Review/etc/adminhtml/system.xml b/app/code/Mage/Review/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Review/etc/adminhtml/system.xml rename to app/code/Mage/Review/etc/adminhtml/system.xml diff --git a/app/code/Mage/Review/etc/config.xml b/app/code/Mage/Review/etc/config.xml new file mode 100644 index 0000000000000..d590e127703f0 --- /dev/null +++ b/app/code/Mage/Review/etc/config.xml @@ -0,0 +1,131 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + + Mage_Review + + + + + + Mage_Review/service-calls.xml + + + + + + + + + Mage_Review.csv + + + + + + + + + Mage_Review_Model_Observer + processProductAfterDeleteEvent + + + + + + + + + standard + + Mage_Review + review + + + + + + + + Mage_Review.csv + + + + + + + + layout.xml + + + + + + + + model + Mage_Review_Model_Observer + tagProductCollectionLoadAfter + + + + + + + model + Mage_Review_Model_Observer + catalogBlockProductCollectionBeforeToHtml + + + + + + /review/customer/ + + + + + + 1 + + + + diff --git a/app/code/Mage/Review/etc/service-calls.xml b/app/code/Mage/Review/etc/service-calls.xml new file mode 100644 index 0000000000000..e7fb003e91906 --- /dev/null +++ b/app/code/Mage/Review/etc/service-calls.xml @@ -0,0 +1,30 @@ + + + + + {{request.params.id}} + + \ No newline at end of file diff --git a/app/code/core/Mage/Review/locale/de_DE/Mage_Review.csv b/app/code/Mage/Review/locale/de_DE/Mage_Review.csv similarity index 100% rename from app/code/core/Mage/Review/locale/de_DE/Mage_Review.csv rename to app/code/Mage/Review/locale/de_DE/Mage_Review.csv diff --git a/app/code/core/Mage/Review/locale/en_US/Mage_Review.csv b/app/code/Mage/Review/locale/en_US/Mage_Review.csv similarity index 100% rename from app/code/core/Mage/Review/locale/en_US/Mage_Review.csv rename to app/code/Mage/Review/locale/en_US/Mage_Review.csv diff --git a/app/code/core/Mage/Review/locale/es_ES/Mage_Review.csv b/app/code/Mage/Review/locale/es_ES/Mage_Review.csv similarity index 100% rename from app/code/core/Mage/Review/locale/es_ES/Mage_Review.csv rename to app/code/Mage/Review/locale/es_ES/Mage_Review.csv diff --git a/app/code/core/Mage/Review/locale/fr_FR/Mage_Review.csv b/app/code/Mage/Review/locale/fr_FR/Mage_Review.csv similarity index 100% rename from app/code/core/Mage/Review/locale/fr_FR/Mage_Review.csv rename to app/code/Mage/Review/locale/fr_FR/Mage_Review.csv diff --git a/app/code/core/Mage/Review/locale/nl_NL/Mage_Review.csv b/app/code/Mage/Review/locale/nl_NL/Mage_Review.csv similarity index 100% rename from app/code/core/Mage/Review/locale/nl_NL/Mage_Review.csv rename to app/code/Mage/Review/locale/nl_NL/Mage_Review.csv diff --git a/app/code/core/Mage/Review/locale/pt_BR/Mage_Review.csv b/app/code/Mage/Review/locale/pt_BR/Mage_Review.csv similarity index 100% rename from app/code/core/Mage/Review/locale/pt_BR/Mage_Review.csv rename to app/code/Mage/Review/locale/pt_BR/Mage_Review.csv diff --git a/app/code/core/Mage/Review/locale/zh_CN/Mage_Review.csv b/app/code/Mage/Review/locale/zh_CN/Mage_Review.csv similarity index 100% rename from app/code/core/Mage/Review/locale/zh_CN/Mage_Review.csv rename to app/code/Mage/Review/locale/zh_CN/Mage_Review.csv diff --git a/app/code/core/Mage/Review/sql/review_setup/install-1.6.0.0.php b/app/code/Mage/Review/sql/review_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Review/sql/review_setup/install-1.6.0.0.php rename to app/code/Mage/Review/sql/review_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Review/view/frontend/customer/list.phtml b/app/code/Mage/Review/view/frontend/customer/list.phtml similarity index 100% rename from app/code/core/Mage/Review/view/frontend/customer/list.phtml rename to app/code/Mage/Review/view/frontend/customer/list.phtml diff --git a/app/code/core/Mage/Review/view/frontend/customer/recent.phtml b/app/code/Mage/Review/view/frontend/customer/recent.phtml similarity index 100% rename from app/code/core/Mage/Review/view/frontend/customer/recent.phtml rename to app/code/Mage/Review/view/frontend/customer/recent.phtml diff --git a/app/code/core/Mage/Review/view/frontend/customer/view.phtml b/app/code/Mage/Review/view/frontend/customer/view.phtml similarity index 100% rename from app/code/core/Mage/Review/view/frontend/customer/view.phtml rename to app/code/Mage/Review/view/frontend/customer/view.phtml diff --git a/app/code/core/Mage/Review/view/frontend/form.phtml b/app/code/Mage/Review/view/frontend/form.phtml similarity index 100% rename from app/code/core/Mage/Review/view/frontend/form.phtml rename to app/code/Mage/Review/view/frontend/form.phtml diff --git a/app/code/core/Mage/Review/view/frontend/helper/summary.phtml b/app/code/Mage/Review/view/frontend/helper/summary.phtml similarity index 100% rename from app/code/core/Mage/Review/view/frontend/helper/summary.phtml rename to app/code/Mage/Review/view/frontend/helper/summary.phtml diff --git a/app/code/Mage/Review/view/frontend/helper/summary.twig b/app/code/Mage/Review/view/frontend/helper/summary.twig new file mode 100644 index 0000000000000..1567b5681619b --- /dev/null +++ b/app/code/Mage/Review/view/frontend/helper/summary.twig @@ -0,0 +1,40 @@ +{# +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + #} +{% if review.reviewsCount %} +
    + {% if review.ratingSummary %} +
    +
    +
    + {% endif %} + +
    +{% else %} +

    {{ 'Be the first to review this product'|translate }}

    +{% endif %} diff --git a/app/code/core/Mage/Review/view/frontend/helper/summary_short.phtml b/app/code/Mage/Review/view/frontend/helper/summary_short.phtml similarity index 100% rename from app/code/core/Mage/Review/view/frontend/helper/summary_short.phtml rename to app/code/Mage/Review/view/frontend/helper/summary_short.phtml diff --git a/app/code/Mage/Review/view/frontend/layout.xml b/app/code/Mage/Review/view/frontend/layout.xml new file mode 100644 index 0000000000000..7e88e8d35f1a2 --- /dev/null +++ b/app/code/Mage/Review/view/frontend/layout.xml @@ -0,0 +1,125 @@ + + + + + + + + reviewsreview/customer + + + + + + + + + + + + + + + + + + + + + + + + Mage_Catalog::zoom.css + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/core/Mage/Review/view/frontend/product/view/count.phtml b/app/code/Mage/Review/view/frontend/product/view/count.phtml similarity index 100% rename from app/code/core/Mage/Review/view/frontend/product/view/count.phtml rename to app/code/Mage/Review/view/frontend/product/view/count.phtml diff --git a/app/code/core/Mage/Review/view/frontend/product/view/list.phtml b/app/code/Mage/Review/view/frontend/product/view/list.phtml similarity index 100% rename from app/code/core/Mage/Review/view/frontend/product/view/list.phtml rename to app/code/Mage/Review/view/frontend/product/view/list.phtml diff --git a/app/code/core/Mage/Review/view/frontend/product/view/other.phtml b/app/code/Mage/Review/view/frontend/product/view/other.phtml similarity index 100% rename from app/code/core/Mage/Review/view/frontend/product/view/other.phtml rename to app/code/Mage/Review/view/frontend/product/view/other.phtml diff --git a/app/code/core/Mage/Review/view/frontend/view.phtml b/app/code/Mage/Review/view/frontend/view.phtml similarity index 100% rename from app/code/core/Mage/Review/view/frontend/view.phtml rename to app/code/Mage/Review/view/frontend/view.phtml diff --git a/app/code/core/Mage/Rss/Block/Abstract.php b/app/code/Mage/Rss/Block/Abstract.php similarity index 100% rename from app/code/core/Mage/Rss/Block/Abstract.php rename to app/code/Mage/Rss/Block/Abstract.php diff --git a/app/code/core/Mage/Rss/Block/Catalog/Abstract.php b/app/code/Mage/Rss/Block/Catalog/Abstract.php similarity index 100% rename from app/code/core/Mage/Rss/Block/Catalog/Abstract.php rename to app/code/Mage/Rss/Block/Catalog/Abstract.php diff --git a/app/code/core/Mage/Rss/Block/Catalog/Category.php b/app/code/Mage/Rss/Block/Catalog/Category.php similarity index 100% rename from app/code/core/Mage/Rss/Block/Catalog/Category.php rename to app/code/Mage/Rss/Block/Catalog/Category.php diff --git a/app/code/core/Mage/Rss/Block/Catalog/New.php b/app/code/Mage/Rss/Block/Catalog/New.php similarity index 100% rename from app/code/core/Mage/Rss/Block/Catalog/New.php rename to app/code/Mage/Rss/Block/Catalog/New.php diff --git a/app/code/core/Mage/Rss/Block/Catalog/NotifyStock.php b/app/code/Mage/Rss/Block/Catalog/NotifyStock.php similarity index 100% rename from app/code/core/Mage/Rss/Block/Catalog/NotifyStock.php rename to app/code/Mage/Rss/Block/Catalog/NotifyStock.php diff --git a/app/code/core/Mage/Rss/Block/Catalog/Review.php b/app/code/Mage/Rss/Block/Catalog/Review.php similarity index 100% rename from app/code/core/Mage/Rss/Block/Catalog/Review.php rename to app/code/Mage/Rss/Block/Catalog/Review.php diff --git a/app/code/core/Mage/Rss/Block/Catalog/Salesrule.php b/app/code/Mage/Rss/Block/Catalog/Salesrule.php similarity index 100% rename from app/code/core/Mage/Rss/Block/Catalog/Salesrule.php rename to app/code/Mage/Rss/Block/Catalog/Salesrule.php diff --git a/app/code/core/Mage/Rss/Block/Catalog/Special.php b/app/code/Mage/Rss/Block/Catalog/Special.php similarity index 100% rename from app/code/core/Mage/Rss/Block/Catalog/Special.php rename to app/code/Mage/Rss/Block/Catalog/Special.php diff --git a/app/code/core/Mage/Rss/Block/List.php b/app/code/Mage/Rss/Block/List.php similarity index 100% rename from app/code/core/Mage/Rss/Block/List.php rename to app/code/Mage/Rss/Block/List.php diff --git a/app/code/core/Mage/Rss/Block/Order/Details.php b/app/code/Mage/Rss/Block/Order/Details.php similarity index 100% rename from app/code/core/Mage/Rss/Block/Order/Details.php rename to app/code/Mage/Rss/Block/Order/Details.php diff --git a/app/code/core/Mage/Rss/Block/Order/New.php b/app/code/Mage/Rss/Block/Order/New.php similarity index 100% rename from app/code/core/Mage/Rss/Block/Order/New.php rename to app/code/Mage/Rss/Block/Order/New.php diff --git a/app/code/core/Mage/Rss/Block/Order/Status.php b/app/code/Mage/Rss/Block/Order/Status.php similarity index 100% rename from app/code/core/Mage/Rss/Block/Order/Status.php rename to app/code/Mage/Rss/Block/Order/Status.php diff --git a/app/code/core/Mage/Rss/Block/Wishlist.php b/app/code/Mage/Rss/Block/Wishlist.php similarity index 100% rename from app/code/core/Mage/Rss/Block/Wishlist.php rename to app/code/Mage/Rss/Block/Wishlist.php diff --git a/app/code/core/Mage/Rss/Helper/Data.php b/app/code/Mage/Rss/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Rss/Helper/Data.php rename to app/code/Mage/Rss/Helper/Data.php diff --git a/app/code/core/Mage/Rss/Helper/Order.php b/app/code/Mage/Rss/Helper/Order.php similarity index 100% rename from app/code/core/Mage/Rss/Helper/Order.php rename to app/code/Mage/Rss/Helper/Order.php diff --git a/app/code/core/Mage/Rss/Model/Resource/Order.php b/app/code/Mage/Rss/Model/Resource/Order.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Rss/Model/Resource/Order.php rename to app/code/Mage/Rss/Model/Resource/Order.php diff --git a/app/code/core/Mage/Rss/Model/Rss.php b/app/code/Mage/Rss/Model/Rss.php similarity index 100% rename from app/code/core/Mage/Rss/Model/Rss.php rename to app/code/Mage/Rss/Model/Rss.php diff --git a/app/code/core/Mage/Rss/Model/System/Config/Backend/Links.php b/app/code/Mage/Rss/Model/System/Config/Backend/Links.php similarity index 100% rename from app/code/core/Mage/Rss/Model/System/Config/Backend/Links.php rename to app/code/Mage/Rss/Model/System/Config/Backend/Links.php diff --git a/app/code/core/Mage/Rss/controllers/CatalogController.php b/app/code/Mage/Rss/controllers/CatalogController.php similarity index 98% rename from app/code/core/Mage/Rss/controllers/CatalogController.php rename to app/code/Mage/Rss/controllers/CatalogController.php index 3ebddb0536db3..50ce836e2dc25 100644 --- a/app/code/core/Mage/Rss/controllers/CatalogController.php +++ b/app/code/Mage/Rss/controllers/CatalogController.php @@ -44,7 +44,7 @@ public function preDispatch() /** * Format actionName => acrResourceId */ - $acl = array('notifystock' => 'Mage_Catalog::products', 'review' => 'Mage_Review::reviews_ratings'); + $acl = array('notifystock' => 'Mage_Catalog::products', 'review' => 'Mage_Review::reviews_all'); if (isset($acl[$action])) { $this->setCurrentArea('adminhtml'); if (Mage_Rss_OrderController::authenticateAndAuthorizeAdmin($this, $acl[$action])) { diff --git a/app/code/core/Mage/Rss/controllers/IndexController.php b/app/code/Mage/Rss/controllers/IndexController.php similarity index 100% rename from app/code/core/Mage/Rss/controllers/IndexController.php rename to app/code/Mage/Rss/controllers/IndexController.php diff --git a/app/code/core/Mage/Rss/controllers/OrderController.php b/app/code/Mage/Rss/controllers/OrderController.php similarity index 96% rename from app/code/core/Mage/Rss/controllers/OrderController.php rename to app/code/Mage/Rss/controllers/OrderController.php index 0442e9ab99fd1..d2d8ef013eed5 100644 --- a/app/code/core/Mage/Rss/controllers/OrderController.php +++ b/app/code/Mage/Rss/controllers/OrderController.php @@ -56,6 +56,7 @@ public function preDispatch() */ public static function authenticateAndAuthorizeAdmin(Mage_Core_Controller_Front_Action $controller, $aclResource) { + Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_ADMINHTML, Mage_Core_Model_App_Area::PART_CONFIG); /** @var $auth Mage_Backend_Model_Auth */ $auth = Mage::getModel('Mage_Backend_Model_Auth'); $session = $auth->getAuthStorage(); diff --git a/app/code/Mage/Rss/etc/adminhtml/acl.xml b/app/code/Mage/Rss/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..81b73a7716139 --- /dev/null +++ b/app/code/Mage/Rss/etc/adminhtml/acl.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + diff --git a/app/code/core/Mage/Rss/etc/adminhtml/system.xml b/app/code/Mage/Rss/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Rss/etc/adminhtml/system.xml rename to app/code/Mage/Rss/etc/adminhtml/system.xml diff --git a/app/code/Mage/Rss/etc/config.xml b/app/code/Mage/Rss/etc/config.xml new file mode 100644 index 0000000000000..91f85782785a7 --- /dev/null +++ b/app/code/Mage/Rss/etc/config.xml @@ -0,0 +1,95 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + + + + + + + + + Mage_Rss.csv + + + + + + + + layout.xml + + + + + + + + + + Mage_Rss.csv + + + + + + /rss/catalog/review + /rss/order/new + /rss/catalog/notifystock + + + + standard + + Mage_Rss + rss + + + + + + + layout.xml + + + + + diff --git a/app/code/core/Mage/Rss/locale/de_DE/Mage_Rss.csv b/app/code/Mage/Rss/locale/de_DE/Mage_Rss.csv similarity index 100% rename from app/code/core/Mage/Rss/locale/de_DE/Mage_Rss.csv rename to app/code/Mage/Rss/locale/de_DE/Mage_Rss.csv diff --git a/app/code/core/Mage/Rss/locale/en_US/Mage_Rss.csv b/app/code/Mage/Rss/locale/en_US/Mage_Rss.csv similarity index 100% rename from app/code/core/Mage/Rss/locale/en_US/Mage_Rss.csv rename to app/code/Mage/Rss/locale/en_US/Mage_Rss.csv diff --git a/app/code/core/Mage/Rss/locale/es_ES/Mage_Rss.csv b/app/code/Mage/Rss/locale/es_ES/Mage_Rss.csv similarity index 100% rename from app/code/core/Mage/Rss/locale/es_ES/Mage_Rss.csv rename to app/code/Mage/Rss/locale/es_ES/Mage_Rss.csv diff --git a/app/code/core/Mage/Rss/locale/fr_FR/Mage_Rss.csv b/app/code/Mage/Rss/locale/fr_FR/Mage_Rss.csv similarity index 100% rename from app/code/core/Mage/Rss/locale/fr_FR/Mage_Rss.csv rename to app/code/Mage/Rss/locale/fr_FR/Mage_Rss.csv diff --git a/app/code/core/Mage/Rss/locale/nl_NL/Mage_Rss.csv b/app/code/Mage/Rss/locale/nl_NL/Mage_Rss.csv similarity index 100% rename from app/code/core/Mage/Rss/locale/nl_NL/Mage_Rss.csv rename to app/code/Mage/Rss/locale/nl_NL/Mage_Rss.csv diff --git a/app/code/core/Mage/Rss/locale/pt_BR/Mage_Rss.csv b/app/code/Mage/Rss/locale/pt_BR/Mage_Rss.csv similarity index 100% rename from app/code/core/Mage/Rss/locale/pt_BR/Mage_Rss.csv rename to app/code/Mage/Rss/locale/pt_BR/Mage_Rss.csv diff --git a/app/code/core/Mage/Rss/locale/zh_CN/Mage_Rss.csv b/app/code/Mage/Rss/locale/zh_CN/Mage_Rss.csv similarity index 100% rename from app/code/core/Mage/Rss/locale/zh_CN/Mage_Rss.csv rename to app/code/Mage/Rss/locale/zh_CN/Mage_Rss.csv diff --git a/app/code/core/Mage/Rss/view/adminhtml/layout.xml b/app/code/Mage/Rss/view/adminhtml/layout.xml similarity index 100% rename from app/code/core/Mage/Rss/view/adminhtml/layout.xml rename to app/code/Mage/Rss/view/adminhtml/layout.xml diff --git a/app/code/core/Mage/Rss/view/frontend/layout.xml b/app/code/Mage/Rss/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/Rss/view/frontend/layout.xml rename to app/code/Mage/Rss/view/frontend/layout.xml diff --git a/app/code/core/Mage/Rss/view/frontend/list.phtml b/app/code/Mage/Rss/view/frontend/list.phtml similarity index 100% rename from app/code/core/Mage/Rss/view/frontend/list.phtml rename to app/code/Mage/Rss/view/frontend/list.phtml diff --git a/app/code/core/Mage/Rss/view/frontend/order/details.phtml b/app/code/Mage/Rss/view/frontend/order/details.phtml similarity index 100% rename from app/code/core/Mage/Rss/view/frontend/order/details.phtml rename to app/code/Mage/Rss/view/frontend/order/details.phtml diff --git a/app/code/core/Mage/Rule/Block/Actions.php b/app/code/Mage/Rule/Block/Actions.php similarity index 100% rename from app/code/core/Mage/Rule/Block/Actions.php rename to app/code/Mage/Rule/Block/Actions.php diff --git a/app/code/core/Mage/Rule/Block/Conditions.php b/app/code/Mage/Rule/Block/Conditions.php similarity index 100% rename from app/code/core/Mage/Rule/Block/Conditions.php rename to app/code/Mage/Rule/Block/Conditions.php diff --git a/app/code/core/Mage/Rule/Block/Editable.php b/app/code/Mage/Rule/Block/Editable.php similarity index 100% rename from app/code/core/Mage/Rule/Block/Editable.php rename to app/code/Mage/Rule/Block/Editable.php diff --git a/app/code/core/Mage/Rule/Block/Newchild.php b/app/code/Mage/Rule/Block/Newchild.php similarity index 100% rename from app/code/core/Mage/Rule/Block/Newchild.php rename to app/code/Mage/Rule/Block/Newchild.php diff --git a/app/code/core/Mage/Rule/Block/Rule.php b/app/code/Mage/Rule/Block/Rule.php similarity index 100% rename from app/code/core/Mage/Rule/Block/Rule.php rename to app/code/Mage/Rule/Block/Rule.php diff --git a/app/code/core/Mage/Rule/Helper/Data.php b/app/code/Mage/Rule/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Rule/Helper/Data.php rename to app/code/Mage/Rule/Helper/Data.php diff --git a/app/code/core/Mage/Rule/Model/Abstract.php b/app/code/Mage/Rule/Model/Abstract.php similarity index 100% rename from app/code/core/Mage/Rule/Model/Abstract.php rename to app/code/Mage/Rule/Model/Abstract.php diff --git a/app/code/core/Mage/Rule/Model/Action/Abstract.php b/app/code/Mage/Rule/Model/Action/Abstract.php similarity index 100% rename from app/code/core/Mage/Rule/Model/Action/Abstract.php rename to app/code/Mage/Rule/Model/Action/Abstract.php diff --git a/app/code/core/Mage/Rule/Model/Action/Collection.php b/app/code/Mage/Rule/Model/Action/Collection.php similarity index 100% rename from app/code/core/Mage/Rule/Model/Action/Collection.php rename to app/code/Mage/Rule/Model/Action/Collection.php diff --git a/app/code/core/Mage/Rule/Model/Action/Interface.php b/app/code/Mage/Rule/Model/Action/Interface.php similarity index 100% rename from app/code/core/Mage/Rule/Model/Action/Interface.php rename to app/code/Mage/Rule/Model/Action/Interface.php diff --git a/app/code/core/Mage/Rule/Model/Condition/Abstract.php b/app/code/Mage/Rule/Model/Condition/Abstract.php similarity index 100% rename from app/code/core/Mage/Rule/Model/Condition/Abstract.php rename to app/code/Mage/Rule/Model/Condition/Abstract.php diff --git a/app/code/core/Mage/Rule/Model/Condition/Combine.php b/app/code/Mage/Rule/Model/Condition/Combine.php similarity index 100% rename from app/code/core/Mage/Rule/Model/Condition/Combine.php rename to app/code/Mage/Rule/Model/Condition/Combine.php diff --git a/app/code/core/Mage/Rule/Model/Condition/Interface.php b/app/code/Mage/Rule/Model/Condition/Interface.php similarity index 100% rename from app/code/core/Mage/Rule/Model/Condition/Interface.php rename to app/code/Mage/Rule/Model/Condition/Interface.php diff --git a/app/code/core/Mage/Rule/Model/Condition/Product/Abstract.php b/app/code/Mage/Rule/Model/Condition/Product/Abstract.php similarity index 100% rename from app/code/core/Mage/Rule/Model/Condition/Product/Abstract.php rename to app/code/Mage/Rule/Model/Condition/Product/Abstract.php diff --git a/app/code/core/Mage/Rule/Model/Renderer/Actions.php b/app/code/Mage/Rule/Model/Renderer/Actions.php similarity index 100% rename from app/code/core/Mage/Rule/Model/Renderer/Actions.php rename to app/code/Mage/Rule/Model/Renderer/Actions.php diff --git a/app/code/core/Mage/Rule/Model/Renderer/Conditions.php b/app/code/Mage/Rule/Model/Renderer/Conditions.php similarity index 100% rename from app/code/core/Mage/Rule/Model/Renderer/Conditions.php rename to app/code/Mage/Rule/Model/Renderer/Conditions.php diff --git a/app/code/core/Mage/Rule/Model/Resource/Abstract.php b/app/code/Mage/Rule/Model/Resource/Abstract.php similarity index 100% rename from app/code/core/Mage/Rule/Model/Resource/Abstract.php rename to app/code/Mage/Rule/Model/Resource/Abstract.php diff --git a/app/code/core/Mage/Rule/Model/Resource/Rule/Collection/Abstract.php b/app/code/Mage/Rule/Model/Resource/Rule/Collection/Abstract.php similarity index 100% rename from app/code/core/Mage/Rule/Model/Resource/Rule/Collection/Abstract.php rename to app/code/Mage/Rule/Model/Resource/Rule/Collection/Abstract.php diff --git a/app/code/core/Mage/Rule/Model/Rule.php b/app/code/Mage/Rule/Model/Rule.php similarity index 100% rename from app/code/core/Mage/Rule/Model/Rule.php rename to app/code/Mage/Rule/Model/Rule.php diff --git a/app/code/Mage/Rule/etc/config.xml b/app/code/Mage/Rule/etc/config.xml new file mode 100644 index 0000000000000..ba2371ed28b51 --- /dev/null +++ b/app/code/Mage/Rule/etc/config.xml @@ -0,0 +1,60 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + + Mage_Rule.csv + + + + + + + + + + + Mage_Rule.csv + + + + + + diff --git a/app/code/core/Mage/Rule/locale/de_DE/Mage_Rule.csv b/app/code/Mage/Rule/locale/de_DE/Mage_Rule.csv similarity index 100% rename from app/code/core/Mage/Rule/locale/de_DE/Mage_Rule.csv rename to app/code/Mage/Rule/locale/de_DE/Mage_Rule.csv diff --git a/app/code/core/Mage/Rule/locale/en_US/Mage_Rule.csv b/app/code/Mage/Rule/locale/en_US/Mage_Rule.csv similarity index 100% rename from app/code/core/Mage/Rule/locale/en_US/Mage_Rule.csv rename to app/code/Mage/Rule/locale/en_US/Mage_Rule.csv diff --git a/app/code/core/Mage/Rule/locale/es_ES/Mage_Rule.csv b/app/code/Mage/Rule/locale/es_ES/Mage_Rule.csv similarity index 100% rename from app/code/core/Mage/Rule/locale/es_ES/Mage_Rule.csv rename to app/code/Mage/Rule/locale/es_ES/Mage_Rule.csv diff --git a/app/code/core/Mage/Rule/locale/fr_FR/Mage_Rule.csv b/app/code/Mage/Rule/locale/fr_FR/Mage_Rule.csv similarity index 100% rename from app/code/core/Mage/Rule/locale/fr_FR/Mage_Rule.csv rename to app/code/Mage/Rule/locale/fr_FR/Mage_Rule.csv diff --git a/app/code/core/Mage/Rule/locale/nl_NL/Mage_Rule.csv b/app/code/Mage/Rule/locale/nl_NL/Mage_Rule.csv similarity index 100% rename from app/code/core/Mage/Rule/locale/nl_NL/Mage_Rule.csv rename to app/code/Mage/Rule/locale/nl_NL/Mage_Rule.csv diff --git a/app/code/core/Mage/Rule/locale/pt_BR/Mage_Rule.csv b/app/code/Mage/Rule/locale/pt_BR/Mage_Rule.csv similarity index 100% rename from app/code/core/Mage/Rule/locale/pt_BR/Mage_Rule.csv rename to app/code/Mage/Rule/locale/pt_BR/Mage_Rule.csv diff --git a/app/code/core/Mage/Rule/locale/zh_CN/Mage_Rule.csv b/app/code/Mage/Rule/locale/zh_CN/Mage_Rule.csv similarity index 100% rename from app/code/core/Mage/Rule/locale/zh_CN/Mage_Rule.csv rename to app/code/Mage/Rule/locale/zh_CN/Mage_Rule.csv diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement.php b/app/code/Mage/Sales/Block/Adminhtml/Billing/Agreement.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement.php rename to app/code/Mage/Sales/Block/Adminhtml/Billing/Agreement.php diff --git a/app/code/Mage/Sales/Block/Adminhtml/Billing/Agreement/Grid.php b/app/code/Mage/Sales/Block/Adminhtml/Billing/Agreement/Grid.php new file mode 100644 index 0000000000000..88e44d851a046 --- /dev/null +++ b/app/code/Mage/Sales/Block/Adminhtml/Billing/Agreement/Grid.php @@ -0,0 +1,171 @@ + + */ +class Mage_Sales_Block_Adminhtml_Billing_Agreement_Grid extends Mage_Adminhtml_Block_Widget_Grid +{ + /** + * Set grid params + */ + protected function _construct() + { + parent::_construct(); + $this->setId('billing_agreements'); + $this->setUseAjax(true); + $this->setDefaultSort('agreement_id'); + $this->setDefaultDir('DESC'); + $this->setSaveParametersInSession(true); + } + + /** + * Retrieve grid url + * + * @return string + */ + public function getGridUrl() + { + return $this->getUrl('*/sales_billing_agreement/grid', array('_current' => true)); + } + + /** + * Retrieve row url + * + * @return string + */ + public function getRowUrl($item) + { + return $this->getUrl('*/sales_billing_agreement/view', array('agreement' => $item->getAgreementId())); + } + + /** + * Prepare collection for grid + * + * @return Mage_Adminhtml_Block_Widget_Grid + */ + protected function _prepareCollection() + { + $collection = Mage::getResourceModel('Mage_Sales_Model_Resource_Billing_Agreement_Collection') + ->addCustomerDetails(); + $this->setCollection($collection); + return parent::_prepareCollection(); + } + + /** + * Add columns to grid + * + * @return Mage_Adminhtml_Block_Widget_Grid + */ + protected function _prepareColumns() + { + $this->addColumn('agreement_id', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('ID'), + 'index' => 'agreement_id', + 'type' => 'text', + 'header_css_class' => 'col-id', + 'column_css_class' => 'col-id' + )); + + $this->addColumn('customer_email', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Customer Email'), + 'index' => 'customer_email', + 'type' => 'text', + 'header_css_class' => 'col-mail', + 'column_css_class' => 'col-mail' + )); + + $this->addColumn('customer_firstname', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Customer Name'), + 'index' => 'customer_firstname', + 'type' => 'text', + 'escape' => true, + 'header_css_class' => 'col-name', + 'column_css_class' => 'col-name' + )); + + $this->addColumn('customer_lastname', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Customer Last Name'), + 'index' => 'customer_lastname', + 'type' => 'text', + 'escape' => true, + 'header_css_class' => 'col-last-name', + 'column_css_class' => 'col-last-name' + )); + + $this->addColumn('method_code', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Payment Method'), + 'index' => 'method_code', + 'type' => 'options', + 'options' => Mage::helper('Mage_Payment_Helper_Data')->getAllBillingAgreementMethods(), + 'header_css_class' => 'col-payment', + 'column_css_class' => 'col-payment' + )); + + $this->addColumn('reference_id', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Reference ID'), + 'index' => 'reference_id', + 'type' => 'text', + 'header_css_class' => 'col-reference', + 'column_css_class' => 'col-reference' + )); + + $this->addColumn('status', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Status'), + 'index' => 'status', + 'type' => 'options', + 'options' => Mage::getSingleton('Mage_Sales_Model_Billing_Agreement')->getStatusesArray(), + 'header_css_class' => 'col-status', + 'column_css_class' => 'col-status' + )); + + $this->addColumn('created_at', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Created At'), + 'index' => 'agreement_created_at', + 'type' => 'datetime', + 'align' => 'center', + 'default' => $this->__('N/A'), + 'html_decorators' => array('nobr'), + 'header_css_class' => 'col-period', + 'column_css_class' => 'col-period' + )); + + $this->addColumn('updated_at', array( + 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Updated At'), + 'index' => 'agreement_updated_at', + 'type' => 'datetime', + 'align' => 'center', + 'default' => $this->__('N/A'), + 'html_decorators' => array('nobr'), + 'header_css_class' => 'col-period', + 'column_css_class' => 'col-period' + )); + + return parent::_prepareColumns(); + } +} diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/View.php b/app/code/Mage/Sales/Block/Adminhtml/Billing/Agreement/View.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/View.php rename to app/code/Mage/Sales/Block/Adminhtml/Billing/Agreement/View.php diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/View/Form.php b/app/code/Mage/Sales/Block/Adminhtml/Billing/Agreement/View/Form.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/View/Form.php rename to app/code/Mage/Sales/Block/Adminhtml/Billing/Agreement/View/Form.php diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Info.php b/app/code/Mage/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Info.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Info.php rename to app/code/Mage/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Info.php diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Orders.php b/app/code/Mage/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Orders.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Orders.php rename to app/code/Mage/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Orders.php diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/View/Tabs.php b/app/code/Mage/Sales/Block/Adminhtml/Billing/Agreement/View/Tabs.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/View/Tabs.php rename to app/code/Mage/Sales/Block/Adminhtml/Billing/Agreement/View/Tabs.php diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php b/app/code/Mage/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php rename to app/code/Mage/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Customer/Edit/Tab/Recurring/Profile.php b/app/code/Mage/Sales/Block/Adminhtml/Customer/Edit/Tab/Recurring/Profile.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Adminhtml/Customer/Edit/Tab/Recurring/Profile.php rename to app/code/Mage/Sales/Block/Adminhtml/Customer/Edit/Tab/Recurring/Profile.php diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile.php b/app/code/Mage/Sales/Block/Adminhtml/Recurring/Profile.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile.php rename to app/code/Mage/Sales/Block/Adminhtml/Recurring/Profile.php diff --git a/app/code/Mage/Sales/Block/Adminhtml/Recurring/Profile/Edit/Form.php b/app/code/Mage/Sales/Block/Adminhtml/Recurring/Profile/Edit/Form.php new file mode 100644 index 0000000000000..172076143aec3 --- /dev/null +++ b/app/code/Mage/Sales/Block/Adminhtml/Recurring/Profile/Edit/Form.php @@ -0,0 +1,242 @@ +_parentElement = $element; + return $this; + } + + /** + * Setter for current product + * + * @param Mage_Catalog_Model_Product $product + */ + public function setProductEntity(Mage_Catalog_Model_Product $product) + { + $this->_product = $product; + return $this; + } + + /** + * Instantiate a recurring payment profile to use it as a helper + */ + protected function _construct() + { + $this->_profile = Mage::getSingleton('Mage_Sales_Model_Recurring_Profile'); + return parent::_construct(); + } + + /** + * Prepare and render the form + * + * @return string + */ + protected function _toHtml() + { + // TODO: implement $this->_isReadonly setting + $form = $this->_prepareForm(); + if ($this->_product && $this->_product->getRecurringProfile()) { + $form->setValues($this->_product->getRecurringProfile()); + } + return $form->toHtml(); + } + + /** + * Instantiate form and fields + * + * @return Varien_Data_Form + */ + protected function _prepareForm() + { + $form = new Varien_Data_Form(); + + $form->setFieldsetRenderer( + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset') + ); + $form->setFieldsetElementRenderer( + $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Form_Renderer_Fieldset_Element') + ); + + /** + * if there is a parent element defined, it will be replaced by a hidden element with the same name + * and overriden by the form elements + * It is needed to maintain HTML consistency of the parent element's form + */ + if ($this->_parentElement) { + $form->setHtmlIdPrefix($this->_parentElement->getHtmlId()) + ->setFieldNameSuffix($this->_parentElement->getName()); + $form->addField('', 'hidden', array('name' => '')); + } + + $noYes = array(Mage::helper('Mage_Adminhtml_Helper_Data')->__('No'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Yes')); + + // schedule + $schedule = $form->addFieldset('schedule_fieldset', array( + 'legend' => Mage::helper('Mage_Sales_Helper_Data')->__('Schedule'), + 'disabled' => $this->_isReadOnly + )); + $schedule->addField('start_date_is_editable', 'select', array( + 'name' => 'start_date_is_editable', + 'label' => Mage::helper('Mage_Sales_Helper_Data')->__('Customer Can Define Start Date'), + 'comment' => Mage::helper('Mage_Sales_Helper_Data')->__('Whether buyer can define the date when billing for the profile begins.'), + 'options' => $noYes, + 'disabled' => $this->_isReadOnly + )); + $this->_addField($schedule, 'schedule_description'); + $this->_addField($schedule, 'suspension_threshold'); + $this->_addField($schedule, 'bill_failed_later', array('options' => $noYes), 'select'); + + // billing + $billing = $form->addFieldset('billing_fieldset', array( + 'legend' => Mage::helper('Mage_Sales_Helper_Data')->__('Billing'), + 'disabled' => $this->_isReadOnly + )); + $this->_addField($billing, 'period_unit', array( + 'options' => $this->_getPeriodUnitOptions(Mage::helper('Mage_Adminhtml_Helper_Data')->__('-- Please Select --')), + ), 'select'); + $this->_addField($billing, 'period_frequency'); + $this->_addField($billing, 'period_max_cycles'); + + // trial + $trial = $form->addFieldset('trial_fieldset', array( + 'legend' => Mage::helper('Mage_Sales_Helper_Data')->__('Trial Period'), + 'disabled' => $this->_isReadOnly + )); + $this->_addField($trial, 'trial_period_unit', array( + 'options' => $this->_getPeriodUnitOptions(Mage::helper('Mage_Adminhtml_Helper_Data')->__('-- Not Selected --')), + ), 'select'); + $this->_addField($trial, 'trial_period_frequency'); + $this->_addField($trial, 'trial_period_max_cycles'); + $this->_addField($trial, 'trial_billing_amount'); + + // initial fees + $initial = $form->addFieldset('initial_fieldset', array( + 'legend' => Mage::helper('Mage_Sales_Helper_Data')->__('Initial Fees'), + 'disabled' => $this->_isReadOnly + )); + $this->_addField($initial, 'init_amount'); + $this->_addField($initial, 'init_may_fail', array('options' => $noYes), 'select'); + + return $form; + } + + /** + * Add a field to the form or fieldset + * Form and fieldset have same abstract + * + * @param Varien_Data_Form|Varien_Data_Form_Element_Fieldset $formOrFieldset + * @param string $elementName + * @param array $options + * @param string $type + * @return Varien_Data_Form_Element_Abstract + */ + protected function _addField($formOrFieldset, $elementName, $options = array(), $type = 'text') + { + $options = array_merge($options, array( + 'name' => $elementName, + 'label' => $this->_profile->getFieldLabel($elementName), + 'note' => $this->_profile->getFieldComment($elementName), + 'disabled' => $this->_isReadOnly, + )); + if (in_array($elementName, array('period_unit', 'period_frequency'))) { + $options['required'] = true; + } + return $formOrFieldset->addField($elementName, $type, $options); + } + + /** + * Getter for period unit options with "Please Select" label + * + * @return array + */ + protected function _getPeriodUnitOptions($emptyLabel) + { + return array_merge(array('' => $emptyLabel), + $this->_profile->getAllPeriodUnits() + ); + } + + /** + * Set readonly flag + * + * @param boolean $isReadonly + * @return Mage_Sales_Block_Adminhtml_Recurring_Profile_Edit_Form + */ + public function setIsReadonly($isReadonly) + { + $this->_isReadOnly = $isReadonly; + return $this; + } + + /** + * Get readonly flag + * + * @return boolean + */ + public function getIsReadonly() + { + return $this->_isReadOnly; + } +} diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/Grid.php b/app/code/Mage/Sales/Block/Adminhtml/Recurring/Profile/Grid.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/Grid.php rename to app/code/Mage/Sales/Block/Adminhtml/Recurring/Profile/Grid.php diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View.php b/app/code/Mage/Sales/Block/Adminhtml/Recurring/Profile/View.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View.php rename to app/code/Mage/Sales/Block/Adminhtml/Recurring/Profile/View.php diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Getawayinfo.php b/app/code/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Getawayinfo.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Getawayinfo.php rename to app/code/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Getawayinfo.php diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Info.php b/app/code/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Info.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Info.php rename to app/code/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Info.php diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Items.php b/app/code/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Items.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Items.php rename to app/code/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Items.php diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Info.php b/app/code/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Info.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Info.php rename to app/code/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Info.php diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php b/app/code/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php rename to app/code/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Report/Filter/Form.php b/app/code/Mage/Sales/Block/Adminhtml/Report/Filter/Form.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Adminhtml/Report/Filter/Form.php rename to app/code/Mage/Sales/Block/Adminhtml/Report/Filter/Form.php diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Report/Filter/Form/Coupon.php b/app/code/Mage/Sales/Block/Adminhtml/Report/Filter/Form/Coupon.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Adminhtml/Report/Filter/Form/Coupon.php rename to app/code/Mage/Sales/Block/Adminhtml/Report/Filter/Form/Coupon.php diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Report/Filter/Form/Order.php b/app/code/Mage/Sales/Block/Adminhtml/Report/Filter/Form/Order.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Adminhtml/Report/Filter/Form/Order.php rename to app/code/Mage/Sales/Block/Adminhtml/Report/Filter/Form/Order.php diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/System/Config/Form/Fieldset/Order/Statuses.php b/app/code/Mage/Sales/Block/Adminhtml/System/Config/Form/Fieldset/Order/Statuses.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Adminhtml/System/Config/Form/Fieldset/Order/Statuses.php rename to app/code/Mage/Sales/Block/Adminhtml/System/Config/Form/Fieldset/Order/Statuses.php diff --git a/app/code/core/Mage/Sales/Block/Billing/Agreement/View.php b/app/code/Mage/Sales/Block/Billing/Agreement/View.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Billing/Agreement/View.php rename to app/code/Mage/Sales/Block/Billing/Agreement/View.php diff --git a/app/code/core/Mage/Sales/Block/Billing/Agreements.php b/app/code/Mage/Sales/Block/Billing/Agreements.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Billing/Agreements.php rename to app/code/Mage/Sales/Block/Billing/Agreements.php diff --git a/app/code/core/Mage/Sales/Block/Guest/Links.php b/app/code/Mage/Sales/Block/Guest/Links.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Guest/Links.php rename to app/code/Mage/Sales/Block/Guest/Links.php diff --git a/app/code/core/Mage/Sales/Block/Items/Abstract.php b/app/code/Mage/Sales/Block/Items/Abstract.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Items/Abstract.php rename to app/code/Mage/Sales/Block/Items/Abstract.php diff --git a/app/code/core/Mage/Sales/Block/Order/Comments.php b/app/code/Mage/Sales/Block/Order/Comments.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Comments.php rename to app/code/Mage/Sales/Block/Order/Comments.php diff --git a/app/code/core/Mage/Sales/Block/Order/Creditmemo.php b/app/code/Mage/Sales/Block/Order/Creditmemo.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Creditmemo.php rename to app/code/Mage/Sales/Block/Order/Creditmemo.php diff --git a/app/code/core/Mage/Sales/Block/Order/Creditmemo/Items.php b/app/code/Mage/Sales/Block/Order/Creditmemo/Items.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Creditmemo/Items.php rename to app/code/Mage/Sales/Block/Order/Creditmemo/Items.php diff --git a/app/code/core/Mage/Sales/Block/Order/Creditmemo/Totals.php b/app/code/Mage/Sales/Block/Order/Creditmemo/Totals.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Creditmemo/Totals.php rename to app/code/Mage/Sales/Block/Order/Creditmemo/Totals.php diff --git a/app/code/core/Mage/Sales/Block/Order/Email/Creditmemo/Items.php b/app/code/Mage/Sales/Block/Order/Email/Creditmemo/Items.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Email/Creditmemo/Items.php rename to app/code/Mage/Sales/Block/Order/Email/Creditmemo/Items.php diff --git a/app/code/core/Mage/Sales/Block/Order/Email/Invoice/Items.php b/app/code/Mage/Sales/Block/Order/Email/Invoice/Items.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Email/Invoice/Items.php rename to app/code/Mage/Sales/Block/Order/Email/Invoice/Items.php diff --git a/app/code/core/Mage/Sales/Block/Order/Email/Items.php b/app/code/Mage/Sales/Block/Order/Email/Items.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Email/Items.php rename to app/code/Mage/Sales/Block/Order/Email/Items.php diff --git a/app/code/core/Mage/Sales/Block/Order/Email/Items/Default.php b/app/code/Mage/Sales/Block/Order/Email/Items/Default.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Email/Items/Default.php rename to app/code/Mage/Sales/Block/Order/Email/Items/Default.php diff --git a/app/code/core/Mage/Sales/Block/Order/Email/Items/Order/Default.php b/app/code/Mage/Sales/Block/Order/Email/Items/Order/Default.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Email/Items/Order/Default.php rename to app/code/Mage/Sales/Block/Order/Email/Items/Order/Default.php diff --git a/app/code/core/Mage/Sales/Block/Order/Email/Items/Order/Grouped.php b/app/code/Mage/Sales/Block/Order/Email/Items/Order/Grouped.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Email/Items/Order/Grouped.php rename to app/code/Mage/Sales/Block/Order/Email/Items/Order/Grouped.php diff --git a/app/code/core/Mage/Sales/Block/Order/Email/Shipment/Items.php b/app/code/Mage/Sales/Block/Order/Email/Shipment/Items.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Email/Shipment/Items.php rename to app/code/Mage/Sales/Block/Order/Email/Shipment/Items.php diff --git a/app/code/core/Mage/Sales/Block/Order/History.php b/app/code/Mage/Sales/Block/Order/History.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/History.php rename to app/code/Mage/Sales/Block/Order/History.php diff --git a/app/code/core/Mage/Sales/Block/Order/Info.php b/app/code/Mage/Sales/Block/Order/Info.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Info.php rename to app/code/Mage/Sales/Block/Order/Info.php diff --git a/app/code/core/Mage/Sales/Block/Order/Info/Buttons.php b/app/code/Mage/Sales/Block/Order/Info/Buttons.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Info/Buttons.php rename to app/code/Mage/Sales/Block/Order/Info/Buttons.php diff --git a/app/code/core/Mage/Sales/Block/Order/Invoice.php b/app/code/Mage/Sales/Block/Order/Invoice.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Invoice.php rename to app/code/Mage/Sales/Block/Order/Invoice.php diff --git a/app/code/core/Mage/Sales/Block/Order/Invoice/Items.php b/app/code/Mage/Sales/Block/Order/Invoice/Items.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Invoice/Items.php rename to app/code/Mage/Sales/Block/Order/Invoice/Items.php diff --git a/app/code/core/Mage/Sales/Block/Order/Invoice/Totals.php b/app/code/Mage/Sales/Block/Order/Invoice/Totals.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Invoice/Totals.php rename to app/code/Mage/Sales/Block/Order/Invoice/Totals.php diff --git a/app/code/core/Mage/Sales/Block/Order/Item/Renderer/Default.php b/app/code/Mage/Sales/Block/Order/Item/Renderer/Default.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Item/Renderer/Default.php rename to app/code/Mage/Sales/Block/Order/Item/Renderer/Default.php diff --git a/app/code/core/Mage/Sales/Block/Order/Item/Renderer/Grouped.php b/app/code/Mage/Sales/Block/Order/Item/Renderer/Grouped.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Item/Renderer/Grouped.php rename to app/code/Mage/Sales/Block/Order/Item/Renderer/Grouped.php diff --git a/app/code/core/Mage/Sales/Block/Order/Items.php b/app/code/Mage/Sales/Block/Order/Items.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Items.php rename to app/code/Mage/Sales/Block/Order/Items.php diff --git a/app/code/core/Mage/Sales/Block/Order/Print.php b/app/code/Mage/Sales/Block/Order/Print.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Print.php rename to app/code/Mage/Sales/Block/Order/Print.php diff --git a/app/code/core/Mage/Sales/Block/Order/Print/Creditmemo.php b/app/code/Mage/Sales/Block/Order/Print/Creditmemo.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Print/Creditmemo.php rename to app/code/Mage/Sales/Block/Order/Print/Creditmemo.php diff --git a/app/code/core/Mage/Sales/Block/Order/Print/Invoice.php b/app/code/Mage/Sales/Block/Order/Print/Invoice.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Print/Invoice.php rename to app/code/Mage/Sales/Block/Order/Print/Invoice.php diff --git a/app/code/core/Mage/Sales/Block/Order/Print/Shipment.php b/app/code/Mage/Sales/Block/Order/Print/Shipment.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Print/Shipment.php rename to app/code/Mage/Sales/Block/Order/Print/Shipment.php diff --git a/app/code/core/Mage/Sales/Block/Order/Recent.php b/app/code/Mage/Sales/Block/Order/Recent.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Recent.php rename to app/code/Mage/Sales/Block/Order/Recent.php diff --git a/app/code/core/Mage/Sales/Block/Order/Shipment.php b/app/code/Mage/Sales/Block/Order/Shipment.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Shipment.php rename to app/code/Mage/Sales/Block/Order/Shipment.php diff --git a/app/code/core/Mage/Sales/Block/Order/Shipment/Items.php b/app/code/Mage/Sales/Block/Order/Shipment/Items.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Shipment/Items.php rename to app/code/Mage/Sales/Block/Order/Shipment/Items.php diff --git a/app/code/core/Mage/Sales/Block/Order/Totals.php b/app/code/Mage/Sales/Block/Order/Totals.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/Totals.php rename to app/code/Mage/Sales/Block/Order/Totals.php diff --git a/app/code/core/Mage/Sales/Block/Order/View.php b/app/code/Mage/Sales/Block/Order/View.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Order/View.php rename to app/code/Mage/Sales/Block/Order/View.php diff --git a/app/code/core/Mage/Sales/Block/Payment/Form/Billing/Agreement.php b/app/code/Mage/Sales/Block/Payment/Form/Billing/Agreement.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Payment/Form/Billing/Agreement.php rename to app/code/Mage/Sales/Block/Payment/Form/Billing/Agreement.php diff --git a/app/code/core/Mage/Sales/Block/Payment/Info/Billing/Agreement.php b/app/code/Mage/Sales/Block/Payment/Info/Billing/Agreement.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Payment/Info/Billing/Agreement.php rename to app/code/Mage/Sales/Block/Payment/Info/Billing/Agreement.php diff --git a/app/code/core/Mage/Sales/Block/Recurring/Profile/View.php b/app/code/Mage/Sales/Block/Recurring/Profile/View.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Recurring/Profile/View.php rename to app/code/Mage/Sales/Block/Recurring/Profile/View.php diff --git a/app/code/core/Mage/Sales/Block/Recurring/Profiles.php b/app/code/Mage/Sales/Block/Recurring/Profiles.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Recurring/Profiles.php rename to app/code/Mage/Sales/Block/Recurring/Profiles.php diff --git a/app/code/core/Mage/Sales/Block/Reorder/Sidebar.php b/app/code/Mage/Sales/Block/Reorder/Sidebar.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Reorder/Sidebar.php rename to app/code/Mage/Sales/Block/Reorder/Sidebar.php diff --git a/app/code/core/Mage/Sales/Block/Widget/Guest/Form.php b/app/code/Mage/Sales/Block/Widget/Guest/Form.php similarity index 100% rename from app/code/core/Mage/Sales/Block/Widget/Guest/Form.php rename to app/code/Mage/Sales/Block/Widget/Guest/Form.php diff --git a/app/code/core/Mage/Sales/Controller/Abstract.php b/app/code/Mage/Sales/Controller/Abstract.php similarity index 100% rename from app/code/core/Mage/Sales/Controller/Abstract.php rename to app/code/Mage/Sales/Controller/Abstract.php diff --git a/app/code/core/Mage/Sales/Exception.php b/app/code/Mage/Sales/Exception.php similarity index 100% rename from app/code/core/Mage/Sales/Exception.php rename to app/code/Mage/Sales/Exception.php diff --git a/app/code/core/Mage/Sales/Helper/Data.php b/app/code/Mage/Sales/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Sales/Helper/Data.php rename to app/code/Mage/Sales/Helper/Data.php diff --git a/app/code/core/Mage/Sales/Helper/Guest.php b/app/code/Mage/Sales/Helper/Guest.php similarity index 100% rename from app/code/core/Mage/Sales/Helper/Guest.php rename to app/code/Mage/Sales/Helper/Guest.php diff --git a/app/code/core/Mage/Sales/Helper/Reorder.php b/app/code/Mage/Sales/Helper/Reorder.php similarity index 100% rename from app/code/core/Mage/Sales/Helper/Reorder.php rename to app/code/Mage/Sales/Helper/Reorder.php diff --git a/app/code/core/Mage/Sales/Model/Abstract.php b/app/code/Mage/Sales/Model/Abstract.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Abstract.php rename to app/code/Mage/Sales/Model/Abstract.php diff --git a/app/code/core/Mage/Sales/Model/Api/Resource.php b/app/code/Mage/Sales/Model/Api/Resource.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Api/Resource.php rename to app/code/Mage/Sales/Model/Api/Resource.php diff --git a/app/code/core/Mage/Sales/Model/Billing/Agreement.php b/app/code/Mage/Sales/Model/Billing/Agreement.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Billing/Agreement.php rename to app/code/Mage/Sales/Model/Billing/Agreement.php diff --git a/app/code/core/Mage/Sales/Model/Billing/Agreement/OrdersUpdater.php b/app/code/Mage/Sales/Model/Billing/Agreement/OrdersUpdater.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Billing/Agreement/OrdersUpdater.php rename to app/code/Mage/Sales/Model/Billing/Agreement/OrdersUpdater.php diff --git a/app/code/core/Mage/Sales/Model/Config.php b/app/code/Mage/Sales/Model/Config.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Config.php rename to app/code/Mage/Sales/Model/Config.php diff --git a/app/code/core/Mage/Sales/Model/Config/Ordered.php b/app/code/Mage/Sales/Model/Config/Ordered.php similarity index 92% rename from app/code/core/Mage/Sales/Model/Config/Ordered.php rename to app/code/Mage/Sales/Model/Config/Ordered.php index 4513f6c4ee3da..a3a8fffdb9f87 100644 --- a/app/code/core/Mage/Sales/Model/Config/Ordered.php +++ b/app/code/Mage/Sales/Model/Config/Ordered.php @@ -68,6 +68,21 @@ abstract class Mage_Sales_Model_Config_Ordered extends Mage_Core_Model_Config_Ba */ protected $_collectors = array(); + /** + * @var Mage_Core_Model_Cache_Type_Config + */ + protected $_configCacheType; + + /** + * @param Mage_Core_Model_Cache_Type_Config $configCacheType + * @param Varien_Simplexml_Element $sourceData + */ + public function __construct(Mage_Core_Model_Cache_Type_Config $configCacheType, $sourceData = null) + { + parent::__construct($sourceData); + $this->_configCacheType = $configCacheType; + } + /** * Initialize total models configuration and objects * @@ -184,13 +199,10 @@ protected function _getSortedCollectorCodes(array $config) */ protected function _initCollectors() { - $useCache = Mage::app()->useCache('config'); $sortedCodes = array(); - if ($useCache) { - $cachedData = Mage::app()->loadCache($this->_collectorsCacheKey); - if ($cachedData) { - $sortedCodes = unserialize($cachedData); - } + $cachedData = $this->_configCacheType->load($this->_collectorsCacheKey); + if ($cachedData) { + $sortedCodes = unserialize($cachedData); } if (!$sortedCodes) { try { @@ -199,11 +211,7 @@ protected function _initCollectors() Mage::logException($e); } $sortedCodes = $this->_getSortedCollectorCodes($this->_modelsConfig); - if ($useCache) { - Mage::app()->saveCache(serialize($sortedCodes), $this->_collectorsCacheKey, array( - Mage_Core_Model_Config::CACHE_TAG - )); - } + $this->_configCacheType->save(serialize($sortedCodes), $this->_collectorsCacheKey); } foreach ($sortedCodes as $code) { $this->_collectors[$code] = $this->_models[$code]; diff --git a/app/code/core/Mage/Sales/Model/Config/Source/Order/Status.php b/app/code/Mage/Sales/Model/Config/Source/Order/Status.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Config/Source/Order/Status.php rename to app/code/Mage/Sales/Model/Config/Source/Order/Status.php diff --git a/app/code/core/Mage/Sales/Model/Config/Source/Order/Status/New.php b/app/code/Mage/Sales/Model/Config/Source/Order/Status/New.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Config/Source/Order/Status/New.php rename to app/code/Mage/Sales/Model/Config/Source/Order/Status/New.php diff --git a/app/code/core/Mage/Sales/Model/Config/Source/Order/Status/Newprocessing.php b/app/code/Mage/Sales/Model/Config/Source/Order/Status/Newprocessing.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Config/Source/Order/Status/Newprocessing.php rename to app/code/Mage/Sales/Model/Config/Source/Order/Status/Newprocessing.php diff --git a/app/code/core/Mage/Sales/Model/Config/Source/Order/Status/Processing.php b/app/code/Mage/Sales/Model/Config/Source/Order/Status/Processing.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Config/Source/Order/Status/Processing.php rename to app/code/Mage/Sales/Model/Config/Source/Order/Status/Processing.php diff --git a/app/code/core/Mage/Sales/Model/Convert/Order.php b/app/code/Mage/Sales/Model/Convert/Order.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Convert/Order.php rename to app/code/Mage/Sales/Model/Convert/Order.php diff --git a/app/code/core/Mage/Sales/Model/Convert/Quote.php b/app/code/Mage/Sales/Model/Convert/Quote.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Convert/Quote.php rename to app/code/Mage/Sales/Model/Convert/Quote.php diff --git a/app/code/core/Mage/Sales/Model/ConverterInterface.php b/app/code/Mage/Sales/Model/ConverterInterface.php similarity index 100% rename from app/code/core/Mage/Sales/Model/ConverterInterface.php rename to app/code/Mage/Sales/Model/ConverterInterface.php diff --git a/app/code/core/Mage/Sales/Model/Email/Template.php b/app/code/Mage/Sales/Model/Email/Template.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Email/Template.php rename to app/code/Mage/Sales/Model/Email/Template.php diff --git a/app/code/core/Mage/Sales/Model/Observer.php b/app/code/Mage/Sales/Model/Observer.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Observer.php rename to app/code/Mage/Sales/Model/Observer.php diff --git a/app/code/core/Mage/Sales/Model/Order.php b/app/code/Mage/Sales/Model/Order.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order.php rename to app/code/Mage/Sales/Model/Order.php diff --git a/app/code/core/Mage/Sales/Model/Order/Address.php b/app/code/Mage/Sales/Model/Order/Address.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Address.php rename to app/code/Mage/Sales/Model/Order/Address.php diff --git a/app/code/core/Mage/Sales/Model/Order/Api.php b/app/code/Mage/Sales/Model/Order/Api.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Api.php rename to app/code/Mage/Sales/Model/Order/Api.php diff --git a/app/code/core/Mage/Sales/Model/Order/Api/V2.php b/app/code/Mage/Sales/Model/Order/Api/V2.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Api/V2.php rename to app/code/Mage/Sales/Model/Order/Api/V2.php diff --git a/app/code/core/Mage/Sales/Model/Order/Config.php b/app/code/Mage/Sales/Model/Order/Config.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Config.php rename to app/code/Mage/Sales/Model/Order/Config.php diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php b/app/code/Mage/Sales/Model/Order/Creditmemo.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Creditmemo.php rename to app/code/Mage/Sales/Model/Order/Creditmemo.php diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Api.php b/app/code/Mage/Sales/Model/Order/Creditmemo/Api.php similarity index 99% rename from app/code/core/Mage/Sales/Model/Order/Creditmemo/Api.php rename to app/code/Mage/Sales/Model/Order/Creditmemo/Api.php index f79941ae3885e..c8890e688c23b 100644 --- a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Api.php +++ b/app/code/Mage/Sales/Model/Order/Creditmemo/Api.php @@ -124,7 +124,7 @@ public function create($orderIncrementId, $creditmemoData = null, $comment = nul $creditmemoData = $this->_prepareCreateData($creditmemoData); /** @var $service Mage_Sales_Model_Service_Order */ - $service = Mage::getModel('Mage_Sales_Model_Service_Order', $order); + $service = Mage::getModel('Mage_Sales_Model_Service_Order', array('order' => $order)); /** @var $creditmemo Mage_Sales_Model_Order_Creditmemo */ $creditmemo = $service->prepareCreditmemo($creditmemoData); diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Api/V2.php b/app/code/Mage/Sales/Model/Order/Creditmemo/Api/V2.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Creditmemo/Api/V2.php rename to app/code/Mage/Sales/Model/Order/Creditmemo/Api/V2.php diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Comment.php b/app/code/Mage/Sales/Model/Order/Creditmemo/Comment.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Creditmemo/Comment.php rename to app/code/Mage/Sales/Model/Order/Creditmemo/Comment.php diff --git a/app/code/Mage/Sales/Model/Order/Creditmemo/Config.php b/app/code/Mage/Sales/Model/Order/Creditmemo/Config.php new file mode 100644 index 0000000000000..5f7622dcaced3 --- /dev/null +++ b/app/code/Mage/Sales/Model/Order/Creditmemo/Config.php @@ -0,0 +1,52 @@ + + */ +class Mage_Sales_Model_Order_Creditmemo_Config extends Mage_Sales_Model_Order_Total_Config_Base +{ + /** + * Cache key for collectors + * + * @var string + */ + protected $_collectorsCacheKey = 'sorted_order_creditmemo_collectors'; + + /** + * Constructor + * + * @param Mage_Core_Model_Cache_Type_Config $configCacheType + */ + public function __construct(Mage_Core_Model_Cache_Type_Config $configCacheType) + { + parent::__construct($configCacheType, Mage::getConfig()->getNode('global/sales/order_creditmemo')); + } +} diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php b/app/code/Mage/Sales/Model/Order/Creditmemo/Item.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php rename to app/code/Mage/Sales/Model/Order/Creditmemo/Item.php diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Abstract.php b/app/code/Mage/Sales/Model/Order/Creditmemo/Total/Abstract.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Abstract.php rename to app/code/Mage/Sales/Model/Order/Creditmemo/Total/Abstract.php diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Cost.php b/app/code/Mage/Sales/Model/Order/Creditmemo/Total/Cost.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Cost.php rename to app/code/Mage/Sales/Model/Order/Creditmemo/Total/Cost.php diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Discount.php b/app/code/Mage/Sales/Model/Order/Creditmemo/Total/Discount.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Discount.php rename to app/code/Mage/Sales/Model/Order/Creditmemo/Total/Discount.php diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Grand.php b/app/code/Mage/Sales/Model/Order/Creditmemo/Total/Grand.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Grand.php rename to app/code/Mage/Sales/Model/Order/Creditmemo/Total/Grand.php diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Shipping.php b/app/code/Mage/Sales/Model/Order/Creditmemo/Total/Shipping.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Shipping.php rename to app/code/Mage/Sales/Model/Order/Creditmemo/Total/Shipping.php diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Subtotal.php b/app/code/Mage/Sales/Model/Order/Creditmemo/Total/Subtotal.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Subtotal.php rename to app/code/Mage/Sales/Model/Order/Creditmemo/Total/Subtotal.php diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Tax.php b/app/code/Mage/Sales/Model/Order/Creditmemo/Total/Tax.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Tax.php rename to app/code/Mage/Sales/Model/Order/Creditmemo/Total/Tax.php diff --git a/app/code/core/Mage/Sales/Model/Order/Grid/Massaction/ItemsUpdater.php b/app/code/Mage/Sales/Model/Order/Grid/Massaction/ItemsUpdater.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Grid/Massaction/ItemsUpdater.php rename to app/code/Mage/Sales/Model/Order/Grid/Massaction/ItemsUpdater.php diff --git a/app/code/core/Mage/Sales/Model/Order/Grid/Row/UrlGenerator.php b/app/code/Mage/Sales/Model/Order/Grid/Row/UrlGenerator.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Grid/Row/UrlGenerator.php rename to app/code/Mage/Sales/Model/Order/Grid/Row/UrlGenerator.php diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice.php b/app/code/Mage/Sales/Model/Order/Invoice.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Invoice.php rename to app/code/Mage/Sales/Model/Order/Invoice.php diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice/Api.php b/app/code/Mage/Sales/Model/Order/Invoice/Api.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Invoice/Api.php rename to app/code/Mage/Sales/Model/Order/Invoice/Api.php diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice/Api/V2.php b/app/code/Mage/Sales/Model/Order/Invoice/Api/V2.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Invoice/Api/V2.php rename to app/code/Mage/Sales/Model/Order/Invoice/Api/V2.php diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice/Comment.php b/app/code/Mage/Sales/Model/Order/Invoice/Comment.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Invoice/Comment.php rename to app/code/Mage/Sales/Model/Order/Invoice/Comment.php diff --git a/app/code/Mage/Sales/Model/Order/Invoice/Config.php b/app/code/Mage/Sales/Model/Order/Invoice/Config.php new file mode 100644 index 0000000000000..bf98de91002b3 --- /dev/null +++ b/app/code/Mage/Sales/Model/Order/Invoice/Config.php @@ -0,0 +1,52 @@ + + */ +class Mage_Sales_Model_Order_Invoice_Config extends Mage_Sales_Model_Order_Total_Config_Base +{ + /** + * Cache key for collectors + * + * @var string + */ + protected $_collectorsCacheKey = 'sorted_order_invoice_collectors'; + + /** + * Constructor + * + * @param Mage_Core_Model_Cache_Type_Config $configCacheType + */ + public function __construct(Mage_Core_Model_Cache_Type_Config $configCacheType) + { + parent::__construct($configCacheType, Mage::getConfig()->getNode('global/sales/order_invoice')); + } +} diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice/Item.php b/app/code/Mage/Sales/Model/Order/Invoice/Item.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Invoice/Item.php rename to app/code/Mage/Sales/Model/Order/Invoice/Item.php diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice/Total/Abstract.php b/app/code/Mage/Sales/Model/Order/Invoice/Total/Abstract.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Invoice/Total/Abstract.php rename to app/code/Mage/Sales/Model/Order/Invoice/Total/Abstract.php diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice/Total/Cost.php b/app/code/Mage/Sales/Model/Order/Invoice/Total/Cost.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Invoice/Total/Cost.php rename to app/code/Mage/Sales/Model/Order/Invoice/Total/Cost.php diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice/Total/Discount.php b/app/code/Mage/Sales/Model/Order/Invoice/Total/Discount.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Invoice/Total/Discount.php rename to app/code/Mage/Sales/Model/Order/Invoice/Total/Discount.php diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice/Total/Grand.php b/app/code/Mage/Sales/Model/Order/Invoice/Total/Grand.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Invoice/Total/Grand.php rename to app/code/Mage/Sales/Model/Order/Invoice/Total/Grand.php diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice/Total/Shipping.php b/app/code/Mage/Sales/Model/Order/Invoice/Total/Shipping.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Invoice/Total/Shipping.php rename to app/code/Mage/Sales/Model/Order/Invoice/Total/Shipping.php diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice/Total/Subtotal.php b/app/code/Mage/Sales/Model/Order/Invoice/Total/Subtotal.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Invoice/Total/Subtotal.php rename to app/code/Mage/Sales/Model/Order/Invoice/Total/Subtotal.php diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice/Total/Tax.php b/app/code/Mage/Sales/Model/Order/Invoice/Total/Tax.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Invoice/Total/Tax.php rename to app/code/Mage/Sales/Model/Order/Invoice/Total/Tax.php diff --git a/app/code/core/Mage/Sales/Model/Order/Item.php b/app/code/Mage/Sales/Model/Order/Item.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Item.php rename to app/code/Mage/Sales/Model/Order/Item.php diff --git a/app/code/core/Mage/Sales/Model/Order/Payment.php b/app/code/Mage/Sales/Model/Order/Payment.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Payment.php rename to app/code/Mage/Sales/Model/Order/Payment.php diff --git a/app/code/core/Mage/Sales/Model/Order/Payment/Transaction.php b/app/code/Mage/Sales/Model/Order/Payment/Transaction.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Payment/Transaction.php rename to app/code/Mage/Sales/Model/Order/Payment/Transaction.php diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php b/app/code/Mage/Sales/Model/Order/Pdf/Abstract.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php rename to app/code/Mage/Sales/Model/Order/Pdf/Abstract.php diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Creditmemo.php b/app/code/Mage/Sales/Model/Order/Pdf/Creditmemo.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Pdf/Creditmemo.php rename to app/code/Mage/Sales/Model/Order/Pdf/Creditmemo.php diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Invoice.php b/app/code/Mage/Sales/Model/Order/Pdf/Invoice.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Pdf/Invoice.php rename to app/code/Mage/Sales/Model/Order/Pdf/Invoice.php diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Abstract.php b/app/code/Mage/Sales/Model/Order/Pdf/Items/Abstract.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Pdf/Items/Abstract.php rename to app/code/Mage/Sales/Model/Order/Pdf/Items/Abstract.php diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Creditmemo/Default.php b/app/code/Mage/Sales/Model/Order/Pdf/Items/Creditmemo/Default.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Pdf/Items/Creditmemo/Default.php rename to app/code/Mage/Sales/Model/Order/Pdf/Items/Creditmemo/Default.php diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Creditmemo/Grouped.php b/app/code/Mage/Sales/Model/Order/Pdf/Items/Creditmemo/Grouped.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Pdf/Items/Creditmemo/Grouped.php rename to app/code/Mage/Sales/Model/Order/Pdf/Items/Creditmemo/Grouped.php diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php b/app/code/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php rename to app/code/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Grouped.php b/app/code/Mage/Sales/Model/Order/Pdf/Items/Invoice/Grouped.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Grouped.php rename to app/code/Mage/Sales/Model/Order/Pdf/Items/Invoice/Grouped.php diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Shipment/Default.php b/app/code/Mage/Sales/Model/Order/Pdf/Items/Shipment/Default.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Pdf/Items/Shipment/Default.php rename to app/code/Mage/Sales/Model/Order/Pdf/Items/Shipment/Default.php diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Shipment.php b/app/code/Mage/Sales/Model/Order/Pdf/Shipment.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Pdf/Shipment.php rename to app/code/Mage/Sales/Model/Order/Pdf/Shipment.php diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Shipment/Packaging.php b/app/code/Mage/Sales/Model/Order/Pdf/Shipment/Packaging.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Pdf/Shipment/Packaging.php rename to app/code/Mage/Sales/Model/Order/Pdf/Shipment/Packaging.php diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Total/Default.php b/app/code/Mage/Sales/Model/Order/Pdf/Total/Default.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Pdf/Total/Default.php rename to app/code/Mage/Sales/Model/Order/Pdf/Total/Default.php diff --git a/app/code/core/Mage/Sales/Model/Order/Shipment.php b/app/code/Mage/Sales/Model/Order/Shipment.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Shipment.php rename to app/code/Mage/Sales/Model/Order/Shipment.php diff --git a/app/code/core/Mage/Sales/Model/Order/Shipment/Api.php b/app/code/Mage/Sales/Model/Order/Shipment/Api.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Shipment/Api.php rename to app/code/Mage/Sales/Model/Order/Shipment/Api.php diff --git a/app/code/core/Mage/Sales/Model/Order/Shipment/Api/V2.php b/app/code/Mage/Sales/Model/Order/Shipment/Api/V2.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Shipment/Api/V2.php rename to app/code/Mage/Sales/Model/Order/Shipment/Api/V2.php diff --git a/app/code/core/Mage/Sales/Model/Order/Shipment/Comment.php b/app/code/Mage/Sales/Model/Order/Shipment/Comment.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Shipment/Comment.php rename to app/code/Mage/Sales/Model/Order/Shipment/Comment.php diff --git a/app/code/core/Mage/Sales/Model/Order/Shipment/Item.php b/app/code/Mage/Sales/Model/Order/Shipment/Item.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Shipment/Item.php rename to app/code/Mage/Sales/Model/Order/Shipment/Item.php diff --git a/app/code/core/Mage/Sales/Model/Order/Shipment/Track.php b/app/code/Mage/Sales/Model/Order/Shipment/Track.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Shipment/Track.php rename to app/code/Mage/Sales/Model/Order/Shipment/Track.php diff --git a/app/code/core/Mage/Sales/Model/Order/Status.php b/app/code/Mage/Sales/Model/Order/Status.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Status.php rename to app/code/Mage/Sales/Model/Order/Status.php diff --git a/app/code/core/Mage/Sales/Model/Order/Status/History.php b/app/code/Mage/Sales/Model/Order/Status/History.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Status/History.php rename to app/code/Mage/Sales/Model/Order/Status/History.php diff --git a/app/code/core/Mage/Sales/Model/Order/Tax.php b/app/code/Mage/Sales/Model/Order/Tax.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Tax.php rename to app/code/Mage/Sales/Model/Order/Tax.php diff --git a/app/code/core/Mage/Sales/Model/Order/Total.php b/app/code/Mage/Sales/Model/Order/Total.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Total.php rename to app/code/Mage/Sales/Model/Order/Total.php diff --git a/app/code/core/Mage/Sales/Model/Order/Total/Abstract.php b/app/code/Mage/Sales/Model/Order/Total/Abstract.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Total/Abstract.php rename to app/code/Mage/Sales/Model/Order/Total/Abstract.php diff --git a/app/code/core/Mage/Sales/Model/Order/Total/Config/Base.php b/app/code/Mage/Sales/Model/Order/Total/Config/Base.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Order/Total/Config/Base.php rename to app/code/Mage/Sales/Model/Order/Total/Config/Base.php diff --git a/app/code/Mage/Sales/Model/Order/Webhook/Observer.php b/app/code/Mage/Sales/Model/Order/Webhook/Observer.php new file mode 100644 index 0000000000000..bf385a406703b --- /dev/null +++ b/app/code/Mage/Sales/Model/Order/Webhook/Observer.php @@ -0,0 +1,143 @@ + + */ +class Mage_Sales_Model_Order_Webhook_Observer +{ + public function dispatchOrderCreatedEvent($observer) + { + try { + $order = $observer->getEvent()->getOrder(); + + if ($order->getState() == Mage_Sales_Model_Order::STATE_COMPLETE) { + $isCompleted = $this->_isValueRegistered('webhook_order_completed', $order->getId()); + if (!$isCompleted) { + $this->_registerValue('webhook_order_completed', $order->getId()); + Mage::helper('Mage_Webhook_Helper_Data')->dispatchEvent( + 'order/created', + array('order' => $order, 'shipping_address' => $order->getShippingAddress()) + ); + } + } + } catch (Exception $exception) { + $this->_handleException($exception); + } + return $this; + } + + /** The following functions belong in a parent class or helper method */ + /** + * Sets a value in the Mage::registry with a key based on registerName and key. + * + * @param $registerName Mage::register name to use + * @param $key The key in the Mage::register array used + * @param $value the value to set + */ + protected function _registerKeyValue($registerName, $key, $value) + { + $array = Mage::registry($registerName); + + if (!isset($array)) { + $array = array(); + } else { + /* yes, unregister it so that we can push it back on */ + Mage::unregister($registerName); + } + + $array[$key] = $value; + + Mage::register($registerName, $array); + } + + /** + * Gets the value registered in the Mage::registry and the key (e.g. order id). + * + * @param $registerName Mage::register name to use + * @param $key The key in the Mage::register array used + * @return the value registered, null if no value + */ + protected function _getRegisterValueForKey($registerName, $key) + { + $array = Mage::registry($registerName); + + if (isset($array)) { + if (isset($array[$key])) { + return $array[$key]; + } + } + + return null; + } + + /** + * Registers a value (such as an order or product id) in an array acting + * as a set. + * + * @param $registerName Mage::register name to use + * @param $value The value (e.g. id) to put in the set + */ + protected function _registerValue($registerName, $value) + { + $set = Mage::registry($registerName); + + if (!isset($set)) { + $set = array(); + } else { + /* yes, unregister it so that we can push it back on */ + Mage::unregister($registerName); + } + + if (!in_array($value, $set)) { + array_push($set, $value); + } + + Mage::register($registerName, $set); + } + + /** + * Determines if a value has been registered + * + * @param $registerName Mage::register name to use + * @param $value The value (e.g. id) to put in the set + * @return true if the value is in the set, false otherwise + */ + protected function _isValueRegistered($registerName, $value) + { + $set = Mage::registry($registerName); + if (isset($set) && in_array($value, $set)) { + return true; + } + + return false; + } +} diff --git a/app/code/core/Mage/Sales/Model/Payment/Method/Billing/AgreementAbstract.php b/app/code/Mage/Sales/Model/Payment/Method/Billing/AgreementAbstract.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Payment/Method/Billing/AgreementAbstract.php rename to app/code/Mage/Sales/Model/Payment/Method/Billing/AgreementAbstract.php diff --git a/app/code/core/Mage/Sales/Model/Payment/Method/Converter.php b/app/code/Mage/Sales/Model/Payment/Method/Converter.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Payment/Method/Converter.php rename to app/code/Mage/Sales/Model/Payment/Method/Converter.php diff --git a/app/code/core/Mage/Sales/Model/Quote.php b/app/code/Mage/Sales/Model/Quote.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Quote.php rename to app/code/Mage/Sales/Model/Quote.php diff --git a/app/code/Mage/Sales/Model/Quote/Address.php b/app/code/Mage/Sales/Model/Quote/Address.php new file mode 100644 index 0000000000000..4e2edf8cd9f78 --- /dev/null +++ b/app/code/Mage/Sales/Model/Quote/Address.php @@ -0,0 +1,1185 @@ + + */ +class Mage_Sales_Model_Quote_Address extends Mage_Customer_Model_Address_Abstract +{ + const RATES_FETCH = 1; + const RATES_RECALCULATE = 2; + + /** + * Prefix of model events + * + * @var string + */ + protected $_eventPrefix = 'sales_quote_address'; + + /** + * Name of event object + * + * @var string + */ + protected $_eventObject = 'quote_address'; + + /** + * Quote object + * + * @var Mage_Sales_Model_Quote + */ + protected $_items = null; + + /** + * Quote object + * + * @var Mage_Sales_Model_Quote + */ + protected $_quote = null; + + /** + * Sales Quote address rates + * + * @var Mage_Sales_Model_Quote_Address_Rate + */ + protected $_rates = null; + + /** + * Total models collector + * + * @var Mage_Sales_Model_Quote_Address_Totla_Collector + */ + protected $_totalCollector = null; + + /** + * Total data as array + * + * @var array + */ + protected $_totals = array(); + + protected $_totalAmounts = array(); + protected $_baseTotalAmounts = array(); + + /** + * Whether to segregate by nominal items only + * + * @var bool + */ + protected $_nominalOnly = null; + + /** + * Initialize resource + */ + protected function _construct() + { + $this->_init('Mage_Sales_Model_Resource_Quote_Address'); + } + + /** + * Initialize quote identifier before save + * + * @return Mage_Sales_Model_Quote_Address + */ + protected function _beforeSave() + { + parent::_beforeSave(); + if ($this->getQuote()) { + $quoteId = $this->getQuote()->getId(); + if ($quoteId) { + $this->setQuoteId($quoteId); + } else { + $this->_dataSaveAllowed = false; + } + $this->setCustomerId($this->getQuote()->getCustomerId()); + /** + * Init customer address id if customer address is assigned + */ + if ($this->getCustomerAddress()) { + $this->setCustomerAddressId($this->getCustomerAddress()->getId()); + } + } + if ($this->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_SHIPPING + && $this->getSameAsBilling() === null + ) { + $this->setSameAsBilling(1); + } + return $this; + } + + /** + * Save child collections + * + * @return Mage_Sales_Model_Quote_Address + */ + protected function _afterSave() + { + parent::_afterSave(); + if (null !== $this->_items) { + $this->getItemsCollection()->save(); + } + if (null !== $this->_rates) { + $this->getShippingRatesCollection()->save(); + } + return $this; + } + + /** + * Declare adress quote model object + * + * @param Mage_Sales_Model_Quote $quote + * @return Mage_Sales_Model_Quote_Address + */ + public function setQuote(Mage_Sales_Model_Quote $quote) + { + $this->_quote = $quote; + $this->setQuoteId($quote->getId()); + return $this; + } + + /** + * Retrieve quote object + * + * @return Mage_Sales_Model_Quote + */ + public function getQuote() + { + return $this->_quote; + } + + /** + * Import quote address data from customer address object + * + * @param Mage_Customer_Model_Address $address + * @return Mage_Sales_Model_Quote_Address + */ + public function importCustomerAddress(Mage_Customer_Model_Address $address) + { + Mage::helper('Mage_Core_Helper_Data')->copyFieldset('customer_address', 'to_quote_address', $address, $this); + $email = null; + if ($address->hasEmail()) { + $email = $address->getEmail(); + } + elseif ($address->getCustomer()) { + $email = $address->getCustomer()->getEmail(); + } + if ($email) { + $this->setEmail($email); + } + return $this; + } + + /** + * Export data to customer address object + * + * @return Mage_Customer_Model_Address + */ + public function exportCustomerAddress() + { + $address = Mage::getModel('Mage_Customer_Model_Address'); + Mage::helper('Mage_Core_Helper_Data')->copyFieldset('sales_convert_quote_address', 'to_customer_address', $this, $address); + return $address; + } + + /** + * Import address data from order address + * + * @param Mage_Sales_Model_Order_Address $address + * @return Mage_Sales_Model_Quote_Address + */ + public function importOrderAddress(Mage_Sales_Model_Order_Address $address) + { + $this->setAddressType($address->getAddressType()) + ->setCustomerId($address->getCustomerId()) + ->setCustomerAddressId($address->getCustomerAddressId()) + ->setEmail($address->getEmail()); + + Mage::helper('Mage_Core_Helper_Data')->copyFieldset('sales_convert_order_address', 'to_quote_address', $address, $this); + + return $this; + } + + /** + * Convert object to array + * + * @param array $arrAttributes + * @return array + */ + public function toArray(array $arrAttributes = array()) + { + $arr = parent::toArray($arrAttributes); + $arr['rates'] = $this->getShippingRatesCollection()->toArray($arrAttributes); + $arr['items'] = $this->getItemsCollection()->toArray($arrAttributes); + foreach ($this->getTotals() as $k=>$total) { + $arr['totals'][$k] = $total->toArray(); + } + return $arr; + } + + /** + * Retrieve address items collection + * + * @return Mage_Eav_Model_Entity_Collection_Abstract + */ + public function getItemsCollection() + { + if (is_null($this->_items)) { + $this->_items = Mage::getModel('Mage_Sales_Model_Quote_Address_Item')->getCollection() + ->setAddressFilter($this->getId()); + + if ($this->getId()) { + foreach ($this->_items as $item) { + $item->setAddress($this); + } + } + } + return $this->_items; + } + + /** + * Get all available address items + * + * @return array + */ + public function getAllItems() + { + // We calculate item list once and cache it in three arrays - all items, nominal, non-nominal + $cachedItems = $this->_nominalOnly ? 'nominal' : ($this->_nominalOnly === false ? 'nonnominal' : 'all'); + $key = 'cached_items_' . $cachedItems; + if (!$this->hasData($key)) { + // For compatibility we will use $this->_filterNominal to divide nominal items from non-nominal + // (because it can be overloaded) + // So keep current flag $this->_nominalOnly and restore it after cycle + $wasNominal = $this->_nominalOnly; + $this->_nominalOnly = true; // Now $this->_filterNominal() will return positive values for nominal items + + $quoteItems = $this->getQuote()->getItemsCollection(); + $addressItems = $this->getItemsCollection(); + + $items = array(); + $nominalItems = array(); + $nonNominalItems = array(); + if ($this->getQuote()->getIsMultiShipping() && $addressItems->count() > 0) { + foreach ($addressItems as $aItem) { + if ($aItem->isDeleted()) { + continue; + } + + if (!$aItem->getQuoteItemImported()) { + $qItem = $this->getQuote()->getItemById($aItem->getQuoteItemId()); + if ($qItem) { + $aItem->importQuoteItem($qItem); + } + } + $items[] = $aItem; + if ($this->_filterNominal($aItem)) { + $nominalItems[] = $aItem; + } else { + $nonNominalItems[] = $aItem; + } + } + } else { + /* + * For virtual quote we assign items only to billing address, otherwise - only to shipping address + */ + $addressType = $this->getAddressType(); + $canAddItems = $this->getQuote()->isVirtual() + ? ($addressType == self::TYPE_BILLING) + : ($addressType == self::TYPE_SHIPPING); + + if ($canAddItems) { + foreach ($quoteItems as $qItem) { + if ($qItem->isDeleted()) { + continue; + } + $items[] = $qItem; + if ($this->_filterNominal($qItem)) { + $nominalItems[] = $qItem; + } else { + $nonNominalItems[] = $qItem; + } + } + } + } + + // Cache calculated lists + $this->setData('cached_items_all', $items); + $this->setData('cached_items_nominal', $nominalItems); + $this->setData('cached_items_nonnominal', $nonNominalItems); + + $this->_nominalOnly = $wasNominal; // Restore original value before we changed it + } + + $items = $this->getData($key); + return $items; + } + + /** + * Getter for all non-nominal items + * + * @return array + */ + public function getAllNonNominalItems() + { + $this->_nominalOnly = false; + $result = $this->getAllItems(); + $this->_nominalOnly = null; + return $result; + } + + /** + * Getter for all nominal items + * + * @return array + */ + public function getAllNominalItems() + { + $this->_nominalOnly = true; + $result = $this->getAllItems(); + $this->_nominalOnly = null; + return $result; + } + + /** + * Segregate by nominal criteria + * + * true: get nominals only + * false: get non-nominals only + * null: get all + * + * @param Mage_Sales_Model_Quote_Item_Abstract + * @return Mage_Sales_Model_Quote_Item_Abstract|false + */ + protected function _filterNominal($item) + { + return (null === $this->_nominalOnly) + || ((false === $this->_nominalOnly) && !$item->isNominal()) + || ((true === $this->_nominalOnly) && $item->isNominal()) + ? $item : false; + } + + /** + * Retrieve all visible items + * + * @return array + */ + public function getAllVisibleItems() + { + $items = array(); + foreach ($this->getAllItems() as $item) { + if (!$item->getParentItemId()) { + $items[] = $item; + } + } + return $items; + } + + /** + * Retrieve item quantity by id + * + * @param int $itemId + * @return float|int + */ + public function getItemQty($itemId = 0) + { + if ($this->hasData('item_qty')) { + return $this->getData('item_qty'); + } + + $qty = 0; + if ($itemId == 0) { + foreach ($this->getAllItems() as $item) { + $qty += $item->getQty(); + } + } else { + $item = $this->getItemById($itemId); + if ($item) { + $qty = $item->getQty(); + } + } + return $qty; + } + + /** + * Check Quote address has Items + * + * @return bool + */ + public function hasItems() + { + return sizeof($this->getAllItems())>0; + } + + /** + * Get address item object by id without + * + * @param int $itemId + * @return Mage_Sales_Model_Quote_Address_Item + */ + public function getItemById($itemId) + { + foreach ($this->getItemsCollection() as $item) { + if ($item->getId()==$itemId) { + return $item; + } + } + return false; + } + + /** + * Get prepared not deleted item + * + * @param $itemId + * @return Mage_Sales_Model_Quote_Address_Item + */ + public function getValidItemById($itemId) + { + foreach ($this->getAllItems() as $item) { + if ($item->getId()==$itemId) { + return $item; + } + } + return false; + } + + /** + * Retrieve item object by quote item Id + * + * @param int $itemId + * @return Mage_Sales_Model_Quote_Address_Item + */ + public function getItemByQuoteItemId($itemId) + { + foreach ($this->getItemsCollection() as $item) { + if ($item->getQuoteItemId()==$itemId) { + return $item; + } + } + return false; + } + + /** + * Remove item from collection + * + * @param int $itemId + * @return Mage_Sales_Model_Quote_Address + */ + public function removeItem($itemId) + { + $item = $this->getItemById($itemId); + if ($item) { + $item->isDeleted(true); + } + return $this; + } + + /** + * Add item to address + * + * @param Mage_Sales_Model_Quote_Item_Abstract $item + * @param int $qty + * @return Mage_Sales_Model_Quote_Address + */ + public function addItem(Mage_Sales_Model_Quote_Item_Abstract $item, $qty=null) + { + if ($item instanceof Mage_Sales_Model_Quote_Item) { + if ($item->getParentItemId()) { + return $this; + } + $addressItem = Mage::getModel('Mage_Sales_Model_Quote_Address_Item') + ->setAddress($this) + ->importQuoteItem($item); + $this->getItemsCollection()->addItem($addressItem); + + if ($item->getHasChildren()) { + foreach ($item->getChildren() as $child) { + $addressChildItem = Mage::getModel('Mage_Sales_Model_Quote_Address_Item') + ->setAddress($this) + ->importQuoteItem($child) + ->setParentItem($addressItem); + $this->getItemsCollection()->addItem($addressChildItem); + } + } + } + else { + $addressItem = $item; + $addressItem->setAddress($this); + if (!$addressItem->getId()) { + $this->getItemsCollection()->addItem($addressItem); + } + } + + if ($qty) { + $addressItem->setQty($qty); + } + return $this; + } + + /** + * Retrieve collection of quote shipping rates + * + * @return Mage_Eav_Model_Entity_Collection_Abstract + */ + public function getShippingRatesCollection() + { + if (is_null($this->_rates)) { + $this->_rates = Mage::getModel('Mage_Sales_Model_Quote_Address_Rate')->getCollection() + ->setAddressFilter($this->getId()); + if ($this->getQuote()->hasNominalItems(false)) { + $this->_rates->setFixedOnlyFilter(true); + } + if ($this->getId()) { + foreach ($this->_rates as $rate) { + $rate->setAddress($this); + } + } + } + return $this->_rates; + } + + /** + * Retrieve all address shipping rates + * + * @return array + */ + public function getAllShippingRates() + { + $rates = array(); + foreach ($this->getShippingRatesCollection() as $rate) { + if (!$rate->isDeleted()) { + $rates[] = $rate; + } + } + return $rates; + } + + /** + * Retrieve all grouped shipping rates + * + * @return array + */ + public function getGroupedAllShippingRates() + { + $rates = array(); + foreach ($this->getShippingRatesCollection() as $rate) { + if (!$rate->isDeleted() && $rate->getCarrierInstance()) { + if (!isset($rates[$rate->getCarrier()])) { + $rates[$rate->getCarrier()] = array(); + } + + $rates[$rate->getCarrier()][] = $rate; + $rates[$rate->getCarrier()][0]->carrier_sort_order = $rate->getCarrierInstance()->getSortOrder(); + } + } + uasort($rates, array($this, '_sortRates')); + return $rates; + } + + /** + * Sort rates recursive callback + * + * @param array $a + * @param array $b + * @return int + */ + protected function _sortRates($a, $b) + { + if ((int)$a[0]->carrier_sort_order < (int)$b[0]->carrier_sort_order) { + return -1; + } + elseif ((int)$a[0]->carrier_sort_order > (int)$b[0]->carrier_sort_order) { + return 1; + } + else { + return 0; + } + } + + /** + * Retrieve shipping rate by identifier + * + * @param int $rateId + * @return Mage_Sales_Model_Quote_Address_Rate | false + */ + public function getShippingRateById($rateId) + { + foreach ($this->getShippingRatesCollection() as $rate) { + if ($rate->getId()==$rateId) { + return $rate; + } + } + return false; + } + + /** + * Retrieve shipping rate by code + * + * @param string $code + * @return Mage_Sales_Model_Quote_Address_Rate + */ + public function getShippingRateByCode($code) + { + foreach ($this->getShippingRatesCollection() as $rate) { + if ($rate->getCode()==$code) { + return $rate; + } + } + return false; + } + + /** + * Mark all shipping rates as deleted + * + * @return Mage_Sales_Model_Quote_Address + */ + public function removeAllShippingRates() + { + foreach ($this->getShippingRatesCollection() as $rate) { + $rate->isDeleted(true); + } + return $this; + } + + /** + * Add shipping rate + * + * @param Mage_Sales_Model_Quote_Address_Rate $rate + * @return Mage_Sales_Model_Quote_Address + */ + public function addShippingRate(Mage_Sales_Model_Quote_Address_Rate $rate) + { + $rate->setAddress($this); + $this->getShippingRatesCollection()->addItem($rate); + return $this; + } + + /** + * Collecting shipping rates by address + * + * @return Mage_Sales_Model_Quote_Address + */ + public function collectShippingRates() + { + if (!$this->getCollectShippingRates()) { + return $this; + } + + $this->setCollectShippingRates(false); + + $this->removeAllShippingRates(); + + if (!$this->getCountryId()) { + return $this; + } + + $found = $this->requestShippingRates(); + if (!$found) { + $this->setShippingAmount(0) + ->setBaseShippingAmount(0) + ->setShippingMethod('') + ->setShippingDescription(''); + } + + return $this; + } + + /** + * Request shipping rates for entire address or specified address item + * Returns true if current selected shipping method code corresponds to one of the found rates + * + * @param Mage_Sales_Model_Quote_Item_Abstract $item + * @return bool + */ + public function requestShippingRates(Mage_Sales_Model_Quote_Item_Abstract $item = null) + { + /** @var $request Mage_Shipping_Model_Rate_Request */ + $request = Mage::getModel('Mage_Shipping_Model_Rate_Request'); + $request->setAllItems($item ? array($item) : $this->getAllItems()); + $request->setDestCountryId($this->getCountryId()); + $request->setDestRegionId($this->getRegionId()); + $request->setDestRegionCode($this->getRegionCode()); + /** + * need to call getStreet with -1 + * to get data in string instead of array + */ + $request->setDestStreet($this->getStreet(-1)); + $request->setDestCity($this->getCity()); + $request->setDestPostcode($this->getPostcode()); + $request->setPackageValue($item ? $item->getBaseRowTotal() : $this->getBaseSubtotal()); + $packageValueWithDiscount = $item + ? $item->getBaseRowTotal() - $item->getBaseDiscountAmount() + : $this->getBaseSubtotalWithDiscount(); + $request->setPackageValueWithDiscount($packageValueWithDiscount); + $request->setPackageWeight($item ? $item->getRowWeight() : $this->getWeight()); + $request->setPackageQty($item ? $item->getQty() : $this->getItemQty()); + + /** + * Need for shipping methods that use insurance based on price of physical products + */ + $packagePhysicalValue = $item + ? $item->getBaseRowTotal() + : $this->getBaseSubtotal() - $this->getBaseVirtualAmount(); + $request->setPackagePhysicalValue($packagePhysicalValue); + + $request->setFreeMethodWeight($item ? 0 : $this->getFreeMethodWeight()); + + /** + * Store and website identifiers need specify from quote + */ + /*$request->setStoreId(Mage::app()->getStore()->getId()); + $request->setWebsiteId(Mage::app()->getStore()->getWebsiteId());*/ + + $request->setStoreId($this->getQuote()->getStore()->getId()); + $request->setWebsiteId($this->getQuote()->getStore()->getWebsiteId()); + $request->setFreeShipping($this->getFreeShipping()); + /** + * Currencies need to convert in free shipping + */ + $request->setBaseCurrency($this->getQuote()->getStore()->getBaseCurrency()); + $request->setPackageCurrency($this->getQuote()->getStore()->getCurrentCurrency()); + $request->setLimitCarrier($this->getLimitCarrier()); + + $request->setBaseSubtotalInclTax($this->getBaseSubtotalInclTax()); + + $result = Mage::getModel('Mage_Shipping_Model_Shipping')->collectRates($request)->getResult(); + + $found = false; + if ($result) { + $shippingRates = $result->getAllRates(); + + foreach ($shippingRates as $shippingRate) { + $rate = Mage::getModel('Mage_Sales_Model_Quote_Address_Rate') + ->importShippingRate($shippingRate); + if (!$item) { + $this->addShippingRate($rate); + } + + if ($this->getShippingMethod() == $rate->getCode()) { + if ($item) { + $item->setBaseShippingAmount($rate->getPrice()); + } else { + /** + * possible bug: this should be setBaseShippingAmount(), + * see Mage_Sales_Model_Quote_Address_Total_Shipping::collect() + * where this value is set again from the current specified rate price + * (looks like a workaround for this bug) + */ + $this->setShippingAmount($rate->getPrice()); + } + + $found = true; + } + } + } + return $found; + } + + /** + * Get totals collector model + * + * @return Mage_Sales_Model_Quote_Address_Total_Collector + */ + public function getTotalCollector() + { + if ($this->_totalCollector === null) { + $this->_totalCollector = Mage::getModel( + 'Mage_Sales_Model_Quote_Address_Total_Collector', + array('store' => $this->getQuote()->getStore()) + ); + } + return $this->_totalCollector; + } + + /** + * Collect address totals + * + * @return Mage_Sales_Model_Quote_Address + */ + public function collectTotals() + { + Mage::dispatchEvent($this->_eventPrefix . '_collect_totals_before', array($this->_eventObject => $this)); + foreach ($this->getTotalCollector()->getCollectors() as $model) { + $model->collect($this); + } + Mage::dispatchEvent($this->_eventPrefix . '_collect_totals_after', array($this->_eventObject => $this)); + return $this; + } + + /** + * Get address totals as array + * + * @return array + */ + public function getTotals() + { + foreach ($this->getTotalCollector()->getRetrievers() as $model) { + $model->fetch($this); + } + return $this->_totals; + } + + /** + * Add total data or model + * + * @param Mage_Sales_Model_Quote_Total|array $total + * @return Mage_Sales_Model_Quote_Address + */ + public function addTotal($total) + { + if (is_array($total)) { + $totalInstance = Mage::getModel('Mage_Sales_Model_Quote_Address_Total') + ->setData($total); + } elseif ($total instanceof Mage_Sales_Model_Quote_Total) { + $totalInstance = $total; + } + $totalInstance->setAddress($this); + $this->_totals[$totalInstance->getCode()] = $totalInstance; + return $this; + } + + /** + * Rewrite clone method + * + * @return Mage_Sales_Model_Quote_Address + */ + public function __clone() + { + $this->setId(null); + } + + /** + * Validate minimum amount + * + * @return bool + */ + public function validateMinimumAmount() + { + $storeId = $this->getQuote()->getStoreId(); + if (!Mage::getStoreConfigFlag('sales/minimum_order/active', $storeId)) { + return true; + } + + if ($this->getQuote()->getIsVirtual() && $this->getAddressType() == self::TYPE_SHIPPING) { + return true; + } + elseif (!$this->getQuote()->getIsVirtual() && $this->getAddressType() != self::TYPE_SHIPPING) { + return true; + } + + $amount = Mage::getStoreConfig('sales/minimum_order/amount', $storeId); + if ($this->getBaseSubtotalWithDiscount() < $amount) { + return false; + } + return true; + } + + /** + * Retrieve applied taxes + * + * @return array + */ + public function getAppliedTaxes() + { + return unserialize($this->getData('applied_taxes')); + } + + /** + * Set applied taxes + * + * @param array $data + * @return Mage_Sales_Model_Quote_Address + */ + public function setAppliedTaxes($data) + { + return $this->setData('applied_taxes', serialize($data)); + } + + /** + * Set shipping amount + * + * @param float $value + * @param bool $alreadyExclTax + * @return Mage_Sales_Model_Quote_Address + */ + public function setShippingAmount($value, $alreadyExclTax = false) + { + return $this->setData('shipping_amount', $value); + } + + /** + * Set base shipping amount + * + * @param float $value + * @param bool $alreadyExclTax + * @return Mage_Sales_Model_Quote_Address + */ + public function setBaseShippingAmount($value, $alreadyExclTax = false) + { + return $this->setData('base_shipping_amount', $value); + } + + /** + * Set total amount value + * + * @param string $code + * @param float $amount + * @return Mage_Sales_Model_Quote_Address + */ + public function setTotalAmount($code, $amount) + { + $this->_totalAmounts[$code] = $amount; + if ($code != 'subtotal') { + $code = $code.'_amount'; + } + $this->setData($code, $amount); + return $this; + } + + /** + * Set total amount value in base store currency + * + * @param string $code + * @param float $amount + * @return Mage_Sales_Model_Quote_Address + */ + public function setBaseTotalAmount($code, $amount) + { + $this->_baseTotalAmounts[$code] = $amount; + if ($code != 'subtotal') { + $code = $code.'_amount'; + } + $this->setData('base_'.$code, $amount); + return $this; + } + + /** + * Add amount total amount value + * + * @param string $code + * @param float $amount + * @return Mage_Sales_Model_Quote_Address + */ + public function addTotalAmount($code, $amount) + { + $amount = $this->getTotalAmount($code)+$amount; + $this->setTotalAmount($code, $amount); + return $this; + } + + /** + * Add amount total amount value in base store currency + * + * @param string $code + * @param float $amount + * @return Mage_Sales_Model_Quote_Address + */ + public function addBaseTotalAmount($code, $amount) + { + $amount = $this->getBaseTotalAmount($code)+$amount; + $this->setBaseTotalAmount($code, $amount); + return $this; + } + + /** + * Get total amount value by code + * + * @param string $code + * @return float + */ + public function getTotalAmount($code) + { + if (isset($this->_totalAmounts[$code])) { + return $this->_totalAmounts[$code]; + } + return 0; + } + + /** + * Get total amount value by code in base store curncy + * + * @param string $code + * @return float + */ + public function getBaseTotalAmount($code) + { + if (isset($this->_baseTotalAmounts[$code])) { + return $this->_baseTotalAmounts[$code]; + } + return 0; + } + + /** + * Get all total amount values + * + * @return array + */ + public function getAllTotalAmounts() + { + return $this->_totalAmounts; + } + + /** + * Get all total amount values in base currency + * + * @return array + */ + public function getAllBaseTotalAmounts() + { + return $this->_baseTotalAmounts; + } + + /** + * Get subtotal amount with applied discount in base currency + * + * @return float + */ + public function getBaseSubtotalWithDiscount() + { + return $this->getBaseSubtotal()+$this->getBaseDiscountAmount(); + } + + /** + * Get subtotal amount with applied discount + * + * @return float + */ + public function getSubtotalWithDiscount() + { + return $this->getSubtotal()+$this->getDiscountAmount(); + } +} diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Item.php b/app/code/Mage/Sales/Model/Quote/Address/Item.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Quote/Address/Item.php rename to app/code/Mage/Sales/Model/Quote/Address/Item.php diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Rate.php b/app/code/Mage/Sales/Model/Quote/Address/Rate.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Quote/Address/Rate.php rename to app/code/Mage/Sales/Model/Quote/Address/Rate.php diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Total.php b/app/code/Mage/Sales/Model/Quote/Address/Total.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Quote/Address/Total.php rename to app/code/Mage/Sales/Model/Quote/Address/Total.php diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Abstract.php b/app/code/Mage/Sales/Model/Quote/Address/Total/Abstract.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Quote/Address/Total/Abstract.php rename to app/code/Mage/Sales/Model/Quote/Address/Total/Abstract.php diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Collector.php b/app/code/Mage/Sales/Model/Quote/Address/Total/Collector.php similarity index 95% rename from app/code/core/Mage/Sales/Model/Quote/Address/Total/Collector.php rename to app/code/Mage/Sales/Model/Quote/Address/Total/Collector.php index 8c17a08c040df..9cbd0abaf71ec 100644 --- a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Collector.php +++ b/app/code/Mage/Sales/Model/Quote/Address/Total/Collector.php @@ -69,10 +69,12 @@ class Mage_Sales_Model_Quote_Address_Total_Collector extends Mage_Sales_Model_Co /** * Init corresponding total models * - * @param array $options + * @param Mage_Core_Model_Cache_Type_Config $configCacheType + * @param Mage_Core_Model_Store $store */ - public function __construct($store = null) + public function __construct(Mage_Core_Model_Cache_Type_Config $configCacheType, $store = null) { + parent::__construct($configCacheType); $this->_store = $store ?: Mage::app()->getStore(); $this->_initModels() ->_initCollectors() diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Custbalance.php b/app/code/Mage/Sales/Model/Quote/Address/Total/Custbalance.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Quote/Address/Total/Custbalance.php rename to app/code/Mage/Sales/Model/Quote/Address/Total/Custbalance.php diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Discount.php b/app/code/Mage/Sales/Model/Quote/Address/Total/Discount.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Quote/Address/Total/Discount.php rename to app/code/Mage/Sales/Model/Quote/Address/Total/Discount.php diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Grand.php b/app/code/Mage/Sales/Model/Quote/Address/Total/Grand.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Quote/Address/Total/Grand.php rename to app/code/Mage/Sales/Model/Quote/Address/Total/Grand.php diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Msrp.php b/app/code/Mage/Sales/Model/Quote/Address/Total/Msrp.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Quote/Address/Total/Msrp.php rename to app/code/Mage/Sales/Model/Quote/Address/Total/Msrp.php diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Nominal.php b/app/code/Mage/Sales/Model/Quote/Address/Total/Nominal.php similarity index 97% rename from app/code/core/Mage/Sales/Model/Quote/Address/Total/Nominal.php rename to app/code/Mage/Sales/Model/Quote/Address/Total/Nominal.php index 96eca9a44e1cb..7d872e485d241 100644 --- a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Nominal.php +++ b/app/code/Mage/Sales/Model/Quote/Address/Total/Nominal.php @@ -39,7 +39,7 @@ class Mage_Sales_Model_Quote_Address_Total_Nominal extends Mage_Sales_Model_Quot */ public function collect(Mage_Sales_Model_Quote_Address $address) { - $collector = Mage::getSingleton('Mage_Sales_Model_Quote_Address_Total_Nominal_Collector', + $collector = Mage::getModel('Mage_Sales_Model_Quote_Address_Total_Nominal_Collector', array('store' => $address->getQuote()->getStore()) ); diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Nominal/Collector.php b/app/code/Mage/Sales/Model/Quote/Address/Total/Nominal/Collector.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Quote/Address/Total/Nominal/Collector.php rename to app/code/Mage/Sales/Model/Quote/Address/Total/Nominal/Collector.php diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Nominal/Recurring/Initial.php b/app/code/Mage/Sales/Model/Quote/Address/Total/Nominal/Recurring/Initial.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Quote/Address/Total/Nominal/Recurring/Initial.php rename to app/code/Mage/Sales/Model/Quote/Address/Total/Nominal/Recurring/Initial.php diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Nominal/Recurring/Trial.php b/app/code/Mage/Sales/Model/Quote/Address/Total/Nominal/Recurring/Trial.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Quote/Address/Total/Nominal/Recurring/Trial.php rename to app/code/Mage/Sales/Model/Quote/Address/Total/Nominal/Recurring/Trial.php diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Nominal/RecurringAbstract.php b/app/code/Mage/Sales/Model/Quote/Address/Total/Nominal/RecurringAbstract.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Quote/Address/Total/Nominal/RecurringAbstract.php rename to app/code/Mage/Sales/Model/Quote/Address/Total/Nominal/RecurringAbstract.php diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Nominal/Shipping.php b/app/code/Mage/Sales/Model/Quote/Address/Total/Nominal/Shipping.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Quote/Address/Total/Nominal/Shipping.php rename to app/code/Mage/Sales/Model/Quote/Address/Total/Nominal/Shipping.php diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Nominal/Subtotal.php b/app/code/Mage/Sales/Model/Quote/Address/Total/Nominal/Subtotal.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Quote/Address/Total/Nominal/Subtotal.php rename to app/code/Mage/Sales/Model/Quote/Address/Total/Nominal/Subtotal.php diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Shipping.php b/app/code/Mage/Sales/Model/Quote/Address/Total/Shipping.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Quote/Address/Total/Shipping.php rename to app/code/Mage/Sales/Model/Quote/Address/Total/Shipping.php diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Subtotal.php b/app/code/Mage/Sales/Model/Quote/Address/Total/Subtotal.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Quote/Address/Total/Subtotal.php rename to app/code/Mage/Sales/Model/Quote/Address/Total/Subtotal.php diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Tax.php b/app/code/Mage/Sales/Model/Quote/Address/Total/Tax.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Quote/Address/Total/Tax.php rename to app/code/Mage/Sales/Model/Quote/Address/Total/Tax.php diff --git a/app/code/core/Mage/Sales/Model/Quote/Config.php b/app/code/Mage/Sales/Model/Quote/Config.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Quote/Config.php rename to app/code/Mage/Sales/Model/Quote/Config.php diff --git a/app/code/Mage/Sales/Model/Quote/Item.php b/app/code/Mage/Sales/Model/Quote/Item.php new file mode 100644 index 0000000000000..4f39a0b5e2fec --- /dev/null +++ b/app/code/Mage/Sales/Model/Quote/Item.php @@ -0,0 +1,909 @@ + + */ +class Mage_Sales_Model_Quote_Item extends Mage_Sales_Model_Quote_Item_Abstract +{ + /** + * Prefix of model events names + * + * @var string + */ + protected $_eventPrefix = 'sales_quote_item'; + + /** + * Parameter name in event + * + * In observe method you can use $observer->getEvent()->getObject() in this case + * + * @var string + */ + protected $_eventObject = 'item'; + + /** + * Quote model object + * + * @var Mage_Sales_Model_Quote + */ + protected $_quote; + + /** + * Item options array + * + * @var array + */ + protected $_options = array(); + + /** + * Item options by code cache + * + * @var array + */ + protected $_optionsByCode = array(); + + /** + * Not Represent options + * + * @var array + */ + protected $_notRepresentOptions = array('info_buyRequest'); + + /** + * Flag stating that options were successfully saved + * + */ + protected $_flagOptionsSaved = null; + + /** + * Array of errors associated with this quote item + * + * @var Mage_Sales_Model_Status_List + */ + protected $_errorInfos; + + /** + * @param Mage_Core_Model_Context $context + * @param Mage_Sales_Model_Status_ListFactory $statusListFactory + * @param Mage_Core_Model_Resource_Abstract $resource + * @param Varien_Data_Collection_Db $resourceCollection + * @param array $data + */ + public function __construct( + Mage_Core_Model_Context $context, + Mage_Sales_Model_Status_ListFactory $statusListFactory, + Mage_Core_Model_Resource_Abstract $resource = null, + Varien_Data_Collection_Db $resourceCollection = null, + array $data = array() + ) { + $this->_errorInfos = $statusListFactory->create(); + parent::__construct($context, $resource, $resourceCollection, $data); + } + + + /** + * Initialize resource model + * + */ + protected function _construct() + { + $this->_init('Mage_Sales_Model_Resource_Quote_Item'); + } + + /** + * Quote Item Before Save prepare data process + * + * @return Mage_Sales_Model_Quote_Item + */ + protected function _beforeSave() + { + parent::_beforeSave(); + $this->setIsVirtual($this->getProduct()->getIsVirtual()); + if ($this->getQuote()) { + $this->setQuoteId($this->getQuote()->getId()); + } + return $this; + } + + /** + * Retrieve address model + * + * @return Mage_Sales_Model_Quote_Address + */ + public function getAddress() + { + if ($this->getQuote()->getItemsQty() == $this->getQuote()->getVirtualItemsQty()) { + $address = $this->getQuote()->getBillingAddress(); + } else { + $address = $this->getQuote()->getShippingAddress(); + } + + return $address; + } + + /** + * Declare quote model object + * + * @param Mage_Sales_Model_Quote $quote + * @return Mage_Sales_Model_Quote_Item + */ + public function setQuote(Mage_Sales_Model_Quote $quote) + { + $this->_quote = $quote; + $this->setQuoteId($quote->getId()); + return $this; + } + + /** + * Retrieve quote model object + * + * @return Mage_Sales_Model_Quote + */ + public function getQuote() + { + return $this->_quote; + } + + /** + * Prepare quantity + * + * @param float|int $qty + * @return int|float + */ + protected function _prepareQty($qty) + { + $qty = Mage::app()->getLocale()->getNumber($qty); + $qty = ($qty > 0) ? $qty : 1; + return $qty; + } + + /** + * Adding quantity to quote item + * + * @param float $qty + * @return Mage_Sales_Model_Quote_Item + */ + public function addQty($qty) + { + $oldQty = $this->getQty(); + $qty = $this->_prepareQty($qty); + + /** + * We can't modify quontity of existing items which have parent + * This qty declared just once duering add process and is not editable + */ + if (!$this->getParentItem() || !$this->getId()) { + $this->setQtyToAdd($qty); + $this->setQty($oldQty+$qty); + } + return $this; + } + + /** + * Declare quote item quantity + * + * @param float $qty + * @return Mage_Sales_Model_Quote_Item + */ + public function setQty($qty) + { + $qty = $this->_prepareQty($qty); + $oldQty = $this->_getData('qty'); + $this->setData('qty', $qty); + + Mage::dispatchEvent('sales_quote_item_qty_set_after', array('item'=>$this)); + + if ($this->getQuote() && $this->getQuote()->getIgnoreOldQty()) { + return $this; + } + if ($this->getUseOldQty()) { + $this->setData('qty', $oldQty); + } + + return $this; + } + + /** + * Retrieve option product with Qty + * + * Return array + * 'qty' => the qty + * 'product' => the product model + * + * @return array + */ + public function getQtyOptions() + { + $qtyOptions = $this->getData('qty_options'); + if (is_null($qtyOptions)) { + $productIds = array(); + $qtyOptions = array(); + foreach ($this->getOptions() as $option) { + /** @var $option Mage_Sales_Model_Quote_Item_Option */ + if (is_object($option->getProduct()) + && $option->getProduct()->getId() != $this->getProduct()->getId() + ) { + $productIds[$option->getProduct()->getId()] = $option->getProduct()->getId(); + } + } + + foreach ($productIds as $productId) { + $option = $this->getOptionByCode('product_qty_' . $productId); + if ($option) { + $qtyOptions[$productId] = $option; + } + } + + $this->setData('qty_options', $qtyOptions); + } + + return $qtyOptions; + } + + /** + * Set option product with Qty + * + * @param $qtyOptions + * @return Mage_Sales_Model_Quote_Item + */ + public function setQtyOptions($qtyOptions) + { + return $this->setData('qty_options', $qtyOptions); + } + + /** + * Setup product for quote item + * + * @param Mage_Catalog_Model_Product $product + * @return Mage_Sales_Model_Quote_Item + */ + public function setProduct($product) + { + if ($this->getQuote()) { + $product->setStoreId($this->getQuote()->getStoreId()); + $product->setCustomerGroupId($this->getQuote()->getCustomerGroupId()); + } + $this->setData('product', $product) + ->setProductId($product->getId()) + ->setProductType($product->getTypeId()) + ->setSku($this->getProduct()->getSku()) + ->setName($product->getName()) + ->setWeight($this->getProduct()->getWeight()) + ->setTaxClassId($product->getTaxClassId()) + ->setBaseCost($product->getCost()) + ->setIsRecurring($product->getIsRecurring()) + ; + + if ($product->getStockItem()) { + $this->setIsQtyDecimal($product->getStockItem()->getIsQtyDecimal()); + } + + Mage::dispatchEvent('sales_quote_item_set_product', array( + 'product' => $product, + 'quote_item'=>$this + )); + + +// if ($options = $product->getCustomOptions()) { +// foreach ($options as $option) { +// $this->addOption($option); +// } +// } + return $this; + } + + /** + * Check product representation in item + * + * @param Mage_Catalog_Model_Product $product + * @return bool + */ + public function representProduct($product) + { + $itemProduct = $this->getProduct(); + if (!$product || $itemProduct->getId() != $product->getId()) { + return false; + } + + /** + * Check maybe product is planned to be a child of some quote item - in this case we limit search + * only within same parent item + */ + $stickWithinParent = $product->getStickWithinParent(); + if ($stickWithinParent) { + if ($this->getParentItem() !== $stickWithinParent) { + return false; + } + } + + // Check options + $itemOptions = $this->getOptionsByCode(); + $productOptions = $product->getCustomOptions(); + + if(!$this->compareOptions($itemOptions, $productOptions)){ + return false; + } + if(!$this->compareOptions($productOptions, $itemOptions)){ + return false; + } + return true; + } + + /** + * Check if two options array are identical + * First options array is prerogative + * Second options array checked against first one + * + * @param array $options1 + * @param array $options2 + * @return bool + */ + public function compareOptions($options1, $options2) + { + foreach ($options1 as $option) { + $code = $option->getCode(); + if (in_array($code, $this->_notRepresentOptions )) { + continue; + } + if ( !isset($options2[$code]) + || ($options2[$code]->getValue() === null) + || $options2[$code]->getValue() != $option->getValue()) { + return false; + } + } + return true; + } + + /** + * Compare item + * + * @param Mage_Sales_Model_Quote_Item $item + * @return bool + */ + public function compare($item) + { + if ($this->getProductId() != $item->getProductId()) { + return false; + } + foreach ($this->getOptions() as $option) { + if (in_array($option->getCode(), $this->_notRepresentOptions)) { + continue; + } + if ($itemOption = $item->getOptionByCode($option->getCode())) { + $itemOptionValue = $itemOption->getValue(); + $optionValue = $option->getValue(); + + // dispose of some options params, that can cramp comparing of arrays + if (is_string($itemOptionValue) && is_string($optionValue)) { + $_itemOptionValue = @unserialize($itemOptionValue); + $_optionValue = @unserialize($optionValue); + if (is_array($_itemOptionValue) && is_array($_optionValue)) { + $itemOptionValue = $_itemOptionValue; + $optionValue = $_optionValue; + // looks like it does not break bundle selection qty + unset($itemOptionValue['qty'], $itemOptionValue['uenc']); + unset($optionValue['qty'], $optionValue['uenc']); + } + } + + if ($itemOptionValue != $optionValue) { + return false; + } + } + else { + return false; + } + } + return true; + } + + /** + * Get item product type + * + * @return string + */ + public function getProductType() + { + if ($option = $this->getOptionByCode('product_type')) { + return $option->getValue(); + } + if ($product = $this->getProduct()) { + return $product->getTypeId(); + } + return $this->_getData('product_type'); + } + + /** + * Return real product type of item + * + * @return unknown + */ + public function getRealProductType() + { + return $this->_getData('product_type'); + } + + /** + * Convert Quote Item to array + * + * @param array $arrAttributes + * @return array + */ + public function toArray(array $arrAttributes=array()) + { + $data = parent::toArray($arrAttributes); + + if ($product = $this->getProduct()) { + $data['product'] = $product->toArray(); + } + return $data; + } + + /** + * Initialize quote item options + * + * @param array $options + * @return Mage_Sales_Model_Quote_Item + */ + public function setOptions($options) + { + foreach ($options as $option) { + $this->addOption($option); + } + return $this; + } + + /** + * Get all item options + * + * @return array + */ + public function getOptions() + { + return $this->_options; + } + + /** + * Get all item options as array with codes in array key + * + * @return array + */ + public function getOptionsByCode() + { + return $this->_optionsByCode; + } + + /** + * Add option to item + * + * @param Mage_Sales_Model_Quote_Item_Option|Varien_Object $option + * @return Mage_Sales_Model_Quote_Item + */ + public function addOption($option) + { + if (is_array($option)) { + $option = Mage::getModel('Mage_Sales_Model_Quote_Item_Option')->setData($option) + ->setItem($this); + } + elseif (($option instanceof Varien_Object) && !($option instanceof Mage_Sales_Model_Quote_Item_Option)) { + $option = Mage::getModel('Mage_Sales_Model_Quote_Item_Option')->setData($option->getData()) + ->setProduct($option->getProduct()) + ->setItem($this); + } + elseif($option instanceof Mage_Sales_Model_Quote_Item_Option) { + $option->setItem($this); + } + else { + Mage::throwException(Mage::helper('Mage_Sales_Helper_Data')->__('Invalid item option format.')); + } + + if ($exOption = $this->getOptionByCode($option->getCode())) { + $exOption->addData($option->getData()); + } + else { + $this->_addOptionCode($option); + $this->_options[] = $option; + } + return $this; + } + + /** + * Can specify specific actions for ability to change given quote options values + * Exemple: cataloginventory decimal qty validation may change qty to int, + * so need to change quote item qty option value. + * + * @param Varien_Object $option + * @param int|float|null $value + * @return Mage_Sales_Model_Quote_Item + */ + public function updateQtyOption(Varien_Object $option, $value) + { + $optionProduct = $option->getProduct(); + $options = $this->getQtyOptions(); + + if (isset($options[$optionProduct->getId()])) { + $options[$optionProduct->getId()]->setValue($value); + } + + $this->getProduct()->getTypeInstance() + ->updateQtyOption($this->getOptions(), $option, $value, $this->getProduct()); + + return $this; + } + + /** + *Remove option from item options + * + * @param string $code + * @return Mage_Sales_Model_Quote_Item + */ + public function removeOption($code) + { + $option = $this->getOptionByCode($code); + if ($option) { + $option->isDeleted(true); + } + return $this; + } + + /** + * Register option code + * + * @param Mage_Sales_Model_Quote_Item_Option $option + * @return Mage_Sales_Model_Quote_Item + */ + protected function _addOptionCode($option) + { + if (!isset($this->_optionsByCode[$option->getCode()])) { + $this->_optionsByCode[$option->getCode()] = $option; + } + else { + Mage::throwException(Mage::helper('Mage_Sales_Helper_Data')->__('An item option with code %s already exists.', $option->getCode())); + } + return $this; + } + + /** + * Get item option by code + * + * @param string $code + * @return Mage_Sales_Model_Quote_Item_Option || null + */ + public function getOptionByCode($code) + { + if (isset($this->_optionsByCode[$code]) && !$this->_optionsByCode[$code]->isDeleted()) { + return $this->_optionsByCode[$code]; + } + return null; + } + + /** + * Checks that item model has data changes. + * Call save item options if model isn't need to save in DB + * + * @return boolean + */ + protected function _hasModelChanged() + { + if (!$this->hasDataChanges()) { + return false; + } + + return $this->_getResource()->hasDataChanged($this); + } + + /** + * Save item options + * + * @return Mage_Sales_Model_Quote_Item + */ + protected function _saveItemOptions() + { + foreach ($this->_options as $index => $option) { + if ($option->isDeleted()) { + $option->delete(); + unset($this->_options[$index]); + unset($this->_optionsByCode[$option->getCode()]); + } else { + $option->save(); + } + } + + $this->_flagOptionsSaved = true; // Report to watchers that options were saved + + return $this; + } + + /** + * Save model plus its options + * Ensures saving options in case when resource model was not changed + */ + public function save() + { + $hasDataChanges = $this->hasDataChanges(); + $this->_flagOptionsSaved = false; + + parent::save(); + + if ($hasDataChanges && !$this->_flagOptionsSaved) { + $this->_saveItemOptions(); + } + } + + /** + * Save item options after item saved + * + * @return Mage_Sales_Model_Quote_Item + */ + protected function _afterSave() + { + $this->_saveItemOptions(); + return parent::_afterSave(); + } + + /** + * Clone quote item + * + * @return Mage_Sales_Model_Quote_Item + */ + public function __clone() + { + parent::__clone(); + $options = $this->getOptions(); + $this->_quote = null; + $this->_options = array(); + $this->_optionsByCode = array(); + foreach ($options as $option) { + $this->addOption(clone $option); + } + return $this; + } + + /** + * Returns formatted buy request - object, holding request received from + * product view page with keys and options for configured product + * + * @return Varien_Object + */ + public function getBuyRequest() + { + $option = $this->getOptionByCode('info_buyRequest'); + $buyRequest = new Varien_Object($option ? unserialize($option->getValue()) : null); + + // Overwrite standard buy request qty, because item qty could have changed since adding to quote + $buyRequest->setOriginalQty($buyRequest->getQty()) + ->setQty($this->getQty() * 1); + + return $buyRequest; + } + + /** + * Sets flag, whether this quote item has some error associated with it. + * + * @param bool $flag + * @return Mage_Sales_Model_Quote_Item + */ + protected function _setHasError($flag) + { + return $this->setData('has_error', $flag); + } + + /** + * Sets flag, whether this quote item has some error associated with it. + * When TRUE - also adds 'unknown' error information to list of quote item errors. + * When FALSE - clears whole list of quote item errors. + * It's recommended to use addErrorInfo() instead - to be able to remove error statuses later. + * + * @param bool $flag + * @return Mage_Sales_Model_Quote_Item + * @see addErrorInfo() + */ + public function setHasError($flag) + { + if ($flag) { + $this->addErrorInfo(); + } else { + $this->_clearErrorInfo(); + } + return $this; + } + + /** + * Clears list of errors, associated with this quote item. + * Also automatically removes error-flag from oneself. + * + * @return Mage_Sales_Model_Quote_Item + */ + protected function _clearErrorInfo() + { + $this->_errorInfos->clear(); + $this->_setHasError(false); + return $this; + } + + /** + * Adds error information to the quote item. + * Automatically sets error flag. + * + * @param string|null $origin Usually a name of module, that embeds error + * @param int|null $code Error code, unique for origin, that sets it + * @param string|null $message Error message + * @param Varien_Object|null $additionalData Any additional data, that caller would like to store + * @return Mage_Sales_Model_Quote_Item + */ + public function addErrorInfo($origin = null, $code = null, $message = null, $additionalData = null) + { + $this->_errorInfos->addItem($origin, $code, $message, $additionalData); + if ($message !== null) { + $this->setMessage($message); + } + $this->_setHasError(true); + + return $this; + } + + /** + * Retrieves all error infos, associated with this item + * + * @return array + */ + public function getErrorInfos() + { + return $this->_errorInfos->getItems(); + } + + /** + * Removes error infos, that have parameters equal to passed in $params. + * $params can have following keys (if not set - then any item is good for this key): + * 'origin', 'code', 'message' + * + * @param array $params + * @return Mage_Sales_Model_Quote_Item + */ + public function removeErrorInfosByParams($params) + { + $removedItems = $this->_errorInfos->removeItemsByParams($params); + foreach ($removedItems as $item) { + if ($item['message'] !== null) { + $this->removeMessageByText($item['message']); + } + } + + if (!$this->_errorInfos->getItems()) { + $this->_setHasError(false); + } + + return $this; + } +} diff --git a/app/code/core/Mage/Sales/Model/Quote/Item/Abstract.php b/app/code/Mage/Sales/Model/Quote/Item/Abstract.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Quote/Item/Abstract.php rename to app/code/Mage/Sales/Model/Quote/Item/Abstract.php diff --git a/app/code/core/Mage/Sales/Model/Quote/Item/Option.php b/app/code/Mage/Sales/Model/Quote/Item/Option.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Quote/Item/Option.php rename to app/code/Mage/Sales/Model/Quote/Item/Option.php diff --git a/app/code/core/Mage/Sales/Model/Quote/Payment.php b/app/code/Mage/Sales/Model/Quote/Payment.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Quote/Payment.php rename to app/code/Mage/Sales/Model/Quote/Payment.php diff --git a/app/code/core/Mage/Sales/Model/Recurring/Profile.php b/app/code/Mage/Sales/Model/Recurring/Profile.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Recurring/Profile.php rename to app/code/Mage/Sales/Model/Recurring/Profile.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Abstract.php b/app/code/Mage/Sales/Model/Resource/Abstract.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Abstract.php rename to app/code/Mage/Sales/Model/Resource/Abstract.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Billing/Agreement.php b/app/code/Mage/Sales/Model/Resource/Billing/Agreement.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Billing/Agreement.php rename to app/code/Mage/Sales/Model/Resource/Billing/Agreement.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Billing/Agreement/Collection.php b/app/code/Mage/Sales/Model/Resource/Billing/Agreement/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Billing/Agreement/Collection.php rename to app/code/Mage/Sales/Model/Resource/Billing/Agreement/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Collection/Abstract.php b/app/code/Mage/Sales/Model/Resource/Collection/Abstract.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Collection/Abstract.php rename to app/code/Mage/Sales/Model/Resource/Collection/Abstract.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Helper/Interface.php b/app/code/Mage/Sales/Model/Resource/Helper/Interface.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Helper/Interface.php rename to app/code/Mage/Sales/Model/Resource/Helper/Interface.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Helper/Mysql4.php b/app/code/Mage/Sales/Model/Resource/Helper/Mysql4.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Helper/Mysql4.php rename to app/code/Mage/Sales/Model/Resource/Helper/Mysql4.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order.php b/app/code/Mage/Sales/Model/Resource/Order.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order.php rename to app/code/Mage/Sales/Model/Resource/Order.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Abstract.php b/app/code/Mage/Sales/Model/Resource/Order/Abstract.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Abstract.php rename to app/code/Mage/Sales/Model/Resource/Order/Abstract.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Address.php b/app/code/Mage/Sales/Model/Resource/Order/Address.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Address.php rename to app/code/Mage/Sales/Model/Resource/Order/Address.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Address/Collection.php b/app/code/Mage/Sales/Model/Resource/Order/Address/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Address/Collection.php rename to app/code/Mage/Sales/Model/Resource/Order/Address/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Attribute/Backend/Billing.php b/app/code/Mage/Sales/Model/Resource/Order/Attribute/Backend/Billing.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Attribute/Backend/Billing.php rename to app/code/Mage/Sales/Model/Resource/Order/Attribute/Backend/Billing.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Attribute/Backend/Child.php b/app/code/Mage/Sales/Model/Resource/Order/Attribute/Backend/Child.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Attribute/Backend/Child.php rename to app/code/Mage/Sales/Model/Resource/Order/Attribute/Backend/Child.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Attribute/Backend/Parent.php b/app/code/Mage/Sales/Model/Resource/Order/Attribute/Backend/Parent.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Attribute/Backend/Parent.php rename to app/code/Mage/Sales/Model/Resource/Order/Attribute/Backend/Parent.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Attribute/Backend/Shipping.php b/app/code/Mage/Sales/Model/Resource/Order/Attribute/Backend/Shipping.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Attribute/Backend/Shipping.php rename to app/code/Mage/Sales/Model/Resource/Order/Attribute/Backend/Shipping.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Collection.php b/app/code/Mage/Sales/Model/Resource/Order/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Collection.php rename to app/code/Mage/Sales/Model/Resource/Order/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Collection/Abstract.php b/app/code/Mage/Sales/Model/Resource/Order/Collection/Abstract.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Collection/Abstract.php rename to app/code/Mage/Sales/Model/Resource/Order/Collection/Abstract.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Comment/Collection/Abstract.php b/app/code/Mage/Sales/Model/Resource/Order/Comment/Collection/Abstract.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Comment/Collection/Abstract.php rename to app/code/Mage/Sales/Model/Resource/Order/Comment/Collection/Abstract.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Creditmemo.php b/app/code/Mage/Sales/Model/Resource/Order/Creditmemo.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Creditmemo.php rename to app/code/Mage/Sales/Model/Resource/Order/Creditmemo.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Creditmemo/Attribute/Backend/Child.php b/app/code/Mage/Sales/Model/Resource/Order/Creditmemo/Attribute/Backend/Child.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Creditmemo/Attribute/Backend/Child.php rename to app/code/Mage/Sales/Model/Resource/Order/Creditmemo/Attribute/Backend/Child.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Creditmemo/Attribute/Backend/Parent.php b/app/code/Mage/Sales/Model/Resource/Order/Creditmemo/Attribute/Backend/Parent.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Creditmemo/Attribute/Backend/Parent.php rename to app/code/Mage/Sales/Model/Resource/Order/Creditmemo/Attribute/Backend/Parent.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Creditmemo/Collection.php b/app/code/Mage/Sales/Model/Resource/Order/Creditmemo/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Creditmemo/Collection.php rename to app/code/Mage/Sales/Model/Resource/Order/Creditmemo/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Creditmemo/Comment.php b/app/code/Mage/Sales/Model/Resource/Order/Creditmemo/Comment.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Creditmemo/Comment.php rename to app/code/Mage/Sales/Model/Resource/Order/Creditmemo/Comment.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Creditmemo/Comment/Collection.php b/app/code/Mage/Sales/Model/Resource/Order/Creditmemo/Comment/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Creditmemo/Comment/Collection.php rename to app/code/Mage/Sales/Model/Resource/Order/Creditmemo/Comment/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Creditmemo/Grid/Collection.php b/app/code/Mage/Sales/Model/Resource/Order/Creditmemo/Grid/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Creditmemo/Grid/Collection.php rename to app/code/Mage/Sales/Model/Resource/Order/Creditmemo/Grid/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Creditmemo/Item.php b/app/code/Mage/Sales/Model/Resource/Order/Creditmemo/Item.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Creditmemo/Item.php rename to app/code/Mage/Sales/Model/Resource/Order/Creditmemo/Item.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Creditmemo/Item/Collection.php b/app/code/Mage/Sales/Model/Resource/Order/Creditmemo/Item/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Creditmemo/Item/Collection.php rename to app/code/Mage/Sales/Model/Resource/Order/Creditmemo/Item/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Grid/Collection.php b/app/code/Mage/Sales/Model/Resource/Order/Grid/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Grid/Collection.php rename to app/code/Mage/Sales/Model/Resource/Order/Grid/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Grid/StatusesArray.php b/app/code/Mage/Sales/Model/Resource/Order/Grid/StatusesArray.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Grid/StatusesArray.php rename to app/code/Mage/Sales/Model/Resource/Order/Grid/StatusesArray.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Invoice.php b/app/code/Mage/Sales/Model/Resource/Order/Invoice.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Invoice.php rename to app/code/Mage/Sales/Model/Resource/Order/Invoice.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Invoice/Attribute/Backend/Child.php b/app/code/Mage/Sales/Model/Resource/Order/Invoice/Attribute/Backend/Child.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Invoice/Attribute/Backend/Child.php rename to app/code/Mage/Sales/Model/Resource/Order/Invoice/Attribute/Backend/Child.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Invoice/Attribute/Backend/Item.php b/app/code/Mage/Sales/Model/Resource/Order/Invoice/Attribute/Backend/Item.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Invoice/Attribute/Backend/Item.php rename to app/code/Mage/Sales/Model/Resource/Order/Invoice/Attribute/Backend/Item.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Invoice/Attribute/Backend/Order.php b/app/code/Mage/Sales/Model/Resource/Order/Invoice/Attribute/Backend/Order.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Invoice/Attribute/Backend/Order.php rename to app/code/Mage/Sales/Model/Resource/Order/Invoice/Attribute/Backend/Order.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Invoice/Attribute/Backend/Parent.php b/app/code/Mage/Sales/Model/Resource/Order/Invoice/Attribute/Backend/Parent.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Invoice/Attribute/Backend/Parent.php rename to app/code/Mage/Sales/Model/Resource/Order/Invoice/Attribute/Backend/Parent.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Invoice/Collection.php b/app/code/Mage/Sales/Model/Resource/Order/Invoice/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Invoice/Collection.php rename to app/code/Mage/Sales/Model/Resource/Order/Invoice/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Invoice/Comment.php b/app/code/Mage/Sales/Model/Resource/Order/Invoice/Comment.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Invoice/Comment.php rename to app/code/Mage/Sales/Model/Resource/Order/Invoice/Comment.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Invoice/Comment/Collection.php b/app/code/Mage/Sales/Model/Resource/Order/Invoice/Comment/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Invoice/Comment/Collection.php rename to app/code/Mage/Sales/Model/Resource/Order/Invoice/Comment/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Invoice/Grid/Collection.php b/app/code/Mage/Sales/Model/Resource/Order/Invoice/Grid/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Invoice/Grid/Collection.php rename to app/code/Mage/Sales/Model/Resource/Order/Invoice/Grid/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Invoice/Item.php b/app/code/Mage/Sales/Model/Resource/Order/Invoice/Item.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Invoice/Item.php rename to app/code/Mage/Sales/Model/Resource/Order/Invoice/Item.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Invoice/Item/Collection.php b/app/code/Mage/Sales/Model/Resource/Order/Invoice/Item/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Invoice/Item/Collection.php rename to app/code/Mage/Sales/Model/Resource/Order/Invoice/Item/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Item.php b/app/code/Mage/Sales/Model/Resource/Order/Item.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Item.php rename to app/code/Mage/Sales/Model/Resource/Order/Item.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Item/Collection.php b/app/code/Mage/Sales/Model/Resource/Order/Item/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Item/Collection.php rename to app/code/Mage/Sales/Model/Resource/Order/Item/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Payment.php b/app/code/Mage/Sales/Model/Resource/Order/Payment.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Payment.php rename to app/code/Mage/Sales/Model/Resource/Order/Payment.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Payment/Collection.php b/app/code/Mage/Sales/Model/Resource/Order/Payment/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Payment/Collection.php rename to app/code/Mage/Sales/Model/Resource/Order/Payment/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Payment/Transaction.php b/app/code/Mage/Sales/Model/Resource/Order/Payment/Transaction.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Payment/Transaction.php rename to app/code/Mage/Sales/Model/Resource/Order/Payment/Transaction.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Payment/Transaction/Collection.php b/app/code/Mage/Sales/Model/Resource/Order/Payment/Transaction/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Payment/Transaction/Collection.php rename to app/code/Mage/Sales/Model/Resource/Order/Payment/Transaction/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Shipment.php b/app/code/Mage/Sales/Model/Resource/Order/Shipment.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Shipment.php rename to app/code/Mage/Sales/Model/Resource/Order/Shipment.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Shipment/Attribute/Backend/Child.php b/app/code/Mage/Sales/Model/Resource/Order/Shipment/Attribute/Backend/Child.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Shipment/Attribute/Backend/Child.php rename to app/code/Mage/Sales/Model/Resource/Order/Shipment/Attribute/Backend/Child.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Shipment/Attribute/Backend/Parent.php b/app/code/Mage/Sales/Model/Resource/Order/Shipment/Attribute/Backend/Parent.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Shipment/Attribute/Backend/Parent.php rename to app/code/Mage/Sales/Model/Resource/Order/Shipment/Attribute/Backend/Parent.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Shipment/Collection.php b/app/code/Mage/Sales/Model/Resource/Order/Shipment/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Shipment/Collection.php rename to app/code/Mage/Sales/Model/Resource/Order/Shipment/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Shipment/Comment.php b/app/code/Mage/Sales/Model/Resource/Order/Shipment/Comment.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Shipment/Comment.php rename to app/code/Mage/Sales/Model/Resource/Order/Shipment/Comment.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Shipment/Comment/Collection.php b/app/code/Mage/Sales/Model/Resource/Order/Shipment/Comment/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Shipment/Comment/Collection.php rename to app/code/Mage/Sales/Model/Resource/Order/Shipment/Comment/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Shipment/Grid/Collection.php b/app/code/Mage/Sales/Model/Resource/Order/Shipment/Grid/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Shipment/Grid/Collection.php rename to app/code/Mage/Sales/Model/Resource/Order/Shipment/Grid/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Shipment/Item.php b/app/code/Mage/Sales/Model/Resource/Order/Shipment/Item.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Shipment/Item.php rename to app/code/Mage/Sales/Model/Resource/Order/Shipment/Item.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Shipment/Item/Collection.php b/app/code/Mage/Sales/Model/Resource/Order/Shipment/Item/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Shipment/Item/Collection.php rename to app/code/Mage/Sales/Model/Resource/Order/Shipment/Item/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Shipment/Track.php b/app/code/Mage/Sales/Model/Resource/Order/Shipment/Track.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Shipment/Track.php rename to app/code/Mage/Sales/Model/Resource/Order/Shipment/Track.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Shipment/Track/Collection.php b/app/code/Mage/Sales/Model/Resource/Order/Shipment/Track/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Shipment/Track/Collection.php rename to app/code/Mage/Sales/Model/Resource/Order/Shipment/Track/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Status.php b/app/code/Mage/Sales/Model/Resource/Order/Status.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Status.php rename to app/code/Mage/Sales/Model/Resource/Order/Status.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Status/Collection.php b/app/code/Mage/Sales/Model/Resource/Order/Status/Collection.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Status/Collection.php rename to app/code/Mage/Sales/Model/Resource/Order/Status/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Status/History.php b/app/code/Mage/Sales/Model/Resource/Order/Status/History.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Status/History.php rename to app/code/Mage/Sales/Model/Resource/Order/Status/History.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Status/History/Collection.php b/app/code/Mage/Sales/Model/Resource/Order/Status/History/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Status/History/Collection.php rename to app/code/Mage/Sales/Model/Resource/Order/Status/History/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Tax.php b/app/code/Mage/Sales/Model/Resource/Order/Tax.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Tax.php rename to app/code/Mage/Sales/Model/Resource/Order/Tax.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Order/Tax/Collection.php b/app/code/Mage/Sales/Model/Resource/Order/Tax/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Order/Tax/Collection.php rename to app/code/Mage/Sales/Model/Resource/Order/Tax/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote.php b/app/code/Mage/Sales/Model/Resource/Quote.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote.php rename to app/code/Mage/Sales/Model/Resource/Quote.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Address.php b/app/code/Mage/Sales/Model/Resource/Quote/Address.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Address.php rename to app/code/Mage/Sales/Model/Resource/Quote/Address.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Address/Attribute/Backend.php b/app/code/Mage/Sales/Model/Resource/Quote/Address/Attribute/Backend.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Address/Attribute/Backend.php rename to app/code/Mage/Sales/Model/Resource/Quote/Address/Attribute/Backend.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Address/Attribute/Backend/Child.php b/app/code/Mage/Sales/Model/Resource/Quote/Address/Attribute/Backend/Child.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Address/Attribute/Backend/Child.php rename to app/code/Mage/Sales/Model/Resource/Quote/Address/Attribute/Backend/Child.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Address/Attribute/Backend/Parent.php b/app/code/Mage/Sales/Model/Resource/Quote/Address/Attribute/Backend/Parent.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Address/Attribute/Backend/Parent.php rename to app/code/Mage/Sales/Model/Resource/Quote/Address/Attribute/Backend/Parent.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Address/Attribute/Backend/Region.php b/app/code/Mage/Sales/Model/Resource/Quote/Address/Attribute/Backend/Region.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Address/Attribute/Backend/Region.php rename to app/code/Mage/Sales/Model/Resource/Quote/Address/Attribute/Backend/Region.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend.php b/app/code/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend.php rename to app/code/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Custbalance.php b/app/code/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Custbalance.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Custbalance.php rename to app/code/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Custbalance.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Discount.php b/app/code/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Discount.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Discount.php rename to app/code/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Discount.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Grand.php b/app/code/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Grand.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Grand.php rename to app/code/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Grand.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Shipping.php b/app/code/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Shipping.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Shipping.php rename to app/code/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Shipping.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Subtotal.php b/app/code/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Subtotal.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Subtotal.php rename to app/code/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Subtotal.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Tax.php b/app/code/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Tax.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Tax.php rename to app/code/Mage/Sales/Model/Resource/Quote/Address/Attribute/Frontend/Tax.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Address/Collection.php b/app/code/Mage/Sales/Model/Resource/Quote/Address/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Address/Collection.php rename to app/code/Mage/Sales/Model/Resource/Quote/Address/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Address/Item.php b/app/code/Mage/Sales/Model/Resource/Quote/Address/Item.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Address/Item.php rename to app/code/Mage/Sales/Model/Resource/Quote/Address/Item.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Address/Item/Collection.php b/app/code/Mage/Sales/Model/Resource/Quote/Address/Item/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Address/Item/Collection.php rename to app/code/Mage/Sales/Model/Resource/Quote/Address/Item/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Address/Rate.php b/app/code/Mage/Sales/Model/Resource/Quote/Address/Rate.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Address/Rate.php rename to app/code/Mage/Sales/Model/Resource/Quote/Address/Rate.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Address/Rate/Collection.php b/app/code/Mage/Sales/Model/Resource/Quote/Address/Rate/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Address/Rate/Collection.php rename to app/code/Mage/Sales/Model/Resource/Quote/Address/Rate/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Collection.php b/app/code/Mage/Sales/Model/Resource/Quote/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Collection.php rename to app/code/Mage/Sales/Model/Resource/Quote/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Item.php b/app/code/Mage/Sales/Model/Resource/Quote/Item.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Item.php rename to app/code/Mage/Sales/Model/Resource/Quote/Item.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Item/Collection.php b/app/code/Mage/Sales/Model/Resource/Quote/Item/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Item/Collection.php rename to app/code/Mage/Sales/Model/Resource/Quote/Item/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Item/Option.php b/app/code/Mage/Sales/Model/Resource/Quote/Item/Option.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Item/Option.php rename to app/code/Mage/Sales/Model/Resource/Quote/Item/Option.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Item/Option/Collection.php b/app/code/Mage/Sales/Model/Resource/Quote/Item/Option/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Item/Option/Collection.php rename to app/code/Mage/Sales/Model/Resource/Quote/Item/Option/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Payment.php b/app/code/Mage/Sales/Model/Resource/Quote/Payment.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Payment.php rename to app/code/Mage/Sales/Model/Resource/Quote/Payment.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote/Payment/Collection.php b/app/code/Mage/Sales/Model/Resource/Quote/Payment/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Quote/Payment/Collection.php rename to app/code/Mage/Sales/Model/Resource/Quote/Payment/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Recurring/Profile.php b/app/code/Mage/Sales/Model/Resource/Recurring/Profile.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Recurring/Profile.php rename to app/code/Mage/Sales/Model/Resource/Recurring/Profile.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Recurring/Profile/Collection.php b/app/code/Mage/Sales/Model/Resource/Recurring/Profile/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Recurring/Profile/Collection.php rename to app/code/Mage/Sales/Model/Resource/Recurring/Profile/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Report.php b/app/code/Mage/Sales/Model/Resource/Report.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Report.php rename to app/code/Mage/Sales/Model/Resource/Report.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Abstract.php b/app/code/Mage/Sales/Model/Resource/Report/Abstract.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Report/Abstract.php rename to app/code/Mage/Sales/Model/Resource/Report/Abstract.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Bestsellers.php b/app/code/Mage/Sales/Model/Resource/Report/Bestsellers.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Report/Bestsellers.php rename to app/code/Mage/Sales/Model/Resource/Report/Bestsellers.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Bestsellers/Collection.php b/app/code/Mage/Sales/Model/Resource/Report/Bestsellers/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Report/Bestsellers/Collection.php rename to app/code/Mage/Sales/Model/Resource/Report/Bestsellers/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Collection/Abstract.php b/app/code/Mage/Sales/Model/Resource/Report/Collection/Abstract.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Report/Collection/Abstract.php rename to app/code/Mage/Sales/Model/Resource/Report/Collection/Abstract.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Invoiced.php b/app/code/Mage/Sales/Model/Resource/Report/Invoiced.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Report/Invoiced.php rename to app/code/Mage/Sales/Model/Resource/Report/Invoiced.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Invoiced/Collection/Invoiced.php b/app/code/Mage/Sales/Model/Resource/Report/Invoiced/Collection/Invoiced.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Report/Invoiced/Collection/Invoiced.php rename to app/code/Mage/Sales/Model/Resource/Report/Invoiced/Collection/Invoiced.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Invoiced/Collection/Order.php b/app/code/Mage/Sales/Model/Resource/Report/Invoiced/Collection/Order.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Report/Invoiced/Collection/Order.php rename to app/code/Mage/Sales/Model/Resource/Report/Invoiced/Collection/Order.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Order.php b/app/code/Mage/Sales/Model/Resource/Report/Order.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Report/Order.php rename to app/code/Mage/Sales/Model/Resource/Report/Order.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Order/Collection.php b/app/code/Mage/Sales/Model/Resource/Report/Order/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Report/Order/Collection.php rename to app/code/Mage/Sales/Model/Resource/Report/Order/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Order/Createdat.php b/app/code/Mage/Sales/Model/Resource/Report/Order/Createdat.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Report/Order/Createdat.php rename to app/code/Mage/Sales/Model/Resource/Report/Order/Createdat.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Order/Updatedat.php b/app/code/Mage/Sales/Model/Resource/Report/Order/Updatedat.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Report/Order/Updatedat.php rename to app/code/Mage/Sales/Model/Resource/Report/Order/Updatedat.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Order/Updatedat/Collection.php b/app/code/Mage/Sales/Model/Resource/Report/Order/Updatedat/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Report/Order/Updatedat/Collection.php rename to app/code/Mage/Sales/Model/Resource/Report/Order/Updatedat/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Refunded.php b/app/code/Mage/Sales/Model/Resource/Report/Refunded.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Report/Refunded.php rename to app/code/Mage/Sales/Model/Resource/Report/Refunded.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Refunded/Collection/Order.php b/app/code/Mage/Sales/Model/Resource/Report/Refunded/Collection/Order.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Report/Refunded/Collection/Order.php rename to app/code/Mage/Sales/Model/Resource/Report/Refunded/Collection/Order.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Refunded/Collection/Refunded.php b/app/code/Mage/Sales/Model/Resource/Report/Refunded/Collection/Refunded.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Report/Refunded/Collection/Refunded.php rename to app/code/Mage/Sales/Model/Resource/Report/Refunded/Collection/Refunded.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Shipping.php b/app/code/Mage/Sales/Model/Resource/Report/Shipping.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Report/Shipping.php rename to app/code/Mage/Sales/Model/Resource/Report/Shipping.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Shipping/Collection/Order.php b/app/code/Mage/Sales/Model/Resource/Report/Shipping/Collection/Order.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Report/Shipping/Collection/Order.php rename to app/code/Mage/Sales/Model/Resource/Report/Shipping/Collection/Order.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Shipping/Collection/Shipment.php b/app/code/Mage/Sales/Model/Resource/Report/Shipping/Collection/Shipment.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Report/Shipping/Collection/Shipment.php rename to app/code/Mage/Sales/Model/Resource/Report/Shipping/Collection/Shipment.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Sale/Collection.php b/app/code/Mage/Sales/Model/Resource/Sale/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Sale/Collection.php rename to app/code/Mage/Sales/Model/Resource/Sale/Collection.php diff --git a/app/code/core/Mage/Sales/Model/Resource/Setup.php b/app/code/Mage/Sales/Model/Resource/Setup.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sales/Model/Resource/Setup.php rename to app/code/Mage/Sales/Model/Resource/Setup.php diff --git a/app/code/core/Mage/Sales/Model/Service/Order.php b/app/code/Mage/Sales/Model/Service/Order.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Service/Order.php rename to app/code/Mage/Sales/Model/Service/Order.php diff --git a/app/code/core/Mage/Sales/Model/Service/Quote.php b/app/code/Mage/Sales/Model/Service/Quote.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Service/Quote.php rename to app/code/Mage/Sales/Model/Service/Quote.php diff --git a/app/code/core/Mage/Sales/Model/Status/List.php b/app/code/Mage/Sales/Model/Status/List.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Status/List.php rename to app/code/Mage/Sales/Model/Status/List.php diff --git a/app/code/core/Mage/Sales/Model/Status/ListFactory.php b/app/code/Mage/Sales/Model/Status/ListFactory.php similarity index 100% rename from app/code/core/Mage/Sales/Model/Status/ListFactory.php rename to app/code/Mage/Sales/Model/Status/ListFactory.php diff --git a/app/code/core/Mage/Sales/controllers/Billing/AgreementController.php b/app/code/Mage/Sales/controllers/Billing/AgreementController.php similarity index 100% rename from app/code/core/Mage/Sales/controllers/Billing/AgreementController.php rename to app/code/Mage/Sales/controllers/Billing/AgreementController.php diff --git a/app/code/core/Mage/Sales/controllers/DownloadController.php b/app/code/Mage/Sales/controllers/DownloadController.php similarity index 100% rename from app/code/core/Mage/Sales/controllers/DownloadController.php rename to app/code/Mage/Sales/controllers/DownloadController.php diff --git a/app/code/core/Mage/Sales/controllers/GuestController.php b/app/code/Mage/Sales/controllers/GuestController.php similarity index 100% rename from app/code/core/Mage/Sales/controllers/GuestController.php rename to app/code/Mage/Sales/controllers/GuestController.php diff --git a/app/code/core/Mage/Sales/controllers/OrderController.php b/app/code/Mage/Sales/controllers/OrderController.php similarity index 100% rename from app/code/core/Mage/Sales/controllers/OrderController.php rename to app/code/Mage/Sales/controllers/OrderController.php diff --git a/app/code/core/Mage/Sales/controllers/Recurring/ProfileController.php b/app/code/Mage/Sales/controllers/Recurring/ProfileController.php similarity index 100% rename from app/code/core/Mage/Sales/controllers/Recurring/ProfileController.php rename to app/code/Mage/Sales/controllers/Recurring/ProfileController.php diff --git a/app/code/core/Mage/Sales/data/sales_setup/data-install-1.6.0.0.php b/app/code/Mage/Sales/data/sales_setup/data-install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Sales/data/sales_setup/data-install-1.6.0.0.php rename to app/code/Mage/Sales/data/sales_setup/data-install-1.6.0.0.php diff --git a/app/code/Mage/Sales/data/sales_setup/data-upgrade-1.6.0.10-1.6.0.11.php b/app/code/Mage/Sales/data/sales_setup/data-upgrade-1.6.0.10-1.6.0.11.php new file mode 100644 index 0000000000000..9dc1e32f82a54 --- /dev/null +++ b/app/code/Mage/Sales/data/sales_setup/data-upgrade-1.6.0.10-1.6.0.11.php @@ -0,0 +1,38 @@ +getEntityTypeId(Mage_Catalog_Model_Product::ENTITY); +$attributeSetId = $this->getAttributeSetId($entityTypeId, 'Default'); + +$groupName = 'Recurring Profile'; +$this->updateAttributeGroup($entityTypeId, $attributeSetId, $groupName, 'sort_order', 41); +$this->updateAttributeGroup($entityTypeId, $attributeSetId, $groupName, 'attribute_group_code', 'recurring-profile'); +$this->updateAttributeGroup($entityTypeId, $attributeSetId, $groupName, 'tab_group_code', 'advanced'); + +$this->addAttributeToGroup($entityTypeId, $attributeSetId, $groupName, 'is_recurring'); +$this->addAttributeToGroup($entityTypeId, $attributeSetId, $groupName, 'recurring_profile'); diff --git a/app/code/core/Mage/Sales/data/sales_setup/data-upgrade-1.6.0.4-1.6.0.5.php b/app/code/Mage/Sales/data/sales_setup/data-upgrade-1.6.0.4-1.6.0.5.php similarity index 100% rename from app/code/core/Mage/Sales/data/sales_setup/data-upgrade-1.6.0.4-1.6.0.5.php rename to app/code/Mage/Sales/data/sales_setup/data-upgrade-1.6.0.4-1.6.0.5.php diff --git a/app/code/core/Mage/Sales/data/sales_setup/data-upgrade-1.6.0.8-1.6.0.9.php b/app/code/Mage/Sales/data/sales_setup/data-upgrade-1.6.0.8-1.6.0.9.php similarity index 100% rename from app/code/core/Mage/Sales/data/sales_setup/data-upgrade-1.6.0.8-1.6.0.9.php rename to app/code/Mage/Sales/data/sales_setup/data-upgrade-1.6.0.8-1.6.0.9.php diff --git a/app/code/Mage/Sales/etc/adminhtml/acl.xml b/app/code/Mage/Sales/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..51c6a79623ec4 --- /dev/null +++ b/app/code/Mage/Sales/etc/adminhtml/acl.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Mage/Sales/etc/adminhtml/menu.xml b/app/code/Mage/Sales/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..88306a6e92f14 --- /dev/null +++ b/app/code/Mage/Sales/etc/adminhtml/menu.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + diff --git a/app/code/core/Mage/Sales/etc/adminhtml/system.xml b/app/code/Mage/Sales/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Sales/etc/adminhtml/system.xml rename to app/code/Mage/Sales/etc/adminhtml/system.xml diff --git a/app/code/core/Mage/Sales/etc/api.xml b/app/code/Mage/Sales/etc/api.xml similarity index 100% rename from app/code/core/Mage/Sales/etc/api.xml rename to app/code/Mage/Sales/etc/api.xml diff --git a/app/code/Mage/Sales/etc/config.xml b/app/code/Mage/Sales/etc/config.xml new file mode 100644 index 0000000000000..818a173ef3e62 --- /dev/null +++ b/app/code/Mage/Sales/etc/config.xml @@ -0,0 +1,730 @@ + + + + + + 1.6.0.11 + true + + + + + + + + + + + + + + Mage_Sales + Mage_Sales_Model_Resource_Setup + + + + + + + + global/sales/quote/item/product_attributes + + + + + + + + + Mage_Sales_Model_Quote_Address_Total_Nominal + subtotal + + + Mage_Sales_Model_Quote_Address_Total_Subtotal + nominal + grand_total + + + Mage_Sales_Model_Quote_Address_Total_Shipping + subtotal,freeshipping,tax_subtotal + grand_total + + + Mage_Sales_Model_Quote_Address_Total_Grand + subtotal + + + Mage_Sales_Model_Quote_Address_Total_Msrp + + + + + Mage_Sales_Model_Quote_Address_Total_Nominal_Recurring_Initial + 10 + + + Mage_Sales_Model_Quote_Address_Total_Nominal_Recurring_Trial + 50 + + + Mage_Sales_Model_Quote_Address_Total_Nominal_Subtotal + 250 + + + Mage_Sales_Model_Quote_Address_Total_Nominal_Shipping + 1250 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + 1 + + + + + + + 1 + + + + + + + 1 + + + + + + + 1 + + + + + + + 1 + + + + + + + + 1 + + + + + + + Mage_Sales_Model_Order_Invoice_Total_Subtotal + + + Mage_Sales_Model_Order_Invoice_Total_Discount + subtotal + + + Mage_Sales_Model_Order_Invoice_Total_Shipping + subtotal,discount + grand_total,tax + + + Mage_Sales_Model_Order_Invoice_Total_Tax + subtotal + + + Mage_Sales_Model_Order_Invoice_Total_Grand + shipping + + + Mage_Sales_Model_Order_Invoice_Total_Cost + discount + grand_total + + + + + + + Mage_Sales_Model_Order_Creditmemo_Total_Subtotal + + + Mage_Sales_Model_Order_Creditmemo_Total_Shipping + subtotal,discount + grand_total,tax + + + Mage_Sales_Model_Order_Creditmemo_Total_Tax + subtotal + + + Mage_Sales_Model_Order_Creditmemo_Total_Discount + subtotal + + + Mage_Sales_Model_Order_Creditmemo_Total_Grand + shipping,subtotal + + + Mage_Sales_Model_Order_Creditmemo_Total_Cost + discount + grand_total + + + + + + + Mage_Sales_Model_Order_Pdf_Items_Invoice_Default + Mage_Sales_Model_Order_Pdf_Items_Invoice_Grouped + + + Mage_Sales_Model_Order_Pdf_Items_Shipment_Default + + + Mage_Sales_Model_Order_Pdf_Items_Creditmemo_Default + Mage_Sales_Model_Order_Pdf_Items_Creditmemo_Grouped + + + + Subtotal + subtotal + 7 + 1 + 100 + + + Discount + discount_amount + + discount_description + 7 + 0 + 200 + + + Shipping & Handling + shipping_amount + 7 + 0 + 400 + + + Adjustment Refund + adjustment_positive + 7 + 0 + 500 + + + Adjustment Fee + adjustment_negative + 7 + 0 + 600 + + + Grand Total + grand_total + 8 + 1 + 700 + + + + + + + + + inform + + + + + + + + + Mage_Sales_Model_Observer + addVatRequestParamsOrderComment + + + + + + + Mage_Sales_Model_Order_Webhook_Observer + dispatchOrderCreatedEvent + + + + + + + + /sales/ + + + + standard + + Mage_Sales + sales + + + + + + + + Mage_Sales.csv + + + + + + + + layout.xml + + + billing_agreement.xml + + + recurring_profile.xml + + + + + + + + Mage_Sales_Model_Observer + changeQuoteCustomerGroupId + + + + + + + Mage_Sales_Model_Observer + restoreQuoteCustomerGroupId + + + + + + + Mage_Sales_Model_Observer + setQuoteCanApplyMsrp + + + + + + + + + + + Mage_Sales.csv + + + + + + + + + Mage_Sales_Model_Observer + substractQtyFromQuotes + + + + + + + Mage_Sales_Model_Observer + markQuotesRecollectOnCatalogRules + + + + + + + Mage_Sales_Model_Observer + markQuotesRecollectOnCatalogRules + + + + + + + Mage_Sales_Model_Observer + catalogProductSaveAfter + + + + + + + Mage_Sales_Model_Observer + catalogProductStatusUpdate + + + + + + + Mage_Sales_Model_Observer + prepareProductEditFormRecurringProfile + + + + + + + Mage_Sales_Model_Observer + restrictAdminBillingAgreementUsage + + + + + + + Mage_Sales_Model_Observer + customerSaveAfter + + + + + + + + + 20 + 100 + 30 + 10 + 40 + + + 1 + + + + + 1 + + sales_email_order_guest_template + sales + bcc + + + 1 + + sales_email_order_comment_guest_template + sales + bcc + + + 1 + + sales_email_invoice_guest_template + sales + bcc + + + 1 + + sales_email_invoice_comment_guest_template + sales + bcc + + + 1 + + sales_email_shipment_guest_template + sales + bcc + + + 1 + + sales_email_shipment_comment_guest_template + sales + bcc + + + 1 + + sales_email_creditmemo_guest_template + sales + bcc + + + 1 + + sales_email_creditmemo_comment_guest_template + sales + bcc + + + + + 1 + + + 1 + + + 1 + + + + 0 + + + + + + + 0 0 * * * + + + Mage_Sales_Model_Observer::cleanExpiredQuotes + + + + + 0 0 * * * + + + Mage_Sales_Model_Observer::aggregateSalesReportOrderData + + + + + 0 0 * * * + + + Mage_Sales_Model_Observer::aggregateSalesReportShipmentData + + + + + 0 0 * * * + + + Mage_Sales_Model_Observer::aggregateSalesReportInvoicedData + + + + + 0 0 * * * + + + Mage_Sales_Model_Observer::aggregateSalesReportRefundedData + + + + + 0 0 * * * + + + Mage_Sales_Model_Observer::aggregateSalesReportBestsellersData + + + + + diff --git a/app/code/core/Mage/Sales/etc/fieldset.xml b/app/code/Mage/Sales/etc/fieldset.xml similarity index 100% rename from app/code/core/Mage/Sales/etc/fieldset.xml rename to app/code/Mage/Sales/etc/fieldset.xml diff --git a/app/code/Mage/Sales/etc/webapi/acl.xml b/app/code/Mage/Sales/etc/webapi/acl.xml new file mode 100644 index 0000000000000..44b3e81949019 --- /dev/null +++ b/app/code/Mage/Sales/etc/webapi/acl.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + diff --git a/app/code/Mage/Sales/etc/webhook/acl.xml b/app/code/Mage/Sales/etc/webhook/acl.xml new file mode 100644 index 0000000000000..f7f56805b58a7 --- /dev/null +++ b/app/code/Mage/Sales/etc/webhook/acl.xml @@ -0,0 +1,34 @@ + + + + + + + + + diff --git a/app/code/core/Mage/Sales/etc/widget.xml b/app/code/Mage/Sales/etc/widget.xml similarity index 100% rename from app/code/core/Mage/Sales/etc/widget.xml rename to app/code/Mage/Sales/etc/widget.xml diff --git a/app/code/core/Mage/Sales/etc/wsdl.xml b/app/code/Mage/Sales/etc/wsdl.xml similarity index 100% rename from app/code/core/Mage/Sales/etc/wsdl.xml rename to app/code/Mage/Sales/etc/wsdl.xml diff --git a/app/code/core/Mage/Sales/etc/wsi.xml b/app/code/Mage/Sales/etc/wsi.xml similarity index 100% rename from app/code/core/Mage/Sales/etc/wsi.xml rename to app/code/Mage/Sales/etc/wsi.xml diff --git a/app/code/core/Mage/Sales/locale/de_DE/Mage_Sales.csv b/app/code/Mage/Sales/locale/de_DE/Mage_Sales.csv similarity index 100% rename from app/code/core/Mage/Sales/locale/de_DE/Mage_Sales.csv rename to app/code/Mage/Sales/locale/de_DE/Mage_Sales.csv diff --git a/app/code/core/Mage/Sales/locale/en_US/Mage_Sales.csv b/app/code/Mage/Sales/locale/en_US/Mage_Sales.csv similarity index 100% rename from app/code/core/Mage/Sales/locale/en_US/Mage_Sales.csv rename to app/code/Mage/Sales/locale/en_US/Mage_Sales.csv diff --git a/app/code/core/Mage/Sales/locale/es_ES/Mage_Sales.csv b/app/code/Mage/Sales/locale/es_ES/Mage_Sales.csv similarity index 100% rename from app/code/core/Mage/Sales/locale/es_ES/Mage_Sales.csv rename to app/code/Mage/Sales/locale/es_ES/Mage_Sales.csv diff --git a/app/code/core/Mage/Sales/locale/fr_FR/Mage_Sales.csv b/app/code/Mage/Sales/locale/fr_FR/Mage_Sales.csv similarity index 100% rename from app/code/core/Mage/Sales/locale/fr_FR/Mage_Sales.csv rename to app/code/Mage/Sales/locale/fr_FR/Mage_Sales.csv diff --git a/app/code/core/Mage/Sales/locale/nl_NL/Mage_Sales.csv b/app/code/Mage/Sales/locale/nl_NL/Mage_Sales.csv similarity index 100% rename from app/code/core/Mage/Sales/locale/nl_NL/Mage_Sales.csv rename to app/code/Mage/Sales/locale/nl_NL/Mage_Sales.csv diff --git a/app/code/core/Mage/Sales/locale/pt_BR/Mage_Sales.csv b/app/code/Mage/Sales/locale/pt_BR/Mage_Sales.csv similarity index 100% rename from app/code/core/Mage/Sales/locale/pt_BR/Mage_Sales.csv rename to app/code/Mage/Sales/locale/pt_BR/Mage_Sales.csv diff --git a/app/code/core/Mage/Sales/locale/zh_CN/Mage_Sales.csv b/app/code/Mage/Sales/locale/zh_CN/Mage_Sales.csv similarity index 100% rename from app/code/core/Mage/Sales/locale/zh_CN/Mage_Sales.csv rename to app/code/Mage/Sales/locale/zh_CN/Mage_Sales.csv diff --git a/app/code/core/Mage/Sales/sql/sales_setup/install-1.6.0.0.php b/app/code/Mage/Sales/sql/sales_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Sales/sql/sales_setup/install-1.6.0.0.php rename to app/code/Mage/Sales/sql/sales_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.0-1.6.0.1.php b/app/code/Mage/Sales/sql/sales_setup/upgrade-1.6.0.0-1.6.0.1.php similarity index 100% rename from app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.0-1.6.0.1.php rename to app/code/Mage/Sales/sql/sales_setup/upgrade-1.6.0.0-1.6.0.1.php diff --git a/app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.1-1.6.0.2.php b/app/code/Mage/Sales/sql/sales_setup/upgrade-1.6.0.1-1.6.0.2.php similarity index 100% rename from app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.1-1.6.0.2.php rename to app/code/Mage/Sales/sql/sales_setup/upgrade-1.6.0.1-1.6.0.2.php diff --git a/app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.2-1.6.0.3.php b/app/code/Mage/Sales/sql/sales_setup/upgrade-1.6.0.2-1.6.0.3.php similarity index 100% rename from app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.2-1.6.0.3.php rename to app/code/Mage/Sales/sql/sales_setup/upgrade-1.6.0.2-1.6.0.3.php diff --git a/app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.3-1.6.0.4.php b/app/code/Mage/Sales/sql/sales_setup/upgrade-1.6.0.3-1.6.0.4.php similarity index 100% rename from app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.3-1.6.0.4.php rename to app/code/Mage/Sales/sql/sales_setup/upgrade-1.6.0.3-1.6.0.4.php diff --git a/app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.4-1.6.0.5.php b/app/code/Mage/Sales/sql/sales_setup/upgrade-1.6.0.4-1.6.0.5.php similarity index 100% rename from app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.4-1.6.0.5.php rename to app/code/Mage/Sales/sql/sales_setup/upgrade-1.6.0.4-1.6.0.5.php diff --git a/app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.5-1.6.0.6.php b/app/code/Mage/Sales/sql/sales_setup/upgrade-1.6.0.5-1.6.0.6.php similarity index 100% rename from app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.5-1.6.0.6.php rename to app/code/Mage/Sales/sql/sales_setup/upgrade-1.6.0.5-1.6.0.6.php diff --git a/app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.6-1.6.0.7.php b/app/code/Mage/Sales/sql/sales_setup/upgrade-1.6.0.6-1.6.0.7.php similarity index 100% rename from app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.6-1.6.0.7.php rename to app/code/Mage/Sales/sql/sales_setup/upgrade-1.6.0.6-1.6.0.7.php diff --git a/app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.7-1.6.0.8.php b/app/code/Mage/Sales/sql/sales_setup/upgrade-1.6.0.7-1.6.0.8.php similarity index 100% rename from app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.7-1.6.0.8.php rename to app/code/Mage/Sales/sql/sales_setup/upgrade-1.6.0.7-1.6.0.8.php diff --git a/app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.8-1.6.0.9.php b/app/code/Mage/Sales/sql/sales_setup/upgrade-1.6.0.8-1.6.0.9.php similarity index 100% rename from app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.8-1.6.0.9.php rename to app/code/Mage/Sales/sql/sales_setup/upgrade-1.6.0.8-1.6.0.9.php diff --git a/app/code/core/Mage/Sales/view/adminhtml/billing/agreement/form.phtml b/app/code/Mage/Sales/view/adminhtml/billing/agreement/form.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/adminhtml/billing/agreement/form.phtml rename to app/code/Mage/Sales/view/adminhtml/billing/agreement/form.phtml diff --git a/app/code/core/Mage/Sales/view/adminhtml/billing/agreement/view/form.phtml b/app/code/Mage/Sales/view/adminhtml/billing/agreement/view/form.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/adminhtml/billing/agreement/view/form.phtml rename to app/code/Mage/Sales/view/adminhtml/billing/agreement/view/form.phtml diff --git a/app/code/Mage/Sales/view/adminhtml/billing/agreement/view/tab/info.phtml b/app/code/Mage/Sales/view/adminhtml/billing/agreement/view/tab/info.phtml new file mode 100644 index 0000000000000..1733d4f38d953 --- /dev/null +++ b/app/code/Mage/Sales/view/adminhtml/billing/agreement/view/tab/info.phtml @@ -0,0 +1,61 @@ + +
    +
    + __('General Information'); ?> +
    +
    + + + + + + + + + + + + + + + + + + + + + + + +
    __('Reference ID'); ?>escapeHtml($this->getReferenceId()) ?>
    __('Customer'); ?> + + getCustomerEmail() ?> + +
    __('Status'); ?>getStatus() ?>
    __('Created At'); ?>getCreatedAt(); ?>
    __('Updated At'); ?>getUpdatedAt(); ?>
    +
    +
    diff --git a/app/code/core/Mage/Sales/view/adminhtml/payment/form/billing/agreement.phtml b/app/code/Mage/Sales/view/adminhtml/payment/form/billing/agreement.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/adminhtml/payment/form/billing/agreement.phtml rename to app/code/Mage/Sales/view/adminhtml/payment/form/billing/agreement.phtml diff --git a/app/code/core/Mage/Sales/view/adminhtml/recurring/profile/view.phtml b/app/code/Mage/Sales/view/adminhtml/recurring/profile/view.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/adminhtml/recurring/profile/view.phtml rename to app/code/Mage/Sales/view/adminhtml/recurring/profile/view.phtml diff --git a/app/code/core/Mage/Sales/view/adminhtml/recurring/profile/view/info.phtml b/app/code/Mage/Sales/view/adminhtml/recurring/profile/view/info.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/adminhtml/recurring/profile/view/info.phtml rename to app/code/Mage/Sales/view/adminhtml/recurring/profile/view/info.phtml diff --git a/app/code/core/Mage/Sales/view/email/creditmemo_new.html b/app/code/Mage/Sales/view/email/creditmemo_new.html similarity index 100% rename from app/code/core/Mage/Sales/view/email/creditmemo_new.html rename to app/code/Mage/Sales/view/email/creditmemo_new.html diff --git a/app/code/core/Mage/Sales/view/email/creditmemo_new_guest.html b/app/code/Mage/Sales/view/email/creditmemo_new_guest.html similarity index 100% rename from app/code/core/Mage/Sales/view/email/creditmemo_new_guest.html rename to app/code/Mage/Sales/view/email/creditmemo_new_guest.html diff --git a/app/code/core/Mage/Sales/view/email/creditmemo_update.html b/app/code/Mage/Sales/view/email/creditmemo_update.html similarity index 100% rename from app/code/core/Mage/Sales/view/email/creditmemo_update.html rename to app/code/Mage/Sales/view/email/creditmemo_update.html diff --git a/app/code/core/Mage/Sales/view/email/creditmemo_update_guest.html b/app/code/Mage/Sales/view/email/creditmemo_update_guest.html similarity index 100% rename from app/code/core/Mage/Sales/view/email/creditmemo_update_guest.html rename to app/code/Mage/Sales/view/email/creditmemo_update_guest.html diff --git a/app/code/core/Mage/Sales/view/email/invoice_new.html b/app/code/Mage/Sales/view/email/invoice_new.html similarity index 100% rename from app/code/core/Mage/Sales/view/email/invoice_new.html rename to app/code/Mage/Sales/view/email/invoice_new.html diff --git a/app/code/core/Mage/Sales/view/email/invoice_new_guest.html b/app/code/Mage/Sales/view/email/invoice_new_guest.html similarity index 100% rename from app/code/core/Mage/Sales/view/email/invoice_new_guest.html rename to app/code/Mage/Sales/view/email/invoice_new_guest.html diff --git a/app/code/core/Mage/Sales/view/email/invoice_update.html b/app/code/Mage/Sales/view/email/invoice_update.html similarity index 100% rename from app/code/core/Mage/Sales/view/email/invoice_update.html rename to app/code/Mage/Sales/view/email/invoice_update.html diff --git a/app/code/core/Mage/Sales/view/email/invoice_update_guest.html b/app/code/Mage/Sales/view/email/invoice_update_guest.html similarity index 100% rename from app/code/core/Mage/Sales/view/email/invoice_update_guest.html rename to app/code/Mage/Sales/view/email/invoice_update_guest.html diff --git a/app/code/core/Mage/Sales/view/email/order_new.html b/app/code/Mage/Sales/view/email/order_new.html similarity index 100% rename from app/code/core/Mage/Sales/view/email/order_new.html rename to app/code/Mage/Sales/view/email/order_new.html diff --git a/app/code/core/Mage/Sales/view/email/order_new_guest.html b/app/code/Mage/Sales/view/email/order_new_guest.html similarity index 100% rename from app/code/core/Mage/Sales/view/email/order_new_guest.html rename to app/code/Mage/Sales/view/email/order_new_guest.html diff --git a/app/code/core/Mage/Sales/view/email/order_update.html b/app/code/Mage/Sales/view/email/order_update.html similarity index 100% rename from app/code/core/Mage/Sales/view/email/order_update.html rename to app/code/Mage/Sales/view/email/order_update.html diff --git a/app/code/core/Mage/Sales/view/email/order_update_guest.html b/app/code/Mage/Sales/view/email/order_update_guest.html similarity index 100% rename from app/code/core/Mage/Sales/view/email/order_update_guest.html rename to app/code/Mage/Sales/view/email/order_update_guest.html diff --git a/app/code/core/Mage/Sales/view/email/shipment_new.html b/app/code/Mage/Sales/view/email/shipment_new.html similarity index 100% rename from app/code/core/Mage/Sales/view/email/shipment_new.html rename to app/code/Mage/Sales/view/email/shipment_new.html diff --git a/app/code/core/Mage/Sales/view/email/shipment_new_guest.html b/app/code/Mage/Sales/view/email/shipment_new_guest.html similarity index 100% rename from app/code/core/Mage/Sales/view/email/shipment_new_guest.html rename to app/code/Mage/Sales/view/email/shipment_new_guest.html diff --git a/app/code/core/Mage/Sales/view/email/shipment_update.html b/app/code/Mage/Sales/view/email/shipment_update.html similarity index 100% rename from app/code/core/Mage/Sales/view/email/shipment_update.html rename to app/code/Mage/Sales/view/email/shipment_update.html diff --git a/app/code/core/Mage/Sales/view/email/shipment_update_guest.html b/app/code/Mage/Sales/view/email/shipment_update_guest.html similarity index 100% rename from app/code/core/Mage/Sales/view/email/shipment_update_guest.html rename to app/code/Mage/Sales/view/email/shipment_update_guest.html diff --git a/app/code/core/Mage/Sales/view/frontend/billing/agreement/view.phtml b/app/code/Mage/Sales/view/frontend/billing/agreement/view.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/billing/agreement/view.phtml rename to app/code/Mage/Sales/view/frontend/billing/agreement/view.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/billing/agreements.phtml b/app/code/Mage/Sales/view/frontend/billing/agreements.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/billing/agreements.phtml rename to app/code/Mage/Sales/view/frontend/billing/agreements.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/billing_agreement.xml b/app/code/Mage/Sales/view/frontend/billing_agreement.xml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/billing_agreement.xml rename to app/code/Mage/Sales/view/frontend/billing_agreement.xml diff --git a/app/code/core/Mage/Sales/view/frontend/email/creditmemo/items.phtml b/app/code/Mage/Sales/view/frontend/email/creditmemo/items.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/email/creditmemo/items.phtml rename to app/code/Mage/Sales/view/frontend/email/creditmemo/items.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/email/invoice/items.phtml b/app/code/Mage/Sales/view/frontend/email/invoice/items.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/email/invoice/items.phtml rename to app/code/Mage/Sales/view/frontend/email/invoice/items.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/email/items.phtml b/app/code/Mage/Sales/view/frontend/email/items.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/email/items.phtml rename to app/code/Mage/Sales/view/frontend/email/items.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/email/items/creditmemo/default.phtml b/app/code/Mage/Sales/view/frontend/email/items/creditmemo/default.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/email/items/creditmemo/default.phtml rename to app/code/Mage/Sales/view/frontend/email/items/creditmemo/default.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/email/items/invoice/default.phtml b/app/code/Mage/Sales/view/frontend/email/items/invoice/default.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/email/items/invoice/default.phtml rename to app/code/Mage/Sales/view/frontend/email/items/invoice/default.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/email/items/order/default.phtml b/app/code/Mage/Sales/view/frontend/email/items/order/default.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/email/items/order/default.phtml rename to app/code/Mage/Sales/view/frontend/email/items/order/default.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/email/items/shipment/default.phtml b/app/code/Mage/Sales/view/frontend/email/items/shipment/default.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/email/items/shipment/default.phtml rename to app/code/Mage/Sales/view/frontend/email/items/shipment/default.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/email/shipment/items.phtml b/app/code/Mage/Sales/view/frontend/email/shipment/items.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/email/shipment/items.phtml rename to app/code/Mage/Sales/view/frontend/email/shipment/items.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/email/shipment/track.phtml b/app/code/Mage/Sales/view/frontend/email/shipment/track.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/email/shipment/track.phtml rename to app/code/Mage/Sales/view/frontend/email/shipment/track.phtml diff --git a/app/code/Mage/Sales/view/frontend/gift-message.js b/app/code/Mage/Sales/view/frontend/gift-message.js new file mode 100644 index 0000000000000..9c464b246d167 --- /dev/null +++ b/app/code/Mage/Sales/view/frontend/gift-message.js @@ -0,0 +1,74 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category gift message + * @package mage + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +/*jshint jquery:true*/ +(function($) { + "use strict"; + $.widget('mage.giftMessage', { + options: { + rowPrefix: '#order-item-row-', // Selector prefix for item's row in the table. + linkPrefix: '#order-item-gift-message-link-', // Selector prefix for the 'Gift Message' link. + duration: 100, // Toggle duration. + expandedClass: 'expanded', // Class added/removed to/from the 'Gift Message' link. + lastClass: 'last' // Class added/removed to/from the last item's row in the products table. + }, + + /** + * Bind a click handler on the widget's element to toggle the gift message. + * @private + */ + _create: function() { + this.element.on('click', $.proxy(this._toggleGiftMessage, this)); + }, + + /** + * Toggle the display of the item's corresponding gift message. + * @private + * @param event - {Object} - Click event. + */ + _toggleGiftMessage: function(event) { + var element = $(event.target), // Click target. The 'Gift Message' link or 'Close' button. + options = this.options, // Cached widget options. + itemId = element.data('item-id'), // The individual item's numeric id. + link = $(options.linkPrefix + itemId), // The 'Gift Message' expandable link. + row = $(options.rowPrefix + itemId), // The item's row in the products table. + region = $('#' + element.attr('aria-controls')); // The gift message container region. + region.toggle(options.duration, function() { + if (region.attr('aria-expanded') === "true") { + region.attr('aria-expanded', "false"); + if (region.hasClass(options.lastClass)) { + row.addClass(options.lastClass); + } + } else { + region.attr('aria-expanded', "true"); + if (region.hasClass(options.lastClass)) { + row.removeClass(options.lastClass); + } + } + link.toggleClass(options.expandedClass); + }); + event.preventDefault(); // Prevent event propagation and avoid going to the link's href. + } + }); +})(jQuery); diff --git a/app/code/core/Mage/Sales/view/frontend/guest/form.phtml b/app/code/Mage/Sales/view/frontend/guest/form.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/guest/form.phtml rename to app/code/Mage/Sales/view/frontend/guest/form.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/layout.xml b/app/code/Mage/Sales/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/layout.xml rename to app/code/Mage/Sales/view/frontend/layout.xml diff --git a/app/code/core/Mage/Sales/view/frontend/order/comments.phtml b/app/code/Mage/Sales/view/frontend/order/comments.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/order/comments.phtml rename to app/code/Mage/Sales/view/frontend/order/comments.phtml diff --git a/app/code/Mage/Sales/view/frontend/order/creditmemo.phtml b/app/code/Mage/Sales/view/frontend/order/creditmemo.phtml new file mode 100644 index 0000000000000..3b8c8c263ad20 --- /dev/null +++ b/app/code/Mage/Sales/view/frontend/order/creditmemo.phtml @@ -0,0 +1,32 @@ + +
    + getChildHtml('creditmemo_items') ?> + +
    diff --git a/app/code/core/Mage/Sales/view/frontend/order/creditmemo/items.phtml b/app/code/Mage/Sales/view/frontend/order/creditmemo/items.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/order/creditmemo/items.phtml rename to app/code/Mage/Sales/view/frontend/order/creditmemo/items.phtml diff --git a/app/code/Mage/Sales/view/frontend/order/creditmemo/items/renderer/default.phtml b/app/code/Mage/Sales/view/frontend/order/creditmemo/items/renderer/default.phtml new file mode 100644 index 0000000000000..d67a5e3801ead --- /dev/null +++ b/app/code/Mage/Sales/view/frontend/order/creditmemo/items/renderer/default.phtml @@ -0,0 +1,302 @@ + +getItem() ?> +getItem()->getOrderItem()->getOrder() ?> + +

    escapeHtml($_item->getName()) ?>

    + getItemOptions()): ?> +
    + +
    escapeHtml($_option['label']) ?>
    + getPrintStatus()): ?> + getFormatedOptionValue($_option) ?> + class="truncated" data-mage-init="{truncateOptions:[]}"> + +
    +
    +
    escapeHtml($_option['label']) ?>
    +
    +
    +
    + + + +
    escapeHtml( (isset($_option['print_value']) ? $_option['print_value'] : $_option['value']) ) ?>
    + + +
    + + getProductAdditionalInformationBlock(); ?> + + setItem($_item->getOrderItem())->toHtml(); ?> + + escapeHtml($_item->getDescription()) ?> + helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $_item->getOrderItem()) && $_item->getGiftMessageId()): ?> + __('Gift Message') ?> + + + escapeHtml(Mage::helper('Mage_Core_Helper_String')->splitInjection($this->getSku())) ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Excl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> + + getOrder()->formatPrice($this->getItem()->getPrice()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?>
    +
    + + +
    +
    + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Incl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + helper('Mage_Checkout_Helper_Data')->getPriceInclTax($this->getItem()); ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> + + getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?>
    +
    + + +
    + + + getQty()*1 ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Excl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> + + getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?>
    +
    + + +
    +
    + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Incl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($this->getItem()); ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?> + + getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxRowDisposition()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?>
    +
    + + + + + +
    + + + formatPrice(-$_item->getDiscountAmount()) ?> + + formatPrice($_item->getRowTotal()-$_item->getDiscountAmount()+$_item->getTaxAmount()+$_item->getWeeeTaxAppliedRowAmount()) ?> + + diff --git a/app/code/core/Mage/Sales/view/frontend/order/history.phtml b/app/code/Mage/Sales/view/frontend/order/history.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/order/history.phtml rename to app/code/Mage/Sales/view/frontend/order/history.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/order/info.phtml b/app/code/Mage/Sales/view/frontend/order/info.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/order/info.phtml rename to app/code/Mage/Sales/view/frontend/order/info.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/order/info/buttons.phtml b/app/code/Mage/Sales/view/frontend/order/info/buttons.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/order/info/buttons.phtml rename to app/code/Mage/Sales/view/frontend/order/info/buttons.phtml diff --git a/app/code/Mage/Sales/view/frontend/order/invoice.phtml b/app/code/Mage/Sales/view/frontend/order/invoice.phtml new file mode 100644 index 0000000000000..bef92be005440 --- /dev/null +++ b/app/code/Mage/Sales/view/frontend/order/invoice.phtml @@ -0,0 +1,32 @@ + +
    + getChildHtml('invoice_items') ?> + +
    diff --git a/app/code/core/Mage/Sales/view/frontend/order/invoice/items.phtml b/app/code/Mage/Sales/view/frontend/order/invoice/items.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/order/invoice/items.phtml rename to app/code/Mage/Sales/view/frontend/order/invoice/items.phtml diff --git a/app/code/Mage/Sales/view/frontend/order/invoice/items/renderer/default.phtml b/app/code/Mage/Sales/view/frontend/order/invoice/items/renderer/default.phtml new file mode 100644 index 0000000000000..eacb99529c3be --- /dev/null +++ b/app/code/Mage/Sales/view/frontend/order/invoice/items/renderer/default.phtml @@ -0,0 +1,299 @@ + +getItem() ?> +getItem()->getOrderItem()->getOrder() ?> + +

    escapeHtml($_item->getName()) ?>

    + getItemOptions()): ?> +
    + +
    escapeHtml($_option['label']) ?>
    + getPrintStatus()): ?> + getFormatedOptionValue($_option) ?> + class="truncated" data-mage-init="{truncateOptions:[]}"> + + +
    +
    +
    escapeHtml($_option['label']) ?>
    +
    +
    +
    + + + +
    escapeHtml( (isset($_option['print_value']) ? $_option['print_value'] : $_option['value']) ) ?>
    + + +
    + + getProductAdditionalInformationBlock(); ?> + + setItem($_item->getOrderItem())->toHtml(); ?> + + escapeHtml($_item->getDescription()) ?> + helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $_item->getOrderItem()) && $_item->getGiftMessageId()): ?> + __('Gift Message') ?> + + + escapeHtml(Mage::helper('Mage_Core_Helper_String')->splitInjection($this->getSku())) ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Excl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> + + getOrder()->formatPrice($this->getItem()->getPrice()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?>
    +
    + + +
    +
    + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Incl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + helper('Mage_Checkout_Helper_Data')->getPriceInclTax($this->getItem()); ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> + + getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?>
    +
    + + +
    + + + getQty()*1 ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Excl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> + + getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?>
    +
    + + +
    +
    + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Incl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($this->getItem()); ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?> + + getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxRowDisposition()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?>
    +
    + + + + + +
    + + + diff --git a/app/code/Mage/Sales/view/frontend/order/items.phtml b/app/code/Mage/Sales/view/frontend/order/items.phtml new file mode 100644 index 0000000000000..ec064e1ff095b --- /dev/null +++ b/app/code/Mage/Sales/view/frontend/order/items.phtml @@ -0,0 +1,77 @@ + +getOrder() ?> + + + + + + + + + + + + + + + + + + getChildHtml('order_totals') ?> + + getItemsCollection(); ?> + + count(); ?> + + getParentItem()) continue; ?> + + getItemHtml($_item) ?> + helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $_item) && $_item->getGiftMessageId()): ?> + + helper('Mage_GiftMessage_Helper_Message')->getGiftMessageForEntity($_item); ?> + + + + + +
    __('Product Name') ?>__('SKU') ?>__('Price') ?>__('Qty') ?>__('Subtotal') ?>
    + + + + diff --git a/app/code/Mage/Sales/view/frontend/order/items/renderer/default.phtml b/app/code/Mage/Sales/view/frontend/order/items/renderer/default.phtml new file mode 100644 index 0000000000000..507f6155cc53b --- /dev/null +++ b/app/code/Mage/Sales/view/frontend/order/items/renderer/default.phtml @@ -0,0 +1,323 @@ + +getItem() ?> + +

    escapeHtml($_item->getName()) ?>

    + getItemOptions()): ?> +
    + +
    escapeHtml($_option['label']) ?>
    + getPrintStatus()): ?> + getFormatedOptionValue($_option) ?> + class="truncated" data-mage-init="{truncateOptions:[]}"> + + +
    +
    +
    escapeHtml($_option['label']) ?>
    +
    +
    +
    + + + +
    + escapeHtml( (isset($_option['print_value']) ? $_option['print_value'] : $_option['value']) )) ?> +
    + + +
    + + getProductAdditionalInformationBlock(); ?> + + setItem($_item)->toHtml(); ?> + + escapeHtml($_item->getDescription()) ?> + helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $_item) && $_item->getGiftMessageId()): ?> + __('Gift Message') ?> + + + escapeHtml(Mage::helper('Mage_Core_Helper_String')->splitInjection($this->getSku())) ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Excl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> + + getOrder()->formatPrice($this->getItem()->getPrice()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?>
    +
    + + +
    +
    + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Incl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + helper('Mage_Checkout_Helper_Data')->getPriceInclTax($this->getItem()); ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> + + getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?>
    +
    + + +
    + + + + + getItem()->getQtyOrdered() > 0): ?> + __('Ordered'); ?>: getItem()->getQtyOrdered()*1 ?>
    + + getItem()->getQtyShipped() > 0): ?> + __('Shipped'); ?>: getItem()->getQtyShipped()*1 ?>
    + + getItem()->getQtyCanceled() > 0): ?> + __('Canceled'); ?>: getItem()->getQtyCanceled()*1 ?>
    + + getItem()->getQtyRefunded() > 0): ?> + __('Refunded'); ?>: getItem()->getQtyRefunded()*1 ?>
    + +
    + + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Excl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> + + getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?>
    +
    + + +
    +
    + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> + + helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + __('Incl. Tax'); ?>: + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($this->getItem()); ?> + typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + + + + typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?> + + getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxRowDisposition()) ?> + + + + + + getApplied($this->getItem())): ?> + + + + typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> + + __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?>
    +
    + + + + + +
    + + + + diff --git a/app/code/core/Mage/Sales/view/frontend/order/print.phtml b/app/code/Mage/Sales/view/frontend/order/print.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/order/print.phtml rename to app/code/Mage/Sales/view/frontend/order/print.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/order/print/creditmemo.phtml b/app/code/Mage/Sales/view/frontend/order/print/creditmemo.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/order/print/creditmemo.phtml rename to app/code/Mage/Sales/view/frontend/order/print/creditmemo.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/order/print/invoice.phtml b/app/code/Mage/Sales/view/frontend/order/print/invoice.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/order/print/invoice.phtml rename to app/code/Mage/Sales/view/frontend/order/print/invoice.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/order/print/shipment.phtml b/app/code/Mage/Sales/view/frontend/order/print/shipment.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/order/print/shipment.phtml rename to app/code/Mage/Sales/view/frontend/order/print/shipment.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/order/recent.phtml b/app/code/Mage/Sales/view/frontend/order/recent.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/order/recent.phtml rename to app/code/Mage/Sales/view/frontend/order/recent.phtml diff --git a/app/code/Mage/Sales/view/frontend/order/shipment.phtml b/app/code/Mage/Sales/view/frontend/order/shipment.phtml new file mode 100644 index 0000000000000..b6237c8c2f47c --- /dev/null +++ b/app/code/Mage/Sales/view/frontend/order/shipment.phtml @@ -0,0 +1,32 @@ + +
    + getChildHtml('shipment_items') ?> + +
    diff --git a/app/code/Mage/Sales/view/frontend/order/shipment/items.phtml b/app/code/Mage/Sales/view/frontend/order/shipment/items.phtml new file mode 100644 index 0000000000000..66f8d70de28b5 --- /dev/null +++ b/app/code/Mage/Sales/view/frontend/order/shipment/items.phtml @@ -0,0 +1,89 @@ + +getOrder() ?> + +getShipmentsCollection() as $_shipment): ?> +

    __('Shipment #') ?>getIncrementId(); ?> | __('Print Shipment') ?>

    +getTracksCollection(); ?> +count()): ?> + + + + + + + + + + +
    + __('Track this shipment') ?> +
    __('Tracking Number(s):') ?>  + count(); + foreach($tracks as $track): ?> + isCustom()): ?> + escapeHtml($track->getNumber()) ?> + + escapeHtml($track->getNumber()) ?> + + , + +
    + + +

    __('Items Shipped') ?>

    + + + + + + + + + + + + getAllItems(); ?> + + + getOrderItem()->getParentItem()) continue; ?> + + getItemHtml($_item) ?> + + +
    __('Product Name') ?>__('SKU') ?>__('Qty Shipped') ?>
    + +getCommentsHtml($_shipment)?> + diff --git a/app/code/Mage/Sales/view/frontend/order/shipment/items/renderer/default.phtml b/app/code/Mage/Sales/view/frontend/order/shipment/items/renderer/default.phtml new file mode 100644 index 0000000000000..68f99e5057fb7 --- /dev/null +++ b/app/code/Mage/Sales/view/frontend/order/shipment/items/renderer/default.phtml @@ -0,0 +1,65 @@ + +getItem() ?> +getItem()->getOrderItem()->getOrder() ?> + +

    escapeHtml($_item->getName()) ?>

    + getItemOptions()): ?> +
    + +
    escapeHtml($_option['label']) ?>
    + getPrintStatus()): ?> + getFormatedOptionValue($_option) ?> + class="truncated" data-mage-init="{truncateOptions:[]}"> + + +
    +
    +
    escapeHtml($_option['label']) ?>
    +
    +
    +
    + + + +
    escapeHtml( (isset($_option['print_value']) ? $_option['print_value'] : $_option['value']) ) ?>
    + + +
    + + getProductAdditionalInformationBlock(); ?> + + setItem($_item->getOrderItem())->toHtml(); ?> + + escapeHtml($_item->getDescription()) ?> + helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $_item->getOrderItem()) && $_item->getGiftMessageId()): ?> + __('Gift Message') ?> + + + escapeHtml(Mage::helper('Mage_Core_Helper_String')->splitInjection($this->getSku())) ?> + getQty()*1 ?> + diff --git a/app/code/core/Mage/Sales/view/frontend/order/totals.phtml b/app/code/Mage/Sales/view/frontend/order/totals.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/order/totals.phtml rename to app/code/Mage/Sales/view/frontend/order/totals.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/order/trackinginfo.phtml b/app/code/Mage/Sales/view/frontend/order/trackinginfo.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/order/trackinginfo.phtml rename to app/code/Mage/Sales/view/frontend/order/trackinginfo.phtml diff --git a/app/code/Mage/Sales/view/frontend/order/view.phtml b/app/code/Mage/Sales/view/frontend/order/view.phtml new file mode 100644 index 0000000000000..a19c165f6a3e8 --- /dev/null +++ b/app/code/Mage/Sales/view/frontend/order/view.phtml @@ -0,0 +1,63 @@ + +
    + getOrder() ?> +

    __('Items Ordered') ?> + getTracksCollection()->count()) : ?> + | __('Track your order') ?> + +

    + + getChildHtml('order_items') ?> + + helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order', $_order) && $_order->getGiftMessageId()): ?> +
    +

    __('Gift Message for This Order') ?>

    + helper('Mage_GiftMessage_Helper_Message')->getGiftMessageForEntity($_order); ?> +
    +
    __('From:') ?> escapeHtml($_giftMessage->getSender()) ?>
    +
    __('To:') ?> escapeHtml($_giftMessage->getRecipient()) ?>
    +
    helper('Mage_GiftMessage_Helper_Message')->getEscapedGiftMessage($_order) ?>
    +
    +
    + + getOrder()->getVisibleStatusHistory() ?> + +
    +

    __('About Your Order') ?>

    +
    + +
    formatDate($_historyItem->getCreatedAtStoreDate(), 'medium', true) ?>
    +
    escapeHtml($_historyItem->getComment()) ?>
    + +
    +
    + + +
    diff --git a/app/code/core/Mage/Sales/view/frontend/orders-returns.js b/app/code/Mage/Sales/view/frontend/orders-returns.js similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/orders-returns.js rename to app/code/Mage/Sales/view/frontend/orders-returns.js diff --git a/app/code/core/Mage/Sales/view/frontend/payment/form/billing/agreement.phtml b/app/code/Mage/Sales/view/frontend/payment/form/billing/agreement.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/payment/form/billing/agreement.phtml rename to app/code/Mage/Sales/view/frontend/payment/form/billing/agreement.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/recurring/grid.phtml b/app/code/Mage/Sales/view/frontend/recurring/grid.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/recurring/grid.phtml rename to app/code/Mage/Sales/view/frontend/recurring/grid.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/recurring/profile/view.phtml b/app/code/Mage/Sales/view/frontend/recurring/profile/view.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/recurring/profile/view.phtml rename to app/code/Mage/Sales/view/frontend/recurring/profile/view.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/recurring/profile/view/info.phtml b/app/code/Mage/Sales/view/frontend/recurring/profile/view/info.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/recurring/profile/view/info.phtml rename to app/code/Mage/Sales/view/frontend/recurring/profile/view/info.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/recurring/profiles.phtml b/app/code/Mage/Sales/view/frontend/recurring/profiles.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/recurring/profiles.phtml rename to app/code/Mage/Sales/view/frontend/recurring/profiles.phtml diff --git a/app/code/core/Mage/Sales/view/frontend/recurring_profile.xml b/app/code/Mage/Sales/view/frontend/recurring_profile.xml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/recurring_profile.xml rename to app/code/Mage/Sales/view/frontend/recurring_profile.xml diff --git a/app/code/Mage/Sales/view/frontend/reorder/sidebar.phtml b/app/code/Mage/Sales/view/frontend/reorder/sidebar.phtml new file mode 100644 index 0000000000000..24978b2736ba0 --- /dev/null +++ b/app/code/Mage/Sales/view/frontend/reorder/sidebar.phtml @@ -0,0 +1,83 @@ + + +getItems()?> + +
    +
    + __('My Orders') ?> +
    +
    +
    +

    __('Last Ordered Items') ?>

    +
      + + +
    1. + isItemAvailableForReorder($_item)): ?> + + + +

      escapeHtml($_item->getName()) ?>

      +
    2. + +
    + +
    +
    + + + + __('View All'); ?> +
    +
    +
    +
    +getPagerHtml(); ?> + + diff --git a/app/code/core/Mage/Sales/view/frontend/widget/guest/form.phtml b/app/code/Mage/Sales/view/frontend/widget/guest/form.phtml similarity index 100% rename from app/code/core/Mage/Sales/view/frontend/widget/guest/form.phtml rename to app/code/Mage/Sales/view/frontend/widget/guest/form.phtml diff --git a/app/code/core/Mage/SalesRule/Exception.php b/app/code/Mage/SalesRule/Exception.php similarity index 100% rename from app/code/core/Mage/SalesRule/Exception.php rename to app/code/Mage/SalesRule/Exception.php diff --git a/app/code/core/Mage/SalesRule/Helper/Coupon.php b/app/code/Mage/SalesRule/Helper/Coupon.php similarity index 100% rename from app/code/core/Mage/SalesRule/Helper/Coupon.php rename to app/code/Mage/SalesRule/Helper/Coupon.php diff --git a/app/code/core/Mage/SalesRule/Helper/Data.php b/app/code/Mage/SalesRule/Helper/Data.php similarity index 100% rename from app/code/core/Mage/SalesRule/Helper/Data.php rename to app/code/Mage/SalesRule/Helper/Data.php diff --git a/app/code/core/Mage/SalesRule/Model/Coupon.php b/app/code/Mage/SalesRule/Model/Coupon.php similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Coupon.php rename to app/code/Mage/SalesRule/Model/Coupon.php diff --git a/app/code/core/Mage/SalesRule/Model/Coupon/Codegenerator.php b/app/code/Mage/SalesRule/Model/Coupon/Codegenerator.php similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Coupon/Codegenerator.php rename to app/code/Mage/SalesRule/Model/Coupon/Codegenerator.php diff --git a/app/code/core/Mage/SalesRule/Model/Coupon/CodegeneratorInterface.php b/app/code/Mage/SalesRule/Model/Coupon/CodegeneratorInterface.php similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Coupon/CodegeneratorInterface.php rename to app/code/Mage/SalesRule/Model/Coupon/CodegeneratorInterface.php diff --git a/app/code/core/Mage/SalesRule/Model/Coupon/Massgenerator.php b/app/code/Mage/SalesRule/Model/Coupon/Massgenerator.php similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Coupon/Massgenerator.php rename to app/code/Mage/SalesRule/Model/Coupon/Massgenerator.php diff --git a/app/code/core/Mage/SalesRule/Model/Observer.php b/app/code/Mage/SalesRule/Model/Observer.php similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Observer.php rename to app/code/Mage/SalesRule/Model/Observer.php diff --git a/app/code/core/Mage/SalesRule/Model/Quote/Discount.php b/app/code/Mage/SalesRule/Model/Quote/Discount.php similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Quote/Discount.php rename to app/code/Mage/SalesRule/Model/Quote/Discount.php diff --git a/app/code/core/Mage/SalesRule/Model/Quote/Freeshipping.php b/app/code/Mage/SalesRule/Model/Quote/Freeshipping.php similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Quote/Freeshipping.php rename to app/code/Mage/SalesRule/Model/Quote/Freeshipping.php diff --git a/app/code/core/Mage/SalesRule/Model/Quote/Nominal/Discount.php b/app/code/Mage/SalesRule/Model/Quote/Nominal/Discount.php similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Quote/Nominal/Discount.php rename to app/code/Mage/SalesRule/Model/Quote/Nominal/Discount.php diff --git a/app/code/core/Mage/SalesRule/Model/Resource/Coupon.php b/app/code/Mage/SalesRule/Model/Resource/Coupon.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Resource/Coupon.php rename to app/code/Mage/SalesRule/Model/Resource/Coupon.php diff --git a/app/code/core/Mage/SalesRule/Model/Resource/Coupon/Collection.php b/app/code/Mage/SalesRule/Model/Resource/Coupon/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Resource/Coupon/Collection.php rename to app/code/Mage/SalesRule/Model/Resource/Coupon/Collection.php diff --git a/app/code/core/Mage/SalesRule/Model/Resource/Coupon/Usage.php b/app/code/Mage/SalesRule/Model/Resource/Coupon/Usage.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Resource/Coupon/Usage.php rename to app/code/Mage/SalesRule/Model/Resource/Coupon/Usage.php diff --git a/app/code/core/Mage/SalesRule/Model/Resource/Report/Collection.php b/app/code/Mage/SalesRule/Model/Resource/Report/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Resource/Report/Collection.php rename to app/code/Mage/SalesRule/Model/Resource/Report/Collection.php diff --git a/app/code/core/Mage/SalesRule/Model/Resource/Report/Rule.php b/app/code/Mage/SalesRule/Model/Resource/Report/Rule.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Resource/Report/Rule.php rename to app/code/Mage/SalesRule/Model/Resource/Report/Rule.php diff --git a/app/code/core/Mage/SalesRule/Model/Resource/Report/Rule/Createdat.php b/app/code/Mage/SalesRule/Model/Resource/Report/Rule/Createdat.php similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Resource/Report/Rule/Createdat.php rename to app/code/Mage/SalesRule/Model/Resource/Report/Rule/Createdat.php diff --git a/app/code/core/Mage/SalesRule/Model/Resource/Report/Rule/Updatedat.php b/app/code/Mage/SalesRule/Model/Resource/Report/Rule/Updatedat.php similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Resource/Report/Rule/Updatedat.php rename to app/code/Mage/SalesRule/Model/Resource/Report/Rule/Updatedat.php diff --git a/app/code/core/Mage/SalesRule/Model/Resource/Report/Updatedat/Collection.php b/app/code/Mage/SalesRule/Model/Resource/Report/Updatedat/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Resource/Report/Updatedat/Collection.php rename to app/code/Mage/SalesRule/Model/Resource/Report/Updatedat/Collection.php diff --git a/app/code/core/Mage/SalesRule/Model/Resource/Rule.php b/app/code/Mage/SalesRule/Model/Resource/Rule.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Resource/Rule.php rename to app/code/Mage/SalesRule/Model/Resource/Rule.php diff --git a/app/code/core/Mage/SalesRule/Model/Resource/Rule/Collection.php b/app/code/Mage/SalesRule/Model/Resource/Rule/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Resource/Rule/Collection.php rename to app/code/Mage/SalesRule/Model/Resource/Rule/Collection.php diff --git a/app/code/core/Mage/SalesRule/Model/Resource/Rule/Customer.php b/app/code/Mage/SalesRule/Model/Resource/Rule/Customer.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Resource/Rule/Customer.php rename to app/code/Mage/SalesRule/Model/Resource/Rule/Customer.php diff --git a/app/code/core/Mage/SalesRule/Model/Resource/Rule/Customer/Collection.php b/app/code/Mage/SalesRule/Model/Resource/Rule/Customer/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Resource/Rule/Customer/Collection.php rename to app/code/Mage/SalesRule/Model/Resource/Rule/Customer/Collection.php diff --git a/app/code/Mage/SalesRule/Model/Rule.php b/app/code/Mage/SalesRule/Model/Rule.php new file mode 100644 index 0000000000000..f39d11e1bb435 --- /dev/null +++ b/app/code/Mage/SalesRule/Model/Rule.php @@ -0,0 +1,565 @@ + + */ +class Mage_SalesRule_Model_Rule extends Mage_Rule_Model_Abstract +{ + /** + * Free Shipping option "For matching items only" + */ + const FREE_SHIPPING_ITEM = 1; + + /** + * Free Shipping option "For shipment with matching items" + */ + const FREE_SHIPPING_ADDRESS = 2; + + /** + * Coupon types + */ + const COUPON_TYPE_NO_COUPON = 1; + const COUPON_TYPE_SPECIFIC = 2; + const COUPON_TYPE_AUTO = 3; + + /** + * Rule type actions + */ + const TO_PERCENT_ACTION = 'to_percent'; + const BY_PERCENT_ACTION = 'by_percent'; + const TO_FIXED_ACTION = 'to_fixed'; + const BY_FIXED_ACTION = 'by_fixed'; + const CART_FIXED_ACTION = 'cart_fixed'; + const BUY_X_GET_Y_ACTION = 'buy_x_get_y'; + + /** + * Store coupon code generator instance + * + * @var Mage_SalesRule_Model_Coupon_CodegeneratorInterface + */ + protected static $_couponCodeGenerator; + + /** + * Prefix of model events names + * + * @var string + */ + protected $_eventPrefix = 'salesrule_rule'; + + /** + * Parameter name in event + * + * In observe method you can use $observer->getEvent()->getRule() in this case + * + * @var string + */ + protected $_eventObject = 'rule'; + + /** + * Contain sores labels + * + * @deprecated after 1.6.2.0 + * + * @var array + */ + protected $_labels = array(); + + /** + * Rule's primary coupon + * + * @var Mage_SalesRule_Model_Coupon + */ + protected $_primaryCoupon; + + /** + * Rule's subordinate coupons + * + * @var array of Mage_SalesRule_Model_Coupon + */ + protected $_coupons; + + /** + * Coupon types cache for lazy getter + * + * @var array + */ + protected $_couponTypes; + + /** + * Store already validated addresses and validation results + * + * @var array + */ + protected $_validatedAddresses = array(); + + /** + * Set resource model and Id field name + */ + protected function _construct() + { + parent::_construct(); + $this->_init('Mage_SalesRule_Model_Resource_Rule'); + $this->setIdFieldName('rule_id'); + } + + /** + * Returns code mass generator instance for auto generated specific coupons + * + * @return Mage_SalesRule_Model_Coupon_MassgneratorInterface + */ + public static function getCouponMassGenerator() + { + return Mage::getSingleton('Mage_SalesRule_Model_Coupon_Massgenerator'); + } + + /** + * Set coupon code and uses per coupon + * + * @return Mage_SalesRule_Model_Rule + */ + protected function _afterLoad() + { + $this->setCouponCode($this->getPrimaryCoupon()->getCode()); + if ($this->getUsesPerCoupon() !== null && !$this->getUseAutoGeneration()) { + $this->setUsesPerCoupon($this->getPrimaryCoupon()->getUsageLimit()); + } + return parent::_afterLoad(); + } + + /** + * Save/delete coupon + * + * @return Mage_SalesRule_Model_Rule + */ + protected function _afterSave() + { + $couponCode = trim($this->getCouponCode()); + if (strlen($couponCode) + && $this->getCouponType() == self::COUPON_TYPE_SPECIFIC + && !$this->getUseAutoGeneration() + ) { + $this->getPrimaryCoupon() + ->setCode($couponCode) + ->setUsageLimit($this->getUsesPerCoupon() ? $this->getUsesPerCoupon() : null) + ->setUsagePerCustomer($this->getUsesPerCustomer() ? $this->getUsesPerCustomer() : null) + ->setExpirationDate($this->getToDate()) + ->save(); + } else { + $this->getPrimaryCoupon()->delete(); + } + + parent::_afterSave(); + return $this; + } + + /** + * Initialize rule model data from array. + * Set store labels if applicable. + * + * @param array $data + * + * @return Mage_SalesRule_Model_Rule + */ + public function loadPost(array $data) + { + parent::loadPost($data); + + if (isset($data['store_labels'])) { + $this->setStoreLabels($data['store_labels']); + } + + return $this; + } + + /** + * Get rule condition combine model instance + * + * @return Mage_SalesRule_Model_Rule_Condition_Combine + */ + public function getConditionsInstance() + { + return Mage::getModel('Mage_SalesRule_Model_Rule_Condition_Combine'); + } + + /** + * Get rule condition product combine model instance + * + * @return Mage_SalesRule_Model_Rule_Condition_Product_Combine + */ + public function getActionsInstance() + { + return Mage::getModel('Mage_SalesRule_Model_Rule_Condition_Product_Combine'); + } + + /** + * Returns code generator instance for auto generated coupons + * + * @return Mage_SalesRule_Model_Coupon_CodegeneratorInterface + */ + public static function getCouponCodeGenerator() + { + if (!self::$_couponCodeGenerator) { + return Mage::getModel('Mage_SalesRule_Model_Coupon_Codegenerator', + array('data' => array('length' => 16))); + } + return self::$_couponCodeGenerator; + } + + /** + * Set code generator instance for auto generated coupons + * + * @param Mage_SalesRule_Model_Coupon_CodegeneratorInterface + */ + public static function setCouponCodeGenerator(Mage_SalesRule_Model_Coupon_CodegeneratorInterface $codeGenerator) + { + self::$_couponCodeGenerator = $codeGenerator; + } + + /** + * Retrieve rule's primary coupon + * + * @return Mage_SalesRule_Model_Coupon + */ + public function getPrimaryCoupon() + { + if ($this->_primaryCoupon === null) { + $this->_primaryCoupon = Mage::getModel('Mage_SalesRule_Model_Coupon'); + $this->_primaryCoupon->loadPrimaryByRule($this->getId()); + $this->_primaryCoupon->setRule($this)->setIsPrimary(true); + } + return $this->_primaryCoupon; + } + + /** + * Get sales rule customer group Ids + * + * @return array + */ + public function getCustomerGroupIds() + { + if (!$this->hasCustomerGroupIds()) { + $customerGroupIds = $this->_getResource()->getCustomerGroupIds($this->getId()); + $this->setData('customer_group_ids', (array)$customerGroupIds); + } + return $this->_getData('customer_group_ids'); + } + + /** + * Get Rule label by specified store + * + * @param Mage_Core_Model_Store|int|bool|null $store + * + * @return string|bool + */ + public function getStoreLabel($store = null) + { + $storeId = Mage::app()->getStore($store)->getId(); + $labels = (array)$this->getStoreLabels(); + + if (isset($labels[$storeId])) { + return $labels[$storeId]; + } elseif (isset($labels[0]) && $labels[0]) { + return $labels[0]; + } + + return false; + } + + /** + * Set if not yet and retrieve rule store labels + * + * @return array + */ + public function getStoreLabels() + { + if (!$this->hasStoreLabels()) { + $labels = $this->_getResource()->getStoreLabels($this->getId()); + $this->setStoreLabels($labels); + } + + return $this->_getData('store_labels'); + } + + /** + * Retrieve subordinate coupons + * + * @return array of Mage_SalesRule_Model_Coupon + */ + public function getCoupons() + { + if ($this->_coupons === null) { + $collection = Mage::getResourceModel('Mage_SalesRule_Model_Resource_Coupon_Collection'); + /** @var Mage_SalesRule_Model_Resource_Coupon_Collection */ + $collection->addRuleToFilter($this); + $this->_coupons = $collection->getItems(); + } + return $this->_coupons; + } + + /** + * Retrieve coupon types + * + * @return array + */ + public function getCouponTypes() + { + if ($this->_couponTypes === null) { + $this->_couponTypes = array( + Mage_SalesRule_Model_Rule::COUPON_TYPE_NO_COUPON => Mage::helper('Mage_SalesRule_Helper_Data')->__('No Coupon'), + Mage_SalesRule_Model_Rule::COUPON_TYPE_SPECIFIC => Mage::helper('Mage_SalesRule_Helper_Data')->__('Specific Coupon'), + ); + $transport = new Varien_Object(array( + 'coupon_types' => $this->_couponTypes, + 'is_coupon_type_auto_visible' => false + )); + Mage::dispatchEvent('salesrule_rule_get_coupon_types', array('transport' => $transport)); + $this->_couponTypes = $transport->getCouponTypes(); + if ($transport->getIsCouponTypeAutoVisible()) { + $this->_couponTypes[Mage_SalesRule_Model_Rule::COUPON_TYPE_AUTO] = Mage::helper('Mage_SalesRule_Helper_Data')->__('Auto'); + } + } + return $this->_couponTypes; + } + + /** + * Acquire coupon instance + * + * @param bool $saveNewlyCreated Whether or not to save newly created coupon + * @param int $saveAttemptCount Number of attempts to save newly created coupon + * + * @return Mage_SalesRule_Model_Coupon|null + */ + public function acquireCoupon($saveNewlyCreated = true, $saveAttemptCount = 10) + { + if ($this->getCouponType() == self::COUPON_TYPE_NO_COUPON) { + return null; + } + if ($this->getCouponType() == self::COUPON_TYPE_SPECIFIC) { + return $this->getPrimaryCoupon(); + } + /** @var Mage_SalesRule_Model_Coupon $coupon */ + $coupon = Mage::getModel('Mage_SalesRule_Model_Coupon'); + $coupon->setRule($this) + ->setIsPrimary(false) + ->setUsageLimit($this->getUsesPerCoupon() ? $this->getUsesPerCoupon() : null) + ->setUsagePerCustomer($this->getUsesPerCustomer() ? $this->getUsesPerCustomer() : null) + ->setExpirationDate($this->getToDate()); + + $couponCode = self::getCouponCodeGenerator()->generateCode(); + $coupon->setCode($couponCode); + + $ok = false; + if (!$saveNewlyCreated) { + $ok = true; + } else if ($this->getId()) { + for ($attemptNum = 0; $attemptNum < $saveAttemptCount; $attemptNum++) { + try { + $coupon->save(); + } catch (Exception $e) { + if ($e instanceof Mage_Core_Exception || $coupon->getId()) { + throw $e; + } + $coupon->setCode( + $couponCode . + self::getCouponCodeGenerator()->getDelimiter() . + sprintf('%04u', rand(0, 9999)) + ); + continue; + } + $ok = true; + break; + } + } + if (!$ok) { + Mage::throwException(Mage::helper('Mage_SalesRule_Helper_Data')->__('Can\'t acquire coupon.')); + } + + return $coupon; + } + + /** + * Check cached validation result for specific address + * + * @param Mage_Sales_Model_Quote_Address $address + * @return bool + */ + public function hasIsValidForAddress($address) + { + $addressId = $this->_getAddressId($address); + return isset($this->_validatedAddresses[$addressId]) ? true : false; + } + + /** + * Set validation result for specific address to results cache + * + * @param Mage_Sales_Model_Quote_Address $address + * @param bool $validationResult + * @return Mage_SalesRule_Model_Rule + */ + public function setIsValidForAddress($address, $validationResult) + { + $addressId = $this->_getAddressId($address); + $this->_validatedAddresses[$addressId] = $validationResult; + return $this; + } + + /** + * Get cached validation result for specific address + * + * @param Mage_Sales_Model_Quote_Address $address + * @return bool + */ + public function getIsValidForAddress($address) + { + $addressId = $this->_getAddressId($address); + return isset($this->_validatedAddresses[$addressId]) ? $this->_validatedAddresses[$addressId] : false; + } + + /** + * Return id for address + * + * @param Mage_Sales_Model_Quote_Address $address + * @return string + */ + private function _getAddressId($address) { + if($address instanceof Mage_Sales_Model_Quote_Address) { + return $address->getId(); + } + return $address; + } + + + + + + /** + * Collect all product attributes used in serialized rule's action or condition + * + * @deprecated after 1.6.2.0 use Mage_SalesRule_Model_Resource_Rule::getProductAttributes() instead + * + * @param string $serializedString + * + * @return array + */ + protected function _getUsedAttributes($serializedString) + { + return $this->_getResource()->getProductAttributes($serializedString); + } + + /** + * @deprecated after 1.6.2.0 + * + * @param string $format + * + * @return string + */ + public function toString($format='') + { + return ''; + } + + /** + * Returns rule as an array for admin interface + * + * @deprecated after 1.6.2.0 + * + * @param array $arrAttributes + * + * Output example: + * array( + * 'name'=>'Example rule', + * 'conditions'=>{condition_combine::toArray} + * 'actions'=>{action_collection::toArray} + * ) + * + * @return array + */ + public function toArray(array $arrAttributes = array()) + { + return parent::toArray($arrAttributes); + } +} diff --git a/app/code/core/Mage/SalesRule/Model/Rule/Action/Collection.php b/app/code/Mage/SalesRule/Model/Rule/Action/Collection.php similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Rule/Action/Collection.php rename to app/code/Mage/SalesRule/Model/Rule/Action/Collection.php diff --git a/app/code/core/Mage/SalesRule/Model/Rule/Action/Product.php b/app/code/Mage/SalesRule/Model/Rule/Action/Product.php similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Rule/Action/Product.php rename to app/code/Mage/SalesRule/Model/Rule/Action/Product.php diff --git a/app/code/core/Mage/SalesRule/Model/Rule/Condition/Address.php b/app/code/Mage/SalesRule/Model/Rule/Condition/Address.php similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Rule/Condition/Address.php rename to app/code/Mage/SalesRule/Model/Rule/Condition/Address.php diff --git a/app/code/core/Mage/SalesRule/Model/Rule/Condition/Combine.php b/app/code/Mage/SalesRule/Model/Rule/Condition/Combine.php similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Rule/Condition/Combine.php rename to app/code/Mage/SalesRule/Model/Rule/Condition/Combine.php diff --git a/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product.php b/app/code/Mage/SalesRule/Model/Rule/Condition/Product.php similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Rule/Condition/Product.php rename to app/code/Mage/SalesRule/Model/Rule/Condition/Product.php diff --git a/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Combine.php b/app/code/Mage/SalesRule/Model/Rule/Condition/Product/Combine.php similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Combine.php rename to app/code/Mage/SalesRule/Model/Rule/Condition/Product/Combine.php diff --git a/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Found.php b/app/code/Mage/SalesRule/Model/Rule/Condition/Product/Found.php similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Found.php rename to app/code/Mage/SalesRule/Model/Rule/Condition/Product/Found.php diff --git a/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Subselect.php b/app/code/Mage/SalesRule/Model/Rule/Condition/Product/Subselect.php similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Subselect.php rename to app/code/Mage/SalesRule/Model/Rule/Condition/Product/Subselect.php diff --git a/app/code/core/Mage/SalesRule/Model/Rule/Customer.php b/app/code/Mage/SalesRule/Model/Rule/Customer.php similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Rule/Customer.php rename to app/code/Mage/SalesRule/Model/Rule/Customer.php diff --git a/app/code/core/Mage/SalesRule/Model/System/Config/Source/Coupon/Format.php b/app/code/Mage/SalesRule/Model/System/Config/Source/Coupon/Format.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/SalesRule/Model/System/Config/Source/Coupon/Format.php rename to app/code/Mage/SalesRule/Model/System/Config/Source/Coupon/Format.php diff --git a/app/code/core/Mage/SalesRule/Model/Validator.php b/app/code/Mage/SalesRule/Model/Validator.php similarity index 100% rename from app/code/core/Mage/SalesRule/Model/Validator.php rename to app/code/Mage/SalesRule/Model/Validator.php diff --git a/app/code/core/Mage/SalesRule/data/salesrule_setup/data-upgrade-1.6.0.3-1.6.0.4.php b/app/code/Mage/SalesRule/data/salesrule_setup/data-upgrade-1.6.0.3-1.6.0.4.php similarity index 100% rename from app/code/core/Mage/SalesRule/data/salesrule_setup/data-upgrade-1.6.0.3-1.6.0.4.php rename to app/code/Mage/SalesRule/data/salesrule_setup/data-upgrade-1.6.0.3-1.6.0.4.php diff --git a/app/code/Mage/SalesRule/etc/adminhtml/acl.xml b/app/code/Mage/SalesRule/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..6275baa6952e1 --- /dev/null +++ b/app/code/Mage/SalesRule/etc/adminhtml/acl.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Mage/SalesRule/etc/adminhtml/menu.xml b/app/code/Mage/SalesRule/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..5618114a56adf --- /dev/null +++ b/app/code/Mage/SalesRule/etc/adminhtml/menu.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/app/code/core/Mage/SalesRule/etc/adminhtml/system.xml b/app/code/Mage/SalesRule/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/SalesRule/etc/adminhtml/system.xml rename to app/code/Mage/SalesRule/etc/adminhtml/system.xml diff --git a/app/code/Mage/SalesRule/etc/config.xml b/app/code/Mage/SalesRule/etc/config.xml new file mode 100644 index 0000000000000..c4eb35aa284f9 --- /dev/null +++ b/app/code/Mage/SalesRule/etc/config.xml @@ -0,0 +1,168 @@ + + + + + + 1.6.0.4 + true + + + + + + + + + + + + Mage_SalesRule + Mage_Sales_Model_Resource_Setup + + + + + + + + Mage_SalesRule_Model_Observer + salesOrderAfterPlace + + + + + + + Mage_SalesRule_Model_Observer + addProductAttributes + + + + + + + Mage_SalesRule_Model_Observer + addSalesRuleNameToOrder + + + + + + + + + Mage_SalesRule_Model_Quote_Freeshipping + subtotal + tax_subtotal,shipping + + + Mage_SalesRule_Model_Quote_Discount + subtotal,shipping + grand_total + + + + + Mage_SalesRule_Model_Quote_Nominal_Discount + 550 + + + + + + + - + + ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 + ABCDEFGHIJKLMNOPQRSTUVWXYZ + 0123456789 + + + + + + + + + + Mage_SalesRule.csv + + + + + + + + + Mage_SalesRule_Model_Observer + catalogAttributeDeleteAfter + + + + + + + Mage_SalesRule_Model_Observer + catalogAttributeSaveAfter + + + + + + + + + + + Mage_SalesRule.csv + + + + + + + + + + 0 0 * * * + + + Mage_SalesRule_Model_Observer::aggregateSalesReportCouponsData + + + + + + + + 12 + 1 + + + + diff --git a/app/code/core/Mage/SalesRule/etc/fieldset.xml b/app/code/Mage/SalesRule/etc/fieldset.xml similarity index 100% rename from app/code/core/Mage/SalesRule/etc/fieldset.xml rename to app/code/Mage/SalesRule/etc/fieldset.xml diff --git a/app/code/core/Mage/SalesRule/locale/de_DE/Mage_SalesRule.csv b/app/code/Mage/SalesRule/locale/de_DE/Mage_SalesRule.csv similarity index 100% rename from app/code/core/Mage/SalesRule/locale/de_DE/Mage_SalesRule.csv rename to app/code/Mage/SalesRule/locale/de_DE/Mage_SalesRule.csv diff --git a/app/code/core/Mage/SalesRule/locale/en_US/Mage_SalesRule.csv b/app/code/Mage/SalesRule/locale/en_US/Mage_SalesRule.csv similarity index 100% rename from app/code/core/Mage/SalesRule/locale/en_US/Mage_SalesRule.csv rename to app/code/Mage/SalesRule/locale/en_US/Mage_SalesRule.csv diff --git a/app/code/core/Mage/SalesRule/locale/es_ES/Mage_SalesRule.csv b/app/code/Mage/SalesRule/locale/es_ES/Mage_SalesRule.csv similarity index 100% rename from app/code/core/Mage/SalesRule/locale/es_ES/Mage_SalesRule.csv rename to app/code/Mage/SalesRule/locale/es_ES/Mage_SalesRule.csv diff --git a/app/code/core/Mage/SalesRule/locale/fr_FR/Mage_SalesRule.csv b/app/code/Mage/SalesRule/locale/fr_FR/Mage_SalesRule.csv similarity index 100% rename from app/code/core/Mage/SalesRule/locale/fr_FR/Mage_SalesRule.csv rename to app/code/Mage/SalesRule/locale/fr_FR/Mage_SalesRule.csv diff --git a/app/code/core/Mage/SalesRule/locale/nl_NL/Mage_SalesRule.csv b/app/code/Mage/SalesRule/locale/nl_NL/Mage_SalesRule.csv similarity index 100% rename from app/code/core/Mage/SalesRule/locale/nl_NL/Mage_SalesRule.csv rename to app/code/Mage/SalesRule/locale/nl_NL/Mage_SalesRule.csv diff --git a/app/code/core/Mage/SalesRule/locale/pt_BR/Mage_SalesRule.csv b/app/code/Mage/SalesRule/locale/pt_BR/Mage_SalesRule.csv similarity index 100% rename from app/code/core/Mage/SalesRule/locale/pt_BR/Mage_SalesRule.csv rename to app/code/Mage/SalesRule/locale/pt_BR/Mage_SalesRule.csv diff --git a/app/code/core/Mage/SalesRule/locale/zh_CN/Mage_SalesRule.csv b/app/code/Mage/SalesRule/locale/zh_CN/Mage_SalesRule.csv similarity index 100% rename from app/code/core/Mage/SalesRule/locale/zh_CN/Mage_SalesRule.csv rename to app/code/Mage/SalesRule/locale/zh_CN/Mage_SalesRule.csv diff --git a/app/code/core/Mage/SalesRule/sql/salesrule_setup/install-1.6.0.0.php b/app/code/Mage/SalesRule/sql/salesrule_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/SalesRule/sql/salesrule_setup/install-1.6.0.0.php rename to app/code/Mage/SalesRule/sql/salesrule_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/SalesRule/sql/salesrule_setup/upgrade-1.6.0.0-1.6.0.1.php b/app/code/Mage/SalesRule/sql/salesrule_setup/upgrade-1.6.0.0-1.6.0.1.php similarity index 100% rename from app/code/core/Mage/SalesRule/sql/salesrule_setup/upgrade-1.6.0.0-1.6.0.1.php rename to app/code/Mage/SalesRule/sql/salesrule_setup/upgrade-1.6.0.0-1.6.0.1.php diff --git a/app/code/core/Mage/SalesRule/sql/salesrule_setup/upgrade-1.6.0.1-1.6.0.2.php b/app/code/Mage/SalesRule/sql/salesrule_setup/upgrade-1.6.0.1-1.6.0.2.php similarity index 100% rename from app/code/core/Mage/SalesRule/sql/salesrule_setup/upgrade-1.6.0.1-1.6.0.2.php rename to app/code/Mage/SalesRule/sql/salesrule_setup/upgrade-1.6.0.1-1.6.0.2.php diff --git a/app/code/core/Mage/SalesRule/sql/salesrule_setup/upgrade-1.6.0.2-1.6.0.3.php b/app/code/Mage/SalesRule/sql/salesrule_setup/upgrade-1.6.0.2-1.6.0.3.php similarity index 100% rename from app/code/core/Mage/SalesRule/sql/salesrule_setup/upgrade-1.6.0.2-1.6.0.3.php rename to app/code/Mage/SalesRule/sql/salesrule_setup/upgrade-1.6.0.2-1.6.0.3.php diff --git a/app/code/core/Mage/Sendfriend/Block/Send.php b/app/code/Mage/Sendfriend/Block/Send.php similarity index 100% rename from app/code/core/Mage/Sendfriend/Block/Send.php rename to app/code/Mage/Sendfriend/Block/Send.php diff --git a/app/code/core/Mage/Sendfriend/Helper/Data.php b/app/code/Mage/Sendfriend/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Sendfriend/Helper/Data.php rename to app/code/Mage/Sendfriend/Helper/Data.php diff --git a/app/code/core/Mage/Sendfriend/Model/Observer.php b/app/code/Mage/Sendfriend/Model/Observer.php similarity index 100% rename from app/code/core/Mage/Sendfriend/Model/Observer.php rename to app/code/Mage/Sendfriend/Model/Observer.php diff --git a/app/code/core/Mage/Sendfriend/Model/Resource/Sendfriend.php b/app/code/Mage/Sendfriend/Model/Resource/Sendfriend.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sendfriend/Model/Resource/Sendfriend.php rename to app/code/Mage/Sendfriend/Model/Resource/Sendfriend.php diff --git a/app/code/core/Mage/Sendfriend/Model/Resource/Sendfriend/Collection.php b/app/code/Mage/Sendfriend/Model/Resource/Sendfriend/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sendfriend/Model/Resource/Sendfriend/Collection.php rename to app/code/Mage/Sendfriend/Model/Resource/Sendfriend/Collection.php diff --git a/app/code/core/Mage/Sendfriend/Model/Resource/Setup.php b/app/code/Mage/Sendfriend/Model/Resource/Setup.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sendfriend/Model/Resource/Setup.php rename to app/code/Mage/Sendfriend/Model/Resource/Setup.php diff --git a/app/code/core/Mage/Sendfriend/Model/Sendfriend.php b/app/code/Mage/Sendfriend/Model/Sendfriend.php similarity index 100% rename from app/code/core/Mage/Sendfriend/Model/Sendfriend.php rename to app/code/Mage/Sendfriend/Model/Sendfriend.php diff --git a/app/code/core/Mage/Sendfriend/controllers/ProductController.php b/app/code/Mage/Sendfriend/controllers/ProductController.php similarity index 100% rename from app/code/core/Mage/Sendfriend/controllers/ProductController.php rename to app/code/Mage/Sendfriend/controllers/ProductController.php diff --git a/app/code/core/Mage/Sendfriend/etc/adminhtml/system.xml b/app/code/Mage/Sendfriend/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Sendfriend/etc/adminhtml/system.xml rename to app/code/Mage/Sendfriend/etc/adminhtml/system.xml diff --git a/app/code/Mage/Sendfriend/etc/config.xml b/app/code/Mage/Sendfriend/etc/config.xml new file mode 100644 index 0000000000000..98b3d3a5f047a --- /dev/null +++ b/app/code/Mage/Sendfriend/etc/config.xml @@ -0,0 +1,117 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + Mage_Sendfriend + Mage_Sendfriend_Model_Resource_Setup + + + + + + + + + + + Mage_Sendfriend.csv + + + + + + + + + + + Mage_Sendfriend_Model_Observer + register + + + + + + + standard + + Mage_Sendfriend + sendfriend + + + + + + + layout.xml + + + + + + + + Mage_Sendfriend.csv + + + + + + + + + 1 + + 0 + 5 + 5 + 0 + + + + \ No newline at end of file diff --git a/app/code/core/Mage/Sendfriend/locale/de_DE/Mage_Sendfriend.csv b/app/code/Mage/Sendfriend/locale/de_DE/Mage_Sendfriend.csv similarity index 100% rename from app/code/core/Mage/Sendfriend/locale/de_DE/Mage_Sendfriend.csv rename to app/code/Mage/Sendfriend/locale/de_DE/Mage_Sendfriend.csv diff --git a/app/code/core/Mage/Sendfriend/locale/en_US/Mage_Sendfriend.csv b/app/code/Mage/Sendfriend/locale/en_US/Mage_Sendfriend.csv similarity index 100% rename from app/code/core/Mage/Sendfriend/locale/en_US/Mage_Sendfriend.csv rename to app/code/Mage/Sendfriend/locale/en_US/Mage_Sendfriend.csv diff --git a/app/code/core/Mage/Sendfriend/locale/es_ES/Mage_Sendfriend.csv b/app/code/Mage/Sendfriend/locale/es_ES/Mage_Sendfriend.csv similarity index 100% rename from app/code/core/Mage/Sendfriend/locale/es_ES/Mage_Sendfriend.csv rename to app/code/Mage/Sendfriend/locale/es_ES/Mage_Sendfriend.csv diff --git a/app/code/core/Mage/Sendfriend/locale/fr_FR/Mage_Sendfriend.csv b/app/code/Mage/Sendfriend/locale/fr_FR/Mage_Sendfriend.csv similarity index 100% rename from app/code/core/Mage/Sendfriend/locale/fr_FR/Mage_Sendfriend.csv rename to app/code/Mage/Sendfriend/locale/fr_FR/Mage_Sendfriend.csv diff --git a/app/code/core/Mage/Sendfriend/locale/nl_NL/Mage_Sendfriend.csv b/app/code/Mage/Sendfriend/locale/nl_NL/Mage_Sendfriend.csv similarity index 100% rename from app/code/core/Mage/Sendfriend/locale/nl_NL/Mage_Sendfriend.csv rename to app/code/Mage/Sendfriend/locale/nl_NL/Mage_Sendfriend.csv diff --git a/app/code/core/Mage/Sendfriend/locale/pt_BR/Mage_Sendfriend.csv b/app/code/Mage/Sendfriend/locale/pt_BR/Mage_Sendfriend.csv similarity index 100% rename from app/code/core/Mage/Sendfriend/locale/pt_BR/Mage_Sendfriend.csv rename to app/code/Mage/Sendfriend/locale/pt_BR/Mage_Sendfriend.csv diff --git a/app/code/core/Mage/Sendfriend/locale/zh_CN/Mage_Sendfriend.csv b/app/code/Mage/Sendfriend/locale/zh_CN/Mage_Sendfriend.csv similarity index 100% rename from app/code/core/Mage/Sendfriend/locale/zh_CN/Mage_Sendfriend.csv rename to app/code/Mage/Sendfriend/locale/zh_CN/Mage_Sendfriend.csv diff --git a/app/code/core/Mage/Sendfriend/sql/sendfriend_setup/install-1.6.0.0.php b/app/code/Mage/Sendfriend/sql/sendfriend_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Sendfriend/sql/sendfriend_setup/install-1.6.0.0.php rename to app/code/Mage/Sendfriend/sql/sendfriend_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Sendfriend/view/email/product_share.html b/app/code/Mage/Sendfriend/view/email/product_share.html similarity index 100% rename from app/code/core/Mage/Sendfriend/view/email/product_share.html rename to app/code/Mage/Sendfriend/view/email/product_share.html diff --git a/app/code/Mage/Sendfriend/view/frontend/layout.xml b/app/code/Mage/Sendfriend/view/frontend/layout.xml new file mode 100644 index 0000000000000..96020c57f7298 --- /dev/null +++ b/app/code/Mage/Sendfriend/view/frontend/layout.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + diff --git a/app/code/core/Mage/Sendfriend/view/frontend/send.phtml b/app/code/Mage/Sendfriend/view/frontend/send.phtml similarity index 100% rename from app/code/core/Mage/Sendfriend/view/frontend/send.phtml rename to app/code/Mage/Sendfriend/view/frontend/send.phtml diff --git a/app/code/core/Mage/Shipping/Block/Tracking/Ajax.php b/app/code/Mage/Shipping/Block/Tracking/Ajax.php similarity index 100% rename from app/code/core/Mage/Shipping/Block/Tracking/Ajax.php rename to app/code/Mage/Shipping/Block/Tracking/Ajax.php diff --git a/app/code/core/Mage/Shipping/Block/Tracking/Popup.php b/app/code/Mage/Shipping/Block/Tracking/Popup.php similarity index 100% rename from app/code/core/Mage/Shipping/Block/Tracking/Popup.php rename to app/code/Mage/Shipping/Block/Tracking/Popup.php diff --git a/app/code/core/Mage/Shipping/Exception.php b/app/code/Mage/Shipping/Exception.php similarity index 100% rename from app/code/core/Mage/Shipping/Exception.php rename to app/code/Mage/Shipping/Exception.php diff --git a/app/code/core/Mage/Shipping/Helper/Data.php b/app/code/Mage/Shipping/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Shipping/Helper/Data.php rename to app/code/Mage/Shipping/Helper/Data.php diff --git a/app/code/core/Mage/Shipping/Model/Carrier/Abstract.php b/app/code/Mage/Shipping/Model/Carrier/Abstract.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Carrier/Abstract.php rename to app/code/Mage/Shipping/Model/Carrier/Abstract.php diff --git a/app/code/core/Mage/Shipping/Model/Carrier/Flatrate.php b/app/code/Mage/Shipping/Model/Carrier/Flatrate.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Carrier/Flatrate.php rename to app/code/Mage/Shipping/Model/Carrier/Flatrate.php diff --git a/app/code/core/Mage/Shipping/Model/Carrier/Freeshipping.php b/app/code/Mage/Shipping/Model/Carrier/Freeshipping.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Carrier/Freeshipping.php rename to app/code/Mage/Shipping/Model/Carrier/Freeshipping.php diff --git a/app/code/core/Mage/Shipping/Model/Carrier/Interface.php b/app/code/Mage/Shipping/Model/Carrier/Interface.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Carrier/Interface.php rename to app/code/Mage/Shipping/Model/Carrier/Interface.php diff --git a/app/code/Mage/Shipping/Model/Carrier/Metadata.php b/app/code/Mage/Shipping/Model/Carrier/Metadata.php new file mode 100644 index 0000000000000..539a15193ff77 --- /dev/null +++ b/app/code/Mage/Shipping/Model/Carrier/Metadata.php @@ -0,0 +1,63 @@ +_carrierCode = $carrierCode; + $this->_carrierConfig = $carrierConfig; + } + + public function getSubscriberExtensionId() + { + return $this->getCarrierConfig('subscriber'); + } + + public function getCarrierConfig($key = null) + { + if ($key == null) { + return $this->_carrierConfig; + } else { + return $this->_carrierConfig[$key]; + } + } + + public function getCarrierCode() + { + return $this->_carrierCode; + } + +} \ No newline at end of file diff --git a/app/code/core/Mage/Shipping/Model/Carrier/Pickup.php b/app/code/Mage/Shipping/Model/Carrier/Pickup.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Carrier/Pickup.php rename to app/code/Mage/Shipping/Model/Carrier/Pickup.php diff --git a/app/code/Mage/Shipping/Model/Carrier/Service/Callback.php b/app/code/Mage/Shipping/Model/Carrier/Service/Callback.php new file mode 100644 index 0000000000000..95e7b887e47eb --- /dev/null +++ b/app/code/Mage/Shipping/Model/Carrier/Service/Callback.php @@ -0,0 +1,55 @@ +_dispatchHelper = $dispatchHelper; + } + + /** + * @Type callback + * @Consumes(schema="http://www.magento.com/schemas/shippingrate-input.xsd", bundle="consumer-ux") + * @Produces(schema="http://www.magento.com/schemas/shippingrate-output.xsd", bundle="consumer-ux") + */ + public function getRates(array $shippingRateInput) + { + $subscriberExtensionId = $shippingRateInput['carrierConfiguration']['subscriber']; + $callbackOutput = $this->_dispatchHelper->dispatchCallback( + $subscriberExtensionId, + self::EVENT_SHIPPING_GET_RATES, + $shippingRateInput + ); + return $callbackOutput; + } +} \ No newline at end of file diff --git a/app/code/Mage/Shipping/Model/Carrier/Service/Config.php b/app/code/Mage/Shipping/Model/Carrier/Service/Config.php new file mode 100644 index 0000000000000..dacccbc0e864a --- /dev/null +++ b/app/code/Mage/Shipping/Model/Carrier/Service/Config.php @@ -0,0 +1,78 @@ +_config = $config; + } + + /** + * Retrieve information from carrier configuration + * + * @param string $field + * @return mixed + */ + public function getConfigData($field) + { + if (empty($this->_config)) { + return null; + } + $tokens = explode('/', $field); + return $this->_getConfigData($tokens, $this->_config); + } + + private function _getConfigData(array $tokens, $config) + { + if (empty($tokens)) { + return $config; + } + $index = array_shift($tokens); + if (!array_key_exists($index, $config)) { + return null; + } + $configValue = $config[$index]; + return $this->_getConfigData($tokens, $configValue); + } + + /** + * Retrieve config flag for store by field + * + * @param string $field + * @return bool + */ + public function getConfigFlag($field) + { + $flag = strtolower($this->getConfigData($field)); + if (!empty($flag) && 'false' !== $flag) { + return true; + } else { + return false; + } + } +} \ No newline at end of file diff --git a/app/code/Mage/Shipping/Model/Carrier/Service/Interface.php b/app/code/Mage/Shipping/Model/Carrier/Service/Interface.php new file mode 100644 index 0000000000000..4e6a0a2fea813 --- /dev/null +++ b/app/code/Mage/Shipping/Model/Carrier/Service/Interface.php @@ -0,0 +1,34 @@ +setCarrier($this->getCarrier()); + $method->setCarrierTitle($this->getCarrierTitle()); + + $method->setMethod($this->getMethod()); + $method->setMethodTitle($this->getMethodTitle()); + + $method->setPrice($this->getPrice()); + $method->setCost($this->getCost()); + + return $method; + } + + protected function getCarrierTitle() + { + return $this->_getData('carrierTitle'); + } + + protected function getMethodTitle() + { + return $this->_getData('methodTitle'); + } +} \ No newline at end of file diff --git a/app/code/Mage/Shipping/Model/Carrier/Service/Result.php b/app/code/Mage/Shipping/Model/Carrier/Service/Result.php new file mode 100644 index 0000000000000..5a48fdbd2115d --- /dev/null +++ b/app/code/Mage/Shipping/Model/Carrier/Service/Result.php @@ -0,0 +1,108 @@ +_rateResult = new Mage_Shipping_Model_Rate_Result(); + } + + /** + * Takes an array of service results from a web service and wraps their contents in a + * Mage_Shipping_Model_Rate_Result object. + * @param $serviceResults array + * @return Mage_Shipping_Model_Rate_Result + */ + public function createRateResult($serviceResults) + { + /** @var $result Mage_Shipping_Model_Rate_Result */ + $result = $this->_getRateResult(); + + $methods = $this->_extractServiceMethods($serviceResults); + + /** @var $serviceMethod Mage_Shipping_Model_Carrier_Service_Method */ + foreach ($methods as $serviceMethod) { + try { + $rateResult = $serviceMethod->createRateResultMethod(); + $result->append($rateResult); + } catch (Exception $ex) { + Mage::logException($ex); + } + } + + return $result; + } + + /** + * @param $ex Exception + * @return Mage_Shipping_Model_Rate_Result + */ + public function createErrorRateResult($ex) + { + /** @var $rateResult Mage_Shipping_Model_Rate_Result */ + $rateResult = $this->_getRateResult(); + $rateResult->setError(true); + return $rateResult; + } + + protected function _getRateResult() + { + return $this->_rateResult; + } + + protected function _extractServiceMethods($serviceResults) + { + $result = array(); + + if (!is_array($serviceResults) || empty($serviceResults)) { + return $result; + } + $shippingMethods = $serviceResults['shippingMethods']; + if (!is_array($shippingMethods)) { + return $result; + } + + foreach ($shippingMethods as $method) { + if (!is_array($method)) { + return $result; + } + $result[] = $this->_getCarrierServiceMethod($method); + } + + return $result; + } + + protected function _getCarrierServiceMethod($method) + { + return Mage::getModel('Mage_Shipping_Model_Carrier_Service_Method', array('data' => $method)); + } +} diff --git a/app/code/Mage/Shipping/Model/Carrier/ServiceAdapter.php b/app/code/Mage/Shipping/Model/Carrier/ServiceAdapter.php new file mode 100644 index 0000000000000..a37380e2edd44 --- /dev/null +++ b/app/code/Mage/Shipping/Model/Carrier/ServiceAdapter.php @@ -0,0 +1,362 @@ +_logger = $logger; + $this->_serviceClassName = $serviceClassName; + $this->_serviceFactory = $objectManager; + $this->_serviceResult = new Mage_Shipping_Model_Carrier_Service_Result(); + } + + /** + * Collect and get rates + * + * @param Mage_Shipping_Model_Rate_Request $request + * @return Mage_Shipping_Model_Rate_Result|bool|null + */ + public function collectRates(Mage_Shipping_Model_Rate_Request $request) + { + if (!$this->isActive()) { + return false; + } + + try { + $serviceInput = $this->_constructInput($request); + $serviceOutput = $this->_getService()->getRates($serviceInput); + return $this->_createRateResult($serviceOutput); + } catch (Exception $ex) { + $this->_logger->logException($ex); + return $this->_createErrorRateResult($ex); + } + } + + /** + * Construct array of data to be sent to web service based on input rate request. + * @param Mage_Shipping_Model_Rate_Request $request + * @return array + */ + protected function _constructInput($request) + { + $inputFields = array(); + $inputFields['carrierConfiguration'] = $this->_getCarrierMetadata()->getCarrierConfig(); + $inputFields['rateRequest'] = $this->_convertObjectToArray($request); + // packageValue + if (isset($inputFields['rateRequest']['packageValue'])) { + $pkgPhysicalVal = $inputFields['rateRequest']['packageValue']; + unset($inputFields['rateRequest']['packageValue']); + $inputFields['rateRequest']['packageValue']['amount'] = $pkgPhysicalVal; + $inputFields['rateRequest']['packageValue']['currencyCode'] = $inputFields['rateRequest']['packageCurrency']['currencyCode']; + } + + // packageValueWithDiscount + if (isset($inputFields['rateRequest']['packageValueWithDiscount'])) { + $pkgPhysicalVal = $inputFields['rateRequest']['packageValueWithDiscount']; + unset($inputFields['rateRequest']['packageValueWithDiscount']); + $inputFields['rateRequest']['packageValueWithDiscount']['amount'] = $pkgPhysicalVal; + $inputFields['rateRequest']['packageValueWithDiscount']['currencyCode'] = $inputFields['rateRequest']['packageCurrency']['currencyCode']; + } + + // packagePhysicalValue + if (isset($inputFields['rateRequest']['packagePhysicalValue'])) { + $pkgPhysicalVal = $inputFields['rateRequest']['packagePhysicalValue']; + unset($inputFields['rateRequest']['packagePhysicalValue']); + $inputFields['rateRequest']['packagePhysicalValue']['amount'] = $pkgPhysicalVal; + $inputFields['rateRequest']['packagePhysicalValue']['currencyCode'] = $inputFields['rateRequest']['packageCurrency']['currencyCode']; + } + + //baseSubtotalWithTax + if (isset($inputFields['rateRequest']['baseSubtotalInclTax'])) { + $inputFields['rateRequest']['baseSubtotalWithTax']['amount'] = $inputFields['rateRequest']['baseSubtotalInclTax']; + $inputFields['rateRequest']['baseSubtotalWithTax']['currencyCode'] = $inputFields['rateRequest']['packageCurrency']; + unset($inputFields['rateRequest']['baseSubtotalInclTax']); + } + + // destination + if (isset($inputFields['rateRequest']['destCountryId'])) { + $destCountry = $request->getDestCountryId(); + unset($inputFields['rateRequest']['destCountryId']); + } else { + $destCountry = self::USA_COUNTRY_ID; + } + $inputFields['rateRequest']['destination']['countryId'] = Mage::getModel('Mage_Directory_Model_Country')->load($destCountry)->getIso2Code(); + + if (isset($inputFields['rateRequest']['destRegionCode'])) { + $inputFields['rateRequest']['destination']['region'] = $inputFields['rateRequest']['destRegionCode']; + unset($inputFields['rateRequest']['destRegionCode']); + } + + if (isset($inputFields['rateRequest']['destPostcode'])) { + $inputFields['rateRequest']['destination']['postcode'] = $inputFields['rateRequest']['destPostcode']; + unset($inputFields['rateRequest']['destPostcode']); + } + + if (isset($inputFields['rateRequest']['destStreet'])) { + $inputFields['rateRequest']['destination']['street'] = $inputFields['rateRequest']['destStreet']; + unset($inputFields['rateRequest']['destStreet']); + } + + if (isset($inputFields['rateRequest']['destCity'])) { + $inputFields['rateRequest']['destination']['city'] = $inputFields['rateRequest']['destCity']; + unset($inputFields['rateRequest']['destCity']); + } + + // Origin + if (isset($inputFields['rateRequest']['countryId'])) { + $origCountry = $inputFields['rateRequest']['countryId']; + unset($inputFields['rateRequest']['countryId']); + } else { + $origCountry = Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, + $inputFields['rateRequest']['storeId'] + ); + } + $inputFields['rateRequest']['origin']['countryId'] = Mage::getModel('Mage_Directory_Model_Country')->load($origCountry)->getIso2Code(); + + if (isset($inputFields['rateRequest']['regionId'])) { + $regionCode = $inputFields['rateRequest']['regionId']; + unset($inputFields['rateRequest']['regionId']); + } else { + $regionCode = Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_REGION_ID, + $inputFields['rateRequest']['storeId'] + ); + } + if (is_numeric($regionCode)) { + $inputFields['rateRequest']['origin']['region'] = Mage::getModel('Mage_Directory_Model_Region')->load($regionCode)->getCode(); + } else { + $inputFields['rateRequest']['origin']['region'] = $regionCode; + } + + if (isset($inputFields['rateRequest']['postcode'])) { + $inputFields['rateRequest']['origin']['postcode'] = $inputFields['rateRequest']['postcode']; + unset($inputFields['rateRequest']['postcode']); + } else { + $inputFields['rateRequest']['origin']['postcode'] = Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_ZIP, + $inputFields['rateRequest']['storeId'] + ); + } + + if (isset($inputFields['rateRequest']['city'])) { + $inputFields['rateRequest']['origin']['city'] = $inputFields['rateRequest']['city']; + unset($inputFields['rateRequest']['city']); + } else { + $inputFields['rateRequest']['origin']['city'] = Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_CITY, + $inputFields['rateRequest']['storeId'] + ); + } + + if (isset($inputFields['rateRequest']['street'])) { + $inputFields['rateRequest']['origin']['street'] = $inputFields['rateRequest']['street']; + unset($inputFields['rateRequest']['street']); + } else { + $address1 = Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_ADDRESS1, + $inputFields['rateRequest']['storeId'] + ); + $address2 = Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_ADDRESS2, + $inputFields['rateRequest']['storeId'] + ); + $inputFields['rateRequest']['origin']['street'] = $address1 . ' ' . $address2; + } + + //items + //@TODO need to match xsd + if (isset($inputFields['rateRequest']['allItems'])) { + $inputFields['rateRequest']['items'] = $inputFields['rateRequest']['allItems']; + unset($inputFields['rateRequest']['allItems']); + } + return $inputFields; + } + + protected function _getService() + { + return $this->_serviceFactory->create($this->_serviceClassName); + } + + protected function _getCarrierMetadata() + { + $arguments = array('carrierCode' => $this->_code, 'carrierConfig' => $this->_getCarrierConfig()); + return Mage::getModel('Mage_Shipping_Model_Carrier_Metadata', $arguments); + } + + protected function _getCarrierConfig() + { + $path = 'carriers/'.$this->_code; + $config = Mage::getStoreConfig($path, $this->getStore()); + $configCamelcaseKey = array(); + foreach ($config as $key => $value) { + $configCamelcaseKey[$this->_to_camel_case($key)] = $value; + } + return $configCamelcaseKey; + } + + /** + * @param $serviceOutput array + * @return Mage_Shipping_Model_Rate_Result + */ + protected function _createRateResult($serviceOutput) + { + return $this->_getServiceResult()->createRateResult($serviceOutput); + } + + /** + * @return Mage_Shipping_Model_Carrier_Service_Result + */ + protected function _getServiceResult() + { + return $this->_serviceResult; + } + + /** + * @param $ex Exception + * @return Mage_Shipping_Model_Rate_Result + */ + protected function _createErrorRateResult($ex) + { + return $this->_getServiceResult()->createErrorRateResult($ex); + } + + /** + * Check if carrier has shipping tracking option available + * + * @return boolean + */ + public function isTrackingAvailable() + { + return $this->getConfigFlag('tracking_available'); + } + + /** + * Get allowed shipping methods + * + * @return array + */ + public function getAllowedMethods() + { + $methods = $this->getConfigData('shipping_methods'); + $allowedMethods = array(); + foreach ($methods as $methodCode => $methodName) { + $allowedMethods[] = array($methodCode => $methodName); + } + return $allowedMethods; + } + + public function setCarrierCode($code) + { + $this->_code = $code; + } + + + /** + * Converts a Varien_Object into an array, including any children objects + * + * Code is very similar to what Webhooks considers their Default Mapper + * + * @param Varien_Object $obj + * @param array $objects + * @param bool $performRedaction If set to true will redact any fields returned from _getListOfRedactedFields. + * @return array|string + */ + protected function _convertObjectToArray($obj, &$objects = array()) + { + if (is_object($obj)) { + $hash = spl_object_hash($obj); + if (!empty($objects[$hash])) { + return self::CYCLE_DETECTED_MARK; + } + $objects[$hash] = true; + $data = $obj->getData(); + } + else if (is_array($obj)) { + $data = $obj; + } + + $result = array(); + foreach ($data as $key=>$value) { + if (is_scalar($value)) { + $result[$this->_to_camel_case($key)] = $value; + } elseif (is_array($value)) { + $result[$this->_to_camel_case($key)] = $this->_convertObjectToArray($value, $objects); + } elseif ($value instanceof Varien_Object) { + $result[$this->_to_camel_case($key)] = $this->_convertObjectToArray($value, $objects); + } + } + return $result; + } + + /** + * Translates a camel case string into a string with underscores (e.g. firstName -> first_name) + * @param string $str String in camel case format + * @return string $str Translated into underscore format + */ + protected function _from_camel_case($str) { + $str[0] = strtolower($str[0]); + $func = create_function('$c', 'return "_" . strtolower($c[1]);'); + return preg_replace_callback('/([A-Z])/', $func, $str); + } + + /** + * Translates a string with underscores into camel case (e.g. first_name -> firstName) + * @param string $str String in underscore format + * @param bool $capitalise_first_char If true, capitalise the first char in $str + * @return string $str translated into camel caps + */ + protected function _to_camel_case($str, $capitalise_first_char = false) { + if($capitalise_first_char) { + $str[0] = strtoupper($str[0]); + } + $func = create_function('$c', 'return strtoupper($c[1]);'); + return preg_replace_callback('/_([a-z])/', $func, $str); + } +} \ No newline at end of file diff --git a/app/code/core/Mage/Shipping/Model/Carrier/Tablerate.php b/app/code/Mage/Shipping/Model/Carrier/Tablerate.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Carrier/Tablerate.php rename to app/code/Mage/Shipping/Model/Carrier/Tablerate.php diff --git a/app/code/Mage/Shipping/Model/Config.php b/app/code/Mage/Shipping/Model/Config.php new file mode 100644 index 0000000000000..f955f173f727d --- /dev/null +++ b/app/code/Mage/Shipping/Model/Config.php @@ -0,0 +1,137 @@ + $carrierConfig) { + if (Mage::getStoreConfigFlag('carriers/'.$code.'/active', $store)) { + $carrierModel = $this->_getCarrier($code, $carrierConfig, $store); + if ($carrierModel) { + $carriers[$code] = $carrierModel; + } + } + } + return $carriers; + } + + /** + * Retrieve all system carriers + * + * @param mixed $store + * @return array + */ + public function getAllCarriers($store = null) + { + $carriers = array(); + $config = Mage::getStoreConfig('carriers', $store); + foreach ($config as $code => $carrierConfig) { + $model = $this->_getCarrier($code, $carrierConfig, $store); + if ($model) { + $carriers[$code] = $model; + } + } + return $carriers; + } + + /** + * Retrieve carrier model instance by carrier code + * + * @param string $carrierCode + * @param mixed $store + * @return bool|Mage_Model_Shipping_Carrier_Abstract + */ + public function getCarrierInstance($carrierCode, $store = null) + { + $carrierConfig = Mage::getStoreConfig('carriers/'.$carrierCode, $store); + if (!empty($carrierConfig)) { + return $this->_getCarrier($carrierCode, $carrierConfig, $store); + } + return false; + } + + /** + * Get carrier model object + * + * @param string $code + * @param array $config + * @param mixed $store + * @return Mage_Shipping_Model_Carrier_Abstract + */ + protected function _getCarrier($code, $config, $store = null) + { + $arguments = array(); + if (!isset($config['model'])) { + if (isset($config['service'])) { + $modelName = 'Mage_Shipping_Model_Carrier_ServiceAdapter'; + $arguments['serviceClassName'] = $config['service']; + } else { + return false; + } + } else { + $modelName = $config['model']; + } + + /** + * Added protection from not existing models usage. + * Related with module uninstall process + */ + try { + $carrier = Mage::getModel($modelName, $arguments); + } catch (Exception $e) { + Mage::logException($e); + return false; + } + $carrier->setId($code); + if ($store) { + $carrier->setStore($store); + } + // Carrier code needs to be injected to allow for dynamic reusable carrier models. + $carrier->setCarrierCode($code); + self::$_carriers[$code] = $carrier; + return self::$_carriers[$code]; + } +} diff --git a/app/code/core/Mage/Shipping/Model/Config/Backend/Tablerate.php b/app/code/Mage/Shipping/Model/Config/Backend/Tablerate.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Config/Backend/Tablerate.php rename to app/code/Mage/Shipping/Model/Config/Backend/Tablerate.php diff --git a/app/code/core/Mage/Shipping/Model/Config/Source/Allmethods.php b/app/code/Mage/Shipping/Model/Config/Source/Allmethods.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Config/Source/Allmethods.php rename to app/code/Mage/Shipping/Model/Config/Source/Allmethods.php diff --git a/app/code/core/Mage/Shipping/Model/Config/Source/Allspecificcountries.php b/app/code/Mage/Shipping/Model/Config/Source/Allspecificcountries.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Config/Source/Allspecificcountries.php rename to app/code/Mage/Shipping/Model/Config/Source/Allspecificcountries.php diff --git a/app/code/core/Mage/Shipping/Model/Config/Source/Flatrate.php b/app/code/Mage/Shipping/Model/Config/Source/Flatrate.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Config/Source/Flatrate.php rename to app/code/Mage/Shipping/Model/Config/Source/Flatrate.php diff --git a/app/code/core/Mage/Shipping/Model/Config/Source/Tablerate.php b/app/code/Mage/Shipping/Model/Config/Source/Tablerate.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Config/Source/Tablerate.php rename to app/code/Mage/Shipping/Model/Config/Source/Tablerate.php diff --git a/app/code/core/Mage/Shipping/Model/Info.php b/app/code/Mage/Shipping/Model/Info.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Info.php rename to app/code/Mage/Shipping/Model/Info.php diff --git a/app/code/core/Mage/Shipping/Model/Rate/Abstract.php b/app/code/Mage/Shipping/Model/Rate/Abstract.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Rate/Abstract.php rename to app/code/Mage/Shipping/Model/Rate/Abstract.php diff --git a/app/code/core/Mage/Shipping/Model/Rate/Request.php b/app/code/Mage/Shipping/Model/Rate/Request.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Rate/Request.php rename to app/code/Mage/Shipping/Model/Rate/Request.php diff --git a/app/code/core/Mage/Shipping/Model/Rate/Result.php b/app/code/Mage/Shipping/Model/Rate/Result.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Rate/Result.php rename to app/code/Mage/Shipping/Model/Rate/Result.php diff --git a/app/code/core/Mage/Shipping/Model/Rate/Result/Abstract.php b/app/code/Mage/Shipping/Model/Rate/Result/Abstract.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Rate/Result/Abstract.php rename to app/code/Mage/Shipping/Model/Rate/Result/Abstract.php diff --git a/app/code/core/Mage/Shipping/Model/Rate/Result/Error.php b/app/code/Mage/Shipping/Model/Rate/Result/Error.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Rate/Result/Error.php rename to app/code/Mage/Shipping/Model/Rate/Result/Error.php diff --git a/app/code/core/Mage/Shipping/Model/Rate/Result/Method.php b/app/code/Mage/Shipping/Model/Rate/Result/Method.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Rate/Result/Method.php rename to app/code/Mage/Shipping/Model/Rate/Result/Method.php diff --git a/app/code/core/Mage/Shipping/Model/Resource/Carrier/Tablerate.php b/app/code/Mage/Shipping/Model/Resource/Carrier/Tablerate.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Shipping/Model/Resource/Carrier/Tablerate.php rename to app/code/Mage/Shipping/Model/Resource/Carrier/Tablerate.php diff --git a/app/code/core/Mage/Shipping/Model/Resource/Carrier/Tablerate/Collection.php b/app/code/Mage/Shipping/Model/Resource/Carrier/Tablerate/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Shipping/Model/Resource/Carrier/Tablerate/Collection.php rename to app/code/Mage/Shipping/Model/Resource/Carrier/Tablerate/Collection.php diff --git a/app/code/core/Mage/Shipping/Model/Shipment/Request.php b/app/code/Mage/Shipping/Model/Shipment/Request.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Shipment/Request.php rename to app/code/Mage/Shipping/Model/Shipment/Request.php diff --git a/app/code/core/Mage/Shipping/Model/Shipment/Return.php b/app/code/Mage/Shipping/Model/Shipment/Return.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Shipment/Return.php rename to app/code/Mage/Shipping/Model/Shipment/Return.php diff --git a/app/code/core/Mage/Shipping/Model/Shipping.php b/app/code/Mage/Shipping/Model/Shipping.php similarity index 98% rename from app/code/core/Mage/Shipping/Model/Shipping.php rename to app/code/Mage/Shipping/Model/Shipping.php index c5801bd2dfb2b..da34b54fce9de 100644 --- a/app/code/core/Mage/Shipping/Model/Shipping.php +++ b/app/code/Mage/Shipping/Model/Shipping.php @@ -405,22 +405,14 @@ public function setCarrierAvailabilityConfigField($code = 'active') * * @param string $carrierCode * @param null|int $storeId - * @return bool|Mage_Core_Model_Abstract + * @return bool|Mage_Model_Shipping_Carrier_Abstract */ public function getCarrierByCode($carrierCode, $storeId = null) { if (!Mage::getStoreConfigFlag('carriers/'.$carrierCode.'/'.$this->_availabilityConfigField, $storeId)) { return false; } - $className = Mage::getStoreConfig('carriers/'.$carrierCode.'/model', $storeId); - if (!$className) { - return false; - } - $obj = Mage::getModel($className); - if ($storeId) { - $obj->setStore($storeId); - } - return $obj; + return Mage::getModel('Mage_Shipping_Model_Config')->getCarrierInstance($carrierCode, $storeId); } /** diff --git a/app/code/core/Mage/Shipping/Model/Source/HandlingAction.php b/app/code/Mage/Shipping/Model/Source/HandlingAction.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Source/HandlingAction.php rename to app/code/Mage/Shipping/Model/Source/HandlingAction.php diff --git a/app/code/core/Mage/Shipping/Model/Source/HandlingType.php b/app/code/Mage/Shipping/Model/Source/HandlingType.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Source/HandlingType.php rename to app/code/Mage/Shipping/Model/Source/HandlingType.php diff --git a/app/code/core/Mage/Shipping/Model/Tracking/Result.php b/app/code/Mage/Shipping/Model/Tracking/Result.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Tracking/Result.php rename to app/code/Mage/Shipping/Model/Tracking/Result.php diff --git a/app/code/core/Mage/Shipping/Model/Tracking/Result/Abstract.php b/app/code/Mage/Shipping/Model/Tracking/Result/Abstract.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Tracking/Result/Abstract.php rename to app/code/Mage/Shipping/Model/Tracking/Result/Abstract.php diff --git a/app/code/core/Mage/Shipping/Model/Tracking/Result/Error.php b/app/code/Mage/Shipping/Model/Tracking/Result/Error.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Tracking/Result/Error.php rename to app/code/Mage/Shipping/Model/Tracking/Result/Error.php diff --git a/app/code/core/Mage/Shipping/Model/Tracking/Result/Status.php b/app/code/Mage/Shipping/Model/Tracking/Result/Status.php similarity index 100% rename from app/code/core/Mage/Shipping/Model/Tracking/Result/Status.php rename to app/code/Mage/Shipping/Model/Tracking/Result/Status.php diff --git a/app/code/core/Mage/Shipping/controllers/TrackingController.php b/app/code/Mage/Shipping/controllers/TrackingController.php similarity index 100% rename from app/code/core/Mage/Shipping/controllers/TrackingController.php rename to app/code/Mage/Shipping/controllers/TrackingController.php diff --git a/app/code/Mage/Shipping/etc/adminhtml/acl.xml b/app/code/Mage/Shipping/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..24dbe57509f43 --- /dev/null +++ b/app/code/Mage/Shipping/etc/adminhtml/acl.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + diff --git a/app/code/core/Mage/Shipping/etc/adminhtml/system.xml b/app/code/Mage/Shipping/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Shipping/etc/adminhtml/system.xml rename to app/code/Mage/Shipping/etc/adminhtml/system.xml diff --git a/app/code/Mage/Shipping/etc/config.xml b/app/code/Mage/Shipping/etc/config.xml new file mode 100644 index 0000000000000..d2420786786f3 --- /dev/null +++ b/app/code/Mage/Shipping/etc/config.xml @@ -0,0 +1,142 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + + Mage_Shipping + + + + + + + + + callback + + + + + + + + + + + Mage_Shipping.csv + + + + + + + + + + + Mage_Shipping.csv + + + + + + + standard + + Mage_Shipping + shipping + + + + + + + layout.xml + + + + + + + + + US + 90034 + 12 + + + + + 0 + 0 + Mage_Shipping_Model_Carrier_Flatrate + Fixed + 5.00 + Flat Rate + I + This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us. + F + + + 0 + 0 + 50 + Mage_Shipping_Model_Carrier_Freeshipping + Free + Free Shipping + This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us. + + + 0 + 0 + package_weight + 1 + Mage_Shipping_Model_Carrier_Tablerate + Table Rate + Best Way + This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us. + F + + + + diff --git a/app/code/Mage/Shipping/etc/webhook/acl.xml b/app/code/Mage/Shipping/etc/webhook/acl.xml new file mode 100644 index 0000000000000..db3f757a80867 --- /dev/null +++ b/app/code/Mage/Shipping/etc/webhook/acl.xml @@ -0,0 +1,34 @@ + + + + + + + + + diff --git a/app/code/core/Mage/Shipping/locale/de_DE/Mage_Shipping.csv b/app/code/Mage/Shipping/locale/de_DE/Mage_Shipping.csv similarity index 100% rename from app/code/core/Mage/Shipping/locale/de_DE/Mage_Shipping.csv rename to app/code/Mage/Shipping/locale/de_DE/Mage_Shipping.csv diff --git a/app/code/core/Mage/Shipping/locale/en_US/Mage_Shipping.csv b/app/code/Mage/Shipping/locale/en_US/Mage_Shipping.csv similarity index 100% rename from app/code/core/Mage/Shipping/locale/en_US/Mage_Shipping.csv rename to app/code/Mage/Shipping/locale/en_US/Mage_Shipping.csv diff --git a/app/code/core/Mage/Shipping/locale/es_ES/Mage_Shipping.csv b/app/code/Mage/Shipping/locale/es_ES/Mage_Shipping.csv similarity index 100% rename from app/code/core/Mage/Shipping/locale/es_ES/Mage_Shipping.csv rename to app/code/Mage/Shipping/locale/es_ES/Mage_Shipping.csv diff --git a/app/code/core/Mage/Shipping/locale/fr_FR/Mage_Shipping.csv b/app/code/Mage/Shipping/locale/fr_FR/Mage_Shipping.csv similarity index 100% rename from app/code/core/Mage/Shipping/locale/fr_FR/Mage_Shipping.csv rename to app/code/Mage/Shipping/locale/fr_FR/Mage_Shipping.csv diff --git a/app/code/core/Mage/Shipping/locale/nl_NL/Mage_Shipping.csv b/app/code/Mage/Shipping/locale/nl_NL/Mage_Shipping.csv similarity index 100% rename from app/code/core/Mage/Shipping/locale/nl_NL/Mage_Shipping.csv rename to app/code/Mage/Shipping/locale/nl_NL/Mage_Shipping.csv diff --git a/app/code/core/Mage/Shipping/locale/pt_BR/Mage_Shipping.csv b/app/code/Mage/Shipping/locale/pt_BR/Mage_Shipping.csv similarity index 100% rename from app/code/core/Mage/Shipping/locale/pt_BR/Mage_Shipping.csv rename to app/code/Mage/Shipping/locale/pt_BR/Mage_Shipping.csv diff --git a/app/code/core/Mage/Shipping/locale/zh_CN/Mage_Shipping.csv b/app/code/Mage/Shipping/locale/zh_CN/Mage_Shipping.csv similarity index 100% rename from app/code/core/Mage/Shipping/locale/zh_CN/Mage_Shipping.csv rename to app/code/Mage/Shipping/locale/zh_CN/Mage_Shipping.csv diff --git a/app/code/core/Mage/Shipping/sql/shipping_setup/install-1.6.0.0.php b/app/code/Mage/Shipping/sql/shipping_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Shipping/sql/shipping_setup/install-1.6.0.0.php rename to app/code/Mage/Shipping/sql/shipping_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Shipping/view/frontend/layout.xml b/app/code/Mage/Shipping/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/Shipping/view/frontend/layout.xml rename to app/code/Mage/Shipping/view/frontend/layout.xml diff --git a/app/code/core/Mage/Shipping/view/frontend/tracking/popup.phtml b/app/code/Mage/Shipping/view/frontend/tracking/popup.phtml similarity index 100% rename from app/code/core/Mage/Shipping/view/frontend/tracking/popup.phtml rename to app/code/Mage/Shipping/view/frontend/tracking/popup.phtml diff --git a/app/code/core/Mage/Sitemap/Helper/Data.php b/app/code/Mage/Sitemap/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Sitemap/Helper/Data.php rename to app/code/Mage/Sitemap/Helper/Data.php diff --git a/app/code/core/Mage/Sitemap/Model/Config/Backend/Priority.php b/app/code/Mage/Sitemap/Model/Config/Backend/Priority.php similarity index 100% rename from app/code/core/Mage/Sitemap/Model/Config/Backend/Priority.php rename to app/code/Mage/Sitemap/Model/Config/Backend/Priority.php diff --git a/app/code/core/Mage/Sitemap/Model/Config/Source/Frequency.php b/app/code/Mage/Sitemap/Model/Config/Source/Frequency.php similarity index 100% rename from app/code/core/Mage/Sitemap/Model/Config/Source/Frequency.php rename to app/code/Mage/Sitemap/Model/Config/Source/Frequency.php diff --git a/app/code/core/Mage/Sitemap/Model/Observer.php b/app/code/Mage/Sitemap/Model/Observer.php similarity index 100% rename from app/code/core/Mage/Sitemap/Model/Observer.php rename to app/code/Mage/Sitemap/Model/Observer.php diff --git a/app/code/core/Mage/Sitemap/Model/Resource/Catalog/Category.php b/app/code/Mage/Sitemap/Model/Resource/Catalog/Category.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sitemap/Model/Resource/Catalog/Category.php rename to app/code/Mage/Sitemap/Model/Resource/Catalog/Category.php diff --git a/app/code/core/Mage/Sitemap/Model/Resource/Catalog/Product.php b/app/code/Mage/Sitemap/Model/Resource/Catalog/Product.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sitemap/Model/Resource/Catalog/Product.php rename to app/code/Mage/Sitemap/Model/Resource/Catalog/Product.php diff --git a/app/code/core/Mage/Sitemap/Model/Resource/Cms/Page.php b/app/code/Mage/Sitemap/Model/Resource/Cms/Page.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sitemap/Model/Resource/Cms/Page.php rename to app/code/Mage/Sitemap/Model/Resource/Cms/Page.php diff --git a/app/code/core/Mage/Sitemap/Model/Resource/Sitemap.php b/app/code/Mage/Sitemap/Model/Resource/Sitemap.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sitemap/Model/Resource/Sitemap.php rename to app/code/Mage/Sitemap/Model/Resource/Sitemap.php diff --git a/app/code/core/Mage/Sitemap/Model/Resource/Sitemap/Collection.php b/app/code/Mage/Sitemap/Model/Resource/Sitemap/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Sitemap/Model/Resource/Sitemap/Collection.php rename to app/code/Mage/Sitemap/Model/Resource/Sitemap/Collection.php diff --git a/app/code/core/Mage/Sitemap/Model/Sitemap.php b/app/code/Mage/Sitemap/Model/Sitemap.php similarity index 100% rename from app/code/core/Mage/Sitemap/Model/Sitemap.php rename to app/code/Mage/Sitemap/Model/Sitemap.php diff --git a/app/code/core/Mage/Sitemap/Model/Source/Product/Image/Include.php b/app/code/Mage/Sitemap/Model/Source/Product/Image/Include.php similarity index 100% rename from app/code/core/Mage/Sitemap/Model/Source/Product/Image/Include.php rename to app/code/Mage/Sitemap/Model/Source/Product/Image/Include.php diff --git a/app/code/Mage/Sitemap/etc/adminhtml/acl.xml b/app/code/Mage/Sitemap/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..71a6fd320ff8b --- /dev/null +++ b/app/code/Mage/Sitemap/etc/adminhtml/acl.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Mage/Sitemap/etc/adminhtml/menu.xml b/app/code/Mage/Sitemap/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..4c00f851cd89f --- /dev/null +++ b/app/code/Mage/Sitemap/etc/adminhtml/menu.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/app/code/core/Mage/Sitemap/etc/adminhtml/system.xml b/app/code/Mage/Sitemap/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Sitemap/etc/adminhtml/system.xml rename to app/code/Mage/Sitemap/etc/adminhtml/system.xml diff --git a/app/code/Mage/Sitemap/etc/config.xml b/app/code/Mage/Sitemap/etc/config.xml new file mode 100644 index 0000000000000..491f63f489b64 --- /dev/null +++ b/app/code/Mage/Sitemap/etc/config.xml @@ -0,0 +1,113 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + Mage_Sitemap + + + + + + + + + + + Mage_Sitemap.csv + + + + + + + + layout.xml + + + + + + + + 50000 + 10485760 + + + 0.25 + daily + + + 0.5 + daily + + + 1 + daily + all + + + 0 + + sitemap_generate_error_email_template + general + + + 0 + + + + + + + + Mage_Sitemap_Model_Observer::scheduledGenerateSitemaps + + + + + diff --git a/app/code/core/Mage/Sitemap/locale/de_DE/Mage_Sitemap.csv b/app/code/Mage/Sitemap/locale/de_DE/Mage_Sitemap.csv similarity index 100% rename from app/code/core/Mage/Sitemap/locale/de_DE/Mage_Sitemap.csv rename to app/code/Mage/Sitemap/locale/de_DE/Mage_Sitemap.csv diff --git a/app/code/core/Mage/Sitemap/locale/en_US/Mage_Sitemap.csv b/app/code/Mage/Sitemap/locale/en_US/Mage_Sitemap.csv similarity index 100% rename from app/code/core/Mage/Sitemap/locale/en_US/Mage_Sitemap.csv rename to app/code/Mage/Sitemap/locale/en_US/Mage_Sitemap.csv diff --git a/app/code/core/Mage/Sitemap/locale/es_ES/Mage_Sitemap.csv b/app/code/Mage/Sitemap/locale/es_ES/Mage_Sitemap.csv similarity index 100% rename from app/code/core/Mage/Sitemap/locale/es_ES/Mage_Sitemap.csv rename to app/code/Mage/Sitemap/locale/es_ES/Mage_Sitemap.csv diff --git a/app/code/core/Mage/Sitemap/locale/fr_FR/Mage_Sitemap.csv b/app/code/Mage/Sitemap/locale/fr_FR/Mage_Sitemap.csv similarity index 100% rename from app/code/core/Mage/Sitemap/locale/fr_FR/Mage_Sitemap.csv rename to app/code/Mage/Sitemap/locale/fr_FR/Mage_Sitemap.csv diff --git a/app/code/core/Mage/Sitemap/locale/nl_NL/Mage_Sitemap.csv b/app/code/Mage/Sitemap/locale/nl_NL/Mage_Sitemap.csv similarity index 100% rename from app/code/core/Mage/Sitemap/locale/nl_NL/Mage_Sitemap.csv rename to app/code/Mage/Sitemap/locale/nl_NL/Mage_Sitemap.csv diff --git a/app/code/core/Mage/Sitemap/locale/pt_BR/Mage_Sitemap.csv b/app/code/Mage/Sitemap/locale/pt_BR/Mage_Sitemap.csv similarity index 100% rename from app/code/core/Mage/Sitemap/locale/pt_BR/Mage_Sitemap.csv rename to app/code/Mage/Sitemap/locale/pt_BR/Mage_Sitemap.csv diff --git a/app/code/core/Mage/Sitemap/locale/zh_CN/Mage_Sitemap.csv b/app/code/Mage/Sitemap/locale/zh_CN/Mage_Sitemap.csv similarity index 100% rename from app/code/core/Mage/Sitemap/locale/zh_CN/Mage_Sitemap.csv rename to app/code/Mage/Sitemap/locale/zh_CN/Mage_Sitemap.csv diff --git a/app/code/core/Mage/Sitemap/sql/sitemap_setup/install-1.6.0.0.php b/app/code/Mage/Sitemap/sql/sitemap_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Sitemap/sql/sitemap_setup/install-1.6.0.0.php rename to app/code/Mage/Sitemap/sql/sitemap_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Sitemap/view/adminhtml/layout.xml b/app/code/Mage/Sitemap/view/adminhtml/layout.xml similarity index 100% rename from app/code/core/Mage/Sitemap/view/adminhtml/layout.xml rename to app/code/Mage/Sitemap/view/adminhtml/layout.xml diff --git a/app/code/core/Mage/Sitemap/view/email/generate_warnings.html b/app/code/Mage/Sitemap/view/email/generate_warnings.html similarity index 100% rename from app/code/core/Mage/Sitemap/view/email/generate_warnings.html rename to app/code/Mage/Sitemap/view/email/generate_warnings.html diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Assigned/Grid.php b/app/code/Mage/Tag/Block/Adminhtml/Assigned/Grid.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Assigned/Grid.php rename to app/code/Mage/Tag/Block/Adminhtml/Assigned/Grid.php diff --git a/app/code/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/Tag.php b/app/code/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/Tag.php new file mode 100644 index 0000000000000..39d959e62588c --- /dev/null +++ b/app/code/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/Tag.php @@ -0,0 +1,161 @@ + + * + * @method Mage_Tag_Block_Adminhtml_Catalog_Product_Edit_Tab_Tag setTitle() setTitle(string $title) + * @method array getTitle() getTitle() + */ + +class Mage_Tag_Block_Adminhtml_Catalog_Product_Edit_Tab_Tag + extends Mage_Backend_Block_Template + implements Mage_Backend_Block_Widget_Tab_Interface +{ + /** + * Id of current tab + */ + const TAB_ID = 'tags'; + + /** + * Array of data helpers + * + * @var array + */ + protected $_helpers; + + /** + * Authentication session + * + * @var Mage_Core_Model_Authorization + */ + protected $_authSession; + + /** + * @param Mage_Core_Block_Template_Context $context + * @param Mage_Core_Model_Authorization $authSession + * @param array $data + */ + public function __construct(Mage_Core_Block_Template_Context $context, + Mage_Core_Model_Authorization $authSession, + array $data = array() + ) { + parent::__construct($context, $data); + + if (isset($data['helpers'])) { + $this->_helpers = $data['helpers']; + } + + $this->_authSession = $authSession; + $this->setId(self::TAB_ID); + $this->setTitle($this->_helper('Mage_Tag_Helper_Data')->__('Product Tags')); + } + + /** + * Helper getter + * + * @param string $helperName + * @return Mage_Core_Helper_Abstract + */ + protected function _helper($helperName) + { + return isset($this->_helpers[$helperName]) ? $this->_helpers[$helperName] : Mage::helper($helperName); + } + + /** + * Tab label getter + * + * @return string + */ + public function getTabLabel() + { + return $this->getTitle(); + } + + /** + * Tab title getter + * + * @return string + */ + public function getTabTitle() + { + return $this->getTitle(); + } + + /** + * Check whether tab can be showed + * + * @return bool + */ + public function canShowTab() + { + return $this->_authSession->isAllowed('Mage_Tag::tag_all'); + } + + /** + * Check whether tab should be hidden + * + * @return bool + */ + public function isHidden() + { + return false; + } + + /** + * Tab class getter + * + * @return string + */ + public function getTabClass() + { + return 'ajax'; + } + + /** + * Tab URL getter + * + * @return string + */ + public function getTabUrl() + { + return $this->getUrl('*/*/tagGrid', array('_current' => true)); + } + + /** + * Retrieve id of tab after which current tab will be rendered + * + * @return string + */ + public function getAfter() + { + return 'reviews'; + } +} diff --git a/app/code/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/Tag/Customer.php b/app/code/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/Tag/Customer.php new file mode 100644 index 0000000000000..fd3153b6c12ba --- /dev/null +++ b/app/code/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/Tag/Customer.php @@ -0,0 +1,162 @@ + + * + * @method Mage_Tag_Block_Adminhtml_Catalog_Product_Edit_Tab_Tag_Customer setTitle() setTitle(string $title) + * @method array getTitle() getTitle() + */ + +class Mage_Tag_Block_Adminhtml_Catalog_Product_Edit_Tab_Tag_Customer + extends Mage_Backend_Block_Template + implements Mage_Backend_Block_Widget_Tab_Interface +{ + /** + * Id of current tab + */ + const TAB_ID = 'customers_tags'; + + /** + * Array of data helpers + * + * @var array + */ + protected $_helpers; + + /** + * Authentication session + * + * @var Mage_Core_Model_Authorization + */ + protected $_authSession; + + /** + * @param Mage_Core_Block_Template_Context $context + * @param Mage_Core_Model_Authorization $authSession + * @param array $data + */ + public function __construct( + Mage_Core_Block_Template_Context $context, + Mage_Core_Model_Authorization $authSession, + array $data = array() + ) { + parent::__construct($context, $data); + + if (isset($data['helpers'])) { + $this->_helpers = $data['helpers']; + } + + $this->_authSession = $authSession; + $this->setId(self::TAB_ID); + $this->setTitle($this->_helper('Mage_Tag_Helper_Data')->__('Customers Tagged Product')); + } + + /** + * Helper getter + * + * @param string $helperName + * @return Mage_Core_Helper_Abstract + */ + protected function _helper($helperName) + { + return isset($this->_helpers[$helperName]) ? $this->_helpers[$helperName] : Mage::helper($helperName); + } + + /** + * Tab label getter + * + * @return string + */ + public function getTabLabel() + { + return $this->getTitle(); + } + + /** + * Tab title getter + * + * @return string + */ + public function getTabTitle() + { + return $this->getTitle(); + } + + /** + * Check whether tab can be showed + * + * @return bool + */ + public function canShowTab() + { + return $this->_authSession->isAllowed('Mage_Tag::tag_all'); + } + + /** + * Check whether tab should be hidden + * + * @return bool + */ + public function isHidden() + { + return false; + } + + /** + * Tab class getter + * + * @return string + */ + public function getTabClass() + { + return 'ajax'; + } + + /** + * Tab URL getter + * + * @return string + */ + public function getTabUrl() + { + return $this->getUrl('*/*/tagCustomerGrid', array('_current' => true)); + } + + /** + * Retrieve id of tab after which current tab will be rendered + * + * @return string + */ + public function getAfter() + { + return 'reviews'; + } +} diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/Tag/Customer/Grid.php b/app/code/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/Tag/Customer/Grid.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/Tag/Customer/Grid.php rename to app/code/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/Tag/Customer/Grid.php diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/Tag/Grid.php b/app/code/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/Tag/Grid.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/Tag/Grid.php rename to app/code/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/Tag/Grid.php diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Customer.php b/app/code/Mage/Tag/Block/Adminhtml/Customer.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Customer.php rename to app/code/Mage/Tag/Block/Adminhtml/Customer.php diff --git a/app/code/Mage/Tag/Block/Adminhtml/Customer/Edit/Tab/Tag.php b/app/code/Mage/Tag/Block/Adminhtml/Customer/Edit/Tab/Tag.php new file mode 100644 index 0000000000000..cd8394861ace0 --- /dev/null +++ b/app/code/Mage/Tag/Block/Adminhtml/Customer/Edit/Tab/Tag.php @@ -0,0 +1,181 @@ +_authSession = $authSession; + if (isset($data['helpers'])) { + $this->_helpers = $data['helpers']; + } + $this->setId('tags'); + $this->setTitle($this->_helper('Mage_Tag_Helper_Data')->__('Product Tags')); + } + + /** + * Set customer object + * + * @param Mage_Customer_Model_Customer $customer + */ + public function setCustomer(Mage_Customer_Model_Customer $customer) + { + $this->_customer = $customer; + } + + /** + * Retrieve current customer instance + * + * @return Mage_Customer_Model_Customer + */ + public function getCustomer() + { + if (!$this->_customer) { + $this->_customer = Mage::registry('current_customer'); + } + + return $this->_customer; + } + + /** + * Helper getter + * + * @param string $helperName + * @return Mage_Core_Helper_Abstract + */ + protected function _helper($helperName) + { + return isset($this->_helpers[$helperName]) ? $this->_helpers[$helperName] : Mage::helper($helperName); + } + + /** + * Tab label getter + * + * @return string + */ + public function getTabLabel() + { + return $this->getTitle(); + } + + /** + * Tab title getter + * + * @return string + */ + public function getTabTitle() + { + return $this->getTitle(); + } + + /** + * Check whether tab can be showed + * + * @return bool + */ + public function canShowTab() + { + if (!$this->getCustomer()) { + return false; + } + return $this->getCustomer()->getId() && $this->_authSession->isAllowed('Mage_Tag::tag_all'); + } + + /** + * Check whether tab should be hidden + * + * @return bool + */ + public function isHidden() + { + return false; + } + + /** + * Place current tab after "Product Reviews" + * + * @return string + */ + public function getAfter() + { + return 'reviews'; + } + + /** + * Tab class getter + * + * @return string + */ + public function getTabClass() + { + return 'ajax'; + } + + /** + * Tab URL getter + * + * @return string + */ + public function getTabUrl() + { + return $this->getUrl('*/customer/productTags', array('_current' => true)); + } +} diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Customer/Edit/Tab/Tag/Grid.php b/app/code/Mage/Tag/Block/Adminhtml/Customer/Edit/Tab/Tag/Grid.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Customer/Edit/Tab/Tag/Grid.php rename to app/code/Mage/Tag/Block/Adminhtml/Customer/Edit/Tab/Tag/Grid.php diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Customer/Grid.php b/app/code/Mage/Tag/Block/Adminhtml/Customer/Grid.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Customer/Grid.php rename to app/code/Mage/Tag/Block/Adminhtml/Customer/Grid.php diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Edit.php b/app/code/Mage/Tag/Block/Adminhtml/Edit.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Edit.php rename to app/code/Mage/Tag/Block/Adminhtml/Edit.php diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Edit/Accordion.php b/app/code/Mage/Tag/Block/Adminhtml/Edit/Accordion.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Edit/Accordion.php rename to app/code/Mage/Tag/Block/Adminhtml/Edit/Accordion.php diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Edit/Assigned.php b/app/code/Mage/Tag/Block/Adminhtml/Edit/Assigned.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Edit/Assigned.php rename to app/code/Mage/Tag/Block/Adminhtml/Edit/Assigned.php diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Edit/Form.php b/app/code/Mage/Tag/Block/Adminhtml/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Edit/Form.php rename to app/code/Mage/Tag/Block/Adminhtml/Edit/Form.php diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Grid/All.php b/app/code/Mage/Tag/Block/Adminhtml/Grid/All.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Grid/All.php rename to app/code/Mage/Tag/Block/Adminhtml/Grid/All.php diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Grid/Pending.php b/app/code/Mage/Tag/Block/Adminhtml/Grid/Pending.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Grid/Pending.php rename to app/code/Mage/Tag/Block/Adminhtml/Grid/Pending.php diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Pending.php b/app/code/Mage/Tag/Block/Adminhtml/Pending.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Pending.php rename to app/code/Mage/Tag/Block/Adminhtml/Pending.php diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Product.php b/app/code/Mage/Tag/Block/Adminhtml/Product.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Product.php rename to app/code/Mage/Tag/Block/Adminhtml/Product.php diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Product/Grid.php b/app/code/Mage/Tag/Block/Adminhtml/Product/Grid.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Product/Grid.php rename to app/code/Mage/Tag/Block/Adminhtml/Product/Grid.php diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Report/Customer.php b/app/code/Mage/Tag/Block/Adminhtml/Report/Customer.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Report/Customer.php rename to app/code/Mage/Tag/Block/Adminhtml/Report/Customer.php diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Report/Customer/Detail.php b/app/code/Mage/Tag/Block/Adminhtml/Report/Customer/Detail.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Report/Customer/Detail.php rename to app/code/Mage/Tag/Block/Adminhtml/Report/Customer/Detail.php diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Report/Popular.php b/app/code/Mage/Tag/Block/Adminhtml/Report/Popular.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Report/Popular.php rename to app/code/Mage/Tag/Block/Adminhtml/Report/Popular.php diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Report/Popular/Detail.php b/app/code/Mage/Tag/Block/Adminhtml/Report/Popular/Detail.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Report/Popular/Detail.php rename to app/code/Mage/Tag/Block/Adminhtml/Report/Popular/Detail.php diff --git a/app/code/Mage/Tag/Block/Adminhtml/Report/Popular/Grid.php b/app/code/Mage/Tag/Block/Adminhtml/Report/Popular/Grid.php new file mode 100644 index 0000000000000..72b46fd365cdc --- /dev/null +++ b/app/code/Mage/Tag/Block/Adminhtml/Report/Popular/Grid.php @@ -0,0 +1,113 @@ + + */ +class Mage_Tag_Block_Adminhtml_Report_Popular_Grid extends Mage_Adminhtml_Block_Widget_Grid +{ + + protected function _construct() + { + parent::_construct(); + $this->setId('grid'); + } + + protected function _prepareCollection() + { + + if ($this->getRequest()->getParam('website')) { + $storeId = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds(); + } else if ($this->getRequest()->getParam('group')) { + $storeId = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds(); + } else if ($this->getRequest()->getParam('store')) { + $storeId = (int)$this->getRequest()->getParam('store'); + } else { + $storeId = ''; + } + + $collection = Mage::getResourceModel('Mage_Tag_Model_Resource_Reports_Collection') + ->addPopularity($storeId) + ->addStatusFilter(Mage_Tag_Model_Tag::STATUS_APPROVED); + + $this->setCollection($collection); + return parent::_prepareCollection(); + } + + protected function _prepareColumns() + { + $this->addColumn('name', array( + 'header' =>Mage::helper('Mage_Tag_Helper_Data')->__('Tag Name'), + 'index' =>'name', + 'header_css_class' => 'col-name', + 'column_css_class' => 'col-name' + )); + + $this->addColumn('taged', array( + 'header' =>Mage::helper('Mage_Tag_Helper_Data')->__('Popularity'), + 'index' =>'popularity', + 'header_css_class' => 'col-qty', + 'column_css_class' => 'col-qty' + )); + + $this->addColumn('action', + array( + 'header' => Mage::helper('Mage_Tag_Helper_Data')->__('Action'), + 'type' => 'action', + 'getter' => 'getId', + 'actions' => array( + array( + 'caption' => Mage::helper('Mage_Tag_Helper_Data')->__('Show Details'), + 'url' => array( + 'base'=>'*/*/tagDetail' + ), + 'field' => 'id' + ) + ), + 'is_system' => true, + 'filter' => false, + 'sortable' => false, + 'index' => 'stores', + 'header_css_class' => 'col-actions', + 'column_css_class' => 'col-actions' + )); + $this->setFilterVisibility(false); + + $this->addExportType('*/*/exportPopularCsv', Mage::helper('Mage_Tag_Helper_Data')->__('CSV')); + $this->addExportType('*/*/exportPopularExcel', Mage::helper('Mage_Tag_Helper_Data')->__('Excel XML')); + + return parent::_prepareColumns(); + } + + public function getRowUrl($row) + { + return $this->getUrl('*/*/tagDetail', array('id'=>$row->getTagId())); + } +} diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Report/Product.php b/app/code/Mage/Tag/Block/Adminhtml/Report/Product.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Report/Product.php rename to app/code/Mage/Tag/Block/Adminhtml/Report/Product.php diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Report/Product/Detail.php b/app/code/Mage/Tag/Block/Adminhtml/Report/Product/Detail.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Report/Product/Detail.php rename to app/code/Mage/Tag/Block/Adminhtml/Report/Product/Detail.php diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Store/Switcher.php b/app/code/Mage/Tag/Block/Adminhtml/Store/Switcher.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Store/Switcher.php rename to app/code/Mage/Tag/Block/Adminhtml/Store/Switcher.php diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Tag.php b/app/code/Mage/Tag/Block/Adminhtml/Tag.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Tag.php rename to app/code/Mage/Tag/Block/Adminhtml/Tag.php diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Tag/Grid.php b/app/code/Mage/Tag/Block/Adminhtml/Tag/Grid.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Adminhtml/Tag/Grid.php rename to app/code/Mage/Tag/Block/Adminhtml/Tag/Grid.php diff --git a/app/code/core/Mage/Tag/Block/All.php b/app/code/Mage/Tag/Block/All.php similarity index 100% rename from app/code/core/Mage/Tag/Block/All.php rename to app/code/Mage/Tag/Block/All.php diff --git a/app/code/core/Mage/Tag/Block/Catalog/Product/Rss.php b/app/code/Mage/Tag/Block/Catalog/Product/Rss.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Catalog/Product/Rss.php rename to app/code/Mage/Tag/Block/Catalog/Product/Rss.php diff --git a/app/code/core/Mage/Tag/Block/Catalog/Product/Rss/Link.php b/app/code/Mage/Tag/Block/Catalog/Product/Rss/Link.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Catalog/Product/Rss/Link.php rename to app/code/Mage/Tag/Block/Catalog/Product/Rss/Link.php diff --git a/app/code/core/Mage/Tag/Block/Customer/Recent.php b/app/code/Mage/Tag/Block/Customer/Recent.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Customer/Recent.php rename to app/code/Mage/Tag/Block/Customer/Recent.php diff --git a/app/code/core/Mage/Tag/Block/Customer/Tags.php b/app/code/Mage/Tag/Block/Customer/Tags.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Customer/Tags.php rename to app/code/Mage/Tag/Block/Customer/Tags.php diff --git a/app/code/Mage/Tag/Block/Customer/View.php b/app/code/Mage/Tag/Block/Customer/View.php new file mode 100644 index 0000000000000..c7b3e4825caaa --- /dev/null +++ b/app/code/Mage/Tag/Block/Customer/View.php @@ -0,0 +1,183 @@ + + */ +class Mage_Tag_Block_Customer_View extends Mage_Catalog_Block_Product_Abstract +{ + /** + * Tagged Product Collection + * + * @var Mage_Tag_Model_Resource_Product_Collection + */ + protected $_collection; + + /** + * Current Tag object + * + * @var Mage_Tag_Model_Tag + */ + protected $_tagInfo; + + /** + * Initialize block + * + */ + protected function _construct() + { + parent::_construct(); + $this->setTagId(Mage::registry('tagId')); + } + + /** + * Retrieve current Tag object + * + * @return Mage_Tag_Model_Tag + */ + public function getTagInfo() + { + if (is_null($this->_tagInfo)) { + $this->_tagInfo = Mage::getModel('Mage_Tag_Model_Tag') + ->load($this->getTagId()); + } + return $this->_tagInfo; + } + + /** + * Retrieve Tagged Product Collection items + * + * @return array + */ + public function getMyProducts() + { + return $this->_getCollection()->getItems(); + } + + /** + * Retrieve count of Tagged Product(s) + * + * @return int + */ + public function getCount() + { + return sizeof($this->getMyProducts()); + } + + /** + * Retrieve Product Info URL + * + * @param int $productId + * @return string + */ + public function getReviewUrl($productId) + { + return Mage::getUrl('review/product/list', array('id' => $productId)); + } + + /** + * Preparing block layout + * + * @return Mage_Tag_Block_Customer_View + */ + protected function _prepareLayout() + { + $toolbar = $this->getLayout() + ->createBlock('Mage_Page_Block_Html_Pager', 'customer_tag_list.toolbar') + ->setCollection($this->_getCollection()); + + $this->setChild('toolbar', $toolbar); + return parent::_prepareLayout(); + } + + /** + * Retrieve Toolbar block HTML + * + * @return string + */ + public function getToolbarHtml() + { + return $this->getChildHtml('toolbar'); + } + + /** + * Retrieve Current Mode + * + * @return string + */ + public function getMode() + { + return $this->getChildBlock('toolbar')->getCurrentMode(); + } + + /** + * Retrieve Tagged product(s) collection + * + * @return Mage_Tag_Model_Resource_Product_Collection + */ + protected function _getCollection() + { + if (is_null($this->_collection)) { + $this->_collection = Mage::getModel('Mage_Tag_Model_Tag') + ->getEntityCollection() + ->addTagFilter($this->getTagId()) + ->addCustomerFilter(Mage::getSingleton('Mage_Customer_Model_Session')->getCustomerId()) + ->addStoreFilter(Mage::app()->getStore()->getId()) + ->addAttributeToSelect(Mage::getSingleton('Mage_Catalog_Model_Config')->getProductAttributes()) + ->setActiveFilter() + ->setVisibility(Mage::getSingleton('Mage_Catalog_Model_Product_Visibility')->getVisibleInSiteIds()); + } + return $this->_collection; + } + + /** + * Product image url getter + * + * @param Mage_Catalog_Model_Product $product + * @return string + */ + public function getImageUrl($product) + { + return (string) $this->helper('Mage_Catalog_Helper_Image')->init($product, 'small_image') + ->resize($this->getImageSize()); + } + + /** + * Product image size getter + * + * @return int + */ + public function getImageSize() + { + return $this->getVar('product_image_size', 'Mage_Tag'); + } + +} diff --git a/app/code/core/Mage/Tag/Block/Popular.php b/app/code/Mage/Tag/Block/Popular.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Popular.php rename to app/code/Mage/Tag/Block/Popular.php diff --git a/app/code/core/Mage/Tag/Block/Product/List.php b/app/code/Mage/Tag/Block/Product/List.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Product/List.php rename to app/code/Mage/Tag/Block/Product/List.php diff --git a/app/code/core/Mage/Tag/Block/Product/Result.php b/app/code/Mage/Tag/Block/Product/Result.php similarity index 100% rename from app/code/core/Mage/Tag/Block/Product/Result.php rename to app/code/Mage/Tag/Block/Product/Result.php diff --git a/app/code/core/Mage/Tag/Helper/Data.php b/app/code/Mage/Tag/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Tag/Helper/Data.php rename to app/code/Mage/Tag/Helper/Data.php diff --git a/app/code/core/Mage/Tag/Model/Api.php b/app/code/Mage/Tag/Model/Api.php similarity index 100% rename from app/code/core/Mage/Tag/Model/Api.php rename to app/code/Mage/Tag/Model/Api.php diff --git a/app/code/core/Mage/Tag/Model/Api/V2.php b/app/code/Mage/Tag/Model/Api/V2.php similarity index 100% rename from app/code/core/Mage/Tag/Model/Api/V2.php rename to app/code/Mage/Tag/Model/Api/V2.php diff --git a/app/code/core/Mage/Tag/Model/Entity/Customer/Collection.php b/app/code/Mage/Tag/Model/Entity/Customer/Collection.php similarity index 100% rename from app/code/core/Mage/Tag/Model/Entity/Customer/Collection.php rename to app/code/Mage/Tag/Model/Entity/Customer/Collection.php diff --git a/app/code/core/Mage/Tag/Model/Indexer/Summary.php b/app/code/Mage/Tag/Model/Indexer/Summary.php similarity index 100% rename from app/code/core/Mage/Tag/Model/Indexer/Summary.php rename to app/code/Mage/Tag/Model/Indexer/Summary.php diff --git a/app/code/core/Mage/Tag/Model/Resource/Customer/Collection.php b/app/code/Mage/Tag/Model/Resource/Customer/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tag/Model/Resource/Customer/Collection.php rename to app/code/Mage/Tag/Model/Resource/Customer/Collection.php diff --git a/app/code/core/Mage/Tag/Model/Resource/Indexer/Summary.php b/app/code/Mage/Tag/Model/Resource/Indexer/Summary.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tag/Model/Resource/Indexer/Summary.php rename to app/code/Mage/Tag/Model/Resource/Indexer/Summary.php diff --git a/app/code/core/Mage/Tag/Model/Resource/Popular/Collection.php b/app/code/Mage/Tag/Model/Resource/Popular/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tag/Model/Resource/Popular/Collection.php rename to app/code/Mage/Tag/Model/Resource/Popular/Collection.php diff --git a/app/code/core/Mage/Tag/Model/Resource/Product/Collection.php b/app/code/Mage/Tag/Model/Resource/Product/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tag/Model/Resource/Product/Collection.php rename to app/code/Mage/Tag/Model/Resource/Product/Collection.php diff --git a/app/code/core/Mage/Tag/Model/Resource/Reports/Collection.php b/app/code/Mage/Tag/Model/Resource/Reports/Collection.php similarity index 100% rename from app/code/core/Mage/Tag/Model/Resource/Reports/Collection.php rename to app/code/Mage/Tag/Model/Resource/Reports/Collection.php diff --git a/app/code/core/Mage/Tag/Model/Resource/Reports/Customer/Collection.php b/app/code/Mage/Tag/Model/Resource/Reports/Customer/Collection.php similarity index 100% rename from app/code/core/Mage/Tag/Model/Resource/Reports/Customer/Collection.php rename to app/code/Mage/Tag/Model/Resource/Reports/Customer/Collection.php diff --git a/app/code/core/Mage/Tag/Model/Resource/Reports/Customer/Detail/Collection.php b/app/code/Mage/Tag/Model/Resource/Reports/Customer/Detail/Collection.php similarity index 100% rename from app/code/core/Mage/Tag/Model/Resource/Reports/Customer/Detail/Collection.php rename to app/code/Mage/Tag/Model/Resource/Reports/Customer/Detail/Collection.php diff --git a/app/code/core/Mage/Tag/Model/Resource/Reports/Customer/Grid/Collection.php b/app/code/Mage/Tag/Model/Resource/Reports/Customer/Grid/Collection.php similarity index 100% rename from app/code/core/Mage/Tag/Model/Resource/Reports/Customer/Grid/Collection.php rename to app/code/Mage/Tag/Model/Resource/Reports/Customer/Grid/Collection.php diff --git a/app/code/core/Mage/Tag/Model/Resource/Reports/Detail/Collection.php b/app/code/Mage/Tag/Model/Resource/Reports/Detail/Collection.php similarity index 100% rename from app/code/core/Mage/Tag/Model/Resource/Reports/Detail/Collection.php rename to app/code/Mage/Tag/Model/Resource/Reports/Detail/Collection.php diff --git a/app/code/core/Mage/Tag/Model/Resource/Reports/Product/Collection.php b/app/code/Mage/Tag/Model/Resource/Reports/Product/Collection.php similarity index 100% rename from app/code/core/Mage/Tag/Model/Resource/Reports/Product/Collection.php rename to app/code/Mage/Tag/Model/Resource/Reports/Product/Collection.php diff --git a/app/code/core/Mage/Tag/Model/Resource/Reports/Product/Detail/Collection.php b/app/code/Mage/Tag/Model/Resource/Reports/Product/Detail/Collection.php similarity index 100% rename from app/code/core/Mage/Tag/Model/Resource/Reports/Product/Detail/Collection.php rename to app/code/Mage/Tag/Model/Resource/Reports/Product/Detail/Collection.php diff --git a/app/code/core/Mage/Tag/Model/Resource/Reports/Product/Grid/Collection.php b/app/code/Mage/Tag/Model/Resource/Reports/Product/Grid/Collection.php similarity index 100% rename from app/code/core/Mage/Tag/Model/Resource/Reports/Product/Grid/Collection.php rename to app/code/Mage/Tag/Model/Resource/Reports/Product/Grid/Collection.php diff --git a/app/code/core/Mage/Tag/Model/Resource/Tag.php b/app/code/Mage/Tag/Model/Resource/Tag.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tag/Model/Resource/Tag.php rename to app/code/Mage/Tag/Model/Resource/Tag.php diff --git a/app/code/core/Mage/Tag/Model/Resource/Tag/Collection.php b/app/code/Mage/Tag/Model/Resource/Tag/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tag/Model/Resource/Tag/Collection.php rename to app/code/Mage/Tag/Model/Resource/Tag/Collection.php diff --git a/app/code/core/Mage/Tag/Model/Resource/Tag/Relation.php b/app/code/Mage/Tag/Model/Resource/Tag/Relation.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tag/Model/Resource/Tag/Relation.php rename to app/code/Mage/Tag/Model/Resource/Tag/Relation.php diff --git a/app/code/core/Mage/Tag/Model/Session.php b/app/code/Mage/Tag/Model/Session.php similarity index 100% rename from app/code/core/Mage/Tag/Model/Session.php rename to app/code/Mage/Tag/Model/Session.php diff --git a/app/code/core/Mage/Tag/Model/Tag.php b/app/code/Mage/Tag/Model/Tag.php similarity index 100% rename from app/code/core/Mage/Tag/Model/Tag.php rename to app/code/Mage/Tag/Model/Tag.php diff --git a/app/code/core/Mage/Tag/Model/Tag/Relation.php b/app/code/Mage/Tag/Model/Tag/Relation.php similarity index 100% rename from app/code/core/Mage/Tag/Model/Tag/Relation.php rename to app/code/Mage/Tag/Model/Tag/Relation.php diff --git a/app/code/core/Mage/Tag/controllers/Adminhtml/Catalog/ProductController.php b/app/code/Mage/Tag/controllers/Adminhtml/Catalog/ProductController.php similarity index 100% rename from app/code/core/Mage/Tag/controllers/Adminhtml/Catalog/ProductController.php rename to app/code/Mage/Tag/controllers/Adminhtml/Catalog/ProductController.php diff --git a/app/code/core/Mage/Tag/controllers/Adminhtml/CustomerController.php b/app/code/Mage/Tag/controllers/Adminhtml/CustomerController.php similarity index 100% rename from app/code/core/Mage/Tag/controllers/Adminhtml/CustomerController.php rename to app/code/Mage/Tag/controllers/Adminhtml/CustomerController.php diff --git a/app/code/core/Mage/Tag/controllers/Adminhtml/Report/TagController.php b/app/code/Mage/Tag/controllers/Adminhtml/Report/TagController.php similarity index 100% rename from app/code/core/Mage/Tag/controllers/Adminhtml/Report/TagController.php rename to app/code/Mage/Tag/controllers/Adminhtml/Report/TagController.php diff --git a/app/code/core/Mage/Tag/controllers/Adminhtml/TagController.php b/app/code/Mage/Tag/controllers/Adminhtml/TagController.php similarity index 93% rename from app/code/core/Mage/Tag/controllers/Adminhtml/TagController.php rename to app/code/Mage/Tag/controllers/Adminhtml/TagController.php index 689ea8fb189d6..5e1a5cdbbbc77 100644 --- a/app/code/core/Mage/Tag/controllers/Adminhtml/TagController.php +++ b/app/code/Mage/Tag/controllers/Adminhtml/TagController.php @@ -37,7 +37,6 @@ class Mage_Tag_Adminhtml_TagController extends Mage_Adminhtml_Controller_Action protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('Mage_Tag::catalog_tag') ->_addBreadcrumb( Mage::helper('Mage_Tag_Helper_Data')->__('Catalog'), Mage::helper('Mage_Tag_Helper_Data')->__('Catalog') ) @@ -150,7 +149,7 @@ public function editAction() $model->addData($data); } - $this->_title($model->getId() ? $model->getName() : $this->__('New Tag')); + $this->_title($model->getId() ? $this->__('Edit Tag \'%s\'', $model->getName()) : $this->__('New Tag')); Mage::register('tag_tag', $model); @@ -260,7 +259,6 @@ public function pendingAction() Mage::helper('Mage_Tag_Helper_Data')->__('Pending Tags'), Mage::helper('Mage_Tag_Helper_Data')->__('Pending Tags') ) - ->_setActiveMenu('Mage_Tag::catalog_tag_pending') ->renderLayout(); } @@ -369,19 +367,10 @@ public function massStatusAction() /** * Check currently called action by permissions for current user * + * @return bool */ protected function _isAllowed() { - switch ($this->getRequest()->getActionName()) { - case 'pending': - return Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Tag::tag_pending'); - break; - case 'all': - return Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Tag::tag_all'); - break; - default: - return Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Tag::tag'); - break; - } + return Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Tag::tag_all'); } } diff --git a/app/code/core/Mage/Tag/controllers/CustomerController.php b/app/code/Mage/Tag/controllers/CustomerController.php similarity index 100% rename from app/code/core/Mage/Tag/controllers/CustomerController.php rename to app/code/Mage/Tag/controllers/CustomerController.php diff --git a/app/code/core/Mage/Tag/controllers/IndexController.php b/app/code/Mage/Tag/controllers/IndexController.php similarity index 100% rename from app/code/core/Mage/Tag/controllers/IndexController.php rename to app/code/Mage/Tag/controllers/IndexController.php diff --git a/app/code/core/Mage/Tag/controllers/ListController.php b/app/code/Mage/Tag/controllers/ListController.php similarity index 100% rename from app/code/core/Mage/Tag/controllers/ListController.php rename to app/code/Mage/Tag/controllers/ListController.php diff --git a/app/code/core/Mage/Tag/controllers/ProductController.php b/app/code/Mage/Tag/controllers/ProductController.php similarity index 100% rename from app/code/core/Mage/Tag/controllers/ProductController.php rename to app/code/Mage/Tag/controllers/ProductController.php diff --git a/app/code/core/Mage/Tag/controllers/Rss/CatalogController.php b/app/code/Mage/Tag/controllers/Rss/CatalogController.php similarity index 100% rename from app/code/core/Mage/Tag/controllers/Rss/CatalogController.php rename to app/code/Mage/Tag/controllers/Rss/CatalogController.php diff --git a/app/code/Mage/Tag/etc/adminhtml/acl.xml b/app/code/Mage/Tag/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..aa19ab342361c --- /dev/null +++ b/app/code/Mage/Tag/etc/adminhtml/acl.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Mage/Tag/etc/adminhtml/menu.xml b/app/code/Mage/Tag/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..a62bad549a5ad --- /dev/null +++ b/app/code/Mage/Tag/etc/adminhtml/menu.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + diff --git a/app/code/core/Mage/Tag/etc/adminhtml/system.xml b/app/code/Mage/Tag/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Tag/etc/adminhtml/system.xml rename to app/code/Mage/Tag/etc/adminhtml/system.xml diff --git a/app/code/core/Mage/Tag/etc/api.xml b/app/code/Mage/Tag/etc/api.xml similarity index 100% rename from app/code/core/Mage/Tag/etc/api.xml rename to app/code/Mage/Tag/etc/api.xml diff --git a/app/code/Mage/Tag/etc/config.xml b/app/code/Mage/Tag/etc/config.xml new file mode 100644 index 0000000000000..f3bf91914ef57 --- /dev/null +++ b/app/code/Mage/Tag/etc/config.xml @@ -0,0 +1,155 @@ + + + + + + 1.6.0.0 + true + + + + + + + + + + + + + Mage_Tag + + + + + + + Mage_Tag_Model_Indexer_Summary + + + + + + + + Mage_Tag_Model_Session + + + + + + + + + + + Mage_Tag_Rss + + + + + standard + + Mage_Tag + tag + + + + + + + + Mage_Tag.csv + + + + + + + + layout.xml + + + rss.xml + + + + + /tag/customer/ + + + + + + + + Mage_Tag_Adminhtml + + + + + + + + + + + model + Mage_Tag_Model_Tag + productDeleteEventAction + + + + + + + + + Mage_Tag.csv + + + + + + + + product.xml + + + customer.xml + + + tag.xml + + + report.xml + + + + + diff --git a/app/code/core/Mage/Tag/etc/view.xml b/app/code/Mage/Tag/etc/view.xml similarity index 100% rename from app/code/core/Mage/Tag/etc/view.xml rename to app/code/Mage/Tag/etc/view.xml diff --git a/app/code/core/Mage/Tag/etc/wsdl.xml b/app/code/Mage/Tag/etc/wsdl.xml similarity index 100% rename from app/code/core/Mage/Tag/etc/wsdl.xml rename to app/code/Mage/Tag/etc/wsdl.xml diff --git a/app/code/core/Mage/Tag/etc/wsi.xml b/app/code/Mage/Tag/etc/wsi.xml similarity index 100% rename from app/code/core/Mage/Tag/etc/wsi.xml rename to app/code/Mage/Tag/etc/wsi.xml diff --git a/app/code/core/Mage/Tag/locale/de_DE/Mage_Tag.csv b/app/code/Mage/Tag/locale/de_DE/Mage_Tag.csv similarity index 100% rename from app/code/core/Mage/Tag/locale/de_DE/Mage_Tag.csv rename to app/code/Mage/Tag/locale/de_DE/Mage_Tag.csv diff --git a/app/code/core/Mage/Tag/locale/en_US/Mage_Tag.csv b/app/code/Mage/Tag/locale/en_US/Mage_Tag.csv similarity index 100% rename from app/code/core/Mage/Tag/locale/en_US/Mage_Tag.csv rename to app/code/Mage/Tag/locale/en_US/Mage_Tag.csv diff --git a/app/code/core/Mage/Tag/locale/es_ES/Mage_Tag.csv b/app/code/Mage/Tag/locale/es_ES/Mage_Tag.csv similarity index 100% rename from app/code/core/Mage/Tag/locale/es_ES/Mage_Tag.csv rename to app/code/Mage/Tag/locale/es_ES/Mage_Tag.csv diff --git a/app/code/core/Mage/Tag/locale/fr_FR/Mage_Tag.csv b/app/code/Mage/Tag/locale/fr_FR/Mage_Tag.csv similarity index 100% rename from app/code/core/Mage/Tag/locale/fr_FR/Mage_Tag.csv rename to app/code/Mage/Tag/locale/fr_FR/Mage_Tag.csv diff --git a/app/code/core/Mage/Tag/locale/nl_NL/Mage_Tag.csv b/app/code/Mage/Tag/locale/nl_NL/Mage_Tag.csv similarity index 100% rename from app/code/core/Mage/Tag/locale/nl_NL/Mage_Tag.csv rename to app/code/Mage/Tag/locale/nl_NL/Mage_Tag.csv diff --git a/app/code/core/Mage/Tag/locale/pt_BR/Mage_Tag.csv b/app/code/Mage/Tag/locale/pt_BR/Mage_Tag.csv similarity index 100% rename from app/code/core/Mage/Tag/locale/pt_BR/Mage_Tag.csv rename to app/code/Mage/Tag/locale/pt_BR/Mage_Tag.csv diff --git a/app/code/core/Mage/Tag/locale/zh_CN/Mage_Tag.csv b/app/code/Mage/Tag/locale/zh_CN/Mage_Tag.csv similarity index 100% rename from app/code/core/Mage/Tag/locale/zh_CN/Mage_Tag.csv rename to app/code/Mage/Tag/locale/zh_CN/Mage_Tag.csv diff --git a/app/code/core/Mage/Tag/sql/tag_setup/install-1.6.0.0.php b/app/code/Mage/Tag/sql/tag_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Tag/sql/tag_setup/install-1.6.0.0.php rename to app/code/Mage/Tag/sql/tag_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Tag/view/adminhtml/customer.xml b/app/code/Mage/Tag/view/adminhtml/customer.xml similarity index 100% rename from app/code/core/Mage/Tag/view/adminhtml/customer.xml rename to app/code/Mage/Tag/view/adminhtml/customer.xml diff --git a/app/code/core/Mage/Tag/view/adminhtml/product.xml b/app/code/Mage/Tag/view/adminhtml/product.xml similarity index 100% rename from app/code/core/Mage/Tag/view/adminhtml/product.xml rename to app/code/Mage/Tag/view/adminhtml/product.xml diff --git a/app/code/core/Mage/Tag/view/adminhtml/report.xml b/app/code/Mage/Tag/view/adminhtml/report.xml similarity index 93% rename from app/code/core/Mage/Tag/view/adminhtml/report.xml rename to app/code/Mage/Tag/view/adminhtml/report.xml index a835baa784069..443d7873ba96a 100644 --- a/app/code/core/Mage/Tag/view/adminhtml/report.xml +++ b/app/code/Mage/Tag/view/adminhtml/report.xml @@ -80,37 +80,38 @@
    ID
    - 50px - right entity_id + col-id + col-id
    Product Name
    name + col-product + col-product
    Number of Unique Tags
    - 50px - right utaged + col-unique-numbers + col-unique-numbers
    Number of Total Tags
    - 50px - right taged + col-total-numbers + col-total-numbers
    Action
    - 100% action getId stores @@ -126,6 +127,8 @@ id + col-actions + col-actions
    @@ -260,34 +263,37 @@
    ID
    entity_id - right - 50px + col-id + col-id
    First Name
    firstname + col-first-name + col-first-name
    Last Name
    lastname + col-last-name + col-last-name
    Total Tags
    taged - 50px - right + col-qty + col-qty
    Action
    - 100% action getId stores @@ -303,6 +309,8 @@ id + col-actions + col-actions
    diff --git a/app/code/core/Mage/Tag/view/adminhtml/tag.xml b/app/code/Mage/Tag/view/adminhtml/tag.xml similarity index 100% rename from app/code/core/Mage/Tag/view/adminhtml/tag.xml rename to app/code/Mage/Tag/view/adminhtml/tag.xml diff --git a/app/code/Mage/Tag/view/adminhtml/tag/edit/container.phtml b/app/code/Mage/Tag/view/adminhtml/tag/edit/container.phtml new file mode 100644 index 0000000000000..14d7db654e674 --- /dev/null +++ b/app/code/Mage/Tag/view/adminhtml/tag/edit/container.phtml @@ -0,0 +1,52 @@ + +
    + getFormInitScripts() ?> +
    + getButtonsHtml('header') ?> +
    + isSingleStoreMode() ): ?> + getStoreSwitcherHtml() ?> + +
    + +
    + getFormHtml() ?> + getTagAssignAccordionHtml() ?> +
    + +hasFooterButtons()): ?> + + + +getFormScripts() ?> +getAcordionsHtml() ?> diff --git a/app/code/core/Mage/Tag/view/adminhtml/tag/index.phtml b/app/code/Mage/Tag/view/adminhtml/tag/index.phtml similarity index 100% rename from app/code/core/Mage/Tag/view/adminhtml/tag/index.phtml rename to app/code/Mage/Tag/view/adminhtml/tag/index.phtml diff --git a/app/code/core/Mage/Tag/view/frontend/cloud.phtml b/app/code/Mage/Tag/view/frontend/cloud.phtml similarity index 100% rename from app/code/core/Mage/Tag/view/frontend/cloud.phtml rename to app/code/Mage/Tag/view/frontend/cloud.phtml diff --git a/app/code/core/Mage/Tag/view/frontend/customer/recent.phtml b/app/code/Mage/Tag/view/frontend/customer/recent.phtml similarity index 100% rename from app/code/core/Mage/Tag/view/frontend/customer/recent.phtml rename to app/code/Mage/Tag/view/frontend/customer/recent.phtml diff --git a/app/code/core/Mage/Tag/view/frontend/customer/tags.phtml b/app/code/Mage/Tag/view/frontend/customer/tags.phtml similarity index 100% rename from app/code/core/Mage/Tag/view/frontend/customer/tags.phtml rename to app/code/Mage/Tag/view/frontend/customer/tags.phtml diff --git a/app/code/core/Mage/Tag/view/frontend/customer/view.phtml b/app/code/Mage/Tag/view/frontend/customer/view.phtml similarity index 100% rename from app/code/core/Mage/Tag/view/frontend/customer/view.phtml rename to app/code/Mage/Tag/view/frontend/customer/view.phtml diff --git a/app/code/core/Mage/Tag/view/frontend/layout.xml b/app/code/Mage/Tag/view/frontend/layout.xml similarity index 100% rename from app/code/core/Mage/Tag/view/frontend/layout.xml rename to app/code/Mage/Tag/view/frontend/layout.xml diff --git a/app/code/core/Mage/Tag/view/frontend/list.phtml b/app/code/Mage/Tag/view/frontend/list.phtml similarity index 100% rename from app/code/core/Mage/Tag/view/frontend/list.phtml rename to app/code/Mage/Tag/view/frontend/list.phtml diff --git a/app/code/core/Mage/Tag/view/frontend/popular.phtml b/app/code/Mage/Tag/view/frontend/popular.phtml similarity index 100% rename from app/code/core/Mage/Tag/view/frontend/popular.phtml rename to app/code/Mage/Tag/view/frontend/popular.phtml diff --git a/app/code/core/Mage/Tag/view/frontend/product/rss/link.phtml b/app/code/Mage/Tag/view/frontend/product/rss/link.phtml similarity index 100% rename from app/code/core/Mage/Tag/view/frontend/product/rss/link.phtml rename to app/code/Mage/Tag/view/frontend/product/rss/link.phtml diff --git a/app/code/core/Mage/Tag/view/frontend/rss.xml b/app/code/Mage/Tag/view/frontend/rss.xml similarity index 100% rename from app/code/core/Mage/Tag/view/frontend/rss.xml rename to app/code/Mage/Tag/view/frontend/rss.xml diff --git a/app/code/core/Mage/Tax/Block/Adminhtml/Frontend/Region/Updater.php b/app/code/Mage/Tax/Block/Adminhtml/Frontend/Region/Updater.php similarity index 100% rename from app/code/core/Mage/Tax/Block/Adminhtml/Frontend/Region/Updater.php rename to app/code/Mage/Tax/Block/Adminhtml/Frontend/Region/Updater.php diff --git a/app/code/core/Mage/Tax/Block/Checkout/Discount.php b/app/code/Mage/Tax/Block/Checkout/Discount.php similarity index 100% rename from app/code/core/Mage/Tax/Block/Checkout/Discount.php rename to app/code/Mage/Tax/Block/Checkout/Discount.php diff --git a/app/code/core/Mage/Tax/Block/Checkout/Grandtotal.php b/app/code/Mage/Tax/Block/Checkout/Grandtotal.php similarity index 100% rename from app/code/core/Mage/Tax/Block/Checkout/Grandtotal.php rename to app/code/Mage/Tax/Block/Checkout/Grandtotal.php diff --git a/app/code/core/Mage/Tax/Block/Checkout/Shipping.php b/app/code/Mage/Tax/Block/Checkout/Shipping.php similarity index 100% rename from app/code/core/Mage/Tax/Block/Checkout/Shipping.php rename to app/code/Mage/Tax/Block/Checkout/Shipping.php diff --git a/app/code/core/Mage/Tax/Block/Checkout/Subtotal.php b/app/code/Mage/Tax/Block/Checkout/Subtotal.php similarity index 100% rename from app/code/core/Mage/Tax/Block/Checkout/Subtotal.php rename to app/code/Mage/Tax/Block/Checkout/Subtotal.php diff --git a/app/code/core/Mage/Tax/Block/Checkout/Tax.php b/app/code/Mage/Tax/Block/Checkout/Tax.php similarity index 100% rename from app/code/core/Mage/Tax/Block/Checkout/Tax.php rename to app/code/Mage/Tax/Block/Checkout/Tax.php diff --git a/app/code/core/Mage/Tax/Block/Sales/Order/Tax.php b/app/code/Mage/Tax/Block/Sales/Order/Tax.php similarity index 100% rename from app/code/core/Mage/Tax/Block/Sales/Order/Tax.php rename to app/code/Mage/Tax/Block/Sales/Order/Tax.php diff --git a/app/code/core/Mage/Tax/Exception.php b/app/code/Mage/Tax/Exception.php similarity index 100% rename from app/code/core/Mage/Tax/Exception.php rename to app/code/Mage/Tax/Exception.php diff --git a/app/code/Mage/Tax/Helper/Data.php b/app/code/Mage/Tax/Helper/Data.php new file mode 100644 index 0000000000000..e5bed64d07292 --- /dev/null +++ b/app/code/Mage/Tax/Helper/Data.php @@ -0,0 +1,906 @@ +_config = $taxConfig; + } + + /** + * Return max postcode length to create search templates + * + * @return integer $len + */ + public function getPostCodeSubStringLength() + { + $len = (int)$this->_postCodeSubStringLength; + if ($len <= 0) { + $len = 10; + } + return $len; + } + + /** + * Get tax configuration object + * + * @return Mage_Tax_Model_Config + */ + public function getConfig() + { + return $this->_config; + } + + /** + * Get tax calculation object + * + * @return Mage_Tac_Model_Calculation + */ + public function getCalculator() + { + if ($this->_calculator === null) { + $this->_calculator = Mage::getSingleton('Mage_Tax_Model_Calculation'); + } + return $this->_calculator; + } + + /** + * Get product price including store convertion rate + * + * @param Mage_Catalog_Model_Product $product + * @param null|string $format + * @return float|string + */ + public function getProductPrice($product, $format=null) + { + try { + $value = $product->getPrice(); + $value = Mage::app()->getStore()->convertPrice($value, $format); + } catch (Exception $e){ + $value = $e->getMessage(); + } + return $value; + } + + /** + * Check if product prices inputed include tax + * + * @param mix $store + * @return bool + */ + public function priceIncludesTax($store=null) + { + return $this->_config->priceIncludesTax($store) || $this->_config->getNeedUseShippingExcludeTax(); + } + + /** + * Check what taxes should be applied after discount + * + * @param mixed $store + * @return bool + */ + public function applyTaxAfterDiscount($store=null) + { + return $this->_config->applyTaxAfterDiscount($store); + } + + /** + * Output + * + * @param boolean $includes + */ + public function getIncExcText($flag, $store=null) + { + if ($flag) { + $s = $this->__('Incl. Tax'); + } else { + $s = $this->__('Excl. Tax'); + } + return $s; + } + + /** + * Get product price display type + * 1 - Excluding tax + * 2 - Including tax + * 3 - Both + * + * @param mixed $store + * @return int + */ + public function getPriceDisplayType($store = null) + { + return $this->_config->getPriceDisplayType($store); + } + + /** + * Check if necessary do product price conversion + * If it necessary will be returned conversion type (minus or plus) + * + * @param mixed $store + * @return false | int + */ + public function needPriceConversion($store = null) + { + $res = false; + if ($this->priceIncludesTax($store)) { + switch ($this->getPriceDisplayType($store)) { + case Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX: + case Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH: + return self::PRICE_CONVERSION_MINUS; + case Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX: + $res = true; + } + } else { + switch ($this->getPriceDisplayType($store)) { + case Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX: + case Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH: + return self::PRICE_CONVERSION_PLUS; + case Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX: + $res = false; + } + } + + if ($res === false) { + $res = $this->displayTaxColumn($store); + } + return $res; + } + + /** + * Check if need display full tax summary information in totals block + * + * @param mixed $store + * @return bool + */ + public function displayFullSummary($store = null) + { + return $this->_config->displayCartFullSummary($store); + } + + /** + * Check if need display zero tax in subtotal + * + * @param mixed $store + * @return bool + */ + public function displayZeroTax($store = null) + { + return $this->_config->displayCartZeroTax($store); + } + + /** + * Check if need display cart prices included tax + * + * @param mixed $store + * @return bool + */ + public function displayCartPriceInclTax($store = null) + { + return $this->_config->displayCartPricesInclTax($store); + } + + /** + * Check if need display cart prices excluding price + * + * @param mixed $store + * @return bool + */ + public function displayCartPriceExclTax($store = null) + { + return $this->_config->displayCartPricesExclTax($store); + } + + /** + * Check if need display cart prices excluding and including tax + * + * @param mixed $store + * @return bool + */ + public function displayCartBothPrices($store = null) + { + return $this->_config->displayCartPricesBoth($store); + } + + /** + * Check if need display order prices included tax + * + * @param mixed $store + * @return bool + */ + public function displaySalesPriceInclTax($store = null) + { + return $this->_config->displaySalesPricesInclTax($store); + } + + /** + * Check if need display order prices excluding price + * + * @param mixed $store + * @return bool + */ + public function displaySalesPriceExclTax($store = null) + { + return $this->_config->displaySalesPricesExclTax($store); + } + + /** + * Check if need display order prices excluding and including tax + * + * @param mixed $store + * @return bool + */ + public function displaySalesBothPrices($store = null) + { + return $this->_config->displaySalesPricesBoth($store); + } + + + /** + * Check if we need display price include and exclude tax for order/invoice subtotal + * + * @param mixed $store + * @return bool + */ + public function displaySalesSubtotalBoth($store = null) + { + return $this->_config->displaySalesSubtotalBoth($store); + } + + /** + * Check if we need display price include tax for order/invoice subtotal + * + * @param mixed $store + * @return bool + */ + public function displaySalesSubtotalInclTax($store = null) + { + return $this->_config->displaySalesSubtotalInclTax($store); + } + + /** + * Check if we need display price exclude tax for order/invoice subtotal + * + * @param mixed $store + * @return bool + */ + public function displaySalesSubtotalExclTax($store = null) + { + return $this->_config->displaySalesSubtotalExclTax($store); + } + + /** + * Check if need display tax column in for shopping cart/order items + * + * @param mixed $store + * @return bool + */ + public function displayTaxColumn($store = null) + { + return $this->_config->displayCartPricesBoth(); + } + + /** + * Get prices javascript format json + * + * @param mixed $store + * @return string + */ + public function getPriceFormat($store = null) + { + Mage::app()->getLocale()->emulate($store); + $priceFormat = Mage::app()->getLocale()->getJsPriceFormat(); + Mage::app()->getLocale()->revert(); + if ($store) { + $priceFormat['pattern'] = Mage::app()->getStore($store)->getCurrentCurrency()->getOutputFormat(); + } + return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($priceFormat); + } + + /** + * Get all tax rates JSON for all product tax classes of specific store + * + * array( + * value_{$productTaxVlassId} => $rate + * ) + * @return string + */ + public function getAllRatesByProductClass($store=null) + { + return $this->_getAllRatesByProductClass($store); + } + + + /** + * Get all tax rates JSON for all product tax classes of specific store + * + * array( + * value_{$productTaxVlassId} => $rate + * ) + * @return string + */ + protected function _getAllRatesByProductClass($store=null) + { + $result = array(); + $calc = Mage::getSingleton('Mage_Tax_Model_Calculation'); + $rates = $calc->getRatesForAllProductTaxClasses($calc->getRateOriginRequest($store)); + + foreach ($rates as $class=>$rate) { + $result["value_{$class}"] = $rate; + } + + return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($result); + } + + /** + * Get product price with all tax settings processing + * + * @param Mage_Catalog_Model_Product $product + * @param float $price inputed product price + * @param bool $includingTax return price include tax flag + * @param null|Mage_Customer_Model_Address $shippingAddress + * @param null|Mage_Customer_Model_Address $billingAddress + * @param null|int $ctc customer tax class + * @param mixed $store + * @param bool $priceIncludesTax flag what price parameter contain tax + * @return float + */ + public function getPrice($product, $price, $includingTax = null, $shippingAddress = null, $billingAddress = null, + $ctc = null, $store = null, $priceIncludesTax = null + ) { + if (!$price) { + return $price; + } + $store = Mage::app()->getStore($store); + if (!$this->needPriceConversion($store)) { + return $store->roundPrice($price); + } + if (is_null($priceIncludesTax)) { + $priceIncludesTax = $this->priceIncludesTax($store); + } + + $percent = $product->getTaxPercent(); + $includingPercent = null; + + $taxClassId = $product->getTaxClassId(); + if (is_null($percent)) { + if ($taxClassId) { + $request = Mage::getSingleton('Mage_Tax_Model_Calculation') + ->getRateRequest($shippingAddress, $billingAddress, $ctc, $store); + $percent = Mage::getSingleton('Mage_Tax_Model_Calculation') + ->getRate($request->setProductClassId($taxClassId)); + } + } + if ($taxClassId && $priceIncludesTax) { + $request = Mage::getSingleton('Mage_Tax_Model_Calculation')->getRateRequest(false, false, false, $store); + $includingPercent = Mage::getSingleton('Mage_Tax_Model_Calculation') + ->getRate($request->setProductClassId($taxClassId)); + } + + if ($percent === false || is_null($percent)) { + if ($priceIncludesTax && !$includingPercent) { + return $price; + } + } + + $product->setTaxPercent($percent); + + if (!is_null($includingTax)) { + if ($priceIncludesTax) { + if ($includingTax) { + /** + * Recalculate price include tax in case of different rates + */ + if ($includingPercent != $percent) { + $price = $this->_calculatePrice($price, $includingPercent, false); + /** + * Using regular rounding. Ex: + * price incl tax = 52.76 + * store tax rate = 19.6% + * customer tax rate= 19% + * + * price excl tax = 52.76 / 1.196 = 44.11371237 ~ 44.11 + * tax = 44.11371237 * 0.19 = 8.381605351 ~ 8.38 + * price incl tax = 52.49531773 ~ 52.50 != 52.49 + * + * that why we need round prices excluding tax before applying tax + * this calculation is used for showing prices on catalog pages + */ + if ($percent != 0) { + $price = $this->getCalculator()->round($price); + $price = $this->_calculatePrice($price, $percent, true); + } + } + } else { + $price = $this->_calculatePrice($price, $includingPercent, false); + } + } else { + if ($includingTax) { + $price = $this->_calculatePrice($price, $percent, true); + } + } + } else { + if ($priceIncludesTax) { + switch ($this->getPriceDisplayType($store)) { + case Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX: + case Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH: + $price = $this->_calculatePrice($price, $includingPercent, false); + break; + + case Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX: + $price = $this->_calculatePrice($price, $includingPercent, false); + $price = $this->_calculatePrice($price, $percent, true); + break; + } + } else { + switch ($this->getPriceDisplayType($store)) { + case Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX: + $price = $this->_calculatePrice($price, $percent, true); + break; + + case Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH: + case Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX: + break; + } + } + } + return $store->roundPrice($price); + } + + /** + * Check if we have display in catalog prices including tax + * + * @return bool + */ + public function displayPriceIncludingTax() + { + return $this->getPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX; + } + + /** + * Check if we have display in catalog prices excluding tax + * + * @return bool + */ + public function displayPriceExcludingTax() + { + return $this->getPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX; + } + + /** + * Check if we have display in catalog prices including and excluding tax + * + * @return bool + */ + public function displayBothPrices() + { + return $this->getPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH; + } + + /** + * Calculate price imcluding/excluding tax base on tax rate percent + * + * @param float $price + * @param float $percent + * @param bool $type true - for calculate price including tax and false if price excluding tax + * @return float + */ + protected function _calculatePrice($price, $percent, $type) + { + $calculator = Mage::getSingleton('Mage_Tax_Model_Calculation'); + if ($type) { + $taxAmount = $calculator->calcTaxAmount($price, $percent, false, false); + return $price + $taxAmount; + } else { + $taxAmount = $calculator->calcTaxAmount($price, $percent, true, false); + return $price - $taxAmount; + } + } + + public function getIncExcTaxLabel($flag) + { + $text = $this->getIncExcText($flag); + return $text ? ' ('.$text.')' : ''; + } + + public function shippingPriceIncludesTax($store = null) + { + return $this->_config->shippingPriceIncludesTax($store); + } + + public function getShippingPriceDisplayType($store = null) + { + return $this->_config->getShippingPriceDisplayType($store); + } + + public function displayShippingPriceIncludingTax() + { + return $this->getShippingPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX; + } + + public function displayShippingPriceExcludingTax() + { + return $this->getShippingPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX; + } + + public function displayShippingBothPrices() + { + return $this->getShippingPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH; + } + + public function getShippingTaxClass($store) + { + return $this->_config->getShippingTaxClass($store); + } + + /** + * Get shipping price + * + * @return float + */ + public function getShippingPrice($price, $includingTax = null, $shippingAddress = null, $ctc = null, $store = null) + { + $pseudoProduct = new Varien_Object(); + $pseudoProduct->setTaxClassId($this->getShippingTaxClass($store)); + + $billingAddress = false; + if ($shippingAddress && $shippingAddress->getQuote() && $shippingAddress->getQuote()->getBillingAddress()) { + $billingAddress = $shippingAddress->getQuote()->getBillingAddress(); + } + + $price = $this->getPrice( + $pseudoProduct, + $price, + $includingTax, + $shippingAddress, + $billingAddress, + $ctc, + $store, + $this->shippingPriceIncludesTax($store) + ); + return $price; + } + + public function getPriceTaxSql($priceField, $taxClassField) + { + if (!$this->priceIncludesTax() && $this->displayPriceExcludingTax()) { + return ''; + } + + $request = Mage::getSingleton('Mage_Tax_Model_Calculation')->getRateRequest(false, false, false); + $defaultTaxes = Mage::getSingleton('Mage_Tax_Model_Calculation')->getRatesForAllProductTaxClasses($request); + + $request = Mage::getSingleton('Mage_Tax_Model_Calculation')->getRateRequest(); + $currentTaxes = Mage::getSingleton('Mage_Tax_Model_Calculation')->getRatesForAllProductTaxClasses($request); + + $defaultTaxString = $currentTaxString = ''; + + $rateToVariable = array( + 'defaultTaxString'=>'defaultTaxes', + 'currentTaxString'=>'currentTaxes', + ); + foreach ($rateToVariable as $rateVariable=>$rateArray) { + if ($$rateArray && is_array($$rateArray)) { + $$rateVariable = ''; + foreach ($$rateArray as $classId=>$rate) { + if ($rate) { + $$rateVariable .= sprintf("WHEN %d THEN %12.4f ", $classId, $rate/100); + } + } + if ($$rateVariable) { + $$rateVariable = "CASE {$taxClassField} {$$rateVariable} ELSE 0 END"; + } + } + } + + $result = ''; + + if ($this->priceIncludesTax()) { + if ($defaultTaxString) { + $result = "-({$priceField}/(1+({$defaultTaxString}))*{$defaultTaxString})"; + } + if (!$this->displayPriceExcludingTax() && $currentTaxString) { + $result .= "+(({$priceField}{$result})*{$currentTaxString})"; + } + } else { + if ($this->displayPriceIncludingTax()) { + if ($currentTaxString) { + $result .= "+({$priceField}*{$currentTaxString})"; + } + } + } + return $result; + } + + /** + * Join tax class + * @param Varien_Db_Select $select + * @param int $storeId + * @param string $priceTable + * @return Mage_Tax_Helper_Data + */ + public function joinTaxClass($select, $storeId, $priceTable = 'main_table') + { + $taxClassAttribute = Mage::getModel('Mage_Eav_Model_Entity_Attribute') + ->loadByCode(Mage_Catalog_Model_Product::ENTITY, 'tax_class_id'); + $joinConditionD = implode(' AND ',array( + "tax_class_d.entity_id = {$priceTable}.entity_id", + $select->getAdapter()->quoteInto('tax_class_d.attribute_id = ?', (int)$taxClassAttribute->getId()), + 'tax_class_d.store_id = 0' + )); + $joinConditionC = implode(' AND ',array( + "tax_class_c.entity_id = {$priceTable}.entity_id", + $select->getAdapter()->quoteInto('tax_class_c.attribute_id = ?', (int)$taxClassAttribute->getId()), + $select->getAdapter()->quoteInto('tax_class_c.store_id = ?', (int)$storeId) + )); + $select + ->joinLeft( + array('tax_class_d' => $taxClassAttribute->getBackend()->getTable()), + $joinConditionD, + array()) + ->joinLeft( + array('tax_class_c' => $taxClassAttribute->getBackend()->getTable()), + $joinConditionC, + array()); + + return $this; + } + + /** + * Get configuration setting "Apply Discount On Prices Including Tax" value + * + * @param null|int $store + * @return 0|1 + */ + public function discountTax($store=null) + { + return $this->_config->discountTax($store); + } + + /** + * Get value of "Apply Tax On" custom/original price configuration settings + * + * @param $store + * @return 0|1 + */ + public function getTaxBasedOn($store = null) + { + return Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_BASED_ON, $store); + } + + /** + * Check if tax can be applied to custom price + * + * @param $store + * @return bool + */ + public function applyTaxOnCustomPrice($store = null) + { + return ((int) Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_APPLY_ON, $store) == 0); + } + + /** + * Check if tax should be applied just to original price + * + * @param $store + * @return bool + */ + public function applyTaxOnOriginalPrice($store = null) + { + return ((int) Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_APPLY_ON, $store) == 1); + } + + /** + * Get taxes/discounts calculation sequence. + * This sequence depends on "Catalog price include tax", "Apply Tax After Discount" + * and "Apply Discount On Prices Including Tax" configuration options. + * + * @param null|int|string|Mage_Core_Model_Store $store + * @return string + */ + public function getCalculationSequence($store=null) + { + return $this->_config->getCalculationSequence($store); + } + + /** + * Get tax caclulation algorithm code + * + * @param null|int $store + * @return string + */ + public function getCalculationAgorithm($store=null) + { + return $this->_config->getAlgorithm($store); + } + + /** + * Get calculated taxes for each tax class + * + * This method returns array with format: + * array( + * $index => array( + * 'tax_amount' => $taxAmount, + * 'base_tax_amount' => $baseTaxAmount, + * 'hidden_tax_amount' => $hiddenTaxAmount + * 'title' => $title + * 'percent' => $percent + * ) + * ) + * + * @param Mage_Sales_Model_Order $source + * @return array + */ + public function getCalculatedTaxes($source) + { + if (Mage::registry('current_invoice')) { + $current = Mage::registry('current_invoice'); + } elseif (Mage::registry('current_creditmemo')) { + $current = Mage::registry('current_creditmemo'); + } else { + $current = $source; + } + + $taxClassAmount = array(); + if ($current && $source) { + foreach($current->getItemsCollection() as $item) { + $taxCollection = Mage::getResourceModel('Mage_Tax_Model_Resource_Sales_Order_Tax_Item') + ->getTaxItemsByItemId( + $item->getOrderItemId() ? $item->getOrderItemId() : $item->getItemId() + ); + + foreach ($taxCollection as $tax) { + $taxClassId = $tax['tax_id']; + $percent = $tax['tax_percent']; + + $price = $item->getRowTotal(); + $basePrice = $item->getBaseRowTotal(); + if ($this->applyTaxAfterDiscount($item->getStoreId())) { + $price = $price - $item->getDiscountAmount() + $item->getHiddenTaxAmount(); + $basePrice = $basePrice - $item->getBaseDiscountAmount() + $item->getBaseHiddenTaxAmount(); + } + + if (isset($taxClassAmount[$taxClassId])) { + $taxClassAmount[$taxClassId]['tax_amount'] += $price * $percent / 100; + $taxClassAmount[$taxClassId]['base_tax_amount'] += $basePrice * $percent / 100; + } else { + $taxClassAmount[$taxClassId]['tax_amount'] = $price * $percent / 100; + $taxClassAmount[$taxClassId]['base_tax_amount'] = $basePrice * $percent / 100; + $taxClassAmount[$taxClassId]['title'] = $tax['title']; + $taxClassAmount[$taxClassId]['percent'] = $tax['percent']; + } + } + } + + foreach ($taxClassAmount as $key=>$tax) { + if ($tax['tax_amount'] == 0 && $tax['base_tax_amount'] == 0) { + unset($taxClassAmount[$key]); + } + } + + $taxClassAmount = array_values($taxClassAmount); + } + + return $taxClassAmount; + } + + /** + * Get calculated Shipping & Handling Tax + * + * This method returns array with format: + * array( + * $index => array( + * 'tax_amount' => $taxAmount, + * 'base_tax_amount' => $baseTaxAmount, + * 'hidden_tax_amount' => $hiddenTaxAmount + * 'title' => $title + * 'percent' => $percent + * ) + * ) + * + * @param Mage_Sales_Model_Order $source + * @return array + */ + public function getShippingTax($source) + { + if (Mage::registry('current_invoice')) { + $current = Mage::registry('current_invoice'); + } elseif (Mage::registry('current_creditmemo')) { + $current = Mage::registry('current_creditmemo'); + } else { + $current = $source; + } + + $taxClassAmount = array(); + if ($current && $source) { + if ($current->getShippingTaxAmount() != 0 && $current->getBaseShippingTaxAmount() != 0) { + $taxClassAmount[0]['tax_amount'] = $current->getShippingTaxAmount(); + $taxClassAmount[0]['base_tax_amount'] = $current->getBaseShippingTaxAmount(); + if ($current->getShippingHiddenTaxAmount() > 0) { + $taxClassAmount[0]['hidden_tax_amount'] = $current->getShippingHiddenTaxAmount(); + } + $taxClassAmount[0]['title'] = $this->__('Shipping & Handling Tax'); + $taxClassAmount[0]['percent'] = NULL; + } + } + + return $taxClassAmount; + } + + /** + * Retrieve default customer tax class from config + */ + public function getDefaultCustomerTaxClass() + { + return Mage::getStoreConfig(self::CONFIG_DEFAULT_CUSTOMER_TAX_CLASS); + } + + /** + * Retrieve default product tax class from config + */ + public function getDefaultProductTaxClass() + { + return Mage::getStoreConfig(self::CONFIG_DEFAULT_PRODUCT_TAX_CLASS); + } + +} diff --git a/app/code/core/Mage/Tax/Model/Calculation.php b/app/code/Mage/Tax/Model/Calculation.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Calculation.php rename to app/code/Mage/Tax/Model/Calculation.php diff --git a/app/code/core/Mage/Tax/Model/Calculation/Rate.php b/app/code/Mage/Tax/Model/Calculation/Rate.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Calculation/Rate.php rename to app/code/Mage/Tax/Model/Calculation/Rate.php diff --git a/app/code/core/Mage/Tax/Model/Calculation/Rate/Title.php b/app/code/Mage/Tax/Model/Calculation/Rate/Title.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Calculation/Rate/Title.php rename to app/code/Mage/Tax/Model/Calculation/Rate/Title.php diff --git a/app/code/Mage/Tax/Model/Calculation/RateFactory.php b/app/code/Mage/Tax/Model/Calculation/RateFactory.php new file mode 100644 index 0000000000000..24b07c8f91c46 --- /dev/null +++ b/app/code/Mage/Tax/Model/Calculation/RateFactory.php @@ -0,0 +1,59 @@ + + */ +class Mage_Tax_Model_Calculation_RateFactory +{ + /** + * @var Magento_ObjectManager + */ + protected $_objectManager; + + /** + * @param Magento_ObjectManager $objectManager + */ + public function __construct(Magento_ObjectManager $objectManager) + { + $this->_objectManager = $objectManager; + } + + /** + * Create new tax rate model + * + * @param array $arguments + * @return Mage_Tax_Model_Calculation_Rate + */ + public function create(array $arguments = array()) + { + return $this->_objectManager->create('Mage_Tax_Model_Calculation_Rate', $arguments); + } +} diff --git a/app/code/Mage/Tax/Model/Calculation/Rule.php b/app/code/Mage/Tax/Model/Calculation/Rule.php new file mode 100644 index 0000000000000..7ab4739e73134 --- /dev/null +++ b/app/code/Mage/Tax/Model/Calculation/Rule.php @@ -0,0 +1,233 @@ + + */ +class Mage_Tax_Model_Calculation_Rule extends Mage_Core_Model_Abstract +{ + protected $_ctcs = null; + protected $_ptcs = null; + protected $_rates = null; + + protected $_ctcModel = null; + protected $_ptcModel = null; + protected $_rateModel = null; + + protected $_calculationModel = null; + + /** + * Prefix of model events names + * + * @var string + */ + protected $_eventPrefix = 'tax_rule'; + + /** + * Helper + * + * @var Mage_Tax_Helper_Data + */ + protected $_helper; + + /** + * Tax Model Class + * + * @var Mage_Tax_Model_Class + */ + protected $_taxClass; + + /** + * @param Mage_Core_Model_Context $context + * @param Mage_Tax_Helper_Data $taxHelper + * @param Mage_Tax_Model_Class $taxClass + * @param Mage_Core_Model_Resource_Abstract $resource + * @param Varien_Data_Collection_Db $resourceCollection + * @param array $data + */ + public function __construct( + Mage_Core_Model_Context $context, + Mage_Tax_Helper_Data $taxHelper, + Mage_Tax_Model_Class $taxClass, + Mage_Core_Model_Resource_Abstract $resource = null, + Varien_Data_Collection_Db $resourceCollection = null, + array $data = array() + ) { + parent::__construct( + $context, + $resource, + $resourceCollection, + $data + ); + + $this->_init('Mage_Tax_Model_Resource_Calculation_Rule'); + + $this->_helper = $taxHelper; + $this->_taxClass = $taxClass; + } + + /** + * After save rule + * Redeclared for populate rate calculations + * + * @return Mage_Tax_Model_Calculation_Rule + */ + protected function _afterSave() + { + parent::_afterSave(); + $this->saveCalculationData(); + Mage::dispatchEvent('tax_settings_change_after'); + return $this; + } + + /** + * After rule delete + * redeclared for dispatch tax_settings_change_after event + * + * @return Mage_Tax_Model_Calculation_Rule + */ + protected function _afterDelete() + { + Mage::dispatchEvent('tax_settings_change_after'); + return parent::_afterDelete(); + } + + public function saveCalculationData() + { + $ctc = $this->getData('tax_customer_class'); + $ptc = $this->getData('tax_product_class'); + $rates = $this->getData('tax_rate'); + + Mage::getSingleton('Mage_Tax_Model_Calculation')->deleteByRuleId($this->getId()); + foreach ($ctc as $c) { + foreach ($ptc as $p) { + foreach ($rates as $r) { + $dataArray = array( + 'tax_calculation_rule_id' =>$this->getId(), + 'tax_calculation_rate_id' =>$r, + 'customer_tax_class_id' =>$c, + 'product_tax_class_id' =>$p, + ); + Mage::getSingleton('Mage_Tax_Model_Calculation')->setData($dataArray)->save(); + } + } + } + } + + public function getCalculationModel() + { + if (is_null($this->_calculationModel)) { + $this->_calculationModel = Mage::getSingleton('Mage_Tax_Model_Calculation'); + } + return $this->_calculationModel; + } + + public function getRates() + { + return $this->getCalculationModel()->getRates($this->getId()); + } + + public function getCustomerTaxClasses() + { + return $this->getCalculationModel()->getCustomerTaxClasses($this->getId()); + } + + public function getProductTaxClasses() + { + return $this->getCalculationModel()->getProductTaxClasses($this->getId()); + } + + /** + * Check Customer Tax Class and if it is empty - use defaults + * + * @return int|array|null + */ + public function getCustomerTaxClassWithDefault() + { + $customerClasses = $this->getAllOptionsForClass(Mage_Tax_Model_Class::TAX_CLASS_TYPE_CUSTOMER); + if (empty($customerClasses)) { + return null; + } + + $configValue = $this->_helper->getDefaultCustomerTaxClass(); + if (!empty($configValue)) { + return $configValue; + } + + $firstClass = array_shift($customerClasses); + return isset($firstClass['value']) ? $firstClass['value'] : null; + } + + /** + * Check Product Tax Class and if it is empty - use defaults + * + * @return int|array|null + */ + public function getProductTaxClassWithDefault() + { + $productClasses = $this->getAllOptionsForClass(Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT); + if (empty($productClasses)) { + return null; + } + + $configValue = $this->_helper->getDefaultProductTaxClass(); + if (!empty($configValue)) { + return $configValue; + } + + $firstClass = array_shift($productClasses); + return isset($firstClass['value']) ? $firstClass['value'] : null; + } + + /** + * Get all possible options for specified class name (customer|product) + * + * @param string $classFilter + * @return array + */ + public function getAllOptionsForClass($classFilter) { + $classes = $this->_taxClass + ->getCollection() + ->setClassTypeFilter($classFilter) + ->toOptionArray(); + + return $classes; + } +} + diff --git a/app/code/core/Mage/Tax/Model/Class.php b/app/code/Mage/Tax/Model/Class.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Class.php rename to app/code/Mage/Tax/Model/Class.php diff --git a/app/code/core/Mage/Tax/Model/Class/Source/Customer.php b/app/code/Mage/Tax/Model/Class/Source/Customer.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Class/Source/Customer.php rename to app/code/Mage/Tax/Model/Class/Source/Customer.php diff --git a/app/code/Mage/Tax/Model/Class/Source/Product.php b/app/code/Mage/Tax/Model/Class/Source/Product.php new file mode 100644 index 0000000000000..a7f316edaf6be --- /dev/null +++ b/app/code/Mage/Tax/Model/Class/Source/Product.php @@ -0,0 +1,114 @@ +_options)) { + $this->_options = Mage::getResourceModel('Mage_Tax_Model_Resource_Class_Collection') + ->addFieldToFilter('class_type', Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT) + ->load() + ->toOptionArray(); + } + + $options = $this->_options; + array_unshift($options, array('value' => '0', 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('None'))); + return $options; + } + + /** + * Get a text for option value + * + * @param string|integer $value + * @return string + */ + public function getOptionText($value) + { + $options = $this->getAllOptions(false); + + foreach ($options as $item) { + if ($item['value'] == $value) { + return $item['label']; + } + } + return false; + } + + /** + * Convert to options array + * + * @return array + */ + public function toOptionArray() + { + return $this->getAllOptions(); + } + + /** + * Retrieve flat column definition + * + * @return array + */ + public function getFlatColums() + { + $attributeCode = $this->getAttribute()->getAttributeCode(); + $column = array( + 'unsigned' => true, + 'default' => null, + 'extra' => null + ); + + if (Mage::helper('Mage_Core_Helper_Data')->useDbCompatibleMode()) { + $column['type'] = 'int'; + $column['is_null'] = true; + } else { + $column['type'] = Varien_Db_Ddl_Table::TYPE_INTEGER; + $column['nullable'] = true; + $column['comment'] = $attributeCode . ' tax column'; + } + + return array($attributeCode => $column); + } + + /** + * Retrieve Select for update attribute value in flat table + * + * @param int $store + * @return Varien_Db_Select|null + */ + public function getFlatUpdateSelect($store) + { + return Mage::getResourceModel('Mage_Eav_Model_Resource_Entity_Attribute_Option') + ->getFlatUpdateSelect($this->getAttribute(), $store, false); + } +} diff --git a/app/code/core/Mage/Tax/Model/Config.php b/app/code/Mage/Tax/Model/Config.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Config.php rename to app/code/Mage/Tax/Model/Config.php diff --git a/app/code/core/Mage/Tax/Model/Config/Price/Include.php b/app/code/Mage/Tax/Model/Config/Price/Include.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Config/Price/Include.php rename to app/code/Mage/Tax/Model/Config/Price/Include.php diff --git a/app/code/core/Mage/Tax/Model/Config/Source/Apply/On.php b/app/code/Mage/Tax/Model/Config/Source/Apply/On.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Config/Source/Apply/On.php rename to app/code/Mage/Tax/Model/Config/Source/Apply/On.php diff --git a/app/code/core/Mage/Tax/Model/Config/Source/Basedon.php b/app/code/Mage/Tax/Model/Config/Source/Basedon.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Config/Source/Basedon.php rename to app/code/Mage/Tax/Model/Config/Source/Basedon.php diff --git a/app/code/core/Mage/Tax/Model/Config/Source/Catalog.php b/app/code/Mage/Tax/Model/Config/Source/Catalog.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Config/Source/Catalog.php rename to app/code/Mage/Tax/Model/Config/Source/Catalog.php diff --git a/app/code/core/Mage/Tax/Model/Config/Source/Class/Customer.php b/app/code/Mage/Tax/Model/Config/Source/Class/Customer.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Config/Source/Class/Customer.php rename to app/code/Mage/Tax/Model/Config/Source/Class/Customer.php diff --git a/app/code/core/Mage/Tax/Model/Config/Source/Class/Product.php b/app/code/Mage/Tax/Model/Config/Source/Class/Product.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Config/Source/Class/Product.php rename to app/code/Mage/Tax/Model/Config/Source/Class/Product.php diff --git a/app/code/core/Mage/Tax/Model/Observer.php b/app/code/Mage/Tax/Model/Observer.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Observer.php rename to app/code/Mage/Tax/Model/Observer.php diff --git a/app/code/Mage/Tax/Model/Rate/CsvImportHandler.php b/app/code/Mage/Tax/Model/Rate/CsvImportHandler.php new file mode 100644 index 0000000000000..bd5ba6b09b5f7 --- /dev/null +++ b/app/code/Mage/Tax/Model/Rate/CsvImportHandler.php @@ -0,0 +1,323 @@ + + */ +class Mage_Tax_Model_Rate_CsvImportHandler +{ + /** + * Helper factory + * + * @var Mage_Core_Model_Factory_Helper + */ + protected $_helperFactory; + + /** + * Collection of publicly available stores + * + * @var Mage_Core_Model_Resource_Store_Collection + */ + protected $_publicStores; + + /** + * Region collection prototype + * + * The instance is used to retrieve regions based on country code + * + * @var Mage_Directory_Model_Resource_Region_Collection + */ + protected $_regionCollection; + + /** + * Country factory + * + * @var Mage_Directory_Model_CountryFactory + */ + protected $_countryFactory; + + /** + * Tax rate factory + * + * @var Mage_Tax_Model_Calculation_RateFactory + */ + protected $_taxRateFactory; + + /** + * @param Mage_Core_Model_Factory_Helper $helperFactory + * @param Mage_Core_Model_Resource_Store_Collection $storeCollection + * @param Mage_Directory_Model_Resource_Region_Collection $regionCollection + * @param Mage_Directory_Model_CountryFactory $countryFactory + * @param Mage_Tax_Model_Calculation_RateFactory $taxRateFactory + */ + public function __construct( + Mage_Core_Model_Factory_Helper $helperFactory, + Mage_Core_Model_Resource_Store_Collection $storeCollection, + Mage_Directory_Model_Resource_Region_Collection $regionCollection, + Mage_Directory_Model_CountryFactory $countryFactory, + Mage_Tax_Model_Calculation_RateFactory $taxRateFactory + ) { + $this->_helperFactory = $helperFactory; + // prevent admin store from loading + $this->_publicStores = $storeCollection->setLoadDefault(false); + $this->_regionCollection = $regionCollection; + $this->_countryFactory = $countryFactory; + $this->_taxRateFactory = $taxRateFactory; + } + + /** + * Retrieve a list of fields required for CSV file (order is important!) + * + * @return array + */ + public function getRequiredCsvFields() + { + // indexes are specified for clarity, they are used during import + return array( + 0 => $this->_helperFactory->get('Mage_Tax_Helper_Data')->__('Code'), + 1 => $this->_helperFactory->get('Mage_Tax_Helper_Data')->__('Country'), + 2 => $this->_helperFactory->get('Mage_Tax_Helper_Data')->__('State'), + 3 => $this->_helperFactory->get('Mage_Tax_Helper_Data')->__('Zip/Post Code'), + 4 => $this->_helperFactory->get('Mage_Tax_Helper_Data')->__('Rate'), + 5 => $this->_helperFactory->get('Mage_Tax_Helper_Data')->__('Zip/Post is Range'), + 6 => $this->_helperFactory->get('Mage_Tax_Helper_Data')->__('Range From'), + 7 => $this->_helperFactory->get('Mage_Tax_Helper_Data')->__('Range To'), + ); + + } + + /** + * Import Tax Rates from CSV file + * + * @param array $file file info retrieved from $_FILES array + * @throws Mage_Core_Exception + */ + public function importFromCsvFile($file) + { + if (!isset($file['tmp_name'])) { + Mage::throwException('Invalid file upload attempt.'); + } + $csvProcessor = new Varien_File_Csv(); + $ratesRawData = $csvProcessor->getData($file['tmp_name']); + // first row of file represents headers + $fileFields = $ratesRawData[0]; + $validFields = $this->_filterFileFields($fileFields); + $invalidFields = array_diff_key($fileFields, $validFields); + $ratesData = $this->_filterRateData($ratesRawData, $invalidFields, $validFields); + // store cache array is used to quickly retrieve store ID when handling locale-specific tax rate titles + $storesCache = $this->_composeStoreCache($validFields); + $regionsCache = array(); + foreach ($ratesData as $rowIndex => $dataRow) { + // skip headers + if ($rowIndex == 0) { + continue; + } + $regionsCache = $this->_importRate($dataRow, $regionsCache, $storesCache); + } + } + + /** + * Filter file fields (i.e. unset invalid fields) + * + * @param array $fileFields + * @return array filtered fields + */ + protected function _filterFileFields(array $fileFields) + { + $filteredFields = $this->getRequiredCsvFields(); + $requiredFieldsNum = count($this->getRequiredCsvFields()); + $fileFieldsNum = count($fileFields); + + // process title-related fields that are located right after required fields with store code as field name) + for ($index = $requiredFieldsNum; $index < $fileFieldsNum; $index++) { + $titleFieldName = $fileFields[$index]; + if ($this->_isStoreCodeValid($titleFieldName)) { + // if store is still valid, append this field to valid file fields + $filteredFields[$index] = $titleFieldName; + } + } + + return $filteredFields; + } + + /** + * Filter rates data (i.e. unset all invalid fields and check consistency) + * + * @param array $rateRawData + * @param array $invalidFields assoc array of invalid file fields + * @param array $validFields assoc array of valid file fields + * @return array + * @throws Mage_Core_Exception + */ + protected function _filterRateData(array $rateRawData, array $invalidFields, array $validFields) + { + $validFieldsNum = count($validFields); + foreach ($rateRawData as $rowIndex => $dataRow) { + // skip empty rows + if (count($dataRow) <= 1) { + unset($rateRawData[$rowIndex]); + } + // unset invalid fields from data row + foreach ($dataRow as $fieldIndex => $fieldValue) { + if (isset($invalidFields[$fieldIndex])) { + unset($rateRawData[$rowIndex][$fieldIndex]); + } + } + // check if number of fields in row match with number of valid fields + if (count($rateRawData[$rowIndex]) != $validFieldsNum) { + Mage::throwException('Invalid file format.'); + } + } + return $rateRawData; + } + + /** + * Compose stores cache + * + * This cache is used to quickly retrieve store ID when handling locale-specific tax rate titles + * + * @param $validFields list of valid CSV file fields + * @return array + */ + protected function _composeStoreCache($validFields) + { + $storesCache = array(); + $requiredFieldsNum = count($this->getRequiredCsvFields()); + $validFieldsNum = count($validFields); + // title related fields located right after required fields + for ($index = $requiredFieldsNum; $index < $validFieldsNum; $index++) { + foreach ($this->_publicStores as $store) { + $storeCode = $validFields[$index]; + if ($storeCode === $store->getCode()) { + $storesCache[$index] = $store->getId(); + } + } + } + return $storesCache; + } + + /** + * Check if public store with specified code still exists + * + * @param string $storeCode + * @return boolean + */ + protected function _isStoreCodeValid($storeCode) + { + $isStoreCodeValid = false; + foreach ($this->_publicStores as $store) { + if ($storeCode === $store->getCode()) { + $isStoreCodeValid = true; + break; + } + } + return $isStoreCodeValid; + } + + /** + * Import single rate + * + * @param array $rateData + * @param array $regionsCache cache of regions of already used countries (is used to optimize performance) + * @param array $storesCache cache of stores related to tax rate titles + * @return array regions cache populated with regions related to country of imported tax rate + * @throws Mage_Core_Exception + */ + protected function _importRate(array $rateData, array $regionsCache, array $storesCache) + { + // data with index 1 must represent country code + $countryCode = $rateData[1]; + $country = $this->_countryFactory->create()->loadByCode($countryCode, 'iso2_code'); + if (!$country->getId()) { + Mage::throwException('One of the countries has invalid code.'); + } + $regionsCache = $this->_addCountryRegionsToCache($countryCode, $regionsCache); + + // data with index 2 must represent region code + $regionCode = $rateData[2]; + if (!empty($regionsCache[$countryCode][$regionCode])) { + $regionId = ($regionsCache[$countryCode][$regionCode] == '*') + ? 0 + : $regionsCache[$countryCode][$regionCode]; + // data with index 3 must represent postcode + $postCode = (empty($rateData[3]) || $rateData[3] == '*') ? null : $rateData[3]; + $modelData = array( + 'code' => $rateData[0], + 'tax_country_id' => $rateData[1], + 'tax_region_id' => $regionId, + 'tax_postcode' => $postCode, + 'rate' => $rateData[4], + 'zip_is_range' => $rateData[5], + 'zip_from' => $rateData[6], + 'zip_to' => $rateData[7], + ); + + // try to load existing rate + /** @var $rateModel Mage_Tax_Model_Calculation_Rate */ + $rateModel = $this->_taxRateFactory->create()->loadByCode($modelData['code']); + $rateModel->addData($modelData); + + // compose titles list + $rateTitles = array(); + foreach ($storesCache as $fileFieldIndex => $storeId) { + $rateTitles[$storeId] = $rateData[$fileFieldIndex]; + } + + $rateModel->setTitle($rateTitles); + $rateModel->save(); + } + + return $regionsCache; + } + + /** + * Add regions of the given country to regions cache + * + * @param string $countryCode + * @param array $regionsCache + * @return array + */ + protected function _addCountryRegionsToCache($countryCode, array $regionsCache) + { + if (!isset($regionsCache[$countryCode])) { + $regionsCache[$countryCode] = array(); + // add 'All Regions' to the list + $regionsCache[$countryCode]['*'] = '*'; + $regionCollection = clone $this->_regionCollection; + $regionCollection->addCountryFilter($countryCode); + if ($regionCollection->getSize()) { + foreach ($regionCollection as $region) { + $regionsCache[$countryCode][$region->getCode()] = $region->getRegionId(); + } + } + } + return $regionsCache; + } +} diff --git a/app/code/core/Mage/Tax/Model/Resource/Calculation.php b/app/code/Mage/Tax/Model/Resource/Calculation.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tax/Model/Resource/Calculation.php rename to app/code/Mage/Tax/Model/Resource/Calculation.php diff --git a/app/code/core/Mage/Tax/Model/Resource/Calculation/Collection.php b/app/code/Mage/Tax/Model/Resource/Calculation/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tax/Model/Resource/Calculation/Collection.php rename to app/code/Mage/Tax/Model/Resource/Calculation/Collection.php diff --git a/app/code/core/Mage/Tax/Model/Resource/Calculation/Grid/Collection.php b/app/code/Mage/Tax/Model/Resource/Calculation/Grid/Collection.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Resource/Calculation/Grid/Collection.php rename to app/code/Mage/Tax/Model/Resource/Calculation/Grid/Collection.php diff --git a/app/code/core/Mage/Tax/Model/Resource/Calculation/Rate.php b/app/code/Mage/Tax/Model/Resource/Calculation/Rate.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tax/Model/Resource/Calculation/Rate.php rename to app/code/Mage/Tax/Model/Resource/Calculation/Rate.php diff --git a/app/code/core/Mage/Tax/Model/Resource/Calculation/Rate/Collection.php b/app/code/Mage/Tax/Model/Resource/Calculation/Rate/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tax/Model/Resource/Calculation/Rate/Collection.php rename to app/code/Mage/Tax/Model/Resource/Calculation/Rate/Collection.php diff --git a/app/code/core/Mage/Tax/Model/Resource/Calculation/Rate/Title.php b/app/code/Mage/Tax/Model/Resource/Calculation/Rate/Title.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tax/Model/Resource/Calculation/Rate/Title.php rename to app/code/Mage/Tax/Model/Resource/Calculation/Rate/Title.php diff --git a/app/code/core/Mage/Tax/Model/Resource/Calculation/Rate/Title/Collection.php b/app/code/Mage/Tax/Model/Resource/Calculation/Rate/Title/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tax/Model/Resource/Calculation/Rate/Title/Collection.php rename to app/code/Mage/Tax/Model/Resource/Calculation/Rate/Title/Collection.php diff --git a/app/code/core/Mage/Tax/Model/Resource/Calculation/Rule.php b/app/code/Mage/Tax/Model/Resource/Calculation/Rule.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tax/Model/Resource/Calculation/Rule.php rename to app/code/Mage/Tax/Model/Resource/Calculation/Rule.php diff --git a/app/code/core/Mage/Tax/Model/Resource/Calculation/Rule/Collection.php b/app/code/Mage/Tax/Model/Resource/Calculation/Rule/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tax/Model/Resource/Calculation/Rule/Collection.php rename to app/code/Mage/Tax/Model/Resource/Calculation/Rule/Collection.php diff --git a/app/code/core/Mage/Tax/Model/Resource/Class.php b/app/code/Mage/Tax/Model/Resource/Class.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tax/Model/Resource/Class.php rename to app/code/Mage/Tax/Model/Resource/Class.php diff --git a/app/code/core/Mage/Tax/Model/Resource/Class/Collection.php b/app/code/Mage/Tax/Model/Resource/Class/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tax/Model/Resource/Class/Collection.php rename to app/code/Mage/Tax/Model/Resource/Class/Collection.php diff --git a/app/code/core/Mage/Tax/Model/Resource/Report/Collection.php b/app/code/Mage/Tax/Model/Resource/Report/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tax/Model/Resource/Report/Collection.php rename to app/code/Mage/Tax/Model/Resource/Report/Collection.php diff --git a/app/code/core/Mage/Tax/Model/Resource/Report/Tax.php b/app/code/Mage/Tax/Model/Resource/Report/Tax.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tax/Model/Resource/Report/Tax.php rename to app/code/Mage/Tax/Model/Resource/Report/Tax.php diff --git a/app/code/core/Mage/Tax/Model/Resource/Report/Tax/Createdat.php b/app/code/Mage/Tax/Model/Resource/Report/Tax/Createdat.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Resource/Report/Tax/Createdat.php rename to app/code/Mage/Tax/Model/Resource/Report/Tax/Createdat.php diff --git a/app/code/core/Mage/Tax/Model/Resource/Report/Tax/Updatedat.php b/app/code/Mage/Tax/Model/Resource/Report/Tax/Updatedat.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Resource/Report/Tax/Updatedat.php rename to app/code/Mage/Tax/Model/Resource/Report/Tax/Updatedat.php diff --git a/app/code/core/Mage/Tax/Model/Resource/Report/Updatedat/Collection.php b/app/code/Mage/Tax/Model/Resource/Report/Updatedat/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tax/Model/Resource/Report/Updatedat/Collection.php rename to app/code/Mage/Tax/Model/Resource/Report/Updatedat/Collection.php diff --git a/app/code/core/Mage/Tax/Model/Resource/Sales/Order/Tax.php b/app/code/Mage/Tax/Model/Resource/Sales/Order/Tax.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tax/Model/Resource/Sales/Order/Tax.php rename to app/code/Mage/Tax/Model/Resource/Sales/Order/Tax.php diff --git a/app/code/core/Mage/Tax/Model/Resource/Sales/Order/Tax/Collection.php b/app/code/Mage/Tax/Model/Resource/Sales/Order/Tax/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tax/Model/Resource/Sales/Order/Tax/Collection.php rename to app/code/Mage/Tax/Model/Resource/Sales/Order/Tax/Collection.php diff --git a/app/code/core/Mage/Tax/Model/Resource/Sales/Order/Tax/Item.php b/app/code/Mage/Tax/Model/Resource/Sales/Order/Tax/Item.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tax/Model/Resource/Sales/Order/Tax/Item.php rename to app/code/Mage/Tax/Model/Resource/Sales/Order/Tax/Item.php diff --git a/app/code/core/Mage/Tax/Model/Resource/Sales/Order/Tax/Item/Collection.php b/app/code/Mage/Tax/Model/Resource/Sales/Order/Tax/Item/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tax/Model/Resource/Sales/Order/Tax/Item/Collection.php rename to app/code/Mage/Tax/Model/Resource/Sales/Order/Tax/Item/Collection.php diff --git a/app/code/core/Mage/Tax/Model/Resource/Setup.php b/app/code/Mage/Tax/Model/Resource/Setup.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/Tax/Model/Resource/Setup.php rename to app/code/Mage/Tax/Model/Resource/Setup.php diff --git a/app/code/core/Mage/Tax/Model/Sales/Order/Tax.php b/app/code/Mage/Tax/Model/Sales/Order/Tax.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Sales/Order/Tax.php rename to app/code/Mage/Tax/Model/Sales/Order/Tax.php diff --git a/app/code/core/Mage/Tax/Model/Sales/Order/Tax/Item.php b/app/code/Mage/Tax/Model/Sales/Order/Tax/Item.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Sales/Order/Tax/Item.php rename to app/code/Mage/Tax/Model/Sales/Order/Tax/Item.php diff --git a/app/code/core/Mage/Tax/Model/Sales/Pdf/Grandtotal.php b/app/code/Mage/Tax/Model/Sales/Pdf/Grandtotal.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Sales/Pdf/Grandtotal.php rename to app/code/Mage/Tax/Model/Sales/Pdf/Grandtotal.php diff --git a/app/code/core/Mage/Tax/Model/Sales/Pdf/Shipping.php b/app/code/Mage/Tax/Model/Sales/Pdf/Shipping.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Sales/Pdf/Shipping.php rename to app/code/Mage/Tax/Model/Sales/Pdf/Shipping.php diff --git a/app/code/core/Mage/Tax/Model/Sales/Pdf/Subtotal.php b/app/code/Mage/Tax/Model/Sales/Pdf/Subtotal.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Sales/Pdf/Subtotal.php rename to app/code/Mage/Tax/Model/Sales/Pdf/Subtotal.php diff --git a/app/code/core/Mage/Tax/Model/Sales/Pdf/Tax.php b/app/code/Mage/Tax/Model/Sales/Pdf/Tax.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Sales/Pdf/Tax.php rename to app/code/Mage/Tax/Model/Sales/Pdf/Tax.php diff --git a/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Discount.php b/app/code/Mage/Tax/Model/Sales/Total/Quote/Discount.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Sales/Total/Quote/Discount.php rename to app/code/Mage/Tax/Model/Sales/Total/Quote/Discount.php diff --git a/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Nominal/Subtotal.php b/app/code/Mage/Tax/Model/Sales/Total/Quote/Nominal/Subtotal.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Sales/Total/Quote/Nominal/Subtotal.php rename to app/code/Mage/Tax/Model/Sales/Total/Quote/Nominal/Subtotal.php diff --git a/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Nominal/Tax.php b/app/code/Mage/Tax/Model/Sales/Total/Quote/Nominal/Tax.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Sales/Total/Quote/Nominal/Tax.php rename to app/code/Mage/Tax/Model/Sales/Total/Quote/Nominal/Tax.php diff --git a/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Shipping.php b/app/code/Mage/Tax/Model/Sales/Total/Quote/Shipping.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Sales/Total/Quote/Shipping.php rename to app/code/Mage/Tax/Model/Sales/Total/Quote/Shipping.php diff --git a/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Subtotal.php b/app/code/Mage/Tax/Model/Sales/Total/Quote/Subtotal.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Sales/Total/Quote/Subtotal.php rename to app/code/Mage/Tax/Model/Sales/Total/Quote/Subtotal.php diff --git a/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Tax.php b/app/code/Mage/Tax/Model/Sales/Total/Quote/Tax.php similarity index 100% rename from app/code/core/Mage/Tax/Model/Sales/Total/Quote/Tax.php rename to app/code/Mage/Tax/Model/Sales/Total/Quote/Tax.php diff --git a/app/code/core/Mage/Tax/Model/System/Config/Source/Algorithm.php b/app/code/Mage/Tax/Model/System/Config/Source/Algorithm.php similarity index 100% rename from app/code/core/Mage/Tax/Model/System/Config/Source/Algorithm.php rename to app/code/Mage/Tax/Model/System/Config/Source/Algorithm.php diff --git a/app/code/core/Mage/Tax/Model/System/Config/Source/Apply.php b/app/code/Mage/Tax/Model/System/Config/Source/Apply.php similarity index 100% rename from app/code/core/Mage/Tax/Model/System/Config/Source/Apply.php rename to app/code/Mage/Tax/Model/System/Config/Source/Apply.php diff --git a/app/code/core/Mage/Tax/Model/System/Config/Source/PriceType.php b/app/code/Mage/Tax/Model/System/Config/Source/PriceType.php similarity index 100% rename from app/code/core/Mage/Tax/Model/System/Config/Source/PriceType.php rename to app/code/Mage/Tax/Model/System/Config/Source/PriceType.php diff --git a/app/code/core/Mage/Tax/Model/System/Config/Source/Tax/Country.php b/app/code/Mage/Tax/Model/System/Config/Source/Tax/Country.php similarity index 100% rename from app/code/core/Mage/Tax/Model/System/Config/Source/Tax/Country.php rename to app/code/Mage/Tax/Model/System/Config/Source/Tax/Country.php diff --git a/app/code/core/Mage/Tax/Model/System/Config/Source/Tax/Display/Type.php b/app/code/Mage/Tax/Model/System/Config/Source/Tax/Display/Type.php similarity index 100% rename from app/code/core/Mage/Tax/Model/System/Config/Source/Tax/Display/Type.php rename to app/code/Mage/Tax/Model/System/Config/Source/Tax/Display/Type.php diff --git a/app/code/core/Mage/Tax/Model/System/Config/Source/Tax/Region.php b/app/code/Mage/Tax/Model/System/Config/Source/Tax/Region.php similarity index 100% rename from app/code/core/Mage/Tax/Model/System/Config/Source/Tax/Region.php rename to app/code/Mage/Tax/Model/System/Config/Source/Tax/Region.php diff --git a/app/code/Mage/Tax/data/tax_setup/data-install-1.6.0.0.php b/app/code/Mage/Tax/data/tax_setup/data-install-1.6.0.0.php new file mode 100644 index 0000000000000..d66028df726de --- /dev/null +++ b/app/code/Mage/Tax/data/tax_setup/data-install-1.6.0.0.php @@ -0,0 +1,70 @@ + 2, + 'class_name' => 'Taxable Goods', + 'class_type' => Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT + ), + array( + 'class_id' => 3, + 'class_name' => 'Retail Customer', + 'class_type' => Mage_Tax_Model_Class::TAX_CLASS_TYPE_CUSTOMER + ) +); +foreach ($data as $row) { + $installer->getConnection()->insertForce($installer->getTable('tax_class'), $row); +} + +/** + * install tax calculation rates + */ +$data = array( + array( + 'tax_calculation_rate_id' => 1, + 'tax_country_id' => 'US', + 'tax_region_id' => 12, + 'tax_postcode' => '*', + 'code' => 'US-CA-*-Rate 1', + 'rate' => '8.2500' + ), + array( + 'tax_calculation_rate_id' => 2, + 'tax_country_id' => 'US', + 'tax_region_id' => 43, + 'tax_postcode' => '*', + 'code' => 'US-NY-*-Rate 1', + 'rate' => '8.3750' + ) +); +foreach ($data as $row) { + $installer->getConnection()->insertForce($installer->getTable('tax_calculation_rate'), $row); +} diff --git a/app/code/Mage/Tax/etc/adminhtml/acl.xml b/app/code/Mage/Tax/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..909f678f937a3 --- /dev/null +++ b/app/code/Mage/Tax/etc/adminhtml/acl.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Mage/Tax/etc/adminhtml/menu.xml b/app/code/Mage/Tax/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..3dc5b7d0c2f0f --- /dev/null +++ b/app/code/Mage/Tax/etc/adminhtml/menu.xml @@ -0,0 +1,35 @@ + + + + + + + + + + diff --git a/app/code/core/Mage/Tax/etc/adminhtml/system.xml b/app/code/Mage/Tax/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Tax/etc/adminhtml/system.xml rename to app/code/Mage/Tax/etc/adminhtml/system.xml diff --git a/app/code/Mage/Tax/etc/config.xml b/app/code/Mage/Tax/etc/config.xml new file mode 100644 index 0000000000000..77460c0d5ef63 --- /dev/null +++ b/app/code/Mage/Tax/etc/config.xml @@ -0,0 +1,241 @@ + + + + + + 1.6.0.5 + true + + + + + + + + + + + + Mage_Tax + Mage_Tax_Model_Resource_Setup + + + + + + + + Mage_Tax_Model_Observer + salesEventConvertQuoteAddressToOrder + + + + + + + Mage_Tax_Model_Observer + salesEventOrderAfterSave + + + + + + + Mage_Tax_Model_Observer + addTaxPercentToProductCollection + + + + + + + Mage_Tax_Model_Observer + quoteCollectTotalsBefore + + + + + + + + + Mage_Tax_Model_Sales_Total_Quote_Subtotal + freeshipping + tax,discount + + + Mage_Tax_Model_Sales_Total_Quote_Shipping + shipping + tax,discount + + + Mage_Tax_Model_Sales_Total_Quote_Tax + subtotal,shipping + grand_total + Mage_Tax_Block_Checkout_Tax + Mage_Adminhtml_Block_Sales_Order_Create_Totals_Tax + + + Mage_Tax_Block_Checkout_Subtotal + Mage_Adminhtml_Block_Sales_Order_Create_Totals_Subtotal + + + Mage_Tax_Block_Checkout_Shipping + Mage_Adminhtml_Block_Sales_Order_Create_Totals_Shipping + + + Mage_Tax_Block_Checkout_Discount + Mage_Adminhtml_Block_Sales_Order_Create_Totals_Discount + + + Mage_Tax_Block_Checkout_Grandtotal + Mage_Adminhtml_Block_Sales_Order_Create_Totals_Grandtotal + + + + + Mage_Tax_Model_Sales_Total_Quote_Nominal_Subtotal + 500 + + + Mage_Tax_Model_Sales_Total_Quote_Nominal_Tax + 750 + + + + + + + + Mage_Tax_Model_Sales_Pdf_Subtotal + + + Mage_Tax_Model_Sales_Pdf_Shipping + + + Mage_Tax_Model_Sales_Pdf_Grandtotal + + + Tax + tax_amount + Mage_Tax_Model_Sales_Pdf_Tax + 7 + 0 + 300 + + + + + + + + + + + + + + + + + + + Mage_Tax.csv + + + + + + + + + + + Mage_Tax.csv + + + + + + + + + + + + TOTAL_BASE_CALCULATION + 0 + 0 + shipping + 0 + 0 + 0 + 0 + + + US + 0 + * + + + 1 + 1 + + + 1 + 1 + 1 + 1 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 0 + 0 + 0 + + + + + + + + 0 0 * * * + + + Mage_Tax_Model_Observer::aggregateSalesReportTaxData + + + + + diff --git a/app/code/core/Mage/Tax/etc/fieldset.xml b/app/code/Mage/Tax/etc/fieldset.xml similarity index 100% rename from app/code/core/Mage/Tax/etc/fieldset.xml rename to app/code/Mage/Tax/etc/fieldset.xml diff --git a/app/code/core/Mage/Tax/locale/de_DE/Mage_Tax.csv b/app/code/Mage/Tax/locale/de_DE/Mage_Tax.csv similarity index 100% rename from app/code/core/Mage/Tax/locale/de_DE/Mage_Tax.csv rename to app/code/Mage/Tax/locale/de_DE/Mage_Tax.csv diff --git a/app/code/core/Mage/Tax/locale/en_US/Mage_Tax.csv b/app/code/Mage/Tax/locale/en_US/Mage_Tax.csv similarity index 100% rename from app/code/core/Mage/Tax/locale/en_US/Mage_Tax.csv rename to app/code/Mage/Tax/locale/en_US/Mage_Tax.csv diff --git a/app/code/core/Mage/Tax/locale/es_ES/Mage_Tax.csv b/app/code/Mage/Tax/locale/es_ES/Mage_Tax.csv similarity index 100% rename from app/code/core/Mage/Tax/locale/es_ES/Mage_Tax.csv rename to app/code/Mage/Tax/locale/es_ES/Mage_Tax.csv diff --git a/app/code/core/Mage/Tax/locale/fr_FR/Mage_Tax.csv b/app/code/Mage/Tax/locale/fr_FR/Mage_Tax.csv similarity index 100% rename from app/code/core/Mage/Tax/locale/fr_FR/Mage_Tax.csv rename to app/code/Mage/Tax/locale/fr_FR/Mage_Tax.csv diff --git a/app/code/core/Mage/Tax/locale/nl_NL/Mage_Tax.csv b/app/code/Mage/Tax/locale/nl_NL/Mage_Tax.csv similarity index 100% rename from app/code/core/Mage/Tax/locale/nl_NL/Mage_Tax.csv rename to app/code/Mage/Tax/locale/nl_NL/Mage_Tax.csv diff --git a/app/code/core/Mage/Tax/locale/pt_BR/Mage_Tax.csv b/app/code/Mage/Tax/locale/pt_BR/Mage_Tax.csv similarity index 100% rename from app/code/core/Mage/Tax/locale/pt_BR/Mage_Tax.csv rename to app/code/Mage/Tax/locale/pt_BR/Mage_Tax.csv diff --git a/app/code/core/Mage/Tax/locale/zh_CN/Mage_Tax.csv b/app/code/Mage/Tax/locale/zh_CN/Mage_Tax.csv similarity index 100% rename from app/code/core/Mage/Tax/locale/zh_CN/Mage_Tax.csv rename to app/code/Mage/Tax/locale/zh_CN/Mage_Tax.csv diff --git a/app/code/core/Mage/Tax/sql/tax_setup/install-1.6.0.0.php b/app/code/Mage/Tax/sql/tax_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Tax/sql/tax_setup/install-1.6.0.0.php rename to app/code/Mage/Tax/sql/tax_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Tax/sql/tax_setup/upgrade-1.6.0.0-1.6.0.1.php b/app/code/Mage/Tax/sql/tax_setup/upgrade-1.6.0.0-1.6.0.1.php similarity index 100% rename from app/code/core/Mage/Tax/sql/tax_setup/upgrade-1.6.0.0-1.6.0.1.php rename to app/code/Mage/Tax/sql/tax_setup/upgrade-1.6.0.0-1.6.0.1.php diff --git a/app/code/core/Mage/Tax/sql/tax_setup/upgrade-1.6.0.1-1.6.0.2.php b/app/code/Mage/Tax/sql/tax_setup/upgrade-1.6.0.1-1.6.0.2.php similarity index 100% rename from app/code/core/Mage/Tax/sql/tax_setup/upgrade-1.6.0.1-1.6.0.2.php rename to app/code/Mage/Tax/sql/tax_setup/upgrade-1.6.0.1-1.6.0.2.php diff --git a/app/code/core/Mage/Tax/sql/tax_setup/upgrade-1.6.0.2-1.6.0.3.php b/app/code/Mage/Tax/sql/tax_setup/upgrade-1.6.0.2-1.6.0.3.php similarity index 100% rename from app/code/core/Mage/Tax/sql/tax_setup/upgrade-1.6.0.2-1.6.0.3.php rename to app/code/Mage/Tax/sql/tax_setup/upgrade-1.6.0.2-1.6.0.3.php diff --git a/app/code/core/Mage/Tax/sql/tax_setup/upgrade-1.6.0.4-1.6.0.5.php b/app/code/Mage/Tax/sql/tax_setup/upgrade-1.6.0.4-1.6.0.5.php similarity index 100% rename from app/code/core/Mage/Tax/sql/tax_setup/upgrade-1.6.0.4-1.6.0.5.php rename to app/code/Mage/Tax/sql/tax_setup/upgrade-1.6.0.4-1.6.0.5.php diff --git a/app/code/core/Mage/Tax/view/frontend/checkout/discount.phtml b/app/code/Mage/Tax/view/frontend/checkout/discount.phtml similarity index 100% rename from app/code/core/Mage/Tax/view/frontend/checkout/discount.phtml rename to app/code/Mage/Tax/view/frontend/checkout/discount.phtml diff --git a/app/code/core/Mage/Tax/view/frontend/checkout/grandtotal.phtml b/app/code/Mage/Tax/view/frontend/checkout/grandtotal.phtml similarity index 100% rename from app/code/core/Mage/Tax/view/frontend/checkout/grandtotal.phtml rename to app/code/Mage/Tax/view/frontend/checkout/grandtotal.phtml diff --git a/app/code/core/Mage/Tax/view/frontend/checkout/shipping.phtml b/app/code/Mage/Tax/view/frontend/checkout/shipping.phtml similarity index 100% rename from app/code/core/Mage/Tax/view/frontend/checkout/shipping.phtml rename to app/code/Mage/Tax/view/frontend/checkout/shipping.phtml diff --git a/app/code/core/Mage/Tax/view/frontend/checkout/subtotal.phtml b/app/code/Mage/Tax/view/frontend/checkout/subtotal.phtml similarity index 100% rename from app/code/core/Mage/Tax/view/frontend/checkout/subtotal.phtml rename to app/code/Mage/Tax/view/frontend/checkout/subtotal.phtml diff --git a/app/code/core/Mage/Tax/view/frontend/checkout/tax.phtml b/app/code/Mage/Tax/view/frontend/checkout/tax.phtml similarity index 100% rename from app/code/core/Mage/Tax/view/frontend/checkout/tax.phtml rename to app/code/Mage/Tax/view/frontend/checkout/tax.phtml diff --git a/app/code/core/Mage/Tax/view/frontend/order/tax.phtml b/app/code/Mage/Tax/view/frontend/order/tax.phtml similarity index 100% rename from app/code/core/Mage/Tax/view/frontend/order/tax.phtml rename to app/code/Mage/Tax/view/frontend/order/tax.phtml diff --git a/app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme.php b/app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme.php new file mode 100644 index 0000000000000..f900da105d1c6 --- /dev/null +++ b/app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme.php @@ -0,0 +1,56 @@ +_blockGroup = 'Mage_Theme'; + $this->_controller = 'Adminhtml_System_Design_Theme'; + if (is_object($this->getLayout()->getBlock('page-title'))) { + $this->getLayout()->getBlock('page-title')->setPageTitle('Themes'); + } + + $this->_updateButton('add', 'label', $this->__('Add New Theme')); + } + + /** + * Prepare header for container + * + * @return string + */ + public function getHeaderText() + { + return $this->__('Themes'); + } +} diff --git a/app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit.php b/app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit.php similarity index 100% rename from app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit.php rename to app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit.php diff --git a/app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form.php b/app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form.php similarity index 100% rename from app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form.php rename to app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form.php diff --git a/app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/File.php b/app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/File.php similarity index 100% rename from app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/File.php rename to app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/File.php diff --git a/app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/Image.php b/app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/Image.php similarity index 100% rename from app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/Image.php rename to app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/Image.php diff --git a/app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/Links.php b/app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/Links.php similarity index 100% rename from app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/Links.php rename to app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/Links.php diff --git a/app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/Css.php b/app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/Css.php new file mode 100644 index 0000000000000..c8cf712d9e499 --- /dev/null +++ b/app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/Css.php @@ -0,0 +1,296 @@ +_uploaderService = $uploaderService; + } + + /** + * Create a form element with necessary controls + * + * @return Mage_Theme_Block_Adminhtml_System_Design_Theme_Edit_Tab_Css + */ + protected function _prepareForm() + { + $form = new Varien_Data_Form(); + $this->setForm($form); + $this->_addThemeCssFieldset(); + + $this->_customCssFile = $this->_getCurrentTheme() + ->getCustomizationData(Mage_Core_Model_Theme_Customization_Files_Css::TYPE)->getFirstItem(); + + $this->_addCustomCssFieldset(); + + $formData['custom_css_content'] = $this->_customCssFile->getContent(); + + /** @var $session Mage_Backend_Model_Session */ + $session = $this->_objectManager->get('Mage_Backend_Model_Session'); + $cssFileContent = $session->getThemeCustomCssData(); + if ($cssFileContent) { + $formData['custom_css_content'] = $cssFileContent; + $session->unsThemeCustomCssData(); + } + $form->addValues($formData); + parent::_prepareForm(); + return $this; + } + + /** + * Set theme css fieldset + * + * @return Mage_Theme_Block_Adminhtml_System_Design_Theme_Edit_Tab_Css + */ + protected function _addThemeCssFieldset() + { + $form = $this->getForm(); + $themeFieldset = $form->addFieldset('theme_css', array( + 'legend' => $this->__('Theme CSS'), + 'class' => 'fieldset-wide' + )); + $this->_addElementTypes($themeFieldset); + foreach ($this->getFiles() as $groupName => $files) { + foreach ($files as &$file) { + $file = $this->_convertFileData($file); + } + $themeFieldset->addField('theme_css_view_' . $groupName, 'links', array( + 'label' => $groupName, + 'title' => $groupName, + 'name' => 'links', + 'values' => $files, + )); + } + + return $this; + } + + /** + * Prepare file items for output on page for download + * + * @param Mage_Core_Model_Theme_File $file + * @return array + */ + protected function _convertFileData($file) + { + return array( + 'href' => $this->getDownloadUrl($file['id'], $this->_getCurrentTheme()->getId()), + 'label' => $file['id'], + 'title' => $file['safePath'], + 'delimiter' => '
    ' + ); + } + + /** + * Set custom css fieldset + * + * @return Mage_Theme_Block_Adminhtml_System_Design_Theme_Edit_Tab_Css + */ + protected function _addCustomCssFieldset() + { + $form = $this->getForm(); + $themeFieldset = $form->addFieldset('custom_css', array( + 'legend' => $this->__('Custom CSS'), + 'class' => 'fieldset-wide' + )); + $this->_addElementTypes($themeFieldset); + + $themeFieldset->addField('css_file_uploader', 'css_file', array( + 'name' => 'css_file_uploader', + 'label' => $this->__('Select CSS File to Upload'), + 'title' => $this->__('Select CSS File to Upload'), + 'accept' => 'text/css', + 'note' => $this->_getUploadCssFileNote() + )); + + $themeFieldset->addField('css_uploader_button', 'button', array( + 'name' => 'css_uploader_button', + 'value' => $this->__('Upload CSS File'), + 'disabled' => 'disabled', + )); + + $downloadButtonConfig = array( + 'name' => 'css_download_button', + 'value' => $this->__('Download CSS File'), + 'onclick' => "setLocation('" . $this->getUrl('*/*/downloadCustomCss', array( + 'theme_id' => $this->_getCurrentTheme()->getId())) . "');" + ); + if (!$this->_customCssFile->getContent()) { + $downloadButtonConfig['disabled'] = 'disabled'; + } + $themeFieldset->addField('css_download_button', 'button', $downloadButtonConfig); + + /** @var $imageButton Mage_Backend_Block_Widget_Button */ + $imageButton = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Button') + ->setData(array( + 'id' => 'css_images_manager', + 'label' => $this->__('Manage'), + 'class' => 'button', + 'onclick' => "MediabrowserUtility.openDialog('" + . $this->getUrl('*/system_design_wysiwyg_files/index', array( + 'target_element_id' => 'custom_css_content', + Mage_Theme_Helper_Storage::PARAM_THEME_ID => $this->_getCurrentTheme()->getId(), + Mage_Theme_Helper_Storage::PARAM_CONTENT_TYPE => Mage_Theme_Model_Wysiwyg_Storage::TYPE_IMAGE + )) + . "', null, null,'" + . $this->quoteEscape( + $this->__('Upload Images...'), true + ) + . "');" + )); + + $themeFieldset->addField('css_browse_image_button', 'note', array( + 'label' => $this->__("Images Assets"), + 'text' => $imageButton->toHtml() + )); + + /** @var $fontButton Mage_Backend_Block_Widget_Button */ + $fontButton = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Button') + ->setData(array( + 'id' => 'css_fonts_manager', + 'label' => $this->__('Manage'), + 'class' => 'button', + 'onclick' => "MediabrowserUtility.openDialog('" + . $this->getUrl('*/system_design_wysiwyg_files/index', array( + 'target_element_id' => 'custom_css_content', + Mage_Theme_Helper_Storage::PARAM_THEME_ID => $this->_getCurrentTheme()->getId(), + Mage_Theme_Helper_Storage::PARAM_CONTENT_TYPE => Mage_Theme_Model_Wysiwyg_Storage::TYPE_FONT + )) + . "', null, null,'" + . $this->quoteEscape( + $this->__('Upload fonts...'), true + ) + . "');", + )); + + $themeFieldset->addField('css_browse_font_button', 'note', array( + 'label' => $this->__("Fonts Assets"), + 'text' => $fontButton->toHtml() + )); + + $themeFieldset->addField('custom_css_content', 'textarea', array( + 'label' => $this->__('Edit custom.css'), + 'title' => $this->__('Edit custom.css'), + 'name' => 'custom_css_content', + )); + + return $this; + } + + /** + * Get note string for css file to Upload + * + * @return string + */ + protected function _getUploadCssFileNote() + { + $messages = array( + $this->__('Allowed file types *.css.'), + $this->__('The file you upload will replace the existing custom.css file (shown below).') + ); + $maxFileSize = $this->_objectManager->get('Magento_File_Size')->getMaxFileSizeInMb(); + if ($maxFileSize) { + $messages[] = $this->__('Max file size to upload %sM', $maxFileSize); + } else { + $messages[] = $this->__('System doesn\'t allow to get file upload settings'); + } + + return implode('
    ', $messages); + } + + /** + * Set additional form field type for theme preview image + * + * @return array + */ + protected function _getAdditionalElementTypes() + { + $linksElement = 'Mage_Theme_Block_Adminhtml_System_Design_Theme_Edit_Form_Element_Links'; + $fileElement = 'Mage_Theme_Block_Adminhtml_System_Design_Theme_Edit_Form_Element_File'; + return array('links' => $linksElement, 'css_file' => $fileElement); + } + + /** + * Return Tab label + * + * @return string + */ + public function getTabLabel() + { + return $this->__('CSS Editor'); + } + + /** + * Get url to downlaod CSS file + * + * @param string $fileId + * @param int $themeId + * @return string + */ + public function getDownloadUrl($fileId, $themeId) + { + return $this->getUrl('*/*/downloadCss', array( + 'theme_id' => $themeId, + 'file' => $this->_helperFactory->get('Mage_Core_Helper_Data')->urlEncode($fileId) + )); + } +} diff --git a/app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/General.php b/app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/General.php similarity index 99% rename from app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/General.php rename to app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/General.php index 822e9a3bb3f7a..6481e2c56d10e 100644 --- a/app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/General.php +++ b/app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/General.php @@ -49,7 +49,7 @@ protected function _prepareForm() /** @var $session Mage_Backend_Model_Session */ $session = $this->_objectManager->get('Mage_Backend_Model_Session'); $formDataFromSession = $session->getThemeData(); - $this->_isThemeEditable = $this->_getCurrentTheme()->isVirtual(); + $this->_isThemeEditable = $this->_getCurrentTheme()->isEditable(); $formData = $this->_getCurrentTheme()->getData(); if ($formDataFromSession && isset($formData['theme_id'])) { unset($formDataFromSession['preview_image']); diff --git a/app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/Js.php b/app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/Js.php similarity index 100% rename from app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/Js.php rename to app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/Js.php diff --git a/app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/TabAbstract.php b/app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/TabAbstract.php new file mode 100644 index 0000000000000..2fe05b8f21dff --- /dev/null +++ b/app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/TabAbstract.php @@ -0,0 +1,94 @@ +_objectManager = $objectManager; + } + + /** + * Get theme that is edited currently + * + * @return Mage_Core_Model_Theme + */ + protected function _getCurrentTheme() + { + return Mage::registry('current_theme'); + } + + /** + * Return Tab title + * + * @return string + */ + public function getTabTitle() + { + return $this->getTabLabel(); + } + + /** + * Can show tab in tabs + * + * @return boolean + */ + public function canShowTab() + { + return $this->_getCurrentTheme()->isVirtual() && $this->_getCurrentTheme()->getId(); + } + + /** + * Tab is hidden + * + * @return boolean + */ + public function isHidden() + { + return false; + } +} diff --git a/app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tabs.php b/app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tabs.php similarity index 100% rename from app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tabs.php rename to app/code/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tabs.php diff --git a/app/code/core/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/Content.php b/app/code/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/Content.php similarity index 100% rename from app/code/core/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/Content.php rename to app/code/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/Content.php diff --git a/app/code/core/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/Content/Files.php b/app/code/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/Content/Files.php similarity index 100% rename from app/code/core/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/Content/Files.php rename to app/code/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/Content/Files.php diff --git a/app/code/core/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/Content/Uploader.php b/app/code/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/Content/Uploader.php similarity index 100% rename from app/code/core/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/Content/Uploader.php rename to app/code/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/Content/Uploader.php diff --git a/app/code/core/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/Tree.php b/app/code/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/Tree.php similarity index 100% rename from app/code/core/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/Tree.php rename to app/code/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/Tree.php diff --git a/app/code/Mage/Theme/Helper/Data.php b/app/code/Mage/Theme/Helper/Data.php new file mode 100644 index 0000000000000..56f3d64189432 --- /dev/null +++ b/app/code/Mage/Theme/Helper/Data.php @@ -0,0 +1,32 @@ +_filesystem = $filesystem; + $this->_session = $session; + $this->_themeFactory = $themeFactory; + + $this->_filesystem->setIsAllowCreateDirectories(true); + $this->_filesystem->ensureDirectoryExists($this->getStorageRoot()); + } + + /** + * Convert path to id + * + * @param string $path + * @return string + */ + public function convertPathToId($path) + { + $path = str_replace($this->getStorageRoot(), '', $path); + return $this->urlEncode($path); + } + + /** + * Convert id to path + * + * @param string $value + * @return string + */ + public function convertIdToPath($value) + { + $path = $this->urlDecode($value); + if (!strstr($path, $this->getStorageRoot())) { + $path = $this->getStorageRoot() . $path; + } + return $path; + } + + /** + * Get short file name + * + * @param string $filename + * @param int $maxLength + * @return string + */ + public function getShortFilename($filename, $maxLength = 20) + { + return strlen($filename) <= $maxLength ? $filename : substr($filename, 0, $maxLength) . '...'; + } + + /** + * Get storage root directory + * + * @return string + */ + public function getStorageRoot() + { + if (null === $this->_storageRoot) { + $this->_storageRoot = implode(Magento_Filesystem::DIRECTORY_SEPARATOR, array( + Magento_Filesystem::fixSeparator($this->_getTheme()->getCustomizationPath()), + $this->getStorageType() + )); + } + return $this->_storageRoot; + } + + /** + * Get theme module for custom static files + * + * @return Mage_Core_Model_Theme + * @throws InvalidArgumentException + */ + protected function _getTheme() + { + $themeId = $this->_getRequest()->getParam(self::PARAM_THEME_ID); + $theme = $this->_themeFactory->create(); + if (!$themeId || $themeId && !$theme->load($themeId)->getId()) { + throw new InvalidArgumentException('Theme was not found.'); + } + return $theme; + } + + /** + * Get storage type + * + * @return string + * @throws Magento_Exception + */ + public function getStorageType() + { + $allowedTypes = array( + Mage_Theme_Model_Wysiwyg_Storage::TYPE_FONT, + Mage_Theme_Model_Wysiwyg_Storage::TYPE_IMAGE + ); + $type = (string)$this->_getRequest()->getParam(self::PARAM_CONTENT_TYPE); + if (!in_array($type, $allowedTypes)) { + throw new Magento_Exception('Invalid type'); + } + return $type; + } + + /** + * Relative url to static content + * + * @return string + */ + public function getRelativeUrl() + { + $pathPieces = array('..', $this->getStorageType()); + $node = $this->_getRequest()->getParam(self::PARAM_NODE); + if ($node !== self::NODE_ROOT) { + $node = $this->urlDecode($node); + $nodes = explode( + Magento_Filesystem::DIRECTORY_SEPARATOR, + trim($node, Magento_Filesystem::DIRECTORY_SEPARATOR) + ); + $pathPieces = array_merge($pathPieces, $nodes); + } + $pathPieces[] = $this->urlDecode($this->_getRequest()->getParam(self::PARAM_FILENAME)); + return implode('/', $pathPieces); + } + + /** + * Get current path + * + * @return string + */ + public function getCurrentPath() + { + if (!$this->_currentPath) { + $currentPath = $this->getStorageRoot(); + $path = $this->_getRequest()->getParam(self::PARAM_NODE); + if ($path && $path !== self::NODE_ROOT) { + $path = $this->convertIdToPath($path); + if ($this->_filesystem->isDirectory($path) + && $this->_filesystem->isPathInDirectory($path, $currentPath) + ) { + $currentPath = $this->_filesystem->getAbsolutePath($path); + } + } + $this->_currentPath = $currentPath; + } + return $this->_currentPath; + } + + /** + * Get thumbnail directory for path + * + * @param string $path + * @return string + */ + public function getThumbnailDirectory($path) + { + return pathinfo($path, PATHINFO_DIRNAME) . Magento_Filesystem::DIRECTORY_SEPARATOR + . Mage_Theme_Model_Wysiwyg_Storage::THUMBNAIL_DIRECTORY; + } + + /** + * Get thumbnail path in current directory by image name + * + * @param $imageName + * @return string + * @throws InvalidArgumentException + */ + public function getThumbnailPath($imageName) + { + $imagePath = $this->getCurrentPath() . Magento_Filesystem::DIRECTORY_SEPARATOR . $imageName; + if (!$this->_filesystem->has($imagePath) + || !$this->_filesystem->isPathInDirectory($imagePath, $this->getStorageRoot()) + ) { + throw new InvalidArgumentException('The image not found.'); + } + return $this->getThumbnailDirectory($imagePath) . Magento_Filesystem::DIRECTORY_SEPARATOR + . pathinfo($imageName, PATHINFO_BASENAME); + } + + /** + * Request params for selected theme + * + * @return array + */ + public function getRequestParams() + { + $themeId = $this->_getRequest()->getParam(self::PARAM_THEME_ID); + $contentType = $this->_getRequest()->getParam(self::PARAM_CONTENT_TYPE); + $node = $this->_getRequest()->getParam(self::PARAM_NODE); + return array( + self::PARAM_THEME_ID => $themeId, + self::PARAM_CONTENT_TYPE => $contentType, + self::PARAM_NODE => $node + ); + } + + /** + * Get allowed extensions by type + * + * @return array + * @throws Magento_Exception + */ + public function getAllowedExtensionsByType() + { + switch ($this->getStorageType()) { + case Mage_Theme_Model_Wysiwyg_Storage::TYPE_FONT: + $extensions = array('ttf', 'otf', 'eot', 'svg', 'woff'); + break; + case Mage_Theme_Model_Wysiwyg_Storage::TYPE_IMAGE: + $extensions = array('jpg', 'jpeg', 'gif', 'png', 'xbm', 'wbmp'); + break; + default: + throw new Magento_Exception('Invalid type'); + } + + return $extensions; + } + + /** + * Get session model + * + * @return Mage_Backend_Model_Session + */ + public function getSession() + { + return $this->_session; + } +} diff --git a/app/code/Mage/Theme/Model/Uploader/Service.php b/app/code/Mage/Theme/Model/Uploader/Service.php new file mode 100644 index 0000000000000..629e13a29b331 --- /dev/null +++ b/app/code/Mage/Theme/Model/Uploader/Service.php @@ -0,0 +1,263 @@ +_fileIo = $fileIo; + $this->_fileSize = $fileSize; + $this->_filesJs = $filesJs; + $this->_objectManager = $objectManager; + parent::__construct($context, $resource, $resourceCollection, $data); + } + + /** + * Upload css file + * + * @param string $file - Key in the $_FILES array + * @return Mage_Theme_Model_Uploader_Service + * @throws Mage_Core_Exception + */ + public function uploadCssFile($file) + { + /** @var $fileUploader Mage_Core_Model_File_Uploader */ + $fileUploader = $this->_objectManager->create('Mage_Core_Model_File_Uploader', array('fileId' => $file)); + $fileUploader->setAllowedExtensions(array('css')); + $fileUploader->setAllowRenameFiles(true); + $fileUploader->setAllowCreateFolders(true); + + $isValidFileSize = $this->_validateFileSize($fileUploader->getFileSize(), $this->getCssUploadMaxSize()); + if (!$isValidFileSize) { + throw new Mage_Core_Exception($this->_objectManager->get('Mage_Core_Helper_Data')->__( + 'CSS file size should be less than %sM.', $this->getCssUploadMaxSizeInMb() + )); + } + + $file = $fileUploader->validateFile(); + $this->setFilePath($file['tmp_name']); + return $this; + } + + /** + * Upload js file + * + * @param string $file - Key in the $_FILES array + * @param Mage_Core_Model_Theme $theme + * @param bool $saveAsTmp + * @return Mage_Theme_Model_Uploader_Service + * @throws Mage_Core_Exception + */ + public function uploadJsFile($file, $theme, $saveAsTmp = true) + { + /** @var $fileUploader Mage_Core_Model_File_Uploader */ + $fileUploader = $this->_objectManager->create('Mage_Core_Model_File_Uploader', array('fileId' => $file)); + $fileUploader->setAllowedExtensions(array('js')); + $fileUploader->setAllowRenameFiles(true); + $fileUploader->setAllowCreateFolders(true); + + $isValidFileSize = $this->_validateFileSize($fileUploader->getFileSize(), $this->getJsUploadMaxSize()); + if (!$isValidFileSize) { + throw new Mage_Core_Exception($this->_objectManager->get('Mage_Core_Helper_Data')->__( + 'JS file size should be less than %sM.', $this->getJsUploadMaxSizeInMb() + )); + } + + $file = $fileUploader->validateFile(); + $this->setFilePath($file['tmp_name']); + $file['content'] = $this->getFileContent(); + + $themeFile = $this->_filesJs->saveJsFile($theme, $file, $saveAsTmp); + $this->setUploadedJsFile($themeFile); + return $this; + } + + /** + * Get js files object + * + * @return Mage_Core_Model_Theme_Customization_Files_Js + */ + public function getJsFiles() + { + return $this->_filesJs; + } + + /** + * Get uploaded file content + * + * @return string + */ + public function getFileContent() + { + return $this->_fileIo->read($this->getFilePath()); + } + + /** + * Get css upload max size + * + * @return int + */ + public function getCssUploadMaxSize() + { + return $this->_getMaxUploadSize(self::XML_PATH_CSS_UPLOAD_LIMIT); + } + + /** + * Get js upload max size + * + * @return int + */ + public function getJsUploadMaxSize() + { + return $this->_getMaxUploadSize(self::XML_PATH_JS_UPLOAD_LIMIT); + } + + /** + * Get max upload size + * + * @param string $node + * @return int + */ + protected function _getMaxUploadSize($node) + { + $maxCssUploadSize = $this->_fileSize->convertSizeToInteger( + (string)Mage::getConfig()->getNode($node) + ); + $maxIniUploadSize = $this->_fileSize->getMaxFileSize(); + return min($maxCssUploadSize, $maxIniUploadSize); + } + + /** + * Get css upload max size in megabytes + * + * @return float + */ + public function getCssUploadMaxSizeInMb() + { + return $this->_fileSize->getFileSizeInMb($this->getCssUploadMaxSize()); + } + + /** + * Get js upload max size in megabytes + * + * @return float + */ + public function getJsUploadMaxSizeInMb() + { + return $this->_fileSize->getFileSizeInMb($this->getJsUploadMaxSize()); + } + + /** + * Validate max file size + * + * @param int $fileSize + * @param int $maxFileSize + * @return bool + */ + protected function _validateFileSize($fileSize, $maxFileSize) + { + if ($fileSize > $maxFileSize) { + return false; + } + return true; + } +} diff --git a/app/code/Mage/Theme/Model/Wysiwyg/Storage.php b/app/code/Mage/Theme/Model/Wysiwyg/Storage.php new file mode 100644 index 0000000000000..a23fbed6f41e4 --- /dev/null +++ b/app/code/Mage/Theme/Model/Wysiwyg/Storage.php @@ -0,0 +1,315 @@ +_filesystem = $filesystem; + $this->_filesystem->setIsAllowCreateDirectories(true); + $this->_helper = $helper; + $this->_objectManager = $objectManager; + } + + /** + * Upload file + * + * @param string $targetPath + * @return bool + * @throws Mage_Core_Exception + */ + public function uploadFile($targetPath) + { + /** @var $uploader Mage_Core_Model_File_Uploader */ + $uploader = $this->_objectManager->create('Mage_Core_Model_File_Uploader', array('fileId' => 'file')); + $uploader->setAllowedExtensions($this->_helper->getAllowedExtensionsByType()); + $uploader->setAllowRenameFiles(true); + $uploader->setFilesDispersion(false); + $result = $uploader->save($targetPath); + + if (!$result) { + throw new Mage_Core_Exception($this->_helper->__('Cannot upload file.') ); + } + + $this->_createThumbnail( + $targetPath . Magento_Filesystem::DIRECTORY_SEPARATOR . $uploader->getUploadedFileName() + ); + + $result['cookie'] = array( + 'name' => $this->_helper->getSession()->getSessionName(), + 'value' => $this->_helper->getSession()->getSessionId(), + 'lifetime' => $this->_helper->getSession()->getCookieLifetime(), + 'path' => $this->_helper->getSession()->getCookiePath(), + 'domain' => $this->_helper->getSession()->getCookieDomain() + ); + + return $result; + } + + /** + * Create thumbnail for image and save it to thumbnails directory + * + * @param string $source + * @return bool|string Resized filepath or false if errors were occurred + */ + public function _createThumbnail($source) + { + if (self::TYPE_IMAGE != $this->_helper->getStorageType() || !$this->_filesystem->isFile($source) + || !$this->_filesystem->isReadable($source) + ) { + return false; + } + $thumbnailDir = $this->_helper->getThumbnailDirectory($source); + $thumbnailPath = $thumbnailDir . Magento_Filesystem::DIRECTORY_SEPARATOR . pathinfo($source, PATHINFO_BASENAME); + try { + $this->_filesystem->ensureDirectoryExists($thumbnailDir); + $adapter = $this->_objectManager->get('Mage_Core_Helper_Data')->getImageAdapterType(); + $image = $this->_objectManager->get('Varien_Image_Adapter')->factory($adapter); + $image->open($source); + $image->keepAspectRatio(true); + $image->resize(self::THUMBNAIL_WIDTH, self::THUMBNAIL_HEIGHT); + $image->save($thumbnailPath); + } catch (Magento_Filesystem_Exception $e) { + $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); + return false; + } + + if ($this->_filesystem->isFile($thumbnailPath)) { + return $thumbnailPath; + } + return false; + } + + /** + * Create folder + * + * @param string $name + * @param string $path + * @return array + * @throws Mage_Core_Exception + */ + public function createFolder($name, $path) + { + if (!preg_match(self::DIRECTORY_NAME_REGEXP, $name)) { + throw new Mage_Core_Exception($this->_helper->__('Invalid folder name.')); + } + if (!$this->_filesystem->isWritable($path)) { + $path = $this->_helper->getStorageRoot(); + } + + $newPath = $path . Magento_Filesystem::DIRECTORY_SEPARATOR . $name; + + if ($this->_filesystem->has($newPath)) { + throw new Mage_Core_Exception($this->_helper->__('A directory with the same name already exists.')); + } + + $this->_filesystem->ensureDirectoryExists($newPath); + + $result = array( + 'name' => $name, + 'short_name' => $this->_helper->getShortFilename($name), + 'path' => str_replace($this->_helper->getStorageRoot(), '', $newPath), + 'id' => $this->_helper->convertPathToId($newPath) + ); + + return $result; + } + + /** + * Delete file + * + * @param string $file + * @return Mage_Theme_Model_Wysiwyg_Storage + */ + public function deleteFile($file) + { + $file = $this->_helper->urlDecode($file); + $path = $this->_helper->getSession()->getStoragePath(); + + $_filePath = $this->_filesystem->getAbsolutePath($path . Magento_Filesystem::DIRECTORY_SEPARATOR . $file); + $_thumbnailPath = $this->_helper->getThumbnailDirectory($_filePath) + . Magento_Filesystem::DIRECTORY_SEPARATOR + . $file; + + if ($this->_filesystem->isPathInDirectory($_filePath, $path) + && $this->_filesystem->isPathInDirectory($_filePath, $this->_helper->getStorageRoot()) + ) { + $this->_filesystem->delete($_filePath); + $this->_filesystem->delete($_thumbnailPath); + } + return $this; + } + + /** + * Get directory collection + * + * @param string $currentPath + * @return array + * @throws Mage_Core_Exception + */ + public function getDirsCollection($currentPath) + { + if (!$this->_filesystem->has($currentPath)) { + throw new Mage_Core_Exception($this->_helper->__('A directory with the name not exists.')); + } + + $paths = $this->_filesystem->searchKeys($currentPath, '*'); + $directories = array(); + foreach ($paths as $path) { + if ($this->_filesystem->isDirectory($path)) { + $directories[] = $path; + } + } + return $directories; + } + + /** + * Get files collection + * + * @return array + */ + public function getFilesCollection() + { + $paths = $this->_filesystem->searchKeys($this->_helper->getCurrentPath(), '*'); + $files = array(); + $requestParams = $this->_helper->getRequestParams(); + $storageType = $this->_helper->getStorageType(); + foreach ($paths as $path) { + if (!$this->_filesystem->isFile($path)) { + continue; + } + $fileName = pathinfo($path, PATHINFO_BASENAME); + $file = array( + 'text' => $fileName, + 'id' => $this->_helper->urlEncode($fileName) + ); + if (self::TYPE_IMAGE == $storageType) { + $requestParams['file'] = $fileName; + $file['thumbnailParams'] = $requestParams; + } + $files[] = $file; + } + return $files; + } + + /** + * Get directories tree array + * + * @return array + */ + public function getTreeArray() + { + $directories = $this->getDirsCollection($this->_helper->getCurrentPath()); + $resultArray = array(); + foreach ($directories as $path) { + $resultArray[] = array( + 'text' => $this->_helper->getShortFilename(pathinfo($path, PATHINFO_BASENAME), 20), + 'id' => $this->_helper->convertPathToId($path), + 'cls' => 'folder' + ); + } + return $resultArray; + } + + /** + * Delete directory + * + * @param string $path + * @return bool + * @throws Mage_Core_Exception + */ + public function deleteDirectory($path) + { + $rootCmp = rtrim($this->_helper->getStorageRoot(), Magento_Filesystem::DIRECTORY_SEPARATOR); + $pathCmp = rtrim($path, Magento_Filesystem::DIRECTORY_SEPARATOR); + + if ($rootCmp == $pathCmp) { + throw new Mage_Core_Exception($this->_helper->__('Cannot delete root directory %s.', $path)); + } + + return $this->_filesystem->delete($path); + } +} diff --git a/app/code/core/Mage/Theme/controllers/Adminhtml/System/Design/ThemeController.php b/app/code/Mage/Theme/controllers/Adminhtml/System/Design/ThemeController.php similarity index 89% rename from app/code/core/Mage/Theme/controllers/Adminhtml/System/Design/ThemeController.php rename to app/code/Mage/Theme/controllers/Adminhtml/System/Design/ThemeController.php index 3eb8dd2eaff9d..8e6713de795f3 100644 --- a/app/code/core/Mage/Theme/controllers/Adminhtml/System/Design/ThemeController.php +++ b/app/code/Mage/Theme/controllers/Adminhtml/System/Design/ThemeController.php @@ -62,12 +62,13 @@ public function newAction() */ public function editAction() { - $themeId = (int) $this->getRequest()->getParam('id'); + $themeId = (int)$this->getRequest()->getParam('id'); /** @var $theme Mage_Core_Model_Theme */ $theme = $this->_objectManager->create('Mage_Core_Model_Theme'); try { - if ($themeId && !$theme->load($themeId)->getId()) { - Mage::throwException($this->__('Theme was not found.')); + $theme->setType(Mage_Core_Model_Theme::TYPE_VIRTUAL); + if ($themeId && (!$theme->load($themeId)->getId() || !$theme->isVisible())) { + throw new Mage_Core_Exception($this->__('Theme "%s" was not found.', $themeId)); } /** @var $cssFileModel Mage_Core_Model_Theme_Customization_Files_Css */ $cssFileModel = $this->_objectManager->create('Mage_Core_Model_Theme_Customization_Files_Css'); @@ -120,7 +121,9 @@ public function saveAction() try { if ($this->getRequest()->getPost()) { - $themeCss->setDataForSave($customCssData); + $themeCss->setDataForSave( + array(Mage_Core_Model_Theme_Customization_Files_Css::CUSTOM_CSS => $customCssData) + ); $theme->setCustomization($themeCss); $themeJs->setDataForSave($uploadJsFiles); @@ -212,18 +215,16 @@ public function uploadJsAction() if (!$theme->getId()) { Mage::throwException($this->__('Theme with id "%d" is not found.', $themeId)); } - $serviceModel->uploadJsFile('js_files_uploader', $theme); - - $this->loadLayout(); + $filesJs = $serviceModel->uploadJsFile('js_files_uploader', $theme); + $temporary = $filesJs->getUploadedJsFile()->getIsTemporary() ? $filesJs->getUploadedJsFile()->getId() : ''; - /** @var $filesJs Mage_Core_Model_Theme_Customization_Files_Js */ - $filesJs = $this->_objectManager->create('Mage_Core_Model_Theme_Customization_Files_Js'); - $customJsFiles = $theme->setCustomization($filesJs) - ->getCustomizationData(Mage_Core_Model_Theme_Customization_Files_Js::TYPE); + $filesData = array( + 'id' => $filesJs->getUploadedJsFile()->getId(), + 'name' => $filesJs->getUploadedJsFile()->getFileName(), + 'temporary' => $temporary + ); - $jsItemsBlock = $this->getLayout()->getBlock('theme_js_file_list'); - $jsItemsBlock->setJsFiles($customJsFiles); - $result = array('content' => $jsItemsBlock->toHtml()); + $result = array('error' => false, 'file' => $filesData); } catch (Mage_Core_Exception $e) { $result = array('error' => true, 'message' => $e->getMessage()); } catch (Exception $e) { @@ -248,19 +249,22 @@ public function downloadCustomCssAction() /** @var $filesCss Mage_Core_Model_Theme_Customization_Files_Css */ $filesCss = $this->_objectManager->create('Mage_Core_Model_Theme_Customization_Files_Css'); - /** @var $customCssFile Mage_Core_Model_Theme_Files */ + /** @var $customCssFile Mage_Core_Model_Theme_File */ $customCssFile = $theme->setCustomization($filesCss) ->getCustomizationData(Mage_Core_Model_Theme_Customization_Files_Css::TYPE)->getFirstItem(); if ($customCssFile->getContent()) { - $this->_prepareDownloadResponse(Mage_Core_Model_Theme_Customization_Files_Css::FILE_PATH, array( - 'type' => 'filename', - 'value' => $customCssFile->getFullPath() - )); + $this->_prepareDownloadResponse( + basename($filesCss->getFilePathByType(Mage_Core_Model_Theme_Customization_Files_Css::CUSTOM_CSS)), + array( + 'type' => 'filename', + 'value' => $customCssFile->getFullPath() + ) + ); } } catch (Exception $e) { $this->_getSession()->addException($e, - $this->__('File "%s" is not found.', Mage_Core_Model_Theme_Customization_Files_Css::FILE_PATH)); + $this->__('File "%s" is not found.', Mage_Core_Model_Theme_Customization_Files_Css::CUSTOM_CSS)); $this->_redirectUrl($this->_getRefererUrl()); $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); } diff --git a/app/code/core/Mage/Theme/controllers/Adminhtml/System/Design/Wysiwyg/FilesController.php b/app/code/Mage/Theme/controllers/Adminhtml/System/Design/Wysiwyg/FilesController.php similarity index 100% rename from app/code/core/Mage/Theme/controllers/Adminhtml/System/Design/Wysiwyg/FilesController.php rename to app/code/Mage/Theme/controllers/Adminhtml/System/Design/Wysiwyg/FilesController.php diff --git a/app/code/Mage/Theme/etc/adminhtml/acl.xml b/app/code/Mage/Theme/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..c903a726b9a56 --- /dev/null +++ b/app/code/Mage/Theme/etc/adminhtml/acl.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + diff --git a/app/code/Mage/Theme/etc/adminhtml/menu.xml b/app/code/Mage/Theme/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..ad3e924d58adb --- /dev/null +++ b/app/code/Mage/Theme/etc/adminhtml/menu.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/app/code/Mage/Theme/etc/config.xml b/app/code/Mage/Theme/etc/config.xml new file mode 100644 index 0000000000000..b3f82a5d85b32 --- /dev/null +++ b/app/code/Mage/Theme/etc/config.xml @@ -0,0 +1,66 @@ + + + + + + 1.6.0.0 + true + + + + + + 2M + + + 2M + + + + + + + admin + + + Mage_Theme_Adminhtml + + + + + + + + + + layout.xml + + + + + diff --git a/app/code/core/Mage/Theme/view/adminhtml/browser/content.phtml b/app/code/Mage/Theme/view/adminhtml/browser/content.phtml similarity index 100% rename from app/code/core/Mage/Theme/view/adminhtml/browser/content.phtml rename to app/code/Mage/Theme/view/adminhtml/browser/content.phtml diff --git a/app/code/core/Mage/Theme/view/adminhtml/browser/content/files.phtml b/app/code/Mage/Theme/view/adminhtml/browser/content/files.phtml similarity index 100% rename from app/code/core/Mage/Theme/view/adminhtml/browser/content/files.phtml rename to app/code/Mage/Theme/view/adminhtml/browser/content/files.phtml diff --git a/app/code/core/Mage/Theme/view/adminhtml/browser/content/uploader.phtml b/app/code/Mage/Theme/view/adminhtml/browser/content/uploader.phtml similarity index 100% rename from app/code/core/Mage/Theme/view/adminhtml/browser/content/uploader.phtml rename to app/code/Mage/Theme/view/adminhtml/browser/content/uploader.phtml diff --git a/app/code/core/Mage/Theme/view/adminhtml/css/theme.css b/app/code/Mage/Theme/view/adminhtml/css/theme.css similarity index 100% rename from app/code/core/Mage/Theme/view/adminhtml/css/theme.css rename to app/code/Mage/Theme/view/adminhtml/css/theme.css diff --git a/app/code/core/Mage/Theme/view/adminhtml/images/bkg_movable-arrows.png b/app/code/Mage/Theme/view/adminhtml/images/bkg_movable-arrows.png similarity index 100% rename from app/code/core/Mage/Theme/view/adminhtml/images/bkg_movable-arrows.png rename to app/code/Mage/Theme/view/adminhtml/images/bkg_movable-arrows.png diff --git a/app/code/core/Mage/Theme/view/adminhtml/images/js_icon.gif b/app/code/Mage/Theme/view/adminhtml/images/js_icon.gif similarity index 100% rename from app/code/core/Mage/Theme/view/adminhtml/images/js_icon.gif rename to app/code/Mage/Theme/view/adminhtml/images/js_icon.gif diff --git a/app/code/core/Mage/Theme/view/adminhtml/js/form.js b/app/code/Mage/Theme/view/adminhtml/js/form.js similarity index 100% rename from app/code/core/Mage/Theme/view/adminhtml/js/form.js rename to app/code/Mage/Theme/view/adminhtml/js/form.js diff --git a/app/code/core/Mage/Theme/view/adminhtml/js/sortable.js b/app/code/Mage/Theme/view/adminhtml/js/sortable.js similarity index 100% rename from app/code/core/Mage/Theme/view/adminhtml/js/sortable.js rename to app/code/Mage/Theme/view/adminhtml/js/sortable.js diff --git a/app/code/core/Mage/Theme/view/adminhtml/layout.xml b/app/code/Mage/Theme/view/adminhtml/layout.xml similarity index 100% rename from app/code/core/Mage/Theme/view/adminhtml/layout.xml rename to app/code/Mage/Theme/view/adminhtml/layout.xml diff --git a/app/code/core/Mage/Theme/view/adminhtml/tabs/css.phtml b/app/code/Mage/Theme/view/adminhtml/tabs/css.phtml similarity index 100% rename from app/code/core/Mage/Theme/view/adminhtml/tabs/css.phtml rename to app/code/Mage/Theme/view/adminhtml/tabs/css.phtml diff --git a/app/code/Mage/Theme/view/adminhtml/tabs/fieldset/js.phtml b/app/code/Mage/Theme/view/adminhtml/tabs/fieldset/js.phtml new file mode 100644 index 0000000000000..be5647bc318b7 --- /dev/null +++ b/app/code/Mage/Theme/view/adminhtml/tabs/fieldset/js.phtml @@ -0,0 +1,53 @@ + + + +
    +
    + +
    +
    + {{name}} ({{size}}) +
    +
    +
    +
    +
    +
    + +
      + getChildBlock('theme.edit.tabs.tab.js.items')->setJsFiles($this->getJsFiles())->toHtml(); ?> +
    + + diff --git a/app/code/core/Mage/Theme/view/adminhtml/tabs/fieldset/js_items.phtml b/app/code/Mage/Theme/view/adminhtml/tabs/fieldset/js_items.phtml similarity index 93% rename from app/code/core/Mage/Theme/view/adminhtml/tabs/fieldset/js_items.phtml rename to app/code/Mage/Theme/view/adminhtml/tabs/fieldset/js_items.phtml index 87a03ea48cbb2..e05111cc87016 100644 --- a/app/code/core/Mage/Theme/view/adminhtml/tabs/fieldset/js_items.phtml +++ b/app/code/Mage/Theme/view/adminhtml/tabs/fieldset/js_items.phtml @@ -25,9 +25,9 @@ */ ?> getJsFiles()->count()): ?> -
  • __('No files found') ?>
  • +
  • __('No files found') ?>
  • - + getJsFiles() as $file): ?>
  • diff --git a/app/code/Mage/Theme/view/adminhtml/tabs/js.phtml b/app/code/Mage/Theme/view/adminhtml/tabs/js.phtml new file mode 100644 index 0000000000000..3131c8421537c --- /dev/null +++ b/app/code/Mage/Theme/view/adminhtml/tabs/js.phtml @@ -0,0 +1,145 @@ + + +getFormHtml(); ?> + +
  • + + + +
    + ${name} +
    + + +
    +
    + + +
  • + + diff --git a/app/code/core/Mage/Usa/Block/Adminhtml/Dhl/Unitofmeasure.php b/app/code/Mage/Usa/Block/Adminhtml/Dhl/Unitofmeasure.php similarity index 100% rename from app/code/core/Mage/Usa/Block/Adminhtml/Dhl/Unitofmeasure.php rename to app/code/Mage/Usa/Block/Adminhtml/Dhl/Unitofmeasure.php diff --git a/app/code/core/Mage/Usa/Helper/Data.php b/app/code/Mage/Usa/Helper/Data.php similarity index 100% rename from app/code/core/Mage/Usa/Helper/Data.php rename to app/code/Mage/Usa/Helper/Data.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Abstract.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Abstract.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract/Source/Mode.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Abstract/Source/Mode.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract/Source/Mode.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Abstract/Source/Mode.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract/Source/Requesttype.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Abstract/Source/Requesttype.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract/Source/Requesttype.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Abstract/Source/Requesttype.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Dhl.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Dhl.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Contenttype.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Contenttype.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Contenttype.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Contenttype.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Abstract.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Abstract.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Abstract.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Abstract.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Doc.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Doc.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Doc.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Doc.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Freedoc.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Freedoc.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Freedoc.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Freedoc.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Freenondoc.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Freenondoc.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Freenondoc.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Freenondoc.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Nondoc.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Nondoc.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Nondoc.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Nondoc.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Size.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Size.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Size.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Size.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Unitofmeasure.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Unitofmeasure.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Unitofmeasure.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Unitofmeasure.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf/Page.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf/Page.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf/Page.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf/Page.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf/PageBuilder.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf/PageBuilder.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf/PageBuilder.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf/PageBuilder.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Dutypaymenttype.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Dutypaymenttype.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Dutypaymenttype.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Dutypaymenttype.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Freemethod.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Freemethod.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Freemethod.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Freemethod.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Method.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Method.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Method.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Method.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Rounding.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Rounding.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Rounding.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Rounding.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Value.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Value.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Value.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Value.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Shipmenttype.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Shipmenttype.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Shipmenttype.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Dhl/Source/Shipmenttype.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Fedex.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Fedex.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Dropoff.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Dropoff.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Dropoff.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Dropoff.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Freemethod.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Freemethod.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Freemethod.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Freemethod.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Method.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Method.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Method.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Method.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Packaging.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Packaging.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Packaging.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Fedex/Source/Packaging.php diff --git a/app/code/Mage/Usa/Model/Shipping/Carrier/Service/Fedex.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Service/Fedex.php new file mode 100644 index 0000000000000..315819d39260d --- /dev/null +++ b/app/code/Mage/Usa/Model/Shipping/Carrier/Service/Fedex.php @@ -0,0 +1,821 @@ +_rateServiceWsdl = $wsdlBasePath . 'RateService_v10.wsdl'; + } + + /** + * Create soap client with selected wsdl + * + * @param string $wsdl + * @param bool $sandboxMode + * @param bool|int $trace + * @return SoapClient + */ + protected function _createSoapClient($wsdl, $sandboxMode, $trace = false ) + { + $client = new SoapClient($wsdl, array('trace' => $trace)); + $client->__setLocation($sandboxMode + ? 'https://wsbeta.fedex.com:443/web-services/rate' + : 'https://ws.fedex.com:443/web-services/rate' + ); + + return $client; + } + + /** + * Create rate soap client + * @param bool $sandboxMode + * @return SoapClient + */ + protected function _createRateSoapClient($sandboxMode) + { + return $this->_createSoapClient($this->_rateServiceWsdl, $sandboxMode); + } + + /** + * @Type call + * @Consumes(schema="http://www.magento.com/schemas/shippingrate-input.xsd", bundle="consumer-ux") + * @Produces(schema="http://www.magento.com/schemas/shippingrate-output.xsd", bundle="consumer-ux") + */ + public function getRates(array $shippingRateInput) + { + $this->setRequest($shippingRateInput); + $this->_result = $this->_getQuotes(); + $this->_updateFreeMethodQuote($shippingRateInput); + return $this->getResult(); + } + + /** + * Prepare and set request to this instance + * + * @param array $request + * @return Mage_Usa_Model_Shipping_Carrier_Service_Fedex + */ + public function setRequest(array $request) + { + $this->_request = $request; + $configuration = $request['carrierConfiguration']; + $rateRequest = $request['rateRequest']; + $r = new Varien_Object(); + + if ($rateRequest['limitMethod']) { + $r->setService($rateRequest->getLimitMethod()); + } + + $r->setAccount($configuration['account']); + $r->setDropoffType($configuration['dropoff']); + $r->setPackaging($configuration['packaging']); + $r->setOrigCountry($rateRequest['origin']['countryId']); + $r->setOrigPostal($rateRequest['origin']['postcode']); + if ($rateRequest['destination']['countryId']) { + $destCountry = $rateRequest['destination']['countryId']; + } else { + $destCountry = self::USA_COUNTRY_ID; + } + $r->setDestCountry($destCountry); + $r->setDestPostal($rateRequest['destination']['postcode']); + $weight = $this->_getTotalNumOfBoxes($rateRequest['packageWeight']); + $r->setWeight($weight); + if ($rateRequest['freeMethodWeight'] != $rateRequest['packageWeight']) { + $r->setFreeMethodWeight($rateRequest['freeMethodWeight']); + } + $r->setValue($rateRequest['packagePhysicalValue']); + $r->setValueWithDiscount($rateRequest['packageValueWithDiscount']); + $r->setMeterNumber($configuration['meterNumber']); + $r->setKey($configuration['key']); + $r->setPassword($configuration['password']); +// $r->setIsReturn($rateRequest->getIsReturn()); + $r->setBaseSubtotalInclTax($rateRequest['baseSubtotalWithTax']); + + $this->_rawRequest = $r; + + return $this; + } + + /** + * @return array|null + */ + protected function _getRequest() + { + return $this->_request; + } + + /** + * @param string $field + * @return mixed + */ + protected function _getConfigData($field) + { + $request=$this->_getRequest(); + $configuration = $request['carrierConfiguration']; + return $configuration[$field]; + } + + /** + * Get result of request + * + * @return array + */ + public function getResult() + { + return $this->_result; + } + + /** + * Get version of rates request + * + * @return array + */ + public function getVersionInfo() + { + return array( + 'ServiceId' => 'crs', + 'Major' => '10', + 'Intermediate' => '0', + 'Minor' => '0' + ); + } + + /** + * Forming request for rate estimation depending to the purpose + * + * @param string $purpose + * @return array + */ + protected function _formRateRequest($purpose) + { + $r = $this->_rawRequest; + $rValue = $r->getValue(); + $ratesRequest = array( + 'WebAuthenticationDetail' => array( + 'UserCredential' => array( + 'Key' => $r->getKey(), + 'Password' => $r->getPassword() + ) + ), + 'ClientDetail' => array( + 'AccountNumber' => $r->getAccount(), + 'MeterNumber' => $r->getMeterNumber() + ), + 'Version' => $this->getVersionInfo(), + 'RequestedShipment' => array( + 'DropoffType' => $r->getDropoffType(), + 'ShipTimestamp' => date('c'), + 'PackagingType' => $r->getPackaging(), + 'TotalInsuredValue' => array( + 'Amount' => $rValue['amount'], + 'Currency' => $rValue['currencyCode'] + ), + 'Shipper' => array( + 'Address' => array( + 'PostalCode' => $r->getOrigPostal(), + 'CountryCode' => $r->getOrigCountry() + ) + ), + 'Recipient' => array( + 'Address' => array( + 'PostalCode' => $r->getDestPostal(), + 'CountryCode' => $r->getDestCountry(), + 'Residential' => (bool)$this->_getConfigData('residenceDelivery') + ) + ), + 'ShippingChargesPayment' => array( + 'PaymentType' => 'SENDER', + 'Payor' => array( + 'AccountNumber' => $r->getAccount(), + 'CountryCode' => $r->getOrigCountry() + ) + ), + 'CustomsClearanceDetail' => array( + 'CustomsValue' => array( + 'Amount' => $rValue['amount'], + 'Currency' => $rValue['currencyCode'] + ) + ), + 'RateRequestTypes' => 'LIST', + 'PackageCount' => '1', + 'PackageDetail' => 'INDIVIDUAL_PACKAGES', + 'RequestedPackageLineItems' => array( + '0' => array( + 'Weight' => array( + 'Value' => (float)$r->getWeight(), + 'Units' => 'LB' + ), + 'GroupPackageCount' => 1, + ) + ) + ) + ); + + if ($purpose == self::RATE_REQUEST_GENERAL) { + $ratesRequest['RequestedShipment']['RequestedPackageLineItems'][0]['InsuredValue'] = array( + 'Amount' => $rValue['amount'], + 'Currency' => $rValue['currencyCode'] + ); + } else if ($purpose == self::RATE_REQUEST_SMARTPOST) { + $ratesRequest['RequestedShipment']['ServiceType'] = self::RATE_REQUEST_SMARTPOST; + $ratesRequest['RequestedShipment']['SmartPostDetail'] = array( + 'Indicia' => ((float)$r->getWeight() >= 1) ? 'PARCEL_SELECT' : 'PRESORTED_STANDARD', + 'HubId' => $this->_getConfigData('smartpostHubid') + ); + } + + return $ratesRequest; + } + + /** + * Makes remote request to the carrier and returns a response + * + * @param string $purpose + * @return mixed + */ + protected function _doRatesRequest($purpose) + { + $ratesRequest = $this->_formRateRequest($purpose); + $client = $this->_createRateSoapClient($this->_getConfigData('sandboxMode')); + return $client->getRates($ratesRequest); + } + + /** + * Do remote request for and handle errors + * + * @return array + */ + protected function _getQuotes() + { + $result = array(); + // make separate request for Smart Post method + $allowedMethods = explode(',', $this->_getConfigData('allowedMethods')); + if (in_array(self::RATE_REQUEST_SMARTPOST, $allowedMethods)) { + $response = $this->_doRatesRequest(self::RATE_REQUEST_SMARTPOST); + $responseResult = $this->_prepareRateResponse($response); + $result = $this->_resultMerge($result, $responseResult); + } + // make general request for all methods + $response = $this->_doRatesRequest(self::RATE_REQUEST_GENERAL); + $responseResult = $this->_prepareRateResponse($response); + $result = $this->_resultMerge($result, $responseResult); + return $result; + } + + /** + * @param array $result1 + * @param array $result2 + * @return array + */ + protected function _resultMerge($result1, $result2) + { + foreach($result2['methodError'] as $error) { + $result1['shippingMethodError'][] = $error; + } + foreach($result2['method'] as $method) { + $result1['shippingMethods'][] = $method; + } + return $result1; + } + + /** + * Prepare shipping rate result based on response + * + * @param mixed $response + * @return array + */ + protected function _prepareRateResponse($response) + { + $costArr = array(); + $priceArr = array(); + $errorTitle = 'Unable to retrieve tracking'; + + if (is_object($response)) { + if ($response->HighestSeverity == 'FAILURE' || $response->HighestSeverity == 'ERROR') { + $errorTitle = (string)$response->Notifications->Message; + } elseif (isset($response->RateReplyDetails)) { + $allowedMethods = explode(",", $this->_getConfigData('allowedMethods')); + + if (is_array($response->RateReplyDetails)) { + foreach ($response->RateReplyDetails as $rate) { + $serviceName = (string)$rate->ServiceType; + if (in_array($serviceName, $allowedMethods)) { + $amount = $this->_getRateAmountOriginBased($rate); + $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 = $this->_getRateAmountOriginBased($rate); + $costArr[$serviceName] = $amount; + $priceArr[$serviceName] = $this->_getMethodPrice($amount, $serviceName); + } + } + } + } + + $result = array(); + if (empty($priceArr)) { + $error = array(); + $error['carrier'] = $this->_code; + $error['carrierTitle'] = $this->_getConfigData('title'); + $error['errorMessage'] = $errorTitle; + $error['errorMessage'] = $this->_getConfigData('specificerrmsg'); + $result['methodError'][] = $error; + } else { + foreach ($priceArr as $method=>$price) { + $rate = array(); + $rate['carrier'] = $this->_code; + $rate['carrierTitle'] = $this->_getConfigData('title'); + $rate['method'] = $method; + $rate['methodTitle'] = $this->getCode('method', $method); + $rate['cost'] = $costArr[$method]; + $rate['price'] = $price; + $result['method'][] = $rate; + } + } + return $result; + } + + /** + * Calculate price considering free shipping and handling fee + * + * @param string $cost + * @param string $method + * @return float|string + */ + protected function _getMethodPrice($cost, $method = '') + { + $baseSubtotalInclTax = $this->_rawRequest->getBaseSubtotalInclTax(); + return $method == $this->_getConfigData('freeMethod') + && (!(bool)$this->_getConfigData('freeShippingEnabled') + || $this->_getConfigData('freeShippingSubtotal') <= $baseSubtotalInclTax['amount']) + ? '0.00' + : $this->_getFinalPriceWithHandlingFee($cost); + } + + /** + * Get configuration data of carrier + * + * @param string $type + * @param string $code + * @return array|bool + */ + public function getCode($type, $code='') + { + $codes = array( + 'method' => array( + 'EUROPE_FIRST_INTERNATIONAL_PRIORITY' => Mage::helper('Mage_Usa_Helper_Data')->__('Europe First Priority'), + 'FEDEX_1_DAY_FREIGHT' => Mage::helper('Mage_Usa_Helper_Data')->__('1 Day Freight'), + 'FEDEX_2_DAY_FREIGHT' => Mage::helper('Mage_Usa_Helper_Data')->__('2 Day Freight'), + 'FEDEX_2_DAY' => Mage::helper('Mage_Usa_Helper_Data')->__('2 Day'), + 'FEDEX_2_DAY_AM' => Mage::helper('Mage_Usa_Helper_Data')->__('2 Day AM'), + 'FEDEX_3_DAY_FREIGHT' => Mage::helper('Mage_Usa_Helper_Data')->__('3 Day Freight'), + 'FEDEX_EXPRESS_SAVER' => Mage::helper('Mage_Usa_Helper_Data')->__('Express Saver'), + 'FEDEX_GROUND' => Mage::helper('Mage_Usa_Helper_Data')->__('Ground'), + 'FIRST_OVERNIGHT' => Mage::helper('Mage_Usa_Helper_Data')->__('First Overnight'), + 'GROUND_HOME_DELIVERY' => Mage::helper('Mage_Usa_Helper_Data')->__('Home Delivery'), + 'INTERNATIONAL_ECONOMY' => Mage::helper('Mage_Usa_Helper_Data')->__('International Economy'), + 'INTERNATIONAL_ECONOMY_FREIGHT' => Mage::helper('Mage_Usa_Helper_Data')->__('Intl Economy Freight'), + 'INTERNATIONAL_FIRST' => Mage::helper('Mage_Usa_Helper_Data')->__('International First'), + 'INTERNATIONAL_GROUND' => Mage::helper('Mage_Usa_Helper_Data')->__('International Ground'), + 'INTERNATIONAL_PRIORITY' => Mage::helper('Mage_Usa_Helper_Data')->__('International Priority'), + 'INTERNATIONAL_PRIORITY_FREIGHT' => Mage::helper('Mage_Usa_Helper_Data')->__('Intl Priority Freight'), + 'PRIORITY_OVERNIGHT' => Mage::helper('Mage_Usa_Helper_Data')->__('Priority Overnight'), + 'SMART_POST' => Mage::helper('Mage_Usa_Helper_Data')->__('Smart Post'), + 'STANDARD_OVERNIGHT' => Mage::helper('Mage_Usa_Helper_Data')->__('Standard Overnight'), + 'FEDEX_FREIGHT' => Mage::helper('Mage_Usa_Helper_Data')->__('Freight'), + 'FEDEX_NATIONAL_FREIGHT' => Mage::helper('Mage_Usa_Helper_Data')->__('National Freight'), + ), + 'dropoff' => array( + 'REGULAR_PICKUP' => Mage::helper('Mage_Usa_Helper_Data')->__('Regular Pickup'), + 'REQUEST_COURIER' => Mage::helper('Mage_Usa_Helper_Data')->__('Request Courier'), + 'DROP_BOX' => Mage::helper('Mage_Usa_Helper_Data')->__('Drop Box'), + 'BUSINESS_SERVICE_CENTER' => Mage::helper('Mage_Usa_Helper_Data')->__('Business Service Center'), + 'STATION' => Mage::helper('Mage_Usa_Helper_Data')->__('Station') + ), + 'packaging' => array( + 'FEDEX_ENVELOPE' => Mage::helper('Mage_Usa_Helper_Data')->__('FedEx Envelope'), + 'FEDEX_PAK' => Mage::helper('Mage_Usa_Helper_Data')->__('FedEx Pak'), + 'FEDEX_BOX' => Mage::helper('Mage_Usa_Helper_Data')->__('FedEx Box'), + 'FEDEX_TUBE' => Mage::helper('Mage_Usa_Helper_Data')->__('FedEx Tube'), + 'FEDEX_10KG_BOX' => Mage::helper('Mage_Usa_Helper_Data')->__('FedEx 10kg Box'), + 'FEDEX_25KG_BOX' => Mage::helper('Mage_Usa_Helper_Data')->__('FedEx 25kg Box'), + 'YOUR_PACKAGING' => Mage::helper('Mage_Usa_Helper_Data')->__('Your Packaging') + ), + 'containers_filter' => array( + array( + 'containers' => array('FEDEX_ENVELOPE', 'FEDEX_PAK'), + 'filters' => array( + 'within_us' => array( + 'method' => array( + 'FEDEX_EXPRESS_SAVER', + 'FEDEX_2_DAY', + 'FEDEX_2_DAY_AM', + 'STANDARD_OVERNIGHT', + 'PRIORITY_OVERNIGHT', + 'FIRST_OVERNIGHT', + ) + ), + 'from_us' => array( + 'method' => array( + 'INTERNATIONAL_FIRST', + 'INTERNATIONAL_ECONOMY', + 'INTERNATIONAL_PRIORITY', + ) + ) + ) + ), + array( + 'containers' => array('FEDEX_BOX', 'FEDEX_TUBE'), + 'filters' => array( + 'within_us' => array( + 'method' => array( + 'FEDEX_2_DAY', + 'FEDEX_2_DAY_AM', + 'STANDARD_OVERNIGHT', + 'PRIORITY_OVERNIGHT', + 'FIRST_OVERNIGHT', + 'FEDEX_FREIGHT', + 'FEDEX_1_DAY_FREIGHT', + 'FEDEX_2_DAY_FREIGHT', + 'FEDEX_3_DAY_FREIGHT', + 'FEDEX_NATIONAL_FREIGHT', + ) + ), + 'from_us' => array( + 'method' => array( + 'INTERNATIONAL_FIRST', + 'INTERNATIONAL_ECONOMY', + 'INTERNATIONAL_PRIORITY', + ) + ) + ) + ), + array( + 'containers' => array('FEDEX_10KG_BOX', 'FEDEX_25KG_BOX'), + 'filters' => array( + 'within_us' => array(), + 'from_us' => array('method' => array('INTERNATIONAL_PRIORITY')) + ) + ), + array( + 'containers' => array('YOUR_PACKAGING'), + 'filters' => array( + 'within_us' => array( + 'method' =>array( + 'FEDEX_GROUND', + 'GROUND_HOME_DELIVERY', + 'SMART_POST', + 'FEDEX_EXPRESS_SAVER', + 'FEDEX_2_DAY', + 'FEDEX_2_DAY_AM', + 'STANDARD_OVERNIGHT', + 'PRIORITY_OVERNIGHT', + 'FIRST_OVERNIGHT', + 'FEDEX_FREIGHT', + 'FEDEX_1_DAY_FREIGHT', + 'FEDEX_2_DAY_FREIGHT', + 'FEDEX_3_DAY_FREIGHT', + 'FEDEX_NATIONAL_FREIGHT', + ) + ), + 'from_us' => array( + 'method' =>array( + 'INTERNATIONAL_FIRST', + 'INTERNATIONAL_ECONOMY', + 'INTERNATIONAL_PRIORITY', + 'INTERNATIONAL_GROUND', + 'FEDEX_FREIGHT', + 'FEDEX_1_DAY_FREIGHT', + 'FEDEX_2_DAY_FREIGHT', + 'FEDEX_3_DAY_FREIGHT', + 'FEDEX_NATIONAL_FREIGHT', + 'INTERNATIONAL_ECONOMY_FREIGHT', + 'INTERNATIONAL_PRIORITY_FREIGHT', + ) + ) + ) + ) + ), + + 'delivery_confirmation_types' => array( + 'NO_SIGNATURE_REQUIRED' => Mage::helper('Mage_Usa_Helper_Data')->__('Not Required'), + 'ADULT' => Mage::helper('Mage_Usa_Helper_Data')->__('Adult'), + 'DIRECT' => Mage::helper('Mage_Usa_Helper_Data')->__('Direct'), + 'INDIRECT' => Mage::helper('Mage_Usa_Helper_Data')->__('Indirect'), + ), + ); + + if (!isset($codes[$type])) { + return false; + } elseif ('' === $code) { + return $codes[$type]; + } + + if (!isset($codes[$type][$code])) { + return false; + } else { + return $codes[$type][$code]; + } + } + + /** + * Get the handling fee for the shipping + cost + * + * @param float $cost + * @return float final price for shipping method + */ + protected function _getFinalPriceWithHandlingFee($cost) + { + $handlingFee = $this->_getConfigData('handlingFee'); + $handlingType = $this->_getConfigData('handlingType'); + if (!$handlingType) { + $handlingType = self::HANDLING_TYPE_FIXED; + } + $handlingAction = $this->_getConfigData('handlingAction'); + if (!$handlingAction) { + $handlingAction = self::HANDLING_ACTION_PERORDER; + } + + return $handlingAction == self::HANDLING_ACTION_PERPACKAGE + ? $this->_getPerpackagePrice($cost, $handlingType, $handlingFee) + : $this->_getPerorderPrice($cost, $handlingType, $handlingFee); + } + + /** + * Get final price for shipping method with handling fee per order + * + * @param float $cost + * @param string $handlingType + * @param float $handlingFee + * @return float + */ + protected function _getPerorderPrice($cost, $handlingType, $handlingFee) + { + if ($handlingType == self::HANDLING_TYPE_PERCENT) { + return ($cost * $this->_numBoxes) + ($cost * $this->_numBoxes * $handlingFee / 100); + } + + return ($cost * $this->_numBoxes) + $handlingFee; + } + + /** + * Get final price for shipping method with handling fee per package + * + * @param float $cost + * @param string $handlingType + * @param float $handlingFee + * @return float + */ + protected function _getPerpackagePrice($cost, $handlingType, $handlingFee) + { + if ($handlingType == self::HANDLING_TYPE_PERCENT) { + return ($cost + ($cost * $handlingFee/100)) * $this->_numBoxes; + } + + return ($cost + $handlingFee) * $this->_numBoxes; + } + + /** + * Get origin based amount form response of rate estimation + * + * @param stdClass $rate + * @return null|float + */ + protected function _getRateAmountOriginBased($rate) + { + $amount = null; + $rateTypeAmounts = array(); + + if (is_object($rate)) { + // The "RATED..." rates are expressed in the currency of the origin country + foreach ($rate->RatedShipmentDetails as $ratedShipmentDetail) { + $netAmount = (string)$ratedShipmentDetail->ShipmentRateDetail->TotalNetCharge->Amount; + $rateType = (string)$ratedShipmentDetail->ShipmentRateDetail->RateType; + $rateTypeAmounts[$rateType] = $netAmount; + } + + // Order is important + foreach (array('RATED_ACCOUNT_SHIPMENT', 'RATED_LIST_SHIPMENT', 'RATED_LIST_PACKAGE') as $rateType) { + if (!empty($rateTypeAmounts[$rateType])) { + $amount = $rateTypeAmounts[$rateType]; + break; + } + } + + if (is_null($amount)) { + $amount = (string)$rate->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount; + } + } + + return $amount; + } + + /** + * @param array $request + * @return null + */ + protected function _updateFreeMethodQuote($request) + { + if (($request['freeMethodWeight'] == $request['packageWeight']) || empty($request['freeMethodWeight'])) { + return; + } + + $freeMethod = $this->_getConfigData('freeMethod'); + if (!$freeMethod) { + return; + } + $freeRateId = false; + + foreach ($this->_result['method'] as $i=>$item) { + if ($item['method'] == $freeMethod) { + $freeRateId = $i; + break; + } + } + + if ($freeRateId === false) { + return; + } + $price = null; + if ($request['freeMethodWeight'] > 0) { + $this->_setFreeMethodRequest($freeMethod); + + $result = $this->_getQuotes(); + if ($result && ($rates = $result['method']) && count($rates)>0) { + if (count($rates) == 1) { + $price = $rates[0]['price']; + } + if (count($rates) > 1) { + foreach ($rates as $rate) { + if ($rate['method'] == $freeMethod + ) { + $price = $rate['price']; + } + } + } + } + } else { + /** + * if we can apply free shipping for all order we should force price + * to $0.00 for shipping with out sending second request to carrier + */ + $price = 0; + } + + /** + * if we did not get our free shipping method in response we must use its old price + */ + if (!is_null($price)) { + $this->_result['method'][$freeRateId]['price'] = $price; + } + } + + /** + * Set free method request + * + * @param $freeMethod + * @return void + */ + protected function _setFreeMethodRequest($freeMethod) + { + $r = $this->_rawRequest; + $weight = $this->_getTotalNumOfBoxes($r->getFreeMethodWeight()); + $r->setWeight($weight); + $r->setService($freeMethod); + } + + + /** + * set the number of boxes for shipping + * + * @return weight + */ + protected function _getTotalNumOfBoxes($weight) + { + /* + reset num box first before retrieve again + */ + $this->_numBoxes = 1; + $weight = $this->_convertWeightToLbs($weight); + $maxPackageWeight = $this->_getConfigData('maxPackageWeight'); + if ($weight > $maxPackageWeight && $maxPackageWeight != 0) { + $this->_numBoxes = ceil($weight/$maxPackageWeight); + $weight = $weight/$this->_numBoxes; + } + return $weight; + } + + /** + * Return weight in pounds + * + * @param integer Weight in someone measure + * @return float Weight in pounds + */ + protected function _convertWeightToLbs($weight) + { + return $weight; + } +} diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Ups.php similarity index 84% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Ups.php index 7706f43629cf3..c37382b3ea85e 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php +++ b/app/code/Mage/Usa/Model/Shipping/Carrier/Ups.php @@ -27,10 +27,6 @@ /** * UPS shipping implementation - * - * @category Mage - * @package Mage_Usa - * @author Magento Core Team */ class Mage_Usa_Model_Shipping_Carrier_Ups extends Mage_Usa_Model_Shipping_Carrier_Abstract @@ -46,8 +42,6 @@ class Mage_Usa_Model_Shipping_Carrier_Ups /** * Delivery Confirmation level based on origin/destination - * - * @var int */ const DELIVERY_CONFIRMATION_SHIPMENT = 1; const DELIVERY_CONFIRMATION_PACKAGE = 2; @@ -62,23 +56,23 @@ class Mage_Usa_Model_Shipping_Carrier_Ups /** * Rate request data * - * @var Mage_Shipping_Model_Rate_Request|null + * @var Mage_Shipping_Model_Rate_Request */ - protected $_request = null; + protected $_request; /** * Raw rate request data * - * @var Varien_Object|null + * @var Varien_Object */ - protected $_rawRequest = null; + protected $_rawRequest; /** * Rate result data * - * @var Mage_Shipping_Model_Rate_Result|null + * @var Mage_Shipping_Model_Rate_Result */ - protected $_result = null; + protected $_result; /** * Base currency rate @@ -92,7 +86,7 @@ class Mage_Usa_Model_Shipping_Carrier_Ups * * @var string */ - protected $_xmlAccessRequest = null; + protected $_xmlAccessRequest; /** * Default cgi gateway url @@ -102,7 +96,7 @@ class Mage_Usa_Model_Shipping_Carrier_Ups protected $_defaultCgiGatewayUrl = 'http://www.ups.com:80/using/services/rave/qcostcgi.cgi'; /** - * Default urls for shipment + * Test urls for shipment * * @var array */ @@ -111,6 +105,16 @@ class Mage_Usa_Model_Shipping_Carrier_Ups 'ShipAccept' => 'https://wwwcie.ups.com/ups.app/xml/ShipAccept', ); + /** + * Live urls for shipment + * + * @var array + */ + protected $_liveUrls = array( + 'ShipConfirm' => 'https://onlinetools.ups.com/ups.app/xml/ShipConfirm', + 'ShipAccept' => 'https://onlinetools.ups.com/ups.app/xml/ShipAccept', + ); + /** * Container types that could be customized for UPS carrier * @@ -149,14 +153,14 @@ public function setRequest(Mage_Shipping_Model_Rate_Request $request) { $this->_request = $request; - $r = new Varien_Object(); + $rowRequest = new Varien_Object(); if ($request->getLimitMethod()) { - $r->setAction($this->getCode('action', 'single')); - $r->setProduct($request->getLimitMethod()); + $rowRequest->setAction($this->getCode('action', 'single')); + $rowRequest->setProduct($request->getLimitMethod()); } else { - $r->setAction($this->getCode('action', 'all')); - $r->setProduct('GND'.$this->getConfigData('dest_type')); + $rowRequest->setAction($this->getCode('action', 'all')); + $rowRequest->setProduct('GND' . $this->getConfigData('dest_type')); } if ($request->getUpsPickup()) { @@ -164,21 +168,21 @@ public function setRequest(Mage_Shipping_Model_Rate_Request $request) } else { $pickup = $this->getConfigData('pickup'); } - $r->setPickup($this->getCode('pickup', $pickup)); + $rowRequest->setPickup($this->getCode('pickup', $pickup)); if ($request->getUpsContainer()) { $container = $request->getUpsContainer(); } else { $container = $this->getConfigData('container'); } - $r->setContainer($this->getCode('container', $container)); + $rowRequest->setContainer($this->getCode('container', $container)); if ($request->getUpsDestType()) { $destType = $request->getUpsDestType(); } else { $destType = $this->getConfigData('dest_type'); } - $r->setDestType($this->getCode('dest_type', $destType)); + $rowRequest->setDestType($this->getCode('dest_type', $destType)); if ($request->getOrigCountry()) { $origCountry = $request->getOrigCountry(); @@ -189,7 +193,7 @@ public function setRequest(Mage_Shipping_Model_Rate_Request $request) ); } - $r->setOrigCountry(Mage::getModel('Mage_Directory_Model_Country')->load($origCountry)->getIso2Code()); + $rowRequest->setOrigCountry(Mage::getModel('Mage_Directory_Model_Country')->load($origCountry)->getIso2Code()); if ($request->getOrigRegionCode()) { $origRegionCode = $request->getOrigRegionCode(); @@ -202,21 +206,21 @@ public function setRequest(Mage_Shipping_Model_Rate_Request $request) if (is_numeric($origRegionCode)) { $origRegionCode = Mage::getModel('Mage_Directory_Model_Region')->load($origRegionCode)->getCode(); } - $r->setOrigRegionCode($origRegionCode); + $rowRequest->setOrigRegionCode($origRegionCode); if ($request->getOrigPostcode()) { - $r->setOrigPostal($request->getOrigPostcode()); + $rowRequest->setOrigPostal($request->getOrigPostcode()); } else { - $r->setOrigPostal(Mage::getStoreConfig( + $rowRequest->setOrigPostal(Mage::getStoreConfig( Mage_Shipping_Model_Shipping::XML_PATH_STORE_ZIP, $request->getStoreId() )); } if ($request->getOrigCity()) { - $r->setOrigCity($request->getOrigCity()); + $rowRequest->setOrigCity($request->getOrigCity()); } else { - $r->setOrigCity(Mage::getStoreConfig( + $rowRequest->setOrigCity(Mage::getStoreConfig( Mage_Shipping_Model_Shipping::XML_PATH_STORE_CITY, $request->getStoreId() )); @@ -231,7 +235,7 @@ public function setRequest(Mage_Shipping_Model_Rate_Request $request) //for UPS, puero rico state for US will assume as puerto rico country if ($destCountry == self::USA_COUNTRY_ID - && ($request->getDestPostcode()=='00912' || $request->getDestRegionCode()==self::PUERTORICO_COUNTRY_ID) + && ($request->getDestPostcode() == '00912' || $request->getDestRegionCode() == self::PUERTORICO_COUNTRY_ID) ) { $destCountry = self::PUERTORICO_COUNTRY_ID; } @@ -241,12 +245,12 @@ public function setRequest(Mage_Shipping_Model_Rate_Request $request) $destCountry = self::GUAM_COUNTRY_ID; } - $r->setDestCountry(Mage::getModel('Mage_Directory_Model_Country')->load($destCountry)->getIso2Code()); + $rowRequest->setDestCountry(Mage::getModel('Mage_Directory_Model_Country')->load($destCountry)->getIso2Code()); - $r->setDestRegionCode($request->getDestRegionCode()); + $rowRequest->setDestRegionCode($request->getDestRegionCode()); if ($request->getDestPostcode()) { - $r->setDestPostal($request->getDestPostcode()); + $rowRequest->setDestPostal($request->getDestPostcode()); } else { } @@ -255,32 +259,30 @@ public function setRequest(Mage_Shipping_Model_Rate_Request $request) $weight = $this->_getCorrectWeight($weight); - $r->setWeight($weight); + $rowRequest->setWeight($weight); if ($request->getFreeMethodWeight()!=$request->getPackageWeight()) { - $r->setFreeMethodWeight($request->getFreeMethodWeight()); + $rowRequest->setFreeMethodWeight($request->getFreeMethodWeight()); } - $r->setValue($request->getPackageValue()); - $r->setValueWithDiscount($request->getPackageValueWithDiscount()); + $rowRequest->setValue($request->getPackageValue()); + $rowRequest->setValueWithDiscount($request->getPackageValueWithDiscount()); if ($request->getUpsUnitMeasure()) { $unit = $request->getUpsUnitMeasure(); } else { $unit = $this->getConfigData('unit_of_measure'); } - $r->setUnitMeasure($unit); - - $r->setIsReturn($request->getIsReturn()); + $rowRequest->setUnitMeasure($unit); + $rowRequest->setIsReturn($request->getIsReturn()); + $rowRequest->setBaseSubtotalInclTax($request->getBaseSubtotalInclTax()); - $r->setBaseSubtotalInclTax($request->getBaseSubtotalInclTax()); - - $this->_rawRequest = $r; + $this->_rawRequest = $rowRequest; return $this; } /** - * Get correct weigt. + * Get correct weight * * Namely: * Checks the current weight to comply with the minimum weight standards set by the carrier. @@ -293,12 +295,12 @@ protected function _getCorrectWeight($weight) { $minWeight = $this->getConfigData('min_package_weight'); - if($weight < $minWeight){ + if ($weight < $minWeight) { $weight = $minWeight; } //rounds a number to one significant figure - $weight = ceil($weight*10) / 10; + $weight = ceil($weight * 10) / 10; return $weight; } @@ -310,7 +312,7 @@ protected function _getCorrectWeight($weight) */ public function getResult() { - return $this->_result; + return $this->_result; } /** @@ -322,10 +324,11 @@ protected function _getQuotes() { switch ($this->getConfigData('type')) { case 'UPS': - return $this->_getCgiQuotes(); - + return $this->_getCgiQuotes(); case 'UPS_XML': - return $this->_getXmlQuotes(); + return $this->_getXmlQuotes(); + default: + break; } return null; } @@ -354,24 +357,27 @@ protected function _setFreeMethodRequest($freeMethod) */ protected function _getCgiQuotes() { - $r = $this->_rawRequest; + $rowRequest = $this->_rawRequest; + if (Mage_Usa_Model_Shipping_Carrier_Abstract::USA_COUNTRY_ID == $rowRequest->getDestCountry()) { + $destPostal = substr($rowRequest->getDestPostal(), 0, 5); + } else { + $destPostal = $rowRequest->getDestPostal(); + } $params = array( 'accept_UPS_license_agreement' => 'yes', - '10_action' => $r->getAction(), - '13_product' => $r->getProduct(), - '14_origCountry' => $r->getOrigCountry(), - '15_origPostal' => $r->getOrigPostal(), - 'origCity' => $r->getOrigCity(), - '19_destPostal' => Mage_Usa_Model_Shipping_Carrier_Abstract::USA_COUNTRY_ID == $r->getDestCountry() ? - substr($r->getDestPostal(), 0, 5) : - $r->getDestPostal(), - '22_destCountry' => $r->getDestCountry(), - '23_weight' => $r->getWeight(), - '47_rate_chart' => $r->getPickup(), - '48_container' => $r->getContainer(), - '49_residential' => $r->getDestType(), - 'weight_std' => strtolower($r->getUnitMeasure()), + '10_action' => $rowRequest->getAction(), + '13_product' => $rowRequest->getProduct(), + '14_origCountry' => $rowRequest->getOrigCountry(), + '15_origPostal' => $rowRequest->getOrigPostal(), + 'origCity' => $rowRequest->getOrigCity(), + '19_destPostal' => $destPostal, + '22_destCountry' => $rowRequest->getDestCountry(), + '23_weight' => $rowRequest->getWeight(), + '47_rate_chart' => $rowRequest->getPickup(), + '48_container' => $rowRequest->getContainer(), + '49_residential' => $rowRequest->getDestType(), + 'weight_std' => strtolower($rowRequest->getUnitMeasure()), ); $params['47_rate_chart'] = $params['47_rate_chart']['label']; @@ -385,15 +391,14 @@ protected function _getCgiQuotes() } $client = new Zend_Http_Client(); $client->setUri($url); - $client->setConfig(array('maxredirects'=>0, 'timeout'=>30)); + $client->setConfig(array('maxredirects' => 0, 'timeout' => 30)); $client->setParameterGet($params); $response = $client->request(); $responseBody = $response->getBody(); $debugData['result'] = $responseBody; $this->_setCachedQuotes($params, $responseBody); - } - catch (Exception $e) { + } catch (Exception $e) { $debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode()); $responseBody = ''; } @@ -410,15 +415,17 @@ protected function _getCgiQuotes() * @param string $origin * @return array|bool */ - public function getShipmentByCode($code, $origin = null){ - if($origin===null){ + public function getShipmentByCode($code, $origin = null) + { + if ($origin === null) { $origin = $this->getConfigData('origin_shipment'); } - $arr = $this->getCode('originShipment',$origin); - if(isset($arr[$code])) + $arr = $this->getCode('originShipment', $origin); + if (isset($arr[$code])) { return $arr[$code]; - else + } else { return false; + } } @@ -432,37 +439,39 @@ protected function _parseCgiResponse($response) { $costArr = array(); $priceArr = array(); - $errorTitle = Mage::helper('Mage_Usa_Helper_Data')->__('Unknown error'); - if (strlen(trim($response))>0) { + if (strlen(trim($response)) > 0) { $rRows = explode("\n", $response); $allowedMethods = explode(",", $this->getConfigData('allowed_methods')); foreach ($rRows as $rRow) { - $r = explode('%', $rRow); - switch (substr($r[0],-1)) { + $row = explode('%', $rRow); + switch (substr($row[0], -1)) { case 3: case 4: - if (in_array($r[1], $allowedMethods)) { - $responsePrice = Mage::app()->getLocale()->getNumber($r[8]); - $costArr[$r[1]] = $responsePrice; - $priceArr[$r[1]] = $this->getMethodPrice($responsePrice, $r[1]); + if (in_array($row[1], $allowedMethods)) { + $responsePrice = Mage::app()->getLocale()->getNumber($row[8]); + $costArr[$row[1]] = $responsePrice; + $priceArr[$row[1]] = $this->getMethodPrice($responsePrice, $row[1]); } break; case 5: - $errorTitle = $r[1]; + $errorTitle = $row[1]; + Mage::log(Mage::helper('Mage_Usa_Helper_Data')->__('Unknown error') . ': ' . $errorTitle); break; case 6: - if (in_array($r[3], $allowedMethods)) { - $responsePrice = Mage::app()->getLocale()->getNumber($r[10]); - $costArr[$r[3]] = $responsePrice; - $priceArr[$r[3]] = $this->getMethodPrice($responsePrice, $r[3]); + if (in_array($row[3], $allowedMethods)) { + $responsePrice = Mage::app()->getLocale()->getNumber($row[10]); + $costArr[$row[3]] = $responsePrice; + $priceArr[$row[3]] = $this->getMethodPrice($responsePrice, $row[3]); } break; + default: + break; } } asort($priceArr); } $result = Mage::getModel('Mage_Shipping_Model_Rate_Result'); - $defaults = $this->getDefaults(); + if (empty($priceArr)) { $error = Mage::getModel('Mage_Shipping_Model_Rate_Result_Error'); $error->setCarrier('ups'); @@ -470,13 +479,13 @@ protected function _parseCgiResponse($response) $error->setErrorMessage($this->getConfigData('specificerrmsg')); $result->append($error); } else { - foreach ($priceArr as $method=>$price) { + foreach ($priceArr as $method => $price) { $rate = Mage::getModel('Mage_Shipping_Model_Rate_Result_Method'); $rate->setCarrier('ups'); $rate->setCarrierTitle($this->getConfigData('title')); $rate->setMethod($method); - $method_arr = $this->getCode('method', $method); - $rate->setMethodTitle($method_arr); + $methodArray = $this->getCode('method', $method); + $rate->setMethodTitle($methodArray); $rate->setCost($costArr[$method]); $rate->setPrice($price); $result->append($rate); @@ -493,15 +502,14 @@ protected function _parseCgiResponse($response) * @param string $code * @return array|bool */ - public function getCode($type, $code='') + public function getCode($type, $code = '') { $codes = array( - 'action'=>array( - 'single'=>'3', - 'all'=>'4', + 'action' => array( + 'single' => '3', + 'all' => '4', ), - - 'originShipment'=>array( + 'originShipment' => array( // United States Domestic Shipments 'United States Domestic Shipments' => array( '01' => Mage::helper('Mage_Usa_Helper_Data')->__('UPS Next Day Air'), @@ -772,7 +780,7 @@ public function getCode($type, $code='') if (!isset($codes[$type])) { return false; - } elseif (''===$code) { + } elseif ('' === $code) { return $codes[$type]; } @@ -795,24 +803,27 @@ protected function _getXmlQuotes() $this->setXMLAccessRequest(); $xmlRequest=$this->_xmlAccessRequest; - $r = $this->_rawRequest; + $rowRequest = $this->_rawRequest; + if (Mage_Usa_Model_Shipping_Carrier_Abstract::USA_COUNTRY_ID == $rowRequest->getDestCountry()) { + $destPostal = substr($rowRequest->getDestPostal(), 0, 5); + } else { + $destPostal = $rowRequest->getDestPostal(); + } $params = array( 'accept_UPS_license_agreement' => 'yes', - '10_action' => $r->getAction(), - '13_product' => $r->getProduct(), - '14_origCountry' => $r->getOrigCountry(), - '15_origPostal' => $r->getOrigPostal(), - 'origCity' => $r->getOrigCity(), - 'origRegionCode' => $r->getOrigRegionCode(), - '19_destPostal' => Mage_Usa_Model_Shipping_Carrier_Abstract::USA_COUNTRY_ID == $r->getDestCountry() ? - substr($r->getDestPostal(), 0, 5) : - $r->getDestPostal(), - '22_destCountry' => $r->getDestCountry(), - 'destRegionCode' => $r->getDestRegionCode(), - '23_weight' => $r->getWeight(), - '47_rate_chart' => $r->getPickup(), - '48_container' => $r->getContainer(), - '49_residential' => $r->getDestType(), + '10_action' => $rowRequest->getAction(), + '13_product' => $rowRequest->getProduct(), + '14_origCountry' => $rowRequest->getOrigCountry(), + '15_origPostal' => $rowRequest->getOrigPostal(), + 'origCity' => $rowRequest->getOrigCity(), + 'origRegionCode' => $rowRequest->getOrigRegionCode(), + '19_destPostal' => $destPostal, + '22_destCountry' => $rowRequest->getDestCountry(), + 'destRegionCode' => $rowRequest->getDestRegionCode(), + '23_weight' => $rowRequest->getWeight(), + '47_rate_chart' => $rowRequest->getPickup(), + '48_container' => $rowRequest->getContainer(), + '49_residential' => $rowRequest->getDestType(), ); if ($params['10_action'] == '4') { @@ -820,11 +831,11 @@ protected function _getXmlQuotes() $serviceCode = null; // Service code is not relevant when we're asking ALL possible services' rates } else { $params['10_action'] = 'Rate'; - $serviceCode = $r->getProduct() ? $r->getProduct() : ''; + $serviceCode = $rowRequest->getProduct() ? $rowRequest->getProduct() : ''; } $serviceDescription = $serviceCode ? $this->getShipmentByCode($serviceCode) : ''; -$xmlRequest .= <<< XMLRequest + $xmlRequest .= <<< XMLRequest @@ -850,7 +861,7 @@ protected function _getXmlQuotes() ""; } - $xmlRequest .= <<< XMLRequest + $xmlRequest .= <<< XMLRequest XMLRequest; @@ -858,7 +869,7 @@ protected function _getXmlQuotes() $xmlRequest .= "{$shipper}"; } - if ($r->getIsReturn()) { + if ($rowRequest->getIsReturn()) { $shipperCity = ''; $shipperPostalCode = $params['19_destPostal']; $shipperCountryCode = $params['22_destCountry']; @@ -870,7 +881,7 @@ protected function _getXmlQuotes() $shipperStateProvince = $params['origRegionCode']; } -$xmlRequest .= <<< XMLRequest + $xmlRequest .= <<< XMLRequest
    {$shipperCity} {$shipperPostalCode} @@ -886,12 +897,11 @@ protected function _getXmlQuotes() {$params['destRegionCode']} XMLRequest; - $xmlRequest .= ($params['49_residential']==='01' - ? "{$params['49_residential']}" - : '' - ); + if ($params['49_residential'] === '01') { + $xmlRequest .= "{$params['49_residential']}"; + } -$xmlRequest .= <<< XMLRequest + $xmlRequest .= <<< XMLRequest
    @@ -907,16 +917,17 @@ protected function _getXmlQuotes() {$params['48_container']} - {$r->getUnitMeasure()} + {$rowRequest->getUnitMeasure()} {$params['23_weight']} XMLRequest; + if ($this->getConfigFlag('negotiated_active')) { $xmlRequest .= ""; } -$xmlRequest .= <<< XMLRequest + $xmlRequest .= <<< XMLRequest
    XMLRequest; @@ -933,12 +944,11 @@ protected function _getXmlQuotes() curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, (boolean)$this->getConfigFlag('mode_xml')); - $xmlResponse = curl_exec ($ch); + $xmlResponse = curl_exec($ch); $debugData['result'] = $xmlResponse; $this->_setCachedQuotes($xmlRequest, $xmlResponse); - } - catch (Exception $e) { + } catch (Exception $e) { $debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode()); $xmlResponse = ''; } @@ -968,19 +978,19 @@ protected function _getBaseCurrencyRate($code) /** * Prepare shipping rate result based on response * - * @param mixed $response + * @param mixed $xmlResponse * @return Mage_Shipping_Model_Rate_Result */ protected function _parseXmlResponse($xmlResponse) { $costArr = array(); $priceArr = array(); - if (strlen(trim($xmlResponse))>0) { + if (strlen(trim($xmlResponse)) > 0) { $xml = new Varien_Simplexml_Config(); $xml->loadString($xmlResponse); $arr = $xml->getXpath("//RatingServiceSelectionResponse/Response/ResponseStatusCode/text()"); $success = (int)$arr[0]; - if ($success===1) { + if ($success === 1) { $arr = $xml->getXpath("//RatingServiceSelectionResponse/RatedShipment"); $allowedMethods = explode(",", $this->getConfigData('allowed_methods')); @@ -992,7 +1002,7 @@ protected function _parseXmlResponse($xmlResponse) $allowedCurrencies = Mage::getModel('Mage_Directory_Model_Currency')->getConfigAllowCurrencies(); - foreach ($arr as $shipElement){ + foreach ($arr as $shipElement) { $code = (string)$shipElement->Service->Code; if (in_array($code, $allowedMethods)) { @@ -1004,12 +1014,16 @@ protected function _parseXmlResponse($xmlResponse) //convert price with Origin country currency code to base currency code $successConversion = true; - $responseCurrencyCode = (string) $shipElement->TotalCharges->CurrencyCode; + $responseCurrencyCode = (string)$shipElement->TotalCharges->CurrencyCode; if ($responseCurrencyCode) { if (in_array($responseCurrencyCode, $allowedCurrencies)) { - $cost = (float) $cost * $this->_getBaseCurrencyRate($responseCurrencyCode); + $cost = (float)$cost * $this->_getBaseCurrencyRate($responseCurrencyCode); } else { - $errorTitle = Mage::helper('Mage_Directory_Helper_Data')->__('Can\'t convert rate from "%s-%s".', $responseCurrencyCode, $this->_request->getPackageCurrency()->getCode()); + $errorTitle = Mage::helper('Mage_Directory_Helper_Data')->__( + 'Can\'t convert rate from "%s-%s".', + $responseCurrencyCode, + $this->_request->getPackageCurrency()->getCode() + ); $error = Mage::getModel('Mage_Shipping_Model_Rate_Result_Error'); $error->setCarrier('ups'); $error->setCarrierTitle($this->getConfigData('title')); @@ -1020,7 +1034,7 @@ protected function _parseXmlResponse($xmlResponse) if ($successConversion) { $costArr[$code] = $cost; - $priceArr[$code] = $this->getMethodPrice(floatval($cost),$code); + $priceArr[$code] = $this->getMethodPrice(floatval($cost), $code); } } } @@ -1035,12 +1049,12 @@ protected function _parseXmlResponse($xmlResponse) } $result = Mage::getModel('Mage_Shipping_Model_Rate_Result'); - $defaults = $this->getDefaults(); + if (empty($priceArr)) { $error = Mage::getModel('Mage_Shipping_Model_Rate_Result_Error'); $error->setCarrier('ups'); $error->setCarrierTitle($this->getConfigData('title')); - if(!isset($errorTitle)){ + if (!isset($errorTitle)) { $errorTitle = Mage::helper('Mage_Usa_Helper_Data')->__('Cannot retrieve shipping rates'); } $error->setErrorMessage($this->getConfigData('specificerrmsg')); @@ -1051,8 +1065,8 @@ protected function _parseXmlResponse($xmlResponse) $rate->setCarrier('ups'); $rate->setCarrierTitle($this->getConfigData('title')); $rate->setMethod($method); - $method_arr = $this->getShipmentByCode($method); - $rate->setMethodTitle($method_arr); + $methodArr = $this->getShipmentByCode($method); + $rate->setMethodTitle($methodArr); $rate->setCost($costArr[$method]); $rate->setPrice($price); $result->append($rate); @@ -1069,19 +1083,16 @@ protected function _parseXmlResponse($xmlResponse) */ public function getTracking($trackings) { - $return = array(); - if (!is_array($trackings)) { $trackings = array($trackings); } - if ($this->getConfigData('type')=='UPS') { + if ($this->getConfigData('type') == 'UPS') { $this->_getCgiTracking($trackings); - } elseif ($this->getConfigData('type')=='UPS_XML'){ + } elseif ($this->getConfigData('type') == 'UPS_XML') { $this->setXMLAccessRequest(); $this->_getXmlTracking($trackings); } - return $this->_result; } @@ -1092,16 +1103,16 @@ public function getTracking($trackings) */ protected function setXMLAccessRequest() { - $userid = $this->getConfigData('username'); - $userid_pass = $this->getConfigData('password'); - $access_key = $this->getConfigData('access_license_number'); + $userId = $this->getConfigData('username'); + $userIdPass = $this->getConfigData('password'); + $accessKey = $this->getConfigData('access_license_number'); $this->_xmlAccessRequest = << - $access_key - $userid - $userid_pass + $accessKey + $userId + $userIdPass XMLAuth; } @@ -1117,8 +1128,7 @@ protected function _getCgiTracking($trackings) //ups no longer support tracking for data streaming version //so we can only reply the popup window to ups. $result = Mage::getModel('Mage_Shipping_Model_Tracking_Result'); - $defaults = $this->getDefaults(); - foreach($trackings as $tracking){ + foreach ($trackings as $tracking) { $status = Mage::getModel('Mage_Shipping_Model_Tracking_Result_Status'); $status->setCarrier('ups'); $status->setCarrierTitle($this->getConfigData('title')); @@ -1126,8 +1136,7 @@ protected function _getCgiTracking($trackings) $status->setPopup(1); $status->setUrl("http://wwwapps.ups.com/WebTracking/processInputRequest?HTMLVersion=5.0&error_carried=true" . "&tracknums_displayed=5&TypeOfInquiryNumber=T&loc=en_US&InquiryNumber1=$tracking" - . "&AgreeToTermsAndConditions=yes" - ); + . "&AgreeToTermsAndConditions=yes"); $result->append($status); } @@ -1145,13 +1154,13 @@ protected function _getXmlTracking($trackings) { $url = $this->getConfigData('tracking_xml_url'); - foreach($trackings as $tracking){ - $xmlRequest=$this->_xmlAccessRequest; + foreach ($trackings as $tracking) { + $xmlRequest = $this->_xmlAccessRequest; -/* -* RequestOption==>'activity' or '1' to request all activities -*/ -$xmlRequest .= <<'activity' or '1' to request all activities + */ + $xmlRequest .= << @@ -1166,17 +1175,16 @@ protected function _getXmlTracking($trackings) try { $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest); curl_setopt($ch, CURLOPT_TIMEOUT, 30); - $xmlResponse = curl_exec ($ch); + $xmlResponse = curl_exec($ch); $debugData['result'] = $xmlResponse; - curl_close ($ch); - } - catch (Exception $e) { + curl_close($ch); + } catch (Exception $e) { $debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode()); $xmlResponse = ''; } @@ -1191,11 +1199,11 @@ protected function _getXmlTracking($trackings) /** * Parse xml tracking response * - * @param string $trackingvalue - * @param string $response + * @param string $trackingValue + * @param string $xmlResponse * @return null */ - protected function _parseXmlTrackingResponse($trackingvalue, $xmlResponse) + protected function _parseXmlTrackingResponse($trackingValue, $xmlResponse) { $errorTitle = 'Unable to retrieve tracking'; $resultArr = array(); @@ -1207,7 +1215,7 @@ protected function _parseXmlTrackingResponse($trackingvalue, $xmlResponse) $arr = $xml->getXpath("//TrackResponse/Response/ResponseStatusCode/text()"); $success = (int)$arr[0][0]; - if($success===1){ + if ($success === 1) { $arr = $xml->getXpath("//TrackResponse/Shipment/Service/Description/text()"); $resultArr['service'] = (string)$arr[0]; @@ -1224,7 +1232,7 @@ protected function _parseXmlTrackingResponse($trackingvalue, $xmlResponse) $activityTags = $xml->getXpath("//TrackResponse/Shipment/Package/Activity"); if ($activityTags) { - $i=1; + $index = 1; foreach ($activityTags as $activityTag) { $addArr=array(); if (isset($activityTag->ActivityLocation->Address->City)) { @@ -1238,36 +1246,36 @@ protected function _parseXmlTrackingResponse($trackingvalue, $xmlResponse) } $dateArr = array(); $date = (string)$activityTag->Date;//YYYYMMDD - $dateArr[] = substr($date,0,4); - $dateArr[] = substr($date,4,2); - $dateArr[] = substr($date,-2,2); + $dateArr[] = substr($date, 0, 4); + $dateArr[] = substr($date, 4, 2); + $dateArr[] = substr($date, -2, 2); $timeArr = array(); $time = (string)$activityTag->Time;//HHMMSS - $timeArr[] = substr($time,0,2); - $timeArr[] = substr($time,2,2); - $timeArr[] = substr($time,-2,2); + $timeArr[] = substr($time, 0, 2); + $timeArr[] = substr($time, 2, 2); + $timeArr[] = substr($time, -2, 2); - if($i==1){ + if ($index === 1) { $resultArr['status'] = (string)$activityTag->Status->StatusType->Description; - $resultArr['deliverydate'] = implode('-',$dateArr);//YYYY-MM-DD - $resultArr['deliverytime'] = implode(':',$timeArr);//HH:MM:SS + $resultArr['deliverydate'] = implode('-', $dateArr);//YYYY-MM-DD + $resultArr['deliverytime'] = implode(':', $timeArr);//HH:MM:SS $resultArr['deliverylocation'] = (string)$activityTag->ActivityLocation->Description; $resultArr['signedby'] = (string)$activityTag->ActivityLocation->SignedForByName; if ($addArr) { - $resultArr['deliveryto']=implode(', ',$addArr); + $resultArr['deliveryto']=implode(', ', $addArr); } - }else{ - $tempArr=array(); + } else { + $tempArr = array(); $tempArr['activity'] = (string)$activityTag->Status->StatusType->Description; - $tempArr['deliverydate'] = implode('-',$dateArr);//YYYY-MM-DD - $tempArr['deliverytime'] = implode(':',$timeArr);//HH:MM:SS + $tempArr['deliverydate'] = implode('-', $dateArr);//YYYY-MM-DD + $tempArr['deliverytime'] = implode(':', $timeArr);//HH:MM:SS if ($addArr) { - $tempArr['deliverylocation']=implode(', ',$addArr); + $tempArr['deliverylocation']=implode(', ', $addArr); } $packageProgress[] = $tempArr; } - $i++; + $index++; } $resultArr['progressdetail'] = $packageProgress; } @@ -1281,20 +1289,18 @@ protected function _parseXmlTrackingResponse($trackingvalue, $xmlResponse) $this->_result = Mage::getModel('Mage_Shipping_Model_Tracking_Result'); } - $defaults = $this->getDefaults(); - if ($resultArr) { $tracking = Mage::getModel('Mage_Shipping_Model_Tracking_Result_Status'); $tracking->setCarrier('ups'); $tracking->setCarrierTitle($this->getConfigData('title')); - $tracking->setTracking($trackingvalue); + $tracking->setTracking($trackingValue); $tracking->addData($resultArr); $this->_result->append($tracking); } else { $error = Mage::getModel('Mage_Shipping_Model_Tracking_Result_Error'); $error->setCarrier('ups'); $error->setCarrierTitle($this->getConfigData('title')); - $error->setTracking($trackingvalue); + $error->setTracking($trackingValue); $error->setErrorMessage($errorTitle); $this->_result->append($error); } @@ -1309,10 +1315,12 @@ protected function _parseXmlTrackingResponse($trackingvalue, $xmlResponse) public function getResponse() { $statuses = ''; - if ($this->_result instanceof Mage_Shipping_Model_Tracking_Result){ - if ($trackings = $this->_result->getAllTrackings()) { - foreach ($trackings as $tracking){ - if($data = $tracking->getAllData()){ + if ($this->_result instanceof Mage_Shipping_Model_Tracking_Result) { + $trackings = $this->_result->getAllTrackings(); + if ($trackings) { + foreach ($trackings as $tracking) { + $data = $tracking->getAllData(); + if ($data) { if (isset($data['status'])) { $statuses .= Mage::helper('Mage_Usa_Helper_Data')->__($data['status']); } else { @@ -1335,13 +1343,13 @@ public function getResponse() */ public function getAllowedMethods() { - $allowed = explode(',', $this->getConfigData('allowed_methods')); - $arr = array(); - $isByCode = $this->getConfigData('type') == 'UPS_XML'; - foreach ($allowed as $k) { - $arr[$k] = $isByCode ? $this->getShipmentByCode($k) : $this->getCode('method', $k); - } - return $arr; + $allowed = explode(',', $this->getConfigData('allowed_methods')); + $arr = array(); + $isByCode = $this->getConfigData('type') == 'UPS_XML'; + foreach ($allowed as $code) { + $arr[$code] = $isByCode ? $this->getShipmentByCode($code) : $this->getCode('method', $code); + } + return $arr; } /** @@ -1510,6 +1518,8 @@ protected function _formShipmentRequest(Varien_Object $request) case self::DELIVERY_CONFIRMATION_SHIPMENT: $serviceOptionsNode = $shipmentPart->addChild('ShipmentServiceOptions'); break; + default: + break; } if (!is_null($serviceOptionsNode)) { $serviceOptionsNode @@ -1526,18 +1536,16 @@ protected function _formShipmentRequest(Varien_Object $request) 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 - )) { + || $request->getRecipientAddressCountryCode() == 'PR') //Puerto Rico + ) { $invoiceLineTotalPart = $shipmentPart->addChild('InvoiceLineTotal'); $invoiceLineTotalPart->addChild('CurrencyCode', $request->getBaseCurrencyCode()); $invoiceLineTotalPart->addChild('MonetaryValue', ceil($packageParams->getCustomsValue())); } $labelPart = $xmlRequest->addChild('LabelSpecification'); - $labelPart->addChild('LabelPrintMethod') - ->addChild('Code', 'GIF'); - $labelPart->addChild('LabelImageFormat') - ->addChild('Code', 'GIF'); + $labelPart->addChild('LabelPrintMethod')->addChild('Code', 'GIF'); + $labelPart->addChild('LabelImageFormat')->addChild('Code', 'GIF'); $this->setXMLAccessRequest(); $xmlRequest = $this->_xmlAccessRequest . $xmlRequest->asXml(); @@ -1556,19 +1564,17 @@ protected function _sendShipmentAcceptRequest(SimpleXMLElement $shipmentConfirmR $request = $xmlRequest->addChild('Request'); $request->addChild('RequestAction', 'ShipAccept'); $xmlRequest->addChild('ShipmentDigest', $shipmentConfirmResponse->ShipmentDigest); - $debugData = array('request' => $xmlRequest->asXML()); - try { - $url = $this->_defaultUrls['ShipAccept']; - $ch = curl_init($url); + try { + $ch = curl_init($this->getShipAcceptUrl()); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_xmlAccessRequest . $xmlRequest->asXML()); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, (boolean)$this->getConfigFlag('mode_xml')); - $xmlResponse = curl_exec ($ch); + $xmlResponse = curl_exec($ch); $debugData['result'] = $xmlResponse; $this->_setCachedQuotes($xmlRequest, $xmlResponse); @@ -1598,11 +1604,27 @@ protected function _sendShipmentAcceptRequest(SimpleXMLElement $shipmentConfirmR return $result; } + /** + * Get ship accept url + * + * @return string + */ + public function getShipAcceptUrl() + { + if ($this->getConfigData('is_account_live')) { + $url = $this->_liveUrls['ShipAccept']; + } else { + $url = $this->_defaultUrls['ShipAccept']; + } + return $url; + } + /** * Do shipment request to carrier web service, obtain Print Shipping Labels and process errors in response * * @param Varien_Object $request * @return Varien_Object + * @throws Exception */ protected function _doShipmentRequest(Varien_Object $request) { @@ -1612,10 +1634,7 @@ protected function _doShipmentRequest(Varien_Object $request) $xmlResponse = $this->_getCachedQuotes($xmlRequest); if ($xmlResponse === null) { - $url = $this->getConfigData('url'); - if (!$url) { - $url = $this->_defaultUrls['ShipConfirm']; - } + $url = $this->getShipConfirmUrl(); $debugData = array('request' => $xmlRequest); $ch = curl_init(); @@ -1657,6 +1676,26 @@ protected function _doShipmentRequest(Varien_Object $request) } } + /** + * Get ship confirm url + * + * @return string + */ + public function getShipConfirmUrl() + { + $url = $this->getConfigData('url'); + if (!$url) { + if ($this->getConfigData('is_account_live')) { + $url = $this->_liveUrls['ShipConfirm']; + return $url; + } else { + $url = $this->_defaultUrls['ShipConfirm']; + return $url; + } + } + return $url; + } + /** * Return container types of carrier * @@ -1665,26 +1704,22 @@ protected function _doShipmentRequest(Varien_Object $request) */ public function getContainerTypes(Varien_Object $params = null) { - if ($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) + 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 ) { $containerTypes = array(); if ($method == '07' // Worldwide Express || $method == '08' // Worldwide Expedited || $method == '65' // Worldwide Saver - ) { // Worldwide Expedited if ($method != '08') { @@ -1695,7 +1730,7 @@ public function getContainerTypes(Varien_Object $params = null) ); } $containerTypes = $containerTypes + array( - '03' => Mage::helper('Mage_Usa_Helper_Data')->__('UPS Tube'), + '03' => Mage::helper('Mage_Usa_Helper_Data')->__('UPS Tube'), '04' => Mage::helper('Mage_Usa_Helper_Data')->__('PAK'), '2a' => Mage::helper('Mage_Usa_Helper_Data')->__('Small Express Box'), '2b' => Mage::helper('Mage_Usa_Helper_Data')->__('Medium Express Box'), @@ -1767,6 +1802,9 @@ public function getDeliveryConfirmationTypes(Varien_Object $params = null) 1 => Mage::helper('Mage_Usa_Helper_Data')->__('Signature Required'), 2 => Mage::helper('Mage_Usa_Helper_Data')->__('Adult Signature Required'), ); + break; + default: + break; } array_unshift($deliveryConfirmationTypes, Mage::helper('Mage_Usa_Helper_Data')->__('Not Required')); @@ -1792,15 +1830,16 @@ public function getCustomizableContainerTypes() * Get delivery confirmation level based on origin/destination * Return null if delivery confirmation is not acceptable * - * @var string $countyDest + * @var string $countyDestination * @return int|null */ - protected function _getDeliveryConfirmationLevel($countyDest = null) { - if (is_null($countyDest)) { + protected function _getDeliveryConfirmationLevel($countyDestination = null) + { + if (is_null($countyDestination)) { return null; } - if ($countyDest == Mage_Usa_Model_Shipping_Carrier_Abstract::USA_COUNTRY_ID) { + if ($countyDestination == Mage_Usa_Model_Shipping_Carrier_Abstract::USA_COUNTRY_ID) { return self::DELIVERY_CONFIRMATION_PACKAGE; } diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Container.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Container.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Container.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Container.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/DestType.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Ups/Source/DestType.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/DestType.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Ups/Source/DestType.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Freemethod.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Freemethod.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Freemethod.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Freemethod.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Method.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Method.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Method.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Method.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Mode.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Mode.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Mode.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Mode.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/OriginShipment.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Ups/Source/OriginShipment.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/OriginShipment.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Ups/Source/OriginShipment.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Pickup.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Pickup.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Pickup.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Pickup.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Type.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Type.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Type.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Type.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Unitofmeasure.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Unitofmeasure.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Unitofmeasure.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Unitofmeasure.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Usps.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Usps.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps/Source/Container.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Usps/Source/Container.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps/Source/Container.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Usps/Source/Container.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps/Source/Freemethod.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Usps/Source/Freemethod.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps/Source/Freemethod.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Usps/Source/Freemethod.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps/Source/Machinable.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Usps/Source/Machinable.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps/Source/Machinable.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Usps/Source/Machinable.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps/Source/Method.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Usps/Source/Method.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps/Source/Method.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Usps/Source/Method.php diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps/Source/Size.php b/app/code/Mage/Usa/Model/Shipping/Carrier/Usps/Source/Size.php similarity index 100% rename from app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps/Source/Size.php rename to app/code/Mage/Usa/Model/Shipping/Carrier/Usps/Source/Size.php diff --git a/app/code/Mage/Usa/etc/adminhtml/system.xml b/app/code/Mage/Usa/etc/adminhtml/system.xml new file mode 100644 index 0000000000000..4a8097a7dc61b --- /dev/null +++ b/app/code/Mage/Usa/etc/adminhtml/system.xml @@ -0,0 +1,702 @@ + + + + +
    + + + + + + + + Mage_Backend_Model_Config_Source_Yesno + + + + Mage_Usa_Model_Shipping_Carrier_Dhl_Source_Method + 1 + + + + + + + Mage_Backend_Model_Config_Source_Enabledisable + + + + validate-number validate-zero-or-greater + + + + Mage_Backend_Model_Config_Source_Yesno + + + + Mage_Usa_Model_Shipping_Carrier_Dhl_Source_Dutypaymenttype + + + + free-method + Mage_Usa_Model_Shipping_Carrier_Dhl_Source_Freemethod + + + + + + + Mage_Shipping_Model_Source_HandlingType + + + + Mage_Shipping_Model_Source_HandlingAction + + + + validate-number validate-zero-or-greater + + + + validate-number validate-zero-or-greater + + + + Mage_Backend_Model_Config_Backend_Encrypted + + + + Mage_Backend_Model_Config_Backend_Encrypted + + + + Mage_Usa_Model_Shipping_Carrier_Abstract_Source_Requesttype + + + + Mage_Usa_Model_Shipping_Carrier_Dhl_Source_Shipmenttype + + + + Mage_Backend_Model_Config_Backend_Encrypted + + + + Mage_Backend_Model_Config_Backend_Encrypted + + + + + + + + + + shipping-applicable-country + Mage_Shipping_Model_Config_Source_Allspecificcountries + + + + Mage_Directory_Model_Config_Source_Country + 1 + + + + shipping-skip-hide + Mage_Backend_Model_Config_Source_Yesno + + + + + + + Mage_Backend_Model_Config_Source_Yesno + + + + validate-number validate-zero-or-greater + + + + Mage_Usa_Model_Shipping_Carrier_Dhl_Source_Protection_Value + + + + Used only when "Additional Protection Value" is set to "Configuration". Can contain only numeric amount. + + + + Mage_Usa_Model_Shipping_Carrier_Dhl_Source_Protection_Rounding + + + + Mage_Backend_Model_Config_Source_Yesno + + + + + + + + + + + + + Mage_Backend_Model_Config_Source_Locale_Weekdays + 1 + + + + Mage_Backend_Model_Config_Source_Locale_Weekdays + 1 + + + + Mage_Backend_Model_Config_Source_Yesno + + + + + + + Mage_Backend_Model_Config_Source_Yesno + + + + + + + Mage_Backend_Model_Config_Backend_Encrypted + Please make sure to use only digits here. No dashes are allowed. + + + + Mage_Backend_Model_Config_Backend_Encrypted + + + + Mage_Backend_Model_Config_Backend_Encrypted + + + + Mage_Backend_Model_Config_Backend_Encrypted + + + + Mage_Backend_Model_Config_Source_Yesno + + + + Mage_Usa_Model_Shipping_Carrier_Abstract_Source_Requesttype + + + + Mage_Usa_Model_Shipping_Carrier_Fedex_Source_Packaging + + + + Mage_Usa_Model_Shipping_Carrier_Fedex_Source_Dropoff + + + + validate-number validate-zero-or-greater + + + + Mage_Shipping_Model_Source_HandlingType + + + + Mage_Shipping_Model_Source_HandlingAction + + + + validate-number validate-zero-or-greater + + + + Mage_Backend_Model_Config_Source_Yesno + + + + Mage_Usa_Model_Shipping_Carrier_Fedex_Source_Method + 1 + + + + The field is applicable if the Smart Post method is selected. + + + + free-method + Mage_Usa_Model_Shipping_Carrier_Fedex_Source_Freemethod + + + + Mage_Backend_Model_Config_Source_Enabledisable + + + + validate-number validate-zero-or-greater + + + + + + + shipping-applicable-country + Mage_Shipping_Model_Config_Source_Allspecificcountries + + + + Mage_Directory_Model_Config_Source_Country + 1 + + + + Mage_Backend_Model_Config_Source_Yesno + + + + shipping-skip-hide + Mage_Backend_Model_Config_Source_Yesno + + + + + + + + + + Mage_Backend_Model_Config_Backend_Encrypted + + + + Mage_Backend_Model_Config_Source_Yesno + + + + Mage_Usa_Model_Shipping_Carrier_Ups_Source_Method + 1 + + + + Mage_Usa_Model_Shipping_Carrier_Abstract_Source_Requesttype + + + + Mage_Usa_Model_Shipping_Carrier_Ups_Source_Container + + + + Mage_Backend_Model_Config_Source_Enabledisable + + + + validate-number validate-zero-or-greater + + + + Mage_Usa_Model_Shipping_Carrier_Ups_Source_DestType + + + + free-method + Mage_Usa_Model_Shipping_Carrier_Ups_Source_Freemethod + + + + + + + + + + Mage_Shipping_Model_Source_HandlingType + + + + Mage_Shipping_Model_Source_HandlingAction + + + + validate-number validate-zero-or-greater + + + + validate-number validate-zero-or-greater + + + + validate-number validate-zero-or-greater + + + + Mage_Usa_Model_Shipping_Carrier_Ups_Source_OriginShipment + + + + Mage_Backend_Model_Config_Backend_Encrypted + + + + Mage_Usa_Model_Shipping_Carrier_Ups_Source_Pickup + + + + + + + + + + + + + Mage_Usa_Model_Shipping_Carrier_Ups_Source_Type + + + + Mage_Backend_Model_Config_Source_Yesno + + + + Mage_Usa_Model_Shipping_Carrier_Ups_Source_Unitofmeasure + + + + Mage_Backend_Model_Config_Backend_Encrypted + + + + Mage_Backend_Model_Config_Source_Yesno + + + + Required for negotiated rates; 6-character UPS. + + + + shipping-applicable-country + Mage_Shipping_Model_Config_Source_Allspecificcountries + + + + Mage_Directory_Model_Config_Source_Country + 1 + + + + shipping-skip-hide + Mage_Backend_Model_Config_Source_Yesno + + + + + + + Enables/Disables SSL verification of Magento server by UPS. + Mage_Usa_Model_Shipping_Carrier_Abstract_Source_Mode + + + + Mage_Backend_Model_Config_Source_Yesno + + + + + + + Mage_Backend_Model_Config_Source_Yesno + + + + + + + + + + + + + Mage_Backend_Model_Config_Backend_Encrypted + + + + Mage_Backend_Model_Config_Backend_Encrypted + + + + Mage_Usa_Model_Shipping_Carrier_Abstract_Source_Mode + + + + Mage_Usa_Model_Shipping_Carrier_Abstract_Source_Requesttype + + + + Mage_Usa_Model_Shipping_Carrier_Usps_Source_Container + + + + Mage_Usa_Model_Shipping_Carrier_Usps_Source_Size + + + + + LARGE + + + + + + LARGE + + + + + + LARGE + + + + + + LARGE + + + + + Mage_Usa_Model_Shipping_Carrier_Usps_Source_Machinable + + + + validate-number validate-zero-or-greater + + + + Mage_Shipping_Model_Source_HandlingType + + + + Mage_Shipping_Model_Source_HandlingAction + + + + validate-number validate-zero-or-greater + + + + Mage_Usa_Model_Shipping_Carrier_Usps_Source_Method + 1 + + + + free-method + Mage_Usa_Model_Shipping_Carrier_Usps_Source_Freemethod + + + + Mage_Backend_Model_Config_Source_Enabledisable + + + + validate-number validate-zero-or-greater + + + + + + + shipping-applicable-country + Mage_Shipping_Model_Config_Source_Allspecificcountries + + + + Mage_Directory_Model_Config_Source_Country + 1 + + + + Mage_Backend_Model_Config_Source_Yesno + + + + shipping-skip-hide + Mage_Backend_Model_Config_Source_Yesno + + + + + + + + + + Mage_Backend_Model_Config_Source_Yesno + + + + + + + + + + Mage_Backend_Model_Config_Backend_Encrypted + + + + Mage_Backend_Model_Config_Backend_Encrypted + + + + + + + Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Contenttype + + + + Mage_Shipping_Model_Source_HandlingType + + + + "Per Order" allows single handling fee for entire order. "Per Package" allows individual handling fee for each package. + Mage_Shipping_Model_Source_HandlingAction + + + + validate-number validate-zero-or-greater + + + + Allows breaking total order weight into smaller pieces if it exeeds 70 kg to ensure accurate calculation of shipping charges. + Mage_Backend_Model_Config_Source_Yesno + + + + Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Unitofmeasure + Mage_Usa_Block_Adminhtml_Dhl_Unitofmeasure + + + + Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Size + + + + + 1 + + + + + + 1 + + + + + + 1 + + + + + Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Doc + + D + + + + + Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Nondoc + + N + + + + + Package ready time after order submission (in hours) + + + + + + + free-method + Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Freedoc + + D + + + + + free-method + Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Freenondoc + + N + + + + + Mage_Backend_Model_Config_Source_Enabledisable + + + + validate-number validate-zero-or-greater + + + + shipping-applicable-country + Mage_Shipping_Model_Config_Source_Allspecificcountries + + + + Mage_Directory_Model_Config_Source_Country + 1 + + + + shipping-skip-hide + Mage_Backend_Model_Config_Source_Yesno + + + + + + + Mage_Backend_Model_Config_Source_Yesno + + +
    +
    +
    diff --git a/app/code/Mage/Usa/etc/config.xml b/app/code/Mage/Usa/etc/config.xml new file mode 100644 index 0000000000000..885f16c276705 --- /dev/null +++ b/app/code/Mage/Usa/etc/config.xml @@ -0,0 +1,230 @@ + + + + + + 1.6.0.1 + true + + + + + + + + + + + Mage_Usa + + + + + + + + Mage_Usa_Model_Shipping_Carrier_Ups + + + Mage_Usa_Model_Shipping_Carrier_Usps + + + Mage_Usa_Model_Shipping_Carrier_Fedex + + + Mage_Usa_Model_Shipping_Carrier_Dhl + + + Mage_Usa_Model_Shipping_Carrier_Dhl_International + + + + + + + + + + + + + + + Mage_Usa.csv + + + + + + + + + + + Mage_Usa.csv + + + + + + + + + + dhl + + + + + + + 0 + 0 + IE,E SAT,E 10:30AM,E,N,S,G + Big Box + + R + G + https://eCommerce.airborne.com/ApiLandingTest.asp + + Mage_Usa_Model_Shipping_Carrier_Dhl + + 0 + P + + + DHL (Deprecated) + This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us. + 150 + F + O + 1,2,3,4,5,6 + 1,2,3,4,5 + 0 + + + + + + + 0 + 0 + 0 + 0 + EUROPE_FIRST_INTERNATIONAL_PRIORITY,FEDEX_1_DAY_FREIGHT,FEDEX_2_DAY_FREIGHT,FEDEX_2_DAY,FEDEX_2_DAY_AM,FEDEX_3_DAY_FREIGHT,FEDEX_EXPRESS_SAVER,FEDEX_GROUND,FIRST_OVERNIGHT,GROUND_HOME_DELIVERY,INTERNATIONAL_ECONOMY,INTERNATIONAL_ECONOMY_FREIGHT,INTERNATIONAL_FIRST,INTERNATIONAL_GROUND,INTERNATIONAL_PRIORITY,INTERNATIONAL_PRIORITY_FREIGHT,PRIORITY_OVERNIGHT,SMART_POST,STANDARD_OVERNIGHT,FEDEX_FREIGHT,FEDEX_NATIONAL_FREIGHT + + REGULAR_PICKUP + FEDEX_GROUND + 0 + Mage_Usa_Model_Shipping_Carrier_Fedex + + YOUR_PACKAGING + Federal Express + This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us. + 150 + F + O + + + + 0 + 0 + 1DM,1DML,1DA,1DAL,1DAPI,1DP,1DPL,2DM,2DML,2DA,2DAL,3DS,GND,GNDCOM,GNDRES,STD,XPR,WXS,XPRL,XDM,XDML,XPD,01,02,03,07,08,11,12,14,54,59,65 + Shipments Originating in United States + 0 + CP + + RES + GND + http://www.ups.com/using/services/rave/qcostcgi.cgi + https://onlinetools.ups.com/ups.app/xml/Rate + 0 + Mage_Usa_Model_Shipping_Carrier_Ups + CC + United Parcel Service + https://www.ups.com/ups.app/xml/Track + LBS + + + This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us. + 0.1 + 150 + F + O + 0 + 1 + UPS + 0 + + + 0 + 0 + Bound Printed Matter,Express Mail,Express Mail Flat Rate Envelope,Express Mail Flat Rate Envelope Hold For Pickup,Express Mail Flat-Rate Envelope Sunday/Holiday Guarantee,Express Mail Hold For Pickup,Express Mail International,Express Mail International Flat Rate Envelope,Express Mail PO to PO,Express Mail Sunday/Holiday Guarantee,First-Class Mail International Large Envelope,First-Class Mail International Letter,First-Class Mail International Package,First-Class Mail International Parcel,First-Class,First-Class Mail,First-Class Mail Flat,First-Class Mail Large Envelope,First-Class Mail International,First-Class Mail Letter,First-Class Mail Parcel,First-Class Mail Package,Global Express Guaranteed (GXG),Global Express Guaranteed Non-Document Non-Rectangular,Global Express Guaranteed Non-Document Rectangular,Library Mail,Media Mail,Parcel Post,Priority Mail,Priority Mail Small Flat Rate Box,Priority Mail Medium Flat Rate Box,Priority Mail Large Flat Rate Box,Priority Mail Flat Rate Box,Priority Mail Flat Rate Envelope,Priority Mail International,Priority Mail International Flat Rate Box,Priority Mail International Flat Rate Envelope,Priority Mail International Small Flat Rate Box,Priority Mail International Medium Flat Rate Box,Priority Mail International Large Flat Rate Box,USPS GXG Envelopes + VARIABLE + + + http://production.shippingapis.com/ShippingAPI.dll + https://secure.shippingapis.com/ShippingAPI.dll + 0 + + true + Bound Printed Matter,Express Mail,Express Mail Flat Rate Envelope,Express Mail Flat Rate Envelope Hold For Pickup,Express Mail Flat-Rate Envelope Sunday/Holiday Guarantee,Express Mail Hold For Pickup,Express Mail International,Express Mail International Flat Rate Envelope,Express Mail PO to PO,Express Mail Sunday/Holiday Guarantee,First-Class Mail International Large Envelope,First-Class Mail International Letters,First-Class Mail International Package,First-Class Mail International Parcel,First-Class,First-Class Mail,First-Class Mail Flat,First-Class Mail Large Envelope,First-Class Mail International,First-Class Mail Letter,First-Class Mail Parcel,First-Class Mail Package,Global Express Guaranteed (GXG),Global Express Guaranteed Non-Document Non-Rectangular,Global Express Guaranteed Non-Document Rectangular,Library Mail,Media Mail,Parcel Post,Priority Mail,Priority Mail Small Flat Rate Box,Priority Mail Medium Flat Rate Box,Priority Mail Large Flat Rate Box,Priority Mail Flat Rate Box,Priority Mail Flat Rate Envelope,Priority Mail International,Priority Mail International Flat Rate Box,Priority Mail International Flat Rate Envelope,Priority Mail International Small Flat Rate Box,Priority Mail International Medium Flat Rate Box,Priority Mail International Large Flat Rate Box,USPS GXG Envelopes + Mage_Usa_Model_Shipping_Carrier_Usps + REGULAR + United States Postal Service + + + 0 + This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us. + 70 + F + O + + + Mage_Usa_Model_Shipping_Carrier_Dhl_International + + 0 + DHL + 0 + 1,3,4,8,P,Q,E,F,H,J,M,V,Y + 2,5,6,7,9,B,C,D,U,K,L,G,W,I,N,O,R,S,T,X + G + https://xmlpi-ea.dhl.com/XMLShippingServlet + + + N + This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us. + 1 + K + R + F + O + + + + diff --git a/app/code/core/Mage/Usa/etc/dhl/international/countries.xml b/app/code/Mage/Usa/etc/dhl/international/countries.xml similarity index 100% rename from app/code/core/Mage/Usa/etc/dhl/international/countries.xml rename to app/code/Mage/Usa/etc/dhl/international/countries.xml diff --git a/app/code/core/Mage/Usa/etc/wsdl/FedEx/RateService_v10.wsdl b/app/code/Mage/Usa/etc/wsdl/FedEx/RateService_v10.wsdl similarity index 100% rename from app/code/core/Mage/Usa/etc/wsdl/FedEx/RateService_v10.wsdl rename to app/code/Mage/Usa/etc/wsdl/FedEx/RateService_v10.wsdl diff --git a/app/code/core/Mage/Usa/etc/wsdl/FedEx/RateService_v9.wsdl b/app/code/Mage/Usa/etc/wsdl/FedEx/RateService_v9.wsdl similarity index 100% rename from app/code/core/Mage/Usa/etc/wsdl/FedEx/RateService_v9.wsdl rename to app/code/Mage/Usa/etc/wsdl/FedEx/RateService_v9.wsdl diff --git a/app/code/core/Mage/Usa/etc/wsdl/FedEx/ShipService_v10.wsdl b/app/code/Mage/Usa/etc/wsdl/FedEx/ShipService_v10.wsdl similarity index 100% rename from app/code/core/Mage/Usa/etc/wsdl/FedEx/ShipService_v10.wsdl rename to app/code/Mage/Usa/etc/wsdl/FedEx/ShipService_v10.wsdl diff --git a/app/code/core/Mage/Usa/etc/wsdl/FedEx/ShipService_v9.wsdl b/app/code/Mage/Usa/etc/wsdl/FedEx/ShipService_v9.wsdl similarity index 100% rename from app/code/core/Mage/Usa/etc/wsdl/FedEx/ShipService_v9.wsdl rename to app/code/Mage/Usa/etc/wsdl/FedEx/ShipService_v9.wsdl diff --git a/app/code/core/Mage/Usa/etc/wsdl/FedEx/TrackService_v5.wsdl b/app/code/Mage/Usa/etc/wsdl/FedEx/TrackService_v5.wsdl similarity index 100% rename from app/code/core/Mage/Usa/etc/wsdl/FedEx/TrackService_v5.wsdl rename to app/code/Mage/Usa/etc/wsdl/FedEx/TrackService_v5.wsdl diff --git a/app/code/core/Mage/Usa/locale/de_DE/Mage_Usa.csv b/app/code/Mage/Usa/locale/de_DE/Mage_Usa.csv similarity index 100% rename from app/code/core/Mage/Usa/locale/de_DE/Mage_Usa.csv rename to app/code/Mage/Usa/locale/de_DE/Mage_Usa.csv diff --git a/app/code/core/Mage/Usa/locale/en_US/Mage_Usa.csv b/app/code/Mage/Usa/locale/en_US/Mage_Usa.csv similarity index 100% rename from app/code/core/Mage/Usa/locale/en_US/Mage_Usa.csv rename to app/code/Mage/Usa/locale/en_US/Mage_Usa.csv diff --git a/app/code/core/Mage/Usa/locale/es_ES/Mage_Usa.csv b/app/code/Mage/Usa/locale/es_ES/Mage_Usa.csv similarity index 100% rename from app/code/core/Mage/Usa/locale/es_ES/Mage_Usa.csv rename to app/code/Mage/Usa/locale/es_ES/Mage_Usa.csv diff --git a/app/code/core/Mage/Usa/locale/fr_FR/Mage_Usa.csv b/app/code/Mage/Usa/locale/fr_FR/Mage_Usa.csv similarity index 100% rename from app/code/core/Mage/Usa/locale/fr_FR/Mage_Usa.csv rename to app/code/Mage/Usa/locale/fr_FR/Mage_Usa.csv diff --git a/app/code/core/Mage/Usa/locale/nl_NL/Mage_Usa.csv b/app/code/Mage/Usa/locale/nl_NL/Mage_Usa.csv similarity index 100% rename from app/code/core/Mage/Usa/locale/nl_NL/Mage_Usa.csv rename to app/code/Mage/Usa/locale/nl_NL/Mage_Usa.csv diff --git a/app/code/core/Mage/Usa/locale/pt_BR/Mage_Usa.csv b/app/code/Mage/Usa/locale/pt_BR/Mage_Usa.csv similarity index 100% rename from app/code/core/Mage/Usa/locale/pt_BR/Mage_Usa.csv rename to app/code/Mage/Usa/locale/pt_BR/Mage_Usa.csv diff --git a/app/code/core/Mage/Usa/locale/zh_CN/Mage_Usa.csv b/app/code/Mage/Usa/locale/zh_CN/Mage_Usa.csv similarity index 100% rename from app/code/core/Mage/Usa/locale/zh_CN/Mage_Usa.csv rename to app/code/Mage/Usa/locale/zh_CN/Mage_Usa.csv diff --git a/app/code/core/Mage/Usa/sql/usa_setup/install-1.6.0.0.php b/app/code/Mage/Usa/sql/usa_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/Usa/sql/usa_setup/install-1.6.0.0.php rename to app/code/Mage/Usa/sql/usa_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/Usa/sql/usa_setup/upgrade-1.6.0.0-1.6.0.1.php b/app/code/Mage/Usa/sql/usa_setup/upgrade-1.6.0.0-1.6.0.1.php similarity index 100% rename from app/code/core/Mage/Usa/sql/usa_setup/upgrade-1.6.0.0-1.6.0.1.php rename to app/code/Mage/Usa/sql/usa_setup/upgrade-1.6.0.0-1.6.0.1.php diff --git a/app/code/core/Mage/Usa/view/adminhtml/dhl/logo.jpg b/app/code/Mage/Usa/view/adminhtml/dhl/logo.jpg similarity index 100% rename from app/code/core/Mage/Usa/view/adminhtml/dhl/logo.jpg rename to app/code/Mage/Usa/view/adminhtml/dhl/logo.jpg diff --git a/app/code/core/Mage/Usa/view/adminhtml/dhl/unitofmeasure.phtml b/app/code/Mage/Usa/view/adminhtml/dhl/unitofmeasure.phtml similarity index 100% rename from app/code/core/Mage/Usa/view/adminhtml/dhl/unitofmeasure.phtml rename to app/code/Mage/Usa/view/adminhtml/dhl/unitofmeasure.phtml diff --git a/app/code/core/Mage/User/Block/Buttons.php b/app/code/Mage/User/Block/Buttons.php similarity index 100% rename from app/code/core/Mage/User/Block/Buttons.php rename to app/code/Mage/User/Block/Buttons.php diff --git a/app/code/core/Mage/User/Block/Role.php b/app/code/Mage/User/Block/Role.php similarity index 100% rename from app/code/core/Mage/User/Block/Role.php rename to app/code/Mage/User/Block/Role.php diff --git a/app/code/core/Mage/User/Block/Role/Edit.php b/app/code/Mage/User/Block/Role/Edit.php similarity index 100% rename from app/code/core/Mage/User/Block/Role/Edit.php rename to app/code/Mage/User/Block/Role/Edit.php diff --git a/app/code/core/Mage/User/Block/Role/Grid/User.php b/app/code/Mage/User/Block/Role/Grid/User.php similarity index 100% rename from app/code/core/Mage/User/Block/Role/Grid/User.php rename to app/code/Mage/User/Block/Role/Grid/User.php diff --git a/app/code/Mage/User/Block/Role/Tab/Edit.php b/app/code/Mage/User/Block/Role/Tab/Edit.php new file mode 100644 index 0000000000000..841a99f787947 --- /dev/null +++ b/app/code/Mage/User/Block/Role/Tab/Edit.php @@ -0,0 +1,196 @@ + + */ +class Mage_User_Block_Role_Tab_Edit extends Mage_Backend_Block_Widget_Form + implements Mage_Backend_Block_Widget_Tab_Interface +{ + + protected $_template = 'role/edit.phtml'; + + /** + * Get tab label + * + * @return string + */ + public function getTabLabel() + { + return Mage::helper('Mage_User_Helper_Data')->__('Role Resources'); + } + + /** + * Get tab title + * + * @return string + */ + public function getTabTitle() + { + return $this->getTabLabel(); + } + + /** + * Whether tab is available + * + * @return bool + */ + public function canShowTab() + { + return true; + } + + /** + * Whether tab is visible + * + * @return bool + */ + public function isHidden() + { + return false; + } + + + /** + * Class constructor + * + */ + protected function _construct() + { + parent::_construct(); + + $rid = Mage::app()->getRequest()->getParam('rid', false); + + $acl = Mage::getSingleton('Mage_Core_Model_Acl_Builder')->getAcl( + Mage_Core_Model_App_Area::AREA_ADMINHTML + ); + $rulesSet = Mage::getResourceModel('Mage_User_Model_Resource_Rules_Collection')->getByRoles($rid)->load(); + + $selectedResourceIds = array(); + + foreach ($rulesSet->getItems() as $item) { + $itemResourceId = $item->getResource_id(); + if ($acl->has($itemResourceId) && $item->getPermission() == 'allow') { + array_push($selectedResourceIds, $itemResourceId); + } + } + + $this->setSelectedResources($selectedResourceIds); + + + } + + /** + * Check if everything is allowed + * + * @return boolean + */ + public function isEverythingAllowed() + { + return in_array(Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL, $this->getSelectedResources()); + } + + /** + * Get Json Representation of Resource Tree + * + * @return string + */ + public function getResTreeJson() + { + + /** @var $aclConfig Mage_Backend_Model_Acl_Config */ + $aclConfig = Mage::getSingleton('Mage_Backend_Model_Acl_Config'); + $resources = $aclConfig->getAclResources(); + + $adminNode = $resources->item(1); + $rootArray = $this->_getNodeJson($adminNode, 1); + + $json = Mage::helper('Mage_Core_Helper_Data')->jsonEncode( + isset($rootArray['children']) ? $rootArray['children'] : array() + ); + + return $json; + } + + /** + * Compare two nodes of the Resource Tree + * + * @param array $a + * @param array $b + * @return boolean + */ + protected function _sortTree($nodeA, $nodeB) + { + return $nodeA['sortOrder']<$nodeB['sortOrder'] ? -1 : ($nodeA['sortOrder']>$nodeB['sortOrder'] ? 1 : 0); + } + + /** + * Get Node Json + * + * @param mixed $node + * @param int $level + * @return array + */ + protected function _getNodeJson(DomElement $node, $level = 0) + { + $item = array(); + $selres = $this->getSelectedResources(); + if ($level != 0) { + $item['text'] = Mage::helper('Mage_User_Helper_Data')->__((string)$node->getAttribute('title')); + // @codingStandardsIgnoreStart + $item['sortOrder'] = $node->hasAttribute('sortOrder') ? (string)$node->getAttribute('sortOrder') : 0; + // @codingStandardsIgnoreEnd + $item['id'] = (string)$node->getAttribute('id'); + + if (in_array($item['id'], $selres)) { + $item['checked'] = true; + } + } + $children = $node->childNodes; + if (!empty($children)) { + $item['children'] = array(); + //$item['cls'] = 'fiche-node'; + foreach ($children as $child) { + if ($child instanceof DOMElement) { + if (!(string)$child->getAttribute('title')) { + continue; + } + if ($level != 0) { + $item['children'][] = $this->_getNodeJson($child, $level+1); + } else { + $item = $this->_getNodeJson($child, $level+1); + } + } + } + usort($item['children'], array($this, '_sortTree')); + } + return $item; + } +} diff --git a/app/code/core/Mage/User/Block/Role/Tab/Info.php b/app/code/Mage/User/Block/Role/Tab/Info.php similarity index 100% rename from app/code/core/Mage/User/Block/Role/Tab/Info.php rename to app/code/Mage/User/Block/Role/Tab/Info.php diff --git a/app/code/core/Mage/User/Block/Role/Tab/Users.php b/app/code/Mage/User/Block/Role/Tab/Users.php similarity index 97% rename from app/code/core/Mage/User/Block/Role/Tab/Users.php rename to app/code/Mage/User/Block/Role/Tab/Users.php index a709701eb550c..d9b478b0c4b16 100644 --- a/app/code/core/Mage/User/Block/Role/Tab/Users.php +++ b/app/code/Mage/User/Block/Role/Tab/Users.php @@ -48,7 +48,7 @@ protected function _prepareLayout() return parent::_prepareLayout(); } - protected function _getGridHtml() + public function getGridHtml() { return $this->getChildHtml('userGrid'); } diff --git a/app/code/core/Mage/User/Block/User.php b/app/code/Mage/User/Block/User.php similarity index 100% rename from app/code/core/Mage/User/Block/User.php rename to app/code/Mage/User/Block/User.php diff --git a/app/code/core/Mage/User/Block/User/Edit.php b/app/code/Mage/User/Block/User/Edit.php similarity index 100% rename from app/code/core/Mage/User/Block/User/Edit.php rename to app/code/Mage/User/Block/User/Edit.php diff --git a/app/code/core/Mage/User/Block/User/Edit/Form.php b/app/code/Mage/User/Block/User/Edit/Form.php similarity index 100% rename from app/code/core/Mage/User/Block/User/Edit/Form.php rename to app/code/Mage/User/Block/User/Edit/Form.php diff --git a/app/code/core/Mage/User/Block/User/Edit/Tab/Main.php b/app/code/Mage/User/Block/User/Edit/Tab/Main.php similarity index 100% rename from app/code/core/Mage/User/Block/User/Edit/Tab/Main.php rename to app/code/Mage/User/Block/User/Edit/Tab/Main.php diff --git a/app/code/core/Mage/User/Block/User/Edit/Tab/Roles.php b/app/code/Mage/User/Block/User/Edit/Tab/Roles.php similarity index 100% rename from app/code/core/Mage/User/Block/User/Edit/Tab/Roles.php rename to app/code/Mage/User/Block/User/Edit/Tab/Roles.php diff --git a/app/code/core/Mage/User/Block/User/Edit/Tabs.php b/app/code/Mage/User/Block/User/Edit/Tabs.php similarity index 100% rename from app/code/core/Mage/User/Block/User/Edit/Tabs.php rename to app/code/Mage/User/Block/User/Edit/Tabs.php diff --git a/app/code/core/Mage/User/Helper/Data.php b/app/code/Mage/User/Helper/Data.php similarity index 100% rename from app/code/core/Mage/User/Helper/Data.php rename to app/code/Mage/User/Helper/Data.php diff --git a/app/code/core/Mage/User/Model/Acl/Loader/Role.php b/app/code/Mage/User/Model/Acl/Loader/Role.php similarity index 100% rename from app/code/core/Mage/User/Model/Acl/Loader/Role.php rename to app/code/Mage/User/Model/Acl/Loader/Role.php diff --git a/app/code/core/Mage/User/Model/Acl/Loader/Rule.php b/app/code/Mage/User/Model/Acl/Loader/Rule.php similarity index 100% rename from app/code/core/Mage/User/Model/Acl/Loader/Rule.php rename to app/code/Mage/User/Model/Acl/Loader/Rule.php diff --git a/app/code/core/Mage/User/Model/Acl/Role/Generic.php b/app/code/Mage/User/Model/Acl/Role/Generic.php similarity index 100% rename from app/code/core/Mage/User/Model/Acl/Role/Generic.php rename to app/code/Mage/User/Model/Acl/Role/Generic.php diff --git a/app/code/core/Mage/User/Model/Acl/Role/Group.php b/app/code/Mage/User/Model/Acl/Role/Group.php similarity index 100% rename from app/code/core/Mage/User/Model/Acl/Role/Group.php rename to app/code/Mage/User/Model/Acl/Role/Group.php diff --git a/app/code/core/Mage/User/Model/Acl/Role/User.php b/app/code/Mage/User/Model/Acl/Role/User.php similarity index 100% rename from app/code/core/Mage/User/Model/Acl/Role/User.php rename to app/code/Mage/User/Model/Acl/Role/User.php diff --git a/app/code/core/Mage/User/Model/Resource/Permissions/Collection.php b/app/code/Mage/User/Model/Resource/Permissions/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/User/Model/Resource/Permissions/Collection.php rename to app/code/Mage/User/Model/Resource/Permissions/Collection.php diff --git a/app/code/core/Mage/User/Model/Resource/Role.php b/app/code/Mage/User/Model/Resource/Role.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/User/Model/Resource/Role.php rename to app/code/Mage/User/Model/Resource/Role.php diff --git a/app/code/core/Mage/User/Model/Resource/Role/Collection.php b/app/code/Mage/User/Model/Resource/Role/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/User/Model/Resource/Role/Collection.php rename to app/code/Mage/User/Model/Resource/Role/Collection.php diff --git a/app/code/core/Mage/User/Model/Resource/Role/Grid/Collection.php b/app/code/Mage/User/Model/Resource/Role/Grid/Collection.php similarity index 100% rename from app/code/core/Mage/User/Model/Resource/Role/Grid/Collection.php rename to app/code/Mage/User/Model/Resource/Role/Grid/Collection.php diff --git a/app/code/core/Mage/User/Model/Resource/Role/User/Collection.php b/app/code/Mage/User/Model/Resource/Role/User/Collection.php similarity index 100% rename from app/code/core/Mage/User/Model/Resource/Role/User/Collection.php rename to app/code/Mage/User/Model/Resource/Role/User/Collection.php diff --git a/app/code/core/Mage/User/Model/Resource/Rules.php b/app/code/Mage/User/Model/Resource/Rules.php old mode 100755 new mode 100644 similarity index 96% rename from app/code/core/Mage/User/Model/Resource/Rules.php rename to app/code/Mage/User/Model/Resource/Rules.php index 21b5616f4ba99..3faedd64e0d41 --- a/app/code/core/Mage/User/Model/Resource/Rules.php +++ b/app/code/Mage/User/Model/Resource/Rules.php @@ -77,7 +77,9 @@ public function saveRel(Mage_User_Model_Rules $rule) $adapter->insert($this->getMainTable(), $insertData); } else { - $acl = Mage::getSingleton('Mage_Core_Model_Acl_Builder')->getAcl(); + $acl = Mage::getSingleton('Mage_Core_Model_Acl_Builder')->getAcl( + Mage_Core_Model_App_Area::AREA_ADMINHTML + ); /** @var $resource Magento_Acl_Resource */ foreach ($acl->getResources() as $resourceId) { $row['permission'] = in_array($resourceId, $postedResources) ? 'allow' : 'deny'; diff --git a/app/code/core/Mage/User/Model/Resource/Rules/Collection.php b/app/code/Mage/User/Model/Resource/Rules/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/User/Model/Resource/Rules/Collection.php rename to app/code/Mage/User/Model/Resource/Rules/Collection.php diff --git a/app/code/core/Mage/User/Model/Resource/User.php b/app/code/Mage/User/Model/Resource/User.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/User/Model/Resource/User.php rename to app/code/Mage/User/Model/Resource/User.php diff --git a/app/code/core/Mage/User/Model/Resource/User/Collection.php b/app/code/Mage/User/Model/Resource/User/Collection.php old mode 100755 new mode 100644 similarity index 100% rename from app/code/core/Mage/User/Model/Resource/User/Collection.php rename to app/code/Mage/User/Model/Resource/User/Collection.php diff --git a/app/code/core/Mage/User/Model/Resource/User/Locked/Collection.php b/app/code/Mage/User/Model/Resource/User/Locked/Collection.php similarity index 100% rename from app/code/core/Mage/User/Model/Resource/User/Locked/Collection.php rename to app/code/Mage/User/Model/Resource/User/Locked/Collection.php diff --git a/app/code/core/Mage/User/Model/Role.php b/app/code/Mage/User/Model/Role.php similarity index 100% rename from app/code/core/Mage/User/Model/Role.php rename to app/code/Mage/User/Model/Role.php diff --git a/app/code/core/Mage/User/Model/Rules.php b/app/code/Mage/User/Model/Rules.php similarity index 100% rename from app/code/core/Mage/User/Model/Rules.php rename to app/code/Mage/User/Model/Rules.php diff --git a/app/code/core/Mage/User/Model/Statuses.php b/app/code/Mage/User/Model/Statuses.php similarity index 100% rename from app/code/core/Mage/User/Model/Statuses.php rename to app/code/Mage/User/Model/Statuses.php diff --git a/app/code/core/Mage/User/Model/User.php b/app/code/Mage/User/Model/User.php similarity index 100% rename from app/code/core/Mage/User/Model/User.php rename to app/code/Mage/User/Model/User.php diff --git a/app/code/core/Mage/User/controllers/Adminhtml/AuthController.php b/app/code/Mage/User/controllers/Adminhtml/AuthController.php similarity index 100% rename from app/code/core/Mage/User/controllers/Adminhtml/AuthController.php rename to app/code/Mage/User/controllers/Adminhtml/AuthController.php diff --git a/app/code/core/Mage/User/controllers/Adminhtml/User/RoleController.php b/app/code/Mage/User/controllers/Adminhtml/User/RoleController.php similarity index 100% rename from app/code/core/Mage/User/controllers/Adminhtml/User/RoleController.php rename to app/code/Mage/User/controllers/Adminhtml/User/RoleController.php diff --git a/app/code/core/Mage/User/controllers/Adminhtml/UserController.php b/app/code/Mage/User/controllers/Adminhtml/UserController.php similarity index 100% rename from app/code/core/Mage/User/controllers/Adminhtml/UserController.php rename to app/code/Mage/User/controllers/Adminhtml/UserController.php diff --git a/app/code/core/Mage/User/data/user_setup/data-install-1.6.0.0.php b/app/code/Mage/User/data/user_setup/data-install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/User/data/user_setup/data-install-1.6.0.0.php rename to app/code/Mage/User/data/user_setup/data-install-1.6.0.0.php diff --git a/app/code/core/Mage/User/data/user_setup/data-upgrade-1.6.1.1-1.6.1.2.php b/app/code/Mage/User/data/user_setup/data-upgrade-1.6.1.1-1.6.1.2.php similarity index 100% rename from app/code/core/Mage/User/data/user_setup/data-upgrade-1.6.1.1-1.6.1.2.php rename to app/code/Mage/User/data/user_setup/data-upgrade-1.6.1.1-1.6.1.2.php diff --git a/app/code/Mage/User/data/user_setup/data-upgrade-1.6.1.3-1.6.1.4.php b/app/code/Mage/User/data/user_setup/data-upgrade-1.6.1.3-1.6.1.4.php new file mode 100644 index 0000000000000..4c3be01a3ff69 --- /dev/null +++ b/app/code/Mage/User/data/user_setup/data-upgrade-1.6.1.3-1.6.1.4.php @@ -0,0 +1,49 @@ +startSetup(); + +$tableName = $installer->getTable('admin_rule'); + +if ($tableName) { + /** @var Varien_Db_Adapter_Interface $connection */ + $connection = $installer->getConnection(); + $remove = array( + 'Mage_Catalog::catalog_attributes', + 'Mage_Cms::cms', + 'Mage_Newsletter::admin_newsletter', + 'Mage_Review::pending', + 'Mage_Review::reviews', + 'Mage_Review::reviews_ratings', + 'Mage_Tag::tag', + 'Mage_Tag::tag_pending', + ); + $connection->delete($tableName, array('resource_id IN (?)' => $remove)); +} + +$installer->endSetup(); \ No newline at end of file diff --git a/app/code/Mage/User/etc/adminhtml/acl.xml b/app/code/Mage/User/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..493437fb89ec7 --- /dev/null +++ b/app/code/Mage/User/etc/adminhtml/acl.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + diff --git a/app/code/Mage/User/etc/adminhtml/menu.xml b/app/code/Mage/User/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..0c598b5a6a990 --- /dev/null +++ b/app/code/Mage/User/etc/adminhtml/menu.xml @@ -0,0 +1,34 @@ + + + + + + + + + diff --git a/app/code/Mage/User/etc/config.xml b/app/code/Mage/User/etc/config.xml new file mode 100644 index 0000000000000..9f0c81cf1c249 --- /dev/null +++ b/app/code/Mage/User/etc/config.xml @@ -0,0 +1,100 @@ + + + + + + 1.6.1.4 + true + + + + + + + Mage_User_Model_User + + + Mage_User_Model_Acl_Loader_Rule + Mage_User_Model_Acl_Loader_Role + + + + + + + Mage_User + + + + + + 0 + 0 + + Mage_User_Model_User + + + + + + + admin_emails_forgot_email_template + general + 1 + + + + + + + + + Mage_User_Adminhtml + + + + + + + + + + layout.xml + + + + + diff --git a/app/code/core/Mage/User/sql/user_setup/install-1.6.0.0.php b/app/code/Mage/User/sql/user_setup/install-1.6.0.0.php similarity index 100% rename from app/code/core/Mage/User/sql/user_setup/install-1.6.0.0.php rename to app/code/Mage/User/sql/user_setup/install-1.6.0.0.php diff --git a/app/code/core/Mage/User/sql/user_setup/upgrade-1.6.0.0-1.6.1.0.php b/app/code/Mage/User/sql/user_setup/upgrade-1.6.0.0-1.6.1.0.php similarity index 100% rename from app/code/core/Mage/User/sql/user_setup/upgrade-1.6.0.0-1.6.1.0.php rename to app/code/Mage/User/sql/user_setup/upgrade-1.6.0.0-1.6.1.0.php diff --git a/app/code/core/Mage/User/sql/user_setup/upgrade-1.6.1.0-1.6.1.1.php b/app/code/Mage/User/sql/user_setup/upgrade-1.6.1.0-1.6.1.1.php similarity index 100% rename from app/code/core/Mage/User/sql/user_setup/upgrade-1.6.1.0-1.6.1.1.php rename to app/code/Mage/User/sql/user_setup/upgrade-1.6.1.0-1.6.1.1.php diff --git a/app/code/core/Mage/User/sql/user_setup/upgrade-1.6.1.2-1.6.1.3.php b/app/code/Mage/User/sql/user_setup/upgrade-1.6.1.2-1.6.1.3.php similarity index 100% rename from app/code/core/Mage/User/sql/user_setup/upgrade-1.6.1.2-1.6.1.3.php rename to app/code/Mage/User/sql/user_setup/upgrade-1.6.1.2-1.6.1.3.php diff --git a/app/code/core/Mage/User/view/adminhtml/admin/forgotpassword.phtml b/app/code/Mage/User/view/adminhtml/admin/forgotpassword.phtml similarity index 99% rename from app/code/core/Mage/User/view/adminhtml/admin/forgotpassword.phtml rename to app/code/Mage/User/view/adminhtml/admin/forgotpassword.phtml index a6d47db27a7d8..767fba0a3900e 100644 --- a/app/code/core/Mage/User/view/adminhtml/admin/forgotpassword.phtml +++ b/app/code/Mage/User/view/adminhtml/admin/forgotpassword.phtml @@ -41,15 +41,15 @@ - + + - diff --git a/app/code/core/Mage/User/view/adminhtml/admin/forgotpassword_url.phtml b/app/code/Mage/User/view/adminhtml/admin/forgotpassword_url.phtml similarity index 100% rename from app/code/core/Mage/User/view/adminhtml/admin/forgotpassword_url.phtml rename to app/code/Mage/User/view/adminhtml/admin/forgotpassword_url.phtml diff --git a/app/code/core/Mage/User/view/adminhtml/admin/resetforgottenpassword.phtml b/app/code/Mage/User/view/adminhtml/admin/resetforgottenpassword.phtml similarity index 99% rename from app/code/core/Mage/User/view/adminhtml/admin/resetforgottenpassword.phtml rename to app/code/Mage/User/view/adminhtml/admin/resetforgottenpassword.phtml index dd72e12d35d58..74f306d120134 100644 --- a/app/code/core/Mage/User/view/adminhtml/admin/resetforgottenpassword.phtml +++ b/app/code/Mage/User/view/adminhtml/admin/resetforgottenpassword.phtml @@ -40,7 +40,7 @@ - + diff --git a/app/code/core/Mage/User/view/adminhtml/layout.xml b/app/code/Mage/User/view/adminhtml/layout.xml similarity index 100% rename from app/code/core/Mage/User/view/adminhtml/layout.xml rename to app/code/Mage/User/view/adminhtml/layout.xml diff --git a/app/code/Mage/User/view/adminhtml/role/edit.phtml b/app/code/Mage/User/view/adminhtml/role/edit.phtml new file mode 100644 index 0000000000000..1971f019dbbfa --- /dev/null +++ b/app/code/Mage/User/view/adminhtml/role/edit.phtml @@ -0,0 +1,164 @@ + + + + +getChildHtml(); ?> + + + +
    + __('Roles Resources') ?> + +
    + +
    + +
    +
    + +
    + +
    +
    + +
    + + + diff --git a/app/code/Mage/User/view/adminhtml/role/info.phtml b/app/code/Mage/User/view/adminhtml/role/info.phtml new file mode 100644 index 0000000000000..eea721c1bedd9 --- /dev/null +++ b/app/code/Mage/User/view/adminhtml/role/info.phtml @@ -0,0 +1,40 @@ + +
    + getBackButtonHtml() ?> + getResetButtonHtml() ?> + getDeleteButtonHtml() ?> + getSaveButtonHtml() ?> +
    +
    + getBlockHtml('formkey')?> +
    + diff --git a/app/code/core/Mage/User/view/adminhtml/role/users.phtml b/app/code/Mage/User/view/adminhtml/role/users.phtml similarity index 96% rename from app/code/core/Mage/User/view/adminhtml/role/users.phtml rename to app/code/Mage/User/view/adminhtml/role/users.phtml index 38fd74195f7ce..f0a18829607a1 100644 --- a/app/code/core/Mage/User/view/adminhtml/role/users.phtml +++ b/app/code/Mage/User/view/adminhtml/role/users.phtml @@ -25,4 +25,4 @@ */ ?>

    __('Role Users') ?>

    -_getGridHtml() ?> +getGridHtml() ?> diff --git a/app/code/core/Mage/User/view/adminhtml/role/users_grid_js.phtml b/app/code/Mage/User/view/adminhtml/role/users_grid_js.phtml similarity index 98% rename from app/code/core/Mage/User/view/adminhtml/role/users_grid_js.phtml rename to app/code/Mage/User/view/adminhtml/role/users_grid_js.phtml index 66da342d58c12..ed6a82f798dc4 100644 --- a/app/code/core/Mage/User/view/adminhtml/role/users_grid_js.phtml +++ b/app/code/Mage/User/view/adminhtml/role/users_grid_js.phtml @@ -28,7 +28,7 @@ + + + + + + + + + + + + + + + diff --git a/app/code/Mage/Webapi/etc/adminhtml/menu.xml b/app/code/Mage/Webapi/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..b66b632b46372 --- /dev/null +++ b/app/code/Mage/Webapi/etc/adminhtml/menu.xml @@ -0,0 +1,35 @@ + + + + + + + + + + diff --git a/app/code/core/Mage/Webapi/etc/adminhtml/system.xml b/app/code/Mage/Webapi/etc/adminhtml/system.xml similarity index 100% rename from app/code/core/Mage/Webapi/etc/adminhtml/system.xml rename to app/code/Mage/Webapi/etc/adminhtml/system.xml diff --git a/app/code/Mage/Webapi/etc/config.xml b/app/code/Mage/Webapi/etc/config.xml new file mode 100644 index 0000000000000..20ce1b74be4b7 --- /dev/null +++ b/app/code/Mage/Webapi/etc/config.xml @@ -0,0 +1,169 @@ + + + + + + 1.0.0.3 + true + + + + + + + + + + + webapi + Mage_Webapi_Controller_Front + + Mage_Webapi_Controller_ActionAbstract + + Magento_Authorization_Policy_Acl + Mage_Webapi_Model_Authorization_Loader_Resource + Mage_Webapi_Model_Authorization_Loader_Role + Mage_Webapi_Model_Authorization_Loader_Rule + Mage_Webapi_Model_Authorization_RoleLocator + + + + + + + Mage_Webapi + + + + + + + + REST and SOAP configurations, generated WSDL file. + Mage_Webapi_Model_Cache_Type + + + + + + + + + + application/json + Mage_Webapi_Controller_Request_Rest_Interpreter_Json + + + + + application/xml + Mage_Webapi_Controller_Request_Rest_Interpreter_Xml + + + application/xhtml+xml + Mage_Webapi_Controller_Request_Rest_Interpreter_Xml + + + text/xml + Mage_Webapi_Controller_Request_Rest_Interpreter_Xml + + + + + + + + */* + Mage_Webapi_Controller_Response_Rest_Renderer_Json + + + application/json + Mage_Webapi_Controller_Response_Rest_Renderer_Json + + + + + text/xml + Mage_Webapi_Controller_Response_Rest_Renderer_Xml + + + application/xml + Mage_Webapi_Controller_Response_Rest_Renderer_Xml + + + application/xhtml+xml + Mage_Webapi_Controller_Response_Rest_Renderer_Xml + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + Mage_Webapi_Model_Authorization_Config + + + + + + + + + + Mage_Webapi_Adminhtml + + + + + + + + + + layout.xml + + + + + diff --git a/app/code/core/Mage/Webapi/etc/validation.xml b/app/code/Mage/Webapi/etc/validation.xml similarity index 100% rename from app/code/core/Mage/Webapi/etc/validation.xml rename to app/code/Mage/Webapi/etc/validation.xml diff --git a/app/code/core/Mage/Webapi/sql/webapi_setup/install-1.0.0.0.php b/app/code/Mage/Webapi/sql/webapi_setup/install-1.0.0.0.php similarity index 100% rename from app/code/core/Mage/Webapi/sql/webapi_setup/install-1.0.0.0.php rename to app/code/Mage/Webapi/sql/webapi_setup/install-1.0.0.0.php diff --git a/app/code/core/Mage/Webapi/sql/webapi_setup/upgrade-1.0.0.0-1.0.0.1.php b/app/code/Mage/Webapi/sql/webapi_setup/upgrade-1.0.0.0-1.0.0.1.php similarity index 100% rename from app/code/core/Mage/Webapi/sql/webapi_setup/upgrade-1.0.0.0-1.0.0.1.php rename to app/code/Mage/Webapi/sql/webapi_setup/upgrade-1.0.0.0-1.0.0.1.php diff --git a/app/code/core/Mage/Webapi/sql/webapi_setup/upgrade-1.0.0.1-1.0.0.2.php b/app/code/Mage/Webapi/sql/webapi_setup/upgrade-1.0.0.1-1.0.0.2.php similarity index 100% rename from app/code/core/Mage/Webapi/sql/webapi_setup/upgrade-1.0.0.1-1.0.0.2.php rename to app/code/Mage/Webapi/sql/webapi_setup/upgrade-1.0.0.1-1.0.0.2.php diff --git a/app/code/core/Mage/Webapi/sql/webapi_setup/upgrade-1.0.0.2-1.0.0.3.php b/app/code/Mage/Webapi/sql/webapi_setup/upgrade-1.0.0.2-1.0.0.3.php similarity index 100% rename from app/code/core/Mage/Webapi/sql/webapi_setup/upgrade-1.0.0.2-1.0.0.3.php rename to app/code/Mage/Webapi/sql/webapi_setup/upgrade-1.0.0.2-1.0.0.3.php diff --git a/app/code/core/Mage/Webapi/view/adminhtml/layout.xml b/app/code/Mage/Webapi/view/adminhtml/layout.xml similarity index 100% rename from app/code/core/Mage/Webapi/view/adminhtml/layout.xml rename to app/code/Mage/Webapi/view/adminhtml/layout.xml diff --git a/app/code/core/Mage/Webapi/view/adminhtml/rolesedit.phtml b/app/code/Mage/Webapi/view/adminhtml/rolesedit.phtml similarity index 100% rename from app/code/core/Mage/Webapi/view/adminhtml/rolesedit.phtml rename to app/code/Mage/Webapi/view/adminhtml/rolesedit.phtml diff --git a/app/code/core/Mage/Webapi/view/adminhtml/rolesusersgridjs.phtml b/app/code/Mage/Webapi/view/adminhtml/rolesusersgridjs.phtml similarity index 100% rename from app/code/core/Mage/Webapi/view/adminhtml/rolesusersgridjs.phtml rename to app/code/Mage/Webapi/view/adminhtml/rolesusersgridjs.phtml diff --git a/app/code/Mage/Webhook/Block/Adminhtml/Registration/Activate.php b/app/code/Mage/Webhook/Block/Adminhtml/Registration/Activate.php new file mode 100644 index 0000000000000..a9c6a1e9c1979 --- /dev/null +++ b/app/code/Mage/Webhook/Block/Adminhtml/Registration/Activate.php @@ -0,0 +1,52 @@ +setTemplate('Mage_Webhook::registration/activate.phtml'); + } + + public function getAcceptUrl() + { + return $this->getUrl('*/*/accept', array('id' => $this->getSubscriber()->getId())); + } + + public function getSubscriber() + { + return Mage::registry('current_subscriber'); + } + + /** + * @return array + */ + public function getUnavailableTopics() + { + return $this->getSubscriber()->getSubscribedCallbackTopics(); + } +} diff --git a/app/code/Mage/Webhook/Block/Adminhtml/Registration/Create/Container.php b/app/code/Mage/Webhook/Block/Adminhtml/Registration/Create/Container.php new file mode 100644 index 0000000000000..12982f1efe127 --- /dev/null +++ b/app/code/Mage/Webhook/Block/Adminhtml/Registration/Create/Container.php @@ -0,0 +1,44 @@ +setTemplate('Mage_Webhook::registration/create/container.phtml'); + } + + public function getSubmitUrl() + { + return $this->getUrl('*/*/register', array('id' => $this->getSubscriber()->getId())); + } + + public function getSubscriber() + { + return Mage::registry('current_subscriber'); + } +} diff --git a/app/code/Mage/Webhook/Block/Adminhtml/Registration/Create/Form.php b/app/code/Mage/Webhook/Block/Adminhtml/Registration/Create/Form.php new file mode 100644 index 0000000000000..78a571e23db93 --- /dev/null +++ b/app/code/Mage/Webhook/Block/Adminhtml/Registration/Create/Form.php @@ -0,0 +1,91 @@ +generateRandomString(self::API_KEY_LENGTH); + $api_secret = $helper->generateRandomString(self::API_SECRET_LENGTH); + $input_length = max(self::API_KEY_LENGTH, self::API_SECRET_LENGTH, self::MIN_TEXT_INPUT_LENGTH); + + /** @var $form Varien_Data_Form */ + $form = new Varien_Data_Form(array( + 'id' => 'api_user', + 'action' => $this->getUrl('*/*/register', array('id' => $subscriber->getId())), + 'method' => 'post', + ) + ); + +// $fieldset = $form->addFieldset('api_user_fieldset', array('legend' => $this->__('Create API User'))); + $fieldset = $form; + + $fieldset->addField('company', 'text', array( + 'label' => $this->__('Company'), + 'name' => 'company', + 'size' => $input_length, + )); + + $fieldset->addField('email', 'text', array( + 'label' => $this->__('Contact Email'), + 'name' => 'email', + 'class' => 'email', + 'required' => true, + 'size' => $input_length, + )); + + $fieldset->addField('apikey', 'text', array( + 'label' => $this->__('API Key'), + 'name' => 'apikey', + 'value' => $api_key, + 'class' => 'monospace', + 'required' => true, + 'size' => $input_length, + )); + + $fieldset->addField('apisecret', 'text', array( + 'label' => $this->__('API Secret'), + 'name' => 'apisecret', + 'value' => $api_secret, + 'class' => 'monospace', + 'required' => true, + 'size' => $input_length, + )); + + $form->setUseContainer(true); + + $this->setForm($form); + + return parent::_prepareForm(); + } +} \ No newline at end of file diff --git a/app/code/Mage/Webhook/Block/Adminhtml/Registration/Failed.php b/app/code/Mage/Webhook/Block/Adminhtml/Registration/Failed.php new file mode 100644 index 0000000000000..b805f00d9716f --- /dev/null +++ b/app/code/Mage/Webhook/Block/Adminhtml/Registration/Failed.php @@ -0,0 +1,46 @@ +setTemplate('registration/failed.phtml'); + } + + public function getSessionError() + { + return $this->_getSession()->getMessages(true) + ->getLastAddedMessage() + ->toString(); + } + + protected function _getSession() + { + return Mage::getSingleton('Mage_Backend_Model_Session'); + } +} diff --git a/app/code/Mage/Webhook/Block/Adminhtml/Registration/Succeeded.php b/app/code/Mage/Webhook/Block/Adminhtml/Registration/Succeeded.php new file mode 100644 index 0000000000000..931d2fa20d5a3 --- /dev/null +++ b/app/code/Mage/Webhook/Block/Adminhtml/Registration/Succeeded.php @@ -0,0 +1,33 @@ +setTemplate('registration/succeeded.phtml'); + } +} diff --git a/app/code/Mage/Webhook/Block/Adminhtml/Subscriber.php b/app/code/Mage/Webhook/Block/Adminhtml/Subscriber.php new file mode 100644 index 0000000000000..2f7d91dfa7834 --- /dev/null +++ b/app/code/Mage/Webhook/Block/Adminhtml/Subscriber.php @@ -0,0 +1,48 @@ +_headerText = $this->__('Subscribers'); + $this->_addButtonLabel = $this->__('Add Subscriber'); + } +} diff --git a/app/code/Mage/Webhook/Block/Adminhtml/Subscriber/Edit.php b/app/code/Mage/Webhook/Block/Adminhtml/Subscriber/Edit.php new file mode 100644 index 0000000000000..ed59ea3b7ff62 --- /dev/null +++ b/app/code/Mage/Webhook/Block/Adminhtml/Subscriber/Edit.php @@ -0,0 +1,73 @@ +_objectId = 'id'; + $this->_blockGroup = 'Mage_Webhook'; + $this->_controller = 'adminhtml_subscriber'; + + $subscriber = Mage::registry('current_subscriber'); + + // Don't allow the merchant to delete subscribers that were generated by config file. + if ($subscriber && $subscriber instanceof Mage_Webhook_Model_Subscriber && $subscriber->getExtensionId()) { + $this->_removeButton('delete'); + } + + if ($this->_isExistingSubscriber()) { + // Adding the test button to the top of the container for now, don't know of a better place to put it + // I've considered adding it to a new form that shows up after this container with a drop down to select + // what message to send. Simpler to just put it at the top and send a generic 'ping' message. + $this->addButton('test', array( 'label' => $this->__('Test'), + 'onclick' => 'setLocation(\'' . $this->getTestUrl() . '\')', + ) + ); + } + } + + public function getTestUrl() + { + return $this->getUrl('*/*/test', array($this->_objectId => $this->getRequest()->getParam($this->_objectId))); + } + + public function getHeaderText() + { + if($this->_isExistingSubscriber()) { + return $this->__('Edit Subscriber'); + } else { + return $this->__('Add Subscriber'); + } + } + + protected function _isExistingSubscriber() + { + return Mage::registry('current_subscriber') && Mage::registry('current_subscriber')->getId(); + } +} diff --git a/app/code/Mage/Webhook/Block/Adminhtml/Subscriber/Edit/Form.php b/app/code/Mage/Webhook/Block/Adminhtml/Subscriber/Edit/Form.php new file mode 100644 index 0000000000000..60dafa568bd4b --- /dev/null +++ b/app/code/Mage/Webhook/Block/Adminhtml/Subscriber/Edit/Form.php @@ -0,0 +1,128 @@ + 'edit_form', + 'action' => $this->getUrl( + '*/*/save', + array('id' => $subscriber->getId()) + ), + 'method' => 'post' + ) + ); + + $fieldset = $form->addFieldset('subscriber_fieldset', array('legend' => $this->__('Subscriber'))); + $fieldset->addField( + 'name', 'text', + array( + 'label' => $this->__('Name'), + 'class' => 'required-entry', + 'required' => true, + 'name' => 'name', + ) + ); + + $fieldset->addField( + 'endpoint_url', 'text', + array( + 'label' => $this->__('Endpoint URL'), + 'class' => 'required-entry', + 'required' => true, + 'name' => 'endpoint_url', + ) + ); + + $fieldset->addField( + 'mapping', 'select', + array( + 'name' => 'mapping', + 'label' => $this->__('Mapping'), + 'title' => $this->__('Mapping'), + 'values' => Mage::getSingleton('Mage_Webhook_Model_Source_Mapping') + ->getMappingsForForm(), + ) + ); + + $fieldset->addField( + 'format', 'select', + array( + 'name' => 'format', + 'label' => $this->__('Format'), + 'title' => $this->__('Format'), + 'values' => Mage::getSingleton('Mage_Webhook_Model_Source_Format') + ->getFormatsForForm(), + ) + ); + + $fieldset->addField( + 'authentication_type', 'select', + array( + 'name' => 'authentication_type', + 'label' => $this->__('Authentication Types'), + 'title' => $this->__('Authentication Types'), + 'values' => Mage::getSingleton('Mage_Webhook_Model_Source_Authentication') + ->getAuthenticationsForForm(), + ) + ); + + $versionData = array( + 'label' => $this->__('Version'), + 'name' => 'version', + ); + if ($subscriber->getExtensionId()) { + $versionData['readonly'] = 'readonly'; + $versionData['class'] = 'disabled'; + } + $fieldset->addField('version', 'text', $versionData); + + $fieldset->addField( + 'topics', 'multiselect', + array( + 'name' => 'topics[]', + 'label' => $this->__('Topics'), + 'title' => $this->__('Topics'), + 'required' => true, + 'values' => Mage::getSingleton('Mage_Webhook_Model_Source_Hook') + ->getTopicsForForm(), + ) + ); + + $values = $subscriber->getData(); + if ($subscriber && $subscriber->getId()) { + $values['topics'] = $subscriber->getTopics(); + } + + $form->setUseContainer(true); + $form->setValues($values); + $this->setForm($form); + return parent::_prepareForm(); + } +} diff --git a/app/code/Mage/Webhook/Block/Adminhtml/Subscriber/Edit/Test/Form.php b/app/code/Mage/Webhook/Block/Adminhtml/Subscriber/Edit/Test/Form.php new file mode 100644 index 0000000000000..24a1705828ef5 --- /dev/null +++ b/app/code/Mage/Webhook/Block/Adminhtml/Subscriber/Edit/Test/Form.php @@ -0,0 +1,51 @@ + 'test_form', + 'action' => $this->getUrl('*/*/test', array()), + 'method' => 'post' + ) + ); + + $fieldset = $form->addFieldset('test_fieldset', array('legend' => $this->__('Test'))); + + $fieldset->addField('test_button', 'submit', array( + 'label' => $this->__('Send Test Message'), + 'name' => 'test_button', + 'value' => $this->__('Start'), + )); + + $form->setUseContainer(true); +// $form->setValues($values); + $this->setForm($form); + + return parent::_prepareForm(); + } +} \ No newline at end of file diff --git a/app/code/Mage/Webhook/Block/Adminhtml/Subscriber/Grid.php b/app/code/Mage/Webhook/Block/Adminhtml/Subscriber/Grid.php new file mode 100644 index 0000000000000..3933f4011a15e --- /dev/null +++ b/app/code/Mage/Webhook/Block/Adminhtml/Subscriber/Grid.php @@ -0,0 +1,108 @@ +setId('subscriberGrid'); + $this->setDefaultSort('subscriber_id'); + $this->setDefaultDir('ASC'); + $this->setSaveParametersInSession(true); + } + + protected function _prepareCollection() + { + Mage::getSingleton('Mage_Webhook_Model_Subscriber_Config')->updateSubscriberCollection(); + + $collection = Mage::getModel('Mage_Webhook_Model_Subscriber')->getCollection(); + $this->setCollection($collection); + return parent::_prepareCollection(); + } + + protected function _prepareColumns() + { + $this->addColumn('id', array( + 'header' => $this->__('ID'), + 'align' => 'right', + 'width' => '50px', + 'index' => 'subscriber_id', + )); + + $this->addColumn('name', array( + 'header' => $this->__('Name'), + 'align' => 'left', + 'index' => 'name', + )); + + $this->addColumn('version', array( + 'header' => $this->__('Version'), + 'align' => 'left', + 'width' => '80px', + 'index' => 'version', + )); + + $this->addColumn('endpoint_url', array( + 'header' => $this->__('Endpoint URL'), + 'align' => 'left', + 'index' => 'endpoint_url', + )); + + $this->addColumn('status', array( + 'header' => $this->__('Status'), + 'align' =>'left', + 'index' => 'status', + 'type' => 'options', + 'width' => '100px', + 'options' => $this->_getStatusOptions() + )); + + $this->addColumn('action', array( + 'header' => Mage::helper('Mage_Webhook_Helper_Data')->__('Action'), + 'align' => 'left', + 'width' => '80px', + 'filter' => false, + 'sortable' => false, + 'renderer' => 'Mage_Webhook_Block_Adminhtml_Subscriber_Grid_Renderer_Action' + )); + + return parent::_prepareColumns(); + } + + public function getRowUrl($row) + { + return $this->getUrl('*/*/edit', array('id' => $row->getId())); + } + + protected function _getStatusOptions() + { + return array( + Mage_Webhook_Model_Subscriber::STATUS_ACTIVE => $this->__('Active'), + Mage_Webhook_Model_Subscriber::STATUS_REVOKED => $this->__('Revoked'), + Mage_Webhook_Model_Subscriber::STATUS_INACTIVE => $this->__('Inactive'), + ); + } +} diff --git a/app/code/Mage/Webhook/Block/Adminhtml/Subscriber/Grid/Renderer/Action.php b/app/code/Mage/Webhook/Block/Adminhtml/Subscriber/Grid/Renderer/Action.php new file mode 100644 index 0000000000000..a3768552a3605 --- /dev/null +++ b/app/code/Mage/Webhook/Block/Adminhtml/Subscriber/Grid/Renderer/Action.php @@ -0,0 +1,48 @@ +getStatus() == Mage_Webhook_Model_Subscriber::STATUS_ACTIVE) { + return '' + . $this->__('Revoke') . ''; + } else if ($row->getStatus() == Mage_Webhook_Model_Subscriber::STATUS_REVOKED) { + return '' + . $this->__('Activate') . ''; + } else if ($row->getStatus() == Mage_Webhook_Model_Subscriber::STATUS_INACTIVE) { + $url = $this->getUrl('*/webhook_registration/activate', array('id' => $row->getId())); + return '' + . $this->__('Activate') + . ''; + } + } + + return ''; + } +} diff --git a/app/code/Mage/Webhook/Controller/Webapi/Webhook.php b/app/code/Mage/Webhook/Controller/Webapi/Webhook.php new file mode 100644 index 0000000000000..e7bcb2ecd63bb --- /dev/null +++ b/app/code/Mage/Webhook/Controller/Webapi/Webhook.php @@ -0,0 +1,361 @@ +_translationHelper = $this->_helperFactory->get('Mage_Customer_Helper_Data'); + $this->_objectManager = $objectManager; + } + + /** + * Create webhook. + * + * @param Mage_Webhook_Model_Webapi_WebhookData $data webhook create data. + * @param string $optional {maxLength:255 chars.}May be not passed. + * @param int $int {min:10}{max:100} Optional integer parameter. + * @param bool $bool optional boolean + * @return int ID of registered subscriber + * @throws Mage_Webapi_Exception + */ + public function createV1(Mage_Webhook_Model_Webapi_WebhookData $data, $optional = 'default', $int = null, $bool = true) + { + try { + $userId = $this->_getApiUserId(); + $topics = $this->_filterTopicsByApiUser($data->topics, $userId); + + /** @var $subscriber Mage_Webhook_Model_Subscriber */ + $subscriber = Mage::getModel('Mage_Webhook_Model_Subscriber'); + if (!empty($topics)) { + $subscriber->setTopics($topics); + $subscriber->setStatus(Mage_Webhook_Model_Subscriber::STATUS_ACTIVE); + } else { + $subscriber->setStatus(Mage_Webhook_Model_Subscriber::STATUS_INACTIVE); + } + $subscriber->setData(get_object_vars($data)); + $subscriber->setApiUserId($userId); + + $subscriber->save(); + + $this->getResponse()->setHttpResponseCode(Mage_Webapi_Controller_Response_Rest::HTTP_CREATED); + } catch (Mage_Core_Exception $e) { + $this->_processException($e); + } + + return $subscriber; + } + + /** + * Filter topics by the read permission of the api user + * + * @param $topics + * @param $userId + * @return array + */ + private function _filterTopicsByApiUser($topics, $userId) + { + /** @var $user Mage_Webapi_Model_Acl_User */ + $user = Mage::getModel('Mage_Webapi_Model_Acl_User')->load($userId); + $roleId = $user->getRoleId(); +// $resourceData = Mage::getResourceModel('Mage_Webapi_Model_Resource_Acl_Rule_Collection') +// ->addFieldToFilter('role_id', $roleId)->load()->toArray(array('resource_id')); +// $resourceData = isset($resourceData['items']) ? $resourceData['items'] : $resourceData; + $resourceIds = Mage::getResourceModel('Mage_Webapi_Model_Resource_Acl_Rule') + ->getResourceIdsByRole($roleId); + if (in_array('Mage_Webapi', $resourceIds)) { // all webapi permission + return $topics; + } else { + $readableResources = array(); + foreach ($resourceIds as $resource) { + if (preg_match("/\/get/", $resource)) { // TODO: Should be allowed to be anything, not just get + $result = preg_split("/\//", $resource); + $readableResources[] = $result[0]; + } + } + + $resultTopics = array(); + foreach($topics as $topic) { + $topic = str_replace("\/", "/", $topic); + $array = preg_split("/\//", $topic); + if (in_array($array[0], $readableResources)) { + $resultTopics[] = $topic; + } + } + return $resultTopics; + } + } + + /** + * Return Api User Id + * + * @return mixed + */ + private function _getApiUserId() + { + if (!isset($this->_api_user_id)) { + $consumerKey = null; + $authHeader = $this->getRequest()->getHeader('Authorization'); + if (strpos($authHeader, 'OAuth ') !== false) { + $authHeader = str_replace('OAuth ', '', $authHeader); + } + $authSettings = explode(',', $authHeader); + foreach($authSettings as $authSetting) { + list($key, $value) = explode('=', $authSetting); + if (trim($key) === 'oauth_consumer_key'){ + $consumerKey = str_replace(array('"'), "", trim($value)); + break; + } + } + $usersData = Mage::getModel('Mage_Webapi_Model_Acl_User') + ->getCollection() + ->addFieldToFilter('api_key', $consumerKey) + ->load() + ->toArray(array('user_id')); + $users = isset($usersData['items']) ? $usersData['items'] : $usersData; + $this->_setApiUserId($users[0]['user_id']); + } + return $this->_api_user_id; + } + + private function _setApiUserId($id) + { + $this->_api_user_id = $id; + } + + /** + * Get WebHook list. + * + * @return Mage_Webhook_Model_Webapi_WebhookData[] array of WebHook data objects + */ + public function listV1() + { + $result = array(); + $subscribersData = $this->_getSubscriberCollectionForRetrieve() + ->load() + ->toArray(Mage_Webhook_Model_Webapi_WebhookData::getSubscriberDataFields()); + $subscribersData = isset($subscribersData['items']) ? $subscribersData['items'] : $subscribersData; + foreach ($subscribersData as $subscriberData) { + $result[] = $this->_createWebhookDataObject($subscriberData); + } + return $result; + } + + /** + * Update webhook. + * + * @param int $id + * @param string[][] $data + * @throws Mage_Webapi_Exception + */ + public function updateV1($id, $data) + { + try { + /** @var $subscriber Mage_Webhook_Model_Subscriber */ + $subscriber = $this->_loadSubscriberById($id); + foreach($data as $key => $value) { + if ($key === 'topics') { + $userId = $this->_getApiUserId(); + $topics = $this->_filterTopicsByApiUser($value, $userId); + + if (empty($topics)) { + throw Mage::exception('Mage_Webhook', "The topics are not authorized."); + } + $subscriber->setTopics($topics); + } else { + $subscriber->setData($key, $value); + } + + } + $subscriber->validate(); + $subscriber->save(); + } catch (Mage_Core_Exception $e) { + $this->_processException($e); + } + + return $subscriber; + } + + /** + * Retrieve WebHooks that a subscriber is registered to and also the subscriber information + * + * @param int $subscriberId + * @return Mage_Webhook_Model_Webapi_WebhookData + * @throws Mage_Webapi_Exception + */ + public function getV1($subscriberId) + { + try { + $subscriberData = $this->_get($subscriberId); + return $this->_createWebhookDataObject($subscriberData); + } catch (Mage_Core_Exception $e) { + $this->_processException($e); + } + } + + /** + * Create WebHook data object based on associative array of subscriber data. + * + * @param array $subscriberData + * @return Mage_Webhook_Model_Webapi_WebhookData + */ + protected function _createWebhookDataObject($subscriberData) + { + $webhookData = new Mage_Webhook_Model_Webapi_WebhookData(); + $subscriberId = $subscriberData['subscriber_id']; + + /** @var Mage_Webhook_Model_Subscriber $subscriber */ + $subscriber = Mage::getModel('Mage_Webhook_Model_Subscriber'); + $subscriber->load($subscriberId); + $webhookData->topics = $subscriber->getTopics(); + + foreach ($subscriberData as $field => $value) { + if (!empty($value)) { + if ($field === 'status') { + $value = Mage_Webhook_Model_Webapi_WebhookData::getSubscriberStatusString($value); + } + $webhookData->$field = $value; + } + } + return $webhookData; + } + + /** + * Retrieve subscriber data by ID + * + * @param string $id + * @return array + */ + protected function _get($id) + { + $collection = $this->_getSubscriberCollectionForRetrieve() + ->addFieldToFilter('subscriber_id', $id); + + $subscribersData = $collection->load() + ->toArray(Mage_Webhook_Model_Webapi_WebhookData::getSubscriberDataFields()); + $subscribers = isset($subscribersData['items']) ? $subscribersData['items'] : $subscribersData; + $count = count($subscribers); + if ($count > 1) { + throw new Mage_Webapi_Exception( + $this->_translationHelper->__("There are more than one subscriber with id %s.", $id), + Mage_Webapi_Exception::HTTP_BAD_REQUEST + ); + } + if ($count == 0) { + throw new Mage_Webapi_Exception( + $this->_translationHelper->__("WebHook with id %s does not exist.", $id), + Mage_Webapi_Exception::HTTP_NOT_FOUND + ); + } + return $subscribers[0]; + } + + /** + * Delete webhook. + * + * @param string $id + * @throws Mage_Webapi_Exception + */ + public function deleteV1($id) + { + try { + /** @var $subscriber Mage_Webhook_Model_Subscriber */ + $subscriber = $this->_loadSubscriberById($id); + $subscriber->delete(); + } catch (Mage_Core_Exception $e) { + $this->_processException($e); + } + } + + /** + * Load subscriber by id. + * + * @param int $id + * @return Mage_Webhook_Model_Subscriber + * @throws Mage_Webapi_Exception + */ + protected function _loadSubscriberById($id) + { + /** @var $subscriber Mage_Webhook_Model_Subscriber */ + $subscriber = Mage::getModel('Mage_Webhook_Model_Subscriber')->load($id); + if (!$subscriber->getId() || $subscriber->getApiUserId() != $this->_getApiUserId()) { + throw new Mage_Webapi_Exception( + $this->_translationHelper->__("WebHook with id %s does not exist.", $id), + Mage_Webapi_Exception::HTTP_NOT_FOUND + ); + } + return $subscriber; + } + + /** + * Retrieve subscriber collection instances + * + * @return Mage_Webhook_Model_Resource_Subscriber_Collection + */ + protected function _getSubscriberCollectionForRetrieve() + { + /** @var $collection Mage_Webhook_Model_Resource_Subscriber_Collection */ + $collection = Mage::getResourceModel('Mage_Webhook_Model_Resource_Subscriber_Collection') + ->addFieldToFilter('api_user_id', $this->_getApiUserId()); + $this->_applyCollectionModifiers($collection); + return $collection; + } + + /** + * Process models exceptions and convert them into Webapi bad request exception. + * + * @param Exception $e + * @throws Mage_Webapi_Exception + */ + protected function _processException($e) + { + throw new Mage_Webapi_Exception($e->getMessage(), Mage_Webapi_Exception::HTTP_BAD_REQUEST); + } +} diff --git a/app/code/Mage/Webhook/Exception.php b/app/code/Mage/Webhook/Exception.php new file mode 100644 index 0000000000000..3e2250d8dd3cb --- /dev/null +++ b/app/code/Mage/Webhook/Exception.php @@ -0,0 +1,29 @@ +_objectManager = $objectManager; + } + + /** + * Dispatch hook with specified data. + * + * @param string $topic topic of the event + * @param array $data data for the hook + * @return Mage_Webhook_Helper_Data + */ + public function dispatchEvent($topic, array $data) + { + try { + $config = Mage::getConfig()->getNode('global/webhook/mappings'); + $queue = Mage::getModel('Mage_Webhook_Model_Event_Queue'); + $mapperFactory = Mage::getModel('Mage_Webhook_Model_Mapper_Factory'); // , $this->_objectManager); + + $eventFactory = $this->_objectManager + ->get('Mage_Webhook_Model_Event_Factory', array($this->_objectManager)); + $marshaller = Mage::getModel( + 'Mage_Webhook_Model_Event_Marshaller', + array( + 'mappingsConfig' => $config, + 'queue' => $queue, + 'mapperFactory' => $mapperFactory, + 'eventFactory' => $eventFactory + ) + ); + $marshaller->marshal($topic, $data); + + // TODO: Remove the 3 lines below and just rely on cronjob in future + $observer = Mage::getModel('Mage_Webhook_Model_Observer'); + $observer->processEventsToDispatch(); + $observer->processDispatchJobs(); + } catch (Exception $e) { + Mage::logException($e); + } + + return $this; + } + + /** + * Dispatches Callback and returns the result + * + * @param $topic + * @param array $data + * @return array + */ + public function dispatchCallback($extensionId, $topic, array $data) + { + $result = null; + $subscriber = $this->_getSingleActiveSubscriber($extensionId, $topic); + + try { + $config = Mage::getConfig()->getNode('global/webhook/mappings'); + $mappingFactory = $this->_objectManager->create('Mage_Webhook_Model_Mapper_Factory', array($this->_objectManager)); + $mapperFactory = $mappingFactory->getMapperFactory($subscriber->getMapping(), $config); + $mapper = $mapperFactory->getMapper( + $topic, $data, $config->descend($subscriber->getMapping() . "/options") + ); + + /** @var $eventFactory Mage_Webhook_Model_Event_Factory */ + $eventData = array( + 'mapping' => $subscriber->getMapping(), + 'bodyData' => $mapper->getData(), + 'headers' => $mapper->getHeaders(), + 'topic' => $topic + ); + + $eventFactory = $this->_objectManager + ->get('Mage_Webhook_Model_Event_Factory', array($this->_objectManager)); + $event = $eventFactory->createEvent(Mage_Webhook_Model_Event_Interface::EVENT_TYPE_CALLBACK, $eventData); + + /** @var $message Mage_Webhook_Model_Message_Interface */ + $message = $this->_objectManager->create('Mage_Webhook_Model_Job_Dispatcher') + ->dispatchCallback($event, $subscriber); + $result = $message->getResponseData(); + } catch (Exception $e) { + Mage::logException($e); + } + + return $result; + } + + protected function _getSingleActiveSubscriber($extensionId, $topic) + { + /** @var $subscriberCollection Mage_Webhook_Model_Resource_Subscriber_Collection */ + $subscriber = $this->_objectManager + ->create('Mage_Webhook_Model_Resource_Subscriber_Collection') + ->addExtensionIdFilter($extensionId) + ->addTopicFilter($topic) + ->addIsActiveFilter(true) + ->getSingleSubscriber(); + if (null === $subscriber) { + throw Mage::exception('Mage_Webhook', 'No subscriber found'); + } + return $subscriber; + } + + + public function generateRandomString($length) + { + /** @var $coreHelper Mage_Core_Helper_Data */ + $coreHelper = Mage::helper('Mage_Core_Helper_Data'); + return $coreHelper->getRandomString($length, Mage_Core_Helper_Data::CHARS_DIGITS . Mage_Core_Helper_Data::CHARS_LOWERS); + } +} diff --git a/app/code/Mage/Webhook/Model/Authentication/Abstract.php b/app/code/Mage/Webhook/Model/Authentication/Abstract.php new file mode 100644 index 0000000000000..104b8a983ad21 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Authentication/Abstract.php @@ -0,0 +1,68 @@ +getHeaders(); + $headers[self::DOMAIN_HEADER] = $this->_getDomain(); + $request->setHeaders($headers); + } + + /** + * Sign outbound HTTP request + * + * @todo - we need to implement signing for WS-Security + * @param Mage_Webhook_Model_Transport_Http_Request $request + * @param Mage_Webhook_Model_Subscriber $subscriber + * @return Mage_Webhook_Model_Transport_Http_Request + */ + public function signRequest(Mage_Webhook_Model_Transport_Http_Request $request, + Mage_Webhook_Model_Subscriber $subscriber) + { + $this->_setDomainHeader($request); + $this->_signRequest($request, $subscriber); + return $request; + } + + /** + * An overridable method to get the domain name + * @return mixed + */ + protected function _getDomain() + { + return parse_url(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST); + } +} diff --git a/app/code/Mage/Webhook/Model/Authentication/Hmac.php b/app/code/Mage/Webhook/Model/Authentication/Hmac.php new file mode 100644 index 0000000000000..1ce24f0b824f1 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Authentication/Hmac.php @@ -0,0 +1,70 @@ +getApiUser()->getSecret(); + if ('' === $secret || is_null($secret)) { + throw new LogicException("The shared secret cannot be a empty."); + } + // Add HMAC Signature + $this->_signRequestHmac($request, $secret, $this->getHashAlgorithm()); + + return $request; + } + + /** + * @param Mage_Webhook_Model_Transport_Http_Request $request + * @param string $hashAlgorithm + */ + protected function _signRequestHmac(Mage_Webhook_Model_Transport_Http_Request $request, $secret, + $hashAlgorithm) + { + $body = $request->getBody(); + + $signature = hash_hmac($hashAlgorithm, $body, $secret); + + $headers = $request->getHeaders(); + $headers[self::HMAC_HEADER] = $signature; + $request->setHeaders($headers); + return $request; + } +} diff --git a/app/code/Mage/Webhook/Model/Authentication/Hmac/Sha256.php b/app/code/Mage/Webhook/Model/Authentication/Hmac/Sha256.php new file mode 100644 index 0000000000000..f263c29a2ee04 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Authentication/Hmac/Sha256.php @@ -0,0 +1,32 @@ + + */ +class Mage_Webhook_Model_Authorization_Config implements Mage_Core_Model_Acl_Config_ConfigInterface +{ + + const ACL_VIRTUAL_RESOURCES_XPATH = '/config/*'; + + /** + * @var Mage_Core_Model_Config + */ + protected $_config; + + /** + * @var Magento_Acl_Config_Reader + */ + protected $_reader; + + /** + * @var Mage_Webhook_Model_Authorization_Config_Reader_Factory + */ + protected $_readerFactory; + + /** + * Module configuration reader + * + * @var Mage_Core_Model_Config_Modules_Reader + */ + protected $_moduleReader; + + /** + * @param Mage_Core_Model_Config_Modules_Reader $moduleReader + * @param Mage_Webhook_Model_Authorization_Config_Reader_Factory $readerFactory + */ + public function __construct( + Mage_Core_Model_Config_Modules_Reader $moduleReader, + Mage_Webhook_Model_Authorization_Config_Reader_Factory $readerFactory + ) { + $this->_moduleReader = $moduleReader; + $this->_readerFactory = $readerFactory; + } + + /** + * Retrieve list of acl files from each module + * + * @return array + */ + protected function _getAclResourceFiles() + { + $files = $this->_moduleReader + ->getModuleConfigurationFiles('webhook' . DIRECTORY_SEPARATOR . 'acl.xml'); + return (array)$files; + } + + /** + * Reader object initialization. + * + * @return Magento_Acl_Config_Reader + */ + protected function _getReader() + { + if (is_null($this->_reader)) { + $aclResourceFiles = $this->_getAclResourceFiles(); + $this->_reader = $this->_readerFactory->createReader(array('configFiles' => $aclResourceFiles)); + } + return $this->_reader; + } + + + /** + * Get DOMXPath with loaded resources inside + * + * @return DOMXPath + */ + protected function _getXPathResources() + { + $aclResources = $this->_getReader()->getAclResources(); + return new DOMXPath($aclResources); + } + + /** + * Return ACL Resources + * + * @return DOMNodeList + */ + public function getAclResources() + { + // We don't have any resources that aren't virtual + return null; + } + + /** + * Return ACL Virtual Resources + * + * Virtual resources are not shown in resource list, they use existing resource to check permission + * + * @return DOMNodeList + */ + public function getAclVirtualResources() + { + return $this->_getXPathResources()->query(self::ACL_VIRTUAL_RESOURCES_XPATH); + } + + /** + * Return the parent of the given topic + * @param $topic_id + * @return string + */ + public function getParentFromTopic( $topic_id) { + $topics = $this->_getXPathResources()->query("//topic[@id='" . $topic_id . "']/../@id"); + return $topics->item(0)->nodeValue; + } +} diff --git a/app/code/Mage/Webhook/Model/Authorization/Config/Reader.php b/app/code/Mage/Webhook/Model/Authorization/Config/Reader.php new file mode 100644 index 0000000000000..1190b0f6ff217 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Authorization/Config/Reader.php @@ -0,0 +1,70 @@ + + */ +class Mage_Webhook_Model_Authorization_Config_Reader extends Magento_Acl_Config_Reader +{ + /** + * Get absolute path to the XML-schema file + * + * @return string + */ + public function getSchemaFile() + { + return __DIR__ . DIRECTORY_SEPARATOR . 'acl.xsd'; + } + + /** + * Get XML-contents, initial for merging + * + * @return string + */ + protected function _getInitialXml() + { + return ''; + } + + /** + * Get Dom configuration model + * @return Magento_Config_Dom + */ + protected function _getDomConfigModel() + { + if (is_null($this->_domConfig)) { + $this->_domConfig = new Mage_Webhook_Model_Authorization_Config_Reader_Dom( + $this->_getInitialXml(), + $this->_getIdAttributes() + ); + } + return $this->_domConfig; + } +} diff --git a/app/code/Mage/Webhook/Model/Authorization/Config/Reader/Dom.php b/app/code/Mage/Webhook/Model/Authorization/Config/Reader/Dom.php new file mode 100644 index 0000000000000..4623961edbcf0 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Authorization/Config/Reader/Dom.php @@ -0,0 +1,52 @@ + + */ +class Mage_Webhook_Model_Authorization_Config_Reader_Dom extends Magento_Config_Dom +{ + /** + * Return attribute for resource node that identify it as unique + * + * @param string $xPath + * @return bool|string + */ + protected function _findIdAttribute($xPath) + { + $topic = 'topic'; + $parent = 'parent'; + // if it ends with 'parent' or 'topic' + if(substr($xPath, -strlen($topic)) === $topic || + substr($xPath, -strlen($parent)) === $parent ){ + return 'id'; + } + return false; + } +} diff --git a/app/code/Mage/Webhook/Model/Authorization/Config/Reader/Factory.php b/app/code/Mage/Webhook/Model/Authorization/Config/Reader/Factory.php new file mode 100644 index 0000000000000..32f6d6a0acca9 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Authorization/Config/Reader/Factory.php @@ -0,0 +1,53 @@ +_objectManager = $objectManager; + } + + /** + * Return new Mage_Webhook_Model_Authorization_Config_Reader + * + * @param array $arguments + * @return Mage_Webhook_Model_Authorization_Config_Reader + */ + public function createReader(array $arguments = array()) + { + return $this->_objectManager->create(self::READER_CLASS_NAME, $arguments, false); + } +} diff --git a/app/code/Mage/Webhook/Model/Authorization/Config/acl.xsd b/app/code/Mage/Webhook/Model/Authorization/Config/acl.xsd new file mode 100644 index 0000000000000..d293baa0b3a91 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Authorization/Config/acl.xsd @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + Attribute id is unique under all mapped ACL resources + + + + + + + + + + + + + + + + + + + ACL Resource. Recursive complex type + + + + + + + + + + + + + + + + + ACL Resource mapping. + + + + + + + + + + + Item id attribute can has only [A-Za-z0-9_]/[A-Za-z0-9_]. Minimal length 3 symbol. Case insensitive. + + + + + + + + + + + + Item title attribute minimal length 3 symbol + + + + + + + + + + + + + Item module attribute can has only [a-z0-9_]. Minimal length 3 symbol. Case insensitive. + + + + + + + diff --git a/app/code/Mage/Webhook/Model/Dispatch/Job.php b/app/code/Mage/Webhook/Model/Dispatch/Job.php new file mode 100644 index 0000000000000..570ffe36032a4 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Dispatch/Job.php @@ -0,0 +1,74 @@ +_init('Mage_Webhook_Model_Resource_Dispatch_Job'); + } + + public function getEvent() + { + return Mage::getModel('Mage_Webhook_Model_Event')->load($this->getEventId()); + } + + public function getSubscriber() + { + return Mage::getModel('Mage_Webhook_Model_Subscriber')->load($this->getSubscriberId()); + } + + public function getStatus() + { + return $this->getData('status'); + } + + public function setStatus($status) + { + return $this->setData('status', $status); + } + + /** + * Prepare data to be saved to database + * @return Mage_Core_Model_Abstract + */ + protected function _beforeSave() + { + parent::_beforeSave(); + if ($this->isObjectNew()) { + $this->setCreatedAt(Varien_Date::formatDate(true)); + } elseif ($this->getId() && !$this->hasData('updated_at')) { + $this->setUpdatedAt($this->_getResource()->formatDate(true)); + } + return $this; + } +} diff --git a/app/code/Mage/Webhook/Model/Event.php b/app/code/Mage/Webhook/Model/Event.php new file mode 100644 index 0000000000000..bf0ba74dfa810 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Event.php @@ -0,0 +1,115 @@ +_init('Mage_Webhook_Model_Resource_Event'); + } + + /** + * Prepare data to be saved to database + * @return Mage_Core_Model_Abstract + */ + protected function _beforeSave() + { + parent::_beforeSave(); + + if ($this->isObjectNew()) { + $this->setCreatedAt($this->_getResource()->formatDate(true)); + } elseif ($this->getId() && !$this->hasData('updated_at')) { + $this->setUpdatedAt($this->_getResource()->formatDate(true)); + } + return $this; + } + + public function setBodyData(array $data) + { + return $this->setData('body_data', serialize($data)); + } + + public function getBodyData() + { + $data = $this->getData('body_data'); + if (!is_null($data)) { + return unserialize($data); + } + return array(); + } + + public function setHeaders(array $headers) + { + return $this->setData('headers', serialize($headers)); + } + + public function getHeaders() + { + $headers = $this->getData('headers'); + if (!is_null($headers)) { + return unserialize($headers); + } + return array(); + } + + public function setOptions(array $options) + { + return $this->setData('options', serialize($options)); + } + + public function getOptions() + { + $options = $this->getData('options'); + if (!is_null($options)) { + return unserialize($options); + } + return array(); + } + + public function getMapping() + { + return $this->getData('mapping'); + } + + public function getStatus() + { + return $this->getData('status'); + } + + public function getTopic() + { + return $this->getData('topic'); + } + + public function setTopic($topic) + { + return $this->setData('topic', $topic); + } +} diff --git a/app/code/Mage/Webhook/Model/Event/Callback.php b/app/code/Mage/Webhook/Model/Event/Callback.php new file mode 100644 index 0000000000000..2c2f1a65b89f0 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Event/Callback.php @@ -0,0 +1,120 @@ +_mapping = $mapping; + $this->_bodyData = $bodyData; + $this->_headers = $headers; + $this->_topic = $topic; + + $this->_status = $status; + $this->_options = $options; + } + + /** + * Returns the status code of the event. Status indicates if the event has been processed + * or not. + * + * @return integer + */ + public function getStatus() + { + return $this->_status; + } + + /** + * Returns the data content mapping. The mapping could be "default", "flat", etc. + * Specifically, it details what mapping the body data is in. + * + * @return string + */ + public function getMapping() + { + return $this->_mapping; + } + + /** + * Returns a PHP array of data that represents what should be included in the message body. + * + * @return array + */ + public function getBodyData() + { + return $this->_bodyData; + } + + /** + * Returns a PHP array of mapped key-value pairs representing header names and values. + * + * @return array + */ + public function getHeaders() + { + return $this->_headers; + } + + /** + * Returns a PHP array of mapped key-value pairs representing options for the event. + * The options could be set for the transport to understand or some future message. + * + * @return array + */ + public function getOptions() + { + return $this->_options; + } + + /** + * Returns a PHP string representing the topic of WebHook + * @return string + */ + public function getTopic() + { + return $this->_topic; + } + +} \ No newline at end of file diff --git a/app/code/Mage/Webhook/Model/Event/Factory.php b/app/code/Mage/Webhook/Model/Event/Factory.php new file mode 100644 index 0000000000000..5a9bcc6c1b813 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Event/Factory.php @@ -0,0 +1,60 @@ +_objectManager = $objectManager; + } + + /** + * @param array $arguments + * @return Mage_Webhook_Model_Event_Interface + */ + public function createEvent($eventType, $eventData) + { + switch ($eventType) { + case Mage_Webhook_Model_Event_Interface::EVENT_TYPE_CALLBACK: + return $this->_objectManager->create('Mage_Webhook_Model_Event_Callback', $eventData); + case Mage_Webhook_Model_Event_Interface::EVENT_TYPE_INFORM: + return $this->_objectManager->create('Mage_Webhook_Model_Event', $eventData); + } + } +} diff --git a/app/code/Mage/Webhook/Model/Event/Interface.php b/app/code/Mage/Webhook/Model/Event/Interface.php new file mode 100644 index 0000000000000..7ab26e36f0db8 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Event/Interface.php @@ -0,0 +1,81 @@ +_mappingsConfig = $mappingsConfig; + $this->_queue = $queue; + $this->_mapperFactory = $mapperFactory; + $this->_eventFactory = $eventFactory; + } + + public function marshal($topic, array $data) + { + $isSuccessful = true; + // serialize all of the different message mappings + foreach ($this->_getMappingsForTopicSubscribers($topic) as $mapping) { + try { + $event = $this->getEvent($topic, $data, $mapping); + + if (!$this->_queue->offer($event)) { + $isSuccessful = false; + } + } catch (Exception $e) { + Mage::logException($e); + $isSuccessful = false; + } + } + + return $isSuccessful; + } + + public function getEvent($topic, array $data, $mapping) + { + $mapperFactory = $this->_mapperFactory->getMapperFactory($mapping, $this->_mappingsConfig); + $mapper = $mapperFactory->getMapper( + $topic, $data, $this->_mappingsConfig->descend("$mapping/options") + ); + + $event = $this->getEventFactory()->createEvent(Mage_Webhook_Model_Event_Interface::EVENT_TYPE_INFORM, array()) + ->setTopic($mapper->getTopic()) + ->setBodyData($mapper->getData()) + ->setHeaders($mapper->getHeaders()) + ->setMapping($mapping); + + return $event; + } + + public function getEventFactory() + { + return $this->_eventFactory; + } + + protected function _getMappingsForTopicSubscribers($topic) + { + // treat $mappings as a set + $mappings = array(); + + // TODO: would really like to just query the database for all the unique mappings and have + // the database do the work + $subscribers = $this->_getSubscriberCollection()->addTopicFilter($topic)->addIsActiveFilter(true)->getItems(); + foreach ($subscribers as $subscriber) { + $mappings[$subscriber->getMapping()] = true; + } + + return array_keys($mappings); + } + + /** + * @return Mage_Webhook_Model_Subscriber_SubscriberCollection + */ + protected function _getSubscriberCollection() + { + return Mage::getResourceModel('Mage_Webhook_Model_Resource_Subscriber_Collection'); + } +} diff --git a/app/code/Mage/Webhook/Model/Event/Marshaller/Interface.php b/app/code/Mage/Webhook/Model/Event/Marshaller/Interface.php new file mode 100644 index 0000000000000..ee509be4533af --- /dev/null +++ b/app/code/Mage/Webhook/Model/Event/Marshaller/Interface.php @@ -0,0 +1,36 @@ +setStatus(Mage_Webhook_Model_Event::READY_TO_SEND); + $event->save(); + return true; + } + + return false; + } + + public function poll() + { + $iterator = $this->_getIterator(); + if ($iterator->valid()) { + $event = $iterator->current(); + + // effectively remove it from the queue + $event->setStatus(Mage_Webhook_Model_Event::PROCESSED); + $event->save(); + + $iterator->next(); + return $event; + } + + return null; + } + + protected function _getIterator() + { + if (is_null($this->_eventsIterator) || !$this->_eventsIterator->valid()) { + $collection = $this->_getEventCollection() + ->addFieldToFilter('status', Mage_Webhook_Model_Event::READY_TO_SEND); + $this->_eventsIterator = $collection->getIterator(); + } + + return $this->_eventsIterator; + } + + protected function _getEventCollection() { + return $collection = Mage::getModel('Mage_Webhook_Model_Event')->getCollection(); + } +} diff --git a/app/code/Mage/Webhook/Model/Event/Queue/Interface.php b/app/code/Mage/Webhook/Model/Event/Queue/Interface.php new file mode 100644 index 0000000000000..b66de2a8d7f54 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Event/Queue/Interface.php @@ -0,0 +1,42 @@ +_config = $config; + } + + /** + * Get formatter factory for specified format + * + * @param string $format + * @return Mage_Webhook_Model_Formatter_Factory_Interface + * @throws LogicException + */ + public function getFormatterFactory($format) + { + $modelName = (string) $this->_config->getNode(self::XML_PATH_FORMATS . $format . '/formatter_factory'); + + if (!$modelName) { + throw new LogicException("Wrong Format name $format."); + } + + $factory = $this->getModel($modelName); + if (!$factory instanceof Mage_Webhook_Model_Formatter_Factory_Interface) { + throw new LogicException("Wrong Formatter type for format $format."); + } + + return $factory; + } + + protected function getModel($modelName) + { + // TODO: probably here we should pass only format configuration options + return Mage::getModel($modelName, $this->_config); + } +} \ No newline at end of file diff --git a/app/code/Mage/Webhook/Model/Formatter/Factory/Interface.php b/app/code/Mage/Webhook/Model/Formatter/Factory/Interface.php new file mode 100644 index 0000000000000..39e95f47b455c --- /dev/null +++ b/app/code/Mage/Webhook/Model/Formatter/Factory/Interface.php @@ -0,0 +1,33 @@ +_config = $config; + } + + /** + * @param $format string indicating the format used + * @return Mage_Webhook_Model_Formatter_Interface + */ + public function getFormatter($format) + { + $modelName = (string) $this->_config->getNode( + self::XML_PATH_DEFAULT_OPTIONS . 'format/' . $format . '/formatter' + ); + + if (!$modelName) { + $modelName = (string) $this->_config->getNode(self::XML_PATH_DEFAULT_OPTIONS . 'default_formatter'); + } + + if (!$modelName) { + throw new LogicException( + "There is no specific formatter for the format given $format and no default formatter." + ); + } + + $formatter = $this->getModel($modelName); + if (!$formatter instanceof Mage_Webhook_Model_Formatter_Interface) { + throw new LogicException("Wrong Formatter type for the model found given the format $format."); + } + + return $formatter; + } + + protected function getModel($modelName) + { + // TODO: probably here we should pass only format configuration options + return Mage::getModel($modelName, $this->_config); + } +} \ No newline at end of file diff --git a/app/code/Mage/Webhook/Model/Formatter/Interface.php b/app/code/Mage/Webhook/Model/Formatter/Interface.php new file mode 100644 index 0000000000000..fad421fabf512 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Formatter/Interface.php @@ -0,0 +1,41 @@ +newMessage(); + $message->setMapping($event->getMapping()); + $headers = $event->getHeaders(); + $headers[Mage_Webhook_Model_Formatter_Interface::CONTENT_TYPE_HEADER] = self::CONTENT_TYPE; + $bodyData = $event->getBodyData(); + $encodedData = json_encode($bodyData); + if (false === $encodedData) { + throw new LogicException("The data provided cannot be encoded as json."); + } + $message->setHeaders($headers); + $message->setBody($encodedData); + return $message; + } + + /** + * @param Mage_Webhook_Model_Message_Interface $message + * @return Mage_Webhook_Model_Message_Interface + */ + public function decode(Mage_Webhook_Model_Message_Interface $message) + { + $message->setResponseData( + json_decode($message->getResponseBody(), true) + ); + return $message; + } + + public function newMessage() { + return Mage::getModel('Mage_Webhook_Model_Message'); + } +} \ No newline at end of file diff --git a/app/code/Mage/Webhook/Model/Job/Dispatcher.php b/app/code/Mage/Webhook/Model/Job/Dispatcher.php new file mode 100644 index 0000000000000..69180a917571d --- /dev/null +++ b/app/code/Mage/Webhook/Model/Job/Dispatcher.php @@ -0,0 +1,177 @@ +_config = Mage::getConfig(); + $this->_formatterFactory = Mage::getModel('Mage_Webhook_Model_Formatter_Factory', $this->_config); + } + + public function dispatch(Mage_Webhook_Model_Job_Interface $job) + { + if ($job->getStatus() == Mage_Webhook_Model_Dispatch_Job::FAILED) { + return false; + } + + $event = $job->getEvent(); + $subscriber = $job->getSubscriber(); + + // TODO: if event or subscriber do not exist, detect and fail this job + + $transportStatus = self::SEND_FAILURE; + try { + if (!$subscriber->isSubscribedToTopic($event->getTopic())) { + $transportStatus = self::SEND_NOT_SUBSCRIBED; + } else { + $response = $this->_sendMessageToSubscriber($event, $subscriber); + $transportStatus = $this->_getTransportStatus($response); + } + } catch (Exception $e) { + /* important to catch exceptions here so the job status can be updated */ + Mage::logException($e); + } + + $this->_updateJobStatusBasedOnTransportStatus($transportStatus, $job); + + return true; + } + + protected function _getTransportStatus($response) + { + if ($response->isSuccessful()) { + return self::SEND_SUCCESS; + } + return self::SEND_FAILURE; + } + + protected function _updateJobStatusBasedOnTransportStatus($status, $job) + { + switch ($status) { + case self::SEND_SUCCESS: + $job->setStatus(Mage_Webhook_Model_Dispatch_Job::SUCCESS); + break; + case self::SEND_NOT_SUBSCRIBED: + $job->setStatus(Mage_Webhook_Model_Dispatch_Job::FAILED_NOT_SUBSCRIBED); + break; + case self::SEND_FAILURE: + $failureHandler = $this->_getFailureHandler(); + $failureHandler->handleFailure($job); + break; + default: + $job->setStatus(Mage_Webhook_Model_Dispatch_Job::FAILED); + break; + } + + $job->save(); + } + + /** + * @param Mage_Webhook_Model_Event_Interface $event + * @param Mage_Webhook_Model_Subscriber $subscriber + * @return mixed + * @throws Mage_Core_Exception + */ + public function dispatchCallback(Mage_Webhook_Model_Event_Interface $event, Mage_Webhook_Model_Subscriber $subscriber) + { + $format = $subscriber->getFormat(); + if (empty($format)) { + throw Mage::exception('Mage_Webhook', + Mage::helper('Mage_Webhook_Helper_Data')->__('Format is empty for subscriber with ID: %s', + $subscriber->getId())); + } + $formatter = $this->_getFormatterFactory()->getFormatterFactory($format)->getFormatter($event->getMapping()); + + $message = $formatter->format($event); + $response = $this->_getTransport()->dispatchMessage($message, $subscriber); + + if ($response->isSuccessful()) { + $message->setResponseBody($response->getBody()); + $formatter->decode($message); + return $message; + } + throw Mage::exception('Mage_Webhook', 'Callback was not able to retrieve the response'); + } + + protected function _sendMessageToSubscriber(Mage_Webhook_Model_Event_Interface $event, + Mage_Webhook_Model_Subscriber $subscriber) + { + $format = $subscriber->getFormat(); + if (empty($format)) { + Mage::logException( + Mage::exception('Mage_Webhook', + Mage::helper('Mage_Webhook_Helper_Data') + ->__('Format is empty for subscriber with ID: %s', $subscriber->getId()))); + return self::SEND_FAILURE; + } + + /** @var $formatter */ + $formatter = $this->_getFormatterFactory()->getFormatterFactory($format)->getFormatter($event->getMapping()); + /** @var $message Mage_Webhook_Model_Message_Interface */ + $message = $formatter->format($event); + + $response = $this->_getTransport()->dispatchMessage($message, $subscriber); + + return $response; + } + + protected function _getFailureHandler() + { + return Mage::getModel('Mage_Webhook_Model_Job_Retry_Handler'); + } + + protected function _getFormatterFactory() + { + return $this->_formatterFactory; + } + + protected function _getTransport() + { + $type = Mage::getConfig()->getNode(self::XML_PATH_WEBHOOK_SETTINGS . '/default/transport_type'); + $modelName = Mage::getConfig()->getNode(self::XML_PATH_WEBHOOK_SETTINGS . "/transports/{$type}/class"); + $transport = Mage::getModel((string) $modelName); + if (!$transport || !$transport instanceof Mage_Webhook_Model_Transport_Interface) { + throw Mage::exception('Mage_Webhook', Mage::helper('Mage_Webhook_Helper_Data') + ->__("Cannot find transport model for type %s.", $type) + ); + } + + return $transport; + } +} diff --git a/app/code/Mage/Webhook/Model/Job/Dispatcher/Interface.php b/app/code/Mage/Webhook/Model/Job/Dispatcher/Interface.php new file mode 100644 index 0000000000000..792a20eef54e0 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Job/Dispatcher/Interface.php @@ -0,0 +1,35 @@ +poll()) != null) { + $this->createJobs($event); + } + } + + /** + * Creates a job from the event parameter. A job associates an event with a subscriber. + * + * @param Mage_Webhook_Model_Event $event + */ + public function createJobs(Mage_Webhook_Model_Event $event) + { + $topic = $event->getTopic(); + + $subscriberCollection = $this->getResourceSubscriberCollection()->addTopicFilter($topic) + ->addMappingFilter($event->getMapping()) + ->addIsActiveFilter(true); + + if (!empty($subscriberCollection)) { + foreach ($subscriberCollection as $subscriber) { + $job = $this->_newDispatchJob() + ->setSubscriberId($subscriber->getId()) + ->setEventId($event->getId()) + ->setStatus(Mage_Webhook_Model_Dispatch_Job::READY_TO_SEND); + $job->save(); + } + } + } + + public function getResourceSubscriberCollection() { + return Mage::getResourceModel('Mage_Webhook_Model_Resource_Subscriber_Collection'); + } + + /** + * Returns an instance of a dispatch job. + * + * @return Mage_Webhook_Model_Dispatch_Job + */ + protected function _newDispatchJob() + { + return Mage::getModel('Mage_Webhook_Model_Dispatch_Job'); + } +} diff --git a/app/code/Mage/Webhook/Model/Job/Retry/Handler.php b/app/code/Mage/Webhook/Model/Job/Retry/Handler.php new file mode 100644 index 0000000000000..80a5ed8127afd --- /dev/null +++ b/app/code/Mage/Webhook/Model/Job/Retry/Handler.php @@ -0,0 +1,57 @@ + 1, + 2 => 2, + 3 => 4, + 4 => 10, + 5 => 30, + 6 => 60, + 7 => 120, + 8 => 240, + ); + + /** + * Handles job dispatch failures. + * @param Mage_Webhook_Model_Job_Interface $job + */ + public function handleFailure(Mage_Webhook_Model_Job_Interface $job) + { + $retryCount = $job->getRetryCount() + 1; + if ($retryCount < count(self::$RETRY_TIME_TO_ADD) + 1) { + $addedTimeInMinutes = self::$RETRY_TIME_TO_ADD[$retryCount] * 60 + time(); + $job->setRetryCount($retryCount); + $job->setRetryAt(Varien_Date::formatDate($addedTimeInMinutes, true)); + $job->setUpdatedAt(Varien_Date::formatDate(time(), true)); + $job->setStatus(Mage_Webhook_Model_Dispatch_Job::RETRY); + } else { + $job->setStatus(Mage_Webhook_Model_Dispatch_Job::FAILED); + } + } +} diff --git a/app/code/Mage/Webhook/Model/Mapper/Default.php b/app/code/Mage/Webhook/Model/Mapper/Default.php new file mode 100644 index 0000000000000..a4dd048bf03dc --- /dev/null +++ b/app/code/Mage/Webhook/Model/Mapper/Default.php @@ -0,0 +1,137 @@ +_topic = $topic; + $this->_objects = $objects; + } + + public function getTopic() + { + return $this->_topic; + } + + public function getHeaders() + { + return array(self::TOPIC_HEADER => $this->_topic); + } + + public function getData() + { + if (is_null($this->_data)) { + $this->_mapData(); + } + + return $this->_data; + } + + protected function _mapData() + { + $this->_data = array(); + foreach ($this->_objects as $name => $object) { + if ($object instanceof Varien_Object || is_array($object)) { + $this->_data[$name] = $this->_convertObjectToArray($object); + } else { + $this->_data[$name] = $object; + } + } + } + + /** + * Converts a Varien_Object into an array, including any children objects + * + * @param Varien_Object $obj + * @param array $objects + * @param bool $performRedaction If set to true will redact any fields returned from _getListOfRedactedFields. + * @return array|string + */ + protected function _convertObjectToArray($obj, &$objects = array(), $performRedaction = true) + { + if (is_object($obj)) { + $hash = spl_object_hash($obj); + if (!empty($objects[$hash])) { + return self::CYCLE_DETECTED_MARK; + } + $objects[$hash] = true; + $data = $obj->getData(); + } + else if (is_array($obj)) { + $data = $obj; + } + + $result = array(); + foreach ($data as $key=>$value) { + if ($performRedaction && $this->_shouldRedact($key)) { + $result[$key] = self::REDACTED; + } elseif (is_scalar($value)) { + $result[$key] = $value; + } elseif (is_array($value)) { + $result[$key] = $this->_convertObjectToArray($value, $objects, $performRedaction); + } elseif ($value instanceof Varien_Object) { + $result[$key] = $this->_convertObjectToArray($value, $objects, $performRedaction); + } + } + return $result; + } + + private $_redactedFields = array( + 'password', + 'password_hash', + ); + /** + * Returns a list of field names that should be redacted before sending any output + */ + protected function _getListOfRedactedFields() + { + // TODO: it shouldn't be hardcoded. add an ability to configure it from XML config + return $this->_redactedFields; + } + + private function _shouldRedact($key) + { + $redacted = $this->_getListOfRedactedFields(); + if (is_string($key)) { + return in_array($key, $redacted); + } else { + return false; + } + } +} \ No newline at end of file diff --git a/app/code/Mage/Webhook/Model/Mapper/Default/Factory.php b/app/code/Mage/Webhook/Model/Mapper/Default/Factory.php new file mode 100644 index 0000000000000..d229bef4af4bf --- /dev/null +++ b/app/code/Mage/Webhook/Model/Mapper/Default/Factory.php @@ -0,0 +1,58 @@ +_objectManager = $objectManager; + } + + /** + * Get mapper + * + * @param string $topic + * @param array $data + * @return Mage_Webhook_Model_Mapper_Interface + */ + public function getMapper($topic, array $data) + { + return $this->_objectManager->create( + 'Mage_Webhook_Model_Mapper_Default', + array('topic' => $topic, 'objects' => $data) + ); + } +} diff --git a/app/code/Mage/Webhook/Model/Mapper/Default/Factory/Interface.php b/app/code/Mage/Webhook/Model/Mapper/Default/Factory/Interface.php new file mode 100644 index 0000000000000..bc3ccfa9409bf --- /dev/null +++ b/app/code/Mage/Webhook/Model/Mapper/Default/Factory/Interface.php @@ -0,0 +1,41 @@ +_objectManager = $objectManager; + } + + /** + * Get mapper factory for specified mapping + * + * @param string $mapping + * @param Mage_Core_Model_Config_Element $config + * @return Mage_Webhook_Model_Mapper_Factory_Interface + * @throws LogicException + */ + public function getMapperFactory($mapping, Mage_Core_Model_Config_Element $config) + { + $options = $config->asArray(); + if (empty($options[$mapping]['mapper_factory'])) { + throw new LogicException("Wrong mapping name $mapping."); + } + + $factory = $this->_objectManager->create($options[$mapping]['mapper_factory'], array($this->_objectManager)); + if (!$factory instanceof Mage_Webhook_Model_Mapper_Factory_Interface) { + throw new LogicException("Wrong Mapper type for mapping $mapping."); + } + + return $factory; + } +} diff --git a/app/code/Mage/Webhook/Model/Mapper/Factory/Default.php b/app/code/Mage/Webhook/Model/Mapper/Factory/Default.php new file mode 100644 index 0000000000000..291db2c07683b --- /dev/null +++ b/app/code/Mage/Webhook/Model/Mapper/Factory/Default.php @@ -0,0 +1,79 @@ +_objectManager = $objectManager; + } + + /** + * (non-PHPdoc) + * @see Mage_Webhook_Model_Mapper_Factory_Interface::getMapper() + */ + public function getMapper($topic, array $data, Mage_Core_Model_Config_Element $config) + { + $customTopicMapperName = (string) $config->descend("topics/$topic/options/model"); + if (!empty($customTopicMapperName)) { + $mapper = $this->_createMapper($customTopicMapperName, $topic, $data); + if ($mapper) { + return $mapper; + } + } + + $defaultMapperName = (string) $config->descend("default_mapper"); + if (!empty($defaultMapperName)) { + $mapper = $this->_createMapper($defaultMapperName, $topic, $data); + if ($mapper) { + return $mapper; + } + } + + return $this->_createMapper('Mage_Webhook_Model_Mapper_Default_Factory', $topic, $data); + } + + protected function _createMapper($className, $topic, array $data) + { + $model = $this->_objectManager->create($className, array($this->_objectManager)); + if (!$model instanceof Mage_Webhook_Model_Mapper_Default_Factory_Interface) { + return false; + } + + return $model->getMapper($topic, $data); + } +} \ No newline at end of file diff --git a/app/code/Mage/Webhook/Model/Mapper/Factory/Interface.php b/app/code/Mage/Webhook/Model/Mapper/Factory/Interface.php new file mode 100644 index 0000000000000..308ac61f368f1 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Mapper/Factory/Interface.php @@ -0,0 +1,40 @@ +setData('mapping', $mapping); + } + + /** + * Takes array of headers in format + * 'header_name' => 'header_value' + * + * @param array $headers + * @return Mage_Webhook_Model_Message_Interface + */ + public function setHeaders(array $headers) + { + return $this->setData('headers', $headers); + } + + /** + * @param string $body + * @return Mage_Webhook_Model_Message_Interface + */ + public function setBody($body) + { + return $this->setData('body', $body); + } + + /** + * @param string $responseBody + * @return Mage_Webhook_Model_Message_Interface + */ + public function setResponseBody($responseBody) + { + return $this->setData('response_body', $responseBody); + } + + /** + * @param $responseData + * @return Mage_Webhook_Model_Message_Interface + */ + public function setResponseData(array $responseData) + { + return $this->setData('response_data', $responseData); + } + + /** + * @return array + */ + public function getHeaders() + { + return $this->getData('headers'); + } + + /** + * @return string + */ + public function getBody() + { + return $this->getData('body'); + } + + /** + * @return string + */ + public function getResponseData() + { + return $this->getData('response_data'); + } + + /** + * @return array + */ + public function getResponseBody() + { + return $this->getData('response_body'); + } + + /** + * @param $url + * @return Mage_Webhook_Model_Message_Interface + */ + public function setEndpointUrl($url) + { + return $this->setData('endpoint_url', $url); + } + + /** + * @return string + */ + public function getEndpointUrl() + { + return $this->getData('endpoint_url'); + } + + /** + * @return string + */ + public function getMapping() + { + return $this->getData('mapping'); + } +} diff --git a/app/code/Mage/Webhook/Model/Message/Interface.php b/app/code/Mage/Webhook/Model/Message/Interface.php new file mode 100644 index 0000000000000..f26de02856874 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Message/Interface.php @@ -0,0 +1,97 @@ + 'header_value' + * + * @param array $headers + * @return Mage_Webhook_Model_Message_Interface + */ + public function setHeaders(array $headers); + + /** + * @param string $body + * @return Mage_Webhook_Model_Message_Interface + */ + public function setBody($body); + + /** + * @param string $responseBody + * @return Mage_Webhook_Model_Message_Interface + */ + public function setResponseBody($responseBody); + + /** + * @param $responseData + * @return Mage_Webhook_Model_Message_Interface + */ + public function setResponseData(array $responseData); + + /** + * @return array + */ + public function getHeaders(); + + /** + * @return string + */ + public function getBody(); + + /** + * @return string + */ + public function getResponseData(); + + /** + * @return array + */ + public function getResponseBody(); + + /** + * @param $url + * @return Mage_Webhook_Model_Message_Interface + */ + public function setEndpointUrl($url); + + /** + * @return string + */ + public function getEndpointUrl(); + + /** + * @return string + */ + public function getMapping(); + +} \ No newline at end of file diff --git a/app/code/Mage/Webhook/Model/Observer.php b/app/code/Mage/Webhook/Model/Observer.php new file mode 100644 index 0000000000000..0bc6438c5f2e9 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Observer.php @@ -0,0 +1,191 @@ +_webapiEventHandlerFactory = $webapiEventHandlerFactory; + } + + /** + * Send the messages for each job. + * + * @return Mage_Webhook_Model_Observer + */ + public function processDispatchJobs() + { + $jobsToDo = array( + Mage_Webhook_Model_Dispatch_Job::READY_TO_SEND, + Mage_Webhook_Model_Dispatch_Job::RETRY + ); + + /** @var $collection Varien_Data_Collection_Db */ + $collection = Mage::getResourceModel('Mage_Webhook_Model_Resource_Dispatch_Job_Collection') + ->setPageSize(self::PAGE_SIZE) + ->setOrder('created_at', Varien_Data_Collection::SORT_ORDER_DESC) + ->addFieldToFilter('status', array('in' => $jobsToDo)) + ->addFieldToFilter('retry_at', array('to' => Varien_Date::formatDate(true), 'datetime' => true)); + + + if ($collection->getSize() > 0) { + for ($i = 1; $i <= $collection->getLastPageNumber(); $i++) { + $collection->setCurPage($i) + ->addLimitPage() + ->clear(); + + foreach ($collection as $job) { + $job_dispatcher = Mage::getModel('Mage_Webhook_Model_Job_Dispatcher'); + $job_dispatcher->dispatch($job); + } + } + } + + return $this; + } + + /** + * Creates jobs to dispatch from unprocessed events. + * + * @return Mage_Webhook_Model_Observer + */ + public function processEventsToDispatch() + { + $queue = Mage::getModel('Mage_Webhook_Model_Event_Queue'); + Mage::getModel('Mage_Webhook_Model_Job_Processor')->createJobsFromQueue($queue); + + return $this; + } + + /** + * Take a generic event and dispatch it by using the magento event topic as our webhook topic name. + * @param $observer Varien_Event_Observer + */ + public function dispatchEvent($observer) + { + $event = $observer->getEvent(); + $topic = $event->getName(); + $object = $event->getDataObject(); + + /** + * Thought was to read params from event in generic fashion. Problem is we can't even get an array + * Best bet is to read data from Observer and filter out 'event'. Then turn that into an array which + * could contain Varien Objects... so maybe wrap it all in a varien object. Worth it? + */ + $topicData = new Varien_Object($observer->getData()); + $topicData->unsetData('event'); + + try { + Mage::helper('Mage_Webhook_Helper_Data')->dispatchEvent($topic, array('object' => $topicData)); + } catch (Exception $e) { + Mage::logException($e); + } + } + + /** + * Triggered after webapi user deleted + * + * @param Varien_Event_Observer $observer + * @return Mage_Webhook_Model_Observer + */ + public function afterWebapiUserDelete(Varien_Event_Observer $observer) + { + try{ + $collection = Mage::getResourceModel('Mage_Webhook_Model_Resource_Subscriber_Collection'); + $subscribers = $collection->addFieldToFilter('api_user_id', array("null" => null)) + ->addFieldToFilter('status', array("neq" => Mage_Webhook_Model_Subscriber::STATUS_INACTIVE)) + ->getItems(); + if (count($subscribers) > 0) { + foreach ($subscribers as $subscriber) { + $subscriber->load($subscriber->getId())->save(); + } + } + } catch (Exception $exception) { + $this->_handleException($exception); + } + return $this; + } + + /** + * Triggered after webapi user change + * + * @param Varien_Event_Observer $observer + * @return Mage_Webhook_Model_Observer + */ + public function afterWebapiUserChange(Varien_Event_Observer $observer) + { + $model = $observer->getEvent()->getObject(); + + $this->_getWebapiEventHandler()->userChanged($model); + } + + /** + * Triggered after webapi role change + * + * @param Varien_Event_Observer $observer + * @return Mage_Webhook_Model_Observer + */ + public function afterWebapiRoleChange(Varien_Event_Observer $observer) + { + $model = $observer->getEvent()->getObject(); + + $this->_getWebapiEventHandler()->roleChanged($model); + } + + /** + * Returns an event handler for events related to webapi + * @return Mage_Webhook_Model_Webapi_EventHandler event handler + */ + protected function _getWebapiEventHandler() + { + if (null === $this->_webapiEventHandler) { + $this->_webapiEventHandler = $this->_webapiEventHandlerFactory->create(); + } + return $this->_webapiEventHandler; + } + + + private function _debug($debuggable) + { + if (method_exists($debuggable, 'debug')) { + Mage::log($debuggable->debug()); + } else { + Mage::log(print_r($debuggable, true)); + } + } + + + +} diff --git a/app/code/Mage/Webhook/Model/Resource/Dispatch/Job.php b/app/code/Mage/Webhook/Model/Resource/Dispatch/Job.php new file mode 100644 index 0000000000000..15e8ad2ef9987 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Resource/Dispatch/Job.php @@ -0,0 +1,33 @@ +_init('webhook_dispatch_job', 'dispatch_job_id'); + } +} diff --git a/app/code/Mage/Webhook/Model/Resource/Dispatch/Job/Collection.php b/app/code/Mage/Webhook/Model/Resource/Dispatch/Job/Collection.php new file mode 100644 index 0000000000000..d5e85d9921f0c --- /dev/null +++ b/app/code/Mage/Webhook/Model/Resource/Dispatch/Job/Collection.php @@ -0,0 +1,45 @@ +_init('Mage_Webhook_Model_Dispatch_Job', 'Mage_Webhook_Model_Resource_Dispatch_Job'); + } + + /** + * Add alias method for Zend limitPage(). + * + * @return Mage_Webhook_Model_Resource_Dispatch_Job_Collection + */ + public function addLimitPage() + { + $this->_select->limitPage($this->getCurPage(), $this->getPageSize()); + return $this; + } +} diff --git a/app/code/Mage/Webhook/Model/Resource/Event.php b/app/code/Mage/Webhook/Model/Resource/Event.php new file mode 100644 index 0000000000000..d920ad10fbf9c --- /dev/null +++ b/app/code/Mage/Webhook/Model/Resource/Event.php @@ -0,0 +1,32 @@ +_init('webhook_event', 'event_id'); + } +} diff --git a/app/code/Mage/Webhook/Model/Resource/Event/Collection.php b/app/code/Mage/Webhook/Model/Resource/Event/Collection.php new file mode 100644 index 0000000000000..a7e60e5cf485d --- /dev/null +++ b/app/code/Mage/Webhook/Model/Resource/Event/Collection.php @@ -0,0 +1,34 @@ +_init('Mage_Webhook_Model_Event', 'Mage_Webhook_Model_Resource_Event'); + } +} diff --git a/app/code/Mage/Webhook/Model/Resource/Subscriber.php b/app/code/Mage/Webhook/Model/Resource/Subscriber.php new file mode 100644 index 0000000000000..3bacd41f3151c --- /dev/null +++ b/app/code/Mage/Webhook/Model/Resource/Subscriber.php @@ -0,0 +1,165 @@ +_init('webhook_subscriber', 'subscriber_id'); + } + + /** + * Get api user subscribers + * + * @param int $apiUserId + * @return array + */ + public function getApiUserSubscribers($apiUserId) + { + $adapter = $this->_getReadAdapter(); + $select = $adapter->select() + ->from($this->getMainTable(), array('subscriber_id')) + ->where('api_user_id = ?', (int)$apiUserId); + return $adapter->fetchCol($select); + } + + /** + * Gets list ot topics for subscriber + * + * @param int $id + * @return Mage_Webhook_Model_Resource_Subscriber + */ + protected function _getTopics($id) + { + $adapter = $this->_getReadAdapter(); + $select = $adapter->select() + ->from($this->getTable('webhook_subscriber_hook'), 'topic') + ->where('subscriber_id = ?', $id); + return $adapter->fetchCol($select); + } + + /** + * Updates list of topics for subscriber + * + * @param array $oldTopics + * @param Mage_Core_Model_Abstract $object + * @return Mage_Webhook_Model_Resource_Subscriber + */ + protected function _updateTopics($oldTopics, Mage_Core_Model_Abstract $object) + { + $newTopics = $object->getData('topics'); + $availableTopics = $object->getAvailableHooks(); + $id = $object->getId(); + if (!empty($newTopics) && is_array($newTopics)) { + if (!empty($availableTopics) && is_array($availableTopics)) { + $newTopics = array_intersect($newTopics, $availableTopics); + } + $intersection = array(); + if (!empty($oldTopics) && is_array($oldTopics)) { + $intersection = array_intersect($newTopics, $oldTopics); + $oldTopics = array_diff($oldTopics, $intersection); + } else { + $oldTopics = array(); + } + $newTopics = array_diff($newTopics, $intersection); + + $insertData = array(); + + foreach ($newTopics as $topic) { + $insertData[] = array( + 'subscriber_id' => $id, + 'topic' => $topic + ); + } + + if (count($oldTopics) > 0) { + $this->_getWriteAdapter()->delete( + $this->getTable('webhook_subscriber_hook'), + array( + 'subscriber_id = ?' => $id, + 'topic in (?)' => $oldTopics + ) + ); + } + + if (count($insertData) > 0) { + $this->_getWriteAdapter()->insertMultiple( + $this->getTable('webhook_subscriber_hook'), + $insertData + ); + } + } + return $this; + } + + /** + * Perform actions after object load + * + * @param Varien_Object $object + * @return Mage_Core_Model_Resource_Db_Abstract + */ + protected function _afterLoad(Mage_Core_Model_Abstract $object) + { + $object->setData('topics', $this->_getTopics($object->getId())); + return parent::_afterLoad($object); + } + + /** + * Perform actions after object save + * + * @param Varien_Object $object + * @return Mage_Core_Model_Resource_Db_Abstract + */ + protected function _afterSave(Mage_Core_Model_Abstract $object) + { + $oldTopics = $this->_getTopics($object->getId()); + $this->_updateTopics($oldTopics, $object); + return parent::_afterSave($object); + } + + /** + * Returns the list of callback topics which already have subscribers + * + * @param array $topicsList + * @return array + */ + public function getSubscribedCallbackTopics($topicsList) + { + $select = $this->_getReadAdapter()->select(); + $select->from($this->getMainTable() . ' as main_table', 'hook.topic as topic')->joinInner( + array('hook' => $this->getTable('webhook_subscriber_hook')), + 'main_table.subscriber_id = hook.subscriber_id', + 'hook.topic as topic' + )->where('hook.topic in(?)', $topicsList) + ->where($this->_getReadAdapter()->prepareSqlCondition( + 'main_table.api_user_id', + array('notnull' => true) + )); + + $result = $this->_getReadAdapter()->fetchCol($select); + + return $result; + } +} diff --git a/app/code/Mage/Webhook/Model/Resource/Subscriber/Collection.php b/app/code/Mage/Webhook/Model/Resource/Subscriber/Collection.php new file mode 100644 index 0000000000000..86e97477069f1 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Resource/Subscriber/Collection.php @@ -0,0 +1,99 @@ +_init('Mage_Webhook_Model_Subscriber', 'Mage_Webhook_Model_Resource_Subscriber'); + } + + /** + * Add filter by topic field to collection + * + * @param $topic + * @return Mage_Webhook_Model_Resource_Subscriber_Collection + */ + public function addTopicFilter($topic) + { + $this->getSelect() + ->joinInner(array('hooks' => $this->getTable('webhook_subscriber_hook')), + $this->getConnection() + ->quoteInto('hooks.subscriber_id=main_table.subscriber_id AND hooks.topic=?', $topic) + ); + return $this; + } + + /** + * Add filter by mapping field to collection + * + * @param $mapping + * @return Mage_Webhook_Model_Resource_Subscriber_Collection + */ + public function addMappingFilter($mapping) + { + $this->addFieldToFilter('mapping', $mapping); + return $this; + } + + public function addExtensionIdFilter($extensionId) + { + $this->addFieldToFilter('extension_id', $extensionId); + return $this; + } + + /** + * Adds filter by status field to collection based on parameter + * + * @param $isActive + * @return Mage_Webhook_Model_Resource_Subscriber_Collection + */ + public function addIsActiveFilter($isActive) + { + if ($isActive) { + $this->addFieldToFilter('status', Mage_Webhook_Model_Subscriber::STATUS_ACTIVE); + } else { + $this->addFieldToFilter('status', Mage_Webhook_Model_Subscriber::STATUS_INACTIVE); + } + return $this; + } + + /** + * Retrieve just a single subscriber + * + * @throws Mage_Core_Exception + */ + public function getSingleSubscriber() + { + /** @var $subscriber Mage_Webhook_Model_Subscriber */ + $subscriber = $this->getFirstItem(); + if (!(bool)$subscriber->getId()) { + return null; + } + return $subscriber; + } +} diff --git a/app/code/Mage/Webhook/Model/Source/Authentication.php b/app/code/Mage/Webhook/Model/Source/Authentication.php new file mode 100644 index 0000000000000..230e9b9e78fb9 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Source/Authentication.php @@ -0,0 +1,78 @@ +_options) { + return $this->_options; + } + + $this->_options = array(); + + $config = Mage::getConfig()->getNode(self::XML_PATH_AUTHENTICATIONS); + if (!$config) { + return $this->_options; + } + $this->_options = $config->asArray(); + + return $this->_options; + } + + public function getAuthenticationsForForm() + { + $elements = array(); + foreach ($this->toOptionArray() as $authName => $authentication) { + $elements[] = array( + 'label' => Mage::helper('Mage_Webhook_Helper_Data')->__($authentication['label']), + 'value' => $authName, + ); + } + + return $elements; + } +} diff --git a/app/code/Mage/Webhook/Model/Source/Format.php b/app/code/Mage/Webhook/Model/Source/Format.php new file mode 100644 index 0000000000000..9fa61a0c6f05d --- /dev/null +++ b/app/code/Mage/Webhook/Model/Source/Format.php @@ -0,0 +1,81 @@ +_options) { + return $this->_options; + } + + $this->_options = array(); + + $config = Mage::getConfig()->getNode(self::XML_PATH_FORMATS); + if (!$config) { + return $this->_options; + } + $this->_options = $config->asArray(); + + return $this->_options; + } + + public function getFormatsForForm() + { + $elements = array(); + // process groups + foreach ($this->toOptionArray() as $formatName => $format) { + if (!empty($format['label'])) { + $elements[] = array( + 'label' => Mage::helper('Mage_Webhook_Helper_Data')->__($format['label']), + 'value' => $formatName, + ); + } + } + + return $elements; + } +} diff --git a/app/code/Mage/Webhook/Model/Source/Hook.php b/app/code/Mage/Webhook/Model/Source/Hook.php new file mode 100644 index 0000000000000..b10f5f762e0d2 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Source/Hook.php @@ -0,0 +1,133 @@ +_options) { + return $this->_options; + } + + $this->_options = array(); + + $config = Mage::getConfig()->getNode(self::XML_PATH_WEBHOOK); + if (!$config) { + return $this->_options; + } + $this->_options = $config->asArray(); + + return $this->_options; + } + + public function getTopicsForForm() + { + $elements = array(); + + // process groups + $elements = $this->_getTopicsForForm($this->toOptionArray(), array(), $elements); + + return $elements; + } + + // TODO: Consider making elements a reference + /** + * Recursive helper function to dynamically build topic information for our form. + * Seeks out nodes under 'webhook' stopping when it finds a leaf that contains 'label' + * The value is constructed using the XML tree parents. + * @param $node + * @param $path + * @param $elements + * @return array + */ + protected function _getTopicsForForm($node, $path, $elements) + { + if (!empty($node['label'])) { + $value = join('/', $path); + + $type = self::DEFAULT_TYPE; + if (!empty($node['type'])) { + $type = $node['type']; + } + + $label = Mage::helper('Mage_Webhook_Helper_Data')->__($node['label']); + + if ($type === self::CALLBACK_TYPE) { + $label = Mage::helper('Mage_Webhook_Helper_Data')->__('%s (Callback)', $label); + } + + $elements[] = array( + 'label' => $label, + 'value' => $value, + ); + + return $elements; + } + + foreach ($node as $group => $child) { + $path[] = $group; + $elements = $this->_getTopicsForForm($child, $path, $elements); + array_pop($path); + } + + return $elements; + } +} diff --git a/app/code/Mage/Webhook/Model/Source/Mapping.php b/app/code/Mage/Webhook/Model/Source/Mapping.php new file mode 100644 index 0000000000000..34910ea9e0395 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Source/Mapping.php @@ -0,0 +1,81 @@ +_options) { + return $this->_options; + } + + $this->_options = array(); + + $config = Mage::getConfig()->getNode(self::XML_PATH_MAPPINGS); + if (!$config) { + return $this->_options; + } + $this->_options = $config->asArray(); + + return $this->_options; + } + + public function getMappingsForForm() + { + $elements = array(); + // process groups + foreach ($this->toOptionArray() as $mappingName => $mapping) { + if (!empty($mapping['label'])) { + $elements[] = array( + 'label' => Mage::helper('Mage_Webhook_Helper_Data')->__($mapping['label']), + 'value' => $mappingName, + ); + } + } + + return $elements; + } +} diff --git a/app/code/Mage/Webhook/Model/Source/Subscriber.php b/app/code/Mage/Webhook/Model/Source/Subscriber.php new file mode 100644 index 0000000000000..52fea6587bb54 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Source/Subscriber.php @@ -0,0 +1,80 @@ +_options) { + return $this->_options; + } + + $this->_options = array(); + + $config = Mage::getConfig()->getNode(self::XML_PATH_SUBSCRIBER_TYPES); + if (!$config) { + return $this->_options; + } + $this->_options = $config->asArray(); + + return $this->_options; + } + + public function getSubscriberTypesForForm() + { + $elements = array(); + // process groups + foreach ($this->toOptionArray() as $subscriberTypeName => $subscriberType) { + if ($subscriberType['status'] === 'enabled') { + $elements[] = array( + 'label' => Mage::helper('Mage_Webhook_Helper_Data')->__($subscriberType['label']), + 'value' => $subscriberTypeName, + ); + } + } + + return $elements; + } +} diff --git a/app/code/Mage/Webhook/Model/Source/Transport.php b/app/code/Mage/Webhook/Model/Source/Transport.php new file mode 100644 index 0000000000000..e124b5e359d6b --- /dev/null +++ b/app/code/Mage/Webhook/Model/Source/Transport.php @@ -0,0 +1,81 @@ +_options) { + return $this->_options; + } + + $this->_options = array(); + + $config = Mage::getConfig()->getNode(self::XML_PATH_TRANSPORTS); + if (!$config) { + return $this->_options; + } + $this->_options = $config->asArray(); + + return $this->_options; + } + + public function getTransportsForForm() + { + $elements = array(); + // process groups + foreach ($this->toOptionArray() as $transportName => $transport) { + if ($transport['status'] === 'enabled') { + $elements[] = array( + 'label' => Mage::helper('Mage_Webhook_Helper_Data')->__($transport['label']), + 'value' => $transportName, + ); + } + } + + return $elements; + } +} diff --git a/app/code/Mage/Webhook/Model/Subscriber.php b/app/code/Mage/Webhook/Model/Subscriber.php new file mode 100644 index 0000000000000..7390d6f4ec454 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Subscriber.php @@ -0,0 +1,300 @@ +_init('Mage_Webhook_Model_Resource_Subscriber'); + } + + /** + * Load the Webapi user model for specified subscriber + * + * @return Mage_Webapi_Model_Acl_User + */ + public function getApiUser() + { + return Mage::getModel('Mage_Webapi_Model_Acl_User')->load($this->getApiUserId()); + } + + /** + * Create new API User and Role for the subscriber's needs + * + * @param string $email + * @param string $key + * @param string $secret + * @param string $company + * @throws Exception + */ + public function createUserAndRole($email, $key, $secret, $company) + { + Mage::getModel('Mage_Webhook_Model_Subscriber_Webapi', $this) + ->createUserAndRole($email, $key, $secret, $company); + + return $this; + } + + /** + * Determines if the subscriber is subscribed to a topic. + * + * @param string $topic the topic to check + * @return boolean true if subscribed, false otherwise + */ + public function isSubscribedToTopic($topic) + { + return in_array($topic, $this->getTopics()); + } + + /** + * Return a list of acl permissions that are required for this subscribers subscriptions. + */ + public function getRequiredPermissions() + { + $aclConfig = Mage::getModel('Mage_Webhook_Model_Authorization_Config'); + $aclPermissions = array(); + foreach ($this->getTopics() as $topic) { + $aclPermissions[$aclConfig->getParentFromTopic($topic)] = TRUE; + } + + return array_keys($aclPermissions); + } + + /** + * Get auth model which is used by the subscriber + * + * @return Mage_Webhook_Model_Authentication_Interface + */ + public function getAuthenticationModel() + { + if (!$this->_authenticationModel) { + $modelClass = (string) Mage::getConfig() + ->getNode(self::XML_PATH_AUTHENTICATION_TYPES . '/' . $this->getAuthenticationType() . '/class'); + $this->_authenticationModel = Mage::getModel($modelClass); + + if (!$this->_authenticationModel instanceof Mage_Webhook_Model_Authentication_Interface) { + throw new LogicException( + "Can't load authentication model '{$this->getAuthenticationType()}' for subscriber with ID {$this->getId()}." + ); + } + } + + return $this->_authenticationModel; + } + + /** + * Prepare data to be saved to database + * @return Mage_Core_Model_Abstract + * @throws Mage_Webhook_Exception + */ + protected function _beforeSave() + { + parent::_beforeSave(); + if (!$this->hasStatus()) { + $this->setStatus(Mage_Webhook_Model_Subscriber::STATUS_INACTIVE); + } + + if (!$this->hasAuthenticationType()) { + $this->setAuthenticationType(self::AUTH_TYPE_NONE); + } + + if(!$this->hasRegistrationMechanism()) { + $this->setRegistrationMechanism(self::REGISTRATION_MECHANISM_MANUAL); + } + + if ($this->hasDataChanges()) { + $this->setUpdatedAt($this->_getResource()->formatDate(time())); + } + + return $this; + } + + /** + * This was being used to filter out callback topics that were already subscribed by someone. No longer the case. + * Limits are no longer tied to callback topics + * TODO: Refactor how limits work + */ + protected function _filterOutRestrictedTopics() + { + $notAllowedTopics = $this->getSubscribedCallbackTopics(); + + if ($this->getApiUserId()) { + if (!$this->getIsNewlyActivated()) { + $existing = $this->getOrigData('topics'); + $existing = is_null($existing) ? array() : $existing; + $notAllowedTopics = array_diff($notAllowedTopics, $existing); + } + + if (!empty($notAllowedTopics) && !$this->getIsNewlyActivated()) { + throw Mage::exception('Mage_Core', 'Cannot save callback which already has subscriber'); + } + $topics = $this->getTopics(); + $topics = array_diff($topics, $notAllowedTopics); + $this->setTopics($topics); + } + } + + /** + * Load object data + * + * @param integer $id + * @return Mage_Core_Model_Abstract + */ + public function load($id, $field=null) + { + parent::load($id, $field); + + if (is_null($this->getApiUserId())) { + $this->setStatus(self::STATUS_INACTIVE); + } + + return $this; + } + + public function getAvailableHooks() + { + $node = Mage::getConfig()->getNode(Mage_Webhook_Model_Source_Hook::XML_PATH_WEBHOOK); + $availableHooks = array(); + foreach ($node->asArray() as $key => $hookNode) { + foreach ($hookNode as $name => $hook) { + if (is_array($hook)) { + $availableHooks[] = $key . '/' . $name; + } + } + if ($hook['label']) { + $availableHooks[] = $key; + } + } + + return $availableHooks; + } + + public function validate() { + Mage::getModel('Mage_Webhook_Model_Subscriber_Webapi', $this)->validate(); + return $this; + } + + /** + * Gets callback topics + * + * @return array + */ + protected function _getCallbackTopics() + { + $topics = $this->getTopics(); + $callbackHooks = array(); + foreach($topics as $topicName) { + $node = Mage::getConfig()->getNode(Mage_Webhook_Model_Source_Hook::XML_PATH_WEBHOOK . '/' . $topicName); + if ($node && $node->type == 'callback') { + $callbackHooks[] = $topicName; + } + } + return $callbackHooks; + } + + /** + * Gets callback topics which already have subscriber + * + * @return array + */ + public function getSubscribedCallbackTopics() + { + $topics = $this->_getCallbackTopics(); + return $this->_getResource()->getSubscribedCallbackTopics($topics); + } +} diff --git a/app/code/Mage/Webhook/Model/Subscriber/Config.php b/app/code/Mage/Webhook/Model/Subscriber/Config.php new file mode 100644 index 0000000000000..7b1ed39cf3acb --- /dev/null +++ b/app/code/Mage/Webhook/Model/Subscriber/Config.php @@ -0,0 +1,161 @@ +_getSubscriberConfigNode(); + + if (!empty($subscriberConfig)) { + $subscriberConfig = $subscriberConfig->asArray(); + } + $subscriberCollection = $this->_getSubscriberCollection(); + + $errors = array(); + + foreach ($subscriberConfig as $extentionId => $subscriberData) { + if (!$this->_validateConfigData($subscriberData)) { + $errors[] = Mage::helper('Mage_Webhook_Helper_Data') + ->__("Invalid config data for subscriber '%s'.", $extentionId); + continue; + } + + $subscribers = $subscriberCollection->getItemsByColumnValue('extension_id', $extentionId); + if (empty($subscribers)) { + // add new subscriber + $this->_addSubscriberFromConfigData($extentionId, $subscriberData); + continue; + } else { + // get first subscriber from array + $subscriber = current($subscribers); + } + + if (isset($subscriberData['version']) && $subscriber->getVersion() != $subscriberData['version']) { + // update subscriber from config + $this->_updateSubscriberFromConfigData($subscriber, $subscriberData); + } + } + + if (!empty($errors)) { + $this->_handleErrors($errors); + } + + return $this; + } + + /** + * If we have errors, lets log them, but lets not blow up as there could be some valid configurations + */ + protected function _handleErrors($errors) + { + Mage::logException(Mage::exception('Mage_Webhook', implode("\n", $errors))); + } + + protected function _getSubscriberConfigNode() + { + $subscriberConfigNode = Mage::getConfig()->getNode(self::XML_PATH_SUBSCRIBERS); + return $subscriberConfigNode; + } + + protected function _validateConfigData($data) + { + // We can't demand that every possible value be supplied as some of these can be supplied + // at a later point in time using the web API + return is_array($data) && isset($data['name']); + } + + protected function _addSubscriberFromConfigData($extentionId, array $configData) + { + /** @var $subscriber Mage_Webhook_Model_Subscriber */ + $subscriber = $this->_createSubscriber($extentionId); + return $this->_updateSubscriberFromConfigData($subscriber, $configData); + } + + protected function _createSubscriber($extentionId) + { + $subscriber = Mage::getModel('Mage_Webhook_Model_Subscriber') + ->setExtensionId($extentionId) + ->setStatus(Mage_Webhook_Model_Subscriber::STATUS_INACTIVE); + return $subscriber; + } + + protected function _updateSubscriberFromConfigData(Mage_Webhook_Model_Subscriber $subscriber, array $configData) + { + $subscriber->setName($configData['name']) + ->setMapping($this->_get($configData, 'mapping', Mage_Webhook_Model_Subscriber::MAPPING_DEFAULT)) + ->setFormat($this->_get($configData, 'format', Mage_Webhook_Model_Subscriber::FORMAT_JSON)) + ->setVersion($this->_get($configData, 'version')) + ->setEndpointUrl($this->_get($configData, 'endpoint_url')) + ->setTopics(isset($configData['topics']) ? $this->_getTopicsFlatList($configData['topics']) : array()) + ->setAuthenticationType( + isset($configData['authentication']['type']) + ? $configData['authentication']['type'] + : Mage_Webhook_Model_Subscriber::AUTH_TYPE_NONE + ) + ->setRegistrationMechanism( + isset($configData['registration_mechanism']) + ? $configData['registration_mechanism'] + : Mage_Webhook_Model_Subscriber::REGISTRATION_MECHANISM_MANUAL + ); + + return $subscriber->save(); + } + + private function _get($array, $key, $default=null) + { + if (isset($array[$key])) { + return $array[$key]; + } else { + return $default; + } + } + + protected function _getTopicsFlatList(array $topics) + { + $flatList = array(); + + foreach ($topics as $topicGroup => $topicNames) { + $topicNamesList = array_keys($topicNames); + foreach ($topicNamesList as $topicName) { + $flatList[] = $topicGroup . '/' . $topicName; + } + } + + return $flatList; + } + + protected function _getSubscriberCollection() + { + return Mage::getResourceModel('Mage_Webhook_Model_Resource_Subscriber_Collection'); + } +} diff --git a/app/code/Mage/Webhook/Model/Subscriber/Factory.php b/app/code/Mage/Webhook/Model/Subscriber/Factory.php new file mode 100644 index 0000000000000..680784c06eeee --- /dev/null +++ b/app/code/Mage/Webhook/Model/Subscriber/Factory.php @@ -0,0 +1,35 @@ +_className; + } + +} \ No newline at end of file diff --git a/app/code/Mage/Webhook/Model/Subscriber/Webapi.php b/app/code/Mage/Webhook/Model/Subscriber/Webapi.php new file mode 100644 index 0000000000000..6e2909f902cfc --- /dev/null +++ b/app/code/Mage/Webhook/Model/Subscriber/Webapi.php @@ -0,0 +1,166 @@ +_subscriber = $subscriber; + } + + public function createUserAndRole($email, $key, $secret, $company = '') + { + if (!$this->_subscriber->getApiUser()) { + throw new LogicException('The API user for current subscriber has already been created.'); + } + + // create new role + $role = $this->_createRole($email, $company); + + // add rules to the new role + // add webhook rules to the new role + $resources = array( + 'webhook/create', + 'webhook/get', + 'webhook/update', + 'webhook/delete', + ); + + $acl = $this->_subscriber->getAuthenticationOption('acl'); + if (is_array($acl)) { + foreach ($acl as $resourceId => $privileges) { + foreach ($privileges as $privilege => $data) { + $resources[] = $resourceId . '/' . $privilege; + } + } + } + + try { + Mage::getModel('Mage_Webapi_Model_Acl_Rule') + ->setRoleId($role->getId()) + ->setResources($resources) + ->saveResources(); + + // create new user for new role + $user = Mage::getModel('Mage_Webapi_Model_Acl_User') + ->setRoleId($role->getId()) + ->setApiKey($key) + ->setSecret($secret) + ->setCompanyName($company) + ->setContactEmail($email) + ->save(); + + $this->_subscriber->setApiUserId($user->getId()); + } catch (Exception $e) { + $role->delete(); + if ($user->getId()) { + $user->delete(); + } + throw $e; + } + + return $user; + } + + protected function _createRole($email, $company) + { + $roleName = $this->_createRoleName($email, $company); + $role = Mage::getModel('Mage_Webapi_Model_Acl_Role')->load($roleName, 'role_name'); + + if ($role->getId()) { + $uniqString = Mage::helper('Mage_Core_Helper_Data')->uniqHash(); + $roleName = $this->_createRoleName($email, $company, $uniqString); + } + + $role = Mage::getModel('Mage_Webapi_Model_Acl_Role') + ->setRoleName($roleName) + ->save(); + + return $role; + } + + protected function _createRoleName($email, $prefix = null, $suffix = null) + { + $result = ''; + if ($prefix) { + $result = $prefix . self::NAME_DELIM; + } + + $result .= $email; + + if ($suffix) { + $result .= self::NAME_DELIM . $suffix; + } + return $result; + } + + protected function _deactive() + { + $this->_subscriber->setStatus(Mage_Webhook_Model_Subscriber::STATUS_INACTIVE); + $this->_subscriber->save(); + } + + protected function _getAclRuleCollection() + { + return Mage::getResourceModel('Mage_Webapi_Model_Resource_Acl_Rule_Collection'); + } + + public function validate() + { + /** @var $requiredPermissions array */ + $requiredPermissions = $this->_subscriber->getRequiredPermissions(); + + /** @var $user Mage_Webapi_Model_Acl_User */ + $user = $this->_subscriber->getApiUser(); + $roleId = $user->getRoleId(); + $resourceData = $this->_getAclRuleCollection()->addFieldToFilter('role_id', $roleId)->load() + ->toArray(array('resource_id')); + $resourceData = isset($resourceData['items']) ? $resourceData['items'] : $resourceData; + + // Need to flatten this array for faster checking + $resourceDataFlat = array(); + foreach ($resourceData as $resourceDataArray) { + foreach ($resourceDataArray as $individualResource) { + $resourceDataFlat[] = $individualResource; + } + } + + foreach ($requiredPermissions as $requiredPermission) { + if (!empty($requiredPermission) && !in_array($requiredPermission, $resourceDataFlat)) { + $this->_deactive(); + return false; + } + } + + return true; + } +} diff --git a/app/code/Mage/Webhook/Model/Transport/Http.php b/app/code/Mage/Webhook/Model/Transport/Http.php new file mode 100644 index 0000000000000..a3930044b9608 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Transport/Http.php @@ -0,0 +1,112 @@ +_generateHttpRequest($message, $subscription); + + $response = $this->_sendRequest($request, $subscription); + + return $response; + } + + protected function _generateHttpRequest(Mage_Webhook_Model_Message $message, Mage_Webhook_Model_Subscriber $subscription) + { + $request = Mage::getModel('Mage_Webhook_Model_Transport_Http_Request') + ->setMethod(Zend_Http_Client::POST) + ->setUrl($subscription->getEndpointUrl()) + ->setHeaders($message->getHeaders()) + ->setBody($message->getBody()); + + $request = $subscription->getAuthenticationModel()->signRequest($request, $subscription); + + return $request; + } + + protected function _sendRequest(Mage_Webhook_Model_Transport_Http_Request $request, + Mage_Webhook_Model_Subscriber $subscription) + { + $adapter = $this->_getAdapter(); + + $this->_setAdapterConfig($adapter, $subscription); + + $adapter->write($request->getMethod(), + $request->getUrl(), + self::HTTP_VERSION, + $this->_prepareHeaders($request->getHeaders()), + $request->getBody() + ); + $result = $adapter->read(); + + $response = Zend_Http_Response::fromString($result); + + return new Mage_Webhook_Model_Transport_Http_Response($response); + } + + protected function _setAdapterConfig(Varien_Http_Adapter_Curl $adapter, + Mage_Webhook_Model_Subscriber $subscription) + { + $config = array( + 'verifypeer' => TRUE, + 'verifyhost' => 2 // Important to be 2 + ); + + $timeout = $subscription->getTimeoutInSecs(); + if (!is_null($timeout) && $timeout > 0) { + $config['timeout'] = $timeout; + } + + $adapter->setConfig($config); + } + + /** + * @return Varien_Http_Adapter_Curl + */ + protected function _getAdapter() + { + return new Varien_Http_Adapter_Curl(); + } + + protected function _prepareHeaders($headers) + { + $result = array(); + foreach ($headers as $headerName => $headerValue) { + $result[] = sprintf('%s: %s', $headerName, $headerValue); + } + return $result; + } +} diff --git a/app/code/Mage/Webhook/Model/Transport/Http/Request.php b/app/code/Mage/Webhook/Model/Transport/Http/Request.php new file mode 100644 index 0000000000000..8fc3c24df36d7 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Transport/Http/Request.php @@ -0,0 +1,80 @@ +_method; + } + + public function setMethod($method) + { + $this->_method = $method; + return $this; + } + + public function getUrl() + { + return $this->_url; + } + + public function setUrl($url) + { + $this->_url = $url; + return $this; + } + + public function getHeaders() + { + return $this->_headers; + } + + public function setHeaders(array $headers) + { + $this->_headers = $headers; + return $this; + } + + public function getBody() + { + return $this->_body; + } + + public function setBody($body) + { + $this->_body = $body; + return $this; + } +} diff --git a/app/code/Mage/Webhook/Model/Transport/Http/Response.php b/app/code/Mage/Webhook/Model/Transport/Http/Response.php new file mode 100644 index 0000000000000..04927fa0d80a8 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Transport/Http/Response.php @@ -0,0 +1,78 @@ +_response = $response; + } + + public function isSuccessful() + { + $statusCode = $this->getStatusCode(); + $classCode = $statusCode / 100; + if ($statusCode >= 200 && $statusCode < 300) { + return true; + } + return false; + } + + public function getStatusCode() + { + return $this->_response->getStatus(); + } + + public function getMessage() + { + return $this->_response->getMessage(); + } + + public function getBody() + { + // CURL Doesn't give us access to a truly RAW body, so calling getBody() will fail if Transfer-Encoding is set + return $this->_response->getRawBody(); + } + + public function getRawBody() + { + return $this->_response->getRawBody(); + } + + public function getHeaders() + { + return $this->_response->getHeaders(); + } + + public function getHeader($headerName) + { + return $this->_response->getHeader($headerName); + } +} diff --git a/app/code/Mage/Webhook/Model/Transport/Interface.php b/app/code/Mage/Webhook/Model/Transport/Interface.php new file mode 100644 index 0000000000000..889872a6b05c0 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Transport/Interface.php @@ -0,0 +1,37 @@ +_modelSubscriberFactory = $modelSubscriberFactory; + $this->_resourceSubscriber = $resourceSubscriber; + $this->_resourceAclUser = $resourceAclUser; + } + + /** + * Notifies the event handler that a webapi user has changed + * @param Mage_Webapi_Model_User $user User object that changed + */ + public function userChanged($user) + { + // call helper that finds and notifies subscriber (user_id) + $this->_validateSubscriptionsForUsers(array($user->getUserId())); + } + + /** + * Notifies the event handler that a webapi role has changed + * @param Mage_Webapi_Model_Role $role Role object that changed + */ + public function roleChanged($role) + { + // get all users that contain this role (role_id) + $users = $this->_getUserIdsFromRole($role->getRoleId()); + + // for each user, call helper that finds and notifies subscriber (user_id) + $this->_validateSubscriptionsForUsers($users); + } + + /** + * Queries Webapi for all the user ids that are currently using this role + * @param int $roleId + * @return array of ints representing the user ids. + */ + private function _getUserIdsFromRole($roleId) + { + return $this->_getAclUserResource()->getRoleUsers($roleId); + } + + /** + * Finds all Subscriptions for the given users, and validates that these subscriptions + * are still valid. + * @param array $userIds users to check against + */ + protected function _validateSubscriptionsForUsers(array $userIds) + { + $subscribers = array(); + + foreach ($userIds as $userId) { + $subsetIds = $this->_findSubscriberIdsForUser($userId); + $subscribers = $this->_fetchSubscribers($subsetIds, $subscribers); + } + + foreach ($subscribers as $subscriber) { + $subscriber->validate(); + } + } + + /** + * Fetches subscriber models given an array of subscriber ids. Will merge these + * subscribers into an associative array where the key is the subscriber id. + * This is done to avoid duplicate models. + * @param array $subscriberIds An array of subscriber ids + * @param array $subscribers An associative array of subscriber ids to subscriber models + * @return array An associate array of subscriber ids to subscriber models + */ + protected function _fetchSubscribers($subscriberIds, $subscribers = array()) + { + if (!is_array($subscriberIds)) { + return $subscribers; + } + + foreach ($subscriberIds as $subId) { + // Filter out duplicates, but load new unique models + if (!isset($subscribers[$subId])) { + $subscribers[$subId] = $this->_createSubscriber()->load($subId); + } + } + + return $subscribers; + } + + + /** + * Given a userId, will find all Subscriber ids that are linked to this user + * @param int $userId webapi user id + * @return array Array of subscriber ids + */ + private function _findSubscriberIdsForUser($userId) + { + return $this->_getSubscriberResource()->getApiUserSubscribers($userId); + } + + final protected function _createSubscriber() + { + return $this->_modelSubscriberFactory->create(); + } + + final protected function _getSubscriberResource() + { + return $this->_resourceSubscriber; + } + + final protected function _getAclUserResource() + { + return $this->_resourceAclUser; + } + + +} diff --git a/app/code/Mage/Webhook/Model/Webapi/EventHandler/Factory.php b/app/code/Mage/Webhook/Model/Webapi/EventHandler/Factory.php new file mode 100644 index 0000000000000..638375278d4a4 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Webapi/EventHandler/Factory.php @@ -0,0 +1,35 @@ +_className; + } + +} \ No newline at end of file diff --git a/app/code/Mage/Webhook/Model/Webapi/WebhookData.php b/app/code/Mage/Webhook/Model/Webapi/WebhookData.php new file mode 100644 index 0000000000000..5ca47a2d5e664 --- /dev/null +++ b/app/code/Mage/Webhook/Model/Webapi/WebhookData.php @@ -0,0 +1,126 @@ +getRequest()->getParam('id'); + if ($subscriberId) { + $subscriber->load($subscriberId); + } + Mage::register('current_subscriber', $subscriber); + + return $subscriber; + } + + /** + * Activate subscriber + * Step 1 - display subscriber required resources + * + * @return void + */ + public function activateAction() + { + $subscriber = $this->_initSubscriber(); + + $this->loadLayout(); + $this->renderLayout(); + } + + /** + * Agree to provide required subscriber resources + * Step 2 - redirect to specified auth action + */ + public function acceptAction() + { + $subscriber = $this->_initSubscriber(); + + $route = '*/webhook_registration/create_api_user'; + + $this->_redirect($route, array('id' => $subscriber->getId())); + } + + /** + * Start createApiUser + */ + public function create_api_userAction() + { + $subscriber = $this->_initSubscriber(); + $user = $subscriber->getApiUser(); + + $this->loadLayout(); + $this->renderLayout(); + } + + /** + * Continue createApiUser + */ + public function registerAction() + { + try { + /** @var Mage_Webhook_Model_Subscriber $subscriber */ + $subscriber = $this->_initSubscriber(); + + $key = $this->getRequest()->getParam('apikey'); + $secret = $this->getRequest()->getParam('apisecret'); + $email = $this->getRequest()->getParam('email'); + $company = $this->getRequest()->getParam('company'); + + if (empty($key) || empty($secret) || empty($email)) { + throw Mage::exception('Mage_Webhook', $this->__('API Key, API Secret and Contact Email are required fields.')); + } + + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { + $this->_redirectFailed($this->__('Invalid Email address provided')); + return; + } + + $subscriber->createUserAndRole($email, $key, $secret, $company) + /* temporary solution in order not to catch an error */ + ->setIsNewlyActivated(true) + ->setStatus(Mage_Webhook_Model_Subscriber::STATUS_ACTIVE) + ->save(); + + $this->_redirectSucceeded($subscriber); + + } catch (Mage_Core_Exception $e) { + $this->_redirectFailed($e->getMessage()); + + } catch (Exception $e) { + Mage::logException($e); + $this->_redirectFailed($this->__('An unexpected error happened. Please try again.')); + } + } + + protected function _redirectSucceeded(Mage_Webhook_Model_Subscriber $subscriber) + { + $this->_getSession()->addSuccess($this->__("The subscriber '%s' has been activated.", $subscriber->getName())); + $this->_redirect('*/webhook_registration/succeeded', array('id' => $subscriber->getId())); + } + + protected function _redirectFailed($errorMessage) + { + $this->_getSession()->addError($errorMessage); + $this->_redirect('*/webhook_registration/failed'); + } + + /** + * Redirect to this page when the authentication process is completed successfully + */ + public function succeededAction() + { + $this->loadLayout(); + $this->renderLayout(); + $subscriber = $this->_initSubscriber(); + $this->_getSession()->addSuccess($this->__("The subscriber '%s' has been activated.", $subscriber->getName())); + } + + /** + * Redirect to this page when the authentication process is failed by some reasons + */ + public function failedAction() + { + $this->loadLayout(); + $this->renderLayout(); + } +} diff --git a/app/code/Mage/Webhook/controllers/Adminhtml/Webhook/SubscriberController.php b/app/code/Mage/Webhook/controllers/Adminhtml/Webhook/SubscriberController.php new file mode 100644 index 0000000000000..cb688338f14ea --- /dev/null +++ b/app/code/Mage/Webhook/controllers/Adminhtml/Webhook/SubscriberController.php @@ -0,0 +1,219 @@ +getRequest()->getParam('id'); + if ($subscriberId) { + $subscriber->load($subscriberId); + } + Mage::register('current_subscriber', $subscriber); + return $subscriber; + } + + /** + * Segments list + * + * @return void + */ + public function indexAction() + { + $this->loadLayout() + ->_setActiveMenu('Mage_Webhook::system_api_webapi_webhook') + ->_title(Mage::helper('Mage_Webhook_Helper_Data')->__('System')) + ->_title(Mage::helper('Mage_Webhook_Helper_Data')->__('Web Services')) + ->_title(Mage::helper('Mage_Webhook_Helper_Data')->__('WebHook Subscribers')); + + $this->renderLayout(); + } + + public function newAction() + { + Mage::register('webhook_action', 'new'); + $this->_forward('edit'); + } + + public function editAction() + { + $model = $this->_initSubscriber(); + + if ($model->getId()) { + $data = Mage::getSingleton('Mage_Backend_Model_Session')->getFormData(true); + if (!empty($data)) { + $model->setData($data); + } + Mage::register('current_data', $model); + } + + $this->loadLayout() + ->_setActiveMenu('system/api') + ->_title(Mage::helper('Mage_Webhook_Helper_Data')->__('System')) + ->_title(Mage::helper('Mage_Webhook_Helper_Data')->__('Web Services')) + ->_title(Mage::helper('Mage_Webhook_Helper_Data')->__('WebHook Subscribers')); + if (Mage::registry('webhook_action') == 'new') { + $this->_title(Mage::helper('Mage_Webhook_Helper_Data')->__('Add Subscriber')); + } else { + $this->_title(Mage::helper('Mage_Webhook_Helper_Data')->__('Edit Subscriber')); + } + + $this->renderLayout(); + } + + /** + * Save subscriber action + * + * @return void + */ + public function saveAction() + { + $data = $this->getRequest()->getPost(); + /** @var $subscriber Mage_Webhook_Model_Subscriber */ + $subscriber = $this->_initSubscriber(); + if ($data) { + $subscriber->addData($data) + ->setTopics(isset($data['topics']) ? $data['topics'] : array()); + + try { + $subscriber->save(); + $this->_getSession()->addSuccess($this->__("The subscriber '%s' has been saved.", $subscriber->getName())); + } + catch (Exception $e) { + Mage::logException($e); + $this->_getSession()->addError($e->getMessage()); + } + } + else { + $this->_getSession()->addError($this->__("The subscriber '%s' has not been saved.", $subscriber->getName())); + } + $this->_redirect('*/*/'); + } + + /** + * Delete subscriber action + * + * @return void + */ + public function deleteAction() + { + $subscriber = $this->_initSubscriber(); + if ($subscriber && !$subscriber->getExtensionId()) { + try { + $subscriber->delete(); + $this->_getSession()->addSuccess($this->__("The subscriber '%s' has been removed.", $subscriber->getName())); + } + catch (Exception $e) { + Mage::logException($e); + $this->_getSession()->addError($e->getMessage()); + } + } + else { + $this->_getSession()->addError($this->__("The subscriber '%s' can not be removed.", $subscriber->getName())); + } + $this->_redirect('*/*/'); + } + + public function testAction() + { + $subscriber = $this->_initSubscriber(); + + if (!$subscriber) { + $this->_getSession()->addError($this->__('Unable to send message: Subscriber doesn\'t exist')); + } + else if (!$subscriber->isSubscribedToTopic(self::TEST)) { + $this->_getSession()->addError($this->__('Unable to send message: Not subscribed to topic')); + } + else { + $object = new Varien_Object(array('message' => $this->__('This is a test message.'))); + Mage::helper('Mage_Webhook_Helper_Data')->dispatchEvent(self::TEST, array('object' => $object)); + $this->_getSession()->addSuccess($this->__('Test message queued.')); + } + + $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); + } + + + /** + * Revoke subscriber + * + * @return void + */ + public function revokeAction() + { + try { + $subscriber = $this->_initSubscriber(); + $subscriber->setStatus(Mage_Webhook_Model_Subscriber::STATUS_REVOKED) + ->save(); + + // TODO: send 'deactivated' notification to the subscriber endpoint url + + $this->_getSession()->addSuccess($this->__("The subscriber '%s' has been revoked.", $subscriber->getName())); + + } catch (Mage_Webhook_Exception $e) { + $this->_getSession()->addError($e->getMessage()); + } catch (Exception $e) { + $this->_getSession()->addError($this->__("An unexpected error happened. Please try again.")); + } + + $this->_redirect('*/webhook_subscriber/index'); + } + + /** + * Activate subscriber + * Step 1 - display subscriber required resources + * + * @return void + */ + public function activateAction() + { + $subscriber = $this->_initSubscriber(); + + try { + $subscriber->setStatus(Mage_Webhook_Model_Subscriber::STATUS_ACTIVE) + ->save(); + + // TODO: send 'deactivated' notification to the subscriber endpoint url + + $this->_getSession()->addSuccess($this->__("The subscriber '%s' has been activated.", $subscriber->getName())); + + } catch (Mage_Webhook_Exception $e) { + $this->_getSession()->addError($e->getMessage()); + } catch (Exception $e) { + $this->_getSession()->addError($this->__("An unexpected error happened. Please try again.")); + } + + $this->_redirect('*/webhook_subscriber/index'); + } +} diff --git a/app/code/Mage/Webhook/controllers/Adminhtml/Webhook/WebapiController.php b/app/code/Mage/Webhook/controllers/Adminhtml/Webhook/WebapiController.php new file mode 100644 index 0000000000000..4085f7aa47665 --- /dev/null +++ b/app/code/Mage/Webhook/controllers/Adminhtml/Webhook/WebapiController.php @@ -0,0 +1,125 @@ +_initSubscriber(); + + // TODO: refactor it !!! + + echo '
    + +
    + + +
    + + +
    + + +
    + +
    '; + } + + /** + * Continue activation + */ + public function registerAction() + { + try { + $subscriber = $this->_initSubscriber(); + + $key = $this->getRequest()->getParam('key'); + $secret = $this->getRequest()->getParam('secret'); + $email = $this->getRequest()->getParam('email'); + $company = $this->getRequest()->getParam('company'); + + if (empty($key) || empty($secret) || empty($email)) { + throw Mage::exception('Mage_Webhook', $this->__("API Key, API Secret and Contact Email are required fields.")); + } + + $subscriber->createUserAndRole($subscriber, $email, $key, $secret, $company); + /* temporary solution in order not to catch an error */ + $subscriber->setIsNewlyActivated(true); + $subscriber->setStatus(Mage_Webhook_Model_Subscriber::STATUS_ACTIVE) + ->save(); + + $this->_redirectSucceeded($subscriber); + + } catch (Mage_Core_Exception $e) { + $this->_redirectFailed($e->getMessage()); + + } catch (Exception $e) { + Mage::logException($e); + $this->_redirectFailed($this->__("An unexpected error happened. Please try again.".$e)); + } + } + + /** + * Initialize general settings for subscriber + * + * @return Mage_Webhook_Model_Subscriber + * @throws Mage_Webhook_Exception + */ + protected function _initSubscriber() + { + $subscriber = Mage::getModel('Mage_Webhook_Model_Subscriber'); + $subscriberId = (int) $this->getRequest()->getParam('id'); + if ($subscriberId) { + $subscriber->load($subscriberId); + } + + if (!$subscriber->getId()) { + throw Mage::exception('Mage_Webhook', $this->__("The subscriber is unknown.")); + } + + Mage::register('current_subscriber', $subscriber); + + return $subscriber; + } + + protected function _redirectSucceeded(Mage_Webhook_Model_Subscriber $subscriber) + { + $this->_getSession()->addSuccess($this->__("The subscriber '%s' has been activated.", $subscriber->getName())); + $this->_redirect('*/webhook_registration/succeeded', array('id' => $subscriber->getId())); + } + + protected function _redirectFailed($errorMessage) + { + $this->_getSession()->addError($errorMessage); + $this->_redirect('*/webhook_registration/failed'); + } +} diff --git a/app/code/Mage/Webhook/controllers/EndpointController.php b/app/code/Mage/Webhook/controllers/EndpointController.php new file mode 100644 index 0000000000000..a42b4bc3e5fd3 --- /dev/null +++ b/app/code/Mage/Webhook/controllers/EndpointController.php @@ -0,0 +1,129 @@ +login('test_user', '111111'); + + $newCustomer = array( + 'firstname' => 'Soap Firstname ' . Mage::helper('Mage_Core_Helper_Data')->uniqHash(), + 'lastname' => 'Soap Lastname ' . Mage::helper('Mage_Core_Helper_Data')->uniqHash(), + 'email' => 'email' . Mage::helper('Mage_Core_Helper_Data')->uniqHash() . '@example.com', + 'password_hash' => 'qa123123', + 'store_id' => 1, + 'website_id' => 1 + ); + + $newCustomerId = $client->customerCustomerCreate($session, $newCustomer); + + var_dump($newCustomerId); + } + + /** + * Send REST customer create request to the Magento REST Server using new OAuth authentication + */ + public function resttestAction() + { + $subscriberId = $this->getRequest()->getParam('id'); + $subscriber = Mage::getModel('Mage_Webhook_Model_Subscriber')->load($subscriberId); + + $request = Mage::getModel('Mage_Webhook_Model_Transport_Http_Request') + ->setMethod(Zend_Http_Client::POST) + ->setUrl(str_replace('/index.php', '', Mage::getBaseUrl()).'api/rest/customers') + ->setHeaders(array('Content-Type' => 'application/xml')) + ->setBody(' + + Earl'.Mage::helper('Mage_Core_Helper_Data')->uniqHash().' + Hickey'.Mage::helper('Mage_Core_Helper_Data')->uniqHash().' + qa123123 + earl'.Mage::helper('Mage_Core_Helper_Data')->uniqHash().'@example.com + 1 + 1 + '); + + $request = $subscriber->getAuthenticationModel()->signRequest($request, $subscriber); + + var_dump(Mage::getSingleton('Mage_Webhook_Model_Transport_Http_Request')->sendRequest($request)); + } + + public function oauthrequestAction() + { + $this->getResponse() + ->setHeader('Content-Type', 'application/x-www-form-urlencoded') + ->setBody('oauth_token=hh5s93j4hdidpolahh5s93j4hdidpola&oauth_token_secret=hdhd0244k9j7ao03hdhd0244k9j7ao03&oauth_callback_confirmed=true'); + } + + public function oauthauthorizeAction() + { + echo ' +

    Login to the 3rd party service

    +
    + + + + + + + + + +


    + +
    +
    '; + } + + public function submitformAction() + { + $callbackUrl = Mage::getBaseUrl().'backend/admin/webhook_oauth/callback'; + + $this->_redirectUrl($callbackUrl . '?oauth_token=hh5s93j4hdidpolahh5s93j4hdidpola&oauth_verifier=hfdp7dh39dks9884hfdp7dh39dks9884'); + } + + public function oauthaccessAction() + { + $this->getResponse() + ->setHeader('Content-Type', 'application/x-www-form-urlencoded') + ->setBody('oauth_token=nnch734d00sl2jdknnch734d00sl2jdk&oauth_token_secret=pfkkdhi9sl3r4s00pfkkdhi9sl3r4s00'); + } + + public function consumercreatedAction() + { + // it's enought to respond HTTP 200 OK + } +} + diff --git a/app/code/Mage/Webhook/etc/adminhtml/acl.xml b/app/code/Mage/Webhook/etc/adminhtml/acl.xml new file mode 100644 index 0000000000000..1c258d86a32ac --- /dev/null +++ b/app/code/Mage/Webhook/etc/adminhtml/acl.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + diff --git a/app/code/Mage/Webhook/etc/adminhtml/menu.xml b/app/code/Mage/Webhook/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..91ccfd1e0be4e --- /dev/null +++ b/app/code/Mage/Webhook/etc/adminhtml/menu.xml @@ -0,0 +1,33 @@ + + + + + + + diff --git a/app/code/Mage/Webhook/etc/config.xml b/app/code/Mage/Webhook/etc/config.xml new file mode 100644 index 0000000000000..73573f7058d78 --- /dev/null +++ b/app/code/Mage/Webhook/etc/config.xml @@ -0,0 +1,206 @@ + + + + + + 1.0.0.2 + true + + + + + + + + + + + + Mage_Webhook + + + + + + + + Mage_Webhook_Model_Authentication_Hmac_Sha256 + + + + Mage_Webhook_Model_Authentication_None + + + + + + + + + webapi + endpoint + + json + endpoint + + + + + enabled + Mage_Webhook_Model_Transport_Http + + + + + + + Mage_Webhook_Model_Mapper_Default_Factory + + Mage_Webhook_Model_Mapper_Factory_Default + + + + + + + Mage_Webhook_Model_Formatter_Json + + Mage_Webhook_Model_Formatter_Factory_Json + + + + + + enabled + + + + + + + + + + + + Mage_Webhook_Model_Observer + afterWebapiUserDelete + + + + + + + Mage_Webhook_Model_Observer + afterWebapiUserChange + + + + + + + Mage_Webhook_Model_Observer + afterWebapiRoleChange + + + + + + + Mage_Webhook_Model_Observer + afterWebapiRoleChange + + + + + + + Mage_Webhook_Model_Observer + dispatchEvent + + + + + + + + + standard + + Mage_Webhook + webhook + + + + + + + + + + Mage_Webhook_Adminhtml + + + + + + + + + + + layout.xml + + + + + + + + * * * * * + Mage_Webhook_Model_Observer::processEventsToDispatch + + + * * * * * + Mage_Webhook_Model_Observer::processDispatchJobs + + + + + diff --git a/app/code/Mage/Webhook/etc/webapi/acl.xml b/app/code/Mage/Webhook/etc/webapi/acl.xml new file mode 100644 index 0000000000000..3e6e0b91584c1 --- /dev/null +++ b/app/code/Mage/Webhook/etc/webapi/acl.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Mage/Webhook/sql/webhook_setup/install-1.0.0.0.php b/app/code/Mage/Webhook/sql/webhook_setup/install-1.0.0.0.php new file mode 100644 index 0000000000000..d9457f5071fd5 --- /dev/null +++ b/app/code/Mage/Webhook/sql/webhook_setup/install-1.0.0.0.php @@ -0,0 +1,195 @@ +startSetup(); + +/* @var $connection Varien_Db_Adapter_Interface */ +$connection = $this->getConnection(); + +/** + * Create new table 'webhook_subscriber' + */ +$subscriberTable = $this->getConnection() + ->newTable($this->getTable('webhook_subscriber')) + ->addColumn('subscriber_id', Varien_Db_Ddl_Table::TYPE_INTEGER, 10, + array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), + 'Subscriber Id') + ->addColumn('name', Varien_Db_Ddl_Table::TYPE_TEXT, 255, + array('nullable' =>false), + 'Subscriber Name') + ->addColumn('endpoint_url', Varien_Db_Ddl_Table::TYPE_TEXT, 255, + array('nullable' =>false), + 'Endpoint URL') + ->addColumn('authentication_type', Varien_Db_Ddl_Table::TYPE_TEXT, 40, + array('nullable' =>false), + 'Authentication Type') + ->addColumn('registration_mechanism', Varien_Db_Ddl_Table::TYPE_TEXT, 40, + array('nullable' =>false), + 'Registration Mechanism') + ->addColumn('encoding', Varien_Db_Ddl_Table::TYPE_TEXT, 40, + array('nullable' =>false), 'Encoding') + ->addColumn('format', Varien_Db_Ddl_Table::TYPE_TEXT, 40, + array('nullable' =>false), + 'Data Format') + ->addColumn('status', Varien_Db_Ddl_Table::TYPE_INTEGER, null, + array('unsigned' => true, 'nullable' => false, 'default' => 0), + 'Status') + ->addColumn('version', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(), + 'Extension Version') + ->addColumn('extension_id', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(), + 'Extension Id') + ->addColumn('api_user_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( + 'unsigned' => true, 'nullable' => true), + 'Webapi User Id') + ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(), + 'Updated At') + ->addIndex( + $this->getIdxName('webhook_subscriber', array('subscriber_id', 'api_user_id'), + Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE), + array('subscriber_id', 'api_user_id'), + array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)) + ->addForeignKey( + $this->getFkName('webhook_subscriber', 'api_user_id', 'webapi_user', 'user_id'), + 'api_user_id', + $this->getTable('webapi_user'), + 'user_id', + Varien_Db_Ddl_Table::ACTION_SET_NULL, + Varien_Db_Ddl_Table::ACTION_CASCADE) + ->setOption('collate', null) + ->setOption('comment', 'Subscriber'); +$this->getConnection()->createTable($subscriberTable); + +/** + * Create table 'webhook_subscriber_hook' + */ +$hookTable = $this->getConnection()->newTable($this->getTable('webhook_subscriber_hook')) + ->addColumn('hook_id', Varien_Db_Ddl_Table::TYPE_INTEGER, 10, array( + 'identity' => true, + 'unsigned' => true, + 'nullable' => false, + 'primary' => true, + ), 'Hook Id') + ->addColumn('subscriber_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( + 'unsigned' => true, + 'nullable' => false, + ), 'Subscriber Id') + ->addColumn('topic', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array( + ), 'Hook Topic') + ->addIndex( + $this->getIdxName('webhook_subscriber_hook', array('topic')), + array('topic')) + ->addForeignKey( + 'FK_WEBHOOK_SUBSCRIBER_SUBSCRIBER_ID', + 'subscriber_id', + $this->getTable('webhook_subscriber'), + 'subscriber_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE + ) + ->setOption('collate', null) + ->setOption('comment', 'Webhook'); +$this->getConnection()->createTable($hookTable); + +/** + * Create table 'webhook_event' + */ +$eventTable = $this->getConnection()->newTable($this->getTable('webhook_event')) + ->addColumn('event_id', Varien_Db_Ddl_Table::TYPE_INTEGER, 10, + array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), + 'Event Id') + ->addColumn('topic', Varien_Db_Ddl_Table::TYPE_TEXT, 255, + array('nullable' => false), 'Hook Topic') + ->addColumn('format', Varien_Db_Ddl_Table::TYPE_TEXT, '255', array(), + 'Format') + ->addColumn('body_data', Varien_Db_Ddl_Table::TYPE_VARBINARY, '4M', + array('nullable' => false), + 'Serialized Data Array') + ->addColumn('headers', Varien_Db_Ddl_Table::TYPE_TEXT, '16k', array(), + 'Headers') + ->addColumn('options', Varien_Db_Ddl_Table::TYPE_TEXT, '16k', array(), + 'Options') + ->addColumn('status', Varien_Db_Ddl_Table::TYPE_INTEGER, 10, array('nullable' => false), + 'Status') + ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array('nullable' => false), + 'Updated At') + ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array('nullable' => false), + 'Created At') + ->addIndex($this->getIdxName('webhook_event', array('status')), array('status')) + ->setOption('collate', null) + ->setOption('comment', 'Queued Event Data'); +$this->getConnection()->createTable($eventTable); + +/** + * Create table 'webhook_dispatch_job' + */ +$dispatchJobTable = $connection->newTable($this->getTable('webhook_dispatch_job')) + ->addColumn('dispatch_job_id', Varien_Db_Ddl_Table::TYPE_INTEGER, 10, array( + 'identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), + 'Dispatch Job Id') + ->addColumn('event_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, + array('unsigned' => true, 'nullable' => false), + 'Event Id') + ->addColumn('subscriber_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, + array('unsigned' => true, 'nullable' => false), + 'Subscriber Id') + ->addColumn('status', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, + array('nullable' => false, 'default' => '0'), + 'Status') + ->addColumn('retry_count', Varien_Db_Ddl_Table::TYPE_INTEGER, null, + array('unsigned' => true, 'nullable' => false), + 'Retry Count') + ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, + array('default' => Varien_Db_Ddl_Table::TIMESTAMP_INIT_UPDATE, 'nullable' => false), + 'Updated At') + ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, + array('default' => '0000-00-00 00:00:00', 'nullable' => false), + 'Created At') + ->addColumn('retry_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, + array('default' => '0000-00-00 00:00:00', 'nullable' => false), + 'Retry At') + ->addForeignKey( + 'FK_WEBHOOK_SERVICE_DISPATCHER_ID', + 'subscriber_id', + $this->getTable('webhook_subscriber'), + 'subscriber_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE + ) + ->addForeignKey( + 'FK_WEBHOOK_MESSAGE_DISPATCHER_ID', + 'event_id', + $this->getTable('webhook_event'), + 'event_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE + ) + ->setOption('collate', null) + ->setOption('comment', 'Dispatch Jobs'); +$this->getConnection()->createTable($dispatchJobTable); + +$this->endSetup(); + diff --git a/app/code/Mage/Webhook/sql/webhook_setup/upgrade-1.0.0.0-1.0.0.1.php b/app/code/Mage/Webhook/sql/webhook_setup/upgrade-1.0.0.0-1.0.0.1.php new file mode 100644 index 0000000000000..e8f41f659e47e --- /dev/null +++ b/app/code/Mage/Webhook/sql/webhook_setup/upgrade-1.0.0.0-1.0.0.1.php @@ -0,0 +1,73 @@ +startSetup(); + +/* @var $connection Varien_Db_Adapter_Interface */ +$connection = $installer->getConnection(); + +$subscriberTable = $installer->getTable('webhook_subscriber'); +$connection->changeColumn( + $subscriberTable, + 'format', + 'mapping', + array( + 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, + 'length' => 40, + 'nullable' => false, + 'comment' => 'Data Mapping' + ) +); +$connection->changeColumn( + $subscriberTable, + 'encoding', + 'format', + array( + 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, + 'length' => 40, + 'nullable' => false, + 'comment' => 'Data Format' + ) +); + +$eventTable = $installer->getTable('webhook_event'); +$connection->changeColumn( + $eventTable, + 'format', + 'mapping', + array( + 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, + 'length' => 255, + 'comment' => 'Data Mapping' + ) +); + +$installer->endSetup(); + diff --git a/app/code/Mage/Webhook/sql/webhook_setup/upgrade-1.0.0.1-1.0.0.2.php b/app/code/Mage/Webhook/sql/webhook_setup/upgrade-1.0.0.1-1.0.0.2.php new file mode 100644 index 0000000000000..2328efa639f33 --- /dev/null +++ b/app/code/Mage/Webhook/sql/webhook_setup/upgrade-1.0.0.1-1.0.0.2.php @@ -0,0 +1,48 @@ +startSetup(); + +/* @var $connection Varien_Db_Adapter_Interface */ +$connection = $installer->getConnection(); + +$subscriberTable = $installer->getTable('webhook_subscriber'); +$connection->addColumn( + $subscriberTable, + 'timeout_in_secs', + array( + 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, + 'nullable' => false, + 'default' => 60, + 'comment' => 'Timeout in seconds' + ) +); + +$installer->endSetup(); diff --git a/app/code/Mage/Webhook/view/adminhtml/css/modal.css b/app/code/Mage/Webhook/view/adminhtml/css/modal.css new file mode 100644 index 0000000000000..ff97d57b65200 --- /dev/null +++ b/app/code/Mage/Webhook/view/adminhtml/css/modal.css @@ -0,0 +1,110 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Webhook + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +@font-face { + font-family: 'Lucidia Sans Unicode'; + font-weight: normal; + font-style: normal; +} + +.inline { + display: inline-block; + vertical-align: middle; +} + +html, body { + height: 100%; +} + +.hide { + display: none !important; +} + +#activate-subscriber>.sh { + background: transparent url("../images/ghost-dark.png") repeat 0% 0%; + padding: 10px; + border-radius: 15px; + -webkit-border-radius: 15px; + -moz-border-radius: 15px; + margin: 0 auto; + width: 450px; + height: 500px; + position: absolute; + z-index: 1000; +} + +#activate-subscriber>.sh>.b { + height: 100%; + border-radius: 7px; + -webkit-border-radius: 7px; + -moz-border-radius: 7px; + /*position: relative;*/ +} + +#activate-subscriber>.sh>.b>.top { + position: relative; + -webkit-border-top-left-radius: 7px; + -webkit-border-top-right-radius: 7px; + -moz-border-radius-topleft: 7px; + -moz-border-radius-topright: 7px; + border-top-left-radius: 7px; + border-top-right-radius: 7px; + height: 20px; + background: #425e66; + background: -moz-linear-gradient(top, #092023 0%, #425e66 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #092023), color-stop(100%, #425e66)); + background: -webkit-linear-gradient(top, #092023 0%, #425e66 100%); + background: -o-linear-gradient(top, #092023 0%, #425e66 100%); + background: -ms-linear-gradient(top, #092023 0%, #425e66 100%); + filter: progid:DXImageTransform.Microsoft.gradient(GradientType = 0, startColorstr = '#092023', endColorstr = '#425e66'); + background: linear-gradient(top, #092023 0%, #425e66 100%); +} + +#activate-subscriber>.sh>.b>.top>.close { + display: block; + position: absolute; + top: 4px; + right: 10px; + font-family: Arial, Helvetica, Verdana, sans-serif; + font-size: 0.8em; + color: #f7f7f7; + text-decoration: none; +} + +#activate-subscriber>.sh>.b>.top>.close:hover { + color: #fff; + text-decoration: underline; +} + +#activate-subscriber>.sh>.b>iframe { + border-radius: 0px 0px 7px 7px; + -webkit-border-radius: 0px 0px 7px 7px; + -moz-border-radius: 0px 0px 7px 7px; + background: #FFF; + width: 450px; + height: 480px; + display: block; +} + diff --git a/app/code/Mage/Webhook/view/adminhtml/css/webhook.css b/app/code/Mage/Webhook/view/adminhtml/css/webhook.css new file mode 100644 index 0000000000000..54be9d3542ce4 --- /dev/null +++ b/app/code/Mage/Webhook/view/adminhtml/css/webhook.css @@ -0,0 +1,147 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Webhook + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +html { + height: 100%; + overflow: hidden; +} + +body { + height: 100%; +} + +body>div:first-child { + height: 100%; +} + +div.outer { + height: 100%; +} + +.section.main { + padding: 1em; +} + +li { + margin-left: 1em; +} + +ul { + padding-left: 1em; +} + +em { + color: #EB5E00; +} + +.red { + color: #EB5E00; +} + +.section { + margin-top: 1em; +} + +div.center { + overflow: auto; + height: 90%; +} + +div.bottom { + border-top: 1px solid #2D444F; + background: #666E73; + width: 100%; + height: 10%; + position: absolute; + bottom: 0px; +} + +div.buttons { + width: 70%; + + margin: 1em auto; +} + +.buttons button { + margin-right: 2em; + margin-left: 2em; +} + +/*.buttons button:last-child,*/ +.buttons button.last-child { + margin-right: 25%; + float: right; +} + +.buttons button:first-child { + margin-left: 25%; + margin-right: 0px; + float: left; +} + +/* Using monospace to make it easier to see how long our keys/secrets really are */ +input.monospace { + font-family: Courier New, monospace; +} + +/* Need this so the form inputs look good in our modal window */ +.api_form input.input-text{ + width: 20em; +} + +.entry-edit .field-row label.error { + float: none; + width: auto; + margin-left: 2em; +} + +/********************************** +*** Section for displaying tree *** +**********************************/ + + +/*ul.tree ul ul:not(:last-of-type),*/ +ul.tree ul ul.not-last-of-type { + list-style-type: none; + background: url(../images/tree/vline.png) repeat-y; + margin: 0; + padding-left: 2em; +} + +ul.tree ul { + margin-left: 10px; +} + +ul.tree ul li { + margin: 0; + padding: 0 12px; + line-height: 20px; + background: url(../images/tree/node.png) no-repeat; +} + +/*ul.tree ul li:last-of-type,*/ +ul.tree ul li.last-of-type { + background: #fff url(../images/tree/lastnode.png) no-repeat; +} diff --git a/app/code/Mage/Webhook/view/adminhtml/images/ghost-dark.png b/app/code/Mage/Webhook/view/adminhtml/images/ghost-dark.png new file mode 100644 index 0000000000000..502eb75d35397 Binary files /dev/null and b/app/code/Mage/Webhook/view/adminhtml/images/ghost-dark.png differ diff --git a/app/code/Mage/Webhook/view/adminhtml/images/ghost.png b/app/code/Mage/Webhook/view/adminhtml/images/ghost.png new file mode 100644 index 0000000000000..2fe0ecd61577f Binary files /dev/null and b/app/code/Mage/Webhook/view/adminhtml/images/ghost.png differ diff --git a/app/code/Mage/Webhook/view/adminhtml/images/green_button.png b/app/code/Mage/Webhook/view/adminhtml/images/green_button.png new file mode 100644 index 0000000000000..bb69b64a0f257 Binary files /dev/null and b/app/code/Mage/Webhook/view/adminhtml/images/green_button.png differ diff --git a/app/code/Mage/Webhook/view/adminhtml/images/green_circle_right.png b/app/code/Mage/Webhook/view/adminhtml/images/green_circle_right.png new file mode 100644 index 0000000000000..a5a04e70a33ef Binary files /dev/null and b/app/code/Mage/Webhook/view/adminhtml/images/green_circle_right.png differ diff --git a/app/code/Mage/Webhook/view/adminhtml/images/grey_button.png b/app/code/Mage/Webhook/view/adminhtml/images/grey_button.png new file mode 100644 index 0000000000000..94138c5582ffc Binary files /dev/null and b/app/code/Mage/Webhook/view/adminhtml/images/grey_button.png differ diff --git a/app/code/Mage/Webhook/view/adminhtml/images/grey_circle_right.png b/app/code/Mage/Webhook/view/adminhtml/images/grey_circle_right.png new file mode 100644 index 0000000000000..3b143f063eddd Binary files /dev/null and b/app/code/Mage/Webhook/view/adminhtml/images/grey_circle_right.png differ diff --git a/app/code/Mage/Webhook/view/adminhtml/images/hor_arrow.png b/app/code/Mage/Webhook/view/adminhtml/images/hor_arrow.png new file mode 100644 index 0000000000000..177303f364633 Binary files /dev/null and b/app/code/Mage/Webhook/view/adminhtml/images/hor_arrow.png differ diff --git a/app/code/Mage/Webhook/view/adminhtml/images/red_button.png b/app/code/Mage/Webhook/view/adminhtml/images/red_button.png new file mode 100644 index 0000000000000..df5ed85a0d2d6 Binary files /dev/null and b/app/code/Mage/Webhook/view/adminhtml/images/red_button.png differ diff --git a/app/code/Mage/Webhook/view/adminhtml/images/red_circle_right.png b/app/code/Mage/Webhook/view/adminhtml/images/red_circle_right.png new file mode 100644 index 0000000000000..9f423c867355c Binary files /dev/null and b/app/code/Mage/Webhook/view/adminhtml/images/red_circle_right.png differ diff --git a/app/code/Mage/Webhook/view/adminhtml/images/tree/lastnode.png b/app/code/Mage/Webhook/view/adminhtml/images/tree/lastnode.png new file mode 100644 index 0000000000000..f8809f80226b5 Binary files /dev/null and b/app/code/Mage/Webhook/view/adminhtml/images/tree/lastnode.png differ diff --git a/app/code/Mage/Webhook/view/adminhtml/images/tree/node.png b/app/code/Mage/Webhook/view/adminhtml/images/tree/node.png new file mode 100644 index 0000000000000..29f6c446045ad Binary files /dev/null and b/app/code/Mage/Webhook/view/adminhtml/images/tree/node.png differ diff --git a/app/code/Mage/Webhook/view/adminhtml/images/tree/vline.png b/app/code/Mage/Webhook/view/adminhtml/images/tree/vline.png new file mode 100644 index 0000000000000..4c9bc6d749a5c Binary files /dev/null and b/app/code/Mage/Webhook/view/adminhtml/images/tree/vline.png differ diff --git a/app/code/Mage/Webhook/view/adminhtml/images/ver_arrow.png b/app/code/Mage/Webhook/view/adminhtml/images/ver_arrow.png new file mode 100644 index 0000000000000..9841f050b1b3b Binary files /dev/null and b/app/code/Mage/Webhook/view/adminhtml/images/ver_arrow.png differ diff --git a/app/code/Mage/Webhook/view/adminhtml/js/activate.js b/app/code/Mage/Webhook/view/adminhtml/js/activate.js new file mode 100644 index 0000000000000..e678e7e57729e --- /dev/null +++ b/app/code/Mage/Webhook/view/adminhtml/js/activate.js @@ -0,0 +1,30 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Webhook + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +$j = jQuery.noConflict(); +$j(document).ready(function(){ + $j("ul.tree ul ul:not(:last-of-type)").addClass("not-last-of-type"); + $j("ul.tree ul li:last-of-type").addClass("last-of-type"); + $j(".buttons button:last-child").addClass("last-child"); +}) \ No newline at end of file diff --git a/app/code/Mage/Webhook/view/adminhtml/js/jquery-extended-selectors.js b/app/code/Mage/Webhook/view/adminhtml/js/jquery-extended-selectors.js new file mode 100644 index 0000000000000..14fa7982e6470 --- /dev/null +++ b/app/code/Mage/Webhook/view/adminhtml/js/jquery-extended-selectors.js @@ -0,0 +1,79 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Webhook + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +/* + * jQuery Extra Selectors - (c) Keith Clark freely distributable under the terms of the MIT license. + * + * twitter.com/keithclarkcouk + * www.keithclark.co.uk + */ + +(function($) { + function getNthIndex(cur, dir) { + var t = cur, idx = 0; + while (cur = cur[dir] ) { + if (t.tagName == cur.tagName) { + idx++; + } + } + return idx; + } + + function isNthOf(elm, pattern, dir) { + var position = getNthIndex(elm, dir), loop; + if (pattern == "odd" || pattern == "even") { + loop = 2; + position -= !(pattern == "odd"); + } else { + var nth = pattern.indexOf("n"); + if (nth > -1) { + loop = parseInt(pattern, 10) || parseInt(pattern.substring(0, nth) + "1", 10); + position -= (parseInt(pattern.substring(nth + 1), 10) || 0) - 1; + } else { + loop = position + 1; + position -= parseInt(pattern, 10) - 1; + } + } + return (loop<0 ? position<=0 : position >= 0) && position % loop == 0 + } + + var pseudos = { + "first-of-type": function(elm) { + return getNthIndex(elm, "previousSibling") == 0; + }, + "last-of-type": function(elm) { + return getNthIndex(elm, "nextSibling") == 0; + }, + "only-of-type": function(elm) { + return pseudos["first-of-type"](elm) && pseudos["last-of-type"](elm); + }, + "nth-of-type": function(elm, i, match) { + return isNthOf(elm, match[3], "previousSibling"); + }, + "nth-last-of-type": function(elm, i, match) { + return isNthOf(elm, match[3], "nextSibling"); + } + } + $.extend($.expr[':'], pseudos); +}(jQuery)); diff --git a/app/code/Mage/Webhook/view/adminhtml/js/validate_form.js b/app/code/Mage/Webhook/view/adminhtml/js/validate_form.js new file mode 100644 index 0000000000000..008ea6935c204 --- /dev/null +++ b/app/code/Mage/Webhook/view/adminhtml/js/validate_form.js @@ -0,0 +1,30 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Webhook + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +$j = jQuery.noConflict(); +$j(document).ready(function(){ + jQuery.validator.addClassRules("required-entry", { + required: true + }); +}) \ No newline at end of file diff --git a/app/code/Mage/Webhook/view/adminhtml/js/webhook.js b/app/code/Mage/Webhook/view/adminhtml/js/webhook.js new file mode 100644 index 0000000000000..237d916f777ce --- /dev/null +++ b/app/code/Mage/Webhook/view/adminhtml/js/webhook.js @@ -0,0 +1,106 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Webhook + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +function activateSubscriber(url) +{ + $j = jQuery.noConflict(); + var activateSubscriberDiv = $j('#activate-subscriber'); + if (undefined === activateSubscriberDiv[0]) { + activateSubscriberDiv = $j('
    '); + $j('body').append(activateSubscriberDiv); + } + activateSubscriberDiv.html(''); + + activateSubscriberDiv.append(' - - diff --git a/app/code/core/Mage/Backend/view/adminhtml/widget/grid.phtml b/app/code/core/Mage/Backend/view/adminhtml/widget/grid.phtml deleted file mode 100644 index 5f17756e836f2..0000000000000 --- a/app/code/core/Mage/Backend/view/adminhtml/widget/grid.phtml +++ /dev/null @@ -1,174 +0,0 @@ - -getColumns()); -?> -getCollection()): ?> -canDisplayContainer()): ?> - getGridHeader()): ?> -
    -
    -

    getGridHeader(); ?>

    -
    -
    - - -
    - - getMessagesBlock()->getGroupedHtml() ?> - - getPagerVisibility() || $this->getExportTypes() || $this->getChildBlock('grid.columnSet')->getFilterVisibility()): ?> -
    - getChildBlock('grid.export')): ?> -
    - getChildHtml('grid.export');?> -
    - -
    - getMainButtonsHtml() ?> -
    - getPagerVisibility()): ?> -
    - __('Page') ?> - - getCollection()->getCurPage() ?> - getCollection()->getLastPageNumber() ?> - 1): ?> - getUiId('previous') ?>>Go to Previous page - - Go to Previous page - - - getUiId('current-page') ?>/> - - - getUiId('next') ?>>Go to Next page - - Go to Previous page - - - __('of %s pages', $this->getCollection()->getLastPageNumber()) ?> - | - __('View') ?> - - __('per page') ?>| - getCollection()->getSize(); ?> - __('Total %d records found', $countRecords) ?> - getUiId('total-count') ?>> - getRssLists()): ?> - getRssLists() as $_rss): ?> - |getLabel() ?> - - -
    - -
    - - getChildBlock('grid.massaction') && $this->getChildBlock('grid.massaction')->isAvailable()): ?> - getChildHtml('grid.massaction') ?> - -
    -
    -
    - - - getChildHtml('grid.columnSet'); ?> -
    -
    -
    -
    - canDisplayContainer()): ?> -
    - - -getChildBlock('grid.js')): ?> - getChildHtml('grid.js'); ?> - - diff --git a/app/code/core/Mage/Backend/view/adminhtml/widget/grid/column_set.phtml b/app/code/core/Mage/Backend/view/adminhtml/widget/grid/column_set.phtml deleted file mode 100644 index 51b2daf56b4da..0000000000000 --- a/app/code/core/Mage/Backend/view/adminhtml/widget/grid/column_set.phtml +++ /dev/null @@ -1,132 +0,0 @@ - -getColumns()); -?> -getCollection()): ?> - getColumns() as $_column): ?> - getHtmlProperty() ?> /> - - isHeaderVisible() || $this->isFilterVisible()): ?> - - isHeaderVisible()): ?> - - getColumns() as $_column): ?> - getHeaderHtmlProperty() ?>>getHeaderHtml() ?> - - - - isFilterVisible()): ?> - - getColumns() as $_column): ?> - getHeaderHtmlProperty() ?>>getFilterHtml() ?> - - - - - - - - getCollection()->getSize()>0) && (!$this->getIsCollapsed())): ?> - getCollection() as $_index => $_item): ?> - hasMultipleRows($_item)) :?> - updateItemByFirstMultiRow($_item); ?> - getRowClass($_item)):?> class="" > - getColumns() as $_column): ?> - shouldRenderCell($_item, $_column)):?> - getRowspan($_item, $_column);?> - class="getCssProperty() ?> "> - getRowField($_item)) != '' ? $_html : ' ') ?> - - shouldRenderEmptyCell($_item, $_column)):?> - getEmptyCellLabel()?> - - - - - - getMultipleRows($_item) as $_i):?> - - - - - getMultipleRowColumns($_i) as $_column): ?> - - getRowField($_i)) != '' ? $_html : ' ') ?> - - - - - - shouldRenderSubTotal($_item)): ?> - - getMultipleRowColumns() as $_column): ?> - - hasSubtotalsLabel() ? $_column->getSubtotalsLabel() : - $_column->getRowField($this->getSubTotals($_item)) - ); - ?> - - - - - - getRowClass($_item)):?> class="" > - getColumns() as $_column): ?> - shouldRenderCell($_item, $_column)):?> - - getRowField($_item)) != '' ? $_html : ' ') ?> - - shouldRenderEmptyCell($_item, $_column)):?> - getEmptyCellLabel()?> - - - - - - - getEmptyText()): ?> - - getEmptyText() ?> - - - - - shouldRenderTotal()): ?> - - - getColumns() as $_column): ?> - hasTotalsLabel()) ? $_column->getTotalsLabel() : $_column->getRowField($this->getTotals()) ?> - - - - - diff --git a/app/code/core/Mage/Backend/view/adminhtml/widget/grid/extended.phtml b/app/code/core/Mage/Backend/view/adminhtml/widget/grid/extended.phtml deleted file mode 100644 index 99eef185e90f7..0000000000000 --- a/app/code/core/Mage/Backend/view/adminhtml/widget/grid/extended.phtml +++ /dev/null @@ -1,250 +0,0 @@ - -getColumns()); - -/** - * @var Mage_Backend_Block_Widget_Grid_Extended $this - */ -?> -getCollection()): ?> -canDisplayContainer()): ?> - getGridHeader()): ?> -
    -
    -

    getGridHeader(); ?>

    -
    -
    - - -
    - - getMessagesBlock()->getGroupedHtml() ?> - - getPagerVisibility() || $this->getExportTypes() || $this->getFilterVisibility()): ?> -
    -
    - getMainButtonsHtml() ?> -
    - getExportTypes()): ?> -
    - __('Export to:') ?> - - getExportButtonHtml() ?> -
    - - getPagerVisibility()): ?> -
    - __('Page') ?> - - getCollection()->getCurPage() ?> - getCollection()->getLastPageNumber() ?> - 1): ?> - Previous Page - - Previous Page - - - - - - Next Page - - Next page - - - __('of %s pages', $this->getCollection()->getLastPageNumber()) ?> - | - __('View') ?> - - __('per page') ?>| - __('Total %d records found', $this->getCollection()->getSize()) ?> - getCollection()->getSize() ?> - getRssLists()): ?> - getRssLists() as $_rss): ?> - |getLabel() ?> - - -
    - -
    - - getMassactionBlock()->isAvailable()): ?> - getMassactionBlockHtml() ?> - -
    -
    - - getColumns() as $_column): ?> - getHtmlProperty() ?> /> - - getHeadersVisibility() || $this->getFilterVisibility()): ?> - - getHeadersVisibility()): ?> - - getColumns() as $_column): ?> - getHeaderHtmlProperty() ?>> - getHeaderHtml() ?> - - - - - getFilterVisibility()): ?> - - getColumns() as $_column): ?> - getHeaderHtmlProperty() ?>>getFilterHtml() ?> - - - - - - getCountTotals()): ?> - - - getColumns() as $_column): ?> - - - - - - - - getCollection()->getSize() > 0) && (!$this->getIsCollapsed())): ?> - getCollection() as $_index => $_item): ?> - getRowClass($_item)): ?> - class="" > - getColumns() as $_column): ?> - - shouldRenderCell($_item, $_column)): ?> - getRowspan($_item, $_column); ?> - - shouldRenderEmptyCell($_item, $_column)): ?> - - - - - - - getMultipleRows($_item)): ?> - - - getMultipleRowColumns($_i) as $_column): ?> - - - - - - - shouldRenderSubTotal($_item)): ?> - - getSubTotalColumns() as $_column): ?> - - - - - - getEmptyText()): ?> - - - - - - -
    hasTotalsLabel()) ? $_column->getTotalsLabel() : $_column->getRowField($_column->getGrid()->getTotals()) ?> -  
    class="getCssProperty() ?> "> - getRowField($_item)) != '' ? $_html : ' ') ?> - getEmptyCellLabel()?>
    - getRowField($_i)) != '' ? $_html : ' ') ?> -
    - hasSubtotalsLabel() ? $_column->getSubtotalsLabel() : - $_column->getRowField($this->getSubTotalItem($_item)) - ); - ?> -
    getEmptyText() ?>
    -
    -
    - canDisplayContainer()): ?> -
    - - - diff --git a/app/code/core/Mage/Backend/view/adminhtml/widget/tabs.phtml b/app/code/core/Mage/Backend/view/adminhtml/widget/tabs.phtml deleted file mode 100644 index 1d683ae190254..0000000000000 --- a/app/code/core/Mage/Backend/view/adminhtml/widget/tabs.phtml +++ /dev/null @@ -1,61 +0,0 @@ - - -
    - getTitle()): ?> -

    getUiId('title') ?>>getTitle() ?>

    - -
      getUiId('tab', $this->getId()) ?> class="getIsHoriz() ? 'tabs-horiz' : 'tabs' ?>"> - -canShowTab($_tab)): continue; endif; ?> - getTabClass($_tab) . ' ' . (preg_match('/\s?ajax\s?/', $_tab->getClass()) ? 'notloaded' : '') ?> - getTabUrl($_tab) != '#') ? 'link' : '' ?> - getTabUrl($_tab) == '#' ? '#' . $this->getTabId($_tab) . '_content' : $this->getTabUrl($_tab) ?> -
    • getTabIsHidden($_tab)): ?> style="display:none"getUiId('tab', 'item', $_tab->getId()) ?>> - getUiId('tab', 'link', $_tab->getId()) ?>> - - - - - getTabLabel($_tab); ?> - - - -
    • - -
    -
    - - diff --git a/app/code/core/Mage/Backup/Helper/Data.php b/app/code/core/Mage/Backup/Helper/Data.php deleted file mode 100644 index c15972f140cdd..0000000000000 --- a/app/code/core/Mage/Backup/Helper/Data.php +++ /dev/null @@ -1,342 +0,0 @@ -_filesystem = $filesystem; - } - - /** - * Get all possible backup type values with descriptive title - * - * @return array - */ - public function getBackupTypes() - { - return array( - self::TYPE_DB => $this->__('Database'), - self::TYPE_MEDIA => $this->__('Database and Media'), - self::TYPE_SYSTEM_SNAPSHOT => $this->__('System'), - self::TYPE_SNAPSHOT_WITHOUT_MEDIA => $this->__('System (excluding Media)') - ); - } - - /** - * Get all possible backup type values - * - * @return array - */ - public function getBackupTypesList() - { - return array( - self::TYPE_DB, - self::TYPE_SYSTEM_SNAPSHOT, - self::TYPE_SNAPSHOT_WITHOUT_MEDIA, - self::TYPE_MEDIA - ); - } - - /** - * Get default backup type value - * - * @return string - */ - public function getDefaultBackupType() - { - return self::TYPE_DB; - } - - /** - * Get directory path where backups stored - * - * @return string - */ - public function getBackupsDir() - { - return Mage::getBaseDir('var') . DS . 'backups'; - } - - /** - * Get backup file extension by backup type - * - * @param string $type - * @return string - */ - public function getExtensionByType($type) - { - $extensions = $this->getExtensions(); - return isset($extensions[$type]) ? $extensions[$type] : ''; - } - - /** - * Get all types to extensions map - * - * @return array - */ - public function getExtensions() - { - return array( - self::TYPE_SYSTEM_SNAPSHOT => 'tgz', - self::TYPE_SNAPSHOT_WITHOUT_MEDIA => 'tgz', - self::TYPE_MEDIA => 'tgz', - self::TYPE_DB => 'gz' - ); - } - - /** - * Generate backup download name - * - * @param Mage_Backup_Model_Backup $backup - * @return string - */ - public function generateBackupDownloadName(Mage_Backup_Model_Backup $backup) - { - $additionalExtension = $backup->getType() == self::TYPE_DB ? '.sql' : ''; - return $backup->getType() . '-' . date('YmdHis', $backup->getTime()) . $additionalExtension . '.' - . $this->getExtensionByType($backup->getType()); - } - - /** - * Check Permission for Rollback - * - * @return boolean - */ - public function isRollbackAllowed() - { - return Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Backup::rollback' ); - } - - /** - * Get paths that should be ignored when creating system snapshots - * - * @return array - */ - public function getBackupIgnorePaths() - { - return array( - '.git', - '.svn', - 'maintenance.flag', - Mage::getBaseDir('var') . DS . 'session', - Mage::getBaseDir('var') . DS . 'cache', - Mage::getBaseDir('var') . DS . 'full_page_cache', - Mage::getBaseDir('var') . DS . 'locks', - Mage::getBaseDir('var') . DS . 'log', - Mage::getBaseDir('var') . DS . 'report' - ); - } - - /** - * Get paths that should be ignored when rolling back system snapshots - * - * @return array - */ - public function getRollbackIgnorePaths() - { - return array( - '.svn', - '.git', - 'maintenance.flag', - Mage::getBaseDir('var') . DS . 'session', - Mage::getBaseDir('var') . DS . 'locks', - Mage::getBaseDir('var') . DS . 'log', - Mage::getBaseDir('var') . DS . 'report', - Mage::getBaseDir('app') . DS . 'Mage.php', - Mage::getBaseDir() . DS . 'errors', - Mage::getBaseDir() . DS . 'index.php' - ); - } - - /** - * Put store into maintenance mode - * - * @return bool - */ - public function turnOnMaintenanceMode() - { - $maintenanceFlagFile = $this->getMaintenanceFlagFilePath(); - $result = $this->_filesystem->write($maintenanceFlagFile, 'maintenance', Mage::getBaseDir()); - - return $result !== false; - } - - /** - * Turn off store maintenance mode - */ - public function turnOffMaintenanceMode() - { - $maintenanceFlagFile = $this->getMaintenanceFlagFilePath(); - $this->_filesystem->delete($maintenanceFlagFile, Mage::getBaseDir()); - } - - /** - * Get backup create success message by backup type - * - * @param string $type - * @return string - */ - public function getCreateSuccessMessageByType($type) - { - $messagesMap = array( - self::TYPE_SYSTEM_SNAPSHOT => $this->__('The system backup has been created.'), - self::TYPE_SNAPSHOT_WITHOUT_MEDIA => $this->__('The system (excluding Media) backup has been created.'), - self::TYPE_MEDIA => $this->__('The database and media backup has been created.'), - self::TYPE_DB => $this->__('The database backup has been created.') - ); - - if (!isset($messagesMap[$type])) { - return; - } - - return $messagesMap[$type]; - } - - /** - * Get path to maintenance flag file - * - * @return string - */ - protected function getMaintenanceFlagFilePath() - { - return Mage::getBaseDir() . DS . 'maintenance.flag'; - } - - /** - * Invalidate Cache - * - * @return Mage_Backup_Helper_Data - */ - public function invalidateCache() - { - if ($cacheTypesNode = Mage::getConfig()->getNode(Mage_Core_Model_Cache::XML_PATH_TYPES)) { - $cacheTypesList = array_keys($cacheTypesNode->asArray()); - Mage::app()->getCacheInstance()->invalidateType($cacheTypesList); - } - return $this; - } - - /** - * Invalidate Indexer - * - * @return Mage_Backup_Helper_Data - */ - public function invalidateIndexer() - { - foreach (Mage::getResourceModel('Mage_Index_Model_Resource_Process_Collection') as $process) { - $process->changeStatus(Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX); - } - return $this; - } - - /** - * Creates backup's display name from it's name - * - * @param string $name - * @return string - */ - public function nameToDisplayName($name) - { - return str_replace('_', ' ', $name); - } - - /** - * Extracts information from backup's filename - * - * @param string $filename - * @return Varien_Object - */ - public function extractDataFromFilename($filename) - { - $extensions = $this->getExtensions(); - - $filenameWithoutExtension = $filename; - - foreach ($extensions as $extension) { - $filenameWithoutExtension = preg_replace('/' . preg_quote($extension, '/') . '$/', '', - $filenameWithoutExtension - ); - } - - $filenameWithoutExtension = substr($filenameWithoutExtension, 0, strrpos($filenameWithoutExtension, ".")); - - list($time, $type) = explode("_", $filenameWithoutExtension); - - $name = str_replace($time . '_' . $type, '', $filenameWithoutExtension); - - if (!empty($name)) { - $name = substr($name, 1); - } - - $result = new Varien_Object(); - $result->addData(array( - 'name' => $name, - 'type' => $type, - 'time' => $time - )); - - return $result; - } -} diff --git a/app/code/core/Mage/Backup/etc/adminhtml/acl.xml b/app/code/core/Mage/Backup/etc/adminhtml/acl.xml deleted file mode 100644 index 187f7c6f0856b..0000000000000 --- a/app/code/core/Mage/Backup/etc/adminhtml/acl.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Backup/etc/adminhtml/menu.xml b/app/code/core/Mage/Backup/etc/adminhtml/menu.xml deleted file mode 100644 index 206f0db444b34..0000000000000 --- a/app/code/core/Mage/Backup/etc/adminhtml/menu.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - diff --git a/app/code/core/Mage/Backup/etc/config.xml b/app/code/core/Mage/Backup/etc/config.xml deleted file mode 100644 index eecf9a70abae4..0000000000000 --- a/app/code/core/Mage/Backup/etc/config.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - Mage_Backup - - - - - - - - - - Mage_Backup.csv - - - - - - - - - - Mage_Backup_Model_Observer::scheduledBackup - - - - - diff --git a/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option.php b/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option.php deleted file mode 100644 index 649087198ce8f..0000000000000 --- a/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option.php +++ /dev/null @@ -1,251 +0,0 @@ - - */ -class Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle_Option extends Mage_Adminhtml_Block_Widget -{ - /** - * Form element - * - * @var Varien_Data_Form_Element_Abstract|null - */ - protected $_element = null; - - /** - * List of customer groups - * - * @deprecated since 1.7.0.0 - * @var array|null - */ - protected $_customerGroups = null; - - /** - * List of websites - * - * @deprecated since 1.7.0.0 - * @var array|null - */ - protected $_websites = null; - - /** - * List of bundle product options - * - * @var array|null - */ - protected $_options = null; - - protected $_template = 'product/edit/bundle/option.phtml'; - - /** - * Bundle option renderer class constructor - * - * Sets block template and necessary data - */ - protected function _construct() - { - - $this->setCanReadPrice(true); - $this->setCanEditPrice(true); - } - - public function getFieldId() - { - return 'bundle_option'; - } - - public function getFieldName() - { - return 'bundle_options'; - } - - /** - * Retrieve Product object - * - * @return Mage_Catalog_Model_Product - */ - public function getProduct() - { - if (!$this->getData('product')) { - $this->setData('product', Mage::registry('product')); - } - return $this->getData('product'); - } - - public function render(Varien_Data_Form_Element_Abstract $element) - { - $this->setElement($element); - return $this->toHtml(); - } - - public function setElement(Varien_Data_Form_Element_Abstract $element) - { - $this->_element = $element; - return $this; - } - - public function getElement() - { - return $this->_element; - } - - public function isMultiWebsites() - { - return !Mage::app()->hasSingleStore(); - } - - protected function _prepareLayout() - { - $this->addChild('add_selection_button', 'Mage_Adminhtml_Block_Widget_Button', array( - 'id' => $this->getFieldId() . '_{{index}}_add_button', - 'label' => Mage::helper('Mage_Bundle_Helper_Data')->__('Add Products to Option'), - 'class' => 'add add-selection' - )); - - $this->addChild('close_search_button', 'Mage_Adminhtml_Block_Widget_Button', array( - 'id' => $this->getFieldId().'_{{index}}_close_button', - 'label' => Mage::helper('Mage_Bundle_Helper_Data')->__('Close'), - 'on_click' => 'bSelection.closeSearch(event)', - 'class' => 'back no-display' - )); - - $this->addChild('option_delete_button', 'Mage_Adminhtml_Block_Widget_Button', array( - 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Delete Option'), - 'class' => 'delete delete-product-option', - 'on_click' => 'bOption.remove(event)' - )); - - $this->addChild( - 'selection_template', - 'Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle_Option_Selection' - ); - - return parent::_prepareLayout(); - } - - public function getAddButtonHtml() - { - return $this->getChildHtml('add_button'); - } - - public function getCloseSearchButtonHtml() - { - return $this->getChildHtml('close_search_button'); - } - - public function getAddSelectionButtonHtml() - { - return $this->getChildHtml('add_selection_button'); - } - - /** - * Retrieve list of bundle product options - * - * @return array - */ - public function getOptions() - { - if (!$this->_options) { - $this->getProduct()->getTypeInstance()->setStoreFilter($this->getProduct()->getStoreId(), - $this->getProduct()); - - $optionCollection = $this->getProduct()->getTypeInstance()->getOptionsCollection($this->getProduct()); - - $selectionCollection = $this->getProduct()->getTypeInstance()->getSelectionsCollection( - $this->getProduct()->getTypeInstance()->getOptionsIds($this->getProduct()), - $this->getProduct() - ); - - $this->_options = $optionCollection->appendSelections($selectionCollection); - if ($this->getCanReadPrice() === false) { - foreach ($this->_options as $option) { - if ($option->getSelections()) { - foreach ($option->getSelections() as $selection) { - $selection->setCanReadPrice($this->getCanReadPrice()); - $selection->setCanEditPrice($this->getCanEditPrice()); - } - } - } - } - } - return $this->_options; - } - - public function getAddButtonId() - { - $buttonId = $this->getLayout() - ->getBlock('admin.product.bundle.items') - ->getChildBlock('add_button')->getId(); - return $buttonId; - } - - public function getOptionDeleteButtonHtml() - { - return $this->getChildHtml('option_delete_button'); - } - - public function getSelectionHtml() - { - return $this->getChildHtml('selection_template'); - } - - public function getTypeSelectHtml() - { - $select = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Html_Select') - ->setData(array( - 'id' => $this->getFieldId().'_{{index}}_type', - 'class' => 'select select-product-option-type required-option-select', - 'extra_params' => 'onchange="bOption.changeType(event)"' - )) - ->setName($this->getFieldName().'[{{index}}][type]') - ->setOptions(Mage::getSingleton('Mage_Bundle_Model_Source_Option_Type')->toOptionArray()); - - return $select->getHtml(); - } - - public function getRequireSelectHtml() - { - $select = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Html_Select') - ->setData(array( - 'id' => $this->getFieldId().'_{{index}}_required', - 'class' => 'select' - )) - ->setName($this->getFieldName().'[{{index}}][required]') - ->setOptions(Mage::getSingleton('Mage_Backend_Model_Config_Source_Yesno')->toOptionArray()); - - return $select->getHtml(); - } - - public function isDefaultStore() - { - return $this->getProduct()->getStoreId() == '0'; - } -} diff --git a/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php b/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php deleted file mode 100644 index fb88eb4faf6b3..0000000000000 --- a/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php +++ /dev/null @@ -1,163 +0,0 @@ - - */ -class Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle_Option_Search_Grid - extends Mage_Adminhtml_Block_Widget_Grid -{ - protected function _construct() - { - parent::_construct(); - $this->setId('bundle_selection_search_grid'); - $this->setRowClickCallback('bSelection.productGridRowClick.bind(bSelection)'); - $this->setCheckboxCheckCallback('bSelection.productGridCheckboxCheck.bind(bSelection)'); - $this->setRowInitCallback('bSelection.productGridRowInit.bind(bSelection)'); - $this->setDefaultSort('id'); - $this->setUseAjax(true); - } - - /** - * Prepare grid filter buttons - */ - protected function _prepareFilterButtons() - { - $this->getChildBlock('reset_filter_button')->setData( - 'onclick', - $this->getJsObjectName() . '.resetFilter(bSelection.gridUpdateCallback)' - ); - $this->getChildBlock('search_button')->setData( - 'onclick', - $this->getJsObjectName() . '.doFilter(bSelection.gridUpdateCallback)' - ); - } - - protected function _beforeToHtml() - { - $this->setId($this->getId() . '_' . $this->getIndex()); - return parent::_beforeToHtml(); - } - - protected function _prepareCollection() - { - $collection = Mage::getModel('Mage_Catalog_Model_Product')->getCollection() - ->setOrder('id') - ->setStore($this->getStore()) - ->addAttributeToSelect('name') - ->addAttributeToSelect('sku') - ->addAttributeToSelect('price') - ->addAttributeToSelect('attribute_set_id') - ->addAttributeToFilter('type_id', array('in' => $this->getAllowedSelectionTypes())) - ->addFilterByRequiredOptions() - ->addStoreFilter(); - - if ($this->getFirstShow()) { - $collection->addIdFilter('-1'); - $this->setEmptyText($this->__('Please enter search conditions to view products.')); - } - - $this->setCollection($collection); - - return parent::_prepareCollection(); - } - - protected function _prepareColumns() - { - $this->addColumn('is_selected', array( - 'header_css_class' => 'a-center', - 'type' => 'checkbox', - 'name' => 'in_selected', - 'align' => 'center', - 'values' => $this->_getSelectedProducts(), - 'index' => 'entity_id', - )); - $this->addColumn('name', array( - 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Product Name'), - 'index' => 'name', - 'column_css_class'=> 'name' - )); - $this->addColumn('sku', array( - 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('SKU'), - 'width' => '80px', - 'index' => 'sku', - 'column_css_class'=> 'sku' - )); - $this->addColumn('price', array( - 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Price'), - 'align' => 'center', - 'type' => 'currency', - 'currency_code' => $this->getStore()->getCurrentCurrencyCode(), - 'rate' => $this->getStore()->getBaseCurrency()->getRate($this->getStore()->getCurrentCurrencyCode()), - 'index' => 'price' - )); - return parent::_prepareColumns(); - } - - public function getGridUrl() - { - return $this->getUrl('*/bundle_selection/grid', array('index' => $this->getIndex(), 'productss' => implode(',', $this->_getProducts()))); - } - - protected function _getSelectedProducts() - { - $products = $this->getRequest()->getPost( - 'selected_products', - explode(',', $this->getRequest()->getParam('productss')) - ); - return $products; - } - - protected function _getProducts() - { - if ($products = $this->getRequest()->getPost('products', null)) { - return $products; - } else if ($productss = $this->getRequest()->getParam('productss', null)) { - return explode(',', $productss); - } else { - return array(); - } - } - - public function getStore() - { - return Mage::app()->getStore(); - } - - /** - * Retrieve array of allowed product types for bundle selection product - * - * @return array - */ - public function getAllowedSelectionTypes() - { - return Mage::helper('Mage_Bundle_Helper_Data')->getAllowedSelectionTypes(); - } -} diff --git a/app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php b/app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php deleted file mode 100644 index d0207e52c364e..0000000000000 --- a/app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php +++ /dev/null @@ -1,274 +0,0 @@ - - */ -class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option extends Mage_Bundle_Block_Catalog_Product_Price -{ - /** - * Store preconfigured options - * - * @var int|array|string - */ - protected $_selectedOptions = null; - - /** - * Show if option has a single selection - * - * @var bool - */ - protected $_showSingle = null; - - /** - * Check if option has a single selection - * - * @return bool - */ - protected function _showSingle() - { - if (is_null($this->_showSingle)) { - $_option = $this->getOption(); - $_selections = $_option->getSelections(); - - $this->_showSingle = (count($_selections) == 1 && $_option->getRequired()); - } - - return $this->_showSingle; - } - - /** - * Retrieve default values for template - * - * @return array - */ - protected function _getDefaultValues() - { - $_option = $this->getOption(); - $_default = $_option->getDefaultSelection(); - $_selections = $_option->getSelections(); - $selectedOptions = $this->_getSelectedOptions(); - $inPreConfigured = $this->getProduct()->hasPreconfiguredValues() - && $this->getProduct()->getPreconfiguredValues() - ->getData('bundle_option_qty/' . $_option->getId()); - - if (empty($selectedOptions) && $_default) { - $_defaultQty = $_default->getSelectionQty()*1; - $_canChangeQty = $_default->getSelectionCanChangeQty(); - } elseif (!$inPreConfigured && $selectedOptions && is_numeric($selectedOptions)) { - $selectedSelection = $_option->getSelectionById($selectedOptions); - $_defaultQty = $selectedSelection->getSelectionQty()*1; - $_canChangeQty = $selectedSelection->getSelectionCanChangeQty(); - } elseif (!$this->_showSingle() || $inPreConfigured) { - $_defaultQty = $this->_getSelectedQty(); - $_canChangeQty = (bool)$_defaultQty; - } else { - $_defaultQty = $_selections[0]->getSelectionQty()*1; - $_canChangeQty = $_selections[0]->getSelectionCanChangeQty(); - } - - return array($_defaultQty, $_canChangeQty); - } - - /** - * Collect selected options - * - * @return void - */ - protected function _getSelectedOptions() - { - if (is_null($this->_selectedOptions)) { - $this->_selectedOptions = array(); - $option = $this->getOption(); - - if ($this->getProduct()->hasPreconfiguredValues()) { - $configValue = $this->getProduct()->getPreconfiguredValues() - ->getData('bundle_option/' . $option->getId()); - if ($configValue) { - $this->_selectedOptions = $configValue; - } elseif (!$option->getRequired()) { - $this->_selectedOptions = 'None'; - } - } - } - - return $this->_selectedOptions; - } - - /** - * Define if selection is selected - * - * @param Mage_Catalog_Model_Product $selection - * @return bool - */ - protected function _isSelected($selection) - { - $selectedOptions = $this->_getSelectedOptions(); - if (is_numeric($selectedOptions)) { - return ($selection->getSelectionId() == $this->_getSelectedOptions()); - } elseif (is_array($selectedOptions) && !empty($selectedOptions)) { - return in_array($selection->getSelectionId(), $this->_getSelectedOptions()); - } elseif ($selectedOptions == 'None') { - return false; - } else { - return ($selection->getIsDefault() && $selection->isSaleable()); - } - } - - /** - * Retrieve selected option qty - * - * @return int - */ - protected function _getSelectedQty() - { - if ($this->getProduct()->hasPreconfiguredValues()) { - $selectedQty = (float)$this->getProduct()->getPreconfiguredValues() - ->getData('bundle_option_qty/' . $this->getOption()->getId()); - if ($selectedQty < 0) { - $selectedQty = 0; - } - } else { - $selectedQty = 0; - } - - return $selectedQty; - } - - /** - * Get product model - * - * @return Mage_Catalog_Model_Product - */ - public function getProduct() - { - if (!$this->hasData('product')) { - $this->setData('product', Mage::registry('current_product')); - } - return $this->getData('product'); - } - - public function getSelectionQtyTitlePrice($_selection, $includeContainer = true) - { - $price = $this->getProduct()->getPriceModel()->getSelectionPreFinalPrice($this->getProduct(), $_selection); - $this->setFormatProduct($_selection); - $priceTitle = $_selection->getSelectionQty()*1 . ' x ' . $this->escapeHtml($_selection->getName()); - - $priceTitle .= '   ' . ($includeContainer ? '' : '') - . '+' . $this->formatPriceString($price, $includeContainer) - . ($includeContainer ? '' : ''); - - return $priceTitle; - } - - /** - * Get price for selection product - * - * @param Mage_Catalog_Model_Product $_selection - * @return int|float - */ - public function getSelectionPrice($_selection) - { - $price = 0; - $store = $this->getProduct()->getStore(); - if ($_selection) { - $price = $this->getProduct()->getPriceModel()->getSelectionPreFinalPrice($this->getProduct(), $_selection); - if (is_numeric($price)) { - $price = $this->helper('Mage_Core_Helper_Data')->currencyByStore($price, $store, false); - } - } - return is_numeric($price) ? $price : 0; - } - - /** - * Get title price for selection product - * - * @param Mage_Catalog_Model_Product $_selection - * @param bool $includeContainer - * @return string - */ - public function getSelectionTitlePrice($_selection, $includeContainer = true) - { - $price = $this->getProduct()->getPriceModel()->getSelectionPreFinalPrice($this->getProduct(), $_selection, 1); - $this->setFormatProduct($_selection); - $priceTitle = $this->escapeHtml($_selection->getName()); - $priceTitle .= '   ' . ($includeContainer ? '' : '') - . '+' . $this->formatPriceString($price, $includeContainer) - . ($includeContainer ? '' : ''); - return $priceTitle; - } - - /** - * Set JS validation container for element - * - * @param int $elementId - * @param int $containerId - * @return string - */ - public function setValidationContainer($elementId, $containerId) - { - return; - } - - /** - * Format price string - * - * @param float $price - * @param bool $includeContainer - * @return string - */ - public function formatPriceString($price, $includeContainer = true) - { - $taxHelper = Mage::helper('Mage_Tax_Helper_Data'); - $coreHelper = $this->helper('Mage_Core_Helper_Data'); - $currentProduct = $this->getProduct(); - if ($currentProduct->getPriceType() == Mage_Bundle_Model_Product_Price::PRICE_TYPE_DYNAMIC - && $this->getFormatProduct() - ) { - $product = $this->getFormatProduct(); - } else { - $product = $currentProduct; - } - - $priceTax = $taxHelper->getPrice($product, $price); - $priceIncTax = $taxHelper->getPrice($product, $price, true); - - $formated = $coreHelper->currencyByStore($priceTax, $product->getStore(), true, $includeContainer); - if ($taxHelper->displayBothPrices() && $priceTax != $priceIncTax) { - $formated .= - ' (+' . - $coreHelper->currencyByStore($priceIncTax, $product->getStore(), true, $includeContainer) . - ' ' . $this->__('Incl. Tax') . ')'; - } - - return $formated; - } -} diff --git a/app/code/core/Mage/Bundle/Model/Price/Index.php b/app/code/core/Mage/Bundle/Model/Price/Index.php deleted file mode 100644 index c15a3e7774897..0000000000000 --- a/app/code/core/Mage/Bundle/Model/Price/Index.php +++ /dev/null @@ -1,156 +0,0 @@ - - */ -class Mage_Bundle_Model_Price_Index extends Mage_Core_Model_Abstract -{ - /** - * Initialize resource model - * - */ - protected function _construct() - { - $this->_init('Mage_Bundle_Model_Resource_Price_Index'); - } - - /** - * Retrieve resource instance wrapper - * - * @return Mage_Bundle_Model_Resource_Price_Index - */ - protected function _getResource() - { - return parent::_getResource(); - } - - /** - * Reindex Product price - * - * @param int $productId - * @param int $priceType - * @return Mage_Bundle_Model_Price_Index - */ - protected function _reindexProduct($productId, $priceType) - { - $this->_getResource()->reindexProduct($productId, $priceType); - return $this; - } - - /** - * Reindex Bundle product Price Index - * - * @param Mage_Core_Model_Product|Mage_Catalog_Model_Product_Condition_Interface|array|int $products - * @return Mage_Bundle_Model_Price_Index - */ - public function reindex($products = null) - { - $this->_getResource()->reindex($products); - return $this; - } - - /** - * Add bundle price range index to Product collection - * - * @param Mage_Catalog_Model_Resource_Product_Collection $collection - * @return Mage_Bundle_Model_Price_Index - */ - public function addPriceIndexToCollection($collection) - { - $productObjects = array(); - $productIds = array(); - foreach ($collection->getItems() as $product) { - /* @var $product Mage_Catalog_Model_Product */ - if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) { - $productIds[] = $product->getEntityId(); - $productObjects[$product->getEntityId()] = $product; - } - } - $websiteId = Mage::app()->getStore($collection->getStoreId()) - ->getWebsiteId(); - $groupId = Mage::getSingleton('Mage_Customer_Model_Session') - ->getCustomerGroupId(); - - $addOptionsToResult = false; - $prices = $this->_getResource()->loadPriceIndex($productIds, $websiteId, $groupId); - foreach ($productIds as $productId) { - if (isset($prices[$productId])) { - $productObjects[$productId] - ->setData('_price_index', true) - ->setData('_price_index_min_price', $prices[$productId]['min_price']) - ->setData('_price_index_max_price', $prices[$productId]['max_price']); - } - else { - $addOptionsToResult = true; - } - } - - if ($addOptionsToResult) { - $collection->addOptionsToResult(); - } - - return $this; - } - - /** - * Add price index to bundle product after load - * - * @param Mage_Catalog_Model_Product $product - * @return Mage_Bundle_Model_Price_Index - */ - public function addPriceIndexToProduct($product) - { - $websiteId = $product->getStore()->getWebsiteId(); - $groupId = Mage::getSingleton('Mage_Customer_Model_Session') - ->getCustomerGroupId(); - $prices = $this->_getResource() - ->loadPriceIndex($product->getId(), $websiteId, $groupId); - if (isset($prices[$product->getId()])) { - $product->setData('_price_index', true) - ->setData('_price_index_min_price', $prices[$product->getId()]['min_price']) - ->setData('_price_index_max_price', $prices[$product->getId()]['max_price']); - } - return $this; - } -} diff --git a/app/code/core/Mage/Bundle/Model/Resource/Price/Index.php b/app/code/core/Mage/Bundle/Model/Resource/Price/Index.php deleted file mode 100755 index ea544da3ac9a6..0000000000000 --- a/app/code/core/Mage/Bundle/Model/Resource/Price/Index.php +++ /dev/null @@ -1,828 +0,0 @@ - - */ -class Mage_Bundle_Model_Resource_Price_Index extends Mage_Core_Model_Resource_Db_Abstract -{ - /** - * EAV attributes cache - * - * @var array - */ - protected $_attributes = array(); - - /** - * Websites cache - * - * @var array - */ - protected $_websites; - - /** - * Customer Groups cache - * - * @var array - */ - protected $_customerGroups; - - /** - * Initialize connection and define main table - * - */ - protected function _construct() - { - $this->_init('catalog_product_bundle_price_index', 'entity_id'); - } - - /** - * Retrieve attribute object - * - * @param string $attributeCode - * @return Mage_Catalog_Model_Resource_Eav_Attribute - */ - protected function _getAttribute($attributeCode) - { - if (!isset($this->_attributes[$attributeCode])) { - $this->_attributes[$attributeCode] = Mage::getSingleton('Mage_Catalog_Model_Config') - ->getAttribute(Mage_Catalog_Model_Product::ENTITY, $attributeCode); - } - return $this->_attributes[$attributeCode]; - } - - /** - * Retrieve websites collection array - * - * @return array - */ - protected function _getWebsites() - { - if (is_null($this->_websites)) { - $this->_websites = Mage::app()->getWebsites(false); - } - return $this->_websites; - } - - /** - * Retrieve customer groups collection array - * - * @return array - */ - protected function _getCustomerGroups() - { - if (is_null($this->_customerGroups)) { - $this->_customerGroups = array(); - foreach (Mage::getModel('Mage_Customer_Model_Group')->getCollection() as $group) { - $this->_customerGroups[$group->getId()] = $group; - } - } - return $this->_customerGroups; - } - - /** - * Retrieve product ids array by product condition - * - * @param Mage_Core_Model_Product|Mage_Catalog_Model_Product_Condition_Interface|array|int $product - * @param int $lastEntityId - * @param int $limit - * @return array - */ - public function getProducts($product = null, $lastEntityId = 0, $limit = 100) - { - - $select = $this->_getReadAdapter()->select() - ->from( - array('e' => $this->getTable('catalog_product_entity')), - array('entity_id') - ) - ->where('e.type_id=?', Mage_Catalog_Model_Product_Type::TYPE_BUNDLE); - if ($product instanceof Mage_Catalog_Model_Product) { - $select->where('e.entity_id=?', $product->getId()); - } elseif ($product instanceof Mage_Catalog_Model_Product_Condition_Interface) { - $value = new Zend_Db_Expr($product->getIdsSelect($this->_getReadAdapter())); - $select->where('e.entity_id IN(?)', $value); - } elseif (is_numeric($product) || is_array($product)) { - $select->where('e.entity_id IN(?)', $product); - } - - $priceType = $this->_getAttribute('price_type'); - $priceTypeAlias = 't_' . $priceType->getAttributeCode(); - $joinConds = array( - $priceTypeAlias . '.attribute_id=:attribute_id', - $priceTypeAlias . '.store_id=0', - $priceTypeAlias . '.entity_id=e.entity_id' - ); - - $select->joinLeft( - array($priceTypeAlias => $priceType->getBackend()->getTable()), - join(' AND ', $joinConds), - array('price_type' => $priceTypeAlias . '.value') - ); - - $select->where('e.entity_id>:last_entity_id', $lastEntityId) - ->order('e.entity_id') - ->limit($limit); - $bind = array( - 'attribute_id' => $priceType->getAttributeId(), - 'last_entity_id' => $lastEntityId - ); - return $this->_getReadAdapter()->fetchPairs($select, $bind); - } - - /** - * Reindex Bundle product Price Index - * - * @param Mage_Core_Model_Product|Mage_Catalog_Model_Product_Condition_Interface|array|int $products - * @return Mage_Bundle_Model_Resource_Price_Index - */ - public function reindex($products = null) - { - $lastEntityId = 0; - while (true) { - $productsData = $this->getProducts($products, $lastEntityId); - if (!$productsData) { - break; - } - - foreach ($productsData as $productId => $priceType) { - $this->_reindexProduct($productId, $priceType); - $lastEntityId = $productId; - } - } - - return $this; - } - - /** - * Reindex product price - * - * @param int $productId - * @param int $priceType - * @return Mage_Bundle_Model_Resource_Price_Index - */ - protected function _reindexProduct($productId, $priceType) - { - $options = $this->getSelections($productId); - $selectionProducts = array(); - foreach ($options as $option) { - foreach ($option['selections'] as $selection) { - $selectionProducts[$selection['product_id']] = $selection['product_id']; - } - } - - $priceIndex = array(); - - foreach ($this->_getWebsites() as $website) { - if (!$website->getDefaultStore()) { - continue; - } - $salableStatus = $this->getProductsSalableStatus($selectionProducts, $website); - $priceData = $this->getProductsPriceData($productId, $website); - $priceData = $priceData[$productId]; - - /* @var $website Mage_Core_Model_Website */ - foreach ($this->_getCustomerGroups() as $group) { - /* @var $group Mage_Customer_Model_Group */ - if ($priceType == Mage_Bundle_Model_Product_Price::PRICE_TYPE_FIXED) { - $basePrice = $this->_getBasePrice($productId, $priceData, $website, $group); - $customOptions = $this->getCustomOptions($productId, $website); - } elseif ($priceType == Mage_Bundle_Model_Product_Price::PRICE_TYPE_DYNAMIC) { - $basePrice = 0; - } - - list($minPrice, $maxPrice) = $this->_calculateBundleSelections($options, $salableStatus, - $productId, $priceType, $basePrice, $priceData, $priceIndex, $website, $group - ); - - if ($priceType == Mage_Bundle_Model_Product_Price::PRICE_TYPE_FIXED) { - list($minPrice, $maxPrice) = - $this->_calculateCustomOptions($customOptions, $basePrice, $minPrice, $maxPrice); - } - - $this->_savePriceIndex($productId, $website->getId(), $group->getId(), $minPrice, $maxPrice); - } - } - - return $this; - } - - /** - * Save price index - * - * @param int $productId - * @param int $websiteId - * @param int $groupId - * @param float $minPrice - * @param float $maxPrice - * @return Mage_Bundle_Model_Resource_Price_Index - */ - protected function _savePriceIndex($productId, $websiteId, $groupId, $minPrice, $maxPrice) - { - $adapter = $this->_getWriteAdapter(); - $adapter->beginTransaction(); - $bind = array($productId, $websiteId, $groupId, $minPrice, $maxPrice); - $adapter->insertOnDuplicate($this->getMainTable(), $bind, array('min_price', 'max_price')); - $adapter->commit(); - - return $this; - } - - /** - * Retrieve bundle options with selections and prices by product - * - * @param int $productId - * @return array - */ - public function getSelections($productId) - { - $options = array(); - $read = $this->_getReadAdapter(); - $select = $read->select() - ->from( - array('option_table' => $this->getTable('catalog_product_bundle_option')), - array('option_id', 'required', 'type') - ) - ->join( - array('selection_table' => $this->getTable('catalog_product_bundle_selection')), - 'selection_table.option_id=option_table.option_id', - array('selection_id', 'product_id', 'selection_price_type', - 'selection_price_value', 'selection_qty', 'selection_can_change_qty') - ) - ->join( - array('e' => $this->getTable('catalog_product_entity')), - 'e.entity_id=selection_table.product_id AND e.required_options=0', - array() - ) - ->where('option_table.parent_id=:product_id'); - - $query = $read->query($select, array('product_id' => $productId)); - while ($row = $query->fetch()) { - if (!isset($options[$row['option_id']])) { - $options[$row['option_id']] = array( - 'option_id' => $row['option_id'], - 'required' => $row['required'], - 'type' => $row['type'], - 'selections' => array() - ); - } - $options[$row['option_id']]['selections'][$row['selection_id']] = array( - 'selection_id' => $row['selection_id'], - 'product_id' => $row['product_id'], - 'price_type' => $row['selection_price_type'], - 'price_value' => $row['selection_price_value'], - 'qty' => $row['selection_qty'], - 'can_change_qty' => $row['selection_can_change_qty'] - ); - } - - return $options; - } - - /** - * Retrieve salable product statuses - * - * @param int|array $products - * @param Mage_Core_Model_Website $website - * @return array - */ - public function getProductsSalableStatus($products, Mage_Core_Model_Website $website) - { - $read = $this->_getReadAdapter(); - $productsData = array(); - $select = $read->select() - ->from(array('e' => $this->getTable('catalog_product_entity')), 'entity_id') - ->where('e.entity_id IN(?)', $products); - // add belong to website - $select->joinLeft( - array('pw' => $this->getTable('catalog_product_website')), - 'e.entity_id=pw.product_id AND pw.website_id=:website_id', - array('pw.website_id') - ); - - $store = $website->getDefaultStore(); - - // add product status - $status = $this->_getAttribute('status'); - if ($status->isScopeGlobal()) { - $select->join( - array('t_status' => $status->getBackend()->getTable()), - 'e.entity_id=t_status.entity_id' - . ' AND t_status.attribute_id=:status_attribute_id' - . ' AND t_status.store_id=0', - array('status' => 't_status.value') - ); - } else { - - $statusField = $read->getCheckSql( - 't2_status.value_id > 0', - 't2_status.value', - 't1_status.value' - ); - - $statusTable = $status->getBackend()->getTable(); - $select->join( - array('t1_status' => $statusTable), - 'e.entity_id=t1_status.entity_id' - . ' AND t1_status.attribute_id=:status_attribute_id' - . ' AND t1_status.store_id=0', - array('status' => $statusField) - ) - ->joinLeft( - array('t2_status' => $statusTable), - 't1_status.entity_id = t2_status.entity_id' - . ' AND t1_status.attribute_id = t2_status.attribute_id' - . ' AND t2_status.store_id=:store_id', - array() - ); - } - - $bind = array( - 'status_attribute_id' => $status->getAttributeId(), - 'website_id' => $website->getId(), - 'store_id' => $store->getId() - ); - - Mage::dispatchEvent('catalog_product_prepare_index_select', array( - 'website' => $website, - 'select' => $select, - 'bind' => $bind - )); - - $query = $read->query($select, $bind); - while ($row = $query->fetch()) { - $salable = isset($row['salable']) ? $row['salable'] : true; - $website = $row['website_id'] > 0 ? true : false; - $status = $row['status']; - - $productsData[$row['entity_id']] = $salable && $status && $website; - } - - return $productsData; - } - - /** - * Retrieve product(s) price data - * - * @param int|array $products - * @param Mage_Core_Model_Website $website - * @return array - */ - public function getProductsPriceData($products, Mage_Core_Model_Website $website) - { - $productsData = array(); - $read = $this->_getReadAdapter(); - $select = $read->select() - ->from(array('e' => $this->getTable('catalog_product_entity')), 'entity_id') - ->where('e.entity_id IN(?)', $products); - - $this->_addAttributeDataToSelect($select, 'price', $website); - $this->_addAttributeDataToSelect($select, 'special_price', $website); - $this->_addAttributeDataToSelect($select, 'special_from_date', $website); - $this->_addAttributeDataToSelect($select, 'special_to_date', $website); - - $query = $read->query($select); - while ($row = $query->fetch()) { - $productsData[$row['entity_id']] = array( - 'price' => $row['price'], - 'special_price' => $row['special_price'], - 'special_from_date' => $row['special_from_date'], - 'special_to_date' => $row['special_to_date'] - ); - } - - return $productsData; - } - - /** - * Add attribute data to select - * - * @param Varien_Db_Select $select - * @param string $attributeCode - * @param Mage_Core_Model_Website $website - * @return Mage_Bundle_Model_Resource_Price_Index - */ - protected function _addAttributeDataToSelect(Varien_Db_Select $select, $attributeCode, - Mage_Core_Model_Website $website) - { - $attribute = $this->_getAttribute($attributeCode); - $store = $website->getDefaultStore(); - if ($attribute->isScopeGlobal()) { - $table = 't_' . $attribute->getAttributeCode(); - $select->joinLeft( - array($table => $attribute->getBackend()->getTable()), - "e.entity_id={$table}.entity_id" - . " AND {$table}.attribute_id={$attribute->getAttributeId()}" - . " AND {$table}.store_id=0", - array($attribute->getAttributeCode() => $table . '.value') - ); - } else { - $tableName = $attribute->getBackend()->getTable(); - $tableGlobal = 't1_' . $attribute->getAttributeCode(); - $tableStore = 't2_' . $attribute->getAttributeCode(); - - $attributeCond = $this->getReadConnection()->getCheckSql( - $tableStore . '.value_id > 0', - $tableStore . '.value', - $tableGlobal . '.value' - ); - $select->joinLeft( - array($tableGlobal => $tableName), - "e.entity_id = {$tableGlobal}.entity_id" - . " AND {$tableGlobal}.attribute_id = {$attribute->getAttributeId()}" - . " AND {$tableGlobal}.store_id = 0", - array($attribute->getAttributeCode() => $attributeCond) - ) - ->joinLeft( - array($tableStore => $tableName), - "{$tableGlobal}.entity_id = {$tableStore}.entity_id" - . " AND {$tableGlobal}.attribute_id = {$tableStore}.attribute_id" - . " AND {$tableStore}.store_id = " . $store->getId(), - array() - ); - } - return $this; - } - - /** - * Retrieve fixed bundle base price (with special price and rules) - * - * @param int $productId - * @param array $priceData - * @param Mage_Core_Model_Website $website - * @param Mage_Customer_Model_Group $customerGroup - * @return float - */ - protected function _getBasePrice($productId, array $priceData, $website, $customerGroup) - { - $store = $website->getDefaultStore(); - $storeTimeStamp = Mage::app()->getLocale()->storeTimeStamp($store); - $finalPrice = $this->_calculateSpecialPrice($priceData['price'], $priceData, $website); - - $rulePrice = Mage::getResourceModel('Mage_CatalogRule_Model_Resource_Rule') - ->getRulePrice($storeTimeStamp, $website->getId(), $customerGroup->getId(), $productId); - - if ($rulePrice !== null && $rulePrice !== false) { - $finalPrice = min($finalPrice, $rulePrice); - } - - return $finalPrice; - } - - /** - * Retrieve custom options for product - * - * @param int $productId - * @param Mage_Core_Model_Website $website - * @return array - */ - public function getCustomOptions($productId, Mage_Core_Model_Website $website) - { - $options = array(); - $store = $website->getDefaultStore(); - $price = $this->_getAttribute('price'); - $adapter = $this->_getReadAdapter(); - - $bind = array( - ':product_id' => $productId, - ':store_id' => $store->getId(), - - ); - $select = $adapter->select() - ->from( - array('option_table' => $this->getTable('catalog_product_option')), - array('option_id', 'is_require', 'type') - ) - ->where('option_table.product_id=:product_id'); - - if ($price->isScopeGlobal()) { - $select->join( - array('price_table' => $this->getTable('catalog_product_option_price')), - 'option_table.option_id = price_table.option_id' . - ' AND price_table.store_id = 0', - array('value_id' => 'option_price_id', 'price', 'price_type') - ); - } else { - $valueIdCond = $adapter->getCheckSql( - 'price_store_table.option_price_id IS NOT NULL', - 'price_store_table.option_price_id', - 'price_global_table.option_price_id' - ); - $priceCond = $adapter->getCheckSql( - 'price_store_table.price IS NOT NULL', - 'price_store_table.price', - 'price_global_table.price' - ); - $priceTypeCond = $adapter->getCheckSql( - 'price_store_table.price_type IS NOT NULL', - 'price_store_table.price_type', - 'price_global_table.price_type' - ); - - $select - ->join( - array('price_global_table' => $this->getTable('catalog_product_option_price')), - 'option_table.option_id=price_global_table.option_id' . - ' AND price_global_table.store_id=0', - array( - 'value_id' => $valueIdCond, - 'price' => $priceCond, - 'price_type' => $priceTypeCond - )) - ->joinLeft( - array('price_store_table' => $this->getTable('catalog_product_option_price')), - 'option_table.option_id = price_store_table.option_id' . - ' AND price_store_table.store_id=:store_id', - array() - ); - } - - $query = $adapter->query($select, $bind); - while ($row = $query->fetch()) { - if (!isset($options[$row['option_id']])) { - $options[$row['option_id']] = array( - 'option_id' => $row['option_id'], - 'is_require' => $row['is_require'], - 'type' => $row['type'], - 'values' => array() - ); - } - $options[$row['option_id']]['values'][$row['value_id']] = array( - 'price_type' => $row['price_type'], - 'price_value' => $row['price'] - ); - } - - $select = $adapter->select() - ->from( - array('option_table' => $this->getTable('catalog_product_option')), - array('option_id', 'is_require', 'type') - ) - ->join( - array('type_table' => $this->getTable('catalog_product_option_type_value')), - 'option_table.option_id=type_table.option_id', - array() - ) - ->where('option_table.product_id=:product_id'); - - if ($price->isScopeGlobal()) { - $select->join( - array('price_table' => $this->getTable('catalog_product_option_type_price')), - 'type_table.option_type_id=price_table.option_type_id' . - ' AND price_table.store_id=0', - array('value_id' => 'option_type_id', 'price', 'price_type') - ); - } else { - $select - ->join( - array('price_global_table' => $this->getTable('catalog_product_option_type_price')), - 'type_table.option_type_id=price_global_table.option_type_id' . - ' AND price_global_table.store_id=0', - array( - 'value_id' => $valueIdCond, - 'price' => $priceCond, - 'price_type' => $priceTypeCond - ) - ) - ->joinLeft( - array('price_store_table' => $this->getTable('catalog_product_option_type_price')), - 'type_table.option_type_id=price_store_table.option_type_id' . - ' AND price_store_table.store_id=:store_id', - array() - ); - } - - $query = $adapter->query($select, $bind); - while ($row = $query->fetch()) { - if (!isset($options[$row['option_id']])) { - $options[$row['option_id']] = array( - 'option_id' => $row['option_id'], - 'is_require' => $row['is_require'], - 'type' => $row['type'], - 'values' => array() - ); - } - $options[$row['option_id']]['values'][$row['value_id']] = array( - 'price_type' => $row['price_type'], - 'price_value' => $row['price'] - ); - } - - return $options; - } - - /** - * Calculate custom options price - * Return array with indexes(0 -> min_price, 1 -> max_price) - * - * @param array $options - * @param float $basePrice - * @param float $minPrice - * @param float $maxPrice - * @return array - */ - public function _calculateCustomOptions(array $options, $basePrice, $minPrice, $maxPrice) - { - foreach ($options as $option) { - $optionPrices = array(); - foreach ($option['values'] as $value) { - if ($value['price_type'] == 'percent') { - $valuePrice = $basePrice * $value['price_value'] / 100; - } else { - $valuePrice = $value['price_value']; - } - $optionPrices[] = $valuePrice; - } - if ($option['is_require']) { - $minPrice += min($optionPrices); - } - $multiTypes = array( - Mage_Catalog_Model_Product_Option::OPTION_TYPE_DROP_DOWN, - Mage_Catalog_Model_Product_Option::OPTION_TYPE_CHECKBOX, - Mage_Catalog_Model_Product_Option::OPTION_TYPE_MULTIPLE - ); - if ($optionPrices) { - if (in_array($option['type'], $multiTypes)) { - $maxPrice += array_sum($optionPrices); - } else { - $maxPrice += max($optionPrices); - } - } - } - - return array($minPrice, $maxPrice); - } - - /** - * Calculate minimal and maximal price for bundle selections - * Return array with prices (0 -> min_price, 1 -> max_price) - * - * @param array $options - * @param array $salableStatus - * @param int $productId - * @param int $priceType - * @param float $basePrice - * @param array $priceData - * @param array $priceIndex - * @param Mage_Core_Model_Website $website - * @param Mage_Customer_Model_Group $group - * @return array - */ - public function _calculateBundleSelections(array $options, array $salableStatus, $productId, $priceType, $basePrice, - $priceData, $priceIndex, $website, $group) - { - $minPrice = $maxPrice = $basePrice; - $optPrice = 0; - - foreach ($options as $option) { - $optionPrices = array(); - foreach ($option['selections'] as $selection) { - if (!$selection['product_id']) { - continue; - } - - if (!$salableStatus[$selection['product_id']]) { - continue; - } - - if ($priceType == Mage_Bundle_Model_Product_Price::PRICE_TYPE_FIXED) { - $basePrice = $this->_getBasePrice($productId, $priceData, $website, $group); - } - - // calculate selection price - if ($priceType == Mage_Bundle_Model_Product_Price::PRICE_TYPE_DYNAMIC) { - $priceIndexKey = join('-', array( - $selection['product_id'], - $website->getId(), - $group->getId() - )); - - $selectionPrice = isset($priceIndex[$priceIndexKey]) ? $priceIndex[$priceIndexKey] : 0; - $selectionPrice = $this->_calculateSpecialPrice($selectionPrice, $priceData, $website); - } else { - if ($selection['price_type']) { // percent - $selectionPrice = $basePrice * $selection['price_value'] / 100; - } else { - $selectionPrice = $this->_calculateSpecialPrice($selection['price_value'], - $priceData, $website); - } - } - - // calculate selection qty - if ($selection['can_change_qty'] && $option['type'] != 'multi' && $option['type'] != 'checkbox') { - $qty = 1; - } else { - $qty = $selection['qty']; - } - - $selectionPrice = $selectionPrice * $qty; - $optionPrices[$selection['selection_id']] = $selectionPrice; - } - - if ($optionPrices) { - if ($option['required']) { - $minPrice += min($optionPrices); - } else { - $optPrice = $optPrice && $optPrice < min($optionPrices) ? $optPrice : min($optionPrices); - } - if (in_array($option['type'], array('multi', 'checkbox'))) { - $maxPrice += array_sum($optionPrices); - } else { - $maxPrice += max($optionPrices); - } - } - } - - if ($minPrice == 0) { - $minPrice = $optPrice; - } - return array($minPrice, $maxPrice); - } - - /** - * Apply special price - * - * @param float $finalPrice - * @param array $priceData - * @param Mage_Core_Model_Website $website - * @return float - */ - public function _calculateSpecialPrice($finalPrice, array $priceData, Mage_Core_Model_Website $website) - { - $store = $website->getDefaultStore(); - $specialPrice = $priceData['special_price']; - - if (!is_null($specialPrice) && $specialPrice != false) { - if (Mage::app()->getLocale()->isStoreDateInInterval($store, $priceData['special_from_date'], - $priceData['special_to_date'])) { - $specialPrice = ($finalPrice * $specialPrice) / 100; - $finalPrice = min($finalPrice, $specialPrice); - } - } - - return $finalPrice; - } - - /** - * Retrieve price index for products - * - * @param int|array $productIds - * @param int $websiteId - * @param int $groupId - * @return array - */ - public function loadPriceIndex($productIds, $websiteId, $groupId) - { - $prices = array(); - $adapter = $this->_getReadAdapter(); - $select = $adapter->select() - ->from( - array('pi' => $this->getMainTable()), - array('entity_id', 'min_price', 'max_price') - ) - ->where('entity_id IN(?)', $productIds) - ->where('website_id=:website_id') - ->where('customer_group_id=:group_id'); - $bind = array( - 'website_id' => $websiteId, - 'group_id' => $groupId - ); - $query = $adapter->query($select, $bind); - while ($row = $query->fetch()) { - $prices[$row['entity_id']] = array( - 'min_price' => $row['min_price'], - 'max_price' => $row['max_price'] - ); - } - - return $prices; - } -} diff --git a/app/code/core/Mage/Bundle/data/bundle_setup/data-upgrade-1.6.0.1-1.6.0.0.2.php b/app/code/core/Mage/Bundle/data/bundle_setup/data-upgrade-1.6.0.1-1.6.0.0.2.php deleted file mode 100644 index 41e8265403452..0000000000000 --- a/app/code/core/Mage/Bundle/data/bundle_setup/data-upgrade-1.6.0.1-1.6.0.0.2.php +++ /dev/null @@ -1,43 +0,0 @@ -getEntityTypeId(Mage_Catalog_Model_Product::ENTITY); - -$minimalAttributeSetName = 'Minimal'; -$this->addAttributeSet($entityTypeId, $minimalAttributeSetName); -$setId = $this->getAttributeSetId($entityTypeId, $minimalAttributeSetName); - -foreach ($attributeCodes as $attributeCode) { - $attribute = $this->getAttribute(Mage_Catalog_Model_Product::ENTITY, $attributeCode); - $this->addAttributeToSet($entityTypeId, $setId, $this->getGeneralGroupName(), $attribute['attribute_id']); -} diff --git a/app/code/core/Mage/Bundle/etc/config.xml b/app/code/core/Mage/Bundle/etc/config.xml deleted file mode 100644 index 9aaa24ca19aae..0000000000000 --- a/app/code/core/Mage/Bundle/etc/config.xml +++ /dev/null @@ -1,256 +0,0 @@ - - - - - - 1.6.0.0.2 - true - core - - - - - - - - - - Mage_Bundle - Mage_Catalog_Model_Resource_Setup - - - - - - - - - Mage_Bundle_Model_Product_Type - 1 - - - - - Mage_Bundle_Model_Product_Price - 40 - Mage_Bundle_Model_Resource_Indexer_Price - Mage_Bundle_Model_Resource_Indexer_Stock - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Mage_Bundle_Model_Sales_Order_Pdf_Items_Invoice - - - Mage_Bundle_Model_Sales_Order_Pdf_Items_Shipment - - - Mage_Bundle_Model_Sales_Order_Pdf_Items_Creditmemo - - - - - - - - - Mage_Bundle.csv - - - - - - - - layout.xml - - - - - - - - - - - - - - - - Mage_Bundle_Model_Observer - appendUpsellProducts - - - - - - - Mage_Bundle_Model_Observer - appendBundleSelectionData - - - - - - - Mage_Bundle_Model_Observer - loadProductOptions - - - - - - - Mage_Bundle_Model_Observer - initOptionRenderer - - - - - - - - - - - Mage_Bundle_Adminhtml - - - - - - - - - - - Mage_Bundle.csv - - - - - - - - layout.xml - - - - - - - - - - - - - - - - - Mage_Bundle_Model_Observer - prepareProductSave - - - - - - - Mage_Bundle_Model_Observer - appendBundleSelectionData - - - - - - - Mage_Bundle_Model_Observer - duplicateProduct - - - - - - - Mage_Bundle_Model_Observer - setAttributeTabBlock - - - - - - - Mage_Bundle_Model_Observer - setAttributeTabBlock - - - - - - diff --git a/app/code/core/Mage/Bundle/view/adminhtml/css/bundle-product.css b/app/code/core/Mage/Bundle/view/adminhtml/css/bundle-product.css deleted file mode 100644 index 0ca525c5a2812..0000000000000 --- a/app/code/core/Mage/Bundle/view/adminhtml/css/bundle-product.css +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Bundle - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ - -#bundle_product_container { - padding-bottom: 15px; -} - -#bundle_product_container .entry-edit > fieldset { - margin-bottom: 0; -} - -#bundle_product_container .ui-icon-grip-dotted-vertical { - float: left; -} - -#bundle_product_container .ui-icon-circle-triangle-s, -#bundle_product_container .ui-icon-circle-close { - cursor: pointer; - float: right; - margin-left: 4px; -} - -#bundle_product_container .option-box { - padding: 0; -} - -#bundle_product_container .option-box .entry-edit-head .input-text { - width: 300px; -} - -#bundle_product_container .option-box .option-header .select-product-option-type { - width: 120px; -} - -#bundle_product_container .option-box .entry-edit-head .is-required { - margin-left: 4px; -} - -#bundle_product_container .qty-box { - text-align: center; -} - -#bundle_product_container .option-header .opt-input-type { - width: 130px; -} - -#bundle_product_container .selection .product-sku { - width: 250px; -} - -#add_new_option { - font-size: 18px; -} - -#bundle_product_container .no-products-message { - border: #dadfe0 1px solid; - background: #fff; - margin: 10px 30px 0; - padding: 20px 40px; - text-align: center; - vertical-align: middle; -} diff --git a/app/code/core/Mage/Bundle/view/adminhtml/product/composite/fieldset/options/type/checkbox.phtml b/app/code/core/Mage/Bundle/view/adminhtml/product/composite/fieldset/options/type/checkbox.phtml deleted file mode 100644 index f28bd1912bb64..0000000000000 --- a/app/code/core/Mage/Bundle/view/adminhtml/product/composite/fieldset/options/type/checkbox.phtml +++ /dev/null @@ -1,52 +0,0 @@ - - -getOption(); ?> -getSelections(); ?> -getSkipSaleableCheck(); ?> -
    getRequired()) echo ' class="required"' ?>>getRequired()) echo '*' ?>escapeHtml($_option->getTitle()) ?>
    -getDecoratedIsLast()):?> class="last"> -
    - getRequired()): ?> - getSelectionQtyTitlePrice($_selections[0]) ?> - - -
      - -
    • _isSelected($_selection)) echo ' checked="checked"' ?>isSaleable() && !$_skipSaleableCheck) echo ' disabled="disabled"' ?> value="getSelectionId() ?>" onclick="ProductConfigure.bundleControl.changeSelection(this)" price="getSelectionPrice($_selection) ?>"/> - - getRequired()): ?> - setValidationContainer('bundle-option-'.$_option->getId().'-'.$_selection->getSelectionId(), 'bundle-option-'.$_option->getId().'-container') ?> - -
    • - -
    -
    - -
    - diff --git a/app/code/core/Mage/Bundle/view/adminhtml/product/composite/fieldset/options/type/multi.phtml b/app/code/core/Mage/Bundle/view/adminhtml/product/composite/fieldset/options/type/multi.phtml deleted file mode 100644 index 1e1c58d4ff65d..0000000000000 --- a/app/code/core/Mage/Bundle/view/adminhtml/product/composite/fieldset/options/type/multi.phtml +++ /dev/null @@ -1,49 +0,0 @@ - - -getOption(); ?> -getSelections(); ?> -getSkipSaleableCheck(); ?> -
    getRequired()) echo ' class="required"' ?>>getRequired()) echo '*' ?>escapeHtml($_option->getTitle()) ?>
    -getDecoratedIsLast()):?> class="last"> -
    - getRequired()): ?> - getSelectionQtyTitlePrice($_selections[0]) ?> - - - - -
    - diff --git a/app/code/core/Mage/Bundle/view/adminhtml/product/composite/fieldset/options/type/radio.phtml b/app/code/core/Mage/Bundle/view/adminhtml/product/composite/fieldset/options/type/radio.phtml deleted file mode 100644 index 063964e825db0..0000000000000 --- a/app/code/core/Mage/Bundle/view/adminhtml/product/composite/fieldset/options/type/radio.phtml +++ /dev/null @@ -1,65 +0,0 @@ - - -getOption(); ?> -getSelections(); ?> -getDefaultSelection(); ?> -getSkipSaleableCheck(); ?> -_getDefaultValues(); ?> - -
    - - id="bundle-option-getId() ?>-qty-input" class="input-text qty" type="text" name="bundle_option_qty[getId() ?>]" value=""/> - - getRequired()) echo ' class="required"' ?>>getRequired()) echo '*' ?>escapeHtml($_option->getTitle()) ?> -
    -getDecoratedIsLast()):?> class="last"> -
    - _showSingle()): ?> - getSelectionTitlePrice($_selections[0]) ?> - - -
      - getRequired()): ?> -
    • isSalable())?'':' checked="checked" ' ?> value="" onclick="ProductConfigure.bundleControl.changeSelection(this)"/> - -
    • - - -
    • _isSelected($_selection)) echo ' checked="checked"' ?>isSaleable() && !$_skipSaleableCheck) echo ' disabled="disabled"' ?>value="getSelectionId() ?>" onclick="ProductConfigure.bundleControl.changeSelection(this)" price="getSelectionPrice($_selection) ?>" qtyId="bundle-option-getId() ?>-qty-input"/> - - getRequired()): ?> - setValidationContainer('bundle-option-'.$_option->getId().'-'.$_selection->getSelectionId(), 'bundle-option-'.$_option->getId().'-container') ?> - -
    • - -
    -
    - -
    - diff --git a/app/code/core/Mage/Bundle/view/adminhtml/product/composite/fieldset/options/type/select.phtml b/app/code/core/Mage/Bundle/view/adminhtml/product/composite/fieldset/options/type/select.phtml deleted file mode 100644 index 5a512862d371b..0000000000000 --- a/app/code/core/Mage/Bundle/view/adminhtml/product/composite/fieldset/options/type/select.phtml +++ /dev/null @@ -1,55 +0,0 @@ - - -getOption(); ?> -getSelections(); ?> -getDefaultSelection(); ?> -getSkipSaleableCheck(); ?> -_getDefaultValues(); ?> - -
    - - id="bundle-option-getId() ?>-qty-input" class="input-text qty" type="text" name="bundle_option_qty[getId() ?>]" value=""/> - - getRequired()) echo ' class="required"' ?>>getRequired()) echo '*' ?>escapeHtml($_option->getTitle()) ?> -
    -getDecoratedIsLast()):?> class="last"> -
    - _showSingle()): ?> - getSelectionTitlePrice($_selections[0]) ?> - - - - -
    - diff --git a/app/code/core/Mage/Bundle/view/adminhtml/product/edit/bundle.phtml b/app/code/core/Mage/Bundle/view/adminhtml/product/edit/bundle.phtml deleted file mode 100644 index 807865ffa3bd4..0000000000000 --- a/app/code/core/Mage/Bundle/view/adminhtml/product/edit/bundle.phtml +++ /dev/null @@ -1,87 +0,0 @@ - - - -
    -
    -

    getTabLabel() ?>

    -
    -
    - - - - - -
    -
    - -
    - getOptionsBoxHtml() ?> -
    - -
    getAddButtonHtml() ?>
    -
    -
    - - - - diff --git a/app/code/core/Mage/Bundle/view/adminhtml/product/edit/bundle/option.phtml b/app/code/core/Mage/Bundle/view/adminhtml/product/edit/bundle/option.phtml deleted file mode 100644 index 7295ff398a5a9..0000000000000 --- a/app/code/core/Mage/Bundle/view/adminhtml/product/edit/bundle/option.phtml +++ /dev/null @@ -1,275 +0,0 @@ - - - - -getSelectionHtml() ?> - - diff --git a/app/code/core/Mage/Bundle/view/adminhtml/sales/creditmemo/create/items/renderer.phtml b/app/code/core/Mage/Bundle/view/adminhtml/sales/creditmemo/create/items/renderer.phtml deleted file mode 100644 index 23d71080d79d2..0000000000000 --- a/app/code/core/Mage/Bundle/view/adminhtml/sales/creditmemo/create/items/renderer.phtml +++ /dev/null @@ -1,411 +0,0 @@ - - - -getItem() ?> -getChilds($_item); ?> - - - - - -getOrderOptions() || $_item->getDescription()): ?> - - - - - - - setPriceDataObject($_item) ?> - getSelectionAttributes($_item) ?> - getOrderItem()->getParentItem()): ?> - - -
    -   -   -   -   -   -   -   -   - - - - - > - getOrderItem()->getParentItem()): ?> -
    escapeHtml($_item->getName()) ?>
    -
    - helper('Mage_Sales_Helper_Data')->__('SKU') ?>: - ', Mage::helper('Mage_Catalog_Helper_Data')->splitSku($this->escapeHtml($_item->getSku()))); ?> -
    - - -
    getValueHtml($_item)?>
    - - - canShowPriceInfo($_item)): ?> - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - __('Excl. Tax'); ?>: - - - typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> - displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - - displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> - - - - getApplied($_item)): ?> -
    - typeOfDisplay($_item, 1, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount'], $tax['amount']); ?> - - - typeOfDisplay($_item, 2, 'sales')): ?> - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> - - typeOfDisplay($_item, 4, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> - - - - - typeOfDisplay($_item, 2, 'sales')): ?> -
    - __('Total'); ?>:
    - displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - __('Incl. Tax'); ?>: - - helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item); ?> - helper('Mage_Checkout_Helper_Data')->getBasePriceInclTax($_item); ?> - - typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> - displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?> - - displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?> - - - getApplied($_item)): ?> -
    - typeOfDisplay($_item, 1, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount'], $tax['amount']); ?> - - - typeOfDisplay($_item, 2, 'sales')): ?> - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> - - typeOfDisplay($_item, 4, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> - - - - - typeOfDisplay($_item, 2, 'sales')): ?> -
    - __('Total'); ?>:
    displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?>
    - - -
    - - -   - - - - canShowPriceInfo($_item)): ?> - - - - - - getOrderItem()->getQtyInvoiced()): ?> - - - - - - getOrderItem()->getQtyShipped() && $this->isShipmentSeparately($_item)): ?> - - - - - - getOrderItem()->getQtyRefunded()): ?> - - - - - - getOrderItem()->getQtyCanceled()): ?> - - - - - -
    __('Ordered') ?>getOrderItem()->getQtyOrdered()*1 ?>
    __('Invoiced') ?>getOrderItem()->getQtyInvoiced()*1 ?>
    __('Shipped') ?>getOrderItem()->getQtyShipped()*1 ?>
    __('Refunded') ?>getOrderItem()->getQtyRefunded()*1 ?>
    __('Canceled') ?>getOrderItem()->getQtyCanceled()*1 ?>
    - isShipmentSeparately($_item)): ?> - - - - - - getOrderItem()->getQtyShipped()): ?> - - - - - -
    __('Ordered') ?>getOrderItem()->getQtyOrdered()*1 ?>
    __('Shipped') ?>getOrderItem()->getQtyShipped()*1 ?>
    - -   - - - canParentReturnToStock($_item)) : ?> - - canShowPriceInfo($_item)): ?> - canReturnItemToStock($_item)) : ?> - getBackToStock()):?> checked="checked" /> - - -   - - - - - canShowPriceInfo($_item)): ?> - canEditQty()) : ?> - - - getQty()*1 ?> - - -   - - - - canShowPriceInfo($_item)): ?> - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - __('Excl. Tax'); ?>: - - - typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> - displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - - displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> - - - - getApplied($_item)): ?> - typeOfDisplay($_item, 1, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> - - - typeOfDisplay($_item, 2, 'sales')): ?> - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> - - typeOfDisplay($_item, 4, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> - - - - - typeOfDisplay($_item, 2, 'sales')): ?> -
    - __('Total'); ?>:
    - displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - __('Incl. Tax'); ?>: - - helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item); ?> - helper('Mage_Checkout_Helper_Data')->getBaseSubtotalInclTax($_item); ?> - typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> - displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - - displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?> - - - - getApplied($_item)): ?> - -
    - typeOfDisplay($_item, 1, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> - - - typeOfDisplay($_item, 2, 'sales')): ?> - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> - - typeOfDisplay($_item, 4, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> - - - - - typeOfDisplay($_item, 2, 'sales')): ?> -
    __('Total'); ?>:
    displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
    - - -
    - - - -   - - - - canShowPriceInfo($_item)): ?> - displayPriceAttribute('tax_amount') ?> - -   - - - - canShowPriceInfo($_item)): ?> - displayPriceAttribute('discount_amount') ?> - -   - - - - canShowPriceInfo($_item)): ?> - displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseTaxAmount()-$_item->getBaseDiscountAmount()+$_item->getBaseWeeeTaxAppliedRowAmnt(), - $_item->getRowTotal()+$_item->getTaxAmount()-$_item->getDiscountAmount()+$_item->getWeeeTaxAppliedRowAmount() - ) ?> - -   - - - - - - - - getOrderOptions($_item->getOrderItem())): ?> -
    - getOrderOptions($_item->getOrderItem()) as $option): ?> -
    -
    - - - - truncate($option['value'], 55, '', $_remainder);?> - - ... - - - -
    - -
    - -   - - escapeHtml($_item->getDescription()) ?> - -   -   -   -   -   -   -   -   - - diff --git a/app/code/core/Mage/Bundle/view/adminhtml/sales/creditmemo/view/items/renderer.phtml b/app/code/core/Mage/Bundle/view/adminhtml/sales/creditmemo/view/items/renderer.phtml deleted file mode 100644 index 5d94b8683e931..0000000000000 --- a/app/code/core/Mage/Bundle/view/adminhtml/sales/creditmemo/view/items/renderer.phtml +++ /dev/null @@ -1,341 +0,0 @@ - - - -getItem() ?> -getChilds($_item); ?> - - - - - -getOrderOptions() || $_item->getDescription()): ?> - - - - - - - setPriceDataObject($_item) ?> - getSelectionAttributes($_item) ?> - getOrderItem()->getParentItem()): ?> - - -
    -   -   -   -   -   -   - - - - - > - getOrderItem()->getParentItem()): ?> -
    escapeHtml($_item->getName()) ?>
    -
    - helper('Mage_Sales_Helper_Data')->__('SKU') ?>: - ', Mage::helper('Mage_Catalog_Helper_Data')->splitSku($this->escapeHtml($_item->getSku()))); ?> -
    - - -
    getValueHtml($_item)?>
    - - - canShowPriceInfo($_item)): ?> - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - __('Excl. Tax'); ?>: - - - typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> - displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - - displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> - - - - getApplied($_item)): ?> -
    - typeOfDisplay($_item, 1, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount'], $tax['amount']); ?> - - - typeOfDisplay($_item, 2, 'sales')): ?> - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> - - typeOfDisplay($_item, 4, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> - - - - - typeOfDisplay($_item, 2, 'sales')): ?> -
    - __('Total'); ?>:
    - displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - __('Incl. Tax'); ?>: - - helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item); ?> - helper('Mage_Checkout_Helper_Data')->getBasePriceInclTax($_item); ?> - - typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> - displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?> - - displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?> - - - getApplied($_item)): ?> -
    - typeOfDisplay($_item, 1, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount'], $tax['amount']); ?> - - - typeOfDisplay($_item, 2, 'sales')): ?> - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> - - typeOfDisplay($_item, 4, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> - - - - - typeOfDisplay($_item, 2, 'sales')): ?> -
    - __('Total'); ?>:
    displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?>
    - - -
    - - -   - - - - canShowPriceInfo($_item)): ?> - getQty()*1 ?> - -   - - - - canShowPriceInfo($_item)): ?> - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - __('Excl. Tax'); ?>: - - - typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> - displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - - displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> - - - - getApplied($_item)): ?> - typeOfDisplay($_item, 1, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> - - - typeOfDisplay($_item, 2, 'sales')): ?> - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> - - typeOfDisplay($_item, 4, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> - - - - - typeOfDisplay($_item, 2, 'sales')): ?> -
    - __('Total'); ?>:
    - displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - __('Incl. Tax'); ?>: - - helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item); ?> - helper('Mage_Checkout_Helper_Data')->getBaseSubtotalInclTax($_item); ?> - typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> - displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - - displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?> - - - - getApplied($_item)): ?> - -
    - typeOfDisplay($_item, 1, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> - - - typeOfDisplay($_item, 2, 'sales')): ?> - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> - - typeOfDisplay($_item, 4, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> - - - - - typeOfDisplay($_item, 2, 'sales')): ?> -
    __('Total'); ?>:
    displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
    - - -
    - - - -   - - - - canShowPriceInfo($_item)): ?> - displayPriceAttribute('tax_amount') ?> - -   - - - - canShowPriceInfo($_item)): ?> - displayPriceAttribute('discount_amount') ?> - -   - - - - canShowPriceInfo($_item)): ?> - displayPrices( - $_item->getBaseRowTotal()-$_item->getBaseDiscountAmount()+$_item->getBaseTaxAmount()+$_item->getBaseWeeeTaxAppliedRowAmnt(), - $_item->getRowTotal()-$_item->getDiscountAmount()+$_item->getTaxAmount()+$_item->getWeeeTaxAppliedRowAmount() - ) ?> - -   - - - - - - - - getOrderOptions()): ?> -
    - getOrderOptions() as $option): ?> -
    -
    - - - - truncate($option['value'], 55, '', $_remainder);?> - - ... - - - -
    - -
    - - escapeHtml($this->getItem()->getDescription()) ?> - -   -   -   -   -   -   - - diff --git a/app/code/core/Mage/Bundle/view/adminhtml/sales/invoice/create/items/renderer.phtml b/app/code/core/Mage/Bundle/view/adminhtml/sales/invoice/create/items/renderer.phtml deleted file mode 100644 index 91f9b9510511a..0000000000000 --- a/app/code/core/Mage/Bundle/view/adminhtml/sales/invoice/create/items/renderer.phtml +++ /dev/null @@ -1,398 +0,0 @@ - - - -getItem() ?> -getChilds($_item); ?> - - - - - -getOrderOptions() || $_item->getDescription()): ?> - - - - - - - setPriceDataObject($_item) ?> - getOrderItem()->getParentItem()): ?> - getSelectionAttributes($_item) ?> - - -
    -   -   -   -   -   -   -   - - - - - > - getOrderItem()->getParentItem()): ?> -
    escapeHtml($_item->getName()) ?>
    -
    - helper('Mage_Sales_Helper_Data')->__('SKU') ?>: - ', Mage::helper('Mage_Catalog_Helper_Data')->splitSku($this->escapeHtml($_item->getSku()))); ?> -
    - - -
    getValueHtml($_item)?>
    - - - canShowPriceInfo($_item)): ?> - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - __('Excl. Tax'); ?>: - - - typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> - displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - - displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> - - - - getApplied($_item)): ?> -
    - typeOfDisplay($_item, 1, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount'], $tax['amount']); ?> - - - typeOfDisplay($_item, 2, 'sales')): ?> - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> - - typeOfDisplay($_item, 4, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> - - - - - typeOfDisplay($_item, 2, 'sales')): ?> -
    - __('Total'); ?>:
    - displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - __('Incl. Tax'); ?>: - - helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item); ?> - helper('Mage_Checkout_Helper_Data')->getBasePriceInclTax($_item); ?> - - typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> - displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?> - - displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?> - - - getApplied($_item)): ?> -
    - typeOfDisplay($_item, 1, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount'], $tax['amount']); ?> - - - typeOfDisplay($_item, 2, 'sales')): ?> - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> - - typeOfDisplay($_item, 4, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> - - - - - typeOfDisplay($_item, 2, 'sales')): ?> -
    - __('Total'); ?>:
    displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?>
    - - -
    - - -   - - - - canShowPriceInfo($_item)): ?> - - - - - - getOrderItem()->getQtyInvoiced()): ?> - - - - - - getOrderItem()->getQtyShipped() && $this->isShipmentSeparately($_item)): ?> - - - - - - getOrderItem()->getQtyRefunded()): ?> - - - - - - getOrderItem()->getQtyCanceled()): ?> - - - - - -
    __('Ordered') ?>getOrderItem()->getQtyOrdered()*1 ?>
    __('Invoiced') ?>getOrderItem()->getQtyInvoiced()*1 ?>
    __('Shipped') ?>getOrderItem()->getQtyShipped()*1 ?>
    __('Refunded') ?>getOrderItem()->getQtyRefunded()*1 ?>
    __('Canceled') ?>getOrderItem()->getQtyCanceled()*1 ?>
    - isShipmentSeparately($_item)): ?> - - - - - - getOrderItem()->getQtyShipped()): ?> - - - - - -
    __('Ordered') ?>getOrderItem()->getQtyOrdered()*1 ?>
    __('Shipped') ?>getOrderItem()->getQtyShipped()*1 ?>
    - -   - - - - canShowPriceInfo($_item)): ?> - canEditQty()) : ?> - - - getQty()*1 ?> - - -   - - - - canShowPriceInfo($_item)): ?> - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - __('Excl. Tax'); ?>: - - - typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> - displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - - displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> - - - - getApplied($_item)): ?> - typeOfDisplay($_item, 1, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> - - - typeOfDisplay($_item, 2, 'sales')): ?> - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> - - typeOfDisplay($_item, 4, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> - - - - - typeOfDisplay($_item, 2, 'sales')): ?> -
    - __('Total'); ?>:
    - displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - __('Incl. Tax'); ?>: - - helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item); ?> - helper('Mage_Checkout_Helper_Data')->getBaseSubtotalInclTax($_item); ?> - typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> - displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - - displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?> - - - - getApplied($_item)): ?> - -
    - typeOfDisplay($_item, 1, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> - - - typeOfDisplay($_item, 2, 'sales')): ?> - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> - - typeOfDisplay($_item, 4, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> - - - - - typeOfDisplay($_item, 2, 'sales')): ?> -
    __('Total'); ?>:
    displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
    - - -
    - - - -   - - - - canShowPriceInfo($_item)): ?> - displayPriceAttribute('tax_amount') ?> - -   - - - - canShowPriceInfo($_item)): ?> - displayPriceAttribute('discount_amount') ?> - -   - - - - canShowPriceInfo($_item)): ?> - displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseTaxAmount()-$_item->getBaseDiscountAmount()+$_item->getBaseWeeeTaxAppliedRowAmnt(), - $_item->getRowTotal()+$_item->getTaxAmount()-$_item->getDiscountAmount()+$_item->getWeeeTaxAppliedRowAmount() - ) ?> - -   - - - - - - - - getOrderOptions($_item->getOrderItem())): ?> -
    - getOrderOptions($_item->getOrderItem()) as $option): ?> -
    -
    - - - - truncate($option['value'], 55, '', $_remainder);?> - - ... - - - -
    - -
    - -   - - escapeHtml($_item->getDescription()) ?> - -   -   -   -   -   -   -   - - diff --git a/app/code/core/Mage/Bundle/view/adminhtml/sales/invoice/view/items/renderer.phtml b/app/code/core/Mage/Bundle/view/adminhtml/sales/invoice/view/items/renderer.phtml deleted file mode 100644 index 154ef92374f5a..0000000000000 --- a/app/code/core/Mage/Bundle/view/adminhtml/sales/invoice/view/items/renderer.phtml +++ /dev/null @@ -1,340 +0,0 @@ - - - -getItem() ?> -getChilds($_item); ?> - - - - - -getOrderOptions() || $_item->getDescription()): ?> - - - - - - - setPriceDataObject($_item) ?> - getOrderItem()->getParentItem()): ?> - getSelectionAttributes($_item) ?> - - -
    -   -   -   -   -   -   - - - - - > - getOrderItem()->getParentItem()): ?> -
    escapeHtml($_item->getName()) ?>
    -
    - helper('Mage_Sales_Helper_Data')->__('SKU') ?>: - ', Mage::helper('Mage_Catalog_Helper_Data')->splitSku($this->escapeHtml($_item->getSku()))); ?> -
    - -
    getValueHtml($_item)?>
    - - - canShowPriceInfo($_item)): ?> - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - __('Excl. Tax'); ?>: - - - typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> - displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - - displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> - - - - getApplied($_item)): ?> -
    - typeOfDisplay($_item, 1, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount'], $tax['amount']); ?> - - - typeOfDisplay($_item, 2, 'sales')): ?> - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> - - typeOfDisplay($_item, 4, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> - - - - - typeOfDisplay($_item, 2, 'sales')): ?> -
    - __('Total'); ?>:
    - displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - __('Incl. Tax'); ?>: - - helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item); ?> - helper('Mage_Checkout_Helper_Data')->getBasePriceInclTax($_item); ?> - - typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> - displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?> - - displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?> - - - getApplied($_item)): ?> -
    - typeOfDisplay($_item, 1, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount'], $tax['amount']); ?> - - - typeOfDisplay($_item, 2, 'sales')): ?> - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> - - typeOfDisplay($_item, 4, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> - - - - - typeOfDisplay($_item, 2, 'sales')): ?> -
    - __('Total'); ?>:
    displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?>
    - - -
    - - -   - - - - canShowPriceInfo($_item)): ?> - getQty()*1 ?> - -   - - - - canShowPriceInfo($_item)): ?> - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - __('Excl. Tax'); ?>: - - - typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> - displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - - displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> - - - - getApplied($_item)): ?> - typeOfDisplay($_item, 1, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> - - - typeOfDisplay($_item, 2, 'sales')): ?> - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> - - typeOfDisplay($_item, 4, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> - - - - - typeOfDisplay($_item, 2, 'sales')): ?> -
    - __('Total'); ?>:
    - displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - __('Incl. Tax'); ?>: - - helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item); ?> - helper('Mage_Checkout_Helper_Data')->getBaseSubtotalInclTax($_item); ?> - typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> - displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - - displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?> - - - - getApplied($_item)): ?> - -
    - typeOfDisplay($_item, 1, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> - - - typeOfDisplay($_item, 2, 'sales')): ?> - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> - - typeOfDisplay($_item, 4, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> - - - - - typeOfDisplay($_item, 2, 'sales')): ?> -
    __('Total'); ?>:
    displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
    - - -
    - - - -   - - - - canShowPriceInfo($_item)): ?> - displayPriceAttribute('tax_amount') ?> - -   - - - - canShowPriceInfo($_item)): ?> - displayPriceAttribute('discount_amount') ?> - -   - - - - canShowPriceInfo($_item)): ?> - displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseTaxAmount()-$_item->getBaseDiscountAmount()+$_item->getBaseWeeeTaxAppliedRowAmnt(), - $_item->getRowTotal()+$_item->getTaxAmount()-$_item->getDiscountAmount()+$_item->getWeeeTaxAppliedRowAmount() - ) ?> - -   - - - - - - - - getOrderOptions()): ?> -
    - getOrderOptions() as $option): ?> -
    -
    - - - - truncate($option['value'], 55, '', $_remainder);?> - - ... - - - -
    - -
    - - escapeHtml($this->getItem()->getDescription()) ?> - -   -   -   -   -   -   - - diff --git a/app/code/core/Mage/Bundle/view/adminhtml/sales/order/view/items/renderer.phtml b/app/code/core/Mage/Bundle/view/adminhtml/sales/order/view/items/renderer.phtml deleted file mode 100644 index 6168aa0ddf77b..0000000000000 --- a/app/code/core/Mage/Bundle/view/adminhtml/sales/order/view/items/renderer.phtml +++ /dev/null @@ -1,415 +0,0 @@ - - - -getItem() ?> -getChildrenItems()); ?> - - - - - -getOrderOptions() || $_item->getDescription() || $this->canDisplayGiftmessage()): ?> - - - - - - - setPriceDataObject($_item) ?> - getSelectionAttributes($_item) ?> - getParentItem()): ?> - - -
    -   -   -   -   -   -   -   -   -   - - - - - > - getParentItem()): ?> - -
    - escapeHtml($_item->getName()) ?> -
    -
    - helper('Mage_Sales_Helper_Data')->__('SKU') ?>: - ', Mage::helper('Mage_Catalog_Helper_Data')->splitSku($this->escapeHtml($_item->getSku()))); ?> -
    - - -
    getValueHtml($_item)?>
    - - - canShowPriceInfo($_item)): ?> - getStatus() ?> - -   - - - - canShowPriceInfo($_item)): ?> - displayPriceAttribute('original_price') ?> - -   - - - - canShowPriceInfo($_item)): ?> - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - __('Excl. Tax'); ?>: - - - typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> - displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - - displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> - - - - getApplied($_item)): ?> -
    - typeOfDisplay($_item, 1, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount'], $tax['amount']); ?> - - - typeOfDisplay($_item, 2, 'sales')): ?> - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> - - typeOfDisplay($_item, 4, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> - - - - - typeOfDisplay($_item, 2, 'sales')): ?> -
    - __('Total'); ?>:
    - displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - __('Incl. Tax'); ?>: - - helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item); ?> - helper('Mage_Checkout_Helper_Data')->getBasePriceInclTax($_item); ?> - - typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> - displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?> - - displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?> - - - getApplied($_item)): ?> -
    - typeOfDisplay($_item, 1, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount'], $tax['amount']); ?> - - - typeOfDisplay($_item, 2, 'sales')): ?> - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> - - typeOfDisplay($_item, 4, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?> - - - - - typeOfDisplay($_item, 2, 'sales')): ?> -
    - __('Total'); ?>:
    displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?>
    - - -
    - - -   - - - - canShowPriceInfo($_item)): ?> - - - - - - getQtyInvoiced()): ?> - - - - - - getQtyShipped() && $this->isShipmentSeparately($_item)): ?> - - - - - - getQtyRefunded()): ?> - - - - - - getQtyCanceled()): ?> - - - - - -
    __('Ordered') ?>getQtyOrdered()*1 ?>
    __('Invoiced') ?>getQtyInvoiced()*1 ?>
    __('Shipped') ?>getQtyShipped()*1 ?>
    __('Refunded') ?>getQtyRefunded()*1 ?>
    __('Canceled') ?>getQtyCanceled()*1 ?>
    - isShipmentSeparately($_item)): ?> - - - - - - getQtyShipped()): ?> - - - - - -
    __('Ordered') ?>getQtyOrdered()*1 ?>
    __('Shipped') ?>getQtyShipped()*1 ?>
    - -   - - - - canShowPriceInfo($_item)): ?> - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - __('Excl. Tax'); ?>: - - - typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> - displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - - displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> - - - - getApplied($_item)): ?> - typeOfDisplay($_item, 1, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> - - - typeOfDisplay($_item, 2, 'sales')): ?> - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> - - typeOfDisplay($_item, 4, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> - - - - - typeOfDisplay($_item, 2, 'sales')): ?> -
    - __('Total'); ?>:
    - displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - __('Incl. Tax'); ?>: - - helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item); ?> - helper('Mage_Checkout_Helper_Data')->getBaseSubtotalInclTax($_item); ?> - typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> - displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - - displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?> - - - - getApplied($_item)): ?> - -
    - typeOfDisplay($_item, 1, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> - - - typeOfDisplay($_item, 2, 'sales')): ?> - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> - - typeOfDisplay($_item, 4, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> - - - - - typeOfDisplay($_item, 2, 'sales')): ?> -
    __('Total'); ?>:
    displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
    - - -
    - - -   - - - - canShowPriceInfo($_item)): ?> - displayPriceAttribute('tax_amount') ?> - -   - - - - - canShowPriceInfo($_item)): ?> - displayTaxPercent($_item) ?> - -   - - - - canShowPriceInfo($_item)): ?> - displayPriceAttribute('discount_amount') ?> - -   - - - - canShowPriceInfo($_item)): ?> - displayPrices( - max(0, $_item->getBaseRowTotal() - $_item->getBaseDiscountAmount() + $_item->getBaseTaxAmount() + $_item->getBaseWeeeTaxAppliedRowAmnt()), - max(0, $_item->getRowTotal() - $_item->getDiscountAmount() + $_item->getTaxAmount() + $_item->getWeeeTaxAppliedRowAmount()) - ); ?> - -   - - - - - - canDisplayGiftmessage()) echo ' class="border"' ?>> - - getOrderOptions()): ?> -
    - getOrderOptions() as $option): ?> -
    :
    -
    - - - - truncate($option['value'], 55, '', $_remainder);?> - - ... - - - -
    - -
    - -   - - escapeHtml($_item->getDescription()) ?> - -   -   -   -   -   -   -   -   -   - - diff --git a/app/code/core/Mage/Bundle/view/adminhtml/sales/shipment/create/items/renderer.phtml b/app/code/core/Mage/Bundle/view/adminhtml/sales/shipment/create/items/renderer.phtml deleted file mode 100644 index 075ddcc2cc477..0000000000000 --- a/app/code/core/Mage/Bundle/view/adminhtml/sales/shipment/create/items/renderer.phtml +++ /dev/null @@ -1,118 +0,0 @@ - - - -getItem() ?> -getChilds($_item); ?> - - - - - -getOrderOptions() || $_item->getDescription()): ?> - - - - - - - setPriceDataObject($_item) ?> - getOrderItem()->getParentItem()): ?> - getSelectionAttributes($_item) ?> - - -
    -   -   - - - - - - getOrderItem()->getParentItem()): ?> -
    escapeHtml($_item->getName()) ?>
    -
    - helper('Mage_Sales_Helper_Data')->__('SKU') ?>: - ', Mage::helper('Mage_Catalog_Helper_Data')->splitSku($this->escapeHtml($_item->getSku()))); ?> -
    - - -
    getValueHtml($_item)?>
    - - - isShipmentSeparately($_item)): ?> - getColumnHtml($_item, 'qty') ?> - -   - - - - isShipmentSeparately($_item)): ?> - - -   - - - - - - - - getOrderOptions($_item->getOrderItem())): ?> -
    - getOrderOptions($_item->getOrderItem()) as $option): ?> -
    -
    - - - - truncate($option['value'], 55, '', $_remainder);?> - - ... - - - -
    - -
    - -   - - escapeHtml($_item->getDescription()) ?> - -   -   - - diff --git a/app/code/core/Mage/Bundle/view/adminhtml/sales/shipment/view/items/renderer.phtml b/app/code/core/Mage/Bundle/view/adminhtml/sales/shipment/view/items/renderer.phtml deleted file mode 100644 index 0f57a74de360a..0000000000000 --- a/app/code/core/Mage/Bundle/view/adminhtml/sales/shipment/view/items/renderer.phtml +++ /dev/null @@ -1,115 +0,0 @@ - - - -getItem() ?> -getOrderItem()), $_item->getOrderItem()->getChildrenItems()) ?> -getChilds($_item) ?> - - - - - -getOrderOptions() || $_item->getDescription()): ?> - - - - - - - setPriceDataObject($_item) ?> - getParentItem()): ?> - getSelectionAttributes($_item) ?> - - -
    -   - - - - - > - getParentItem()): ?> - -
    escapeHtml($_item->getName()) ?>
    -
    - helper('Mage_Sales_Helper_Data')->__('SKU') ?>: - ', Mage::helper('Mage_Catalog_Helper_Data')->splitSku($this->escapeHtml($_item->getSku()))); ?> -
    - - -
    getValueHtml($_item)?>
    - - - isShipmentSeparately() && $_item->getParentItem()) || (!$this->isShipmentSeparately() && !$_item->getParentItem())): ?> - getId()])): ?> - getId()]->getQty()*1 ?> - getIsVirtual()): ?> - __('N/A') ?> - - 0 - - -   - - - - - - - - getOrderOptions($_item->getOrderItem())): ?> -
    - getOrderOptions($_item->getOrderItem()) as $option): ?> -
    -
    - - - - truncate($option['value'], 55, '', $_remainder);?> - - ... - - - -
    - -
    - - escapeHtml($_item->getDescription()) ?> - -   - - diff --git a/app/code/core/Mage/Bundle/view/frontend/catalog/product/view/type/bundle.phtml b/app/code/core/Mage/Bundle/view/frontend/catalog/product/view/type/bundle.phtml deleted file mode 100644 index d95356056a997..0000000000000 --- a/app/code/core/Mage/Bundle/view/frontend/catalog/product/view/type/bundle.phtml +++ /dev/null @@ -1,59 +0,0 @@ - -getProduct() ?> - -isSaleable()): ?> - - -displayProductStockStatus()): ?> - isAvailable()): ?> -

    helper('Mage_Catalog_Helper_Data')->__('Availability:') ?> helper('Mage_Catalog_Helper_Data')->__('In stock') ?>

    - -

    helper('Mage_Catalog_Helper_Data')->__('Availability:') ?> helper('Mage_Catalog_Helper_Data')->__('Out of stock') ?>

    - - -
    - getPriceHtml($_product) ?> -
    -getChildHtml('bundle_prices') ?> diff --git a/app/code/core/Mage/Bundle/view/frontend/catalog/product/view/type/bundle/option/checkbox.phtml b/app/code/core/Mage/Bundle/view/frontend/catalog/product/view/type/bundle/option/checkbox.phtml deleted file mode 100644 index bf8793f1b5863..0000000000000 --- a/app/code/core/Mage/Bundle/view/frontend/catalog/product/view/type/bundle/option/checkbox.phtml +++ /dev/null @@ -1,49 +0,0 @@ - - - -getOption() ?> -getSelections() ?> -
    getRequired()) echo ' class="required"' ?>>escapeHtml($_option->getTitle()) ?>getRequired()) echo '*' ?>
    -getDecoratedIsLast()):?> class="last"> -
    - getRequired()): ?> - getSelectionQtyTitlePrice($_selections[0]) ?> - - -
      - -
    • getRequired()) echo 'data-validate = {"validate-one-required-by-name":true}'?> name="bundle_option[getId() ?>][]"_isSelected($_selection)) echo ' checked="checked"' ?>isSaleable()) echo ' disabled="disabled"' ?> value="getSelectionId() ?>"/> - -
    • - -
    -
    - -
    - diff --git a/app/code/core/Mage/Bundle/view/frontend/catalog/product/view/type/bundle/option/multi.phtml b/app/code/core/Mage/Bundle/view/frontend/catalog/product/view/type/bundle/option/multi.phtml deleted file mode 100644 index da4ceecf84bf4..0000000000000 --- a/app/code/core/Mage/Bundle/view/frontend/catalog/product/view/type/bundle/option/multi.phtml +++ /dev/null @@ -1,49 +0,0 @@ - - - -getOption() ?> -getSelections() ?> -
    getRequired()) echo ' class="required"' ?>>escapeHtml($_option->getTitle()) ?>getRequired()) echo '*' ?>
    -getDecoratedIsLast()):?> class="last"> -
    - getRequired()): ?> - getSelectionQtyTitlePrice($_selections[0]) ?> - - - - -
    - diff --git a/app/code/core/Mage/Bundle/view/frontend/catalog/product/view/type/bundle/option/radio.phtml b/app/code/core/Mage/Bundle/view/frontend/catalog/product/view/type/bundle/option/radio.phtml deleted file mode 100644 index b8109820a4360..0000000000000 --- a/app/code/core/Mage/Bundle/view/frontend/catalog/product/view/type/bundle/option/radio.phtml +++ /dev/null @@ -1,62 +0,0 @@ - - - -getOption(); ?> -getSelections(); ?> -getDefaultSelection(); ?> -_getDefaultValues(); ?> - -
    - getRequired()) echo ' class="required"' ?>>escapeHtml($_option->getTitle()) ?>getRequired()) echo '*' ?> -
    -getDecoratedIsLast()):?> class="last"> -
    - _showSingle()): ?> - getSelectionTitlePrice($_selections[0]) ?> - - -
      - getRequired()): ?> -
    • isSalable())?'':' checked="checked" ' ?> value=""/> - -
    • - - -
    • getRequired()) echo 'data-validate = {"validate-one-required-by-name":true}'?> name="bundle_option[getId() ?>]"_isSelected($_selection)) echo ' checked="checked"' ?>isSaleable()) echo ' disabled="disabled"' ?>value="getSelectionId() ?>"/> - -
    • - -
    -
    - -
    - - id="bundle-option-getId() ?>-qty-input" class="input-text qty" type="text" name="bundle_option_qty[getId() ?>]" value=""/> - - diff --git a/app/code/core/Mage/Bundle/view/frontend/catalog/product/view/type/bundle/option/select.phtml b/app/code/core/Mage/Bundle/view/frontend/catalog/product/view/type/bundle/option/select.phtml deleted file mode 100644 index 2de84a1695812..0000000000000 --- a/app/code/core/Mage/Bundle/view/frontend/catalog/product/view/type/bundle/option/select.phtml +++ /dev/null @@ -1,55 +0,0 @@ - - - -getOption(); ?> -getSelections(); ?> -getDefaultSelection(); ?> -_getDefaultValues(); ?> - -
    - getRequired()) echo ' class="required"' ?>>escapeHtml($_option->getTitle()) ?>getRequired()) echo '*' ?> -
    -getDecoratedIsLast()):?> class="last"> -
    - _showSingle()): ?> - getSelectionTitlePrice($_selections[0]) ?> - - - - -
    - - id="bundle-option-getId() ?>-qty-input" class="input-text qty" type="text" name="bundle_option_qty[getId() ?>]" value=""/> - - diff --git a/app/code/core/Mage/Bundle/view/frontend/sales/order/creditmemo/items/renderer.phtml b/app/code/core/Mage/Bundle/view/frontend/sales/order/creditmemo/items/renderer.phtml deleted file mode 100644 index 89da8eee76da1..0000000000000 --- a/app/code/core/Mage/Bundle/view/frontend/sales/order/creditmemo/items/renderer.phtml +++ /dev/null @@ -1,328 +0,0 @@ - -getItem() ?> - -getChilds($parentItem) ?> -getItem()->getOrderItem()->getOrder() ?> - - - - - - - -getItemOptions() || $parentItem->getDescription() || $this->helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $parentItem) && $parentItem->getGiftMessageId()): ?> - - - - - -getOrderItem()->getParentItem()): ?> - getSelectionAttributes($_item) ?> - - -
    -   -   -   -   -   -   - - - - - id="order-item-row-getId() ?>"> - getOrderItem()->getParentItem()): ?> -

    escapeHtml($_item->getName()) ?>

    - - -
    getValueHtml($_item) ?>
    - - escapeHtml($_item->getSku()) ?> - - canShowPriceInfo($_item)): ?> - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Excl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> - - getOrder()->formatPrice($this->getItem()->getPrice()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?>
    -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Incl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - helper('Mage_Checkout_Helper_Data')->getPriceInclTax($this->getItem()); ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> - - getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - __('Total Incl. Tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?>
    -
    - - -
    - - -   - - - - canShowPriceInfo($_item)): ?> - getQty()*1 ?> - -   - - - - canShowPriceInfo($_item)): ?> - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Excl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> - - getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?>
    -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Incl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - getOrder()->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)); ?> - - - -   - - -   - - - - canShowPriceInfo($_item)): ?> - getOrder()->formatPrice(-$_item->getDiscountAmount()) ?> - -   - - - - canShowPriceInfo($_item)): ?> - getOrder()->formatPrice($_item->getRowTotal()-$_item->getDiscountAmount()+$_item->getTaxAmount()+$_item->getWeeeTaxAppliedRowAmount()) ?> - -   - - - - - - - - - getItemOptions()): ?> -
    - -
    escapeHtml($_option['label']) ?>
    - getPrintStatus()): ?> - getFormatedOptionValue($_option) ?> - class="truncated"> - - -
    -
    -
    escapeHtml($_option['label']) ?>
    -
    -
    -
    - - - -
    escapeHtml( (isset($_option['print_value']) ? $_option['print_value'] : $_option['value']) ) ?>
    - - -
    - - escapeHtml($_item->getDescription()) ?> - helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $parentItem) && $parentItem->getGiftMessageId()): ?> - __('Gift Message') ?> - - -   -   -   -   -   -   - - diff --git a/app/code/core/Mage/Bundle/view/frontend/sales/order/invoice/items/renderer.phtml b/app/code/core/Mage/Bundle/view/frontend/sales/order/invoice/items/renderer.phtml deleted file mode 100644 index 2e9aa7a507f45..0000000000000 --- a/app/code/core/Mage/Bundle/view/frontend/sales/order/invoice/items/renderer.phtml +++ /dev/null @@ -1,352 +0,0 @@ - -getItem() ?> -getItem()->getOrderItem()->getOrder() ?> - -getChilds($parentItem) ?> - - - - - - - -getItemOptions() || $parentItem->getDescription() || $this->helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $parentItem) && $parentItem->getGiftMessageId()): ?> - - - - - -getOrderItem()->getParentItem()): ?> - getSelectionAttributes($_item) ?> - - -
    -   -   -   -   - - - - - id="order-item-row-getId() ?>"> - getOrderItem()->getParentItem()): ?> -

    escapeHtml($_item->getName()) ?>

    - -
    getValueHtml($_item) ?>
    - - escapeHtml($_item->getSku()) ?> - - canShowPriceInfo($_item)): ?> - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Excl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> - - getOrder()->formatPrice($this->getItem()->getPrice()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?>
    -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Incl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - helper('Mage_Checkout_Helper_Data')->getPriceInclTax($this->getItem()); ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> - - getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?>
    -
    - - -
    - - -   - - - - canShowPriceInfo($_item)): ?> - getQty()*1 ?> - -   - - - - canShowPriceInfo($_item)): ?> - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Excl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> - - getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?>
    -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Incl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($this->getItem()); ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?> - - getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxRowDisposition()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?>
    -
    - - - - - -
    - - -   - - - - - - - - - getItemOptions()): ?> -
    - -
    escapeHtml($_option['label']) ?>
    - getPrintStatus()): ?> - getFormatedOptionValue($_option) ?> - class="truncated"> - - -
    -
    -
    escapeHtml($_option['label']) ?>
    -
    -
    -
    - - - -
    escapeHtml( (isset($_option['print_value']) ? $_option['print_value'] : $_option['value']) ) ?>
    - - -
    - - escapeHtml($_item->getDescription()) ?> - helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $parentItem) && $parentItem->getGiftMessageId()): ?> - __('Gift Message') ?> - - -   -   -   -   - - diff --git a/app/code/core/Mage/Bundle/view/frontend/sales/order/items/renderer.phtml b/app/code/core/Mage/Bundle/view/frontend/sales/order/items/renderer.phtml deleted file mode 100644 index c2a8461bba75f..0000000000000 --- a/app/code/core/Mage/Bundle/view/frontend/sales/order/items/renderer.phtml +++ /dev/null @@ -1,375 +0,0 @@ - -getItem() ?> -getChildrenItems()); ?> - - - - - - - -getItemOptions() || $parentItem->getDescription() || $this->helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $parentItem) && $parentItem->getGiftMessageId()): ?> - - - - - -getParentItem()): ?> - getSelectionAttributes($_item) ?> - - getLastRow()) echo 'class="last"'; ?>> -
    -   -   -   -   - - - - - id="order-item-row-getId() ?>"> - - getParentItem()): ?> -

    escapeHtml($_item->getName()) ?>

    - -
    getValueHtml($_item)?>
    - - escapeHtml(Mage::helper('Mage_Core_Helper_String')->splitInjection($_item->getSku())) ?> - - getParentItem()): ?> - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Excl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> - - getOrder()->formatPrice($this->getItem()->getPrice()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?>
    -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Incl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - helper('Mage_Checkout_Helper_Data')->getPriceInclTax($this->getItem()); ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> - - getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?>
    -
    - - -
    - - -   - - - - getParentItem() && $this->isChildCalculated()) || - (!$_item->getParentItem() && !$this->isChildCalculated())): ?> - - getQtyOrdered() > 0): ?> - __('Ordered'); ?>: getQtyOrdered()*1 ?>
    - - getQtyShipped() > 0 && !$this->isShipmentSeparately()): ?> - __('Shipped'); ?>: getQtyShipped()*1 ?>
    - - getQtyCanceled() > 0): ?> - __('Canceled'); ?>: getQtyCanceled()*1 ?>
    - - getQtyRefunded() > 0): ?> - __('Refunded'); ?>: getQtyRefunded()*1 ?> - -
    - getQtyShipped() > 0 && $_item->getParentItem() && $this->isShipmentSeparately()): ?> - __('Shipped'); ?>: getQtyShipped()*1 ?> - -   - - - - getParentItem()): ?> - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Excl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> - - getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?>
    -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Incl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($this->getItem()); ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?> - - getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxRowDisposition()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - __('Total Incl. Tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?>
    -
    - - - - - -
    - - -   - - - - - - - - - - getItemOptions()): ?> -
    - -
    escapeHtml($_option['label']) ?>
    - getPrintStatus()): ?> - getFormatedOptionValue($_option) ?> - class="truncated"> - - -
    -
    -
    escapeHtml($_option['label']) ?>
    -
    -
    -
    - - - -
    escapeHtml( (isset($_option['print_value']) ? $_option['print_value'] : $_option['value']) ) ?>
    - - -
    - - escapeHtml($_item->getDescription()) ?> - helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $parentItem) && $parentItem->getGiftMessageId()): ?> - __('Gift Message') ?> - - -   -   -   -   - - diff --git a/app/code/core/Mage/Bundle/view/frontend/sales/order/shipment/items/renderer.phtml b/app/code/core/Mage/Bundle/view/frontend/sales/order/shipment/items/renderer.phtml deleted file mode 100644 index 9d3d3433b6e3e..0000000000000 --- a/app/code/core/Mage/Bundle/view/frontend/sales/order/shipment/items/renderer.phtml +++ /dev/null @@ -1,111 +0,0 @@ - -getItem() ?> -getOrderItem()), $parentItem->getOrderItem()->getChildrenItems()) ?> -getChilds($parentItem) ?> - - - - - - - -getItemOptions() || $parentItem->getDescription() || $this->helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $parentItem) && $parentItem->getGiftMessageId()): ?> - - - - - -getParentItem()): ?> - getSelectionAttributes($_item) ?> - - -
    -   -   - - - - - id="order-item-row-getId() ?>"> - getParentItem()): ?> -

    escapeHtml($_item->getName()) ?>

    - -
    getValueHtml($_item) ?>
    - - escapeHtml($_item->getSku()) ?> - - isShipmentSeparately() && $_item->getParentItem()) || (!$this->isShipmentSeparately() && !$_item->getParentItem())): ?> - getId()])): ?> - getId()]->getQty()*1 ?> - getIsVirtual()): ?> - __('N/A') ?> - - 0 - - -   - - - - - - - - - getItemOptions()): ?> -
    - -
    escapeHtml($_option['label']) ?>
    - getPrintStatus()): ?> - getFormatedOptionValue($_option) ?> - class="truncated"> - - -
    -
    -
    escapeHtml($_option['label']) ?>
    -
    -
    -
    - - - -
    escapeHtml( (isset($_option['print_value']) ? $_option['print_value'] : $_option['value']) ) ?>
    - - -
    - - escapeHtml($_item->getDescription()) ?> - helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $parentItem) && $parentItem->getGiftMessageId()): ?> - __('Gift Message') ?> - - -   -   - - diff --git a/app/code/core/Mage/Captcha/Helper/Data.php b/app/code/core/Mage/Captcha/Helper/Data.php deleted file mode 100755 index 875388ed137b8..0000000000000 --- a/app/code/core/Mage/Captcha/Helper/Data.php +++ /dev/null @@ -1,198 +0,0 @@ - - */ -class Mage_Captcha_Helper_Data extends Mage_Core_Helper_Abstract -{ - /** - * Used for "name" attribute of captcha's input field - */ - const INPUT_NAME_FIELD_VALUE = 'captcha'; - - /** - * Always show captcha - */ - const MODE_ALWAYS = 'always'; - - /** - * Show captcha only after certain number of unsuccessful attempts - */ - const MODE_AFTER_FAIL = 'after_fail'; - - /** - * Captcha fonts path - */ - const XML_PATH_CAPTCHA_FONTS = 'default/captcha/fonts'; - - /** - * Default captcha type - */ - const DEFAULT_CAPTCHA_TYPE = 'Zend'; - - /** - * List uses Models of Captcha - * @var array - */ - protected $_captcha = array(); - - /** - * @var Mage_Core_Model_Config - */ - protected $_config; - - /** - * @var Magento_Filesystem - */ - protected $_filesystem; - - /** - * @var Mage_Core_Model_Dir - */ - protected $_dirs = null; - - /** - * @var Mage_Core_Model_App - */ - protected $_app; - - /** - * @param Mage_Core_Model_Dir $dirs - * @param Mage_Core_Model_App $app - * @param Mage_Core_Model_Config $config - * @param Magento_Filesystem $filesystem - * @param Mage_Core_Model_Translate $translator - */ - public function __construct( - Mage_Core_Model_Dir $dirs, - Mage_Core_Model_App $app, - Mage_Core_Model_Config $config, - Magento_Filesystem $filesystem, - Mage_Core_Model_Translate $translator - ) { - - $this->_dirs = $dirs; - $this->_app = $app; - $this->_config = $config; - $this->_filesystem = $filesystem; - parent::__construct($translator); - } - - /** - * Get Captcha - * - * @param string $formId - * @return Mage_Captcha_Model_Interface - */ - public function getCaptcha($formId) - { - if (!array_key_exists($formId, $this->_captcha)) { - $type = ucfirst($this->getConfigNode('type')); - if (!$type) { - $type = self::DEFAULT_CAPTCHA_TYPE; - } - $this->_captcha[$formId] = $this->_config->getModelInstance( - 'Mage_Captcha_Model_' . $type, - array( - 'params' => array('formId' => $formId, 'helper' => $this) - ) - ); - } - return $this->_captcha[$formId]; - } - - /** - * Returns value of the node with respect to current area (frontend or backend) - * - * @param string $id The last part of XML_PATH_$area_CAPTCHA_ constant (case insensitive) - * @param Mage_Core_Model_Store $store - * @return Mage_Core_Model_Config_Element - */ - public function getConfigNode($id, $store = null) - { - $store = $this->_app->getStore($store); - $areaCode = $store->isAdmin() ? 'admin' : 'customer'; - return $store->getConfig($areaCode . '/captcha/' . $id); - } - - /** - * Get list of available fonts. - * - * Return format: - * [['arial'] => ['label' => 'Arial', 'path' => '/www/magento/fonts/arial.ttf']] - * - * @return array - */ - public function getFonts() - { - $node = $this->_config->getNode(Mage_Captcha_Helper_Data::XML_PATH_CAPTCHA_FONTS); - $fonts = array(); - if ($node) { - $libDir = $this->_dirs->getDir(Mage_Core_Model_Dir::LIB); - foreach ($node->children() as $fontName => $fontNode) { - $fonts[$fontName] = array( - 'label' => (string)$fontNode->label, - 'path' => $libDir . DIRECTORY_SEPARATOR . $fontNode->path - ); - } - } - return $fonts; - } - - /** - * Get captcha image directory - * - * @param mixed $website - * @return string - */ - public function getImgDir($website = null) - { - $mediaDir = $this->_dirs->getDir(Mage_Core_Model_Dir::MEDIA); - $captchaDir = Magento_Filesystem::getPathFromArray(array($mediaDir, 'captcha', - $this->_app->getWebsite($website)->getCode())); - $this->_filesystem->setWorkingDirectory($mediaDir); - $this->_filesystem->setIsAllowCreateDirectories(true); - $this->_filesystem->ensureDirectoryExists($captchaDir, 0755); - return $captchaDir . Magento_Filesystem::DIRECTORY_SEPARATOR; - } - - /** - * Get captcha image base URL - * - * @param mixed $website - * @return string - */ - public function getImgUrl($website = null) - { - return $this->_app->getStore()->getBaseUrl(Mage_Core_Model_Dir::MEDIA) . 'captcha' - . '/' . $this->_app->getWebsite($website)->getCode() . '/'; - } -} diff --git a/app/code/core/Mage/Captcha/etc/config.xml b/app/code/core/Mage/Captcha/etc/config.xml deleted file mode 100755 index b6df2889aca4a..0000000000000 --- a/app/code/core/Mage/Captcha/etc/config.xml +++ /dev/null @@ -1,284 +0,0 @@ - - - - - - 1.7.0.0.0 - true - core - - - - - - - - - - - - Mage_Captcha - - - - - - - - Mage_Captcha_Model_Observer - checkUserLogin - - - - - - - Mage_Captcha_Model_Observer - checkUserCreate - - - - - - - Mage_Captcha_Model_Observer - checkUserLoginBackend - - - - - - - Mage_Captcha_Model_Observer - checkGuestCheckout - - - Mage_Captcha_Model_Observer - checkRegisterCheckout - - - - - - - Mage_Captcha_Model_Observer - resetAttemptForFrontend - - - - - - - Mage_Captcha_Model_Observer - resetAttemptForBackend - - - - - - - - - standard - - Mage_Captcha - captcha - - - - - - - layout.xml - - - - - - - - Mage_Captcha.csv - - - - - - - - - - - Mage_Captcha_Adminhtml - - - - - - - - - - layout.xml - - - - - - - - Mage_Captcha.csv - - - - - - - - - Mage_Captcha_Model_Observer - checkUserForgotPasswordBackend - - - - - - - Mage_Captcha_Model_Observer - checkForgotPassword - - - - - - - - - - captcha - - - - - - default - 0 - linlibertine - after_fail - backend_forgotpassword - 3 - 1000 - 7 - 4-5 - ABCDEFGHJKMnpqrstuvwxyz23456789 - 0 - - 1 - - - - - - default - 0 - linlibertine - after_fail - user_forgotpassword - 3 - 1000 - 7 - 4-5 - ABCDEFGHJKMnpqrstuvwxyz23456789 - 0 - - 1 - 1 - 1 - 1 - - - - - - - - LinLibertineFont/LinLibertine_Bd-2.8.1.ttf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */30 * * * * - - - Mage_Captcha_Model_Observer::deleteOldAttempts - - - - - */10 * * * * - - - Mage_Captcha_Model_Observer::deleteExpiredImages - - - - - - diff --git a/app/code/core/Mage/Catalog/Block/Product/Abstract.php b/app/code/core/Mage/Catalog/Block/Product/Abstract.php deleted file mode 100644 index 7eb9b6e5b069d..0000000000000 --- a/app/code/core/Mage/Catalog/Block/Product/Abstract.php +++ /dev/null @@ -1,729 +0,0 @@ - - */ -abstract class Mage_Catalog_Block_Product_Abstract extends Mage_Core_Block_Template -{ - protected $_priceBlock = array(); - - /** - * Default price block - * - * @var string - */ - protected $_block = 'Mage_Catalog_Block_Product_Price'; - - protected $_priceBlockDefaultTemplate = 'product/price.phtml'; - - protected $_tierPriceDefaultTemplate = 'product/view/tierprices.phtml'; - - protected $_priceBlockTypes = array(); - - /** - * Flag which allow/disallow to use link for as low as price - * - * @var bool - */ - protected $_useLinkForAsLowAs = true; - - protected $_reviewsHelperBlock; - - /** - * Default product amount per row - * - * @var int - */ - protected $_defaultColumnCount = 3; - - /** - * Product amount per row depending on custom page layout of category - * - * @var array - */ - protected $_columnCountLayoutDepend = array(); - - /** - * Default MAP renderer type - * - * @var string - */ - protected $_mapRenderer = 'msrp'; - - /** - * Retrieve url for add product to cart - * Will return product view page URL if product has required options - * - * @param Mage_Catalog_Model_Product $product - * @param array $additional - * @return string - */ - public function getAddToCartUrl($product, $additional = array()) - { - if ($product->getTypeInstance()->hasRequiredOptions($product)) { - if (!isset($additional['_escape'])) { - $additional['_escape'] = true; - } - if (!isset($additional['_query'])) { - $additional['_query'] = array(); - } - $additional['_query']['options'] = 'cart'; - - return $this->getProductUrl($product, $additional); - } - return $this->helper('Mage_Checkout_Helper_Cart')->getAddUrl($product, $additional); - } - - /** - * Retrieves url for form submitting: - * some objects can use setSubmitRouteData() to set route and params for form submitting, - * otherwise default url will be used - * - * @param Mage_Catalog_Model_Product $product - * @param array $additional - * @return string - */ - public function getSubmitUrl($product, $additional = array()) - { - $submitRouteData = $this->getData('submit_route_data'); - if ($submitRouteData) { - $route = $submitRouteData['route']; - $params = isset($submitRouteData['params']) ? $submitRouteData['params'] : array(); - $submitUrl = $this->getUrl($route, array_merge($params, $additional)); - } else { - $submitUrl = $this->getAddToCartUrl($product, $additional); - } - return $submitUrl; - } - - /** - * Enter description here... - * - * @param Mage_Catalog_Model_Product $product - * @return string - */ - public function getAddToWishlistUrl($product) - { - return $this->helper('Mage_Wishlist_Helper_Data')->getAddUrl($product); - } - - /** - * Retrieve Add Product to Compare Products List URL - * - * @param Mage_Catalog_Model_Product $product - * @return string - */ - public function getAddToCompareUrl($product) - { - return $this->helper('Mage_Catalog_Helper_Product_Compare')->getAddUrl($product); - } - - /** - * Gets minimal sales quantity - * - * @param Mage_Catalog_Model_Product $product - * @return int|null - */ - public function getMinimalQty($product) - { - $stockItem = $product->getStockItem(); - if ($stockItem) { - return ($stockItem->getMinSaleQty() - && $stockItem->getMinSaleQty() > 0 ? $stockItem->getMinSaleQty() * 1 : null); - } - return null; - } - - protected function _getPriceBlock($productTypeId) - { - if (!isset($this->_priceBlock[$productTypeId])) { - $block = $this->_block; - if (isset($this->_priceBlockTypes[$productTypeId])) { - if ($this->_priceBlockTypes[$productTypeId]['block'] != '') { - $block = $this->_priceBlockTypes[$productTypeId]['block']; - } - } - $this->_priceBlock[$productTypeId] = $this->getLayout()->createBlock($block); - } - return $this->_priceBlock[$productTypeId]; - } - - protected function _getPriceBlockTemplate($productTypeId) - { - if (isset($this->_priceBlockTypes[$productTypeId])) { - if ($this->_priceBlockTypes[$productTypeId]['template'] != '') { - return $this->_priceBlockTypes[$productTypeId]['template']; - } - } - return $this->_priceBlockDefaultTemplate; - } - - - /** - * Prepares and returns block to render some product type - * - * @param string $productType - * @return Mage_Core_Block_Template - */ - public function _preparePriceRenderer($productType) - { - return $this->_getPriceBlock($productType) - ->setTemplate($this->_getPriceBlockTemplate($productType)) - ->setUseLinkForAsLowAs($this->_useLinkForAsLowAs); - } - - /** - * Returns product price block html - * - * @param Mage_Catalog_Model_Product $product - * @param boolean $displayMinimalPrice - * @param string $idSuffix - * @return string - */ - public function getPriceHtml($product, $displayMinimalPrice = false, $idSuffix = '') - { - $type_id = $product->getTypeId(); - if (Mage::helper('Mage_Catalog_Helper_Data')->canApplyMsrp($product)) { - $realPriceHtml = $this->_preparePriceRenderer($type_id) - ->setProduct($product) - ->setDisplayMinimalPrice($displayMinimalPrice) - ->setIdSuffix($idSuffix) - ->toHtml(); - $product->setAddToCartUrl($this->getAddToCartUrl($product)); - $product->setRealPriceHtml($realPriceHtml); - $type_id = $this->_mapRenderer; - } - - return $this->_preparePriceRenderer($type_id) - ->setProduct($product) - ->setDisplayMinimalPrice($displayMinimalPrice) - ->setIdSuffix($idSuffix) - ->toHtml(); - } - - /** - * Adding customized price template for product type - * - * @param string $type - * @param string $block - * @param string $template - */ - public function addPriceBlockType($type, $block = '', $template = '') - { - if ($type) { - $this->_priceBlockTypes[$type] = array( - 'block' => $block, - 'template' => $template - ); - } - } - - /** - * Get product reviews summary - * - * @param Mage_Catalog_Model_Product $product - * @param bool $templateType - * @param bool $displayIfNoReviews - * @return string - */ - public function getReviewsSummaryHtml(Mage_Catalog_Model_Product $product, $templateType = false, - $displayIfNoReviews = false) - { - if ($this->_initReviewsHelperBlock()) { - return $this->_reviewsHelperBlock->getSummaryHtml($product, $templateType, $displayIfNoReviews); - } - - return ''; - } - - /** - * Add/replace reviews summary template by type - * - * @param string $type - * @param string $template - * @return string - */ - public function addReviewSummaryTemplate($type, $template) - { - if ($this->_initReviewsHelperBlock()) { - $this->_reviewsHelperBlock->addTemplate($type, $template); - } - - return ''; - } - - /** - * Create reviews summary helper block once - * - * @return boolean - */ - protected function _initReviewsHelperBlock() - { - if (!$this->_reviewsHelperBlock) { - if (!Mage::helper('Mage_Catalog_Helper_Data')->isModuleEnabled('Mage_Review')) { - return false; - } else { - $this->_reviewsHelperBlock = $this->getLayout()->createBlock('Mage_Review_Block_Helper'); - } - } - - return true; - } - - /** - * Retrieve currently viewed product object - * - * @return Mage_Catalog_Model_Product - */ - public function getProduct() - { - if (!$this->hasData('product')) { - $this->setData('product', Mage::registry('product')); - } - return $this->getData('product'); - } - - public function getTierPriceTemplate() - { - if (!$this->hasData('tier_price_template')) { - return $this->_tierPriceDefaultTemplate; - } - - return $this->getData('tier_price_template'); - } - /** - * Returns product tier price block html - * - * @param Mage_Catalog_Model_Product $product - * @return string - */ - public function getTierPriceHtml($product = null) - { - if (is_null($product)) { - $product = $this->getProduct(); - } - return $this->_getPriceBlock($product->getTypeId()) - ->setTemplate($this->getTierPriceTemplate()) - ->setProduct($product) - ->setInGrouped($this->getProduct()->isGrouped()) - ->toHtml(); - } - - /** - * Get tier prices (formatted) - * - * @param Mage_Catalog_Model_Product $product - * @return array - */ - public function getTierPrices($product = null) - { - if (is_null($product)) { - $product = $this->getProduct(); - } - $prices = $product->getFormatedTierPrice(); - - $res = array(); - if (is_array($prices)) { - foreach ($prices as $price) { - $price['price_qty'] = $price['price_qty'] * 1; - - $_productPrice = $product->getPrice(); - if ($_productPrice != $product->getFinalPrice()) { - $_productPrice = $product->getFinalPrice(); - } - - // Group price must be used for percent calculation if it is lower - $groupPrice = $product->getGroupPrice(); - if ($_productPrice > $groupPrice) { - $_productPrice = $groupPrice; - } - - if ($price['price'] < $_productPrice) { - $price['savePercent'] = ceil(100 - ((100 / $_productPrice) * $price['price'])); - - $tierPrice = Mage::app()->getStore()->convertPrice( - Mage::helper('Mage_Tax_Helper_Data')->getPrice($product, $price['website_price']) - ); - $price['formated_price'] = Mage::app()->getStore()->formatPrice($tierPrice); - $price['formated_price_incl_tax'] = Mage::app()->getStore()->formatPrice( - Mage::app()->getStore()->convertPrice( - Mage::helper('Mage_Tax_Helper_Data')->getPrice($product, $price['website_price'], true) - ) - ); - - if (Mage::helper('Mage_Catalog_Helper_Data')->canApplyMsrp($product)) { - $oldPrice = $product->getFinalPrice(); - $product->setPriceCalculation(false); - $product->setPrice($tierPrice); - $product->setFinalPrice($tierPrice); - - $this->getPriceHtml($product); - $product->setPriceCalculation(true); - - $price['real_price_html'] = $product->getRealPriceHtml(); - $product->setFinalPrice($oldPrice); - } - - $res[] = $price; - } - } - } - - return $res; - } - - /** - * Add all attributes and apply pricing logic to products collection - * to get correct values in different products lists. - * E.g. crosssells, upsells, new products, recently viewed - * - * @param Mage_Catalog_Model_Resource_Product_Collection $collection - * @return Mage_Catalog_Model_Resource_Product_Collection - */ - protected function _addProductAttributesAndPrices(Mage_Catalog_Model_Resource_Product_Collection $collection) - { - return $collection - ->addMinimalPrice() - ->addFinalPrice() - ->addTaxPercents() - ->addAttributeToSelect(Mage::getSingleton('Mage_Catalog_Model_Config')->getProductAttributes()) - ->addUrlRewrite(); - } - - /** - * Retrieve given media attribute label or product name if no label - * - * @param Mage_Catalog_Model_Product $product - * @param string $mediaAttributeCode - * - * @return string - */ - public function getImageLabel($product=null, $mediaAttributeCode='image') - { - if (is_null($product)) { - $product = $this->getProduct(); - } - - $label = $product->getData($mediaAttributeCode.'_label'); - if (empty($label)) { - $label = $product->getName(); - } - - return $label; - } - - /** - * Retrieve Product URL using UrlDataObject - * - * @param Mage_Catalog_Model_Product $product - * @param array $additional the route params - * @return string - */ - public function getProductUrl($product, $additional = array()) - { - if ($this->hasProductUrl($product)) { - if (!isset($additional['_escape'])) { - $additional['_escape'] = true; - } - return $product->getUrlModel()->getUrl($product, $additional); - } - - return '#'; - } - - /** - * Check Product has URL - * - * @param Mage_Catalog_Model_Product $product - * @return bool - */ - public function hasProductUrl($product) - { - if ($product->getVisibleInSiteVisibilities()) { - return true; - } - if ($product->hasUrlDataObject()) { - if (in_array($product->hasUrlDataObject()->getVisibility(), $product->getVisibleInSiteVisibilities())) { - return true; - } - } - - return false; - } - - /** - * Retrieve product amount per row - * - * @return int - */ - public function getColumnCount() - { - if (!$this->_getData('column_count')) { - $pageLayout = $this->getPageLayout(); - if ($pageLayout && $this->getColumnCountLayoutDepend($pageLayout->getCode())) { - $this->setData( - 'column_count', - $this->getColumnCountLayoutDepend($pageLayout->getCode()) - ); - } else { - $this->setData('column_count', $this->_defaultColumnCount); - } - } - - return (int) $this->_getData('column_count'); - } - - /** - * Add row size depends on page layout - * - * @param string $pageLayout - * @param int $columnCount - * @return Mage_Catalog_Block_Product_List - */ - public function addColumnCountLayoutDepend($pageLayout, $columnCount) - { - $this->_columnCountLayoutDepend[$pageLayout] = $columnCount; - return $this; - } - - /** - * Remove row size depends on page layout - * - * @param string $pageLayout - * @return Mage_Catalog_Block_Product_List - */ - public function removeColumnCountLayoutDepend($pageLayout) - { - if (isset($this->_columnCountLayoutDepend[$pageLayout])) { - unset($this->_columnCountLayoutDepend[$pageLayout]); - } - - return $this; - } - - /** - * Retrieve row size depends on page layout - * - * @param string $pageLayout - * @return int|boolean - */ - public function getColumnCountLayoutDepend($pageLayout) - { - if (isset($this->_columnCountLayoutDepend[$pageLayout])) { - return $this->_columnCountLayoutDepend[$pageLayout]; - } - - return false; - } - - /** - * Retrieve current page layout - * - * @return Varien_Object - */ - public function getPageLayout() - { - return $this->helper('Mage_Page_Helper_Layout')->getCurrentPageLayout(); - } - - /** - * Check whether the price can be shown for the specified product - * - * @param Mage_Catalog_Model_Product $product - * @return bool - */ - public function getCanShowProductPrice($product) - { - return $product->getCanShowPrice() !== false; - } - - /** - * Get if it is necessary to show product stock status - * - * @return bool - */ - public function displayProductStockStatus() - { - $statusInfo = new Varien_Object(array('display_status' => true)); - Mage::dispatchEvent('catalog_block_product_status_display', array('status' => $statusInfo)); - return (boolean)$statusInfo->getDisplayStatus(); - } - - /** - * If exists price template block, retrieve price blocks from it - * - * @return Mage_Catalog_Block_Product_Abstract - */ - protected function _prepareLayout() - { - parent::_prepareLayout(); - - /* @var $block Mage_Catalog_Block_Product_Price_Template */ - $block = $this->getLayout()->getBlock('catalog_product_price_template'); - if ($block) { - foreach ($block->getPriceBlockTypes() as $type => $priceBlock) { - $this->addPriceBlockType($type, $priceBlock['block'], $priceBlock['template']); - } - } - - return $this; - } - - /** - * Product thumbnail image url getter - * - * @param Mage_Core_Model_Product $product - * @return string - */ - public function getThumbnailUrl($product) - { - return (string) $this->helper('Mage_Catalog_Helper_Image')->init($product, 'thumbnail')->resize($this->getThumbnailSize()); - } - - /** - * Thumbnail image size getter - * - * @return int - */ - public function getThumbnailSize() - { - return $this->getVar('product_thumbnail_image_size', 'Mage_Catalog'); - } - - /** - * Product thumbnail image sidebar url getter - * - * @param Mage_Core_Model_Product $product - * @return string - */ - public function getThumbnailSidebarUrl($product) - { - return (string) $this->helper('Mage_Catalog_Helper_Image')->init($product, 'thumbnail') - ->resize($this->getThumbnailSidebarSize()); - } - - /** - * Thumbnail image sidebar size getter - * - * @return int - */ - public function getThumbnailSidebarSize() - { - return $this->getVar('product_thumbnail_image_sidebar_size', 'Mage_Catalog'); - } - - /** - * Product small image url getter - * - * @param Mage_Core_Model_Product $product - * @return string - */ - public function getSmallImageUrl($product) - { - return (string) $this->helper('Mage_Catalog_Helper_Image')->init($product, 'small_image') - ->resize($this->getSmallImageSize()); - } - - /** - * Small image size getter - * - * @return int - */ - public function getSmallImageSize() - { - return $this->getVar('product_small_image_size', 'Mage_Catalog'); - } - - /** - * Product small image sidebar url getter - * - * @param Mage_Core_Model_Product $product - * @return string - */ - public function getSmallImageSidebarUrl($product) - { - return (string) $this->helper('Mage_Catalog_Helper_Image')->init($product, 'small_image') - ->resize($this->getSmallImageSidebarSize()); - } - - /** - * Small image sidebar size getter - * - * @return int - */ - public function getSmallImageSidebarSize() - { - return $this->getVar('product_small_image_sidebar_size', 'Mage_Catalog'); - } - - /** - * Product base image url getter - * - * @param Mage_Core_Model_Product $product - * @return string - */ - public function getBaseImageUrl($product) - { - return (string) $this->helper('Mage_Catalog_Helper_Image')->init($product, 'image')->resize($this->getBaseImageSize()); - } - - /** - * Base image size getter - * - * @return int - */ - public function getBaseImageSize() - { - return $this->getVar('product_base_image_size', 'Mage_Catalog'); - } - - /** - * Product base image icon url getter - * - * @param Mage_Core_Model_Product $product - * @return string - */ - public function getBaseImageIconUrl($product) - { - return (string) $this->helper('Mage_Catalog_Helper_Image')->init($product, 'image')->resize($this->getBaseImageIconSize()); - } - - /** - * Base image icon size getter - * - * @return int - */ - public function getBaseImageIconSize() - { - return $this->getVar('product_base_image_icon_size', 'Mage_Catalog'); - } -} diff --git a/app/code/core/Mage/Catalog/Block/Product/Configurable/AssociatedSelector/Backend/Grid/ColumnSet.php b/app/code/core/Mage/Catalog/Block/Product/Configurable/AssociatedSelector/Backend/Grid/ColumnSet.php deleted file mode 100644 index 410a83d0ec8e5..0000000000000 --- a/app/code/core/Mage/Catalog/Block/Product/Configurable/AssociatedSelector/Backend/Grid/ColumnSet.php +++ /dev/null @@ -1,163 +0,0 @@ - - * - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class Mage_Catalog_Block_Product_Configurable_AssociatedSelector_Backend_Grid_ColumnSet - extends Mage_Backend_Block_Widget_Grid_ColumnSet -{ - /** - * Registry instance - * - * @var Mage_Core_Model_Registry - */ - protected $_registryManager; - - /** - * Product type configurable instance - * - * @var Mage_Catalog_Model_Product_Type_Configurable - */ - protected $_productType; - - /** - * @param Mage_Core_Controller_Request_Http $request - * @param Mage_Core_Model_Layout $layout - * @param Mage_Core_Model_Event_Manager $eventManager - * @param Mage_Core_Model_Url $urlBuilder - * @param Mage_Core_Model_Translate $translator - * @param Mage_Core_Model_Cache $cache - * @param Mage_Core_Model_Design_Package $designPackage - * @param Mage_Core_Model_Session $session - * @param Mage_Core_Model_Store_Config $storeConfig - * @param Mage_Core_Controller_Varien_Front $frontController - * @param Mage_Core_Model_Factory_Helper $helperFactory - * @param Mage_Core_Model_Dir $dirs - * @param Mage_Core_Model_Logger $logger - * @param Magento_Filesystem $filesystem - * @param Mage_Backend_Model_Widget_Grid_Row_UrlGeneratorFactory $generatorFactory - * @param Mage_Core_Model_Registry $registryManager, - * @param Mage_Catalog_Model_Product_Type_Configurable $productType - * @param Mage_Backend_Model_Widget_Grid_SubTotals $subtotals - * @param Mage_Backend_Model_Widget_Grid_Totals $totals - * @param array $data - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) - */ - public function __construct( - Mage_Core_Controller_Request_Http $request, - Mage_Core_Model_Layout $layout, - Mage_Core_Model_Event_Manager $eventManager, - Mage_Core_Model_Url $urlBuilder, - Mage_Core_Model_Translate $translator, - Mage_Core_Model_Cache $cache, - Mage_Core_Model_Design_Package $designPackage, - Mage_Core_Model_Session $session, - Mage_Core_Model_Store_Config $storeConfig, - Mage_Core_Controller_Varien_Front $frontController, - Mage_Core_Model_Factory_Helper $helperFactory, - Mage_Core_Model_Dir $dirs, - Mage_Core_Model_Logger $logger, - Magento_Filesystem $filesystem, - Mage_Backend_Model_Widget_Grid_Row_UrlGeneratorFactory $generatorFactory, - Mage_Core_Model_Registry $registryManager, - Mage_Backend_Model_Widget_Grid_SubTotals $subtotals, - Mage_Backend_Model_Widget_Grid_Totals $totals, - Mage_Catalog_Model_Product_Type_Configurable $productType, - array $data = array() - ) { - parent::__construct($request, $layout, $eventManager, $urlBuilder, $translator, $cache, $designPackage, - $session, $storeConfig, $frontController, $helperFactory, $dirs, $logger, $filesystem, - $helperFactory->get('Mage_Backend_Helper_Data'), $generatorFactory, $subtotals, $totals, $data); - - $this->_registryManager = $registryManager; - $this->_productType = $productType; - } - - /** - * Retrieve currently edited product object - * - * @return Mage_Catalog_Model_Product - */ - protected function _getProduct() - { - return $this->_registryManager->registry('current_product'); - } - - /** - * Preparing layout - * - * @return Mage_Catalog_Block_Product_Configurable_AssociatedSelector_Backend_Grid_ColumnSet - */ - protected function _prepareLayout() - { - parent::_prepareLayout(); - - $product = $this->_getProduct(); - $attributes = $this->_productType->getUsedProductAttributes($product); - foreach ($attributes as $attribute) { - /** @var $attribute Mage_Catalog_Model_Entity_Attribute */ - /** @var $block Mage_Backend_Block_Widget_Grid_Column */ - $block = $this->addChild( - $attribute->getAttributeCode(), - 'Mage_Backend_Block_Widget_Grid_Column', - array( - 'header' => $attribute->getStoreLabel(), - 'index' => $attribute->getAttributeCode(), - 'type' => 'options', - 'options' => $this->getOptions($attribute->getSource()), - 'sortable' => false - ) - ); - $block->setId($attribute->getAttributeCode())->setGrid($this); - } - return $this; - } - - /** - * Get option as hash - * - * @param Mage_Eav_Model_Entity_Attribute_Source_Abstract $sourceModel - * @return array - */ - private function getOptions(Mage_Eav_Model_Entity_Attribute_Source_Abstract $sourceModel) - { - $result = array(); - foreach ($sourceModel->getAllOptions() as $option) { - if ($option['value'] != '') { - $result[$option['value']] = $option['label']; - } - } - return $result; - } -} diff --git a/app/code/core/Mage/Catalog/Block/Product/List/Upsell.php b/app/code/core/Mage/Catalog/Block/Product/List/Upsell.php deleted file mode 100644 index 0d0ae5de83e25..0000000000000 --- a/app/code/core/Mage/Catalog/Block/Product/List/Upsell.php +++ /dev/null @@ -1,173 +0,0 @@ - - */ - -class Mage_Catalog_Block_Product_List_Upsell extends Mage_Catalog_Block_Product_Abstract -{ - /** - * Default MAP renderer type - * - * @var string - */ - protected $_mapRenderer = 'msrp_noform'; - - protected $_columnCount = 4; - - protected $_items; - - protected $_itemCollection; - - protected $_itemLimits = array(); - - protected function _prepareData() - { - $product = Mage::registry('product'); - /* @var $product Mage_Catalog_Model_Product */ - $this->_itemCollection = $product->getUpSellProductCollection() - ->setPositionOrder() - ->addStoreFilter() - ; - if (Mage::helper('Mage_Catalog_Helper_Data')->isModuleEnabled('Mage_Checkout')) { - Mage::getResourceSingleton('Mage_Checkout_Model_Resource_Cart') - ->addExcludeProductFilter( - $this->_itemCollection, - Mage::getSingleton('Mage_Checkout_Model_Session')->getQuoteId() - ); - - $this->_addProductAttributesAndPrices($this->_itemCollection); - } - $this->_itemCollection->setVisibility( - Mage::getSingleton('Mage_Catalog_Model_Product_Visibility')->getVisibleInCatalogIds() - ); - - if ($this->getItemLimit('upsell') > 0) { - $this->_itemCollection->setPageSize($this->getItemLimit('upsell')); - } - - $this->_itemCollection->load(); - - /** - * Updating collection with desired items - */ - Mage::dispatchEvent('catalog_product_upsell', array( - 'product' => $product, - 'collection' => $this->_itemCollection, - 'limit' => $this->getItemLimit() - )); - - foreach ($this->_itemCollection as $product) { - $product->setDoNotUseCategoryId(true); - } - - return $this; - } - - protected function _beforeToHtml() - { - $this->_prepareData(); - return parent::_beforeToHtml(); - } - - public function getItemCollection() - { - return $this->_itemCollection; - } - - public function getItems() - { - if (is_null($this->_items)) { - $this->_items = $this->getItemCollection()->getItems(); - } - return $this->_items; - } - - public function getRowCount() - { - return ceil(count($this->getItemCollection()->getItems())/$this->getColumnCount()); - } - - public function setColumnCount($columns) - { - if (intval($columns) > 0) { - $this->_columnCount = intval($columns); - } - return $this; - } - - public function getColumnCount() - { - return $this->_columnCount; - } - - public function resetItemsIterator() - { - $this->getItems(); - reset($this->_items); - } - - public function getIterableItem() - { - $item = current($this->_items); - next($this->_items); - return $item; - } - - /** - * Set how many items we need to show in upsell block - * Notice: this parametr will be also applied - * - * @param string $type - * @param int $limit - * @return Mage_Catalog_Block_Product_List_Upsell - */ - public function setItemLimit($type, $limit) - { - if (intval($limit) > 0) { - $this->_itemLimits[$type] = intval($limit); - } - return $this; - } - - public function getItemLimit($type = '') - { - if ($type == '') { - return $this->_itemLimits; - } - if (isset($this->_itemLimits[$type])) { - return $this->_itemLimits[$type]; - } - else { - return 0; - } - } -} diff --git a/app/code/core/Mage/Catalog/Block/Product/View.php b/app/code/core/Mage/Catalog/Block/Product/View.php deleted file mode 100644 index c8a70ea577973..0000000000000 --- a/app/code/core/Mage/Catalog/Block/Product/View.php +++ /dev/null @@ -1,267 +0,0 @@ - - */ -class Mage_Catalog_Block_Product_View extends Mage_Catalog_Block_Product_Abstract -{ - /** - * Default MAP renderer type - * - * @var string - */ - protected $_mapRenderer = 'msrp_item'; - - /** - * Add meta information from product to head block - * - * @return Mage_Catalog_Block_Product_View - */ - protected function _prepareLayout() - { - $this->getLayout()->createBlock('Mage_Catalog_Block_Breadcrumbs'); - $headBlock = $this->getLayout()->getBlock('head'); - if ($headBlock) { - $product = $this->getProduct(); - $title = $product->getMetaTitle(); - if ($title) { - $headBlock->setTitle($title); - } - $keyword = $product->getMetaKeyword(); - $currentCategory = Mage::registry('current_category'); - if ($keyword) { - $headBlock->setKeywords($keyword); - } elseif($currentCategory) { - $headBlock->setKeywords($product->getName()); - } - $description = $product->getMetaDescription(); - if ($description) { - $headBlock->setDescription( ($description) ); - } else { - $headBlock->setDescription(Mage::helper('Mage_Core_Helper_String')->substr($product->getDescription(), 0, 255)); - } - if ($this->helper('Mage_Catalog_Helper_Product')->canUseCanonicalTag()) { - $params = array('_ignore_category'=>true); - $headBlock->addLinkRel('canonical', $product->getUrlModel()->getUrl($product, $params)); - } - } - - return parent::_prepareLayout(); - } - - /** - * Retrieve current product model - * - * @return Mage_Catalog_Model_Product - */ - public function getProduct() - { - if (!Mage::registry('product') && $this->getProductId()) { - $product = Mage::getModel('Mage_Catalog_Model_Product')->load($this->getProductId()); - Mage::register('product', $product); - } - return Mage::registry('product'); - } - - /** - * Check if product can be emailed to friend - * - * @return bool - */ - public function canEmailToFriend() - { - $sendToFriendModel = Mage::registry('send_to_friend_model'); - return $sendToFriendModel && $sendToFriendModel->canEmailToFriend(); - } - - /** - * Retrieve url for direct adding product to cart - * - * @param Mage_Catalog_Model_Product $product - * @param array $additional - * @return string - */ - public function getAddToCartUrl($product, $additional = array()) - { - if ($this->hasCustomAddToCartUrl()) { - return $this->getCustomAddToCartUrl(); - } - - if ($this->getRequest()->getParam('wishlist_next')){ - $additional['wishlist_next'] = 1; - } - - $addUrlKey = Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED; - $addUrlValue = Mage::getUrl('*/*/*', array('_use_rewrite' => true, '_current' => true)); - $additional[$addUrlKey] = Mage::helper('Mage_Core_Helper_Data')->urlEncode($addUrlValue); - - return $this->helper('Mage_Checkout_Helper_Cart')->getAddUrl($product, $additional); - } - - /** - * Get JSON encoded configuration array which can be used for JS dynamic - * price calculation depending on product options - * - * @return string - */ - public function getJsonConfig() - { - $config = array(); - if (!$this->hasOptions()) { - return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($config); - } - - $_request = Mage::getSingleton('Mage_Tax_Model_Calculation')->getRateRequest(false, false, false); - /* @var $product Mage_Catalog_Model_Product */ - $product = $this->getProduct(); - $_request->setProductClassId($product->getTaxClassId()); - $defaultTax = Mage::getSingleton('Mage_Tax_Model_Calculation')->getRate($_request); - - $_request = Mage::getSingleton('Mage_Tax_Model_Calculation')->getRateRequest(); - $_request->setProductClassId($product->getTaxClassId()); - $currentTax = Mage::getSingleton('Mage_Tax_Model_Calculation')->getRate($_request); - - $_regularPrice = $product->getPrice(); - $_finalPrice = $product->getFinalPrice(); - $_priceInclTax = Mage::helper('Mage_Tax_Helper_Data')->getPrice($product, $_finalPrice, true); - $_priceExclTax = Mage::helper('Mage_Tax_Helper_Data')->getPrice($product, $_finalPrice); - $_tierPrices = array(); - $_tierPricesInclTax = array(); - foreach ($product->getTierPrice() as $tierPrice) { - $_tierPrices[] = Mage::helper('Mage_Core_Helper_Data')->currency($tierPrice['website_price'], false, false); - $_tierPricesInclTax[] = Mage::helper('Mage_Core_Helper_Data')->currency( - Mage::helper('Mage_Tax_Helper_Data')->getPrice($product, (int)$tierPrice['website_price'], true), - false, false); - } - $config = array( - 'productId' => $product->getId(), - 'priceFormat' => Mage::app()->getLocale()->getJsPriceFormat(), - 'includeTax' => Mage::helper('Mage_Tax_Helper_Data')->priceIncludesTax() ? 'true' : 'false', - 'showIncludeTax' => Mage::helper('Mage_Tax_Helper_Data')->displayPriceIncludingTax(), - 'showBothPrices' => Mage::helper('Mage_Tax_Helper_Data')->displayBothPrices(), - 'productPrice' => Mage::helper('Mage_Core_Helper_Data')->currency($_finalPrice, false, false), - 'productOldPrice' => Mage::helper('Mage_Core_Helper_Data')->currency($_regularPrice, false, false), - 'priceInclTax' => Mage::helper('Mage_Core_Helper_Data')->currency($_priceInclTax, false, false), - 'priceExclTax' => Mage::helper('Mage_Core_Helper_Data')->currency($_priceExclTax, false, false), - 'defaultTax' => $defaultTax, - 'currentTax' => $currentTax, - 'idSuffix' => '_clone', - 'oldPlusDisposition' => 0, - 'plusDisposition' => 0, - 'plusDispositionTax' => 0, - 'oldMinusDisposition' => 0, - 'minusDisposition' => 0, - 'tierPrices' => $_tierPrices, - 'tierPricesInclTax' => $_tierPricesInclTax, - ); - - $responseObject = new Varien_Object(); - Mage::dispatchEvent('catalog_product_view_config', array('response_object'=>$responseObject)); - if (is_array($responseObject->getAdditionalOptions())) { - foreach ($responseObject->getAdditionalOptions() as $option=>$value) { - $config[$option] = $value; - } - } - - return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($config); - } - - /** - * Return true if product has options - * - * @return bool - */ - public function hasOptions() - { - if ($this->getProduct()->getTypeInstance()->hasOptions($this->getProduct())) { - return true; - } - return false; - } - - /** - * Check if product has required options - * - * @return bool - */ - public function hasRequiredOptions() - { - return $this->getProduct()->getTypeInstance()->hasRequiredOptions($this->getProduct()); - } - - /** - * Define if setting of product options must be shown instantly. - * Used in case when options are usually hidden and shown only when user - * presses some button or link. In editing mode we better show these options - * instantly. - * - * @return bool - */ - public function isStartCustomization() - { - return $this->getProduct()->getConfigureMode() || Mage::app()->getRequest()->getParam('startcustomization'); - } - - /** - * Get default qty - either as preconfigured, or as 1. - * Also restricts it by minimal qty. - * - * @param null|Mage_Catalog_Model_Product $product - * @return int|float - */ - public function getProductDefaultQty($product = null) - { - if (!$product) { - $product = $this->getProduct(); - } - - $qty = $this->getMinimalQty($product); - $config = $product->getPreconfiguredValues(); - $configQty = $config->getQty(); - if ($configQty > $qty) { - $qty = $configQty; - } - - return $qty; - } - - /** - * Get container name, where product options should be displayed - * - * @return string - */ - public function getOptionsContainer() - { - return $this->getProduct()->getOptionsContainer() == 'container1' ? 'container1' : 'container2'; - } -} diff --git a/app/code/core/Mage/Catalog/Block/Product/View/Options.php b/app/code/core/Mage/Catalog/Block/Product/View/Options.php deleted file mode 100644 index 9fbd4a060bde7..0000000000000 --- a/app/code/core/Mage/Catalog/Block/Product/View/Options.php +++ /dev/null @@ -1,204 +0,0 @@ - - */ -class Mage_Catalog_Block_Product_View_Options extends Mage_Core_Block_Template -{ - protected $_product; - - protected $_optionRenders = array(); - - protected function _construct() - { - parent::_construct(); - $this->addOptionRenderer( - 'default', - 'Mage_Catalog_Block_Product_View_Options_Type_Default', - 'product/view/options/type/default.phtml' - ); - } - - /** - * Retrieve product object - * - * @return Mage_Catalog_Model_Product - */ - public function getProduct() - { - if (!$this->_product) { - if (Mage::registry('current_product')) { - $this->_product = Mage::registry('current_product'); - } else { - $this->_product = Mage::getSingleton('Mage_Catalog_Model_Product'); - } - } - return $this->_product; - } - - /** - * Set product object - * - * @param Mage_Catalog_Model_Product $product - * @return Mage_Catalog_Block_Product_View_Options - */ - public function setProduct(Mage_Catalog_Model_Product $product = null) - { - $this->_product = $product; - return $this; - } - - /** - * Add option renderer to renderers array - * - * @param string $type - * @param string $block - * @param string $template - * @return Mage_Catalog_Block_Product_View_Options - */ - public function addOptionRenderer($type, $block, $template) - { - $this->_optionRenders[$type] = array( - 'block' => $block, - 'template' => $template, - 'renderer' => null - ); - return $this; - } - - /** - * Get option render by given type - * - * @param string $type - * @return array - */ - public function getOptionRender($type) - { - if (isset($this->_optionRenders[$type])) { - return $this->_optionRenders[$type]; - } - - return $this->_optionRenders['default']; - } - - public function getGroupOfOption($type) - { - $group = Mage::getSingleton('Mage_Catalog_Model_Product_Option')->getGroupByType($type); - - return $group == '' ? 'default' : $group; - } - - /** - * Get product options - * - * @return array - */ - public function getOptions() - { - return $this->getProduct()->getOptions(); - } - - public function hasOptions() - { - if ($this->getOptions()) { - return true; - } - return false; - } - - /** - * Get price configuration - * - * @param Mage_Catalog_Model_Product_Option_Value|Mage_Catalog_Model_Product_Option $option - * @return array - */ - protected function _getPriceConfiguration($option) - { - $data = array(); - $data['price'] = Mage::helper('Mage_Core_Helper_Data')->currency($option->getPrice(true), false, false); - $data['oldPrice'] = Mage::helper('Mage_Core_Helper_Data')->currency($option->getPrice(false), false, false); - $data['priceValue'] = $option->getPrice(false); - $data['type'] = $option->getPriceType(); - $data['excludeTax'] = $price = Mage::helper('Mage_Tax_Helper_Data')->getPrice($option->getProduct(), $data['price'], false); - $data['includeTax'] = $price = Mage::helper('Mage_Tax_Helper_Data')->getPrice($option->getProduct(), $data['price'], true); - return $data; - } - - /** - * Get json representation of - * - * @return string - */ - public function getJsonConfig() - { - $config = array(); - - foreach ($this->getOptions() as $option) { - /* @var $option Mage_Catalog_Model_Product_Option */ - $priceValue = 0; - if ($option->getGroupByType() == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT) { - $_tmpPriceValues = array(); - foreach ($option->getValues() as $value) { - /* @var $value Mage_Catalog_Model_Product_Option_Value */ - $id = $value->getId(); - $_tmpPriceValues[$id] = $this->_getPriceConfiguration($value); - } - $priceValue = $_tmpPriceValues; - } else { - $priceValue = $this->_getPriceConfiguration($option); - } - $config[$option->getId()] = $priceValue; - } - - return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($config); - } - - /** - * Get option html block - * - * @param Mage_Catalog_Model_Product_Option $option - */ - public function getOptionHtml(Mage_Catalog_Model_Product_Option $option) - { - $renderer = $this->getOptionRender( - $this->getGroupOfOption($option->getType()) - ); - if (is_null($renderer['renderer'])) { - $renderer['renderer'] = $this->getLayout()->createBlock($renderer['block']) - ->setTemplate($renderer['template']); - } - return $renderer['renderer'] - ->setProduct($this->getProduct()) - ->setOption($option) - ->toHtml(); - } -} diff --git a/app/code/core/Mage/Catalog/Block/Product/View/Options/Abstract.php b/app/code/core/Mage/Catalog/Block/Product/View/Options/Abstract.php deleted file mode 100644 index 326b59a285dd1..0000000000000 --- a/app/code/core/Mage/Catalog/Block/Product/View/Options/Abstract.php +++ /dev/null @@ -1,177 +0,0 @@ - - */ -abstract class Mage_Catalog_Block_Product_View_Options_Abstract extends Mage_Core_Block_Template -{ - /** - * Product object - * - * @var Mage_Catalog_Model_Product - */ - protected $_product; - - /** - * Product option object - * - * @var Mage_Catalog_Model_Product_Option - */ - protected $_option; - - /** - * Set Product object - * - * @param Mage_Catalog_Model_Product $product - * @return Mage_Catalog_Block_Product_View_Options_Abstract - */ - public function setProduct(Mage_Catalog_Model_Product $product = null) - { - $this->_product = $product; - return $this; - } - - /** - * Retrieve Product object - * - * @return Mage_Catalog_Model_Product - */ - public function getProduct() - { - return $this->_product; - } - - /** - * Set option - * - * @param Mage_Catalog_Model_Product_Option $option - * @return Mage_Catalog_Block_Product_View_Options_Abstract - */ - public function setOption(Mage_Catalog_Model_Product_Option $option) - { - $this->_option = $option; - return $this; - } - - /** - * Get option - * - * @return Mage_Catalog_Model_Product_Option - */ - public function getOption() - { - return $this->_option; - } - - public function getFormatedPrice() - { - if ($option = $this->getOption()) { - return $this->_formatPrice(array( - 'is_percent' => ($option->getPriceType() == 'percent'), - 'pricing_value' => $option->getPrice($option->getPriceType() == 'percent') - )); - } - return ''; - } - - /** - * Return formated price - * - * @param array $value - * @return string - */ - protected function _formatPrice($value, $flag=true) - { - if ($value['pricing_value'] == 0) { - return ''; - } - - $taxHelper = Mage::helper('Mage_Tax_Helper_Data'); - $store = $this->getProduct()->getStore(); - - $sign = '+'; - if ($value['pricing_value'] < 0) { - $sign = '-'; - $value['pricing_value'] = 0 - $value['pricing_value']; - } - - $priceStr = $sign; - $_priceInclTax = $this->getPrice($value['pricing_value'], true); - $_priceExclTax = $this->getPrice($value['pricing_value']); - if ($taxHelper->displayPriceIncludingTax()) { - $priceStr .= $this->helper('Mage_Core_Helper_Data')->currencyByStore($_priceInclTax, $store, true, $flag); - } elseif ($taxHelper->displayPriceExcludingTax()) { - $priceStr .= $this->helper('Mage_Core_Helper_Data')->currencyByStore($_priceExclTax, $store, true, $flag); - } elseif ($taxHelper->displayBothPrices()) { - $priceStr .= $this->helper('Mage_Core_Helper_Data')->currencyByStore($_priceExclTax, $store, true, $flag); - if ($_priceInclTax != $_priceExclTax) { - $priceStr .= ' ('.$sign.$this->helper('Mage_Core_Helper_Data') - ->currencyByStore($_priceInclTax, $store, true, $flag).' '.$this->__('Incl. Tax').')'; - } - } - - if ($flag) { - $priceStr = ''.$priceStr.''; - } - - return $priceStr; - } - - /** - * Get price with including/excluding tax - * - * @param decimal $price - * @param bool $includingTax - * @return decimal - */ - public function getPrice($price, $includingTax = null) - { - if (!is_null($includingTax)) { - $price = Mage::helper('Mage_Tax_Helper_Data')->getPrice($this->getProduct(), $price, true); - } else { - $price = Mage::helper('Mage_Tax_Helper_Data')->getPrice($this->getProduct(), $price); - } - return $price; - } - - /** - * Returns price converted to current currency rate - * - * @param float $price - * @return float - */ - public function getCurrencyPrice($price) - { - $store = $this->getProduct()->getStore(); - return $this->helper('Mage_Core_Helper_Data')->currencyByStore($price, $store, false); - } -} diff --git a/app/code/core/Mage/Catalog/Helper/Image.php b/app/code/core/Mage/Catalog/Helper/Image.php deleted file mode 100644 index be8866f8ef165..0000000000000 --- a/app/code/core/Mage/Catalog/Helper/Image.php +++ /dev/null @@ -1,632 +0,0 @@ - - */ -class Mage_Catalog_Helper_Image extends Mage_Core_Helper_Abstract -{ - /** - * Current model - * - * @var Mage_Catalog_Model_Product_Image - */ - protected $_model; - - /** - * Scheduled for resize image - * - * @var bool - */ - protected $_scheduleResize = false; - - /** - * Scheduled for rotate image - * - * @var bool - */ - protected $_scheduleRotate = false; - - /** - * Angle - * - * @var int - */ - protected $_angle; - - /** - * Watermark file name - * - * @var string - */ - protected $_watermark; - - /** - * Watermark Position - * - * @var string - */ - protected $_watermarkPosition; - - /** - * Watermark Size - * - * @var string - */ - protected $_watermarkSize; - - /** - * Watermark Image opacity - * - * @var int - */ - protected $_watermarkImageOpacity; - - /** - * Current Product - * - * @var Mage_Catalog_Model_Product - */ - protected $_product; - - /** - * Image File - * - * @var string - */ - protected $_imageFile; - - /** - * Image Placeholder - * - * @var string - */ - protected $_placeholder; - - /** - * Reset all previous data - * - * @return Mage_Catalog_Helper_Image - */ - protected function _reset() - { - $this->_model = null; - $this->_scheduleResize = false; - $this->_scheduleRotate = false; - $this->_angle = null; - $this->_watermark = null; - $this->_watermarkPosition = null; - $this->_watermarkSize = null; - $this->_watermarkImageOpacity = null; - $this->_product = null; - $this->_imageFile = null; - return $this; - } - - /** - * Initialize Helper to work with Image - * - * @param Mage_Catalog_Model_Product $product - * @param string $attributeName - * @param mixed $imageFile - * @return Mage_Catalog_Helper_Image - */ - public function init(Mage_Catalog_Model_Product $product, $attributeName, $imageFile=null) - { - $this->_reset(); - $this->_setModel(Mage::getModel('Mage_Catalog_Model_Product_Image')); - $this->_getModel()->setDestinationSubdir($attributeName); - $this->setProduct($product); - - $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); - } else { - // add for work original size - $this->_getModel()->setBaseFile($this->getProduct()->getData($this->_getModel()->getDestinationSubdir())); - } - return $this; - } - - /** - * Schedule resize of the image - * $width *or* $height can be null - in this case, lacking dimension will be calculated. - * - * @see Mage_Catalog_Model_Product_Image - * @param int $width - * @param int $height - * @return Mage_Catalog_Helper_Image - */ - public function resize($width, $height = null) - { - $this->_getModel()->setWidth($width)->setHeight($height); - $this->_scheduleResize = true; - return $this; - } - - /** - * Set image quality, values in percentage from 0 to 100 - * - * @param int $quality - * @return Mage_Catalog_Helper_Image - */ - public function setQuality($quality) - { - $this->_getModel()->setQuality($quality); - return $this; - } - - /** - * Guarantee, that image picture width/height will not be distorted. - * Applicable before calling resize() - * It is true by default. - * - * @see Mage_Catalog_Model_Product_Image - * @param bool $flag - * @return Mage_Catalog_Helper_Image - */ - public function keepAspectRatio($flag) - { - $this->_getModel()->setKeepAspectRatio($flag); - return $this; - } - - /** - * Guarantee, that image will have dimensions, set in $width/$height - * Applicable before calling resize() - * Not applicable, if keepAspectRatio(false) - * - * $position - TODO, not used for now - picture position inside the frame. - * - * @see Mage_Catalog_Model_Product_Image - * @param bool $flag - * @param array $position - * @return Mage_Catalog_Helper_Image - */ - public function keepFrame($flag, $position = array('center', 'middle')) - { - $this->_getModel()->setKeepFrame($flag); - return $this; - } - - /** - * Guarantee, that image will not lose transparency if any. - * Applicable before calling resize() - * It is true by default. - * - * $alphaOpacity - TODO, not used for now - * - * @see Mage_Catalog_Model_Product_Image - * @param bool $flag - * @param int $alphaOpacity - * @return Mage_Catalog_Helper_Image - */ - public function keepTransparency($flag, $alphaOpacity = null) - { - $this->_getModel()->setKeepTransparency($flag); - return $this; - } - - /** - * Guarantee, that image picture will not be bigger, than it was. - * Applicable before calling resize() - * It is false by default - * - * @param bool $flag - * @return Mage_Catalog_Helper_Image - */ - public function constrainOnly($flag) - { - $this->_getModel()->setConstrainOnly($flag); - return $this; - } - - /** - * Set color to fill image frame with. - * Applicable before calling resize() - * The keepTransparency(true) overrides this (if image has transparent color) - * It is white by default. - * - * @see Mage_Catalog_Model_Product_Image - * @param array $colorRGB - * @return Mage_Catalog_Helper_Image - */ - public function backgroundColor($colorRGB) - { - // assume that 3 params were given instead of array - if (!is_array($colorRGB)) { - $colorRGB = func_get_args(); - } - $this->_getModel()->setBackgroundColor($colorRGB); - return $this; - } - - /** - * Rotate image into specified angle - * - * @param int $angle - * @return Mage_Catalog_Helper_Image - */ - public function rotate($angle) - { - $this->setAngle($angle); - $this->_getModel()->setAngle($angle); - $this->_scheduleRotate = true; - return $this; - } - - /** - * Add watermark to image - * size param in format 100x200 - * - * @param string $fileName - * @param string $position - * @param string $size - * @param int $imageOpacity - * @return Mage_Catalog_Helper_Image - */ - public function watermark($fileName, $position, $size=null, $imageOpacity=null) - { - $this->setWatermark($fileName) - ->setWatermarkPosition($position) - ->setWatermarkSize($size) - ->setWatermarkImageOpacity($imageOpacity); - return $this; - } - - /** - * Set placeholder - * - * @param string $fileName - * @return void - */ - public function placeholder($fileName) - { - $this->_placeholder = $fileName; - } - - /** - * Get Placeholder - * - * @return string - */ - public function getPlaceholder() - { - if (!$this->_placeholder) { - $attr = $this->_getModel()->getDestinationSubdir(); - $this->_placeholder = 'Mage_Catalog::images/product/placeholder/' . $attr . '.jpg'; - } - return $this->_placeholder; - } - - /** - * Return Image URL - * - * @return string - */ - public function __toString() - { - try { - $model = $this->_getModel(); - - if ($this->getImageFile()) { - $model->setBaseFile($this->getImageFile()); - } else { - $model->setBaseFile($this->getProduct()->getData($model->getDestinationSubdir())); - } - - if ($model->isCached()) { - return $model->getUrl(); - } else { - if ($this->_scheduleRotate) { - $model->rotate($this->getAngle()); - } - - if ($this->_scheduleResize) { - $model->resize(); - } - - if ($this->getWatermark()) { - $model->setWatermark($this->getWatermark()); - } - - $url = $model->saveFile()->getUrl(); - } - } catch (Exception $e) { - $url = Mage::getDesign()->getViewFileUrl($this->getPlaceholder()); - } - return $url; - } - - /** - * Set current Image model - * - * @param Mage_Catalog_Model_Product_Image $model - * @return Mage_Catalog_Helper_Image - */ - protected function _setModel($model) - { - $this->_model = $model; - return $this; - } - - /** - * Get current Image model - * - * @return Mage_Catalog_Model_Product_Image - */ - protected function _getModel() - { - return $this->_model; - } - - /** - * Set Rotation Angle - * - * @param int $angle - * @return Mage_Catalog_Helper_Image - */ - protected function setAngle($angle) - { - $this->_angle = $angle; - return $this; - } - - /** - * Get Rotation Angle - * - * @return int - */ - protected function getAngle() - { - return $this->_angle; - } - - /** - * Set watermark file name - * - * @param string $watermark - * @return Mage_Catalog_Helper_Image - */ - protected function setWatermark($watermark) - { - $this->_watermark = $watermark; - $this->_getModel()->setWatermarkFile($watermark); - return $this; - } - - /** - * Get watermark file name - * - * @return string - */ - protected function getWatermark() - { - return $this->_watermark; - } - - /** - * Set watermark position - * - * @param string $position - * @return Mage_Catalog_Helper_Image - */ - protected function setWatermarkPosition($position) - { - $this->_watermarkPosition = $position; - $this->_getModel()->setWatermarkPosition($position); - return $this; - } - - /** - * Get watermark position - * - * @return string - */ - protected function getWatermarkPosition() - { - return $this->_watermarkPosition; - } - - /** - * Set watermark size - * param size in format 100x200 - * - * @param string $size - * @return Mage_Catalog_Helper_Image - */ - public function setWatermarkSize($size) - { - $this->_watermarkSize = $size; - $this->_getModel()->setWatermarkSize($this->parseSize($size)); - return $this; - } - - /** - * Get watermark size - * - * @return string - */ - protected function getWatermarkSize() - { - return $this->_watermarkSize; - } - - /** - * Set watermark image opacity - * - * @param int $imageOpacity - * @return Mage_Catalog_Helper_Image - */ - public function setWatermarkImageOpacity($imageOpacity) - { - $this->_watermarkImageOpacity = $imageOpacity; - $this->_getModel()->setWatermarkImageOpacity($imageOpacity); - return $this; - } - - /** - * Get watermark image opacity - * - * @return int - */ - protected function getWatermarkImageOpacity() - { - if ($this->_watermarkImageOpacity) { - return $this->_watermarkImageOpacity; - } - - return $this->_getModel()->getWatermarkImageOpacity(); - } - - /** - * Set current Product - * - * @param Mage_Catalog_Model_Product $product - * @return Mage_Catalog_Helper_Image - */ - protected function setProduct($product) - { - $this->_product = $product; - return $this; - } - - /** - * Get current Product - * - * @return Mage_Catalog_Model_Product - */ - protected function getProduct() - { - return $this->_product; - } - - /** - * Set Image file - * - * @param string $file - * @return Mage_Catalog_Helper_Image - */ - protected function setImageFile($file) - { - $this->_imageFile = $file; - return $this; - } - - /** - * Get Image file - * - * @return string - */ - protected function getImageFile() - { - return $this->_imageFile; - } - - /** - * Retrieve size from string - * - * @param string $string - * @return array|bool - */ - protected function parseSize($string) - { - $size = explode('x', strtolower($string)); - if (sizeof($size) == 2) { - return array( - 'width' => ($size[0] > 0) ? $size[0] : null, - 'heigth' => ($size[1] > 0) ? $size[1] : null, - ); - } - return false; - } - - /** - * Retrieve original image width - * - * @return int|null - */ - public function getOriginalWidth() - { - return $this->_getModel()->getImageProcessor()->getOriginalWidth(); - } - - /** - * Retrieve original image height - * - * @return int|null - */ - public function getOriginalHeight() - { - return $this->_getModel()->getImageProcessor()->getOriginalHeight(); - } - - /** - * Retrieve Original image size as array - * 0 - width, 1 - height - * - * @return array - */ - public function getOriginalSizeArray() - { - return array( - $this->getOriginalWidth(), - $this->getOriginalHeight() - ); - } - - /** - * Check - is this file an image - * - * @param string $filePath - * @return bool - * @throws Mage_Core_Exception - */ - public function validateUploadFile($filePath) { - if (!getimagesize($filePath)) { - Mage::throwException($this->__('Disallowed file type.')); - } - - $adapter = Mage::helper('Mage_Core_Helper_Data')->getImageAdapterType(); - $_processor = new Varien_Image($filePath, $adapter); - return $_processor->getMimeType() !== null; - } - -} diff --git a/app/code/core/Mage/Catalog/Helper/Product.php b/app/code/core/Mage/Catalog/Helper/Product.php deleted file mode 100644 index 625a9383a156a..0000000000000 --- a/app/code/core/Mage/Catalog/Helper/Product.php +++ /dev/null @@ -1,518 +0,0 @@ - - */ -class Mage_Catalog_Helper_Product extends Mage_Core_Helper_Url -{ - const XML_PATH_PRODUCT_URL_SUFFIX = 'catalog/seo/product_url_suffix'; - const XML_PATH_PRODUCT_URL_USE_CATEGORY = 'catalog/seo/product_use_categories'; - const XML_PATH_USE_PRODUCT_CANONICAL_TAG = 'catalog/seo/product_canonical_tag'; - const XML_PATH_AUTO_GENERATE_MASK = 'catalog/fields_masks'; - const XML_PATH_UNASSIGNABLE_ATTRIBUTES = 'global/catalog/product/attributes/unassignable'; - const XML_PATH_ATTRIBUTES_USED_IN_AUTOGENERATION = 'global/catalog/product/attributes/used_in_autogeneration'; - const XML_PATH_PRODUCT_TYPE_SWITCHER_LABEL = 'global/catalog/product/attributes/weight/type_switcher/label'; - - /** - * Flag that shows if Magento has to check product to be saleable (enabled and/or inStock) - * - * @var boolean - */ - protected $_skipSaleableCheck = false; - - /** - * Cache for product rewrite suffix - * - * @var array - */ - protected $_productUrlSuffix = array(); - - protected $_statuses; - - protected $_priceBlock; - - /** - * Retrieve product view page url - * - * @param mixed $product - * @return string - */ - public function getProductUrl($product) - { - if ($product instanceof Mage_Catalog_Model_Product) { - return $product->getProductUrl(); - } - elseif (is_numeric($product)) { - return Mage::getModel('Mage_Catalog_Model_Product')->load($product)->getProductUrl(); - } - return false; - } - - /** - * Retrieve product price - * - * @param Mage_Catalog_Model_Product $product - * @return float - */ - public function getPrice($product) - { - return $product->getPrice(); - } - - /** - * Retrieve product final price - * - * @param Mage_Catalog_Model_Product $product - * @return float - */ - public function getFinalPrice($product) - { - return $product->getFinalPrice(); - } - - /** - * Retrieve base image url - * - * @return string - */ - public function getImageUrl($product) - { - $url = false; - if (!$product->getImage()) { - $url = Mage::getDesign()->getViewFileUrl('Mage_Catalog::images/product/placeholder/image.jpg'); - } - elseif ($attribute = $product->getResource()->getAttribute('image')) { - $url = $attribute->getFrontend()->getUrl($product); - } - return $url; - } - - /** - * Retrieve small image url - * - * @return unknown - */ - public function getSmallImageUrl($product) - { - $url = false; - if (!$product->getSmallImage()) { - $url = Mage::getDesign()->getViewFileUrl('Mage_Catalog::images/product/placeholder/small_image.jpg'); - } - elseif ($attribute = $product->getResource()->getAttribute('small_image')) { - $url = $attribute->getFrontend()->getUrl($product); - } - return $url; - } - - /** - * Retrieve thumbnail image url - * - * @return unknown - */ - public function getThumbnailUrl($product) - { - return ''; - } - - public function getEmailToFriendUrl($product) - { - $categoryId = null; - if ($category = Mage::registry('current_category')) { - $categoryId = $category->getId(); - } - return $this->_getUrl('sendfriend/product/send', array( - 'id' => $product->getId(), - 'cat_id' => $categoryId - )); - } - - public function getStatuses() - { - if(is_null($this->_statuses)) { - $this->_statuses = array();//Mage::getModel('Mage_Catalog_Model_Product_Status')->getResourceCollection()->load(); - } - - return $this->_statuses; - } - - /** - * Check if a product can be shown - * - * @param Mage_Catalog_Model_Product|int $product - * @return boolean - */ - public function canShow($product, $where = 'catalog') - { - if (is_int($product)) { - $product = Mage::getModel('Mage_Catalog_Model_Product')->load($product); - } - - /* @var $product Mage_Catalog_Model_Product */ - - if (!$product->getId()) { - return false; - } - - return $product->isVisibleInCatalog() && $product->isVisibleInSiteVisibility(); - } - - /** - * Retrieve product rewrite sufix for store - * - * @param int $storeId - * @return string - */ - public function getProductUrlSuffix($storeId = null) - { - if (is_null($storeId)) { - $storeId = Mage::app()->getStore()->getId(); - } - - if (!isset($this->_productUrlSuffix[$storeId])) { - $this->_productUrlSuffix[$storeId] = Mage::getStoreConfig(self::XML_PATH_PRODUCT_URL_SUFFIX, $storeId); - } - return $this->_productUrlSuffix[$storeId]; - } - - /** - * Check if can be used for product - * - * @param $store - * @return bool - */ - public function canUseCanonicalTag($store = null) - { - return Mage::getStoreConfig(self::XML_PATH_USE_PRODUCT_CANONICAL_TAG, $store); - } - - /** - * Return information array of product attribute input types - * Only a small number of settings returned, so we won't break anything in current data flow - * As soon as development process goes on we need to add there all possible settings - * - * @param string $inputType - * @return array - */ - public function getAttributeInputTypes($inputType = null) - { - /** - * @todo specify there all relations for properties depending on input type - */ - $inputTypes = array( - 'multiselect' => array( - 'backend_model' => 'Mage_Eav_Model_Entity_Attribute_Backend_Array' - ), - 'boolean' => array( - 'source_model' => 'Mage_Eav_Model_Entity_Attribute_Source_Boolean' - ) - ); - - if (is_null($inputType)) { - return $inputTypes; - } else if (isset($inputTypes[$inputType])) { - return $inputTypes[$inputType]; - } - return array(); - } - - /** - * Return default attribute backend model by input type - * - * @param string $inputType - * @return string|null - */ - public function getAttributeBackendModelByInputType($inputType) - { - $inputTypes = $this->getAttributeInputTypes(); - if (!empty($inputTypes[$inputType]['backend_model'])) { - return $inputTypes[$inputType]['backend_model']; - } - return null; - } - - /** - * Return default attribute source model by input type - * - * @param string $inputType - * @return string|null - */ - public function getAttributeSourceModelByInputType($inputType) - { - $inputTypes = $this->getAttributeInputTypes(); - if (!empty($inputTypes[$inputType]['source_model'])) { - return $inputTypes[$inputType]['source_model']; - } - return null; - } - - /** - * Inits product to be used for product controller actions and layouts - * $params can have following data: - * 'category_id' - id of category to check and append to product as current. - * If empty (except FALSE) - will be guessed (e.g. from last visited) to load as current. - * - * @param int $productId - * @param Mage_Core_Controller_Front_Action $controller - * @param Varien_Object $params - * - * @return false|Mage_Catalog_Model_Product - */ - public function initProduct($productId, $controller, $params = null) - { - // Prepare data for routine - if (!$params) { - $params = new Varien_Object(); - } - - // Init and load product - Mage::dispatchEvent('catalog_controller_product_init_before', array( - 'controller_action' => $controller, - 'params' => $params, - )); - - if (!$productId) { - return false; - } - - $product = Mage::getModel('Mage_Catalog_Model_Product') - ->setStoreId(Mage::app()->getStore()->getId()) - ->load($productId); - - if (!$this->canShow($product)) { - return false; - } - if (!in_array(Mage::app()->getStore()->getWebsiteId(), $product->getWebsiteIds())) { - return false; - } - - // Load product current category - $categoryId = $params->getCategoryId(); - if (!$categoryId && ($categoryId !== false)) { - $lastId = Mage::getSingleton('Mage_Catalog_Model_Session')->getLastVisitedCategoryId(); - if ($product->canBeShowInCategory($lastId)) { - $categoryId = $lastId; - } - } elseif (!$product->canBeShowInCategory($categoryId)) { - $categoryId = null; - } - - if ($categoryId) { - $category = Mage::getModel('Mage_Catalog_Model_Category')->load($categoryId); - $product->setCategory($category); - Mage::register('current_category', $category); - } - - // Register current data and dispatch final events - Mage::register('current_product', $product); - Mage::register('product', $product); - - try { - Mage::dispatchEvent('catalog_controller_product_init', array('product' => $product)); - Mage::dispatchEvent('catalog_controller_product_init_after', - array('product' => $product, - 'controller_action' => $controller - ) - ); - } catch (Mage_Core_Exception $e) { - Mage::logException($e); - return false; - } - - return $product; - } - - /** - * Prepares product options by buyRequest: retrieves values and assigns them as default. - * Also parses and adds product management related values - e.g. qty - * - * @param Mage_Catalog_Model_Product $product - * @param Varien_Object $buyRequest - * @return Mage_Catalog_Helper_Product - */ - public function prepareProductOptions($product, $buyRequest) - { - $optionValues = $product->processBuyRequest($buyRequest); - $optionValues->setQty($buyRequest->getQty()); - $product->setPreconfiguredValues($optionValues); - - return $this; - } - - /** - * Process $buyRequest and sets its options before saving configuration to some product item. - * This method is used to attach additional parameters to processed buyRequest. - * - * $params holds parameters of what operation must be performed: - * - 'current_config', Varien_Object or array - current buyRequest that configures product in this item, - * used to restore currently attached files - * - 'files_prefix': string[a-z0-9_] - prefix that was added at frontend to names of file inputs, - * so they won't intersect with other submitted options - * - * @param Varien_Object|array $buyRequest - * @param Varien_Object|array $params - * @return Varien_Object - */ - public function addParamsToBuyRequest($buyRequest, $params) - { - if (is_array($buyRequest)) { - $buyRequest = new Varien_Object($buyRequest); - } - if (is_array($params)) { - $params = new Varien_Object($params); - } - - - // Ensure that currentConfig goes as Varien_Object - for easier work with it later - $currentConfig = $params->getCurrentConfig(); - if ($currentConfig) { - if (is_array($currentConfig)) { - $params->setCurrentConfig(new Varien_Object($currentConfig)); - } else if (!($currentConfig instanceof Varien_Object)) { - $params->unsCurrentConfig(); - } - } - - /* - * Notice that '_processing_params' must always be object to protect processing forged requests - * where '_processing_params' comes in $buyRequest as array from user input - */ - $processingParams = $buyRequest->getData('_processing_params'); - if (!$processingParams || !($processingParams instanceof Varien_Object)) { - $processingParams = new Varien_Object(); - $buyRequest->setData('_processing_params', $processingParams); - } - $processingParams->addData($params->getData()); - - return $buyRequest; - } - - /** - * Return loaded product instance - * - * @param int|string $productId (SKU or ID) - * @param int $store - * @param string $identifierType - * @return Mage_Catalog_Model_Product - */ - public function getProduct($productId, $store, $identifierType = null) - { - /** @var $product Mage_Catalog_Model_Product */ - $product = Mage::getModel('Mage_Catalog_Model_Product')->setStoreId(Mage::app()->getStore($store)->getId()); - - $expectedIdType = false; - if ($identifierType === null) { - if (is_string($productId) && !preg_match("/^[+-]?[1-9][0-9]*$|^0$/", $productId)) { - $expectedIdType = 'sku'; - } - } - - if ($identifierType == 'sku' || $expectedIdType == 'sku') { - $idBySku = $product->getIdBySku($productId); - if ($idBySku) { - $productId = $idBySku; - } else if ($identifierType == 'sku') { - // Return empty product because it was not found by originally specified SKU identifier - return $product; - } - } - - if ($productId && is_numeric($productId)) { - $product->load((int) $productId); - } - - return $product; - } - - /** - * Set flag that shows if Magento has to check product to be saleable (enabled and/or inStock) - * - * For instance, during order creation in the backend admin has ability to add any products to order - * - * @param bool $skipSaleableCheck - * @return Mage_Catalog_Helper_Product - */ - public function setSkipSaleableCheck($skipSaleableCheck = false) - { - $this->_skipSaleableCheck = $skipSaleableCheck; - return $this; - } - - /** - * Get flag that shows if Magento has to check product to be saleable (enabled and/or inStock) - * - * @return boolean - */ - public function getSkipSaleableCheck() - { - return $this->_skipSaleableCheck; - } - - /** - * Get masks for auto generation of fields - * - * @return array - */ - public function getFieldsAutogenerationMasks() - { - return Mage::getConfig() - ->getNode(Mage_Catalog_Helper_Product::XML_PATH_AUTO_GENERATE_MASK, 'default') - ->asArray(); - } - - /** - * Retrieve list of attributes that cannot be removed from attribute set - * - * @return array - */ - public function getUnassignableAttributes() - { - $data = Mage::getConfig()->getNode(self::XML_PATH_UNASSIGNABLE_ATTRIBUTES); - return false === $data || is_string($data->asArray()) ? array() : array_keys($data->asArray()); - } - - /** - * Retrieve list of attributes that allowed for autogeneration - * - * @return array - */ - public function getAttributesAllowedForAutogeneration() - { - return array_keys(Mage::getConfig()->getNode(self::XML_PATH_ATTRIBUTES_USED_IN_AUTOGENERATION)->asArray()); - } - - /** - * Get label for virtual control - * - * @return string - */ - public function getTypeSwitcherControlLabel() - { - return $this->__((string)Mage::getConfig()->getNode(self::XML_PATH_PRODUCT_TYPE_SWITCHER_LABEL)); - } -} diff --git a/app/code/core/Mage/Catalog/Helper/Product/Options.php b/app/code/core/Mage/Catalog/Helper/Product/Options.php deleted file mode 100644 index 43a41376db25a..0000000000000 --- a/app/code/core/Mage/Catalog/Helper/Product/Options.php +++ /dev/null @@ -1,81 +0,0 @@ - - */ -class Mage_Catalog_Helper_Product_Options extends Mage_Core_Helper_Abstract -{ - /** - * @var Magento_Filesystem - */ - protected $_filesystem; - - /** - * @param Magento_Filesystem $filesystem - */ - public function __construct(Magento_Filesystem $filesystem) - { - $this->_filesystem = $filesystem; - } - - /** - * Fetches and outputs file to user browser - * $info is array with following indexes: - * - 'path' - full file path - * - 'type' - mime type of file - * - 'size' - size of file - * - 'title' - user-friendly name of file (usually - original name as uploaded in Magento) - * - * @param Mage_Core_Controller_Response_Http $response - * @param string $filePath - * @param array $info - * @return bool - */ - public function downloadFileOption($response, $filePath, $info) - { - try { - $response->setHttpResponseCode(200) - ->setHeader('Pragma', 'public', true) - ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true) - ->setHeader('Content-type', $info['type'], true) - ->setHeader('Content-Length', $info['size']) - ->setHeader('Content-Disposition', 'inline' . '; filename='.$info['title']) - ->clearBody(); - $response->sendHeaders(); - - echo $this->_filesystem->read($filePath); - } catch (Exception $e) { - return false; - } - return true; - } -} diff --git a/app/code/core/Mage/Catalog/Helper/Product/Url.php b/app/code/core/Mage/Catalog/Helper/Product/Url.php deleted file mode 100644 index 0e38fec0ce8c5..0000000000000 --- a/app/code/core/Mage/Catalog/Helper/Product/Url.php +++ /dev/null @@ -1,135 +0,0 @@ - - */ -class Mage_Catalog_Helper_Product_Url extends Mage_Core_Helper_Url -{ - /** - * Symbol convert table - * - * @var array - */ - protected $_convertTable = array( - '&' => 'and', '@' => 'at', '©' => 'c', '®' => 'r', 'À' => 'a', - 'Á' => 'a', 'Â' => 'a', 'Ä' => 'a', 'Å' => 'a', 'Æ' => 'ae','Ç' => 'c', - 'È' => 'e', 'É' => 'e', 'Ë' => 'e', 'Ì' => 'i', 'Í' => 'i', 'Î' => 'i', - 'Ï' => 'i', 'Ò' => 'o', 'Ó' => 'o', 'Ô' => 'o', 'Õ' => 'o', 'Ö' => 'o', - 'Ø' => 'o', 'Ù' => 'u', 'Ú' => 'u', 'Û' => 'u', 'Ü' => 'u', 'Ý' => 'y', - 'ß' => 'ss','à' => 'a', 'á' => 'a', 'â' => 'a', 'ä' => 'a', 'å' => 'a', - 'æ' => 'ae','ç' => 'c', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', - 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ò' => 'o', 'ó' => 'o', - 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ø' => 'o', 'ù' => 'u', 'ú' => 'u', - 'û' => 'u', 'ü' => 'u', 'ý' => 'y', 'þ' => 'p', 'ÿ' => 'y', 'Ā' => 'a', - 'ā' => 'a', 'Ă' => 'a', 'ă' => 'a', 'Ą' => 'a', 'ą' => 'a', 'Ć' => 'c', - 'ć' => 'c', 'Ĉ' => 'c', 'ĉ' => 'c', 'Ċ' => 'c', 'ċ' => 'c', 'Č' => 'c', - 'č' => 'c', 'Ď' => 'd', 'ď' => 'd', 'Đ' => 'd', 'đ' => 'd', 'Ē' => 'e', - 'ē' => 'e', 'Ĕ' => 'e', 'ĕ' => 'e', 'Ė' => 'e', 'ė' => 'e', 'Ę' => 'e', - 'ę' => 'e', 'Ě' => 'e', 'ě' => 'e', 'Ĝ' => 'g', 'ĝ' => 'g', 'Ğ' => 'g', - 'ğ' => 'g', 'Ġ' => 'g', 'ġ' => 'g', 'Ģ' => 'g', 'ģ' => 'g', 'Ĥ' => 'h', - 'ĥ' => 'h', 'Ħ' => 'h', 'ħ' => 'h', 'Ĩ' => 'i', 'ĩ' => 'i', 'Ī' => 'i', - 'ī' => 'i', 'Ĭ' => 'i', 'ĭ' => 'i', 'Į' => 'i', 'į' => 'i', 'İ' => 'i', - 'ı' => 'i', 'IJ' => 'ij','ij' => 'ij','Ĵ' => 'j', 'ĵ' => 'j', 'Ķ' => 'k', - 'ķ' => 'k', 'ĸ' => 'k', 'Ĺ' => 'l', 'ĺ' => 'l', 'Ļ' => 'l', 'ļ' => 'l', - 'Ľ' => 'l', 'ľ' => 'l', 'Ŀ' => 'l', 'ŀ' => 'l', 'Ł' => 'l', 'ł' => 'l', - 'Ń' => 'n', 'ń' => 'n', 'Ņ' => 'n', 'ņ' => 'n', 'Ň' => 'n', 'ň' => 'n', - 'ʼn' => 'n', 'Ŋ' => 'n', 'ŋ' => 'n', 'Ō' => 'o', 'ō' => 'o', 'Ŏ' => 'o', - 'ŏ' => 'o', 'Ő' => 'o', 'ő' => 'o', 'Œ' => 'oe','œ' => 'oe','Ŕ' => 'r', - 'ŕ' => 'r', 'Ŗ' => 'r', 'ŗ' => 'r', 'Ř' => 'r', 'ř' => 'r', 'Ś' => 's', - 'ś' => 's', 'Ŝ' => 's', 'ŝ' => 's', 'Ş' => 's', 'ş' => 's', 'Š' => 's', - 'š' => 's', 'Ţ' => 't', 'ţ' => 't', 'Ť' => 't', 'ť' => 't', 'Ŧ' => 't', - 'ŧ' => 't', 'Ũ' => 'u', 'ũ' => 'u', 'Ū' => 'u', 'ū' => 'u', 'Ŭ' => 'u', - 'ŭ' => 'u', 'Ů' => 'u', 'ů' => 'u', 'Ű' => 'u', 'ű' => 'u', 'Ų' => 'u', - 'ų' => 'u', 'Ŵ' => 'w', 'ŵ' => 'w', 'Ŷ' => 'y', 'ŷ' => 'y', 'Ÿ' => 'y', - 'Ź' => 'z', 'ź' => 'z', 'Ż' => 'z', 'ż' => 'z', 'Ž' => 'z', 'ž' => 'z', - 'ſ' => 'z', 'Ə' => 'e', 'ƒ' => 'f', 'Ơ' => 'o', 'ơ' => 'o', 'Ư' => 'u', - 'ư' => 'u', 'Ǎ' => 'a', 'ǎ' => 'a', 'Ǐ' => 'i', 'ǐ' => 'i', 'Ǒ' => 'o', - 'ǒ' => 'o', 'Ǔ' => 'u', 'ǔ' => 'u', 'Ǖ' => 'u', 'ǖ' => 'u', 'Ǘ' => 'u', - 'ǘ' => 'u', 'Ǚ' => 'u', 'ǚ' => 'u', 'Ǜ' => 'u', 'ǜ' => 'u', 'Ǻ' => 'a', - 'ǻ' => 'a', 'Ǽ' => 'ae','ǽ' => 'ae','Ǿ' => 'o', 'ǿ' => 'o', 'ə' => 'e', - 'Ё' => 'jo','Є' => 'e', 'І' => 'i', 'Ї' => 'i', 'А' => 'a', 'Б' => 'b', - 'В' => 'v', 'Г' => 'g', 'Д' => 'd', 'Е' => 'e', 'Ж' => 'zh','З' => 'z', - 'И' => 'i', 'Й' => 'j', 'К' => 'k', 'Л' => 'l', 'М' => 'm', 'Н' => 'n', - 'О' => 'o', 'П' => 'p', 'Р' => 'r', 'С' => 's', 'Т' => 't', 'У' => 'u', - 'Ф' => 'f', 'Х' => 'h', 'Ц' => 'c', 'Ч' => 'ch','Ш' => 'sh','Щ' => 'sch', - 'Ъ' => '-', 'Ы' => 'y', 'Ь' => '-', 'Э' => 'je','Ю' => 'ju','Я' => 'ja', - 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e', - 'ж' => 'zh','з' => 'z', 'и' => 'i', 'й' => 'j', 'к' => 'k', 'л' => 'l', - 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', - 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch', - 'ш' => 'sh','щ' => 'sch','ъ' => '-','ы' => 'y', 'ь' => '-', 'э' => 'je', - 'ю' => 'ju','я' => 'ja','ё' => 'jo','є' => 'e', 'і' => 'i', 'ї' => 'i', - 'Ґ' => 'g', 'ґ' => 'g', 'א' => 'a', 'ב' => 'b', 'ג' => 'g', 'ד' => 'd', - 'ה' => 'h', 'ו' => 'v', 'ז' => 'z', 'ח' => 'h', 'ט' => 't', 'י' => 'i', - 'ך' => 'k', 'כ' => 'k', 'ל' => 'l', 'ם' => 'm', 'מ' => 'm', 'ן' => 'n', - 'נ' => 'n', 'ס' => 's', 'ע' => 'e', 'ף' => 'p', 'פ' => 'p', 'ץ' => 'C', - 'צ' => 'c', 'ק' => 'q', 'ר' => 'r', 'ש' => 'w', 'ת' => 't', '™' => 'tm', - ); - - /** - * Check additional instruction for convertation table in configuration - * - * @param Mage_Core_Model_Translate $translator - * @param Mage_Core_Model_Config $config - */ - public function __construct(Mage_Core_Model_Translate $translator, Mage_Core_Model_Config $config) - { - parent::__construct($translator); - $convertNode = $config->getNode('default/url/convert'); - if ($convertNode) { - foreach ($convertNode->children() as $node) { - $this->_convertTable[strval($node->from)] = strval($node->to); - } - } - } - - /** - * Get chars convertation table - * - * @return array - */ - public function getConvertTable() - { - return $this->_convertTable; - } - - /** - * Process string based on convertation table - * - * @param string $string - * @return string - */ - public function format($string) - { - return strtr($string, $this->getConvertTable()); - } -} diff --git a/app/code/core/Mage/Catalog/Helper/Product/View.php b/app/code/core/Mage/Catalog/Helper/Product/View.php deleted file mode 100644 index 6a47172a86c0b..0000000000000 --- a/app/code/core/Mage/Catalog/Helper/Product/View.php +++ /dev/null @@ -1,198 +0,0 @@ - - */ -class Mage_Catalog_Helper_Product_View extends Mage_Core_Helper_Abstract -{ - // List of exceptions throwable during prepareAndRender() method - public $ERR_NO_PRODUCT_LOADED = 1; - public $ERR_BAD_CONTROLLER_INTERFACE = 2; - - /** - * Path to list of session models to get messages - */ - const XML_PATH_SESSION_MESSAGE_MODELS = 'global/session/catalog/product/message_models'; - - /** - * General config object - * - * @var Mage_Core_Model_Config - */ - protected $_config; - - /** - * @param Mage_Core_Model_Translate $translator - * @param Mage_Core_Model_Config $config - * @param array $data - */ - public function __construct( - Mage_Core_Model_Translate $translator, - Mage_Core_Model_Config $config, - array $data = array() - ) { - parent::__construct($translator); - $this->_config = $config; - } - - /** - * Inits layout for viewing product page - * - * @param Mage_Catalog_Model_Product $product - * @param Mage_Core_Controller_Front_Action $controller - * - * @return Mage_Catalog_Helper_Product_View - */ - public function initProductLayout($product, $controller) - { - $design = Mage::getSingleton('Mage_Catalog_Model_Design'); - $settings = $design->getDesignSettings($product); - - if ($settings->getCustomDesign()) { - $design->applyCustomDesign($settings->getCustomDesign()); - } - - $update = $controller->getLayout()->getUpdate(); - $controller->addPageLayoutHandles( - array('id' => $product->getId(), 'sku' => $product->getSku(), 'type' => $product->getTypeId()) - ); - $controller->loadLayoutUpdates(); - // Apply custom layout update once layout is loaded - $layoutUpdates = $settings->getLayoutUpdates(); - if ($layoutUpdates) { - if (is_array($layoutUpdates)) { - foreach ($layoutUpdates as $layoutUpdate) { - $update->addUpdate($layoutUpdate); - } - } - } - - $controller->generateLayoutXml()->generateLayoutBlocks(); - - // Apply custom layout (page) template once the blocks are generated - if ($settings->getPageLayout()) { - $controller->getLayout()->helper('Mage_Page_Helper_Layout')->applyTemplate($settings->getPageLayout()); - } - - $currentCategory = Mage::registry('current_category'); - $root = $controller->getLayout()->getBlock('root'); - if ($root) { - $controllerClass = $controller->getFullActionName(); - if ($controllerClass != 'catalog-product-view') { - $root->addBodyClass('catalog-product-view'); - } - $root->addBodyClass('product-' . $product->getUrlKey()); - if ($currentCategory instanceof Mage_Catalog_Model_Category) { - $root->addBodyClass('categorypath-' . $currentCategory->getUrlPath()) - ->addBodyClass('category-' . $currentCategory->getUrlKey()); - } - } - - return $this; - } - - /** - * Prepares product view page - inits layout and all needed stuff - * - * $params can have all values as $params in Mage_Catalog_Helper_Product - initProduct(). - * Plus following keys: - * - 'buy_request' - Varien_Object holding buyRequest to configure product - * - 'specify_options' - boolean, whether to show 'Specify options' message - * - 'configure_mode' - boolean, whether we're in Configure-mode to edit product configuration - * - * @param int $productId - * @param Mage_Core_Controller_Front_Action $controller - * @param null|Varien_Object $params - * - * @return Mage_Catalog_Helper_Product_View - * @throws Mage_Core_Exception - */ - public function prepareAndRender($productId, $controller, $params = null) - { - // Prepare data - $productHelper = Mage::helper('Mage_Catalog_Helper_Product'); - if (!$params) { - $params = new Varien_Object(); - } - - // Standard algorithm to prepare and rendern product view page - $product = $productHelper->initProduct($productId, $controller, $params); - if (!$product) { - throw new Mage_Core_Exception($this->__('Product is not loaded'), $this->ERR_NO_PRODUCT_LOADED); - } - - $buyRequest = $params->getBuyRequest(); - if ($buyRequest) { - $productHelper->prepareProductOptions($product, $buyRequest); - } - - if ($params->hasConfigureMode()) { - $product->setConfigureMode($params->getConfigureMode()); - } - - Mage::dispatchEvent('catalog_controller_product_view', array('product' => $product)); - - if ($params->getSpecifyOptions()) { - $notice = $product->getTypeInstance()->getSpecifyOptionMessage(); - Mage::getSingleton('Mage_Catalog_Model_Session')->addNotice($notice); - } - - Mage::getSingleton('Mage_Catalog_Model_Session')->setLastViewedProductId($product->getId()); - - $this->initProductLayout($product, $controller); - - if ($controller instanceof Mage_Catalog_Controller_Product_View_Interface) { - foreach ($this->_getSessionMessageModels() as $sessionModel) { - $controller->initLayoutMessages($sessionModel); - } - } else { - throw new Mage_Core_Exception( - $this->__('Bad controller interface for showing product'), - $this->ERR_BAD_CONTROLLER_INTERFACE - ); - } - $controller->renderLayout(); - - return $this; - } - - /** - * Get list of session models with messages - * - * @return array - */ - protected function _getSessionMessageModels() - { - $messageModels = $this->_config->getNode(self::XML_PATH_SESSION_MESSAGE_MODELS) - ->asArray(); - return array_values($messageModels); - } -} diff --git a/app/code/core/Mage/Catalog/Model/Product.php b/app/code/core/Mage/Catalog/Model/Product.php deleted file mode 100644 index 006627ba7938e..0000000000000 --- a/app/code/core/Mage/Catalog/Model/Product.php +++ /dev/null @@ -1,1993 +0,0 @@ - - */ -class Mage_Catalog_Model_Product extends Mage_Catalog_Model_Abstract -{ - /** - * Entity code. - * Can be used as part of method name for entity processing - */ - const ENTITY = 'catalog_product'; - - const CACHE_TAG = 'catalog_product'; - protected $_cacheTag = 'catalog_product'; - protected $_eventPrefix = 'catalog_product'; - protected $_eventObject = 'product'; - protected $_canAffectOptions = false; - - /** - * Product type singleton instance - * - * @var Mage_Catalog_Model_Product_Type_Abstract - */ - protected $_typeInstance = null; - - /** - * Product link instance - * - * @var Mage_Catalog_Model_Product_Link - */ - protected $_linkInstance; - - /** - * Product object customization (not stored in DB) - * - * @var array - */ - protected $_customOptions = array(); - - /** - * Product Url Instance - * - * @var Mage_Catalog_Model_Product_Url - */ - protected $_urlModel = null; - - protected static $_url; - protected static $_urlRewrite; - - protected $_errors = array(); - - protected $_optionInstance; - - protected $_options = array(); - - /** - * Product reserved attribute codes - */ - protected $_reservedAttributes; - - /** - * Flag for available duplicate function - * - * @var boolean - */ - protected $_isDuplicable = true; - - /** - * Flag for get Price function - * - * @var boolean - */ - protected $_calculatePrice = true; - - /** - * @param Mage_Core_Model_Event_Manager $eventDispatcher - * @param Mage_Core_Model_Cache $cacheManager - * @param Mage_Catalog_Model_Resource_Product $resource - * @param Mage_Catalog_Model_Resource_Product_Collection $resourceCollection - * @param array $data - */ - public function __construct( - Mage_Core_Model_Event_Manager $eventDispatcher, - Mage_Core_Model_Cache $cacheManager, - Mage_Catalog_Model_Resource_Product $resource, - Mage_Catalog_Model_Resource_Product_Collection $resourceCollection, - array $data = array() - ) { - parent::__construct($eventDispatcher, $cacheManager, $resource, $resourceCollection, $data); - } - - /** - * Initialize resources - */ - protected function _construct() - { - $this->_init('Mage_Catalog_Model_Resource_Product'); - } - - /** - * Retrieve Store Id - * - * @return int - */ - public function getStoreId() - { - if ($this->hasData('store_id')) { - return $this->getData('store_id'); - } - return Mage::app()->getStore()->getId(); - } - - /** - * Get collection instance - * - * @return object - */ - public function getResourceCollection() - { - $collection = parent::getResourceCollection(); - $collection->setStoreId($this->getStoreId()); - return $collection; - } - - /** - * Get product url model - * - * @return Mage_Catalog_Model_Product_Url - */ - public function getUrlModel() - { - if ($this->_urlModel === null) { - $this->_urlModel = Mage::getSingleton('Mage_Catalog_Model_Product_Url'); - } - return $this->_urlModel; - } - - /** - * Validate Product Data - * - * @todo implement full validation process with errors returning which are ignoring now - * - * @return array - */ - public function validate() - { - Mage::dispatchEvent($this->_eventPrefix . '_validate_before', array($this->_eventObject => $this)); - $this->_enforceFunctionalLimitations(); - $result = $this->_getResource()->validate($this); - Mage::dispatchEvent($this->_eventPrefix . '_validate_after', array($this->_eventObject => $this)); - return $result; - } - - /** - * Get product name - * - * @return string - */ - public function getName() - { - return $this->_getData('name'); - } - - /** - * Get product price throught type instance - * - * @return unknown - */ - public function getPrice() - { - if ($this->_calculatePrice || !$this->getData('price')) { - return $this->getPriceModel()->getPrice($this); - } else { - return $this->getData('price'); - } - } - - /** - * Set Price calculation flag - * - * @param bool $calculate - * @return void - */ - public function setPriceCalculation($calculate = true) - { - $this->_calculatePrice = $calculate; - } - - /** - * Get product type identifier - * - * @return string - */ - public function getTypeId() - { - return $this->_getData('type_id'); - } - - /** - * Get product status - * - * @return int - */ - public function getStatus() - { - if (is_null($this->_getData('status'))) { - $this->setData('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED); - } - return $this->_getData('status'); - } - - /** - * Retrieve type instance of the product. - * Type instance implements product type depended logic and is a singleton shared by all products of the same type. - * - * @return Mage_Catalog_Model_Product_Type_Abstract - */ - public function getTypeInstance() - { - if ($this->_typeInstance === null) { - $this->_typeInstance = Mage::getSingleton('Mage_Catalog_Model_Product_Type') - ->factory($this); - } - return $this->_typeInstance; - } - - /** - * Set type instance for the product - * - * @param Mage_Catalog_Model_Product_Type_Abstract|null $instance Product type instance - * @return Mage_Catalog_Model_Product - */ - public function setTypeInstance($instance) - { - $this->_typeInstance = $instance; - return $this; - } - - /** - * Retrieve link instance - * - * @return Mage_Catalog_Model_Product_Link - */ - public function getLinkInstance() - { - if (!$this->_linkInstance) { - $this->_linkInstance = Mage::getSingleton('Mage_Catalog_Model_Product_Link'); - } - return $this->_linkInstance; - } - - /** - * Retrive product id by sku - * - * @param string $sku - * @return integer - */ - public function getIdBySku($sku) - { - return $this->_getResource()->getIdBySku($sku); - } - - /** - * Retrieve product category id - * - * @return int - */ - public function getCategoryId() - { - if ($category = Mage::registry('current_category')) { - return $category->getId(); - } - return false; - } - - /** - * Retrieve product category - * - * @return Mage_Catalog_Model_Category - */ - public function getCategory() - { - $category = $this->getData('category'); - if (is_null($category) && $this->getCategoryId()) { - $category = Mage::getModel('Mage_Catalog_Model_Category')->load($this->getCategoryId()); - $this->setCategory($category); - } - return $category; - } - - /** - * Retrieve assigned category Ids - * - * @return array - */ - public function getCategoryIds() - { - if (!$this->hasData('category_ids')) { - $wasLocked = false; - if ($this->isLockedAttribute('category_ids')) { - $wasLocked = true; - $this->unlockAttribute('category_ids'); - } - $ids = $this->_getResource()->getCategoryIds($this); - $this->setData('category_ids', $ids); - if ($wasLocked) { - $this->lockAttribute('category_ids'); - } - } - - return (array)$this->_getData('category_ids'); - } - - /** - * Retrieve product categories - * - * @return Varien_Data_Collection - */ - public function getCategoryCollection() - { - return $this->_getResource()->getCategoryCollection($this); - } - - /** - * Retrieve product websites identifiers - * - * @return array - */ - public function getWebsiteIds() - { - if (!$this->hasWebsiteIds()) { - $ids = $this->_getResource()->getWebsiteIds($this); - $this->setWebsiteIds($ids); - } - return $this->getData('website_ids'); - } - - /** - * Get all sore ids where product is presented - * - * @return array - */ - public function getStoreIds() - { - if (!$this->hasStoreIds()) { - $storeIds = array(); - if ($websiteIds = $this->getWebsiteIds()) { - foreach ($websiteIds as $websiteId) { - $websiteStores = Mage::app()->getWebsite($websiteId)->getStoreIds(); - $storeIds = array_merge($storeIds, $websiteStores); - } - } - $this->setStoreIds($storeIds); - } - return $this->getData('store_ids'); - } - - /** - * Retrieve product attributes - * if $groupId is null - retrieve all product attributes - * - * @param int $groupId Retrieve attributes of the specified group - * @param bool $skipSuper Not used - * @return array - */ - public function getAttributes($groupId = null, $skipSuper = false) - { - $productAttributes = $this->getTypeInstance()->getEditableAttributes($this); - if ($groupId) { - $attributes = array(); - foreach ($productAttributes as $attribute) { - if ($attribute->isInGroup($this->getAttributeSetId(), $groupId)) { - $attributes[] = $attribute; - } - } - } else { - $attributes = $productAttributes; - } - - return $attributes; - } - - /** - * Check product options and type options and save them, too - */ - protected function _beforeSave() - { - $this->cleanCache(); - $this->setTypeHasOptions(false); - $this->setTypeHasRequiredOptions(false); - - $this->getTypeInstance()->beforeSave($this); - - $hasOptions = false; - $hasRequiredOptions = false; - - /** - * $this->_canAffectOptions - set by type instance only - * $this->getCanSaveCustomOptions() - set either in controller when "Custom Options" ajax tab is loaded, - * or in type instance as well - */ - $this->canAffectOptions($this->_canAffectOptions && $this->getCanSaveCustomOptions()); - if ($this->getCanSaveCustomOptions()) { - $options = $this->getProductOptions(); - if (is_array($options)) { - $this->setIsCustomOptionChanged(true); - foreach ($this->getProductOptions() as $option) { - $this->getOptionInstance()->addOption($option); - if ((!isset($option['is_delete'])) || $option['is_delete'] != '1') { - $hasOptions = true; - } - } - foreach ($this->getOptionInstance()->getOptions() as $option) { - if ($option['is_require'] == '1') { - $hasRequiredOptions = true; - break; - } - } - } - } - - /** - * Set true, if any - * Set false, ONLY if options have been affected by Options tab and Type instance tab - */ - if ($hasOptions || (bool)$this->getTypeHasOptions()) { - $this->setHasOptions(true); - if ($hasRequiredOptions || (bool)$this->getTypeHasRequiredOptions()) { - $this->setRequiredOptions(true); - } elseif ($this->canAffectOptions()) { - $this->setRequiredOptions(false); - } - } elseif ($this->canAffectOptions()) { - $this->setHasOptions(false); - $this->setRequiredOptions(false); - } - - parent::_beforeSave(); - $this->_enforceFunctionalLimitations(); - } - - /** - * Sub-routine for enforcing functional limitations - * - * @throws Mage_Core_Exception - */ - protected function _enforceFunctionalLimitations() - { - /** @var $limitation Mage_Catalog_Model_Product_Limitation */ - $limitation = Mage::getObjectManager()->get('Mage_Catalog_Model_Product_Limitation'); - if ($this->isObjectNew() && $limitation->isCreateRestricted()) { - throw new Mage_Core_Exception($limitation->getCreateRestrictedMessage()); - } - } - - /** - * Check/set if options can be affected when saving product - * If value specified, it will be set. - * - * @param bool $value - * @return bool - */ - public function canAffectOptions($value = null) - { - if (null !== $value) { - $this->_canAffectOptions = (bool)$value; - } - return $this->_canAffectOptions; - } - - /** - * Saving product type related data and init index - * - * @return Mage_Catalog_Model_Product - */ - protected function _afterSave() - { - $this->getLinkInstance()->saveProductRelations($this); - $this->getTypeInstance()->save($this); - - /** - * Product Options - */ - $this->getOptionInstance()->setProduct($this) - ->saveOptions(); - - $result = parent::_afterSave(); - - Mage::getSingleton('Mage_Index_Model_Indexer')->processEntityAction( - $this, self::ENTITY, Mage_Index_Model_Event::TYPE_SAVE - ); - return $result; - } - - /** - * Clear chache related with product and protect delete from not admin - * Register indexing event before delete product - * - * @return Mage_Catalog_Model_Product - */ - protected function _beforeDelete() - { - $this->_protectFromNonAdmin(); - $this->cleanCache(); - Mage::getSingleton('Mage_Index_Model_Indexer')->logEvent( - $this, self::ENTITY, Mage_Index_Model_Event::TYPE_DELETE - ); - return parent::_beforeDelete(); - } - - /** - * Init indexing process after product delete commit - * - * @return Mage_Catalog_Model_Product - */ - protected function _afterDeleteCommit() - { - parent::_afterDeleteCommit(); - Mage::getSingleton('Mage_Index_Model_Indexer')->indexEvents( - self::ENTITY, Mage_Index_Model_Event::TYPE_DELETE - ); - } - - /** - * Load product options if they exists - * - * @return Mage_Catalog_Model_Product - */ - protected function _afterLoad() - { - parent::_afterLoad(); - /** - * Load product options - */ - if ($this->getHasOptions()) { - foreach ($this->getProductOptionsCollection() as $option) { - $option->setProduct($this); - $this->addOption($option); - } - } - return $this; - } - - /** - * Clear cache related with product id - * - * @return Mage_Catalog_Model_Product - */ - public function cleanCache() - { - Mage::app()->cleanCache('catalog_product_'.$this->getId()); - return $this; - } - - /** - * Get product price model - * - * @return Mage_Catalog_Model_Product_Type_Price - */ - public function getPriceModel() - { - return Mage::getSingleton('Mage_Catalog_Model_Product_Type')->priceFactory($this->getTypeId()); - } - - /** - * Get product group price - * - * @return float - */ - public function getGroupPrice() - { - return $this->getPriceModel()->getGroupPrice($this); - } - - /** - * Get product tier price by qty - * - * @param double $qty - * @return double - */ - public function getTierPrice($qty=null) - { - return $this->getPriceModel()->getTierPrice($qty, $this); - } - - /** - * Count how many tier prices we have for the product - * - * @return int - */ - public function getTierPriceCount() - { - return $this->getPriceModel()->getTierPriceCount($this); - } - - /** - * Get formated by currency tier price - * - * @param double $qty - * @return array || double - */ - public function getFormatedTierPrice($qty=null) - { - return $this->getPriceModel()->getFormatedTierPrice($qty, $this); - } - - /** - * Get formated by currency product price - * - * @return array || double - */ - public function getFormatedPrice() - { - return $this->getPriceModel()->getFormatedPrice($this); - } - - /** - * Sets final price of product - * - * This func is equal to magic 'setFinalPrice()', but added as a separate func, because in cart with bundle - * products it's called very often in Item->getProduct(). So removing chain of magic with more cpu consuming - * algorithms gives nice optimization boost. - * - * @param float $price Price amount - * @return Mage_Catalog_Model_Product - */ - public function setFinalPrice($price) - { - $this->_data['final_price'] = $price; - return $this; - } - - /** - * Get product final price - * - * @param double $qty - * @return double - */ - public function getFinalPrice($qty=null) - { - $price = $this->_getData('final_price'); - if ($price !== null) { - return $price; - } - return $this->getPriceModel()->getFinalPrice($qty, $this); - } - - /** - * Returns calculated final price - * - * @return float - */ - public function getCalculatedFinalPrice() - { - return $this->_getData('calculated_final_price'); - } - - /** - * Returns minimal price - * - * @return float - */ - public function getMinimalPrice() - { - return max($this->_getData('minimal_price'), 0); - } - - /** - * Returns special price - * - * @return float - */ - public function getSpecialPrice() - { - return $this->_getData('special_price'); - } - - /** - * Returns starting date of the special price - * - * @return mixed - */ - public function getSpecialFromDate() - { - return $this->_getData('special_from_date'); - } - - /** - * Returns end date of the special price - * - * @return mixed - */ - public function getSpecialToDate() - { - return $this->_getData('special_to_date'); - } - - -/******************************************************************************* - ** Linked products API - */ - /** - * Retrieve array of related roducts - * - * @return array - */ - public function getRelatedProducts() - { - if (!$this->hasRelatedProducts()) { - $products = array(); - $collection = $this->getRelatedProductCollection(); - foreach ($collection as $product) { - $products[] = $product; - } - $this->setRelatedProducts($products); - } - return $this->getData('related_products'); - } - - /** - * Retrieve related products identifiers - * - * @return array - */ - public function getRelatedProductIds() - { - if (!$this->hasRelatedProductIds()) { - $ids = array(); - foreach ($this->getRelatedProducts() as $product) { - $ids[] = $product->getId(); - } - $this->setRelatedProductIds($ids); - } - return $this->getData('related_product_ids'); - } - - /** - * Retrieve collection related product - * - * @return Mage_Catalog_Model_Resource_Product_Link_Product_Collection - */ - public function getRelatedProductCollection() - { - $collection = $this->getLinkInstance()->useRelatedLinks() - ->getProductCollection() - ->setIsStrongMode(); - $collection->setProduct($this); - return $collection; - } - - /** - * Retrieve collection related link - * - * @return Mage_Catalog_Model_Resource_Product_Link_Collection - */ - public function getRelatedLinkCollection() - { - $collection = $this->getLinkInstance()->useRelatedLinks() - ->getLinkCollection(); - $collection->setProduct($this); - $collection->addLinkTypeIdFilter(); - $collection->addProductIdFilter(); - $collection->joinAttributes(); - return $collection; - } - - /** - * Retrieve array of up sell products - * - * @return array - */ - public function getUpSellProducts() - { - if (!$this->hasUpSellProducts()) { - $products = array(); - foreach ($this->getUpSellProductCollection() as $product) { - $products[] = $product; - } - $this->setUpSellProducts($products); - } - return $this->getData('up_sell_products'); - } - - /** - * Retrieve up sell products identifiers - * - * @return array - */ - public function getUpSellProductIds() - { - if (!$this->hasUpSellProductIds()) { - $ids = array(); - foreach ($this->getUpSellProducts() as $product) { - $ids[] = $product->getId(); - } - $this->setUpSellProductIds($ids); - } - return $this->getData('up_sell_product_ids'); - } - - /** - * Retrieve collection up sell product - * - * @return Mage_Catalog_Model_Resource_Product_Link_Product_Collection - */ - public function getUpSellProductCollection() - { - $collection = $this->getLinkInstance()->useUpSellLinks() - ->getProductCollection() - ->setIsStrongMode(); - $collection->setProduct($this); - return $collection; - } - - /** - * Retrieve collection up sell link - * - * @return Mage_Catalog_Model_Resource_Product_Link_Collection - */ - public function getUpSellLinkCollection() - { - $collection = $this->getLinkInstance()->useUpSellLinks() - ->getLinkCollection(); - $collection->setProduct($this); - $collection->addLinkTypeIdFilter(); - $collection->addProductIdFilter(); - $collection->joinAttributes(); - return $collection; - } - - /** - * Retrieve array of cross sell products - * - * @return array - */ - public function getCrossSellProducts() - { - if (!$this->hasCrossSellProducts()) { - $products = array(); - foreach ($this->getCrossSellProductCollection() as $product) { - $products[] = $product; - } - $this->setCrossSellProducts($products); - } - return $this->getData('cross_sell_products'); - } - - /** - * Retrieve cross sell products identifiers - * - * @return array - */ - public function getCrossSellProductIds() - { - if (!$this->hasCrossSellProductIds()) { - $ids = array(); - foreach ($this->getCrossSellProducts() as $product) { - $ids[] = $product->getId(); - } - $this->setCrossSellProductIds($ids); - } - return $this->getData('cross_sell_product_ids'); - } - - /** - * Retrieve collection cross sell product - * - * @return Mage_Catalog_Model_Resource_Product_Link_Product_Collection - */ - public function getCrossSellProductCollection() - { - $collection = $this->getLinkInstance()->useCrossSellLinks() - ->getProductCollection() - ->setIsStrongMode(); - $collection->setProduct($this); - return $collection; - } - - /** - * Retrieve collection cross sell link - * - * @return Mage_Catalog_Model_Resource_Product_Link_Collection - */ - public function getCrossSellLinkCollection() - { - $collection = $this->getLinkInstance()->useCrossSellLinks() - ->getLinkCollection(); - $collection->setProduct($this); - $collection->addLinkTypeIdFilter(); - $collection->addProductIdFilter(); - $collection->joinAttributes(); - return $collection; - } - - /** - * Retrieve collection grouped link - * - * @return Mage_Catalog_Model_Resource_Product_Link_Collection - */ - public function getGroupedLinkCollection() - { - $collection = $this->getLinkInstance()->useGroupedLinks() - ->getLinkCollection(); - $collection->setProduct($this); - $collection->addLinkTypeIdFilter(); - $collection->addProductIdFilter(); - $collection->joinAttributes(); - return $collection; - } - -/******************************************************************************* - ** Media API - */ - /** - * Retrive attributes for media gallery - * - * @return array - */ - public function getMediaAttributes() - { - if (!$this->hasMediaAttributes()) { - $mediaAttributes = array(); - foreach ($this->getAttributes() as $attribute) { - if($attribute->getFrontend()->getInputType() == 'media_image') { - $mediaAttributes[$attribute->getAttributeCode()] = $attribute; - } - } - $this->setMediaAttributes($mediaAttributes); - } - return $this->getData('media_attributes'); - } - - /** - * Retrive media gallery images - * - * @return Varien_Data_Collection - */ - public function getMediaGalleryImages() - { - if(!$this->hasData('media_gallery_images') && is_array($this->getMediaGallery('images'))) { - $images = new Varien_Data_Collection(); - foreach ($this->getMediaGallery('images') as $image) { - if (isset($image['disabled']) && $image['disabled']) { - continue; - } - $image['url'] = $this->getMediaConfig()->getMediaUrl($image['file']); - $image['id'] = isset($image['value_id']) ? $image['value_id'] : null; - $image['path'] = $this->getMediaConfig()->getMediaPath($image['file']); - $images->addItem(new Varien_Object($image)); - } - $this->setData('media_gallery_images', $images); - } - - return $this->getData('media_gallery_images'); - } - - /** - * Add image to media gallery - * - * @param string $file file path of image in file system - * @param string|array $mediaAttribute code of attribute with type 'media_image', - * leave blank if image should be only in gallery - * @param boolean $move if true, it will move source file - * @param boolean $exclude mark image as disabled in product page view - * @return Mage_Catalog_Model_Product - */ - public function addImageToMediaGallery($file, $mediaAttribute=null, $move=false, $exclude=true) - { - $attributes = $this->getTypeInstance()->getSetAttributes($this); - if (!isset($attributes['media_gallery'])) { - return $this; - } - $mediaGalleryAttribute = $attributes['media_gallery']; - /* @var $mediaGalleryAttribute Mage_Catalog_Model_Resource_Eav_Attribute */ - $mediaGalleryAttribute->getBackend()->addImage($this, $file, $mediaAttribute, $move, $exclude); - return $this; - } - - /** - * Retrive product media config - * - * @return Mage_Catalog_Model_Product_Media_Config - */ - public function getMediaConfig() - { - return Mage::getSingleton('Mage_Catalog_Model_Product_Media_Config'); - } - - /** - * Create duplicate - * - * @return Mage_Catalog_Model_Product - */ - public function duplicate() - { - $this->getWebsiteIds(); - $this->getCategoryIds(); - - /* @var $newProduct Mage_Catalog_Model_Product */ - $newProduct = Mage::getModel('Mage_Catalog_Model_Product')->setData($this->getData()) - ->setIsDuplicate(true) - ->setOriginalId($this->getId()) - ->setStatus(Mage_Catalog_Model_Product_Status::STATUS_DISABLED) - ->setCreatedAt(null) - ->setUpdatedAt(null) - ->setId(null) - ->setStoreId(Mage::app()->getStore()->getId()); - - Mage::dispatchEvent( - 'catalog_model_product_duplicate', - array('current_product' => $this, 'new_product' => $newProduct) - ); - - /* Prepare Related*/ - $data = array(); - $this->getLinkInstance()->useRelatedLinks(); - $attributes = array(); - foreach ($this->getLinkInstance()->getAttributes() as $_attribute) { - if (isset($_attribute['code'])) { - $attributes[] = $_attribute['code']; - } - } - foreach ($this->getRelatedLinkCollection() as $_link) { - $data[$_link->getLinkedProductId()] = $_link->toArray($attributes); - } - $newProduct->setRelatedLinkData($data); - - /* Prepare UpSell*/ - $data = array(); - $this->getLinkInstance()->useUpSellLinks(); - $attributes = array(); - foreach ($this->getLinkInstance()->getAttributes() as $_attribute) { - if (isset($_attribute['code'])) { - $attributes[] = $_attribute['code']; - } - } - foreach ($this->getUpSellLinkCollection() as $_link) { - $data[$_link->getLinkedProductId()] = $_link->toArray($attributes); - } - $newProduct->setUpSellLinkData($data); - - /* Prepare Cross Sell */ - $data = array(); - $this->getLinkInstance()->useCrossSellLinks(); - $attributes = array(); - foreach ($this->getLinkInstance()->getAttributes() as $_attribute) { - if (isset($_attribute['code'])) { - $attributes[] = $_attribute['code']; - } - } - foreach ($this->getCrossSellLinkCollection() as $_link) { - $data[$_link->getLinkedProductId()] = $_link->toArray($attributes); - } - $newProduct->setCrossSellLinkData($data); - - /* Prepare Grouped */ - $data = array(); - $this->getLinkInstance()->useGroupedLinks(); - $attributes = array(); - foreach ($this->getLinkInstance()->getAttributes() as $_attribute) { - if (isset($_attribute['code'])) { - $attributes[] = $_attribute['code']; - } - } - foreach ($this->getGroupedLinkCollection() as $_link) { - $data[$_link->getLinkedProductId()] = $_link->toArray($attributes); - } - $newProduct->setGroupedLinkData($data); - - $newProduct->save(); - - $this->getOptionInstance()->duplicate($this->getId(), $newProduct->getId()); - $this->getResource()->duplicate($this->getId(), $newProduct->getId()); - - // TODO - duplicate product on all stores of the websites it is associated with - /*if ($storeIds = $this->getWebsiteIds()) { - foreach ($storeIds as $storeId) { - $this->setStoreId($storeId) - ->load($this->getId()); - - $newProduct->setData($this->getData()) - ->setSku(null) - ->setStatus(Mage_Catalog_Model_Product_Status::STATUS_DISABLED) - ->setId($newId) - ->save(); - } - }*/ - return $newProduct; - } - - /** - * Is product grouped - * - * @return bool - */ - public function isSuperGroup() - { - return $this->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_GROUPED; - } - - /** - * Alias for isConfigurable() - * - * @return bool - */ - public function isSuperConfig() - { - return $this->isConfigurable(); - } - /** - * Check is product grouped - * - * @return bool - */ - public function isGrouped() - { - return $this->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_GROUPED; - } - - /** - * Check is product configurable - * - * @return bool - */ - public function isConfigurable() - { - return $this->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE; - } - - /** - * Whether product configurable or grouped - * - * @return bool - */ - public function isSuper() - { - return $this->isConfigurable() || $this->isGrouped(); - } - - /** - * Returns visible status IDs in catalog - * - * @return array - */ - public function getVisibleInCatalogStatuses() - { - return Mage::getSingleton('Mage_Catalog_Model_Product_Status')->getVisibleStatusIds(); - } - - /** - * Retrieve visible statuses - * - * @return array - */ - public function getVisibleStatuses() - { - return Mage::getSingleton('Mage_Catalog_Model_Product_Status')->getVisibleStatusIds(); - } - - /** - * Check Product visilbe in catalog - * - * @return bool - */ - public function isVisibleInCatalog() - { - return in_array($this->getStatus(), $this->getVisibleInCatalogStatuses()); - } - - /** - * Retrieve visible in site visibilities - * - * @return array - */ - public function getVisibleInSiteVisibilities() - { - return Mage::getSingleton('Mage_Catalog_Model_Product_Visibility')->getVisibleInSiteIds(); - } - - /** - * Check Product visible in site - * - * @return bool - */ - public function isVisibleInSiteVisibility() - { - return in_array($this->getVisibility(), $this->getVisibleInSiteVisibilities()); - } - - /** - * Checks product can be duplicated - * - * @return boolean - */ - public function isDuplicable() - { - return $this->_isDuplicable; - } - - /** - * Set is duplicable flag - * - * @param boolean $value - * @return Mage_Catalog_Model_Product - */ - public function setIsDuplicable($value) - { - $this->_isDuplicable = (boolean) $value; - return $this; - } - - - /** - * Check is product available for sale - * - * @return bool - */ - public function isSalable() - { - Mage::dispatchEvent('catalog_product_is_salable_before', array( - 'product' => $this - )); - - $salable = $this->isAvailable(); - - $object = new Varien_Object(array( - 'product' => $this, - 'is_salable' => $salable - )); - Mage::dispatchEvent('catalog_product_is_salable_after', array( - 'product' => $this, - 'salable' => $object - )); - return $object->getIsSalable(); - } - - /** - * Check whether the product type or stock allows to purchase the product - * - * @return bool - */ - public function isAvailable() - { - return $this->getTypeInstance()->isSalable($this) - || Mage::helper('Mage_Catalog_Helper_Product')->getSkipSaleableCheck(); - } - - /** - * Is product salable detecting by product type - * - * @return bool - */ - public function getIsSalable() - { - $productType = $this->getTypeInstance(); - if (method_exists($productType, 'getIsSalable')) { - return $productType->getIsSalable($this); - } - if ($this->hasData('is_salable')) { - return $this->getData('is_salable'); - } - - return $this->isSalable(); - } - - /** - * Check is a virtual product - * Data helper wrapper - * - * @return bool - */ - public function isVirtual() - { - return $this->getIsVirtual(); - } - - /** - * Whether the product is a recurring payment - * - * @return bool - */ - public function isRecurring() - { - return $this->getIsRecurring() == '1'; - } - - /** - * Alias for isSalable() - * - * @return bool - */ - public function isSaleable() - { - return $this->isSalable(); - } - - /** - * Whether product available in stock - * - * @return bool - */ - public function isInStock() - { - return $this->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_ENABLED; - } - - /** - * Get attribute text by its code - * - * @param $attributeCode Code of the attribute - * @return string - */ - public function getAttributeText($attributeCode) - { - return $this->getResource() - ->getAttribute($attributeCode) - ->getSource() - ->getOptionText($this->getData($attributeCode)); - } - - /** - * Returns array with dates for custom design - * - * @return array - */ - public function getCustomDesignDate() - { - $result = array(); - $result['from'] = $this->getData('custom_design_from'); - $result['to'] = $this->getData('custom_design_to'); - - return $result; - } - - /** - * Retrieve Product URL - * - * @param bool $useSid - * @return string - */ - public function getProductUrl($useSid = null) - { - return $this->getUrlModel()->getProductUrl($this, $useSid); - } - - /** - * Retrieve URL in current store - * - * @param array $params the route params - * @return string - */ - public function getUrlInStore($params = array()) - { - return $this->getUrlModel()->getUrlInStore($this, $params); - } - - /** - * Formats URL key - * - * @param $str URL - * @return string - */ - public function formatUrlKey($str) - { - return $this->getUrlModel()->formatUrlKey($str); - } - - /** - * Retrieve Product Url Path (include category) - * - * @param Mage_Catalog_Model_Category $category - * @return string - */ - public function getUrlPath($category=null) - { - return $this->getUrlModel()->getUrlPath($this, $category); - } - - /** - * Save current attribute with code $code and assign new value - * - * @param string $code Attribute code - * @param mixed $value New attribute value - * @param int $store Store ID - * @return void - */ - public function addAttributeUpdate($code, $value, $store) - { - $oldValue = $this->getData($code); - $oldStore = $this->getStoreId(); - - $this->setData($code, $value); - $this->setStoreId($store); - $this->getResource()->saveAttribute($this, $code); - - $this->setData($code, $oldValue); - $this->setStoreId($oldStore); - } - - /** - * Renders the object to array - * - * @param array $arrAttributes Attribute array - * @return array - */ - public function toArray(array $arrAttributes=array()) - { - $data = parent::toArray($arrAttributes); - if ($stock = $this->getStockItem()) { - $data['stock_item'] = $stock->toArray(); - } - unset($data['stock_item']['product']); - return $data; - } - - /** - * Same as setData(), but also initiates the stock item (if it is there) - * - * @param array $data Array to form the object from - * @return Mage_Catalog_Model_Product - */ - public function fromArray($data) - { - if (isset($data['stock_item'])) { - if (Mage::helper('Mage_Catalog_Helper_Data')->isModuleEnabled('Mage_CatalogInventory')) { - $stockItem = Mage::getModel('Mage_CatalogInventory_Model_Stock_Item') - ->setData($data['stock_item']) - ->setProduct($this); - $this->setStockItem($stockItem); - } - unset($data['stock_item']); - } - $this->setData($data); - return $this; - } - - /** - * Delete product - * - * @return Mage_Catalog_Model_Product - */ - public function delete() - { - parent::delete(); - Mage::dispatchEvent($this->_eventPrefix.'_delete_after_done', array($this->_eventObject=>$this)); - return $this; - } - - /** - * Returns request path - * - * @return string - */ - public function getRequestPath() - { - return $this->_getData('request_path'); - } - - /** - * Custom function for other modules - * @return string - */ - - public function getGiftMessageAvailable() - { - return $this->_getData('gift_message_available'); - } - - /** - * Returns rating summary - * - * @return mixed - */ - public function getRatingSummary() - { - return $this->_getData('rating_summary'); - } - - /** - * Check is product composite - * - * @return bool - */ - public function isComposite() - { - return $this->getTypeInstance()->isComposite($this); - } - - /** - * Check if product can be configured - * - * @return bool - */ - public function canConfigure() - { - $options = $this->getOptions(); - return !empty($options) || $this->getTypeInstance()->canConfigure($this); - } - - /** - * Retrieve sku through type instance - * - * @return string - */ - public function getSku() - { - return $this->getTypeInstance()->getSku($this); - } - - /** - * Retrieve weight throught type instance - * - * @return unknown - */ - public function getWeight() - { - return $this->getTypeInstance()->getWeight($this); - } - - /** - * Retrieve option instance - * - * @return Mage_Catalog_Model_Product_Option - */ - public function getOptionInstance() - { - if (!$this->_optionInstance) { - $this->_optionInstance = Mage::getSingleton('Mage_Catalog_Model_Product_Option'); - } - return $this->_optionInstance; - } - - /** - * Retrieve options collection of product - * - * @return Mage_Catalog_Model_Resource_Product_Option_Collection - */ - public function getProductOptionsCollection() - { - $collection = $this->getOptionInstance() - ->getProductOptionCollection($this); - - return $collection; - } - - /** - * Add option to array of product options - * - * @param Mage_Catalog_Model_Product_Option $option - * @return Mage_Catalog_Model_Product - */ - public function addOption(Mage_Catalog_Model_Product_Option $option) - { - $this->_options[$option->getId()] = $option; - return $this; - } - - /** - * Get option from options array of product by given option id - * - * @param int $optionId - * @return Mage_Catalog_Model_Product_Option | null - */ - public function getOptionById($optionId) - { - if (isset($this->_options[$optionId])) { - return $this->_options[$optionId]; - } - - return null; - } - - /** - * Get all options of product - * - * @return array - */ - public function getOptions() - { - return $this->_options; - } - - /** - * Retrieve is a virtual product - * - * @return bool - */ - public function getIsVirtual() - { - return $this->getTypeInstance()->isVirtual($this); - } - - /** - * Add custom option information to product - * - * @param string $code Option code - * @param mixed $value Value of the option - * @param int $product Product ID - * @return Mage_Catalog_Model_Product - */ - public function addCustomOption($code, $value, $product=null) - { - $product = $product ? $product : $this; - $option = Mage::getModel('Mage_Catalog_Model_Product_Configuration_Item_Option') - ->addData(array( - 'product_id'=> $product->getId(), - 'product' => $product, - 'code' => $code, - 'value' => $value, - )); - $this->_customOptions[$code] = $option; - return $this; - } - - /** - * Sets custom options for the product - * - * @param array $options Array of options - * @return void - */ - public function setCustomOptions(array $options) - { - $this->_customOptions = $options; - } - - /** - * Get all custom options of the product - * - * @return array - */ - public function getCustomOptions() - { - return $this->_customOptions; - } - - /** - * Get product custom option info - * - * @param string $code - * @return array - */ - public function getCustomOption($code) - { - if (isset($this->_customOptions[$code])) { - return $this->_customOptions[$code]; - } - return null; - } - - /** - * Checks if there custom option for this product - * - * @return bool - */ - public function hasCustomOptions() - { - if (count($this->_customOptions)) { - return true; - } else { - return false; - } - } - - /** - * Check availability display product in category - * - * @param int $categoryId - * @return bool - */ - public function canBeShowInCategory($categoryId) - { - return $this->_getResource()->canBeShowInCategory($this, $categoryId); - } - - /** - * Retrieve category ids where product is available - * - * @return array - */ - public function getAvailableInCategories() - { - return $this->_getResource()->getAvailableInCategories($this); - } - - /** - * Retrieve default attribute set id - * - * @return int - */ - public function getDefaultAttributeSetId() - { - return $this->getResource()->getEntityType()->getDefaultAttributeSetId(); - } - - /** - * Return Catalog Product Image helper instance - * - * @return Mage_Catalog_Helper_Image - */ - protected function _getImageHelper() - { - return Mage::helper('Mage_Catalog_Helper_Image'); - } - - /** - * Returns system reserved attribute codes - * - * @return array Reserved attribute names - */ - public function getReservedAttributes() - { - if ($this->_reservedAttributes === null) { - $_reserved = array('position'); - $methods = get_class_methods(__CLASS__); - foreach ($methods as $method) { - if (preg_match('/^get([A-Z]{1}.+)/', $method, $matches)) { - $method = $matches[1]; - $tmp = strtolower(preg_replace('/(.)([A-Z])/', "$1_$2", $method)); - $_reserved[] = $tmp; - } - } - $_allowed = array( - 'type_id','calculated_final_price','request_path','rating_summary' - ); - $this->_reservedAttributes = array_diff($_reserved, $_allowed); - } - return $this->_reservedAttributes; - } - - /** - * Check whether attribute reserved or not - * - * @param Mage_Catalog_Model_Entity_Attribute $attribute Attribute model object - * @return boolean - */ - public function isReservedAttribute ($attribute) - { - return $attribute->getIsUserDefined() - && in_array($attribute->getAttributeCode(), $this->getReservedAttributes()); - } - - /** - * Set original loaded data if needed - * - * @param string $key - * @param mixed $data - * @return Varien_Object - */ - public function setOrigData($key=null, $data=null) - { - if (Mage::app()->getStore()->isAdmin()) { - return parent::setOrigData($key, $data); - } - - return $this; - } - - /** - * Reset all model data - * - * @return Mage_Catalog_Model_Product - */ - public function reset() - { - $this->unlockAttributes(); - $this->_clearData(); - return $this; - } - - /** - * Get cahce tags associated with object id - * - * @return array - */ - public function getCacheIdTags() - { - $tags = parent::getCacheIdTags(); - $affectedCategoryIds = $this->getAffectedCategoryIds(); - if (!$affectedCategoryIds) { - $affectedCategoryIds = $this->getCategoryIds(); - } - foreach ($affectedCategoryIds as $categoryId) { - $tags[] = Mage_Catalog_Model_Category::CACHE_TAG.'_'.$categoryId; - } - return $tags; - } - - /** - * Check for empty SKU on each product - * - * @param array $productIds - * @return boolean|null - */ - public function isProductsHasSku(array $productIds) - { - $products = $this->_getResource()->getProductsSku($productIds); - if (count($products)) { - foreach ($products as $product) { - if (!strlen($product['sku'])) { - return false; - } - } - return true; - } - return null; - } - - /** - * Parse buyRequest into options values used by product - * - * @param Varien_Object $buyRequest - * @return Varien_Object - */ - public function processBuyRequest(Varien_Object $buyRequest) - { - $options = new Varien_Object(); - - /* add product custom options data */ - $customOptions = $buyRequest->getOptions(); - if (is_array($customOptions)) { - $options->setOptions(array_diff($buyRequest->getOptions(), array(''))); - } - - /* add product type selected options data */ - $type = $this->getTypeInstance(); - $typeSpecificOptions = $type->processBuyRequest($this, $buyRequest); - $options->addData($typeSpecificOptions); - - /* check correctness of product's options */ - $options->setErrors($type->checkProductConfiguration($this, $buyRequest)); - - return $options; - } - - /** - * Get preconfigured values from product - * - * @return Varien_Object - */ - public function getPreconfiguredValues() - { - $preconfiguredValues = $this->getData('preconfigured_values'); - if (!$preconfiguredValues) { - $preconfiguredValues = new Varien_Object(); - } - - return $preconfiguredValues; - } - - /** - * Prepare product custom options. - * To be sure that all product custom options does not has ID and has product instance - * - * @return Mage_Catalog_Model_Product - */ - public function prepareCustomOptions() - { - foreach ($this->getCustomOptions() as $option) { - if (!is_object($option->getProduct()) || $option->getId()) { - $this->addCustomOption($option->getCode(), $option->getValue()); - } - } - - return $this; - } - - /** - * Clearing references on product - * - * @return Mage_Catalog_Model_Product - */ - protected function _clearReferences() - { - $this->_clearOptionReferences(); - return $this; - } - - /** - * Clearing product's data - * - * @return Mage_Catalog_Model_Product - */ - protected function _clearData() - { - foreach ($this->_data as $data){ - if (is_object($data) && method_exists($data, 'reset')){ - $data->reset(); - } - } - - $this->setData(array()); - $this->setOrigData(); - $this->_customOptions = array(); - $this->_optionInstance = null; - $this->_options = array(); - $this->_canAffectOptions = false; - $this->_errors = array(); - - return $this; - } - - /** - * Clearing references to product from product's options - * - * @return Mage_Catalog_Model_Product - */ - protected function _clearOptionReferences() - { - /** - * unload product options - */ - if (!empty($this->_options)) { - foreach ($this->_options as $key => $option) { - $option->setProduct(); - $option->clearInstance(); - } - } - - return $this; - } - - /** - * Retrieve product entities info as array - * - * @param string|array $columns One or several columns - * @return array - */ - public function getProductEntitiesInfo($columns = null) - { - return $this->_getResource()->getProductEntitiesInfo($columns); - } - - /** - * Checks whether product has disabled status - * - * @return bool - */ - public function isDisabled() - { - return $this->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_DISABLED; - } - - /** - * Sets product image from it's child if possible - * - * @return string - */ - public function getImage() - { - $this->getTypeInstance()->setImageFromChildProduct($this); - return parent::getImage(); - } -} diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Price.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Price.php deleted file mode 100644 index 93910312c850c..0000000000000 --- a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Price.php +++ /dev/null @@ -1,140 +0,0 @@ - - */ -class Mage_Catalog_Model_Product_Attribute_Backend_Price extends Mage_Eav_Model_Entity_Attribute_Backend_Abstract -{ - /** - * Catalog helper - * - * @var Mage_Catalog_Helper_Data - */ - protected $_helper; - - /** - * Constructor to inject dependencies - * - * @param array $data - */ - public function __construct($data = array()) - { - if (isset($data['helper'])) { - $this->_helper = $data['helper']; - } - } - - /** - * Get catalog helper - * - * @return Mage_Catalog_Helper_Data - */ - protected function _getHelper() - { - if (empty($this->_helper)) { - $this->_helper = Mage::helper('Mage_Catalog_Helper_Data'); - } - return $this->_helper; - } - - /** - * Set Attribute instance - * Rewrite for redefine attribute scope - * - * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute - * @return Mage_Catalog_Model_Product_Attribute_Backend_Price - */ - public function setAttribute($attribute) - { - parent::setAttribute($attribute); - $this->setScope($attribute); - return $this; - } - - /** - * Redefine Attribute scope - * - * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute - * @return Mage_Catalog_Model_Product_Attribute_Backend_Price - */ - public function setScope($attribute) - { - if ($this->_getHelper()->isPriceGlobal()) { - $attribute->setIsGlobal(Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL); - } else { - $attribute->setIsGlobal(Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE); - } - - return $this; - } - - /** - * After Save Attribute manipulation - * - * @param Mage_Catalog_Model_Product $object - * @return Mage_Catalog_Model_Product_Attribute_Backend_Price - */ - public function afterSave($object) - { - $value = $object->getData($this->getAttribute()->getAttributeCode()); - /** - * Orig value is only for existing objects - */ - $oridData = $object->getOrigData(); - $origValueExist = $oridData && array_key_exists($this->getAttribute()->getAttributeCode(), $oridData); - if ($object->getStoreId() != 0 || !$value || $origValueExist) { - return $this; - } - - if ($this->getAttribute()->getIsGlobal() == Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE) { - $baseCurrency = Mage::app()->getBaseCurrencyCode(); - - $storeIds = $object->getStoreIds(); - if (is_array($storeIds)) { - foreach ($storeIds as $storeId) { - $storeCurrency = Mage::app()->getStore($storeId)->getBaseCurrencyCode(); - if ($storeCurrency == $baseCurrency) { - continue; - } - $rate = Mage::getModel('Mage_Directory_Model_Currency')->load($baseCurrency)->getRate($storeCurrency); - if (!$rate) { - $rate = 1; - } - $newValue = $value * $rate; - $object->addAttributeUpdate($this->getAttribute()->getAttributeCode(), $newValue, $storeId); - } - } - } - - return $this; - } -} diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Stock.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Stock.php deleted file mode 100644 index 0f6e870f3a731..0000000000000 --- a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Stock.php +++ /dev/null @@ -1,86 +0,0 @@ - - */ -class Mage_Catalog_Model_Product_Attribute_Backend_Stock extends Mage_Eav_Model_Entity_Attribute_Backend_Abstract -{ - /** - * @var Mage_CatalogInventory_Model_Stock_Item - */ - protected $_inventory; - - public function __construct(array $data = array()) - { - $this->_inventory = isset($data['inventory']) - ? $data['inventory'] - : Mage::getModel('Mage_CatalogInventory_Model_Stock_Item'); - } - - /** - * Set inventory data to custom attribute - * - * @param Varien_Object $object - * @return Mage_Eav_Model_Entity_Attribute_Backend_Abstract - */ - public function afterLoad($object) - { - $this->_inventory->loadByProduct($object); - $object->setData( - $this->getAttribute()->getAttributeCode(), - array( - 'is_in_stock' => $this->_inventory->getIsInStock(), - 'qty' => $this->_inventory->getQty(), - ) - ); - return parent::afterLoad($object); - } - - /** - * Prepare inventory data from custom attribute - * - * @param Mage_Catalog_Model_Product $object - * @return Mage_Eav_Model_Entity_Attribute_Backend_Abstract|void - */ - public function beforeSave($object) - { - $stockData = $object->getData($this->getAttribute()->getAttributeCode()); - if (isset($stockData['qty']) && $stockData['qty'] === '') { - $stockData['qty'] = null; - } - if ($object->getStockData() !== null || $stockData !== null) { - $object->setStockData(array_replace((array)$object->getStockData(), (array)$stockData)); - } - $object->unsetData($this->getAttribute()->getAttributeCode()); - parent::beforeSave($object); - } -} diff --git a/app/code/core/Mage/Catalog/Model/Product/Image.php b/app/code/core/Mage/Catalog/Model/Product/Image.php deleted file mode 100644 index f70b61570e70b..0000000000000 --- a/app/code/core/Mage/Catalog/Model/Product/Image.php +++ /dev/null @@ -1,736 +0,0 @@ - - */ -class Mage_Catalog_Model_Product_Image extends Mage_Core_Model_Abstract -{ - protected $_width; - protected $_height; - protected $_quality = 90; - - protected $_keepAspectRatio = true; - protected $_keepFrame = true; - protected $_keepTransparency = true; - protected $_constrainOnly = false; - protected $_backgroundColor = array(255, 255, 255); - - protected $_baseFile; - protected $_isBaseFilePlaceholder; - protected $_newFile; - protected $_processor; - protected $_destinationSubdir; - protected $_angle; - - protected $_watermarkFile; - protected $_watermarkPosition; - protected $_watermarkWidth; - protected $_watermarkHeigth; - protected $_watermarkImageOpacity = 70; - - /** - * @var Magento_Filesystem $filesystem - */ - protected $_filesystem; - - /** - * @param Mage_Core_Model_Event_Manager $eventDispatcher - * @param Mage_Core_Model_Cache $cacheManager - * @param Magento_Filesystem $filesystem - * @param Mage_Core_Model_Resource_Abstract $resource - * @param Varien_Data_Collection_Db $resourceCollection - * @param array $data - */ - public function __construct( - Mage_Core_Model_Event_Manager $eventDispatcher, - Mage_Core_Model_Cache $cacheManager, - Magento_Filesystem $filesystem, - Mage_Core_Model_Resource_Abstract $resource = null, - Varien_Data_Collection_Db $resourceCollection = null, - array $data = array() - ) { - parent::__construct($eventDispatcher, $cacheManager, $resource, $resourceCollection, $data); - $baseDir = Mage::getSingleton('Mage_Catalog_Model_Product_Media_Config')->getBaseMediaPath(); - $this->_filesystem = $filesystem; - $this->_filesystem->setIsAllowCreateDirectories(true); - $this->_filesystem->ensureDirectoryExists($baseDir); - $this->_filesystem->setIsAllowCreateDirectories(false); - $this->_filesystem->setWorkingDirectory($baseDir); - } - - /** - * @return Mage_Catalog_Model_Product_Image - */ - public function setWidth($width) - { - $this->_width = $width; - return $this; - } - - public function getWidth() - { - return $this->_width; - } - - /** - * @return Mage_Catalog_Model_Product_Image - */ - public function setHeight($height) - { - $this->_height = $height; - return $this; - } - - public function getHeight() - { - return $this->_height; - } - - /** - * Set image quality, values in percentage from 0 to 100 - * - * @param int $quality - * @return Mage_Catalog_Model_Product_Image - */ - public function setQuality($quality) - { - $this->_quality = $quality; - return $this; - } - - /** - * Get image quality - * - * @return int - */ - public function getQuality() - { - return $this->_quality; - } - - /** - * @return Mage_Catalog_Model_Product_Image - */ - public function setKeepAspectRatio($keep) - { - $this->_keepAspectRatio = (bool)$keep; - return $this; - } - - /** - * @return Mage_Catalog_Model_Product_Image - */ - public function setKeepFrame($keep) - { - $this->_keepFrame = (bool)$keep; - return $this; - } - - /** - * @return Mage_Catalog_Model_Product_Image - */ - public function setKeepTransparency($keep) - { - $this->_keepTransparency = (bool)$keep; - return $this; - } - - /** - * @return Mage_Catalog_Model_Product_Image - */ - public function setConstrainOnly($flag) - { - $this->_constrainOnly = (bool)$flag; - return $this; - } - - /** - * @return Mage_Catalog_Model_Product_Image - */ - public function setBackgroundColor(array $rgbArray) - { - $this->_backgroundColor = $rgbArray; - return $this; - } - - /** - * @return Mage_Catalog_Model_Product_Image - */ - public function setSize($size) - { - // determine width and height from string - list($width, $height) = explode('x', strtolower($size), 2); - foreach (array('width', 'height') as $wh) { - $$wh = (int)$$wh; - if (empty($$wh)) - $$wh = null; - } - - // set sizes - $this->setWidth($width)->setHeight($height); - - return $this; - } - - protected function _checkMemory($file = null) - { -// print '$this->_getMemoryLimit() = '.$this->_getMemoryLimit(); -// print '$this->_getMemoryUsage() = '.$this->_getMemoryUsage(); -// print '$this->_getNeedMemoryForBaseFile() = '.$this->_getNeedMemoryForBaseFile(); - - return $this->_getMemoryLimit() > ($this->_getMemoryUsage() + $this->_getNeedMemoryForFile($file)) || $this->_getMemoryLimit() == -1; - } - - protected function _getMemoryLimit() - { - $memoryLimit = trim(strtoupper(ini_get('memory_limit'))); - - if (!isset($memoryLimit[0])) { - $memoryLimit = "128M"; - } - - if (substr($memoryLimit, -1) == 'K') { - return substr($memoryLimit, 0, -1) * 1024; - } - if (substr($memoryLimit, -1) == 'M') { - return substr($memoryLimit, 0, -1) * 1024 * 1024; - } - if (substr($memoryLimit, -1) == 'G') { - return substr($memoryLimit, 0, -1) * 1024 * 1024 * 1024; - } - return $memoryLimit; - } - - protected function _getMemoryUsage() - { - if (function_exists('memory_get_usage')) { - return memory_get_usage(); - } - return 0; - } - - protected function _getNeedMemoryForFile($file = null) - { - $file = is_null($file) ? $this->getBaseFile() : $file; - if (!$file) { - return 0; - } - - if (!$this->_filesystem->isFile($file)) { - return 0; - } - - $imageInfo = getimagesize($file); - - if (!isset($imageInfo[0]) || !isset($imageInfo[1])) { - return 0; - } - if (!isset($imageInfo['channels'])) { - // if there is no info about this parameter lets set it for maximum - $imageInfo['channels'] = 4; - } - if (!isset($imageInfo['bits'])) { - // if there is no info about this parameter lets set it for maximum - $imageInfo['bits'] = 8; - } - return round( - ($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $imageInfo['channels'] / 8 + Pow(2, 16)) * 1.65 - ); - } - - /** - * Convert array of 3 items (decimal r, g, b) to string of their hex values - * - * @param array $rgbArray - * @return string - */ - protected function _rgbToString($rgbArray) - { - $result = array(); - foreach ($rgbArray as $value) { - if (null === $value) { - $result[] = 'null'; - } else { - $result[] = sprintf('%02s', dechex($value)); - } - } - return implode($result); - } - - /** - * Set filenames for base file and new file - * - * @param string $file - * @return Mage_Catalog_Model_Product_Image - */ - public function setBaseFile($file) - { - $this->_isBaseFilePlaceholder = false; - - if (($file) && (0 !== strpos($file, '/', 0))) { - $file = '/' . $file; - } - $baseDir = Mage::getSingleton('Mage_Catalog_Model_Product_Media_Config')->getBaseMediaPath(); - - if ('/no_selection' == $file) { - $file = null; - } - if ($file) { - if ((!$this->_fileExists($baseDir . $file)) || !$this->_checkMemory($baseDir . $file)) { - $file = null; - } - } - if (!$file) { - $this->_isBaseFilePlaceholder = true; - // check if placeholder defined in config - $isConfigPlaceholder = Mage::getStoreConfig("catalog/placeholder/{$this->getDestinationSubdir()}_placeholder"); - $configPlaceholder = '/placeholder/' . $isConfigPlaceholder; - if ($isConfigPlaceholder && $this->_fileExists($baseDir . $configPlaceholder)) { - $file = $configPlaceholder; - } else { - $this->_newFile = true; - return $this; - } - } - - $baseFile = $baseDir . $file; - - if (!$file || !$this->_filesystem->isFile($baseFile)) { - throw new Exception(Mage::helper('Mage_Catalog_Helper_Data')->__('Image file was not found.')); - } - - $this->_baseFile = $baseFile; - - // build new filename (most important params) - $path = array( - Mage::getSingleton('Mage_Catalog_Model_Product_Media_Config')->getBaseMediaPath(), - 'cache', - Mage::app()->getStore()->getId(), - $path[] = $this->getDestinationSubdir() - ); - if ((!empty($this->_width)) || (!empty($this->_height))) { - $path[] = "{$this->_width}x{$this->_height}"; - } - - // add misk params as a hash - $miscParams = array( - ($this->_keepAspectRatio ? '' : 'non') . 'proportional', - ($this->_keepFrame ? '' : 'no') . 'frame', - ($this->_keepTransparency ? '' : 'no') . 'transparency', - ($this->_constrainOnly ? 'do' : 'not') . 'constrainonly', - $this->_rgbToString($this->_backgroundColor), - 'angle' . $this->_angle, - 'quality' . $this->_quality - ); - - // if has watermark add watermark params to hash - if ($this->getWatermarkFile()) { - $miscParams[] = $this->getWatermarkFile(); - $miscParams[] = $this->getWatermarkImageOpacity(); - $miscParams[] = $this->getWatermarkPosition(); - $miscParams[] = $this->getWatermarkWidth(); - $miscParams[] = $this->getWatermarkHeight(); - } - - $path[] = md5(implode('_', $miscParams)); - - // append prepared filename - $this->_newFile = implode('/', $path) . $file; // the $file contains heading slash - - return $this; - } - - public function getBaseFile() - { - return $this->_baseFile; - } - - public function getNewFile() - { - return $this->_newFile; - } - - /** - * @return Mage_Catalog_Model_Product_Image - */ - public function setImageProcessor($processor) - { - $this->_processor = $processor; - return $this; - } - - /** - * @return Varien_Image - */ - public function getImageProcessor() - { - if (!$this->_processor) { - $adapter = Mage::helper('Mage_Core_Helper_Data')->getImageAdapterType(); - $this->_processor = new Varien_Image($this->getBaseFile(), $adapter); - } - $this->_processor->keepAspectRatio($this->_keepAspectRatio); - $this->_processor->keepFrame($this->_keepFrame); - $this->_processor->keepTransparency($this->_keepTransparency); - $this->_processor->constrainOnly($this->_constrainOnly); - $this->_processor->backgroundColor($this->_backgroundColor); - $this->_processor->quality($this->_quality); - return $this->_processor; - } - - /** - * @see Varien_Image_Adapter_Abstract - * @return Mage_Catalog_Model_Product_Image - */ - public function resize() - { - if (is_null($this->getWidth()) && is_null($this->getHeight())) { - return $this; - } - $this->getImageProcessor()->resize($this->_width, $this->_height); - return $this; - } - - /** - * @return Mage_Catalog_Model_Product_Image - */ - public function rotate($angle) - { - $angle = intval($angle); - $this->getImageProcessor()->rotate($angle); - return $this; - } - - /** - * Set angle for rotating - * - * This func actually affects only the cache filename. - * - * @param int $angle - * @return Mage_Catalog_Model_Product_Image - */ - public function setAngle($angle) - { - $this->_angle = $angle; - return $this; - } - - /** - * Add watermark to image - * size param in format 100x200 - * - * @param string $file - * @param string $position - * @param string $size - * @param int $width - * @param int $heigth - * @param int $imageOpacity - * @return Mage_Catalog_Model_Product_Image - */ - public function setWatermark($file, $position=null, $size=null, $width=null, $heigth=null, $imageOpacity=null) - { - if ($this->_isBaseFilePlaceholder) { - return $this; - } - - if ($file) { - $this->setWatermarkFile($file); - } else { - return $this; - } - - if ($position) { - $this->setWatermarkPosition($position); - } - if ($size) { - $this->setWatermarkSize($size); - } - if ($width) { - $this->setWatermarkWidth($width); - } - if ($heigth) { - $this->setWatermarkHeight($heigth); - } - if ($imageOpacity) { - $this->setImageOpacity($imageOpacity); - } - $filePath = $this->_getWatermarkFilePath(); - - if ($filePath) { - $this->getImageProcessor() - ->setWatermarkPosition( $this->getWatermarkPosition() ) - ->setWatermarkImageOpacity( $this->getWatermarkImageOpacity() ) - ->setWatermarkWidth( $this->getWatermarkWidth() ) - ->setWatermarkHeight( $this->getWatermarkHeight() ) - ->watermark($filePath); - } - - return $this; - } - - /** - * @return Mage_Catalog_Model_Product_Image - */ - public function saveFile() - { - if ($this->_isBaseFilePlaceholder) { - return $this; - } - $filename = $this->getNewFile(); - $this->getImageProcessor()->save($filename); - Mage::helper('Mage_Core_Helper_File_Storage_Database')->saveFile($filename); - return $this; - } - - /** - * @return string - */ - public function getUrl() - { - if ($this->_newFile === true) { - $url = Mage::getDesign()->getViewFileUrl( - "Mage_Catalog::images/product/placeholder/{$this->getDestinationSubdir()}.jpg" - ); - } else { - $baseDir = Mage::getBaseDir('media'); - $path = str_replace($baseDir . DS, "", $this->_newFile); - $url = Mage::getBaseUrl('media') . str_replace(DS, '/', $path);; - } - - return $url; - } - - /** - * @return Mage_Catalog_Model_Product_Image - */ - public function setDestinationSubdir($dir) - { - $this->_destinationSubdir = $dir; - return $this; - } - - /** - * @return string - */ - public function getDestinationSubdir() - { - return $this->_destinationSubdir; - } - - public function isCached() - { - if (is_string($this->_newFile)) { - return $this->_fileExists($this->_newFile); - } - } - - /** - * Set watermark file name - * - * @param string $file - * @return Mage_Catalog_Model_Product_Image - */ - public function setWatermarkFile($file) - { - $this->_watermarkFile = $file; - return $this; - } - - /** - * Get watermark file name - * - * @return string - */ - public function getWatermarkFile() - { - return $this->_watermarkFile; - } - - /** - * Get relative watermark file path - * or false if file not found - * - * @return string | bool - */ - protected function _getWatermarkFilePath() - { - $filePath = false; - - if (!$file = $this->getWatermarkFile()) { - return $filePath; - } - - $baseDir = Mage::getSingleton('Mage_Catalog_Model_Product_Media_Config')->getBaseMediaPath(); - - if ($this->_fileExists($baseDir . '/watermark/stores/' . Mage::app()->getStore()->getId() . $file)) { - $filePath = $baseDir . '/watermark/stores/' . Mage::app()->getStore()->getId() . $file; - } elseif ($this->_fileExists($baseDir . '/watermark/websites/' . Mage::app()->getWebsite()->getId() . $file)) { - $filePath = $baseDir . '/watermark/websites/' . Mage::app()->getWebsite()->getId() . $file; - } elseif ($this->_fileExists($baseDir . '/watermark/default/' . $file)) { - $filePath = $baseDir . '/watermark/default/' . $file; - } elseif ($this->_fileExists($baseDir . '/watermark/' . $file)) { - $filePath = $baseDir . '/watermark/' . $file; - } else { - $viewFile = Mage::getDesign()->getViewFile($file); - if ($this->_filesystem->isFile($viewFile)) { - $filePath = $viewFile; - } - } - - return $filePath; - } - - /** - * Set watermark position - * - * @param string $position - * @return Mage_Catalog_Model_Product_Image - */ - public function setWatermarkPosition($position) - { - $this->_watermarkPosition = $position; - return $this; - } - - /** - * Get watermark position - * - * @return string - */ - public function getWatermarkPosition() - { - return $this->_watermarkPosition; - } - - /** - * Set watermark image opacity - * - * @param int $imageOpacity - * @return Mage_Catalog_Model_Product_Image - */ - public function setWatermarkImageOpacity($imageOpacity) - { - $this->_watermarkImageOpacity = $imageOpacity; - return $this; - } - - /** - * Get watermark image opacity - * - * @return int - */ - public function getWatermarkImageOpacity() - { - return $this->_watermarkImageOpacity; - } - - /** - * Set watermark size - * - * @param array $size - * @return Mage_Catalog_Model_Product_Image - */ - public function setWatermarkSize($size) - { - if (is_array($size)) { - $this->setWatermarkWidth($size['width']) - ->setWatermarkHeight($size['heigth']); - } - return $this; - } - - /** - * Set watermark width - * - * @param int $width - * @return Mage_Catalog_Model_Product_Image - */ - public function setWatermarkWidth($width) - { - $this->_watermarkWidth = $width; - return $this; - } - - /** - * Get watermark width - * - * @return int - */ - public function getWatermarkWidth() - { - return $this->_watermarkWidth; - } - - /** - * Set watermark heigth - * - * @param int $heigth - * @return Mage_Catalog_Model_Product_Image - */ - public function setWatermarkHeight($heigth) - { - $this->_watermarkHeigth = $heigth; - return $this; - } - - /** - * Get watermark height - * - * @return string - */ - public function getWatermarkHeight() - { - return $this->_watermarkHeigth; - } - - public function clearCache() - { - $directory = Mage::getBaseDir('media') . DS . 'catalog' . DS . 'product' . DS.'cache' . DS; - $this->_filesystem->delete($directory); - - Mage::helper('Mage_Core_Helper_File_Storage_Database')->deleteFolder($directory); - } - - /** - * First check this file on FS - * If it doesn't exist - try to download it from DB - * - * @param string $filename - * @return bool - */ - protected function _fileExists($filename) - { - if ($this->_filesystem->isFile($filename)) { - return true; - } else { - return Mage::helper('Mage_Core_Helper_File_Storage_Database')->saveFileToFilesystem($filename); - } - } -} diff --git a/app/code/core/Mage/Catalog/Model/Resource/Category.php b/app/code/core/Mage/Catalog/Model/Resource/Category.php deleted file mode 100755 index 279a28dc0c480..0000000000000 --- a/app/code/core/Mage/Catalog/Model/Resource/Category.php +++ /dev/null @@ -1,890 +0,0 @@ - - */ -class Mage_Catalog_Model_Resource_Category extends Mage_Catalog_Model_Resource_Abstract -{ - /** - * Category tree object - * - * @var Varien_Data_Tree_Db - */ - protected $_tree; - - /** - * Catalog products table name - * - * @var string - */ - protected $_categoryProductTable; - - /** - * Id of 'is_active' category attribute - * - * @var int - */ - protected $_isActiveAttributeId = null; - - /** - * Store id - * - * @var int - */ - protected $_storeId = null; - - /** - * Class constructor - * - */ - public function __construct() - { - $resource = Mage::getSingleton('Mage_Core_Model_Resource'); - $this->setType(Mage_Catalog_Model_Category::ENTITY) - ->setConnection( - $resource->getConnection('catalog_read'), - $resource->getConnection('catalog_write') - ); - $this->_categoryProductTable = $this->getTable('catalog_category_product'); - } - - /** - * Set store Id - * - * @param integer $storeId - * @return Mage_Catalog_Model_Resource_Category - */ - public function setStoreId($storeId) - { - $this->_storeId = $storeId; - return $this; - } - - /** - * Return store id - * - * @return integer - */ - public function getStoreId() - { - if ($this->_storeId === null) { - return Mage::app()->getStore()->getId(); - } - return $this->_storeId; - } - - /** - * Retrieve category tree object - * - * @return Varien_Data_Tree_Db - */ - protected function _getTree() - { - if (!$this->_tree) { - $this->_tree = Mage::getResourceModel('Mage_Catalog_Model_Resource_Category_Tree') - ->load(); - } - return $this->_tree; - } - - /** - * Process category data before delete - * update children count for parent category - * delete child categories - * - * @param Varien_Object $object - * @return Mage_Catalog_Model_Resource_Category - */ - protected function _beforeDelete(Varien_Object $object) - { - parent::_beforeDelete($object); - - /** - * Update children count for all parent categories - */ - $parentIds = $object->getParentIds(); - if ($parentIds) { - $childDecrease = $object->getChildrenCount() + 1; // +1 is itself - $data = array('children_count' => new Zend_Db_Expr('children_count - ' . $childDecrease)); - $where = array('entity_id IN(?)' => $parentIds); - $this->_getWriteAdapter()->update( $this->getEntityTable(), $data, $where); - } - $this->deleteChildren($object); - return $this; - } - - /** - * Delete children categories of specific category - * - * @param Varien_Object $object - * @return Mage_Catalog_Model_Resource_Category - */ - public function deleteChildren(Varien_Object $object) - { - $adapter = $this->_getWriteAdapter(); - $pathField = $adapter->quoteIdentifier('path'); - - $select = $adapter->select() - ->from($this->getEntityTable(), array('entity_id')) - ->where($pathField . ' LIKE :c_path'); - - $childrenIds = $adapter->fetchCol($select, array('c_path' => $object->getPath() . '/%')); - - if (!empty($childrenIds)) { - $adapter->delete( - $this->getEntityTable(), - array('entity_id IN (?)' => $childrenIds) - ); - } - - /** - * Add deleted children ids to object - * This data can be used in after delete event - */ - $object->setDeletedChildrenIds($childrenIds); - return $this; - } - - /** - * Process category data before saving - * prepare path and increment children count for parent categories - * - * @param Varien_Object $object - * @return Mage_Catalog_Model_Resource_Category - */ - protected function _beforeSave(Varien_Object $object) - { - parent::_beforeSave($object); - - if (!$object->getChildrenCount()) { - $object->setChildrenCount(0); - } - if ($object->getLevel() === null) { - $object->setLevel(1); - } - - if (!$object->getId()) { - $object->setPosition($this->_getMaxPosition($object->getPath()) + 1); - $path = explode('/', $object->getPath()); - $level = count($path); - $object->setLevel($level); - if ($level) { - $object->setParentId($path[$level - 1]); - } - $object->setPath($object->getPath() . '/'); - - $toUpdateChild = explode('/',$object->getPath()); - - $this->_getWriteAdapter()->update( - $this->getEntityTable(), - array('children_count' => new Zend_Db_Expr('children_count+1')), - array('entity_id IN(?)' => $toUpdateChild) - ); - - } - return $this; - } - - /** - * Process category data after save category object - * save related products ids and update path value - * - * @param Varien_Object $object - * @return Mage_Catalog_Model_Resource_Category - */ - protected function _afterSave(Varien_Object $object) - { - /** - * Add identifier for new category - */ - if (substr($object->getPath(), -1) == '/') { - $object->setPath($object->getPath() . $object->getId()); - $this->_savePath($object); - } - - $this->_saveCategoryProducts($object); - return parent::_afterSave($object); - } - - /** - * Update path field - * - * @param Mage_Catalog_Model_Category $object - * @return Mage_Catalog_Model_Resource_Category - */ - protected function _savePath($object) - { - if ($object->getId()) { - $this->_getWriteAdapter()->update( - $this->getEntityTable(), - array('path' => $object->getPath()), - array('entity_id = ?' => $object->getId()) - ); - } - return $this; - } - - /** - * Get maximum position of child categories by specific tree path - * - * @param string $path - * @return int - */ - protected function _getMaxPosition($path) - { - $adapter = $this->getReadConnection(); - $positionField = $adapter->quoteIdentifier('position'); - $level = count(explode('/', $path)); - $bind = array( - 'c_level' => $level, - 'c_path' => $path . '/%' - ); - $select = $adapter->select() - ->from($this->getTable('catalog_category_entity'), 'MAX(' . $positionField . ')') - ->where($adapter->quoteIdentifier('path') . ' LIKE :c_path') - ->where($adapter->quoteIdentifier('level') . ' = :c_level'); - - $position = $adapter->fetchOne($select, $bind); - if (!$position) { - $position = 0; - } - return $position; - } - - /** - * Save category products relation - * - * @param Mage_Catalog_Model_Category $category - * @return Mage_Catalog_Model_Resource_Category - */ - protected function _saveCategoryProducts($category) - { - $category->setIsChangedProductList(false); - $id = $category->getId(); - /** - * new category-product relationships - */ - $products = $category->getPostedProducts(); - - /** - * Example re-save category - */ - if ($products === null) { - return $this; - } - - /** - * old category-product relationships - */ - $oldProducts = $category->getProductsPosition(); - - $insert = array_diff_key($products, $oldProducts); - $delete = array_diff_key($oldProducts, $products); - - /** - * Find product ids which are presented in both arrays - * and saved before (check $oldProducts array) - */ - $update = array_intersect_key($products, $oldProducts); - $update = array_diff_assoc($update, $oldProducts); - - $adapter = $this->_getWriteAdapter(); - - /** - * Delete products from category - */ - if (!empty($delete)) { - $cond = array( - 'product_id IN(?)' => array_keys($delete), - 'category_id=?' => $id - ); - $adapter->delete($this->_categoryProductTable, $cond); - } - - /** - * Add products to category - */ - if (!empty($insert)) { - $data = array(); - foreach ($insert as $productId => $position) { - $data[] = array( - 'category_id' => (int)$id, - 'product_id' => (int)$productId, - 'position' => (int)$position - ); - } - $adapter->insertMultiple($this->_categoryProductTable, $data); - } - - /** - * Update product positions in category - */ - if (!empty($update)) { - foreach ($update as $productId => $position) { - $where = array( - 'category_id = ?'=> (int)$id, - 'product_id = ?' => (int)$productId - ); - $bind = array('position' => (int)$position); - $adapter->update($this->_categoryProductTable, $bind, $where); - } - } - - if (!empty($insert) || !empty($delete)) { - $productIds = array_unique(array_merge(array_keys($insert), array_keys($delete))); - Mage::dispatchEvent('catalog_category_change_products', array( - 'category' => $category, - 'product_ids' => $productIds - )); - } - - if (!empty($insert) || !empty($update) || !empty($delete)) { - $category->setIsChangedProductList(true); - - /** - * Setting affected products to category for third party engine index refresh - */ - $productIds = array_keys($insert + $delete + $update); - $category->setAffectedProductIds($productIds); - } - return $this; - } - - /** - * Get positions of associated to category products - * - * @param Mage_Catalog_Model_Category $category - * @return array - */ - public function getProductsPosition($category) - { - $select = $this->_getWriteAdapter()->select() - ->from($this->_categoryProductTable, array('product_id', 'position')) - ->where('category_id = :category_id'); - $bind = array('category_id' => (int)$category->getId()); - - return $this->_getWriteAdapter()->fetchPairs($select, $bind); - } - - /** - * Get chlden categories count - * - * @param int $categoryId - * @return int - */ - public function getChildrenCount($categoryId) - { - $select = $this->_getReadAdapter()->select() - ->from($this->getEntityTable(), 'children_count') - ->where('entity_id = :entity_id'); - $bind = array('entity_id' => $categoryId); - - return $this->_getReadAdapter()->fetchOne($select, $bind); - } - - /** - * Check if category id exist - * - * @param int $entityId - * @return bool - */ - public function checkId($entityId) - { - $select = $this->_getReadAdapter()->select() - ->from($this->getEntityTable(), 'entity_id') - ->where('entity_id = :entity_id'); - $bind = array('entity_id' => $entityId); - - return $this->_getReadAdapter()->fetchOne($select, $bind); - } - - /** - * Check array of category identifiers - * - * @param array $ids - * @return array - */ - public function verifyIds(array $ids) - { - if (empty($ids)) { - return array(); - } - - $select = $this->_getReadAdapter()->select() - ->from($this->getEntityTable(), 'entity_id') - ->where('entity_id IN(?)', $ids); - - return $this->_getReadAdapter()->fetchCol($select); - } - - /** - * Get count of active/not active children categories - * - * @param Mage_Catalog_Model_Category $category - * @param bool $isActiveFlag - * @return int - */ - public function getChildrenAmount($category, $isActiveFlag = true) - { - $storeId = Mage::app()->getStore()->getId(); - $attributeId = $this->_getIsActiveAttributeId(); - $table = $this->getTable(array($this->getEntityTablePrefix(), 'int')); - $adapter = $this->_getReadAdapter(); - $checkSql = $adapter->getCheckSql('c.value_id > 0', 'c.value', 'd.value'); - - $bind = array( - 'attribute_id' => $attributeId, - 'store_id' => $storeId, - 'active_flag' => $isActiveFlag, - 'c_path' => $category->getPath() . '/%' - ); - $select = $adapter->select() - ->from(array('m' => $this->getEntityTable()), array('COUNT(m.entity_id)')) - ->joinLeft( - array('d' => $table), - 'd.attribute_id = :attribute_id AND d.store_id = 0 AND d.entity_id = m.entity_id', - array() - ) - ->joinLeft( - array('c' => $table), - "c.attribute_id = :attribute_id AND c.store_id = :store_id AND c.entity_id = m.entity_id", - array() - ) - ->where('m.path LIKE :c_path') - ->where($checkSql . ' = :active_flag'); - - return $this->_getReadAdapter()->fetchOne($select, $bind); - } - - /** - * Get "is_active" attribute identifier - * - * @return int - */ - protected function _getIsActiveAttributeId() - { - if ($this->_isActiveAttributeId === null) { - $bind = array( - 'catalog_category' => Mage_Catalog_Model_Category::ENTITY, - 'is_active' => 'is_active', - ); - $select = $this->_getReadAdapter()->select() - ->from(array('a'=>$this->getTable('eav_attribute')), array('attribute_id')) - ->join(array('t'=>$this->getTable('eav_entity_type')), 'a.entity_type_id = t.entity_type_id') - ->where('entity_type_code = :catalog_category') - ->where('attribute_code = :is_active'); - - $this->_isActiveAttributeId = $this->_getReadAdapter()->fetchOne($select, $bind); - } - - return $this->_isActiveAttributeId; - } - - /** - * Return entities where attribute value is - * - * @param array|int $entityIdsFilter - * @param Mage_Eav_Model_Entity_Attribute $attribute - * @param mixed $expectedValue - * @return array - */ - public function findWhereAttributeIs($entityIdsFilter, $attribute, $expectedValue) - { - $bind = array( - 'attribute_id' => $attribute->getId(), - 'value' => $expectedValue - ); - $select = $this->_getReadAdapter()->select() - ->from($attribute->getBackend()->getTable(), array('entity_id')) - ->where('attribute_id = :attribute_id') - ->where('value = :value') - ->where('entity_id IN(?)', $entityIdsFilter); - - return $this->_getReadAdapter()->fetchCol($select, $bind); - } - - /** - * Get products count in category - * - * @param Mage_Catalog_Model_Category $category - * @return int - */ - public function getProductCount($category) - { - $productTable = Mage::getSingleton('Mage_Core_Model_Resource')->getTableName('catalog_category_product'); - - $select = $this->getReadConnection()->select() - ->from( - array('main_table' => $productTable), - array(new Zend_Db_Expr('COUNT(main_table.product_id)')) - ) - ->where('main_table.category_id = :category_id'); - - $bind = array('category_id' => (int)$category->getId()); - $counts = $this->getReadConnection()->fetchOne($select, $bind); - - return intval($counts); - } - - /** - * Retrieve categories - * - * @param integer $parent - * @param integer $recursionLevel - * @param boolean|string $sorted - * @param boolean $asCollection - * @param boolean $toLoad - * @return Varien_Data_Tree_Node_Collection|Mage_Catalog_Model_Resource_Category_Collection - */ - public function getCategories($parent, $recursionLevel = 0, $sorted = false, $asCollection = false, $toLoad = true) - { - $tree = Mage::getResourceModel('Mage_Catalog_Model_Resource_Category_Tree'); - /* @var $tree Mage_Catalog_Model_Resource_Category_Tree */ - $nodes = $tree->loadNode($parent) - ->loadChildren($recursionLevel) - ->getChildren(); - - $tree->addCollectionData(null, $sorted, $parent, $toLoad, true); - - if ($asCollection) { - return $tree->getCollection(); - } - return $nodes; - } - - /** - * Return parent categories of category - * - * @param Mage_Catalog_Model_Category $category - * @return array - */ - public function getParentCategories($category) - { - $pathIds = array_reverse(explode(',', $category->getPathInStore())); - $categories = Mage::getResourceModel('Mage_Catalog_Model_Resource_Category_Collection') - ->setStore(Mage::app()->getStore()) - ->addAttributeToSelect('name') - ->addAttributeToSelect('url_key') - ->addFieldToFilter('entity_id', array('in' => $pathIds)) - ->addFieldToFilter('is_active', 1) - ->load() - ->getItems(); - return $categories; - } - - /** - * Return parent category of current category with own custom design settings - * - * @param Mage_Catalog_Model_Category $category - * @return Mage_Catalog_Model_Category - */ - public function getParentDesignCategory($category) - { - $pathIds = array_reverse($category->getPathIds()); - $collection = $category->getCollection() - ->setStore(Mage::app()->getStore()) - ->addAttributeToSelect('custom_design') - ->addAttributeToSelect('custom_design_from') - ->addAttributeToSelect('custom_design_to') - ->addAttributeToSelect('page_layout') - ->addAttributeToSelect('custom_layout_update') - ->addAttributeToSelect('custom_apply_to_products') - ->addFieldToFilter('entity_id', array('in' => $pathIds)) - ->addAttributeToFilter('custom_use_parent_settings', array(array('eq' => 0), array('null' => 0)), 'left') - ->addFieldToFilter('level', array('neq' => 0)) - ->setOrder('level', 'DESC') - ->load(); - return $collection->getFirstItem(); - } - - - /** - * Return child categories - * - * @param Mage_Catalog_Model_Category $category - * @return Mage_Catalog_Model_Resource_Category_Collection - */ - public function getChildrenCategories($category) - { - $collection = $category->getCollection(); - /* @var $collection Mage_Catalog_Model_Resource_Category_Collection */ - $collection->addAttributeToSelect('url_key') - ->addAttributeToSelect('name') - ->addAttributeToSelect('all_children') - ->addAttributeToSelect('is_anchor') - ->addAttributeToFilter('is_active', 1) - ->addIdFilter($category->getChildren()) - ->setOrder('position', Varien_Db_Select::SQL_ASC) - ->joinUrlRewrite() - ->load(); - - return $collection; - } - - /** - * Return children ids of category - * - * @param Mage_Catalog_Model_Category $category - * @param boolean $recursive - * @return array - */ - public function getChildren($category, $recursive = true) - { - $attributeId = (int)$this->_getIsActiveAttributeId(); - $backendTable = $this->getTable(array($this->getEntityTablePrefix(), 'int')); - $adapter = $this->_getReadAdapter(); - $checkSql = $adapter->getCheckSql('c.value_id > 0', 'c.value', 'd.value'); - $bind = array( - 'attribute_id' => $attributeId, - 'store_id' => $category->getStoreId(), - 'scope' => 1, - 'c_path' => $category->getPath() . '/%' - ); - $select = $this->_getReadAdapter()->select() - ->from(array('m' => $this->getEntityTable()), 'entity_id') - ->joinLeft( - array('d' => $backendTable), - 'd.attribute_id = :attribute_id AND d.store_id = 0 AND d.entity_id = m.entity_id', - array() - ) - ->joinLeft( - array('c' => $backendTable), - 'c.attribute_id = :attribute_id AND c.store_id = :store_id AND c.entity_id = m.entity_id', - array() - ) - ->where($checkSql . ' = :scope') - ->where($adapter->quoteIdentifier('path') . ' LIKE :c_path'); - if (!$recursive) { - $select->where($adapter->quoteIdentifier('level') . ' <= :c_level'); - $bind['c_level'] = $category->getLevel() + 1; - } - - return $adapter->fetchCol($select, $bind); - } - - /** - * Return all children ids of category (with category id) - * - * @param Mage_Catalog_Model_Category $category - * @return array - */ - public function getAllChildren($category) - { - $children = $this->getChildren($category); - $myId = array($category->getId()); - $children = array_merge($myId, $children); - - return $children; - } - - /** - * Check is category in list of store categories - * - * @param Mage_Catalog_Model_Category $category - * @return boolean - */ - public function isInRootCategoryList($category) - { - $rootCategoryId = Mage::app()->getStore()->getRootCategoryId(); - - return in_array($rootCategoryId, $category->getParentIds()); - } - - /** - * Check category is forbidden to delete. - * If category is root and assigned to store group return false - * - * @param integer $categoryId - * @return boolean - */ - public function isForbiddenToDelete($categoryId) - { - $select = $this->_getReadAdapter()->select() - ->from($this->getTable('core_store_group'), array('group_id')) - ->where('root_category_id = :root_category_id'); - $result = $this->_getReadAdapter()->fetchOne($select, array('root_category_id' => $categoryId)); - - if ($result) { - return true; - } - return false; - } - - /** - * Get category path value by its id - * - * @param int $categoryId - * @return string - */ - public function getCategoryPathById($categoryId) - { - $select = $this->getReadConnection()->select() - ->from($this->getEntityTable(), array('path')) - ->where('entity_id = :entity_id'); - $bind = array('entity_id' => (int)$categoryId); - - return $this->getReadConnection()->fetchOne($select, $bind); - } - - /** - * Move category to another parent node - * - * @param Mage_Catalog_Model_Category $category - * @param Mage_Catalog_Model_Category $newParent - * @param null|int $afterCategoryId - * @return Mage_Catalog_Model_Resource_Category - */ - public function changeParent(Mage_Catalog_Model_Category $category, Mage_Catalog_Model_Category $newParent, - $afterCategoryId = null) - { - $childrenCount = $this->getChildrenCount($category->getId()) + 1; - $table = $this->getEntityTable(); - $adapter = $this->_getWriteAdapter(); - $levelFiled = $adapter->quoteIdentifier('level'); - $pathField = $adapter->quoteIdentifier('path'); - - /** - * Decrease children count for all old category parent categories - */ - $adapter->update( - $table, - array('children_count' => new Zend_Db_Expr('children_count - ' . $childrenCount)), - array('entity_id IN(?)' => $category->getParentIds()) - ); - - /** - * Increase children count for new category parents - */ - $adapter->update( - $table, - array('children_count' => new Zend_Db_Expr('children_count + ' . $childrenCount)), - array('entity_id IN(?)' => $newParent->getPathIds()) - ); - - $position = $this->_processPositions($category, $newParent, $afterCategoryId); - - $newPath = sprintf('%s/%s', $newParent->getPath(), $category->getId()); - $newLevel = $newParent->getLevel() + 1; - $levelDisposition = $newLevel - $category->getLevel(); - - /** - * Update children nodes path - */ - $adapter->update( - $table, - array( - 'path' => new Zend_Db_Expr('REPLACE(' . $pathField . ','. - $adapter->quote($category->getPath() . '/'). ', '.$adapter->quote($newPath . '/').')' - ), - 'level' => new Zend_Db_Expr( $levelFiled . ' + ' . $levelDisposition) - ), - array($pathField . ' LIKE ?' => $category->getPath() . '/%') - ); - /** - * Update moved category data - */ - $data = array( - 'path' => $newPath, - 'level' => $newLevel, - 'position' =>$position, - 'parent_id' =>$newParent->getId() - ); - $adapter->update($table, $data, array('entity_id = ?' => $category->getId())); - - // Update category object to new data - $category->addData($data); - - return $this; - } - - /** - * Process positions of old parent category children and new parent category children. - * Get position for moved category - * - * @param Mage_Catalog_Model_Category $category - * @param Mage_Catalog_Model_Category $newParent - * @param null|int $afterCategoryId - * @return int - */ - protected function _processPositions($category, $newParent, $afterCategoryId) - { - $table = $this->getEntityTable(); - $adapter = $this->_getWriteAdapter(); - $positionField = $adapter->quoteIdentifier('position'); - - $bind = array( - 'position' => new Zend_Db_Expr($positionField . ' - 1') - ); - $where = array( - 'parent_id = ?' => $category->getParentId(), - $positionField . ' > ?' => $category->getPosition() - ); - $adapter->update($table, $bind, $where); - - /** - * Prepare position value - */ - if ($afterCategoryId) { - $select = $adapter->select() - ->from($table,'position') - ->where('entity_id = :entity_id'); - $position = $adapter->fetchOne($select, array('entity_id' => $afterCategoryId)); - - $bind = array( - 'position' => new Zend_Db_Expr($positionField . ' + 1') - ); - $where = array( - 'parent_id = ?' => $newParent->getId(), - $positionField . ' > ?' => $position - ); - $adapter->update($table,$bind,$where); - } elseif ($afterCategoryId !== null) { - $position = 0; - $bind = array( - 'position' => new Zend_Db_Expr($positionField . ' + 1') - ); - $where = array( - 'parent_id = ?' => $newParent->getId(), - $positionField . ' > ?' => $position - ); - $adapter->update($table,$bind,$where); - } else { - $select = $adapter->select() - ->from($table,array('position' => new Zend_Db_Expr('MIN(' . $positionField. ')'))) - ->where('parent_id = :parent_id'); - $position = $adapter->fetchOne($select, array('parent_id' => $newParent->getId())); - } - $position += 1; - - return $position; - } -} diff --git a/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php b/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php deleted file mode 100644 index a675931cf918a..0000000000000 --- a/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php +++ /dev/null @@ -1,354 +0,0 @@ - - */ -class Mage_Catalog_Model_Resource_Eav_Attribute extends Mage_Eav_Model_Entity_Attribute -{ - const SCOPE_STORE = 0; - const SCOPE_GLOBAL = 1; - const SCOPE_WEBSITE = 2; - - const MODULE_NAME = 'Mage_Catalog'; - const ENTITY = 'catalog_eav_attribute'; - - /** - * Event prefix - * - * @var string - */ - protected $_eventPrefix = 'catalog_entity_attribute'; - /** - * Event object name - * - * @var string - */ - protected $_eventObject = 'attribute'; - - /** - * Array with labels - * - * @var array - */ - static protected $_labels = null; - - protected function _construct() - { - $this->_init('Mage_Catalog_Model_Resource_Attribute'); - } - - /** - * Processing object before save data - * - * @throws Mage_Core_Exception - * @return Mage_Core_Model_Abstract - */ - protected function _beforeSave() - { - $this->setData('modulePrefix', self::MODULE_NAME); - if (isset($this->_origData['is_global'])) { - if (!isset($this->_data['is_global'])) { - $this->_data['is_global'] = self::SCOPE_GLOBAL; - } - if (($this->_data['is_global'] != $this->_origData['is_global']) - && $this->_getResource()->isUsedBySuperProducts($this)) { - Mage::throwException(Mage::helper('Mage_Catalog_Helper_Data')->__('Scope must not be changed, because the attribute is used in configurable products.')); - } - } - if ($this->getFrontendInput() == 'price') { - if (!$this->getBackendModel()) { - $this->setBackendModel('Mage_Catalog_Model_Product_Attribute_Backend_Price'); - } - } - if ($this->getFrontendInput() == 'textarea') { - if ($this->getIsWysiwygEnabled()) { - $this->setIsHtmlAllowedOnFront(1); - } - } - return parent::_beforeSave(); - } - - /** - * Processing object after save data - * - * @return Mage_Core_Model_Abstract - */ - protected function _afterSave() - { - /** - * Fix saving attribute in admin - */ - Mage::getSingleton('Mage_Eav_Model_Config')->clear(); - Mage::getSingleton('Mage_Index_Model_Indexer')->processEntityAction( - $this, self::ENTITY, Mage_Index_Model_Event::TYPE_SAVE - ); - return parent::_afterSave(); - } - - /** - * Register indexing event before delete catalog eav attribute - * - * @return Mage_Catalog_Model_Resource_Eav_Attribute - */ - protected function _beforeDelete() - { - if ($this->_getResource()->isUsedBySuperProducts($this)) { - Mage::throwException(Mage::helper('Mage_Catalog_Helper_Data')->__('This attribute is used in configurable products.')); - } - Mage::getSingleton('Mage_Index_Model_Indexer')->logEvent( - $this, self::ENTITY, Mage_Index_Model_Event::TYPE_DELETE - ); - return parent::_beforeDelete(); - } - - /** - * Init indexing process after catalog eav attribute delete commit - * - * @return Mage_Catalog_Model_Resource_Eav_Attribute - */ - protected function _afterDeleteCommit() - { - parent::_afterDeleteCommit(); - Mage::getSingleton('Mage_Index_Model_Indexer')->indexEvents( - self::ENTITY, Mage_Index_Model_Event::TYPE_DELETE - ); - return $this; - } - - /** - * Return is attribute global - * - * @return integer - */ - public function getIsGlobal() - { - return $this->_getData('is_global'); - } - - /** - * Retrieve attribute is global scope flag - * - * @return bool - */ - public function isScopeGlobal() - { - return $this->getIsGlobal() == self::SCOPE_GLOBAL; - } - - /** - * Retrieve attribute is website scope website - * - * @return bool - */ - public function isScopeWebsite() - { - return $this->getIsGlobal() == self::SCOPE_WEBSITE; - } - - /** - * Retrieve attribute is store scope flag - * - * @return bool - */ - public function isScopeStore() - { - return !$this->isScopeGlobal() && !$this->isScopeWebsite(); - } - - /** - * Retrieve store id - * - * @return int - */ - public function getStoreId() - { - $dataObject = $this->getDataObject(); - if ($dataObject) { - return $dataObject->getStoreId(); - } - return $this->getData('store_id'); - } - - /** - * Retrieve apply to products array - * Return empty array if applied to all products - * - * @return array - */ - public function getApplyTo() - { - if ($this->getData('apply_to')) { - if (is_array($this->getData('apply_to'))) { - return $this->getData('apply_to'); - } - return explode(',', $this->getData('apply_to')); - } else { - return array(); - } - } - - /** - * Retrieve source model - * - * @return Mage_Eav_Model_Entity_Attribute_Source_Abstract - */ - public function getSourceModel() - { - $model = $this->getData('source_model'); - if (empty($model)) { - if ($this->getBackendType() == 'int' && $this->getFrontendInput() == 'select') { - return $this->_getDefaultSourceModel(); - } - } - return $model; - } - - /** - * Whether allowed for rule condition - * - * @return bool - */ - public function isAllowedForRuleCondition() - { - $allowedInputTypes = array( - 'boolean', - 'date', - 'datetime', - 'multiselect', - 'price', - 'select', - 'text', - 'textarea', - 'weight', - ); - return $this->getIsVisible() && in_array($this->getFrontendInput(), $allowedInputTypes); - } - - /** - * Get default attribute source model - * - * @return string - */ - public function _getDefaultSourceModel() - { - return 'Mage_Eav_Model_Entity_Attribute_Source_Table'; - } - - /** - * Check is an attribute used in EAV index - * - * @return bool - */ - public function isIndexable() - { - // exclude price attribute - if ($this->getAttributeCode() == 'price') { - return false; - } - - if (!$this->getIsFilterableInSearch() && !$this->getIsVisibleInAdvancedSearch() && !$this->getIsFilterable()) { - return false; - } - - $backendType = $this->getBackendType(); - $frontendInput = $this->getFrontendInput(); - - if ($backendType == 'int' && $frontendInput == 'select') { - return true; - } else if ($backendType == 'varchar' && $frontendInput == 'multiselect') { - return true; - } else if ($backendType == 'decimal') { - return true; - } - - return false; - } - - /** - * Retrieve index type for indexable attribute - * - * @return string|false - */ - public function getIndexType() - { - if (!$this->isIndexable()) { - return false; - } - if ($this->getBackendType() == 'decimal') { - return 'decimal'; - } - - return 'source'; - } -} diff --git a/app/code/core/Mage/Catalog/Model/Resource/Setup.php b/app/code/core/Mage/Catalog/Model/Resource/Setup.php deleted file mode 100755 index c72d5bdc6065d..0000000000000 --- a/app/code/core/Mage/Catalog/Model/Resource/Setup.php +++ /dev/null @@ -1,911 +0,0 @@ - - */ -class Mage_Catalog_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup -{ - /** - * @param Mage_Core_Model_Config_Resource $resourcesConfig - * @param Mage_Core_Model_Config_Modules $modulesConfig - * @param Mage_Core_Model_Resource $resource - * @param Mage_Core_Model_Config_Modules_Reader $modulesReader - * @param Mage_Core_Model_Cache $cache - * @param $resourceName - */ - public function __construct( - Mage_Core_Model_Config_Resource $resourcesConfig, - Mage_Core_Model_Config_Modules $modulesConfig, - Mage_Core_Model_Resource $resource, - Mage_Core_Model_Config_Modules_Reader $modulesReader, - Mage_Core_Model_Cache $cache, - $resourceName - ) { - parent::__construct($resourcesConfig, $modulesConfig, $resource, $modulesReader, $cache, $resourceName); - $entityTypeForMinimal = $this->getEntityType('Minimal', 'entity_type_id'); - if (is_numeric($entityTypeForMinimal)) { - $minimalAttributeSetId = $this->getAttributeSet( - Mage_Catalog_Model_Product::ENTITY, $entityTypeForMinimal, 'attribute_set_id' - ); - if (is_numeric($minimalAttributeSetId)) { - $this->setExcludedAttributeSetIds(array($minimalAttributeSetId)); - } - } - } - - /** - * Prepare catalog attribute values to save - * - * @param array $attr - * @return array - */ - protected function _prepareValues($attr) - { - $data = parent::_prepareValues($attr); - $data = array_merge($data, array( - 'frontend_input_renderer' => $this->_getValue($attr, 'input_renderer'), - 'is_global' => $this->_getValue( - $attr, - 'global', - Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL - ), - 'is_visible' => $this->_getValue($attr, 'visible', 1), - 'is_searchable' => $this->_getValue($attr, 'searchable', 0), - 'is_filterable' => $this->_getValue($attr, 'filterable', 0), - 'is_comparable' => $this->_getValue($attr, 'comparable', 0), - 'is_visible_on_front' => $this->_getValue($attr, 'visible_on_front', 0), - 'is_wysiwyg_enabled' => $this->_getValue($attr, 'wysiwyg_enabled', 0), - 'is_html_allowed_on_front' => $this->_getValue($attr, 'is_html_allowed_on_front', 0), - 'is_visible_in_advanced_search' => $this->_getValue($attr, 'visible_in_advanced_search', 0), - 'is_filterable_in_search' => $this->_getValue($attr, 'filterable_in_search', 0), - 'used_in_product_listing' => $this->_getValue($attr, 'used_in_product_listing', 0), - 'used_for_sort_by' => $this->_getValue($attr, 'used_for_sort_by', 0), - 'apply_to' => $this->_getValue($attr, 'apply_to'), - 'position' => $this->_getValue($attr, 'position', 0), - 'is_configurable' => $this->_getValue($attr, 'is_configurable', 1), - 'is_used_for_promo_rules' => $this->_getValue($attr, 'used_for_promo_rules', 0) - )); - return $data; - } - - /** - * Default entites and attributes - * - * @return array - */ - public function getDefaultEntities() - { - return array( - 'catalog_category' => array( - 'entity_model' => 'Mage_Catalog_Model_Resource_Category', - 'attribute_model' => 'Mage_Catalog_Model_Resource_Eav_Attribute', - 'table' => 'catalog_category_entity', - 'additional_attribute_table' => 'catalog_eav_attribute', - 'entity_attribute_collection' => 'Mage_Catalog_Model_Resource_Category_Attribute_Collection', - 'default_group' => 'General Information', - 'attributes' => array( - 'name' => array( - 'type' => 'varchar', - 'label' => 'Name', - 'input' => 'text', - 'sort_order' => 1, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'General Information', - ), - 'is_active' => array( - 'type' => 'int', - 'label' => 'Is Active', - 'input' => 'select', - 'source' => 'Mage_Eav_Model_Entity_Attribute_Source_Boolean', - 'sort_order' => 2, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'General Information', - ), - 'url_key' => array( - 'type' => 'varchar', - 'label' => 'URL Key', - 'input' => 'text', - 'backend' => 'Mage_Catalog_Model_Category_Attribute_Backend_Urlkey', - 'required' => false, - 'sort_order' => 3, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'General Information', - ), - 'description' => array( - 'type' => 'text', - 'label' => 'Description', - 'input' => 'textarea', - 'required' => false, - 'sort_order' => 4, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'wysiwyg_enabled' => true, - 'is_html_allowed_on_front' => true, - 'group' => 'General Information', - ), - 'image' => array( - 'type' => 'varchar', - 'label' => 'Image', - 'input' => 'image', - 'backend' => 'Mage_Catalog_Model_Category_Attribute_Backend_Image', - 'required' => false, - 'sort_order' => 5, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'General Information', - ), - 'meta_title' => array( - 'type' => 'varchar', - 'label' => 'Page Title', - 'input' => 'text', - 'required' => false, - 'sort_order' => 6, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'General Information', - ), - 'meta_keywords' => array( - 'type' => 'text', - 'label' => 'Meta Keywords', - 'input' => 'textarea', - 'required' => false, - 'sort_order' => 7, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'General Information', - ), - 'meta_description' => array( - 'type' => 'text', - 'label' => 'Meta Description', - 'input' => 'textarea', - 'required' => false, - 'sort_order' => 8, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'General Information', - ), - 'display_mode' => array( - 'type' => 'varchar', - 'label' => 'Display Mode', - 'input' => 'select', - 'source' => 'Mage_Catalog_Model_Category_Attribute_Source_Mode', - 'required' => false, - 'sort_order' => 10, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'Display Settings', - ), - 'landing_page' => array( - 'type' => 'int', - 'label' => 'CMS Block', - 'input' => 'select', - 'source' => 'Mage_Catalog_Model_Category_Attribute_Source_Page', - 'required' => false, - 'sort_order' => 20, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'Display Settings', - ), - 'is_anchor' => array( - 'type' => 'int', - 'label' => 'Is Anchor', - 'input' => 'select', - 'source' => 'Mage_Eav_Model_Entity_Attribute_Source_Boolean', - 'required' => false, - 'sort_order' => 30, - 'group' => 'Display Settings', - ), - 'path' => array( - 'type' => 'static', - 'label' => 'Path', - 'required' => false, - 'sort_order' => 12, - 'visible' => false, - 'group' => 'General Information', - ), - 'position' => array( - 'type' => 'static', - 'label' => 'Position', - 'required' => false, - 'sort_order' => 13, - 'visible' => false, - 'group' => 'General Information', - ), - 'all_children' => array( - 'type' => 'text', - 'required' => false, - 'sort_order' => 14, - 'visible' => false, - 'group' => 'General Information', - ), - 'path_in_store' => array( - 'type' => 'text', - 'required' => false, - 'sort_order' => 15, - 'visible' => false, - 'group' => 'General Information', - ), - 'children' => array( - 'type' => 'text', - 'required' => false, - 'sort_order' => 16, - 'visible' => false, - 'group' => 'General Information', - ), - 'url_path' => array( - 'type' => 'varchar', - 'required' => false, - 'sort_order' => 17, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'visible' => false, - 'group' => 'General Information', - ), - 'custom_design' => array( - 'type' => 'varchar', - 'label' => 'Custom Design', - 'input' => 'select', - 'source' => 'Mage_Core_Model_Design_Source_Design', - 'required' => false, - 'sort_order' => 10, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'Custom Design', - ), - 'custom_design_from' => array( - 'type' => 'datetime', - 'label' => 'Active From', - 'input' => 'date', - 'backend' => 'Mage_Eav_Model_Entity_Attribute_Backend_Datetime', - 'required' => false, - 'sort_order' => 30, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'Custom Design', - ), - 'custom_design_to' => array( - 'type' => 'datetime', - 'label' => 'Active To', - 'input' => 'date', - 'backend' => 'Mage_Eav_Model_Entity_Attribute_Backend_Datetime', - 'required' => false, - 'sort_order' => 40, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'Custom Design', - ), - 'page_layout' => array( - 'type' => 'varchar', - 'label' => 'Page Layout', - 'input' => 'select', - 'source' => 'Mage_Catalog_Model_Category_Attribute_Source_Layout', - 'required' => false, - 'sort_order' => 50, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'Custom Design', - ), - 'custom_layout_update' => array( - 'type' => 'text', - 'label' => 'Custom Layout Update', - 'input' => 'textarea', - 'backend' => 'Mage_Catalog_Model_Attribute_Backend_Customlayoutupdate', - 'required' => false, - 'sort_order' => 60, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'Custom Design', - ), - 'level' => array( - 'type' => 'static', - 'label' => 'Level', - 'required' => false, - 'sort_order' => 24, - 'visible' => false, - 'group' => 'General Information', - ), - 'children_count' => array( - 'type' => 'static', - 'label' => 'Children Count', - 'required' => false, - 'sort_order' => 25, - 'visible' => false, - 'group' => 'General Information', - ), - 'available_sort_by' => array( - 'type' => 'text', - 'label' => 'Available Product Listing Sort By', - 'input' => 'multiselect', - 'source' => 'Mage_Catalog_Model_Category_Attribute_Source_Sortby', - 'backend' => 'Mage_Catalog_Model_Category_Attribute_Backend_Sortby', - 'sort_order' => 40, - 'input_renderer' => 'Mage_Adminhtml_Block_Catalog_Category_Helper_Sortby_Available', - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'Display Settings', - ), - 'default_sort_by' => array( - 'type' => 'varchar', - 'label' => 'Default Product Listing Sort By', - 'input' => 'select', - 'source' => 'Mage_Catalog_Model_Category_Attribute_Source_Sortby', - 'backend' => 'Mage_Catalog_Model_Category_Attribute_Backend_Sortby', - 'sort_order' => 50, - 'input_renderer' => 'Mage_Adminhtml_Block_Catalog_Category_Helper_Sortby_Default', - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'Display Settings', - ), - 'include_in_menu' => array( - 'type' => 'int', - 'label' => 'Include in Navigation Menu', - 'input' => 'select', - 'source' => 'Mage_Eav_Model_Entity_Attribute_Source_Boolean', - 'default' => '1', - 'sort_order' => 10, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'General Information', - ), - 'custom_use_parent_settings' => array( - 'type' => 'int', - 'label' => 'Use Parent Category Settings', - 'input' => 'select', - 'source' => 'Mage_Eav_Model_Entity_Attribute_Source_Boolean', - 'required' => false, - 'sort_order' => 5, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'Custom Design', - ), - 'custom_apply_to_products' => array( - 'type' => 'int', - 'label' => 'Apply To Products', - 'input' => 'select', - 'source' => 'Mage_Eav_Model_Entity_Attribute_Source_Boolean', - 'required' => false, - 'sort_order' => 6, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'Custom Design', - ), - 'filter_price_range' => array( - 'type' => 'decimal', - 'label' => 'Layered Navigation Price Step', - 'input' => 'text', - 'required' => false, - 'sort_order' => 51, - 'input_renderer' => 'Mage_Adminhtml_Block_Catalog_Category_Helper_Pricestep', - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'Display Settings', - ), - ) - ), - 'catalog_product' => array( - 'entity_model' => 'Mage_Catalog_Model_Resource_Product', - 'attribute_model' => 'Mage_Catalog_Model_Resource_Eav_Attribute', - 'table' => 'catalog_product_entity', - 'additional_attribute_table' => 'catalog_eav_attribute', - 'entity_attribute_collection' => 'Mage_Catalog_Model_Resource_Product_Attribute_Collection', - 'attributes' => array( - 'name' => array( - 'type' => 'varchar', - 'label' => 'Name', - 'input' => 'text', - 'sort_order' => 1, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'searchable' => true, - 'visible_in_advanced_search' => true, - 'used_in_product_listing' => true, - 'used_for_sort_by' => true, - ), - 'sku' => array( - 'type' => 'static', - 'label' => 'SKU', - 'input' => 'text', - 'backend' => 'Mage_Catalog_Model_Product_Attribute_Backend_Sku', - 'unique' => true, - 'sort_order' => 2, - 'searchable' => true, - 'comparable' => true, - 'visible_in_advanced_search' => true, - ), - 'description' => array( - 'type' => 'text', - 'label' => 'Description', - 'input' => 'textarea', - 'sort_order' => 3, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'searchable' => true, - 'comparable' => true, - 'wysiwyg_enabled' => true, - 'is_html_allowed_on_front' => true, - 'visible_in_advanced_search' => true, - ), - 'short_description' => array( - 'type' => 'text', - 'label' => 'Short Description', - 'input' => 'textarea', - 'sort_order' => 4, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'searchable' => true, - 'comparable' => true, - 'wysiwyg_enabled' => true, - 'is_html_allowed_on_front' => true, - 'visible_in_advanced_search' => true, - 'used_in_product_listing' => true, - ), - 'price' => array( - 'type' => 'decimal', - 'label' => 'Price', - 'input' => 'price', - 'backend' => 'Mage_Catalog_Model_Product_Attribute_Backend_Price', - 'sort_order' => 1, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE, - 'searchable' => true, - 'filterable' => true, - 'visible_in_advanced_search' => true, - 'used_in_product_listing' => true, - 'used_for_sort_by' => true, - 'apply_to' => 'simple,configurable,virtual', - 'group' => 'Prices', - ), - 'special_price' => array( - 'type' => 'decimal', - 'label' => 'Special Price', - 'input' => 'price', - 'backend' => 'Mage_Catalog_Model_Product_Attribute_Backend_Price', - 'required' => false, - 'sort_order' => 2, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE, - 'used_in_product_listing' => true, - 'apply_to' => 'simple,configurable,virtual', - 'group' => 'Prices', - ), - 'special_from_date' => array( - 'type' => 'datetime', - 'label' => 'Special Price From Date', - 'input' => 'date', - 'backend' => 'Mage_Catalog_Model_Product_Attribute_Backend_Startdate', - 'required' => false, - 'sort_order' => 3, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE, - 'used_in_product_listing' => true, - 'apply_to' => 'simple,configurable,virtual', - 'group' => 'Prices', - ), - 'special_to_date' => array( - 'type' => 'datetime', - 'label' => 'Special Price To Date', - 'input' => 'date', - 'backend' => 'Mage_Eav_Model_Entity_Attribute_Backend_Datetime', - 'required' => false, - 'sort_order' => 4, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE, - 'used_in_product_listing' => true, - 'apply_to' => 'simple,configurable,virtual', - 'group' => 'Prices', - ), - 'cost' => array( - 'type' => 'decimal', - 'label' => 'Cost', - 'input' => 'price', - 'backend' => 'Mage_Catalog_Model_Product_Attribute_Backend_Price', - 'required' => false, - 'user_defined' => true, - 'sort_order' => 5, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE, - 'apply_to' => 'simple,virtual', - 'group' => 'Prices', - ), - 'weight' => array( - 'type' => 'decimal', - 'label' => 'Weight', - 'input' => 'weight', - 'sort_order' => 5, - 'apply_to' => Mage_Catalog_Model_Product_Type::TYPE_SIMPLE, - ), - 'manufacturer' => array( - 'type' => 'int', - 'label' => 'Manufacturer', - 'input' => 'select', - 'required' => false, - 'user_defined' => true, - 'searchable' => true, - 'filterable' => true, - 'comparable' => true, - 'visible_in_advanced_search' => true, - 'apply_to' => Mage_Catalog_Model_Product_Type::TYPE_SIMPLE, - ), - 'meta_title' => array( - 'type' => 'varchar', - 'label' => 'Meta Title', - 'input' => 'text', - 'required' => false, - 'sort_order' => 1, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'Meta Information', - ), - 'meta_keyword' => array( - 'type' => 'text', - 'label' => 'Meta Keywords', - 'input' => 'textarea', - 'required' => false, - 'sort_order' => 2, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'Meta Information', - ), - 'meta_description' => array( - 'type' => 'varchar', - 'label' => 'Meta Description', - 'input' => 'textarea', - 'required' => false, - 'note' => 'Maximum 255 chars', - 'class' => 'validate-length maximum-length-255', - 'sort_order' => 3, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'Meta Information', - ), - 'image' => array( - 'type' => 'varchar', - 'label' => 'Base Image', - 'input' => 'media_image', - 'frontend' => 'Mage_Catalog_Model_Product_Attribute_Frontend_Image', - 'required' => false, - 'sort_order' => 1, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'Images', - ), - 'small_image' => array( - 'type' => 'varchar', - 'label' => 'Small Image', - 'input' => 'media_image', - 'frontend' => 'Mage_Catalog_Model_Product_Attribute_Frontend_Image', - 'required' => false, - 'sort_order' => 2, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'used_in_product_listing' => true, - 'group' => 'Images', - ), - 'thumbnail' => array( - 'type' => 'varchar', - 'label' => 'Thumbnail', - 'input' => 'media_image', - 'frontend' => 'Mage_Catalog_Model_Product_Attribute_Frontend_Image', - 'required' => false, - 'sort_order' => 3, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'used_in_product_listing' => true, - 'group' => 'Images', - ), - 'media_gallery' => array( - 'type' => 'varchar', - 'label' => 'Media Gallery', - 'input' => 'gallery', - 'backend' => 'Mage_Catalog_Model_Product_Attribute_Backend_Media', - 'required' => false, - 'sort_order' => 4, - 'group' => 'Images', - ), - 'old_id' => array( - 'type' => 'int', - 'required' => false, - 'sort_order' => 6, - 'visible' => false, - ), - 'group_price' => array( - 'type' => 'decimal', - 'label' => 'Group Price', - 'input' => 'text', - 'backend' => 'Mage_Catalog_Model_Product_Attribute_Backend_Groupprice', - 'required' => false, - 'sort_order' => 6, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE, - 'apply_to' => 'simple,configurable,virtual', - 'group' => 'Prices', - ), - 'tier_price' => array( - 'type' => 'decimal', - 'label' => 'Tier Price', - 'input' => 'text', - 'backend' => 'Mage_Catalog_Model_Product_Attribute_Backend_Tierprice', - 'required' => false, - 'sort_order' => 6, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE, - 'apply_to' => 'simple,configurable,virtual', - 'group' => 'Prices', - ), - 'color' => array( - 'type' => 'int', - 'label' => 'Color', - 'input' => 'select', - 'required' => false, - 'user_defined' => true, - 'searchable' => true, - 'filterable' => true, - 'comparable' => true, - 'visible_in_advanced_search' => true, - 'apply_to' => Mage_Catalog_Model_Product_Type::TYPE_SIMPLE, - ), - 'news_from_date' => array( - 'type' => 'datetime', - 'label' => 'Set Product as New from Date', - 'input' => 'date', - 'backend' => 'Mage_Eav_Model_Entity_Attribute_Backend_Datetime', - 'required' => false, - 'sort_order' => 7, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE, - 'used_in_product_listing' => true, - ), - 'news_to_date' => array( - 'type' => 'datetime', - 'label' => 'Set Product as New to Date', - 'input' => 'date', - 'backend' => 'Mage_Eav_Model_Entity_Attribute_Backend_Datetime', - 'required' => false, - 'sort_order' => 8, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE, - 'used_in_product_listing' => true, - ), - 'gallery' => array( - 'type' => 'varchar', - 'label' => 'Image Gallery', - 'input' => 'gallery', - 'required' => false, - 'sort_order' => 5, - 'group' => 'Images', - ), - 'status' => array( - 'type' => 'int', - 'label' => 'Status', - 'input' => 'select', - 'source' => 'Mage_Catalog_Model_Product_Status', - 'sort_order' => 9, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE, - 'searchable' => true, - 'used_in_product_listing' => true, - ), - 'url_key' => array( - 'type' => 'varchar', - 'label' => 'URL Key', - 'input' => 'text', - 'backend' => 'Mage_Catalog_Model_Product_Attribute_Backend_Urlkey', - 'required' => false, - 'sort_order' => 10, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'used_in_product_listing' => true, - ), - 'url_path' => array( - 'type' => 'varchar', - 'required' => false, - 'sort_order' => 11, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'visible' => false, - ), - 'minimal_price' => array( - 'type' => 'decimal', - 'label' => 'Minimal Price', - 'input' => 'price', - 'required' => false, - 'sort_order' => 7, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'visible' => false, - 'apply_to' => 'simple,configurable,virtual', - 'group' => 'Prices', - ), - 'is_recurring' => array( - 'type' => 'int', - 'label' => 'Enable Recurring Profile', - 'input' => 'select', - 'source' => 'Mage_Eav_Model_Entity_Attribute_Source_Boolean', - 'required' => false, - 'note' => - 'Products with recurring profile participate in catalog as nominal items.', - 'sort_order' => 1, - 'apply_to' => 'simple,virtual', - 'is_configurable' => false, - 'group' => 'Recurring Profile', - ), - 'recurring_profile' => array( - 'type' => 'text', - 'label' => 'Recurring Payment Profile', - 'input' => 'text', - 'backend' => 'Mage_Catalog_Model_Product_Attribute_Backend_Recurring', - 'required' => false, - 'sort_order' => 2, - 'apply_to' => 'simple,virtual', - 'is_configurable' => false, - 'group' => 'Recurring Profile', - ), - 'visibility' => array( - 'type' => 'int', - 'label' => 'Visibility', - 'input' => 'select', - 'source' => 'Mage_Catalog_Model_Product_Visibility', - 'default' => '4', - 'sort_order' => 12, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - ), - 'custom_design' => array( - 'type' => 'varchar', - 'label' => 'Custom Design', - 'input' => 'select', - 'source' => 'Mage_Core_Model_Design_Source_Design', - 'required' => false, - 'sort_order' => 1, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'Design', - ), - 'custom_design_from' => array( - 'type' => 'datetime', - 'label' => 'Active From', - 'input' => 'date', - 'backend' => 'Mage_Eav_Model_Entity_Attribute_Backend_Datetime', - 'required' => false, - 'sort_order' => 2, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'Design', - ), - 'custom_design_to' => array( - 'type' => 'datetime', - 'label' => 'Active To', - 'input' => 'date', - 'backend' => 'Mage_Eav_Model_Entity_Attribute_Backend_Datetime', - 'required' => false, - 'sort_order' => 3, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'Design', - ), - 'custom_layout_update' => array( - 'type' => 'text', - 'label' => 'Custom Layout Update', - 'input' => 'textarea', - 'backend' => 'Mage_Catalog_Model_Attribute_Backend_Customlayoutupdate', - 'required' => false, - 'sort_order' => 4, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'Design', - ), - 'page_layout' => array( - 'type' => 'varchar', - 'label' => 'Page Layout', - 'input' => 'select', - 'source' => 'Mage_Catalog_Model_Product_Attribute_Source_Layout', - 'required' => false, - 'sort_order' => 5, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'Design', - ), - 'category_ids' => array( - 'type' => 'static', - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, - 'required' => false, - 'sort_order' => 13, - 'visible' => false, - ), - 'options_container' => array( - 'type' => 'varchar', - 'label' => 'Display Product Options In', - 'input' => 'select', - 'source' => 'Mage_Catalog_Model_Entity_Product_Attribute_Design_Options_Container', - 'required' => false, - 'default' => 'container2', - 'sort_order' => 6, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'group' => 'Design', - ), - 'required_options' => array( - 'type' => 'static', - 'input' => 'text', - 'required' => false, - 'sort_order' => 14, - 'visible' => false, - 'used_in_product_listing' => true, - ), - 'has_options' => array( - 'type' => 'static', - 'input' => 'text', - 'required' => false, - 'sort_order' => 15, - 'visible' => false, - ), - 'image_label' => array( - 'type' => 'varchar', - 'label' => 'Image Label', - 'input' => 'text', - 'required' => false, - 'sort_order' => 16, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'visible' => false, - 'used_in_product_listing' => true, - 'is_configurable' => false, - ), - 'small_image_label' => array( - 'type' => 'varchar', - 'label' => 'Small Image Label', - 'input' => 'text', - 'required' => false, - 'sort_order' => 17, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'visible' => false, - 'used_in_product_listing' => true, - 'is_configurable' => false, - ), - 'thumbnail_label' => array( - 'type' => 'varchar', - 'label' => 'Thumbnail Label', - 'input' => 'text', - 'required' => false, - 'sort_order' => 18, - 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, - 'visible' => false, - 'used_in_product_listing' => true, - 'is_configurable' => false, - ), - 'created_at' => array( - 'type' => 'static', - 'input' => 'text', - 'backend' => 'Mage_Eav_Model_Entity_Attribute_Backend_Time_Created', - 'sort_order' => 19, - 'visible' => false, - ), - 'updated_at' => array( - 'type' => 'static', - 'input' => 'text', - 'backend' => 'Mage_Eav_Model_Entity_Attribute_Backend_Time_Updated', - 'sort_order' => 20, - 'visible' => false, - ), - ) - ) - ); - } - - /** - * Returns category entity row by category id - * - * @param int $entityId - * @return array - */ - protected function _getCategoryEntityRow($entityId) - { - $select = $this->getConnection()->select(); - - $select->from($this->getTable('catalog_category_entity')); - $select->where('entity_id = :entity_id'); - - return $this->getConnection()->fetchRow($select, array('entity_id' => $entityId)); - } - - /** - * Returns category path as array - * - * @param array $category - * @param array $path - * @return string - */ - protected function _getCategoryPath($category, $path = array()) - { - $path[] = $category['entity_id']; - - if ($category['parent_id'] != 0) { - $parentCategory = $this->_getCategoryEntityRow($category['parent_id']); - if ($parentCategory) { - $path = $this->_getCategoryPath($parentCategory, $path); - } - } - - return $path; - } -} diff --git a/app/code/core/Mage/Catalog/controllers/ProductController.php b/app/code/core/Mage/Catalog/controllers/ProductController.php deleted file mode 100644 index fc087fc589dfa..0000000000000 --- a/app/code/core/Mage/Catalog/controllers/ProductController.php +++ /dev/null @@ -1,115 +0,0 @@ -getRequest()->getParam('category', false); - $productId = (int)$this->getRequest()->getParam('id'); - - $params = new Varien_Object(); - $params->setCategoryId($categoryId); - - return Mage::helper('Mage_Catalog_Helper_Product')->initProduct($productId, $this, $params); - } - - /** - * Initialize product view layout - * - * @param Mage_Catalog_Model_Product $product - * @return Mage_Catalog_ProductController - */ - protected function _initProductLayout($product) - { - Mage::helper('Mage_Catalog_Helper_Product_View')->initProductLayout($product, $this); - return $this; - } - - /** - * Product view action - */ - public function viewAction() - { - // Get initial data from request - $categoryId = (int) $this->getRequest()->getParam('category', false); - $productId = (int) $this->getRequest()->getParam('id'); - $specifyOptions = $this->getRequest()->getParam('options'); - - // Prepare helper and params - $viewHelper = Mage::helper('Mage_Catalog_Helper_Product_View'); - - $params = new Varien_Object(); - $params->setCategoryId($categoryId); - $params->setSpecifyOptions($specifyOptions); - - // Render page - try { - $viewHelper->prepareAndRender($productId, $this, $params); - } catch (Exception $e) { - if ($e->getCode() == $viewHelper->ERR_NO_PRODUCT_LOADED) { - if (isset($_GET['store']) && !$this->getResponse()->isRedirect()) { - $this->_redirect(''); - } elseif (!$this->getResponse()->isRedirect()) { - $this->_forward('noRoute'); - } - } else { - Mage::logException($e); - $this->_forward('noRoute'); - } - } - } - - /** - * View product gallery action - */ - public function galleryAction() - { - if (!$this->_initProduct()) { - if (isset($_GET['store']) && !$this->getResponse()->isRedirect()) { - $this->_redirect(''); - } elseif (!$this->getResponse()->isRedirect()) { - $this->_forward('noRoute'); - } - return; - } - $this->loadLayout(); - $this->renderLayout(); - } -} diff --git a/app/code/core/Mage/Catalog/data/catalog_setup/data-upgrade-1.6.0.0.15-1.6.0.0.16.php b/app/code/core/Mage/Catalog/data/catalog_setup/data-upgrade-1.6.0.0.15-1.6.0.0.16.php deleted file mode 100644 index 4a58acb46fe40..0000000000000 --- a/app/code/core/Mage/Catalog/data/catalog_setup/data-upgrade-1.6.0.0.15-1.6.0.0.16.php +++ /dev/null @@ -1,49 +0,0 @@ -getEntityTypeId(Mage_Catalog_Model_Product::ENTITY); - -$minimalAttributeSetName = 'Minimal'; -$this->addAttributeSet($entityTypeId, $minimalAttributeSetName); -$setId = $this->getAttributeSetId($entityTypeId, $minimalAttributeSetName); - -foreach ($attributeCodes as $attributeCode) { - $attribute = $this->getAttribute(Mage_Catalog_Model_Product::ENTITY, $attributeCode); - $this->addAttributeToSet($entityTypeId, $setId, $this->getGeneralGroupName(), $attribute['attribute_id']); -} diff --git a/app/code/core/Mage/Catalog/etc/adminhtml/acl.xml b/app/code/core/Mage/Catalog/etc/adminhtml/acl.xml deleted file mode 100644 index addc4c7ad9724..0000000000000 --- a/app/code/core/Mage/Catalog/etc/adminhtml/acl.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Catalog/etc/adminhtml/menu.xml b/app/code/core/Mage/Catalog/etc/adminhtml/menu.xml deleted file mode 100644 index 1e5483a812c39..0000000000000 --- a/app/code/core/Mage/Catalog/etc/adminhtml/menu.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Catalog/etc/adminhtml/system.xml b/app/code/core/Mage/Catalog/etc/adminhtml/system.xml deleted file mode 100644 index e8abef0012c35..0000000000000 --- a/app/code/core/Mage/Catalog/etc/adminhtml/system.xml +++ /dev/null @@ -1,293 +0,0 @@ - - - - - - - -
    - separator-top - - catalog - Mage_Catalog::config_catalog - - - - - Use {{name}} as Product Name placeholder - - - - Use {{name}} as Product Name placeholder - - - - Use {{name}} and {{sku}} as Product Name and Product SKU placeholders - - - - Use {{name}} and {{description}} as Product Name and Product Description placeholders - - - - - - - Mage_Catalog_Model_Config_Source_ListMode - - - - Comma-separated. - validate-per-page-value-list - - - - Must be in the allowed values list. - validate-per-page-value - - - - Comma-separated. - validate-per-page-value-list - - - - Must be in the allowed values list. - validate-per-page-value - - - - Mage_Catalog_Block_Adminhtml_System_Config_Form_Field_Select_Flatcatalog - Mage_Catalog_Model_System_Config_Backend_Catalog_Category_Flat - Mage_Backend_Model_Config_Source_Yesno - - - - Mage_Catalog_Block_Adminhtml_System_Config_Form_Field_Select_Flatproduct - Mage_Catalog_Model_System_Config_Backend_Catalog_Product_Flat - Mage_Backend_Model_Config_Source_Yesno - - - - Mage_Catalog_Model_Config_Source_ListSort - - - - Whether to show "All" option in the "Show X Per Page" dropdown. - Mage_Backend_Model_Config_Source_Yesno - - - - E.g. {{media url="path/to/image.jpg"}} {{skin url="path/to/picture.gif"}}. Dynamic directives parsing impacts catalog performance. - Mage_Backend_Model_Config_Source_Yesno - - - - - 1 - Mage_Catalog_Model_Config_Clone_Media_Image - - - Mage_Backend_Model_Config_Backend_Image - catalog/product/placeholder - catalog/product/placeholder - - - - - - - Mage_Catalog_Model_System_Config_Backend_Catalog_Url_Rewrite_Suffix - Cache refresh needed. - - - - Mage_Catalog_Model_System_Config_Backend_Catalog_Url_Rewrite_Suffix - Cache refresh needed. - - - - Mage_Backend_Model_Config_Source_Yesno - Mage_Catalog_Model_Config_Backend_Seo_Product - - - - Mage_Backend_Model_Config_Source_Yesno - - - - - - - Mage_Backend_Model_Config_Source_Yesno - - - - Mage_Backend_Model_Config_Source_Yesno - - - - - - - "Currency Options" > "Base Currency").]]> - Mage_Catalog_Model_Config_Source_Price_Scope - 1 - - - - - - - Mage_Backend_Model_Config_Source_Yesno - - - - Mage_Catalog_Model_Config_Source_Price_Step - - - - validate-number validate-number-range number-range-0.01-1000000000 - - manual - - - - - Maximum number of price intervals is 100 - validate-digits validate-digits-range digits-range-2-100 - - manual - - - - - This setting will be applied when all prices in the specific price interval are equal. - Mage_Backend_Model_Config_Source_Yesno - - improved - - - - - Please specify the number of products, that will not be divided into subintervals. - validate-digits validate-digits-range digits-range-1-10000 - - improved - - - - - - - - - - - - - - Mage_Backend_Model_Config_Source_Yesno - - - - Mage_Adminhtml_Block_Catalog_Form_Renderer_Config_DateFieldsOrder - - - - Mage_Catalog_Model_Config_Source_TimeFormat - - - - Use four-digit year format. - Mage_Adminhtml_Block_Catalog_Form_Renderer_Config_YearRange - - -
    -
    - - - 1 - Mage_Catalog_Model_Config_Clone_Media_Image - - - Example format: 200x300. - - - - - - - Mage_Backend_Model_Config_Backend_Image - catalog/product/watermark - catalog/product/watermark - Allowed file types: jpeg, gif, png. - - - - Mage_Catalog_Model_Config_Source_Watermark_Position - - -
    -
    - - - - Applicable to catalog products and categories only. Any media content will be inserted into editor as a static URL. It is not updated if the system configuration base URL changes. - Mage_Backend_Model_Config_Source_Yesno - - -
    -
    - - - - - Mage_Backend_Model_Config_Source_Yesno - - - - Mage_Backend_Model_Config_Source_Yesno - - Warning! Applying MAP by default will hide all product prices on the frontend.]]> - - - - - Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type - - - - - - - - -
    -
    -
    diff --git a/app/code/core/Mage/Catalog/etc/config.xml b/app/code/core/Mage/Catalog/etc/config.xml deleted file mode 100644 index 54cdd37357817..0000000000000 --- a/app/code/core/Mage/Catalog/etc/config.xml +++ /dev/null @@ -1,495 +0,0 @@ - - - - - - 1.6.0.0.20 - true - core - - - - - - - - - - - - - Mage_Catalog - Mage_Catalog_Model_Resource_Setup - - - - - - - Mage_Catalog_Model_Product_Indexer_Eav - - - Mage_Catalog_Model_Product_Indexer_Price - - - Mage_Catalog_Model_Indexer_Url - - - Mage_Catalog_Model_Product_Indexer_Flat - - - Mage_Catalog_Model_Category_Indexer_Flat - - - Mage_Catalog_Model_Category_Indexer_Product - - - - - - - - Mage_Catalog_Model_Observer - catalogProductCompareClean - - - - - - - Mage_Catalog_Model_Observer - addCatalogToTopmenuItems - - - - - - - Mage_Catalog_Model_Observer - transitionProductType - - - - - - - - - - Mage_Catalog_Model_Product_Type_Simple - 0 - 10 - - - - Mage_Catalog_Model_Product_Type_Grouped - Mage_Catalog_Model_Product_Type_Grouped_Price - 1 - - - - - 50 - Mage_Catalog_Model_Resource_Product_Indexer_Price_Grouped - - - - Mage_Catalog_Model_Product_Type_Configurable - Mage_Catalog_Model_Product_Type_Configurable_Price - 1 - - - - - 30 - Mage_Catalog_Model_Resource_Product_Indexer_Price_Configurable - - - - Mage_Catalog_Model_Product_Type_Virtual - 0 - 20 - - - - - - container1 - - - - container2 - - - - - - - - - - Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Text - - - - - - - - - - - - Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_File - - - - - - - - - - Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Date - - - - - - - - - - - - - - - 64 - - frontend/product/collection/attributes - - 0 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Mage_Catalog_Model_Template_Filter - - - 10 - - - - - - sku - - - - - - - url_key - - - - - - status - - - - - - - - visibility - - - - - - - - - - - - - Mage_Catalog_Model_Session - Mage_Checkout_Model_Session - - - - - - - - - - - Mage_Catalog.csv - - - - - - - - - Mage_Catalog_Model_Observer - catalogCheckIsUsingStaticUrlsAllowed - - - - - - - - - standard - - Mage_Catalog - catalog - - - - - catalog - - - - - - model - Mage_Catalog_Model_Product_Compare_Item - bindCustomerLogin - - - - - - - model - Mage_Catalog_Model_Product_Compare_Item - bindCustomerLogout - - - - - - - model - Mage_Catalog_Model_Product_Option_Observer - copyQuoteFilesToOrderFiles - - - - - - - - - Mage_Catalog.csv - - - - - - - - layout.xml - - - msrp.xml - - - - - - 9,15,30 - 5,10,15,20,25 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - - - {{name}} - {{name}} - {{name}},{{sku}} - {{name}} {{description}} - - - grid-list - 9,15,30 - 5,10,15,20,25 - 9 - 10 - 0 - position - 1 - - - 2 - - - .html - .html - 1 - 1 - - - 0 - 0 - - - m,d,y - 12h - php,exe - - - auto - 100 - 10 - 0 - 9 - 1 - - - - - - catalog - custom_options - - - - - - 0 - 0 - 1 - Our price is lower than the manufacturer's "minimum advertised price." As a result, we cannot show you the price in catalog or the product page. <br /><br /> You have no obligation to purchase the product once you know the price. You can simply remove the item from your cart. - Our price is lower than the manufacturer's "minimum advertised price." As a result, we cannot show you the price in catalog or the product page. <br /><br /> You have no obligation to purchase the product once you know the price. You can simply remove the item from your cart. - - - - - - - - 0 2 * * * - - - Mage_Catalog_Model_Observer::reindexProductPrices - - - - - diff --git a/app/code/core/Mage/Catalog/etc/view.xml b/app/code/core/Mage/Catalog/etc/view.xml deleted file mode 100644 index 6548bb5948505..0000000000000 --- a/app/code/core/Mage/Catalog/etc/view.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - 50 - 75 - 85 - 135 - 56 - 265 - - diff --git a/app/code/core/Mage/Catalog/view/adminhtml/js/product-gallery.js b/app/code/core/Mage/Catalog/view/adminhtml/js/product-gallery.js deleted file mode 100644 index c314f82de3f36..0000000000000 --- a/app/code/core/Mage/Catalog/view/adminhtml/js/product-gallery.js +++ /dev/null @@ -1,328 +0,0 @@ -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category mage - * @package mage - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ -/*jshint jquery:true*/ -(function($) { - "use strict"; - /** - * Product gallery widget - */ - $.widget('mage.productGallery', { - options: { - imageSelector: '[data-role="image"]', - template: '.image-template', - types: null, - initialized: false - }, - - /** - * Gallery creation - * @protected - */ - _create: function() { - this.options.types = this.options.types || this.element.data('types'); - this.options.images = this.options.images || this.element.data('images'); - this.$template = this.element.find(this.options.template); - this._bind(); - $.each(this.options.images, $.proxy(function(index, imageData) { - this.element.trigger('addItem', imageData); - }, this)); - this.options.initialized = true; - }, - - /** - * Bind handler to elements - * @protected - */ - _bind: function() { - var events = { - addItem: '_addItem', - removeItem: '_removeItem', - setImageType: '_setImageType', - setPosition: '_setPosition', - resort: '_resort', - 'click [data-role="delete-button"]': function(event) { - event.preventDefault(); - var $imageContainer = $(event.currentTarget).closest(this.options.imageSelector); - this.element.trigger('removeItem', $imageContainer.data('imageData')); - }, - 'click [data-role="make-main-button"]': function(event) { - event.preventDefault(); - var $imageContainer = $(event.currentTarget).closest(this.options.imageSelector); - var imageData = $imageContainer.data('imageData'); - this.setMain(imageData); - }, - 'change [data-role="type-selector"]': '_changeType', - 'change [data-role="visibility-trigger"]': '_changeVisibility' - }; - events['click ' + this.options.imageSelector] = function() { - $(event.currentTarget).toggleClass('active'); - }; - this._on(events); - - this.element.sortable({ - distance: 8, - items: this.options.imageSelector, - tolerance: "pointer", - cancel: 'input, button, .ui-dialog, .uploader', - update: $.proxy(function() { - this.element.trigger('resort'); - }, this) - }); - }, - - /** - * Change visibility - * - * @param event - * @private - */ - _changeVisibility: function(event) { - var $checkbox = $(event.currentTarget); - var $imageContainer = $checkbox.closest(this.options.imageSelector); - $imageContainer.toggleClass('disabled', $checkbox.is(':checked')); - }, - - /** - * Set image as main - * @param {Object} imageData - * @private - */ - setMain: function(imageData) { - var baseImage = this.options.types.image; - var sameImages = $.grep( - $.map(this.options.types, function(el) { - return el; - }), - function(el) { - return el.value == baseImage.value; - } - ); - - $.each(sameImages, $.proxy(function(index, image) { - this.element.trigger('setImageType', { - type: image.code, - imageData: imageData - }); - }, this)); - }, - - /** - * Set image - * @param event - * @private - */ - _changeType: function(event) { - var $checkbox = $(event.currentTarget); - var $imageContainer = $checkbox.closest(this.options.imageSelector); - this.element.trigger('setImageType', { - type: $checkbox.val(), - imageData: $checkbox.is(':checked') ? $imageContainer.data('imageData') : null - }); - }, - - /** - * Find element by fileName - * @param {Object} data - * @returns {Element} - */ - findElement: function(data) { - return this.element.find(this.options.imageSelector).filter(function() { - return $(this).data('imageData').file == data.file; - }).first(); - }, - - /** - * Add image - * @param event - * @param imageData - * @private - */ - _addItem: function(event, imageData) { - var count = this.element.find(this.options.imageSelector).length; - imageData = $.extend({ - file_id: Math.random().toString(33).substr(2, 18), - disabled: 0, - position: count + 1 - }, imageData); - - var element = this.$template.tmpl(imageData).data('imageData', imageData); - if (count === 0) { - element.prependTo(this.element); - } else { - element.insertAfter(this.element.find(this.options.imageSelector + ':last')); - } - - if (!this.options.initialized && this.options.images.length === 0 || - this.options.initialized && this.element.find(this.options.imageSelector + ':not(.removed)').length == 1 - ) { - this.setMain(imageData); - } - $.each(this.options.types, $.proxy(function(index, image) { - if (imageData.file == image.value) { - this.element.trigger('setImageType', { - type: image.code, - imageData: imageData - }); - } - }, this)); - }, - - /** - * Remove Image - * @param {jQuery.Event} event - * @param imageData - * @private - */ - _removeItem: function(event, imageData) { - var $imageContainer = this.findElement(imageData); - $imageContainer.addClass('removed').hide().find('.is-removed').val(1); - }, - - /** - * Set image type - * @param event - * @param data - * @private - */ - _setImageType: function(event, data){ - this.element.find('.type-' + data.type).hide(); - if (data.imageData) { - this.options.types[data.type].value = data.imageData.file; - this.findElement(data.imageData).find('.type-' + data.type).show(); - } else { - this.options.types[data.type].value = null; - } - this.element.find('.image-' + data.type).val(this.options.types[data.type].value || 'no_selection'); - }, - - /** - * Resort images - * @private - */ - _resort: function() { - this.element.find('.position').each($.proxy(function(index, element) { - var value = $(element).val(); - if (value != index) { - this.element.trigger('moveElement', { - imageData: $(element).closest(this.options.imageSelector).data('imageData'), - position: index - }); - $(element).val(index); - } - }, this)); - }, - - /** - * Set image position - * @param event - * @param data - * @private - */ - _setPosition: function(event, data) { - var $element = this.findElement(data.imageData); - var curIndex = this.element.find(this.options.imageSelector).index($element); - var newPosition = data.position + (curIndex > data.position ? -1 : 0); - if (data.position != curIndex) { - if (data.position === 0) { - this.element.prepend($element); - } else { - $element.insertAfter( - this.element.find(this.options.imageSelector).eq(newPosition) - ); - } - this.element.trigger('resort'); - } - } - }); - - // Extension for mage.productGallery - Add advanced settings dialog - $.widget('mage.productGallery', $.mage.productGallery, { - options: { - dialogTemplate: '.dialog-template' - }, - - /** - * Bind handler to elements - * @protected - */ - _bind: function() { - this._super(); - var events = { - 'click [data-role="delete-button"]': function() { - this.element.find('[data-role="dialog"]').trigger('close'); - } - }; - events['dblclick ' + this.options.imageSelector] = function(event) { - this._showDialog($(event.currentTarget).data('imageData')); - }; - this._on(events); - this.element.on('sortstart', $.proxy(function() { - this.element.find('[data-role="dialog"]').trigger('close'); - }, this)); - - }, - - /** - * Show dialog - * @param imageData - * @private - */ - _showDialog: function(imageData) { - var $imageContainer = this.findElement(imageData); - var dialogElement = $imageContainer.data('dialog'); - if ($imageContainer.is('.removed')) { - return; - } - - if (!dialogElement) { - var $template = this.element.find(this.options.dialogTemplate); - var imageCountInLine = 6; - dialogElement = $template.tmpl(imageData); - - dialogElement.on("open", $.proxy(function(event) { - var imagesList = this.element.find(this.options.imageSelector + ':not(.removed)'); - var index = imagesList.index($imageContainer); - var positionIndex = Math.floor(index / imageCountInLine + 1) * imageCountInLine - 1; - if (positionIndex > imagesList.length - 1) { - positionIndex = imagesList.length - 1; - } - var afterElement = imagesList.get(positionIndex); - $(event.target).insertAfter(afterElement); - $imageContainer.find('[data-role="type-selector"]').each($.proxy(function(index, checkbox) { - var $checkbox = $(checkbox); - $checkbox.prop('checked', this.options.types[$checkbox.val()].value == imageData.file); - }, this)); - $(event.target).show(); - }, this)); - dialogElement.on("close", function(event) { - $(event.target).hide(); - }); - $imageContainer.data('dialog', dialogElement); - } - dialogElement.trigger('open'); - - } - }); -})(jQuery); diff --git a/app/code/core/Mage/Catalog/view/adminhtml/product/configurable/attribute-selector/js.phtml b/app/code/core/Mage/Catalog/view/adminhtml/product/configurable/attribute-selector/js.phtml deleted file mode 100644 index 059d72730a632..0000000000000 --- a/app/code/core/Mage/Catalog/view/adminhtml/product/configurable/attribute-selector/js.phtml +++ /dev/null @@ -1,61 +0,0 @@ - - - diff --git a/app/code/core/Mage/Catalog/view/adminhtml/product/grouped/container.phtml b/app/code/core/Mage/Catalog/view/adminhtml/product/grouped/container.phtml deleted file mode 100644 index 63f6c4426ba5b..0000000000000 --- a/app/code/core/Mage/Catalog/view/adminhtml/product/grouped/container.phtml +++ /dev/null @@ -1,38 +0,0 @@ - - - -
    -
    -

    - getTabLabel() ?> -

    -
    -
    - getChildHtml()?> -
    -
    diff --git a/app/code/core/Mage/Catalog/view/adminhtml/product/product.css b/app/code/core/Mage/Catalog/view/adminhtml/product/product.css deleted file mode 100644 index 5068880ed710b..0000000000000 --- a/app/code/core/Mage/Catalog/view/adminhtml/product/product.css +++ /dev/null @@ -1,1074 +0,0 @@ -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Catalog - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ - -.ui-helper-hidden { - display: none; -} - -.ui-helper-hidden-accessible { - position: absolute !important; - clip: rect(1px 1px 1px 1px); - clip: rect(1px, 1px, 1px, 1px); -} - -.ui-helper-reset { - margin: 0; - padding: 0; - border: 0; - outline: 0; - line-height: 1.3; - text-decoration: none; - font-size: 100%; - list-style: none; -} - -.ui-helper-clearfix:before, .ui-helper-clearfix:after { - content: ""; - display: table; -} - -.ui-helper-clearfix:after { - clear: both; -} - -.ui-helper-clearfix { - zoom: 1; -} - -.ui-helper-zfix { - width: 100%; - height: 100%; - top: 0; - left: 0; - position: absolute; - opacity: 0; - filter: Alpha(Opacity = 0); -} - - - -.ui-autocomplete .ui-state-disabled { - cursor: default !important; -} - -.ui-icon { - display: block; - text-indent: -99999px; - overflow: hidden; - background-repeat: no-repeat; -} - -.ui-widget-content { - border: 1px solid #dddddd; - background: #eeeeee url(images/ui-bg_highlight-soft_100_eeeeee_1x100.png) 50% top repeat-x; - color: #333333; -} - -.ui-widget-content a { - color: #333333; -} - -.ui-autocomplete .ui-state-default, -.ui-autocomplete .ui-widget-content .ui-state-default, -.ui-autocomplete .ui-widget-header .ui-state-default { - border: 1px solid #cccccc; - background: #f6f6f6 url(images/ui-bg_glass_100_f6f6f6_1x400.png) 50% 50% repeat-x; - font-weight: bold; - color: #1c94c4; -} - -.ui-autocomplete .ui-state-default a, -.ui-autocomplete .ui-state-default a:link, -.ui-autocomplete .ui-state-default a:visited { - color: #1c94c4; - text-decoration: none; -} - -.ui-autocomplete .ui-state-hover, -.ui-autocomplete .ui-widget-content .ui-state-hover, -.ui-autocomplete .ui-widget-header .ui-state-hover, -.ui-autocomplete .ui-state-focus, -.ui-autocomplete .ui-widget-content .ui-state-focus, -.ui-autocomplete .ui-widget-header .ui-state-focus { - border: 1px solid #fbcb09; - background: #fdf5ce url(images/ui-bg_glass_100_fdf5ce_1x400.png) 50% 50% repeat-x; - font-weight: bold; - color: #c77405; -} - -.ui-autocomplete .ui-state-hover a, .ui-autocomplete .ui-state-hover a:hover { - color: #c77405; - text-decoration: none; -} - -.ui-autocomplete .ui-state-active, -.ui-autocomplete .ui-widget-content .ui-state-active, -.ui-autocomplete .ui-widget-header .ui-state-active { - border: 1px solid #fbd850; - background: #ffffff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x; - font-weight: bold; - color: #eb8f00; -} - -.ui-autocomplete .ui-state-active a, -.ui-autocomplete .ui-state-active a:link, -.ui-autocomplete .ui-state-active a:visited { - color: #eb8f00; - text-decoration: none; -} - -.ui-widget :active { - outline: none; -} - -.ui-autocomplete .ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight { - border: 1px solid #fed22f; - background: #ffe45c url(images/ui-bg_highlight-soft_75_ffe45c_1x100.png) 50% top repeat-x; - color: #363636; -} - -.ui-autocomplete .ui-state-highlight a, .ui-widget-content .ui-state-highlight a, .ui-widget-header .ui-state-highlight a { - color: #363636; -} - -.ui-autocomplete .ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error { - border: 1px solid #cd0a0a; - background: #b81900 url(images/ui-bg_diagonals-thick_18_b81900_40x40.png) 50% 50% repeat; - color: #ffffff; -} - -.ui-autocomplete .ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { - color: #ffffff; -} - -.ui-autocomplete .ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { - color: #ffffff; -} - -.ui-autocomplete .ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { - opacity: .35; - filter: Alpha(Opacity = 35); - background-image: none; -} - -.ui-icon { - width: 16px; - height: 16px; - background-image: url(images/ui-icons_222222_256x240.png); -} - -.ui-icon-carat-1-n { - background-position: 0 0; -} - -.ui-icon-carat-1-ne { - background-position: -16px 0; -} - -.ui-icon-carat-1-e { - background-position: -32px 0; -} - -.ui-icon-carat-1-se { - background-position: -48px 0; -} - -.ui-icon-carat-1-s { - background-position: -64px 0; -} - -.ui-icon-carat-1-sw { - background-position: -80px 0; -} - -.ui-icon-carat-1-w { - background-position: -96px 0; -} - -.ui-icon-carat-1-nw { - background-position: -112px 0; -} - -.ui-icon-carat-2-n-s { - background-position: -128px 0; -} - -.ui-icon-carat-2-e-w { - background-position: -144px 0; -} - -.ui-icon-triangle-1-n { - background-position: 0 -16px; -} - -.ui-icon-triangle-1-ne { - background-position: -16px -16px; -} - -.ui-icon-triangle-1-e { - background-position: -32px -16px; -} - -.ui-icon-triangle-1-se { - background-position: -48px -16px; -} - -.ui-icon-triangle-1-s { - background-position: -64px -16px; -} - -.ui-icon-triangle-1-sw { - background-position: -80px -16px; -} - -.ui-icon-triangle-1-w { - background-position: -96px -16px; -} - -.ui-icon-triangle-1-nw { - background-position: -112px -16px; -} - -.ui-icon-triangle-2-n-s { - background-position: -128px -16px; -} - -.ui-icon-triangle-2-e-w { - background-position: -144px -16px; -} - -.ui-icon-arrow-1-n { - background-position: 0 -32px; -} - -.ui-icon-arrow-1-ne { - background-position: -16px -32px; -} - -.ui-icon-arrow-1-e { - background-position: -32px -32px; -} - -.ui-icon-arrow-1-se { - background-position: -48px -32px; -} - -.ui-icon-arrow-1-s { - background-position: -64px -32px; -} - -.ui-icon-arrow-1-sw { - background-position: -80px -32px; -} - -.ui-icon-arrow-1-w { - background-position: -96px -32px; -} - -.ui-icon-arrow-1-nw { - background-position: -112px -32px; -} - -.ui-icon-arrow-2-n-s { - background-position: -128px -32px; -} - -.ui-icon-arrow-2-ne-sw { - background-position: -144px -32px; -} - -.ui-icon-arrow-2-e-w { - background-position: -160px -32px; -} - -.ui-icon-arrow-2-se-nw { - background-position: -176px -32px; -} - -.ui-icon-arrowstop-1-n { - background-position: -192px -32px; -} - -.ui-icon-arrowstop-1-e { - background-position: -208px -32px; -} - -.ui-icon-arrowstop-1-s { - background-position: -224px -32px; -} - -.ui-icon-arrowstop-1-w { - background-position: -240px -32px; -} - -.ui-icon-arrowthick-1-n { - background-position: 0 -48px; -} - -.ui-icon-arrowthick-1-ne { - background-position: -16px -48px; -} - -.ui-icon-arrowthick-1-e { - background-position: -32px -48px; -} - -.ui-icon-arrowthick-1-se { - background-position: -48px -48px; -} - -.ui-icon-arrowthick-1-s { - background-position: -64px -48px; -} - -.ui-icon-arrowthick-1-sw { - background-position: -80px -48px; -} - -.ui-icon-arrowthick-1-w { - background-position: -96px -48px; -} - -.ui-icon-arrowthick-1-nw { - background-position: -112px -48px; -} - -.ui-icon-arrowthick-2-n-s { - background-position: -128px -48px; -} - -.ui-icon-arrowthick-2-ne-sw { - background-position: -144px -48px; -} - -.ui-icon-arrowthick-2-e-w { - background-position: -160px -48px; -} - -.ui-icon-arrowthick-2-se-nw { - background-position: -176px -48px; -} - -.ui-icon-arrowthickstop-1-n { - background-position: -192px -48px; -} - -.ui-icon-arrowthickstop-1-e { - background-position: -208px -48px; -} - -.ui-icon-arrowthickstop-1-s { - background-position: -224px -48px; -} - -.ui-icon-arrowthickstop-1-w { - background-position: -240px -48px; -} - -.ui-icon-arrowreturnthick-1-w { - background-position: 0 -64px; -} - -.ui-icon-arrowreturnthick-1-n { - background-position: -16px -64px; -} - -.ui-icon-arrowreturnthick-1-e { - background-position: -32px -64px; -} - -.ui-icon-arrowreturnthick-1-s { - background-position: -48px -64px; -} - -.ui-icon-arrowreturn-1-w { - background-position: -64px -64px; -} - -.ui-icon-arrowreturn-1-n { - background-position: -80px -64px; -} - -.ui-icon-arrowreturn-1-e { - background-position: -96px -64px; -} - -.ui-icon-arrowreturn-1-s { - background-position: -112px -64px; -} - -.ui-icon-arrowrefresh-1-w { - background-position: -128px -64px; -} - -.ui-icon-arrowrefresh-1-n { - background-position: -144px -64px; -} - -.ui-icon-arrowrefresh-1-e { - background-position: -160px -64px; -} - -.ui-icon-arrowrefresh-1-s { - background-position: -176px -64px; -} - -.ui-icon-arrow-4 { - background-position: 0 -80px; -} - -.ui-icon-arrow-4-diag { - background-position: -16px -80px; -} - -.ui-icon-extlink { - background-position: -32px -80px; -} - -.ui-icon-newwin { - background-position: -48px -80px; -} - -.ui-icon-refresh { - background-position: -64px -80px; -} - -.ui-icon-shuffle { - background-position: -80px -80px; -} - -.ui-icon-transfer-e-w { - background-position: -96px -80px; -} - -.ui-icon-transferthick-e-w { - background-position: -112px -80px; -} - -.ui-icon-folder-collapsed { - background-position: 0 -96px; -} - -.ui-icon-folder-open { - background-position: -16px -96px; -} - -.ui-icon-document { - background-position: -32px -96px; -} - -.ui-icon-document-b { - background-position: -48px -96px; -} - -.ui-icon-note { - background-position: -64px -96px; -} - -.ui-icon-mail-closed { - background-position: -80px -96px; -} - -.ui-icon-mail-open { - background-position: -96px -96px; -} - -.ui-icon-suitcase { - background-position: -112px -96px; -} - -.ui-icon-comment { - background-position: -128px -96px; -} - -.ui-icon-person { - background-position: -144px -96px; -} - -.ui-icon-print { - background-position: -160px -96px; -} - -.ui-icon-trash { - background-position: -176px -96px; -} - -.ui-icon-locked { - background-position: -192px -96px; -} - -.ui-icon-unlocked { - background-position: -208px -96px; -} - -.ui-icon-bookmark { - background-position: -224px -96px; -} - -.ui-icon-tag { - background-position: -240px -96px; -} - -.ui-icon-home { - background-position: 0 -112px; -} - -.ui-icon-flag { - background-position: -16px -112px; -} - -.ui-icon-calendar { - background-position: -32px -112px; -} - -.ui-icon-cart { - background-position: -48px -112px; -} - -.ui-icon-pencil { - background-position: -64px -112px; -} - -.ui-icon-clock { - background-position: -80px -112px; -} - -.ui-icon-disk { - background-position: -96px -112px; -} - -.ui-icon-calculator { - background-position: -112px -112px; -} - -.ui-icon-zoomin { - background-position: -128px -112px; -} - -.ui-icon-zoomout { - background-position: -144px -112px; -} - -.ui-icon-search { - background-position: -160px -112px; -} - -.ui-icon-wrench { - background-position: -176px -112px; -} - -.ui-icon-gear { - background-position: -192px -112px; -} - -.ui-icon-heart { - background-position: -208px -112px; -} - -.ui-icon-star { - background-position: -224px -112px; -} - -.ui-icon-link { - background-position: -240px -112px; -} - -.ui-icon-cancel { - background-position: 0 -128px; -} - -.ui-icon-plus { - background-position: -16px -128px; -} - -.ui-icon-plusthick { - background-position: -32px -128px; -} - -.ui-icon-minus { - background-position: -48px -128px; -} - -.ui-icon-minusthick { - background-position: -64px -128px; -} - -.ui-icon-close { - background-position: -80px -128px; -} - -.ui-icon-closethick { - background-position: -96px -128px; -} - -.ui-icon-key { - background-position: -112px -128px; -} - -.ui-icon-lightbulb { - background-position: -128px -128px; -} - -.ui-icon-scissors { - background-position: -144px -128px; -} - -.ui-icon-clipboard { - background-position: -160px -128px; -} - -.ui-icon-copy { - background-position: -176px -128px; -} - -.ui-icon-contact { - background-position: -192px -128px; -} - -.ui-icon-image { - background-position: -208px -128px; -} - -.ui-icon-video { - background-position: -224px -128px; -} - -.ui-icon-script { - background-position: -240px -128px; -} - -.ui-icon-alert { - background-position: 0 -144px; -} - -.ui-icon-info { - background-position: -16px -144px; -} - -.ui-icon-notice { - background-position: -32px -144px; -} - -.ui-icon-help { - background-position: -48px -144px; -} - -.ui-icon-check { - background-position: -64px -144px; -} - -.ui-icon-bullet { - background-position: -80px -144px; -} - -.ui-icon-radio-off { - background-position: -96px -144px; -} - -.ui-icon-radio-on { - background-position: -112px -144px; -} - -.ui-icon-pin-w { - background-position: -128px -144px; -} - -.ui-icon-pin-s { - background-position: -144px -144px; -} - -.ui-icon-play { - background-position: 0 -160px; -} - -.ui-icon-pause { - background-position: -16px -160px; -} - -.ui-icon-seek-next { - background-position: -32px -160px; -} - -.ui-icon-seek-prev { - background-position: -48px -160px; -} - -.ui-icon-seek-end { - background-position: -64px -160px; -} - -.ui-icon-seek-start { - background-position: -80px -160px; -} - -.ui-icon-seek-first { - background-position: -80px -160px; -} - -.ui-icon-stop { - background-position: -96px -160px; -} - -.ui-icon-eject { - background-position: -112px -160px; -} - -.ui-icon-volume-off { - background-position: -128px -160px; -} - -.ui-icon-volume-on { - background-position: -144px -160px; -} - -.ui-icon-power { - background-position: 0 -176px; -} - -.ui-icon-signal-diag { - background-position: -16px -176px; -} - -.ui-icon-signal { - background-position: -32px -176px; -} - -.ui-icon-battery-0 { - background-position: -48px -176px; -} - -.ui-icon-battery-1 { - background-position: -64px -176px; -} - -.ui-icon-battery-2 { - background-position: -80px -176px; -} - -.ui-icon-battery-3 { - background-position: -96px -176px; -} - -.ui-icon-circle-plus { - background-position: 0 -192px; -} - -.ui-icon-circle-minus { - background-position: -16px -192px; -} - -.ui-icon-circle-close { - background-position: -32px -192px; -} - -.ui-icon-circle-triangle-e { - background-position: -48px -192px; -} - -.ui-icon-circle-triangle-s { - background-position: -64px -192px; -} - -.ui-icon-circle-triangle-w { - background-position: -80px -192px; -} - -.ui-icon-circle-triangle-n { - background-position: -96px -192px; -} - -.ui-icon-circle-arrow-e { - background-position: -112px -192px; -} - -.ui-icon-circle-arrow-s { - background-position: -128px -192px; -} - -.ui-icon-circle-arrow-w { - background-position: -144px -192px; -} - -.ui-icon-circle-arrow-n { - background-position: -160px -192px; -} - -.ui-icon-circle-zoomin { - background-position: -176px -192px; -} - -.ui-icon-circle-zoomout { - background-position: -192px -192px; -} - -.ui-icon-circle-check { - background-position: -208px -192px; -} - -.ui-icon-circlesmall-plus { - background-position: 0 -208px; -} - -.ui-icon-circlesmall-minus { - background-position: -16px -208px; -} - -.ui-icon-circlesmall-close { - background-position: -32px -208px; -} - -.ui-icon-squaresmall-plus { - background-position: -48px -208px; -} - -.ui-icon-squaresmall-minus { - background-position: -64px -208px; -} - -.ui-icon-squaresmall-close { - background-position: -80px -208px; -} - -.ui-icon-grip-dotted-vertical { - background-position: 0 -224px; - cursor: n-resize; -} - -.ui-icon-grip-dotted-horizontal { - background-position: -16px -224px; -} - -.ui-icon-grip-solid-vertical { - background-position: -32px -224px; -} - -.ui-icon-grip-solid-horizontal { - background-position: -48px -224px; -} - -.ui-icon-gripsmall-diagonal-se { - background-position: -64px -224px; -} - -.ui-icon-grip-diagonal-se { - background-position: -80px -224px; -} - -.ui-autocomplete .ui-corner-all, -.ui-dialog.ui-corner-all, -.ui-dialog .ui-corner-all, -.ui-autocomplete .ui-corner-top, -.ui-autocomplete .ui-corner-left, -.ui-autocomplete .ui-corner-tl { - -moz-border-radius-topleft: 4px; - -webkit-border-top-left-radius: 4px; - -khtml-border-top-left-radius: 4px; - border-top-left-radius: 4px; -} - -.ui-autocomplete .ui-corner-all, -.ui-dialog.ui-corner-all, -.ui-dialog .ui-corner-all, -.ui-autocomplete .ui-corner-top, -.ui-autocomplete .ui-corner-right, -.ui-autocomplete .ui-corner-tr { - -moz-border-radius-topright: 4px; - -webkit-border-top-right-radius: 4px; - -khtml-border-top-right-radius: 4px; - border-top-right-radius: 4px; -} - -.ui-autocomplete .ui-corner-all, -.ui-dialog.ui-corner-all, -.ui-dialog .ui-corner-all, -.ui-autocomplete .ui-corner-bottom, -.ui-autocomplete .ui-corner-left, -.ui-autocomplete .ui-corner-bl { - -moz-border-radius-bottomleft: 4px; - -webkit-border-bottom-left-radius: 4px; - -khtml-border-bottom-left-radius: 4px; - border-bottom-left-radius: 4px; -} - -.ui-autocomplete .ui-corner-all, -.ui-dialog.ui-corner-all, -.ui-dialog .ui-corner-all, -.ui-autocomplete .ui-corner-bottom, -.ui-autocomplete .ui-corner-right, -.ui-autocomplete .ui-corner-br { - -moz-border-radius-bottomright: 4px; - -webkit-border-bottom-right-radius: 4px; - -khtml-border-bottom-right-radius: 4px; - border-bottom-right-radius: 4px; -} - -.ui-button.ui-corner-all { - -moz-border-radius: 0; - -webkit-border-radius: 0; - -khtml-border-radius: 0; - border-radius: 0; -} - -.ui-autocomplete { - position: absolute; - cursor: default; -} - -* html .ui-autocomplete { - width: 1px; -} - -.ui-menu { - list-style: none; - padding: 2px; - margin: 0; - display: block; - float: left; -} - -.ui-menu .ui-menu { - margin-top: -3px; -} - -.ui-menu .ui-menu-item { - margin: 0; - padding: 0; - zoom: 1; - float: left; - clear: left; - width: 100%; -} - -.ui-menu .ui-menu-item a { - text-decoration: none; - display: block; - padding: .2em .4em; - line-height: 1.5; - zoom: 1; -} - -.ui-menu .ui-menu-item a.ui-state-hover, -.ui-menu .ui-menu-item a.ui-state-active { - font-weight: normal; - margin: -1px; -} - -.ui-dialog { - position: absolute; - padding: .2em; - width: 300px; - overflow: hidden; -} - -.ui-dialog .ui-dialog-titlebar { - padding: .4em 1em; - position: relative; -} - -.ui-dialog .ui-dialog-title { - float: left; - margin: .1em 16px .1em 0; -} - -.ui-dialog .ui-dialog-titlebar-close { - position: absolute; - right: .3em; - top: 50%; - width: 19px; - margin: -10px 0 0 0; - padding: 1px; - height: 18px; -} - -.ui-dialog .ui-dialog-titlebar-close span { - display: block; - margin: 1px; -} - -.ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { - padding: 0; -} - -.ui-dialog .ui-dialog-content { - position: relative; - border: 0; - padding: .5em 1em; - background: none; - overflow: auto; - zoom: 1; -} - -.ui-dialog .ui-dialog-buttonpane { - text-align: left; - border-width: 1px 0 0 0; - background-image: none; - margin: .5em 0 0 0; - padding: .3em 1em .5em .4em; -} - -.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { - float: right; -} - -.ui-dialog .ui-dialog-buttonpane button { - margin: .5em .4em .5em 0; - cursor: pointer; -} - -.ui-dialog .ui-resizable-se { - width: 14px; - height: 14px; - right: 3px; - bottom: 3px; -} - -.widget-button-split.widget-button-save { - margin: 0 0 3px 5px; - padding: 0; -} -.widget-button-split.widget-button-save .main-control, .widget-button-split.widget-button-save .btn-toggle { - padding: 0 7px 2px; - font: bold 12px arial,helvetica,sans-serif; - filter: none; - text-shadow: none; -} -#grouped-product-container .no-products-message { - border: #dadfe0 1px solid; - background: #fff; - margin: 0 30px 10px; - padding: 20px 40px; - text-align: center; - vertical-align: middle; -} -.ui-dialog.mage-new-category-dialog, -.ui-dialog.mage-new-category-dialog .ui-dialog-content, -.ui-dialog.mage-new-category-dialog .hor-scroll, -.ui-dialog.mage-new-category-dialog .mage-suggest-dropdown { - overflow: visible; -} - -#new_category_parent-suggest, #category_ids-suggest { - width: 180px; -} diff --git a/app/code/core/Mage/Catalog/view/frontend/layout.xml b/app/code/core/Mage/Catalog/view/frontend/layout.xml deleted file mode 100644 index 6fb9a182f1220..0000000000000 --- a/app/code/core/Mage/Catalog/view/frontend/layout.xml +++ /dev/null @@ -1,277 +0,0 @@ - - - - - - - - - Mage_Catalog::widgets.css - - - - - Mage_Catalog::images/media/col_left_callout.jpg - Our customer service is available 24/7. Call us at (555) 555-0123. - checkout/cart - - - - - - Mage_Catalog::images/media/col_right_callout.jpg - Keep your eyes open for our special Back to School items and save A LOT! - - - - - - - - - - - - - - - - - - empty6 - one_column5 - two_columns_left4 - two_columns_right4 - three_columns3 - product_list_toolbar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - scriptaculous/scriptaculous.js - varien/product.js - - - - - - - - - catalog.compare.sidebar - - - - - - - - - - - - - varien/product.js - varien/configurable.js - Mage_Catalog::zoom.css - - - - - - - - - - - - 4 - upsell4 - - - - - detailed_info - - - detailed_info - - - - - - - - - - - textMage_Catalog_Block_Product_View_Options_Type_Text - fileMage_Catalog_Block_Product_View_Options_Type_File - selectMage_Catalog_Block_Product_View_Options_Type_Select - dateMage_Catalog_Block_Product_View_Options_Type_Date - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Catalog/view/frontend/product/compare/sidebar.phtml b/app/code/core/Mage/Catalog/view/frontend/product/compare/sidebar.phtml deleted file mode 100644 index 9517965fbe79a..0000000000000 --- a/app/code/core/Mage/Catalog/view/frontend/product/compare/sidebar.phtml +++ /dev/null @@ -1,73 +0,0 @@ - -helper('Mage_Catalog_Helper_Product_Compare'); -$_items = $_helper->getItemCount() > 0 ? $_helper->getItemCollection() : null; -?> -
    -
    - __('Compare Products') ?> - getItemCount() > 0): ?> - __('(%d)', $_helper->getItemCount()) ?> - - -
    -
    - getItemCount() > 0): ?> -
      - $_item): ?> -
    1. - - __('Remove This Item') ?> -

      helper('Mage_Catalog_Helper_Output')->productAttribute($_item, $_item->getName(), 'name') ?>

      -
    2. - -
    -
    - __('Clear All') ?> - -
    - - -

    __('You have no items to compare.') ?>

    - -
    -
    diff --git a/app/code/core/Mage/Catalog/view/frontend/product/view/options/type/date.phtml b/app/code/core/Mage/Catalog/view/frontend/product/view/options/type/date.phtml deleted file mode 100644 index 7142934f9e782..0000000000000 --- a/app/code/core/Mage/Catalog/view/frontend/product/view/options/type/date.phtml +++ /dev/null @@ -1,77 +0,0 @@ - -getOption() ?> -getId() ?> -
    getIsRequire()) echo ' class="required"' ?>>getIsRequire()) echo '*' ?>escapeHtml($_option->getTitle()) ?> - getFormatedPrice() ?>
    -getDecoratedIsLast()):?> class="last"> - -getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DATE_TIME - || $_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DATE): ?> - - getDateHtml() ?> - - useCalendar()): ?> - - - - - -getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DATE_TIME - || $_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_TIME): ?> - getTimeHtml() ?> - - -getIsRequire()): ?> - - - - - - - - diff --git a/app/code/core/Mage/Catalog/view/frontend/product/view/type/default.phtml b/app/code/core/Mage/Catalog/view/frontend/product/view/type/default.phtml deleted file mode 100644 index d0629d384da57..0000000000000 --- a/app/code/core/Mage/Catalog/view/frontend/product/view/type/default.phtml +++ /dev/null @@ -1,38 +0,0 @@ - - -getProduct() ?> - -displayProductStockStatus()): ?> - isAvailable()): ?> -

    __('Availability:') ?> __('In stock') ?>

    - -

    __('Availability:') ?> __('Out of stock') ?>

    - - -getChildHtml('product_type_data_extra') ?> -getPriceHtml($_product) ?> diff --git a/app/code/core/Mage/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php b/app/code/core/Mage/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php deleted file mode 100644 index 574a19efc85b2..0000000000000 --- a/app/code/core/Mage/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php +++ /dev/null @@ -1,232 +0,0 @@ - - */ -class Mage_CatalogInventory_Block_Adminhtml_Form_Field_Stock extends Varien_Data_Form_Element_Select -{ - const QUANTITY_FIELD_HTML_ID = 'qty'; - - /** - * Quantity field element - * - * @var Varien_Data_Form_Element_Text - */ - protected $_qty; - - /** - * Is product composite (grouped or configurable) - * - * @var bool - */ - protected $_isProductComposite; - - public function __construct(array $data = array()) - { - $this->_qty = isset($data['qty']) ? $data['qty'] : $this->_createQtyElement(); - unset($data['qty']); - parent::__construct($data); - $this->setName($data['name']); - } - - /** - * Create quantity field - * - * @return Varien_Data_Form_Element_Text - */ - protected function _createQtyElement() - { - $element = Mage::getModel('Varien_Data_Form_Element_Text'); - $element->setId(self::QUANTITY_FIELD_HTML_ID)->setName('qty'); - return $element; - } - - /** - * Join quantity and in stock elements' html - * - * @return string - */ - public function getElementHtml() - { - $this->_disableFields(); - return $this->_qty->getElementHtml() . parent::getElementHtml() - . $this->_getJs(self::QUANTITY_FIELD_HTML_ID, $this->getId()); - } - - /** - * Set form to quantity element in addition to current element - * - * @param $form - * @return Varien_Data_Form - */ - public function setForm($form) - { - $this->_qty->setForm($form); - return parent::setForm($form); - } - - /** - * Set value to quantity element in addition to current element - * - * @param $value - * @return Varien_Data_Form_Element_Select - */ - public function setValue($value) - { - if (is_array($value) && isset($value['qty'])) { - $this->_qty->setValue($value['qty']); - } - if (is_array($value) && isset($value['is_in_stock'])) { - parent::setValue($value['is_in_stock']); - } - return $this; - } - - /** - * Set name to quantity element in addition to current element - * - * @param string $name - */ - public function setName($name) - { - $this->_qty->setName($name . '[qty]'); - parent::setName($name . '[is_in_stock]'); - } - - /** - * Get whether product is configurable or grouped - * - * @return bool - */ - protected function _isProductComposite() - { - if ($this->_isProductComposite === null) { - $this->_isProductComposite = $this->_qty->getForm()->getDataObject()->isComposite(); - } - return $this->_isProductComposite; - } - - /** - * Disable fields depending on product type - * - * @return Mage_CatalogInventory_Block_Adminhtml_Form_Field_Stock - */ - protected function _disableFields() - { - if (!$this->_isProductComposite() && $this->_qty->getValue() === null) { - $this->setDisabled('disabled'); - } - if ($this->_isProductComposite()) { - $this->_qty->setDisabled('disabled'); - } - return $this; - } - - /** - * Get js for quantity and in stock synchronisation - * - * @param $quantityFieldId - * @param $inStockFieldId - * @return string - */ - protected function _getJs($quantityFieldId, $inStockFieldId) - { - return " - - "; - } -} diff --git a/app/code/core/Mage/CatalogInventory/Model/Resource/Stock/Item.php b/app/code/core/Mage/CatalogInventory/Model/Resource/Stock/Item.php deleted file mode 100755 index ed1f01bd0d9a6..0000000000000 --- a/app/code/core/Mage/CatalogInventory/Model/Resource/Stock/Item.php +++ /dev/null @@ -1,134 +0,0 @@ - - */ -class Mage_CatalogInventory_Model_Resource_Stock_Item extends Mage_Core_Model_Resource_Db_Abstract -{ - /** - * Define main table and initialize connection - * - */ - protected function _construct() - { - $this->_init('cataloginventory_stock_item', 'item_id'); - } - - /** - * Loading stock item data by product - * - * @param Mage_CatalogInventory_Model_Stock_Item $item - * @param int $productId - * @return Mage_CatalogInventory_Model_Resource_Stock_Item - */ - public function loadByProductId(Mage_CatalogInventory_Model_Stock_Item $item, $productId) - { - $select = $this->_getLoadSelect('product_id', $productId, $item) - ->where('stock_id = :stock_id'); - $data = $this->_getReadAdapter()->fetchRow($select, array(':stock_id' => $item->getStockId())); - if ($data) { - $item->setData($data); - } - $this->_afterLoad($item); - return $this; - } - - /** - * Retrieve select object and join it to product entity table to get type ids - * - * @param string $field - * @param mixed $value - * @param Mage_CatalogInventory_Model_Stock_Item $object - * @return Varien_Db_Select - */ - protected function _getLoadSelect($field, $value, $object) - { - $select = parent::_getLoadSelect($field, $value, $object) - ->join(array('p' => $this->getTable('catalog_product_entity')), - 'product_id=p.entity_id', - array('type_id') - ); - return $select; - } - - /** - * Add join for catalog in stock field to product collection - * - * @param Mage_Catalog_Model_Resource_Product_Collection $productCollection - * @param array $columns - * @return Mage_CatalogInventory_Model_Resource_Stock_Item - */ - public function addCatalogInventoryToProductCollection($productCollection, $columns = null) - { - if ($columns === null) { - $adapter = $this->_getReadAdapter(); - $isManageStock = (int)Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK); - $stockExpr = $adapter->getCheckSql('cisi.use_config_manage_stock = 1', $isManageStock, 'cisi.manage_stock'); - $stockExpr = $adapter->getCheckSql("({$stockExpr} = 1)", 'cisi.is_in_stock', '1'); - - $columns = array( - 'is_saleable' => new Zend_Db_Expr($stockExpr), - 'inventory_in_stock' => 'is_in_stock' - ); - } - - $productCollection->joinTable( - array('cisi' => 'cataloginventory_stock_item'), - 'product_id=entity_id', - $columns, - null, - 'left' - ); - return $this; - } - - /** - * Use qty correction for qty column update - * - * @param Mage_Core_Model_Abstract $object - * @param string $table - * @return array - */ - protected function _prepareDataForTable(Varien_Object $object, $table) - { - $data = parent::_prepareDataForTable($object, $table); - if (!$object->isObjectNew() && $object->getQtyCorrection()) { - $qty = abs($object->getQtyCorrection()); - if ($object->getQtyCorrection() < 0) { - $data['qty'] = new Zend_Db_Expr('qty-' . $qty); - } else { - $data['qty'] = new Zend_Db_Expr('qty+' . $object->getQtyCorrection()); - } - } - return $data; - } -} diff --git a/app/code/core/Mage/CatalogInventory/etc/adminhtml/acl.xml b/app/code/core/Mage/CatalogInventory/etc/adminhtml/acl.xml deleted file mode 100644 index f7aeb3a2be00c..0000000000000 --- a/app/code/core/Mage/CatalogInventory/etc/adminhtml/acl.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/CatalogInventory/etc/config.xml b/app/code/core/Mage/CatalogInventory/etc/config.xml deleted file mode 100644 index f986a79db3a97..0000000000000 --- a/app/code/core/Mage/CatalogInventory/etc/config.xml +++ /dev/null @@ -1,305 +0,0 @@ - - - - - - 1.6.0.0.3 - true - core - - - - - - - - - - Mage_CatalogInventory - Mage_Eav_Model_Entity_Setup - - - - - - - - Mage_CatalogInventory_Model_Observer - displayProductStatusInfo - - - - - - - Mage_CatalogInventory_Model_Observer - addInventoryData - - - - - - - Mage_CatalogInventory_Model_Observer - removeInventoryData - - - - - - - Mage_CatalogInventory_Model_Observer - addStockStatusToCollection - - - - - - - Mage_CatalogInventory_Model_Observer - prepareCatalogProductIndexSelect - - - - - - - Mage_CatalogInventory_Model_Observer - addInventoryDataToCollection - - - - - - - Mage_CatalogInventory_Model_Observer - checkQuoteItemQty - - - - - - - Mage_CatalogInventory_Model_Observer - checkoutAllSubmitAfter - - - - - - - Mage_CatalogInventory_Model_Observer - subtractQuoteInventory - - - - - - - Mage_CatalogInventory_Model_Observer - reindexQuoteInventory - - - - - - - Mage_CatalogInventory_Model_Observer - revertQuoteInventory - - - - - - - Mage_CatalogInventory_Model_Observer - cancelOrderItem - - - - - - - Mage_CatalogInventory_Model_Observer - refundOrderInventory - - - - - - - Mage_CatalogInventory_Model_Observer - saveInventoryData - - - - - - - Mage_CatalogInventory_Model_Observer - copyInventoryData - - - - - - - Mage_CatalogInventory_Model_Observer - updateItemsStockUponConfigChange - - - - - - - Mage_CatalogInventory_Model_Observer - prepareCatalogProductIndexSelect - - - - - - - Mage_CatalogInventory_Model_Observer - reindexProductsMassAction - - - - - - - Mage_CatalogInventory_Model_Observer - reindexProductsMassAction - - - - - - - - - 1 - - - 1 - - - Mage_CatalogInventory_Model_Resource_Indexer_Stock_Configurable - - - Mage_CatalogInventory_Model_Resource_Indexer_Stock_Grouped - - - - - - - - Mage_CatalogInventory_Model_Indexer_Stock - - - - - - - - - - - - - - - - - - - layout.xml - - - - - - - - Mage_CatalogInventory.csv - - - - - - - - - - layout.xml - - - - - - - - Mage_CatalogInventory.csv - - - - - - - - - Mage_CatalogInventory_Model_Observer - reindexProductsMassAction - - - - - - - - - 1 - 1 - 0 - 0 - 1 - - - 1 - 0 - 10000 - 1 - 0 - 1 - 0 - 1 - - - - diff --git a/app/code/core/Mage/CatalogInventory/view/adminhtml/layout.xml b/app/code/core/Mage/CatalogInventory/view/adminhtml/layout.xml deleted file mode 100644 index 8046c49af7bdb..0000000000000 --- a/app/code/core/Mage/CatalogInventory/view/adminhtml/layout.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - Mage_Catalog_Model_Resource_Product_Collection_AssociatedProductUpdater - - - - - -
    Stock Availability
    - text - inventory_in_stock - inventory_in_stock - 0 - 1 - Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid_Renderer_Inventory -
    -
    - - -
    Qty
    - text - qty - qty - 0 - 1 - associated-product-qty -
    -
    -
    -
    -
    -
    diff --git a/app/code/core/Mage/CatalogInventory/view/frontend/stockqty/composite.phtml b/app/code/core/Mage/CatalogInventory/view/frontend/stockqty/composite.phtml deleted file mode 100644 index 68412c7929ee0..0000000000000 --- a/app/code/core/Mage/CatalogInventory/view/frontend/stockqty/composite.phtml +++ /dev/null @@ -1,60 +0,0 @@ - -isMsgVisible()): ?> -

    - __('Only %s left', "{$this->getStockQty()}") ?> -

    - - - - - - - - - - - getChildProducts() as $childProduct) : ?> - getProductStockQty($childProduct); ?> - 0) : ?> - - - - - - - -
    __('Product Name') ?>__('Qty') ?>
    getName() ?>
    - - diff --git a/app/code/core/Mage/CatalogRule/Model/Observer.php b/app/code/core/Mage/CatalogRule/Model/Observer.php deleted file mode 100644 index 5f9f82128cc37..0000000000000 --- a/app/code/core/Mage/CatalogRule/Model/Observer.php +++ /dev/null @@ -1,402 +0,0 @@ -getEvent()->getProduct(); - if ($product->getIsMassupdate()) { - return; - } - - $productWebsiteIds = $product->getWebsiteIds(); - - $rules = Mage::getModel('Mage_CatalogRule_Model_Rule')->getCollection() - ->addFieldToFilter('is_active', 1); - - foreach ($rules as $rule) { - $websiteIds = array_intersect($productWebsiteIds, $rule->getWebsiteIds()); - $rule->applyToProduct($product, $websiteIds); - } - - return $this; - } - - /** - * Apply all price rules for current date. - * Handle cataolg_product_import_after event - * - * @param Varien_Event_Observer $observer - * - * @return Mage_CatalogRule_Model_Observer - */ - public function applyAllRules($observer) - { - $resource = Mage::getResourceSingleton('Mage_CatalogRule_Model_Resource_Rule'); - $resource->applyAllRulesForDateRange($resource->formatDate(mktime(0,0,0))); - Mage::getModel('Mage_CatalogRule_Model_Flag')->loadSelf() - ->setState(0) - ->save(); - - return $this; - } - - /** - * Apply catalog price rules to product on frontend - * - * @param Varien_Event_Observer $observer - * - * @return Mage_CatalogRule_Model_Observer - */ - public function processFrontFinalPrice($observer) - { - $product = $observer->getEvent()->getProduct(); - $pId = $product->getId(); - $storeId = $product->getStoreId(); - - if ($observer->hasDate()) { - $date = $observer->getEvent()->getDate(); - } else { - $date = Mage::app()->getLocale()->storeTimeStamp($storeId); - } - - if ($observer->hasWebsiteId()) { - $wId = $observer->getEvent()->getWebsiteId(); - } else { - $wId = Mage::app()->getStore($storeId)->getWebsiteId(); - } - - if ($observer->hasCustomerGroupId()) { - $gId = $observer->getEvent()->getCustomerGroupId(); - } elseif ($product->hasCustomerGroupId()) { - $gId = $product->getCustomerGroupId(); - } else { - $gId = Mage::getSingleton('Mage_Customer_Model_Session')->getCustomerGroupId(); - } - - $key = "$date|$wId|$gId|$pId"; - if (!isset($this->_rulePrices[$key])) { - $rulePrice = Mage::getResourceModel('Mage_CatalogRule_Model_Resource_Rule') - ->getRulePrice($date, $wId, $gId, $pId); - $this->_rulePrices[$key] = $rulePrice; - } - if ($this->_rulePrices[$key]!==false) { - $finalPrice = min($product->getData('final_price'), $this->_rulePrices[$key]); - $product->setFinalPrice($finalPrice); - } - return $this; - } - - /** - * Apply catalog price rules to product in admin - * - * @param Varien_Event_Observer $observer - * - * @return Mage_CatalogRule_Model_Observer - */ - public function processAdminFinalPrice($observer) - { - $product = $observer->getEvent()->getProduct(); - $storeId = $product->getStoreId(); - $date = Mage::app()->getLocale()->storeDate($storeId); - $key = false; - - if ($ruleData = Mage::registry('rule_data')) { - $wId = $ruleData->getWebsiteId(); - $gId = $ruleData->getCustomerGroupId(); - $pId = $product->getId(); - - $key = "$date|$wId|$gId|$pId"; - } - elseif (!is_null($product->getWebsiteId()) && !is_null($product->getCustomerGroupId())) { - $wId = $product->getWebsiteId(); - $gId = $product->getCustomerGroupId(); - $pId = $product->getId(); - $key = "$date|$wId|$gId|$pId"; - } - - if ($key) { - if (!isset($this->_rulePrices[$key])) { - $rulePrice = Mage::getResourceModel('Mage_CatalogRule_Model_Resource_Rule') - ->getRulePrice($date, $wId, $gId, $pId); - $this->_rulePrices[$key] = $rulePrice; - } - if ($this->_rulePrices[$key]!==false) { - $finalPrice = min($product->getData('final_price'), $this->_rulePrices[$key]); - $product->setFinalPrice($finalPrice); - } - } - - return $this; - } - - /** - * Calculate price using catalog price rules of configurable product - * - * @param Varien_Event_Observer $observer - * - * @return Mage_CatalogRule_Model_Observer - */ - public function catalogProductTypeConfigurablePrice(Varien_Event_Observer $observer) - { - $product = $observer->getEvent()->getProduct(); - if ($product instanceof Mage_Catalog_Model_Product - && $product->getConfigurablePrice() !== null - ) { - $configurablePrice = $product->getConfigurablePrice(); - $productPriceRule = Mage::getModel('Mage_CatalogRule_Model_Rule')->calcProductPriceRule($product, $configurablePrice); - if ($productPriceRule !== null) { - $product->setConfigurablePrice($productPriceRule); - } - } - - return $this; - } - - /** - * Daily update catalog price rule by cron - * Update include interval 3 days - current day - 1 days before + 1 days after - * This method is called from cron process, cron is working in UTC time and - * we should generate data for interval -1 day ... +1 day - * - * @param Varien_Event_Observer $observer - * - * @return Mage_CatalogRule_Model_Observer - */ - public function dailyCatalogUpdate($observer) - { - Mage::getResourceSingleton('Mage_CatalogRule_Model_Resource_Rule')->applyAllRulesForDateRange(); - - return $this; - } - - /** - * Clean out calculated catalog rule prices for products - */ - public function flushPriceCache() - { - $this->_rulePrices = array(); - } - - /** - * Calculate minimal final price with catalog rule price - * - * @param Varien_Event_Observer $observer - * @return Mage_CatalogRule_Model_Observer - */ - public function prepareCatalogProductPriceIndexTable(Varien_Event_Observer $observer) - { - $select = $observer->getEvent()->getSelect(); - - $indexTable = $observer->getEvent()->getIndexTable(); - $entityId = $observer->getEvent()->getEntityId(); - $customerGroupId = $observer->getEvent()->getCustomerGroupId(); - $websiteId = $observer->getEvent()->getWebsiteId(); - $websiteDate = $observer->getEvent()->getWebsiteDate(); - $updateFields = $observer->getEvent()->getUpdateFields(); - - Mage::getSingleton('Mage_CatalogRule_Model_Rule_Product_Price') - ->applyPriceRuleToIndexTable($select, $indexTable, $entityId, $customerGroupId, $websiteId, - $updateFields, $websiteDate); - - return $this; - } - - /** - * Check rules that contains affected attribute - * If rules were found they will be set to inactive and notice will be add to admin session - * - * @param string $attributeCode - * - * @return Mage_CatalogRule_Model_Observer - */ - protected function _checkCatalogRulesAvailability($attributeCode) - { - /* @var $collection Mage_CatalogRule_Model_Resource_Rule_Collection */ - $collection = Mage::getResourceModel('Mage_CatalogRule_Model_Resource_Rule_Collection') - ->addAttributeInConditionFilter($attributeCode); - - $disabledRulesCount = 0; - foreach ($collection as $rule) { - /* @var $rule Mage_CatalogRule_Model_Rule */ - $rule->setIsActive(0); - /* @var $rule->getConditions() Mage_CatalogRule_Model_Rule_Condition_Combine */ - $this->_removeAttributeFromConditions($rule->getConditions(), $attributeCode); - $rule->save(); - - $disabledRulesCount++; - } - - if ($disabledRulesCount) { - Mage::getModel('Mage_CatalogRule_Model_Rule')->applyAll(); - Mage::getSingleton('Mage_Adminhtml_Model_Session')->addWarning( - Mage::helper('Mage_CatalogRule_Helper_Data')->__('%d Catalog Price Rules based on "%s" attribute have been disabled.', $disabledRulesCount, $attributeCode)); - } - - return $this; - } - - /** - * Remove catalog attribute condition by attribute code from rule conditions - * - * @param Mage_CatalogRule_Model_Rule_Condition_Combine $combine - * - * @param string $attributeCode - */ - protected function _removeAttributeFromConditions($combine, $attributeCode) - { - $conditions = $combine->getConditions(); - foreach ($conditions as $conditionId => $condition) { - if ($condition instanceof Mage_CatalogRule_Model_Rule_Condition_Combine) { - $this->_removeAttributeFromConditions($condition, $attributeCode); - } - if ($condition instanceof Mage_Rule_Model_Condition_Product_Abstract) { - if ($condition->getAttribute() == $attributeCode) { - unset($conditions[$conditionId]); - } - } - } - $combine->setConditions($conditions); - } - - /** - * After save attribute if it is not used for promo rules already check rules for containing this attribute - * - * @param Varien_Event_Observer $observer - * - * @return Mage_CatalogRule_Model_Observer - */ - public function catalogAttributeSaveAfter(Varien_Event_Observer $observer) - { - $attribute = $observer->getEvent()->getAttribute(); - if ($attribute->dataHasChangedFor('is_used_for_promo_rules') && !$attribute->getIsUsedForPromoRules()) { - $this->_checkCatalogRulesAvailability($attribute->getAttributeCode()); - } - - return $this; - } - - /** - * After delete attribute check rules that contains deleted attribute - * - * @param Varien_Event_Observer $observer - * @return Mage_CatalogRule_Model_Observer - */ - public function catalogAttributeDeleteAfter(Varien_Event_Observer $observer) - { - $attribute = $observer->getEvent()->getAttribute(); - if ($attribute->getIsUsedForPromoRules()) { - $this->_checkCatalogRulesAvailability($attribute->getAttributeCode()); - } - - return $this; - } - - public function prepareCatalogProductCollectionPrices(Varien_Event_Observer $observer) - { - /* @var $collection Mage_Catalog_Model_Resource_Product_Collection */ - $collection = $observer->getEvent()->getCollection(); - $store = Mage::app()->getStore($observer->getEvent()->getStoreId()); - $websiteId = $store->getWebsiteId(); - if ($observer->getEvent()->hasCustomerGroupId()) { - $groupId = $observer->getEvent()->getCustomerGroupId(); - } else { - /* @var $session Mage_Customer_Model_Session */ - $session = Mage::getSingleton('Mage_Customer_Model_Session'); - if ($session->isLoggedIn()) { - $groupId = Mage::getSingleton('Mage_Customer_Model_Session')->getCustomerGroupId(); - } else { - $groupId = Mage_Customer_Model_Group::NOT_LOGGED_IN_ID; - } - } - if ($observer->getEvent()->hasDate()) { - $date = $observer->getEvent()->getDate(); - } else { - $date = Mage::app()->getLocale()->storeTimeStamp($store); - } - - $productIds = array(); - /* @var $product Mage_Core_Model_Product */ - foreach ($collection as $product) { - $key = implode('|', array($date, $websiteId, $groupId, $product->getId())); - if (!isset($this->_rulePrices[$key])) { - $productIds[] = $product->getId(); - } - } - - if ($productIds) { - $rulePrices = Mage::getResourceModel('Mage_CatalogRule_Model_Resource_Rule') - ->getRulePrices($date, $websiteId, $groupId, $productIds); - foreach ($productIds as $productId) { - $key = implode('|', array($date, $websiteId, $groupId, $productId)); - $this->_rulePrices[$key] = isset($rulePrices[$productId]) ? $rulePrices[$productId] : false; - } - } - - return $this; - } - - /** - * Create catalog rule relations for imported products - * - * @param Varien_Event_Observer $observer - */ - public function createCatalogRulesRelations(Varien_Event_Observer $observer) - { - $adapter = $observer->getEvent()->getAdapter(); - $affectedEntityIds = $adapter->getAffectedEntityIds(); - - if (empty($affectedEntityIds)) { - return; - } - - $rules = Mage::getModel('Mage_CatalogRule_Model_Rule')->getCollection() - ->addFieldToFilter('is_active', 1); - - foreach ($rules as $rule) { - $rule->setProductsFilter($affectedEntityIds); - Mage::getResourceSingleton('Mage_CatalogRule_Model_Resource_Rule')->updateRuleProductData($rule); - } - } -} diff --git a/app/code/core/Mage/CatalogRule/etc/adminhtml/acl.xml b/app/code/core/Mage/CatalogRule/etc/adminhtml/acl.xml deleted file mode 100644 index 4d0f046f50ed7..0000000000000 --- a/app/code/core/Mage/CatalogRule/etc/adminhtml/acl.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - diff --git a/app/code/core/Mage/CatalogRule/etc/adminhtml/menu.xml b/app/code/core/Mage/CatalogRule/etc/adminhtml/menu.xml deleted file mode 100644 index c15c13675e976..0000000000000 --- a/app/code/core/Mage/CatalogRule/etc/adminhtml/menu.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - diff --git a/app/code/core/Mage/CatalogRule/etc/config.xml b/app/code/core/Mage/CatalogRule/etc/config.xml deleted file mode 100644 index bab91f6ca8720..0000000000000 --- a/app/code/core/Mage/CatalogRule/etc/config.xml +++ /dev/null @@ -1,185 +0,0 @@ - - - - - - 1.6.0.4 - true - core - - - - - - - - - - - - Mage_CatalogRule - - - - - - - - Mage_CatalogRule_Model_Observer - prepareCatalogProductPriceIndexTable - - - - - - - Mage_CatalogRule_Model_Observer - catalogProductTypeConfigurablePrice - - - - - - - - - - - - - - - - Mage_CatalogRule_Model_Observer - processFrontFinalPrice - - - - - - - Mage_CatalogRule_Model_Observer - prepareCatalogProductCollectionPrices - - - - - - - - - Mage_CatalogRule.csv - - - - - - - - - - - Mage_CatalogRule.csv - - - - - - - - - Mage_CatalogRule_Model_Observer - processAdminFinalPrice - - - - - - - Mage_CatalogRule_Model_Observer - applyAllRulesOnProduct - - - - - - - Mage_CatalogRule_Model_Observer - createCatalogRulesRelations - - - - - - - Mage_CatalogRule_Model_Observer - applyAllRules - - - - - - - Mage_CatalogRule_Model_Observer - catalogAttributeDeleteAfter - - - - - - - Mage_CatalogRule_Model_Observer - catalogAttributeSaveAfter - - - - - - - - - - 0 1 * * * - - - Mage_CatalogRule_Model_Observer::dailyCatalogUpdate - - - - - - - - Mage_CatalogRule_Model_Observer - processAdminFinalPrice - - - - - - diff --git a/app/code/core/Mage/CatalogSearch/Model/Fulltext/Observer.php b/app/code/core/Mage/CatalogSearch/Model/Fulltext/Observer.php deleted file mode 100644 index 4e7d1149893d3..0000000000000 --- a/app/code/core/Mage/CatalogSearch/Model/Fulltext/Observer.php +++ /dev/null @@ -1,193 +0,0 @@ - - */ -class Mage_CatalogSearch_Model_Fulltext_Observer -{ - /** - * Retrieve fulltext (indexer) model - * - * @return Mage_CatalogSearch_Model_Fulltext - */ - protected function _getFulltextModel() - { - return Mage::getSingleton('Mage_CatalogSearch_Model_Fulltext'); - } - - /** - * Update product index when product data updated - * - * @param Varien_Event_Observer $observer - * @return Mage_CatalogSearch_Model_Fulltext_Observer - */ - public function refreshProductIndex(Varien_Event_Observer $observer) - { - $product = $observer->getEvent()->getProduct(); - - $this->_getFulltextModel() - ->rebuildIndex(null, $product->getId()) - ->resetSearchResults(); - - return $this; - } - - /** - * Clean product index when product deleted or marked as unsearchable/invisible - * - * @param Varien_Event_Observer $observer - * @return Mage_CatalogSearch_Model_Fulltext_Observer - */ - public function cleanProductIndex(Varien_Event_Observer $observer) - { - $product = $observer->getEvent()->getProduct(); - - $this->_getFulltextModel() - ->cleanIndex(null, $product->getId()) - ->resetSearchResults(); - - return $this; - } - - /** - * Update all attribute-dependant index - * - * @param Varien_Event_Observer $observer - * @return Mage_CatalogSearch_Model_Fulltext_Observer - */ - public function eavAttributeChange(Varien_Event_Observer $observer) - { - $attribute = $observer->getEvent()->getAttribute(); - /* @var $attribute Mage_Eav_Model_Entity_Attribute */ - $entityType = Mage::getSingleton('Mage_Eav_Model_Config')->getEntityType(Mage_Catalog_Model_Product::ENTITY); - /* @var $entityType Mage_Eav_Model_Entity_Type */ - - if ($attribute->getEntityTypeId() != $entityType->getId()) { - return $this; - } - $delete = $observer->getEventName() == 'eav_entity_attribute_delete_after'; - - if (!$delete && !$attribute->dataHasChangedFor('is_searchable')) { - return $this; - } - - $showNotice = false; - if ($delete) { - if ($attribute->getIsSearchable()) { - $showNotice = true; - } - } - elseif ($attribute->dataHasChangedFor('is_searchable')) { - $showNotice = true; - } - - if ($showNotice) { - $url = Mage::getSingleton('Mage_Backend_Model_Url')->getUrl('adminhtml/system_cache'); - Mage::getSingleton('Mage_Adminhtml_Model_Session')->addNotice( - Mage::helper('Mage_CatalogSearch_Helper_Data')->__('Attribute setting change related with Search Index. Please run Rebuild Search Index process.', $url) - ); - } - - return $this; - } - - /** - * Rebuild index after import - * - * @return Mage_CatalogSearch_Model_Fulltext_Observer - */ - public function refreshIndexAfterImport() - { - $this->_getFulltextModel() - ->rebuildIndex(); - return $this; - } - - /** - * Refresh fulltext index when we add new store - * - * @param Varien_Event_Observer $observer - * @return Mage_CatalogSearch_Model_Fulltext_Observer - */ - public function refreshStoreIndex(Varien_Event_Observer $observer) - { - $storeId = $observer->getEvent()->getStore()->getId(); - $this->_getFulltextModel()->rebuildIndex($storeId); - return $this; - } - - /** - * Catalog Product mass website update - * - * @param Varien_Event_Observer $observer - * @return Mage_CatalogSearch_Model_Fulltext_Observer - */ - public function catalogProductWebsiteUpdate(Varien_Event_Observer $observer) - { - $websiteIds = $observer->getEvent()->getWebsiteIds(); - $productIds = $observer->getEvent()->getProductIds(); - $actionType = $observer->getEvent()->getAction(); - - foreach ($websiteIds as $websiteId) { - foreach (Mage::app()->getWebsite($websiteId)->getStoreIds() as $storeId) { - if ($actionType == 'remove') { - $this->_getFulltextModel() - ->cleanIndex($storeId, $productIds) - ->resetSearchResults(); - } - elseif ($actionType == 'add') { - $this->_getFulltextModel() - ->rebuildIndex($storeId, $productIds) - ->resetSearchResults(); - } - } - } - - return $this; - } - - /** - * Store delete processing - * - * @param Varien_Event_Observer $observer - * @return Mage_CatalogSearch_Model_Fulltext_Observer - */ - public function cleanStoreIndex(Varien_Event_Observer $observer) - { - $store = $observer->getEvent()->getStore(); - /* @var $store Mage_Core_Model_Store */ - - $this->_getFulltextModel() - ->cleanIndex($store->getId()); - - return $this; - } -} diff --git a/app/code/core/Mage/CatalogSearch/Model/Indexer/Fulltext.php b/app/code/core/Mage/CatalogSearch/Model/Indexer/Fulltext.php deleted file mode 100644 index 61c5e9f761348..0000000000000 --- a/app/code/core/Mage/CatalogSearch/Model/Indexer/Fulltext.php +++ /dev/null @@ -1,446 +0,0 @@ - - */ -class Mage_CatalogSearch_Model_Indexer_Fulltext extends Mage_Index_Model_Indexer_Abstract -{ - /** - * Data key for matching result to be saved in - */ - const EVENT_MATCH_RESULT_KEY = 'catalogsearch_fulltext_match_result'; - - /** - * List of searchable attributes - * - * @var null|array - */ - protected $_searchableAttributes = null; - - /** - * Retrieve resource instance - * - * @return Mage_CatalogSearch_Model_Resource_Indexer_Fulltext - */ - protected function _getResource() - { - return Mage::getResourceSingleton('Mage_CatalogSearch_Model_Resource_Indexer_Fulltext'); - } - - /** - * Indexer must be match entities - * - * @var array - */ - protected $_matchedEntities = array( - Mage_Catalog_Model_Product::ENTITY => array( - Mage_Index_Model_Event::TYPE_SAVE, - Mage_Index_Model_Event::TYPE_MASS_ACTION, - Mage_Index_Model_Event::TYPE_DELETE - ), - Mage_Catalog_Model_Resource_Eav_Attribute::ENTITY => array( - Mage_Index_Model_Event::TYPE_SAVE, - Mage_Index_Model_Event::TYPE_DELETE, - ), - Mage_Core_Model_Store::ENTITY => array( - Mage_Index_Model_Event::TYPE_SAVE, - Mage_Index_Model_Event::TYPE_DELETE - ), - Mage_Core_Model_Store_Group::ENTITY => array( - Mage_Index_Model_Event::TYPE_SAVE - ), - Mage_Core_Model_Config_Data::ENTITY => array( - Mage_Index_Model_Event::TYPE_SAVE - ), - Mage_Catalog_Model_Category::ENTITY => array( - Mage_Index_Model_Event::TYPE_SAVE - ) - ); - - /** - * Related Configuration Settings for match - * - * @var array - */ - protected $_relatedConfigSettings = array( - Mage_CatalogSearch_Model_Fulltext::XML_PATH_CATALOG_SEARCH_TYPE - ); - - /** - * Retrieve Fulltext Search instance - * - * @return Mage_CatalogSearch_Model_Fulltext - */ - protected function _getIndexer() - { - return Mage::getSingleton('Mage_CatalogSearch_Model_Fulltext'); - } - - /** - * Retrieve Indexer name - * - * @return string - */ - public function getName() - { - return Mage::helper('Mage_CatalogSearch_Helper_Data')->__('Catalog Search'); - } - - /** - * Retrieve Indexer description - * - * @return string - */ - public function getDescription() - { - return Mage::helper('Mage_CatalogSearch_Helper_Data')->__('Rebuild Catalog product fulltext search index'); - } - - /** - * Check if event can be matched by process - * Overwrote for check is flat catalog product is enabled and specific save - * attribute, store, store_group - * - * @param Mage_Index_Model_Event $event - * @return bool - */ - public function matchEvent(Mage_Index_Model_Event $event) - { - $data = $event->getNewData(); - if (isset($data[self::EVENT_MATCH_RESULT_KEY])) { - return $data[self::EVENT_MATCH_RESULT_KEY]; - } - - $entity = $event->getEntity(); - if ($entity == Mage_Catalog_Model_Resource_Eav_Attribute::ENTITY) { - /* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */ - $attribute = $event->getDataObject(); - - if (!$attribute) { - $result = false; - } elseif ($event->getType() == Mage_Index_Model_Event::TYPE_SAVE) { - $result = $attribute->dataHasChangedFor('is_searchable'); - } elseif ($event->getType() == Mage_Index_Model_Event::TYPE_DELETE) { - $result = $attribute->getIsSearchable(); - } else { - $result = false; - } - } else if ($entity == Mage_Core_Model_Store::ENTITY) { - if ($event->getType() == Mage_Index_Model_Event::TYPE_DELETE) { - $result = true; - } else { - /* @var $store Mage_Core_Model_Store */ - $store = $event->getDataObject(); - if ($store && $store->isObjectNew()) { - $result = true; - } else { - $result = false; - } - } - } else if ($entity == Mage_Core_Model_Store_Group::ENTITY) { - /* @var $storeGroup Mage_Core_Model_Store_Group */ - $storeGroup = $event->getDataObject(); - if ($storeGroup && $storeGroup->dataHasChangedFor('website_id')) { - $result = true; - } else { - $result = false; - } - } else if ($entity == Mage_Core_Model_Config_Data::ENTITY) { - $data = $event->getDataObject(); - if ($data && in_array($data->getPath(), $this->_relatedConfigSettings)) { - $result = $data->isValueChanged(); - } else { - $result = false; - } - } else { - $result = parent::matchEvent($event); - } - - $event->addNewData(self::EVENT_MATCH_RESULT_KEY, $result); - - return $result; - } - - /** - * Register data required by process in event object - * - * @param Mage_Index_Model_Event $event - */ - protected function _registerEvent(Mage_Index_Model_Event $event) - { - $event->addNewData(self::EVENT_MATCH_RESULT_KEY, true); - switch ($event->getEntity()) { - case Mage_Catalog_Model_Product::ENTITY: - $this->_registerCatalogProductEvent($event); - break; - - case Mage_Core_Model_Config_Data::ENTITY: - case Mage_Core_Model_Store::ENTITY: - case Mage_Catalog_Model_Resource_Eav_Attribute::ENTITY: - case Mage_Core_Model_Store_Group::ENTITY: - $event->addNewData('catalogsearch_fulltext_skip_call_event_handler', true); - $process = $event->getProcess(); - $process->changeStatus(Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX); - break; - case Mage_Catalog_Model_Category::ENTITY: - $this->_registerCatalogCategoryEvent($event); - break; - } - } - - /** - * Get data required for category'es products reindex - * - * @param Mage_Index_Model_Event $event - * @return Mage_CatalogSearch_Model_Indexer_Search - */ - protected function _registerCatalogCategoryEvent(Mage_Index_Model_Event $event) - { - switch ($event->getType()) { - case Mage_Index_Model_Event::TYPE_SAVE: - /* @var $category Mage_Catalog_Model_Category */ - $category = $event->getDataObject(); - $productIds = $category->getAffectedProductIds(); - if ($productIds) { - $event->addNewData('catalogsearch_category_update_product_ids', $productIds); - $event->addNewData('catalogsearch_category_update_category_ids', array($category->getId())); - } else { - $movedCategoryId = $category->getMovedCategoryId(); - if ($movedCategoryId) { - $event->addNewData('catalogsearch_category_update_product_ids', array()); - $event->addNewData('catalogsearch_category_update_category_ids', array($movedCategoryId)); - } - } - break; - } - - return $this; - } - - /** - * Register data required by catatalog product process in event object - * - * @param Mage_Index_Model_Event $event - * @return Mage_CatalogSearch_Model_Indexer_Search - */ - protected function _registerCatalogProductEvent(Mage_Index_Model_Event $event) - { - switch ($event->getType()) { - case Mage_Index_Model_Event::TYPE_SAVE: - /* @var $product Mage_Catalog_Model_Product */ - $product = $event->getDataObject(); - - $event->addNewData('catalogsearch_update_product_id', $product->getId()); - break; - case Mage_Index_Model_Event::TYPE_DELETE: - /* @var $product Mage_Catalog_Model_Product */ - $product = $event->getDataObject(); - - $event->addNewData('catalogsearch_delete_product_id', $product->getId()); - break; - case Mage_Index_Model_Event::TYPE_MASS_ACTION: - /* @var $actionObject Varien_Object */ - $actionObject = $event->getDataObject(); - - $reindexData = array(); - $rebuildIndex = false; - - // check if status changed - $attrData = $actionObject->getAttributesData(); - if (isset($attrData['status'])) { - $rebuildIndex = true; - $reindexData['catalogsearch_status'] = $attrData['status']; - } - - // check changed websites - if ($actionObject->getWebsiteIds()) { - $rebuildIndex = true; - $reindexData['catalogsearch_website_ids'] = $actionObject->getWebsiteIds(); - $reindexData['catalogsearch_action_type'] = $actionObject->getActionType(); - } - - $searchableAttributes = array(); - if (is_array($attrData)) { - $searchableAttributes = array_intersect($this->_getSearchableAttributes(), array_keys($attrData)); - } - - if (count($searchableAttributes) > 0) { - $rebuildIndex = true; - $reindexData['catalogsearch_force_reindex'] = true; - } - - // register affected products - if ($rebuildIndex) { - $reindexData['catalogsearch_product_ids'] = $actionObject->getProductIds(); - foreach ($reindexData as $k => $v) { - $event->addNewData($k, $v); - } - } - break; - } - - return $this; - } - - /** - * Retrieve searchable attributes list - * - * @return array - */ - protected function _getSearchableAttributes() - { - if (is_null($this->_searchableAttributes)) { - /** @var $attributeCollection Mage_Catalog_Model_Resource_Product_Attribute_Collection */ - $attributeCollection = Mage::getResourceModel('Mage_Catalog_Model_Resource_Product_Attribute_Collection'); - $attributeCollection->addIsSearchableFilter(); - - foreach ($attributeCollection as $attribute) { - $this->_searchableAttributes[] = $attribute->getAttributeCode(); - } - } - - return $this->_searchableAttributes; - } - - /** - * Check if product is composite - * - * @param int $productId - * @return bool - */ - protected function _isProductComposite($productId) - { - $product = Mage::getModel('Mage_Catalog_Model_Product')->load($productId); - return $product->isComposite(); - } - - /** - * Process event - * - * @param Mage_Index_Model_Event $event - */ - protected function _processEvent(Mage_Index_Model_Event $event) - { - $data = $event->getNewData(); - - if (!empty($data['catalogsearch_fulltext_reindex_all'])) { - $this->reindexAll(); - } else if (!empty($data['catalogsearch_delete_product_id'])) { - $productId = $data['catalogsearch_delete_product_id']; - - if (!$this->_isProductComposite($productId)) { - $parentIds = $this->_getResource()->getRelationsByChild($productId); - if (!empty($parentIds)) { - $this->_getIndexer()->rebuildIndex(null, $parentIds); - } - } - - $this->_getIndexer()->cleanIndex(null, $productId) - ->resetSearchResults(); - } else if (!empty($data['catalogsearch_update_product_id'])) { - $productId = $data['catalogsearch_update_product_id']; - $productIds = array($productId); - - if (!$this->_isProductComposite($productId)) { - $parentIds = $this->_getResource()->getRelationsByChild($productId); - if (!empty($parentIds)) { - $productIds = array_merge($productIds, $parentIds); - } - } - - $this->_getIndexer()->rebuildIndex(null, $productIds) - ->resetSearchResults(); - } else if (!empty($data['catalogsearch_product_ids'])) { - // mass action - $productIds = $data['catalogsearch_product_ids']; - - if (!empty($data['catalogsearch_website_ids'])) { - $websiteIds = $data['catalogsearch_website_ids']; - $actionType = $data['catalogsearch_action_type']; - - foreach ($websiteIds as $websiteId) { - foreach (Mage::app()->getWebsite($websiteId)->getStoreIds() as $storeId) { - if ($actionType == 'remove') { - $this->_getIndexer() - ->cleanIndex($storeId, $productIds) - ->resetSearchResults(); - } else if ($actionType == 'add') { - $this->_getIndexer() - ->rebuildIndex($storeId, $productIds) - ->resetSearchResults(); - } - } - } - } - if (isset($data['catalogsearch_status'])) { - $status = $data['catalogsearch_status']; - if ($status == Mage_Catalog_Model_Product_Status::STATUS_ENABLED) { - $this->_getIndexer() - ->rebuildIndex(null, $productIds) - ->resetSearchResults(); - } else { - $this->_getIndexer() - ->cleanIndex(null, $productIds) - ->resetSearchResults(); - } - } - if (isset($data['catalogsearch_force_reindex'])) { - $this->_getIndexer() - ->rebuildIndex(null, $productIds) - ->resetSearchResults(); - } - } else if (isset($data['catalogsearch_category_update_product_ids'])) { - $productIds = $data['catalogsearch_category_update_product_ids']; - $categoryIds = $data['catalogsearch_category_update_category_ids']; - - $this->_getIndexer() - ->updateCategoryIndex($productIds, $categoryIds); - } - } - - /** - * Rebuild all index data - * - */ - public function reindexAll() - { - $resourceModel = $this->_getIndexer()->getResource(); - $resourceModel->beginTransaction(); - try { - $this->_getIndexer()->rebuildIndex(); - $resourceModel->commit(); - } catch (Exception $e) { - $resourceModel->rollBack(); - throw $e; - } - } -} diff --git a/app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php b/app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php deleted file mode 100755 index a719ba9f734bd..0000000000000 --- a/app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php +++ /dev/null @@ -1,790 +0,0 @@ - - */ -class Mage_CatalogSearch_Model_Resource_Fulltext extends Mage_Core_Model_Resource_Db_Abstract -{ - /** - * Searchable attributes cache - * - * @var array - */ - protected $_searchableAttributes = null; - - /** - * Index values separator - * - * @var string - */ - protected $_separator = '|'; - - /** - * Array of Zend_Date objects per store - * - * @var array - */ - protected $_dates = array(); - - /** - * Product Type Instances cache - * - * @var array - */ - protected $_productTypes = array(); - - /** - * Product Emulators cache - * - * @var array - */ - protected $_productEmulators = array(); - - /** - * Store search engine instance - * - * @var object - */ - protected $_engine = null; - - /** - * Init resource model - * - */ - protected function _construct() - { - $this->_init('catalogsearch_fulltext', 'product_id'); - $this->_engine = Mage::helper('Mage_CatalogSearch_Helper_Data')->getEngine(); - } - - /** - * Return options separator - * - * @return string - */ - public function getSeparator() - { - return $this->_separator; - } - - /** - * Regenerate search index for store(s) - * - * @param int|null $storeId - * @param int|array|null $productIds - * @return Mage_CatalogSearch_Model_Resource_Fulltext - */ - public function rebuildIndex($storeId = null, $productIds = null) - { - if (is_null($storeId)) { - $storeIds = array_keys(Mage::app()->getStores()); - foreach ($storeIds as $storeId) { - $this->_rebuildStoreIndex($storeId, $productIds); - } - } else { - $this->_rebuildStoreIndex($storeId, $productIds); - } - - return $this; - } - - /** - * Regenerate search index for specific store - * - * @param int $storeId Store View Id - * @param int|array $productIds Product Entity Id - * @return Mage_CatalogSearch_Model_Resource_Fulltext - */ - protected function _rebuildStoreIndex($storeId, $productIds = null) - { - $this->cleanIndex($storeId, $productIds); - - // prepare searchable attributes - $staticFields = array(); - foreach ($this->_getSearchableAttributes('static') as $attribute) { - $staticFields[] = $attribute->getAttributeCode(); - } - $dynamicFields = array( - 'int' => array_keys($this->_getSearchableAttributes('int')), - 'varchar' => array_keys($this->_getSearchableAttributes('varchar')), - 'text' => array_keys($this->_getSearchableAttributes('text')), - 'decimal' => array_keys($this->_getSearchableAttributes('decimal')), - 'datetime' => array_keys($this->_getSearchableAttributes('datetime')), - ); - - // status and visibility filter - $visibility = $this->_getSearchableAttribute('visibility'); - $status = $this->_getSearchableAttribute('status'); - $statusVals = Mage::getSingleton('Mage_Catalog_Model_Product_Status')->getVisibleStatusIds(); - $allowedVisibilityValues = $this->_engine->getAllowedVisibility(); - - $lastProductId = 0; - while (true) { - $products = $this->_getSearchableProducts($storeId, $staticFields, $productIds, $lastProductId); - if (!$products) { - break; - } - - $productAttributes = array(); - $productRelations = array(); - foreach ($products as $productData) { - $lastProductId = $productData['entity_id']; - $productAttributes[$productData['entity_id']] = $productData['entity_id']; - $productChildren = $this->_getProductChildIds($productData['entity_id'], $productData['type_id']); - $productRelations[$productData['entity_id']] = $productChildren; - if ($productChildren) { - foreach ($productChildren as $productChildId) { - $productAttributes[$productChildId] = $productChildId; - } - } - } - - $productIndexes = array(); - $productAttributes = $this->_getProductAttributes($storeId, $productAttributes, $dynamicFields); - foreach ($products as $productData) { - if (!isset($productAttributes[$productData['entity_id']])) { - continue; - } - - $productAttr = $productAttributes[$productData['entity_id']]; - if (!isset($productAttr[$visibility->getId()]) - || !in_array($productAttr[$visibility->getId()], $allowedVisibilityValues) - ) { - continue; - } - if (!isset($productAttr[$status->getId()]) || !in_array($productAttr[$status->getId()], $statusVals)) { - continue; - } - - $productIndex = array( - $productData['entity_id'] => $productAttr - ); - - if ($productChildren = $productRelations[$productData['entity_id']]) { - foreach ($productChildren as $productChildId) { - if (isset($productAttributes[$productChildId])) { - $productIndex[$productChildId] = $productAttributes[$productChildId]; - } - } - } - - $index = $this->_prepareProductIndex($productIndex, $productData, $storeId); - - $productIndexes[$productData['entity_id']] = $index; - } - - $this->_saveProductIndexes($storeId, $productIndexes); - } - - $this->resetSearchResults(); - - return $this; - } - - /** - * Retrieve searchable products per store - * - * @param int $storeId - * @param array $staticFields - * @param array|int $productIds - * @param int $lastProductId - * @param int $limit - * @return array - */ - protected function _getSearchableProducts($storeId, array $staticFields, $productIds = null, $lastProductId = 0, - $limit = 100) - { - $websiteId = Mage::app()->getStore($storeId)->getWebsiteId(); - $writeAdapter = $this->_getWriteAdapter(); - - $select = $writeAdapter->select() - ->useStraightJoin(true) - ->from( - array('e' => $this->getTable('catalog_product_entity')), - array_merge(array('entity_id', 'type_id'), $staticFields) - ) - ->join( - array('website' => $this->getTable('catalog_product_website')), - $writeAdapter->quoteInto( - 'website.product_id=e.entity_id AND website.website_id=?', - $websiteId - ), - array() - ) - ->join( - array('stock_status' => $this->getTable('cataloginventory_stock_status')), - $writeAdapter->quoteInto( - 'stock_status.product_id=e.entity_id AND stock_status.website_id=?', - $websiteId - ), - array('in_stock' => 'stock_status') - ); - - if (!is_null($productIds)) { - $select->where('e.entity_id IN(?)', $productIds); - } - - $select->where('e.entity_id>?', $lastProductId) - ->limit($limit) - ->order('e.entity_id'); - - $result = $writeAdapter->fetchAll($select); - - return $result; - } - - /** - * Reset search results - * - * @return Mage_CatalogSearch_Model_Resource_Fulltext - */ - public function resetSearchResults() - { - $adapter = $this->_getWriteAdapter(); - $adapter->update($this->getTable('catalogsearch_query'), array('is_processed' => 0)); - $adapter->delete($this->getTable('catalogsearch_result')); - - Mage::dispatchEvent('catalogsearch_reset_search_result'); - - return $this; - } - - /** - * Delete search index data for store - * - * @param int $storeId Store View Id - * @param int $productId Product Entity Id - * @return Mage_CatalogSearch_Model_Resource_Fulltext - */ - public function cleanIndex($storeId = null, $productId = null) - { - if ($this->_engine) { - $this->_engine->cleanIndex($storeId, $productId); - } - - return $this; - } - - /** - * Prepare results for query - * - * @param Mage_CatalogSearch_Model_Fulltext $object - * @param string $queryText - * @param Mage_CatalogSearch_Model_Query $query - * @return Mage_CatalogSearch_Model_Resource_Fulltext - */ - public function prepareResult($object, $queryText, $query) - { - $adapter = $this->_getWriteAdapter(); - if (!$query->getIsProcessed()) { - $searchType = $object->getSearchType($query->getStoreId()); - - $preparedTerms = Mage::getResourceHelper('Mage_CatalogSearch') - ->prepareTerms($queryText, $query->getMaxQueryWords()); - - $bind = array(); - $like = array(); - $likeCond = ''; - if ($searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_LIKE - || $searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_COMBINE - ) { - $helper = Mage::getResourceHelper('Mage_Core'); - $words = Mage::helper('Mage_Core_Helper_String')->splitWords($queryText, true, $query->getMaxQueryWords()); - foreach ($words as $word) { - $like[] = $helper->getCILike('s.data_index', $word, array('position' => 'any')); - } - if ($like) { - $likeCond = '(' . join(' OR ', $like) . ')'; - } - } - $mainTableAlias = 's'; - $fields = array( - 'query_id' => new Zend_Db_Expr($query->getId()), - 'product_id', - ); - $select = $adapter->select() - ->from(array($mainTableAlias => $this->getMainTable()), $fields) - ->joinInner(array('e' => $this->getTable('catalog_product_entity')), - 'e.entity_id = s.product_id', - array()) - ->where($mainTableAlias.'.store_id = ?', (int)$query->getStoreId()); - - if ($searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_FULLTEXT - || $searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_COMBINE - ) { - $bind[':query'] = implode(' ', $preparedTerms[0]); - $where = Mage::getResourceHelper('Mage_CatalogSearch') - ->chooseFulltext($this->getMainTable(), $mainTableAlias, $select); - } - - if ($likeCond != '' && $searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_COMBINE) { - $where .= ($where ? ' OR ' : '') . $likeCond; - } elseif ($likeCond != '' && $searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_LIKE) { - $select->columns(array('relevance' => new Zend_Db_Expr(0))); - $where = $likeCond; - } - - if ($where != '') { - $select->where($where); - } - - $sql = $adapter->insertFromSelect($select, - $this->getTable('catalogsearch_result'), - array(), - Varien_Db_Adapter_Interface::INSERT_ON_DUPLICATE); - $adapter->query($sql, $bind); - - $query->setIsProcessed(1); - } - - return $this; - } - - /** - * Retrieve EAV Config Singleton - * - * @return Mage_Eav_Model_Config - */ - public function getEavConfig() - { - return Mage::getSingleton('Mage_Eav_Model_Config'); - } - - /** - * Retrieve searchable attributes - * - * @param string $backendType - * @return array - */ - protected function _getSearchableAttributes($backendType = null) - { - if (is_null($this->_searchableAttributes)) { - $this->_searchableAttributes = array(); - - $productAttributeCollection = Mage::getResourceModel('Mage_Catalog_Model_Resource_Product_Attribute_Collection'); - - if ($this->_engine && $this->_engine->allowAdvancedIndex()) { - $productAttributeCollection->addToIndexFilter(true); - } else { - $productAttributeCollection->addSearchableAttributeFilter(); - } - $attributes = $productAttributeCollection->getItems(); - - Mage::dispatchEvent('catelogsearch_searchable_attributes_load_after', array( - 'engine' => $this->_engine, - 'attributes' => $attributes - )); - - $entity = $this->getEavConfig() - ->getEntityType(Mage_Catalog_Model_Product::ENTITY) - ->getEntity(); - - foreach ($attributes as $attribute) { - $attribute->setEntity($entity); - } - - $this->_searchableAttributes = $attributes; - } - - if (!is_null($backendType)) { - $attributes = array(); - foreach ($this->_searchableAttributes as $attributeId => $attribute) { - if ($attribute->getBackendType() == $backendType) { - $attributes[$attributeId] = $attribute; - } - } - - return $attributes; - } - - return $this->_searchableAttributes; - } - - /** - * Retrieve searchable attribute by Id or code - * - * @param int|string $attribute - * @return Mage_Eav_Model_Entity_Attribute - */ - protected function _getSearchableAttribute($attribute) - { - $attributes = $this->_getSearchableAttributes(); - if (is_numeric($attribute)) { - if (isset($attributes[$attribute])) { - return $attributes[$attribute]; - } - } elseif (is_string($attribute)) { - foreach ($attributes as $attributeModel) { - if ($attributeModel->getAttributeCode() == $attribute) { - return $attributeModel; - } - } - } - - return $this->getEavConfig()->getAttribute(Mage_Catalog_Model_Product::ENTITY, $attribute); - } - - /** - * Returns expresion for field unification - * - * @param string $field - * @param string $backendType - * @return Zend_Db_Expr - */ - protected function _unifyField($field, $backendType = 'varchar') - { - if ($backendType == 'datetime') { - $expr = Mage::getResourceHelper('Mage_CatalogSearch')->castField( - $this->_getReadAdapter()->getDateFormatSql($field, '%Y-%m-%d %H:%i:%s')); - } else { - $expr = Mage::getResourceHelper('Mage_CatalogSearch')->castField($field); - } - return $expr; - } - - /** - * Load product(s) attributes - * - * @param int $storeId - * @param array $productIds - * @param array $attributeTypes - * @return array - */ - protected function _getProductAttributes($storeId, array $productIds, array $attributeTypes) - { - $result = array(); - $selects = array(); - $adapter = $this->_getWriteAdapter(); - $ifStoreValue = $adapter->getCheckSql('t_store.value_id > 0', 't_store.value', 't_default.value'); - foreach ($attributeTypes as $backendType => $attributeIds) { - if ($attributeIds) { - $tableName = $this->getTable('catalog_product_entity_' . $backendType); - $selects[] = $adapter->select() - ->from( - array('t_default' => $tableName), - array('entity_id', 'attribute_id')) - ->joinLeft( - array('t_store' => $tableName), - $adapter->quoteInto( - 't_default.entity_id=t_store.entity_id' . - ' AND t_default.attribute_id=t_store.attribute_id' . - ' AND t_store.store_id=?', - $storeId), - array('value' => $this->_unifyField($ifStoreValue, $backendType))) - ->where('t_default.store_id=?', 0) - ->where('t_default.attribute_id IN (?)', $attributeIds) - ->where('t_default.entity_id IN (?)', $productIds); - } - } - - if ($selects) { - $select = $adapter->select()->union($selects, Zend_Db_Select::SQL_UNION_ALL); - $query = $adapter->query($select); - while ($row = $query->fetch()) { - $result[$row['entity_id']][$row['attribute_id']] = $row['value']; - } - } - - return $result; - } - - /** - * Retrieve Product Type Instance - * - * @param string $typeId - * @return Mage_Catalog_Model_Product_Type_Abstract - */ - protected function _getProductTypeInstance($typeId) - { - if (!isset($this->_productTypes[$typeId])) { - $productEmulator = $this->_getProductEmulator($typeId); - - $this->_productTypes[$typeId] = Mage::getSingleton('Mage_Catalog_Model_Product_Type') - ->factory($productEmulator); - } - return $this->_productTypes[$typeId]; - } - - /** - * Return all product children ids - * - * @param int $productId Product Entity Id - * @param string $typeId Super Product Link Type - * @return array - */ - protected function _getProductChildIds($productId, $typeId) - { - $typeInstance = $this->_getProductTypeInstance($typeId); - $relation = $typeInstance->isComposite($this->_getProductEmulator($typeId)) - ? $typeInstance->getRelationInfo() - : false; - - if ($relation && $relation->getTable() && $relation->getParentFieldName() && $relation->getChildFieldName()) { - $select = $this->_getReadAdapter()->select() - ->from( - array('main' => $this->getTable($relation->getTable())), - array($relation->getChildFieldName())) - ->where("{$relation->getParentFieldName()}=?", $productId); - if (!is_null($relation->getWhere())) { - $select->where($relation->getWhere()); - } - return $this->_getReadAdapter()->fetchCol($select); - } - - return null; - } - - /** - * Retrieve Product Emulator (Varien Object) - * - * @param string $typeId - * @return Varien_Object - */ - protected function _getProductEmulator($typeId) - { - if (!isset($this->_productEmulators[$typeId])) { - $productEmulator = new Varien_Object(); - $productEmulator->setIdFieldName('entity_id') - ->setTypeId($typeId); - $this->_productEmulators[$typeId] = $productEmulator; - } - return $this->_productEmulators[$typeId]; - } - - /** - * Prepare Fulltext index value for product - * - * @param array $indexData - * @param array $productData - * @param int $storeId - * @return string - */ - protected function _prepareProductIndex($indexData, $productData, $storeId) - { - $index = array(); - - foreach ($this->_getSearchableAttributes('static') as $attribute) { - $attributeCode = $attribute->getAttributeCode(); - - if (isset($productData[$attributeCode])) { - $value = $this->_getAttributeValue($attribute->getId(), $productData[$attributeCode], $storeId); - if ($value) { - //For grouped products - if (isset($index[$attributeCode])) { - if (!is_array($index[$attributeCode])) { - $index[$attributeCode] = array($index[$attributeCode]); - } - $index[$attributeCode][] = $value; - } - //For other types of products - else { - $index[$attributeCode] = $value; - } - } - } - } - - foreach ($indexData as $entityId => $attributeData) { - foreach ($attributeData as $attributeId => $attributeValue) { - $value = $this->_getAttributeValue($attributeId, $attributeValue, $storeId); - if (!is_null($value) && $value !== false) { - $attributeCode = $this->_getSearchableAttribute($attributeId)->getAttributeCode(); - - if (isset($index[$attributeCode])) { - $index[$attributeCode][$entityId] = $value; - } else { - $index[$attributeCode] = array($entityId => $value); - } - } - } - } - - if (!$this->_engine->allowAdvancedIndex()) { - $product = $this->_getProductEmulator($productData['type_id']) - ->setId($productData['entity_id']) - ->setStoreId($storeId); - $typeInstance = $this->_getProductTypeInstance($productData['type_id']); - if ($data = $typeInstance->getSearchableData($product)) { - $index['options'] = $data; - } - } - - if (isset($productData['in_stock'])) { - $index['in_stock'] = $productData['in_stock']; - } - - if ($this->_engine) { - return $this->_engine->prepareEntityIndex($index, $this->_separator); - } - - return Mage::helper('Mage_CatalogSearch_Helper_Data')->prepareIndexdata($index, $this->_separator); - } - - /** - * Retrieve attribute source value for search - * - * @param int $attributeId - * @param mixed $value - * @param int $storeId - * @return mixed - */ - protected function _getAttributeValue($attributeId, $value, $storeId) - { - $attribute = $this->_getSearchableAttribute($attributeId); - if (!$attribute->getIsSearchable()) { - if ($this->_engine->allowAdvancedIndex()) { - if ($attribute->getAttributeCode() == 'visibility') { - return $value; - } elseif (!($attribute->getIsVisibleInAdvancedSearch() - || $attribute->getIsFilterable() - || $attribute->getIsFilterableInSearch() - || $attribute->getUsedForSortBy()) - ) { - return null; - } - } else { - return null; - } - } - - if ($attribute->usesSource()) { - if ($this->_engine->allowAdvancedIndex()) { - return $value; - } - - $attribute->setStoreId($storeId); - $value = $attribute->getSource()->getIndexOptionText($value); - - if (is_array($value)) { - $value = implode($this->_separator, $value); - } elseif (empty($value)) { - $inputType = $attribute->getFrontend()->getInputType(); - if ($inputType == 'select' || $inputType == 'multiselect') { - return null; - } - } - } elseif ($attribute->getBackendType() == 'datetime') { - $value = $this->_getStoreDate($storeId, $value); - } else { - $inputType = $attribute->getFrontend()->getInputType(); - if ($inputType == 'price') { - $value = Mage::app()->getStore($storeId)->roundPrice($value); - } - } - - $value = preg_replace("#\s+#siu", ' ', trim(strip_tags($value))); - - return $value; - } - - /** - * Save Product index - * - * @param int $productId - * @param int $storeId - * @param string $index - * @return Mage_CatalogSearch_Model_Resource_Fulltext - */ - protected function _saveProductIndex($productId, $storeId, $index) - { - if ($this->_engine) { - $this->_engine->saveEntityIndex($productId, $storeId, $index); - } - - return $this; - } - - /** - * Save Multiply Product indexes - * - * @param int $storeId - * @param array $productIndexes - * @return Mage_CatalogSearch_Model_Resource_Fulltext - */ - protected function _saveProductIndexes($storeId, $productIndexes) - { - if ($this->_engine) { - $this->_engine->saveEntityIndexes($storeId, $productIndexes); - } - - return $this; - } - - /** - * Retrieve Date value for store - * - * @param int $storeId - * @param string $date - * @return string - */ - protected function _getStoreDate($storeId, $date = null) - { - if (!isset($this->_dates[$storeId])) { - $timezone = Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE, $storeId); - $locale = Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, $storeId); - $locale = new Zend_Locale($locale); - - $dateObj = new Zend_Date(null, null, $locale); - $dateObj->setTimezone($timezone); - $this->_dates[$storeId] = array($dateObj, $locale->getTranslation(null, 'date', $locale)); - } - - if (!is_empty_date($date)) { - list($dateObj, $format) = $this->_dates[$storeId]; - $dateObj->setDate($date, Varien_Date::DATETIME_INTERNAL_FORMAT); - - return $dateObj->toString($format); - } - - return null; - } - - - - - - // Deprecated methods - - /** - * Update category products indexes - * - * deprecated after 1.6.2.0 - * - * @param array $productIds - * @param array $categoryIds - * @return Mage_CatalogSearch_Model_Resource_Fulltext - */ - public function updateCategoryIndex($productIds, $categoryIds) - { - return $this; - } -} diff --git a/app/code/core/Mage/CatalogSearch/etc/adminhtml/acl.xml b/app/code/core/Mage/CatalogSearch/etc/adminhtml/acl.xml deleted file mode 100644 index f083089848ba3..0000000000000 --- a/app/code/core/Mage/CatalogSearch/etc/adminhtml/acl.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - diff --git a/app/code/core/Mage/CatalogSearch/etc/adminhtml/menu.xml b/app/code/core/Mage/CatalogSearch/etc/adminhtml/menu.xml deleted file mode 100644 index 7b9ff41a4b221..0000000000000 --- a/app/code/core/Mage/CatalogSearch/etc/adminhtml/menu.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - diff --git a/app/code/core/Mage/CatalogSearch/etc/config.xml b/app/code/core/Mage/CatalogSearch/etc/config.xml deleted file mode 100644 index 344e94de44501..0000000000000 --- a/app/code/core/Mage/CatalogSearch/etc/config.xml +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - Mage_CatalogSearch - - - - - - - Mage_CatalogSearch_Model_Indexer_Fulltext - - - - - - - - standard - - Mage_CatalogSearch - catalogsearch - - - - - - - - Mage_CatalogSearch.csv - - - - - - - - layout.xml - - - - - - - - - layout.xml - - - - - - - - Mage_CatalogSearch.csv - - - - - - - - - 1 - - - 1 - 128 - 10 - 1 - 2000 - - - - diff --git a/app/code/core/Mage/Centinel/etc/config.xml b/app/code/core/Mage/Centinel/etc/config.xml deleted file mode 100644 index 2cc3362877216..0000000000000 --- a/app/code/core/Mage/Centinel/etc/config.xml +++ /dev/null @@ -1,177 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - - - Mage_Centinel_Model_Observer - salesEventConvertQuoteToOrder - - - - - - - Mage_Centinel_Model_Observer - checkoutSubmitAllAfter - - - - - - - - - - - Mage_Centinel.csv - - - - - - - - - model - Mage_Centinel_Model_Observer - paymentFormBlockToHtmlBefore - - - - - - - standard - - Mage_Centinel - centinel - - - - - - - layout.xml - - - - - /centinel/ - - - - - - - - model - Mage_Centinel_Model_Observer - paymentInfoBlockPrepareSpecificInformation - - - - - - - - - Mage_Centinel.csv - - - - - - - - layout.xml - - - - - - - - - - Mage_Centinel_Adminhtml - - - - - - - - - - - - - Mage_Centinel_Model_State_Visa - - - - - - - Mage_Centinel_Model_State_Mastercard - - - - - - - Mage_Centinel_Model_State_Jcb - - - - - - - Mage_Centinel_Model_State_Mastercard - - - - - - - - diff --git a/app/code/core/Mage/Centinel/view/frontend/logo.phtml b/app/code/core/Mage/Centinel/view/frontend/logo.phtml deleted file mode 100644 index 9a6f1cb542b41..0000000000000 --- a/app/code/core/Mage/Centinel/view/frontend/logo.phtml +++ /dev/null @@ -1,33 +0,0 @@ - - diff --git a/app/code/core/Mage/Checkout/Block/Onepage/Abstract.php b/app/code/core/Mage/Checkout/Block/Onepage/Abstract.php deleted file mode 100644 index 9e662bb15ae81..0000000000000 --- a/app/code/core/Mage/Checkout/Block/Onepage/Abstract.php +++ /dev/null @@ -1,224 +0,0 @@ - - */ -abstract class Mage_Checkout_Block_Onepage_Abstract extends Mage_Core_Block_Template -{ - protected $_customer; - protected $_checkout; - protected $_quote; - protected $_countryCollection; - protected $_regionCollection; - protected $_addressesCollection; - - /** - * Get logged in customer - * - * @return Mage_Customer_Model_Customer - */ - public function getCustomer() - { - if (empty($this->_customer)) { - $this->_customer = Mage::getSingleton('Mage_Customer_Model_Session')->getCustomer(); - } - return $this->_customer; - } - - /** - * Retrieve checkout session model - * - * @return Mage_Checkout_Model_Session - */ - public function getCheckout() - { - if (empty($this->_checkout)) { - $this->_checkout = Mage::getSingleton('Mage_Checkout_Model_Session'); - } - return $this->_checkout; - } - - /** - * Retrieve sales quote model - * - * @return Mage_Sales_Model_Quote - */ - public function getQuote() - { - if (empty($this->_quote)) { - $this->_quote = $this->getCheckout()->getQuote(); - } - return $this->_quote; - } - - public function isCustomerLoggedIn() - { - return Mage::getSingleton('Mage_Customer_Model_Session')->isLoggedIn(); - } - - public function getCountryCollection() - { - if (!$this->_countryCollection) { - $this->_countryCollection = Mage::getSingleton('Mage_Directory_Model_Country')->getResourceCollection() - ->loadByStore(); - } - return $this->_countryCollection; - } - - public function getRegionCollection() - { - if (!$this->_regionCollection) { - $this->_regionCollection = Mage::getModel('Mage_Directory_Model_Region')->getResourceCollection() - ->addCountryFilter($this->getAddress()->getCountryId()) - ->load(); - } - return $this->_regionCollection; - } - - public function customerHasAddresses() - { - return count($this->getCustomer()->getAddresses()); - } - -/* */ - public function getAddressesHtmlSelect($type) - { - if ($this->isCustomerLoggedIn()) { - $options = array(); - foreach ($this->getCustomer()->getAddresses() as $address) { - $options[] = array( - 'value' => $address->getId(), - 'label' => $address->format('oneline') - ); - } - - $addressId = $this->getAddress()->getCustomerAddressId(); - if (empty($addressId)) { - if ($type=='billing') { - $address = $this->getCustomer()->getPrimaryBillingAddress(); - } else { - $address = $this->getCustomer()->getPrimaryShippingAddress(); - } - if ($address) { - $addressId = $address->getId(); - } - } - - $select = $this->getLayout()->createBlock('Mage_Core_Block_Html_Select') - ->setName($type.'_address_id') - ->setId($type.'-address-select') - ->setClass('address-select') - ->setExtraParams('onchange="'.$type.'.newAddress(!this.value)"') - ->setValue($addressId) - ->setOptions($options); - - $select->addOption('', Mage::helper('Mage_Checkout_Helper_Data')->__('New Address')); - - return $select->getHtml(); - } - return ''; - } - - public function getCountryHtmlSelect($type) - { - $countryId = $this->getAddress()->getCountryId(); - if (is_null($countryId)) { - $countryId = Mage::helper('Mage_Core_Helper_Data')->getDefaultCountry(); - } - $select = $this->getLayout()->createBlock('Mage_Core_Block_Html_Select') - ->setName($type.'[country_id]') - ->setId($type.':country_id') - ->setTitle(Mage::helper('Mage_Checkout_Helper_Data')->__('Country')) - ->setClass('validate-select') - ->setValue($countryId) - ->setOptions($this->getCountryOptions()); - if ($type === 'shipping') { - $select->setExtraParams('onchange="if(window.shipping)shipping.setSameAsBilling(false);"'); - } - - return $select->getHtml(); - } - - - public function getRegionHtmlSelect($type) - { - $select = $this->getLayout()->createBlock('Mage_Core_Block_Html_Select') - ->setName($type.'[region]') - ->setId($type.':region') - ->setTitle(Mage::helper('Mage_Checkout_Helper_Data')->__('State/Province')) - ->setClass('required-entry validate-state') - ->setValue($this->getAddress()->getRegionId()) - ->setOptions($this->getRegionCollection()->toOptionArray()); - - return $select->getHtml(); - } - - public function getCountryOptions() - { - $options = false; - $useCache = Mage::app()->useCache('config'); - if ($useCache) { - $cacheId = 'DIRECTORY_COUNTRY_SELECT_STORE_' . Mage::app()->getStore()->getCode(); - $cacheTags = array('config'); - if ($optionsCache = Mage::app()->loadCache($cacheId)) { - $options = unserialize($optionsCache); - } - } - - if ($options == false) { - $options = $this->getCountryCollection()->toOptionArray(); - if ($useCache) { - Mage::app()->saveCache(serialize($options), $cacheId, $cacheTags); - } - } - return $options; - } - - /** - * Get checkout steps codes - * - * @return array - */ - protected function _getStepCodes() - { - return array('login', 'billing', 'shipping', 'shipping_method', 'payment', 'review'); - } - - - /** - * Retrieve is allow and show block - * - * @return bool - */ - public function isShow() - { - return true; - } -/* */ -} diff --git a/app/code/core/Mage/Checkout/etc/adminhtml/acl.xml b/app/code/core/Mage/Checkout/etc/adminhtml/acl.xml deleted file mode 100644 index 16bbb5db608d5..0000000000000 --- a/app/code/core/Mage/Checkout/etc/adminhtml/acl.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Checkout/etc/adminhtml/menu.xml b/app/code/core/Mage/Checkout/etc/adminhtml/menu.xml deleted file mode 100644 index 26464d25396cd..0000000000000 --- a/app/code/core/Mage/Checkout/etc/adminhtml/menu.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - diff --git a/app/code/core/Mage/Checkout/etc/config.xml b/app/code/core/Mage/Checkout/etc/config.xml deleted file mode 100644 index ec56bbfcce9ff..0000000000000 --- a/app/code/core/Mage/Checkout/etc/config.xml +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - - Mage_Checkout - Mage_Checkout_Model_Resource_Setup - - - - - - - - - Mage_Checkout_Block_Total_Nominal - - - - - - - - /checkout/onepage - /checkout/multishipping - - - - - - Mage_Checkout_Model_Observer - loadCustomerQuote - - - - - - - Mage_Checkout_Model_Observer - unsetAll - - - - - - - Mage_Checkout_Model_Observer - salesQuoteSaveAfter - - - - - - - standard - - Mage_Checkout - checkout - - - - - - - - Mage_Checkout.csv - - - - - - - - layout.xml - - - - - - - - - - Mage_Checkout.csv - - - - - - - - - 1 - 1 - - - 30 - 1 - itself - parent - - - 1 - - - 1 - 3 - - - general - general - - - - - diff --git a/app/code/core/Mage/Checkout/view/frontend/cart/item/default.phtml b/app/code/core/Mage/Checkout/view/frontend/cart/item/default.phtml deleted file mode 100644 index 121a6556071ba..0000000000000 --- a/app/code/core/Mage/Checkout/view/frontend/cart/item/default.phtml +++ /dev/null @@ -1,278 +0,0 @@ - -getItem(); -$isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility(); -$canApplyMsrp = Mage::helper('Mage_Catalog_Helper_Data')->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM); -?> - - hasProductUrl()):?><?php echo $this->escapeHtml($this->getProductName()) ?>hasProductUrl()):?> - -

    - hasProductUrl()):?> - escapeHtml($this->getProductName()) ?> - - escapeHtml($this->getProductName()) ?> - -

    - getOptionList()):?> -
    - - getFormatedOptionValue($_option) ?> -
    escapeHtml($_option['label']) ?>
    - class="truncated"> - -
    -
    -
    escapeHtml($_option['label']) ?>
    -
    -
    -
    - - - -
    - - getMessages()): ?> - -

    * escapeHtml($message['text']) ?>

    - - - getProductAdditionalInformationBlock(); ?> - - setItem($_item)->toHtml() ?> - - - - - __('Edit') ?> - - - helper('Mage_Wishlist_Helper_Data')->isAllowInCart()) : ?> - - - __('Move'); ?> - - - - - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> colspan="2"> - - __('See price before order confirmation.'); ?> - getId(); ?> - __("What's this?"); ?> - - - - - - helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?> - - helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()) ?> - - - - - - getApplied($_item)): ?> - - - - typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - __('Total'); ?>: helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?> -
    - - - - - helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item); ?> - typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - - - - - - typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?> - - helper('Mage_Checkout_Helper_Data')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?> - - - - getApplied($_item)): ?> - - - - typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - __('Total incl. tax'); ?>: helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?> -
    - - - - - - - - - helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()) && !$_item->getNoSubtotal()): ?> - - typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - - - - - - - -- - - typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> - - helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()) ?> - - - - - getApplied($_item)): ?> - - - - typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - __('Total'); ?>: helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> -
    - - - - - helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()) && !$_item->getNoSubtotal()): ?> - - helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item); ?> - typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - - - - - - - -- - - typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - - helper('Mage_Checkout_Helper_Data')->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> - - - - - - - getApplied($_item)): ?> - - - - typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - __('Total incl. tax'); ?>: helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> -
    - - - - - __('Remove item')?> - diff --git a/app/code/core/Mage/Checkout/view/frontend/cart/sidebar/default.phtml b/app/code/core/Mage/Checkout/view/frontend/cart/sidebar/default.phtml deleted file mode 100644 index 68020f158ef25..0000000000000 --- a/app/code/core/Mage/Checkout/view/frontend/cart/sidebar/default.phtml +++ /dev/null @@ -1,145 +0,0 @@ - -getItem(); - $isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility(); - $canApplyMsrp = Mage::helper('Mage_Catalog_Helper_Data')->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM); -?> -
  • - hasProductUrl()): ?> - <?php echo $this->escapeHtml($this->getProductName()) ?> - - <?php echo $this->escapeHtml($this->getProductName()) ?> - -
    - __('Remove This Item') ?> - - __('Edit item')?> - -

    hasProductUrl()): ?>escapeHtml($this->getProductName()) ?>hasProductUrl()): ?>

    - getQty() ?> x - - - - __('See price before order confirmation.'); ?> - - - - helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - __('Excl. Tax'); ?>: - - typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?> - - helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()) ?> - - getApplied($_item)): ?> -
    - typeOfDisplay($_item, 1, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : formatPrice($tax['amount'],true,true); ?>
    - -
    - typeOfDisplay($_item, 2, 'sales')): ?> - getApplied($_item) as $tax): ?> - : formatPrice($tax['amount_incl_tax'],true,true); ?>
    - - typeOfDisplay($_item, 4, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : formatPrice($tax['amount_incl_tax'],true,true); ?>
    - -
    - - typeOfDisplay($_item, 2, 'sales')): ?> - __('Total'); ?>:
    helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>
    - - - - - - - helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item); ?> - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> -
    __('Incl. Tax'); ?>: - - typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?> - - helper('Mage_Checkout_Helper_Data')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?> - - getApplied($_item)): ?> -
    - typeOfDisplay($_item, 1, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : formatPrice($tax['amount'],true,true); ?>
    - -
    - typeOfDisplay($_item, 2, 'sales')): ?> - getApplied($_item) as $tax): ?> - : formatPrice($tax['amount_incl_tax'],true,true); ?>
    - - typeOfDisplay($_item, 4, 'sales')): ?> - - getApplied($_item) as $tax): ?> - : formatPrice($tax['amount_incl_tax'],true,true); ?>
    - -
    - - typeOfDisplay($_item, 2, 'sales')): ?> - __('Total incl. tax'); ?>:
    helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?>
    - - - - - - - getOptionList()):?> -
    -
    -
    - -
    escapeHtml($_option['label']) ?>
    -
    - - - - - -
    - -
    -
    - __('Details') ?> -
    - -
    -
  • diff --git a/app/code/core/Mage/Checkout/view/frontend/layout.xml b/app/code/core/Mage/Checkout/view/frontend/layout.xml deleted file mode 100644 index 7f866d8d23931..0000000000000 --- a/app/code/core/Mage/Checkout/view/frontend/layout.xml +++ /dev/null @@ -1,415 +0,0 @@ - - - - - - - - - - - - - - - - - - simpleMage_Checkout_Block_Cart_Item_Renderer - groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped - configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable - - - - - - - - - - - - - cart.phtml - cart/noItems.phtml - - simpleMage_Checkout_Block_Cart_Item_Renderer - groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped - configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - defaultMage_Checkout_Block_Cart_Item_Renderer - groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped - configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable - - - - - - - - - - - - - defaultMage_Checkout_Block_Cart_Item_Renderer - groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped - configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable - - - defaultMage_Checkout_Block_Cart_Item_Renderer - groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped - configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable - - - - - - - - - - - - - - purchaseorder - - - - - - - - - - - - - - - - defaultMage_Checkout_Block_Cart_Item_Renderer - groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped - configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable - groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped - configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - purchaseorder - - - - - - - - - - - - - - - - - - - - - - - - - - purchaseorder - - - - - - - - - - - - - - - - - - - 1 - - - - - - - - - - - defaultMage_Checkout_Block_Cart_Item_Renderer - groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped - configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Checkout/view/frontend/multishipping/addresses.phtml b/app/code/core/Mage/Checkout/view/frontend/multishipping/addresses.phtml deleted file mode 100644 index 3fb73a5878b17..0000000000000 --- a/app/code/core/Mage/Checkout/view/frontend/multishipping/addresses.phtml +++ /dev/null @@ -1,81 +0,0 @@ - - -getMessagesBlock()->getGroupedHtml() ?> -
    -
    -
    -

    __('Ship to Multiple Addresses') ?>

    - -
    - - -

    __('Please select shipping address for applicable items') ?>

    - - - - - - - - - - - - - - - - - - - - getItems() as $_index => $_item): ?> - getQuoteItem()) :?> - - - - - - - - - -
    __('Product') ?>__('Qty') ?>__('Send To') ?> 
    getItemHtml($_item->getQuoteItem())?>getProduct()->getIsVirtual()): echo $this->__('Shipping selection is not applicable.'); else: echo $this->getAddressesHtmlSelect($_item, $_index); endif; ?>__('Remove Item') ?>
    - -
    - - -
    -
    -
    diff --git a/app/code/core/Mage/Checkout/view/frontend/multishipping/billing.phtml b/app/code/core/Mage/Checkout/view/frontend/multishipping/billing.phtml deleted file mode 100644 index fc77f1633a908..0000000000000 --- a/app/code/core/Mage/Checkout/view/frontend/multishipping/billing.phtml +++ /dev/null @@ -1,116 +0,0 @@ - - -
    -
    -

    __('Billing Information') ?>

    -
    - getMessagesBlock()->getGroupedHtml() ?> - -
    -
    -
    -
    -
    -

    __('Billing Address') ?> | __('Change') ?>

    -
    -
    - getAddress() ?> -
    format('html') ?>
    -
    -
    -
    -
    -
    -
    -

    __('Payment Method') ?>

    -
    -
    - - -
    - getMethods(); - $_methodsCount = count($_methods); - ?> - getCode() ?> -
    - 1): ?> - getSelectedMethodCode()==$_code): ?> checked="checked" class="radio" /> - - - - -
    - getChildHtml('payment.method.'.$_code)) : ?> -
    - -
    - - -
    - getChildHtml('checkout_billing_items') ?> -
    -
    -
    -
    -
    - - -
    -
    - -
    diff --git a/app/code/core/Mage/Checkout/view/frontend/multishipping/item/default.phtml b/app/code/core/Mage/Checkout/view/frontend/multishipping/item/default.phtml deleted file mode 100644 index f1adcb2221d26..0000000000000 --- a/app/code/core/Mage/Checkout/view/frontend/multishipping/item/default.phtml +++ /dev/null @@ -1,45 +0,0 @@ - -

    escapeHtml($this->getProductName()) ?>

    -getOptionList()):?> -
    - - getFormatedOptionValue($_option) ?> -
    escapeHtml($_option['label']) ?>
    - class="truncated"> - -
    -
    -
    escapeHtml($_option['label']) ?>
    -
    -
    -
    - - - -
    - diff --git a/app/code/core/Mage/Checkout/view/frontend/multishipping/payment.js b/app/code/core/Mage/Checkout/view/frontend/multishipping/payment.js deleted file mode 100644 index a4f8afa6a8d15..0000000000000 --- a/app/code/core/Mage/Checkout/view/frontend/multishipping/payment.js +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Varien - * @package js - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ -var paymentForm = Class.create(); -paymentForm.prototype = { - initialize: function(formId){ - this.formId = formId; - this.validator = new Validation(this.formId); - var elements = Form.getElements(formId); - - var method = null; - for (var i=0; i -
    -

    __('Checkout') ?>

    -
    - - -
      -getSteps() as $_stepId => $_stepInfo): ?> -getChildBlock($_stepId) || !$this->getChildBlock($_stepId)->isShow()): continue; endif; $i++ ?> -
    1. -
      - -

      - __('Edit') ?> -
      - -
    2. - -
    - diff --git a/app/code/core/Mage/Checkout/view/frontend/onepage/billing.phtml b/app/code/core/Mage/Checkout/view/frontend/onepage/billing.phtml deleted file mode 100644 index d9f03af151619..0000000000000 --- a/app/code/core/Mage/Checkout/view/frontend/onepage/billing.phtml +++ /dev/null @@ -1,229 +0,0 @@ - -
    -
    -
      - customerHasAddresses()): ?> -
    • - -
      - getAddressesHtmlSelect('billing') ?> -
      -
    • - -
    • customerHasAddresses()): ?> style="display:none;"> -
      - -
        -
      • getLayout()->createBlock('Mage_Customer_Block_Widget_Name')->setObject($this->getAddress()->getFirstname() ? $this->getAddress() : $this->getQuote()->getCustomer())->setForceUseCustomerRequiredAttributes(!$this->isCustomerLoggedIn())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
      • -
      • -
        - -
        - -
        -
        - isCustomerLoggedIn()): ?> -
        - -
        - -
        -
        - -
      • - helper('Mage_Customer_Helper_Address')->getAttributeValidationClass('street'); ?> -
      • - -
        - -
        -
      • - - helper('Mage_Customer_Helper_Address')->getStreetLines(); $_i <= $_n; $_i++): ?> -
      • -
        - -
        -
      • - - helper('Mage_Customer_Helper_Address')->isVatAttributeVisible()) : ?> -
      • - -
        - -
        -
      • - -
      • -
        - -
        - -
        -
        -
        - -
        - - -
        -
        -
      • -
      • -
        - -
        - -
        -
        -
        - -
        - getCountryHtmlSelect('billing') ?> -
        -
        -
      • -
      • -
        - -
        - -
        -
        -
        - -
        - -
        -
        -
      • - isCustomerLoggedIn()): ?> - - getLayout()->createBlock('Mage_Customer_Block_Widget_Dob') ?> - getLayout()->createBlock('Mage_Customer_Block_Widget_Gender') ?> - isEnabled() || $_gender->isEnabled()): ?> -
      • - isEnabled()): ?> -
        - setDate($this->getQuote()->getCustomerDob())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?> -
        - - isEnabled()): ?> -
        - setGender($this->getQuote()->getCustomerGender())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?> -
        - -
      • - - - getLayout()->createBlock('Mage_Customer_Block_Widget_Taxvat') ?> - isEnabled()): ?> -
      • - setTaxvat($this->getQuote()->getCustomerTaxvat())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?> -
      • - - -
      • -
        - -
        - -
        -
        -
        - -
        - -
        -
        -
      • - - isCustomerLoggedIn() && $this->customerHasAddresses()):?> -
      • - getAddress()->getSaveInAddressBook()):?> checked="checked" class="checkbox" /> -
      • - -
      • - - getChildHtml('form.additional.info'); ?> -
      -
      -
    • - - getChildHtml('checkout.onepage.billing.extra')?> - canShip()): ?> -
    • - isUseBillingAddressForShipping()) {?> checked="checked" title="__('Ship to this address') ?>" onclick="$('shipping:same_as_billing').checked = true;" class="radio" />
    • -
    • - isUseBillingAddressForShipping()) {?> checked="checked" title="__('Ship to different address') ?>" onclick="$('shipping:same_as_billing').checked = false;" class="radio" /> -
    • - -
    - canShip()): ?> - - -
    -

    __('* Required Fields') ?>

    - - -
    -
    -
    - - diff --git a/app/code/core/Mage/Checkout/view/frontend/onepage/login.phtml b/app/code/core/Mage/Checkout/view/frontend/onepage/login.phtml deleted file mode 100644 index e2a165702ab3d..0000000000000 --- a/app/code/core/Mage/Checkout/view/frontend/onepage/login.phtml +++ /dev/null @@ -1,123 +0,0 @@ - - -getChildHtml('checkout.onepage.login.extra')?> -
    - getChildHtml('login_before')?> -
    -

    isAllowedGuestCheckout() ): ?>__('Checkout as a Guest or Register') ?>__('Register to Create an Account') ?>

    - isAllowedGuestCheckout() ): ?> -

    __('Register with us for future convenience:') ?>

    - -

    __('Register and save time!') ?>
    - __('Register with us for future convenience:') ?>

    -
      -
    • __('Fast and easy check out') ?>
    • -
    • __('Easy access to your order history and status') ?>
    • -
    - - isAllowedGuestCheckout() ): ?> -
      - isAllowedGuestCheckout() ): ?> -
    • - getQuote()->getCheckoutMethod()==Mage_Checkout_Model_Type_Onepage::METHOD_GUEST): ?> checked="checked" class="radio" /> -
    • - -
    • - getQuote()->getCheckoutMethod()==Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER || !$this->isAllowedGuestCheckout()): ?> checked="checked" class="radio" /> -
    • -
    -

    __('Register and save time!') ?>

    -

    __('Register with us for future convenience:') ?>

    -
      -
    • __('Fast and easy check out') ?>
    • -
    • __('Easy access to your order history and status') ?>
    • -
    - - - -
    -
    -

    __('Login') ?>

    - getMessagesBlock()->getGroupedHtml() ?> -
    -
    -

    __('Already registered?') ?>

    -

    __('Please log in below:') ?>

    -
      -
    • - -
      - -
      -
    • -
    • - -
      - -
      -
    • - getChildHtml('login.form.additional.info'); ?> -
    -
    -
    -
    -
    -
    -
    -
    -

     

    - -
    -
    -
    -
    -

    __('* Required Fields') ?>

    - __('Forgot your password?') ?> - -
    -
    -
    - diff --git a/app/code/core/Mage/Checkout/view/frontend/onepage/payment.phtml b/app/code/core/Mage/Checkout/view/frontend/onepage/payment.phtml deleted file mode 100644 index 0f855b9dc1784..0000000000000 --- a/app/code/core/Mage/Checkout/view/frontend/onepage/payment.phtml +++ /dev/null @@ -1,73 +0,0 @@ - - -
    -
    - getChildHtml('methods') ?> -
    -
    - -
    -

    __('* Required Fields') ?>

    - - - -
    - - diff --git a/app/code/core/Mage/Checkout/view/frontend/onepage/review/button.phtml b/app/code/core/Mage/Checkout/view/frontend/onepage/review/button.phtml deleted file mode 100644 index 4c5617069f3de..0000000000000 --- a/app/code/core/Mage/Checkout/view/frontend/onepage/review/button.phtml +++ /dev/null @@ -1,27 +0,0 @@ - - diff --git a/app/code/core/Mage/Checkout/view/frontend/onepage/review/info.phtml b/app/code/core/Mage/Checkout/view/frontend/onepage/review/info.phtml deleted file mode 100644 index 8bec89832008a..0000000000000 --- a/app/code/core/Mage/Checkout/view/frontend/onepage/review/info.phtml +++ /dev/null @@ -1,84 +0,0 @@ - -getChildHtml('items_before'); ?> -
    - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): $colspan = $rowspan = 2; else: $colspan = $rowspan = 1; endif; ?> - - - - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - - - - - - - - - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - - - - - - - - getChildHtml('totals'); ?> - - getItems() as $_item): ?> - getItemHtml($_item)?> - - -
    __('Product Name') ?>__('Price') ?>__('Qty') ?>__('Subtotal') ?>
    helper('Mage_Tax_Helper_Data')->getIncExcTaxLabel(false) ?>helper('Mage_Tax_Helper_Data')->getIncExcTaxLabel(true) ?>helper('Mage_Tax_Helper_Data')->getIncExcTaxLabel(false) ?>helper('Mage_Tax_Helper_Data')->getIncExcTaxLabel(true) ?>
    -
    -getChildHtml('items_after'); ?> - -
    - getChildHtml('agreements') ?> -
    -

    __('Forgot an Item?') ?> __('Edit Your Cart') ?>

    - getChildHtml('button') ?> - -
    - -
    diff --git a/app/code/core/Mage/Checkout/view/frontend/onepage/review/item.phtml b/app/code/core/Mage/Checkout/view/frontend/onepage/review/item.phtml deleted file mode 100644 index a1b88afe87134..0000000000000 --- a/app/code/core/Mage/Checkout/view/frontend/onepage/review/item.phtml +++ /dev/null @@ -1,239 +0,0 @@ - -getItem()?> - -

    escapeHtml($this->getProductName()) ?>

    - getOptionList()):?> -
    - - getFormatedOptionValue($_option) ?> -
    escapeHtml($_option['label']) ?>
    - class="truncated"> - -
    -
    -
    escapeHtml($_option['label']) ?>
    -
    -
    -
    - - - -
    - - getProductAdditionalInformationBlock()):?> - setItem($_item)->toHtml() ?> - - - helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - - - - - - typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?> - - helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()) ?> - - - - - - getApplied($_item)): ?> - - - - typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - __('Total'); ?>:
    helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>
    -
    - - - - - helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item); ?> - typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - - - - - - typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?> - - helper('Mage_Checkout_Helper_Data')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?> - - - - getApplied($_item)): ?> - - - - typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - __('Total incl. tax'); ?>:
    helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?>
    -
    - - - - - getQty() ?> - helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - - - - - - typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> - - helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()) ?> - - - - getApplied($_item)): ?> - - - - typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - __('Total'); ?>:
    helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?>
    -
    - - - - - helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item); ?> - typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - - - - - - typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - - helper('Mage_Checkout_Helper_Data')->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> - - - - - - getApplied($_item)): ?> - - - - typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - __('Total incl. tax'); ?>:
    helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
    -
    - - - - - diff --git a/app/code/core/Mage/Checkout/view/frontend/onepage/shipping_method/available.phtml b/app/code/core/Mage/Checkout/view/frontend/onepage/shipping_method/available.phtml deleted file mode 100644 index 4017d0ab65b00..0000000000000 --- a/app/code/core/Mage/Checkout/view/frontend/onepage/shipping_method/available.phtml +++ /dev/null @@ -1,101 +0,0 @@ - - -getShippingRates(); ?> - -

    __('Sorry, no quotes are available for this order at this time.') ?>

    - -
    - - $_rates): ?> -
    escapeHtml($this->getCarrierName($code)) ?>
    -
    -
      - - getCode()."':".(float)$_rate->getPrice(); ?> -
    • - getErrorMessage()): ?> -
        • escapeHtml($_rate->getErrorMessage()) ?>
      - - - - - getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio"/> - - getCode() === $this->getAddressShippingMethod()): ?> - - - - - - -
    • - -
    -
    - -
    - - diff --git a/app/code/core/Mage/Cms/etc/adminhtml/acl.xml b/app/code/core/Mage/Cms/etc/adminhtml/acl.xml deleted file mode 100644 index 84d740c9fcdea..0000000000000 --- a/app/code/core/Mage/Cms/etc/adminhtml/acl.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Cms/etc/adminhtml/menu.xml b/app/code/core/Mage/Cms/etc/adminhtml/menu.xml deleted file mode 100644 index 0514ddc5d0022..0000000000000 --- a/app/code/core/Mage/Cms/etc/adminhtml/menu.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - diff --git a/app/code/core/Mage/Cms/etc/config.xml b/app/code/core/Mage/Cms/etc/config.xml deleted file mode 100644 index 00a813e86d2e0..0000000000000 --- a/app/code/core/Mage/Cms/etc/config.xml +++ /dev/null @@ -1,184 +0,0 @@ - - - - - - 1.6.0.0.3 - true - core - - - - - - - - - - standard - - Mage_Cms - cms - - - - - - - - Mage_Cms_Model_Observer - noRoute - - - - - - - Mage_Cms_Model_Observer - noCookies - - - - - - - - - Mage_Cms.csv - - - - - - - - layout.xml - - - - - - - - - - Mage_Cms.csv - - - - - - - - - - - - - - - - 1 - 1 - 1 - 1 - - - 1 - 1 - 1 - 1 - - - 1 - 1 - 1 - 1 - 1 - 1 - - - 1000 - 600 - 100 - 75 - - - - - - - - Mage_Cms - - - - - - - - Mage_Cms_Controller_Router - initControllerRouters - - - - - - - Mage_Cms_Model_Template_Filter - - - Mage_Cms_Model_Template_Filter - - - - - - - home - no-route - enable-cookies - cms - cms/index/noRoute - 1 - - - - - enabled - - - - - - wysiwyg - - - - - diff --git a/app/code/core/Mage/Connect/Helper/Data.php b/app/code/core/Mage/Connect/Helper/Data.php deleted file mode 100644 index b40a1937ace37..0000000000000 --- a/app/code/core/Mage/Connect/Helper/Data.php +++ /dev/null @@ -1,166 +0,0 @@ - - */ -class Mage_Connect_Helper_Data extends Mage_Core_Helper_Data -{ - /** - * @var Magento_Filesystem - */ - protected $_filesystem; - - /** - * @param Mage_Core_Model_Translate $translator - * @param Mage_Core_Model_Config_Modules $modulesConfig - * @param Magento_Filesystem $filesystem - */ - public function __construct( - Mage_Core_Model_Translate $translator, - Mage_Core_Model_Config_Modules $modulesConfig, - Magento_Filesystem $filesystem - ) { - parent::__construct($translator, $modulesConfig); - $this->_filesystem = $filesystem; - } - - /** - * Retrieve file system path for local extension packages - * Return path with last directory separator - * - * @return string - */ - public function getLocalPackagesPath() - { - return Mage::getBaseDir('var') . DS . 'connect' . DS; - } - - /** - * Retrieve file system path for local extension packages (for version 1 packages only) - * Return path with last directory separator - * - * @return string - */ - public function getLocalPackagesPathV1x() - { - return Mage::getBaseDir('var') . DS . 'pear' . DS; - } - - /** - * Retrieve a map to convert a channel from previous version of Magento Connect Manager - * - * @return array - */ - public function getChannelMapFromV1x() - { - return array( - 'connect.magentocommerce.com/community' => 'community', - 'connect.magentocommerce.com/core' => 'community' - ); - } - - /** - * Retrieve a map to convert a channel to previous version of Magento Connect Manager - * - * @return array - */ - public function getChannelMapToV1x() - { - return array( - 'community' => 'connect.magentocommerce.com/community' - ); - } - - /** - * Convert package channel in order for it to be compatible with current version of Magento Connect Manager - * - * @param string $channel - * - * @return string - */ - public function convertChannelFromV1x($channel) - { - $channelMap = $this->getChannelMapFromV1x(); - if (isset($channelMap[$channel])) { - $channel = $channelMap[$channel]; - } - return $channel; - } - - /** - * Convert package channel in order for it to be compatible with previous version of Magento Connect Manager - * - * @param string $channel - * - * @return string - */ - public function convertChannelToV1x($channel) - { - $channelMap = $this->getChannelMapToV1x(); - if (isset($channelMap[$channel])) { - $channel = $channelMap[$channel]; - } - return $channel; - } - - /** - * Load local package data array - * - * @param string $packageName without extension - * @return array|false - */ - public function loadLocalPackage($packageName) - { - //check LFI protection - $this->checkLfiProtection($packageName); - - $path = $this->getLocalPackagesPath(); - $xmlFile = $path . $packageName . '.xml'; - $serFile = $path . $packageName . '.ser'; - - if ($this->_filesystem->isFile($xmlFile) && $this->_filesystem->isReadable($xmlFile)) { - $xml = simplexml_load_string($this->_filesystem->read($xmlFile)); - $data = Mage::helper('Mage_Core_Helper_Data')->xmlToAssoc($xml); - if (!empty($data)) { - return $data; - } - } - - if ($this->_filesystem->isFile($serFile) && $this->_filesystem->isReadable($xmlFile)) { - $data = unserialize($this->_filesystem->read($serFile)); - if (!empty($data)) { - return $data; - } - } - - return false; - } -} diff --git a/app/code/core/Mage/Connect/etc/adminhtml.xml b/app/code/core/Mage/Connect/etc/adminhtml.xml deleted file mode 100644 index 187c98c5f2b7a..0000000000000 --- a/app/code/core/Mage/Connect/etc/adminhtml.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - diff --git a/app/code/core/Mage/Connect/etc/adminhtml/menu.xml b/app/code/core/Mage/Connect/etc/adminhtml/menu.xml deleted file mode 100644 index dcbb0694cb752..0000000000000 --- a/app/code/core/Mage/Connect/etc/adminhtml/menu.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - diff --git a/app/code/core/Mage/Connect/etc/config.xml b/app/code/core/Mage/Connect/etc/config.xml deleted file mode 100644 index dfaff9a3649e6..0000000000000 --- a/app/code/core/Mage/Connect/etc/config.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - Mage_Connect_Adminhtml - - - - - - - - - - layout.xml - - - - - - - - Mage_Connect.csv - - - - - - diff --git a/app/code/core/Mage/Contacts/etc/adminhtml/acl.xml b/app/code/core/Mage/Contacts/etc/adminhtml/acl.xml deleted file mode 100644 index e4296baca5632..0000000000000 --- a/app/code/core/Mage/Contacts/etc/adminhtml/acl.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Contacts/etc/config.xml b/app/code/core/Mage/Contacts/etc/config.xml deleted file mode 100644 index 36b749fae5efc..0000000000000 --- a/app/code/core/Mage/Contacts/etc/config.xml +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - standard - - Mage_Contacts - contacts - - - - - - - - Mage_Contacts.csv - - - - - - - - layout.xml - - - - - - - - - Mage_Contacts - - - - - - - - - - - - Mage_Contacts.csv - - - - - - - - - - 1 - - - - custom2 - contacts_email_email_template - - - - diff --git a/app/code/core/Mage/Core/Block/Abstract.php b/app/code/core/Mage/Core/Block/Abstract.php deleted file mode 100644 index d47303833cf5e..0000000000000 --- a/app/code/core/Mage/Core/Block/Abstract.php +++ /dev/null @@ -1,1103 +0,0 @@ - - * @SuppressWarnings(PHPMD.ExcessivePublicCount) - * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -abstract class Mage_Core_Block_Abstract extends Varien_Object - implements Mage_Core_Block -{ - /** - * @var Mage_Core_Model_Design_Package - */ - protected $_designPackage; - - /** - * @var Mage_Core_Model_Session - */ - protected $_session; - - /** - * @var Mage_Core_Model_Translate - */ - protected $_translator; - - /** - * Cache group Tag - */ - const CACHE_GROUP = 'block_html'; - /** - * Block name in layout - * - * @var string - */ - protected $_nameInLayout; - - /** - * Parent layout of the block - * - * @var Mage_Core_Model_Layout - */ - protected $_layout; - - /** - * @var Mage_Core_Controller_Request_Http - */ - protected $_request; - - /** - * Messages block instance - * - * @var Mage_Core_Block_Messages - */ - protected $_messagesBlock = null; - - /** - * Block html frame open tag - * @var string - */ - protected $_frameOpenTag; - - /** - * Block html frame close tag - * @var string - */ - protected $_frameCloseTag; - - /** - * Url Builder - * - * @var Mage_Core_Model_Url - */ - protected $_urlBuilder; - - /** - * System event manager - * - * - * @var Mage_Core_Model_Event_Manager - */ - protected $_eventManager; - - /** - * Application front controller - * - * @var Mage_Core_Controller_Varien_Front - */ - protected $_frontController; - - /** - * @param Mage_Core_Controller_Request_Http $request - * @param Mage_Core_Model_Layout $layout - * @param Mage_Core_Model_Event_Manager $eventManager - * @param Mage_Core_Model_Url $urlBuilder - * @param Mage_Core_Model_Translate $translator - * @param Mage_Core_Model_Cache $cache - * @param Mage_Core_Model_Design_Package $designPackage - * @param Mage_Core_Model_Session_Abstract $session - * @param Mage_Core_Model_Store_Config $storeConfig - * @param Mage_Core_Controller_Varien_Front $frontController - * @param Mage_Core_Model_Factory_Helper $helperFactory - * @param array $data - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) - */ - public function __construct( - Mage_Core_Controller_Request_Http $request, - Mage_Core_Model_Layout $layout, - Mage_Core_Model_Event_Manager $eventManager, - Mage_Core_Model_Url $urlBuilder, - Mage_Core_Model_Translate $translator, - Mage_Core_Model_Cache $cache, - Mage_Core_Model_Design_Package $designPackage, - Mage_Core_Model_Session_Abstract $session, - Mage_Core_Model_Store_Config $storeConfig, - Mage_Core_Controller_Varien_Front $frontController, - Mage_Core_Model_Factory_Helper $helperFactory, - array $data = array() - ) { - $this->_request = $request; - $this->_layout = $layout; - $this->_eventManager = $eventManager; - $this->_urlBuilder = $urlBuilder; - $this->_translator = $translator; - $this->_cache = $cache; - $this->_designPackage = $designPackage; - $this->_session = $session; - $this->_storeConfig = $storeConfig; - $this->_frontController = $frontController; - $this->_helperFactory = $helperFactory; - - parent::__construct($data); - $this->_construct(); - } - - /** - * @return Mage_Core_Controller_Request_Http - */ - public function getRequest() - { - return $this->_request; - } - - /** - * Internal constructor, that is called from real constructor - * - * Please override this one instead of overriding real __construct constructor - * - */ - protected function _construct() - { - /** - * Please override this one instead of overriding real __construct constructor - */ - } - - /** - * Retrieve parent block - * - * @return Mage_Core_Block_Abstract|bool - */ - public function getParentBlock() - { - $layout = $this->getLayout(); - if (!$layout) { - return false; - } - $parentName = $layout->getParentName($this->getNameInLayout()); - if ($parentName) { - return $layout->getBlock($parentName); - } - return false; - } - - /** - * Set layout object - * - * @param Mage_Core_Model_Layout $layout - * @return Mage_Core_Block_Abstract - */ - public function setLayout(Mage_Core_Model_Layout $layout) - { - $this->_layout = $layout; - $this->_eventManager->dispatch('core_block_abstract_prepare_layout_before', array('block' => $this)); - $this->_prepareLayout(); - $this->_eventManager->dispatch('core_block_abstract_prepare_layout_after', array('block' => $this)); - return $this; - } - - /** - * Preparing global layout - * - * You can redefine this method in child classes for changing layout - * - * @return Mage_Core_Block_Abstract - */ - protected function _prepareLayout() - { - return $this; - } - - /** - * Retrieve layout object - * - * @return Mage_Core_Model_Layout - */ - public function getLayout() - { - return $this->_layout; - } - - /** - * Sets/changes name of a block in layout - * - * @param string $name - * @return Mage_Core_Block_Abstract - */ - public function setNameInLayout($name) - { - $layout = $this->getLayout(); - if (!empty($this->_nameInLayout) && $layout) { - if ($name === $this->_nameInLayout) { - return $this; - } - $layout->renameElement($this->_nameInLayout, $name); - } - $this->_nameInLayout = $name; - return $this; - } - - /** - * Retrieves sorted list of child names - * - * @return array - */ - public function getChildNames() - { - $layout = $this->getLayout(); - if (!$layout) { - return array(); - } - return $layout->getChildNames($this->getNameInLayout()); - } - - /** - * Set block attribute value - * - * Wrapper for method "setData" - * - * @param string $name - * @param mixed $value - * @return Mage_Core_Block_Abstract - */ - public function setAttribute($name, $value = null) - { - return $this->setData($name, $value); - } - - /** - * Set child block - * - * @param string $alias - * @param Mage_Core_Block_Abstract|string $block - * @return Mage_Core_Block_Abstract - */ - public function setChild($alias, $block) - { - $layout = $this->getLayout(); - if (!$layout) { - return $this; - } - $thisName = $this->getNameInLayout(); - if ($layout->getChildName($thisName, $alias)) { - $this->unsetChild($alias); - } - if ($block instanceof self) { - $block = $block->getNameInLayout(); - } - $layout->setChild($thisName, $block, $alias); - - return $this; - } - - /** - * Create block with name: {parent}.{alias} and set as child - * - * @param string $alias - * @param string $block - * @param array $data - * @return Mage_Core_Block_Abstract new block - */ - public function addChild($alias, $block, $data = array()) - { - $block = $this->getLayout()->createBlock($block, $this->getNameInLayout() . '.' . $alias, $data); - $this->setChild($alias, $block); - return $block; - } - - /** - * Unset child block - * - * @param string $alias - * @return Mage_Core_Block_Abstract - */ - public function unsetChild($alias) - { - $layout = $this->getLayout(); - if (!$layout) { - return $this; - } - $layout->unsetChild($this->getNameInLayout(), $alias); - return $this; - } - - /** - * Call a child and unset it, if callback matched result - * - * $params will pass to child callback - * $params may be array, if called from layout with elements with same name, for example: - * ...value_1value_2value_3 - * - * Or, if called like this: - * ...value_1value_2value_3 - * - then it will be $params1, $params2, $params3 - * - * It is no difference anyway, because they will be transformed in appropriate way. - * - * @param string $alias - * @param string $callback - * @param mixed $result - * @param array $params - * @return Mage_Core_Block_Abstract - */ - public function unsetCallChild($alias, $callback, $result, $params) - { - $child = $this->getChildBlock($alias); - if ($child) { - $args = func_get_args(); - $alias = array_shift($args); - $callback = array_shift($args); - $result = (string)array_shift($args); - if (!is_array($params)) { - $params = $args; - } - - if ($result == call_user_func_array(array(&$child, $callback), $params)) { - $this->unsetChild($alias); - } - } - return $this; - } - - /** - * Unset all children blocks - * - * @return Mage_Core_Block_Abstract - */ - public function unsetChildren() - { - $layout = $this->getLayout(); - if (!$layout) { - return $this; - } - $name = $this->getNameInLayout(); - $children = $layout->getChildNames($name); - foreach ($children as $childName) { - $layout->unsetChild($name, $childName); - } - return $this; - } - - /** - * Retrieve child block by name - * - * @param string $alias - * @return Mage_Core_Block_Abstract|bool - */ - public function getChildBlock($alias) - { - $layout = $this->getLayout(); - if (!$layout) { - return false; - } - $name = $layout->getChildName($this->getNameInLayout(), $alias); - if ($name) { - return $layout->getBlock($name); - } - return false; - } - - /** - * Retrieve child block HTML - * - * @param string $alias - * @param boolean $useCache - * @return string - */ - public function getChildHtml($alias = '', $useCache = true) - { - $layout = $this->getLayout(); - if (!$layout) { - return ''; - } - $name = $this->getNameInLayout(); - $out = ''; - if ($alias) { - $childName = $layout->getChildName($name, $alias); - if ($childName) { - $out = $layout->renderElement($childName, $useCache); - } - } else { - foreach ($layout->getChildNames($name) as $child) { - $out .= $layout->renderElement($child, $useCache); - } - } - - return $out; - } - - /** - * Render output of child child element - * - * @param string $alias - * @param string $childChildAlias - * @param bool $useCache - * @return string - */ - public function getChildChildHtml($alias, $childChildAlias = '', $useCache = true) - { - $layout = $this->getLayout(); - if (!$layout) { - return ''; - } - $childName = $layout->getChildName($this->getNameInLayout(), $alias); - if (!$childName) { - return ''; - } - $out = ''; - if ($childChildAlias) { - $childChildName = $layout->getChildName($childName, $childChildAlias); - $out = $layout->renderElement($childChildName, $useCache); - } else { - foreach ($layout->getChildNames($childName) as $childChild) { - $out .= $layout->renderElement($childChild, $useCache); - } - } - return $out; - } - - /** - * Retrieve block html - * - * @param string $name - * @return string - */ - public function getBlockHtml($name) - { - $block = $this->_layout->getBlock($name); - if ($block) { - return $block->toHtml(); - } - return ''; - } - - /** - * Insert child element into specified position - * - * By default inserts as first element into children list - * - * @param Mage_Core_Block_Abstract|string $element - * @param string|int|null $siblingName - * @param bool $after - * @param string $alias - * @return Mage_Core_Block_Abstract|bool - */ - public function insert($element, $siblingName = 0, $after = true, $alias = '') - { - $layout = $this->getLayout(); - if (!$layout) { - return false; - } - if ($element instanceof Mage_Core_Block_Abstract) { - $elementName = $element->getNameInLayout(); - } else { - $elementName = $element; - } - $layout->setChild($this->_nameInLayout, $elementName, $alias); - $layout->reorderChild($this->_nameInLayout, $elementName, $siblingName, $after); - return $this; - } - - /** - * Append element to the end of children list - * - * @param Mage_Core_Block_Abstract|string $element - * @param string $alias - * @return Mage_Core_Block_Abstract - */ - public function append($element, $alias = '') - { - return $this->insert($element, null, true, $alias); - } - - /** - * Add self to the specified group of parent block - * - * @param string $groupName - * @return Mage_Core_Block_Abstract|bool - */ - public function addToParentGroup($groupName) - { - $layout = $this->getLayout(); - if (!$layout) { - return false; - } - $layout->addToParentGroup($this->getNameInLayout(), $groupName); - - return $this; - } - - /** - * Get a group of child blocks - * - * Returns an array of => - * or an array of => - * The callback currently supports only $this methods and passes the alias as parameter - * - * @param string $groupName - * @return array - */ - public function getGroupChildNames($groupName) - { - return $this->getLayout()->getGroupChildNames($this->getNameInLayout(), $groupName); - } - - /** - * Get a value from child block by specified key - * - * @param string $alias - * @param string $key - * @return mixed - */ - public function getChildData($alias, $key = '') - { - $child = $this->getChildBlock($alias); - if ($child) { - return $child->getData($key); - } - return null; - } - - /** - * Before rendering html, but after trying to load cache - * - * @return Mage_Core_Block_Abstract - */ - protected function _beforeToHtml() - { - return $this; - } - - /** - * Specify block output frame tags - * - * @param $openTag - * @param $closeTag - * @return Mage_Core_Block_Abstract - */ - public function setFrameTags($openTag, $closeTag = null) - { - $this->_frameOpenTag = $openTag; - if ($closeTag) { - $this->_frameCloseTag = $closeTag; - } else { - $this->_frameCloseTag = '/' . $openTag; - } - return $this; - } - - /** - * Produce and return block's html output - * - * It is a final method, but you can override _toHtml() method in descendants if needed. - * - * @return string - */ - final public function toHtml() - { - $this->_eventManager->dispatch('core_block_abstract_to_html_before', array('block' => $this)); - if ($this->_storeConfig->getConfig('advanced/modules_disable_output/' . $this->getModuleName())) { - return ''; - } - $html = $this->_loadCache(); - if ($html === false) { - if ($this->hasData('translate_inline')) { - $this->_translator->setTranslateInline($this->getData('translate_inline')); - } - - $this->_beforeToHtml(); - $html = $this->_toHtml(); - $this->_saveCache($html); - - if ($this->hasData('translate_inline')) { - $this->_translator->setTranslateInline(true); - } - } - $html = $this->_afterToHtml($html); - - /** - * Check framing options - */ - if ($this->_frameOpenTag) { - $html = '<' . $this->_frameOpenTag . '>' . $html . '<' . $this->_frameCloseTag . '>'; - } - - return $html; - } - - /** - * Processing block html after rendering - * - * @param string $html - * @return string - */ - protected function _afterToHtml($html) - { - return $html; - } - - /** - * Override this method in descendants to produce html - * - * @return string - */ - protected function _toHtml() - { - return ''; - } - - /** - * Retrieve data-ui-id attribute which will distinguish link/input/container/anything else in template among others - * Function takes an arbitrary amount of parameters - * - * @return string - */ - public function getUiId() - { - return ' data-ui-id="' . call_user_func_array(array($this, 'getJsId'), func_get_args()) . '" '; - } - - /** - * Generate id for using in JavaScript UI - * Function takes an arbitrary amount of parameters - * - * @return string - */ - public function getJsId() - { - $rawId = $this->_nameInLayout . '-' . implode('-', func_get_args()); - return trim(preg_replace('/[^a-z0-9]+/', '-', strtolower($rawId)), '-'); - } - - /** - * Generate url by route and parameters - * - * @param string $route - * @param array $params - * @return string - */ - public function getUrl($route = '', $params = array()) - { - return $this->_urlBuilder->getUrl($route, $params); - } - - /** - * Generate base64-encoded url by route and parameters - * - * @param string $route - * @param array $params - * @return string - */ - public function getUrlBase64($route = '', $params = array()) - { - return $this->helper('Mage_Core_Helper_Data')->urlEncode($this->getUrl($route, $params)); - } - - /** - * Generate url-encoded url by route and parameters - * - * @param string $route - * @param array $params - * @return string - */ - public function getUrlEncoded($route = '', $params = array()) - { - return $this->helper('Mage_Core_Helper_Data')->urlEncode($this->getUrl($route, $params)); - } - - /** - * Retrieve url of themes file - * - * @param string $file path to file in theme - * @param array $params - * @return string - * @throws Magento_Exception - */ - public function getViewFileUrl($file = null, array $params = array()) - { - try { - return Mage::getDesign()->getViewFileUrl($file, $params); - } catch (Magento_Exception $e) { - Mage::logException($e); - return $this->_getNotFoundUrl(); - } - } - - /** - * Get 404 file not found url - * - * @param string $route - * @param array $params - * @return string - */ - protected function _getNotFoundUrl($route = '', $params = array('_direct' => 'core/index/notfound')) - { - return $this->getUrl($route, $params); - } - - /** - * Retrieve messages block - * - * @return Mage_Core_Block_Messages - */ - public function getMessagesBlock() - { - if (is_null($this->_messagesBlock)) { - return $this->getLayout()->getMessagesBlock(); - } - return $this->_messagesBlock; - } - - /** - * Set messages block - * - * @param Mage_Core_Block_Messages $block - * @return Mage_Core_Block_Abstract - */ - public function setMessagesBlock(Mage_Core_Block_Messages $block) - { - $this->_messagesBlock = $block; - return $this; - } - - /** - * Return helper object - * - * @param string $name - * @return Mage_Core_Helper_Abstract - */ - public function helper($name) - { - if ($this->getLayout()) { - return $this->getLayout()->helper($name); - } - return $this->_helperFactory->get($name); - } - - /** - * Retrieve formatting date - * - * @param string $date - * @param string $format - * @param bool $showTime - * @return string - */ - public function formatDate($date = null, $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, $showTime = false) - { - return $this->helper('Mage_Core_Helper_Data')->formatDate($date, $format, $showTime); - } - - /** - * Retrieve formatting time - * - * @param string $time - * @param string $format - * @param bool $showDate - * @return string - */ - public function formatTime($time = null, $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, $showDate = false) - { - return $this->helper('Mage_Core_Helper_Data')->formatTime($time, $format, $showDate); - } - - /** - * Retrieve module name of block - * - * @return string - */ - public function getModuleName() - { - if (!$this->_getData('module_name')) { - $this->setData('module_name', self::extractModuleName(get_class($this))); - } - return $this->_getData('module_name'); - } - - /** - * Extract module name from specified block class name - * - * @param string $className - * @return string - */ - public static function extractModuleName($className) - { - return substr($className, 0, strpos($className, '_Block')); - } - - /** - * Translate block sentence - * - * @return string - * @SuppressWarnings(PHPMD.ShortMethodName) - */ - public function __() - { - $args = func_get_args(); - $expr = new Mage_Core_Model_Translate_Expr(array_shift($args), $this->getModuleName()); - array_unshift($args, $expr); - return $this->_translator->translate($args); - } - - /** - * Escape html entities - * - * @param string|array $data - * @param array $allowedTags - * @return string - */ - public function escapeHtml($data, $allowedTags = null) - { - return $this->helper('Mage_Core_Helper_Data')->escapeHtml($data, $allowedTags); - } - - /** - * Wrapper for standard strip_tags() function with extra functionality for html entities - * - * @param string $data - * @param string $allowableTags - * @param bool $allowHtmlEntities - * @return string - */ - public function stripTags($data, $allowableTags = null, $allowHtmlEntities = false) - { - return $this->helper('Mage_Core_Helper_Data')->stripTags($data, $allowableTags, $allowHtmlEntities); - } - - /** - * Escape html entities in url - * - * @param string $data - * @return string - */ - public function escapeUrl($data) - { - return $this->helper('Mage_Core_Helper_Data')->escapeUrl($data); - } - - /** - * Escape quotes inside html attributes - * Use $addSlashes = false for escaping js that inside html attribute (onClick, onSubmit etc) - * - * @param string $data - * @param bool $addSlashes - * @return string - */ - public function quoteEscape($data, $addSlashes = false) - { - return $this->helper('Mage_Core_Helper_Data')->quoteEscape($data, $addSlashes); - } - - /** - * Escape quotes in java scripts - * - * @param mixed $data - * @param string $quote - * @return mixed - */ - public function jsQuoteEscape($data, $quote = '\'') - { - return $this->helper('Mage_Core_Helper_Data')->jsQuoteEscape($data, $quote); - } - - /** - * Get block name - * - * @return string - */ - public function getNameInLayout() - { - return $this->_nameInLayout; - } - - /** - * Prepare url for save to cache - * - * @return Mage_Core_Block_Abstract - */ - protected function _beforeCacheUrl() - { - if ($this->_cache->canUse(self::CACHE_GROUP)) { - Mage::app()->setUseSessionVar(true); - } - return $this; - } - - /** - * Replace URLs from cache - * - * @param string $html - * @return string - */ - protected function _afterCacheUrl($html) - { - if ($this->_cache->canUse(self::CACHE_GROUP)) { - Mage::app()->setUseSessionVar(false); - Magento_Profiler::start('CACHE_URL'); - $html = $this->_urlBuilder->sessionUrlVar($html); - Magento_Profiler::stop('CACHE_URL'); - } - return $html; - } - - /** - * Get cache key informative items - * Provide string array key to share specific info item with FPC placeholder - * - * @return array - */ - public function getCacheKeyInfo() - { - return array( - $this->getNameInLayout() - ); - } - - /** - * Get Key for caching block content - * - * @return string - */ - public function getCacheKey() - { - if ($this->hasData('cache_key')) { - return $this->getData('cache_key'); - } - /** - * don't prevent recalculation by saving generated cache key - * because of ability to render single block instance with different data - */ - $key = $this->getCacheKeyInfo(); - //ksort($key); // ignore order - $key = array_values($key); // ignore array keys - $key = implode('|', $key); - $key = sha1($key); - return $key; - } - - /** - * Get tags array for saving cache - * - * @return array - */ - public function getCacheTags() - { - if (!$this->hasData('cache_tags')) { - $tags = array(); - } else { - $tags = $this->getData('cache_tags'); - } - $tags[] = self::CACHE_GROUP; - return $tags; - } - - /** - * Get block cache life time - * - * @return int - */ - public function getCacheLifetime() - { - if (!$this->hasData('cache_lifetime')) { - return null; - } - return $this->getData('cache_lifetime'); - } - - /** - * Load block html from cache storage - * - * @return string | false - */ - protected function _loadCache() - { - if (is_null($this->getCacheLifetime()) || !$this->_cache->canUse(self::CACHE_GROUP)) { - return false; - } - $cacheKey = $this->getCacheKey(); - $cacheData = $this->_cache->load($cacheKey); - if ($cacheData) { - $cacheData = str_replace( - $this->_getSidPlaceholder($cacheKey), - $this->_session->getSessionIdQueryParam() . '=' . $this->_session->getEncryptedSessionId(), - $cacheData - ); - } - return $cacheData; - } - - /** - * Save block content to cache storage - * - * @param string $data - * @return Mage_Core_Block_Abstract - */ - protected function _saveCache($data) - { - if (is_null($this->getCacheLifetime()) || !$this->_cache->canUse(self::CACHE_GROUP)) { - return false; - } - $cacheKey = $this->getCacheKey(); - $data = str_replace( - $this->_session->getSessionIdQueryParam() . '=' . $this->_session->getEncryptedSessionId(), - $this->_getSidPlaceholder($cacheKey), - $data - ); - - $this->_cache->save($data, $cacheKey, $this->getCacheTags(), $this->getCacheLifetime()); - return $this; - } - - /** - * Get SID placeholder for cache - * - * @param null|string $cacheKey - * @return string - */ - protected function _getSidPlaceholder($cacheKey = null) - { - if (is_null($cacheKey)) { - $cacheKey = $this->getCacheKey(); - } - - return ''; - } - - /** - * Get variable value from view configuration - * - * Module name can be omitted. If omitted, it will be determined automatically. - * - * @param string $name variable name - * @param string $module optional module name - * @return string|false - */ - public function getVar($name, $module = null) - { - $module = $module ?: $this->getModuleName(); - return $this->_designPackage->getViewConfig()->getVarValue($module, $name); - } -} diff --git a/app/code/core/Mage/Core/Block/Messages.php b/app/code/core/Mage/Core/Block/Messages.php deleted file mode 100644 index 9d339b8e0cf12..0000000000000 --- a/app/code/core/Mage/Core/Block/Messages.php +++ /dev/null @@ -1,343 +0,0 @@ - - */ -class Mage_Core_Block_Messages extends Mage_Core_Block_Template -{ - /** - * Messages collection - * - * @var Mage_Core_Model_Message_Collection - */ - protected $_messages; - - /** - * Store first level html tag name for messages html output - * - * @var string - */ - protected $_messagesFirstLevelTagName = 'ul'; - - /** - * Store second level html tag name for messages html output - * - * @var string - */ - protected $_messagesSecondLevelTagName = 'li'; - - /** - * Store content wrapper html tag name for messages html output - * - * @var string - */ - protected $_messagesContentWrapperTagName = 'span'; - - /** - * Flag which require message text escape - * - * @var bool - */ - protected $_escapeMessageFlag = false; - - /** - * Storage for used types of message storages - * - * @var array - */ - protected $_usedStorageTypes = array(); - - /** - * Grouped message types - * - * @var array - */ - protected $_messageTypes = array( - Mage_Core_Model_Message::ERROR, - Mage_Core_Model_Message::WARNING, - Mage_Core_Model_Message::NOTICE, - Mage_Core_Model_Message::SUCCESS - ); - - /** - * Preparing global layout - * - * @return Mage_Core_Block_Messages - */ - public function _prepareLayout() - { - $this->addStorageType(get_class($this->_session)); - $this->addMessages($this->_session->getMessages(true)); - parent::_prepareLayout(); - return $this; - } - - /** - * Set message escape flag - * - * @param bool $flag - * @return Mage_Core_Block_Messages - */ - public function setEscapeMessageFlag($flag) - { - $this->_escapeMessageFlag = $flag; - return $this; - } - - /** - * Set messages collection - * - * @param Mage_Core_Model_Message_Collection $messages - * @return Mage_Core_Block_Messages - */ - public function setMessages(Mage_Core_Model_Message_Collection $messages) - { - $this->_messages = $messages; - return $this; - } - - /** - * Add messages to display - * - * @param Mage_Core_Model_Message_Collection $messages - * @return Mage_Core_Block_Messages - */ - public function addMessages(Mage_Core_Model_Message_Collection $messages) - { - foreach ($messages->getItems() as $message) { - $this->getMessageCollection()->add($message); - } - return $this; - } - - /** - * Retrieve messages collection - * - * @return Mage_Core_Model_Message_Collection - */ - public function getMessageCollection() - { - if (!($this->_messages instanceof Mage_Core_Model_Message_Collection)) { - $this->_messages = Mage::getModel('Mage_Core_Model_Message_Collection'); - } - return $this->_messages; - } - - /** - * Adding new message to message collection - * - * @param Mage_Core_Model_Message_Abstract $message - * @return Mage_Core_Block_Messages - */ - public function addMessage(Mage_Core_Model_Message_Abstract $message) - { - $this->getMessageCollection()->add($message); - return $this; - } - - /** - * Adding new error message - * - * @param string $message - * @return Mage_Core_Block_Messages - */ - public function addError($message) - { - $this->addMessage(Mage::getSingleton('Mage_Core_Model_Message')->error($message)); - return $this; - } - - /** - * Adding new warning message - * - * @param string $message - * @return Mage_Core_Block_Messages - */ - public function addWarning($message) - { - $this->addMessage(Mage::getSingleton('Mage_Core_Model_Message')->warning($message)); - return $this; - } - - /** - * Adding new notice message - * - * @param string $message - * @return Mage_Core_Block_Messages - */ - public function addNotice($message) - { - $this->addMessage(Mage::getSingleton('Mage_Core_Model_Message')->notice($message)); - return $this; - } - - /** - * Adding new success message - * - * @param string $message - * @return Mage_Core_Block_Messages - */ - public function addSuccess($message) - { - $this->addMessage(Mage::getSingleton('Mage_Core_Model_Message')->success($message)); - return $this; - } - - /** - * Retrieve messages array by message type - * - * @param string $type - * @return array - */ - public function getMessages($type=null) - { - return $this->getMessageCollection()->getItems($type); - } - - /** - * Retrieve messages in HTML format - * - * @param string $type - * @return string - */ - public function getHtml($type = null) - { - $html = '<' . $this->_messagesFirstLevelTagName . ' id="admin_messages">'; - foreach ($this->getMessages($type) as $message) { - $html .= '<' . $this->_messagesSecondLevelTagName . ' class="' . $message->getType() . '-msg" ' - . $this->getUiId('message') . '>' - . $this->_escapeMessageFlag ? $this->escapeHtml($message->getText()) : $message->getText() - . '_messagesSecondLevelTagName . '>'; - } - $html .= '_messagesFirstLevelTagName . '>'; - return $html; - } - - /** - * Return grouped message types - * - * @return array - */ - protected function _getMessageTypes() - { - return $this->_messageTypes; - } - - /** - * Retrieve messages in HTML format grouped by type - * - * @return string - */ - public function getGroupedHtml() - { - $html = ''; - foreach ($this->_getMessageTypes() as $type) { - if ($messages = $this->getMessages($type)) { - if (!$html) { - $html .= '<' . $this->_messagesFirstLevelTagName . ' class="messages">'; - } - $html .= '<' . $this->_messagesSecondLevelTagName . ' class="' . $type . '-msg">'; - $html .= '<' . $this->_messagesFirstLevelTagName . '>'; - - foreach ($messages as $message) { - $html.= '<' . $this->_messagesSecondLevelTagName . '>'; - $html.= '<' . $this->_messagesContentWrapperTagName . $this->getUiId('message', $type) . '>'; - $html.= ($this->_escapeMessageFlag) ? $this->escapeHtml($message->getText()) : $message->getText(); - $html.= '_messagesContentWrapperTagName . '>'; - $html.= '_messagesSecondLevelTagName . '>'; - } - $html .= '_messagesFirstLevelTagName . '>'; - $html .= '_messagesSecondLevelTagName . '>'; - } - } - if ($html) { - $html .= '_messagesFirstLevelTagName . '>'; - } - return $html; - } - - /** - * Render block HTML - * - * @return string - */ - protected function _toHtml() - { - if ($this->getTemplate()) { - $html = parent::_toHtml(); - } else { - $html = $this->getGroupedHtml(); - } - return $html; - } - - /** - * Set messages first level html tag name for output messages as html - * - * @param string $tagName - */ - public function setMessagesFirstLevelTagName($tagName) - { - $this->_messagesFirstLevelTagName = $tagName; - } - - /** - * Set messages first level html tag name for output messages as html - * - * @param string $tagName - */ - 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 deleted file mode 100644 index e2539658faf2d..0000000000000 --- a/app/code/core/Mage/Core/Block/Template.php +++ /dev/null @@ -1,372 +0,0 @@ - - */ -class Mage_Core_Block_Template extends Mage_Core_Block_Abstract -{ - const XML_PATH_DEBUG_TEMPLATE_HINTS = 'dev/debug/template_hints'; - const XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS = 'dev/debug/template_hints_blocks'; - const XML_PATH_TEMPLATE_ALLOW_SYMLINK = 'dev/template/allow_symlink'; - - /** - * Assigned variables for view - * - * @var array - */ - protected $_viewVars = array(); - - protected $_baseUrl; - - protected $_jsUrl; - - /** - * Is allowed symlinks flag - * - * @var bool - */ - protected $_allowSymlinks = null; - - protected static $_showTemplateHints; - protected static $_showTemplateHintsBlocks; - - /** - * @var Mage_Core_Model_Dir - */ - protected $_dirs; - - /** - * @var Mage_Core_Model_Logger - */ - protected $_logger; - - /** - * @var Magento_Filesystem - */ - protected $_filesystem; - - /** - * Path to template file in theme. - * - * @var string - */ - protected $_template; - - /** - * Constructor - * @param Mage_Core_Controller_Request_Http $request - * @param Mage_Core_Model_Layout $layout - * @param Mage_Core_Model_Event_Manager $eventManager - * @param Mage_Core_Model_Url $urlBuilder - * @param Mage_Core_Model_Translate $translator - * @param Mage_Core_Model_Cache $cache - * @param Mage_Core_Model_Design_Package $designPackage - * @param Mage_Core_Model_Session_Abstract $session - * @param Mage_Core_Model_Store_Config $storeConfig - * @param Mage_Core_Controller_Varien_Front $frontController - * @param Mage_Core_Model_Factory_Helper $helperFactory - * @param Mage_Core_Model_Dir $dirs - * @param Mage_Core_Model_Logger $logger - * @param Magento_Filesystem $filesystem - * @param array $data - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) - */ - public function __construct( - Mage_Core_Controller_Request_Http $request, - Mage_Core_Model_Layout $layout, - Mage_Core_Model_Event_Manager $eventManager, - Mage_Core_Model_Url $urlBuilder, - Mage_Core_Model_Translate $translator, - Mage_Core_Model_Cache $cache, - Mage_Core_Model_Design_Package $designPackage, - Mage_Core_Model_Session_Abstract $session, - Mage_Core_Model_Store_Config $storeConfig, - Mage_Core_Controller_Varien_Front $frontController, - Mage_Core_Model_Factory_Helper $helperFactory, - Mage_Core_Model_Dir $dirs, - Mage_Core_Model_Logger $logger, - Magento_Filesystem $filesystem, - array $data = array() - ) { - $this->_dirs = $dirs; - $this->_logger = $logger; - $this->_filesystem = $filesystem; - parent::__construct($request, $layout, $eventManager, $urlBuilder, $translator, $cache, $designPackage, - $session, $storeConfig, $frontController, $helperFactory, $data); - } - - /** - * Internal constructor, that is called from real constructor - */ - protected function _construct() - { - parent::_construct(); - - /* - * In case template was passed through constructor - * we assign it to block's property _template - * Mainly for those cases when block created - * not via Mage_Core_Model_Layout::addBlock() - */ - if ($this->hasData('template')) { - $this->setTemplate($this->getData('template')); - } - } - - /** - * Get relevant path to template - * - * @return string - */ - public function getTemplate() - { - return $this->_template; - } - - /** - * Set path to template used for generating block's output. - * - * @param string $template - * @return Mage_Core_Block_Template - */ - public function setTemplate($template) - { - $this->_template = $template; - return $this; - } - - /** - * Get absolute path to template - * - * @return string - */ - public function getTemplateFile() - { - $params = array('module' => $this->getModuleName()); - $area = $this->getArea(); - if ($area) { - $params['area'] = $area; - } - $templateName = $this->_designPackage->getFilename($this->getTemplate(), $params); - return $templateName; - } - - /** - * Get design area - * @return string - */ - public function getArea() - { - $result = $this->_getData('area'); - if (!$result && $this->getLayout()) { - $result = $this->getLayout()->getArea(); - } - return $result; - } - - /** - * Assign variable - * - * @param string|array $key - * @param mixed $value - * @return Mage_Core_Block_Template - */ - public function assign($key, $value=null) - { - if (is_array($key)) { - foreach ($key as $k=>$v) { - $this->assign($k, $v); - } - } else { - $this->_viewVars[$key] = $value; - } - return $this; - } - - /** - * Check if direct output is allowed for block - * - * @return bool - */ - public function getDirectOutput() - { - if ($this->getLayout()) { - return $this->getLayout()->isDirectOutput(); - } - return false; - } - - public function getShowTemplateHints() - { - if (is_null(self::$_showTemplateHints)) { - self::$_showTemplateHints = Mage::getStoreConfig(self::XML_PATH_DEBUG_TEMPLATE_HINTS) - && Mage::helper('Mage_Core_Helper_Data')->isDevAllowed(); - self::$_showTemplateHintsBlocks = Mage::getStoreConfig(self::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS) - && Mage::helper('Mage_Core_Helper_Data')->isDevAllowed(); - } - return self::$_showTemplateHints; - } - - /** - * Retrieve block view from file (template) - * - * @param string $fileName - * @return string - * @throws Exception - */ - public function fetchView($fileName) - { - $viewShortPath = str_replace($this->_dirs->getDir(Mage_Core_Model_Dir::ROOT), '', $fileName); - Magento_Profiler::start('TEMPLATE:' . $fileName, array('group' => 'TEMPLATE', 'file_name' => $viewShortPath)); - - // EXTR_SKIP protects from overriding - // already defined variables - extract ($this->_viewVars, EXTR_SKIP); - $do = $this->getDirectOutput(); - - if (!$do) { - ob_start(); - } - if ($this->getShowTemplateHints()) { - echo << -
    {$fileName}
    -HTML; - if (self::$_showTemplateHintsBlocks) { - $thisClass = get_class($this); - echo <<{$thisClass}
    -HTML; - } - } - - try { - if ((Magento_Filesystem::isPathInDirectory($fileName, $this->_dirs->getDir(Mage_Core_Model_Dir::APP)) - || Magento_Filesystem::isPathInDirectory($fileName, $this->_dirs->getDir(Mage_Core_Model_Dir::THEMES)) - || $this->_getAllowSymlinks()) && $this->_filesystem->isFile($fileName) - ) { - include $fileName; - } else { - $this->_logger->log("Invalid template file: '{$fileName}'", Zend_Log::CRIT); - } - - } catch (Exception $e) { - if (!$do) { - ob_get_clean(); - } - throw $e; - } - - if ($this->getShowTemplateHints()) { - echo '
    '; - } - - if (!$do) { - $html = ob_get_clean(); - } else { - $html = ''; - } - Magento_Profiler::stop('TEMPLATE:' . $fileName); - return $html; - } - - /** - * Render block HTML - * - * @return string - */ - protected function _toHtml() - { - if (!$this->getTemplate()) { - return ''; - } - return $this->fetchView($this->getTemplateFile()); - } - - /** - * Get base url of the application - * - * @return string - */ - public function getBaseUrl() - { - if (!$this->_baseUrl) { - $this->_baseUrl = $this->_urlBuilder->getBaseUrl(); - } - return $this->_baseUrl; - } - - /** - * Get data from specified object - * - * @param Varien_Object $object - * @param string $key - * @return mixed - */ - public function getObjectData(Varien_Object $object, $key) - { - return $object->getDataUsingMethod((string)$key); - } - - /** - * Get cache key informative items - * - * @return array - */ - public function getCacheKeyInfo() - { - return array( - 'BLOCK_TPL', - Mage::app()->getStore()->getCode(), - $this->getTemplateFile(), - 'template' => $this->getTemplate() - ); - } - - /** - * Get is allowed symliks flag - * - * @return bool - */ - protected function _getAllowSymlinks() - { - if (is_null($this->_allowSymlinks)) { - $this->_allowSymlinks = $this->_storeConfig->getConfigFlag(self::XML_PATH_TEMPLATE_ALLOW_SYMLINK); - } - return $this->_allowSymlinks; - } -} diff --git a/app/code/core/Mage/Core/Controller/Response/Http.php b/app/code/core/Mage/Core/Controller/Response/Http.php deleted file mode 100644 index 00d323b8999f7..0000000000000 --- a/app/code/core/Mage/Core/Controller/Response/Http.php +++ /dev/null @@ -1,107 +0,0 @@ - - */ -class Mage_Core_Controller_Response_Http extends Zend_Controller_Response_Http -{ - /** - * Transport object for observers to perform - * - * @var Varien_Object - */ - protected static $_transportObject = null; - - /** - * Fixes CGI only one Status header allowed bug - * - * @link http://bugs.php.net/bug.php?id=36705 - * - * @return Mage_Core_Controller_Response_Http - */ - public function sendHeaders() - { - if (!$this->canSendHeaders()) { - Mage::log('HEADERS ALREADY SENT: '.mageDebugBacktrace(true, true, true)); - return $this; - } - - if (substr(php_sapi_name(), 0, 3) == 'cgi') { - $statusSent = false; - foreach ($this->_headersRaw as $i=>$header) { - if (stripos($header, 'status:')===0) { - if ($statusSent) { - unset($this->_headersRaw[$i]); - } else { - $statusSent = true; - } - } - } - foreach ($this->_headers as $i=>$header) { - if (strcasecmp($header['name'], 'status')===0) { - if ($statusSent) { - unset($this->_headers[$i]); - } else { - $statusSent = true; - } - } - } - } - return parent::sendHeaders(); - } - - public function sendResponse() - { - return parent::sendResponse(); - } - - /** - * Additionally check for session messages in several domains case - * - * @param string $url - * @param int $code - * @return Mage_Core_Controller_Response_Http - */ - public function setRedirect($url, $code = 302) - { - /** - * Use single transport object instance - */ - if (self::$_transportObject === null) { - self::$_transportObject = new Varien_Object; - } - self::$_transportObject->setUrl($url); - self::$_transportObject->setCode($code); - Mage::dispatchEvent('controller_response_redirect', - array('response' => $this, 'transport' => self::$_transportObject)); - - return parent::setRedirect(self::$_transportObject->getUrl(), self::$_transportObject->getCode()); - } -} diff --git a/app/code/core/Mage/Core/Controller/Varien/Action.php b/app/code/core/Mage/Core/Controller/Varien/Action.php deleted file mode 100755 index 12714ed595faf..0000000000000 --- a/app/code/core/Mage/Core/Controller/Varien/Action.php +++ /dev/null @@ -1,1159 +0,0 @@ - - */ -abstract class Mage_Core_Controller_Varien_Action extends Mage_Core_Controller_Varien_ActionAbstract -{ - const FLAG_NO_CHECK_INSTALLATION = 'no-install-check'; - const FLAG_NO_DISPATCH = 'no-dispatch'; - const FLAG_NO_PRE_DISPATCH = 'no-preDispatch'; - const FLAG_NO_POST_DISPATCH = 'no-postDispatch'; - const FLAG_NO_START_SESSION = 'no-startSession'; - const FLAG_NO_DISPATCH_BLOCK_EVENT = 'no-beforeGenerateLayoutBlocksDispatch'; - const FLAG_NO_COOKIES_REDIRECT = 'no-cookies-redirect'; - - const PARAM_NAME_SUCCESS_URL = 'success_url'; - const PARAM_NAME_ERROR_URL = 'error_url'; - const PARAM_NAME_REFERER_URL = 'referer_url'; - const PARAM_NAME_BASE64_URL = 'r64'; - const PARAM_NAME_URL_ENCODED = 'uenc'; - - const XML_PAGE_TYPE_RENDER_INHERITED = 'global/dev/page_type/render_inherited'; - - /** - * @var Mage_Core_Controller_Request_Http - */ - protected $_request; - - /** - * @var Mage_Core_Controller_Response_Http - */ - protected $_response; - - /** - * @var Magento_ObjectManager - */ - protected $_objectManager; - - /** - * Real module name (like 'Mage_Module') - * - * @var string - */ - protected $_realModuleName; - - /** - * Action flags - * - * for example used to disable rendering default layout - * - * @var array - */ - protected $_flags = array(); - - /** - * Action list where need check enabled cookie - * - * @var array - */ - protected $_cookieCheckActions = array(); - - /** - * Currently used area - * - * @var string - */ - protected $_currentArea; - - /** - * Namespace for session. - * Should be defined for proper working session. - * - * @var string - */ - protected $_sessionNamespace; - - /** - * Whether layout is loaded - * - * @see self::loadLayout() - * @var bool - */ - protected $_isLayoutLoaded = false; - - /** - * Title parts to be rendered in the page head title - * - * @see self::_title() - * @var array - */ - protected $_titles = array(); - - /** - * Whether the default title should be removed - * - * @see self::_title() - * @var bool - */ - protected $_removeDefaultTitle = false; - - /** - * @var Mage_Core_Controller_Varien_Front - */ - protected $_frontController = null; - - /** - * @var Mage_Core_Model_Layout_Factory - */ - protected $_layoutFactory; - - /** - * Constructor - * - * @param Mage_Core_Controller_Request_Http $request - * @param Mage_Core_Controller_Response_Http $response - * @param Magento_ObjectManager $objectManager - * @param Mage_Core_Controller_Varien_Front $frontController - * @param Mage_Core_Model_Layout_Factory $layoutFactory - * @param string $areaCode - */ - public function __construct( - Mage_Core_Controller_Request_Http $request, - Mage_Core_Controller_Response_Http $response, - Magento_ObjectManager $objectManager, - Mage_Core_Controller_Varien_Front $frontController, - Mage_Core_Model_Layout_Factory $layoutFactory, - $areaCode = null - ) { - parent::__construct($request, $response, $areaCode); - - $this->_objectManager = $objectManager; - $this->_frontController = $frontController; - $this->_layoutFactory = $layoutFactory; - $this->_frontController->setAction($this); - - $this->_construct(); - } - - protected function _construct() - { - } - - /** - * Set currently used area code - * @param string $areaCode - * @return Mage_Core_Controller_Varien_Action - */ - public function setCurrentArea($areaCode) - { - Mage::getConfig()->setCurrentAreaCode($areaCode); - $this->_currentArea = $areaCode; - return $this; - } - - public function hasAction($action) - { - return method_exists($this, $this->getActionMethodName($action)); - } - - /** - * Retrieve flag value - * - * @param string $action - * @param string $flag - * @return bool - */ - public function getFlag($action, $flag = '') - { - if ('' === $action) { - $action = $this->getRequest()->getActionName(); - } - if ('' === $flag) { - return $this->_flags; - } elseif (isset($this->_flags[$action][$flag])) { - return $this->_flags[$action][$flag]; - } else { - return false; - } - } - - /** - * Setting flag value - * - * @param string $action - * @param string $flag - * @param string $value - * @return Mage_Core_Controller_Varien_Action - */ - public function setFlag($action, $flag, $value) - { - if ('' === $action) { - $action = $this->getRequest()->getActionName(); - } - $this->_flags[$action][$flag] = $value; - return $this; - } - - /** - * Retrieve current layout object - * - * @return Mage_Core_Model_Layout - */ - public function getLayout() - { - return $this->_layoutFactory->createLayout(array('area' => $this->_currentArea)); - } - - /** - * Load layout by handles(s) - * - * @param string|null|bool $handles - * @param bool $generateBlocks - * @param bool $generateXml - * @return Mage_Core_Controller_Varien_Action - */ - public function loadLayout($handles = null, $generateBlocks = true, $generateXml = true) - { - // if handles were specified in arguments load them first - if (false !== $handles && '' !== $handles) { - $this->getLayout()->getUpdate()->addHandle($handles ? $handles : 'default'); - } - - // add default layout handles for this action - $this->addActionLayoutHandles(); - - $this->loadLayoutUpdates(); - - if (!$generateXml) { - return $this; - } - $this->generateLayoutXml(); - - if (!$generateBlocks) { - return $this; - } - $this->generateLayoutBlocks(); - $this->_isLayoutLoaded = true; - - return $this; - } - - /** - * Retrieve the default layout handle name for the current action - * - * @return string - */ - public function getDefaultLayoutHandle() - { - return strtolower($this->getFullActionName()); - } - - /** - * Add layout handle by full controller action name - * - * @return Mage_Core_Controller_Varien_Action - */ - public function addActionLayoutHandles() - { - $renderInherited = (string) Mage::app()->getConfig()->getNode(self::XML_PAGE_TYPE_RENDER_INHERITED); - if (!$renderInherited || !$this->addPageLayoutHandles()) { - $this->getLayout()->getUpdate()->addHandle($this->getDefaultLayoutHandle()); - } - return $this; - } - - /** - * Add layout updates handles associated with the action page - * - * @param array $parameters page parameters - * @return bool - */ - public function addPageLayoutHandles(array $parameters = array()) - { - $handle = $this->getDefaultLayoutHandle(); - $pageHandles = array($handle); - foreach ($parameters as $key => $value) { - $pageHandles[] = $handle . '_' . $key . '_' . $value; - } - return $this->getLayout()->getUpdate()->addPageHandles(array_reverse($pageHandles)); - } - - public function loadLayoutUpdates() - { - Magento_Profiler::start('LAYOUT'); - - // dispatch event for adding handles to layout update - Mage::dispatchEvent( - 'controller_action_layout_load_before', - array('action' => $this, 'layout' => $this->getLayout()) - ); - - // load layout updates by specified handles - Magento_Profiler::start('layout_load'); - $this->getLayout()->getUpdate()->load(); - Magento_Profiler::stop('layout_load'); - - Magento_Profiler::stop('LAYOUT'); - return $this; - } - - public function generateLayoutXml() - { - Magento_Profiler::start('LAYOUT'); - - // dispatch event for adding text layouts - if (!$this->getFlag('', self::FLAG_NO_DISPATCH_BLOCK_EVENT)) { - Mage::dispatchEvent( - 'controller_action_layout_generate_xml_before', - array('action' => $this, 'layout' => $this->getLayout()) - ); - } - - // generate xml from collected text updates - Magento_Profiler::start('layout_generate_xml'); - $this->getLayout()->generateXml(); - Magento_Profiler::stop('layout_generate_xml'); - - Magento_Profiler::stop('LAYOUT'); - return $this; - } - - public function generateLayoutBlocks() - { - Magento_Profiler::start('LAYOUT'); - - // dispatch event for adding xml layout elements - if(!$this->getFlag('', self::FLAG_NO_DISPATCH_BLOCK_EVENT)) { - Mage::dispatchEvent( - 'controller_action_layout_generate_blocks_before', - array('action' => $this, 'layout' => $this->getLayout()) - ); - } - - // generate blocks from xml layout - Magento_Profiler::start('layout_generate_blocks'); - $this->getLayout()->generateElements(); - Magento_Profiler::stop('layout_generate_blocks'); - - if (!$this->getFlag('', self::FLAG_NO_DISPATCH_BLOCK_EVENT)) { - Mage::dispatchEvent( - 'controller_action_layout_generate_blocks_after', - array('action' => $this, 'layout' => $this->getLayout()) - ); - } - - Magento_Profiler::stop('LAYOUT'); - return $this; - } - - /** - * Rendering layout - * - * @param string $output - * @return Mage_Core_Controller_Varien_Action - */ - public function renderLayout($output = '') - { - if ($this->getFlag('', 'no-renderLayout')) { - return; - } - - if ($this->_frontController->getNoRender()) { - return; - } - - Magento_Profiler::start('LAYOUT'); - - $this->_renderTitles(); - - Magento_Profiler::start('layout_render'); - - if ('' !== $output) { - $this->getLayout()->addOutputElement($output); - } - - Mage::dispatchEvent('controller_action_layout_render_before'); - Mage::dispatchEvent('controller_action_layout_render_before_' . $this->getFullActionName()); - - $this->getLayout()->setDirectOutput(false); - - $output = $this->getLayout()->getOutput(); - Mage::getSingleton('Mage_Core_Model_Translate_Inline')->processResponseBody($output); - $this->getResponse()->appendBody($output); - Magento_Profiler::stop('layout_render'); - - Magento_Profiler::stop('LAYOUT'); - return $this; - } - - public function dispatch($action) - { - $this->getRequest()->setDispatched(true); - try { - $actionMethodName = $this->getActionMethodName($action); - if (!method_exists($this, $actionMethodName)) { - $actionMethodName = 'norouteAction'; - } - - $profilerKey = 'CONTROLLER_ACTION:' . $this->getFullActionName(); - Magento_Profiler::start($profilerKey); - - Mage::getConfig()->setCurrentAreaCode($this->_currentArea); - - Magento_Profiler::start('predispatch'); - $this->preDispatch(); - Magento_Profiler::stop('predispatch'); - - if ($this->getRequest()->isDispatched()) { - /** - * preDispatch() didn't change the action, so we can continue - */ - if (!$this->getFlag('', self::FLAG_NO_DISPATCH)) { - Magento_Profiler::start('action_body'); - $this->$actionMethodName(); - Magento_Profiler::stop('action_body'); - - Magento_Profiler::start('postdispatch'); - $this->postDispatch(); - Magento_Profiler::stop('postdispatch'); - } - } - - Magento_Profiler::stop($profilerKey); - } catch (Mage_Core_Controller_Varien_Exception $e) { - // set prepared flags - foreach ($e->getResultFlags() as $flagData) { - list($action, $flag, $value) = $flagData; - $this->setFlag($action, $flag, $value); - } - // call forward, redirect or an action - list($method, $parameters) = $e->getResultCallback(); - switch ($method) { - case Mage_Core_Controller_Varien_Exception::RESULT_REDIRECT: - list($path, $arguments) = $parameters; - $this->_redirect($path, $arguments); - break; - case Mage_Core_Controller_Varien_Exception::RESULT_FORWARD: - list($action, $controller, $module, $params) = $parameters; - $this->_forward($action, $controller, $module, $params); - break; - default: - $actionMethodName = $this->getActionMethodName($method); - $this->getRequest()->setActionName($method); - $this->$actionMethodName($method); - break; - } - } - } - - /** - * Retrieve action method name - * - * @param string $action - * @return string - */ - public function getActionMethodName($action) - { - return $action . 'Action'; - } - - /** - * Start session if it is not restricted - * - * @return Mage_Core_Controller_Varien_Action - */ - protected function _startSession() - { - if (!$this->getFlag('', self::FLAG_NO_START_SESSION)) { - $checkCookie = in_array($this->getRequest()->getActionName(), $this->_cookieCheckActions) - && !$this->getRequest()->getParam('nocookie', false); - $cookies = Mage::getSingleton('Mage_Core_Model_Cookie')->get(); - /** @var $session Mage_Core_Model_Session */ - $session = Mage::getSingleton('Mage_Core_Model_Session', - array('data' => array('name' => $this->_sessionNamespace))) - ->start(); - - if (empty($cookies)) { - if ($session->getCookieShouldBeReceived()) { - $this->setFlag('', self::FLAG_NO_COOKIES_REDIRECT, true); - $session->unsCookieShouldBeReceived(); - $session->setSkipSessionIdFlag(true); - } elseif ($checkCookie) { - if (isset($_GET[$session->getSessionIdQueryParam()]) && Mage::app()->getUseSessionInUrl() - && $this->_sessionNamespace != Mage_Backend_Controller_ActionAbstract::SESSION_NAMESPACE - ) { - $session->setCookieShouldBeReceived(true); - } else { - $this->setFlag('', self::FLAG_NO_COOKIES_REDIRECT, true); - } - } - } - } - return $this; - } - - /** - * Initialize area and design - * - * @return Mage_Core_Controller_Varien_Action - */ - protected function _initDesign() - { - $area = Mage::app()->getArea($this->getLayout()->getArea()); - $area->load(); - $area->detectDesign($this->getRequest()); - return $this; - } - - /** - * Dispatch event before action - * - * @return null - */ - public function preDispatch() - { - if (!$this->getFlag('', self::FLAG_NO_CHECK_INSTALLATION)) { - if (!Mage::isInstalled()) { - $this->setFlag('', self::FLAG_NO_DISPATCH, true); - $this->_redirect('install'); - return; - } - } - - // Prohibit disabled store actions - if (Mage::isInstalled() && !Mage::app()->getStore()->getIsActive()) { - Mage::app()->throwStoreException(); - } - - if ($this->_rewrite()) { - return; - } - - // Start session - $this->_startSession(); - - // Load area and initialize design depend on loaded area - $this->_initDesign(); - - if ($this->getFlag('', self::FLAG_NO_COOKIES_REDIRECT) - && Mage::getStoreConfig('web/browser_capabilities/cookies') - ) { - $this->_forward('noCookies', 'index', 'core'); - return; - } - - if ($this->getFlag('', self::FLAG_NO_PRE_DISPATCH)) { - return; - } - - $this->_firePreDispatchEvents(); - } - - /** - * Fire predispatch events, execute extra logic after predispatch - */ - protected function _firePreDispatchEvents() - { - Mage::dispatchEvent('controller_action_predispatch', array('controller_action' => $this)); - Mage::dispatchEvent('controller_action_predispatch_' . $this->getRequest()->getRouteName(), - array('controller_action' => $this)); - Mage::dispatchEvent('controller_action_predispatch_' . $this->getFullActionName(), - array('controller_action' => $this)); - } - - /** - * Dispatches event after action - */ - public function postDispatch() - { - if ($this->getFlag('', self::FLAG_NO_POST_DISPATCH)) { - return; - } - - Mage::dispatchEvent( - 'controller_action_postdispatch_' . $this->getFullActionName(), - array('controller_action' => $this) - ); - Mage::dispatchEvent( - 'controller_action_postdispatch_' . $this->getRequest()->getRouteName(), - array('controller_action' => $this) - ); - Mage::dispatchEvent('controller_action_postdispatch', array('controller_action' => $this)); - } - - public function norouteAction($coreRoute = null) - { - $status = $this->getRequest()->getParam('__status__'); - if (!$status instanceof Varien_Object) { - $status = new Varien_Object(); - } - - Mage::dispatchEvent('controller_action_noroute', array('action' => $this, 'status' => $status)); - - if ($status->getLoaded() !== true - || $status->getForwarded() === true - || !is_null($coreRoute) - ) { - $this->loadLayout(array('default', 'noRoute')); - $this->renderLayout(); - } else { - $status->setForwarded(true); - $this->_forward( - $status->getForwardAction(), - $status->getForwardController(), - $status->getForwardModule(), - array('__status__' => $status)); - } - } - - public function noCookiesAction() - { - $redirect = new Varien_Object(); - Mage::dispatchEvent('controller_action_nocookies', array( - 'action' => $this, - 'redirect' => $redirect - )); - - if ($url = $redirect->getRedirectUrl()) { - $this->_redirectUrl($url); - } elseif ($redirect->getRedirect()) { - $this->_redirect($redirect->getPath(), $redirect->getArguments()); - } else { - $this->loadLayout(array('default', 'noCookie')); - $this->renderLayout(); - } - - $this->getRequest()->setDispatched(true); - } - - /** - * Throw control to different action (control and module if was specified). - * - * @param string $action - * @param string|null $controller - * @param string|null $module - * @param array|null $params - */ - protected function _forward($action, $controller = null, $module = null, array $params = null) - { - $request = $this->getRequest(); - - $request->initForward(); - - if (isset($params)) { - $request->setParams($params); - } - - if (isset($controller)) { - $request->setControllerName($controller); - - // Module should only be reset if controller has been specified - if (isset($module)) { - $request->setModuleName($module); - } - } - - $request->setActionName($action) - ->setDispatched(false); - } - - /** - * Initializing layout messages by message storage(s), loading and adding messages to layout messages block - * - * @param string|array $messagesStorage - * @return Mage_Core_Controller_Varien_Action - */ - protected function _initLayoutMessages($messagesStorage) - { - if (!is_array($messagesStorage)) { - $messagesStorage = array($messagesStorage); - } - foreach ($messagesStorage as $storageName) { - $storage = Mage::getSingleton($storageName); - if ($storage) { - $block = $this->getLayout()->getMessagesBlock(); - $block->addMessages($storage->getMessages(true)); - $block->setEscapeMessageFlag($storage->getEscapeMessages(true)); - $block->addStorageType($storageName); - } else { - Mage::throwException( - Mage::helper('Mage_Core_Helper_Data')->__('Invalid messages storage "%s" for layout messages initialization', (string)$storageName) - ); - } - } - return $this; - } - - /** - * Initializing layout messages by message storage(s), loading and adding messages to layout messages block - * - * @param string|array $messagesStorage - * @return Mage_Core_Controller_Varien_Action - */ - public function initLayoutMessages($messagesStorage) - { - return $this->_initLayoutMessages($messagesStorage); - } - - /** - * Set redirect url into response - * - * @param string $url - * @return Mage_Core_Controller_Varien_Action - */ - protected function _redirectUrl($url) - { - $this->getResponse()->setRedirect($url); - return $this; - } - - /** - * Set redirect into response - * - * @param string $path - * @param array $arguments - * @return Mage_Core_Controller_Varien_Action - */ - protected function _redirect($path, $arguments = array()) - { - return $this->setRedirectWithCookieCheck($path, $arguments); - } - - /** - * Set redirect into response with session id in URL if it is enabled. - * It allows to distinguish primordial request from browser with cookies disabled. - * - * @param string $path - * @param array $arguments - * @return Mage_Core_Controller_Varien_Action - */ - public function setRedirectWithCookieCheck($path, array $arguments = array()) - { - /** @var $session Mage_Core_Model_Session */ - $session = Mage::getSingleton('Mage_Core_Model_Session', - array('data' => array('name' => $this->_sessionNamespace))); - if ($session->getCookieShouldBeReceived() && Mage::app()->getUseSessionInUrl() - && $this->_sessionNamespace != Mage_Backend_Controller_ActionAbstract::SESSION_NAMESPACE - ) { - $arguments += array('_query' => array( - $session->getSessionIdQueryParam() => $session->getSessionId() - )); - } - $this->getResponse()->setRedirect(Mage::getUrl($path, $arguments)); - return $this; - } - - - /** - * Redirect to success page - * - * @param string $defaultUrl - * @return Mage_Core_Controller_Varien_Action - */ - protected function _redirectSuccess($defaultUrl) - { - $successUrl = $this->getRequest()->getParam(self::PARAM_NAME_SUCCESS_URL); - if (empty($successUrl)) { - $successUrl = $defaultUrl; - } - if (!$this->_isUrlInternal($successUrl)) { - $successUrl = Mage::app()->getStore()->getBaseUrl(); - } - $this->getResponse()->setRedirect($successUrl); - return $this; - } - - /** - * Redirect to error page - * - * @param string $defaultUrl - * @return Mage_Core_Controller_Varien_Action - */ - protected function _redirectError($defaultUrl) - { - $errorUrl = $this->getRequest()->getParam(self::PARAM_NAME_ERROR_URL); - if (empty($errorUrl)) { - $errorUrl = $defaultUrl; - } - if (!$this->_isUrlInternal($errorUrl)) { - $errorUrl = Mage::app()->getStore()->getBaseUrl(); - } - $this->getResponse()->setRedirect($errorUrl); - return $this; - } - - /** - * Set referer url for redirect in response - * - * @param string $defaultUrl - * @return Mage_Core_Controller_Varien_Action - */ - protected function _redirectReferer($defaultUrl=null) - { - - $refererUrl = $this->_getRefererUrl(); - if (empty($refererUrl)) { - $refererUrl = empty($defaultUrl) ? Mage::getBaseUrl() : $defaultUrl; - } - - $this->getResponse()->setRedirect($refererUrl); - return $this; - } - - /** - * Identify referer url via all accepted methods (HTTP_REFERER, regular or base64-encoded request param) - * - * @return string - */ - protected function _getRefererUrl() - { - $refererUrl = $this->getRequest()->getServer('HTTP_REFERER'); - $url = $this->getRequest()->getParam(self::PARAM_NAME_REFERER_URL); - if ($url) { - $refererUrl = $url; - } - $url = $this->getRequest()->getParam(self::PARAM_NAME_BASE64_URL); - if ($url) { - $refererUrl = Mage::helper('Mage_Core_Helper_Data')->urlDecode($url); - } - $url = $this->getRequest()->getParam(self::PARAM_NAME_URL_ENCODED); - if ($url) { - $refererUrl = Mage::helper('Mage_Core_Helper_Data')->urlDecode($url); - } - - if (!$this->_isUrlInternal($refererUrl)) { - $refererUrl = Mage::app()->getStore()->getBaseUrl(); - } - return $refererUrl; - } - - /** - * Check url to be used as internal - * - * @param string $url - * @return bool - */ - protected function _isUrlInternal($url) - { - if (strpos($url, 'http') !== false) { - /** - * Url must start from base secure or base unsecure url - */ - if ((strpos($url, Mage::app()->getStore()->getBaseUrl()) === 0) - || (strpos($url, Mage::app()->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true)) === 0) - ) { - return true; - } - } - return false; - } - - /** - * Get real module name (like 'Mage_Module') - * - * @return string - */ - protected function _getRealModuleName() - { - if (empty($this->_realModuleName)) { - $class = get_class($this); - $this->_realModuleName = substr( - $class, - 0, - strpos(strtolower($class), '_' . strtolower($this->getRequest()->getControllerName() . 'Controller')) - ); - } - return $this->_realModuleName; - } - - /** - * Support for controllers rewrites - * - * Example of configuration: - * - * - * - * - * - * new_route/new_controller - * true - * - * new_module/new_controller/new_action - * - * - * - * - * - * - * - * This will override: - * 1. core_module/core_controller/core_action to new_module/new_controller/new_action - * 2. all other actions of core_module/core_controller to new_module/new_controller - * - * @return boolean true if rewrite happened - */ - protected function _rewrite() - { - $route = $this->getRequest()->getRouteName(); - $controller = $this->getRequest()->getControllerName(); - $action = $this->getRequest()->getActionName(); - - $rewrite = Mage::getConfig()->getNode('global/routers/' . $route . '/rewrite/' . $controller); - if (!$rewrite) { - return false; - } - - if (!($rewrite->actions && $rewrite->actions->$action) || $rewrite->is('override_actions')) { - $t = explode('/', (string)$rewrite->to); - if (sizeof($t) !== 2 || empty($t[0]) || empty($t[1])) { - return false; - } - $t[2] = $action; - } else { - $t = explode('/', (string)$rewrite->actions->$action->to); - if (sizeof($t) !== 3 || empty($t[0]) || empty($t[1]) || empty($t[2])) { - return false; - } - } - - $this->_forward( - $t[2] === '*' ? $action : $t[2], - $t[1] === '*' ? $controller : $t[1], - $t[0] === '*' ? $route : $t[0] - ); - - return true; - } - - /** - * Validate Form Key - * - * @return bool - */ - protected function _validateFormKey() - { - if (!($formKey = $this->getRequest()->getParam('form_key', null)) - || $formKey != Mage::getSingleton('Mage_Core_Model_Session')->getFormKey() - ) { - return false; - } - return true; - } - - /** - * Add an extra title to the end or one from the end, or remove all - * - * Usage examples: - * $this->_title('foo')->_title('bar'); - * => bar / foo / - * - * $this->_title()->_title('foo')->_title('bar'); - * => bar / foo - * - * $this->_title('foo')->_title(false)->_title('bar'); - * bar / - * - * @see self::_renderTitles() - * @param string|false|-1|null $text - * @param bool $resetIfExists - * @return Mage_Core_Controller_Varien_Action - */ - protected function _title($text = null, $resetIfExists = true) - { - if (is_string($text)) { - $this->_titles[] = $text; - } elseif (-1 === $text) { - if (empty($this->_titles)) { - $this->_removeDefaultTitle = true; - } else { - array_pop($this->_titles); - } - } elseif (empty($this->_titles) || $resetIfExists) { - if (false === $text) { - $this->_removeDefaultTitle = false; - $this->_titles = array(); - } elseif (null === $text) { - $this->_removeDefaultTitle = true; - $this->_titles = array(); - } - } - return $this; - } - - /** - * Prepare titles in the 'head' layout block - * Supposed to work only in actions where layout is rendered - * Falls back to the default logic if there are no titles eventually - * - * @see self::loadLayout() - * @see self::renderLayout() - */ - protected function _renderTitles() - { - if ($this->_isLayoutLoaded && $this->_titles) { - $titleBlock = $this->getLayout()->getBlock('head'); - if ($titleBlock) { - if (!$this->_removeDefaultTitle) { - $title = trim($titleBlock->getTitle()); - if ($title) { - array_unshift($this->_titles, $title); - } - } - $titleBlock->setTitle(array_reverse($this->_titles)); - } - } - } - - /** - * Convert dates in array from localized to internal format - * - * @param array $array - * @param array $dateFields - * @return array - */ - protected function _filterDates($array, $dateFields) - { - if (empty($dateFields)) { - return $array; - } - $filterInput = new Zend_Filter_LocalizedToNormalized(array( - 'date_format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) - )); - $filterInternal = new Zend_Filter_NormalizedToLocalized(array( - 'date_format' => Varien_Date::DATE_INTERNAL_FORMAT - )); - - foreach ($dateFields as $dateField) { - if (array_key_exists($dateField, $array) && !empty($dateField)) { - $array[$dateField] = $filterInput->filter($array[$dateField]); - $array[$dateField] = $filterInternal->filter($array[$dateField]); - } - } - return $array; - } - - /** - * Convert dates with time in array from localized to internal format - * - * @param array $array - * @param array $dateFields - * @return array - */ - protected function _filterDateTime($array, $dateFields) - { - if (empty($dateFields)) { - return $array; - } - $filterInput = new Zend_Filter_LocalizedToNormalized(array( - 'date_format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) - )); - $filterInternal = new Zend_Filter_NormalizedToLocalized(array( - 'date_format' => Varien_Date::DATETIME_INTERNAL_FORMAT - )); - - foreach ($dateFields as $dateField) { - if (array_key_exists($dateField, $array) && !empty($dateField)) { - $array[$dateField] = $filterInput->filter($array[$dateField]); - $array[$dateField] = $filterInternal->filter($array[$dateField]); - } - } - return $array; - } - - /** - * Declare headers and content file in response for file download - * - * @param string $fileName - * @param string|array $content set to null to avoid starting output, $contentLength should be set explicitly in - * that case - * @param string $contentType - * @param int $contentLength explicit content length, if strlen($content) isn't applicable - * @return Mage_Core_Controller_Varien_Action - */ - protected function _prepareDownloadResponse( - $fileName, - $content, - $contentType = 'application/octet-stream', - $contentLength = null) - { - /** @var Magento_Filesystem $filesystem */ - $filesystem = $this->_objectManager->create('Magento_Filesystem'); - $isFile = false; - $file = null; - if (is_array($content)) { - if (!isset($content['type']) || !isset($content['value'])) { - return $this; - } - if ($content['type'] == 'filename') { - $isFile = true; - $file = $content['value']; - $contentLength = $filesystem->getFileSize($file); - } - } - - $this->getResponse() - ->setHttpResponseCode(200) - ->setHeader('Pragma', 'public', true) - ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true) - ->setHeader('Content-type', $contentType, true) - ->setHeader('Content-Length', is_null($contentLength) ? strlen($content) : $contentLength, true) - ->setHeader('Content-Disposition', 'attachment; filename="'.$fileName.'"', true) - ->setHeader('Last-Modified', date('r'), true); - - if (!is_null($content)) { - if ($isFile) { - $this->getResponse()->clearBody(); - $this->getResponse()->sendHeaders(); - - if (!$filesystem->isFile($file)) { - Mage::throwException(Mage::helper('Mage_Core_Helper_Data')->__('File not found')); - } - $stream = $filesystem->createAndOpenStream($file, 'r'); - while ($buffer = $stream->read(1024)) { - print $buffer; - } - $stream->close(); - if (!empty($content['rm'])) { - $filesystem->delete($file); - } - - exit(0); - } else { - $this->getResponse()->setBody($content); - } - } - return $this; - } -} diff --git a/app/code/core/Mage/Core/Controller/Varien/Router/Base.php b/app/code/core/Mage/Core/Controller/Varien/Router/Base.php deleted file mode 100644 index 9ec6c39662a16..0000000000000 --- a/app/code/core/Mage/Core/Controller/Varien/Router/Base.php +++ /dev/null @@ -1,665 +0,0 @@ -_app = $app; - $this->_filesystem = $filesystem; - $this->_areaCode = $areaCode; - $this->_baseController = $baseController; - - if (is_null($this->_areaCode) || is_null($this->_baseController)) { - throw new InvalidArgumentException("Not enough options to initialize router."); - } - } - - public function collectRoutes($configArea, $useRouterName) - { - $routers = array(); - $routersConfigNode = Mage::getConfig()->getNode($configArea . '/routers'); - if ($routersConfigNode) { - $routers = $routersConfigNode->children(); - } - foreach ($routers as $routerName => $routerConfig) { - $use = (string)$routerConfig->use; - if ($use == $useRouterName) { - $modules = array((string)$routerConfig->args->module); - if ($routerConfig->args->modules) { - foreach ($routerConfig->args->modules->children() as $customModule) { - if ($customModule) { - if ($before = $customModule->getAttribute('before')) { - $position = array_search($before, $modules); - if ($position === false) { - $position = 0; - } - array_splice($modules, $position, 0, (string)$customModule); - } elseif ($after = $customModule->getAttribute('after')) { - $position = array_search($after, $modules); - if ($position === false) { - $position = count($modules); - } - array_splice($modules, $position+1, 0, (string)$customModule); - } else { - $modules[] = (string)$customModule; - } - } - } - } - - $frontName = (string)$routerConfig->args->frontName; - $this->addModule($frontName, $modules, $routerName); - } - } - } - - public function fetchDefault() - { - $this->getFront()->setDefault(array( - 'module' => 'core', - 'controller' => 'index', - 'action' => 'index' - )); - } - - /** - * checking if this admin if yes then we don't use this router - * - * @return bool - */ - protected function _beforeModuleMatch() - { - if (Mage::app()->getStore()->isAdmin()) { - return false; - } - return true; - } - - /** - * dummy call to pass through checking - * - * @return bool - */ - protected function _afterModuleMatch() - { - return true; - } - - /** - * Match provided request and if matched - return corresponding controller - * - * @param Mage_Core_Controller_Request_Http $request - * @return Mage_Core_Controller_Front_Action|null - */ - public function match(Mage_Core_Controller_Request_Http $request) - { - //checking before even try to find out that current module - //should use this router - if (!$this->_beforeModuleMatch()) { - return null; - } - - $params = $this->_parseRequest($request); - - if (false == $this->_canProcess($params)) { - return null; - } - - $this->_app->loadAreaPart($this->_areaCode, Mage_Core_Model_App_Area::PART_CONFIG); - - return $this->_matchController($request, $params); - } - - /** - * Check if router can process provided request - * - * @param array $params - * @return bool - */ - protected function _canProcess(array $params) - { - return true; - } - - /** - * Parse request URL params - * - * @param Mage_Core_Controller_Request_Http $request - * @return array - */ - protected function _parseRequest(Mage_Core_Controller_Request_Http $request) - { - $output = array(); - - $path = trim($request->getPathInfo(), '/'); - - $params = explode('/', ($path ? $path : $this->_getDefaultPath())); - foreach ($this->_requiredParams as $paramName) { - $output[$paramName] = array_shift($params); - } - - for ($i = 0, $l = sizeof($params); $i < $l; $i += 2) { - $output['variables'][$params[$i]] = isset($params[$i+1]) ? urldecode($params[$i + 1]) : ''; - } - return $output; - } - - /** - * Match module front name - * - * @param Mage_Core_Controller_Request_Http $request - * @param string $param - * @return string|null - */ - protected function _matchModuleFrontName(Mage_Core_Controller_Request_Http $request, $param) - { - // get module name - if ($request->getModuleName()) { - $moduleFrontName = $request->getModuleName(); - } else { - if (!empty($param)) { - $moduleFrontName = $param; - } else { - $moduleFrontName = $this->getFront()->getDefault('module'); - $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, ''); - } - } - if (!$moduleFrontName) { - return null; - } - return $moduleFrontName; - } - - /** - * Match controller name - * - * @param Mage_Core_Controller_Request_Http $request - * @param string $param - * @return string - */ - protected function _matchControllerName(Mage_Core_Controller_Request_Http $request, $param) - { - if ($request->getControllerName()) { - $controller = $request->getControllerName(); - } else { - if (!empty($param)) { - $controller = $param; - } else { - $controller = $this->getFront()->getDefault('controller'); - $request->setAlias( - Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, - ltrim($request->getOriginalPathInfo(), '/') - ); - } - } - return $controller; - } - - /** - * Match controller name - * - * @param Mage_Core_Controller_Request_Http $request - * @param string $param - * @return string - */ - protected function _matchActionName(Mage_Core_Controller_Request_Http $request, $param) - { - if (empty($action)) { - if ($request->getActionName()) { - $action = $request->getActionName(); - } else { - $action = !empty($param) ? $param : $this->getFront()->getDefault('action'); - } - } else { - $action = $param; - } - - return $action; - } - - /** - * Get not found controller instance - * - * @param $currentModuleName - * @param Mage_Core_Controller_Request_Http $request - * @return Mage_Core_Controller_Varien_Action|null - */ - protected function _getNotFoundControllerInstance($currentModuleName, Mage_Core_Controller_Request_Http $request) - { - $controllerInstance = null; - - if ($this->_noRouteShouldBeApplied()) { - $controller = 'index'; - $action = 'noroute'; - - $controllerClassName = $this->_validateControllerClassName($currentModuleName, $controller); - if (false == $controllerClassName) { - return null; - } - - if (false == $this->_validateControllerAction($controllerClassName, $action)) { - return null; - } - - // instantiate controller class - $controllerInstance = $this->_controllerFactory->createController($controllerClassName, - array('request' => $request, 'areaCode' => $this->_areaCode) - ); - } else { - return null; - } - - return $controllerInstance; - } - - /** - * Check whether action handler exists for provided handler - * - * @param string $controllerClassName - * @param string $action - * @return bool - */ - protected function _validateControllerAction($controllerClassName, $action) - { - return method_exists($controllerClassName, $action . 'Action'); - } - - /** - * Create matched controller instance - * - * @param Mage_Core_Controller_Request_Http $request - * @param array $params - * @return Mage_Core_Controller_Front_Action|null - */ - protected function _matchController(Mage_Core_Controller_Request_Http $request, array $params) - { - $this->fetchDefault(); - - $moduleFrontName = $this->_matchModuleFrontName($request, $params['moduleFrontName']); - if (empty($moduleFrontName)) { - return null; - } - - /** - * Searching router args by module name from route using it as key - */ - $modules = $this->getModulesByFrontName($moduleFrontName); - - if (empty($modules) === true) { - return null; - } - - // checks after we found out that this router should be used for current module - if (!$this->_afterModuleMatch()) { - return null; - } - - /** - * Going through modules to find appropriate controller - */ - $found = false; - $currentModuleName = null; - $controller = null; - $action = null; - $controllerInstance = null; - - foreach ($modules as $moduleName) { - $currentModuleName = $moduleName; - - $request->setRouteName($this->getRouteByFrontName($moduleFrontName)); - - $controller = $this->_matchControllerName($request, $params['controllerName']); - - $action = $this->_matchActionName($request, $params['actionName']); - - //checking if this place should be secure - $this->_checkShouldBeSecure($request, '/' . $moduleFrontName . '/' . $controller . '/' . $action); - - $controllerClassName = $this->_validateControllerClassName($moduleName, $controller); - if (false == $controllerClassName) { - continue; - } - - if (false === $this->_validateControllerAction($controllerClassName, $action)) { - continue; - } - - Mage::getConfig()->setCurrentAreaCode($this->_areaCode); - // instantiate controller class - $controllerInstance = $this->_controllerFactory->createController($controllerClassName, - array('request' => $request, 'areaCode' => $this->_areaCode) - ); - - $found = true; - break; - } - - /** - * if we did not found any suitable - */ - if (false == $found) { - $controllerInstance = $this->_getNotFoundControllerInstance($currentModuleName, $request); - if (is_null($controllerInstance)) { - return null; - } - } - - // set values only after all the checks are done - $request->setModuleName($moduleFrontName); - $request->setControllerName($controller); - $request->setActionName($action); - $request->setControllerModule($currentModuleName); - if (isset($params['variables'])) { - $request->setParams($params['variables']); - } - return $controllerInstance; - } - - /** - * Get router default request path - * @return string - */ - protected function _getDefaultPath() - { - return Mage::getStoreConfig('web/default/front'); - } - - /** - * Allow to control if we need to enable no route functionality in current router - * - * @return bool - */ - protected function _noRouteShouldBeApplied() - { - return false; - } - - /** - * Generating and validating class file name, - * class and if everything ok do include if needed and return of class name - * - * @param $realModule - * @param $controller - * @return bool|string - */ - protected function _validateControllerClassName($realModule, $controller) - { - $controllerFileName = $this->getControllerFileName($realModule, $controller); - if (!$this->validateControllerFileName($controllerFileName)) { - return false; - } - - $controllerClassName = $this->getControllerClassName($realModule, $controller); - if (!$controllerClassName) { - return false; - } - - // include controller file if needed - if (!$this->_includeControllerClass($controllerFileName, $controllerClassName)) { - return false; - } - - return $controllerClassName; - } - - /** - * Include the file containing controller class if this class is not defined yet - * - * @param $controllerFileName - * @param $controllerClassName - * @return bool - * @throws Mage_Core_Exception - */ - protected function _includeControllerClass($controllerFileName, $controllerClassName) - { - if (!class_exists($controllerClassName, false)) { - if (!$this->_filesystem->isFile($controllerFileName)) { - return false; - } - include $controllerFileName; - - if (!class_exists($controllerClassName, false)) { - throw Mage::exception('Mage_Core', - Mage::helper('Mage_Core_Helper_Data')->__('Controller file was loaded but class does not exist') - ); - } - } - return true; - } - - public function addModule($frontName, $moduleName, $routeName) - { - $this->_modules[$frontName] = $moduleName; - $this->_routes[$routeName] = $frontName; - return $this; - } - - /** - * Retrieve list of modules subscribed to given frontName - * - * @param string $frontName - * @return array - */ - public function getModulesByFrontName($frontName) - { - $modules = array(); - if (isset($this->_modules[$frontName])) { - if (false === is_array($this->_modules[$frontName])) { - $modules = array($this->_modules[$frontName]); - } else { - $modules = $this->_modules[$frontName]; - } - } - return $modules; - } - - public function getModuleByName($moduleName, $modules) - { - foreach ($modules as $module) { - if ($moduleName === $module || (is_array($module) - && $this->getModuleByName($moduleName, $module))) { - return true; - } - } - return false; - } - - public function getFrontNameByRoute($routeName) - { - if (isset($this->_routes[$routeName])) { - return $this->_routes[$routeName]; - } - return false; - } - - public function getRouteByFrontName($frontName) - { - return array_search($frontName, $this->_routes); - } - - public function getControllerFileName($realModule, $controller) - { - $parts = explode('_', $realModule); - $realModule = implode('_', array_splice($parts, 0, 2)); - $file = Mage::getModuleDir('controllers', $realModule); - if (count($parts)) { - $file .= DS . implode(DS, $parts); - } - $file .= DS . uc_words($controller, DS) . 'Controller.php'; - return $file; - } - - public function validateControllerFileName($fileName) - { - if ($fileName - && $this->_filesystem->isFile($fileName) - && $this->_filesystem->isReadable($fileName) - && false === strpos($fileName, '//') - ) { - return true; - } - return false; - } - - public function getControllerClassName($realModule, $controller) - { - $class = $realModule . '_' . uc_words($controller) . 'Controller'; - return $class; - } - - public function rewrite(array $p) - { - $rewrite = Mage::getConfig()->getNode('global/rewrite'); - if ($module = $rewrite->{$p[0]}) { - if (!$module->children()) { - $p[0] = trim((string)$module); - } - } - if (isset($p[1]) && ($controller = $rewrite->{$p[0]}->{$p[1]})) { - if (!$controller->children()) { - $p[1] = trim((string)$controller); - } - } - if (isset($p[2]) && ($action = $rewrite->{$p[0]}->{$p[1]}->{$p[2]})) { - if (!$action->children()) { - $p[2] = trim((string)$action); - } - } - - return $p; - } - - /** - * Check that request uses https protocol if it should. - * Function redirects user to correct URL if needed. - * - * @param Zend_Controller_Request_Http $request - * @param string $path - * @return void - */ - protected function _checkShouldBeSecure(Zend_Controller_Request_Http $request, $path = '') - { - if (!Mage::isInstalled() || $request->getPost()) { - return; - } - - if ($this->_shouldBeSecure($path) && !$request->isSecure()) { - $url = $this->_getCurrentSecureUrl($request); - if ($this->_shouldRedirectToSecure()) { - $url = Mage::getSingleton('Mage_Core_Model_Url')->getRedirectUrl($url); - } - - Mage::app()->getFrontController()->getResponse() - ->setRedirect($url) - ->sendResponse(); - exit; - } - } - - /** - * Check whether redirect url should be used for secure routes - * - * @return bool - */ - protected function _shouldRedirectToSecure() - { - return Mage::app()->getUseSessionInUrl(); - } - - protected function _getCurrentSecureUrl($request) - { - $alias = $request->getAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS); - if ($alias) { - return Mage::getBaseUrl('link', true) . ltrim($alias, '/'); - } - - return Mage::getBaseUrl('link', true) . ltrim($request->getPathInfo(), '/'); - } - - /** - * Check whether URL for corresponding path should use https protocol - * - * @param string $path - * @return bool - */ - protected function _shouldBeSecure($path) - { - return substr(Mage::getStoreConfig('web/unsecure/base_url'), 0, 5) === 'https' - || Mage::getStoreConfigFlag('web/secure/use_in_frontend') - && substr(Mage::getStoreConfig('web/secure/base_url'), 0, 5) == 'https' - && Mage::getConfig()->shouldUrlBeSecure($path); - } -} diff --git a/app/code/core/Mage/Core/Controller/Varien/Router/Factory.php b/app/code/core/Mage/Core/Controller/Varien/Router/Factory.php deleted file mode 100644 index 06896cb459853..0000000000000 --- a/app/code/core/Mage/Core/Controller/Varien/Router/Factory.php +++ /dev/null @@ -1,62 +0,0 @@ -_objectManager = $objectManager; - } - - /** - * @param string $className - * @param array $routerInfo - * @return Mage_Core_Controller_Varien_Router_Abstract - */ - public function createRouter($className, array $routerInfo = array()) - { - $arguments = array( - 'areaCode' => null, - 'baseController' => null, - ); - if (isset($routerInfo['area'])) { - $arguments['areaCode'] = $routerInfo['area']; - } - if (isset($routerInfo['base_controller'])) { - $arguments['baseController'] = $routerInfo['base_controller']; - } - - return $this->_objectManager->get($className, $arguments); - } -} diff --git a/app/code/core/Mage/Core/Helper/Abstract.php b/app/code/core/Mage/Core/Helper/Abstract.php deleted file mode 100755 index 4495454f7af2a..0000000000000 --- a/app/code/core/Mage/Core/Helper/Abstract.php +++ /dev/null @@ -1,384 +0,0 @@ -_translator = $translator; - } - - /** - * Retrieve request object - * - * @return Zend_Controller_Request_Http - */ - protected function _getRequest() - { - if (!$this->_request) { - $this->_request = Mage::getObjectManager()->get('Mage_Core_Controller_Request_Http'); - } - return $this->_request; - } - - /** - * Loading cache data - * - * @param string $cacheId - * @return mixed - */ - protected function _loadCache($cacheId) - { - return Mage::app()->loadCache($cacheId); - } - - /** - * Saving cache - * - * @param mixed $data - * @param string $cacheId - * @param array $tags - * @param bool $lifeTime - * @return Mage_Core_Helper_Abstract - */ - protected function _saveCache($data, $cacheId, $tags = array(), $lifeTime = false) - { - Mage::app()->saveCache($data, $cacheId, $tags, $lifeTime); - return $this; - } - - /** - * Removing cache - * - * @param string $cacheId - * @return Mage_Core_Helper_Abstract - */ - protected function _removeCache($cacheId) - { - Mage::app()->removeCache($cacheId); - return $this; - } - - /** - * Cleaning cache - * - * @param array $tags - * @return Mage_Core_Helper_Abstract - */ - protected function _cleanCache($tags=array()) - { - Mage::app()->cleanCache($tags); - return $this; - } - - /** - * Retrieve helper module name - * - * @return string - */ - protected function _getModuleName() - { - if (!$this->_moduleName) { - $class = get_class($this); - $this->_moduleName = substr($class, 0, strpos($class, '_Helper')); - } - return $this->_moduleName; - } - - /** - * Check whether or not the module output is enabled in Configuration - * - * @param string $moduleName Full module name - * @return boolean - */ - public function isModuleOutputEnabled($moduleName = null) - { - if ($moduleName === null) { - $moduleName = $this->_getModuleName(); - } - - if (!$this->isModuleEnabled($moduleName)) { - return false; - } - - if (Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $moduleName)) { - return false; - } - return true; - } - - /** - * Check is module exists and enabled in global config. - * - * @param string $moduleName the full module name, example Mage_Core - * @return boolean - */ - public function isModuleEnabled($moduleName = null) - { - if ($moduleName === null) { - $moduleName = $this->_getModuleName(); - } - - if (!Mage::getConfig()->getNode('modules/' . $moduleName)) { - return false; - } - - $isActive = Mage::getConfig()->getNode('modules/' . $moduleName . '/active'); - if (!$isActive || !in_array((string)$isActive, array('true', '1'))) { - return false; - } - return true; - } - - /** - * Translate - * - * @SuppressWarnings(PHPMD.ShortMethodName) - * @return string - */ - public function __() - { - $args = func_get_args(); - $expr = new Mage_Core_Model_Translate_Expr(array_shift($args), $this->_getModuleName()); - array_unshift($args, $expr); - return $this->_translator->translate($args); - } - - /** - * Escape html entities - * - * @param string|array $data - * @param array $allowedTags - * @return mixed - */ - public function escapeHtml($data, $allowedTags = null) - { - if (is_array($data)) { - $result = array(); - foreach ($data as $item) { - $result[] = $this->escapeHtml($item); - } - } else { - // process single item - if (strlen($data)) { - if (is_array($allowedTags) and !empty($allowedTags)) { - $allowed = implode('|', $allowedTags); - $result = preg_replace('/<([\/\s\r\n]*)(' . $allowed . ')([\/\s\r\n]*)>/si', '##$1$2$3##', $data); - $result = htmlspecialchars($result, ENT_COMPAT, 'UTF-8', false); - $result = preg_replace('/##([\/\s\r\n]*)(' . $allowed . ')([\/\s\r\n]*)##/si', '<$1$2$3>', $result); - } else { - $result = htmlspecialchars($data, ENT_COMPAT, 'UTF-8', false); - } - } else { - $result = $data; - } - } - return $result; - } - - /** - * Remove html tags, but leave "<" and ">" signs - * - * @param string $html - * @return string - */ - public function removeTags($html) - { - $html = preg_replace("# <(?![/a-z]) | (?<=\s)>(?![a-z]) #exi", "htmlentities('$0')", $html); - $html = strip_tags($html); - return htmlspecialchars_decode($html); - } - - /** - * Wrapper for standard strip_tags() function with extra functionality for html entities - * - * @param string $data - * @param string $allowableTags - * @param bool $escape - * @return string - */ - public function stripTags($data, $allowableTags = null, $escape = false) - { - $result = strip_tags($data, $allowableTags); - return $escape ? $this->escapeHtml($result, $allowableTags) : $result; - } - - /** - * Escape html entities in url - * - * @param string $data - * @return string - */ - public function escapeUrl($data) - { - return htmlspecialchars($data); - } - - /** - * Escape quotes in java script - * - * @param mixed $data - * @param string $quote - * @return mixed - */ - public function jsQuoteEscape($data, $quote = '\'') - { - if (is_array($data)) { - $result = array(); - foreach ($data as $item) { - $result[] = str_replace($quote, '\\' . $quote, $item); - } - return $result; - } - return str_replace($quote, '\\' . $quote, $data); - } - - /** - * Escape quotes inside html attributes - * Use $addSlashes = false for escaping js that inside html attribute (onClick, onSubmit etc) - * - * @param string $data - * @param bool $addSlashes - * @return string - */ - public function quoteEscape($data, $addSlashes = false) - { - if ($addSlashes === true) { - $data = addslashes($data); - } - return htmlspecialchars($data, ENT_QUOTES, null, false); - } - - /** - * Retrieve url - * - * @param string $route - * @param array $params - * @return string - */ - protected function _getUrl($route, $params = array()) - { - return Mage::getUrl($route, $params); - } - - /** - * Declare layout - * - * @param Mage_Core_Model_Layout $layout - * @return Mage_Core_Helper_Abstract - */ - public function setLayout($layout) - { - $this->_layout = $layout; - return $this; - } - - /** - * Retrieve layout model object - * - * @return Mage_Core_Model_Layout - */ - public function getLayout() - { - return $this->_layout; - } - - /** - * base64_encode() for URLs encoding - * - * @param string $url - * @return string - */ - public function urlEncode($url) - { - return strtr(base64_encode($url), '+/=', '-_,'); - } - - /** - * base64_decode() for URLs decoding - * - * @param string $url - * @return string - */ - public function urlDecode($url) - { - $url = base64_decode(strtr($url, '-_,', '+/=')); - return Mage::getSingleton('Mage_Core_Model_Url')->sessionUrlVar($url); - } - - /** - * Translate array - * - * @param array $arr - * @return array - */ - public function translateArray($arr = array()) - { - foreach ($arr as $k => $v) { - if (is_array($v)) { - $v = self::translateArray($v); - } elseif ($k === 'label') { - $v = self::__($v); - } - $arr[$k] = $v; - } - return $arr; - } -} diff --git a/app/code/core/Mage/Core/Helper/Data.php b/app/code/core/Mage/Core/Helper/Data.php deleted file mode 100644 index e70f245d802f9..0000000000000 --- a/app/code/core/Mage/Core/Helper/Data.php +++ /dev/null @@ -1,835 +0,0 @@ - - */ -class Mage_Core_Helper_Data extends Mage_Core_Helper_Abstract -{ - const XML_PATH_DEFAULT_COUNTRY = 'general/country/default'; - const XML_PATH_PROTECTED_FILE_EXTENSIONS = 'general/file/protected_extensions'; - const XML_PATH_PUBLIC_FILES_VALID_PATHS = 'general/file/public_files_valid_paths'; - const XML_PATH_ENCRYPTION_MODEL = 'global/helpers/core/encryption_model'; - const XML_PATH_DEV_ALLOW_IPS = 'dev/restrict/allow_ips'; - const XML_PATH_CONNECTION_TYPE = 'global/resources/default_setup/connection/type'; - const XML_PATH_IMAGE_ADAPTER = 'dev/image/adapter'; - const XML_PATH_STATIC_FILE_SIGNATURE = 'dev/static/sign'; - - const CHARS_LOWERS = 'abcdefghijklmnopqrstuvwxyz'; - const CHARS_UPPERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; - const CHARS_DIGITS = '0123456789'; - const CHARS_SPECIALS = '!$*+-.=?@^_|~'; - const CHARS_PASSWORD_LOWERS = 'abcdefghjkmnpqrstuvwxyz'; - const CHARS_PASSWORD_UPPERS = 'ABCDEFGHJKLMNPQRSTUVWXYZ'; - const CHARS_PASSWORD_DIGITS = '23456789'; - const CHARS_PASSWORD_SPECIALS = '!$*-.=?@_'; - - /** - * Config pathes to merchant country code and merchant VAT number - */ - const XML_PATH_MERCHANT_COUNTRY_CODE = 'general/store_information/merchant_country'; - const XML_PATH_MERCHANT_VAT_NUMBER = 'general/store_information/merchant_vat_number'; - const XML_PATH_EU_COUNTRIES_LIST = 'general/country/eu_countries'; - - const XML_PATH_SINGLE_STORE_MODE_ENABLED = 'general/single_store_mode/enabled'; - - /** - * Const for correct dividing decimal values - */ - const DIVIDE_EPSILON = 10000; - - /** - * Config path to mail sending setting that shows if email communications are disabled - */ - const XML_PATH_SYSTEM_SMTP_DISABLE = 'system/smtp/disable'; - - /** - * @var Mage_Core_Model_Encryption - */ - protected $_encryptor = null; - - protected $_allowedFormats = array( - Mage_Core_Model_Locale::FORMAT_TYPE_FULL, - Mage_Core_Model_Locale::FORMAT_TYPE_LONG, - Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, - Mage_Core_Model_Locale::FORMAT_TYPE_SHORT - ); - - /** - * @var Mage_Core_Model_Config_Modules - */ - protected $_config; - - /** - * @param Mage_Core_Model_Translate $translator - * @param Mage_Core_Model_Config_Modules $config - */ - public function __construct(Mage_Core_Model_Translate $translator, Mage_Core_Model_Config_Modules $config) - { - parent::__construct($translator); - $this->_config = $config; - } - - /** - * @return Mage_Core_Model_Encryption - */ - public function getEncryptor() - { - if ($this->_encryptor === null) { - $encryptionModel = (string)$this->_config->getNode(self::XML_PATH_ENCRYPTION_MODEL); - - if (!$encryptionModel) { - $encryptionModel = 'Mage_Core_Model_Encryption'; - } - - $this->_encryptor = Mage::getObjectManager()->create($encryptionModel); - - $this->_encryptor->setHelper($this); - } - return $this->_encryptor; - } - - /** - * Convert and format price value for current application store - * - * @param float $value - * @param bool $format - * @param bool $includeContainer - * @return mixed - */ - public static function currency($value, $format = true, $includeContainer = true) - { - return self::currencyByStore($value, null, $format, $includeContainer); - } - - /** - * Convert and format price value for specified store - * - * @param float $value - * @param int|Mage_Core_Model_Store $store - * @param bool $format - * @param bool $includeContainer - * @return mixed - */ - public static function currencyByStore($value, $store = null, $format = true, $includeContainer = true) - { - try { - if (!($store instanceof Mage_Core_Model_Store)) { - $store = Mage::app()->getStore($store); - } - - $value = $store->convertPrice($value, $format, $includeContainer); - } - catch (Exception $e){ - $value = $e->getMessage(); - } - - return $value; - } - - /** - * Format and convert currency using current store option - * - * @param float $value - * @param bool $includeContainer - * @return string - */ - public function formatCurrency($value, $includeContainer = true) - { - return $this->currency($value, true, $includeContainer); - } - - /** - * Formats price - * - * @param float $price - * @param bool $includeContainer - * @return string - */ - public function formatPrice($price, $includeContainer = true) - { - return Mage::app()->getStore()->formatPrice($price, $includeContainer); - } - - /** - * Format date using current locale options and time zone. - * - * @param date|Zend_Date|null $date - * @param string $format See Mage_Core_Model_Locale::FORMAT_TYPE_* constants - * @param bool $showTime Whether to include time - * @return string - */ - public function formatDate($date = null, $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, $showTime = false) - { - if (!in_array($format, $this->_allowedFormats, true)) { - return $date; - } - if (!($date instanceof Zend_Date) && $date && !strtotime($date)) { - return ''; - } - if (is_null($date)) { - $date = Mage::app()->getLocale()->date( - Mage::getSingleton('Mage_Core_Model_Date')->gmtTimestamp(), - null, - null - ); - } else if (!$date instanceof Zend_Date) { - $date = Mage::app()->getLocale()->date(strtotime($date), null, null); - } - - if ($showTime) { - $format = Mage::app()->getLocale()->getDateTimeFormat($format); - } else { - $format = Mage::app()->getLocale()->getDateFormat($format); - } - - return $date->toString($format); - } - - /** - * Format time using current locale options - * - * @param date|Zend_Date|null $time - * @param string $format - * @param bool $showDate - * @return string - */ - public function formatTime($time = null, $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, $showDate = false) - { - if (!in_array($format, $this->_allowedFormats, true)) { - return $time; - } - - if (is_null($time)) { - $date = Mage::app()->getLocale()->date(time()); - } else if ($time instanceof Zend_Date) { - $date = $time; - } else { - $date = Mage::app()->getLocale()->date(strtotime($time)); - } - - if ($showDate) { - $format = Mage::app()->getLocale()->getDateTimeFormat($format); - } else { - $format = Mage::app()->getLocale()->getTimeFormat($format); - } - - return $date->toString($format); - } - - /** - * Encrypt data using application key - * - * @param string $data - * @return string - */ - public function encrypt($data) - { - if (!Mage::isInstalled()) { - return $data; - } - return $this->getEncryptor()->encrypt($data); - } - - /** - * Decrypt data using application key - * - * @param string $data - * @return string - */ - public function decrypt($data) - { - if (!Mage::isInstalled()) { - return $data; - } - return $this->getEncryptor()->decrypt($data); - } - - public function validateKey($key) - { - return $this->getEncryptor()->validateKey($key); - } - - public function getRandomString($len, $chars = null) - { - if (is_null($chars)) { - $chars = self::CHARS_LOWERS . self::CHARS_UPPERS . self::CHARS_DIGITS; - } - mt_srand(10000000*(double)microtime()); - for ($i = 0, $str = '', $lc = strlen($chars)-1; $i < $len; $i++) { - $str .= $chars[mt_rand(0, $lc)]; - } - return $str; - } - - /** - * Generate salted hash from password - * - * @param string $password - * @param string|integer|boolean $salt - */ - public function getHash($password, $salt = false) - { - return $this->getEncryptor()->getHash($password, $salt); - } - - public function validateHash($password, $hash) - { - return $this->getEncryptor()->validateHash($password, $hash); - } - - /** - * Retrieve store identifier - * - * @param mixed $store - * @return int - */ - public function getStoreId($store=null) - { - return Mage::app()->getStore($store)->getId(); - } - - public function removeAccents($string, $german=false) - { - static $replacements; - - if (empty($replacements[$german])) { - $subst = array( - // single ISO-8859-1 letters - 192=>'A', 193=>'A', 194=>'A', 195=>'A', 196=>'A', 197=>'A', 199=>'C', - 208=>'D', 200=>'E', 201=>'E', 202=>'E', 203=>'E', 204=>'I', 205=>'I', - 206=>'I', 207=>'I', 209=>'N', 210=>'O', 211=>'O', 212=>'O', 213=>'O', - 214=>'O', 216=>'O', 138=>'S', 217=>'U', 218=>'U', 219=>'U', 220=>'U', - 221=>'Y', 142=>'Z', 224=>'a', 225=>'a', 226=>'a', 227=>'a', 228=>'a', - 229=>'a', 231=>'c', 232=>'e', 233=>'e', 234=>'e', 235=>'e', 236=>'i', - 237=>'i', 238=>'i', 239=>'i', 241=>'n', 240=>'o', 242=>'o', 243=>'o', - 244=>'o', 245=>'o', 246=>'o', 248=>'o', 154=>'s', 249=>'u', 250=>'u', - 251=>'u', 252=>'u', 253=>'y', 255=>'y', 158=>'z', - // HTML entities - 258=>'A', 260=>'A', 262=>'C', 268=>'C', 270=>'D', 272=>'D', 280=>'E', - 282=>'E', 286=>'G', 304=>'I', 313=>'L', 317=>'L', 321=>'L', 323=>'N', - 327=>'N', 336=>'O', 340=>'R', 344=>'R', 346=>'S', 350=>'S', 354=>'T', - 356=>'T', 366=>'U', 368=>'U', 377=>'Z', 379=>'Z', 259=>'a', 261=>'a', - 263=>'c', 269=>'c', 271=>'d', 273=>'d', 281=>'e', 283=>'e', 287=>'g', - 305=>'i', 322=>'l', 314=>'l', 318=>'l', 324=>'n', 328=>'n', 337=>'o', - 341=>'r', 345=>'r', 347=>'s', 351=>'s', 357=>'t', 355=>'t', 367=>'u', - 369=>'u', 378=>'z', 380=>'z', - // ligatures - 198=>'Ae', 230=>'ae', 140=>'Oe', 156=>'oe', 223=>'ss', - ); - - if ($german) { - // umlauts - $subst = array_merge($subst, array( - 196=>'Ae', 228=>'ae', 214=>'Oe', 246=>'oe', 220=>'Ue', 252=>'ue' - )); - } - - $replacements[$german] = array(); - foreach ($subst as $k=>$v) { - $replacements[$german][$k<256 ? chr($k) : '&#'.$k.';'] = $v; - } - } - - // convert string from default database format (UTF-8) - // to encoding which replacement arrays made with (ISO-8859-1) - if ($s = @iconv('UTF-8', 'ISO-8859-1', $string)) { - $string = $s; - } - - // Replace - $string = strtr($string, $replacements[$german]); - - return $string; - } - - public function isDevAllowed($storeId=null) - { - $allow = true; - - $allowedIps = Mage::getStoreConfig(self::XML_PATH_DEV_ALLOW_IPS, $storeId); - $remoteAddr = Mage::helper('Mage_Core_Helper_Http')->getRemoteAddr(); - if (!empty($allowedIps) && !empty($remoteAddr)) { - $allowedIps = preg_split('#\s*,\s*#', $allowedIps, null, PREG_SPLIT_NO_EMPTY); - if (array_search($remoteAddr, $allowedIps) === false - && array_search(Mage::helper('Mage_Core_Helper_Http')->getHttpHost(), $allowedIps) === false) { - $allow = false; - } - } - - return $allow; - } - - /** - * Get information about available cache types - * - * @return array - */ - public function getCacheTypes() - { - $types = array(); - $config = Mage::getConfig()->getNode(Mage_Core_Model_Cache::XML_PATH_TYPES); - foreach ($config->children() as $type=>$node) { - $types[$type] = (string)$node->label; - } - return $types; - } - - /** - * Copy data from object|array to object|array containing fields - * from fieldset matching an aspect. - * - * Contents of $aspect are a field name in target object or array. - * If '*' - will be used the same name as in the source object or array. - * - * @param string $fieldset - * @param string $aspect - * @param array|Varien_Object $source - * @param array|Varien_Object $target - * @param string $root - * @return boolean - */ - public function copyFieldset($fieldset, $aspect, $source, $target, $root='global') - { - if (!(is_array($source) || $source instanceof Varien_Object) - || !(is_array($target) || $target instanceof Varien_Object)) { - - return false; - } - $fields = Mage::getConfig()->getFieldset($fieldset, $root); - if (!$fields) { - return false; - } - - $sourceIsArray = is_array($source); - $targetIsArray = is_array($target); - - $result = false; - foreach ($fields as $code=>$node) { - if (empty($node->$aspect)) { - continue; - } - - if ($sourceIsArray) { - $value = isset($source[$code]) ? $source[$code] : null; - } else { - $value = $source->getDataUsingMethod($code); - } - - $targetCode = (string)$node->$aspect; - $targetCode = $targetCode == '*' ? $code : $targetCode; - - if ($targetIsArray) { - $target[$targetCode] = $value; - } else { - $target->setDataUsingMethod($targetCode, $value); - } - - $result = true; - } - - $eventName = sprintf('core_copy_fieldset_%s_%s', $fieldset, $aspect); - Mage::dispatchEvent($eventName, array( - 'target' => $target, - 'source' => $source, - 'root' => $root - )); - - return $result; - } - - /** - * Decorate a plain array of arrays or objects - * The array actually can be an object with Iterator interface - * - * Keys with prefix_* will be set: - * *_is_first - if the element is first - * *_is_odd / *_is_even - for odd/even elements - * *_is_last - if the element is last - * - * The respective key/attribute will be set to element, depending on object it is or array. - * Varien_Object is supported. - * - * $forceSetAll true will cause to set all possible values for all elements. - * When false (default), only non-empty values will be set. - * - * @param mixed $array - * @param string $prefix - * @param bool $forceSetAll - * @return mixed - */ - public function decorateArray($array, $prefix = 'decorated_', $forceSetAll = false) - { - // check if array or an object to be iterated given - if (!(is_array($array) || is_object($array))) { - return $array; - } - - $keyIsFirst = "{$prefix}is_first"; - $keyIsOdd = "{$prefix}is_odd"; - $keyIsEven = "{$prefix}is_even"; - $keyIsLast = "{$prefix}is_last"; - - $count = count($array); // this will force Iterator to load - $i = 0; - $isEven = false; - foreach ($array as $key => $element) { - if (is_object($element)) { - $this->_decorateArrayObject($element, $keyIsFirst, (0 === $i), $forceSetAll || (0 === $i)); - $this->_decorateArrayObject($element, $keyIsOdd, !$isEven, $forceSetAll || !$isEven); - $this->_decorateArrayObject($element, $keyIsEven, $isEven, $forceSetAll || $isEven); - $isEven = !$isEven; - $i++; - $this->_decorateArrayObject($element, $keyIsLast, ($i === $count), $forceSetAll || ($i === $count)); - } - elseif (is_array($element)) { - if ($forceSetAll || (0 === $i)) { - $array[$key][$keyIsFirst] = (0 === $i); - } - if ($forceSetAll || !$isEven) { - $array[$key][$keyIsOdd] = !$isEven; - } - if ($forceSetAll || $isEven) { - $array[$key][$keyIsEven] = $isEven; - } - $isEven = !$isEven; - $i++; - if ($forceSetAll || ($i === $count)) { - $array[$key][$keyIsLast] = ($i === $count); - } - } - } - - return $array; - } - - /** - * Mark passed object with specified flag and appropriate value. - * - * @param Varien_Object $element - * @param string $key - * @param mixed $value - * @param bool $dontSkip - */ - private function _decorateArrayObject($element, $key, $value, $dontSkip) { - if ($dontSkip && $element instanceof Varien_Object) { - $element->setData($key, $value); - } - } - - /** - * Transform an assoc array to SimpleXMLElement object - * Array has some limitations. Appropriate exceptions will be thrown - * - * @param array $array - * @param string $rootName - * @return SimpleXMLElement - * @throws Magento_Exception - */ - public function assocToXml(array $array, $rootName = '_') - { - if (empty($rootName) || is_numeric($rootName)) { - throw new Magento_Exception('Root element must not be empty or numeric'); - } - - $xmlstr = << -<$rootName> -XML; - $xml = new SimpleXMLElement($xmlstr); - foreach ($array as $key => $value) { - if (is_numeric($key)) { - throw new Magento_Exception('Array root keys must not be numeric.'); - } - } - return self::_assocToXml($array, $rootName, $xml); - } - - /** - * Function, that actually recursively transforms array to xml - * - * @param array $array - * @param string $rootName - * @param SimpleXMLElement $xml - * @return SimpleXMLElement - * @throws Magento_Exception - */ - private function _assocToXml(array $array, $rootName, SimpleXMLElement &$xml) - { - $hasNumericKey = false; - $hasStringKey = false; - foreach ($array as $key => $value) { - if (!is_array($value)) { - if (is_string($key)) { - if ($key === $rootName) { - throw new Magento_Exception( - 'Associative key must not be the same as its parent associative key.' - ); - } - $hasStringKey = true; - $xml->$key = $value; - } - elseif (is_int($key)) { - $hasNumericKey = true; - $xml->{$rootName}[$key] = $value; - } - } - else { - self::_assocToXml($value, $key, $xml->$key); - } - } - if ($hasNumericKey && $hasStringKey) { - throw new Magento_Exception('Associative and numeric keys must not be mixed at one level.'); - } - return $xml; - } - - /** - * Transform SimpleXMLElement to associative array - * SimpleXMLElement must be conform structure, generated by assocToXml() - * - * @param SimpleXMLElement $xml - * @return array - */ - public function xmlToAssoc(SimpleXMLElement $xml) - { - $array = array(); - foreach ($xml as $key => $value) { - if (isset($value->$key)) { - $i = 0; - foreach ($value->$key as $v) { - $array[$key][$i++] = (string)$v; - } - } - else { - // try to transform it into string value, trimming spaces between elements - $array[$key] = trim((string)$value); - if (empty($array[$key]) && !empty($value)) { - $array[$key] = self::xmlToAssoc($value); - } - // untrim strings values - else { - $array[$key] = (string)$value; - } - } - } - return $array; - } - - /** - * Encode the mixed $valueToEncode into the JSON format - * - * @param mixed $valueToEncode - * @param boolean $cycleCheck Optional; whether or not to check for object recursion; off by default - * @param array $options Additional options used during encoding - * @return string - */ - public function jsonEncode($valueToEncode, $cycleCheck = false, $options = array()) - { - $json = Zend_Json::encode($valueToEncode, $cycleCheck, $options); - /* @var $inline Mage_Core_Model_Translate_Inline */ - $inline = Mage::getSingleton('Mage_Core_Model_Translate_Inline'); - if ($inline->isAllowed()) { - $inline->setIsJson(true); - $inline->processResponseBody($json); - $inline->setIsJson(false); - } - - return $json; - } - - /** - * Decodes the given $encodedValue string which is - * encoded in the JSON format - * - * @param string $encodedValue - * @return mixed - */ - public function jsonDecode($encodedValue, $objectDecodeType = Zend_Json::TYPE_ARRAY) - { - return Zend_Json::decode($encodedValue, $objectDecodeType); - } - - /** - * Generate a hash from unique ID - * @param $prefix - * @return string - */ - public function uniqHash($prefix = '') - { - return $prefix . md5(uniqid(microtime().mt_rand(), true)); - } - - /** - * Return default country code - * - * @param Mage_Core_Model_Store|string|int $store - * @return string - */ - public function getDefaultCountry($store = null) - { - return Mage::getStoreConfig(self::XML_PATH_DEFAULT_COUNTRY, $store); - } - - /** - * Return list with protected file extensions - * - * @param Mage_Core_Model_Store|string|int $store - * @return array - */ - public function getProtectedFileExtensions($store = null) - { - return Mage::getStoreConfig(self::XML_PATH_PROTECTED_FILE_EXTENSIONS, $store); - } - - /** - * Return list with public files valid paths - * - * @return array - */ - public function getPublicFilesValidPath() - { - return Mage::getStoreConfig(self::XML_PATH_PUBLIC_FILES_VALID_PATHS); - } - - /** - * Check LFI protection - * - * @throws Mage_Core_Exception - * @param string $name - * @return bool - */ - public function checkLfiProtection($name) - { - if (preg_match('#\.\.[\\\/]#', $name)) { - throw new Mage_Core_Exception($this->__('Requested file may not include parent directory traversal ("../", "..\\" notation)')); - } - return true; - } - - /** - * Check whether database compatible mode is used (configs enable it for MySQL by default). - * - * @return bool - */ - public function useDbCompatibleMode() - { - /** @var $resourceConfig Mage_Core_Model_Config_Resource */ - $resourceConfig = Mage::getSingleton('Mage_Core_Model_Config_Resource'); - $connType = (string) $resourceConfig->getResourceConnectionConfig('default_setup')->type; - $value = (string) $resourceConfig->getResourceTypeConfig($connType)->compatibleMode; - return (bool) $value; - } - - /** - * Retrieve merchant country code - * - * @param Mage_Core_Model_Store|string|int|null $store - * @return string - */ - public function getMerchantCountryCode($store = null) - { - return (string) Mage::getStoreConfig(self::XML_PATH_MERCHANT_COUNTRY_CODE, $store); - } - - /** - * Retrieve merchant VAT number - * - * @param Mage_Core_Model_Store|string|int|null $store - * @return string - */ - public function getMerchantVatNumber($store = null) - { - return (string) Mage::getStoreConfig(self::XML_PATH_MERCHANT_VAT_NUMBER, $store); - } - - /** - * Check whether specified country is in EU countries list - * - * @param string $countryCode - * @param null|int $storeId - * @return bool - */ - public function isCountryInEU($countryCode, $storeId = null) - { - $euCountries = explode(',', Mage::getStoreConfig(self::XML_PATH_EU_COUNTRIES_LIST, $storeId)); - return in_array($countryCode, $euCountries); - } - - /** - * Returns the floating point remainder (modulo) of the division of the arguments - * - * @param float|int $dividend - * @param float|int $divisor - * @return float|int - */ - public function getExactDivision($dividend, $divisor) - { - $epsilon = $divisor / self::DIVIDE_EPSILON; - - $remainder = fmod($dividend, $divisor); - if (abs($remainder - $divisor) < $epsilon || abs($remainder) < $epsilon) { - $remainder = 0; - } - - return $remainder; - } - - /** - * Returns image adapter type - * - * @return string - */ - public function getImageAdapterType() - { - return Mage::getStoreConfig(self::XML_PATH_IMAGE_ADAPTER); - } - - /** - * Check if static files have to be signed - * - * @return bool - */ - public function isStaticFilesSigned() - { - return (bool) Mage::getStoreConfig(self::XML_PATH_STATIC_FILE_SIGNATURE); - } - - /** - * Check if Single-Store mode is enabled in configuration - * - * This flag only shows that admin does not want to show certain UI components at backend (like store switchers etc) - * if Magento has only one store view but it does not check the store view collection - * - * @return bool - */ - public function isSingleStoreModeEnabled() - { - return (bool) Mage::getStoreConfig(self::XML_PATH_SINGLE_STORE_MODE_ENABLED); - } -} diff --git a/app/code/core/Mage/Core/Helper/Js.php b/app/code/core/Mage/Core/Helper/Js.php deleted file mode 100644 index 1fec738297ba3..0000000000000 --- a/app/code/core/Mage/Core/Helper/Js.php +++ /dev/null @@ -1,175 +0,0 @@ - - */ -class Mage_Core_Helper_Js extends Mage_Core_Helper_Abstract -{ - /** - * Key for cache - */ - const JAVASCRIPT_TRANSLATE_CONFIG_KEY = 'javascript_translate_config'; - - /** - * Translate file name - */ - const JAVASCRIPT_TRANSLATE_CONFIG_FILENAME = 'jstranslator.xml'; - - /** - * Array of senteces of JS translations - * - * @var array - */ - protected $_translateData = null; - - /** - * Translate config - * - * @var Varien_Simplexml_Config - */ - protected $_config = null; - - /** - * Modules configuration reader - * - * @var Mage_Core_Model_Config_Modules_Reader - */ - protected $_configReader; - - /** - * @param Mage_Core_Model_Translate $translator - * @param Mage_Core_Model_Config_Modules_Reader $configReader - */ - public function __construct( - Mage_Core_Model_Translate $translator, - Mage_Core_Model_Config_Modules_Reader $configReader - ) { - parent::__construct($translator); - $this->_configReader = $configReader; - } - - /** - * Retrieve JSON of JS sentences translation - * - * @return string - */ - public function getTranslateJson() - { - return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($this->_getTranslateData()); - } - - /** - * Retrieve JS translator initialization javascript - * - * @return string - */ - public function getTranslatorScript() - { - $script = '(function($) {$.mage.translate.add(' . $this->getTranslateJson() . ')})(jQuery);'; - return $this->getScript($script); - } - - /** - * Retrieve framed javascript - * - * @param string $script - * @return script - */ - public function getScript($script) - { - return ''; - } - - /** - * Retrieve javascript include code - * - * @param string $file - * @return string - */ - public function includeScript($file) - { - return '' . "\n"; - } - - /** - * Retrieve JS translation array - * - * @return array - */ - protected function _getTranslateData() - { - if ($this->_translateData === null) { - $this->_translateData = array(); - $messages = $this->_getXmlConfig()->getXpath('*/message'); - if (!empty($messages)) { - foreach ($messages as $message) { - $messageText = (string)$message; - $module = $message->getParent()->getAttribute("module"); - $this->_translateData[$messageText] = Mage::helper( - empty($module) ? 'Mage_Core' : $module - )->__($messageText); - } - } - - foreach ($this->_translateData as $key => $value) { - if ($key == $value) { - unset($this->_translateData[$key]); - } - } - } - return $this->_translateData; - } - - /** - * Load config from files and try to cache it - * - * @return Varien_Simplexml_Config - */ - protected function _getXmlConfig() - { - if (is_null($this->_config)) { - $canUsaCache = Mage::app()->useCache('config'); - $cachedXml = Mage::app()->loadCache(self::JAVASCRIPT_TRANSLATE_CONFIG_KEY); - if ($canUsaCache && $cachedXml) { - $xmlConfig = new Varien_Simplexml_Config($cachedXml); - } else { - $xmlConfig = new Varien_Simplexml_Config(); - $xmlConfig->loadString(''); - $this->_configReader->loadModulesConfiguration(self::JAVASCRIPT_TRANSLATE_CONFIG_FILENAME, $xmlConfig); - - if ($canUsaCache) { - Mage::app()->saveCache($xmlConfig->getXmlString(), self::JAVASCRIPT_TRANSLATE_CONFIG_KEY, - array(Mage_Core_Model_Config::CACHE_TAG)); - } - } - $this->_config = $xmlConfig; - } - return $this->_config; - } -} diff --git a/app/code/core/Mage/Core/Helper/Theme.php b/app/code/core/Mage/Core/Helper/Theme.php deleted file mode 100644 index bcc626f007cfb..0000000000000 --- a/app/code/core/Mage/Core/Helper/Theme.php +++ /dev/null @@ -1,398 +0,0 @@ -_design = $design; - $this->_dirs = $dirs; - $this->_layoutMergeFactory = $layoutMergeFactory; - $this->_themeCollection = $themeCollection; - parent::__construct($translator); - } - - /** - * Get CSS files of a given theme - * - * Returned array has a structure - * array( - * 'Mage_Catalog::widgets.css' => 'http://mage2.com/pub/media/theme/frontend/_theme15/en_US/Mage_Cms/widgets.css' - * ) - * - * @param Mage_Core_Model_Theme $theme - * @return array - */ - public function getCssFiles($theme) - { - $arguments = array( - 'area' => $theme->getArea(), - 'theme' => $theme->getThemeId() - ); - /** @var $layoutMerge Mage_Core_Model_Layout_Merge */ - $layoutMerge = $this->_layoutMergeFactory->create(array('arguments' => $arguments)); - $layoutElement = $layoutMerge->getFileLayoutUpdatesXml(); - - $elements = array_merge( - $layoutElement->xpath(self::XPATH_SELECTOR_REFS), - $layoutElement->xpath(self::XPATH_SELECTOR_BLOCKS) - ); - - $params = array( - 'area' => $theme->getArea(), - 'themeModel' => $theme, - 'skipProxy' => true - ); - - $basePath = $this->_dirs->getDir(Mage_Core_Model_Dir::ROOT); - $files = array(); - foreach ($elements as $fileId) { - $fileId = (string)$fileId; - $path = $this->_design->getViewFile($fileId, $params); - $file = array( - 'id' => $fileId, - 'path' => Magento_Filesystem::fixSeparator($path), - ); - $file['safePath'] = $this->getSafePath($file['path'], $basePath); - - //keys are used also to remove duplicates - $files[$fileId] = $file; - } - - return $files; - } - - /** - * Get CSS files by group - * - * @param Mage_Core_Model_Theme $theme - * @return array - * @throws Mage_Core_Exception - */ - public function getGroupedCssFiles($theme) - { - $jsDir = $this->_dirs->getDir(Mage_Core_Model_Dir::PUB_LIB); - $codeDir = $this->_dirs->getDir(Mage_Core_Model_Dir::MODULES); - $designDir = $this->_dirs->getDir(Mage_Core_Model_Dir::THEMES); - - $groups = array(); - $themes = array(); - foreach ($this->getCssFiles($theme) as $file) { - $this->_detectTheme($file, $designDir); - $this->_detectGroup($file); - - if (isset($file['theme']) && $file['theme']->getThemeId()) { - $themes[$file['theme']->getThemeId()] = $file['theme']; - } - - if (!isset($file['group'])) { - Mage::throwException( - $this->__('Group is missed for file "%s"', $file['safePath']) - ); - } - $group = $file['group']; - unset($file['theme']); - unset($file['group']); - - if (!isset($groups[$group])) { - $groups[$group] = array(); - } - $groups[$group][] = $file; - } - - if (count($themes) > 1) { - $themes = $this->_sortThemesByHierarchy($themes); - } - - $order = array_merge(array($codeDir, $jsDir), array_map(function ($fileTheme) { - /** @var $fileTheme Mage_Core_Model_Theme */ - return $fileTheme->getThemeId(); - }, $themes)); - $groups = $this->_sortArrayByArray($groups, $order); - - $labels = $this->_getGroupLabels($themes, $jsDir, $codeDir); - foreach ($groups as $key => $group) { - usort($group, array($this, '_sortGroupFilesCallback')); - $groups[$labels[$key]] = $group; - unset($groups[$key]); - } - return $groups; - } - - /** - * Detect theme view file belongs to and set it to file data under "theme" key - * - * @param array $file - * @param string $designDir - * @return Mage_Theme_Helper_Data - * @throws Mage_Core_Exception - */ - protected function _detectTheme(&$file, $designDir) - { - //TODO use cache here, so files of the same theme share one model - - $isInsideDesignDir = substr($file['path'], 0, strlen($designDir)) == $designDir; - if (!$isInsideDesignDir) { - return $this; - } - - $relativePath = substr($file['path'], strlen($designDir)); - - $area = strtok($relativePath, Magento_Filesystem::DIRECTORY_SEPARATOR); - $package = strtok(Magento_Filesystem::DIRECTORY_SEPARATOR); - $theme = strtok(Magento_Filesystem::DIRECTORY_SEPARATOR); - - if ($area === false || $package === false || $theme === false) { - Mage::throwException($this->__('Theme path "%s/%s/%s" is incorrect', $area, $package, $theme)); - } - $themeModel = $this->_themeCollection->getThemeByFullPath($area . '/' . $package . '/' . $theme); - - if (!$themeModel || !$themeModel->getThemeId()) { - Mage::throwException($this->__('Invalid theme loaded by theme path "%s/%s/%s"', $area, $package, $theme)); - } - - $file['theme'] = $themeModel; - - return $this; - } - - /** - * Detect group where file should be placed and set it to file data under "group" key - * - * @param array $file - * @return Mage_Theme_Helper_Data - * @throws Mage_Core_Exception - */ - protected function _detectGroup(&$file) - { - $jsDir = $this->_dirs->getDir(Mage_Core_Model_Dir::PUB_LIB); - $codeDir = $this->_dirs->getDir(Mage_Core_Model_Dir::MODULES); - $designDir = $this->_dirs->getDir(Mage_Core_Model_Dir::THEMES); - - $group = null; - if (substr($file['path'], 0, strlen($designDir)) == $designDir) { - if (!isset($file['theme']) || !$file['theme']->getThemeId()) { - Mage::throwException( - $this->__('Theme is missed for file "%s"', $file['safePath']) - ); - } - $group = $file['theme']->getThemeId(); - } elseif (substr($file['path'], 0, strlen($jsDir)) == $jsDir) { - $group = $jsDir; - } elseif (substr($file['path'], 0, strlen($codeDir)) == $codeDir) { - $group = $codeDir; - } else { - Mage::throwException( - $this->__('Invalid view file directory "%s"', $file['safePath']) - ); - } - $file['group'] = $group; - - return $this; - } - - /** - * Sort themes according to their hierarchy - * - * @param array $themes - * @return array - */ - protected function _sortThemesByHierarchy(array $themes) - { - uasort($themes, array($this, '_sortThemesByHierarchyCallback')); - return $themes; - } - - /** - * Sort one associative array according to another array - * - * $groups = array( - * b => item2, - * a => item1, - * c => item3, - * ); - * $order = array(a,b,c); - * result: array( - * a => item1, - * b => item2, - * c => item3, - * ) - * - * @param array $groups - * @param array $order - * @return array - */ - protected function _sortArrayByArray(array $groups, array $order) - { - $ordered = array(); - foreach ($order as $key) { - if (array_key_exists($key, $groups)) { - $ordered[$key] = $groups[$key]; - unset($groups[$key]); - } - } - return $ordered + $groups; - } - - /** - * Get group labels - * - * @param array $themes - * @param string $jsDir - * @param string $codeDir - * @return array - */ - protected function _getGroupLabels(array $themes, $jsDir, $codeDir) - { - $labels = array( - $jsDir => $this->__('Library files'), - $codeDir => $this->__('Framework files') - ); - foreach ($themes as $theme) { - /** @var $theme Mage_Core_Model_Theme */ - $labels[$theme->getThemeId()] = $this->__('"%s" Theme files', $theme->getThemeTitle()); - } - return $labels; - } - - /** - * Callback for sorting files inside group - * - * Return "1" if $firstFile should go before $secondFile, otherwise return "-1" - * - * @param array $firstFile - * @param array $secondFile - * @return int - */ - protected function _sortGroupFilesCallback(array $firstFile, array $secondFile) - { - $hasContextFirst = strpos($firstFile['id'], '::') !== false; - $hasContextSecond = strpos($secondFile['id'], '::') !== false; - - if ($hasContextFirst && $hasContextSecond) { - $result = strcmp($firstFile['id'], $secondFile['id']); - } elseif (!$hasContextFirst && !$hasContextSecond) { - $result = strcmp($firstFile['id'], $secondFile['id']); - } elseif ($hasContextFirst) { - //case when first item has module context and second item doesn't - $result = 1; - } else { - //case when second item has module context and first item doesn't - $result = -1; - } - return $result; - } - - /** - * Sort themes by hierarchy callback - * - * @param Mage_Core_Model_Theme $firstTheme - * @param Mage_Core_Model_Theme $secondTheme - * @return int - */ - protected function _sortThemesByHierarchyCallback($firstTheme, $secondTheme) - { - $parentTheme = $firstTheme->getParentTheme(); - while ($parentTheme) { - if ($parentTheme->getThemeId() == $secondTheme->getThemeId()) { - return -1; - } - $parentTheme = $parentTheme->getParentTheme(); - } - return 1; - } - - /** - * Get relative file path cut to be safe for public sharing - * - * Path is considered from the base Magento directory - * - * @param string $filePath - * @param string $basePath - * @return string - */ - public function getSafePath($filePath, $basePath) - { - return ltrim(str_ireplace($basePath, '', $filePath), '\\/'); - } -} diff --git a/app/code/core/Mage/Core/Helper/Url.php b/app/code/core/Mage/Core/Helper/Url.php deleted file mode 100644 index 97b1a1c8bd24b..0000000000000 --- a/app/code/core/Mage/Core/Helper/Url.php +++ /dev/null @@ -1,152 +0,0 @@ - - */ -class Mage_Core_Helper_Url extends Mage_Core_Helper_Abstract -{ - /** - * @param Mage_Core_Model_Translate $translate - */ - public function __construct(Mage_Core_Model_Translate $translate) - { - parent::__construct($translate); - } - - /** - * Retrieve current url - * - * @return string - */ - public function getCurrentUrl() - { - $request = $this->_getRequest(); - $port = $this->_getRequest()->getServer('SERVER_PORT'); - if ($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; - } - - /** - * Retrieve current url in base64 encoding - * - * @return string - */ - public function getCurrentBase64Url() - { - return $this->urlEncode($this->getCurrentUrl()); - } - - public function getEncodedUrl($url = null) - { - if (!$url) { - $url = $this->getCurrentUrl(); - } - return $this->urlEncode($url); - } - - /** - * Retrieve homepage url - * - * @return string - */ - public function getHomeUrl() - { - return Mage::getBaseUrl(); - } - - protected function _prepareString($string) - { - $string = preg_replace('#[^0-9a-z]+#i', '-', $string); - $string = strtolower($string); - $string = trim($string, '-'); - - return $string; - } - - /** - * Add request parameter into url - * - * @param $url string - * @param $param array( 'key' => value ) - * @return string - */ - public function addRequestParam($url, $param) - { - $startDelimiter = (false === strpos($url,'?'))? '?' : '&'; - - $arrQueryParams = array(); - foreach($param as $key=>$value) { - if (is_numeric($key) || is_object($value)) { - continue; - } - - if (is_array($value)) { - // $key[]=$value1&$key[]=$value2 ... - $arrQueryParams[] = $key . '[]=' . implode('&' . $key . '[]=', $value); - } elseif (is_null($value)) { - $arrQueryParams[] = $key; - } else { - $arrQueryParams[] = $key . '=' . $value; - } - } - $url .= $startDelimiter . implode('&', $arrQueryParams); - - return $url; - } - - /** - * Remove request parameter from url - * @param string $url - * @param string $paramKey - * @param bool $caseSensitive - * @return string - */ - public function removeRequestParam($url, $paramKey, $caseSensitive = false) - { - $regExpression = '/\\?[^#]*?(' . preg_quote($paramKey, '/') . '\\=[^#&]*&?)/' . ($caseSensitive ? '' : 'i'); - while (preg_match($regExpression, $url, $mathes) != 0) { - $paramString = $mathes[1]; - if (preg_match('/&$/', $paramString) == 0) { - $url = preg_replace('/(&|\\?)?' . preg_quote($paramString, '/') . '/', '', $url); - } else { - $url = str_replace($paramString, '', $url); - } - } - return $url; - } -} diff --git a/app/code/core/Mage/Core/Model/Abstract.php b/app/code/core/Mage/Core/Model/Abstract.php deleted file mode 100644 index a6d5caa314d21..0000000000000 --- a/app/code/core/Mage/Core/Model/Abstract.php +++ /dev/null @@ -1,703 +0,0 @@ -getEvent()->getObject() in this case - * - * @var string - */ - protected $_eventObject = 'object'; - - /** - * Resource model instance - * - * @var Mage_Core_Model_Resource_Db_Abstract - */ - protected $_resource; - - /** - * Resource collection - * - * @var Mage_Core_Model_Resource_Db_Collection_Abstract - */ - protected $_resourceCollection; - /** - * Name of the resource model - * - * @var string - */ - protected $_resourceName; - - /** - * Name of the resource collection model - * - * @var string - */ - protected $_collectionName; - - /** - * Model cache tag for clear cache in after save and after delete - * - * When you use true - all cache will be clean - * - * @var string|array|true - */ - protected $_cacheTag = false; - - /** - * Flag which can stop data saving after before save - * Can be used for next sequence: we check data in _beforeSave, if data are - * not valid - we can set this flag to false value and save process will be stopped - * - * @var bool - */ - protected $_dataSaveAllowed = true; - - /** - * Flag which allow detect object state: is it new object (without id) or existing one (with id) - * - * @var bool - */ - protected $_isObjectNew = null; - - /** - * Validator for checking the model state before saving it - * - * @var Zend_Validate_Interface|bool|null - */ - protected $_validatorBeforeSave = null; - - /** - * Application Event Dispatcher - * - * @var Mage_Core_Model_Event_Manager - */ - protected $_eventDispatcher; - - /** - * Application Cache Manager - * - * @var Mage_Core_Model_Cache - */ - protected $_cacheManager; - - /** - * @param Mage_Core_Model_Event_Manager $eventDispatcher - * @param Mage_Core_Model_Cache $cacheManager - * @param array $data - * @param Mage_Core_Model_Resource_Abstract $resource - * @param Varien_Data_Collection_Db $resourceCollection - */ - public function __construct( - Mage_Core_Model_Event_Manager $eventDispatcher, - Mage_Core_Model_Cache $cacheManager, - Mage_Core_Model_Resource_Abstract $resource = null, - Varien_Data_Collection_Db $resourceCollection = null, - array $data = array() - ) { - $this->_eventDispatcher = $eventDispatcher; - $this->_cacheManager = $cacheManager; - $this->_resource = $resource; - $this->_resourceCollection = $resourceCollection; - - if ($this->_resource) { - $this->_idFieldName = $this->_getResource()->getIdFieldName(); - } - - parent::__construct($data); - $this->_construct(); - } - - /** - * Model construct that should be used for object initialization - */ - protected function _construct() - { - } - - /** - * Standard model initialization - * - * @param string $resourceModel - * @return Mage_Core_Model_Abstract - */ - protected function _init($resourceModel) - { - $this->_setResourceModel($resourceModel); - $this->_idFieldName = $this->_getResource()->getIdFieldName(); - } - - /** - * Remove not serializable fields - * - * @return array - */ - public function __sleep() - { - $properties = array_keys(get_object_vars($this)); - if (Mage::getIsSerializable()) { - $properties = array_diff($properties, array('_eventDispatcher', '_cacheManager')); - } - return $properties; - } - - /** - * Init not serializable fields - */ - public function __wakeup() - { - if (Mage::getIsSerializable()) { - $this->_eventDispatcher = Mage::getSingleton('Mage_Core_Model_Event_Manager'); - $this->_cacheManager = Mage::getSingleton('Mage_Core_Model_Cache'); - } - } - - /** - * Set resource names - * - * If collection name is omitted, resource name will be used with _collection appended - * - * @param string $resourceName - * @param string|null $collectionName - */ - protected function _setResourceModel($resourceName, $collectionName = null) - { - $this->_resourceName = $resourceName; - if (is_null($collectionName)) { - $collectionName = $resourceName . '_Collection'; - } - $this->_collectionName = $collectionName; - } - - /** - * Get resource instance - * - * @return Mage_Core_Model_Resource_Db_Abstract - */ - protected function _getResource() - { - if (empty($this->_resourceName) && empty($this->_resource)) { - Mage::throwException(Mage::helper('Mage_Core_Helper_Data')->__('Resource is not set.')); - } - - return $this->_resource ?: Mage::getResourceSingleton($this->_resourceName); - } - - /** - * Retrieve model resource name - * - * @return string - */ - public function getResourceName() - { - return ($this->_resource) ? get_class($this->_resource) : ($this->_resourceName ? $this->_resourceName : null); - } - - /** - * Get collection instance - * - * @return Mage_Core_Model_Resource_Db_Collection_Abstract - */ - public function getResourceCollection() - { - if (empty($this->_resourceCollection) && empty($this->_collectionName)) { - Mage::throwException( - Mage::helper('Mage_Core_Helper_Data')->__('Model collection resource name is not defined.') - ); - } - return $this->_resourceCollection ? - clone $this->_resourceCollection : - Mage::getResourceModel($this->_collectionName, array('resource' => $this->_getResource())); - } - - /** - * Retrieve collection instance - * - * @return Mage_Core_Model_Resource_Db_Collection_Abstract - */ - public function getCollection() - { - return $this->getResourceCollection(); - } - - /** - * Load object data - * - * @param integer $modelId - * @param null|string $field - * @return Mage_Core_Model_Abstract - */ - public function load($modelId, $field = null) - { - $this->_beforeLoad($modelId, $field); - $this->_getResource()->load($this, $modelId, $field); - $this->_afterLoad(); - $this->setOrigData(); - $this->_hasDataChanges = false; - return $this; - } - - /** - * Get array of objects transferred to default events processing - * - * @return array - */ - protected function _getEventData() - { - return array( - 'data_object' => $this, - $this->_eventObject => $this, - ); - } - - /** - * Processing object before load data - * - * @param int $modelId - * @param null|string $field - * @return Mage_Core_Model_Abstract - */ - protected function _beforeLoad($modelId, $field = null) - { - $params = array('object' => $this, 'field' => $field, 'value' => $modelId); - $this->_eventDispatcher->dispatch('model_load_before', $params); - $params = array_merge($params, $this->_getEventData()); - $this->_eventDispatcher->dispatch($this->_eventPrefix . '_load_before', $params); - return $this; - } - - /** - * Processing object after load data - * - * @return Mage_Core_Model_Abstract - */ - protected function _afterLoad() - { - $this->_eventDispatcher->dispatch('model_load_after', array('object' => $this)); - $this->_eventDispatcher->dispatch($this->_eventPrefix . '_load_after', $this->_getEventData()); - return $this; - } - - /** - * Object after load processing. Implemented as public interface for supporting objects after load in collections - * - * @return Mage_Core_Model_Abstract - */ - public function afterLoad() - { - $this->getResource()->afterLoad($this); - $this->_afterLoad(); - return $this; - } - - /** - * Check whether model has changed data. - * Can be overloaded in child classes to perform advanced check whether model needs to be saved - * e.g. usign resouceModel->hasDataChanged() or any other technique - * - * @return boolean - */ - protected function _hasModelChanged() - { - return $this->hasDataChanges(); - } - - /** - * Save object data - * - * @return Mage_Core_Model_Abstract - * @throws Exception - */ - public function save() - { - /** - * Direct deleted items to delete method - */ - if ($this->isDeleted()) { - return $this->delete(); - } - if (!$this->_hasModelChanged()) { - return $this; - } - $this->_getResource()->beginTransaction(); - try { - $this->_validateBeforeSave(); - $this->_beforeSave(); - if ($this->_dataSaveAllowed) { - $this->_getResource()->save($this); - $this->_afterSave(); - } - $this->_getResource()->addCommitCallback(array($this, 'afterCommitCallback')) - ->commit(); - $this->_hasDataChanges = false; - } catch (Exception $e) { - $this->_getResource()->rollBack(); - $this->_hasDataChanges = true; - throw $e; - } - return $this; - } - - /** - * Callback function which called after transaction commit in resource model - * - * @return Mage_Core_Model_Abstract - */ - public function afterCommitCallback() - { - $this->_eventDispatcher->dispatch('model_save_commit_after', array('object' => $this)); - $this->_eventDispatcher->dispatch($this->_eventPrefix . '_save_commit_after', $this->_getEventData()); - return $this; - } - - /** - * Check object state (true - if it is object without id on object just created) - * This method can help detect if object just created in _afterSave method - * problem is what in after save object has id and we can't detect what object was - * created in this transaction - * - * @param bool|null $flag - * @return bool - */ - public function isObjectNew($flag = null) - { - if ($flag !== null) { - $this->_isObjectNew = $flag; - } - if ($this->_isObjectNew !== null) { - return $this->_isObjectNew; - } - return !(bool)$this->getId(); - } - - /** - * Processing object before save data - * - * @return Mage_Core_Model_Abstract - */ - protected function _beforeSave() - { - if (!$this->getId()) { - $this->isObjectNew(true); - } - $this->_eventDispatcher->dispatch('model_save_before', array('object' => $this)); - $this->_eventDispatcher->dispatch($this->_eventPrefix . '_save_before', $this->_getEventData()); - return $this; - } - - /** - * Validate model before saving it - * - * @return Mage_Core_Model_Abstract - * @throws Mage_Core_Exception - */ - protected function _validateBeforeSave() - { - $validator = $this->_getValidatorBeforeSave(); - if ($validator && !$validator->isValid($this)) { - $errors = $validator->getMessages(); - $exception = new Mage_Core_Exception(implode(PHP_EOL, $errors)); - foreach ($errors as $errorMessage) { - $exception->addMessage(new Mage_Core_Model_Message_Error($errorMessage)); - } - throw $exception; - } - return $this; - } - - /** - * Returns validator, which contains all rules to validate this model. - * Returns FALSE, if no validation rules exist. - * - * @return Zend_Validate_Interface|false - */ - protected function _getValidatorBeforeSave() - { - if ($this->_validatorBeforeSave === null) { - $this->_validatorBeforeSave = $this->_createValidatorBeforeSave(); - } - return $this->_validatorBeforeSave; - } - - /** - * Creates validator for the model with all validation rules in it. - * Returns FALSE, if no validation rules exist. - * - * @return Zend_Validate_Interface|bool - */ - protected function _createValidatorBeforeSave() - { - $modelRules = $this->_getValidationRulesBeforeSave(); - $resourceRules = $this->_getResource()->getValidationRulesBeforeSave(); - if (!$modelRules && !$resourceRules) { - return false; - } - - if ($modelRules && $resourceRules) { - $validator = new Zend_Validate(); - $validator->addValidator($modelRules); - $validator->addValidator($resourceRules); - } elseif ($modelRules) { - $validator = $modelRules; - } else { - $validator = $resourceRules; - } - - return $validator; - } - - /** - * Template method to return validate rules for the entity - * - * @return Zend_Validate_Interface|null - */ - protected function _getValidationRulesBeforeSave() - { - return null; - } - - /** - * Get list of cache tags applied to model object. - * Return false if cache tags are not supported by model - * - * @return array|bool - */ - public function getCacheTags() - { - $tags = false; - if ($this->_cacheTag) { - if ($this->_cacheTag === true) { - $tags = array(); - } else { - if (is_array($this->_cacheTag)) { - $tags = $this->_cacheTag; - } else { - $tags = array($this->_cacheTag); - } - $idTags = $this->getCacheIdTags(); - if ($idTags) { - $tags = array_merge($tags, $idTags); - } - } - } - return $tags; - } - - /** - * Get cache tags associated with object id - * - * @return array - */ - public function getCacheIdTags() - { - $tags = false; - if ($this->getId() && $this->_cacheTag) { - $tags = array(); - if (is_array($this->_cacheTag)) { - foreach ($this->_cacheTag as $_tag) { - $tags[] = $_tag . '_' . $this->getId(); - } - } else { - $tags[] = $this->_cacheTag . '_' . $this->getId(); - } - } - return $tags; - } - - /** - * Remove model object related cache - * - * @return Mage_Core_Model_Abstract - */ - public function cleanModelCache() - { - $tags = $this->getCacheTags(); - if ($tags !== false) { - $this->_cacheManager->clean($tags); - } - return $this; - } - - /** - * Processing object after save data - * - * @return Mage_Core_Model_Abstract - */ - protected function _afterSave() - { - $this->cleanModelCache(); - $this->_eventDispatcher->dispatch('model_save_after', array('object' => $this)); - $this->_eventDispatcher->dispatch($this->_eventPrefix . '_save_after', $this->_getEventData()); - return $this; - } - - /** - * Delete object from database - * - * @return Mage_Core_Model_Abstract - * @throws Exception - */ - public function delete() - { - $this->_getResource()->beginTransaction(); - try { - $this->_beforeDelete(); - $this->_getResource()->delete($this); - $this->_afterDelete(); - - $this->_getResource()->commit(); - $this->_afterDeleteCommit(); - } catch (Exception $e) { - $this->_getResource()->rollBack(); - throw $e; - } - return $this; - } - - /** - * Processing object before delete data - * - * @return Mage_Core_Model_Abstract - */ - protected function _beforeDelete() - { - $this->_eventDispatcher->dispatch('model_delete_before', array('object' => $this)); - $this->_eventDispatcher->dispatch($this->_eventPrefix . '_delete_before', $this->_getEventData()); - $this->cleanModelCache(); - return $this; - } - - /** - * Safeguard func that will check, if we are in admin area - * - * @throws Mage_Core_Exception - */ - protected function _protectFromNonAdmin() - { - if (Mage::registry('isSecureArea')) { - return; - } - if (!Mage::app()->getStore()->isAdmin()) { - Mage::throwException(Mage::helper('Mage_Core_Helper_Data') - ->__('Cannot complete this operation from non-admin area.')); - } - } - - /** - * Processing object after delete data - * - * @return Mage_Core_Model_Abstract - */ - protected function _afterDelete() - { - $this->_eventDispatcher->dispatch('model_delete_after', array('object' => $this)); - $this->_eventDispatcher->dispatch($this->_eventPrefix . '_delete_after', $this->_getEventData()); - return $this; - } - - /** - * Processing manipulation after main transaction commit - * - * @return Mage_Core_Model_Abstract - */ - protected function _afterDeleteCommit() - { - $this->_eventDispatcher->dispatch('model_delete_commit_after', array('object' => $this)); - $this->_eventDispatcher->dispatch($this->_eventPrefix . '_delete_commit_after', $this->_getEventData()); - return $this; - } - - /** - * Retrieve model resource - * - * @return Mage_Core_Model_Resource_Db_Abstract - */ - public function getResource() - { - return $this->_getResource(); - } - - /** - * Retreive entity id - * - * @return mixed - */ - public function getEntityId() - { - return $this->_getData('entity_id'); - } - - /** - * Clearing object for correct deleting by garbage collector - * - * @return Mage_Core_Model_Abstract - */ - final public function clearInstance() - { - $this->_clearReferences(); - $this->_eventDispatcher->dispatch($this->_eventPrefix . '_clear', $this->_getEventData()); - $this->_clearData(); - return $this; - } - - /** - * Clearing cyclic references - * - * @return Mage_Core_Model_Abstract - */ - protected function _clearReferences() - { - return $this; - } - - /** - * Clearing object's data - * - * @return Mage_Core_Model_Abstract - */ - protected function _clearData() - { - return $this; - } - -} diff --git a/app/code/core/Mage/Core/Model/Acl/Builder.php b/app/code/core/Mage/Core/Model/Acl/Builder.php deleted file mode 100644 index 54d76c4ee04ad..0000000000000 --- a/app/code/core/Mage/Core/Model/Acl/Builder.php +++ /dev/null @@ -1,107 +0,0 @@ -_areaConfig = $data['areaConfig']; - if (!isset($data['objectFactory'])) { - throw new InvalidArgumentException('Object Factory must be passed to ACL builder'); - } - $this->_objectFactory = $data['objectFactory']; - } - - /** - * Build Access Control List - * - * @return Magento_Acl - * @throws LogicException - */ - public function getAcl() - { - if (!$this->_acl) { - try { - $acl = $this->_objectFactory->getModelInstance('Magento_Acl'); - $this->_objectFactory->getModelInstance($this->_getLoaderClass('resource'))->populateAcl($acl); - $this->_objectFactory->getModelInstance($this->_getLoaderClass('role'))->populateAcl($acl); - $this->_objectFactory->getModelInstance($this->_getLoaderClass('rule'))->populateAcl($acl); - $this->_acl = $acl; - } catch (Exception $e) { - throw new LogicException('Could not create acl object: ' . $e->getMessage()); - } - } - return $this->_acl; - } - - /** - * Retrieve ACL loader class from config or NullLoader if not defined - * - * @param string $loaderType - * @return string - */ - protected function _getLoaderClass($loaderType) - { - $loaderClass = (string) (isset($this->_areaConfig['acl'][$loaderType . 'Loader']) - ? $this->_areaConfig['acl'][$loaderType . 'Loader'] - : ''); - - return $loaderClass ?: 'Magento_Acl_Loader_Default'; - } -} diff --git a/app/code/core/Mage/Core/Model/App/Proxy.php b/app/code/core/Mage/Core/Model/App/Proxy.php deleted file mode 100644 index d71f97bacb85d..0000000000000 --- a/app/code/core/Mage/Core/Model/App/Proxy.php +++ /dev/null @@ -1,581 +0,0 @@ -_objectManager = $objectManager; - } - - /** - * Get application model - * - * @return Mage_Core_Model_App - */ - protected function _getApp() - { - if (null === $this->_app) { - $this->_app = $this->_objectManager->get('Mage_Core_Model_App'); - } - - return $this->_app; - } - - /** - * Run application. Run process responsible for request processing and sending response. - * - * @return Mage_Core_Model_AppInterface - */ - public function run() - { - return $this->_getApp()->run(); - } - - /** - * Throw an exception, if the application has not been installed yet - * - * @throws Magento_Exception - */ - public function requireInstalledInstance() - { - $this->_getApp()->requireInstalledInstance(); - } - - /** - * Retrieve cookie object - * - * @return Mage_Core_Model_Cookie - */ - public function getCookie() - { - return $this->_getApp()->getCookie(); - } - - /** - * Reinitialize stores - * - * @return void - */ - public function reinitStores() - { - $this->_getApp()->reinitStores(); - } - - /** - * Check if system is run in the single store mode - * - * @return bool - */ - public function isSingleStoreMode() - { - return $this->_getApp()->isSingleStoreMode(); - } - - /** - * Check if store has only one store view - * - * @return bool - */ - public function hasSingleStore() - { - return $this->_getApp()->hasSingleStore(); - } - - /** - * Set current default store - * - * @param string $store - */ - public function setCurrentStore($store) - { - $this->_getApp()->setCurrentStore($store); - } - - /** - * Get current store code - * - * @return string - */ - public function getCurrentStore() - { - return $this->_getApp()->getCurrentStore(); - } - - /** - * Re-declare custom error handler - * - * @param string $handler - * @return Mage_Core_Model_AppInterface - */ - public function setErrorHandler($handler) - { - return $this->_getApp()->setErrorHandler($handler); - } - - /** - * Loading application area - * - * @param string $code - * @return Mage_Core_Model_AppInterface - */ - public function loadArea($code) - { - return $this->_getApp()->loadArea($code); - } - - /** - * Loading part of area data - * - * @param string $area - * @param string $part - * @return Mage_Core_Model_AppInterface - */ - public function loadAreaPart($area, $part) - { - return $this->_getApp()->loadAreaPart($area, $part); - } - - /** - * Retrieve application area - * - * @param string $code - * @return Mage_Core_Model_App_Area - */ - public function getArea($code) - { - return $this->_getApp()->getArea($code); - } - - /** - * Retrieve application store object - * - * @param null|string|bool|int|Mage_Core_Model_Store $id - * @return Mage_Core_Model_Store - * @throws Mage_Core_Model_Store_Exception - */ - public function getStore($id = null) - { - return $this->_getApp()->getStore($id); - } - - /** - * Retrieve application store object without Store_Exception - * - * @param string|int|Mage_Core_Model_Store $id - * @return Mage_Core_Model_Store - */ - public function getSafeStore($id = null) - { - return $this->_getApp()->getSafeStore($id); - } - - /** - * Retrieve stores array - * - * @param bool $withDefault - * @param bool $codeKey - * @return array - */ - public function getStores($withDefault = false, $codeKey = false) - { - return $this->_getApp()->getStores($withDefault, $codeKey); - } - - /** - * Retrieve default store for default group and website - * - * @return Mage_Core_Model_Store - */ - public function getDefaultStoreView() - { - return $this->_getApp()->getDefaultStoreView(); - } - - /** - * Get distributive locale code - * - * @return string - */ - public function getDistroLocaleCode() - { - return $this->_getApp()->getDistroLocaleCode(); - } - - /** - * Retrieve application website object - * - * @param null|bool|int|string|Mage_Core_Model_Website $id - * @return Mage_Core_Model_Website - * @throws Mage_Core_Exception - */ - public function getWebsite($id = null) - { - return $this->_getApp()->getWebsite($id); - } - - /** - * Get websites - * - * @param bool $withDefault - * @param bool $codeKey - * @return array - */ - public function getWebsites($withDefault = false, $codeKey = false) - { - return $this->_getApp()->getWebsites($withDefault, $codeKey); - } - - /** - * Retrieve application store group object - * - * @param null|Mage_Core_Model_Store_Group|string $id - * @return Mage_Core_Model_Store_Group - * @throws Mage_Core_Exception - */ - public function getGroup($id = null) - { - return $this->_getApp()->getGroup($id); - } - - /** - * Retrieve application locale object - * - * @return Mage_Core_Model_Locale - */ - public function getLocale() - { - return $this->_getApp()->getLocale(); - } - - /** - * Retrieve layout object - * - * @return Mage_Core_Model_Layout - */ - public function getLayout() - { - return $this->_getApp()->getLayout(); - } - - /** - * Retrieve helper object - * - * @param string $name - * @return Mage_Core_Helper_Abstract - */ - public function getHelper($name) - { - return $this->_getApp()->getHelper($name); - } - - /** - * Retrieve application base currency code - * - * @return string - */ - public function getBaseCurrencyCode() - { - return $this->_getApp()->getBaseCurrencyCode(); - } - - /** - * Retrieve configuration object - * - * @return Mage_Core_Model_Config - */ - public function getConfig() - { - return $this->_getApp()->getConfig(); - } - - /** - * Retrieve front controller object - * - * @return Mage_Core_Controller_Varien_Front - */ - public function getFrontController() - { - return $this->_getApp()->getFrontController(); - } - - /** - * Get core cache model - * - * @return Mage_Core_Model_Cache - */ - public function getCacheInstance() - { - return $this->_getApp()->getCacheInstance(); - } - - /** - * Retrieve cache object - * - * @return Zend_Cache_Core - */ - public function getCache() - { - return $this->_getApp()->getCache(); - } - - /** - * Loading cache data - * - * @param string $id - * @return mixed - */ - public function loadCache($id) - { - return $this->_getApp()->loadCache($id); - } - - /** - * Saving cache data - * - * @param mixed $data - * @param string $id - * @param array $tags - * @param bool $lifeTime - * @return Mage_Core_Model_AppInterface - */ - public function saveCache($data, $id, $tags = array(), $lifeTime = false) - { - return $this->_getApp()->saveCache($data, $id, $tags, $lifeTime); - } - - /** - * Remove cache - * - * @param string $id - * @return Mage_Core_Model_AppInterface - */ - public function removeCache($id) - { - return $this->_getApp()->removeCache($id); - } - - /** - * Cleaning cache - * - * @param array $tags - * @return Mage_Core_Model_AppInterface - */ - public function cleanCache($tags = array()) - { - return $this->_getApp()->cleanCache($tags); - } - - /** - * Check whether to use cache for specific component - * - * @param null|string $type - * @return boolean - */ - public function useCache($type = null) - { - return $this->_getApp()->useCache($type); - } - - /** - * Save cache usage settings - * - * @param array $data - * @return Mage_Core_Model_AppInterface - */ - public function saveUseCache($data) - { - return $this->_getApp()->saveUseCache($data); - } - - /** - * Deletes all session files - * - * @return Mage_Core_Model_AppInterface - */ - public function cleanAllSessions() - { - return $this->_getApp()->cleanAllSessions(); - } - - /** - * Retrieve request object - * - * @return Mage_Core_Controller_Request_Http - */ - public function getRequest() - { - return $this->_getApp()->getRequest(); - } - - /** - * Request setter - * - * @param Mage_Core_Controller_Request_Http $request - * @return Mage_Core_Model_AppInterface - */ - public function setRequest(Mage_Core_Controller_Request_Http $request) - { - return $this->_getApp()->setRequest($request); - } - - /** - * Retrieve response object - * - * @return Zend_Controller_Response_Http - */ - public function getResponse() - { - return $this->_getApp()->getResponse(); - } - - /** - * Response setter - * - * @param Mage_Core_Controller_Response_Http $response - * @return Mage_Core_Model_AppInterface - */ - public function setResponse(Mage_Core_Controller_Response_Http $response) - { - return $this->_getApp()->setResponse($response); - } - - /** - * @throws Mage_Core_Model_Store_Exception - */ - public function throwStoreException() - { - $this->_getApp()->throwStoreException(); - } - - /** - * Set use session var instead of SID for URL - * - * @param bool $var - * @return Mage_Core_Model_AppInterface - */ - public function setUseSessionVar($var) - { - return $this->_getApp()->setUseSessionVar($var); - } - - /** - * Retrieve use flag session var instead of SID for URL - * - * @return bool - */ - public function getUseSessionVar() - { - return $this->_getApp()->getUseSessionVar(); - } - - /** - * Get either default or any store view - * - * @return Mage_Core_Model_Store - */ - public function getAnyStoreView() - { - return $this->_getApp()->getAnyStoreView(); - } - - /** - * Set Use session in URL flag - * - * @param bool $flag - * @return Mage_Core_Model_AppInterface - */ - public function setUseSessionInUrl($flag = true) - { - return $this->_getApp()->setUseSessionInUrl($flag); - } - - /** - * Retrieve use session in URL flag - * - * @return bool - */ - public function getUseSessionInUrl() - { - return $this->_getApp()->getUseSessionInUrl(); - } - - /** - * Allow or disallow single store mode - * - * @param bool $value - */ - public function setIsSingleStoreModeAllowed($value) - { - $this->_getApp()->setIsSingleStoreModeAllowed($value); - } - - /** - * Prepare array of store groups - * can be filtered to contain default store group or not by $withDefault flag - * depending on flag $codeKey array keys can be group id or group code - * - * @param bool $withDefault - * @param bool $codeKey - * @return array - */ - public function getGroups($withDefault = false, $codeKey = false) - { - return $this->_getApp()->getGroups($withDefault, $codeKey); - } - - /** - * Unset website by id from app cache - * - * @param null|bool|int|string|Mage_Core_Model_Website $id - */ - public function clearWebsiteCache($id = null) - { - $this->_getApp()->clearWebsiteCache($id); - } - - /** - * Check if developer mode is enabled. - * - * @return bool - */ - public function isDeveloperMode() - { - return $this->_getApp()->isDeveloperMode(); - } -} diff --git a/app/code/core/Mage/Core/Model/App/State.php b/app/code/core/Mage/Core/Model/App/State.php deleted file mode 100644 index 941238633d71e..0000000000000 --- a/app/code/core/Mage/Core/Model/App/State.php +++ /dev/null @@ -1,109 +0,0 @@ - 1, - 'hashed_directory_umask' => 0777, - 'file_name_prefix' => 'mage', - ); - - /** - * Disallow cache saving - * - * @var bool - */ - protected $_disallowSave = false; - - /** - * List of allowed cache options - * - * @var array - */ - protected $_allowedCacheOptions = null; - - /** - * @var bool - */ - protected $_globalBanUseCache = false; - - /** - * @param Mage_Core_Model_ConfigInterface $config - * @param Mage_Core_Model_Config_Primary $cacheConfig - * @param Mage_Core_Model_Dir $dirs - * @param Mage_Core_Model_Factory_Helper $helperFactory - * @param bool $banCache - * @param array $options - */ - public function __construct( - Mage_Core_Model_ConfigInterface $config, - Mage_Core_Model_Config_Primary $cacheConfig, - Mage_Core_Model_Dir $dirs, - Mage_Core_Model_Factory_Helper $helperFactory, - $banCache = false, - array $options = array() - ) { - $configOptions = $cacheConfig->getNode('global/cache'); - if ($configOptions) { - $configOptions = $configOptions->asArray(); - } else { - $configOptions = array(); - } - $options = array_merge($configOptions, $options); - - $this->_config = $config; - $this->_helperFactory = $helperFactory; - $this->_globalBanUseCache = $banCache; - - $this->_defaultBackendOptions['cache_dir'] = $dirs->getDir(Mage_Core_Model_Dir::CACHE); - /** - * Initialize id prefix - */ - $this->_idPrefix = isset($options['id_prefix']) ? $options['id_prefix'] : ''; - if (!$this->_idPrefix && isset($options['prefix'])) { - $this->_idPrefix = $options['prefix']; - } - if (empty($this->_idPrefix)) { - $this->_idPrefix = substr(md5($dirs->getDir(Mage_Core_Model_Dir::CONFIG)), 0, 3) . '_'; - } - - $backend = $this->_getBackendOptions($options); - $frontend = $this->_getFrontendOptions($options); - - // Start profiling - $profilerTags = $this->_generateProfilerTags('create', $backend['type'], $frontend['type']); - - Magento_Profiler::start('cache_frontend_create', $profilerTags); - - // create cache - $this->_frontend = Zend_Cache::factory($frontend['type'], $backend['type'], $frontend, $backend['options'], - true, true, true - ); - - // stop profiling - Magento_Profiler::stop('cache_frontend_create'); - - if (isset($options['disallow_save'])) { - $this->_disallowSave = $options['disallow_save']; - } - } - - /** - * Get cache backend options. Result array contain backend type ('type' key) and backend options ('options') - * - * @param array $cacheOptions - * @return array - */ - protected function _getBackendOptions(array $cacheOptions) - { - $enable2levels = false; - $type = isset($cacheOptions['backend']) ? $cacheOptions['backend'] : $this->_defaultBackend; - if (isset($cacheOptions['backend_options']) && is_array($cacheOptions['backend_options'])) { - $options = $cacheOptions['backend_options']; - } else { - $options = array(); - } - - $backendType = false; - switch (strtolower($type)) { - case 'sqlite': - if (extension_loaded('sqlite') && isset($options['cache_db_complete_path'])) { - $backendType = 'Sqlite'; - } - break; - case 'memcached': - if (extension_loaded('memcached')) { - if (isset($cacheOptions['memcached'])) { - $options = $cacheOptions['memcached']; - } - $enable2levels = true; - $backendType = 'Libmemcached'; - } elseif (extension_loaded('memcache')) { - if (isset($cacheOptions['memcached'])) { - $options = $cacheOptions['memcached']; - } - $enable2levels = true; - $backendType = 'Memcached'; - } - break; - case 'apc': - if (extension_loaded('apc') && ini_get('apc.enabled')) { - $enable2levels = true; - $backendType = 'Apc'; - } - break; - case 'xcache': - if (extension_loaded('xcache')) { - $enable2levels = true; - $backendType = 'Xcache'; - } - break; - case 'eaccelerator': - case 'varien_cache_backend_eaccelerator': - if (extension_loaded('eaccelerator') && ini_get('eaccelerator.enable')) { - $enable2levels = true; - $backendType = 'Varien_Cache_Backend_Eaccelerator'; - } - break; - case 'database': - $backendType = 'Varien_Cache_Backend_Database'; - $options = $this->getDbAdapterOptions(); - break; - default: - if ($type != $this->_defaultBackend) { - try { - if (class_exists($type, true)) { - $implements = class_implements($type, true); - if (in_array('Zend_Cache_Backend_Interface', $implements)) { - $backendType = $type; - } - } - } catch (Exception $e) { - } - } - } - - if (!$backendType) { - $backendType = $this->_defaultBackend; - foreach ($this->_defaultBackendOptions as $option => $value) { - if (!array_key_exists($option, $options)) { - $options[$option] = $value; - } - } - } - - $backendOptions = array('type' => $backendType, 'options' => $options); - if ($enable2levels) { - $backendOptions = $this->_getTwoLevelsBackendOptions($backendOptions, $cacheOptions); - } - return $backendOptions; - } - - /** - * Get options for database backend type - * - * @return array - */ - protected function getDbAdapterOptions() - { - $options['adapter_callback'] = array($this, 'getDbAdapter'); - $options['data_table'] = Mage::getSingleton('Mage_Core_Model_Resource')->getTableName('core_cache'); - $options['tags_table'] = Mage::getSingleton('Mage_Core_Model_Resource')->getTableName('core_cache_tag'); - return $options; - } - - /** - * Initialize two levels backend model options - * - * @param array $fastOptions fast level backend type and options - * @param array $cacheOptions all cache options - * @return array - */ - protected function _getTwoLevelsBackendOptions($fastOptions, $cacheOptions) - { - $options = array(); - $options['fast_backend'] = $fastOptions['type']; - $options['fast_backend_options'] = $fastOptions['options']; - $options['fast_backend_custom_naming'] = true; - $options['fast_backend_autoload'] = true; - $options['slow_backend_custom_naming'] = true; - $options['slow_backend_autoload'] = true; - - if (isset($cacheOptions['auto_refresh_fast_cache'])) { - $options['auto_refresh_fast_cache'] = (bool)$cacheOptions['auto_refresh_fast_cache']; - } else { - $options['auto_refresh_fast_cache'] = false; - } - if (isset($cacheOptions['slow_backend'])) { - $options['slow_backend'] = $cacheOptions['slow_backend']; - } else { - $options['slow_backend'] = $this->_defaultBackend; - } - if (isset($cacheOptions['slow_backend_options'])) { - $options['slow_backend_options'] = $cacheOptions['slow_backend_options']; - } else { - $options['slow_backend_options'] = $this->_defaultBackendOptions; - } - if ($options['slow_backend'] == 'database') { - $options['slow_backend'] = 'Varien_Cache_Backend_Database'; - $options['slow_backend_options'] = $this->getDbAdapterOptions(); - if (isset($cacheOptions['slow_backend_store_data'])) { - $options['slow_backend_options']['store_data'] = (bool)$cacheOptions['slow_backend_store_data']; - } else { - $options['slow_backend_options']['store_data'] = false; - } - } - - $backend = array( - 'type' => 'TwoLevels', - 'options' => $options - ); - return $backend; - } - - /** - * Get options of cache frontend (options of Zend_Cache_Core) - * - * @param array $cacheOptions - * @return array - */ - protected function _getFrontendOptions(array $cacheOptions) - { - $options = isset($cacheOptions['frontend_options']) ? $cacheOptions['frontend_options'] : array(); - if (!array_key_exists('caching', $options)) { - $options['caching'] = true; - } - if (!array_key_exists('lifetime', $options)) { - $options['lifetime'] = isset($cacheOptions['lifetime']) ? $cacheOptions['lifetime'] - : self::DEFAULT_LIFETIME; - } - if (!array_key_exists('automatic_cleaning_factor', $options)) { - $options['automatic_cleaning_factor'] = 0; - } - $options['cache_id_prefix'] = $this->_idPrefix; - $options['type'] = isset($cacheOptions['frontend']) ? $cacheOptions['frontend'] : 'Varien_Cache_Core'; - return $options; - } - - /** - * Prepare unified valid identifier with preffix - * - * @param string $id - * @return string - */ - protected function _id($id) - { - if ($id) { - $id = strtoupper($id); - } - return $id; - } - - /** - * Prepare cache tags. - * - * @param array $tags - * @return array - */ - protected function _tags($tags = array()) - { - foreach ($tags as $key => $value) { - $tags[$key] = $this->_id($value); - } - return $tags; - } - - /** - * Generate Magento Profiler tags - * - * @param string $operation - * @param string $frontendType - * @param string $backendType - * @return array - */ - protected function _generateProfilerTags($operation, $frontendType = '', $backendType = '') - { - $profilerTags = array('group' => 'cache', - 'operation' => 'cache:' . $operation); - - if (!empty($frontendType)) { - $profilerTags['frontend_type'] = $frontendType; - } elseif ($this->_frontend) { - $profilerTags['frontend_type'] = get_class($this->_frontend); - } - - if (!empty($backendType)) { - $profilerTags['backend_type'] = $backendType; - } elseif ($this->_frontend) { - $parsedBackendType = $this->_getBackendType(); - if ($parsedBackendType) { - $profilerTags['backend_type'] = $parsedBackendType; - } - } - - return $profilerTags; - } - - /** - * Get cache backend type - * - * @return string - */ - protected function _getBackendType() - { - $backendType = ''; - - if ($this->_frontend) { - $backend = $this->_frontend->getBackend(); - $backendClass = get_class($backend); - - $possibleCacheBackends = array('Zend_Cache_Backend_', 'Varien_Cache_Backend_'); - foreach ($possibleCacheBackends as $backendClassStart) { - if (substr($backendClass, 0, strlen($backendClassStart)) == $backendClassStart) { - $backendType = substr($backendClass, strlen($backendClassStart)); - break; - } - } - } - - return $backendType; - } - - /** - * Get cache frontend API object - * - * @return Zend_Cache_Core - */ - public function getFrontend() - { - return $this->_frontend; - } - - /** - * Load data from cache by id - * - * @param string $id - * @return string - */ - public function load($id) - { - Magento_Profiler::start('cache_load', $this->_generateProfilerTags('load')); - $result = $this->_frontend->load($this->_id($id)); - Magento_Profiler::stop('cache_load'); - - return $result; - } - - /** - * Save data - * - * @param string $data - * @param string $id - * @param array $tags - * @param int $lifeTime - * @return bool - */ - public function save($data, $id, $tags=array(), $lifeTime=null) - { - /** - * Add global magento cache tag to all cached data exclude config cache - */ - if (!in_array(Mage_Core_Model_Config::CACHE_TAG, $tags)) { - $tags[] = Mage_Core_Model_AppInterface::CACHE_TAG; - } - if ($this->_disallowSave) { - return true; - } - - Magento_Profiler::start('cache_save', $this->_generateProfilerTags('save')); - $result = $this->_frontend->save((string)$data, $this->_id($id), $this->_tags($tags), $lifeTime); - Magento_Profiler::stop('cache_save'); - - return $result; - } - - /** - * Remove cached data by identifier - * - * @param string $id - * @return bool - */ - public function remove($id) - { - Magento_Profiler::start('cache_remove', $this->_generateProfilerTags('remove')); - $result = $this->_frontend->remove($this->_id($id)); - Magento_Profiler::stop('cache_remove'); - - return $result; - } - - /** - * Clean cached data by specific tag - * - * @param array $tags - * @return bool - */ - public function clean($tags = array()) - { - Magento_Profiler::start('cache_clean', $this->_generateProfilerTags('clean')); - - $mode = Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG; - if (!empty($tags)) { - if (!is_array($tags)) { - $tags = array($tags); - } - $res = $this->_frontend->clean($mode, $this->_tags($tags)); - } else { - $res = $this->_frontend->clean($mode, array(Mage_Core_Model_AppInterface::CACHE_TAG)); - $res = $res && $this->_frontend->clean($mode, array(Mage_Core_Model_Config::CACHE_TAG)); - } - - Magento_Profiler::stop('cache_clean'); - - return $res; - } - - /** - * Clean cached data by specific tag - * - * @return bool - */ - public function flush() - { - Magento_Profiler::start('cache_flush', $this->_generateProfilerTags('flush')); - $res = $this->_frontend->clean(); - Magento_Profiler::stop('cache_flush'); - - return $res; - } - - /** - * Get adapter for database cache backend model - * - * @return Zend_Db_Adapter_Abstract - */ - public function getDbAdapter() - { - return Mage::getSingleton('Mage_Core_Model_Resource')->getConnection('core_write'); - } - - /** - * Get cache resource model - * - * @return Mage_Core_Model_Resource_Cache - */ - protected function _getResource() - { - return Mage::getResourceSingleton('Mage_Core_Model_Resource_Cache'); - } - - /** - * Initialize cache types options - * - * @return Mage_Core_Model_Cache - */ - protected function _initOptions() - { - $options = $this->load(self::OPTIONS_CACHE_ID); - if ($options === false) { - $options = $this->_getResource()->getAllOptions(); - if (is_array($options)) { - $this->_allowedCacheOptions = $options; - $this->save(serialize($this->_allowedCacheOptions), self::OPTIONS_CACHE_ID); - } else { - $this->_allowedCacheOptions = array(); - } - } else { - $this->_allowedCacheOptions = unserialize($options); - } - - if ($this->_globalBanUseCache) { - foreach ($this->_allowedCacheOptions as $key => $val) { - $this->_allowedCacheOptions[$key] = false; - } - } - - return $this; - } - - /** - * Save cache usage options - * - * @param array $options - * @return Mage_Core_Model_Cache - */ - public function saveOptions($options) - { - $this->remove(self::OPTIONS_CACHE_ID); - $options = $this->_getResource()->saveAllOptions($options); - return $this; - } - - /** - * Check if cache can be used for specific data type - * - * @param string $typeCode - * @return bool - */ - public function canUse($typeCode) - { - if (is_null($this->_allowedCacheOptions)) { - $this->_initOptions(); - } - - if (empty($typeCode)) { - return $this->_allowedCacheOptions; - } else { - if (isset($this->_allowedCacheOptions[$typeCode])) { - return (bool)$this->_allowedCacheOptions[$typeCode]; - } else { - return false; - } - } - } - - /** - * Disable cache usage for specific data type - * - * @param string $typeCode - * @return Mage_Core_Model_Cache - */ - public function banUse($typeCode) - { - $this->_allowedCacheOptions[$typeCode] = false; - return $this; - } - - /** - * Enable cache usage for specific data type - * - * @param string $typeCode - * @return Mage_Core_Model_Cache - */ - public function allowUse($typeCode) - { - $this->_allowedCacheOptions[$typeCode] = true; - return $this; - } - - /** - * Get cache tags by cache type from configuration - * - * @param string $type - * @return array - */ - public function getTagsByType($type) - { - $path = self::XML_PATH_TYPES.'/'.$type.'/tags'; - $tagsConfig = $this->_config->getNode($path); - if ($tagsConfig) { - $tags = (string) $tagsConfig; - $tags = explode(',', $tags); - } else { - $tags = false; - } - return $tags; - } - - /** - * Get information about all declared cache types - * - * @return array - */ - public function getTypes() - { - $types = array(); - $config = $this->_config->getNode(self::XML_PATH_TYPES); - if ($config) { - /** @var $helper Mage_Core_Helper_Data*/ - $helper = $this->_helperFactory->get('Mage_Core_Helper_Data'); - foreach ($config->children() as $type=>$node) { - $types[$type] = new Varien_Object(array( - 'id' => $type, - 'cache_type' => $helper->__((string)$node->label), - 'description' => $helper->__((string)$node->description), - 'tags' => strtoupper((string) $node->tags), - 'status' => (int)$this->canUse($type), - )); - } - } - return $types; - } - - /** - * Get invalidate types codes - * - * @return array - */ - protected function _getInvalidatedTypes() - { - $types = $this->load(self::INVALIDATED_TYPES); - if ($types) { - $types = unserialize($types); - } else { - $types = array(); - } - return $types; - } - - /** - * Save invalidated cache types - * - * @param array $types - * @return Mage_Core_Model_Cache - */ - protected function _saveInvalidatedTypes($types) - { - $this->save(serialize($types), self::INVALIDATED_TYPES); - return $this; - } - - /** - * Get array of all invalidated cache types - * - * @return array - */ - public function getInvalidatedTypes() - { - $invalidatedTypes = array(); - $types = $this->_getInvalidatedTypes(); - if ($types) { - $allTypes = $this->getTypes(); - foreach ($types as $type => $flag) { - if (isset($allTypes[$type]) && $this->canUse($type)) { - $invalidatedTypes[$type] = $allTypes[$type]; - } - } - } - return $invalidatedTypes; - } - - /** - * Mark specific cache type(s) as invalidated - * - * @param string|array $typeCode - * @return Mage_Core_Model_Cache - */ - public function invalidateType($typeCode) - { - $types = $this->_getInvalidatedTypes(); - if (!is_array($typeCode)) { - $typeCode = array($typeCode); - } - foreach ($typeCode as $code) { - $types[$code] = 1; - } - $this->_saveInvalidatedTypes($types); - return $this; - } - - /** - * Clean cached data for specific cache type - * - * @param string $typeCode - * @return Mage_Core_Model_Cache - */ - public function cleanType($typeCode) - { - $tags = $this->getTagsByType($typeCode); - $this->clean($tags); - - $types = $this->_getInvalidatedTypes(); - unset($types[$typeCode]); - $this->_saveInvalidatedTypes($types); - return $this; - } -} diff --git a/app/code/core/Mage/Core/Model/Cache/Proxy.php b/app/code/core/Mage/Core/Model/Cache/Proxy.php deleted file mode 100644 index a2cfe18b6ac54..0000000000000 --- a/app/code/core/Mage/Core/Model/Cache/Proxy.php +++ /dev/null @@ -1,236 +0,0 @@ -_objectManager = $objectManager; - } - - /** - * Create cache model - * - * @return Mage_Core_Model_Cache|mixed - */ - protected function _getCache() - { - if (null == $this->_cache) { - $this->_cache = $this->_objectManager->get('Mage_Core_Model_Cache'); - } - return $this->_cache; - } - - /** - * Get cache frontend API object - * - * @return Zend_Cache_Core - */ - public function getFrontend() - { - return $this->_getCache()->getFrontend(); - } - - /** - * Load data from cache by id - * - * @param string $id - * @return string - */ - public function load($id) - { - return $this->_getCache()->load($id); - } - - /** - * Save data - * - * @param string $data - * @param string $id - * @param array $tags - * @param int $lifeTime - * @return bool - */ - public function save($data, $id, $tags = array(), $lifeTime = null) - { - return $this->_getCache()->save($data, $id, $tags, $lifeTime); - } - - /** - * Remove cached data by identifier - * - * @param string $id - * @return bool - */ - public function remove($id) - { - return $this->_getCache()->remove($id); - } - - /** - * Clean cached data by specific tag - * - * @param array $tags - * @return bool - */ - public function clean($tags = array()) - { - return $this->_getCache()->clean($tags); - } - - /** - * Clean cached data by specific tag - * - * @return bool - */ - public function flush() - { - return $this->_getCache()->flush(); - } - - /** - * Get adapter for database cache backend model - * - * @return Zend_Db_Adapter_Abstract - */ - public function getDbAdapter() - { - return $this->_getCache()->getDbAdapter(); - } - - /** - * Save cache usage options - * - * @param array $options - * @return Mage_Core_Model_Cache - */ - public function saveOptions($options) - { - return $this->_getCache()->saveOptions($options); - } - - /** - * Check if cache can be used for specific data type - * - * @param string $typeCode - * @return bool - */ - public function canUse($typeCode) - { - return $this->_getCache()->canUse($typeCode); - } - - /** - * Disable cache usage for specific data type - * - * @param string $typeCode - * @return Mage_Core_Model_Cache - */ - public function banUse($typeCode) - { - return $this->_getCache()->banUse($typeCode); - } - - /** - * Enable cache usage for specific data type - * - * @param string $typeCode - * @return Mage_Core_Model_Cache - */ - public function allowUse($typeCode) - { - return $this->_getCache()->allowUse($typeCode); - } - - /** - * Get cache tags by cache type from configuration - * - * @param string $type - * @return array - */ - public function getTagsByType($type) - { - return $this->_getCache()->getTagsByType($type); - } - - /** - * Get information about all declared cache types - * - * @return array - */ - public function getTypes() - { - return $this->_getCache()->getTypes(); - } - - /** - * Get array of all invalidated cache types - * - * @return array - */ - public function getInvalidatedTypes() - { - return $this->_getCache()->getInvalidatedTypes(); - } - - /** - * Mark specific cache type(s) as invalidated - * - * @param string|array $typeCode - * @return Mage_Core_Model_Cache - */ - public function invalidateType($typeCode) - { - return $this->_getCache()->invalidateType($typeCode); - } - - /** - * Clean cached data for specific cache type - * - * @param string $typeCode - * @return Mage_Core_Model_Cache - */ - public function cleanType($typeCode) - { - return $this->_getCache()->cleanType($typeCode); - } -} diff --git a/app/code/core/Mage/Core/Model/Config.php b/app/code/core/Mage/Core/Model/Config.php deleted file mode 100644 index 68c1659366707..0000000000000 --- a/app/code/core/Mage/Core/Model/Config.php +++ /dev/null @@ -1,685 +0,0 @@ -_objectManager = $objectManager; - $this->_app = $app; - $this->_storage = $storage; - $this->_config = $this->_storage->getConfiguration(); - $this->_moduleReader = $moduleReader; - $this->_invalidator = $invalidator; - $this->_objectManager->setConfiguration($this->getNode('global/di')->asArray()); - Magento_Profiler::stop('config_load'); - } - - /** - * Load allowed areas from config - * - * @return Mage_Core_Model_Config - */ - protected function _loadAreas() - { - $this->_allowedAreas = array(); - $nodeAreas = $this->getNode('global/areas'); - if (is_object($nodeAreas)) { - foreach ($nodeAreas->asArray() as $areaCode => $areaInfo) { - if (empty($areaCode) - || (!isset($areaInfo['base_controller']) || empty($areaInfo['base_controller'])) - ) { - continue; - } - /** - * TODO: Check of 'routers' nodes existance is excessive: - * TODO: 'routers' check is moved Mage_Core_Model_Config::getRouters() - */ - - /** - * TODO: Routers are not required in API. - * TODO: That is why Check for empty router class moved to Mage_Core_Model_Config::getRouters() - */ - $this->_allowedAreas[$areaCode] = $areaInfo; - } - } - - return $this; - } - - /** - * Returns nodes found by xpath expression - * - * @param string $xpath - * @return array - */ - public function getXpath($xpath) - { - return $this->_config->getXpath($xpath); - } - - /** - * Returns node found by the $path and scope info - * - * @param string $path - * @param string $scope - * @param string|int $scopeCode - * @return Mage_Core_Model_Config_Element - */ - public function getNode($path = null, $scope = '', $scopeCode = null) - { - if ($scope !== '') { - if (('store' === $scope) || ('website' === $scope)) { - $scope .= 's'; - } - if (('default' !== $scope) && is_int($scopeCode)) { - if ('stores' == $scope) { - $scopeCode = $this->_app->getStore($scopeCode)->getCode(); - } elseif ('websites' == $scope) { - $scopeCode = $this->_app->getWebsite($scopeCode)->getCode(); - } else { - Mage::throwException( - $this->_objectManager->get('Mage_Core_Helper_Data') - ->__('Unknown scope "%s".', $scope) - ); - } - } - $path = $scope . ($scopeCode ? '/' . $scopeCode : '' ) . (empty($path) ? '' : '/' . $path); - } - try { - return $this->_config->getNode($path); - } catch (Mage_Core_Model_Config_Cache_Exception $e) { - $this->reinit(); - return $this->_config->getNode($path); - } - } - - /** - * Create node by $path and set its value. - * - * @param string $path separated by slashes - * @param string $value - * @param bool $overwrite - */ - public function setNode($path, $value, $overwrite = true) - { - try { - $this->_config->setNode($path, $value, $overwrite); - } catch (Mage_Core_Model_Config_Cache_Exception $e) { - $this->reinit(); - $this->_config->setNode($path, $value, $overwrite); - } - } - - /** - * Get currently used area code - * @return string|null - */ - public function getCurrentAreaCode() - { - return $this->_currentAreaCode; - } - - /** - * Set currently used area code - * - * @param $areaCode - * @return Mage_Core_Model_Config - */ - public function setCurrentAreaCode($areaCode) - { - $this->_currentAreaCode = $areaCode; - return $this; - } - - /** - * Get allowed areas - * - * @return array - */ - public function getAreas() - { - if (is_null($this->_allowedAreas) ) { - $this->_loadAreas(); - } - return $this->_allowedAreas; - } - - /** - * Retrieve area config by area code - * - * @param string|null $areaCode - * @throws InvalidArgumentException - * @return array - */ - public function getAreaConfig($areaCode = null) - { - $areaCode = empty($areaCode) ? $this->getCurrentAreaCode() : $areaCode; - $areas = $this->getAreas(); - if (!isset($areas[$areaCode])) { - throw new InvalidArgumentException('Requested area (' . $areaCode . ') doesn\'t exist'); - } - return $areas[$areaCode]; - } - - /** - * Identify front name of the requested area. Return current area front name if area code is not specified. - * - * @param string|null $areaCode - * @return string - * @throws LogicException If front name is not defined. - */ - public function getAreaFrontName($areaCode = null) - { - $areaCode = empty($areaCode) ? $this->getCurrentAreaCode() : $areaCode; - $areaConfig = $this->getAreaConfig($areaCode); - if (!isset($areaConfig['frontName'])) { - throw new LogicException(sprintf( - 'Area "%s" must have front name defined in the application config.', - $areaCode - )); - } - return $areaConfig['frontName']; - } - - /** - * Get routers from config - * - * @return array - */ - public function getRouters() - { - $routers = array(); - foreach ($this->getAreas() as $areaCode => $areaInfo) { - if (isset($areaInfo['routers']) && is_array($areaInfo['routers'])) { - foreach ($areaInfo['routers'] as $routerKey => $routerInfo ) { - if (!isset($routerInfo['class']) || empty($routerInfo['class'])) { - continue; - } - $routerInfo = array_merge($routerInfo, $areaInfo); - unset($routerInfo['routers']); - $routerInfo['area'] = $areaCode; - $routers[$routerKey] = $routerInfo; - } - } - } - return $routers; - } - - /** - * Get module config node - * - * @param string $moduleName - * @return Varien_Simplexml_Element - */ - public function getModuleConfig($moduleName = '') - { - $modules = $this->getNode('modules'); - if ('' === $moduleName) { - return $modules; - } else { - return $modules->$moduleName; - } - } - - /** - * Check if specified module is enabled - * - * @param string $moduleName - * @return bool - */ - public function isModuleEnabled($moduleName) - { - if (!$this->getNode('modules/' . $moduleName)) { - return false; - } - - $isActive = $this->getNode('modules/' . $moduleName . '/active'); - if (!$isActive || !in_array((string)$isActive, array('true', '1'))) { - return false; - } - return true; - } - - /** - * Get module directory by directory type - * - * @param string $type - * @param string $moduleName - * @return string - */ - public function getModuleDir($type, $moduleName) - { - return $this->_moduleReader->getModuleDir($type, $moduleName); - } - - /** - * Set path to the corresponding module directory - * - * @param string $moduleName - * @param string $type directory type (etc, controllers, locale etc) - * @param string $path - * @return Mage_Core_Model_Config - */ - public function setModuleDir($moduleName, $type, $path) - { - $this->_moduleReader->setModuleDir($moduleName, $type, $path); - return $this; - } - - /** - * Retrieve store Ids for $path with checking - * - * if empty $allowValues then retrieve all stores values - * - * return array($storeId => $pathValue) - * - * @param string $path - * @param array $allowValues - * @param string $useAsKey - * @return array - */ - public function getStoresConfigByPath($path, $allowValues = array(), $useAsKey = 'id') - { - $storeValues = array(); - $stores = $this->getNode('stores'); - /** @var $store Varien_Simplexml_Element */ - foreach ($stores->children() as $code => $store) { - switch ($useAsKey) { - case 'id': - $key = (int) $store->descend('system/store/id'); - break; - - case 'code': - $key = $code; - break; - - case 'name': - $key = (string) $store->descend('system/store/name'); - break; - - default: - $key = false; - break; - } - - if ($key === false) { - continue; - } - - $pathValue = (string) $store->descend($path); - - if (empty($allowValues)) { - $storeValues[$key] = $pathValue; - } elseif (in_array($pathValue, $allowValues)) { - $storeValues[$key] = $pathValue; - } - } - - return $storeValues; - } - - /** - * Get fieldset from configuration - * - * @param string $name fieldset name - * @param string $root fieldset area, could be 'admin' - * @return null|array - */ - public function getFieldset($name, $root = 'global') - { - /** @var $config Mage_Core_Model_Config_Base */ - $config = $this->_objectManager->get('Mage_Core_Model_Config_Fieldset'); - $rootNode = $config->getNode($root . '/fieldsets'); - if (!$rootNode) { - return null; - } - return $rootNode->$name ? $rootNode->$name->children() : null; - } - - /** - * Get standard path variables. - * - * To be used in blocks, templates, etc. - * - * @return array - */ - public function getPathVars() - { - $path = array(); - $path['baseUrl'] = Mage::getBaseUrl(); - $path['baseSecureUrl'] = Mage::getBaseUrl('link', true); - return $path; - } - - /** - * Check whether given path should be secure according to configuration security requirements for URL - * "Secure" should not be confused with https protocol, it is about web/secure/*_url settings usage only - * - * @param string $url - * @return bool - */ - public function shouldUrlBeSecure($url) - { - if (!Mage::getStoreConfigFlag(Mage_Core_Model_Store::XML_PATH_SECURE_IN_FRONTEND)) { - return false; - } - - if (!isset($this->_secureUrlCache[$url])) { - $this->_secureUrlCache[$url] = false; - $secureUrls = $this->getNode('frontend/secure_url'); - foreach ($secureUrls->children() as $match) { - if (strpos($url, (string)$match) === 0) { - $this->_secureUrlCache[$url] = true; - break; - } - } - } - return $this->_secureUrlCache[$url]; - } - - /** - * Get default server variables values - * - * @return array - */ - public function getDistroBaseUrl() - { - if (isset($_SERVER['SCRIPT_NAME']) && isset($_SERVER['HTTP_HOST'])) { - $secure = (!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] != 'off')) - || (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443'); - $scheme = ($secure ? 'https' : 'http') . '://' ; - - $hostArr = explode(':', $_SERVER['HTTP_HOST']); - $host = $hostArr[0]; - $port = isset($hostArr[1]) && (!$secure && $hostArr[1] != 80 || $secure && $hostArr[1] != 443) - ? ':'. $hostArr[1] - : ''; - $path = Mage::getObjectManager()->get('Mage_Core_Controller_Request_Http')->getBasePath(); - - return $scheme . $host . $port . rtrim($path, '/') . '/'; - } - return 'http://localhost/'; - } - - /** - * Determine whether provided name begins from any available modules, according to namespaces priority - * If matched, returns as the matched module "factory" name or a fully qualified module name - * - * @param string $name - * @param bool $asFullModuleName - * @return string - */ - public function determineOmittedNamespace($name, $asFullModuleName = false) - { - if (null === $this->_moduleNamespaces) { - $this->_moduleNamespaces = array(); - /** @var $moduleConfig Varien_Simplexml_Element */ - foreach ($this->getXpath('modules/*') as $moduleConfig) { - if ((string)$moduleConfig->active == 'true') { - $moduleName = $moduleConfig->getName(); - $module = strtolower($moduleName); - $this->_moduleNamespaces[substr($module, 0, strpos($module, '_'))][$module] = $moduleName; - } - } - } - - $name = explode('_', strtolower($name)); - $partsNum = count($name); - $defaultNamespaceFlag = false; - foreach ($this->_moduleNamespaces as $namespaceName => $namespace) { - // assume the namespace is omitted (default namespace only, which comes first) - if ($defaultNamespaceFlag === false) { - $defaultNamespaceFlag = true; - $defaultNS = $namespaceName . '_' . $name[0]; - if (isset($namespace[$defaultNS])) { - return $asFullModuleName ? $namespace[$defaultNS] : $name[0]; // return omitted as well - } - } - // assume namespace is qualified - if (isset($name[1])) { - $fullNS = $name[0] . '_' . $name[1]; - if (2 <= $partsNum && isset($namespace[$fullNS])) { - return $asFullModuleName ? $namespace[$fullNS] : $fullNS; - } - } - } - return ''; - } - - /** - * Reinitialize configuration - * - * @return Mage_Core_Model_Config - */ - public function reinit() - { - $this->removeCache(); - $this->_invalidator->invalidate(); - $this->_config = $this->_storage->getConfiguration(); - $this->_cacheInstanceId = null; - } - - /** - * Get model class instance. - * - * Example: - * $config->getModelInstance('Mage_Catalog_Model_Resource_Product') - * - * Will instantiate Mage_Catalog_Model_Resource_Product - * - * @param string $modelClass - * @param array|object $constructArguments - * @return Mage_Core_Model_Abstract|bool - */ - public function getModelInstance($modelClass = '', $constructArguments = array()) - { - if (class_exists($modelClass)) { - Magento_Profiler::start('FACTORY:' . $modelClass); - $obj = $this->_objectManager->create($modelClass, $constructArguments); - Magento_Profiler::stop('FACTORY:' . $modelClass); - return $obj; - } else { - return false; - } - } - - /** - * Get resource model object by alias - * - * @param string $modelClass - * @param array $constructArguments - * @return object - */ - public function getResourceModelInstance($modelClass='', $constructArguments=array()) - { - return $this->getModelInstance($modelClass, $constructArguments); - } - - /** - * Remove configuration cache - */ - public function removeCache() - { - /** @var $eventManager Mage_Core_Model_Event_Manager */ - $eventManager = $this->_objectManager->get('Mage_Core_Model_Event_Manager'); - $eventManager->dispatch('application_clean_cache', array('tags' => array(self::CACHE_TAG))); - $this->_storage->removeCache(); - } -} diff --git a/app/code/core/Mage/Core/Model/Config/Base.php b/app/code/core/Mage/Core/Model/Config/Base.php deleted file mode 100644 index bb69a3a1abb76..0000000000000 --- a/app/code/core/Mage/Core/Model/Config/Base.php +++ /dev/null @@ -1,75 +0,0 @@ - - */ - -class Mage_Core_Model_Config_Base extends Varien_Simplexml_Config implements Mage_Core_Model_ConfigInterface -{ - /** - * List of instances - * - * @var array - */ - public static $instances = array(); - - /** - * @param string|Varien_Simplexml_Element $sourceData $sourceData - */ - public function __construct($sourceData = null) - { - $this->_elementClass = 'Mage_Core_Model_Config_Element'; - parent::__construct($sourceData); - self::$instances[] = $this; - } - - /** - * Reinitialize config object - */ - public function reinit() - { - - } - - /** - * Cleanup objects because of simplexml memory leak - */ - public static function destroy() - { - foreach (self::$instances as $instance) { - $instance->_xml = null; - } - self::$instances = array(); - } -} diff --git a/app/code/core/Mage/Core/Model/Config/Cache.php b/app/code/core/Mage/Core/Model/Config/Cache.php deleted file mode 100644 index 6bea9b8717200..0000000000000 --- a/app/code/core/Mage/Core/Model/Config/Cache.php +++ /dev/null @@ -1,261 +0,0 @@ -_containerFactory = $containerFactory; - $this->_cache = $cache; - $this->_configSections = $configSections; - $this->_cacheLockId = $this->_cacheId . '.lock'; - $this->_baseFactory = $baseFactory; - } - - /** - * Save cache of specified - * - * @param string $idPrefix cache id prefix - * @param string $sectionName - * @param Varien_Simplexml_Element $source - * @param int $recursionLevel - * @param array $tags - * @SuppressWarnings(PHPMD.UnusedLocalVariable) - */ - protected function _saveSectionCache($idPrefix, $sectionName, $source, $recursionLevel = 0, $tags = array()) - { - if ($source && $source->$sectionName) { - $cacheId = $idPrefix . '_' . $sectionName; - if ($recursionLevel > 0) { - foreach ($source->$sectionName->children() as $subSectionName => $node) { - $this->_saveSectionCache( - $cacheId, $subSectionName, $source->$sectionName, $recursionLevel-1, $tags - ); - } - } - $this->_cachePartsForSave[$cacheId] = $source->$sectionName->asNiceXml('', false); - } - } - - /** - * Lock caching to prevent concurrent cache writes - */ - protected function _lock() - { - $this->_cache->save(time(), $this->_cacheLockId, array(), 60); - } - - /** - * Unlock caching - */ - protected function _unlock() - { - $this->_cache->remove($this->_cacheLockId); - } - - /** - * Check whether caching is locked - * - * @return bool - */ - protected function _isLocked() - { - return !!$this->_cache->load($this->_cacheLockId); - } - - /** - * Set cache lifetime - * - * @param int $lifetime - */ - public function setCacheLifetime($lifetime) - { - $this->_cacheLifetime = $lifetime; - } - - /** - * Retrieve cache lifetime - * - * @return int - */ - public function getCacheLifeTime() - { - return $this->_cacheLifetime; - } - - /** - * @return Mage_Core_Model_ConfigInterface|bool - */ - public function load() - { - $canUse = $this->_cache->canUse('config'); - if (!$this->_loadedConfig) { - $config = ($canUse && false == $this->_isLocked()) - ? $this->_cache->load($this->_cacheId) - : false; - - if ($config) { - $this->_loadedConfig = $this->_containerFactory->create(array('sourceData' => $config)); - } - } - return $canUse && $this->_loadedConfig ? $this->_loadedConfig: false; - } - - /** - * Save config cache - * - * @param Mage_Core_Model_Config_Base $config - */ - public function save(Mage_Core_Model_Config_Base $config) - { - if ($this->_cache->canUse('config') && false == $this->_isLocked()) { - $cacheSections = $this->_configSections->getSections(); - $xml = clone $config->getNode(); - if (!empty($cacheSections)) { - foreach ($cacheSections as $sectionName => $level) { - $this->_saveSectionCache( - $this->_cacheId, $sectionName, $xml, $level, array(Mage_Core_Model_Config::CACHE_TAG) - ); - unset($xml->$sectionName); - } - } - $this->_cachePartsForSave[$this->_cacheId] = $xml->asNiceXml('', false); - $this->_lock(); - $this->clean(); - foreach ($this->_cachePartsForSave as $cacheId => $cacheData) { - $this->_cache->save( - $cacheData, $cacheId, array(Mage_Core_Model_Config::CACHE_TAG), $this->_cacheLifetime - ); - } - unset($this->_cachePartsForSave); - $this->_unlock(); - } - } - - /** - * Clean cached data - * - * @return bool - */ - public function clean() - { - $this->_loadedConfig = null; - return $this->_cache->clean(array(Mage_Core_Model_Config::CACHE_TAG)); - } - - /** - * Load config section cached data - * - * @param string $sectionKey - * @return Mage_Core_Model_Config_Base|bool - * @throws Mage_Core_Model_Config_Cache_Exception - */ - public function getSection($sectionKey) - { - $cacheId = $this->_cacheId . '_' . $sectionKey; - $result = false; - if ($this->_cache->canUse('config')) { - $xmlString = $this->_cache->load($cacheId); - if ($xmlString) { - $result = $this->_baseFactory->create($xmlString); - } else { - throw new Mage_Core_Model_Config_Cache_Exception(); - } - } - return $result; - } -} diff --git a/app/code/core/Mage/Core/Model/Config/Fieldset.php b/app/code/core/Mage/Core/Model/Config/Fieldset.php deleted file mode 100644 index 6361a1efbc86c..0000000000000 --- a/app/code/core/Mage/Core/Model/Config/Fieldset.php +++ /dev/null @@ -1,59 +0,0 @@ -useCache('config'); - if ($canUseCache) { - /* Setup caching with no checksum validation */ - $this->setCache(Mage::app()->getCache()) - ->setCacheChecksum(null) - ->setCacheId('fieldset_config') - ->setCacheTags(array(Mage_Core_Model_Config::CACHE_TAG)); - if ($this->loadCache()) { - return; - } - } - - $config = $configReader->loadModulesConfiguration('fieldset.xml'); - $this->setXml($config->getNode()); - - if ($canUseCache) { - $this->saveCache(); - } - } -} diff --git a/app/code/core/Mage/Core/Model/Config/Loader/Local.php b/app/code/core/Mage/Core/Model/Config/Loader/Local.php deleted file mode 100644 index 69e64149ba24b..0000000000000 --- a/app/code/core/Mage/Core/Model/Config/Loader/Local.php +++ /dev/null @@ -1,118 +0,0 @@ -_dirs = $dirs; - $this->_customFile = $customFile; - $this->_customConfig = $customConfig; - $this->_prototypeFactory = $prototypeFactory; - } - - /** - * Populate configuration object - * - * @param Mage_Core_Model_Config_Base $config - */ - public function load(Mage_Core_Model_Config_Base $config) - { - $etcDir = $this->_dirs->getDir(Mage_Core_Model_Dir::CONFIG); - $localConfigParts = array(); - - $localConfigFile = $etcDir . DIRECTORY_SEPARATOR . self::LOCAL_CONFIG_FILE; - if (file_exists($localConfigFile)) { - // 1. app/etc/local.xml - $localConfig = $this->_prototypeFactory->create(''); - $localConfig->loadFile($localConfigFile); - $localConfigParts[] = $localConfig; - - // 2. app/etc//.xml - if (preg_match('/^[a-z\d_-]+(\/|\\\)+[a-z\d_-]+\.xml$/', $this->_customFile)) { - $localConfigExtraFile = $etcDir . DIRECTORY_SEPARATOR . $this->_customFile; - $localConfig = $this->_prototypeFactory->create(''); - $localConfig->loadFile($localConfigExtraFile); - $localConfigParts[] = $localConfig; - } - } - - // 3. extra local configuration string - if ($this->_customConfig) { - $localConfig = $this->_prototypeFactory->create(''); - $localConfig->loadString($this->_customConfig); - $localConfigParts[] = $localConfig; - } - - if ($localConfigParts) { - foreach ($localConfigParts as $oneConfigPart) { - $config->extend($oneConfigPart); - } - } - } -} diff --git a/app/code/core/Mage/Core/Model/Config/Loader/Modules/File.php b/app/code/core/Mage/Core/Model/Config/Loader/Modules/File.php deleted file mode 100644 index c1d18bfd2d910..0000000000000 --- a/app/code/core/Mage/Core/Model/Config/Loader/Modules/File.php +++ /dev/null @@ -1,209 +0,0 @@ -_dirs = $dirs; - $this->_prototypeFactory = $prototypeFactory; - } - - /** - * Iterate all active modules "etc" folders and combine data from - * specidied xml file name to one object - * - * @param Mage_Core_Model_ConfigInterface $modulesConfig - * @param string $fileName - * @param Mage_Core_Model_Config_Base|null $mergeToObject - * @param Mage_Core_Model_Config_Base|null $mergeModel - * @param array $configCache - * @return Mage_Core_Model_Config_Base|null - */ - public function loadConfigurationFromFile( - Mage_Core_Model_ConfigInterface $modulesConfig, - $fileName, - $mergeToObject = null, - $mergeModel = null, - $configCache = array() - ) { - if ($mergeToObject === null) { - $mergeToObject = $this->_prototypeFactory->create(''); - } - if ($mergeModel === null) { - $mergeModel = $this->_prototypeFactory->create(''); - } - $modules = $modulesConfig->getNode('modules')->children(); - /** @var $module Varien_Simplexml_Element */ - foreach ($modules as $modName => $module) { - if ($module->is('active')) { - if (!is_array($fileName)) { - $fileName = array($fileName); - } - foreach ($fileName as $configFile) { - $this->_loadFileConfig( - $configFile, $configCache, $modName, $mergeToObject, $modulesConfig, $mergeModel - ); - } - } - } - return $mergeToObject; - } - - /** - * Load configuration from single file - * - * @param string $configFile - * @param array $configCache - * @param string $modName - * @param Mage_Core_Model_Config_Base $mergeToObject - * @param Mage_Core_Model_ConfigInterface $modulesConfig - * @param Mage_Core_Model_Config_Base $mergeModel - */ - public function _loadFileConfig( - $configFile, $configCache, $modName, $mergeToObject, Mage_Core_Model_ConfigInterface $modulesConfig, $mergeModel - ) { - if ($configFile == 'config.xml' && isset($configCache[$modName])) { - $mergeToObject->extend($configCache[$modName], true); - //Prevent overriding node of module if it was redefined in etc/modules - $mergeToObject->extend( - $this->_prototypeFactory->create( - "<{$modName}>true" - ), - true - ); - } else { - $configFilePath = $this->getModuleDir($modulesConfig, 'etc', $modName) . DS . $configFile; - if ($mergeModel->loadFile($configFilePath)) { - $mergeToObject->extend($mergeModel, true); - } - } - } - - /** - * Go through all modules and find configuration files of active modules - * - * @param Mage_Core_Model_ConfigInterface $modulesConfig - * @param $filename - * @return array - */ - public function getConfigurationFiles(Mage_Core_Model_ConfigInterface $modulesConfig, $filename) - { - $result = array(); - $modules = $modulesConfig->getNode('modules')->children(); - foreach ($modules as $moduleName => $module) { - if ((!$module->is('active'))) { - continue; - } - $file = $this->getModuleDir($modulesConfig, 'etc', $moduleName) . DIRECTORY_SEPARATOR . $filename; - if (file_exists($file)) { - $result[] = $file; - } - } - return $result; - } - - /** - * Get module directory by directory type - * - * @param Mage_Core_Model_ConfigInterface $modulesConfig - * @param string $type - * @param string $moduleName - * @return string - */ - public function getModuleDir(Mage_Core_Model_ConfigInterface $modulesConfig, $type, $moduleName) - { - if (isset($this->_moduleDirs[$moduleName][$type])) { - return $this->_moduleDirs[$moduleName][$type]; - } - - $codePool = (string)$modulesConfig->getNode('modules/' . $moduleName . '/codePool'); - - $dir = $this->_dirs->getDir(Mage_Core_Model_Dir::MODULES) . DIRECTORY_SEPARATOR - . $codePool . DIRECTORY_SEPARATOR - . uc_words($moduleName, DIRECTORY_SEPARATOR); - - switch ($type) { - case 'etc': - case 'controllers': - case 'sql': - case 'data': - case 'locale': - case 'view': - $dir .= DS . $type; - break; - } - - $dir = str_replace('/', DS, $dir); - return $dir; - } - - /** - * Set path to the corresponding module directory - * - * @param string $moduleName - * @param string $type directory type (etc, controllers, locale etc) - * @param string $path - */ - public function setModuleDir($moduleName, $type, $path) - { - if (!isset($this->_moduleDirs[$moduleName])) { - $this->_moduleDirs[$moduleName] = array(); - } - $this->_moduleDirs[$moduleName][$type] = $path; - } -} diff --git a/app/code/core/Mage/Core/Model/Config/Loader/Primary.php b/app/code/core/Mage/Core/Model/Config/Loader/Primary.php deleted file mode 100644 index 7decbe51b37ae..0000000000000 --- a/app/code/core/Mage/Core/Model/Config/Loader/Primary.php +++ /dev/null @@ -1,88 +0,0 @@ -_dirs = $dirs; - $this->_localLoader = $localLoader; - $this->_prototypeFactory = $prototypeFactory; - } - - /** - * Load primary configuration - * - * @param Mage_Core_Model_Config_Base $config - */ - public function load(Mage_Core_Model_Config_Base $config) - { - $etcDir = $this->_dirs->getDir(Mage_Core_Model_Dir::CONFIG); - if (!$config->getNode()) { - $config->loadString(''); - } - // 1. app/etc/*.xml (except local config) - foreach (scandir($etcDir) as $filename) { - if ('.' == $filename || '..' == $filename || '.xml' != substr($filename, -4) - || Mage_Core_Model_Config_Loader_Local::LOCAL_CONFIG_FILE == $filename - ) { - continue; - } - $baseConfigFile = $etcDir . DIRECTORY_SEPARATOR . $filename; - $baseConfig = $this->_prototypeFactory->create(''); - $baseConfig->loadFile($baseConfigFile); - $config->extend($baseConfig); - } - // 2. local configuration - $this->_localLoader->load($config); - } -} diff --git a/app/code/core/Mage/Core/Model/Config/Modules/Reader.php b/app/code/core/Mage/Core/Model/Config/Modules/Reader.php deleted file mode 100644 index 6c4ac0039bca0..0000000000000 --- a/app/code/core/Mage/Core/Model/Config/Modules/Reader.php +++ /dev/null @@ -1,102 +0,0 @@ -_config = $modulesConfig; - $this->_fileReader = $fileReader; - } - - /** - * Iterate all active modules "etc" folders and combine data from - * specidied xml file name to one object - * - * @param string $fileName - * @param null|Mage_Core_Model_Config_Base $mergeToObject - * @param null|Mage_Core_Model_Config_Base $mergeModel - * @return Mage_Core_Model_Config_Base - */ - public function loadModulesConfiguration($fileName, $mergeToObject = null, $mergeModel = null) - { - return $this->_fileReader->loadConfigurationFromFile($this->_config, $fileName, $mergeToObject, $mergeModel); - } - - /** - * Go through all modules and find configuration files of active modules - * - * @param string $filename - * @return array - */ - public function getModuleConfigurationFiles($filename) - { - return $this->_fileReader->getConfigurationFiles($this->_config, $filename); - } - - /** - * Get module directory by directory type - * - * @param string $type - * @param string $moduleName - * @return string - */ - public function getModuleDir($type, $moduleName) - { - return $this->_fileReader->getModuleDir($this->_config, $type, $moduleName); - } - - /** - * Set path to the corresponding module directory - * - * @param string $moduleName - * @param string $type directory type (etc, controllers, locale etc) - * @param string $path - */ - public function setModuleDir($moduleName, $type, $path) - { - $this->_fileReader->setModuleDir($moduleName, $type, $path); - } -} diff --git a/app/code/core/Mage/Core/Model/Config/Primary.php b/app/code/core/Mage/Core/Model/Config/Primary.php deleted file mode 100644 index 0acb2d1132572..0000000000000 --- a/app/code/core/Mage/Core/Model/Config/Primary.php +++ /dev/null @@ -1,91 +0,0 @@ -%s'; - - /** - * Application installation timestamp - * - * @var int|null - */ - protected $_installDate; - - /** - * @var Mage_Core_Model_Config_Loader_Primary - */ - protected $_loader; - - /** - * @param Mage_Core_Model_Config_Loader_Primary $loader - */ - public function __construct(Mage_Core_Model_Config_Loader_Primary $loader) - { - parent::__construct(''); - $this->_loader = $loader; - $this->_loader->load($this); - $this->_loadInstallDate(); - } - - /** - * Load application installation date - */ - protected function _loadInstallDate() - { - $installDateNode = $this->getNode(self::XML_PATH_INSTALL_DATE); - if ($installDateNode) { - $this->_installDate = strtotime((string)$installDateNode); - } - } - - /** - * Retrieve application installation date as a timestamp or NULL, if it has not been installed yet - * - * @return int|null - */ - public function getInstallDate() - { - return $this->_installDate; - } - - /** - * Reinitialize primary configuration - */ - public function reinit() - { - $this->loadString(''); - $this->_loader->load($this); - $this->_loadInstallDate(); - } -} diff --git a/app/code/core/Mage/Core/Model/Db/Updater.php b/app/code/core/Mage/Core/Model/Db/Updater.php deleted file mode 100644 index a1094f3833239..0000000000000 --- a/app/code/core/Mage/Core/Model/Db/Updater.php +++ /dev/null @@ -1,158 +0,0 @@ -_config = $modulesConfig; - $this->_factory = $factory; - $this->_appState = $appState; - } - - /** - * Check whether modules updates processing should be skipped - * - * @return bool - */ - protected function _shouldSkipProcessModulesUpdates() - { - if (!$this->_appState->isInstalled()) { - return false; - } - - $ignoreDevelopmentMode = (bool)(string)$this->_config->getNode(self::XML_PATH_IGNORE_DEV_MODE); - if ($this->_appState->isDeveloperMode() && false == $ignoreDevelopmentMode) { - return false; - } - - return (bool)(string)$this->_config->getNode(self::XML_PATH_SKIP_PROCESS_MODULES_UPDATES); - } - - /** - * Apply database scheme updates whenever needed - */ - public function updateScheme() - { - if (true == $this->_shouldSkipProcessModulesUpdates()) { - return; - } - - Magento_Profiler::start('apply_db_schema_updates'); - $this->_appState->setUpdateMode(true); - - $resources = $this->_config->getNode('global/resources')->children(); - $afterApplyUpdates = array(); - foreach ($resources as $resName => $resource) { - if (!$resource->setup) { - continue; - } - $className = $this->_defaultClass; - if (isset($resource->setup->class)) { - $className = $resource->setup->getClassName(); - } - - $setupClass = $this->_factory->create($className, array('resourceName' => $resName)); - $setupClass->applyUpdates(); - - if ($setupClass->getCallAfterApplyAllUpdates()) { - $afterApplyUpdates[] = $setupClass; - } - } - - /** @var $setupClass Mage_Core_Model_Resource_SetupInterface*/ - foreach ($afterApplyUpdates as $setupClass) { - $setupClass->afterApplyAllUpdates(); - } - - $this->_appState->setUpdateMode(false); - self::$_schemaUpdatesChecked = true; - Magento_Profiler::stop('apply_db_schema_updates'); - } - - /** - * Apply database data updates whenever needed - */ - public function updateData() - { - if (!self::$_schemaUpdatesChecked) { - return; - } - $resources = $this->_config->getNode('global/resources')->children(); - foreach ($resources as $resName => $resource) { - if (!$resource->setup) { - continue; - } - $className = $this->_defaultClass; - if (isset($resource->setup->class)) { - $className = $resource->setup->getClassName(); - } - $setupClass = $this->_factory->create($className, array('resourceName' => $resName)); - $setupClass->applyDataUpdates(); - } - } -} diff --git a/app/code/core/Mage/Core/Model/Design/Fallback.php b/app/code/core/Mage/Core/Model/Design/Fallback.php deleted file mode 100644 index 2e7e9df07c988..0000000000000 --- a/app/code/core/Mage/Core/Model/Design/Fallback.php +++ /dev/null @@ -1,246 +0,0 @@ -_dirs = $dirs; - $this->_objectManager = $objectManager; - $this->_filesystem = $filesystem; - if (!array_key_exists('area', $params) || !array_key_exists('themeModel', $params) - || !array_key_exists('locale', $params) - ) { - throw new InvalidArgumentException("Missing one of the param keys: 'area', 'themeModel', 'locale'."); - } - $this->_area = $params['area']; - $this->_theme = $params['themeModel']; - $this->_locale = $params['locale']; - } - - /** - * Get area code - * - * @return string - */ - public function getArea() - { - return $this->_area; - } - - /** - * Get theme identification code - * - * @return string - */ - public function getTheme() - { - return $this->_theme->getId() ?: $this->_theme->getThemePath(); - } - - /** - * Get locale code - * - * @return null|string - */ - public function getLocale() - { - return $this->_locale; - } - - /** - * Get existing file name, using fallback mechanism - * - * @param string $file - * @param string|null $module - * @return string - */ - public function getFile($file, $module = null) - { - $dir = $this->_dirs->getDir(Mage_Core_Model_Dir::THEMES); - $dirs = array(); - $themeModel = $this->_theme; - while ($themeModel) { - $themePath = $themeModel->getThemePath(); - if ($themePath) { - $dirs[] = "{$dir}/{$this->_area}/{$themePath}"; - } - $themeModel = $themeModel->getParentTheme(); - } - - if ($module) { - $moduleDir = array($this->_objectManager->get('Mage_Core_Model_Config')->getModuleDir('view', $module) - . "/{$this->_area}"); - } else { - $moduleDir = array(); - } - return $this->_fallback($file, $dirs, $module, $moduleDir); - } - - /** - * Get locale file name, using fallback mechanism - * - * @param string $file - * @return string - */ - public function getLocaleFile($file) - { - $dir = $this->_dirs->getDir(Mage_Core_Model_Dir::THEMES); - $dirs = array(); - $themeModel = $this->_theme; - while ($themeModel) { - $themePath = $themeModel->getThemePath(); - if ($themePath) { - $dirs[] = "{$dir}/{$this->_area}/{$themePath}/locale/{$this->_locale}"; - } - $themeModel = $themeModel->getParentTheme(); - } - - return $this->_fallback($file, $dirs); - } - - /** - * Get theme file name, using fallback mechanism - * - * @param string $file - * @param string|null $module - * @return string - */ - public function getViewFile($file, $module = null) - { - $dir = $this->_dirs->getDir(Mage_Core_Model_Dir::THEMES); - $moduleDir = $module ? $this->_objectManager->get('Mage_Core_Model_Config')->getModuleDir('view', $module) : ''; - - $dirs = array(); - $themeModel = $this->_theme; - while ($themeModel) { - $themePath = $themeModel->getThemePath(); - if ($themePath) { - $dirs[] = "{$dir}/{$this->_area}/{$themePath}/locale/{$this->_locale}"; - $dirs[] = "{$dir}/{$this->_area}/{$themePath}"; - } - $themeModel = $themeModel->getParentTheme(); - } - - return $this->_fallback( - $file, - $dirs, - $module, - array("{$moduleDir}/{$this->_area}/locale/{$this->_locale}", "{$moduleDir}/{$this->_area}"), - array($this->_dirs->getDir(Mage_Core_Model_Dir::PUB_LIB)) - ); - } - - /** - * Go through specified directories and try to locate the file - * - * Returns the first found file or last file from the list as absolute path - * - * @param string $file relative file name - * @param array $themeDirs theme directories (absolute paths) - must not be empty - * @param string|bool $module module context - * @param array $moduleDirs module directories (absolute paths, makes sense with previous parameter only) - * @param array $extraDirs additional lookup directories (absolute paths) - * @return string - */ - protected function _fallback($file, $themeDirs, $module = false, $moduleDirs = array(), $extraDirs = array()) - { - // add customization path - $dirs = array(); - if ($this->_theme->getCustomizationPath()) { - $dirs[] = $this->_theme->getCustomizationPath(); - } - - // add modules to lookup - $dirs = array_merge($dirs, $themeDirs); - if ($module) { - array_walk($themeDirs, function (&$dir) use ($module) { - $dir = "{$dir}/{$module}"; - }); - $dirs = array_merge($dirs, $themeDirs, $moduleDirs); - } - $dirs = array_merge($dirs, $extraDirs); - - // look for files - $tryFile = ''; - foreach ($dirs as $dir) { - $tryFile = str_replace('/', DIRECTORY_SEPARATOR, "{$dir}/{$file}"); - if ($this->_filesystem->has($tryFile)) { - break; - } - } - return $tryFile; - } -} diff --git a/app/code/core/Mage/Core/Model/Design/Fallback/CachingProxy.php b/app/code/core/Mage/Core/Model/Design/Fallback/CachingProxy.php deleted file mode 100644 index 05643ec81344c..0000000000000 --- a/app/code/core/Mage/Core/Model/Design/Fallback/CachingProxy.php +++ /dev/null @@ -1,233 +0,0 @@ -_fallback = $fallback; - $this->_filesystem = $filesystem; - if (!$filesystem->isDirectory($baseDir)) { - throw new InvalidArgumentException("Wrong base directory specified: '{$baseDir}'"); - } - $this->_baseDir = $baseDir; - $this->_canSaveMap = $canSaveMap; - $this->_mapFile = $mapDir . DIRECTORY_SEPARATOR - . "{$fallback->getArea()}_{$fallback->getTheme()}_{$fallback->getLocale()}.ser"; - if ($this->_filesystem->isFile($this->_mapFile)) { - $this->_map = unserialize($this->_filesystem->read($this->_mapFile)); - } - } - - /** - * Write the serialized class map to the file - */ - public function __destruct() - { - if ($this->_isMapChanged && $this->_canSaveMap) { - $dir = dirname($this->_mapFile); - if (!$this->_filesystem->isDirectory($dir)) { - $this->_filesystem->createDirectory($dir, 0777); - } - $this->_filesystem->write($this->_mapFile, serialize($this->_map)); - } - } - - /** - * Return relative file name from map - * - * @param string $prefix - * @param string $file - * @param string|null $module - * @return string|null - */ - protected function _getFromMap($prefix, $file, $module = null) - { - $mapKey = "$prefix|$file|$module"; - if (isset($this->_map[$mapKey])) { - $value = $this->_map[$mapKey]; - if ('' !== (string)$value) { - return $this->_baseDir . DIRECTORY_SEPARATOR . $value; - } else { - return $value; - } - } else { - return null; - } - } - - /** - * Sets file to map. The file path must be within baseDir path. - * - * @param string $prefix - * @param string $file - * @param string|null $module - * @param string $filePath - * @throws Magento_Exception - */ - protected function _setToMap($prefix, $file, $module, $filePath) - { - $pattern = $this->_baseDir . DIRECTORY_SEPARATOR; - if (0 !== strpos($filePath, $pattern, 0)) { - throw new Magento_Exception( - "Attempt to store fallback path '{$filePath}', which is not within '{$pattern}'" - ); - } - $mapKey = "$prefix|$file|$module"; - $this->_map[$mapKey] = substr($filePath, strlen($pattern)); - $this->_isMapChanged = true; - } - - /** - * Proxy to Mage_Core_Model_Design_Fallback::getFile() - * - * @param string $file - * @param string|null $module - * @return string - */ - public function getFile($file, $module = null) - { - $result = $this->_getFromMap('theme', $file, $module); - if (!$result) { - $result = $this->_fallback->getFile($file, $module); - $this->_setToMap('theme', $file, $module, $result); - } - return $result; - } - - /** - * Proxy to Mage_Core_Model_Design_Fallback::getLocaleFile() - * - * @param string $file - * @return string - */ - public function getLocaleFile($file) - { - $result = $this->_getFromMap('locale', $file); - if (!$result) { - $result = $this->_fallback->getLocaleFile($file); - $this->_setToMap('locale', $file, null, $result); - } - return $result; - } - - /** - * Proxy to Mage_Core_Model_Design_Fallback::getViewFile() - * - * @param string $file - * @param string|null $module - * @return string - */ - public function getViewFile($file, $module = null) - { - $result = $this->_getFromMap('view', $file, $module); - if (!$result) { - $result = $this->_fallback->getViewFile($file, $module); - $this->_setToMap('view', $file, $module, $result); - } - return $result; - } - - /** - * Set file path to map. - * - * @param string $filePath - * @param string $file - * @param string|null $module - * @return Mage_Core_Model_Design_Fallback_CachingProxy - */ - public function setFilePathToMap($filePath, $file, $module = null) - { - $this->_setToMap('view', $file, $module, $filePath); - return $this; - } -} diff --git a/app/code/core/Mage/Core/Model/Design/FallbackInterface.php b/app/code/core/Mage/Core/Model/Design/FallbackInterface.php deleted file mode 100644 index 4ee91a2b1c181..0000000000000 --- a/app/code/core/Mage/Core/Model/Design/FallbackInterface.php +++ /dev/null @@ -1,57 +0,0 @@ -load(Mage::getStoreConfig('path_to_email_template_id_config')); - * $variables = array( - * 'someObject' => Mage::getSingleton('Mage_Core_Model_Resource_Email_Template') - * 'someString' => 'Some string value' - * ); - * $emailTemplate->send('some@domain.com', 'Name Of User', $variables); - * - * @method Mage_Core_Model_Resource_Email_Template _getResource() - * @method Mage_Core_Model_Resource_Email_Template getResource() - * @method string getTemplateCode() - * @method Mage_Core_Model_Email_Template setTemplateCode(string $value) - * @method string getTemplateText() - * @method Mage_Core_Model_Email_Template setTemplateText(string $value) - * @method string getTemplateStyles() - * @method Mage_Core_Model_Email_Template setTemplateStyles(string $value) - * @method int getTemplateType() - * @method Mage_Core_Model_Email_Template setTemplateType(int $value) - * @method string getTemplateSubject() - * @method Mage_Core_Model_Email_Template setTemplateSubject(string $value) - * @method string getTemplateSenderName() - * @method Mage_Core_Model_Email_Template setTemplateSenderName(string $value) - * @method string getTemplateSenderEmail() - * @method Mage_Core_Model_Email_Template setTemplateSenderEmail(string $value) - * @method string getAddedAt() - * @method Mage_Core_Model_Email_Template setAddedAt(string $value) - * @method string getModifiedAt() - * @method Mage_Core_Model_Email_Template setModifiedAt(string $value) - * @method string getOrigTemplateCode() - * @method Mage_Core_Model_Email_Template setOrigTemplateCode(string $value) - * @method string getOrigTemplateVariables() - * @method Mage_Core_Model_Email_Template setOrigTemplateVariables(string $value) - * - * @category Mage - * @package Mage_Core - * @author Magento Core Team - */ -class Mage_Core_Model_Email_Template extends Mage_Core_Model_Template -{ - /** - * Configuration path for default email templates - */ - const XML_PATH_TEMPLATE_EMAIL = 'global/template/email'; - const XML_PATH_SENDING_SET_RETURN_PATH = 'system/smtp/set_return_path'; - const XML_PATH_SENDING_RETURN_PATH_EMAIL = 'system/smtp/return_path_email'; - const XML_PATH_DESIGN_EMAIL_LOGO = 'design/email/logo'; - const XML_PATH_DESIGN_EMAIL_LOGO_ALT = 'design/email/logo_alt'; - - protected $_templateFilter; - protected $_preprocessFlag = false; - protected $_bcc = array(); - protected $_returnPath = ''; - protected $_replyTo = ''; - - /** - * @var Exception|null - */ - protected $_sendingException = null; - - /** - * @var Magento_Filesystem - */ - protected $_filesystem; - - static protected $_defaultTemplates; - - /** - * Initialize data - * - * @param Mage_Core_Model_Event_Manager $eventDispatcher - * @param Mage_Core_Model_Cache $cacheManager - * @param Magento_Filesystem $filesystem - * @param array $data - */ - public function __construct( - Mage_Core_Model_Event_Manager $eventDispatcher, - Mage_Core_Model_Cache $cacheManager, - Magento_Filesystem $filesystem, - array $data = array() - ) { - $this->_filesystem = $filesystem; - parent::__construct($eventDispatcher, $cacheManager); - } - - /** - * Initialize email template model - */ - protected function _construct() - { - $this->_init('Mage_Core_Model_Resource_Email_Template'); - } - - /** - * Return logo URL for emails - * Take logo from theme if custom logo is undefined - * - * @param Mage_Core_Model_Store|int|string $store - * @return string - */ - protected function _getLogoUrl($store) - { - $store = Mage::app()->getStore($store); - $fileName = $store->getConfig(self::XML_PATH_DESIGN_EMAIL_LOGO); - if ($fileName) { - $uploadDir = Mage_Backend_Model_Config_Backend_Email_Logo::UPLOAD_DIR; - $fullFileName = Mage::getBaseDir('media') . DS . $uploadDir . DS . $fileName; - if ($this->_filesystem->isFile($fullFileName)) { - return Mage::getBaseUrl('media') . $uploadDir . '/' . $fileName; - } - } - return Mage::getDesign()->getViewFileUrl('Mage_Core::logo_email.gif'); - } - - /** - * Return logo alt for emails - * - * @param Mage_Core_Model_Store|int|string $store - * @return string - */ - protected function _getLogoAlt($store) - { - $store = Mage::app()->getStore($store); - $alt = $store->getConfig(self::XML_PATH_DESIGN_EMAIL_LOGO_ALT); - if ($alt) { - return $alt; - } - return $store->getFrontendName(); - } - - /** - * Retrieve mail object instance - * - * @return Zend_Mail - */ - protected function _getMail() - { - return new Zend_Mail('utf-8'); - } - - /** - * Declare template processing filter - * - * @param Varien_Filter_Template $filter - * @return Mage_Core_Model_Email_Template - */ - public function setTemplateFilter(Varien_Filter_Template $filter) - { - $this->_templateFilter = $filter; - return $this; - } - - /** - * Get filter object for template processing log - * - * @return Mage_Core_Model_Email_Template_Filter - */ - public function getTemplateFilter() - { - if (empty($this->_templateFilter)) { - $this->_templateFilter = Mage::getModel('Mage_Core_Model_Email_Template_Filter'); - $this->_templateFilter->setUseAbsoluteLinks($this->getUseAbsoluteLinks()) - ->setStoreId($this->getDesignConfig()->getStore()); - } - return $this->_templateFilter; - } - - /** - * Load template by code - * - * @param string $templateCode - * @return Mage_Core_Model_Email_Template - */ - public function loadByCode($templateCode) - { - $this->addData($this->getResource()->loadByCode($templateCode)); - return $this; - } - - /** - * Load default email template - * - * @param string $templateId - * @return Mage_Core_Model_Email_Template - */ - public function loadDefault($templateId) - { - $defaultTemplates = self::getDefaultTemplates(); - if (!isset($defaultTemplates[$templateId])) { - return $this; - } - - $data = &$defaultTemplates[$templateId]; - $this->setTemplateType($data['type'] == 'html' ? self::TYPE_HTML : self::TYPE_TEXT); - - $module = Mage::getConfig()->determineOmittedNamespace($data['@']['module'], true); - $templateText = $this->loadBaseContents($module, $data['file']); - - if (preg_match('//u', $templateText, $matches)) { - $this->setTemplateSubject($matches[1]); - $templateText = str_replace($matches[0], '', $templateText); - } - - if (preg_match('//us', $templateText, $matches)) { - $this->setData('orig_template_variables', str_replace("\n", '', $matches[1])); - $templateText = str_replace($matches[0], '', $templateText); - } - - if (preg_match('//s', $templateText, $matches)) { - $this->setTemplateStyles($matches[1]); - $templateText = str_replace($matches[0], '', $templateText); - } - - /** - * Remove comment lines - */ - $templateText = preg_replace('#\{\*.*\*\}#suU', '', $templateText); - - $this->setTemplateText($templateText); - $this->setId($templateId); - - return $this; - } - - /** - * Look for base template and read its contents - * - * @param string $module A fully qualified module name (_) - * @param string $filename File path relative to module/view folder - * @return string - * @throws Exception if the requested filename is not found - */ - public function loadBaseContents($module, $filename) - { - $includeFilename = Mage::getConfig()->getModuleDir('view', $module) . DIRECTORY_SEPARATOR . $filename; - $contents = $this->_filesystem->read($includeFilename); - if (!$contents) { - throw new Exception(sprintf('Failed to include file "%s".', $includeFilename)); - } - return $contents; - } - - /** - * Retrieve default templates from config - * - * @return array - */ - static public function getDefaultTemplates() - { - if (is_null(self::$_defaultTemplates)) { - self::$_defaultTemplates = Mage::getConfig()->getNode(self::XML_PATH_TEMPLATE_EMAIL)->asArray(); - } - - return self::$_defaultTemplates; - } - - /** - * Get default templates as options array - * - * @return array - */ - static public function getDefaultTemplatesAsOptionsArray() - { - $options = array(array('value'=> '', 'label'=> '', 'group' => '')); - $groups = array(); - foreach (self::getDefaultTemplates() as $templateId => $row) { - $module = $row['@']['module']; - $moduleFullName = Mage::getConfig()->determineOmittedNamespace($module, true); - $options[] = array( - 'value' => $templateId, - 'label' => Mage::helper($module)->__($row['label']), - 'group' => $moduleFullName, - ); - $groups[$module] = 1; - } - uasort($options, function($a, $b) { - $key = 'label'; - if ($a[$key] == $b[$key]) { - return 0; - } - return ($a[$key] < $b[$key]) ? -1 : 1; - }); - - return $options; - } - - /** - * Return template id - * - * return int|null - */ - public function getId() - { - return $this->getTemplateId(); - } - - /** - * Set id of template - * - * @param int $value - * @return Mage_Core_Model_Email_Template - */ - public function setId($value) - { - return $this->setTemplateId($value); - } - - /** - * Return true if this template can be used for sending queue as main template - * - * @return boolean - */ - public function isValidForSend() - { - return !Mage::getStoreConfigFlag('system/smtp/disable') - && $this->getSenderName() - && $this->getSenderEmail() - && $this->getTemplateSubject(); - } - - /** - * Getter for template type - * - * @return int|string - */ - public function getType(){ - return $this->getTemplateType(); - } - - /** - * Process email template code - * - * @param array $variables - * @return string - * @throws Exception - */ - public function getProcessedTemplate(array $variables = array()) - { - $processor = $this->getTemplateFilter(); - $processor->setUseSessionInUrl(false) - ->setPlainTemplateMode($this->isPlain()); - - if (!$this->_preprocessFlag) { - $variables['this'] = $this; - } - - if (isset($variables['subscriber']) && ($variables['subscriber'] instanceof Mage_Newsletter_Model_Subscriber)) { - $processor->setStoreId($variables['subscriber']->getStoreId()); - } - - if (!isset($variables['logo_url'])) { - $variables['logo_url'] = $this->_getLogoUrl($processor->getStoreId()); - } - if (!isset($variables['logo_alt'])) { - $variables['logo_alt'] = $this->_getLogoAlt($processor->getStoreId()); - } - - $processor->setIncludeProcessor(array($this, 'getInclude')) - ->setVariables($variables); - - $this->_applyDesignConfig(); - $storeId = $this->getDesignConfig()->getStore(); - try { - $processedResult = $processor->setStoreId($storeId) - ->filter($this->getPreparedTemplateText()); - } catch (Exception $e) { - $this->_cancelDesignConfig(); - throw $e; - } - $this->_cancelDesignConfig(); - return $processedResult; - } - - /** - * Makes additional text preparations for HTML templates - * - * @return string - */ - public function getPreparedTemplateText() - { - if ($this->isPlain() || !$this->getTemplateStyles()) { - return $this->getTemplateText(); - } - // wrap styles into style tag - $html = "\n%s"; - return sprintf($html, $this->getTemplateStyles(), $this->getTemplateText()); - } - - /** - * Get template code for include directive - * - * @param string $template - * @param array $variables - * @return string - */ - public function getInclude($template, array $variables) - { - $thisClass = __CLASS__; - $includeTemplate = new $thisClass(); - - $includeTemplate->loadByCode($template); - - return $includeTemplate->getProcessedTemplate($variables); - } - - /** - * Send mail to recipient - * - * @param array|string $email E-mail(s) - * @param array|string|null $name receiver name(s) - * @param array $variables template variables - * @return boolean - **/ - public function send($email, $name = null, array $variables = array()) - { - if (!$this->isValidForSend()) { - Mage::logException(new Exception('This letter cannot be sent.')); // translation is intentionally omitted - return false; - } - - $emails = array_values((array)$email); - $names = is_array($name) ? $name : (array)$name; - $names = array_values($names); - foreach ($emails as $key => $email) { - if (!isset($names[$key])) { - $names[$key] = substr($email, 0, strpos($email, '@')); - } - } - - $variables['email'] = reset($emails); - $variables['name'] = reset($names); - - ini_set('SMTP', Mage::getStoreConfig('system/smtp/host')); - ini_set('smtp_port', Mage::getStoreConfig('system/smtp/port')); - - $mail = $this->_getMail(); - foreach ($this->_bcc as $bcc) { - $mail->addBcc($bcc); - } - if ($this->_returnPath) { - $mail->setReturnPath($this->_returnPath); - } - if ($this->_replyTo) { - $mail->setReplyTo($this->_replyTo); - } - - $setReturnPath = Mage::getStoreConfig(self::XML_PATH_SENDING_SET_RETURN_PATH); - switch ($setReturnPath) { - case 1: - $returnPathEmail = $this->getSenderEmail(); - break; - case 2: - $returnPathEmail = Mage::getStoreConfig(self::XML_PATH_SENDING_RETURN_PATH_EMAIL); - break; - default: - $returnPathEmail = null; - break; - } - - if ($returnPathEmail !== null) { - $mailTransport = new Zend_Mail_Transport_Sendmail("-f" . $returnPathEmail); - Zend_Mail::setDefaultTransport($mailTransport); - } - - foreach ($emails as $key => $email) { - $mail->addTo($email, '=?utf-8?B?' . base64_encode($names[$key]) . '?='); - } - - $this->setUseAbsoluteLinks(true); - $text = $this->getProcessedTemplate($variables, true); - - if ($this->isPlain()) { - $mail->setBodyText($text); - } else { - $mail->setBodyHTML($text); - } - - $mail->setSubject('=?utf-8?B?' . base64_encode($this->getProcessedTemplateSubject($variables)) . '?='); - $mail->setFrom($this->getSenderEmail(), $this->getSenderName()); - - $result = false; - $this->_sendingException = null; - try { - $mail->send(); - $result = true; - } catch (Exception $e) { - Mage::logException($e); - $this->_sendingException = $e; - } - $this->_bcc = array(); - $this->_returnPath = ''; - $this->_replyTo = ''; - - return $result; - } - - /** - * Get exception, generated during send() method - * - * @return Exception|null - */ - public function getSendingException() - { - return $this->_sendingException; - } - - /** - * Send transactional email to recipient - * - * @param int|string $templateId - * @param string|array $sender sender information, can be declared as part of config path - * @param string $email recipient email - * @param string $name recipient name - * @param array $vars variables which can be used in template - * @param int|null $storeId - * @return Mage_Core_Model_Email_Template - * @throws Mage_Core_Exception - */ - public function sendTransactional($templateId, $sender, $email, $name, $vars = array(), $storeId = null) - { - $this->setSentSuccess(false); - if (($storeId === null) && $this->getDesignConfig()->getStore()) { - $storeId = $this->getDesignConfig()->getStore(); - } - - if (is_numeric($templateId)) { - $this->load($templateId); - } else { - $this->loadDefault($templateId); - } - - if (!$this->getId()) { - throw Mage::exception('Mage_Core', - Mage::helper('Mage_Core_Helper_Data')->__('Invalid transactional email code: %s', $templateId)); - } - - if (!is_array($sender)) { - $this->setSenderName(Mage::getStoreConfig('trans_email/ident_' . $sender . '/name', $storeId)); - $this->setSenderEmail(Mage::getStoreConfig('trans_email/ident_' . $sender . '/email', $storeId)); - } else { - $this->setSenderName($sender['name']); - $this->setSenderEmail($sender['email']); - } - - if (!isset($vars['store'])) { - $vars['store'] = Mage::app()->getStore($storeId); - } - $this->setSentSuccess($this->send($email, $name, $vars)); - return $this; - } - - /** - * Process email subject - * - * @param array $variables - * @return string - * @throws Exception - */ - public function getProcessedTemplateSubject(array $variables) - { - $processor = $this->getTemplateFilter(); - - if (!$this->_preprocessFlag) { - $variables['this'] = $this; - } - - $processor->setVariables($variables); - - $this->_applyDesignConfig(); - $storeId = $this->getDesignConfig()->getStore(); - try { - $processedResult = $processor->setStoreId($storeId) - ->filter($this->getTemplateSubject()); - } catch (Exception $e) { - $this->_cancelDesignConfig(); - throw $e; - } - $this->_cancelDesignConfig(); - return $processedResult; - } - - /** - * Add email BCC - * - * @param string|array $bcc - * @return Mage_Core_Model_Email_Template - */ - public function addBcc($bcc) - { - $this->_bcc[] = $bcc; - return $this; - } - - /** - * Set Return Path - * - * @param string $email - * @return Mage_Core_Model_Email_Template - */ - public function setReturnPath($email) - { - $this->_returnPath = $email; - return $this; - } - - /** - * Add Reply-To header - * - * @param string $email - * @return Mage_Core_Model_Email_Template - */ - public function setReplyTo($email) - { - $this->_replyTo = $email; - return $this; - } - - /** - * Parse variables string into array of variables - * - * @param string $variablesString - * @return array - */ - protected function _parseVariablesString($variablesString) - { - $variables = array(); - if ($variablesString && is_string($variablesString)) { - $variablesString = str_replace("\n", '', $variablesString); - $variables = Zend_Json::decode($variablesString); - } - return $variables; - } - - /** - * Retrieve option array of variables - * - * @param boolean $withGroup if true wrap variable options in group - * @return array - */ - public function getVariablesOptionArray($withGroup = false) - { - $optionArray = array(); - $variables = $this->_parseVariablesString($this->getData('orig_template_variables')); - if ($variables) { - foreach ($variables as $value => $label) { - $optionArray[] = array( - 'value' => '{{' . $value . '}}', - 'label' => Mage::helper('Mage_Core_Helper_Data')->__('%s', $label) - ); - } - if ($withGroup) { - $optionArray = array( - 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Template Variables'), - 'value' => $optionArray - ); - } - } - return $optionArray; - } - - /** - * Validate email template code - * - * @return Mage_Core_Model_Email_Template - */ - protected function _beforeSave() - { - $code = $this->getTemplateCode(); - if (empty($code)) { - Mage::throwException(Mage::helper('Mage_Core_Helper_Data')->__('The template Name must not be empty.')); - } - if ($this->_getResource()->checkCodeUsage($this)) { - Mage::throwException(Mage::helper('Mage_Core_Helper_Data')->__('Duplicate Of Template Name')); - } - return parent::_beforeSave(); - } -} diff --git a/app/code/core/Mage/Core/Model/Email/Template/Filter.php b/app/code/core/Mage/Core/Model/Email/Template/Filter.php deleted file mode 100644 index 2af49e197c3dc..0000000000000 --- a/app/code/core/Mage/Core/Model/Email/Template/Filter.php +++ /dev/null @@ -1,502 +0,0 @@ - - */ -class Mage_Core_Model_Email_Template_Filter extends Varien_Filter_Template -{ - /** - * Use absolute links flag - * - * @var bool - */ - protected $_useAbsoluteLinks = false; - - /** - * Whether to allow SID in store directive: NO - * - * @var bool - */ - protected $_useSessionInUrl = false; - - /** - * Modifier Callbacks - * - * @var array - */ - protected $_modifiers = array('nl2br' => ''); - - protected $_storeId = null; - - protected $_plainTemplateMode = false; - - /** - * Setup callbacks for filters - * - */ - public function __construct() - { - $this->_modifiers['escape'] = array($this, 'modifierEscape'); - } - - /** - * Set use absolute links flag - * - * @param bool $flag - * @return Mage_Core_Model_Email_Template_Filter - */ - public function setUseAbsoluteLinks($flag) - { - $this->_useAbsoluteLinks = $flag; - return $this; - } - - /** - * Setter whether SID is allowed in store directive - * Doesn't set anything intentionally, since SID is not allowed in any kind of emails - * - * @param bool $flag - * @return Mage_Core_Model_Email_Template_Filter - */ - public function setUseSessionInUrl($flag) - { - $this->_useSessionInUrl = $flag; - return $this; - } - - /** - * Setter - * - * @param boolean $plainTemplateMode - * @return Mage_Core_Model_Email_Template_Filter - */ - public function setPlainTemplateMode($plainTemplateMode) - { - $this->_plainTemplateMode = (bool)$plainTemplateMode; - return $this; - } - - /** - * Getter - * - * @return boolean - */ - public function getPlainTemplateMode() - { - return $this->_plainTemplateMode; - } - - /** - * Setter - * - * @param integer $storeId - * @return Mage_Core_Model_Email_Template_Filter - */ - public function setStoreId($storeId) - { - $this->_storeId = $storeId; - return $this; - } - - /** - * Getter - * if $_storeId is null return Design store id - * - * @return integer - */ - public function getStoreId() - { - if (null === $this->_storeId) { - $this->_storeId = Mage::app()->getStore()->getId(); - } - return $this->_storeId; - } - - /** - * Retrieve Block html directive - * - * @param array $construction - * @return string - */ - public function blockDirective($construction) - { - $skipParams = array('type', 'id', 'output'); - $blockParameters = $this->_getIncludeParameters($construction[2]); - $layout = Mage::app()->getLayout(); - - if (isset($blockParameters['type'])) { - $type = $blockParameters['type']; - $block = $layout->createBlock($type, null, $blockParameters); - } elseif (isset($blockParameters['id'])) { - $block = $layout->createBlock('Mage_Cms_Block_Block'); - if ($block) { - $block->setBlockId($blockParameters['id']); - } - } - - if ($block) { - $block->setBlockParams($blockParameters); - foreach ($blockParameters as $k => $v) { - if (in_array($k, $skipParams)) { - continue; - } - $block->setDataUsingMethod($k, $v); - } - } - - if (!$block) { - return ''; - } - if (isset($blockParameters['output'])) { - $method = $blockParameters['output']; - } - if (!isset($method) || !is_string($method) || !method_exists($block, $method)) { - $method = 'toHtml'; - } - return $block->$method(); - } - - /** - * Retrieve layout html directive - * - * @param array $construction - * @return string - */ - public function layoutDirective($construction) - { - $skipParams = array('handle', 'area'); - - $params = $this->_getIncludeParameters($construction[2]); - $layoutParams = array(); - if (isset($params['area'])) { - $layoutParams['area'] = $params['area']; - } - /** @var $layout Mage_Core_Model_Layout */ - $layout = Mage::getModel('Mage_Core_Model_Layout', $layoutParams); - - $layout->getUpdate()->addHandle($params['handle']); - $layout->getUpdate()->load(); - - $layout->generateXml(); - $layout->generateElements(); - - foreach ($layout->getAllBlocks() as $block) { - /* @var $block Mage_Core_Block_Abstract */ - foreach ($params as $k => $v) { - if (in_array($k, $skipParams)) { - continue; - } - - $block->setDataUsingMethod($k, $v); - } - } - - /** - * Add output method for first block - */ - $allBlocks = $layout->getAllBlocks(); - $firstBlock = reset($allBlocks); - if ($firstBlock) { - $layout->addOutputElement($firstBlock->getNameInLayout()); - } - - $layout->setDirectOutput(false); - $result = $layout->getOutput(); - $layout->__destruct(); // To overcome bug with SimpleXML memory leak (https://bugs.php.net/bug.php?id=62468) - return $result; - } - - /** - * Retrieve block parameters - * - * @param mixed $value - * @return array - */ - protected function _getBlockParameters($value) - { - $tokenizer = new Varien_Filter_Template_Tokenizer_Parameter(); - $tokenizer->setString($value); - - return $tokenizer->tokenize(); - } - - /** - * Retrieve View URL directive - * - * @param array $construction - * @return string - */ - public function viewDirective($construction) - { - $params = $this->_getIncludeParameters($construction[2]); - $url = Mage::getDesign()->getViewFileUrl($params['url'], $params); - return $url; - } - - /** - * Retrieve media file URL directive - * - * @param array $construction - * @return string - */ - public function mediaDirective($construction) - { - $params = $this->_getIncludeParameters($construction[2]); - return Mage::getBaseUrl('media') . $params['url']; - } - - /** - * Retrieve store URL directive - * Support url and direct_url properties - * - * @param array $construction - * @return string - */ - public function storeDirective($construction) - { - $params = $this->_getIncludeParameters($construction[2]); - if (!isset($params['_query'])) { - $params['_query'] = array(); - } - foreach ($params as $k => $v) { - if (strpos($k, '_query_') === 0) { - $params['_query'][substr($k, 7)] = $v; - unset($params[$k]); - } - } - $params['_absolute'] = $this->_useAbsoluteLinks; - - if ($this->_useSessionInUrl === false) { - $params['_nosid'] = true; - } - - if (isset($params['direct_url'])) { - $path = ''; - $params['_direct'] = $params['direct_url']; - unset($params['direct_url']); - } - else { - $path = isset($params['url']) ? $params['url'] : ''; - unset($params['url']); - } - - return Mage::app()->getStore($this->getStoreId())->getUrl($path, $params); - } - - /** - * Directive for converting special characters to HTML entities - * Supported options: - * allowed_tags - Comma separated html tags that have not to be converted - * - * @param array $construction - * @return string - */ - public function escapehtmlDirective($construction) - { - $params = $this->_getIncludeParameters($construction[2]); - if (!isset($params['var'])) { - return ''; - } - - $allowedTags = null; - if (isset($params['allowed_tags'])) { - $allowedTags = preg_split('/\s*\,\s*/', $params['allowed_tags'], 0, PREG_SPLIT_NO_EMPTY); - } - - return Mage::helper('Mage_Core_Helper_Data')->escapeHtml($params['var'], $allowedTags); - } - - /** - * Var directive with modifiers support - * - * @param array $construction - * @return string - */ - public function varDirective($construction) - { - if (count($this->_templateVars)==0) { - // If template preprocessing - return $construction[0]; - } - - $parts = explode('|', $construction[2], 2); - if (2 === count($parts)) { - list($variableName, $modifiersString) = $parts; - return $this->_amplifyModifiers($this->_getVariable($variableName, ''), $modifiersString); - } - return $this->_getVariable($construction[2], ''); - } - - /** - * Apply modifiers one by one, with specified params - * - * Modifier syntax: modifier1[:param1:param2:...][|modifier2:...] - * - * @param string $value - * @param string $modifiers - * @return string - */ - protected function _amplifyModifiers($value, $modifiers) - { - foreach (explode('|', $modifiers) as $part) { - if (empty($part)) { - continue; - } - $params = explode(':', $part); - $modifier = array_shift($params); - if (isset($this->_modifiers[$modifier])) { - $callback = $this->_modifiers[$modifier]; - if (!$callback) { - $callback = $modifier; - } - array_unshift($params, $value); - $value = call_user_func_array($callback, $params); - } - } - return $value; - } - - /** - * Escape specified string - * - * @param string $value - * @param string $type - * @return string - */ - public function modifierEscape($value, $type = 'html') - { - switch ($type) { - case 'html': - return htmlspecialchars($value, ENT_QUOTES); - - case 'htmlentities': - return htmlentities($value, ENT_QUOTES); - - case 'url': - return rawurlencode($value); - } - return $value; - } - - /** - * HTTP Protocol directive - * - * Using: - * {{protocol}} - current protocol http or https - * {{protocol url="www.domain.com/"}} domain URL with current protocol - * {{protocol http="http://url" https="https://url"} - * also allow additional parameter "store" - * - * @param array $construction - * @return string - */ - public function protocolDirective($construction) - { - $params = $this->_getIncludeParameters($construction[2]); - $store = null; - if (isset($params['store'])) { - $store = Mage::app()->getSafeStore($params['store']); - } - $isSecure = Mage::app()->getStore($store)->isCurrentlySecure(); - $protocol = $isSecure ? 'https' : 'http'; - if (isset($params['url'])) { - return $protocol . '://' . $params['url']; - } - elseif (isset($params['http']) && isset($params['https'])) { - if ($isSecure) { - return $params['https']; - } - return $params['http']; - } - - return $protocol; - } - - /** - * Store config directive - * - * @param array $construction - * @return string - */ - public function configDirective($construction) - { - $configValue = ''; - $params = $this->_getIncludeParameters($construction[2]); - $storeId = $this->getStoreId(); - if (isset($params['path'])) { - $configValue = Mage::getStoreConfig($params['path'], $storeId); - } - return $configValue; - } - - /** - * Custom Variable directive - * - * @param array $construction - * @return string - */ - public function customvarDirective($construction) - { - $customVarValue = ''; - $params = $this->_getIncludeParameters($construction[2]); - if (isset($params['code'])) { - $variable = Mage::getModel('Mage_Core_Model_Variable') - ->setStoreId($this->getStoreId()) - ->loadByCode($params['code']); - $mode = $this->getPlainTemplateMode() - ? Mage_Core_Model_Variable::TYPE_TEXT - : Mage_Core_Model_Variable::TYPE_HTML; - if ($value = $variable->getValue($mode)) { - $customVarValue = $value; - } - } - return $customVarValue; - } - - /** - * Filter the string as template. - * Rewrited for logging exceptions - * - * @param string $value - * @return string - */ - public function filter($value) - { - try { - $value = parent::filter($value); - } catch (Exception $e) { - $value = ''; - Mage::logException($e); - } - return $value; - } -} diff --git a/app/code/core/Mage/Core/Model/EntryPoint/Http.php b/app/code/core/Mage/Core/Model/EntryPoint/Http.php deleted file mode 100644 index c3f3083dd62d6..0000000000000 --- a/app/code/core/Mage/Core/Model/EntryPoint/Http.php +++ /dev/null @@ -1,49 +0,0 @@ -_objectManager->get('Mage_Core_Controller_Request_Http'); - $response = $this->_objectManager->get('Mage_Core_Controller_Response_Http'); - $handler = $this->_objectManager->get('Magento_Http_Handler_Composite'); - $handler->handle($request, $response); - } catch (Mage_Core_Model_Session_Exception $e) { - header('Location: ' . Mage::getBaseUrl()); - } catch (Mage_Core_Model_Store_Exception $e) { - require Mage::getBaseDir(Mage_Core_Model_Dir::PUB) . DS . 'errors' . DS . '404.php'; - } catch (Magento_BootstrapException $e) { - header('Content-Type: text/plain', true, 503); - echo $e->getMessage(); - } catch (Exception $e) { - Mage::printException($e); - } - } -} diff --git a/app/code/core/Mage/Core/Model/EntryPoint/Media.php b/app/code/core/Mage/Core/Model/EntryPoint/Media.php deleted file mode 100644 index da4e12f4e5e5c..0000000000000 --- a/app/code/core/Mage/Core/Model/EntryPoint/Media.php +++ /dev/null @@ -1,51 +0,0 @@ -_objectManager = $objectManager ?: new Mage_Core_Model_ObjectManager( - new Mage_Core_Model_ObjectManager_Config($params), - $baseDir - ); - } - - /** - * Process request to application - */ - public abstract function processRequest(); -} - diff --git a/app/code/core/Mage/Core/Model/Layout.php b/app/code/core/Mage/Core/Model/Layout.php deleted file mode 100644 index d13182b982edf..0000000000000 --- a/app/code/core/Mage/Core/Model/Layout.php +++ /dev/null @@ -1,1542 +0,0 @@ -_blockFactory = $blockFactory; - $this->_area = $area; - $this->_structure = $structure; - $this->_argumentProcessor = $argumentProcessor; - $this->_translator = $translator; - $this->_elementClass = 'Mage_Core_Model_Layout_Element'; - $this->setXml(simplexml_load_string('', $this->_elementClass)); - $this->_renderingOutput = new Varien_Object; - $this->_scheduledStructure = $scheduledStructure; - } - - /** - * Cleanup circular references between layout & blocks - * - * Destructor should be called explicitly in order to work around the PHP bug - * https://bugs.php.net/bug.php?id=62468 - */ - public function __destruct() - { - if (isset($this->_update) && is_object($this->_update)) { - $this->_update->__destruct(); - $this->_update = null; - } - $this->_blocks = array(); - $this->_xml = null; - } - - /** - * Retrieve the layout update instance - * - * @return Mage_Core_Model_Layout_Merge - */ - public function getUpdate() - { - if (!$this->_update) { - $arguments = array('area' => $this->getArea()); - $this->_update = Mage::getModel('Mage_Core_Model_Layout_Merge', array('arguments' => $arguments)); - } - return $this->_update; - } - - /** - * Retrieve layout area - * - * @return string - */ - public function getArea() - { - return $this->_area; - } - - /** - * Declaring layout direct output flag - * - * @param bool $flag - * @return Mage_Core_Model_Layout - */ - public function setDirectOutput($flag) - { - $this->_directOutput = $flag; - return $this; - } - - /** - * Retrieve direct output flag - * - * @return bool - */ - public function isDirectOutput() - { - return $this->_directOutput; - } - - /** - * Layout xml generation - * - * @return Mage_Core_Model_Layout - */ - public function generateXml() - { - $xml = $this->getUpdate()->asSimplexml(); - $this->setXml($xml); - $this->_structure->importElements(array()); - return $this; - } - - /** - * Create structure of elements from the loaded XML configuration - */ - public function generateElements() - { - Magento_Profiler::start(__CLASS__ . '::' . __METHOD__); - Magento_Profiler::start('build_structure'); - - $this->_scheduledStructure->flushScheduledStructure(); - - $this->_readStructure($this->getNode()); - while (false === $this->_scheduledStructure->isStructureEmpty()) { - $this->_scheduleElement(key($this->_scheduledStructure->getStructure())); - }; - $this->_scheduledStructure->flushPaths(); - - foreach ($this->_scheduledStructure->getListToMove() as $elementToMove) { - $this->_moveElementInStructure($elementToMove); - } - - foreach ($this->_scheduledStructure->getListToRemove() as $elementToRemove) { - $this->_removeElement($elementToRemove); - } - - Magento_Profiler::stop('build_structure'); - - Magento_Profiler::start('generate_elements'); - - while (false === $this->_scheduledStructure->isElementsEmpty()) { - list($type, $node) = current($this->_scheduledStructure->getElements()); - $elementName = key($this->_scheduledStructure->getElements()); - - if (isset($node['output'])) { - $this->addOutputElement($elementName); - } - if ($type == self::TYPE_BLOCK) { - $this->_generateBlock($elementName); - } else { - $this->_generateContainer($elementName, (string)$node[self::CONTAINER_OPT_LABEL], array( - self::CONTAINER_OPT_HTML_TAG => (string)$node[self::CONTAINER_OPT_HTML_TAG], - self::CONTAINER_OPT_HTML_ID => (string)$node[self::CONTAINER_OPT_HTML_ID], - self::CONTAINER_OPT_HTML_CLASS => (string)$node[self::CONTAINER_OPT_HTML_CLASS] - )); - $this->_scheduledStructure->unsetElement($elementName); - } - } - Magento_Profiler::stop('generate_elements'); - Magento_Profiler::stop(__CLASS__ . '::' . __METHOD__); - } - - /** - * Remove scheduled element - * - * @param string $elementName - * @param bool $isChild - * @return Mage_Core_Model_Layout - */ - protected function _removeElement($elementName, $isChild = false) - { - $elementsToRemove = array_keys($this->_structure->getChildren($elementName)); - $this->_scheduledStructure->unsetElement($elementName); - - foreach ($elementsToRemove as $element) { - $this->_removeElement($element, true); - } - - if (!$isChild) { - $this->_structure->unsetElement($elementName); - $this->_scheduledStructure->unsetElementFromListToRemove($elementName); - } - return $this; - } - - /** - * Move element in scheduled structure - * - * @param string $element - * @return Mage_Core_Model_Layout - */ - protected function _moveElementInStructure($element) - { - list ($destination, $siblingName, $isAfter, $alias) = $this->_scheduledStructure->getElementToMove($element); - if (!$alias && false === $this->_structure->getChildId($destination, $this->getElementAlias($element))) { - $alias = $this->getElementAlias($element); - } - $this->_structure->unsetChild($element, $alias)->setAsChild($element, $destination, $alias); - $this->reorderChild($destination, $element, $siblingName, $isAfter); - return $this; - } - - /** - * Traverse through all elements of specified XML-node and schedule structural elements of it - * - * @param Mage_Core_Model_Layout_Element $parent - */ - protected function _readStructure($parent) - { - foreach ($parent as $node) { - /** @var $node Mage_Core_Model_Layout_Element */ - switch ($node->getName()) { - case self::TYPE_CONTAINER: - case self::TYPE_BLOCK: - $this->_scheduleStructure($node, $parent); - $this->_readStructure($node); - break; - - case self::TYPE_REFERENCE: - $this->_readStructure($node); - break; - - case self::TYPE_ACTION: - $referenceName = $parent->getAttribute('name'); - $element = $this->_scheduledStructure->getStructureElement($referenceName, array()); - $element['actions'][] = array($node, $parent); - $this->_scheduledStructure->setStructureElement($referenceName, $element); - break; - - case self::TYPE_ARGUMENTS: - $referenceName = $parent->getAttribute('name'); - $element = $this->_scheduledStructure->getStructureElement($referenceName, array()); - $args = $this->_readArguments($node); - $element['arguments'] = $this->_mergeArguments($element, $args); - - $this->_scheduledStructure->setStructureElement($referenceName, $element); - break; - - case self::TYPE_MOVE: - $this->_scheduleMove($node); - break; - - case self::TYPE_REMOVE: - $this->_scheduledStructure->setElementToRemoveList((string)$node->getAttribute('name')); - break; - } - } - } - - /** - * Merge element arguments - * - * @param array $element - * @param array $arguments - * @return array - */ - protected function _mergeArguments(array $element, array $arguments) - { - $output = $arguments; - if (isset($element['arguments'])) { - $output = array_replace_recursive($element['arguments'], $arguments); - } - return $output; - } - - /** - * Read arguments node and create prepared array of them - * - * @param Mage_Core_Model_Layout_Element $node - * @return array - */ - protected function _readArguments(Mage_Core_Model_Layout_Element $node) - { - $arguments = array(); - $moduleName = isset($node['module']) ? (string)$node['module'] : null; - - foreach ($node->children() as $argument) { - /** @var $argument Mage_Core_Model_Layout_Element */ - - $type = $argument->getAttribute('type'); - if (null !== $type) { - $arguments[$argument->getName()]['type'] = $type; - } - - if ($argument->hasChildren()) { - $value = array(); - $this->_fillArgumentsArray($argument, $value, $moduleName); - unset($value['updater']); - unset($value['@']); - - $updaters = $this->_getArgumentUpdaters($argument); - - if (false === empty($updaters)) { - $arguments[$argument->getName()]['updater'] = $updaters; - } - - if (is_array($value) && !empty($value)) { - $arguments[$argument->getName()]['value'] = $value; - } - } else { - $value = $this->_translator->translateArgument($argument, $moduleName); - if ('' !== $value) { - $arguments[$argument->getName()]['value'] = $value; - } - } - } - return $arguments; - } - - protected function _fillArgumentsArray(Mage_Core_Model_Layout_Element $node, &$argumentsArray, $moduleName) - { - $moduleName = isset($node['module']) ? (string)$node['module'] : $moduleName; - - /** @var $childNode Mage_Core_Model_Layout_Element */ - foreach ($node->children() as $childNode) { - $nodeName = $childNode->getName(); - if ($childNode->hasChildren()) { - $this->_fillArgumentsArray($childNode, $argumentsArray[$nodeName], $moduleName); - } else { - $argumentsArray[$nodeName] = $this->_translator->translateArgument($childNode, $moduleName); - } - } - } - - /** - * Get argument updaters list - * - * @param Mage_Core_Model_Layout_Element $argument - * @return array - */ - protected function _getArgumentUpdaters(Mage_Core_Model_Layout_Element $argument) - { - $updaters = array(); - foreach ($argument->children() as $argumentChild) { - /** @var $argumentChild Mage_Core_Model_Layout_Element */ - if ('updater' == $argumentChild->getName()) { - $updaters[uniqid()] = trim((string)$argumentChild); - } - } - return $updaters; - } - - /** - * Schedule structural changes for move directive - * - * @param Mage_Core_Model_Layout_Element $node - * @throws Magento_Exception - * @return Mage_Core_Model_Layout - */ - protected function _scheduleMove($node) - { - $elementName = (string)$node->getAttribute('element'); - $destination = (string)$node->getAttribute('destination'); - $alias = (string)$node->getAttribute('as') ?: ''; - if ($elementName && $destination) { - list($siblingName, $isAfter) = $this->_beforeAfterToSibling($node); - $this->_scheduledStructure->setElementToMove( - $elementName, - array($destination, $siblingName, $isAfter, $alias) - ); - } else { - throw new Magento_Exception('Element name and destination must be specified.'); - } - return $this; - } - - /** - * Populate queue for generating structural elements - * - * @param Mage_Core_Model_Layout_Element $node - * @param Mage_Core_Model_Layout_Element $parent - * @see _scheduleElement() where the _scheduledStructure is used - */ - protected function _scheduleStructure($node, $parent) - { - if ((string)$node->getAttribute('name')) { - $name = (string)$node->getAttribute('name'); - } else { - $name = $this->_generateAnonymousName($parent->getElementName() . '_schedule_block'); - $node->addAttribute('name', $name); - } - $path = $name; - - // type, alias, parentName, siblingName, isAfter, node - $row = array( - self::SCHEDULED_STRUCTURE_INDEX_NAME => $node->getName(), - self::SCHEDULED_STRUCTURE_INDEX_ALIAS => '', - self::SCHEDULED_STRUCTURE_INDEX_PARENT_NAME => '', - self::SCHEDULED_STRUCTURE_INDEX_SIBLING_NAME => null, - self::SCHEDULED_STRUCTURE_INDEX_IS_AFTER => true, - self::SCHEDULED_STRUCTURE_INDEX_LAYOUT_ELEMENT => $node - ); - - $parentName = $parent->getElementName(); - if ($parentName) { - $row[self::SCHEDULED_STRUCTURE_INDEX_ALIAS] = (string)$node->getAttribute('as'); - $row[self::SCHEDULED_STRUCTURE_INDEX_PARENT_NAME] = $parentName; - - list( - $row[self::SCHEDULED_STRUCTURE_INDEX_SIBLING_NAME], - $row[self::SCHEDULED_STRUCTURE_INDEX_IS_AFTER] - ) = $this->_beforeAfterToSibling($node); - - // materialized path for referencing nodes in the plain array of _scheduledStructure - if ($this->_scheduledStructure->hasPath($parentName)) { - $path = $this->_scheduledStructure->getPath($parentName) . '/' . $path; - } - } - - $this->_overrideElementWorkaround($name, $path); - $this->_scheduledStructure->setPathElement($name, $path); - if ($this->_scheduledStructure->hasStructureElement($name)) { - // union of arrays - $this->_scheduledStructure->setStructureElement( - $name, - $row + $this->_scheduledStructure->getStructureElement($name) - ); - } else { - $this->_scheduledStructure->setStructureElement($name, $row); - } - } - - /** - * Analyze "before" and "after" information in the node and return sibling name and whether "after" or "before" - * - * @param Mage_Core_Model_Layout_Element $node - * @return array - */ - protected function _beforeAfterToSibling($node) - { - $result = array(null, true); - if (isset($node['after'])) { - $result[0] = (string)$node['after']; - } elseif (isset($node['before'])) { - $result[0] = (string)$node['before']; - $result[1] = false; - } - return $result; - } - - /** - * Destroy previous element with same name and all its children, if new element overrides it - * - * This is a workaround to handle situation, when an element emerges with name of element that already exists. - * In this case we destroy entire structure of the former element and replace with the new one. - * - * @param string $name - * @param string $path - */ - protected function _overrideElementWorkaround($name, $path) - { - if ($this->_scheduledStructure->hasStructureElement($name)) { - foreach ($this->_scheduledStructure->getPaths() as $potentialChild => $childPath) { - if (0 === strpos($childPath, "{$path}/")) { - $this->_scheduledStructure->unsetPathElement($potentialChild); - $this->_scheduledStructure->unsetStructureElement($potentialChild); - } - } - } - } - - /** - * Process queue of structural elements and actually add them to structure, and schedule elements for generation - * - * The catch is to populate parents first, if they are not in the structure yet. - * Since layout updates could come in arbitrary order, a case is possible where an element is declared in reference, - * while referenced element itself is not declared yet. - * - * @SuppressWarnings(PHPMD.NPathComplexity) - * @param string $key in _scheduledStructure represent element name - */ - protected function _scheduleElement($key) - { - $row = $this->_scheduledStructure->getStructureElement($key); - - if (!isset($row[self::SCHEDULED_STRUCTURE_INDEX_LAYOUT_ELEMENT])) { - Mage::log("Broken reference: missing declaration of the element '{$key}'.", Zend_Log::CRIT); - $this->_scheduledStructure->unsetPathElement($key); - $this->_scheduledStructure->unsetStructureElement($key); - return; - } - list($type, $alias, $parentName, $siblingName, $isAfter, $node) = $row; - $name = $this->_createStructuralElement($key, $type, $parentName . $alias); - if ($parentName) { - // recursively populate parent first - if ($this->_scheduledStructure->hasStructureElement($parentName)) { - $this->_scheduleElement($parentName, $this->_scheduledStructure->getStructureElement($parentName)); - } - if ($this->_structure->hasElement($parentName)) { - $this->_structure->setAsChild($name, $parentName, $alias); - } else { - Mage::log("Broken reference: the '{$name}' element cannot be added as child to '{$parentName}, " - . 'because the latter doesn\'t exist', Zend_Log::CRIT - ); - } - } - $this->_scheduledStructure->unsetStructureElement($key); - $data = array( - $type, - $node, - isset($row['actions']) ? $row['actions'] : array(), - isset($row['arguments']) ? $row['arguments'] : array() - ); - $this->_scheduledStructure->setElement($name, $data); - - /** - * Some elements provide info "after" or "before" which sibling they are supposed to go - * Make sure to populate these siblings as well and order them correctly - */ - if ($siblingName) { - if ($this->_scheduledStructure->hasStructureElement($siblingName)) { - $this->_scheduleElement($siblingName); - } - $this->reorderChild($parentName, $name, $siblingName, $isAfter); - } - } - - /** - * Register an element in structure - * - * Will assign an "anonymous" name to the element, if provided with an empty name - * - * @param string $name - * @param string $type - * @param string $class - * @return string - */ - protected function _createStructuralElement($name, $type, $class) - { - if (empty($name)) { - $name = $this->_generateAnonymousName($class); - } - $this->_structure->createElement($name, array('type' => $type)); - return $name; - } - - /** - * Generate anonymous element name for structure - * - * @param string $class - * @return string - */ - protected function _generateAnonymousName($class) - { - $position = strpos($class, 'Block'); - $key = $position !== false ? substr($class, $position + 6) : $class; - $key = strtolower(trim($key, '_')); - - if (!isset($this->_nameIncrement[$key])) { - $this->_nameIncrement[$key] = 0; - } - - if ($this->_nameIncrement[$key] == 0 && !$this->_structure->hasElement($key)) { - $this->_nameIncrement[$key]++; - return $key; - } - - do { - $name = $key . '_' . $this->_nameIncrement[$key]++; - } while ($this->_structure->hasElement($name)); - - return $name; - } - - /** - * Creates block object based on xml node data and add it to the layout - * - * @param string $elementName - * @return Mage_Core_Block_Abstract - * @throws Magento_Exception - */ - protected function _generateBlock($elementName) - { - list($type, $node, $actions, $arguments) = $this->_scheduledStructure->getElement($elementName); - if ($type !== self::TYPE_BLOCK) { - throw new Magento_Exception("Unexpected element type specified for generating block: {$type}."); - } - - // create block - if (!empty($node['class'])) { - $className = (string)$node['class']; - } else { - $className = (string)$node['type']; - } - - $arguments = $this->_argumentProcessor->process($arguments); - - $block = $this->_createBlock($className, $elementName, $arguments); - if (!empty($node['template'])) { - $block->setTemplate((string)$node['template']); - } - - $this->_scheduledStructure->unsetElement($elementName); - - // execute block methods - foreach ($actions as $action) { - list($actionNode, $parent) = $action; - $this->_generateAction($actionNode, $parent); - } - - return $block; - } - - /** - * Set container-specific data to structure element - * - * @param string $name - * @param string $label - * @param array $options - * @throws Magento_Exception if any of arguments are invalid - */ - protected function _generateContainer($name, $label, array $options) - { - if (empty($label)) { - throw new Magento_Exception('Container requires a label.'); - } - $this->_structure->setAttribute($name, self::CONTAINER_OPT_LABEL, $label); - unset($options[self::CONTAINER_OPT_LABEL]); - unset($options['type']); - if (empty($options[self::CONTAINER_OPT_HTML_TAG]) - && (!empty($options[self::CONTAINER_OPT_HTML_ID]) || !empty($options[self::CONTAINER_OPT_HTML_CLASS])) - ) { - throw new Magento_Exception('HTML ID or class will not have effect, if HTML tag is not specified.'); - } - foreach ($options as $key => $value) { - $this->_structure->setAttribute($name, $key, $value); - } - } - - /** - * Run action defined in layout update - * - * @param Mage_Core_Model_Layout_Element $node - * @param Mage_Core_Model_Layout_Element $parent - */ - protected function _generateAction($node, $parent) - { - $configPath = $node->getAttribute('ifconfig'); - if ($configPath && !Mage::getStoreConfigFlag($configPath)) { - return; - } - - $method = $node->getAttribute('method'); - $parentName = $node->getAttribute('block'); - if (empty($parentName)) { - $parentName = $parent->getElementName(); - } - - $profilerKey = 'BLOCK_ACTION:' . $parentName . '>' . $method; - Magento_Profiler::start($profilerKey); - - $block = $this->getBlock($parentName); - if (!empty($block)) { - $args = $this->_extractArgs($node); - $this->_translator->translateActionParameters($node, $args); - call_user_func_array(array($block, $method), $args); - } - - Magento_Profiler::stop($profilerKey); - } - - /** - * Get child block if exists - * - * @param string $parentName - * @param string $alias - * @return bool|Mage_Core_Block_Abstract - */ - public function getChildBlock($parentName, $alias) - { - $name = $this->_structure->getChildId($parentName, $alias); - if ($this->isBlock($name)) { - return $this->getBlock($name); - } - return false; - } - - /** - * Set child element into layout structure - * - * @param string $parentName - * @param string $elementName - * @param string $alias - * @return Mage_Core_Model_Layout - */ - public function setChild($parentName, $elementName, $alias) - { - $this->_structure->setAsChild($elementName, $parentName, $alias); - return $this; - } - - /** - * Reorder a child of a specified element - * - * If $offsetOrSibling is null, it will put the element to the end - * If $offsetOrSibling is numeric (integer) value, it will put the element after/before specified position - * Otherwise -- after/before specified sibling - * - * @param string $parentName - * @param string $childName - * @param string|int|null $offsetOrSibling - * @param bool $after - */ - public function reorderChild($parentName, $childName, $offsetOrSibling, $after = true) - { - if (is_numeric($offsetOrSibling)) { - $offset = (int)abs($offsetOrSibling) * ($after ? 1 : -1); - $this->_structure->reorderChild($parentName, $childName, $offset); - } elseif (null === $offsetOrSibling) { - $this->_structure->reorderChild($parentName, $childName, null); - } else { - $children = $this->getChildNames($parentName); - $sibling = $this->_filterSearchMinus($offsetOrSibling, $children, $after); - if ($childName !== $sibling) { - $siblingParentName = $this->_structure->getParentId($sibling); - if ($parentName !== $siblingParentName) { - Mage::log( - "Broken reference: the '{$childName}' tries to reorder itself towards '{$sibling}', " - . "but their parents are different: '{$parentName}' and '{$siblingParentName}' respectively.", - Zend_Log::CRIT - ); - return; - } - $this->_structure->reorderToSibling($parentName, $childName, $sibling, $after ? 1 : -1); - } - } - } - - /** - * Search for an array element using needle, but needle may be '-', which means "first" or "last" element - * - * Returns first or last element in the haystack, or the $needle argument - * - * @param string $needle - * @param array $haystack - * @param bool $isLast - * @return string - */ - protected function _filterSearchMinus($needle, array $haystack, $isLast) - { - if ('-' === $needle) { - if ($isLast) { - return array_pop($haystack); - } - return array_shift($haystack); - } - return $needle; - } - - /** - * Remove child element from parent - * - * @param string $parentName - * @param string $alias - * @return Mage_Core_Model_Layout - */ - public function unsetChild($parentName, $alias) - { - $this->_structure->unsetChild($parentName, $alias); - return $this; - } - - /** - * Get list of child names - * - * @param string $parentName - * @return array - */ - public function getChildNames($parentName) - { - return array_keys($this->_structure->getChildren($parentName)); - } - - /** - * Get list of child blocks - * - * Returns associative array of => - * - * @param string $parentName - * @return array - */ - public function getChildBlocks($parentName) - { - $blocks = array(); - foreach ($this->_structure->getChildren($parentName) as $childName => $alias) { - $block = $this->getBlock($childName); - if ($block) { - $blocks[$alias] = $block; - } - } - return $blocks; - } - - /** - * Get child name by alias - * - * @param string $parentName - * @param string $alias - * @return bool|string - */ - public function getChildName($parentName, $alias) - { - return $this->_structure->getChildId($parentName, $alias); - } - - /** - * Find an element in layout, render it and return string with its output - * - * @param string $name - * @param bool $useCache - * @return string - */ - public function renderElement($name, $useCache = true) - { - if (!isset($this->_renderElementCache[$name]) || !$useCache) { - if ($this->isBlock($name)) { - $result = $this->_renderBlock($name); - } else { - $result = $this->_renderContainer($name); - } - $this->_renderElementCache[$name] = $result; - } - $this->_renderingOutput->setData('output', $this->_renderElementCache[$name]); - Mage::dispatchEvent('core_layout_render_element', array( - 'element_name' => $name, - 'layout' => $this, - 'transport' => $this->_renderingOutput, - )); - return $this->_renderingOutput->getData('output'); - } - - /** - * Gets HTML of block element - * - * @param string $name - * @return string - * @throws Magento_Exception - */ - protected function _renderBlock($name) - { - $block = $this->getBlock($name); - return $block ? $block->toHtml() : ''; - } - - /** - * Gets HTML of container element - * - * @param string $name - * @return string - */ - protected function _renderContainer($name) - { - $html = ''; - $children = $this->getChildNames($name); - foreach ($children as $child) { - $html .= $this->renderElement($child); - } - if ($html == '' || !$this->_structure->getAttribute($name, self::CONTAINER_OPT_HTML_TAG)) { - return $html; - } - - $htmlId = $this->_structure->getAttribute($name, self::CONTAINER_OPT_HTML_ID); - if ($htmlId) { - $htmlId = ' id="' . $htmlId . '"'; - } - - $htmlClass = $this->_structure->getAttribute($name, self::CONTAINER_OPT_HTML_CLASS); - if ($htmlClass) { - $htmlClass = ' class="'. $htmlClass . '"'; - } - - $htmlTag = $this->_structure->getAttribute($name, self::CONTAINER_OPT_HTML_TAG); - - $html = sprintf('<%1$s%2$s%3$s>%4$s', $htmlTag, $htmlId, $htmlClass, $html); - - return $html; - } - - /** - * Add element to parent group - * - * @param string $blockName - * @param string $parentGroupName - * @return bool - */ - public function addToParentGroup($blockName, $parentGroupName) - { - return $this->_structure->addToParentGroup($blockName, $parentGroupName); - } - - /** - * Get element names for specified group - * - * @param string $blockName - * @param string $groupName - * @return array - */ - public function getGroupChildNames($blockName, $groupName) - { - return $this->_structure->getGroupChildNames($blockName, $groupName); - } - - /** - * Update args according to its type - * - * @param Mage_Core_Model_Layout_Element $node - * @return array - */ - protected function _extractArgs($node) - { - $args = (array)$node->children(); - unset($args['@attributes']); - - foreach ($args as $key => $arg) { - if (($arg instanceof Mage_Core_Model_Layout_Element)) { - if (isset($arg['helper'])) { - $args[$key] = $this->_getArgsByHelper($arg); - } else { - /** - * if there is no helper we hope that this is assoc array - */ - $arr = $this->_getArgsFromAssoc($arg); - if (!empty($arr)) { - $args[$key] = $arr; - } - } - } - } - - if (isset($node['json'])) { - $json = explode(' ', (string)$node['json']); - foreach ($json as $arg) { - $args[$arg] = Mage::helper('Mage_Core_Helper_Data')->jsonDecode($args[$arg]); - } - } - - return $args; - } - - /** - * Gets arguments using helper method - * - * @param Mage_Core_Model_Layout_Element $arg - * @return mixed - */ - protected function _getArgsByHelper(Mage_Core_Model_Layout_Element $arg) - { - $helper = (string)$arg['helper']; - list($helperName, $helperMethod) = explode('::', $helper); - $arg = $arg->asArray(); - unset($arg['@']); - return call_user_func_array(array(Mage::helper($helperName), $helperMethod), $arg); - } - - /** - * Converts input array to arguments array - * - * @param array $array - * @return array - */ - protected function _getArgsFromAssoc($array) - { - $arr = array(); - foreach ($array as $key => $value) { - $arr[(string)$key] = $value->asArray(); - } - return $arr; - } - - /** - * Check if element exists in layout structure - * - * @param string $name - * @return bool - */ - public function hasElement($name) - { - return $this->_structure->hasElement($name); - } - - /** - * Get property value of an element - * - * @param string $name - * @param string $attribute - * @return mixed - */ - public function getElementProperty($name, $attribute) - { - return $this->_structure->getAttribute($name, $attribute); - } - - /** - * Whether specified element is a block - * - * @param string $name - * @return bool - */ - public function isBlock($name) - { - if ($this->_structure->hasElement($name)) { - return self::TYPE_BLOCK === $this->_structure->getAttribute($name, 'type'); - } - return false; - } - - /** - * Checks if element with specified name is container - * - * @param string $name - * @return bool - */ - public function isContainer($name) - { - if ($this->_structure->hasElement($name)) { - return self::TYPE_CONTAINER === $this->_structure->getAttribute($name, 'type'); - } - return false; - } - - /** - * Whether the specified element may be manipulated externally - * - * @param string $name - * @return bool - */ - public function isManipulationAllowed($name) - { - $parentName = $this->_structure->getParentId($name); - return $parentName && $this->isContainer($parentName); - } - - /** - * Save block in blocks registry - * - * @param string $name - * @param Mage_Core_Block_Abstract $block - * @return Mage_Core_Model_Layout - */ - public function setBlock($name, $block) - { - $this->_blocks[$name] = $block; - return $this; - } - - /** - * Remove block from registry - * - * @param string $name - * @return Mage_Core_Model_Layout - */ - public function unsetElement($name) - { - if (isset($this->_blocks[$name])) { - $this->_blocks[$name] = null; - unset($this->_blocks[$name]); - } - $this->_structure->unsetElement($name); - - return $this; - } - - /** - * Block Factory - * - * @param string $type - * @param string $name - * @param array $attributes - * @return Mage_Core_Block_Abstract - */ - public function createBlock($type, $name = '', array $attributes = array()) - { - $name = $this->_createStructuralElement($name, self::TYPE_BLOCK, $type); - $block = $this->_createBlock($type, $name, $attributes); - return $block; - } - - /** - * Create block and add to layout - * - * @param string|Mage_Core_Block_Abstract $block - * @param string $name - * @param array $attributes - * @return Mage_Core_Block_Abstract - */ - protected function _createBlock($block, $name, array $attributes = array()) - { - $block = $this->_getBlockInstance($block, $attributes); - - $block->setType(get_class($block)); - $block->setNameInLayout($name); - $block->addData($attributes); - $block->setLayout($this); - - $this->_blocks[$name] = $block; - Mage::dispatchEvent('core_layout_block_create_after', array('block' => $block)); - return $this->_blocks[$name]; - } - - /** - * Add a block to registry, create new object if needed - * - * @param string|Mage_Core_Block_Abstract $block - * @param string $name - * @param string $parent - * @param string $alias - * @return Mage_Core_Block_Abstract - */ - public function addBlock($block, $name = '', $parent = '', $alias = '') - { - if (empty($name) && $block instanceof Mage_Core_Block_Abstract) { - $name = $block->getNameInLayout(); - } - $name = $this->_createStructuralElement( - $name, - self::TYPE_BLOCK, - $name ?: (is_object($block) ? get_class($block) : $block) - ); - if ($parent) { - $this->_structure->setAsChild($name, $parent, $alias); - } - return $this->_createBlock($block, $name); - } - - /** - * Insert container into layout structure - * - * @param string $name - * @param string $label - * @param array $options - * @param string $parent - * @param string $alias - */ - public function addContainer($name, $label, array $options = array(), $parent = '', $alias = '') - { - $name = $this->_createStructuralElement($name, self::TYPE_CONTAINER, $alias); - $this->_generateContainer($name, $label, $options); - if ($parent) { - $this->_structure->setAsChild($name, $parent, $alias); - } - } - - /** - * Rename element in layout and layout structure - * - * @param string $oldName - * @param string $newName - * @return bool - */ - public function renameElement($oldName, $newName) - { - if (isset($this->_blocks[$oldName])) { - $block = $this->_blocks[$oldName]; - $this->_blocks[$oldName] = null; - unset($this->_blocks[$oldName]); - $this->_blocks[$newName] = $block; - } - $this->_structure->renameElement($oldName, $newName); - - return $this; - } - - /** - * Create block object instance based on block type - * - * @param string|Mage_Core_Block_Abstract $block - * @param array $attributes - * @return Mage_Core_Block_Abstract - */ - protected function _getBlockInstance($block, array $attributes = array()) - { - if ($block && is_string($block)) { - if (class_exists($block)) { - $block = $this->_blockFactory->createBlock($block, $attributes); - } - } - if (!$block instanceof Mage_Core_Block_Abstract) { - Mage::throwException(Mage::helper('Mage_Core_Helper_Data')->__('Invalid block type: %s', $block)); - } - return $block; - } - - - /** - * Retrieve all blocks from registry as array - * - * @return array - */ - public function getAllBlocks() - { - return $this->_blocks; - } - - /** - * Get block object by name - * - * @param string $name - * @return Mage_Core_Block_Abstract|bool - */ - public function getBlock($name) - { - if ($this->_scheduledStructure->hasElement($name)) { - $this->_generateBlock($name); - } - if (isset($this->_blocks[$name])) { - return $this->_blocks[$name]; - } else { - return false; - } - } - - /** - * Gets parent name of an element with specified name - * - * @param string $childName - * @return bool|string - */ - public function getParentName($childName) - { - return $this->_structure->getParentId($childName); - } - - /** - * Get element alias by name - * - * @param string $name - * @return bool|string - */ - public function getElementAlias($name) - { - return $this->_structure->getChildAlias($this->_structure->getParentId($name), $name); - } - - /** - * Add an element to output - * - * @param string $name - * @return Mage_Core_Model_Layout - */ - public function addOutputElement($name) - { - $this->_output[$name] = $name; - return $this; - } - - /** - * Remove an element from output - * - * @param string $name - * @return Mage_Core_Model_Layout - */ - public function removeOutputElement($name) - { - if (isset($this->_output[$name])) { - unset($this->_output[$name]); - } - return $this; - } - - /** - * Get all blocks marked for output - * - * @return string - */ - public function getOutput() - { - $out = ''; - foreach ($this->_output as $name) { - $out .= $this->renderElement($name); - } - - return $out; - } - - /** - * Retrieve messages block - * - * @return Mage_Core_Block_Messages - */ - public function getMessagesBlock() - { - $block = $this->getBlock('messages'); - if ($block) { - return $block; - } - return $this->createBlock('Mage_Core_Block_Messages', 'messages'); - } - - /** - * Get block singleton - * - * @param string $type - * @return Mage_Core_Helper_Abstract - */ - public function getBlockSingleton($type) - { - if (!isset($this->_helpers[$type])) { - if (!$type) { - Mage::throwException(Mage::helper('Mage_Core_Helper_Data')->__('Invalid block type: %s', $type)); - } - - $helper = Mage::getModel($type); - if ($helper) { - if ($helper instanceof Mage_Core_Block_Abstract) { - $helper->setLayout($this); - } - $this->_helpers[$type] = $helper; - } - } - return $this->_helpers[$type]; - } - - /** - * Retrieve helper object - * - * @param string $name - * @return Mage_Core_Helper_Abstract - */ - public function helper($name) - { - $helper = Mage::helper($name); - if (!$helper) { - return false; - } - return $helper->setLayout($this); - } - - /** - * Lookup module name for translation from current specified layout node - * - * Priorities: - * 1) "module" attribute in the element - * 2) "module" attribute in any ancestor element - * 3) layout handle name - first 1 or 2 parts (namespace is determined automatically) - * - * @param Varien_Simplexml_Element $node - * @return string - */ - public static function findTranslationModuleName(Varien_Simplexml_Element $node) - { - // Commented out code uses not yet implemented functionality. - $result = (string) $node->getAttribute('module'); - if ($result) { - //return Mage::getConfig()->getModuleConfig($result) ? $result : 'core'; - return $result; - } - foreach (array_reverse($node->xpath('ancestor::*[@module]')) as $element) { - $result = (string)$element->getAttribute('module'); - if ($result) { - //return Mage::getConfig()->getModuleConfig($result) ? $result : 'core'; - return $result; - } - } - foreach ($node->xpath('ancestor-or-self::*[last()-1]') as $handle) { - $name = Mage::getConfig()->determineOmittedNamespace($handle->getName(), true); - if ($name) { - //return Mage::getConfig()->getModuleConfig($name) ? $name : 'core'; - return $name; - } - } - return 'Mage_Core'; - } - - /** - * Retrieve block factory - * - * @return Mage_Core_Model_BlockFactory - */ - public function getBlockFactory() - { - return $this->_blockFactory; - } -} diff --git a/app/code/core/Mage/Core/Model/Layout/Argument/Handler/Options.php b/app/code/core/Mage/Core/Model/Layout/Argument/Handler/Options.php deleted file mode 100644 index 8c5d7a7d4e9d5..0000000000000 --- a/app/code/core/Mage/Core/Model/Layout/Argument/Handler/Options.php +++ /dev/null @@ -1,51 +0,0 @@ - - */ -class Mage_Core_Model_Layout_Argument_Handler_Options extends Mage_Core_Model_Layout_Argument_HandlerAbstract -{ - /** - * Return option array of given option model - * @param string $value - * @throws InvalidArgumentException - * @return Mage_Core_Model_Abstract|boolean - */ - public function process($value) - { - /** @var $valueInstance Mage_Core_Model_Option_ArrayInterface */ - $valueInstance = $this->_objectManager->create($value, array(), false); - if (false === ($valueInstance instanceof Mage_Core_Model_Option_ArrayInterface)) { - throw new InvalidArgumentException('Incorrect option model'); - } - return $valueInstance->toOptionArray(); - } -} diff --git a/app/code/core/Mage/Core/Model/Layout/Argument/Handler/Url.php b/app/code/core/Mage/Core/Model/Layout/Argument/Handler/Url.php deleted file mode 100644 index 964032d2995c5..0000000000000 --- a/app/code/core/Mage/Core/Model/Layout/Argument/Handler/Url.php +++ /dev/null @@ -1,67 +0,0 @@ - - */ -class Mage_Core_Model_Layout_Argument_Handler_Url extends Mage_Core_Model_Layout_Argument_HandlerAbstract -{ - /** - * @var Mage_Core_Model_Url - */ - protected $_urlModel; - - /** - * @param Magento_ObjectManager $objectManager - * @param Mage_Core_Model_Url $urlModel - */ - public function __construct(Magento_ObjectManager $objectManager, Mage_Core_Model_Url $urlModel) - { - parent::__construct($objectManager); - - $this->_urlModel = $urlModel; - } - - /** - * Generate url - * @param string $value - * @throws InvalidArgumentException - * @return Mage_Core_Model_Abstract|boolean - */ - public function process($value) - { - if (false === is_array($value) || (!isset($value['path']))) { - throw new InvalidArgumentException('Passed value has incorrect format'); - } - - $params = array_key_exists('params', $value) ? $value['params'] : null; - return $this->_urlModel->getUrl($value['path'], $params); - } -} diff --git a/app/code/core/Mage/Core/Model/Layout/Argument/Updater.php b/app/code/core/Mage/Core/Model/Layout/Argument/Updater.php deleted file mode 100644 index aa90d18c43bfb..0000000000000 --- a/app/code/core/Mage/Core/Model/Layout/Argument/Updater.php +++ /dev/null @@ -1,71 +0,0 @@ - - */ -class Mage_Core_Model_Layout_Argument_Updater -{ - /** - * @var Magento_ObjectManager - */ - protected $_objectManager; - - /** - * @param Magento_ObjectManager $objectManager - */ - public function __construct(Magento_ObjectManager $objectManager) - { - $this->_objectManager = $objectManager; - } - - /** - * Apply all updater to value - * - * @param mixed $value - * @param array $updaters - * @throws InvalidArgumentException - * @return mixed - */ - public function applyUpdaters($value, array $updaters = array()) - { - foreach ($updaters as $updater) { - /** @var Mage_Core_Model_Layout_Argument_UpdaterInterface $updaterInstance */ - $updaterInstance = $this->_objectManager->create($updater, array(), false); - if (false === ($updaterInstance instanceof Mage_Core_Model_Layout_Argument_UpdaterInterface)) { - throw new InvalidArgumentException($updater - . ' should implement Mage_Core_Model_Layout_Argument_UpdaterInterface' - ); - } - $value = $updaterInstance->update($value); - } - return $value; - } -} diff --git a/app/code/core/Mage/Core/Model/Layout/Factory.php b/app/code/core/Mage/Core/Model/Layout/Factory.php deleted file mode 100644 index 0903d442562c6..0000000000000 --- a/app/code/core/Mage/Core/Model/Layout/Factory.php +++ /dev/null @@ -1,76 +0,0 @@ -_objectManager = $objectManager; - } - - /** - * @param array $arguments - * @param string $className - * @return Mage_Core_Model_Layout - */ - public function createLayout(array $arguments = array(), $className = self::CLASS_NAME) - { - // because layout singleton was used everywhere in magento code, in observers, models, blocks, etc. - // the only way how we can replace default layout object with custom one is to save instance of custom layout - // to instance manager storage using default layout class name as alias - $createLayout = true; - if (isset($arguments['area'])) { - if ($this->_objectManager->hasSharedInstance(self::CLASS_NAME)) { - /** @var $layout Mage_Core_Model_Layout */ - $layout = $this->_objectManager->get(self::CLASS_NAME); - if ($arguments['area'] != $layout->getArea()) { - $this->_objectManager->removeSharedInstance(self::CLASS_NAME); - } else { - $createLayout = false; - } - } - } - if ($createLayout) { - $layout = $this->_objectManager->create($className, $arguments, false); - $this->_objectManager->addSharedInstance($layout, self::CLASS_NAME); - } - - return $this->_objectManager->get(self::CLASS_NAME); - } -} diff --git a/app/code/core/Mage/Core/Model/Locale.php b/app/code/core/Mage/Core/Model/Locale.php deleted file mode 100644 index d0d5e0d9d6c20..0000000000000 --- a/app/code/core/Mage/Core/Model/Locale.php +++ /dev/null @@ -1,781 +0,0 @@ - - */ -class Mage_Core_Model_Locale -{ - /** - * Default locale name - */ - const DEFAULT_LOCALE = 'en_US'; - const DEFAULT_TIMEZONE = 'UTC'; - const DEFAULT_CURRENCY = 'USD'; - - /** - * XML path constants - */ - const XML_PATH_DEFAULT_LOCALE = 'general/locale/code'; - const XML_PATH_DEFAULT_TIMEZONE = 'general/locale/timezone'; - const XML_PATH_ALLOW_CODES = 'global/locale/allow/codes'; - const XML_PATH_ALLOW_CURRENCIES = 'global/locale/allow/currencies'; - const XML_PATH_ALLOW_CURRENCIES_INSTALLED = 'system/currency/installed'; - - /** - * Date and time format codes - */ - const FORMAT_TYPE_FULL = 'full'; - const FORMAT_TYPE_LONG = 'long'; - const FORMAT_TYPE_MEDIUM= 'medium'; - const FORMAT_TYPE_SHORT = 'short'; - - /** - * Default locale code - * - * @var string - */ - protected $_defaultLocale; - - /** - * Locale object - * - * @var Zend_Locale - */ - protected $_locale; - - /** - * Locale code - * - * @var string - */ - protected $_localeCode; - - /** - * Emulated locales stack - * - * @var array - */ - protected $_emulatedLocales = array(); - - protected static $_currencyCache = array(); - - public function __construct($locale = null) - { - $this->setLocale($locale); - } - - /** - * Set default locale code - * - * @param string $locale - * @return Mage_Core_Model_Locale - */ - public function setDefaultLocale($locale) - { - $this->_defaultLocale = $locale; - return $this; - } - - /** - * REtrieve default locale code - * - * @return string - */ - public function getDefaultLocale() - { - if (!$this->_defaultLocale) { - $locale = Mage::getStoreConfig(self::XML_PATH_DEFAULT_LOCALE); - if (!$locale) { - $locale = self::DEFAULT_LOCALE; - } - $this->_defaultLocale = $locale; - } - return $this->_defaultLocale; - } - - /** - * Set locale - * - * @param string $locale - * @return Mage_Core_Model_Locale - */ - public function setLocale($locale = null) - { - if (($locale !== null) && is_string($locale)) { - $this->_localeCode = $locale; - } else { - $this->_localeCode = $this->getDefaultLocale(); - } - Mage::dispatchEvent('core_locale_set_locale', array('locale'=>$this)); - return $this; - } - - /** - * Retrieve timezone code - * - * @return string - */ - public function getTimezone() - { - return self::DEFAULT_TIMEZONE; - } - - /** - * Retrieve currency code - * - * @return string - */ - public function getCurrency() - { - return self::DEFAULT_CURRENCY; - } - - /** - * Retrieve locale object - * - * @return Zend_Locale - */ - public function getLocale() - { - if (!$this->_locale) { - Zend_Locale_Data::setCache(Mage::app()->getCache()); - $this->_locale = new Zend_Locale($this->getLocaleCode()); - } elseif ($this->_locale->__toString() != $this->_localeCode) { - $this->setLocale($this->_localeCode); - } - - return $this->_locale; - } - - /** - * Retrieve locale code - * - * @return string - */ - public function getLocaleCode() - { - if ($this->_localeCode === null) { - $this->setLocale(); - } - return $this->_localeCode; - } - - /** - * Specify current locale code - * - * @param string $code - * @return Mage_Core_Model_Locale - */ - public function setLocaleCode($code) - { - $this->_localeCode = $code; - $this->_locale = null; - return $this; - } - - /** - * Get options array for locale dropdown in currunt locale - * - * @return array - */ - public function getOptionLocales() - { - return $this->_getOptionLocales(); - } - - /** - * Get translated to original locale options array for locale dropdown - * - * @return array - */ - public function getTranslatedOptionLocales() - { - return $this->_getOptionLocales(true); - } - - /** - * Get options array for locale dropdown - * - * @param bool $translatedName translation flag - * @return array - */ - protected function _getOptionLocales($translatedName=false) - { - $options = array(); - $locales = $this->getLocale()->getLocaleList(); - $languages = $this->getLocale()->getTranslationList('language', $this->getLocale()); - $countries = $this->getCountryTranslationList(); - - $allowed = $this->getAllowLocales(); - foreach ($locales as $code=>$active) { - if (strstr($code, '_')) { - if (!in_array($code, $allowed)) { - continue; - } - $data = explode('_', $code); - if (!isset($languages[$data[0]]) || !isset($countries[$data[1]])) { - continue; - } - if ($translatedName) { - $label = ucwords($this->getLocale()->getTranslation($data[0], 'language', $code)) - . ' (' . $this->getLocale()->getTranslation($data[1], 'country', $code) . ') / ' - . $languages[$data[0]] . ' (' . $countries[$data[1]] . ')'; - } else { - $label = $languages[$data[0]] . ' (' . $countries[$data[1]] . ')'; - } - $options[] = array( - 'value' => $code, - 'label' => $label - ); - } - } - return $this->_sortOptionArray($options); - } - - /** - * Retrieve timezone option list - * - * @return array - */ - public function getOptionTimezones() - { - $options= array(); - $zones = $this->getTranslationList('windowstotimezone'); - ksort($zones); - foreach ($zones as $code=>$name) { - $name = trim($name); - $options[] = array( - 'label' => empty($name) ? $code : $name . ' (' . $code . ')', - 'value' => $code, - ); - } - return $this->_sortOptionArray($options); - } - - /** - * Retrieve days of week option list - * - * @return array - */ - public function getOptionWeekdays() - { - $options= array(); - $days = $this->getTranslationList('days'); - foreach (array_values($days['format']['wide']) as $code => $name) { - $options[] = array( - 'label' => $name, - 'value' => $code, - ); - } - return $options; - } - - /** - * Retrieve country option list - * - * @return array - */ - public function getOptionCountries() - { - $options = array(); - $countries = $this->getCountryTranslationList(); - - foreach ($countries as $code=>$name) { - $options[] = array( - 'label' => $name, - 'value' => $code, - ); - } - return $this->_sortOptionArray($options); - } - - /** - * Retrieve currency option list - * - * @return unknown - */ - public function getOptionCurrencies() - { - $currencies = $this->getTranslationList('currencytoname'); - $options = array(); - $allowed = $this->getAllowCurrencies(); - - foreach ($currencies as $name=>$code) { - if (!in_array($code, $allowed)) { - continue; - } - - $options[] = array( - 'label' => $name, - 'value' => $code, - ); - } - return $this->_sortOptionArray($options); - } - - /** - * Retrieve all currency option list - * - * @return unknown - */ - public function getOptionAllCurrencies() - { - $currencies = $this->getTranslationList('currencytoname'); - $options = array(); - foreach ($currencies as $name=>$code) { - $options[] = array( - 'label' => $name, - 'value' => $code, - ); - } - return $this->_sortOptionArray($options); - } - - protected function _sortOptionArray($option) - { - $data = array(); - foreach ($option as $item) { - $data[$item['value']] = $item['label']; - } - asort($data); - $option = array(); - foreach ($data as $key => $label) { - $option[] = array( - 'value' => $key, - 'label' => $label - ); - } - return $option; - } - - /** - * Retrieve array of allowed locales - * - * @return array - */ - public function getAllowLocales() - { - return Mage::getSingleton('Mage_Core_Model_Locale_Config')->getAllowedLocales(); - } - - /** - * Retrieve array of allowed currencies - * - * @return unknown - */ - public function getAllowCurrencies() - { - $data = array(); - if (Mage::isInstalled()) { - $data = Mage::app()->getStore()->getConfig(self::XML_PATH_ALLOW_CURRENCIES_INSTALLED); - return explode(',', $data); - } else { - $data = Mage::getSingleton('Mage_Core_Model_Locale_Config')->getAllowedCurrencies(); - } - return $data; - } - - /** - * Retrieve ISO date format - * - * @param string $type - * @return string - */ - public function getDateFormat($type=null) - { - return $this->getTranslation($type, 'date'); - } - - /** - * Retrieve short date format with 4-digit year - * - * @return string - */ - public function getDateFormatWithLongYear() - { - return preg_replace('/(?getTranslation(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, 'date')); - } - - - /** - * Retrieve ISO time format - * - * @param string $type - * @return string - */ - public function getTimeFormat($type=null) - { - return $this->getTranslation($type, 'time'); - } - - /** - * Retrieve ISO datetime format - * - * @param string $type - * @return string - */ - public function getDateTimeFormat($type) - { - return $this->getDateFormat($type) . ' ' . $this->getTimeFormat($type); - } - - /** - * Create Zend_Date object for current locale - * - * @param mixed $date - * @param string $part - * @param string|Zend_Locale $locale - * @param bool $useTimezone - * @return Zend_Date - */ - public function date($date = null, $part = null, $locale = null, $useTimezone = true) - { - if (is_null($locale)) { - $locale = $this->getLocale(); - } - - if (empty($date)) { - // $date may be false, but Zend_Date uses strict compare - $date = null; - } - $date = new Zend_Date($date, $part, $locale); - if ($useTimezone) { - if ($timezone = Mage::app()->getStore()->getConfig(self::XML_PATH_DEFAULT_TIMEZONE)) { - $date->setTimezone($timezone); - } - } - - return $date; - } - - /** - * Create Zend_Date object with date converted to store timezone and store Locale - * - * @param mixed $store Information about store - * @param string|integer|Zend_Date|array|null $date date in UTC - * @param boolean $includeTime flag for including time to date - * @return Zend_Date - */ - public function storeDate($store=null, $date=null, $includeTime=false) - { - $timezone = Mage::app()->getStore($store)->getConfig(self::XML_PATH_DEFAULT_TIMEZONE); - $date = new Zend_Date($date, null, $this->getLocale()); - $date->setTimezone($timezone); - if (!$includeTime) { - $date->setHour(0) - ->setMinute(0) - ->setSecond(0); - } - return $date; - } - - /** - * Create Zend_Date object with date converted from store's timezone - * to UTC time zone. Date can be passed in format of store's locale - * or in format which was passed as parameter. - * - * @param mixed $store Information about store - * @param string|integer|Zend_Date|array|null $date date in store's timezone - * @param boolean $includeTime flag for including time to date - * @param null|string $format - * @return Zend_Date - */ - public function utcDate($store, $date, $includeTime = false, $format = null) - { - $dateObj = $this->storeDate($store, $date, $includeTime); - $dateObj->set($date, $format); - $dateObj->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE); - return $dateObj; - } - - /** - * Get store timestamp - * Timstamp will be builded with store timezone settings - * - * @param mixed $store - * @return int - */ - public function storeTimeStamp($store=null) - { - $timezone = Mage::app()->getStore($store)->getConfig(self::XML_PATH_DEFAULT_TIMEZONE); - $currentTimezone = @date_default_timezone_get(); - @date_default_timezone_set($timezone); - $date = date('Y-m-d H:i:s'); - @date_default_timezone_set($currentTimezone); - return strtotime($date); - } - - /** - * Create Zend_Currency object for current locale - * - * @param string $currency - * @return Zend_Currency - */ - public function currency($currency) - { - Magento_Profiler::start('locale/currency'); - if (!isset(self::$_currencyCache[$this->getLocaleCode()][$currency])) { - $options = array(); - try { - $currencyObject = new Zend_Currency($currency, $this->getLocale()); - } catch (Exception $e) { - $currencyObject = new Zend_Currency($this->getCurrency(), $this->getLocale()); - $options['name'] = $currency; - $options['currency'] = $currency; - $options['symbol'] = $currency; - } - - $options = new Varien_Object($options); - Mage::dispatchEvent('currency_display_options_forming', array( - 'currency_options' => $options, - 'base_code' => $currency - )); - - $currencyObject->setFormat($options->toArray()); - self::$_currencyCache[$this->getLocaleCode()][$currency] = $currencyObject; - } - Magento_Profiler::stop('locale/currency'); - return self::$_currencyCache[$this->getLocaleCode()][$currency]; - } - - /** - * Returns the first found number from an string - * Parsing depends on given locale (grouping and decimal) - * - * Examples for input: - * ' 2345.4356,1234' = 23455456.1234 - * '+23,3452.123' = 233452.123 - * ' 12343 ' = 12343 - * '-9456km' = -9456 - * '0' = 0 - * '2 054,10' = 2054.1 - * '2'054.52' = 2054.52 - * '2,46 GB' = 2.46 - * - * @param string|float|int $value - * @return float|null - */ - public function getNumber($value) - { - if (is_null($value)) { - return null; - } - - if (!is_string($value)) { - return floatval($value); - } - - //trim spaces and apostrophes - $value = str_replace(array('\'', ' '), '', $value); - - $separatorComa = strpos($value, ','); - $separatorDot = strpos($value, '.'); - - if ($separatorComa !== false && $separatorDot !== false) { - if ($separatorComa > $separatorDot) { - $value = str_replace('.', '', $value); - $value = str_replace(',', '.', $value); - } - else { - $value = str_replace(',', '', $value); - } - } - elseif ($separatorComa !== false) { - $value = str_replace(',', '.', $value); - } - - return floatval($value); - } - - /** - * Functions returns array with price formatting info for js function - * formatCurrency in js/varien/js.js - * - * @return array - */ - public function getJsPriceFormat() - { - $format = Zend_Locale_Data::getContent($this->getLocaleCode(), 'currencynumber'); - $symbols = Zend_Locale_Data::getList($this->getLocaleCode(), 'symbols'); - - $pos = strpos($format, ';'); - if ($pos !== false){ - $format = substr($format, 0, $pos); - } - $format = preg_replace("/[^0\#\.,]/", "", $format); - $totalPrecision = 0; - $decimalPoint = strpos($format, '.'); - if ($decimalPoint !== false) { - $totalPrecision = (strlen($format) - (strrpos($format, '.')+1)); - } else { - $decimalPoint = strlen($format); - } - $requiredPrecision = $totalPrecision; - $t = substr($format, $decimalPoint); - $pos = strpos($t, '#'); - if ($pos !== false){ - $requiredPrecision = strlen($t) - $pos - $totalPrecision; - } - $group = 0; - if (strrpos($format, ',') !== false) { - $group = ($decimalPoint - strrpos($format, ',') - 1); - } else { - $group = strrpos($format, '.'); - } - $integerRequired = (strpos($format, '.') - strpos($format, '0')); - - $result = array( - 'pattern' => Mage::app()->getStore()->getCurrentCurrency()->getOutputFormat(), - 'precision' => $totalPrecision, - 'requiredPrecision' => $requiredPrecision, - 'decimalSymbol' => $symbols['decimal'], - 'groupSymbol' => $symbols['group'], - 'groupLength' => $group, - 'integerRequired' => $integerRequired - ); - - return $result; - } - - /** - * Push current locale to stack and replace with locale from specified store - * Event is not dispatched. - * - * @param int $storeId - */ - public function emulate($storeId) - { - if ($storeId) { - $this->_emulatedLocales[] = clone $this->getLocale(); - $this->_locale = new Zend_Locale(Mage::getStoreConfig(self::XML_PATH_DEFAULT_LOCALE, $storeId)); - $this->_localeCode = $this->_locale->toString(); - Mage::getSingleton('Mage_Core_Model_Translate')->setLocale($this->_localeCode)->init('frontend', true); - } - else { - $this->_emulatedLocales[] = false; - } - } - - /** - * Get last locale, used before last emulation - * - */ - public function revert() - { - $locale = array_pop($this->_emulatedLocales); - if ($locale) { - $this->_locale = $locale; - $this->_localeCode = $this->_locale->toString(); - Mage::getSingleton('Mage_Core_Model_Translate')->setLocale($this->_localeCode)->init('adminhtml', true); - } - } - - /** - * Returns localized informations as array, supported are several - * types of informations. - * For detailed information about the types look into the documentation - * - * @param string $path (Optional) Type of information to return - * @param string $value (Optional) Value for detail list - * @return array Array with the wished information in the given language - */ - public function getTranslationList($path = null, $value = null) - { - return $this->getLocale()->getTranslationList($path, $this->getLocale(), $value); - } - - /** - * Returns a localized information string, supported are several types of informations. - * For detailed information about the types look into the documentation - * - * @param string $value Name to get detailed information about - * @param string $path (Optional) Type of information to return - * @return string|false The wished information in the given language - */ - public function getTranslation($value = null, $path = null) - { - return $this->getLocale()->getTranslation($value, $path, $this->getLocale()); - } - -/** - * Returns the localized country name - * - * @param string $value Name to get detailed information about - * @return array - */ - public function getCountryTranslation($value) - { - return $this->getLocale()->getTranslation($value, 'country', $this->getLocale()); - } - - /** - * Returns an array with the name of all countries translated to the given language - * - * @return array - */ - public function getCountryTranslationList() - { - return $this->getLocale()->getTranslationList('territory', $this->getLocale(), 2); - } - - /** - * Checks if current date of the given store (in the store timezone) is within the range - * - * @param int|string|Mage_Core_Model_Store $store - * @param string|null $dateFrom - * @param string|null $dateTo - * @return bool - */ - public function isStoreDateInInterval($store, $dateFrom = null, $dateTo = null) - { - if (!$store instanceof Mage_Core_Model_Store) { - $store = Mage::app()->getStore($store); - } - - $storeTimeStamp = $this->storeTimeStamp($store); - $fromTimeStamp = strtotime($dateFrom); - $toTimeStamp = strtotime($dateTo); - if ($dateTo) { - // fix date YYYY-MM-DD 00:00:00 to YYYY-MM-DD 23:59:59 - $toTimeStamp += 86400; - } - - $result = false; - if (!is_empty_date($dateFrom) && $storeTimeStamp < $fromTimeStamp) { - } - elseif (!is_empty_date($dateTo) && $storeTimeStamp > $toTimeStamp) { - } - else { - $result = true; - } - - return $result; - } -} diff --git a/app/code/core/Mage/Core/Model/ObjectManager.php b/app/code/core/Mage/Core/Model/ObjectManager.php deleted file mode 100644 index c600b5d110d84..0000000000000 --- a/app/code/core/Mage/Core/Model/ObjectManager.php +++ /dev/null @@ -1,50 +0,0 @@ -configure($this); - Magento_Profiler::stop('configuration'); - Magento_Profiler::stop('di'); - } -} diff --git a/app/code/core/Mage/Core/Model/ObjectManager/Config.php b/app/code/core/Mage/Core/Model/ObjectManager/Config.php deleted file mode 100644 index 344b6d457049f..0000000000000 --- a/app/code/core/Mage/Core/Model/ObjectManager/Config.php +++ /dev/null @@ -1,152 +0,0 @@ - array( - 'Mage_Core_Model_Db_UpdaterInterface' => 'Mage_Core_Model_Db_Updater', - 'Mage_Core_Model_AppInterface' => 'Mage_Core_Model_App_Proxy', - 'Mage_Core_Model_Config_InvalidatorInterface' => 'Mage_Core_Model_Config_Invalidator_Proxy', - ), - 'Mage_Core_Model_Cache' => array( - 'parameters' => array('config' => 'Mage_Core_Model_Config_Proxy') - ), - 'Mage_Core_Model_Config' => array( - 'parameters' => array('storage' => 'Mage_Core_Model_Config_Storage') - ), - 'Mage_Core_Model_Config_Container' => array( - 'parameters' => array('configCache' => 'Mage_Core_Model_Config_Cache_Proxy') - ), - 'Mage_Core_Model_Config_Resource' => array( - 'parameters' => array('config' => 'Mage_Core_Model_Config_Primary') - ), - 'Mage_Core_Model_Config_Locales' => array( - 'parameters' => array('storage' => 'Mage_Core_Model_Config_Storage_Locales') - ), - 'Mage_Core_Model_Config_Modules' => array( - 'parameters' => array('storage' => 'Mage_Core_Model_Config_Storage_Modules') - ), - 'Mage_Core_Model_Config_Storage' => array( - 'parameters' => array('loader' => 'Mage_Core_Model_Config_Loader_Proxy') - ), - 'Mage_Core_Model_Config_Storage_Modules' => array( - 'parameters' => array('loader' => 'Mage_Core_Model_Config_Loader_Modules_Proxy') - ), - 'Mage_Core_Model_Config_Storage_Locales' => array( - 'parameters' => array('loader' => 'Mage_Core_Model_Config_Loader_Locales_Proxy') - ), - 'Mage_Core_Model_Event_Config' => array( - 'parameters' => array('config' => 'Mage_Core_Model_Config_Modules_Proxy') - ), - 'Mage_Install_Model_Installer' => array( - 'parameters' => array('config' => 'Mage_Core_Model_Config_Proxy') - ), - 'Mage_Core_Model_Config_Invalidator' => array( - 'parameters' => array( - 'primaryConfig' => 'Mage_Core_Model_Config_Primary', - 'modulesConfig' => 'Mage_Core_Model_Config_Modules', - 'localesConfig' => 'Mage_Core_Model_Config_Locales', - ) - ), - 'Magento_Filesystem' => array( - 'parameters' => array( - 'adapter' => 'Magento_Filesystem_Adapter_Local' - ), - 'shared' => 0 - ) - ); - - /** - * Configure object manager - * - * @param Magento_ObjectManager $objectManager - */ - public function configure(Magento_ObjectManager $objectManager) - { - Magento_Profiler::start('initial'); - $objectManager->setConfiguration(array_replace_recursive( - $this->_initialConfig, - array( - 'Mage_Core_Model_Dir' => array( - 'parameters' => array( - 'baseDir' => $this->_getParam(Mage::PARAM_BASEDIR), - 'uris' => $this->_getParam(MAGE::PARAM_APP_URIS, array()), - 'dirs' => $this->_getParam(Mage::PARAM_APP_DIRS, array()) - ) - ), - 'Mage_Core_Model_Config_Loader_Local' => array( - 'parameters' => array( - 'customFile' => $this->_getParam(Mage::PARAM_CUSTOM_LOCAL_FILE), - 'customConfig' => $this->_getParam(Mage::PARAM_CUSTOM_LOCAL_CONFIG) - ) - ), - 'Mage_Core_Model_Config_Loader_Modules' => array( - 'parameters' => array('allowedModules' => $this->_getParam(Mage::PARAM_ALLOWED_MODULES, array())) - ), - 'Mage_Core_Model_Cache' => array( - 'parameters' => array( - 'options' => $this->_getParam(Mage::PARAM_CACHE_OPTIONS, array()), - 'banCache' => $this->_getParam(Mage::PARAM_BAN_CACHE, false), - ) - ), - 'Mage_Core_Model_StoreManager' => array( - 'parameters' => array( - 'scopeCode' => $this->_getParam(Mage::PARAM_RUN_CODE, ''), - 'scopeType' => $this->_getParam(Mage::PARAM_RUN_TYPE, 'store'), - ) - ) - ) - )); - - Magento_Profiler::start('primary_load'); - /** @var $config Mage_Core_Model_Config_Primary*/ - $config = $objectManager->get('Mage_Core_Model_Config_Primary'); - Magento_Profiler::stop('primary_load'); - $configurators = $config->getNode('global/configurators'); - if ($configurators) { - $configurators = $configurators->asArray(); - if (count($configurators)) { - foreach ($configurators as $configuratorClass) { - /** @var $configurator Magento_ObjectManager_Configuration*/ - $configurator = $objectManager->create($configuratorClass, array('params' => $this->_params)); - $configurator->configure($objectManager); - } - } - } - Magento_Profiler::stop('initial'); - Magento_Profiler::start('global_primary'); - $diConfig = $config->getNode('global/di'); - if ($diConfig) { - $objectManager->setConfiguration($diConfig->asArray()); - } - Magento_Profiler::stop('global_primary'); - } -} diff --git a/app/code/core/Mage/Core/Model/Observer.php b/app/code/core/Mage/Core/Model/Observer.php deleted file mode 100644 index 958cb8a778e80..0000000000000 --- a/app/code/core/Mage/Core/Model/Observer.php +++ /dev/null @@ -1,126 +0,0 @@ - - */ -class Mage_Core_Model_Observer -{ - /** - * Check if synchronize process is finished and generate notification message - * - * @param Varien_Event_Observer $observer - * @return Mage_Core_Model_Observer - */ - public function addSynchronizeNotification(Varien_Event_Observer $observer) - { - $adminSession = Mage::getSingleton('Mage_Backend_Model_Auth_Session'); - if (!$adminSession->hasSyncProcessStopWatch()) { - $flag = Mage::getSingleton('Mage_Core_Model_File_Storage')->getSyncFlag(); - $state = $flag->getState(); - if ($state == Mage_Core_Model_File_Storage_Flag::STATE_RUNNING) { - $syncProcessStopWatch = true; - } else { - $syncProcessStopWatch = false; - } - - $adminSession->setSyncProcessStopWatch($syncProcessStopWatch); - } - $adminSession->setSyncProcessStopWatch(false); - - if (!$adminSession->getSyncProcessStopWatch()) { - if (!isset($flag)) { - $flag = Mage::getSingleton('Mage_Core_Model_File_Storage')->getSyncFlag(); - } - - $state = $flag->getState(); - if ($state == Mage_Core_Model_File_Storage_Flag::STATE_FINISHED) { - $flagData = $flag->getFlagData(); - if (isset($flagData['has_errors']) && $flagData['has_errors']) { - $severity = Mage_AdminNotification_Model_Inbox::SEVERITY_MAJOR; - $title = Mage::helper('Mage_Adminhtml_Helper_Data')->__('An error has occured while syncronizing media storages.'); - $description = Mage::helper('Mage_Adminhtml_Helper_Data')->__('One or more media files failed to be synchronized during the media storages syncronization process. Refer to the log file for details.'); - } else { - $severity = Mage_AdminNotification_Model_Inbox::SEVERITY_NOTICE; - $title = Mage::helper('Mage_Adminhtml_Helper_Data')->__('Media storages synchronization has completed!'); - $description = Mage::helper('Mage_Adminhtml_Helper_Data')->__('Synchronization of media storages has been successfully completed.'); - } - - $date = date('Y-m-d H:i:s'); - Mage::getModel('Mage_AdminNotification_Model_Inbox')->parse(array( - array( - 'severity' => $severity, - 'date_added' => $date, - 'title' => $title, - 'description' => $description, - 'url' => '', - 'internal' => true - ) - )); - - $flag->setState(Mage_Core_Model_File_Storage_Flag::STATE_NOTIFIED)->save(); - } - - $adminSession->setSyncProcessStopWatch(false); - } - - return $this; - } - - /** - * Cron job method to clean old cache resources - * - * @param Mage_Cron_Model_Schedule $schedule - */ - public function cleanCache(Mage_Cron_Model_Schedule $schedule) - { - Mage::app()->getCache()->clean(Zend_Cache::CLEANING_MODE_OLD); - Mage::dispatchEvent('core_clean_cache'); - } - - /** - * Theme registration - * - * @param Varien_Event_Observer $observer - * @return Mage_Core_Model_Observer - */ - public function themeRegistration(Varien_Event_Observer $observer) - { - $baseDir = $observer->getEvent()->getBaseDir(); - $pathPattern = $observer->getEvent()->getPathPattern(); - try { - Mage::getObjectManager()->get('Mage_Core_Model_Theme_Registration')->register($baseDir, $pathPattern); - } catch (Mage_Core_Exception $e) { - Mage::logException($e); - } - return $this; - } -} diff --git a/app/code/core/Mage/Core/Model/Resource.php b/app/code/core/Mage/Core/Model/Resource.php deleted file mode 100644 index ba4e273803fcc..0000000000000 --- a/app/code/core/Mage/Core/Model/Resource.php +++ /dev/null @@ -1,388 +0,0 @@ -_resourceConfig = $resourceConfig; - $this->_cache = $cache; - } - - /** - * Set resource configuration - * - * @param Mage_Core_Model_Config_Resource $resourceConfig - */ - public function setResourceConfig(Mage_Core_Model_Config_Resource $resourceConfig) - { - $this->_resourceConfig = $resourceConfig; - } - - /** - * Set cache instance - * - * @param Mage_Core_Model_CacheInterface $cache - */ - public function setCache(Mage_Core_Model_CacheInterface $cache) - { - $this->_cache = $cache; - } - - /** - * Creates a connection to resource whenever needed - * - * @param string $name - * @return Varien_Db_Adapter_Interface - */ - public function getConnection($name) - { - if (isset($this->_connections[$name])) { - $connection = $this->_connections[$name]; - if (isset($this->_skippedConnections[$name])) { - $connection->setCacheAdapter(Mage::app()->getCache()); - unset($this->_skippedConnections[$name]); - } - return $connection; - } - $connConfig = $this->_resourceConfig->getResourceConnectionConfig($name); - - if (!$connConfig) { - $this->_connections[$name] = $this->_getDefaultConnection($name); - return $this->_connections[$name]; - } - if (!$connConfig->is('active', 1)) { - return false; - } - - $origName = $connConfig->getParent()->getName(); - if (isset($this->_connections[$origName])) { - $this->_connections[$name] = $this->_connections[$origName]; - return $this->_connections[$origName]; - } - - $connection = $this->_newConnection((string)$connConfig->type, $connConfig); - if ($connection) { - $connection->setCacheAdapter($this->_cache->getFrontend()); - } - - $this->_connections[$name] = $connection; - if ($origName !== $name) { - $this->_connections[$origName] = $connection; - } - - return $connection; - } - - /** - * Retrieve connection adapter class name by connection type - * - * @param string $type the connection type - * @return string|false - */ - protected function _getConnectionAdapterClassName($type) - { - $config = $this->_resourceConfig->getResourceTypeConfig($type); - if (!empty($config->adapter)) { - return (string)$config->adapter; - } - return false; - } - - /** - * Create new connection adapter instance by connection type and config - * - * @param string $type the connection type - * @param Mage_Core_Model_Config_Element|array $config the connection configuration - * @return Varien_Db_Adapter_Interface|false - */ - protected function _newConnection($type, $config) - { - if ($config instanceof Mage_Core_Model_Config_Element) { - $config = $config->asArray(); - } - if (!is_array($config)) { - return false; - } - - $connection = false; - // try to get adapter and create connection - $className = $this->_getConnectionAdapterClassName($type); - if ($className) { - $connection = new $className($config); - if ($connection instanceof Varien_Db_Adapter_Interface) { - /** @var Zend_Db_Adapter_Abstract $connection */ - - // Set additional params for Magento profiling tool - $profiler = $connection->getProfiler(); - if ($profiler instanceof Varien_Db_Profiler) { - /** @var Varien_Db_Profiler $profiler */ - $profiler->setType($type); - - $host = !empty($config['host']) ? $config['host'] : ''; - $profiler->setHost($host); - } - - // run after initialization statements - if (!empty($config['initStatements'])) { - $connection->query($config['initStatements']); - } - } else { - $connection = false; - } - } - - // try to get connection from type - if (!$connection) { - $typeInstance = $this->getConnectionTypeInstance($type); - /** @var Mage_Core_Model_Resource_Type_Abstract $typeInstance */ - $connection = $typeInstance->getConnection($config); - if (!$connection instanceof Varien_Db_Adapter_Interface) { - $connection = false; - } - } - - return $connection; - } - - /** - * Retrieve default connection name by required connection name - * - * @param string $requiredConnectionName - * @return string - */ - protected function _getDefaultConnection($requiredConnectionName) - { - if (strpos($requiredConnectionName, 'read') !== false) { - return $this->getConnection(self::DEFAULT_READ_RESOURCE); - } - return $this->getConnection(self::DEFAULT_WRITE_RESOURCE); - } - - /** - * Get connection type instance - * - * Creates new if doesn't exist - * - * @param string $type - * @return Mage_Core_Model_Resource_Type_Abstract - */ - public function getConnectionTypeInstance($type) - { - if (!isset($this->_connectionTypes[$type])) { - $config = $this->_resourceConfig->getResourceTypeConfig($type); - $typeClass = $config->getClassName(); - $this->_connectionTypes[$type] = new $typeClass(); - } - return $this->_connectionTypes[$type]; - } - - /** - * Get resource table name, validated by db adapter - * - * @param string|array $modelEntity - * @return string - */ - public function getTableName($modelEntity) - { - $tableSuffix = null; - if (is_array($modelEntity)) { - list($modelEntity, $tableSuffix) = $modelEntity; - } - - $tableName = $modelEntity; - - $mappedTableName = $this->getMappedTableName($tableName); - if ($mappedTableName) { - $tableName = $mappedTableName; - } else { - $tablePrefix = (string)$this->_resourceConfig->getTablePrefix(); - if ($tablePrefix && strpos($tableName, $tablePrefix) !== 0) { - $tableName = $tablePrefix . $tableName; - } - } - - if ($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])) { - return $this->_mappedTableNames[$tableName]; - } else { - return false; - } - } - - /** - * Create new connection with custom config - * - * @param string $name - * @param string $type - * @param array $config - * @return unknown - */ - public function createConnection($name, $type, $config) - { - if (!isset($this->_connections[$name])) { - $connection = $this->_newConnection($type, $config); - - $this->_connections[$name] = $connection; - } - return $this->_connections[$name]; - } - - public function checkDbConnection() - { - if (!$this->getConnection('core_read')) { - //Mage::app()->getResponse()->setRedirect(Mage::getUrl('install')); - } - } - - public function getAutoUpdate() - { - return self::AUTO_UPDATE_ALWAYS; - #return Mage::app()->loadCache(self::AUTO_UPDATE_CACHE_KEY); - } - - public function setAutoUpdate($value) - { - #Mage::app()->saveCache($value, self::AUTO_UPDATE_CACHE_KEY); - return $this; - } - /** - * Retrieve 32bit UNIQUE HASH for a Table index - * - * @param string $tableName - * @param array|string $fields - * @param string $indexType - * @return string - */ - public function getIdxName($tableName, $fields, $indexType = Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX) - { - return $this->getConnection(self::DEFAULT_READ_RESOURCE) - ->getIndexName($this->getTableName($tableName), $fields, $indexType); - } - - /** - * Retrieve 32bit UNIQUE HASH for a Table foreign key - * - * @param string $priTableName the target table name - * @param string $priColumnName the target table column name - * @param string $refTableName the reference table name - * @param string $refColumnName the reference table column name - * @return string - */ - public function getFkName($priTableName, $priColumnName, $refTableName, $refColumnName) - { - return $this->getConnection(self::DEFAULT_READ_RESOURCE) - ->getForeignKeyName($this->getTableName($priTableName), $priColumnName, - $this->getTableName($refTableName), $refColumnName); - } -} diff --git a/app/code/core/Mage/Core/Model/Resource/Abstract.php b/app/code/core/Mage/Core/Model/Resource/Abstract.php deleted file mode 100644 index 8a1794a5597bb..0000000000000 --- a/app/code/core/Mage/Core/Model/Resource/Abstract.php +++ /dev/null @@ -1,254 +0,0 @@ - - */ -abstract class Mage_Core_Model_Resource_Abstract -{ - /** - * @var Varien_Db_Adapter_Interface - */ - protected $_writeAdapter; - /** - * Main constructor - */ - public function __construct() - { - /** - * Please override this one instead of overriding real __construct constructor - */ - $this->_construct(); - } - - /** - * Array of callbacks subscribed to commit transaction commit - * - * @var array - */ - static protected $_commitCallbacks = array(); - - /** - * Resource initialization - */ - abstract protected function _construct(); - - /** - * Retrieve connection for read data - */ - abstract protected function _getReadAdapter(); - - /** - * Retrieve connection for write data - */ - abstract protected function _getWriteAdapter(); - - /** - * Start resource transaction - * - * @return Mage_Core_Model_Resource_Abstract - */ - public function beginTransaction() - { - $this->_getWriteAdapter()->beginTransaction(); - return $this; - } - - /** - * Subscribe some callback to transaction commit - * - * @param callback $callback - * @return Mage_Core_Model_Resource_Abstract - */ - public function addCommitCallback($callback) - { - $adapterKey = spl_object_hash($this->_getWriteAdapter()); - self::$_commitCallbacks[$adapterKey][] = $callback; - return $this; - } - - /** - * Commit resource transaction - * - * @return Mage_Core_Model_Resource_Abstract - */ - public function commit() - { - $this->_getWriteAdapter()->commit(); - /** - * Process after commit callbacks - */ - if ($this->_getWriteAdapter()->getTransactionLevel() === 0) { - $adapterKey = spl_object_hash($this->_getWriteAdapter()); - if (isset(self::$_commitCallbacks[$adapterKey])) { - $callbacks = self::$_commitCallbacks[$adapterKey]; - self::$_commitCallbacks[$adapterKey] = array(); - foreach ($callbacks as $index => $callback) { - call_user_func($callback); - } - } - } - return $this; - } - - /** - * Roll back resource transaction - * - * @return Mage_Core_Model_Resource_Abstract - */ - public function rollBack() - { - $this->_getWriteAdapter()->rollBack(); - return $this; - } - - /** - * Format date to internal format - * - * @param string|Zend_Date $date - * @param bool $includeTime - * @return string - */ - public function formatDate($date, $includeTime=true) - { - return Varien_Date::formatDate($date, $includeTime); - } - - /** - * Convert internal date to UNIX timestamp - * - * @param string $str - * @return int - */ - public function mktime($str) - { - return Varien_Date::toTimestamp($str); - } - - /** - * Serialize specified field in an object - * - * @param Varien_Object $object - * @param string $field - * @param mixed $defaultValue - * @param bool $unsetEmpty - * @return Mage_Core_Model_Resource_Abstract - */ - protected function _serializeField(Varien_Object $object, $field, $defaultValue = null, $unsetEmpty = false) - { - $value = $object->getData($field); - if (empty($value)) { - if ($unsetEmpty) { - $object->unsetData($field); - } else { - if (is_object($defaultValue) || is_array($defaultValue)) { - $defaultValue = serialize($defaultValue); - } - $object->setData($field, $defaultValue); - } - } elseif (is_array($value) || is_object($value)) { - $object->setData($field, serialize($value)); - } - - return $this; - } - - /** - * Unserialize Varien_Object field in an object - * - * @param Mage_Core_Model_Abstract $object - * @param string $field - * @param mixed $defaultValue - */ - protected function _unserializeField(Varien_Object $object, $field, $defaultValue = null) - { - $value = $object->getData($field); - if (empty($value)) { - $object->setData($field, $defaultValue); - } elseif (!is_array($value) && !is_object($value)) { - $object->setData($field, unserialize($value)); - } - } - - /** - * Prepare data for passed table - * - * @param Varien_Object $object - * @param string $table - * @return array - */ - protected function _prepareDataForTable(Varien_Object $object, $table) - { - $data = array(); - $fields = $this->_getWriteAdapter()->describeTable($table); - foreach (array_keys($fields) as $field) { - if ($object->hasData($field)) { - $fieldValue = $object->getData($field); - if ($fieldValue instanceof Zend_Db_Expr) { - $data[$field] = $fieldValue; - } else { - if (null !== $fieldValue) { - $fieldValue = $this->_prepareTableValueForSave($fieldValue, $fields[$field]['DATA_TYPE']); - $data[$field] = $this->_getWriteAdapter()->prepareColumnValue($fields[$field], $fieldValue); - } else if (!empty($fields[$field]['NULLABLE'])) { - $data[$field] = null; - } - } - } - } - return $data; - } - - /** - * Prepare value for save - * - * @param mixed $value - * @param string $type - * @return mixed - */ - protected function _prepareTableValueForSave($value, $type) - { - $type = strtolower($type); - if ($type == 'decimal' || $type == 'numeric' || $type == 'float') { - $value = Mage::app()->getLocale()->getNumber($value); - } - return $value; - } - - /** - * Template method to return validate rules to be executed before entity is saved - * - * @return Zend_Validate_Interface|null - */ - public function getValidationRulesBeforeSave() - { - return null; - } -} diff --git a/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php b/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php deleted file mode 100644 index 67d28b81eecd0..0000000000000 --- a/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php +++ /dev/null @@ -1,705 +0,0 @@ - - */ -abstract class Mage_Core_Model_Resource_Db_Abstract extends Mage_Core_Model_Resource_Abstract -{ - /** - * Cached resources singleton - * - * @var Mage_Core_Model_Resource - */ - protected $_resources; - - /** - * Prefix for resources that will be used in this resource model - * - * @var string - */ - protected $_resourcePrefix = 'core'; - - /** - * Connections cache for this resource model - * - * @var array - */ - protected $_connections = array(); - - /** - * Resource model name that contains entities (names of tables) - * - * @var string - */ - protected $_resourceModel; - - /** - * Tables used in this resource model - * - * @var array - */ - protected $_tables = array(); - - /** - * Main table name - * - * @var string - */ - protected $_mainTable; - - /** - * Main table primary key field name - * - * @var string - */ - protected $_idFieldName; - - /** - * Primery key auto increment flag - * - * @var bool - */ - protected $_isPkAutoIncrement = true; - - /** - * Use is object new method for save of object - * - * @var boolean - */ - protected $_useIsObjectNew = false; - - /** - * Fields of main table - * - * @var array - */ - protected $_mainTableFields; - - /** - * Main table unique keys field names - * could array( - * array('field' => 'db_field_name1', 'title' => 'Field 1 should be unique') - * array('field' => 'db_field_name2', 'title' => 'Field 2 should be unique') - * array( - * 'field' => array('db_field_name3', 'db_field_name3'), - * 'title' => 'Field 3 and Field 4 combination should be unique' - * ) - * ) - * or string 'my_field_name' - will be autoconverted to - * array( array( 'field' => 'my_field_name', 'title' => 'my_field_name' ) ) - * - * @var array - */ - protected $_uniqueFields = null; - - /** - * Serializable fields declaration - * Structure: array( - * => array( - * , - * , - * // optional parameter - * ), - * ) - * - * @var array - */ - protected $_serializableFields = array(); - - /** - * Class constructor - * - * @param array $arguments - * @throws InvalidArgumentException - */ - public function __construct(Mage_Core_Model_Resource $resource) - { - $this->_resources = $resource; - parent::__construct(); - } - - /** - * Standard resource model initialization - * - * @param string $mainTable - * @param string $idFieldName - * @return Mage_Core_Model_Resource_Abstract - */ - protected function _init($mainTable, $idFieldName) - { - $this->_setMainTable($mainTable, $idFieldName); - } - - /** - * Initialize connections and tables for this resource model - * If one or both arguments are string, will be used as prefix - * If $tables is null and $connections is string, $tables will be the same - * - * @param string|array $connections - * @param string|array|null $tables - * @return Mage_Core_Model_Resource_Abstract - */ - protected function _setResource($connections, $tables = null) - { - if (is_array($connections)) { - foreach ($connections as $k=>$v) { - $this->_connections[$k] = $this->_resources->getConnection($v); - } - } else if (is_string($connections)) { - $this->_resourcePrefix = $connections; - } - - if (is_null($tables) && is_string($connections)) { - $this->_resourceModel = $this->_resourcePrefix; - } else if (is_array($tables)) { - foreach ($tables as $k => $v) { - $this->_tables[$k] = $this->_resources->getTableName($v); - } - } else if (is_string($tables)) { - $this->_resourceModel = $tables; - } - return $this; - } - - /** - * Set main entity table name and primary key field name - * If field name is ommited {table_name}_id will be used - * - * @param string $mainTable - * @param string|null $idFieldName - * @return Mage_Core_Model_Resource_Db_Abstract - */ - protected function _setMainTable($mainTable, $idFieldName = null) - { - $this->_mainTable = $mainTable; - if (is_null($idFieldName)) { - $idFieldName = $mainTable . '_id'; - } - - $this->_idFieldName = $idFieldName; - return $this; - } - - /** - * Get primary key field name - * - * @return string - */ - public function getIdFieldName() - { - if (empty($this->_idFieldName)) { - Mage::throwException(Mage::helper('Mage_Core_Helper_Data')->__('Empty identifier field name')); - } - return $this->_idFieldName; - } - - /** - * Returns main table name - extracted from "module/table" style and - * validated by db adapter - * - * @return string - */ - public function getMainTable() - { - if (empty($this->_mainTable)) { - Mage::throwException(Mage::helper('Mage_Core_Helper_Data')->__('Empty main table name')); - } - return $this->getTable($this->_mainTable); - } - - /** - * Get real table name for db table, validated by db adapter - * - * @param string $tableName - * @return string - */ - public function getTable($tableName) - { - if (is_array($tableName)) { - $cacheName = join('@', $tableName); - list($tableName, $entitySuffix) = $tableName; - } else { - $cacheName = $tableName; - $entitySuffix = null; - } - - if (!is_null($entitySuffix)) { - $tableName .= '_' . $entitySuffix; - } - - if (!isset($this->_tables[$cacheName])) { - $this->_tables[$cacheName] = $this->_resources->getTableName($tableName); - } - return $this->_tables[$cacheName]; - } - - /** - * Get connection by name or type - * - * @param string $connectionName - * @return Varien_Db_Adapter_Interface|bool - */ - protected function _getConnection($connectionName) - { - if (isset($this->_connections[$connectionName])) { - return $this->_connections[$connectionName]; - } - $connectionNameFull = ($this->_resourcePrefix ? $this->_resourcePrefix . '_' : '') . $connectionName; - $connectionInstance = $this->_resources->getConnection($connectionNameFull); - // cache only active connections to detect inactive ones as soon as they become active - if ($connectionInstance) { - $this->_connections[$connectionName] = $connectionInstance; - } - return $connectionInstance; - } - - /** - * Retrieve connection for read data - * - * @return Varien_Db_Adapter_Interface - */ - protected function _getReadAdapter() - { - $writeAdapter = $this->_getWriteAdapter(); - if ($writeAdapter && $writeAdapter->getTransactionLevel() > 0) { - // if transaction is started we should use write connection for reading - return $writeAdapter; - } - return $this->_getConnection('read'); - } - - /** - * Retrieve connection for write data - * - * @return Varien_Db_Adapter_Interface - */ - protected function _getWriteAdapter() - { - return $this->_getConnection('write'); - } - - /** - * Temporary resolving collection compatibility - * - * @return Varien_Db_Adapter_Interface - */ - public function getReadConnection() - { - return $this->_getReadAdapter(); - } - - /** - * Load an object - * - * @param Mage_Core_Model_Abstract $object - * @param mixed $value - * @param string $field field to load by (defaults to model id) - * @return Mage_Core_Model_Resource_Db_Abstract - */ - public function load(Mage_Core_Model_Abstract $object, $value, $field = null) - { - if (is_null($field)) { - $field = $this->getIdFieldName(); - } - - $read = $this->_getReadAdapter(); - if ($read && !is_null($value)) { - $select = $this->_getLoadSelect($field, $value, $object); - $data = $read->fetchRow($select); - - if ($data) { - $object->setData($data); - } - } - - $this->unserializeFields($object); - $this->_afterLoad($object); - - return $this; - } - - /** - * Retrieve select object for load object data - * - * @param string $field - * @param mixed $value - * @param Mage_Core_Model_Abstract $object - * @return Zend_Db_Select - */ - protected function _getLoadSelect($field, $value, $object) - { - $field = $this->_getReadAdapter()->quoteIdentifier(sprintf('%s.%s', $this->getMainTable(), $field)); - $select = $this->_getReadAdapter()->select() - ->from($this->getMainTable()) - ->where($field . '=?', $value); - return $select; - } - - /** - * Save object object data - * - * @param Mage_Core_Model_Abstract $object - * @return Mage_Core_Model_Resource_Db_Abstract - */ - public function save(Mage_Core_Model_Abstract $object) - { - if ($object->isDeleted()) { - return $this->delete($object); - } - - $this->_serializeFields($object); - $this->_beforeSave($object); - $this->_checkUnique($object); - if (!is_null($object->getId()) && (!$this->_useIsObjectNew || !$object->isObjectNew())) { - $condition = $this->_getWriteAdapter()->quoteInto($this->getIdFieldName().'=?', $object->getId()); - /** - * Not auto increment primary key support - */ - if ($this->_isPkAutoIncrement) { - $data = $this->_prepareDataForSave($object); - unset($data[$this->getIdFieldName()]); - $this->_getWriteAdapter()->update($this->getMainTable(), $data, $condition); - } else { - $select = $this->_getWriteAdapter()->select() - ->from($this->getMainTable(), array($this->getIdFieldName())) - ->where($condition); - if ($this->_getWriteAdapter()->fetchOne($select) !== false) { - $data = $this->_prepareDataForSave($object); - unset($data[$this->getIdFieldName()]); - if (!empty($data)) { - $this->_getWriteAdapter()->update($this->getMainTable(), $data, $condition); - } - } else { - $this->_getWriteAdapter()->insert($this->getMainTable(), $this->_prepareDataForSave($object)); - } - } - } else { - $bind = $this->_prepareDataForSave($object); - if ($this->_isPkAutoIncrement) { - unset($bind[$this->getIdFieldName()]); - } - $this->_getWriteAdapter()->insert($this->getMainTable(), $bind); - - $object->setId($this->_getWriteAdapter()->lastInsertId($this->getMainTable())); - - if ($this->_useIsObjectNew) { - $object->isObjectNew(false); - } - } - - $this->unserializeFields($object); - $this->_afterSave($object); - - return $this; - } - - /** - * Delete the object - * - * @param Mage_Core_Model_Abstract $object - * @return Mage_Core_Model_Resource_Db_Abstract - */ - public function delete(Mage_Core_Model_Abstract $object) - { - $this->_beforeDelete($object); - $this->_getWriteAdapter()->delete( - $this->getMainTable(), - $this->_getWriteAdapter()->quoteInto($this->getIdFieldName() . '=?', $object->getId()) - ); - $this->_afterDelete($object); - return $this; - } - - /** - * Add unique field restriction - * - * @param array|string $field - * @return Mage_Core_Model_Resource_Db_Abstract - */ - public function addUniqueField($field) - { - if (is_null($this->_uniqueFields)) { - $this->_initUniqueFields(); - } - if (is_array($this->_uniqueFields) ) { - $this->_uniqueFields[] = $field; - } - return $this; - } - - /** - * Reset unique fields restrictions - * - * @return Mage_Core_Model_Resource_Db_Abstract - */ - public function resetUniqueField() - { - $this->_uniqueFields = array(); - return $this; - } - - /** - * Unserialize serializeable object fields - * - * @param Mage_Core_Model_Abstract $object - */ - public function unserializeFields(Mage_Core_Model_Abstract $object) - { - foreach ($this->_serializableFields as $field => $parameters) { - list($serializeDefault, $unserializeDefault) = $parameters; - $this->_unserializeField($object, $field, $unserializeDefault); - } - } - - /** - * Initialize unique fields - * - * @return Mage_Core_Model_Resource_Db_Abstract - */ - protected function _initUniqueFields() - { - $this->_uniqueFields = array(); - return $this; - } - - /** - * Get configuration of all unique fields - * - * @return array - */ - public function getUniqueFields() - { - if (is_null($this->_uniqueFields)) { - $this->_initUniqueFields(); - } - return $this->_uniqueFields; - } - - /** - * Prepare data for save - * - * @param Mage_Core_Model_Abstract $object - * @return array - */ - protected function _prepareDataForSave(Mage_Core_Model_Abstract $object) - { - return $this->_prepareDataForTable($object, $this->getMainTable()); - } - - /** - * Check that model data fields that can be saved - * has really changed comparing with origData - * - * @param Mage_Core_Model_Abstract $object - * @return boolean - */ - public function hasDataChanged($object) - { - if (!$object->getOrigData()) { - return true; - } - - $fields = $this->_getWriteAdapter()->describeTable($this->getMainTable()); - foreach (array_keys($fields) as $field) { - if ($object->getOrigData($field) != $object->getData($field)) { - return true; - } - } - - return false; - } - - /** - * Prepare value for save - * - * @param mixed $value - * @param string $type - * @return mixed - */ - protected function _prepareValueForSave($value, $type) - { - return $this->_prepareTableValueForSave($value, $type); - } - - /** - * Check for unique values existence - * - * @param Mage_Core_Model_Abstract $object - * @return Mage_Core_Model_Resource_Db_Abstract - * @throws Mage_Core_Exception - */ - protected function _checkUnique(Mage_Core_Model_Abstract $object) - { - $existent = array(); - $fields = $this->getUniqueFields(); - if (!empty($fields)) { - if (!is_array($fields)) { - $this->_uniqueFields = array( - array( - 'field' => $fields, - 'title' => $fields - )); - } - - $data = new Varien_Object($this->_prepareDataForSave($object)); - $select = $this->_getWriteAdapter()->select() - ->from($this->getMainTable()); - - foreach ($fields as $unique) { - $select->reset(Zend_Db_Select::WHERE); - - if (is_array($unique['field'])) { - foreach ($unique['field'] as $field) { - $select->where($field . '=?', trim($data->getData($field))); - } - } else { - $select->where($unique['field'] . '=?', trim($data->getData($unique['field']))); - } - - if ($object->getId() || $object->getId() === '0') { - $select->where($this->getIdFieldName() . '!=?', $object->getId()); - } - - $test = $this->_getWriteAdapter()->fetchRow($select); - if ($test) { - $existent[] = $unique['title']; - } - } - } - - if (!empty($existent)) { - if (count($existent) == 1 ) { - $error = Mage::helper('Mage_Core_Helper_Data')->__('%s already exists.', $existent[0]); - } else { - $error = Mage::helper('Mage_Core_Helper_Data')->__('%s already exist.', implode(', ', $existent)); - } - Mage::throwException($error); - } - return $this; - } - - /** - * After load - * - * @param Mage_Core_Model_Abstract $object - */ - public function afterLoad(Mage_Core_Model_Abstract $object) - { - $this->_afterLoad($object); - } - - /** - * Perform actions after object load - * - * @param Varien_Object $object - * @return Mage_Core_Model_Resource_Db_Abstract - */ - protected function _afterLoad(Mage_Core_Model_Abstract $object) - { - return $this; - } - - /** - * Perform actions before object save - * - * @param Varien_Object $object - * @return Mage_Core_Model_Resource_Db_Abstract - */ - protected function _beforeSave(Mage_Core_Model_Abstract $object) - { - return $this; - } - - /** - * Perform actions after object save - * - * @param Varien_Object $object - * @return Mage_Core_Model_Resource_Db_Abstract - */ - protected function _afterSave(Mage_Core_Model_Abstract $object) - { - return $this; - } - - /** - * Perform actions before object delete - * - * @param Varien_Object $object - * @return Mage_Core_Model_Resource_Db_Abstract - */ - protected function _beforeDelete(Mage_Core_Model_Abstract $object) - { - return $this; - } - - /** - * Perform actions after object delete - * - * @param Varien_Object $object - * @return Mage_Core_Model_Resource_Db_Abstract - */ - protected function _afterDelete(Mage_Core_Model_Abstract $object) - { - return $this; - } - - /** - * Serialize serializeable fields of the object - * - * @param Mage_Core_Model_Abstract $object - */ - protected function _serializeFields(Mage_Core_Model_Abstract $object) - { - foreach ($this->_serializableFields as $field => $parameters) { - list($serializeDefault, $unserializeDefault) = $parameters; - $this->_serializeField($object, $field, $serializeDefault, isset($parameters[2])); - } - } - - /** - * Retrieve table checksum - * - * @param string|array $table - * @return int|array - */ - public function getChecksum($table) - { - if (!$this->_getReadAdapter()) { - return false; - } - $checksum = $this->_getReadAdapter()->getTablesChecksum($table); - if (count($checksum) == 1) { - return $checksum[$table]; - } - return $checksum; - } -} diff --git a/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php b/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php deleted file mode 100644 index 9d6445e4fc213..0000000000000 --- a/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php +++ /dev/null @@ -1,711 +0,0 @@ - - */ -abstract class Mage_Core_Model_Resource_Db_Collection_Abstract extends Varien_Data_Collection_Db -{ - const CACHE_TAG = 'COLLECTION_DATA'; - - /** - * Model name - * - * @var string - */ - protected $_model; - - /** - * Resource model name - * - * @var string - */ - protected $_resourceModel; - - /** - * Resource instance - * - * @var Mage_Core_Model_Resource_Db_Abstract - */ - protected $_resource; - - /** - * Fields to select in query - * - * @var array|null - */ - protected $_fieldsToSelect = null; - - /** - * Fields initial fields to select like id_field - * - * @var array|null - */ - protected $_initialFieldsToSelect = null; - - /** - * Fields to select changed flag - * - * @var boolean - */ - protected $_fieldsToSelectChanged = false; - - /** - * Store joined tables here - * - * @var array - */ - protected $_joinedTables = array(); - - /** - * Collection main table - * - * @var string - */ - protected $_mainTable = null; - - /** - * Reset items data changed flag - * - * @var boolean - */ - protected $_resetItemsDataChanged = false; - - /** - * Name prefix of events that are dispatched by model - * - * @var string - */ - protected $_eventPrefix = ''; - - /** - * Name of event parameter - * - * @var string - */ - protected $_eventObject = ''; - - /** - * Use analytic function flag - * If true - allows to prepare final select with analytic function - * - * @var bool - */ - protected $_useAnalyticFunction = false; - - /** - * Collection constructor - * - * @param Mage_Core_Model_Resource_Db_Abstract $resource - */ - public function __construct($resource = null) - { - parent::__construct(); - $this->_construct(); - $this->_resource = $resource; - $this->setConnection($this->getResource()->getReadConnection()); - $this->_initSelect(); - } - - /** - * Initialization here - * - */ - protected function _construct() - { - - } - - /** - * Retrieve main table - * - * @return string - */ - public function getMainTable() - { - if ($this->_mainTable === null) { - $this->setMainTable($this->getResource()->getMainTable()); - } - - return $this->_mainTable; - } - - /** - * Set main collection table - * - * @param string $table - * @return Mage_Core_Model_Resource_Db_Collection_Abstract - */ - public function setMainTable($table) - { - $table = $this->getTable($table); - if ($this->_mainTable !== null && $table !== $this->_mainTable && $this->getSelect() !== null) { - $from = $this->getSelect()->getPart(Zend_Db_Select::FROM); - if (isset($from['main_table'])) { - $from['main_table']['tableName'] = $table; - } - $this->getSelect()->setPart(Zend_Db_Select::FROM, $from); - } - - $this->_mainTable = $table; - return $this; - } - - /** - * Init collection select - * - * @return Mage_Core_Model_Resource_Db_Collection_Abstract - */ - protected function _initSelect() - { - $this->getSelect()->from(array('main_table' => $this->getMainTable())); - return $this; - } - - /** - * Get Zend_Db_Select instance and applies fields to select if needed - * - * @return Varien_Db_Select - */ - public function getSelect() - { - if ($this->_select && $this->_fieldsToSelectChanged) { - $this->_fieldsToSelectChanged = false; - $this->_initSelectFields(); - } - return parent::getSelect(); - } - - /** - * Init fields for select - * - * @return Mage_Core_Model_Resource_Db_Collection_Abstract - */ - protected function _initSelectFields() - { - $columns = $this->_select->getPart(Zend_Db_Select::COLUMNS); - $columnsToSelect = array(); - foreach ($columns as $columnEntry) { - list($correlationName, $column, $alias) = $columnEntry; - if ($correlationName !== 'main_table') { // Add joined fields to select - if ($column instanceof Zend_Db_Expr) { - $column = $column->__toString(); - } - $key = ($alias !== null ? $alias : $column); - $columnsToSelect[$key] = $columnEntry; - } - } - - $columns = $columnsToSelect; - - $columnsToSelect = array_keys($columnsToSelect); - - if ($this->_fieldsToSelect !== null) { - $insertIndex = 0; - foreach ($this->_fieldsToSelect as $alias => $field) { - if (!is_string($alias)) { - $alias = null; - } - - if ($field instanceof Zend_Db_Expr) { - $column = $field->__toString(); - } else { - $column = $field; - } - - if (($alias !== null && in_array($alias, $columnsToSelect)) || - // If field already joined from another table - ($alias === null && isset($alias, $columnsToSelect))) { - continue; - } - - $columnEntry = array('main_table', $field, $alias); - array_splice($columns, $insertIndex, 0, array($columnEntry)); // Insert column - $insertIndex ++; - - } - } else { - array_unshift($columns, array('main_table', '*', null)); - } - - $this->_select->setPart(Zend_Db_Select::COLUMNS, $columns); - - return $this; - } - - /** - * Retrieve initial fields to select like id field - * - * @return array - */ - protected function _getInitialFieldsToSelect() - { - if ($this->_initialFieldsToSelect === null) { - $this->_initialFieldsToSelect = array(); - $this->_initInitialFieldsToSelect(); - } - - return $this->_initialFieldsToSelect; - } - - /** - * Initialize initial fields to select like id field - * - * @return Mage_Core_Model_Resource_Db_Collection_Abstract - */ - protected function _initInitialFieldsToSelect() - { - $idFieldName = $this->getResource()->getIdFieldName(); - if ($idFieldName) { - $this->_initialFieldsToSelect[] = $idFieldName; - } - return $this; - } - - /** - * Add field to select - * - * @param string|array $field - * @param string|null $alias - * @return Mage_Core_Model_Resource_Db_Collection_Abstract - */ - public function addFieldToSelect($field, $alias = null) - { - if ($field === '*') { // If we will select all fields - $this->_fieldsToSelect = null; - $this->_fieldsToSelectChanged = true; - return $this; - } - - if (is_array($field)) { - if ($this->_fieldsToSelect === null) { - $this->_fieldsToSelect = $this->_getInitialFieldsToSelect(); - } - - foreach ($field as $key => $value) { - $this->addFieldToSelect( - $value, - (is_string($key) ? $key : null), - false - ); - } - - $this->_fieldsToSelectChanged = true; - return $this; - } - - if ($alias === null) { - $this->_fieldsToSelect[] = $field; - } else { - $this->_fieldsToSelect[$alias] = $field; - } - - $this->_fieldsToSelectChanged = true; - return $this; - } - - /** - * Add attribute expression (SUM, COUNT, etc) - * Example: ('sub_total', 'SUM({{attribute}})', 'revenue') - * Example: ('sub_total', 'SUM({{revenue}})', 'revenue') - * For some functions like SUM use groupByAttribute. - * - * @param string $alias - * @param string $expression - * @param array|string $fields - * @return Mage_Core_Model_Resource_Db_Collection_Abstract - */ - public function addExpressionFieldToSelect($alias, $expression, $fields) - { - // validate alias - if (!is_array($fields)) { - $fields = array($fields => $fields); - } - - $fullExpression = $expression; - foreach ($fields as $fieldKey=>$fieldItem) { - $fullExpression = str_replace('{{' . $fieldKey . '}}', $fieldItem, $fullExpression); - } - - $this->getSelect()->columns(array($alias=>$fullExpression)); - - return $this; - } - - /** - * Removes field from select - * - * @param string|null $field - * @param boolean $isAlias Alias identifier - * @return Mage_Core_Model_Resource_Db_Collection_Abstract - */ - public function removeFieldFromSelect($field, $isAlias = false) - { - if ($isAlias) { - if (isset($this->_fieldsToSelect[$field])) { - unset($this->_fieldsToSelect[$field]); - } - } else { - foreach ($this->_fieldsToSelect as $key => $value) { - if ($value === $field) { - unset($this->_fieldsToSelect[$key]); - break; - } - } - } - - $this->_fieldsToSelectChanged = true; - return $this; - } - - /** - * Removes all fields from select - * - * @return Mage_Core_Model_Resource_Db_Collection_Abstract - */ - public function removeAllFieldsFromSelect() - { - $this->_fieldsToSelect = $this->_getInitialFieldsToSelect(); - $this->_fieldsToSelectChanged = true; - return $this; - } - - /** - * Standard resource collection initialization - * - * @param string $model - * @param string $resourceModel - * @return Mage_Core_Model_Resource_Db_Collection_Abstract - */ - protected function _init($model, $resourceModel) - { - $this->setModel($model); - $this->setResourceModel($resourceModel); - return $this; - } - - /** - * Set model name for collection items - * - * @param string $model - * @return Mage_Core_Model_Resource_Db_Collection_Abstract - */ - public function setModel($model) - { - if (is_string($model)) { - $this->_model = $model; - $this->setItemObjectClass($model); - } - return $this; - } - - /** - * Get model instance - * - * @param array $args - * @return Varien_Object - */ - public function getModelName($args = array()) - { - return $this->_model; - } - - /** - * Set resource model name for collection items - * - * @param string $model - */ - public function setResourceModel($model) - { - $this->_resourceModel = $model; - } - - /** - * Retrieve resource model name - * - * @return string - */ - public function getResourceModelName() - { - return $this->_resourceModel; - } - - /** - * Get resource instance - * - * @return Mage_Core_Model_Resource_Db_Abstract - */ - public function getResource() - { - if (empty($this->_resource)) { - $this->_resource = Mage::getResourceModel($this->getResourceModelName()); - } - return $this->_resource; - } - - /** - * Retrieve table name - * - * @param string $table - * @return string - */ - public function getTable($table) - { - return $this->getResource()->getTable($table); - } - - /** - * Retrieve all ids for collection - * - * @return array - */ - public function getAllIds() - { - $idsSelect = clone $this->getSelect(); - $idsSelect->reset(Zend_Db_Select::ORDER); - $idsSelect->reset(Zend_Db_Select::LIMIT_COUNT); - $idsSelect->reset(Zend_Db_Select::LIMIT_OFFSET); - $idsSelect->reset(Zend_Db_Select::COLUMNS); - - $idsSelect->columns($this->getResource()->getIdFieldName(), 'main_table'); - return $this->getConnection()->fetchCol($idsSelect, $this->_bindParams); - } - - public function getData() - { - if ($this->_data === null) { - $this->_renderFilters() - ->_renderOrders() - ->_renderLimit(); - /** - * Prepare select for execute - * @var string $query - */ - $query = $this->_prepareSelect($this->getSelect()); - $this->_data = $this->_fetchAll($query, $this->_bindParams); - $this->_afterLoadData(); - } - return $this->_data; - } - - /** - * Prepare select for load - * - * @return string - */ - protected function _prepareSelect(Varien_Db_Select $select) - { - $helper = Mage::getResourceHelper('Mage_Core'); - - $unionParts = $select->getPart(Zend_Db_Select::UNION); - if (!empty($unionParts)) { - $select = $helper->limitUnion($select); - } - - if ($this->_useAnalyticFunction) { - return $helper->getQueryUsingAnalyticFunction($select); - } - - return (string)$select; - } - /** - * Join table to collection select - * - * @param string $table - * @param string $cond - * @param string $cols - * @return Mage_Core_Model_Resource_Db_Collection_Abstract - */ - public function join($table, $cond, $cols = '*') - { - if (is_array($table)) { - foreach ($table as $k => $v) { - $alias = $k; - $table = $v; - break; - } - } else { - $alias = $table; - } - - if (!isset($this->_joinedTables[$table])) { - $this->getSelect()->join( - array($alias => $this->getTable($table)), - $cond, - $cols - ); - $this->_joinedTables[$alias] = true; - } - return $this; - } - - /** - * Redeclare before load method for adding event - * - * @return Mage_Core_Model_Resource_Db_Collection_Abstract - */ - protected function _beforeLoad() - { - parent::_beforeLoad(); - Mage::dispatchEvent('core_collection_abstract_load_before', array('collection' => $this)); - if ($this->_eventPrefix && $this->_eventObject) { - Mage::dispatchEvent($this->_eventPrefix.'_load_before', array( - $this->_eventObject => $this - )); - } - return $this; - } - - /** - * Set reset items data changed flag - * - * @param boolean $flag - * @return Mage_Core_Model_Resource_Db_Collection_Abstract - */ - public function setResetItemsDataChanged($flag) - { - $this->_resetItemsDataChanged = (bool)$flag; - return $this; - } - - /** - * Set flag data has changed to all collection items - * - * @return Mage_Core_Model_Resource_Db_Collection_Abstract - */ - public function resetItemsDataChanged() - { - foreach ($this->_items as $item) { - $item->setDataChanges(false); - } - - return $this; - } - - /** - * Redeclare after load method for specifying collection items original data - * - * @return Mage_Core_Model_Resource_Db_Collection_Abstract - */ - protected function _afterLoad() - { - parent::_afterLoad(); - foreach ($this->_items as $item) { - $item->setOrigData(); - if ($this->_resetItemsDataChanged) { - $item->setDataChanges(false); - } - } - Mage::dispatchEvent('core_collection_abstract_load_after', array('collection' => $this)); - if ($this->_eventPrefix && $this->_eventObject) { - Mage::dispatchEvent($this->_eventPrefix.'_load_after', array( - $this->_eventObject => $this - )); - } - return $this; - } - - /** - * Save all the entities in the collection - * - * @return Mage_Core_Model_Resource_Db_Collection_Abstract - */ - public function save() - { - foreach ($this->getItems() as $item) { - $item->save(); - } - return $this; - } - - /** - * Check if cache can be used for collection - * - * @return bool - */ - protected function _canUseCache() - { - return Mage::getObjectManager()->get('Mage_Core_Model_Cache')->canUse('collections') - && !empty($this->_cacheConf); - } - - /** - * Load cached data for select - * - * @param Zend_Db_Select $select - * @return string | false - */ - protected function _loadCache($select) - { - $data = Mage::getObjectManager()->get('Mage_Core_Model_Cache')->load($this->_getSelectCacheId($select)); - return $data; - } - - /** - * Save collection data to cache - * - * @param array $data - * @param Zend_Db_Select $select - * @return Mage_Core_Model_Resource_Db_Collection_Abstract - */ - protected function _saveCache($data, $select) - { - Mage::getObjectManager()->get('Mage_Core_Model_Cache')->save( - serialize($data), $this->_getSelectCacheId($select), $this->_getCacheTags(), false - ); - return $this; - } - - /** - * Redeclared for processing cache tags throw application object - * - * @return array - */ - protected function _getCacheTags() - { - $tags = parent::_getCacheTags(); - $tags[] = Mage_Core_Model_AppInterface::CACHE_TAG; - $tags[] = self::CACHE_TAG; - return $tags; - } - - /** - * Format Date to internal database date format - * - * @param int|string|Zend_Date $date - * @param boolean $includeTime - * @return string - */ - public function formatDate($date, $includeTime = true) - { - return Varien_Date::formatDate($date, $includeTime); - } -} diff --git a/app/code/core/Mage/Core/Model/Resource/Layout/Link/Collection.php b/app/code/core/Mage/Core/Model/Resource/Layout/Link/Collection.php deleted file mode 100644 index ca8695c386ede..0000000000000 --- a/app/code/core/Mage/Core/Model/Resource/Layout/Link/Collection.php +++ /dev/null @@ -1,94 +0,0 @@ -_init('Mage_Core_Model_Layout_Link', 'Mage_Core_Model_Resource_Layout_Link'); - } - - /** - * Join with layout update table - * - * @param array $fields - * @return Mage_Core_Model_Resource_Layout_Link_Collection - */ - protected function _joinWithUpdate($fields = array()) - { - $flagName = 'joined_with_update_table'; - if (!$this->getFlag($flagName)) { - $this->getSelect() - ->join( - array('update' => $this->getTable('core_layout_update')), - 'update.layout_update_id = main_table.layout_update_id', - array($fields) - ); - $this->setFlag($flagName, true); - } - - return $this; - } - - /** - * Filter by temporary flag - * - * @param bool $isTemporary - * @return Mage_Core_Model_Resource_Layout_Update_Collection - */ - public function addTemporaryFilter($isTemporary) - { - $this->addFieldToFilter('main_table.is_temporary', $isTemporary ? 1 : 0); - return $this; - } - - /** - * Get links for layouts that are older then specified number of days - * - * @param $days - * @return Mage_Core_Model_Resource_Layout_Update_Collection - */ - public function addUpdatedDaysBeforeFilter($days) - { - $datetime = new DateTime(); - $storeInterval = new DateInterval('P' . $days . 'D'); - $datetime->sub($storeInterval); - $formattedDate = $this->formatDate($datetime->getTimestamp()); - - $this->_joinWithUpdate(); - $this->addFieldToFilter('update.updated_at', array('notnull' => true)) - ->addFieldToFilter('update.updated_at', array('lt' => $formattedDate)); - - return $this; - } -} diff --git a/app/code/core/Mage/Core/Model/Resource/Layout/Update.php b/app/code/core/Mage/Core/Model/Resource/Layout/Update.php deleted file mode 100644 index 804b9aac75758..0000000000000 --- a/app/code/core/Mage/Core/Model/Resource/Layout/Update.php +++ /dev/null @@ -1,114 +0,0 @@ -_init('core_layout_update', 'layout_update_id'); - } - - /** - * Retrieve layout updates by handle - * - * @param string $handle - * @param array $params - * @return string - */ - public function fetchUpdatesByHandle($handle, $params = array()) - { - $bind = array( - 'store_id' => Mage::app()->getStore()->getId(), - 'theme_id' => Mage::getDesign()->getDesignTheme()->getThemeId(), - ); - - foreach ($params as $key => $value) { - if (isset($bind[$key])) { - $bind[$key] = $value; - } - } - $bind['layout_update_handle'] = $handle; - $result = ''; - - $readAdapter = $this->_getReadAdapter(); - if ($readAdapter) { - $select = $this->_getFetchUpdatesByHandleSelect(); - $result = join('', $readAdapter->fetchCol($select, $bind)); - } - return $result; - } - - /** - * Get select to fetch updates by handle - * - * @param bool $loadAllUpdates - * @return Varien_Db_Select - */ - protected function _getFetchUpdatesByHandleSelect($loadAllUpdates = false) - { - $select = $this->_getReadAdapter()->select() - ->from(array('layout_update' => $this->getMainTable()), array('xml')) - ->join(array('link' => $this->getTable('core_layout_link')), - 'link.layout_update_id=layout_update.layout_update_id', '') - ->where('link.store_id IN (0, :store_id)') - ->where('link.theme_id = :theme_id') - ->where('layout_update.handle = :layout_update_handle') - ->order('layout_update.sort_order ' . Varien_Db_Select::SQL_ASC); - - if (!$loadAllUpdates) { - $select->where('link.is_temporary = 0'); - } - - return $select; - } - - /** - * Update a "layout update link" if relevant data is provided - * - * @param Mage_Core_Model_Layout_Update|Mage_Core_Model_Abstract $object - * @return Mage_Core_Model_Resource_Layout_Update - */ - protected function _afterSave(Mage_Core_Model_Abstract $object) - { - $data = $object->getData(); - if (isset($data['store_id']) && isset($data['theme_id'])) { - $this->_getWriteAdapter()->insertOnDuplicate($this->getTable('core_layout_link'), array( - 'store_id' => $data['store_id'], - 'theme_id' => $data['theme_id'], - 'layout_update_id' => $object->getId(), - 'is_temporary' => (int)$object->getIsTemporary(), - )); - } - Mage::app()->cleanCache(array('layout', Mage_Core_Model_Layout_Merge::LAYOUT_GENERAL_CACHE_TAG)); - return parent::_afterSave($object); - } -} diff --git a/app/code/core/Mage/Core/Model/Resource/Setup.php b/app/code/core/Mage/Core/Model/Resource/Setup.php deleted file mode 100644 index ccceb25c2e720..0000000000000 --- a/app/code/core/Mage/Core/Model/Resource/Setup.php +++ /dev/null @@ -1,904 +0,0 @@ - - */ -class Mage_Core_Model_Resource_Setup implements Mage_Core_Model_Resource_SetupInterface -{ - /** - * Setup resource name - * @var string - */ - protected $_resourceName; - - /** - * Setup resource configuration object - * - * @var Varien_Simplexml_Element - */ - protected $_resourceConfig; - - /** - * Connection configuration object - * - * @var Varien_Simplexml_Element - */ - protected $_connectionConfig; - - /** - * Setup module configuration object - * - * @var Varien_Simplexml_Element - */ - protected $_moduleConfig; - - /** - * Call afterApplyAllUpdates method flag - * - * @var boolean - */ - protected $_callAfterApplyAllUpdates = false; - - /** - * Setup Connection - * - * @var Varien_Db_Adapter_Pdo_Mysql - */ - protected $_conn; - /** - * Tables cache array - * - * @var array - */ - protected $_tables = array(); - /** - * Tables data cache array - * - * @var array - */ - protected $_setupCache = array(); - - /** - * Flag which shows, that setup has hooked queries from DB adapter - * - * @var bool - */ - protected $_queriesHooked = false; - - /** - * Modules configuration - * - * @var Mage_Core_Model_Resource - */ - protected $_resourceModel; - - /** - * Modules configuration reader - * - * @var Mage_Core_Model_Config_Modules_Reader - */ - protected $_modulesReader; - - /** - * @var Mage_Core_Model_Config_Modules - */ - protected $_config; - - /** - * Initialize resource configurations, setup connection, etc - * - * @param Mage_Core_Model_Config_Resource $resourcesConfig - * @param Mage_Core_Model_Config_Modules $modulesConfig - * @param Mage_Core_Model_Resource $resource - * @param Mage_Core_Model_Config_Modules_Reader $modulesReader - * @param string $resourceName - */ - public function __construct( - Mage_Core_Model_Config_Resource $resourcesConfig, - Mage_Core_Model_Config_Modules $modulesConfig, - Mage_Core_Model_Resource $resource, - Mage_Core_Model_Config_Modules_Reader $modulesReader, - $resourceName - ) { - $resourcesConfig->setConfig($modulesConfig); - $this->_config = $modulesConfig; - $this->_resourceModel = $resource; - $this->_resourceName = $resourceName; - $this->_modulesReader = $modulesReader; - $this->_resourceConfig = $resourcesConfig->getResourceConfig($resourceName); - $connection = $resourcesConfig->getResourceConnectionConfig($resourceName); - if ($connection) { - $this->_connectionConfig = $connection; - } else { - $this->_connectionConfig = $resourcesConfig->getResourceConnectionConfig(self::DEFAULT_SETUP_CONNECTION); - } - - $modName = (string)$this->_resourceConfig->setup->module; - $this->_moduleConfig = $this->_config->getModuleConfig($modName); - $connection = $this->_resourceModel->getConnection($this->_resourceName); - /** - * If module setup configuration wasn't loaded - */ - if (!$connection) { - $connection = $this->_resourceModel->getConnection($this->_resourceName); - } - $this->_conn = $connection; - } - - /** - * Get connection object - * - * @return Varien_Db_Adapter_Interface - */ - public function getConnection() - { - return $this->_conn; - } - - /** - * Add table placeholder/table name relation - * - * @param string $tableName - * @param string $realTableName - * @return Mage_Core_Model_Resource_Setup - */ - public function setTable($tableName, $realTableName) - { - $this->_tables[$tableName] = $realTableName; - return $this; - } - - /** - * Get table name (validated by db adapter) by table placeholder - * - * @param string|array $tableName - * @return string - */ - public function getTable($tableName) - { - $cacheKey = $this->_getTableCacheName($tableName); - if (!isset($this->_tables[$cacheKey])) { - $this->_tables[$cacheKey] = $this->_resourceModel->getTableName($tableName); - } - return $this->_tables[$cacheKey]; - } - - /** - * Retrieve table name for cache - * - * @param string|array $tableName - * @return string - */ - protected function _getTableCacheName($tableName) - { - if (is_array($tableName)) { - return join('_', $tableName); - - } - return $tableName; - } - - /** - * Get core resource resource model - * - * @return Mage_Core_Model_Resource_Resource - */ - protected function _getResource() - { - return Mage::getResourceSingleton('Mage_Core_Model_Resource_Resource'); - } - - /** - * Apply data updates to the system after upgrading. - * - * @return Mage_Core_Model_Resource_Setup - */ - public function applyDataUpdates() - { - $dataVer= $this->_getResource()->getDataVersion($this->_resourceName); - $configVer = (string)$this->_moduleConfig->version; - if ($dataVer !== false) { - $status = version_compare($configVer, $dataVer); - if ($status == self::VERSION_COMPARE_GREATER) { - $this->_upgradeData($dataVer, $configVer); - } - } elseif ($configVer) { - $this->_installData($configVer); - } - return $this; - } - - /** - * Apply module resource install, upgrade and data scripts - * - * @return Mage_Core_Model_Resource_Setup - */ - public function applyUpdates() - { - $dbVer = $this->_getResource()->getDbVersion($this->_resourceName); - $configVer = (string)$this->_moduleConfig->version; - - /** - * Hook queries in adapter, so that in MySQL compatibility mode extensions and custom modules will avoid - * errors due to changes in database structure - */ - /** @var $helper Mage_Core_Helper_Data */ - $helper = Mage::helper('Mage_Core_Helper_Data'); - if (((string)$this->_moduleConfig->codePool != 'core') && $helper->useDbCompatibleMode()) { - $this->_hookQueries(); - } - - // Module is installed - if ($dbVer !== false) { - $status = version_compare($configVer, $dbVer); - switch ($status) { - case self::VERSION_COMPARE_LOWER: - $this->_rollbackResourceDb($configVer, $dbVer); - break; - case self::VERSION_COMPARE_GREATER: - $this->_upgradeResourceDb($dbVer, $configVer); - break; - default: - return true; - break; - } - } elseif ($configVer) { - $this->_installResourceDb($configVer); - } - - $this->_unhookQueries(); - - return $this; - } - - /** - * Hooks queries to strengthen backwards compatibility in MySQL. - * Currently - dynamically updates column types for foreign keys, when their targets were changed - * during MMDB development. - * - * @return Mage_Core_Model_Resource_Setup - */ - protected function _hookQueries() - { - $this->_queriesHooked = true; - /* @var $adapter Varien_Db_Adapter_Pdo_Mysql */ - $adapter = $this->getConnection(); - $adapter->setQueryHook(array('object' => $this, 'method' => 'callbackQueryHook')); - return $this; - } - - /** - * Removes query hook - * - * @return Mage_Core_Model_Resource_Setup - */ - protected function _unhookQueries() - { - if (!$this->_queriesHooked) { - return $this; - } - /* @var $adapter Varien_Db_Adapter_Pdo_Mysql */ - $adapter = $this->getConnection(); - $adapter->setQueryHook(null); - $this->_queriesHooked = false; - return $this; - } - - /** - * Callback function, called on every query adapter processes. - * Modifies SQL or tables, so that foreign keys will be set successfully - * - * @param string $sql - * @param array $bind - * @return Mage_Core_Model_Resource_Setup - */ - public function callbackQueryHook(&$sql, &$bind) - { - Mage::getSingleton('Mage_Core_Model_Resource_Setup_Query_Modifier', - array('adapter' => $this->getConnection())) - ->processQuery($sql, $bind); - return $this; - } - - /** - * Run data install scripts - * - * @param string $newVersion - * @return Mage_Core_Model_Resource_Setup - */ - protected function _installData($newVersion) - { - $oldVersion = $this->_modifyResourceDb(self::TYPE_DATA_INSTALL, '', $newVersion); - $this->_modifyResourceDb(self::TYPE_DATA_UPGRADE, $oldVersion, $newVersion); - $this->_getResource()->setDataVersion($this->_resourceName, $newVersion); - - return $this; - } - - /** - * Run data upgrade scripts - * - * @param string $oldVersion - * @param string $newVersion - * @return Mage_Core_Model_Resource_Setup - */ - protected function _upgradeData($oldVersion, $newVersion) - { - $this->_modifyResourceDb('data-upgrade', $oldVersion, $newVersion); - $this->_getResource()->setDataVersion($this->_resourceName, $newVersion); - - return $this; - } - - /** - * Run resource installation file - * - * @param string $newVersion - * @return Mage_Core_Model_Resource_Setup - */ - protected function _installResourceDb($newVersion) - { - $oldVersion = $this->_modifyResourceDb(self::TYPE_DB_INSTALL, '', $newVersion); - $this->_modifyResourceDb(self::TYPE_DB_UPGRADE, $oldVersion, $newVersion); - $this->_getResource()->setDbVersion($this->_resourceName, $newVersion); - - return $this; - } - - /** - * Run resource upgrade files from $oldVersion to $newVersion - * - * @param string $oldVersion - * @param string $newVersion - * @return Mage_Core_Model_Resource_Setup - */ - protected function _upgradeResourceDb($oldVersion, $newVersion) - { - $this->_modifyResourceDb(self::TYPE_DB_UPGRADE, $oldVersion, $newVersion); - $this->_getResource()->setDbVersion($this->_resourceName, $newVersion); - - return $this; - } - - /** - * Roll back resource - * - * @param string $newVersion - * @param string $oldVersion - * @return Mage_Core_Model_Resource_Setup - */ - protected function _rollbackResourceDb($newVersion, $oldVersion) - { - $this->_modifyResourceDb(self::TYPE_DB_ROLLBACK, $newVersion, $oldVersion); - return $this; - } - - /** - * Uninstall resource - * - * @param string $version existing resource version - * @return Mage_Core_Model_Resource_Setup - */ - protected function _uninstallResourceDb($version) - { - $this->_modifyResourceDb(self::TYPE_DB_UNINSTALL, $version, ''); - return $this; - } - - /** - * Retrieve available Database install/upgrade files for current module - * - * @param string $actionType - * @param string $fromVersion - * @param string $toVersion - * @return array - */ - protected function _getAvailableDbFiles($actionType, $fromVersion, $toVersion) - { - $resModel = (string)$this->_connectionConfig->model; - $modName = (string)$this->_moduleConfig[0]->getName(); - - $filesDir = $this->_modulesReader->getModuleDir('sql', $modName) . DS . $this->_resourceName; - if (!is_dir($filesDir) || !is_readable($filesDir)) { - return array(); - } - - $dbFiles = array(); - $typeFiles = array(); - $regExpDb = sprintf('#^%s-(.*)\.(php|sql)$#i', $actionType); - $regExpType = sprintf('#^%s-%s-(.*)\.(php|sql)$#i', $resModel, $actionType); - $handlerDir = dir($filesDir); - while (false !== ($file = $handlerDir->read())) { - $matches = array(); - if (preg_match($regExpDb, $file, $matches)) { - $dbFiles[$matches[1]] = $filesDir . DS . $file; - } else if (preg_match($regExpType, $file, $matches)) { - $typeFiles[$matches[1]] = $filesDir . DS . $file; - } - } - $handlerDir->close(); - - if (empty($typeFiles) && empty($dbFiles)) { - return array(); - } - - foreach ($typeFiles as $version => $file) { - $dbFiles[$version] = $file; - } - - return $this->_getModifySqlFiles($actionType, $fromVersion, $toVersion, $dbFiles); - } - - /** - * Retrieve available Data install/upgrade files for current module - * - * @param string $actionType - * @param string $fromVersion - * @param string $toVersion - * @return array - */ - protected function _getAvailableDataFiles($actionType, $fromVersion, $toVersion) - { - $modName = (string)$this->_moduleConfig[0]->getName(); - $files = array(); - - $filesDir = Mage::getModuleDir('data', $modName) . DS . $this->_resourceName; - if (is_dir($filesDir) && is_readable($filesDir)) { - $regExp = sprintf('#^%s-(.*)\.php$#i', $actionType); - $handlerDir = dir($filesDir); - while (false !== ($file = $handlerDir->read())) { - $matches = array(); - if (preg_match($regExp, $file, $matches)) { - $files[$matches[1]] = $filesDir . DS . $file; - } - - } - $handlerDir->close(); - } - - // search data files in old location - $filesDir = Mage::getModuleDir('sql', $modName) . DS . $this->_resourceName; - if (is_dir($filesDir) && is_readable($filesDir)) { - $regExp = sprintf('#^%s-%s-(.*)\.php$#i', $this->_connectionConfig->model, $actionType); - $handlerDir = dir($filesDir); - - while (false !== ($file = $handlerDir->read())) { - $matches = array(); - if (preg_match($regExp, $file, $matches)) { - $files[$matches[1]] = $filesDir . DS . $file; - } - } - $handlerDir->close(); - } - - if (empty($files)) { - return array(); - } - - return $this->_getModifySqlFiles($actionType, $fromVersion, $toVersion, $files); - } - - /** - * Save resource version - * - * @param string $actionType - * @param string $version - * @return Mage_Core_Model_Resource_Setup - */ - protected function _setResourceVersion($actionType, $version) - { - switch ($actionType) { - case self::TYPE_DB_INSTALL: - case self::TYPE_DB_UPGRADE: - $this->_getResource()->setDbVersion($this->_resourceName, $version); - break; - case self::TYPE_DATA_INSTALL: - case self::TYPE_DATA_UPGRADE: - $this->_getResource()->setDataVersion($this->_resourceName, $version); - break; - default: - break; - } - - return $this; - } - - /** - * Run module modification files. Return version of last applied upgrade (false if no upgrades applied) - * @param string $actionType - * @param string $fromVersion - * @param string $toVersion - * @return bool|string - * @throws Magento_Exception - */ - protected function _modifyResourceDb($actionType, $fromVersion, $toVersion) - { - switch ($actionType) { - case self::TYPE_DB_INSTALL: - case self::TYPE_DB_UPGRADE: - $files = $this->_getAvailableDbFiles($actionType, $fromVersion, $toVersion); - break; - case self::TYPE_DATA_INSTALL: - case self::TYPE_DATA_UPGRADE: - $files = $this->_getAvailableDataFiles($actionType, $fromVersion, $toVersion); - break; - default: - $files = array(); - break; - } - if (empty($files) || !$this->getConnection()) { - return false; - } - - $version = false; - - foreach ($files as $file) { - $fileName = $file['fileName']; - $fileType = pathinfo($fileName, PATHINFO_EXTENSION); - $this->getConnection()->disallowDdlCache(); - try { - switch ($fileType) { - case 'php': - $conn = $this->getConnection(); - $result = include $fileName; - break; - case 'sql': - $sql = file_get_contents($fileName); - if (!empty($sql)) { - - $result = $this->run($sql); - } else { - $result = true; - } - break; - default: - $result = false; - break; - } - - if ($result) { - $this->_setResourceVersion($actionType, $file['toVersion']); - Mage::log($fileName); - } else { - Mage::log("Failed resource setup: {$fileName}"); - } - } catch (Exception $e) { - printf('
    %s
    ', print_r($e, true)); - throw new Magento_Exception(sprintf('Error in file: "%s" - %s', $fileName, $e->getMessage()), 0, $e); - } - $version = $file['toVersion']; - $this->getConnection()->allowDdlCache(); - } - return $version; - } - - /** - * Get data files for modifications - * - * @param string $actionType - * @param string $fromVersion - * @param string $toVersion - * @param array $arrFiles - * @return array - */ - protected function _getModifySqlFiles($actionType, $fromVersion, $toVersion, $arrFiles) - { - $arrRes = array(); - switch ($actionType) { - case self::TYPE_DB_INSTALL: - case self::TYPE_DATA_INSTALL: - uksort($arrFiles, 'version_compare'); - foreach ($arrFiles as $version => $file) { - if (version_compare($version, $toVersion) !== self::VERSION_COMPARE_GREATER) { - $arrRes[0] = array( - 'toVersion' => $version, - 'fileName' => $file - ); - } - } - break; - - case self::TYPE_DB_UPGRADE: - case self::TYPE_DATA_UPGRADE: - uksort($arrFiles, 'version_compare'); - foreach ($arrFiles as $version => $file) { - $versionInfo = explode('-', $version); - - // In array must be 2 elements: 0 => version from, 1 => version to - if (count($versionInfo)!=2) { - break; - } - $infoFrom = $versionInfo[0]; - $infoTo = $versionInfo[1]; - if (version_compare($infoFrom, $fromVersion) !== self::VERSION_COMPARE_LOWER - && version_compare($infoTo, $toVersion) !== self::VERSION_COMPARE_GREATER) { - $arrRes[] = array( - 'toVersion' => $infoTo, - 'fileName' => $file - ); - } - } - break; - - case self::TYPE_DB_ROLLBACK: - break; - - case self::TYPE_DB_UNINSTALL: - break; - default: - break; - } - return $arrRes; - } - - -/******************* UTILITY METHODS *****************/ - - /** - * Retrieve row or field from table by id or string and parent id - * - * @param string $table - * @param string $idField - * @param string|integer $id - * @param string $field - * @param string $parentField - * @param string|integer $parentId - * @return mixed|boolean - */ - public function getTableRow($table, $idField, $id, $field = null, $parentField = null, $parentId = 0) - { - $table = $this->getTable($table); - if (empty($this->_setupCache[$table][$parentId][$id])) { - $adapter = $this->getConnection(); - $bind = array('id_field' => $id); - $select = $adapter->select() - ->from($table) - ->where($adapter->quoteIdentifier($idField) . '= :id_field'); - if (!is_null($parentField)) { - $select->where($adapter->quoteIdentifier($parentField) . '= :parent_id'); - $bind['parent_id'] = $parentId; - } - $this->_setupCache[$table][$parentId][$id] = $adapter->fetchRow($select, $bind); - } - - if (is_null($field)) { - return $this->_setupCache[$table][$parentId][$id]; - } - return isset($this->_setupCache[$table][$parentId][$id][$field]) - ? $this->_setupCache[$table][$parentId][$id][$field] - : false; - } - - - /** - * Delete table row - * - * @param string $table - * @param string $idField - * @param string|int $id - * @param null|string $parentField - * @param int|string $parentId - * @return Mage_Core_Model_Resource_Setup - */ - public function deleteTableRow($table, $idField, $id, $parentField = null, $parentId = 0) - { - $table = $this->getTable($table); - $adapter = $this->getConnection(); - $where = array($adapter->quoteIdentifier($idField) . '=?' => $id); - if (!is_null($parentField)) { - $where[$adapter->quoteIdentifier($parentField) . '=?'] = $parentId; - } - - $adapter->delete($table, $where); - - if (isset($this->_setupCache[$table][$parentId][$id])) { - unset($this->_setupCache[$table][$parentId][$id]); - } - - return $this; - } - - /** - * Update one or more fields of table row - * - * @param string $table - * @param string $idField - * @param string|integer $id - * @param string|array $field - * @param mixed|null $value - * @param string $parentField - * @param string|integer $parentId - * @return Mage_Eav_Model_Entity_Setup - */ - public function updateTableRow($table, $idField, $id, $field, $value = null, $parentField = null, $parentId = 0) - { - $table = $this->getTable($table); - if (is_array($field)) { - $data = $field; - } else { - $data = array($field => $value); - } - - $adapter = $this->getConnection(); - $where = array($adapter->quoteIdentifier($idField) . '=?' => $id); - $adapter->update($table, $data, $where); - - if (isset($this->_setupCache[$table][$parentId][$id])) { - if (is_array($field)) { - $this->_setupCache[$table][$parentId][$id] = - array_merge($this->_setupCache[$table][$parentId][$id], $field); - } else { - $this->_setupCache[$table][$parentId][$id][$field] = $value; - } - } - - return $this; - } - - /** - * Check is table exists - * - * @param string $table - * @return bool - */ - public function tableExists($table) - { - $table = $this->getTable($table); - return $this->getConnection()->isTableExists($table); - } - -/******************* CONFIG *****************/ - - /** - * Save configuration data - * - * @param string $path - * @param string $value - * @param int|string $scope - * @param int $scopeId - * @return Mage_Core_Model_Resource_Setup - */ - public function setConfigData($path, $value, $scope = Mage_Core_Model_Store::DEFAULT_CODE, $scopeId = 0) - { - $table = $this->getTable('core_config_data'); - // this is a fix for mysql 4.1 - $this->getConnection()->showTableStatus($table); - - $data = array( - 'scope' => $scope, - 'scope_id' => $scopeId, - 'path' => $path, - 'value' => $value - ); - $this->getConnection()->insertOnDuplicate($table, $data, array('value')); - return $this; - } - - /** - * Delete config field values - * - * @param string $path - * @param string $scope (default|stores|websites|config) - * @return Mage_Core_Model_Resource_Setup - */ - public function deleteConfigData($path, $scope = null) - { - $where = array('path = ?' => $path); - if (!is_null($scope)) { - $where['scope = ?'] = $scope; - } - $this->getConnection()->delete($this->getTable('core_config_data'), $where); - return $this; - } - - /** - * Run plain SQL query(ies) - * - * @param string $sql - * @return Mage_Core_Model_Resource_Setup - */ - public function run($sql) - { - $this->getConnection()->multiQuery($sql); - return $this; - } - - /** - * Prepare database before install/upgrade - * - * @return Mage_Core_Model_Resource_Setup - */ - public function startSetup() - { - $this->getConnection()->startSetup(); - return $this; - } - - /** - * Prepare database after install/upgrade - * - * @return Mage_Core_Model_Resource_Setup - */ - public function endSetup() - { - $this->getConnection()->endSetup(); - return $this; - } - - /** - * Retrieve 32bit UNIQUE HASH for a Table index - * - * @param string $tableName - * @param array|string $fields - * @param string $indexType - * @return string - */ - public function getIdxName($tableName, $fields, $indexType = '') - { - return $this->_resourceModel->getIdxName($tableName, $fields, $indexType); - } - - /** - * Retrieve 32bit UNIQUE HASH for a Table foreign key - * - * @param string $priTableName the target table name - * @param string $priColumnName the target table column name - * @param string $refTableName the reference table name - * @param string $refColumnName the reference table column name - * @return string - */ - public function getFkName($priTableName, $priColumnName, $refTableName, $refColumnName) - { - return $this->_resourceModel - ->getFkName($priTableName, $priColumnName, $refTableName, $refColumnName); - } - - /** - * Check call afterApplyAllUpdates method for setup class - * - * @return boolean - */ - public function getCallAfterApplyAllUpdates() - { - return $this->_callAfterApplyAllUpdates; - } - - /** - * Run each time after applying of all updates, - * if setup model setted $_callAfterApplyAllUpdates flag to true - * - * @return Mage_Core_Model_Resource_Setup - */ - public function afterApplyAllUpdates() - { - return $this; - } -} diff --git a/app/code/core/Mage/Core/Model/Resource/Setup/Query/Modifier.php b/app/code/core/Mage/Core/Model/Resource/Setup/Query/Modifier.php deleted file mode 100644 index f32e9621f8926..0000000000000 --- a/app/code/core/Mage/Core/Model/Resource/Setup/Query/Modifier.php +++ /dev/null @@ -1,349 +0,0 @@ - - */ -class Mage_Core_Model_Resource_Setup_Query_Modifier -{ - /** - * MySQL adapter instance - * - * @var Varien_Db_Adapter_Pdo_Mysql - */ - protected $_adapter; - - /** - * Types of column we process for foreign keys - * - * @var array - */ - protected $_processedTypes = array('tinyint', 'smallint', 'mediumint', 'int', 'longint'); - - /** - * Inits query modifier - * - * @param $adapter Varien_Db_Adapter_Pdo_Mysql - * @return void - */ - public function __construct(Varien_Db_Adapter_Interface $adapter) - { - $this->_adapter = $adapter; - } - - /** - * Returns column definition from CREATE TABLE sql - * - * @param string $sql - * @param string $column - * @return array - */ - protected function _getColumnDefinitionFromSql($sql, $column) - { - $result = null; - foreach ($this->_processedTypes as $type) { - $pattern = '/\s([^\s]+)\s+' . $type . '[^\s]*(\s+[^,]+)/i'; - if (!preg_match_all($pattern, $sql, $matches, PREG_SET_ORDER)) { - continue; - } - foreach ($matches as $match) { - $gotColumn = $this->_prepareIdentifier($match[1]); - if ($gotColumn != $column) { - continue; - } - - $definition = $match[2]; - $unsigned = preg_match('/\sUNSIGNED/i', $definition) > 0; - - $result = array( - 'type' => $type, - 'unsigned' => $unsigned - ); - break; - } - if ($result) { - break; - } - } - - return $result; - } - - /** - * Replaces first occurence of $needle in a $haystack - * - * @param string $haystack - * @param string $needle - * @param array $replacement - * @param bool $caseInsensitive - * @return string - */ - protected function _firstReplace($haystack, $needle, $replacement, $caseInsensitive = false) - { - $pos = $caseInsensitive ? stripos($haystack, $needle) : strpos($haystack, $needle); - if ($pos === false) { - return $haystack; - } - - return substr($haystack, 0, $pos) . $replacement . substr($haystack, $pos + strlen($needle)); - } - - /** - * Fixes column definition in CREATE TABLE sql to match defintion of column it's set to - * - * @param string $sql - * @param string $column - * @param array $refColumnDefinition - * @return Mage_Core_Model_Resource_Setup_Query_Modifier - */ - protected function _fixColumnDefinitionInSql(&$sql, $column, $refColumnDefinition) - { - $pos = stripos($sql, "`{$column}`"); // First try to find column directly recorded - if ($pos === false) { - $pattern = '/[`\s]' . preg_quote($column, '/') . '[`\s]/i'; - if (!preg_match($pattern, $sql, $matches)) { - return $this; - } - - $columnEntry = $matches[0]; - $pos = strpos($sql, $columnEntry); - if ($pos === false) { - return $this; - } - } - - $startSql = substr($sql, 0, $pos); - $restSql = substr($sql, $pos); - - // Column type definition - $columnDefinition = $this->_getColumnDefinitionFromSql($sql, $column); - if (!$columnDefinition) { - return $this; - } - - // Find pattern for type defintion - $pattern = '/\s*([^\s]+)\s+(' . $columnDefinition['type'] . '[^\s]*)\s+([^,]+)/i'; - if (!preg_match($pattern, $restSql, $matches)) { - return $this; - } - - // Replace defined type with needed type - $typeDefined = $matches[2]; - $typeNeeded = $refColumnDefinition['type']; - if ($refColumnDefinition['unsigned'] && !$columnDefinition['unsigned']) { - $typeNeeded .= ' unsigned'; - } - - $restSql = $this->_firstReplace($restSql, $typeDefined, $typeNeeded); - - if (!$refColumnDefinition['unsigned'] && ($columnDefinition['unsigned'])) { - $restSql = $this->_firstReplace($restSql, 'unsigned', '', true); - } - - // Compose SQL back - $sql = $startSql . $restSql; - - return $this; - } - - /** - * Fixes column definition in already existing table, so outgoing foreign key will be successfully set - * - * @param string $sql - * @param string $column - * @param array $refColumnDefinition - * @return Mage_Core_Model_Resource_Setup_Query_Modifier - */ - protected function _fixColumnDefinitionInTable($table, $column, $refColumnDefinition) - { - $description = $this->_adapter->fetchAll('DESCRIBE ' . $table); - foreach ($description as $columnData) { - $columnName = $this->_prepareIdentifier($columnData['Field']); - if ($columnName != $column) { - continue; - } - $definition = $refColumnDefinition['type']; - if ($refColumnDefinition['unsigned']) { - $definition .= ' UNSIGNED'; - } - if ($columnData['Null'] == 'YES') { - $definition .= ' NULL'; - } else { - $definition .= ' NOT NULL'; - } - if ($columnData['Default']) { - $definition .= ' DEFAULT ' . $columnData['Default']; - } - if ($columnData['Extra']) { - $definition .= ' ' . $columnData['Extra']; - } - - $query = 'ALTER TABLE ' . $table . ' MODIFY COLUMN ' . $column . ' ' . $definition; - $this->_adapter->query($query); - } - return $this; - } - - /** - * Returns column definition from already existing table - * - * @param string $sql - * @param string $column - * @return array|null - */ - protected function _getColumnDefinitionFromTable($table, $column) - { - $description = $this->_adapter->describeTable($table); - if (!isset($description[$column])) { - return null; - } - - return array( - 'type' => $this->_prepareIdentifier($description[$column]['DATA_TYPE']), - 'unsigned' => (bool) $description[$column]['UNSIGNED'] - ); - } - - /** - * Returns whether table exists - * - * @param string $table - * @return bool - */ - protected function _tableExists($table) - { - $rows = $this->_adapter->fetchAll('SHOW TABLES'); - foreach ($rows as $row) { - $tableFound = strtolower(current($row)); - if ($table == $tableFound) { - return true; - } - } - return false; - } - - /** - * Trims and lowercases identifier, to make common view of all of them - * - * @param string $identifier - * @return string - */ - protected function _prepareIdentifier($identifier) - { - return strtolower(trim($identifier, "`\n\r\t")); - } - - /** - * Processes query, modifies targeted columns to fit foreign keys restrictions - * - * @param string $sql - * @param array $bind - * @return Mage_Core_Model_Resource_Setup_Query_Modifier - */ - public function processQuery(&$sql, &$bind) - { - // Quick test to skip queries without foreign keys - if (!stripos($sql, 'foreign')) { - return $this; - } - - // Find foreign keys set - $pattern = '/CONSTRAINT\s+[^\s]+\s+FOREIGN\s+KEY[^(]+\\(([^),]+)\\)\s+REFERENCES\s+([^\s.]+)\s+\\(([^)]+)\\)/i'; - if (!preg_match_all($pattern, $sql, $matchesFk, PREG_SET_ORDER)) { - return $this; - } - - // Get current table name - if (!preg_match('/\s*(CREATE|ALTER)\s+TABLE\s+([^\s.]+)/i', $sql, $match)) { - return $this; - } - - $operation = $this->_prepareIdentifier($match[1]); - $table = $this->_prepareIdentifier($match[2]); - - // Process all - foreach ($matchesFk as $match) { - $column = $this->_prepareIdentifier($match[1]); - $refTable = $this->_prepareIdentifier($match[2]); - $refColumn = $this->_prepareIdentifier($match[3]); - - // Check tables existance - if (($operation != 'create') && !($this->_tableExists($table))) { - continue; - } - if (!$this->_tableExists($refTable)) { - continue; - } - - // Self references are out of our fix scope - if ($refTable == $table) { - continue; - } - - // Extract column type - if ($operation == 'create') { - $columnDefinition = $this->_getColumnDefinitionFromSql($sql, $column); - } else { - $columnDefinition = $this->_getColumnDefinitionFromTable($table, $column); - } - - // We fix only int columns - if (!$columnDefinition || !in_array($columnDefinition['type'], $this->_processedTypes)) { - continue; - } - - // Extract referenced column type - $refColumnDefinition = $this->_getColumnDefinitionFromTable($refTable, $refColumn); - if (!$refColumnDefinition) { - continue; - } - - // We fix only int columns - if (!$refColumnDefinition || !in_array($refColumnDefinition['type'], $this->_processedTypes)) { - continue; - } - - // Whether we need to fix - if ($refColumnDefinition == $columnDefinition) { - continue; - } - - // Fix column to be the same type as referenced one - if ($operation == 'create') { - $this->_fixColumnDefinitionInSql($sql, $column, $refColumnDefinition); - } else { - $this->_fixColumnDefinitionInTable($table, $column, $refColumnDefinition); - } - } - - return $this; - } -} diff --git a/app/code/core/Mage/Core/Model/Resource/Theme/Collection.php b/app/code/core/Mage/Core/Model/Resource/Theme/Collection.php deleted file mode 100644 index add330d19c86b..0000000000000 --- a/app/code/core/Mage/Core/Model/Resource/Theme/Collection.php +++ /dev/null @@ -1,174 +0,0 @@ -_init('Mage_Core_Model_Theme', 'Mage_Core_Model_Resource_Theme'); - } - - /** - * Add title for parent themes - * - * @return Mage_Core_Model_Resource_Theme_Collection - */ - public function addParentTitle() - { - $this->getSelect()->joinLeft( - array('parent' => $this->getMainTable()), - 'main_table.parent_id = parent.theme_id', - array('parent_theme_title' => 'parent.theme_title') - ); - return $this; - } - - /** - * Add area filter - * - * @param string $area - * @return Mage_Core_Model_Resource_Theme_Collection - */ - public function addAreaFilter($area = Mage_Core_Model_App_Area::AREA_FRONTEND) - { - $this->getSelect()->where('main_table.area=?', $area); - return $this; - } - - /** - * Return array for select field - * - * @return array - */ - public function toOptionArray() - { - return $this->_toOptionArray('theme_id', 'theme_title'); - } - - /** - * Return array for grid column - * - * @return array - */ - public function toOptionHash() - { - return $this->_toOptionHash('theme_id', 'theme_title'); - } - - /** - * Check whether all themes have non virtual parent theme - * - * @return Mage_Core_Model_Resource_Theme_Collection - */ - public function checkParentInThemes() - { - /** @var $theme Mage_Core_Model_Theme */ - foreach ($this as $theme) { - if ($theme->getParentId()) { - $newParentId = $this->_getParentThemeRecursively($theme->getParentId()); - if ($newParentId != $theme->getParentId()) { - $theme->setParentId($newParentId); - $theme->save(); - } - } - } - return $this; - } - - /** - * Get parent non virtual theme recursively - * - * @param int $parentId - * @return int|null - */ - protected function _getParentThemeRecursively($parentId) - { - /** @var $parentTheme Mage_Core_Model_Theme */ - $parentTheme = $this->getItemById($parentId); - if (!$parentTheme->getId() || ($parentTheme->isVirtual() && !$parentTheme->getParentId())) { - $parentId = null; - } else if ($parentTheme->isVirtual()) { - $parentId = $this->_getParentThemeRecursively($parentTheme->getParentId()); - } - return $parentId; - } - - /** - * Get theme from DB by area and theme_path - * - * @param string $fullPath - * @return Mage_Core_Model_Theme - */ - public function getThemeByFullPath($fullPath) - { - $this->clear(); - list($area, $themePath) = explode('/', $fullPath, 2); - $this->addFieldToFilter('area', $area); - $this->addFieldToFilter('theme_path', $themePath); - - return $this->getFirstItem(); - } - - /** - * Set page size - * - * @param int $size - * @return Mage_Core_Model_Resource_Theme_Collection - */ - public function setPageSize($size = self::DEFAULT_PAGE_SIZE) - { - return parent::setPageSize($size); - } - - /** - * Update all child themes relations - * - * @param Mage_Core_Model_Theme $themeModel - * @return Mage_Core_Model_Resource_Theme_Collection - */ - public function updateChildRelations(Mage_Core_Model_Theme $themeModel) - { - $parentThemeId = $themeModel->getParentId(); - $this->addFieldToFilter('parent_id', array('eq' => $themeModel->getId()))->load(); - - /** @var $theme Mage_Core_Model_Theme */ - foreach ($this->getItems() as $theme) { - $theme->setParentId($parentThemeId)->save(); - } - return $this; - } -} diff --git a/app/code/core/Mage/Core/Model/Resource/Theme/Customization/Link.php b/app/code/core/Mage/Core/Model/Resource/Theme/Customization/Link.php deleted file mode 100644 index 86fe6419e0a6a..0000000000000 --- a/app/code/core/Mage/Core/Model/Resource/Theme/Customization/Link.php +++ /dev/null @@ -1,39 +0,0 @@ -_init('core_theme_files_link', 'files_link_id'); - } -} diff --git a/app/code/core/Mage/Core/Model/Resource/Theme/Files.php b/app/code/core/Mage/Core/Model/Resource/Theme/Files.php deleted file mode 100644 index 465d341af3e45..0000000000000 --- a/app/code/core/Mage/Core/Model/Resource/Theme/Files.php +++ /dev/null @@ -1,39 +0,0 @@ -_init('core_theme_files', 'theme_files_id'); - } -} diff --git a/app/code/core/Mage/Core/Model/Resource/Theme/Files/Collection.php b/app/code/core/Mage/Core/Model/Resource/Theme/Files/Collection.php deleted file mode 100644 index 5d33e4a6b7679..0000000000000 --- a/app/code/core/Mage/Core/Model/Resource/Theme/Files/Collection.php +++ /dev/null @@ -1,64 +0,0 @@ -_init('Mage_Core_Model_Theme_Files', 'Mage_Core_Model_Resource_Theme_Files'); - } - - /** - * Add select order - * - * $field is properly quoted, lately it was treated field "order" as special SQL word and was not working - * - * @param string $field - * @param string $direction - * @return Mage_Core_Model_Resource_Theme_Files_Collection|Varien_Data_Collection|Varien_Data_Collection_Db - */ - public function setOrder($field, $direction = self::SORT_ORDER_DESC) - { - return parent::setOrder($this->getConnection()->quoteIdentifier($field), $direction); - } - - /** - * Set default order - * - * @param string $direction - * @return Mage_Core_Model_Resource_Theme_Files_Collection - */ - public function setDefaultOrder($direction) - { - return $this->setOrder('sort_order', $direction); - } -} diff --git a/app/code/core/Mage/Core/Model/Resource/Theme/Grid/Collection.php b/app/code/core/Mage/Core/Model/Resource/Theme/Grid/Collection.php deleted file mode 100644 index 63676de39565d..0000000000000 --- a/app/code/core/Mage/Core/Model/Resource/Theme/Grid/Collection.php +++ /dev/null @@ -1,43 +0,0 @@ -addAreaFilter(Mage_Core_Model_App_Area::AREA_FRONTEND)->addParentTitle(); - return $this; - } -} diff --git a/app/code/core/Mage/Core/Model/Session.php b/app/code/core/Mage/Core/Model/Session.php deleted file mode 100644 index fc579ab2475d3..0000000000000 --- a/app/code/core/Mage/Core/Model/Session.php +++ /dev/null @@ -1,57 +0,0 @@ -init('core', $name); - } - - /** - * Retrieve Session Form Key - * - * @return string A 16 bit unique key for forms - */ - public function getFormKey() - { - if (!$this->getData('_form_key')) { - $this->setData('_form_key', Mage::helper('Mage_Core_Helper_Data')->getRandomString(16)); - } - return $this->getData('_form_key'); - } -} diff --git a/app/code/core/Mage/Core/Model/Store/Group/Factory.php b/app/code/core/Mage/Core/Model/Store/Group/Factory.php deleted file mode 100644 index fb01d21c63fd8..0000000000000 --- a/app/code/core/Mage/Core/Model/Store/Group/Factory.php +++ /dev/null @@ -1,60 +0,0 @@ -_objectManager = $objectManager; - } - - /** - * @param array $arguments - * @return mixed - */ - public function createFromArray(array $arguments = array()) - { - return $this->_objectManager->get(self::CLASS_NAME, $arguments); - } -} diff --git a/app/code/core/Mage/Core/Model/Store/Storage/Default.php b/app/code/core/Mage/Core/Model/Store/Storage/Default.php deleted file mode 100644 index 8d7b3c0c19c74..0000000000000 --- a/app/code/core/Mage/Core/Model/Store/Storage/Default.php +++ /dev/null @@ -1,254 +0,0 @@ -_store = $storeFactory->create(); - $this->_store->setId(Mage_Core_Model_AppInterface::DISTRO_STORE_ID); - $this->_store->setCode(Mage_Core_Model_AppInterface::DISTRO_STORE_CODE); - $this->_website = $websiteFactory->create(); - $this->_group = $groupFactory->createFromArray(); - } - - /** - * Initialize current applicaition store - */ - public function initCurrentStore() - { - //not applicable for default storage - } - - /** - * Allow or disallow single store mode - * - * @param bool $value - */ - public function setIsSingleStoreModeAllowed($value) - { - //not applicable for default storage - } - - /** - * Check if store has only one store view - * - * @return bool - */ - public function hasSingleStore() - { - return false; - } - - /** - * Retrieve application store object - * - * @param null|string|bool|int|Mage_Core_Model_Store $id - * @return Mage_Core_Model_Store - */ - public function getStore($id = null) - { - return $this->_store; - } - - /** - * Retrieve stores array - * - * @param bool $withDefault - * @param bool $codeKey - * @return Mage_Core_Model_Store[] - */ - public function getStores($withDefault = false, $codeKey = false) - { - return array(); - } - - /** - * Retrieve application website object - * - * @param null|bool|int|string|Mage_Core_Model_Website $id - * @return Mage_Core_Model_Website - * @throws Mage_Core_Exception - */ - public function getWebsite($id = null) - { - if ($id instanceof Mage_Core_Model_Website) { - return $id; - } - - return $this->_website; - } - - /** - * Get loaded websites - * - * @param bool $withDefault - * @param bool|string $codeKey - * @return Mage_Core_Model_Website[] - */ - public function getWebsites($withDefault = false, $codeKey = false) - { - $websites = array(); - - if ($withDefault) { - $key = $codeKey ? $this->_website->getCode() : $this->_website->getId(); - $websites[$key] = $this->_website; - } - - return $websites; - } - - /** - * Retrieve application store group object - * - * @param null|Mage_Core_Model_Store_Group|string $id - * @return Mage_Core_Model_Store_Group - * @throws Mage_Core_Exception - */ - public function getGroup($id = null) - { - if ($id instanceof Mage_Core_Model_Store_Group) { - return $id; - } - - return $this->_group; - } - - /** - * Prepare array of store groups - * can be filtered to contain default store group or not by $withDefault flag - * depending on flag $codeKey array keys can be group id or group code - * - * @param bool $withDefault - * @param bool $codeKey - * @return Mage_Core_Model_Store_Group[] - */ - public function getGroups($withDefault = false, $codeKey = false) - { - $groups = array(); - - if ($withDefault) { - $key = $codeKey ? $this->_group->getCode() : $this->_group->getId(); - $groups[$key] = $this->_group; - } - return $groups; - } - - /** - * Reinitialize store list - */ - public function reinitStores() - { - //not applicable for default storage - } - - /** - * Retrieve default store for default group and website - * - * @return Mage_Core_Model_Store - */ - public function getDefaultStoreView() - { - return null; - } - - /** - * Unset website by id from app cache - * - * @param null|bool|int|string|Mage_Core_Model_Website $id - */ - public function clearWebsiteCache($id = null) - { - //not applicable for default storage - } - - /** - * Get either default or any store view - * - * @return Mage_Core_Model_Store - */ - public function getAnyStoreView() - { - return null; - } - - /** - * Set current default store - * - * @param string $store - */ - public function setCurrentStore($store) - { - - } - - /** - * @throws Mage_Core_Model_Store_Exception - */ - public function throwStoreException() - { - //not applicable for default storage - } - - /** - * Get current store code - * - * @return string - */ - public function getCurrentStore() - { - return $this->_store->getCode(); - } -} diff --git a/app/code/core/Mage/Core/Model/Template.php b/app/code/core/Mage/Core/Model/Template.php deleted file mode 100644 index ba3b122b21e13..0000000000000 --- a/app/code/core/Mage/Core/Model/Template.php +++ /dev/null @@ -1,224 +0,0 @@ - - */ -abstract class Mage_Core_Model_Template extends Mage_Core_Model_Abstract -{ - /** - * Types of template - */ - const TYPE_TEXT = 1; - const TYPE_HTML = 2; - - /** - * Default design area for emulation - */ - const DEFAULT_DESIGN_AREA = 'frontend'; - - /** - * Configuration of desing package for template - * - * @var Varien_Object - */ - protected $_designConfig; - - - /** - * Configuration of emulated desing package. - * - * @var Varien_Object|boolean - */ - protected $_emulatedDesignConfig = false; - - /** - * Initial environment information - * @see self::_applyDesignConfig() - * - * @var Varien_Object|null - */ - protected $_initialEnvironmentInfo = null; - - /** - * Package area - * - * @var string - */ - protected $_area; - - /** - * Store id - * - * @var int - */ - protected $_store; - - /** - * Initialize data - * - * @param Mage_Core_Model_Event_Manager $eventDispatcher - * @param Mage_Core_Model_Cache $cacheManager - * @param array $data - */ - public function __construct( - Mage_Core_Model_Event_Manager $eventDispatcher, - Mage_Core_Model_Cache $cacheManager, - array $data = array() - ) { - $this->_area = isset($data['area']) ? $data['area'] : null; - $this->_store = isset($data['store']) ? $data['store'] : null; - parent::__construct($eventDispatcher, $cacheManager, null, null, $data); - } - - /** - * Applying of design config - * - * @return Mage_Core_Model_Template - */ - protected function _applyDesignConfig() - { - $designConfig = $this->getDesignConfig(); - $store = $designConfig->getStore(); - $storeId = is_object($store) ? $store->getId() : $store; - $area = $designConfig->getArea(); - if (!is_null($storeId)) { - /** @var $appEmulation Mage_Core_Model_App_Emulation */ - $appEmulation = Mage::getSingleton('Mage_Core_Model_App_Emulation'); - $this->_initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId, $area); - } - return $this; - } - - /** - * Revert design settings to previous - * - * @return Mage_Core_Model_Template - */ - protected function _cancelDesignConfig() - { - if (!empty($this->_initialEnvironmentInfo)) { - $appEmulation = Mage::getSingleton('Mage_Core_Model_App_Emulation'); - $appEmulation->stopEnvironmentEmulation($this->_initialEnvironmentInfo); - $this->_initialEnvironmentInfo = null; - } - return $this; - } - - /** - * Get design configuration data - * - * @return Varien_Object - */ - public function getDesignConfig() - { - if ($this->_designConfig === null) { - if ($this->_area === null) { - $this->_area = Mage::getDesign()->getArea(); - } - if ($this->_store === null) { - $this->_store = Mage::app()->getStore()->getId(); - } - $this->_designConfig = new Varien_Object(array( - 'area' => $this->_area, - 'store' => $this->_store - )); - } - return $this->_designConfig; - } - - /** - * Initialize design information for template processing - * - * @param array $config - * @return Mage_Core_Model_Template - * @throws Magento_Exception - */ - public function setDesignConfig(array $config) - { - if (!isset($config['area']) || !isset($config['store'])) { - throw new Magento_Exception('Design config must have area and store.'); - } - $this->getDesignConfig()->setData($config); - return $this; - } - - /** - * Save current design config and replace with design config from specified store - * Event is not dispatched. - * - * @param int|string $storeId - * @param string $area - */ - public function emulateDesign($storeId, $area=self::DEFAULT_DESIGN_AREA) - { - if ($storeId) { - // save current design settings - $this->_emulatedDesignConfig = clone $this->getDesignConfig(); - if ($this->getDesignConfig()->getStore() != $storeId) { - $this->setDesignConfig(array('area' => $area, 'store' => $storeId)); - $this->_applyDesignConfig(); - } - } else { - $this->_emulatedDesignConfig = false; - } - } - - /** - * Revert to last design config, used before emulation - * - */ - public function revertDesign() - { - if ($this->_emulatedDesignConfig) { - $this->setDesignConfig($this->_emulatedDesignConfig->getData()); - $this->_cancelDesignConfig(); - $this->_emulatedDesignConfig = false; - } - } - - /** - * Return true if template type eq text - * - * @return boolean - */ - public function isPlain() - { - return $this->getType() == self::TYPE_TEXT; - } - - /** - * Getter for template type - * - * @return int|string - */ - abstract public function getType(); -} diff --git a/app/code/core/Mage/Core/Model/Theme.php b/app/code/core/Mage/Core/Model/Theme.php deleted file mode 100644 index 6e1c5445d54ae..0000000000000 --- a/app/code/core/Mage/Core/Model/Theme.php +++ /dev/null @@ -1,536 +0,0 @@ -_objectManager = $objectManager; - $this->_themeFactory = $themeFactory; - $this->_helper = $helper; - $this->_themeImage = $themeImage; - $this->_themeImage->setTheme($this); - } - - /** - * Theme model initialization - */ - protected function _construct() - { - $this->_init('Mage_Core_Model_Resource_Theme'); - } - - /** - * Get theme image model - * - * @return Mage_Core_Model_Theme_Image - */ - public function getThemeImage() - { - return $this->_themeImage; - } - - /** - * Themes collection loaded from file system configurations - * - * @return Mage_Core_Model_Theme_Collection - */ - public function getCollectionFromFilesystem() - { - return $this->_objectManager->get('Mage_Core_Model_Theme_Collection'); - } - - /** - * Validate theme data - * - * @return Mage_Core_Model_Theme - * @throws Mage_Core_Exception - */ - protected function _validate() - { - /** @var $validator Mage_Core_Model_Theme_Validator */ - $validator = $this->_objectManager->get('Mage_Core_Model_Theme_Validator'); - if (!$validator->validate($this)) { - $messages = $validator->getErrorMessages(); - throw new Mage_Core_Exception(implode(PHP_EOL, reset($messages))); - } - return $this; - } - - /** - * Check if theme is deletable - * - * @return bool - */ - public function isDeletable() - { - return $this->isVirtual(); - } - - /** - * Check if theme is editable - * - * @return bool - */ - public function isEditable() - { - return $this->isVirtual(); - } - - /** - * Check theme is existing in filesystem - * - * @return bool - */ - public function isVirtual() - { - $collection = $this->getCollectionFromFilesystem()->addDefaultPattern('*')->getItems(); - return !($this->getThemePath() && isset($collection[$this->getFullPath()])); - } - - /** - * Check is theme has child themes - * - * @return bool - */ - public function hasChildThemes() - { - return (bool)$this->getCollection()->addFieldToFilter('parent_id', array('eq' => $this->getId()))->getSize(); - } - - /** - * Return path to customized theme files - * - * @return string|null - */ - public function getCustomizationPath() - { - $customPath = $this->getData('customization_path'); - if ($this->getId() && empty($customPath)) { - /** @var $modelDir Mage_Core_Model_Dir */ - $modelDir = $this->_objectManager->get('Mage_Core_Model_Dir'); - $customPath = $modelDir->getDir(Mage_Core_Model_Dir::THEME) . DIRECTORY_SEPARATOR - . self::PATH_PREFIX_CUSTOMIZATION . DIRECTORY_SEPARATOR . $this->getId(); - $this->setData('customization_path', $customPath); - } - return $customPath; - } - - /** - * Return theme customization collection by type - * - * @param string $type - * @return Varien_Data_Collection - * @throws InvalidArgumentException - */ - public function getCustomizationData($type) - { - if (!isset($this->_themeCustomizations[$type])) { - throw new InvalidArgumentException('Customization is not present'); - } - return $this->_themeCustomizations[$type]->getCollectionByTheme($this); - } - - /** - * Add theme customization - * - * @param Mage_Core_Model_Theme_Customization_CustomizationInterface $customization - * @return Mage_Core_Model_Theme - */ - public function setCustomization(Mage_Core_Model_Theme_Customization_CustomizationInterface $customization) - { - $this->_themeCustomizations[$customization->getType()] = $customization; - return $this; - } - - /** - * Save all theme customization object - * - * @return Mage_Core_Model_Theme - */ - public function saveThemeCustomization() - { - /** @var $file Mage_Core_Model_Theme_Customization_CustomizationInterface */ - foreach ($this->_themeCustomizations as $file) { - $file->saveData($this); - } - return $this; - } - - /** - * Include customized files on default handle - * - * @return Mage_Core_Model_Theme - */ - protected function _applyCustomizationFiles() - { - if (!$this->isCustomized()) { - return $this; - } - /** @var $link Mage_Core_Model_Theme_Customization_Link */ - $link = $this->_objectManager->create('Mage_Core_Model_Theme_Customization_Link'); - $link->setThemeId($this->getId())->changeCustomFilesUpdate(); - return $this; - } - - /** - * Check if theme object data was changed. - * - * @return bool - */ - public function hasDataChanges() - { - return parent::hasDataChanges() || $this->isCustomized(); - } - - /** - * Check whether present customization objects - * - * @return bool - */ - public function isCustomized() - { - return !empty($this->_themeCustomizations); - } - - /** - * Update all relations after deleting theme - * - * @return Mage_Core_Model_Theme - */ - protected function _afterSave() - { - $this->saveThemeCustomization(); - if ($this->isCustomized()) { - $this->_applyCustomizationFiles(); - } - - $this->_checkAssignedThemeChanged(); - return parent::_afterSave(); - } - - /** - * Before theme save - * - * @return Mage_Core_Model_Theme - */ - protected function _beforeSave() - { - $this->_validate(); - return parent::_beforeSave(); - } - - /** - * Processing theme before deleting data - * - * @return Mage_Core_Model_Theme - * @throws Mage_Core_Exception - */ - protected function _beforeDelete() - { - if (!$this->isDeletable()) { - throw new Mage_Core_Exception($this->_helper->__('Theme isn\'t deletable.')); - } - $this->getThemeImage()->removePreviewImage(); - return parent::_beforeDelete(); - } - - /** - * Check is theme assigned to store and dispatch event if that was changed - * - * @return Mage_Core_Model_Theme - */ - protected function _checkAssignedThemeChanged() - { - /** @var $service Mage_Core_Model_Theme_Service */ - $service = $this->_objectManager->get('Mage_Core_Model_Theme_Service'); - if ($service->isThemeAssignedToStore($this)) { - $this->_eventDispatcher->dispatch('assigned_theme_changed', array('theme' => $this)); - } - return $this; - } - - /** - * Update all relations after deleting theme - * - * @return Mage_Core_Model_Theme - */ - protected function _afterDelete() - { - $this->getCollection()->updateChildRelations($this); - return parent::_afterDelete(); - } - - /** - * Get parent theme model - * - * @return Mage_Core_Model_Theme|null - */ - public function getParentTheme() - { - if ($this->hasData('parent_theme')) { - return $this->getData('parent_theme'); - } - - $theme = null; - if ($this->getParentId()) { - $theme = $this->_themeFactory->create()->load($this->getParentId()); - } - $this->setParentTheme($theme); - return $theme; - } - - /** - * Save data from form - * - * @param array $themeData - * @return Mage_Core_Model_Theme - */ - public function saveFormData($themeData) - { - if (isset($themeData['theme_id'])) { - $this->load($themeData['theme_id']); - if ($this->getId() && !$this->isEditable()) { - Mage::throwException($this->_helper->__('Theme isn\'t editable.')); - } - } - $previewImageData = array(); - if (isset($themeData['preview_image'])) { - $previewImageData = $themeData['preview_image']; - unset($themeData['preview_image']); - } - $this->addData($themeData); - - if (isset($previewImageData['delete'])) { - $this->getThemeImage()->removePreviewImage(); - } - - $this->getThemeImage()->uploadPreviewImage('preview_image'); - $this->setArea(Mage_Core_Model_App_Area::AREA_FRONTEND)->save(); - return $this; - } - - /** - * Return cache key for current theme - * - * @return string - */ - public function getCacheKey() - { - if (!$this->getId()) { - return self::CACHE_TAG_NO_THEME . $this->getThemePath(); - } - - return $this->getId() . $this->getThemePath(); - } - - /** - * Retrieve theme full path which is used to distinguish themes if they are not in DB yet - * - * Alternative id looks like "//". - * Used as id in file-system theme collection - * - * @return string - */ - public function getFullPath() - { - return $this->getArea() . self::PATH_SEPARATOR . $this->getThemePath(); - } - - /** - * Check if the theme is compatible with Magento version - * - * @return bool - */ - public function isThemeCompatible() - { - $magentoVersion = Mage::getVersion(); - if (version_compare($magentoVersion, $this->getMagentoVersionFrom(), '>=')) { - if ($this->getMagentoVersionTo() == '*' - || version_compare($magentoVersion, $this->getMagentoVersionFrom(), '<=') - ) { - return true; - } - } - return false; - } - - /** - * Check if the theme is compatible with Magento version and mark theme label if not compatible - * - * @return Mage_Core_Model_Theme - */ - public function checkThemeCompatible() - { - if (!$this->isThemeCompatible()) { - $this->setThemeTitle($this->_helper->__('%s (incompatible version)', $this->getThemeTitle())); - } - return $this; - } - - /** - * Return labels collection array - * - * @param bool|string $label add empty values to result with specific label - * @return array - */ - public function getLabelsCollection($label = false) - { - if (!$this->_labelsCollection) { - /** @var $themeCollection Mage_Core_Model_Resource_Theme_Collection */ - $themeCollection = $this->getCollection(); - $themeCollection->setOrder('theme_title', Varien_Data_Collection::SORT_ORDER_ASC) - ->addAreaFilter(Mage_Core_Model_App_Area::AREA_FRONTEND) - ->walk('checkThemeCompatible'); - $this->_labelsCollection = $themeCollection->toOptionArray(); - } - $options = $this->_labelsCollection; - if ($label) { - array_unshift($options, array('value' => '', 'label' => $label)); - } - return $options; - } - - /** - * Return labels collection for backend system configuration with empty value "No Theme" - * - * @return array - */ - public function getLabelsCollectionForSystemConfiguration() - { - return $this->getLabelsCollection($this->_helper->__('-- No Theme --')); - } - - /** - * Clear data for clone - */ - public function __clone() - { - $this->unsetData()->setOrigData(); - } -} diff --git a/app/code/core/Mage/Core/Model/Theme/Collection.php b/app/code/core/Mage/Core/Model/Theme/Collection.php deleted file mode 100644 index 574956d16ad51..0000000000000 --- a/app/code/core/Mage/Core/Model/Theme/Collection.php +++ /dev/null @@ -1,344 +0,0 @@ -_filesystem = $filesystem; - parent::__construct(); - } - - /** - * Retrieve collection empty item - * - * @return Mage_Core_Model_Theme - */ - public function getNewEmptyItem() - { - return Mage::getObjectManager()->create($this->_itemObjectClass); - } - - /** - * Set base directory path of design - * - * @param string $path - * @return Mage_Core_Model_Theme_Collection - */ - public function setBaseDir($path) - { - if ($this->isLoaded() && $this->_baseDir) { - $this->clearTargetPatterns()->clear(); - } - $this->_baseDir = rtrim($path, DIRECTORY_SEPARATOR); - return $this; - } - - /** - * Get base directory path - * - * @return string - */ - public function getBaseDir() - { - if (empty($this->_baseDir)) { - $this->setBaseDir(Mage::getBaseDir('design')); - } - return $this->_baseDir; - } - - /** - * Add default pattern to themes configuration - * - * @param string $area - * @return Mage_Core_Model_Theme_Collection - */ - public function addDefaultPattern($area = Mage_Core_Model_App_Area::AREA_FRONTEND) - { - $this->addTargetPattern(implode(DIRECTORY_SEPARATOR, array($area, '*', '*', 'theme.xml'))); - return $this; - } - - /** - * Target directory setter. Adds directory to be scanned - * - * @param string $relativeTarget - * @return Mage_Core_Model_Theme_Collection - */ - public function addTargetPattern($relativeTarget) - { - if ($this->isLoaded()) { - $this->clear(); - } - $this->_targetDirs[] = $relativeTarget; - return $this; - } - - /** - * Clear target patterns - * - * @return Mage_Core_Model_Theme_Collection - */ - public function clearTargetPatterns() - { - $this->_targetDirs = array(); - return $this; - } - - /** - * Return target dir for themes with theme configuration file - * - * @throws Magento_Exception - * @return array|string - */ - public function getTargetPatterns() - { - if (empty($this->_targetDirs)) { - throw new Magento_Exception('Please specify at least one target pattern to theme config file.'); - } - return $this->_targetDirs; - } - - /** - * Fill collection with theme model loaded from filesystem - * - * @param bool $printQuery - * @param bool $logQuery - * @return Mage_Core_Model_Theme_Collection - */ - public function loadData($printQuery = false, $logQuery = false) - { - if ($this->isLoaded()) { - return $this; - } - - $pathsToThemeConfig = array(); - foreach ($this->getTargetPatterns() as $directoryPath) { - $pathsToThemeConfig = array_merge( - $pathsToThemeConfig, - str_replace('/', DIRECTORY_SEPARATOR, - $this->_filesystem->searchKeys($this->getBaseDir(), $directoryPath) - ) - ); - } - - $this->_loadFromFilesystem($pathsToThemeConfig) - ->clearTargetPatterns() - ->_updateRelations() - ->_renderFilters() - ->_clearFilters(); - - return $this; - } - - /** - * Set all parent themes - * - * @return Mage_Core_Model_Theme_Collection - */ - protected function _updateRelations() - { - $themeItems = $this->getItems(); - /** @var $theme Mage_Core_Model_Theme */ - foreach ($themeItems as $theme) { - $parentThemePath = $theme->getParentThemePath(); - if ($parentThemePath) { - $id = $theme->getArea() . '/' . $parentThemePath; - if (isset($themeItems[$id])) { - $theme->setParentTheme($themeItems[$id]); - } - } - } - return $this; - } - - /** - * Load themes collection from file system by file list - * - * @param array $themeConfigPaths - * @return Mage_Core_Model_Theme_Collection - */ - protected function _loadFromFilesystem(array $themeConfigPaths) - { - foreach ($themeConfigPaths as $themeConfigPath) { - $theme = $this->getNewEmptyItem() - ->addData($this->_preparePathData($themeConfigPath)) - ->addData($this->_prepareConfigurationData($themeConfigPath)); - $this->addItem($theme); - } - $this->_setIsLoaded(); - - return $this; - } - - /** - * Return default path related data - * - * @param string $configPath - * @return array - */ - protected function _preparePathData($configPath) - { - $themeDirectory = dirname($configPath); - $fullPath = trim(substr($themeDirectory, strlen($this->getBaseDir())), DIRECTORY_SEPARATOR); - $pathPieces = explode(DIRECTORY_SEPARATOR, $fullPath); - $area = array_shift($pathPieces); - $themePath = implode(Mage_Core_Model_Theme::PATH_SEPARATOR, $pathPieces); - return array('area' => $area, 'theme_path' => $themePath, 'theme_directory' => $themeDirectory); - } - - /** - * Return default configuration data - * - * @param string $configPath - * @return array - */ - public function _prepareConfigurationData($configPath) - { - $themeConfig = $this->_getConfigModel(array($configPath)); - - $packageCodes = $themeConfig->getPackageCodes(); - $packageCode = reset($packageCodes); - - $themeCodes = $themeConfig->getPackageThemeCodes($packageCode); - $themeCode = reset($themeCodes); - - $themeVersions = $themeConfig->getCompatibleVersions($packageCode, $themeCode); - $media = $themeConfig->getMedia($packageCode, $themeCode); - $parentTheme = $themeConfig->getParentTheme($packageCode, $themeCode); - - return array( - 'parent_id' => null, - 'theme_version' => $themeConfig->getThemeVersion($packageCode, $themeCode), - 'theme_title' => $themeConfig->getThemeTitle($packageCode, $themeCode), - 'preview_image' => $media['preview_image'] ? $media['preview_image'] : null, - 'magento_version_from' => $themeVersions['from'], - 'magento_version_to' => $themeVersions['to'], - 'is_featured' => $themeConfig->isFeatured($packageCode, $themeCode), - 'parent_theme_path' => $parentTheme ? implode('/', $parentTheme) : null - ); - } - - /** - * Apply set field filters - * - * @return Mage_Core_Model_Theme_Collection - */ - protected function _renderFilters() - { - $filters = $this->getFilter(array()); - /** @var $theme Mage_Core_Model_Theme */ - foreach ($this->getItems() as $itemKey => $theme) { - $removeItem = false; - foreach ($filters as $filter) { - if ($filter['type'] == 'and' && $theme->getDataUsingMethod($filter['field']) != $filter['value']) { - $removeItem = true; - } - } - if ($removeItem) { - $this->removeItemByKey($itemKey); - } - } - return $this; - } - - /** - * Clear all added filters - * - * @return Mage_Core_Model_Theme_Collection - */ - protected function _clearFilters() - { - $this->_filters = array(); - return $this; - } - - /** - * Return configuration model for themes - * - * @param array $configPaths - * @return Magento_Config_Theme - */ - protected function _getConfigModel(array $configPaths) - { - return new Magento_Config_Theme($configPaths); - } - - /** - * Retrieve item id - * - * @param Mage_Core_Model_Theme|Varien_Object $item - * @return string - */ - protected function _getItemId(Varien_Object $item) - { - return $item->getFullPath(); - } - - /** - * Return array for select field - * - * @param bool $addEmptyField - * @return array - */ - public function toOptionArray($addEmptyField = false) - { - $optionArray = $addEmptyField ? array('' => '') : array(); - return $optionArray + $this->_toOptionArray('theme_id', 'theme_title'); - } -} diff --git a/app/code/core/Mage/Core/Model/Theme/Customization/Files/Css.php b/app/code/core/Mage/Core/Model/Theme/Customization/Files/Css.php deleted file mode 100644 index 3683c9d64040d..0000000000000 --- a/app/code/core/Mage/Core/Model/Theme/Customization/Files/Css.php +++ /dev/null @@ -1,81 +0,0 @@ -getCollectionByTheme($theme)->getFirstItem(); - $cssFile->addData(array( - 'theme_id' => $theme->getId(), - 'file_path' => self::FILE_PATH, - 'file_type' => $this->_getFileType(), - 'content' => $this->_dataForSave - ))->save(); - - return $this; - } -} diff --git a/app/code/core/Mage/Core/Model/Theme/Customization/Files/Js.php b/app/code/core/Mage/Core/Model/Theme/Customization/Files/Js.php deleted file mode 100644 index 08fc02d5ab9ed..0000000000000 --- a/app/code/core/Mage/Core/Model/Theme/Customization/Files/Js.php +++ /dev/null @@ -1,252 +0,0 @@ -_dataForDelete = $data; - return $this; - } - - /** - * Save data - * - * @param Mage_Core_Model_Theme_Customization_CustomizedInterface $theme - * @return Mage_Core_Model_Theme_Customization_Files_FilesAbstract - */ - public function saveData(Mage_Core_Model_Theme_Customization_CustomizedInterface $theme) - { - if (null !== $this->_dataForDelete) { - $this->_delete($theme); - } - parent::saveData($theme); - if ($this->hasJsOrderData()) { - $this->_reorder($theme, $this->getJsOrderData()); - } - - return $this; - } - - /** - * Delete js files from theme - * - * @param $theme Mage_Core_Model_Theme - * @return Mage_Core_Model_Theme_Customization_Files_Js - */ - protected function _delete(Mage_Core_Model_Theme $theme) - { - /** @var $jsCollection Mage_Core_Model_Resource_Theme_Files_Collection */ - $jsCollection = $this->getCollectionByTheme($theme); - /** @var $jsFile Mage_Core_Model_Theme_Files */ - foreach ($jsCollection as $jsFile) { - if (in_array($jsFile->getId(), $this->_dataForDelete)) { - $jsFile->delete(); - } - } - - return $this; - } - - /** - * Remove temporary files - * - * @param Mage_Core_Model_Theme $theme - * @return Mage_Core_Model_Theme_Customization_Files_Js - */ - public function removeTemporaryFiles($theme) - { - /** @var $jsFiles Mage_Core_Model_Resource_Theme_Files_Collection */ - $jsFiles = $this->_themeFiles->getCollection() - ->addFilter('is_temporary', true) - ->addFilter('theme_id', $theme->getId()) - ->addFilter('file_type', Mage_Core_Model_Theme_Files::TYPE_JS); - - /** @var $file Mage_Core_Model_Theme_Files */ - foreach ($jsFiles as $file) { - $file->delete(); - } - - return $this; - } - - /** - * Save form data - * - * @param Mage_Core_Model_Theme $theme - * @return Mage_Core_Model_Theme_Customization_Files_Js - */ - protected function _save($theme) - { - $themeFile = $this->_themeFiles; - $themeJsFiles = (array)$this->_dataForSave; - foreach ($themeJsFiles as $fileId) { - $themeFile->load($fileId); - if ($themeFile->getId() && ($themeFile->getThemeId() == $theme->getId())) { - $themeFile->setIsTemporary(false)->save(); - } - } - return $this; - } - - /** - * Save js file - * - * @param Mage_Core_Model_Theme $theme - * @param array $file - * @param bool $temporary - * @return Mage_Core_Model_Theme_Files - */ - public function saveJsFile($theme, $file, $temporary = true) - { - $newFileModel = $this->_themeFiles->unsetData(); - return $newFileModel->addData(array( - 'theme_id' => $theme->getId(), - 'file_path' => 'js/' . $this->_prepareFileName($theme, $file['name']), - 'file_type' => Mage_Core_Model_Theme_Files::TYPE_JS, - 'content' => $file['content'], - 'is_temporary' => $temporary - ))->save(); - } - - /** - * Prepare file name - * - * @param Mage_Core_Model_Theme $theme - * @param string $newFileName - * @return string - */ - protected function _prepareFileName($theme, $newFileName) - { - $fileInfo = pathinfo($newFileName); - $index = 1; - while ($this->_getThemeFileByName($theme, $newFileName)->getId()) { - $newFileName = $fileInfo['filename'] . '_' . $index . '.' . $fileInfo['extension']; - $index++; - } - - return $newFileName; - } - - /** - * Get theme js files by name - * - * @param Mage_Core_Model_Theme $theme - * @param string $fileName - * @return Mage_Core_Model_Resource_Theme_Files_Collection - */ - protected function _getThemeFileByName($theme, $fileName) - { - /** @var $jsFile Mage_Core_Model_Resource_Theme_Files_Collection */ - $jsFile = parent::getCollectionByTheme($theme) - ->addFieldToFilter('file_path', array('like' => "%{$fileName}")) - ->getFirstItem(); - - return $jsFile; - } - - /** - * Save data - * - * @param Mage_Core_Model_Theme_Customization_CustomizedInterface $theme - * @param string $order - * @return Mage_Core_Model_Resource_Theme_Files_Collection|Mage_Core_Model_Resource_Db_Collection_Abstract - */ - public function getCollectionByTheme( - Mage_Core_Model_Theme_Customization_CustomizedInterface $theme, - $order = Varien_Data_Collection::SORT_ORDER_ASC - ) { - return parent::getCollectionByTheme($theme)->setDefaultOrder($order); - } - - /** - * Reorder theme JS files - * - * @param Mage_Core_Model_Theme $theme - * @param array $orderData - * @return Mage_Core_Model_Theme_Customization_Files_Js - */ - public function _reorder(Mage_Core_Model_Theme $theme, $orderData) - { - /** @var $collection Mage_Core_Model_Resource_Theme_Files_Collection */ - $collection = $this->getCollectionByTheme($theme); - /** @var $file Mage_Core_Model_Theme_Files */ - foreach ($collection as $file) { - $position = array_search($file->getId(), $orderData); - if ($position === false) { - //uploaded files will be on top - $file->setSortOrder(0); - } - $file->setSortOrder($position + 1); - } - $collection->save(); - - return $this; - } -} diff --git a/app/code/core/Mage/Core/Model/Theme/Customization/Link.php b/app/code/core/Mage/Core/Model/Theme/Customization/Link.php deleted file mode 100644 index 5351243895943..0000000000000 --- a/app/code/core/Mage/Core/Model/Theme/Customization/Link.php +++ /dev/null @@ -1,238 +0,0 @@ -_objectManager = $objectManager; - $this->_themeFiles = $themeFiles; - $this->_designPackage = $designPackage; - } - - /** - * Get theme id - * - * @return int - * @throws Magento_Exception - */ - public function getThemeId() - { - if (!$this->hasData('theme_id')) { - throw new Magento_Exception('Theme id should be set'); - } - return $this->getData('theme_id'); - } - - /** - * Get layout link id for current theme customization files - * - * @return Mage_Core_Model_Layout_Link - */ - protected function _getLinkByTheme() - { - if (!$this->getId()) { - $this->load($this->getThemeId(), 'theme_id'); - } - - /** @var $link Mage_Core_Model_Layout_Update */ - $link = $this->_objectManager->create('Mage_Core_Model_Layout_Link'); - $linkId = $this->getLayoutLinkId(); - if ($linkId) { - $link->load($linkId); - } - return $link; - } - - /** - * Get update model - * - * @param int $updateId - * @return Mage_Core_Model_Layout_Update - */ - protected function _getUpdate($updateId) - { - /** @var $update Mage_Core_Model_Layout_Update */ - $update = $this->_objectManager->create('Mage_Core_Model_Layout_Update'); - if ($updateId) { - $update->load($updateId); - } - return $update; - } - - /** - * Get files collection for current theme - * - * @return Mage_Core_Model_Resource_Theme_Files_Collection - */ - protected function _getFilesCollection() - { - $filesCollection = $this->_themeFiles->getCollection() - ->setDefaultOrder(Varien_Data_Collection::SORT_ORDER_ASC) - ->addFilter('theme_id', $this->getThemeId()); - return $filesCollection; - } - - /** - * Remove relation and layout update - * - * @return Mage_Core_Model_Theme_Customization_Link - */ - public function _beforeDelete() - { - $link = $this->_getLinkByTheme(); - $update = $this->_getUpdate($link->getLayoutUpdateId()); - $link->delete(); - $update->delete(); - return parent::_beforeDelete(); - } - - /** - * Add custom files to inclusion on frontend page - * - * @param string $handle - * @return Mage_Core_Model_Theme_Customization_Link - */ - public function changeCustomFilesUpdate($handle = 'default') - { - $link = $this->_getLinkByTheme(); - $customFiles = $this->_getFilesCollection()->getItems(); - if (empty($customFiles) && !$link->getId()) { - return $this; - } elseif (empty($customFiles) && $link->getId()) { - $this->delete(); - return $this; - } - - $update = $this->_getUpdate($link->getLayoutUpdateId()); - $this->_prepareUpdate($update, $customFiles); - $update->setHandle($handle)->save(); - - if (!$link->getId()) { - $link->setThemeId($this->getThemeId()) - ->setLayoutUpdateId($update->getId()) - ->save(); - $this->setLayoutLinkId($link->getId())->save(); - } - return $this; - } - - /** - * Add layout update for custom files - * - * @param Mage_Core_Model_Layout_Update $update - * @param array $customFiles - * @return Mage_Core_Model_Theme_Customization_Link - */ - public function _prepareUpdate(Mage_Core_Model_Layout_Update $update, array $customFiles) - { - $xmlActions = ''; - /** @var $customFile Mage_Core_Model_Theme_Files */ - foreach ($customFiles as $customFile) { - if ($customFile->hasContent()) { - $xmlActions .= $this->_getInclusionAction($customFile); - $params = array( - 'area' => Mage_Core_Model_Design_Package::DEFAULT_AREA, - 'themeModel' => $customFile->getTheme() - ); - $this->_designPackage->updateFilePathInMap( - $customFile->getFullPath(), - $customFile->getRelativePath(), - $params - ); - } - } - if (!empty($xmlActions)) { - $update->setXml('' . $xmlActions . '')->save(); - } - return $this; - } - - /** - * Generate piece of layout update - * - * @param Mage_Core_Model_Theme_Files $customFile - * @throws Magento_Exception - * @return string - */ - public function _getInclusionAction(Mage_Core_Model_Theme_Files $customFile) - { - switch ($customFile->getFileType()) { - case Mage_Core_Model_Theme_Files::TYPE_CSS: - $action = "{$customFile->getRelativePath()}"; - break; - case Mage_Core_Model_Theme_Files::TYPE_JS: - $action = "{$customFile->getRelativePath()}"; - break; - default: - throw new Magento_Exception('Unsupported file type format'); - break; - } - return $action; - } -} diff --git a/app/code/core/Mage/Core/Model/Theme/Factory.php b/app/code/core/Mage/Core/Model/Theme/Factory.php deleted file mode 100644 index 84b695a375d31..0000000000000 --- a/app/code/core/Mage/Core/Model/Theme/Factory.php +++ /dev/null @@ -1,54 +0,0 @@ -_objectManager = $objectManager; - } - - /** - * Create new instance - * - * @param array $data - * @return Mage_Core_Model_Theme - */ - public function create(array $data = array()) - { - return $this->_objectManager->create('Mage_Core_Model_Theme', $data); - } -} diff --git a/app/code/core/Mage/Core/Model/Theme/Files.php b/app/code/core/Mage/Core/Model/Theme/Files.php deleted file mode 100644 index 277d37dc66dd0..0000000000000 --- a/app/code/core/Mage/Core/Model/Theme/Files.php +++ /dev/null @@ -1,227 +0,0 @@ -_ioFile = $ioFile; - $this->_objectManager = $objectManager; - } - - /** - * Theme files model initialization - */ - protected function _construct() - { - $this->_init('Mage_Core_Model_Resource_Theme_Files'); - } - - /** - * Get theme model - * - * @return Mage_Core_Model_Theme - * @throws Magento_Exception - */ - public function getTheme() - { - if ($this->hasData('theme')) { - return $this->getData('theme'); - } - - /** @var $theme Mage_Core_Model_Theme */ - $theme = $this->_objectManager->create('Mage_Core_Model_Theme'); - $themeId = $this->getData('theme_id'); - if ($themeId && $theme->load($themeId)->getId()) { - $this->setData('theme', $theme); - } else { - throw new Magento_Exception('Theme id should be set'); - } - return $theme; - } - - /** - * Create/update/delete file after save - * Delete file if only file is empty - * - * @return Mage_Core_Model_Theme_Files - */ - protected function _afterSave() - { - if ($this->hasContent()) { - $this->_saveFile(); - } else { - $this->delete(); - } - return parent::_afterSave(); - } - - /** - * Delete file form file system after delete form db - * - * @return Mage_Core_Model_Theme_Files - */ - protected function _afterDelete() - { - $this->_deleteFile(); - return parent::_afterDelete(); - } - - /** - * Create/update file in file system - * - * @return bool|int - */ - protected function _saveFile() - { - $filePath = $this->getFullPath(); - $this->_ioFile->checkAndCreateFolder(dirname($filePath)); - $result = $this->_ioFile->write($filePath, $this->getContent()); - return $result; - } - - /** - * Delete file form file system - * - * @return bool - */ - protected function _deleteFile() - { - $result = $this->_ioFile->rm($this->getFullPath()); - return $result; - } - - /** - * Check if file has content - * - * @return bool - */ - public function hasContent() - { - return (bool)trim($this->getContent()); - } - - /** - * Return path to customization directory - * - * @return string - */ - public function getRelativePath() - { - return self::PATH_PREFIX_CUSTOMIZED . '/' . $this->getFilePath(); - } - - /** - * Get file name of customization file - * - * @return string - */ - public function getFileName() - { - return basename($this->getFilePath()); - } - - /** - * Return absolute path to file of customization - * - * @return null|string - */ - public function getFullPath() - { - $path = null; - if ($this->getId()) { - $path = $this->getTheme()->getCustomizationPath(). DIRECTORY_SEPARATOR . $this->getRelativePath(); - $path = str_replace('/', DIRECTORY_SEPARATOR, $path); - } - return $path; - } -} diff --git a/app/code/core/Mage/Core/Model/Theme/Image.php b/app/code/core/Mage/Core/Model/Theme/Image.php deleted file mode 100644 index 6e1b3a609d87c..0000000000000 --- a/app/code/core/Mage/Core/Model/Theme/Image.php +++ /dev/null @@ -1,317 +0,0 @@ -_objectManager = $objectManager; - $this->_helper = $helper; - $this->_filesystem = $filesystem; - } - - /** - * Setter for theme object - * - * @param Mage_Core_Model_Theme $theme - * @return Mage_Core_Model_Theme_Image - */ - public function setTheme($theme) - { - $this->_theme = $theme; - return $this; - } - - /** - * Getter for theme object - * - * @return Mage_Core_Model_Theme - * @throws BadMethodCallException - */ - public function getTheme() - { - if (null === $this->_theme) { - throw new BadMethodCallException('Theme was not set'); - } - return $this->_theme; - } - - /** - * Getter for theme preview image - * - * @return string - */ - public function getPreviewImage() - { - return $this->getTheme()->getPreviewImage(); - } - - /** - * Setter for theme preview image - * - * @param string $imageName - * @return Mage_Core_Model_Theme_Image - */ - public function setPreviewImage($imageName) - { - $this->getTheme()->setPreviewImage($imageName); - return $this; - } - - /** - * Save preview image - * - * @return Mage_Core_Model_Theme_Image - */ - public function savePreviewImage() - { - if (!$this->getPreviewImage() || !$this->getTheme()->getThemeDirectory()) { - return $this; - } - $currentWorkingDir = getcwd(); - - chdir($this->getTheme()->getThemeDirectory()); - - $imagePath = realpath($this->getPreviewImage()); - - if (0 === strpos($imagePath, $this->getTheme()->getThemeDirectory())) { - $this->createPreviewImage($imagePath); - } - - chdir($currentWorkingDir); - - return $this; - } - - /** - * Get directory path for origin image - * - * @return string - */ - public function getImagePathOrigin() - { - return $this->_getPreviewImagePublishedRootDir() . DIRECTORY_SEPARATOR . self::IMAGE_DIR_ORIGIN; - } - - /** - * Get themes root directory absolute path - * - * @return string - */ - protected function _getPreviewImagePublishedRootDir() - { - /** @var $dir Mage_Core_Model_Dir */ - $dir = $this->_objectManager->get('Mage_Core_Model_Dir'); - $dirPath = $dir->getDir(Mage_Core_Model_Dir::THEME); - $this->_filesystem->setIsAllowCreateDirectories(true); - $this->_filesystem->ensureDirectoryExists($dirPath); - $this->_filesystem->setWorkingDirectory($dirPath); - return $dirPath; - } - - /** - * Get preview image directory url - * - * @return string - */ - public function getPreviewImageDirectoryUrl() - { - return $this->_objectManager->get('Mage_Core_Model_App')->getStore()->getBaseUrl( - Mage_Core_Model_Store::URL_TYPE_MEDIA - ) . Mage_Core_Model_Dir::THEME . '/' . self::IMAGE_DIR_PREVIEW . '/'; - } - - /** - * Upload and create preview image - * - * @param string $scope the request key for file - * @return bool - * @throws Mage_Core_Exception - */ - public function uploadPreviewImage($scope) - { - $adapter = new Zend_File_Transfer_Adapter_Http(); - if (!$adapter->isUploaded($scope)) { - return false; - } - if (!$adapter->isValid($scope)) { - Mage::throwException($this->_helper->__('Uploaded image is not valid')); - } - $upload = new Varien_File_Uploader($scope); - $upload->setAllowCreateFolders(true); - $upload->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png', 'xbm', 'wbmp')); - $upload->setAllowRenameFiles(true); - $upload->setFilesDispersion(false); - - if (!$upload->save($this->getImagePathOrigin())) { - Mage::throwException($this->_helper->__('Image can not be saved.')); - } - - $fileName = $this->getImagePathOrigin() . DS . $upload->getUploadedFileName(); - $this->removePreviewImage()->createPreviewImage($fileName); - $this->_filesystem->delete($fileName); - return true; - } - - /** - * Create preview image - * - * @param string $imagePath - * @return string - */ - public function createPreviewImage($imagePath) - { - $adapter = $this->_helper->getImageAdapterType(); - $image = new Varien_Image($imagePath, $adapter); - $image->keepTransparency(true); - $image->constrainOnly(true); - $image->keepFrame(true); - $image->keepAspectRatio(true); - $image->backgroundColor(array(255, 255, 255)); - $image->resize(self::PREVIEW_IMAGE_WIDTH, self::PREVIEW_IMAGE_HEIGHT); - - $imageName = uniqid('preview_image_') . image_type_to_extension($image->getMimeType()); - $image->save($this->_getImagePathPreview(), $imageName); - - $this->setPreviewImage($imageName); - - return $imageName; - } - - /** - * Get directory path for preview image - * - * @return string - */ - protected function _getImagePathPreview() - { - return $this->_getPreviewImagePublishedRootDir() . DIRECTORY_SEPARATOR . self::IMAGE_DIR_PREVIEW; - } - - /** - * Create preview image copy - * - * @return Mage_Core_Model_Theme_Image - */ - public function createPreviewImageCopy() - { - $filePath = $this->_getImagePathPreview() . DIRECTORY_SEPARATOR . $this->getPreviewImage(); - $destinationFileName = Varien_File_Uploader::getNewFileName($filePath); - $this->_filesystem->copy( - $this->_getImagePathPreview() . DIRECTORY_SEPARATOR . $this->getPreviewImage(), - $this->_getImagePathPreview() . DIRECTORY_SEPARATOR . $destinationFileName - ); - $this->setPreviewImage($destinationFileName); - return $this; - } - - /** - * Delete preview image - * - * @return Mage_Core_Model_Theme_Image - */ - public function removePreviewImage() - { - $previewImage = $this->getPreviewImage(); - $this->setPreviewImage(''); - if ($previewImage) { - $this->_filesystem->delete($this->_getImagePathPreview() . DIRECTORY_SEPARATOR . $previewImage); - } - return $this; - } - - /** - * Get url for themes preview image - * - * @return string - */ - public function getPreviewImageUrl() - { - if (!$this->getPreviewImage()) { - return $this->_getPreviewImageDefaultUrl(); - } - return $this->getPreviewImageDirectoryUrl() . $this->getPreviewImage(); - } - - /** - * Return default themes preview image url - * - * @return string - */ - protected function _getPreviewImageDefaultUrl() - { - return $this->_objectManager->get('Mage_Core_Model_Design_Package') - ->getViewFileUrl('Mage_Core::theme/default_preview.jpg'); - } -} diff --git a/app/code/core/Mage/Core/Model/Theme/Registration.php b/app/code/core/Mage/Core/Model/Theme/Registration.php deleted file mode 100644 index 79867abfb5e3f..0000000000000 --- a/app/code/core/Mage/Core/Model/Theme/Registration.php +++ /dev/null @@ -1,154 +0,0 @@ -setThemeModel($model); - } - - /** - * Get theme model - * - * @return Mage_Core_Model_Theme - */ - public function getThemeModel() - { - return $this->_theme; - } - - /** - * Set theme model - * - * @param Mage_Core_Model_Theme $theme - * @return Mage_Core_Model_Theme_Registration - */ - public function setThemeModel($theme) - { - $this->_theme = $theme; - return $this; - } - - /** - * Theme registration - * - * @param string $baseDir - * @param string $pathPattern - * @return Mage_Core_Model_Theme - */ - public function register($baseDir = '', $pathPattern = '') - { - $this->_collection = $this->getThemeModel()->getCollectionFromFilesystem(); - $this->_collection->setBaseDir($baseDir); - if (empty($pathPattern)) { - $this->_collection->addDefaultPattern('*'); - } else { - $this->_collection->addTargetPattern($pathPattern); - } - - foreach ($this->_collection as $theme) { - $this->_registerThemeRecursively($theme); - } - - /** @var $dbCollection Mage_Core_Model_Resource_Theme_Collection */ - $dbCollection = $this->getThemeModel()->getResourceCollection(); - $dbCollection->checkParentInThemes(); - - return $this; - } - - /** - * Register theme and recursively all its ascendants - * Second param is optional and is used to prevent circular references in inheritance chain - * - * @param Mage_Core_Model_Theme $theme - * @param array $inheritanceChain - * @return Mage_Core_Model_Theme_Collection - * @throws Mage_Core_Exception - */ - protected function _registerThemeRecursively(&$theme, $inheritanceChain = array()) - { - if ($theme->getId()) { - return $this; - } - $themeModel = $this->getThemeFromDb($theme->getFullPath()); - if ($themeModel->getId()) { - $theme = $themeModel; - return $this; - } - - $tempId = $theme->getFullPath(); - if (in_array($tempId, $inheritanceChain)) { - Mage::throwException(Mage::helper('Mage_Core_Helper_Data') - ->__('Circular-reference in theme inheritance detected for "%s"', $tempId)); - } - array_push($inheritanceChain, $tempId); - $parentTheme = $theme->getParentTheme(); - if ($parentTheme) { - $this->_registerThemeRecursively($parentTheme, $inheritanceChain); - $theme->setParentId($parentTheme->getId()); - } - - $theme->getThemeImage()->savePreviewImage(); - $theme->save(); - - return $this; - } - - /** - * Get theme from DB by full path - * - * @param string $fullPath - * @return Mage_Core_Model_Theme - */ - public function getThemeFromDb($fullPath) - { - /** @var $collection Mage_Core_Model_Resource_Theme_Collection */ - $collection = $this->getThemeModel()->getCollection(); - return $collection->getThemeByFullPath($fullPath); - } -} diff --git a/app/code/core/Mage/Core/Model/Theme/Service.php b/app/code/core/Mage/Core/Model/Theme/Service.php deleted file mode 100644 index c2d9a7778b051..0000000000000 --- a/app/code/core/Mage/Core/Model/Theme/Service.php +++ /dev/null @@ -1,372 +0,0 @@ -_themeFactory = $themeFactory; - $this->_design = $design; - $this->_app = $app; - $this->_helper = $helper; - $this->_layoutUpdate = $layoutUpdate; - $this->_eventManager = $eventManager; - $this->_configWriter = $configWriter; - } - - /** - * Assign theme to the stores - * - * @param int $themeId - * @param array $stores - * @param string $scope - * @return Mage_Core_Model_Theme - * @throws UnexpectedValueException - */ - public function assignThemeToStores( - $themeId, - array $stores = array(), - $scope = Mage_Core_Model_Config::SCOPE_STORES - ) { - /** @var $theme Mage_Core_Model_Theme */ - $theme = $this->_themeFactory->create()->load($themeId); - if (!$theme->getId()) { - throw new UnexpectedValueException('Theme is not recognized. Requested id: ' . $themeId); - } - - $themeCustomization = $theme->isVirtual() ? $theme : $this->createThemeCustomization($theme); - - $configPath = Mage_Core_Model_Design_Package::XML_PATH_THEME_ID; - - // Unassign given theme from stores that were unchecked - /** @var $config Mage_Core_Model_Config_Data */ - foreach ($this->_getAssignedScopesCollection($scope, $configPath) as $config) { - if ($config->getValue() == $themeId && !in_array($config->getScopeId(), $stores)) { - $this->_configWriter->delete($configPath, $scope, $config->getScopeId()); - } - } - - if (count($stores) > 0) { - foreach ($stores as $storeId) { - $this->_configWriter->save($configPath, $themeCustomization->getId(), $scope, $storeId); - } - - $this->_app->cleanCache(Mage_Core_Model_Config::CACHE_TAG); - } - $this->_makeTemporaryLayoutUpdatesPermanent($themeId, $stores); - $this->_app->cleanCache(array('layout', Mage_Core_Model_Layout_Merge::LAYOUT_GENERAL_CACHE_TAG)); - - $this->_eventManager->dispatch('assign_theme_to_stores_after', - array( - 'themeService' => $this, - 'themeId' => $themeId, - 'stores' => $stores, - 'scope' => $scope, - 'theme' => $theme, - 'themeCustomization' => $themeCustomization, - ) - ); - - return $themeCustomization; - } - - /** - * Create theme customization - * - * @param Mage_Core_Model_Theme $theme - * @return Mage_Core_Model_Theme - */ - public function createThemeCustomization($theme) - { - $themeCopyCount = $this->_getThemeCustomizations()->addFilter('parent_id', $theme->getId())->count(); - - $themeData = $theme->getData(); - $themeData['parent_id'] = $theme->getId(); - $themeData['theme_id'] = null; - $themeData['theme_path'] = null; - $themeData['theme_title'] = $theme->getThemeTitle() . ' - ' . $this->_helper->__('Copy') . ' #' - . ($themeCopyCount + 1); - - /** @var $themeCustomization Mage_Core_Model_Theme */ - $themeCustomization = $this->_themeFactory->create()->setData($themeData); - $themeCustomization->getThemeImage()->createPreviewImageCopy(); - $themeCustomization->save(); - return $themeCustomization; - } - - /** - * Get assigned scopes collection of a theme - * - * @param string $scope - * @param string $configPath - * @return Mage_Core_Model_Resource_Config_Data_Collection - */ - protected function _getAssignedScopesCollection($scope, $configPath) - { - return Mage::getSingleton('Mage_Core_Model_Config_Data')->getCollection() - ->addFieldToFilter('scope', $scope) - ->addFieldToFilter('path', $configPath); - } - - /** - * Make temporary updates for given theme and given stores permanent - * - * @param int $themeId - * @param array $storeIds - */ - protected function _makeTemporaryLayoutUpdatesPermanent($themeId, array $storeIds) - { - // currently all layout updates are related to theme only - $storeIds = array_merge($storeIds, array(Mage_Core_Model_AppInterface::ADMIN_STORE_ID)); - - $this->_layoutUpdate->makeTemporaryLayoutUpdatesPermanent($themeId, $storeIds); - } - - /** - * Check whether theme customizations exist in Magento - * - * @return bool - */ - public function isCustomizationsExist() - { - if ($this->_isCustomizationsExist === null) { - $this->_isCustomizationsExist = false; - /** @var $theme Mage_Core_Model_Theme */ - foreach ($this->_themeFactory->create()->getCollection() as $theme) { - if ($theme->isVirtual()) { - $this->_isCustomizationsExist = true; - break; - } - } - } - return $this->_isCustomizationsExist; - } - - /** - * Return frontend theme collection by page. Theme customizations are not included, only physical themes. - * - * @param int $page - * @param int $pageSize - * @return Mage_Core_Model_Resource_Theme_Collection - */ - public function getThemes($page, $pageSize) - { - /** @var $collection Mage_Core_Model_Resource_Theme_Collection */ - $collection = $this->_themeFactory->create()->getCollection(); - $collection->addAreaFilter(Mage_Core_Model_App_Area::AREA_FRONTEND) - ->addFilter('theme_path', 'theme_path IS NOT NULL', 'string') - ->setPageSize($pageSize); - return $collection->setCurPage($page); - } - - /** - * Check if current theme has assigned to any store - * - * @param Mage_Core_Model_Theme $theme - * @return bool - */ - public function isThemeAssignedToStore(Mage_Core_Model_Theme $theme) - { - $assignedThemes = $this->getAssignedThemeCustomizations(); - return isset($assignedThemes[$theme->getId()]); - } - - /** - * Return theme customizations which are assigned to store views - * - * @see self::_prepareThemeCustomizations() - * @return array - */ - public function getAssignedThemeCustomizations() - { - if (is_null($this->_assignedThemeCustomizations)) { - $this->_prepareThemeCustomizations(); - } - return $this->_assignedThemeCustomizations; - } - - /** - * Return theme customizations which are not assigned to store views. - * - * @see self::_prepareThemeCustomizations() - * @return array - */ - public function getUnassignedThemeCustomizations() - { - if (is_null($this->_unassignedThemeCustomizations)) { - $this->_prepareThemeCustomizations(); - } - return $this->_unassignedThemeCustomizations; - } - - /** - * Fetch theme customization and sort them out to arrays: - * self::_assignedThemeCustomizations and self::_unassignedThemeCustomizations. - * - * NOTE: To get into "assigned" list theme customization not necessary should be assigned to store-view directly. - * It can be set to website or as default theme and be used by store-view via config fallback mechanism. - * - * @return Mage_Core_Model_Theme_Service - */ - protected function _prepareThemeCustomizations() - { - /** @var $themeCustomizations Mage_Core_Model_Resource_Theme_Collection */ - $themeCustomizations = $this->_getThemeCustomizations(); - $assignedThemes = $this->getStoresByThemes(); - - $this->_assignedThemeCustomizations = array(); - $this->_unassignedThemeCustomizations = array(); - /** @var $theme Mage_Core_Model_Theme */ - foreach ($themeCustomizations as $theme) { - if (isset($assignedThemes[$theme->getId()])) { - $theme->setAssignedStores($assignedThemes[$theme->getId()]); - $this->_assignedThemeCustomizations[$theme->getId()] = $theme; - } else { - $this->_unassignedThemeCustomizations[$theme->getId()] = $theme; - } - } - return $this; - } - - /** - * Return theme customizations collection - * - * @return Mage_Core_Model_Resource_Theme_Collection - */ - protected function _getThemeCustomizations() - { - /** @var $collection Mage_Core_Model_Resource_Theme_Collection */ - $collection = $this->_themeFactory->create()->getCollection(); - $collection->addAreaFilter(Mage_Core_Model_App_Area::AREA_FRONTEND) - ->addFilter('theme_path', 'theme_path IS NULL', 'string'); - return $collection; - } - - /** - * Return stores grouped by assigned themes - * - * @return array - */ - public function getStoresByThemes() - { - $storesByThemes = array(); - $stores = $this->_app->getStores(); - /** @var $store Mage_Core_Model_Store */ - foreach ($stores as $store) { - $themeId = $this->_design->getConfigurationDesignTheme( - Mage_Core_Model_App_Area::AREA_FRONTEND, - array('store' => $store) - ); - if (!isset($storesByThemes[$themeId])) { - $storesByThemes[$themeId] = array(); - } - $storesByThemes[$themeId][] = $store; - } - - return $storesByThemes; - } -} diff --git a/app/code/core/Mage/Core/Model/Theme/Validator.php b/app/code/core/Mage/Core/Model/Theme/Validator.php deleted file mode 100644 index 1dd3234769f47..0000000000000 --- a/app/code/core/Mage/Core/Model/Theme/Validator.php +++ /dev/null @@ -1,170 +0,0 @@ - array('validator_name' => [validators], ...), ...) - * - * @var array - */ - protected $_dataValidators = array(); - - /** - * List of errors after validation process - * - * array('dataKey' => 'Error message') - * - * @var array - */ - protected $_errorMessages = array(); - - /** - * Initialize validators - */ - public function __construct() - { - $this->_setThemeValidators(); - } - - /** - * Set default theme validators - * - * @return Mage_Core_Model_Theme_Validator - */ - protected function _setThemeValidators() - { - $helper = Mage::helper('Mage_Core_Helper_Data'); - - $versionValidators = array( - array('name' => 'not_empty', 'class' => 'Zend_Validate_NotEmpty', 'break' => true, 'options' => array(), - 'message' => $helper->__('Field can\'t be empty')), - array('name' => 'available', 'class' => 'Zend_Validate_Regex', 'break' => true, - 'options' => array('pattern' => '/^(\d+\.\d+\.\d+\.\d+(\-[a-zA-Z0-9]+)?)$|^\*$/'), - 'message' => $helper->__('Theme version has not compatible format')) - ); - - $this->addDataValidators('theme_version', $versionValidators) - ->addDataValidators('magento_version_to', $versionValidators) - ->addDataValidators('magento_version_from', $versionValidators); - - return $this; - } - - /** - * Add validators - * - * @param string $dataKey - * @param array $validators - * @return Mage_Core_Model_Theme_Validator - */ - public function addDataValidators($dataKey, $validators) - { - if (!isset($this->_dataValidators[$dataKey])) { - $this->_dataValidators[$dataKey] = array(); - } - foreach ($validators as $validator) { - $this->_dataValidators[$dataKey][$validator['name']] = $validator; - } - return $this; - } - - /** - * Return error messages for items - * - * @param string|null $dataKey - * @return array - */ - public function getErrorMessages($dataKey = null) - { - if ($dataKey) { - return isset($this->_errorMessages[$dataKey]) ? $this->_errorMessages[$dataKey] : array(); - } - return $this->_errorMessages; - } - - /** - * Instantiate class validator - * - * @param array $validators - * @return Mage_Core_Model_Theme_Validator - */ - protected function _instantiateValidators(array &$validators) - { - foreach ($validators as &$validator) { - if (is_string($validator['class'])) { - $validator['class'] = new $validator['class']($validator['options']); - $validator['class']->setDisableTranslator(true); - } - } - return $this; - } - - /** - * Validate one data item - * - * @param array $validator - * @param string $dataKey - * @param mixed $dataValue - * @return bool - */ - protected function _validateDataItem($validator, $dataKey, $dataValue) - { - if ($validator['class'] instanceof Zend_Validate_NotEmpty && !$validator['class']->isValid($dataValue) - || !empty($dataValue) && !$validator['class']->isValid($dataValue) - ) { - $this->_errorMessages[$dataKey][] = $validator['message']; - if ($validator['break']) { - return false; - } - } - return true; - } - - /** - * Validate all data items - * - * @param Varien_Object $data - * @return bool - */ - public function validate(Varien_Object $data) - { - foreach ($this->_dataValidators as $dataKey => $validators) { - if (!isset($data[$dataKey]) || !$data->dataHasChangedFor($dataKey)) { - continue; - } - - $this->_instantiateValidators($validators); - foreach ($validators as $validator) { - if (!$this->_validateDataItem($validator, $dataKey, $data[$dataKey])) { - break; - } - } - } - return empty($this->_errorMessages); - } -} diff --git a/app/code/core/Mage/Core/Model/Translate.php b/app/code/core/Mage/Core/Model/Translate.php deleted file mode 100644 index 4ad94f5f4474d..0000000000000 --- a/app/code/core/Mage/Core/Model/Translate.php +++ /dev/null @@ -1,641 +0,0 @@ -_designPackage = $designPackage; - $this->_localeHierarchy = $loader->load(); - } - - /** - * Initialization translation data - * - * @param string $area - * @param bool $forceReload - * @return Mage_Core_Model_Translate - */ - public function init($area, $forceReload = false) - { - $this->setConfig(array(self::CONFIG_KEY_AREA => $area)); - - $this->_translateInline = Mage::getSingleton('Mage_Core_Model_Translate_Inline') - ->isAllowed($area == 'adminhtml' ? 'admin' : null); - - if (!$forceReload) { - if ($this->_canUseCache()) { - $this->_data = $this->_loadCache(); - if ($this->_data !== false) { - return $this; - } - } - Mage::app()->removeCache($this->getCacheId()); - } - - $this->_data = array(); - - foreach ($this->getModulesConfig() as $moduleName => $info) { - $info = $info->asArray(); - $this->_loadModuleTranslation($moduleName, $info['files'], $forceReload); - } - - $this->_loadThemeTranslation($forceReload); - $this->_loadDbTranslation($forceReload); - - if (!$forceReload && $this->_canUseCache()) { - $this->_saveCache(); - } - - return $this; - } - - /** - * Retrieve modules configuration by translation - * - * @return Mage_Core_Model_Config_Element - */ - public function getModulesConfig() - { - if (!Mage::getConfig()->getNode($this->getConfig(self::CONFIG_KEY_AREA) . '/translate/modules')) { - return array(); - } - - $config = Mage::getConfig()->getNode($this->getConfig(self::CONFIG_KEY_AREA) - . '/translate/modules')->children(); - if (!$config) { - return array(); - } - return $config; - } - - /** - * Initialize configuration - * - * @param array $config - * @return Mage_Core_Model_Translate - */ - public function setConfig($config) - { - $this->_config = $config; - if (!isset($this->_config[self::CONFIG_KEY_LOCALE])) { - $this->_config[self::CONFIG_KEY_LOCALE] = $this->getLocale(); - } - if (!isset($this->_config[self::CONFIG_KEY_STORE])) { - $this->_config[self::CONFIG_KEY_STORE] = Mage::app()->getStore()->getId(); - } - if (!isset($this->_config[self::CONFIG_KEY_DESIGN_THEME])) { - $this->_config[self::CONFIG_KEY_DESIGN_THEME] = $this->_designPackage->getDesignTheme()->getId(); - } - return $this; - } - - /** - * Retrieve config value by key - * - * @param string $key - * @return mixed - */ - public function getConfig($key) - { - if (isset($this->_config[$key])) { - return $this->_config[$key]; - } - return null; - } - - /** - * Load data from module translation files - * - * @param string $moduleName - * @param array $files - * @param boolean $forceReload - * @return Mage_Core_Model_Translate - */ - protected function _loadModuleTranslation($moduleName, $files, $forceReload = false) - { - $requiredLocaleList = $this->_composeRequiredLocaleList($this->getLocale()); - foreach ($files as $file) { - foreach ($requiredLocaleList as $locale) { - $moduleFilePath = $this->_getModuleFilePath($moduleName, $file, $locale); - $this->_addData($this->_getFileData($moduleFilePath), $moduleName, $forceReload); - } - } - return $this; - } - - /** - * Compose the list of locales which are required to translate text entity based on given locale - * - * @param string $locale - * @return array - */ - protected function _composeRequiredLocaleList($locale) - { - $requiredLocaleList = array($locale); - if (isset($this->_localeHierarchy[$locale])) { - $requiredLocaleList = array_merge($this->_localeHierarchy[$locale], $requiredLocaleList); - } - return $requiredLocaleList; - } - - /** - * Adding translation data - * - * @param array $data - * @param string $scope - * @param boolean $forceReload - * @return Mage_Core_Model_Translate - */ - protected function _addData($data, $scope, $forceReload = false) - { - foreach ($data as $key => $value) { - if ($key === $value) { - continue; - } - $key = $this->_prepareDataString($key); - $value = $this->_prepareDataString($value); - if ($scope && isset($this->_dataScope[$key]) && !$forceReload ) { - /** - * Checking previous value - */ - $scopeKey = $this->_dataScope[$key] . self::SCOPE_SEPARATOR . $key; - if (!isset($this->_data[$scopeKey])) { - if (isset($this->_data[$key])) { - $this->_data[$scopeKey] = $this->_data[$key]; - unset($this->_data[$key]); - } - } - $scopeKey = $scope . self::SCOPE_SEPARATOR . $key; - $this->_data[$scopeKey] = $value; - } else { - $this->_data[$key] = $value; - $this->_dataScope[$key]= $scope; - } - } - return $this; - } - - /** - * Prepare data string - * - * @param string $string - * @return string - */ - protected function _prepareDataString($string) - { - return str_replace('""', '"', $string); - } - - /** - * Load current theme translation - * - * @param boolean $forceReload - * @return Mage_Core_Model_Translate - */ - protected function _loadThemeTranslation($forceReload = false) - { - if (!$this->_config[self::CONFIG_KEY_DESIGN_THEME]) { - return $this; - } - - $requiredLocaleList = $this->_composeRequiredLocaleList($this->getLocale()); - foreach ($requiredLocaleList as $locale) { - $file = $this->_designPackage->getLocaleFileName('translate.csv', array('locale' => $locale)); - $this->_addData( - $this->_getFileData($file), - self::CONFIG_KEY_DESIGN_THEME . $this->_config[self::CONFIG_KEY_DESIGN_THEME], - $forceReload - ); - } - return $this; - } - - /** - * Loading current store translation from DB - * - * @param boolean $forceReload - * @return Mage_Core_Model_Translate - */ - protected function _loadDbTranslation($forceReload = false) - { - $requiredLocaleList = $this->_composeRequiredLocaleList($this->getLocale()); - foreach ($requiredLocaleList as $locale) { - $arr = $this->getResource()->getTranslationArray(null, $locale); - $this->_addData($arr, $this->getConfig(self::CONFIG_KEY_STORE), $forceReload); - } - return $this; - } - - /** - * Retrieve translation file for module - * - * @param string $module - * @param string $fileName - * @param string $locale - * @return string - */ - protected function _getModuleFilePath($module, $fileName, $locale) - { - $file = Mage::getModuleDir('locale', $module); - $file .= DS . $locale . DS . $fileName; - return $file; - } - - /** - * Retrieve data from file - * - * @param string $file - * @return array - */ - protected function _getFileData($file) - { - $data = array(); - if (file_exists($file)) { - $parser = new Varien_File_Csv(); - $parser->setDelimiter(self::CSV_SEPARATOR); - $data = $parser->getDataPairs($file); - } - return $data; - } - - /** - * Retrieve translation data - * - * @return array - */ - public function getData() - { - if (is_null($this->_data)) { - return array(); - } - return $this->_data; - } - - /** - * Retrieve locale - * - * @return string - */ - public function getLocale() - { - if (is_null($this->_locale)) { - $this->_locale = Mage::app()->getLocale()->getLocaleCode(); - } - return $this->_locale; - } - - /** - * Set locale - * - * @param string $locale - * @return Mage_Core_Model_Translate - */ - public function setLocale($locale) - { - $this->_locale = $locale; - return $this; - } - - /** - * Retrieve DB resource model - * - * @return Mage_Core_Model_Resource_Translate - */ - public function getResource() - { - return Mage::getResourceSingleton('Mage_Core_Model_Resource_Translate'); - } - - /** - * Retrieve translation object - * - * @return Zend_Translate_Adapter - */ - public function getTranslate() - { - if (is_null($this->_translate)) { - $this->_translate = new Zend_Translate('array', $this->getData(), $this->getLocale()); - } - return $this->_translate; - } - - /** - * Translate - * - * @param array $args - * @return string - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.NPathComplexity) - */ - public function translate($args) - { - $text = array_shift($args); - - if ($this->_isEmptyTranslateArg($text)) { - return ''; - } - - if ($text instanceof Mage_Core_Model_Translate_Expr) { - $code = $text->getCode(self::SCOPE_SEPARATOR); - $module = $text->getModule(); - $text = $text->getText(); - $translated = $this->_getTranslatedString($text, $code); - } else { - if (!empty($_REQUEST['theme'])) { - $module = self::CONFIG_KEY_DESIGN_THEME . $_REQUEST['theme']; - } else { - $module = self::CONFIG_KEY_DESIGN_THEME . $this->_config[self::CONFIG_KEY_DESIGN_THEME]; - } - $code = $module . self::SCOPE_SEPARATOR . $text; - $translated = $this->_getTranslatedString($text, $code); - } - - $result = @vsprintf($translated, $args); - if ($result === false) { - $result = $translated; - } - - if ($this->_translateInline && $this->getTranslateInline()) { - if (strpos($result, '{{{') === false - || strpos($result, '}}}') === false - || strpos($result, '}}{{') === false - ) { - $result = '{{{' . $result . '}}{{' . $translated . '}}{{' . $text . '}}{{' . $module . '}}}'; - } - } - - return $result; - } - - /** - * Check is empty translate argument - * - * @param mixed $text - * @return bool - */ - protected function _isEmptyTranslateArg($text) - { - if (is_string($text) && '' == $text - || is_null($text) - || is_bool($text) && false === $text - || is_object($text) && '' == $text->getText() - ) { - return true; - } - return false; - } - - /** - * Set Translate inline mode - * - * @param bool $flag - * @return Mage_Core_Model_Translate - */ - public function setTranslateInline($flag = null) - { - $this->_canUseInline = (bool)$flag; - return $this; - } - - /** - * Retrieve active translate mode - * - * @return bool - * @SuppressWarnings(PHPMD.BooleanGetMethodName) - */ - public function getTranslateInline() - { - return $this->_canUseInline; - } - - /** - * Retrieve cache identifier - * - * @return string - */ - public function getCacheId() - { - if (is_null($this->_cacheId)) { - $this->_cacheId = 'translate'; - if (isset($this->_config[self::CONFIG_KEY_LOCALE])) { - $this->_cacheId .= '_' . $this->_config[self::CONFIG_KEY_LOCALE]; - } - if (isset($this->_config[self::CONFIG_KEY_AREA])) { - $this->_cacheId .= '_' . $this->_config[self::CONFIG_KEY_AREA]; - } - if (isset($this->_config[self::CONFIG_KEY_STORE])) { - $this->_cacheId .= '_' . $this->_config[self::CONFIG_KEY_STORE]; - } - if (isset($this->_config[self::CONFIG_KEY_DESIGN_THEME])) { - $this->_cacheId .= '_' . $this->_config[self::CONFIG_KEY_DESIGN_THEME]; - } - } - return $this->_cacheId; - } - - /** - * Loading data cache - * - * @return array | false - */ - protected function _loadCache() - { - if (!$this->_canUseCache()) { - return false; - } - $data = Mage::app()->loadCache($this->getCacheId()); - $data = unserialize($data); - return $data; - } - - /** - * Saving data cache - * - * @return Mage_Core_Model_Translate - */ - protected function _saveCache() - { - if (!$this->_canUseCache()) { - return $this; - } - Mage::app()->saveCache(serialize($this->getData()), $this->getCacheId(), array(self::CACHE_TAG), false); - return $this; - } - - /** - * Check cache usage availability - * - * @return bool - */ - protected function _canUseCache() - { - return Mage::app()->useCache('translate'); - } - - /** - * Return translated string from text. - * - * @param string $text - * @param string $code - * @return string - */ - protected function _getTranslatedString($text, $code) - { - if (array_key_exists($code, $this->getData())) { - $translated = $this->_data[$code]; - } elseif (array_key_exists($text, $this->getData())) { - $translated = $this->_data[$text]; - } else { - $translated = $text; - } - return $translated; - } -} diff --git a/app/code/core/Mage/Core/Model/Url.php b/app/code/core/Mage/Core/Model/Url.php deleted file mode 100644 index bab614d0f4e7d..0000000000000 --- a/app/code/core/Mage/Core/Model/Url.php +++ /dev/null @@ -1,1222 +0,0 @@ -'value1', 'param2'=>'value2') - * - * - query: (?)'param1=value1¶m2=value2' - * - query_array: array('param1'=>'value1', 'param2'=>'value2') - * - fragment: (#)'fragment-anchor' - * - * URL structure: - * - * https://user:password@host:443/base_path/[base_script][storeview_path]route_name/controller_name/action_name/param1/value1?query_param=query_value#fragment - * \__________A___________/\____________________________________B_____________________________________/ - * \__________________C___________________/ \__________________D_________________/ \_____E_____/ - * \_____________F______________/ \___________________________G______________________/ - * \___________________________________________________H____________________________________________________/ - * - * - A: authority - * - B: path - * - C: absolute_base_url - * - D: action_path - * - E: route_params - * - F: host_url - * - G: route_path - * - H: route_url - * - * @category Mage - * @package Mage_Core - * @author Magento Core Team - */ -class Mage_Core_Model_Url extends Varien_Object -{ - /** - * Default controller name - */ - const DEFAULT_CONTROLLER_NAME = 'index'; - - /** - * Default action name - */ - const DEFAULT_ACTION_NAME = 'index'; - - /** - * Configuration paths - */ - const XML_PATH_UNSECURE_URL = 'web/unsecure/base_url'; - const XML_PATH_SECURE_URL = 'web/secure/base_url'; - const XML_PATH_SECURE_IN_ADMIN = 'default/web/secure/use_in_adminhtml'; - const XML_PATH_SECURE_IN_FRONT = 'web/secure/use_in_frontend'; - - /** - * Configuration data cache - * - * @var array - */ - static protected $_configDataCache; - - /** - * Encrypted session identifier - * - * @var string|null - */ - static protected $_encryptedSessionId; - - /** - * Reserved Route parameter keys - * - * @var array - */ - protected $_reservedRouteParams = array( - '_store', '_type', '_secure', '_forced_secure', '_use_rewrite', '_nosid', - '_absolute', '_current', '_direct', '_fragment', '_escape', '_query', - '_store_to_url' - ); - - /** - * Controller request object - * - * @var Zend_Controller_Request_Http - */ - protected $_request; - - /** - * Use Session ID for generate URL - * - * @var bool - */ - protected $_useSession; - - /** - * Initialize object - */ - protected function _construct() - { - $this->setStore(null); - } - - /** - * Initialize object data from retrieved url - * - * @param string $url - * @return Mage_Core_Model_Url - */ - public function parseUrl($url) - { - $data = parse_url($url); - $parts = array( - 'scheme' => 'setScheme', - 'host' => 'setHost', - 'port' => 'setPort', - 'user' => 'setUser', - 'pass' => 'setPassword', - 'path' => 'setPath', - 'query' => 'setQuery', - 'fragment' => 'setFragment'); - - foreach ($parts as $component => $method) { - if (isset($data[$component])) { - $this->$method($data[$component]); - } - } - return $this; - } - - /** - * Retrieve default controller name - * - * @return string - */ - public function getDefaultControllerName() - { - return self::DEFAULT_CONTROLLER_NAME; - } - - /** - * Set use_url_cache flag - * - * @param boolean $flag - * @return Mage_Core_Model_Url - */ - public function setUseUrlCache($flag) - { - $this->setData('use_url_cache', $flag); - return $this; - } - - /** - * Set use session rule - * - * @param bool $useSession - * @return Mage_Core_Model_Url - */ - public function setUseSession($useSession) - { - $this->_useSession = (bool) $useSession; - return $this; - } - - /** - * Set route front name - * - * @param string $name - * @return Mage_Core_Model_Url - */ - public function setRouteFrontName($name) - { - $this->setData('route_front_name', $name); - return $this; - } - - /** - * Retrieve use session rule - * - * @return bool - */ - public function getUseSession() - { - if (is_null($this->_useSession)) { - $this->_useSession = Mage::app()->getUseSessionInUrl(); - } - return $this->_useSession; - } - - /** - * Retrieve default action name - * - * @return string - */ - public function getDefaultActionName() - { - return self::DEFAULT_ACTION_NAME; - } - - /** - * Retrieve configuration data - * - * @param string $key - * @param string|null $prefix - * @return string - */ - public function getConfigData($key, $prefix = null) - { - if (is_null($prefix)) { - $prefix = 'web/' . ($this->isSecure() ? 'secure' : 'unsecure').'/'; - } - $path = $prefix . $key; - - $cacheId = $this->getStore()->getCode() . '/' . $path; - if (!isset(self::$_configDataCache[$cacheId])) { - $data = $this->getStore()->getConfig($path); - self::$_configDataCache[$cacheId] = $data; - } - - return self::$_configDataCache[$cacheId]; - } - - /** - * Set request - * - * @param Zend_Controller_Request_Http $request - * @return Mage_Core_Model_Url - */ - public function setRequest(Zend_Controller_Request_Http $request) - { - $this->_request = $request; - return $this; - } - - /** - * Zend request object - * - * @return Mage_Core_Controller_Request_Http - */ - public function getRequest() - { - if (!$this->_request) { - $this->_request = Mage::app()->getRequest(); - } - return $this->_request; - } - - /** - * Retrieve URL type - * - * @return string - */ - public function getType() - { - if (!$this->hasData('type')) { - $this->setData('type', Mage_Core_Model_Store::URL_TYPE_LINK); - } - return $this->_getData('type'); - } - - /** - * Retrieve is secure mode URL - * - * @return bool - */ - public function isSecure() - { - if ($this->hasData('secure_is_forced')) { - return (bool)$this->getData('secure'); - } - - $store = $this->getStore(); - - if ($store->isAdmin() && !$store->isAdminUrlSecure()) { - return false; - } - if (!$store->isAdmin() && !$store->isFrontUrlSecure()) { - return false; - } - - if (!$this->hasData('secure')) { - if ($this->getType() == Mage_Core_Model_Store::URL_TYPE_LINK && !$store->isAdmin()) { - $pathSecure = Mage::getConfig()->shouldUrlBeSecure('/' . $this->getActionPath()); - $this->setData('secure', $pathSecure); - } else { - $this->setData('secure', true); - } - } - return $this->getData('secure'); - } - - /** - * Set store entity - * - * @param mixed $data - * @return Mage_Core_Model_Url - */ - public function setStore($params) - { - $this->setData('store', Mage::app()->getStore($params)); - return $this; - } - - /** - * Get current store for the url instance - * - * @return Mage_Core_Model_Store - */ - public function getStore() - { - if (!$this->hasData('store')) { - $this->setStore(null); - } - return $this->_getData('store'); - } - - /** - * Retrieve Base URL - * - * @param array $params - * @return string - */ - public function getBaseUrl($params = array()) - { - $currentType = $this->getType(); - if (isset($params['_store'])) { - $this->setStore($params['_store']); - } - if (isset($params['_type'])) { - $this->setType($params['_type']); - } - if (isset($params['_secure'])) { - $this->setSecure($params['_secure']); - } - - /** - * Add availability support urls without store code - */ - if ($this->getType() == Mage_Core_Model_Store::URL_TYPE_LINK - && $this->getRequest()->isDirectAccessFrontendName($this->getRouteFrontName())) { - $this->setType(Mage_Core_Model_Store::URL_TYPE_DIRECT_LINK); - } - - $result = $this->getStore()->getBaseUrl($this->getType(), $this->isSecure()); - $this->setType($currentType); - return $result; - } - - /** - * Set Route Parameters - * - * @param array $data - * @return Mage_Core_Model_Url - */ - public function setRoutePath($data) - { - if ($this->_getData('route_path') == $data) { - return $this; - } - - $this->unsetData('route_path'); - $a = explode('/', $data); - - $route = array_shift($a); - if ('*' === $route) { - $route = $this->getRequest()->getRequestedRouteName(); - } - $this->setRouteName($route); - - $controller = ''; - if (!empty($a)) { - $controller = array_shift($a); - if ('*' === $controller) { - $controller = $this->getRequest()->getRequestedControllerName(); - } - } - $this->setControllerName($controller); - - $action = ''; - if (!empty($a)) { - $action = array_shift($a); - if ('*' === $action) { - $action = $this->getRequest()->getRequestedActionName(); - } - } - $this->setActionName($action); - - if (!empty($a)) { - while (!empty($a)) { - $key = array_shift($a); - if (!empty($a)) { - $value = array_shift($a); - $this->setRouteParam($key, $value); - } - } - } - - return $this; - } - - /** - * Retrieve action path - * - * @return string - */ - public function getActionPath() - { - if (!$this->getRouteName()) { - return ''; - } - - $hasParams = (bool) $this->getRouteParams(); - $path = $this->getRouteFrontName() . '/'; - - if ($this->getControllerName()) { - $path .= $this->getControllerName() . '/'; - } elseif ($hasParams) { - $path .= $this->getDefaultControllerName() . '/'; - } - if ($this->getActionName()) { - $path .= $this->getActionName() . '/'; - } elseif ($hasParams) { - $path .= $this->getDefaultActionName() . '/'; - } - - return $path; - } - - /** - * Retrieve route path - * - * @param array $routeParams - * @return string - */ - public function getRoutePath($routeParams = array()) - { - if (!$this->hasData('route_path')) { - $routePath = $this->getRequest()->getAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS); - if (!empty($routeParams['_use_rewrite']) && ($routePath !== null)) { - $this->setData('route_path', $routePath); - return $routePath; - } - $routePath = $this->getActionPath(); - if ($this->getRouteParams()) { - foreach ($this->getRouteParams() as $key=>$value) { - if (is_null($value) || false === $value || '' === $value || !is_scalar($value)) { - continue; - } - $routePath .= $key . '/' . $value . '/'; - } - } - if ($routePath != '' && substr($routePath, -1, 1) !== '/') { - $routePath .= '/'; - } - $this->setData('route_path', $routePath); - } - return $this->_getData('route_path'); - } - - /** - * Set route name - * - * @param string $data - * @return Mage_Core_Model_Url - */ - public function setRouteName($data) - { - if ($this->_getData('route_name') == $data) { - return $this; - } - $this->unsetData('route_front_name') - ->unsetData('route_path') - ->unsetData('controller_name') - ->unsetData('action_name') - ->unsetData('secure'); - return $this->setData('route_name', $data); - } - - /** - * Retrieve route front name - * - * @return string - */ - public function getRouteFrontName() - { - if (!$this->hasData('route_front_name')) { - $routeName = $this->getRouteName(); - $route = Mage::app()->getFrontController()->getRouterByRoute($routeName); - $frontName = $route->getFrontNameByRoute($routeName); - - $this->setRouteFrontName($frontName); - } - - return $this->_getData('route_front_name'); - } - - /** - * Retrieve route name - * - * @param mixed $default - * @return string|null - */ - public function getRouteName($default = null) - { - return $this->_getData('route_name') ? $this->_getData('route_name') : $default; - } - - /** - * Set Controller Name - * - * Reset action name and route path if has change - * - * @param string $data - * @return Mage_Core_Model_Url - */ - public function setControllerName($data) - { - if ($this->_getData('controller_name') == $data) { - return $this; - } - $this->unsetData('route_path')->unsetData('action_name')->unsetData('secure'); - return $this->setData('controller_name', $data); - } - - /** - * Retrieve controller name - * - * @param mixed $default - * @return string|null - */ - public function getControllerName($default = null) - { - return $this->_getData('controller_name') ? $this->_getData('controller_name') : null; - } - - /** - * Set Action name - * Reseted route path if action name has change - * - * @param string $data - * @return Mage_Core_Model_Url - */ - public function setActionName($data) - { - if ($this->_getData('action_name') == $data) { - return $this; - } - $this->unsetData('route_path'); - return $this->setData('action_name', $data)->unsetData('secure'); - } - - /** - * Retrieve action name - * - * @param mixed $default - * @return string|null - */ - public function getActionName($default = null) - { - return $this->_getData('action_name') ? $this->_getData('action_name') : $default; - } - - /** - * Set route params - * - * @param array $data - * @param boolean $unsetOldParams - * @return Mage_Core_Model_Url - */ - public function setRouteParams(array $data, $unsetOldParams = true) - { - if (isset($data['_type'])) { - $this->setType($data['_type']); - unset($data['_type']); - } - - if (isset($data['_store'])) { - $this->setStore($data['_store']); - unset($data['_store']); - } - - if (isset($data['_forced_secure'])) { - $this->setSecure((bool)$data['_forced_secure']); - $this->setSecureIsForced(true); - unset($data['_forced_secure']); - } elseif (isset($data['_secure'])) { - $this->setSecure((bool)$data['_secure']); - unset($data['_secure']); - } - - if (isset($data['_absolute'])) { - unset($data['_absolute']); - } - - if ($unsetOldParams) { - $this->unsetData('route_params'); - } - - $this->setUseUrlCache(true); - if (isset($data['_current'])) { - if (is_array($data['_current'])) { - foreach ($data['_current'] as $key) { - if (array_key_exists($key, $data) || !$this->getRequest()->getUserParam($key)) { - continue; - } - $data[$key] = $this->getRequest()->getUserParam($key); - } - } elseif ($data['_current']) { - foreach ($this->getRequest()->getUserParams() as $key => $value) { - if (array_key_exists($key, $data) || $this->getRouteParam($key)) { - continue; - } - $data[$key] = $value; - } - foreach ($this->getRequest()->getQuery() as $key => $value) { - $this->setQueryParam($key, $value); - } - $this->setUseUrlCache(false); - } - unset($data['_current']); - } - - if (isset($data['_use_rewrite'])) { - unset($data['_use_rewrite']); - } - - if (isset($data['_store_to_url']) && (bool)$data['_store_to_url'] === true) { - if (!Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_STORE_IN_URL, $this->getStore()) - && !Mage::app()->hasSingleStore() - ) { - $this->setQueryParam('___store', $this->getStore()->getCode()); - } - } - unset($data['_store_to_url']); - - foreach ($data as $k => $v) { - $this->setRouteParam($k, $v); - } - - return $this; - } - - /** - * Retrieve route params - * - * @return array - */ - public function getRouteParams() - { - return $this->_getData('route_params'); - } - - /** - * Set route param - * - * @param string $key - * @param mixed $data - * @return Mage_Core_Model_Url - */ - public function setRouteParam($key, $data) - { - $params = $this->_getData('route_params'); - if (isset($params[$key]) && $params[$key] == $data) { - return $this; - } - $params[$key] = $data; - $this->unsetData('route_path'); - return $this->setData('route_params', $params); - } - - /** - * Retrieve route params - * - * @param string $key - * @return mixed - */ - public function getRouteParam($key) - { - return $this->getData('route_params', $key); - } - - /** - * Retrieve route URL - * - * @param string $routePath - * @param array $routeParams - * @return string - */ - public function getRouteUrl($routePath = null, $routeParams = null) - { - if (filter_var($routePath, FILTER_VALIDATE_URL)) { - return $routePath; - } - - $this->unsetData('route_params'); - - if (isset($routeParams['_direct'])) { - if (is_array($routeParams)) { - $this->setRouteParams($routeParams, false); - } - return $this->getBaseUrl() . $routeParams['_direct']; - } - - $this->setRoutePath($routePath); - if (is_array($routeParams)) { - $this->setRouteParams($routeParams, false); - } - - $url = $this->getBaseUrl() . $this->getRoutePath($routeParams); - return $url; - } - - /** - * If the host was switched but session cookie won't recognize it - add session id to query - * - * @return Mage_Core_Model_Url - */ - public function checkCookieDomains() - { - $hostArr = explode(':', $this->getRequest()->getServer('HTTP_HOST')); - if ($hostArr[0] !== $this->getHost()) { - $session = Mage::getSingleton('Mage_Core_Model_Session'); - if (!$session->isValidForHost($this->getHost())) { - if (!self::$_encryptedSessionId) { - $helper = Mage::helper('Mage_Core_Helper_Data'); - if (!$helper) { - return $this; - } - self::$_encryptedSessionId = $session->getEncryptedSessionId(); - } - $this->setQueryParam($session->getSessionIdQueryParam(), self::$_encryptedSessionId); - } - } - return $this; - } - - /** - * Add session param - * - * @return Mage_Core_Model_Url - */ - public function addSessionParam() - { - $session = Mage::getSingleton('Mage_Core_Model_Session'); - - if (!self::$_encryptedSessionId) { - $helper = Mage::helper('Mage_Core_Helper_Data'); - if (!$helper) { - return $this; - } - self::$_encryptedSessionId = $session->getEncryptedSessionId(); - } - $this->setQueryParam($session->getSessionIdQueryParam(), self::$_encryptedSessionId); - return $this; - } - - /** - * Set URL query param(s) - * - * @param mixed $data - * @return Mage_Core_Model_Url - */ - public function setQuery($data) - { - if ($this->_getData('query') == $data) { - return $this; - } - $this->unsetData('query_params'); - return $this->setData('query', $data); - } - - /** - * Get query params part of url - * - * @param bool $escape "&" escape flag - * @return string - */ - public function getQuery($escape = false) - { - if (!$this->hasData('query')) { - $query = ''; - $params = $this->getQueryParams(); - if (is_array($params)) { - ksort($params); - $query = http_build_query($params, '', $escape ? '&' : '&'); - } - $this->setData('query', $query); - } - return $this->_getData('query'); - } - - /** - * Set query Params as array - * - * @param array $data - * @return Mage_Core_Model_Url - */ - public function setQueryParams(array $data) - { - $this->unsetData('query'); - - if ($this->_getData('query_params') == $data) { - return $this; - } - - $params = $this->_getData('query_params'); - if (!is_array($params)) { - $params = array(); - } - foreach ($data as $param => $value) { - $params[$param] = $value; - } - $this->setData('query_params', $params); - - return $this; - } - - /** - * Purge Query params array - * - * @return Mage_Core_Model_Url - */ - public function purgeQueryParams() - { - $this->setData('query_params', array()); - return $this; - } - - /** - * Return Query Params - * - * @return array - */ - public function getQueryParams() - { - if (!$this->hasData('query_params')) { - $params = array(); - if ($this->_getData('query')) { - foreach (explode('&', $this->_getData('query')) as $param) { - $paramArr = explode('=', $param); - $params[$paramArr[0]] = urldecode($paramArr[1]); - } - } - $this->setData('query_params', $params); - } - return $this->_getData('query_params'); - } - - /** - * Set query param - * - * @param string $key - * @param mixed $data - * @return Mage_Core_Model_Url - */ - public function setQueryParam($key, $data) - { - $params = $this->getQueryParams(); - if (isset($params[$key]) && $params[$key] == $data) { - return $this; - } - $params[$key] = $data; - $this->unsetData('query'); - return $this->setData('query_params', $params); - } - - /** - * Retrieve query param - * - * @param string $key - * @return mixed - */ - public function getQueryParam($key) - { - if (!$this->hasData('query_params')) { - $this->getQueryParams(); - } - return $this->getData('query_params', $key); - } - - /** - * Set fragment to URL - * - * @param string $data - * @return Mage_Core_Model_Url - */ - public function setFragment($data) - { - return $this->setData('fragment', $data); - } - - /** - * Retrieve URL fragment - * - * @return string|null - */ - public function getFragment() - { - return $this->_getData('fragment'); - } - - /** - * Build url by requested path and parameters - * - * @param string|null $routePath - * @param array|null $routeParams - * @return string - */ - public function getUrl($routePath = null, $routeParams = null) - { - if (filter_var($routePath, FILTER_VALIDATE_URL)) { - return $routePath; - } - - $escapeQuery = false; - - /** - * All system params should be unset before we call getRouteUrl - * this method has condition for adding default controller and action names - * in case when we have params - */ - $fragment = null; - if (isset($routeParams['_fragment'])) { - $fragment = $routeParams['_fragment']; - unset($routeParams['_fragment']); - } - - if (isset($routeParams['_escape'])) { - $escapeQuery = $routeParams['_escape']; - unset($routeParams['_escape']); - } - - $query = null; - if (isset($routeParams['_query'])) { - $this->purgeQueryParams(); - $query = $routeParams['_query']; - unset($routeParams['_query']); - } - - $noSid = null; - if (isset($routeParams['_nosid'])) { - $noSid = (bool)$routeParams['_nosid']; - unset($routeParams['_nosid']); - } - $url = $this->getRouteUrl($routePath, $routeParams); - /** - * Apply query params, need call after getRouteUrl for rewrite _current values - */ - if ($query !== null) { - if (is_string($query)) { - $this->setQuery($query); - } elseif (is_array($query)) { - $this->setQueryParams($query, !empty($routeParams['_current'])); - } - if ($query === false) { - $this->setQueryParams(array()); - } - } - - if ($noSid !== true) { - $this->_prepareSessionUrl($url); - } - - $query = $this->getQuery($escapeQuery); - if ($query) { - $mark = (strpos($url, '?') === false) ? '?' : ($escapeQuery ? '&' : '&'); - $url .= $mark . $query; - $this->unsetData('query'); - $this->unsetData('query_params'); - } - - if (!is_null($fragment)) { - $url .= '#' . $fragment; - } - - return $this->escape($url); - } - - /** - * Check and add session id to URL - * - * @param string $url - * - * @return Mage_Core_Model_Url - */ - protected function _prepareSessionUrl($url) - { - return $this->_prepareSessionUrlWithParams($url, array()); - } - - /** - * Check and add session id to URL, session is obtained with parameters - * - * @param string $url - * @param array $params - * - * @return Mage_Core_Model_Url - */ - protected function _prepareSessionUrlWithParams($url, array $params) - { - if (!$this->getUseSession()) { - return $this; - } - /** @var $session Mage_Core_Model_Session */ - $session = Mage::getSingleton('Mage_Core_Model_Session', array('data' => $params)); - - $sessionId = $session->getSessionIdForHost($url); - if (Mage::app()->getUseSessionVar() && !$sessionId) { - $this->setQueryParam('___SID', $this->isSecure() ? 'S' : 'U'); // Secure/Unsecure - } else if ($sessionId) { - $this->setQueryParam($session->getSessionIdQueryParam(), $sessionId); - } - return $this; - } - - /** - * Rebuild URL to handle the case when session ID was changed - * - * @param string $url - * @return string - */ - public function getRebuiltUrl($url) - { - $this->parseUrl($url); - $port = $this->getPort(); - if ($port) { - $port = ':' . $port; - } else { - $port = ''; - } - $url = $this->getScheme() . '://' . $this->getHost() . $port . $this->getPath(); - - $this->_prepareSessionUrl($url); - - $query = $this->getQuery(); - if ($query) { - $url .= '?' . $query; - } - - $fragment = $this->getFragment(); - if ($fragment) { - $url .= '#' . $fragment; - } - - return $this->escape($url); - } - - /** - * Escape (enclosure) URL string - * - * @param string $value - * @return string - */ - public function escape($value) - { - $value = str_replace('"', '%22', $value); - $value = str_replace("'", '%27', $value); - $value = str_replace('>', '%3E', $value); - $value = str_replace('<', '%3C', $value); - return $value; - } - - /** - * Build url by direct url and parameters - * - * @param string $url - * @param array $params - * @return string - */ - public function getDirectUrl($url, $params = array()) - { - $params['_direct'] = $url; - return $this->getUrl('', $params); - } - - /** - * Replace Session ID value in URL - * - * @param string $html - * @return string - */ - public function sessionUrlVar($html) - { - return preg_replace_callback('#(\?|&|&)___SID=([SU])(&|&)?#', - array($this, "sessionVarCallback"), $html); - } - - /** - * Check and return use SID for URL - * - * @param bool $secure - * @return bool - */ - public function useSessionIdForUrl($secure = false) - { - $key = 'use_session_id_for_url_' . (int) $secure; - if (is_null($this->getData($key))) { - $httpHost = Mage::app()->getFrontController()->getRequest()->getHttpHost(); - $urlHost = parse_url($this->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, $secure), - PHP_URL_HOST); - - if ($httpHost != $urlHost) { - $this->setData($key, true); - } else { - $this->setData($key, false); - } - } - return $this->getData($key); - } - - /** - * Callback function for session replace - * - * @param array $match - * @return string - */ - public function sessionVarCallback($match) - { - if ($this->useSessionIdForUrl($match[2] == 'S' ? true : false)) { - $session = Mage::getSingleton('Mage_Core_Model_Session'); - /* @var $session Mage_Core_Model_Session */ - return $match[1] - . $session->getSessionIdQueryParam() - . '=' . $session->getEncryptedSessionId() - . (isset($match[3]) ? $match[3] : ''); - } else { - if ($match[1] == '?' && isset($match[3])) { - return '?'; - } elseif ($match[1] == '?' && !isset($match[3])) { - return ''; - } elseif (($match[1] == '&' || $match[1] == '&') && !isset($match[3])) { - return ''; - } elseif (($match[1] == '&' || $match[1] == '&') && isset($match[3])) { - return $match[3]; - } - } - return ''; - } - - /** - * Check if users originated URL is one of the domain URLs assigned to stores - * - * @return boolean - */ - public function isOwnOriginUrl() - { - $storeDomains = array(); - $referer = parse_url(Mage::app()->getRequest()->getServer('HTTP_REFERER'), PHP_URL_HOST); - foreach (Mage::app()->getStores() as $store) { - $storeDomains[] = parse_url($store->getBaseUrl(), PHP_URL_HOST); - $storeDomains[] = parse_url($store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true), PHP_URL_HOST); - } - $storeDomains = array_unique($storeDomains); - if (empty($referer) || in_array($referer, $storeDomains)) { - return true; - } - return false; - } - - /** - * Return frontend redirect URL with SID and other session parameters if any - * - * @param string $url - * - * @return string - */ - public function getRedirectUrl($url) - { - $this->_prepareSessionUrlWithParams($url, array( - 'name' => Mage_Core_Controller_Front_Action::SESSION_NAMESPACE - )); - - $query = $this->getQuery(false); - if ($query) { - $url .= (strpos($url, '?') === false ? '?' : '&') . $query; - } - - return $url; - } -} diff --git a/app/code/core/Mage/Core/Model/Validator/Factory.php b/app/code/core/Mage/Core/Model/Validator/Factory.php deleted file mode 100644 index 7063a3116d1fd..0000000000000 --- a/app/code/core/Mage/Core/Model/Validator/Factory.php +++ /dev/null @@ -1,123 +0,0 @@ -_objectManager = $objectManager; - $this->_translator = $translator; - - $this->_configFiles = $moduleReader->getModuleConfigurationFiles('validation.xml'); - $this->_initializeDefaultTranslator(); - } - - /** - * Create and set default translator to Magento_Validator_ValidatorAbstract. - */ - protected function _initializeDefaultTranslator() - { - $translateAdapter = $this->_translator; - $objectManager = $this->_objectManager; - // Pass translations to Mage_Core_Model_Translate from validators - $translatorCallback = function () use ($translateAdapter, $objectManager) { - /** @var Mage_Core_Model_Translate $translateAdapter */ - $args = func_get_args(); - $expr = $objectManager->create('Mage_Core_Model_Translate_Expr'); - $expr->setText($args[0]); - array_unshift($args, $expr); - return $translateAdapter->translate($args); - }; - /** @var Magento_Translate_Adapter $translator */ - $translator = $this->_objectManager->create('Magento_Translate_Adapter'); - $translator->setOptions(array('translator' => $translatorCallback)); - Magento_Validator_ValidatorAbstract::setDefaultTranslator($translator); - } - - /** - * Get validator config object. - * - * Will instantiate Magento_Validator_Config - * - * @return Magento_Validator_Config - */ - public function getValidatorConfig() - { - return $this->_objectManager->get('Magento_Validator_Config', array('configFiles' => $this->_configFiles)); - } - - /** - * Create validator builder instance based on entity and group. - * - * @param string $entityName - * @param string $groupName - * @param array|null $builderConfig - * @return Magento_Validator_Builder - */ - public function createValidatorBuilder($entityName, $groupName, array $builderConfig = null) - { - return $this->getValidatorConfig()->createValidatorBuilder($entityName, $groupName, $builderConfig); - } - - /** - * Create validator based on entity and group. - * - * @param string $entityName - * @param string $groupName - * @param array|null $builderConfig - * @return Magento_Validator - */ - public function createValidator($entityName, $groupName, array $builderConfig = null) - { - return $this->getValidatorConfig()->createValidator($entityName, $groupName, $builderConfig); - } -} diff --git a/app/code/core/Mage/Core/etc/config.xml b/app/code/core/Mage/Core/etc/config.xml deleted file mode 100644 index d4b677579d972..0000000000000 --- a/app/code/core/Mage/Core/etc/config.xml +++ /dev/null @@ -1,415 +0,0 @@ - - - - - - 1.6.0.10 - true - core - - - - - - Mage_Core_Model_Encryption - - - - - - - - System(config.xml, local.xml) and modules configuration files(config.xml). - CONFIG - - - - Layout building instructions. - LAYOUT_GENERAL_CACHE_TAG - - - - Page blocks HTML. - BLOCK_HTML - - - - Translation files. - TRANSLATE - - - - Collection data files. - COLLECTION_DATA - - - - - - 1 - - - - - - Shockwave Flash - - - - - - - - - - 0 - - - 1 - - - - app/etc/aliases_to_classes_map.json - - - - - - Mage_Core_Model_Observer - themeRegistration - - - - - - - Mage_Core_Model_Session - - - 0 - - - - Mage_Core_Model_Config_Proxy - - - - 0 - - - - - - - default/demo - - - - - standard - - Mage_Core - core - - - - - - - - Mage_Core.csv - - - - - - - - layout.xml - - - - - - - - - - Mage_Core.csv - - - - - - - - - Mage_Core_Model_Variable_Observer - prepareWysiwygPluginConfig - - - - - - - Mage_Core_Model_Observer - addSynchronizeNotification - - - - - - - Mage_Core_Model_Observer - addSynchronizeNotification - - - - - - - default/backend - - - - - Mage_Backend_Model_Url - - - - - - - - - Mage_Core.csv - - - - - - - default/basic - - - - - - - 1 - 5 - - - - - - - - 0 - - - 0 - 0 - - - - - - 0 - system.log - exception.log - - - 0 - - - - - 0 - localhost - 25 - - - 0 - default_setup - 3600 - - css - css_secure - js - theme - - - - - - custom1@example.com - Custom 1 - - - custom2@example.com - Custom 2 - - - owner@example.com - Owner - - - sales@example.com - Sales - - - support@example.com - CustomerSupport - - - - - - frontend - Mage_Core_Controller_Varien_Router_Base - Mage_Core_Controller_Varien_Action - - - - 0 - 1 - - - 0 - - - {{base_url}} - {{unsecure_base_url}} - {{unsecure_base_url}} - - - {{unsecure_base_url}} - {{secure_base_url}} - {{secure_base_url}} - 0 - 0 - SSL_OFFLOADED - - - 3600 - 1 - 0 - 31536000 - - - 0 - 0 - 0 - 0 - 1 - - - 1 - 1 - - - - - dashboard - - - 0 - - - - 1 - - - - - AT,BE,BG,CY,CZ,DK,EE,FI,FR,DE,GR,HU,IE,IT,LV,LT,LU,MT,NL,PL,PT,RO,SK,SI,ES,SE,GB - - - 0 - 0,6 - - - - php - htaccess - jsp - pl - py - asp - sh - cgi - htm - html - phtml - shtml - - - - /app/*/* - - - - - 0 - - - - - GD2 - - - - - - - - - frontend - Mage_Core_Controller_Varien_Router_Base - Mage_Core_Controller_Varien_Action - - - - - - - - - - 30 2 * * * - - - Mage_Core_Model_Observer::cleanCache - - - - - diff --git a/app/code/core/Mage/Core/view/adminhtml/prototype/magento.css b/app/code/core/Mage/Core/view/adminhtml/prototype/magento.css deleted file mode 100644 index 3a56677fbb66d..0000000000000 --- a/app/code/core/Mage/Core/view/adminhtml/prototype/magento.css +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Core - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ - -.dialog { border:1px solid #555; } -.dialog .bot { display:none !important; } -.overlay_magento { background-color:#000; filter:alpha(opacity=60); -moz-opacity:.6; opacity:.6; -webkit-opacity:.6; } -.top.table_window { border-bottom:1px solid #e6e6e6; background:#6a838b url(magento/top_bg.gif) 0 100% repeat-x; } - -.magento_nw { width:6px; height:28px; } -.magento_n { height:28px; } -.magento_ne { width:6px; height:28px; } - -.magento_w { width:6px; } -.magento_e { width:6px; } -.magento_w, -.magento_e, -.magento_content { background: #fafafa url(magento/content_bg.gif) 0 0 repeat-x; } - -.magento_sw { background:#deebf0; width:5px; height:3px; } -.magento_s { background:#deebf0; height:3px; } -.magento_se, - -.magento_sizer { background:#deebf0; width:5px; height:3px; } -.magento_sizer { cursor:se-resize; } - -.magento_close { width:16px; height:16px; background:url(magento/window_close.png) no-repeat 0 0; position:absolute; top:5px; right:7px; cursor:pointer; z-index:1000; } - -.magento_title { float:left; width:100%; font:bold 12px/28px Arial, Helvetica, sans-serif; color:#fff; text-align:left; } - -.magento_content { overflow:auto; font-size:12px; } -.magento_content, -.magento_content label { color:#333; font-family:Arial, sans-serif; } - -.magento_buttons { padding:10px; text-align:right; } -.magento_buttons input.button { border-width:1px; border-style:solid; border-color:#ed6502 #a04300 #a04300 #ed6502; background:#ffac47 url(magento/btn_bg.gif) 0 100% repeat-x; padding:0 7px 1px 7px; font:bold 12px/18px Arial, Helvetica, sans-serif; color:#fff; cursor:pointer; text-align:center; white-space:nowrap; } -.magento_buttons button.button span span span { display:inline; background:none; padding:0; height:auto; } - -/* FOR IE */ -* html .magento_close { background-image:none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/magento/window_close.png", sizingMethod="crop"); } - - -.dialog.ui-dialog, .ui-dialog .ui-dialog-titlebar, .ui-dialog .ui-dialog-buttonset button.button { -webkit-border-radius: 0px; border-radius: 0px; } -.dialog.ui-dialog { border:1px solid #555; display: none; padding: 0; } -.ui-widget-overlay { background:#000; filter:alpha(opacity=60); -moz-opacity:.6; opacity:.6; -webkit-opacity:.6; position: absolute; left:0px; top:0px; } -.ui-dialog .ui-dialog-titlebar { border-bottom:1px solid #e6e6e6; background:#6a838b url(magento/top_bg.gif) 0 100% repeat-x; height:28px; border: none; } -.ui-dialog .ui-dialog-titlebar span { margin: 0px; } -.ui-dialog .ui-dialog-title { float:left; width:100%; font:bold 12px/28px Arial, Helvetica, sans-serif; color:#fff; text-align:left; cursor: move; } -.ui-dialog .ui-dialog-content, .ui-dialog .ui-dialog-titlebar, .ui-dialog .ui-dialog-buttonset { padding: 0 6px; } -.ui-dialog .ui-icon { text-indent: -99999px; } -.ui-dialog .ui-dialog-titlebar-close { width:16px; height:16px; background:url(magento/window_close.png) no-repeat 0 0; position:absolute; top:5px; right:7px; cursor:pointer; z-index:1000; margin: 0px; padding: 0; } -.ui-dialog .ui-dialog-titlebar-close .ui-icon { display: none; } -.ui-dialog .ui-dialog-titlebar-close.ui-state-hover { border: none; } -.ui-dialog .ui-dialog-content form { display: block; overflow: hidden; } -.ui-dialog .ui-dialog-content { background: #fafafa url(magento/content_bg.gif) 0 0 repeat-x; overflow: auto; } -.ui-dialog .ui-dialog-buttonpane { background: #fafafa; margin: 0; padding: 0; border: none;} -.ui-dialog .ui-dialog-buttonset { padding:10px; text-align:right; } -.ui-dialog .ui-dialog-buttonset input.button { border-width:1px; border-style:solid; border-color:#ed6502 #a04300 #a04300 #ed6502; background:#ffac47 url(magento/btn_bg.gif) 0 100% repeat-x; padding:0 7px 1px 7px; font:bold 12px/18px Arial, Helvetica, sans-serif; color:#fff; cursor:pointer; text-align:center; white-space:nowrap; margin-left: 5px; } -.ui-dialog .ui-dialog-buttonset button.button { margin-left: 5px; background: #FFAC47; border-color: #ED6502 #A04300 #A04300 #ED6502; border-style: solid; border-width: 1px; color: #FFFFFF; cursor: pointer; font: bold 12px arial,helvetica,sans-serif; padding: 0; } -.ui-dialog .ui-dialog-buttonset button.button span { padding: 0 7px 1px; text-align: center !important; white-space: nowrap; display: block; background: transparent; height: auto; color:#ffffff; } -.ui-dialog .ui-dialog-buttonset button.button span span span { display:inline; background:none; padding:0; height:auto; } - -.ui-resizable { position: relative;} -.ui-resizable-handle { position: absolute;font-size: 0.1px; display: block; } -.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; } -.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; } -.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: 0px; left: 0; } -.ui-resizable-e { cursor: e-resize; width: 7px; right: 0px; top: 0; height: 100%; } -.ui-resizable-w { cursor: w-resize; width: 7px; left: -7px; top: 0; height: 100%; } -.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; } -.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: 0px; } -.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; } -.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: 0px; top: -5px;} diff --git a/app/code/core/Mage/Cron/etc/config.xml b/app/code/core/Mage/Cron/etc/config.xml deleted file mode 100644 index 802d50f6f1ab9..0000000000000 --- a/app/code/core/Mage/Cron/etc/config.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - Mage_Cron - - - - - - - - - - Mage_Cron_Model_Observer - dispatch - - - - - - - - - 15 - 20 - 15 - 10 - 60 - 600 - - - - - - - - - Mage_Cron.csv - - - - - - diff --git a/app/code/core/Mage/CurrencySymbol/etc/adminhtml/acl.xml b/app/code/core/Mage/CurrencySymbol/etc/adminhtml/acl.xml deleted file mode 100644 index 5cc952605ad44..0000000000000 --- a/app/code/core/Mage/CurrencySymbol/etc/adminhtml/acl.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/CurrencySymbol/etc/adminhtml/menu.xml b/app/code/core/Mage/CurrencySymbol/etc/adminhtml/menu.xml deleted file mode 100644 index 55368694d4f14..0000000000000 --- a/app/code/core/Mage/CurrencySymbol/etc/adminhtml/menu.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - diff --git a/app/code/core/Mage/CurrencySymbol/etc/config.xml b/app/code/core/Mage/CurrencySymbol/etc/config.xml deleted file mode 100644 index 0a5f11598e4e1..0000000000000 --- a/app/code/core/Mage/CurrencySymbol/etc/config.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - 1.0.0.0.0 - true - core - - - - - - - - - - - - Mage_CurrencySymbol_Model_Observer - currencyDisplayOptions - - - - - - - - - - - - Mage_CurrencySymbol_Adminhtml - - - - - - - - - - - layout.xml - - - - - - - - Mage_CurrencySymbol.csv - - - - - - diff --git a/app/code/core/Mage/Customer/Helper/Address.php b/app/code/core/Mage/Customer/Helper/Address.php deleted file mode 100644 index 336395cb6392a..0000000000000 --- a/app/code/core/Mage/Customer/Helper/Address.php +++ /dev/null @@ -1,311 +0,0 @@ - - */ -class Mage_Customer_Helper_Address extends Mage_Core_Helper_Abstract -{ - /** - * VAT Validation parameters XML paths - */ - const XML_PATH_VIV_DISABLE_AUTO_ASSIGN_DEFAULT = 'customer/create_account/viv_disable_auto_group_assign_default'; - const XML_PATH_VIV_ON_EACH_TRANSACTION = 'customer/create_account/viv_on_each_transaction'; - const XML_PATH_VAT_VALIDATION_ENABLED = 'customer/create_account/auto_group_assign'; - const XML_PATH_VIV_TAX_CALCULATION_ADDRESS_TYPE = 'customer/create_account/tax_calculation_address_type'; - const XML_PATH_VAT_FRONTEND_VISIBILITY = 'customer/create_account/vat_frontend_visibility'; - - /** - * Array of Customer Address Attributes - * - * @var array - */ - protected $_attributes; - - /** - * Customer address config node per website - * - * @var array - */ - protected $_config = array(); - - /** - * Customer Number of Lines in a Street Address per website - * - * @var array - */ - protected $_streetLines = array(); - protected $_formatTemplate = array(); - - /** - * Block factory - * - * @var Mage_Core_Model_BlockFactory - */ - protected $_blockFactory; - - /** - * @param Mage_Core_Model_Translate $translator - * @param Mage_Core_Model_BlockFactory $blockFactory - */ - public function __construct(Mage_Core_Model_Translate $translator, Mage_Core_Model_BlockFactory $blockFactory) - { - parent::__construct($translator); - $this->_blockFactory = $blockFactory; - } - - /** - * Addresses url - */ - public function getBookUrl() - { - - } - - public function getEditUrl() - { - - } - - public function getDeleteUrl() - { - - } - - public function getCreateUrl() - { - - } - - public function getRenderer($renderer) - { - if (is_string($renderer) && $renderer) { - return $this->_blockFactory->createBlock($renderer, array()); - } else { - return $renderer; - } - } - - /** - * Return customer address config value by key and store - * - * @param string $key - * @param Mage_Core_Model_Store|int|string $store - * @return string|null - */ - public function getConfig($key, $store = null) - { - /** @var $storeManager Mage_Core_Model_StoreManager */ - $storeManager = Mage::getObjectManager()->get('Mage_Core_Model_StoreManager'); - /** @var $store Mage_Core_Model_Store */ - $store = $storeManager->getStore($store); - - $websiteId = $store->getWebsiteId(); - if (!isset($this->_config[$websiteId])) { - $this->_config[$websiteId] = $store->getConfig('customer/address', $store); - } - return isset($this->_config[$websiteId][$key]) ? (string)$this->_config[$websiteId][$key] : null; - } - - /** - * Return Number of Lines in a Street Address for store - * - * @param Mage_Core_Model_Store|int|string $store - * @return int - */ - public function getStreetLines($store = null) - { - $websiteId = Mage::app()->getStore($store)->getWebsiteId(); - if (!isset($this->_streetLines[$websiteId])) { - $attribute = Mage::getSingleton('Mage_Eav_Model_Config')->getAttribute('customer_address', 'street'); - $lines = (int)$attribute->getMultilineCount(); - if ($lines <= 0) { - $lines = 2; - } - $this->_streetLines[$websiteId] = min(4, $lines); - } - - return $this->_streetLines[$websiteId]; - } - - public function getFormat($code) - { - $format = Mage::getSingleton('Mage_Customer_Model_Address_Config')->getFormatByCode($code); - return $format->getRenderer() ? $format->getRenderer()->getFormat() : ''; - } - - /** - * Determine if specified address config value can be shown - * - * @param string $key - * @return bool - */ - public function canShowConfig($key) - { - return (bool)$this->getConfig($key); - } - - /** - * Return array of Customer Address Attributes - * - * @return array - */ - public function getAttributes() - { - if (is_null($this->_attributes)) { - $this->_attributes = array(); - /* @var $config Mage_Eav_Model_Config */ - $config = Mage::getSingleton('Mage_Eav_Model_Config'); - foreach ($config->getEntityAttributeCodes('customer_address') as $attributeCode) { - $this->_attributes[$attributeCode] = $config->getAttribute('customer_address', $attributeCode); - } - } - return $this->_attributes; - } - - /** - * Get string with frontend validation classes for attribute - * - * @param string $attributeCode - * @return string - */ - public function getAttributeValidationClass($attributeCode) - { - /** @var $attribute Mage_Customer_Model_Attribute */ - $attribute = isset($this->_attributes[$attributeCode]) ? $this->_attributes[$attributeCode] - : Mage::getSingleton('Mage_Eav_Model_Config')->getAttribute('customer_address', $attributeCode); - $class = $attribute ? $attribute->getFrontend()->getClass() : ''; - - if (in_array($attributeCode, array('firstname', 'middlename', 'lastname', 'prefix', 'suffix', 'taxvat'))) { - if ($class && !$attribute->getIsVisible()) { - $class = ''; // address attribute is not visible thus its validation rules are not applied - } - - /** @var $customerAttribute Mage_Customer_Model_Attribute */ - $customerAttribute = Mage::getSingleton('Mage_Eav_Model_Config')->getAttribute('customer', $attributeCode); - $class .= $customerAttribute && $customerAttribute->getIsVisible() - ? $customerAttribute->getFrontend()->getClass() : ''; - $class = implode(' ', array_unique(array_filter(explode(' ', $class)))); - } - - return $class; - } - - /** - * Convert streets array to new street lines count - * Examples of use: - * $origStreets = array('street1', 'street2', 'street3', 'street4') - * $toCount = 3 - * Result: - * array('street1 street2', 'street3', 'street4') - * $toCount = 2 - * Result: - * array('street1 street2', 'street3 street4') - * - * @param array $origStreets - * @param int $toCount - * @return array - */ - public function convertStreetLines($origStreets, $toCount) - { - $lines = array(); - if (!empty($origStreets) && $toCount > 0) { - $countArgs = (int)floor(count($origStreets)/$toCount); - $modulo = count($origStreets) % $toCount; - $offset = 0; - $neededLinesCount = 0; - for ($i = 0; $i < $toCount; $i++) { - $offset += $neededLinesCount; - $neededLinesCount = $countArgs; - if ($modulo > 0) { - ++$neededLinesCount; - --$modulo; - } - $values = array_slice($origStreets, $offset, $neededLinesCount); - if (is_array($values)) { - $lines[] = implode(' ', $values); - } - } - } - - return $lines; - } - - /** - * Check whether VAT ID validation is enabled - * - * @param Mage_Core_Model_Store|string|int $store - * @return bool - */ - public function isVatValidationEnabled($store = null) - { - return (bool)Mage::getStoreConfig(self::XML_PATH_VAT_VALIDATION_ENABLED, $store); - } - - /** - * Retrieve disable auto group assign default value - * - * @return bool - */ - public function getDisableAutoGroupAssignDefaultValue() - { - return (bool)Mage::getStoreConfig(self::XML_PATH_VIV_DISABLE_AUTO_ASSIGN_DEFAULT); - } - - /** - * Retrieve 'validate on each transaction' value - * - * @param Mage_Core_Model_Store|string|int $store - * @return bool - */ - public function getValidateOnEachTransaction($store = null) - { - return (bool)Mage::getStoreConfig(self::XML_PATH_VIV_ON_EACH_TRANSACTION, $store); - } - - /** - * Retrieve customer address type on which tax calculation must be based - * - * @param Mage_Core_Model_Store|string|int|null $store - * @return string - */ - public function getTaxCalculationAddressType($store = null) - { - return (string)Mage::getStoreConfig(self::XML_PATH_VIV_TAX_CALCULATION_ADDRESS_TYPE, $store); - } - - /** - * Check if VAT ID address attribute has to be shown on frontend (on Customer Address management forms) - * - * @return boolean - */ - public function isVatAttributeVisible() - { - return (bool)Mage::getStoreConfig(self::XML_PATH_VAT_FRONTEND_VISIBILITY); - } -} diff --git a/app/code/core/Mage/Customer/Model/Address/Factory.php b/app/code/core/Mage/Customer/Model/Address/Factory.php deleted file mode 100644 index 6a5270118c34a..0000000000000 --- a/app/code/core/Mage/Customer/Model/Address/Factory.php +++ /dev/null @@ -1,53 +0,0 @@ -_objectManager = $objectManager; - } - - /** - * Create customer address model instance. - * - * @param array $arguments - * @return Mage_Customer_Model_Address - */ - public function create(array $arguments = array()) - { - return $this->_objectManager->create(self::ADDRESS_CLASS_NAME, $arguments, false); - } -} diff --git a/app/code/core/Mage/Customer/Model/Customer/Factory.php b/app/code/core/Mage/Customer/Model/Customer/Factory.php deleted file mode 100644 index 4f42b02595687..0000000000000 --- a/app/code/core/Mage/Customer/Model/Customer/Factory.php +++ /dev/null @@ -1,53 +0,0 @@ -_objectManager = $objectManager; - } - - /** - * Create customer model instance. - * - * @param array $arguments - * @return Mage_Customer_Model_Customer - */ - public function create(array $arguments = array()) - { - return $this->_objectManager->create(self::CUSTOMER_CLASS_NAME, $arguments, false); - } -} diff --git a/app/code/core/Mage/Customer/Model/Session.php b/app/code/core/Mage/Customer/Model/Session.php deleted file mode 100644 index 93d07d7e15b42..0000000000000 --- a/app/code/core/Mage/Customer/Model/Session.php +++ /dev/null @@ -1,347 +0,0 @@ - - */ -class Mage_Customer_Model_Session extends Mage_Core_Model_Session_Abstract -{ - /** - * Customer object - * - * @var Mage_Customer_Model_Customer - */ - protected $_customer; - - /** - * Flag with customer id validations result - * - * @var bool - */ - protected $_isCustomerIdChecked = null; - - /** - * Persistent customer group id - * - * @var null|int - */ - protected $_persistentCustomerGroupId = null; - - /** - * Retrieve customer sharing configuration model - * - * @return Mage_Customer_Model_Config_Share - */ - public function getCustomerConfigShare() - { - return Mage::getSingleton('Mage_Customer_Model_Config_Share'); - } - - public function __construct() - { - $namespace = 'customer'; - if ($this->getCustomerConfigShare()->isWebsiteScope()) { - $namespace .= '_' . (Mage::app()->getStore()->getWebsite()->getCode()); - } - - $this->init($namespace); - Mage::dispatchEvent('customer_session_init', array('customer_session'=>$this)); - } - - /** - * Set customer object and setting customer id in session - * - * @param Mage_Customer_Model_Customer $customer - * @return Mage_Customer_Model_Session - */ - public function setCustomer(Mage_Customer_Model_Customer $customer) - { - // check if customer is not confirmed - if ($customer->isConfirmationRequired()) { - if ($customer->getConfirmation()) { - return $this->_logout(); - } - } - $this->_customer = $customer; - $this->setId($customer->getId()); - // save customer as confirmed, if it is not - if ((!$customer->isConfirmationRequired()) && $customer->getConfirmation()) { - $customer->setConfirmation(null)->save(); - $customer->setIsJustConfirmed(true); - } - return $this; - } - - /** - * Retrieve customer model object - * - * @return Mage_Customer_Model_Customer - */ - public function getCustomer() - { - if ($this->_customer instanceof Mage_Customer_Model_Customer) { - return $this->_customer; - } - - $customer = Mage::getModel('Mage_Customer_Model_Customer') - ->setWebsiteId(Mage::app()->getStore()->getWebsiteId()); - if ($this->getId()) { - $customer->load($this->getId()); - } - - $this->setCustomer($customer); - return $this->_customer; - } - - /** - * Set customer id - * - * @param int|null $id - * @return Mage_Customer_Model_Session - */ - public function setCustomerId($id) - { - $this->setData('customer_id', $id); - return $this; - } - - /** - * Retrieve customer id from current session - * - * @return int|null - */ - public function getCustomerId() - { - if ($this->getData('customer_id')) { - return $this->getData('customer_id'); - } - return ($this->isLoggedIn()) ? $this->getId() : null; - } - - /** - * Set customer group id - * - * @param int|null $id - * @return Mage_Customer_Model_Session - */ - public function setCustomerGroupId($id) - { - $this->setData('customer_group_id', $id); - return $this; - } - - /** - * Get customer group id - * If customer is not logged in system, 'not logged in' group id will be returned - * - * @return int - */ - public function getCustomerGroupId() - { - if ($this->getData('customer_group_id')) { - return $this->getData('customer_group_id'); - } - if ($this->isLoggedIn() && $this->getCustomer()) { - return $this->getCustomer()->getGroupId(); - } - return Mage_Customer_Model_Group::NOT_LOGGED_IN_ID; - } - - /** - * Checking customer login status - * - * @return bool - */ - public function isLoggedIn() - { - return (bool)$this->getId() && (bool)$this->checkCustomerId($this->getId()); - } - - /** - * Check exists customer (light check) - * - * @param int $customerId - * @return bool - */ - public function checkCustomerId($customerId) - { - if ($this->_isCustomerIdChecked === null) { - $this->_isCustomerIdChecked = Mage::getResourceSingleton('Mage_Customer_Model_Resource_Customer') - ->checkCustomerId($customerId); - } - return $this->_isCustomerIdChecked; - } - - /** - * Customer authorization - * - * @param string $username - * @param string $password - * @return bool - */ - public function login($username, $password) - { - /** @var $customer Mage_Customer_Model_Customer */ - $customer = Mage::getModel('Mage_Customer_Model_Customer') - ->setWebsiteId(Mage::app()->getStore()->getWebsiteId()); - - if ($customer->authenticate($username, $password)) { - $this->setCustomerAsLoggedIn($customer); - $this->renewSession(); - return true; - } - return false; - } - - public function setCustomerAsLoggedIn($customer) - { - $this->setCustomer($customer); - Mage::dispatchEvent('customer_login', array('customer'=>$customer)); - return $this; - } - - /** - * Authorization customer by identifier - * - * @param int $customerId - * @return bool - */ - public function loginById($customerId) - { - $customer = Mage::getModel('Mage_Customer_Model_Customer')->load($customerId); - if ($customer->getId()) { - $this->setCustomerAsLoggedIn($customer); - return true; - } - return false; - } - - /** - * Logout customer - * - * @return Mage_Customer_Model_Session - */ - public function logout() - { - if ($this->isLoggedIn()) { - Mage::dispatchEvent('customer_logout', array('customer' => $this->getCustomer()) ); - $this->_logout(); - } - return $this; - } - - /** - * Authenticate controller action by login customer - * - * @param Mage_Core_Controller_Varien_Action $action - * @param bool $loginUrl - * @return bool - */ - public function authenticate(Mage_Core_Controller_Varien_Action $action, $loginUrl = null) - { - if ($this->isLoggedIn()) { - return true; - } - - $this->setBeforeAuthUrl(Mage::getUrl('*/*/*', array('_current' => true))); - if (isset($loginUrl)) { - $action->getResponse()->setRedirect($loginUrl); - } else { - $action->setRedirectWithCookieCheck(Mage_Customer_Helper_Data::ROUTE_ACCOUNT_LOGIN, - Mage::helper('Mage_Customer_Helper_Data')->getLoginUrlParams() - ); - } - - return false; - } - - /** - * Set auth url - * - * @param string $key - * @param string $url - * @return Mage_Customer_Model_Session - */ - protected function _setAuthUrl($key, $url) - { - $url = Mage::helper('Mage_Core_Helper_Url') - ->removeRequestParam($url, Mage::getSingleton('Mage_Core_Model_Session')->getSessionIdQueryParam()); - // Add correct session ID to URL if needed - $url = Mage::getModel('Mage_Core_Model_Url')->getRebuiltUrl($url); - return $this->setData($key, $url); - } - - /** - * Logout without dispatching event - * - * @return Mage_Customer_Model_Session - */ - protected function _logout() - { - $this->setId(null); - $this->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID); - $this->getCookie()->delete($this->getSessionName()); - return $this; - } - - /** - * Set Before auth url - * - * @param string $url - * @return Mage_Customer_Model_Session - */ - public function setBeforeAuthUrl($url) - { - return $this->_setAuthUrl('before_auth_url', $url); - } - - /** - * Set After auth url - * - * @param string $url - * @return Mage_Customer_Model_Session - */ - public function setAfterAuthUrl($url) - { - return $this->_setAuthUrl('after_auth_url', $url); - } - - /** - * Reset core session hosts after reseting session ID - * - * @return Mage_Customer_Model_Session - */ - public function renewSession() - { - parent::renewSession(); - $this->_cleanHosts(); - return $this; - } -} diff --git a/app/code/core/Mage/Customer/Service/Customer.php b/app/code/core/Mage/Customer/Service/Customer.php deleted file mode 100644 index 753034c1363fb..0000000000000 --- a/app/code/core/Mage/Customer/Service/Customer.php +++ /dev/null @@ -1,411 +0,0 @@ -_translateHelper = $helper; - $this->_customerFactory = $customerFactory; - $this->_addressFactory = $addressFactory; - $this->_isAdminStore = $isAdminStore; - } - - /** - * Set is admin store flag. - * - * @param bool $isAdminStore - * @return Mage_Customer_Service_Customer - */ - public function setIsAdminStore($isAdminStore) - { - $this->_isAdminStore = $isAdminStore; - return $this; - } - - /** - * Set flag if send remainder email - * - * @param bool $flag - * @return Mage_Customer_Service_Customer - */ - public function setSendRemainderEmail($flag) - { - // todo: drop next string as soon as front controller of webapi will be able to return routers - $this->_sendRemainderEmail = (bool)$flag; - return $this; - } - - /** - * Set before save callback. - * - * @param callable $callback - * @return Mage_Customer_Service_Customer - */ - public function setBeforeSaveCallback($callback) - { - $this->_beforeSaveCallback = $callback; - return $this; - } - - /** - * Set after save callback. - * - * @param callable $callback - * @return Mage_Customer_Service_Customer - */ - public function setAfterSaveCallback($callback) - { - $this->_afterSaveCallback = $callback; - return $this; - } - - /** - * Create customer with optional ability of adding addresses. - * - * @param array $customerData - * @param array|null $addressesData array of addresses - * @return Mage_Customer_Model_Customer - */ - public function create(array $customerData, array $addressesData = null) - { - $customer = $this->_customerFactory->create(); - $this->_preparePasswordForSave($customer, $customerData); - $this->_save($customer, $customerData, $addressesData); - - return $customer; - } - - /** - * Update customer entity. - * - * Update customer with optional ability to update customer addresses. - * Addresses that are not in $addressesData array but present in customer addresses collection will be removed. - * New address is created in case when no entity_id is present, otherwise corresponding address will be updated - * with data provided. - * - * @param string|int $customerId - * @param array $customerData - * @param array|null $addressesData array of addresses - * @return Mage_Customer_Model_Customer - */ - public function update($customerId, array $customerData, array $addressesData = null) - { - /** @var Mage_Customer_Model_Customer $customer */ - $customer = $this->_loadCustomerById($customerId); - - $this->_save($customer, $customerData, $addressesData); - if ($customerData) { - $this->_changePassword($customer, $customerData); - } - - return $customer; - } - - /** - * Save customer entity. Perform supplementary business workflow actions - * - * @param Mage_Customer_Model_Customer $customer - * @param array $customerData - * @param array|null $addressesData - * @return Mage_Customer_Service_Customer - */ - protected function _save($customer, array $customerData, array $addressesData = null) - { - if ($customerData) { - $this->_setDataUsingMethods($customer, $customerData); - } - $this->_beforeSave($customer, $customerData, $addressesData); - $customer->save(); - $this->_afterSave($customer, $customerData, $addressesData); - - return $this; - } - - /** - * Sets each value from data to entity Varien_Object using setter method. - * - * @param Varien_Object $entity - * @param array $data - */ - protected function _setDataUsingMethods($entity, array $data) - { - foreach ($data as $property => $value) { - $entity->setDataUsingMethod($property, $value); - } - } - - /** - * Trigger before save logic - * - * @param Mage_Customer_Model_Customer $customer - * @param array $customerData - * @param array $addressesData - */ - protected function _beforeSave($customer, array $customerData, array $addressesData = null) - { - if (!is_null($addressesData)) { - $this->_prepareCustomerAddressesForSave($customer, $addressesData); - } - if (is_callable($this->_beforeSaveCallback)) { - call_user_func_array($this->_beforeSaveCallback, array($customer, $customerData, $addressesData)); - } - } - - /** - * Trigger before save logic - * - * @param Mage_Customer_Model_Customer $customer - * @param array $customerData - * @param array $addressesData - */ - protected function _afterSave($customer, array $customerData, array $addressesData = null) - { - if (is_callable($this->_afterSaveCallback)) { - call_user_func_array($this->_afterSaveCallback, array($customer, $customerData, $addressesData)); - } - $this->_sendWelcomeEmail($customer, $customerData); - } - - /** - * Set customer password - * - * @param Mage_Customer_Model_Customer $customer - * @param array $customerData - */ - protected function _preparePasswordForSave($customer, array $customerData) - { - $password = $this->_getCustomerPassword($customer, $customerData); - if (!is_null($password)) { - // 'force_confirmed' should be set in admin area only - if ($this->_isAdminStore) { - $customer->setForceConfirmed(true); - } - $customer->setPassword($password); - } - } - - /** - * Get customer password - * - * @param Mage_Customer_Model_Customer $customer - * @param array $customerData - * @return string|null - */ - protected function _getCustomerPassword($customer, array $customerData) - { - $password = null; - - if ($this->_isAutogeneratePassword($customerData)) { - $password = $customer->generatePassword(); - } elseif (isset($customerData['password'])) { - $password = $customerData['password']; - } - - return $password; - } - - /** - * Change customer password - * - * @param Mage_Customer_Model_Customer $customer - * @param array $customerData - * @return Mage_Customer_Service_Customer - */ - protected function _changePassword($customer, array $customerData) - { - if (!empty($customerData['password']) || $this->_isAutogeneratePassword($customerData)) { - $newPassword = $this->_getCustomerPassword($customer, $customerData); - $customer->changePassword($newPassword); - if ($this->_sendRemainderEmail) { - $customer->sendPasswordReminderEmail(); - } - } - - return $this; - } - - /** - * Check if password should be generated automatically - * - * @param array $customerData - * @return bool - */ - protected function _isAutogeneratePassword(array $customerData) - { - return isset($customerData['autogenerate_password']) && $customerData['autogenerate_password']; - } - - /** - * Retrieve send email flag - * - * @param array $customerData - * @return bool - */ - protected function _isSendEmail(array $customerData) - { - return isset($customerData['sendemail']) && $customerData['sendemail']; - } - - /** - * Send welcome email to customer - * - * @param Mage_Customer_Model_Customer $customer - * @param array $customerData - * @return Mage_Customer_Service_Customer - */ - protected function _sendWelcomeEmail($customer, array $customerData) - { - if ($customer->getWebsiteId() - && ($this->_isSendEmail($customerData) || $this->_isAutogeneratePassword($customerData)) - ) { - $isNewCustomer = !(bool)$customer->getOrigData($customer->getIdFieldName()); - $storeId = $customer->getSendemailStoreId(); - - if ($isNewCustomer) { - $customer->sendNewAccountEmail('registered', '', $storeId); - } elseif (!$customer->getConfirmation()) { - // Confirm not confirmed customer - $customer->sendNewAccountEmail('confirmed', '', $storeId); - } - } - return $this; - } - - /** - * Load customer by its ID - * - * @param int|string $customerId - * @return Mage_Customer_Model_Customer - * @throws Mage_Core_Exception - */ - protected function _loadCustomerById($customerId) - { - $customer = $this->_customerFactory->create(); - $customer->load($customerId); - if (!$customer->getId()) { - throw new Mage_Core_Exception($this->_translateHelper->__("The customer with the specified ID not found.")); - } - - return $customer; - } - - /** - * Save customer addresses. - * - * @param Mage_Customer_Model_Customer $customer - * @param array $addressesData - * @throws Mage_Core_Exception - */ - protected function _prepareCustomerAddressesForSave($customer, array $addressesData) - { - $hasChanges = $customer->hasDataChanges(); - $actualAddressesIds = array(); - foreach ($addressesData as $addressData) { - $addressId = null; - if (array_key_exists('entity_id', $addressData)) { - $addressId = $addressData['entity_id']; - unset($addressData['entity_id']); - } - - if (null !== $addressId) { - $address = $customer->getAddressItemById($addressId); - if (!$address || !$address->getId()) { - throw new Mage_Core_Exception( - $this->_translateHelper->__('The address with the specified ID not found.')); - } - } else { - $address = $this->_addressFactory->create(); - $address->setCustomerId($customer->getId()); - // Add customer address into addresses collection - $customer->addAddress($address); - } - $address->addData($addressData); - $hasChanges = $hasChanges || $address->hasDataChanges(); - - // Set post_index for detect default billing and shipping addresses - $address->setPostIndex($addressId); - - $actualAddressesIds[] = $address->getId(); - } - - /** @var Mage_Customer_Model_Address $address */ - foreach ($customer->getAddressesCollection() as $address) { - if (!in_array($address->getId(), $actualAddressesIds)) { - $address->setData('_deleted', true); - $hasChanges = true; - } - } - $customer->setDataChanges($hasChanges); - } -} diff --git a/app/code/core/Mage/Customer/controllers/AccountController.php b/app/code/core/Mage/Customer/controllers/AccountController.php deleted file mode 100644 index f4f46a35b43d9..0000000000000 --- a/app/code/core/Mage/Customer/controllers/AccountController.php +++ /dev/null @@ -1,856 +0,0 @@ - - */ -class Mage_Customer_AccountController extends Mage_Core_Controller_Front_Action -{ - /** - * Action list where need check enabled cookie - * - * @var array - */ - protected $_cookieCheckActions = array('loginPost', 'createpost'); - - /** - * Retrieve customer session model object - * - * @return Mage_Customer_Model_Session - */ - protected function _getSession() - { - return Mage::getSingleton('Mage_Customer_Model_Session'); - } - - /** - * Action predispatch - * - * Check customer authentication for some actions - */ - public function preDispatch() - { - // a brute-force protection here would be nice - - parent::preDispatch(); - - if (!$this->getRequest()->isDispatched()) { - return; - } - - $action = $this->getRequest()->getActionName(); - $openActions = array( - 'create', - 'login', - 'logoutsuccess', - 'forgotpassword', - 'forgotpasswordpost', - 'resetpassword', - 'resetpasswordpost', - 'confirm', - 'confirmation' - ); - $pattern = '/^(' . implode('|', $openActions) . ')/i'; - - if (!preg_match($pattern, $action)) { - if (!$this->_getSession()->authenticate($this)) { - $this->setFlag('', 'no-dispatch', true); - } - } else { - $this->_getSession()->setNoReferer(true); - } - } - - /** - * Action postdispatch - * - * Remove No-referer flag from customer session after each action - */ - public function postDispatch() - { - parent::postDispatch(); - $this->_getSession()->unsNoReferer(false); - } - - /** - * Default customer account page - */ - public function indexAction() - { - $this->loadLayout(); - $this->_initLayoutMessages('Mage_Customer_Model_Session'); - $this->_initLayoutMessages('Mage_Catalog_Model_Session'); - $this->getLayout()->getBlock('head')->setTitle($this->__('My Account')); - $this->renderLayout(); - } - - /** - * Customer login form page - */ - public function loginAction() - { - if ($this->_getSession()->isLoggedIn()) { - $this->_redirect('*/*/'); - return; - } - $this->getResponse()->setHeader('Login-Required', 'true'); - $this->loadLayout(); - $this->_initLayoutMessages('Mage_Customer_Model_Session'); - $this->_initLayoutMessages('Mage_Catalog_Model_Session'); - $this->renderLayout(); - } - - /** - * Login post action - */ - public function loginPostAction() - { - if ($this->_getSession()->isLoggedIn()) { - $this->_redirect('*/*/'); - return; - } - $session = $this->_getSession(); - - if ($this->getRequest()->isPost()) { - $login = $this->getRequest()->getPost('login'); - if (!empty($login['username']) && !empty($login['password'])) { - try { - $session->login($login['username'], $login['password']); - if ($session->getCustomer()->getIsJustConfirmed()) { - $this->_welcomeCustomer($session->getCustomer(), true); - } - } catch (Mage_Core_Exception $e) { - switch ($e->getCode()) { - case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED: - $value = Mage::helper('Mage_Customer_Helper_Data')->getEmailConfirmationUrl($login['username']); - $message = Mage::helper('Mage_Customer_Helper_Data')->__('This account is not confirmed. Click here to resend confirmation email.', $value); - break; - case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD: - $message = $e->getMessage(); - break; - default: - $message = $e->getMessage(); - } - $session->addError($message); - $session->setUsername($login['username']); - } catch (Exception $e) { - // Mage::logException($e); // PA DSS violation: this exception log can disclose customer password - } - } else { - $session->addError($this->__('Login and password are required.')); - } - } - - $this->_loginPostRedirect(); - } - - /** - * Define target URL and redirect customer after logging in - */ - protected function _loginPostRedirect() - { - $session = $this->_getSession(); - - if (!$session->getBeforeAuthUrl() || $session->getBeforeAuthUrl() == Mage::getBaseUrl()) { - // Set default URL to redirect customer to - $session->setBeforeAuthUrl(Mage::helper('Mage_Customer_Helper_Data')->getAccountUrl()); - // Redirect customer to the last page visited after logging in - if ($session->isLoggedIn()) { - if (!Mage::getStoreConfigFlag( - Mage_Customer_Helper_Data::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD - )) { - $referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME); - if ($referer) { - $referer = Mage::helper('Mage_Core_Helper_Data')->urlDecode($referer); - if ($this->_isUrlInternal($referer)) { - $session->setBeforeAuthUrl($referer); - } - } - } else if ($session->getAfterAuthUrl()) { - $session->setBeforeAuthUrl($session->getAfterAuthUrl(true)); - } - } else { - $session->setBeforeAuthUrl(Mage::helper('Mage_Customer_Helper_Data')->getLoginUrl()); - } - } else if ($session->getBeforeAuthUrl() == Mage::helper('Mage_Customer_Helper_Data')->getLogoutUrl()) { - $session->setBeforeAuthUrl(Mage::helper('Mage_Customer_Helper_Data')->getDashboardUrl()); - } else { - if (!$session->getAfterAuthUrl()) { - $session->setAfterAuthUrl($session->getBeforeAuthUrl()); - } - if ($session->isLoggedIn()) { - $session->setBeforeAuthUrl($session->getAfterAuthUrl(true)); - } - } - $this->_redirectUrl($session->getBeforeAuthUrl(true)); - } - - /** - * Customer logout action - */ - public function logoutAction() - { - $this->_getSession()->logout() - ->renewSession() - ->setBeforeAuthUrl($this->_getRefererUrl()); - - $this->_redirect('*/*/logoutSuccess'); - } - - /** - * Logout success page - */ - public function logoutSuccessAction() - { - $this->loadLayout(); - $this->renderLayout(); - } - - /** - * Customer register form page - */ - public function createAction() - { - if ($this->_getSession()->isLoggedIn()) { - $this->_redirect('*/*'); - return; - } - - $this->loadLayout(); - $this->_initLayoutMessages('Mage_Customer_Model_Session'); - $this->renderLayout(); - } - - /** - * Create customer account action - */ - public function createPostAction() - { - $session = $this->_getSession(); - if ($session->isLoggedIn()) { - $this->_redirect('*/*/'); - return; - } - $session->setEscapeMessages(true); // prevent XSS injection in user input - - if (!$this->getRequest()->isPost()) { - $this->_redirectError(Mage::getUrl('*/*/create', array('_secure' => true))); - return; - } - - try { - $customer = $this->_extractCustomer(); - $address = $this->_extractAddress($customer); - $this->_validateCustomer($customer, $address); - - $customer->save()->setOrigData(); - Mage::dispatchEvent('customer_register_success', - array('account_controller' => $this, 'customer' => $customer) - ); - - if ($customer->isConfirmationRequired()) { - $customer->sendNewAccountEmail( - 'confirmation', - $session->getBeforeAuthUrl(), - Mage::app()->getStore()->getId() - ); - $session->addSuccess($this->__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please click here.', Mage::helper('Mage_Customer_Helper_Data')->getEmailConfirmationUrl($customer->getEmail()))); - $this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure' => true))); - } else { - $session->setCustomerAsLoggedIn($customer); - $url = $this->_welcomeCustomer($customer); - $this->_redirectSuccess($url); - } - return; - } catch (Mage_Core_Exception $e) { - if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) { - $url = Mage::getUrl('customer/account/forgotpassword'); - $message = $this->__('There is already an account with this email address. If you are sure that it is your email address, click here to get your password and access your account.', $url); - $session->setEscapeMessages(false); - } else { - $message = $e->getMessage(); - } - $session->addError($message); - } catch (Magento_Validator_Exception $e) { - foreach ($e->getMessages() as $messages) { - foreach ($messages as $message) { - $session->addError($message); - } - } - } catch (Exception $e) { - $session->addException($e, $this->__('Cannot save the customer.')); - } - - $session->setCustomerFormData($this->getRequest()->getPost()); - $this->_redirectError(Mage::getUrl('*/*/create', array('_secure' => true))); - } - - /** - * Do validation of customer and its address using validate methods in models - * - * @param Mage_Customer_Model_Customer $customer - * @param Mage_Customer_Model_Address|null $address - * @throws Magento_Validator_Exception - */ - protected function _validateCustomer($customer, $address = null) - { - $errors = array(); - if ($address) { - $addressErrors = $address->validate(); - if (is_array($addressErrors)) { - $errors = array_merge($errors, $addressErrors); - } - } - $customerErrors = $customer->validate(); - if (is_array($customerErrors)) { - $errors = array_merge($errors, $customerErrors); - } - if (count($errors) > 0) { - throw new Magento_Validator_Exception(array($errors)); - } - } - - /** - * Add address to customer during create account - * - * @param Mage_Customer_Model_Customer $customer - * @return Mage_Customer_Model_Address|null - */ - protected function _extractAddress($customer) - { - if (!$this->getRequest()->getPost('create_address')) { - return null; - } - /* @var Mage_Customer_Model_Address $address */ - $address = Mage::getModel('Mage_Customer_Model_Address'); - /* @var Mage_Customer_Model_Form $addressForm */ - $addressForm = Mage::getModel('Mage_Customer_Model_Form'); - $addressForm->setFormCode('customer_register_address') - ->setEntity($address); - - $addressData = $addressForm->extractData($this->getRequest(), 'address', false); - $address->setId(null) - ->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false)) - ->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false)); - $addressForm->compactData($addressData); - $customer->addAddress($address); - return $address; - } - - /** - * Extract customer entity from request - * - * @return Mage_Customer_Model_Customer - */ - protected function _extractCustomer() - { - /** @var Mage_Customer_Model_Customer $customer */ - if (!$customer = Mage::registry('current_customer')) { - $customer = Mage::getModel('Mage_Customer_Model_Customer')->setId(null); - } - /* @var Mage_Customer_Model_Form $customerForm */ - $customerForm = Mage::getModel('Mage_Customer_Model_Form'); - $customerForm->setFormCode('customer_account_create') - ->setEntity($customer); - - $customerData = $customerForm->extractData($this->getRequest()); - // Initialize customer group id - $customer->getGroupId(); - $customerForm->compactData($customerData); - $customer->setPassword($this->getRequest()->getPost('password')); - $customer->setConfirmation($this->getRequest()->getPost('confirmation')); - if ($this->getRequest()->getParam('is_subscribed', false)) { - $customer->setIsSubscribed(1); - } - return $customer; - } - - /** - * Add welcome message and send new account email. - * Returns success URL - * - * @param Mage_Customer_Model_Customer $customer - * @param bool $isJustConfirmed - * @return string - */ - protected function _welcomeCustomer(Mage_Customer_Model_Customer $customer, $isJustConfirmed = false) - { - $this->_getSession()->addSuccess( - $this->__('Thank you for registering with %s.', Mage::app()->getStore()->getFrontendName()) - ); - if ($this->_isVatValidationEnabled()) { - // Show corresponding VAT message to customer - $configAddressType = Mage::helper('Mage_Customer_Helper_Address')->getTaxCalculationAddressType(); - $userPrompt = ''; - switch ($configAddressType) { - case Mage_Customer_Model_Address_Abstract::TYPE_SHIPPING: - $userPrompt = $this->__('If you are a registered VAT customer, please click here to enter you shipping address for proper VAT calculation', Mage::getUrl('customer/address/edit')); - break; - default: - $userPrompt = $this->__('If you are a registered VAT customer, please click here to enter you billing address for proper VAT calculation', Mage::getUrl('customer/address/edit')); - } - $this->_getSession()->addSuccess($userPrompt); - } - - $customer->sendNewAccountEmail( - $isJustConfirmed ? 'confirmed' : 'registered', - '', - Mage::app()->getStore()->getId() - ); - - $successUrl = Mage::getUrl('*/*/index', array('_secure' => true)); - if (!Mage::getStoreConfigFlag(Mage_Customer_Helper_Data::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD) - && $this->_getSession()->getBeforeAuthUrl() - ) { - $successUrl = $this->_getSession()->getBeforeAuthUrl(true); - } - return $successUrl; - } - - /** - * Confirm customer account by id and confirmation key - */ - public function confirmAction() - { - if ($this->_getSession()->isLoggedIn()) { - $this->_redirect('*/*/'); - return; - } - try { - $id = $this->getRequest()->getParam('id', false); - $key = $this->getRequest()->getParam('key', false); - $backUrl = $this->getRequest()->getParam('back_url', false); - if (empty($id) || empty($key)) { - throw new Exception($this->__('Bad request.')); - } - - // load customer by id (try/catch in case if it throws exceptions) - try { - $customer = Mage::getModel('Mage_Customer_Model_Customer')->load($id); - if ((!$customer) || (!$customer->getId())) { - throw new Exception('Failed to load customer by id.'); - } - } - catch (Exception $e) { - throw new Exception($this->__('Wrong customer account specified.')); - } - - // check if it is inactive - if ($customer->getConfirmation()) { - if ($customer->getConfirmation() !== $key) { - throw new Exception($this->__('Wrong confirmation key.')); - } - - // activate customer - try { - $customer->setConfirmation(null); - $customer->save(); - } - catch (Exception $e) { - throw new Exception($this->__('Failed to confirm customer account.')); - } - - // log in and send greeting email, then die happy - $this->_getSession()->setCustomerAsLoggedIn($customer); - $successUrl = $this->_welcomeCustomer($customer, true); - $this->_redirectSuccess($backUrl ? $backUrl : $successUrl); - return; - } - - // die happy - $this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure'=>true))); - return; - } - catch (Exception $e) { - // die unhappy - $this->_getSession()->addError($e->getMessage()); - $this->_redirectError(Mage::getUrl('*/*/index', array('_secure'=>true))); - return; - } - } - - /** - * Send confirmation link to specified email - */ - public function confirmationAction() - { - $customer = Mage::getModel('Mage_Customer_Model_Customer'); - if ($this->_getSession()->isLoggedIn()) { - $this->_redirect('*/*/'); - return; - } - - // try to confirm by email - $email = $this->getRequest()->getPost('email'); - if ($email) { - try { - $customer->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($email); - if (!$customer->getId()) { - throw new Exception(''); - } - if ($customer->getConfirmation()) { - $customer->sendNewAccountEmail('confirmation', '', Mage::app()->getStore()->getId()); - $this->_getSession()->addSuccess($this->__('Please, check your email for confirmation key.')); - } else { - $this->_getSession()->addSuccess($this->__('This email does not require confirmation.')); - } - $this->_getSession()->setUsername($email); - $this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure' => true))); - } catch (Exception $e) { - $this->_getSession()->addException($e, $this->__('Wrong email.')); - $this->_redirectError(Mage::getUrl('*/*/*', array('email' => $email, '_secure' => true))); - } - return; - } - - // output form - $this->loadLayout(); - - $this->getLayout()->getBlock('accountConfirmation') - ->setEmail($this->getRequest()->getParam('email', $email)); - - $this->_initLayoutMessages('Mage_Customer_Model_Session'); - $this->renderLayout(); - } - - /** - * Forgot customer password page - */ - public function forgotPasswordAction() - { - $this->loadLayout(); - - $this->getLayout()->getBlock('forgotPassword')->setEmailValue( - $this->_getSession()->getForgottenEmail() - ); - $this->_getSession()->unsForgottenEmail(); - - $this->_initLayoutMessages('Mage_Customer_Model_Session'); - $this->renderLayout(); - } - - /** - * Forgot customer password action - */ - public function forgotPasswordPostAction() - { - $email = (string) $this->getRequest()->getPost('email'); - if ($email) { - if (!Zend_Validate::is($email, 'EmailAddress')) { - $this->_getSession()->setForgottenEmail($email); - $this->_getSession()->addError($this->__('Invalid email address.')); - $this->_redirect('*/*/forgotpassword'); - return; - } - - /** @var $customer Mage_Customer_Model_Customer */ - $customer = Mage::getModel('Mage_Customer_Model_Customer') - ->setWebsiteId(Mage::app()->getStore()->getWebsiteId()) - ->loadByEmail($email); - - if ($customer->getId()) { - try { - $newResetPasswordLinkToken = Mage::helper('Mage_Customer_Helper_Data')->generateResetPasswordLinkToken(); - $customer->changeResetPasswordLinkToken($newResetPasswordLinkToken); - $customer->sendPasswordResetConfirmationEmail(); - } catch (Exception $exception) { - $this->_getSession()->addError($exception->getMessage()); - $this->_redirect('*/*/forgotpassword'); - return; - } - } - $this->_getSession() - ->addSuccess(Mage::helper('Mage_Customer_Helper_Data')->__('If there is an account associated with %s you will receive an email with a link to reset your password.', Mage::helper('Mage_Customer_Helper_Data')->escapeHtml($email))); - $this->_redirect('*/*/'); - return; - } else { - $this->_getSession()->addError($this->__('Please enter your email.')); - $this->_redirect('*/*/forgotpassword'); - return; - } - } - - /** - * Display reset forgotten password form - * - * User is redirected on this action when he clicks on the corresponding link in password reset confirmation email - * - */ - public function resetPasswordAction() - { - $resetPasswordLinkToken = (string) $this->getRequest()->getQuery('token'); - $customerId = (int) $this->getRequest()->getQuery('id'); - try { - $this->_validateResetPasswordLinkToken($customerId, $resetPasswordLinkToken); - $this->loadLayout(); - // Pass received parameters to the reset forgotten password form - $this->getLayout()->getBlock('resetPassword') - ->setCustomerId($customerId) - ->setResetPasswordLinkToken($resetPasswordLinkToken); - $this->renderLayout(); - } catch (Exception $exception) { - $this->_getSession()->addError(Mage::helper('Mage_Customer_Helper_Data')->__('Your password reset link has expired.')); - $this->_redirect('*/*/forgotpassword'); - } - } - - /** - * Reset forgotten password - * - * Used to handle data recieved from reset forgotten password form - * - */ - public function resetPasswordPostAction() - { - $resetPasswordLinkToken = (string) $this->getRequest()->getQuery('token'); - $customerId = (int) $this->getRequest()->getQuery('id'); - $password = (string) $this->getRequest()->getPost('password'); - $passwordConfirmation = (string) $this->getRequest()->getPost('confirmation'); - - try { - $this->_validateResetPasswordLinkToken($customerId, $resetPasswordLinkToken); - } catch (Exception $exception) { - $this->_getSession()->addError(Mage::helper('Mage_Customer_Helper_Data')->__('Your password reset link has expired.')); - $this->_redirect('*/*/'); - return; - } - - $errorMessages = array(); - if (iconv_strlen($password) <= 0) { - array_push($errorMessages, Mage::helper('Mage_Customer_Helper_Data')->__('New password field cannot be empty.')); - } - /** @var $customer Mage_Customer_Model_Customer */ - $customer = Mage::getModel('Mage_Customer_Model_Customer')->load($customerId); - - $customer->setPassword($password); - $customer->setConfirmation($passwordConfirmation); - $validationErrorMessages = $customer->validate(); - if (is_array($validationErrorMessages)) { - $errorMessages = array_merge($errorMessages, $validationErrorMessages); - } - - if (!empty($errorMessages)) { - $this->_getSession()->setCustomerFormData($this->getRequest()->getPost()); - foreach ($errorMessages as $errorMessage) { - $this->_getSession()->addError($errorMessage); - } - $this->_redirect('*/*/resetpassword', array( - 'id' => $customerId, - 'token' => $resetPasswordLinkToken - )); - return; - } - - try { - // Empty current reset password token i.e. invalidate it - $customer->setRpToken(null); - $customer->setRpTokenCreatedAt(null); - $customer->setConfirmation(null); - $customer->save(); - $this->_getSession()->addSuccess(Mage::helper('Mage_Customer_Helper_Data')->__('Your password has been updated.')); - $this->_redirect('*/*/login'); - } catch (Exception $exception) { - $this->_getSession()->addException($exception, $this->__('Cannot save a new password.')); - $this->_redirect('*/*/resetpassword', array( - 'id' => $customerId, - 'token' => $resetPasswordLinkToken - )); - return; - } - } - - /** - * Check if password reset token is valid - * - * @param int $customerId - * @param string $resetPasswordLinkToken - * @throws Mage_Core_Exception - */ - protected function _validateResetPasswordLinkToken($customerId, $resetPasswordLinkToken) - { - if (!is_int($customerId) - || !is_string($resetPasswordLinkToken) - || empty($resetPasswordLinkToken) - || empty($customerId) - || $customerId < 0 - ) { - throw Mage::exception('Mage_Core', Mage::helper('Mage_Customer_Helper_Data')->__('Invalid password reset token.')); - } - - /** @var $customer Mage_Customer_Model_Customer */ - $customer = Mage::getModel('Mage_Customer_Model_Customer')->load($customerId); - if (!$customer || !$customer->getId()) { - throw Mage::exception('Mage_Core', Mage::helper('Mage_Customer_Helper_Data')->__('Wrong customer account specified.')); - } - - $customerToken = $customer->getRpToken(); - if (strcmp($customerToken, $resetPasswordLinkToken) != 0 || $customer->isResetPasswordLinkTokenExpired()) { - throw Mage::exception('Mage_Core', Mage::helper('Mage_Customer_Helper_Data')->__('Your password reset link has expired.')); - } - } - - /** - * Forgot customer account information page - */ - public function editAction() - { - $this->loadLayout(); - $this->_initLayoutMessages('Mage_Customer_Model_Session'); - $this->_initLayoutMessages('Mage_Catalog_Model_Session'); - - $block = $this->getLayout()->getBlock('customer_edit'); - if ($block) { - $block->setRefererUrl($this->_getRefererUrl()); - } - $data = $this->_getSession()->getCustomerFormData(true); - $customer = $this->_getSession()->getCustomer(); - if (!empty($data)) { - $customer->addData($data); - } - if ($this->getRequest()->getParam('changepass')==1){ - $customer->setChangePassword(1); - } - - $this->getLayout()->getBlock('head')->setTitle($this->__('Account Information')); - $this->getLayout()->getBlock('messages')->setEscapeMessageFlag(true); - $this->renderLayout(); - } - - /** - * Change customer password action - */ - public function editPostAction() - { - if (!$this->_validateFormKey()) { - $this->_redirect('*/*/edit'); - return; - } - - if ($this->getRequest()->isPost()) { - /** @var $customer Mage_Customer_Model_Customer */ - $customer = $this->_getSession()->getCustomer(); - - /** @var $customerForm Mage_Customer_Model_Form */ - $customerForm = Mage::getModel('Mage_Customer_Model_Form'); - $customerForm->setFormCode('customer_account_edit') - ->setEntity($customer); - - $customerData = $customerForm->extractData($this->getRequest()); - - $customerForm->compactData($customerData); - $errors = array(); - - // If password change was requested then add it to common validation scheme - if ($this->getRequest()->getParam('change_password')) { - $currPass = $this->getRequest()->getPost('current_password'); - $newPass = $this->getRequest()->getPost('password'); - $confPass = $this->getRequest()->getPost('confirmation'); - - $oldPass = $this->_getSession()->getCustomer()->getPasswordHash(); - if (Mage::helper('Mage_Core_Helper_String')->strpos($oldPass, ':')) { - list($_salt, $salt) = explode(':', $oldPass); - } else { - $salt = false; - } - - if ($customer->hashPassword($currPass, $salt) == $oldPass) { - if (strlen($newPass)) { - /** - * Set entered password and its confirmation - they - * will be validated later to match each other and be of right length - */ - $customer->setPassword($newPass); - $customer->setConfirmation($confPass); - } else { - $errors[] = $this->__('New password field cannot be empty.'); - } - } else { - $errors[] = $this->__('Invalid current password'); - } - } - - // Validate account and compose list of errors if any - $customerErrors = $customer->validate(); - if (is_array($customerErrors)) { - $errors = array_merge($errors, $customerErrors); - } - - if (!empty($errors)) { - $this->_getSession()->setCustomerFormData($this->getRequest()->getPost()); - foreach ($errors as $message) { - $this->_getSession()->addError($message); - } - $this->_redirect('*/*/edit'); - return; - } - - try { - $customer->setConfirmation(null); - $customer->save(); - $this->_getSession()->setCustomer($customer) - ->addSuccess($this->__('The account information has been saved.')); - - $this->_redirect('customer/account'); - return; - } catch (Mage_Core_Exception $e) { - $this->_getSession()->setCustomerFormData($this->getRequest()->getPost()) - ->addError($e->getMessage()); - } catch (Exception $e) { - $this->_getSession()->setCustomerFormData($this->getRequest()->getPost()) - ->addException($e, $this->__('Cannot save the customer.')); - } - } - - $this->_redirect('*/*/edit'); - } - - /** - * Filtering posted data. Converting localized data if needed - * - * @param array - * @return array - */ - protected function _filterPostData($data) - { - $data = $this->_filterDates($data, array('dob')); - return $data; - } - - /** - * Check whether VAT ID validation is enabled - * - * @param Mage_Core_Model_Store|string|int $store - * @return bool - */ - protected function _isVatValidationEnabled($store = null) - { - return Mage::helper('Mage_Customer_Helper_Address')->isVatValidationEnabled($store); - } -} diff --git a/app/code/core/Mage/Customer/etc/adminhtml/acl.xml b/app/code/core/Mage/Customer/etc/adminhtml/acl.xml deleted file mode 100644 index 2820df64e56d9..0000000000000 --- a/app/code/core/Mage/Customer/etc/adminhtml/acl.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Customer/etc/adminhtml/menu.xml b/app/code/core/Mage/Customer/etc/adminhtml/menu.xml deleted file mode 100644 index 6b4c6bf9b5478..0000000000000 --- a/app/code/core/Mage/Customer/etc/adminhtml/menu.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - diff --git a/app/code/core/Mage/Customer/etc/adminhtml/system.xml b/app/code/core/Mage/Customer/etc/adminhtml/system.xml deleted file mode 100644 index a48dd8b072e3d..0000000000000 --- a/app/code/core/Mage/Customer/etc/adminhtml/system.xml +++ /dev/null @@ -1,254 +0,0 @@ - - - - - - - -
    - separator-top - - customer - Mage_Customer::config_customer - - - 1 - - - Mage_Customer_Model_Config_Share - Mage_Customer_Model_Config_Share - - - - - - - Leave empty for default (15 minutes). - - - - - - - To show VAT number on frontend, set Show VAT Number on Frontend option to Yes. - Mage_Backend_Model_Config_Source_Yesno - - - - Mage_Customer_Model_Config_Source_Address_Type - - 1 - - - - - Mage_Customer_Model_Config_Source_Group - - - - Mage_Customer_Model_Config_Source_Group - - 1 - - - - - Mage_Customer_Model_Config_Source_Group - - 1 - - - - - Mage_Customer_Model_Config_Source_Group - - 1 - - - - - Mage_Customer_Model_Config_Source_Group - - 1 - - - - - Mage_Backend_Model_Config_Source_Yesno - - 1 - - - - - Mage_Backend_Model_Config_Source_Yesno - - - - Mage_Backend_Model_Config_Source_Yesno - - - - - - - Mage_Backend_Model_Config_Source_Email_Template - - - - Mage_Backend_Model_Config_Source_Email_Identity - - - - Mage_Backend_Model_Config_Source_Yesno - - - - Mage_Backend_Model_Config_Source_Email_Template - - - - This email will be sent instead of default welcome email, after account confirmation. - Mage_Backend_Model_Config_Source_Email_Template - - - - Mage_Backend_Model_Config_Source_Yesno - - - - - - - Mage_Backend_Model_Config_Source_Email_Template - - - - Mage_Backend_Model_Config_Source_Email_Template - - - - Mage_Backend_Model_Config_Source_Email_Identity - - - - Please enter a number 1 or greater in this field. - required-entry validate-digits validate-digits-range digits-range-1- - Mage_Customer_Model_Config_Backend_Password_Link_Expirationperiod - - - - - - - Mage_Customer_Model_Config_Backend_Address_Street - Leave empty for default (2). Valid range: 1-4 - - - - Mage_Backend_Model_Config_Source_Nooptreq - Mage_Customer_Model_Config_Backend_Show_Address - The title that goes before name (Mr., Mrs., etc.) - - - - - Put semicolon in the beginning for empty first option.
    Leave empty for open text field.]]> -
    -
    - - - Mage_Backend_Model_Config_Source_Yesno - Always optional. - Mage_Customer_Model_Config_Backend_Show_Address - - - - Mage_Backend_Model_Config_Source_Nooptreq - The suffix that goes after name (Jr., Sr., etc.) - Mage_Customer_Model_Config_Backend_Show_Address - - - - - Put semicolon in the beginning for empty first option.
    Leave empty for open text field.]]> -
    -
    - - - Mage_Backend_Model_Config_Source_Nooptreq - Mage_Customer_Model_Config_Backend_Show_Customer - - - - Mage_Backend_Model_Config_Source_Nooptreq - Mage_Customer_Model_Config_Backend_Show_Customer - - - - Mage_Backend_Model_Config_Source_Nooptreq - Mage_Customer_Model_Config_Backend_Show_Customer - -
    - - - - - Mage_Backend_Model_Config_Source_Yesno - Customer will stay on the current page if "No" is selected. - - - - - - - - - - - - - - - - - - - - -
    -
    - - - Validate VAT Number - Mage_Adminhtml_Block_Customer_System_Config_Validatevat - - -
    -
    -
    diff --git a/app/code/core/Mage/Customer/etc/config.xml b/app/code/core/Mage/Customer/etc/config.xml deleted file mode 100644 index 9e10e7de39e39..0000000000000 --- a/app/code/core/Mage/Customer/etc/config.xml +++ /dev/null @@ -1,250 +0,0 @@ - - - - - - 1.6.2.0.3 - true - core - - - - - - - - -
    - - - Text - - - Text One Line - - - HTML - true - - - PDF - - - JavaScript Template - - -
    -
    - - - - Mage_Customer - Mage_Customer_Model_Resource_Setup - - - - - - - - - Mage_Customer_Model_Observer - beforeAddressSave - - - - - - - Mage_Customer_Model_Observer - afterAddressSave - - - - -
    - - - - - - Mage_Customer.csv - - - - - - - - /customer/ - - - - - - Mage_Customer_Model_Observer - quoteSubmitAfter - - - - - - - standard - - Mage_Customer - customer - - - - - - - - Mage_Customer.csv - - - - - - - - layout.xml - - - - - - - - 1 - - - 0 - 1 - billing - example.com - general - customer_create_account_email_template - customer_create_account_email_confirmation_template - customer_create_account_email_confirmed_template - 0 - - - 1 - - - support - customer_password_forgot_email_template - customer_password_remind_email_template - 1 - -
    - 2 - - - - - - - -
    - - 1 - - - {{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}} -{{depend company}}{{var company}}{{/depend}} -{{if street1}}{{var street1}} -{{/if}} -{{depend street2}}{{var street2}}{{/depend}} -{{depend street3}}{{var street3}}{{/depend}} -{{depend street4}}{{var street4}}{{/depend}} -{{if city}}{{var city}}, {{/if}}{{if region}}{{var region}}, {{/if}}{{if postcode}}{{var postcode}}{{/if}} -{{var country}} -T: {{var telephone}} -{{depend fax}}F: {{var fax}}{{/depend}} -{{depend vat_id}}VAT: {{var vat_id}}{{/depend}} - {{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}}, {{var street}}, {{var city}}, {{var region}} {{var postcode}}, {{var country}} - -{{depend company}}{{var company}}
    {{/depend}} -{{if street1}}{{var street1}}
    {{/if}} -{{depend street2}}{{var street2}}
    {{/depend}} -{{depend street3}}{{var street3}}
    {{/depend}} -{{depend street4}}{{var street4}}
    {{/depend}} -{{if city}}{{var city}}, {{/if}}{{if region}}{{var region}}, {{/if}}{{if postcode}}{{var postcode}}{{/if}}
    -{{var country}}
    -{{depend telephone}}T: {{var telephone}}{{/depend}} -{{depend fax}}
    F: {{var fax}}{{/depend}} -{{depend vat_id}}
    VAT: {{var vat_id}}{{/depend}}]]> - F: {{var fax}}{{/depend}}| -{{depend vat_id}}
    VAT: {{var vat_id}}{{/depend}}|]]>
    - #{company}
    #{street0}
    #{street1}
    #{street2}
    #{street3}
    #{city}, #{region}, #{postcode}
    #{country_id}
    T: #{telephone}
    F: #{fax}
    VAT: #{vat_id}]]>
    -
    -
    -
    -
    diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Container.php b/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Container.php deleted file mode 100644 index 0372430cfda22..0000000000000 --- a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Container.php +++ /dev/null @@ -1,83 +0,0 @@ -addButton('back_button', array( - 'label' => $this->_helperFactory->get('Mage_Catalog_Helper_Data')->__('Back'), - 'onclick' => 'setLocation(\'' . $this->getUrl('*/*') . '\')', - 'class' => 'back' - )); - - parent::_prepareLayout(); - } - - /** - * Get header text - * - * @return string - */ - public function getHeaderText() - { - return $this->_helperFactory->get('Mage_DesignEditor_Helper_Data')->__('Visual Design Editor'); - } - - /** - * @param string $url - * - * @return Mage_DesignEditor_Block_Adminhtml_Editor_Container - */ - public function setFrameUrl($url) - { - $this->_frameUrl = $url; - return $this; - } - - /** - * Retrieve frame url - * - * @return string - */ - public function getFrameUrl() - { - return $this->_frameUrl; - } -} diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/File.php b/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/File.php deleted file mode 100644 index 49a216bbe2a81..0000000000000 --- a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Element/File.php +++ /dev/null @@ -1,50 +0,0 @@ -_htmlAttributes); - } -} - diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons.php b/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons.php deleted file mode 100644 index 8fc41e724f3fb..0000000000000 --- a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons.php +++ /dev/null @@ -1,186 +0,0 @@ -_themeId; - } - - /** - * Get current theme id - * - * @param int $themeId - * @return Mage_DesignEditor_Block_Adminhtml_Editor_Toolbar_Buttons - */ - public function setThemeId($themeId) - { - $this->_themeId = $themeId; - - return $this; - } - - /** - * Get "View Layout" button URL - * - * @return string - */ - public function getViewLayoutUrl() - { - return $this->getUrl('*/*/getLayoutUpdate'); - } - - /** - * Get "Quit" button URL - * - * @return string - */ - public function getQuitUrl() - { - return $this->getUrl('*/*/quit'); - } - - /** - * Get "Navigation Mode" button URL - * - * @return string - */ - public function getNavigationModeUrl() - { - return $this->getUrl('*/*/launch', array( - 'theme_id' => $this->getThemeId(), - 'mode' => Mage_DesignEditor_Model_State::MODE_NAVIGATION - )); - } - - /** - * Get "Design Mode" button URL - * - * @return string - */ - public function getDesignModeUrl() - { - return $this->getUrl('*/*/launch', array( - 'theme_id' => $this->getThemeId(), - 'mode' => Mage_DesignEditor_Model_State::MODE_DESIGN - )); - } - - /** - * Get assign to storeview button - * - * @return string - */ - public function getAssignButtonHtml() - { - /** @var $assignButton Mage_Backend_Block_Widget_Button */ - $assignButton = $this->getLayout()->createBlock('Mage_Backend_Block_Widget_Button'); - $assignButton->setData(array( - 'label' => $this->__('Assign this Theme'), - 'data_attribute' => array( - 'mage-init' => array( - 'button' => array( - 'event' => 'assign', - 'target' => 'body', - 'eventData' => array( - 'theme_id' => $this->getThemeId() - ) - ), - ), - ), - 'class' => 'save action-theme-assign', - 'target' => '_blank' - )); - - return $assignButton->toHtml(); - } - - /** - * Get switch mode button - * - * @return string - */ - public function getSwitchModeButtonHtml() - { - $eventData = array( - 'theme_id' => $this->getThemeId(), - ); - - if ($this->isNavigationMode()) { - $label = $this->__('Design Mode'); - $eventData['mode_url'] = $this->getDesignModeUrl(); - } else { - $label = $this->__('Navigation Mode'); - $eventData['mode_url'] = $this->getNavigationModeUrl(); - $eventData['save_changes_url'] = $this->getSaveTemporaryLayoutUpdateUrl(); - } - - /** @var $switchButton Mage_Backend_Block_Widget_Button */ - $switchButton = $this->getLayout()->createBlock('Mage_Backend_Block_Widget_Button'); - $switchButton->setData(array( - 'label' => $label, - 'data_attribute' => array( - 'mage-init' => array( - 'button' => array( - 'event' => 'switchMode', - 'target' => 'body', - 'eventData' => $eventData - ), - ), - ), - 'class' => 'action-switch-mode', - )); - - return $switchButton->toHtml(); - } - - /** - * Get save temporary layout changes url - * - * @return string - */ - public function getSaveTemporaryLayoutUpdateUrl() - { - return $this->getUrl('*/*/saveTemporaryLayoutUpdate'); - } -} diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/HandlesHierarchy.php b/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/HandlesHierarchy.php deleted file mode 100644 index 13a588e667793..0000000000000 --- a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/HandlesHierarchy.php +++ /dev/null @@ -1,171 +0,0 @@ -_vdeUrlBuilder = $vdeUrlBuilder; - - parent::__construct($request, $layout, $eventManager, $urlBuilder, $translator, $cache, $designPackage, - $session, $storeConfig, $frontController, $helperFactory, $dirs, $logger, $filesystem, $data - ); - } - - /** - * Recursively render each level of the page handles hierarchy - * - * @param array $hierarchy - * @return string - */ - protected function _renderHierarchy(array $hierarchy) - { - if (!$hierarchy) { - return ''; - } - $result = '
      '; - foreach ($hierarchy as $name => $info) { - $linkUrl = $this->_vdeUrlBuilder->getUrl('design/page/type', array('handle' => $name)); - $class = $info['type'] == Mage_Core_Model_Layout_Merge::TYPE_FRAGMENT - ? ' class="vde_option_fragment"' - : ''; - $result .= '
    • '; - $result .= ''; - $result .= $this->escapeHtml($info['label']); - $result .= ''; - $result .= $this->_renderHierarchy($info['children']); - $result .= '
    • '; - } - $result .= '
    '; - return $result; - } - - /** - * Render page handles hierarchy as an HTML list - * - * @return string - */ - public function renderHierarchy() - { - return $this->_renderHierarchy($this->getHierarchy()); - } - - /** - * Retrieve the name of the currently selected page handle - * - * @return string|null - */ - public function getSelectedHandle() - { - if ($this->_selectedHandle === null) { - $pageHandles = $this->getHierarchy(); - $defaultHandle = reset($pageHandles); - if ($defaultHandle !== false) { - $this->_selectedHandle = $defaultHandle['name']; - } - } - return $this->_selectedHandle; - } - - /** - * Retrieve label for the currently selected page handle - * - * @return string|null - */ - public function getSelectedHandleLabel() - { - return $this->escapeHtml($this->getLayout()->getUpdate()->getPageHandleLabel($this->getSelectedHandle())); - } - - /** - * Set the name of the currently selected page handle - * - * @param string $handleName Page handle name - */ - public function setSelectedHandle($handleName) - { - $this->_selectedHandle = $handleName; - } -} diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Tools.php b/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Tools.php deleted file mode 100644 index abf6c77f1e0c8..0000000000000 --- a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Tools.php +++ /dev/null @@ -1,46 +0,0 @@ -getChildHtml('design_editor_tools_design'), - $this->getChildHtml('design_editor_tools_block'), - $this->getChildHtml('design_editor_tools_settings'), - $this->getChildHtml('design_editor_tools_code'), - ); - } -} diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code.php b/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code.php deleted file mode 100644 index 9e4c715a67b48..0000000000000 --- a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code.php +++ /dev/null @@ -1,45 +0,0 @@ -getChildHtml('design_editor_tools_code_css'), - $this->getChildHtml('design_editor_tools_code_js'), - $this->getChildHtml('design_editor_tools_code_custom') - ); - } -} diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Css/Group.php b/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Css/Group.php deleted file mode 100644 index e5c1cb6dcbb41..0000000000000 --- a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Css/Group.php +++ /dev/null @@ -1,66 +0,0 @@ -getUrl('*/system_design_theme/downloadCss', array( - 'theme_id' => $themeId, - 'file' => $this->_helperFactory->get('Mage_Theme_Helper_Data')->urlEncode($fileId) - )); - } - - /** - * Check if files group needs "add" button - * - * @return bool - */ - public function hasAddButton() - { - return false; - } - - /** - * Check if files group needs download buttons next to each file - * - * @return bool - */ - public function hasDownloadButton() - { - return true; - } -} diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Custom.php b/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Custom.php deleted file mode 100644 index f26387cf08a11..0000000000000 --- a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Custom.php +++ /dev/null @@ -1,120 +0,0 @@ - '#', - 'method' => 'post' - )); - $this->setForm($form); - $form->setUseContainer(true); - - $form->addType('css_file', 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_File'); - - $form->addField($this->getFileElementName(), 'css_file', array( - 'name' => $this->getFileElementName(), - 'accept' => 'text/css', - 'no_span' => true - )); - - parent::_prepareForm(); - return $this; - } - - /** - * Get url to download custom CSS file - * - * @param Mage_Core_Model_Theme $theme - * @return string - */ - public function getDownloadCustomCssUrl($theme) - { - return $this->getUrl('*/system_design_theme/downloadCustomCss', array('theme_id' => $theme->getThemeId())); - } - - /** - * Get url to save custom CSS file - * - * @param Mage_Core_Model_Theme $theme - * @return string - */ - public function getSaveCustomCssUrl($theme) - { - return $this->getUrl('*/system_design_editor_tools/saveCssContent', array('theme_id' => $theme->getThemeId())); - } - - /** - * Get theme custom css content - * - * @param Mage_Core_Model_Theme $theme - * @return string - */ - public function getCustomCssContent($theme) - { - /** @var $cssFile Mage_Core_Model_Theme_Files */ - $cssFile = $theme->getCustomizationData(Mage_Core_Model_Theme_Customization_Files_Css::TYPE)->getFirstItem(); - return $cssFile->getContent(); - } - - /** - * Get custom CSS file name - * - * @return string - */ - public function getCustomFileName() - { - return pathinfo(Mage_Core_Model_Theme_Customization_Files_Css::FILE_PATH, PATHINFO_BASENAME); - } - - /** - * Get file element name - * - * @return string - */ - public function getFileElementName() - { - return self::FILE_ELEMENT_NAME; - } -} diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Js.php b/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Js.php deleted file mode 100644 index 37d443fb3861f..0000000000000 --- a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Js.php +++ /dev/null @@ -1,189 +0,0 @@ -_service = $service; - } - - /** - * Create a form element with necessary controls - * - * @return Mage_DesignEditor_Block_Adminhtml_Editor_Tools_Code_Js - */ - protected function _prepareForm() - { - $form = new Varien_Data_Form(array( - 'action' => '#', - 'method' => 'post' - )); - $this->setForm($form); - $form->setUseContainer(true); - - $form->addType('js_files', 'Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_File'); - - $jsConfig = array( - 'name' => 'js_files_uploader', - 'title' => $this->__('Select JS Files to Upload'), - 'accept' => 'application/x-javascript', - 'multiple' => '', - ); - if ($this->_service->isThemeAssignedToStore($this->getTheme())) { - $confirmMessage = $this->__('You are about to upload JavaScript files. ' - . 'This will take effect immediately and might affect the design of your store if your theme ' - . 'is assigned to the store front. Are you sure you want to do this?'); - $jsConfig['onclick'] = "return confirm('{$confirmMessage}');"; - } - $form->addField('js_files_uploader', 'js_files', $jsConfig); - - parent::_prepareForm(); - return $this; - } - - /** - * Return confirmation message for delete action - * - * @return string - */ - public function getConfirmMessageDelete() - { - if ($this->_service->isThemeAssignedToStore($this->getTheme())) { - $confirmMessage = $this->__('Are you sure you want to delete the selected JavaScript file? This operation' - . ' cannot be undone. It will affect the theme and frontend design if the theme is currently assigned' - . ' to the store front'); - } else { - $confirmMessage = $this->__('Are you sure you want to delete the selected JavaScript file? This operation' - . 'cannot be undone. It will affect the theme.'); - } - return $confirmMessage; - } - - /** - * Get upload js url - * - * @return string - */ - public function getJsUploadUrl() - { - return $this->getUrl('*/system_design_editor_tools/uploadjs', array('id' => $this->getTheme()->getId())); - } - - /** - * Get reorder js url - * - * @return string - */ - public function getJsReorderUrl() - { - return $this->getUrl('*/system_design_editor_tools/reorderjs', array('id' => $this->getTheme()->getId())); - } - - /** - * Get delete js url - * - * @return string - */ - public function getJsDeleteUrl() - { - return $this->getUrl('*/system_design_editor_tools/deleteCustomFiles', array( - 'id' => $this->getTheme()->getId() - )); - } - - /** - * Get custom js files - * - * @return Mage_Core_Model_Resource_Theme_Files_Collection - */ - public function getJsFiles() - { - return $this->getTheme()->getCustomizationData(Mage_Core_Model_Theme_Customization_Files_Js::TYPE); - } - - /** - * Get js tab title - * - * @return string - */ - public function getTitle() - { - return $this->__('Custom javascript files'); - } -} diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Design.php b/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Design.php deleted file mode 100644 index a35fc72c110fd..0000000000000 --- a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Design.php +++ /dev/null @@ -1,33 +0,0 @@ -_app = $app; - parent::__construct($request, $layout, $eventManager, $urlBuilder, $translator, $cache, $designPackage, - $session, $storeConfig, $frontController, $helperFactory, $dirs, $logger, $filesystem, $data - ); - } - - /** - * Get tab title - * - * @return string - */ - abstract public function getTabTitle(); - - /** - * Add theme buttons - * - * @param Mage_DesignEditor_Block_Adminhtml_Theme $themeBlock - * @return Mage_DesignEditor_Block_Adminhtml_Theme_Selector_List_Abstract - */ - protected function _addThemeButtons($themeBlock) - { - $themeBlock->clearButtons(); - return $this; - } - - /** - * Get list items of themes - * - * @return array - */ - public function getListItems() - { - /** @var $itemBlock Mage_DesignEditor_Block_Adminhtml_Theme */ - $itemBlock = $this->getChildBlock('theme'); - - $themeCollection = $this->getCollection(); - - $items = array(); - /** @var $theme Mage_Core_Model_Theme */ - foreach ($themeCollection as $theme) { - $itemBlock->setTheme($theme); - $this->_addThemeButtons($itemBlock); - $items[] = $this->getChildHtml('theme', false); - } - - return $items; - } - - /** - * Get assign to storeview button - * - * @param Mage_DesignEditor_Block_Adminhtml_Theme $themeBlock - * @return Mage_DesignEditor_Block_Adminhtml_Theme_Selector_List_Abstract - */ - protected function _addAssignButtonHtml($themeBlock) - { - $themeId = $themeBlock->getTheme()->getId(); - /** @var $assignButton Mage_Backend_Block_Widget_Button */ - $assignButton = $this->getLayout()->createBlock('Mage_Backend_Block_Widget_Button'); - $assignButton->setData(array( - 'label' => $this->__('Assign to a Storeview'), - 'data_attribute' => array( - 'mage-init' => array( - 'button' => array( - 'event' => 'assign', - 'target' => 'body', - 'eventData' => array( - 'theme_id' => $themeId - ) - ), - ), - ), - 'class' => 'save action-theme-assign', - 'target' => '_blank' - )); - - $themeBlock->addButton($assignButton); - return $this; - } - - /** - * Get preview button - * - * @param Mage_DesignEditor_Block_Adminhtml_Theme $themeBlock - * @return Mage_DesignEditor_Block_Adminhtml_Theme_Selector_List_Abstract - */ - protected function _addPreviewButtonHtml($themeBlock) - { - /** @var $previewButton Mage_Backend_Block_Widget_Button */ - $previewButton = $this->getLayout()->createBlock('Mage_Backend_Block_Widget_Button'); - $previewButton->setData(array( - 'label' => $this->__('Preview Theme'), - 'class' => 'action-theme-preview', - 'data_attribute' => array( - 'mage-init' => array( - 'button' => array( - 'event' => 'preview', - 'target' => 'body', - 'eventData' => array( - 'preview_url' => $this->_getPreviewUrl($themeBlock->getTheme()->getId()) - ) - ), - ), - ) - )); - - $themeBlock->addButton($previewButton); - return $this; - } - - /** - * Get edit button - * - * @param Mage_DesignEditor_Block_Adminhtml_Theme $themeBlock - * @return Mage_DesignEditor_Block_Adminhtml_Theme_Selector_List_Abstract - */ - protected function _addEditButtonHtml($themeBlock) - { - /** @var $editButton Mage_Backend_Block_Widget_Button */ - $editButton = $this->getLayout()->createBlock('Mage_Backend_Block_Widget_Button'); - $editButton->setData(array( - 'label' => $this->__('Edit Theme'), - 'class' => 'add action-edit', - 'data_attribute' => array( - 'mage-init' => array( - 'button' => array( - 'event' => 'preview', - 'target' => 'body', - 'eventData' => array( - 'preview_url' => $this->_getEditUrl($themeBlock->getTheme()->getId()) - ) - ), - ), - ) - )); - - $themeBlock->addButton($editButton); - return $this; - } - - /** - * Get preview url for selected theme - * - * @param int $themeId - * @return string - */ - protected function _getPreviewUrl($themeId) - { - return $this->getUrl('*/*/launch', array( - 'theme_id' => $themeId, - 'mode' => Mage_DesignEditor_Model_State::MODE_NAVIGATION - )); - } - - /** - * Get edit theme url for selected theme - * - * @param int $themeId - * @return string - */ - protected function _getEditUrl($themeId) - { - return $this->getUrl('*/*/launch', array( - 'theme_id' => $themeId, - 'mode' => Mage_DesignEditor_Model_State::MODE_DESIGN - )); - } -} diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/List/Available.php b/app/code/core/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/List/Available.php deleted file mode 100644 index fe3b65ea49221..0000000000000 --- a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/List/Available.php +++ /dev/null @@ -1,170 +0,0 @@ -_serviceModel = $serviceModel; - - parent::__construct($request, $layout, $eventManager, $urlBuilder, $translator, $cache, $designPackage, - $session, $storeConfig, $frontController, $helperFactory, $dirs, $logger, $filesystem, $app, $data - ); - } - - /** - * Get service model - * - * @return Mage_Core_Model_Theme_Service - */ - protected function _getServiceModel() - { - return $this->_serviceModel; - } - - /** - * Get tab title - * - * @return string - */ - public function getTabTitle() - { - return $this->__('Available theme list'); - } - - /** - * Get next page url - * - * @return string - */ - public function getNextPageUrl() - { - return $this->getNextPage() <= $this->getCollection()->getLastPageNumber() - ? $this->getUrl('*/*/*', array('page' => $this->getNextPage())) - : ''; - } - - /** - * Get demo button - * - * @param Mage_DesignEditor_Block_Adminhtml_Theme $themeBlock - * @return Mage_DesignEditor_Block_Adminhtml_Theme_Selector_List_Available - */ - protected function _addDemoButtonHtml($themeBlock) - { - /** @var $demoButton Mage_Backend_Block_Widget_Button */ - $demoButton = $this->getLayout()->createBlock('Mage_Backend_Block_Widget_Button'); - $demoButton->setData(array( - 'label' => $this->__('Theme Demo'), - 'class' => 'action-theme-preview', - 'data_attribute' => array( - 'mage-init' => array( - 'button' => array( - 'event' => 'preview', - 'target' => 'body', - 'eventData' => array( - 'preview_url' => $this->_getPreviewUrl($themeBlock->getTheme()->getId()) - ) - ), - ), - ) - )); - - $themeBlock->addButton($demoButton); - return $this; - } - - /** - * Add theme buttons - * - * @param Mage_DesignEditor_Block_Adminhtml_Theme $themeBlock - * @return Mage_DesignEditor_Block_Adminhtml_Theme_Selector_List_Abstract - */ - protected function _addThemeButtons($themeBlock) - { - parent::_addThemeButtons($themeBlock); - - $this->_addDemoButtonHtml($themeBlock)->_addAssignButtonHtml($themeBlock); - - if ($this->_getServiceModel()->isCustomizationsExist()) { - $this->_addEditButtonHtml($themeBlock); - } - - return $this; - } -} diff --git a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/Tabs.php b/app/code/core/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/Tabs.php deleted file mode 100644 index 26f2b95fc8826..0000000000000 --- a/app/code/core/Mage/DesignEditor/Block/Adminhtml/Theme/Selector/Tabs.php +++ /dev/null @@ -1,53 +0,0 @@ -setId('theme_selector_tabs'); - $this->setDestElementId('theme_selector'); - $this->setTitle($this->__('Design & Theme Gallery')); - $this->setIsHoriz(true); - } - - /** - * Add content container to template - * - * @return string - */ - protected function _toHtml() - { - return parent::_toHtml() . '
    '; - } -} diff --git a/app/code/core/Mage/DesignEditor/Block/Page/Html/Head.php b/app/code/core/Mage/DesignEditor/Block/Page/Html/Head.php deleted file mode 100644 index 8d7fe555654d9..0000000000000 --- a/app/code/core/Mage/DesignEditor/Block/Page/Html/Head.php +++ /dev/null @@ -1,63 +0,0 @@ -getLayout()->getBlock('vde_head'); - if ($block) { - // remove all current JS files - foreach (array_keys($this->_data['items']) as $itemKey) { - if (strpos($itemKey, 'js/') === 0) { - unset($this->_data['items'][$itemKey]); - } - } - - // add data from VDE head - $vdeItems = $block->getData('items'); - $this->_data['items'] = array_merge($this->_data['items'], $vdeItems); - } - - return parent::getCssJsHtml(); - } -} diff --git a/app/code/core/Mage/DesignEditor/Block/Page/Html/Head/Vde.php b/app/code/core/Mage/DesignEditor/Block/Page/Html/Head/Vde.php deleted file mode 100644 index 38d031b97ff12..0000000000000 --- a/app/code/core/Mage/DesignEditor/Block/Page/Html/Head/Vde.php +++ /dev/null @@ -1,38 +0,0 @@ -_configuration = $configuration; - } - - /** - * Get VDE front name prefix - * - * @return string - */ - public function getFrontName() - { - return (string)$this->_configuration->getNode(self::XML_PATH_FRONT_NAME); - } - - /** - * Get VDE default handle name - * - * @return string - */ - public function getDefaultHandle() - { - return (string)$this->_configuration->getNode(self::XML_PATH_DEFAULT_HANDLE); - } - - /** - * Get disabled cache types in VDE mode - * - * @return array - */ - public function getDisabledCacheTypes() - { - $cacheTypes = $this->_configuration->getNode(self::XML_PATH_DISABLED_CACHE_TYPES)->asArray(); - return array_keys($cacheTypes); - } - - /** - * Get list of configuration element values - * - * @param string $xmlPath - * @return array - */ - protected function _getElementsList($xmlPath) - { - $elements = array(); - $node = $this->_configuration->getNode($xmlPath); - if ($node) { - $data = $node->asArray(); - if (is_array($data)) { - $elements = array_values($data); - } - } - return $elements; - } - - /** - * Get list of allowed blocks - * - * @return array - */ - public function getBlockWhiteList() - { - return $this->_getElementsList(self::XML_PATH_BLOCK_WHITE_LIST); - } - - /** - * Get list of not allowed blocks - * - * @return array - */ - public function getBlockBlackList() - { - return $this->_getElementsList(self::XML_PATH_BLOCK_BLACK_LIST); - } - - /** - * Get list of allowed blocks - * - * @return array - */ - public function getContainerWhiteList() - { - return $this->_getElementsList(self::XML_PATH_CONTAINER_WHITE_LIST); - } - - /** - * Get expiration days count - * - * @return string - */ - public function getDaysToExpire() - { - return (int)$this->_configuration->getNode(self::XML_PATH_DAYS_TO_EXPIRE); - } -} diff --git a/app/code/core/Mage/DesignEditor/Model/Layout.php b/app/code/core/Mage/DesignEditor/Model/Layout.php deleted file mode 100644 index 4c2892e9a236d..0000000000000 --- a/app/code/core/Mage/DesignEditor/Model/Layout.php +++ /dev/null @@ -1,433 +0,0 @@ -_wrapperBlock = $wrapperBlock; - $this->_helper = $helper; - parent::__construct($blockFactory, $structure, $argumentProcessor, $translator, $scheduledStructure, $area); - } - - /** - * Set sanitizing flag - * - * @param bool $flag - */ - public function setSanitizing($flag) - { - $this->_sanitationEnabled = $flag; - } - - /** - * Set wrapping flag - * - * @param bool $flag - */ - public function setWrapping($flag) - { - $this->_wrappingEnabled = $flag; - } - - /** - * Replace all inline JavaScript - * - * @return string - */ - public function getOutput() - { - $output = parent::getOutput(); - if (preg_match('/]*>.*<\/body>/is', $output, $body)) { - $oldBody = $body[0]; - // Replace script tags - $newBody = preg_replace('/]*>.*?<\/script>/is', '', $oldBody); - // Replace JS events - foreach ($this->_jsEvents as $event) { - $newBody = preg_replace("/(<[^>]+){$event}\\s*=\\s*(['\"])/is", "$1{$event}-vde=$2", $newBody); - } - // Replace href JS - $newBody = preg_replace('/(<[^>]+)href\s*=\s*([\'"])javascript:/is', '$1href-vde=$2', $newBody); - $output = str_replace($oldBody, $newBody, $output); - } - return $output; - } - - /** - * Replace all potentially dangerous blocks in layout into stubs - * - * It is important to sanitize the references first, because they refer to blocks to check whether they are safe. - * But if the blocks were sanitized before references, then they ALL will be considered safe. - * - * @param Varien_Simplexml_Element $node - */ - public function sanitizeLayout(Varien_Simplexml_Element $node) - { - $this->_sanitizeLayout($node, 'reference'); // it is important to sanitize references first - $this->_sanitizeLayout($node, 'block'); - } - - /** - * Sanitize nodes which names match the specified one - * - * Recursively goes through all underlying nodes - * - * @param Varien_Simplexml_Element $node - * @param string $nodeName - */ - protected function _sanitizeLayout(Varien_Simplexml_Element $node, $nodeName) - { - if ($node->getName() == $nodeName) { - switch ($nodeName) { - case 'block': - $this->_sanitizeBlock($node); - break; - case 'reference': - $this->_sanitizeReference($node); - break; - } - } - foreach ($node->children() as $child) { - $this->_sanitizeLayout($child, $nodeName); - } - } - - /** - * Replace "unsafe" types of blocks into Mage_Core_Block_Template and cut all their actions - * - * A "stub" template will be assigned for the blocks - * - * @param Varien_Simplexml_Element $node - */ - protected function _sanitizeBlock(Varien_Simplexml_Element $node) - { - $type = $node->getAttribute('type'); - if (!$type) { - return; // we encountered a node with name "block", however it doesn't actually define any block... - } - if ($this->_isParentSafe($node) || $this->_isTypeSafe($type)) { - return; - } - $this->_overrideAttribute($node, 'template', 'Mage_DesignEditor::stub.phtml'); - $this->_overrideAttribute($node, 'type', 'Mage_Core_Block_Template'); - $this->_deleteNodes($node, 'action'); - } - - /** - * Get list of allowed containers - * - * @return array - */ - protected function _getContainerWhiteList() - { - if ($this->_containerWhiteList === null) { - $this->_containerWhiteList = $this->_helper->getContainerWhiteList(); - } - return $this->_containerWhiteList; - } - - /** - * Whether parent node of specified node can be considered a safe container - * - * @param Varien_Simplexml_Element $node - * @return bool - */ - protected function _isParentSafe(Varien_Simplexml_Element $node) - { - $parentAttributes = $node->getParent()->attributes(); - if (isset($parentAttributes['name'])) { - if (!in_array($parentAttributes['name'], $this->_getContainerWhiteList())) { - return false; - } - } - return true; - } - - /** - * Get list of allowed blocks - * - * @return array - */ - protected function _getBlockWhiteList() - { - if ($this->_blockWhiteList === null) { - $this->_blockWhiteList = $this->_helper->getBlockWhiteList(); - } - return $this->_blockWhiteList; - } - - /** - * Get list of not allowed blocks - * - * @return array - */ - protected function _getBlockBlackList() - { - if ($this->_blockBlackList === null) { - $this->_blockBlackList = $this->_helper->getBlockBlackList(); - } - return $this->_blockBlackList; - } - - /** - * Check whether the specified type of block can be safely used in layout without required context - * - * @param string $type - * @return bool - */ - protected function _isTypeSafe($type) - { - if (in_array($type, $this->_getBlockBlackList())) { - return false; - } - foreach ($this->_getBlockWhiteList() as $safeType) { - if ('_' !== substr($safeType, -1, 1)) { - if ($type === $safeType) { - return true; - } - } elseif (0 === strpos($type, $safeType)) { - return true; - } - } - return false; - } - - /** - * Add or update specified attribute of a node with specified value - * - * @param Varien_Simplexml_Element $node - * @param string $name - * @param string $value - */ - protected function _overrideAttribute(Varien_Simplexml_Element $node, $name, $value) - { - $attributes = $node->attributes(); - if (isset($attributes[$name])) { - $attributes[$name] = $value; - } else { - $attributes->addAttribute($name, $value); - } - } - - /** - * Delete child nodes by specified name - * - * @param Varien_Simplexml_Element $node - * @param string $name - */ - protected function _deleteNodes(Varien_Simplexml_Element $node, $name) - { - $count = count($node->{$name}); - for ($i = $count; $i >= 0; $i--) { - unset($node->{$name}[$i]); - } - } - - /** - * Cleanup reference node according to the block it refers to - * - * Look for the block by reference name and if the block is "unsafe", cleanup the reference node from actions - * - * @param Varien_Simplexml_Element $node - */ - protected function _sanitizeReference(Varien_Simplexml_Element $node) - { - $attributes = $node->attributes(); - $name = $attributes['name']; - $result = $node->xpath("//block[@name='{$name}']") ?: array(); - /** @var $block Varien_Simplexml_Element */ - foreach ($result as $block) { - $isTypeSafe = $this->_isTypeSafe($block->getAttribute('type')); - if (!$isTypeSafe || !$this->_isParentSafe($block)) { - $this->_deleteNodes($node, 'action'); - } - break; - } - } - - /** - * Create structure of elements from the loaded XML configuration - */ - public function generateElements() - { - if ($this->_sanitationEnabled) { - $this->sanitizeLayout($this->getNode()); - } - - parent::generateElements(); - } - - /** - * Gets HTML of block element - * - * @param string $name - * @return string - * @throws Magento_Exception - */ - protected function _renderBlock($name) - { - $result = parent::_renderBlock($name); - - if ($this->_wrappingEnabled) { - $block = $this->getBlock($name); - if (strpos(get_class($block), 'Mage_DesignEditor_Block_') !== 0 && $this->isManipulationAllowed($name)) { - $result = $this->_wrapElement($result, $name, false, true); - } - } - - return $result; - } - - /** - * Gets HTML of container element - * - * @param string $name - * @return string - */ - protected function _renderContainer($name) - { - $result = parent::_renderContainer($name); - - if ($this->_wrappingEnabled && $this->hasElement($name)) { - $result = $this->_wrapElement($result, $name, true); - } - - return $result; - } - - /** - * Wrap layout element - * - * @param string $elementContent - * @param string $elementName - * @param bool $isContainer - * @param bool $canManipulate - * @return string - */ - protected function _wrapElement($elementContent, $elementName, $isContainer = false, $canManipulate = false) - { - $elementId = 'vde_element_' . rtrim(strtr(base64_encode($elementName), '+/', '-_'), '='); - $this->_wrapperBlock->setData(array( - 'element_id' => $elementId, - 'element_title' => $this->getElementProperty($elementName, 'label') ?: $elementName, - 'element_html' => $elementContent, - 'is_manipulation_allowed' => $canManipulate, - 'is_container' => $isContainer, - 'element_name' => $elementName, - )); - return $this->_wrapperBlock->toHtml(); - } -} diff --git a/app/code/core/Mage/DesignEditor/Model/Observer.php b/app/code/core/Mage/DesignEditor/Model/Observer.php deleted file mode 100644 index 37daf7487bcf3..0000000000000 --- a/app/code/core/Mage/DesignEditor/Model/Observer.php +++ /dev/null @@ -1,83 +0,0 @@ -_objectManager = $objectManager; - $this->_helper = $helper; - } - - /** - * Clear temporary layout updates and layout links - */ - public function clearLayoutUpdates() - { - $daysToExpire = $this->_helper->getDaysToExpire(); - - // remove expired links - /** @var $linkCollection Mage_Core_Model_Resource_Layout_Link_Collection */ - $linkCollection = $this->_objectManager->create('Mage_Core_Model_Resource_Layout_Link_Collection'); - $linkCollection->addTemporaryFilter(true) - ->addUpdatedDaysBeforeFilter($daysToExpire); - - /** @var $layoutLink Mage_Core_Model_Layout_Link */ - foreach ($linkCollection as $layoutLink) { - $layoutLink->delete(); - } - - // remove expired updates without links - /** @var $layoutCollection Mage_Core_Model_Resource_Layout_Update_Collection */ - $layoutCollection = $this->_objectManager->create('Mage_Core_Model_Resource_Layout_Update_Collection'); - $layoutCollection->addNoLinksFilter() - ->addUpdatedDaysBeforeFilter($daysToExpire); - - /** @var $layoutUpdate Mage_Core_Model_Layout_Update */ - foreach ($layoutCollection as $layoutUpdate) { - $layoutUpdate->delete(); - } - } -} diff --git a/app/code/core/Mage/DesignEditor/Model/State.php b/app/code/core/Mage/DesignEditor/Model/State.php deleted file mode 100644 index e8e43fbaf459d..0000000000000 --- a/app/code/core/Mage/DesignEditor/Model/State.php +++ /dev/null @@ -1,253 +0,0 @@ -_backendSession = $backendSession; - $this->_layoutFactory = $layoutFactory; - $this->_urlModelFactory = $urlModelFactory; - $this->_cacheManager = $cacheManager; - $this->_dataHelper = $dataHelper; - $this->_objectManager = $objectManager; - $this->_designPackage = $designPackage; - $this->_application = $application; - } - - /** - * Update system data for current VDE environment - * - * @param string $areaCode - * @param Mage_Core_Controller_Request_Http $request - * @param Mage_Core_Controller_Varien_ActionAbstract $controller - */ - public function update( - $areaCode, - Mage_Core_Controller_Request_Http $request, - Mage_Core_Controller_Varien_ActionAbstract $controller - ) { - $handle = $request->getParam('handle', ''); - if (empty($handle)) { - $mode = self::MODE_NAVIGATION; - - if (!$request->isAjax()) { - $this->_backendSession->setData(self::CURRENT_HANDLE_SESSION_KEY, $controller->getFullActionName()); - $this->_backendSession->setData(self::CURRENT_URL_SESSION_KEY, $request->getPathInfo()); - } - } else { - $mode = self::MODE_DESIGN; - } - - $this->_backendSession->setData(self::CURRENT_MODE_SESSION_KEY, $mode); - $this->_injectUrlModel($mode); - $this->_injectLayout($mode, $areaCode); - $this->_injectLayoutUpdateResourceModel(); - $this->_setTheme(); - $this->_disableCache(); - } - - /** - * Reset VDE state data - * - * @return Mage_DesignEditor_Model_State - */ - public function reset() - { - $this->_backendSession->unsetData(self::CURRENT_HANDLE_SESSION_KEY) - ->unsetData(self::CURRENT_URL_SESSION_KEY) - ->unsetData(self::CURRENT_MODE_SESSION_KEY); - - return $this; - } - - /** - * Create layout instance that will be used as main layout for whole system - * - * @param string $mode - * @param string $areaCode - */ - protected function _injectLayout($mode, $areaCode) - { - switch ($mode) { - case self::MODE_DESIGN: - $this->_layoutFactory->createLayout(array('area' => $areaCode), self::LAYOUT_DESIGN_CLASS_NAME); - break; - case self::MODE_NAVIGATION: - default: - $this->_layoutFactory->createLayout(array('area' => $areaCode), self::LAYOUT_NAVIGATION_CLASS_NAME); - break; - } - } - - /** - * Create url model instance that will be used instead of Mage_Core_Model_Url in navigation mode - */ - protected function _injectUrlModel($mode) - { - switch ($mode) { - case self::MODE_DESIGN: - $this->_urlModelFactory->replaceClassName(self::URL_MODEL_DESIGN_MODE_CLASS_NAME); - break; - case self::MODE_NAVIGATION: - default: - $this->_urlModelFactory->replaceClassName(self::URL_MODEL_NAVIGATION_MODE_CLASS_NAME); - break; - } - } - - /** - * Replace layout update resource model with custom vde one - */ - protected function _injectLayoutUpdateResourceModel() - { - $this->_objectManager->addAlias(self::LAYOUT_UPDATE_RESOURCE_MODEL_CORE_CLASS_NAME, - self::LAYOUT_UPDATE_RESOURCE_MODEL_VDE_CLASS_NAME - ); - } - - /** - * Set current VDE theme - */ - protected function _setTheme() - { - $themeId = $this->_backendSession->getData('theme_id'); - if ($themeId !== null) { - $this->_application->getStore()->setConfig(Mage_Core_Model_Design_Package::XML_PATH_THEME_ID, $themeId); - } - } - - /** - * Disable some cache types in VDE mode - */ - protected function _disableCache() - { - foreach ($this->_dataHelper->getDisabledCacheTypes() as $cacheCode) { - if ($this->_cacheManager->canUse($cacheCode)) { - $this->_cacheManager->banUse($cacheCode); - } - } - } -} diff --git a/app/code/core/Mage/DesignEditor/Model/Url/Factory.php b/app/code/core/Mage/DesignEditor/Model/Url/Factory.php deleted file mode 100644 index 869611a1654f9..0000000000000 --- a/app/code/core/Mage/DesignEditor/Model/Url/Factory.php +++ /dev/null @@ -1,70 +0,0 @@ -_objectManager = $objectManager; - } - - /** - * Replace name of url model - * - * @param string $className - * @return Mage_DesignEditor_Model_Url_Factory - */ - public function replaceClassName($className) - { - $this->_objectManager->addAlias(self::CLASS_NAME, $className); - - return $this; - } - - /** - * Create url model new instance - * - * @param array $arguments - * @return Mage_Core_Model_Url - */ - public function createFromArray(array $arguments = array()) - { - return $this->_objectManager->create(self::CLASS_NAME, $arguments, false); - } -} diff --git a/app/code/core/Mage/DesignEditor/controllers/Adminhtml/System/Design/Editor/ToolsController.php b/app/code/core/Mage/DesignEditor/controllers/Adminhtml/System/Design/Editor/ToolsController.php deleted file mode 100644 index 6ac9ac6aeaa51..0000000000000 --- a/app/code/core/Mage/DesignEditor/controllers/Adminhtml/System/Design/Editor/ToolsController.php +++ /dev/null @@ -1,230 +0,0 @@ -getRequest()->getParam('theme'); - - /** @var $themeCss Mage_Core_Model_Theme_Customization_Files_Css */ - $themeCss = $this->_objectManager->create('Mage_Core_Model_Theme_Customization_Files_Css'); - - /** @var $serviceModel Mage_Theme_Model_Uploader_Service */ - $serviceModel = $this->_objectManager->get('Mage_Theme_Model_Uploader_Service'); - try { - $theme = $this->_loadTheme($themeId); - - $cssFileContent = $serviceModel->uploadCssFile( - Mage_DesignEditor_Block_Adminhtml_Editor_Tools_Code_Custom::FILE_ELEMENT_NAME - )->getFileContent(); - $themeCss->setDataForSave($cssFileContent); - $themeCss->saveData($theme); - $response = array('error' => false, 'content' => $cssFileContent); - $this->_session->addSuccess($this->__('Success: Theme custom css was saved.')); - } catch (Mage_Core_Exception $e) { - $this->_session->addError($e->getMessage()); - $response = array('error' => true, 'message' => $e->getMessage()); - } catch (Exception $e) { - $errorMessage = $this->__('Cannot upload css file'); - $this->_session->addError($errorMessage); - $response = array('error' => true, 'message' => $errorMessage); - $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); - } - $this->loadLayout(); - $response['message_html'] = $this->getLayout()->getMessagesBlock()->toHtml(); - $this->getResponse()->setBody($this->_objectManager->get('Mage_Core_Helper_Data')->jsonEncode($response)); - } - - /** - * Save custom css file - */ - public function saveCssContentAction() - { - $themeId = $this->getRequest()->getParam('theme_id', false); - $customCssContent = $this->getRequest()->getParam('custom_css_content', null); - try { - if (!$themeId || (null === $customCssContent)) { - throw new InvalidArgumentException('Param "stores" is not valid'); - } - - $theme = $this->_loadTheme($themeId); - - /** @var $themeCss Mage_Core_Model_Theme_Customization_Files_Css */ - $themeCss = $this->_objectManager->create('Mage_Core_Model_Theme_Customization_Files_Css'); - $themeCss->setDataForSave($customCssContent); - $theme->setCustomization($themeCss)->save(); - $response = array('error' => false); - $this->_session->addSuccess($this->__('Theme custom css was saved.')); - } catch (Mage_Core_Exception $e) { - $this->_session->addError($e->getMessage()); - $response = array('error' => true, 'message' => $e->getMessage()); - } catch (Exception $e) { - $errorMessage = $this->__('Cannot save custom css'); - $this->_session->addError($errorMessage); - $response = array('error' => true, 'message' => $errorMessage); - $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); - } - $this->loadLayout(); - $response['message_html'] = $this->getLayout()->getMessagesBlock()->toHtml(); - $this->getResponse()->setBody($this->_objectManager->get('Mage_Core_Helper_Data')->jsonEncode($response)); - } - - /** - * Ajax list of existing javascript files - */ - public function jsListAction() - { - $themeId = $this->getRequest()->getParam('id'); - try { - $theme = $this->_loadTheme($themeId); - $this->loadLayout(); - - /** @var $filesJs Mage_Core_Model_Theme_Customization_Files_Js */ - $filesJs = $this->_objectManager->create('Mage_Core_Model_Theme_Customization_Files_Js'); - $customJsFiles = $theme->setCustomization($filesJs) - ->getCustomizationData(Mage_Core_Model_Theme_Customization_Files_Js::TYPE); - - $jsItemsBlock = $this->getLayout()->getBlock('design_editor_tools_code_js_items'); - $jsItemsBlock->setJsFiles($customJsFiles); - - $result = array('error' => false, 'content' => $jsItemsBlock->toHtml()); - $this->getResponse()->setBody($this->_objectManager->get('Mage_Core_Helper_Data')->jsonEncode($result)); - } catch (Exception $e) { - $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); - } - } - - /** - * Upload js file - */ - public function uploadJsAction() - { - /** @var $serviceModel Mage_Theme_Model_Uploader_Service */ - $serviceModel = $this->_objectManager->get('Mage_Theme_Model_Uploader_Service'); - $themeId = $this->getRequest()->getParam('id'); - try { - $theme = $this->_loadTheme($themeId); - $serviceModel->uploadJsFile('js_files_uploader', $theme, false); - $theme->setCustomization($serviceModel->getJsFiles())->save(); - $this->_forward('jsList'); - return; - } catch (Mage_Core_Exception $e) { - $this->_getSession()->addError($e->getMessage()); - $response = array('error' => true, 'message' => $e->getMessage()); - } catch (Exception $e) { - $errorMessage = $this->__('Cannot upload js file'); - $this->_getSession()->addError($errorMessage); - $response = array('error' => true, 'message' => $errorMessage); - $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); - } - $this->loadLayout(); - $response['message_html'] = $this->getLayout()->getMessagesBlock()->toHtml(); - $this->getResponse()->setBody($this->_objectManager->get('Mage_Core_Helper_Data')->jsonEncode($response)); - } - - /** - * Delete custom file action - */ - public function deleteCustomFilesAction() - { - $themeId = $this->getRequest()->getParam('id'); - $removeJsFiles = (array)$this->getRequest()->getParam('js_removed_files'); - try { - $theme = $this->_loadTheme($themeId); - - /** @var $themeJs Mage_Core_Model_Theme_Customization_Files_Js */ - $themeJs = $this->_objectManager->create('Mage_Core_Model_Theme_Customization_Files_Js'); - $theme->setCustomization($themeJs); - - $themeJs->setDataForDelete($removeJsFiles); - $theme->save(); - - $this->_forward('jsList'); - } catch (Exception $e) { - $this->_redirectUrl($this->_getRefererUrl()); - $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); - } - } - - /** - * Reorder js file - */ - public function reorderJsAction() - { - $themeId = $this->getRequest()->getParam('id'); - $reorderJsFiles = (array)$this->getRequest()->getParam('js_order', array()); - /** @var $themeJs Mage_Core_Model_Theme_Customization_Files_Js */ - $themeJs = $this->_objectManager->create('Mage_Core_Model_Theme_Customization_Files_Js'); - try { - $theme = $this->_loadTheme($themeId); - $themeJs->setJsOrderData($reorderJsFiles); - $theme->setCustomization($themeJs); - $theme->save(); - - $result = array('success' => true); - } catch (Mage_Core_Exception $e) { - $this->_session->addError($e->getMessage()); - $result = array('error' => true, 'message' => $e->getMessage()); - } catch (Exception $e) { - $errorMessage = $this->__('Cannot upload css file'); - $this->_session->addError($errorMessage); - $result = array('error' => true, 'message' => $errorMessage); - $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); - } - $this->loadLayout(); - $result['message_html'] = $this->getLayout()->getMessagesBlock()->toHtml(); - $this->getResponse()->setBody($this->_objectManager->get('Mage_Core_Helper_Data')->jsonEncode($result)); - } - - /** - * Load theme by theme id - * - * Method also checks if theme actually loaded and if theme is virtual or not - * - * @param int $themeId - * @return Mage_Core_Model_Theme - * @throws Mage_Core_Exception - */ - protected function _loadTheme($themeId) - { - /** @var $theme Mage_Core_Model_Theme */ - $theme = $this->_objectManager->create('Mage_Core_Model_Theme'); - if (!$themeId || !$theme->load($themeId)->getId()) { - throw new Mage_Core_Exception($this->__('Theme "%s" was not found.', $themeId)); - } - if (!$theme->isEditable()) { - throw new Mage_Core_Exception($this->__('Theme "%s" is not editable.', $themeId)); - } - return $theme; - } -} diff --git a/app/code/core/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorController.php b/app/code/core/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorController.php deleted file mode 100644 index 9d8cd519a543b..0000000000000 --- a/app/code/core/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorController.php +++ /dev/null @@ -1,567 +0,0 @@ -_doSelectionTheme('firstEntrance'); - } - - /** - * Ajax loading available themes - */ - public function loadThemeListAction() - { - /** @var $coreHelper Mage_Core_Helper_Data */ - $coreHelper = $this->_objectManager->get('Mage_Core_Helper_Data'); - - $page = $this->getRequest()->getParam('page', 1); - $pageSize = $this->getRequest() - ->getParam('page_size', Mage_Core_Model_Resource_Theme_Collection::DEFAULT_PAGE_SIZE); - - try { - $this->loadLayout(); - /** @var $service Mage_Core_Model_Theme_Service */ - $service = $this->_objectManager->get('Mage_Core_Model_Theme_Service'); - - /** @var $collection Mage_Core_Model_Resource_Theme_Collection */ - $collection = $service->getThemes($page, $pageSize); - $this->getLayout()->getBlock('available.theme.list')->setCollection($collection)->setNextPage(++$page); - $this->getResponse()->setBody($coreHelper->jsonEncode( - array('content' => $this->getLayout()->getOutput()) - )); - } catch (Exception $e) { - $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); - $this->getResponse()->setBody($coreHelper->jsonEncode( - array('error' => $this->_helper->__('Theme list can not be loaded')) - )); - } - } - - /** - * Activate the design editor in the session and redirect to the frontend of the selected store - */ - public function launchAction() - { - $themeId = (int)$this->getRequest()->getParam('theme_id', $this->_getSession()->getData('theme_id')); - $mode = (string)$this->getRequest()->getParam('mode', Mage_DesignEditor_Model_State::MODE_DESIGN); - /** @var $theme Mage_Core_Model_Theme */ - $theme = $this->_objectManager->create('Mage_Core_Model_Theme'); - - try { - $theme->load($themeId); - if (!$theme->getId()) { - throw new InvalidArgumentException(sprintf('Theme "%s" was not found.', $themeId)); - } - - if (!$theme->isVirtual()) { - $themeCustomization = $this->_getThemeCustomization($theme); - $this->_redirect('*/*/*/', array( - 'theme_id' => $themeCustomization->getId(), - 'mode' => $mode - )); - return; - } - - $this->_getSession()->setData('theme_id', $theme->getId()); - - /** @var $eventDispatcher Mage_Core_Model_Event_Manager */ - $eventDispatcher = $this->_objectManager->get('Mage_Core_Model_Event_Manager'); - $eventDispatcher->dispatch('design_editor_activate'); - - $customLayoutParams = array('area' => Mage_Core_Model_App_Area::AREA_FRONTEND); - - /** @var $customFrontLayout Mage_Core_Model_Layout_Merge */ - $customFrontLayout = $this->_objectManager->create('Mage_Core_Model_Layout_Merge', - array('arguments' => $customLayoutParams) - ); - $pageTypes = $customFrontLayout->getPageHandlesHierarchy(); - - $this->_setTitle(); - $this->loadLayout(); - - $this->_configureToolsBlock($theme); - - /** @var $toolbarBlock Mage_DesignEditor_Block_Adminhtml_Editor_Toolbar_Buttons */ - $toolbarBlock = $this->getLayout()->getBlock('design_editor_toolbar_buttons'); - $toolbarBlock->setThemeId($themeId) - ->setMode($mode); - - /** @var $hierarchyBlock Mage_DesignEditor_Block_Adminhtml_Editor_Toolbar_HandlesHierarchy */ - $hierarchyBlock = $this->getLayout()->getBlock('design_editor_toolbar_handles_hierarchy'); - if ($hierarchyBlock) { - $hierarchyBlock->setHierarchy($pageTypes) - ->setMode($mode); - } - - /** @var $viewOptionsBlock Mage_DesignEditor_Block_Adminhtml_Editor_Toolbar_ViewOptions */ - $viewOptionsBlock = $this->getLayout()->getBlock('design_editor_toolbar_view_options'); - if ($viewOptionsBlock) { - $viewOptionsBlock->setMode($mode); - } - - /** @var $editorBlock Mage_DesignEditor_Block_Adminhtml_Editor_Container */ - $editorBlock = $this->getLayout()->getBlock('design_editor'); - if ($mode == Mage_DesignEditor_Model_State::MODE_NAVIGATION) { - $currentUrl = $this->_getCurrentUrl(); - } else { - $currentUrl = $this->_getCurrentHandleUrl(); - } - $editorBlock->setFrameUrl($currentUrl); - - $this->renderLayout(); - } catch (Mage_Core_Exception $e) { - $this->_getSession()->addException($e, $e->getMessage()); - $this->_redirect('*/*/'); - return; - } catch (Exception $e) { - $this->_getSession()->addException($e, $this->__('The theme was not found.')); - $this->_redirect('*/*/'); - return; - } - } - - /** - * VDE quit action - */ - public function quitAction() - { - /** @var $state Mage_DesignEditor_Model_State */ - $state = $this->_objectManager->get('Mage_DesignEditor_Model_State'); - $state->reset(); - - /** @var $eventDispatcher Mage_Core_Model_Event_Manager */ - $eventDispatcher = $this->_objectManager->get('Mage_Core_Model_Event_Manager'); - $eventDispatcher->dispatch('design_editor_deactivate'); - - $this->_redirect('*/*/'); - } - - /** - * Assign theme to list of store views - */ - public function assignThemeToStoreAction() - { - $themeId = (int)$this->getRequest()->getParam('theme_id', $this->_getSession()->getData('theme_id')); - $stores = $this->getRequest()->getParam('stores'); - - /** @var $coreHelper Mage_Core_Helper_Data */ - $coreHelper = $this->_objectManager->get('Mage_Core_Helper_Data'); - - try { - if (!is_numeric($themeId)) { - throw new InvalidArgumentException('Theme id is not valid'); - } - - //TODO used until we find a way to convert array to JSON on JS side - $defaultStore = -1; - $emptyStores = -2; - if ($stores == $defaultStore) { - $ids = array_keys(Mage::app()->getStores()); - $stores = array(array_shift($ids)); - } elseif ($stores == $emptyStores) { - $stores = array(); - } - - if (!is_array($stores)) { - throw new InvalidArgumentException('Param "stores" is not valid'); - } - - $this->_saveLayoutUpdate( - $this->getRequest()->getParam('layoutUpdate', array()), - $this->getRequest()->getParam('handle'), - $themeId - ); - /** @var $themeService Mage_Core_Model_Theme_Service */ - $themeService = $this->_objectManager->get('Mage_Core_Model_Theme_Service'); - /** @var $themeCustomization Mage_Core_Model_Theme */ - $themeCustomization = $themeService->assignThemeToStores($themeId, $stores); - - $message = $coreHelper->__('Theme successfully assigned'); - $response = array( - 'success' => $message, - 'themeId' => $themeCustomization->getId() - ); - $this->getResponse()->setBody($coreHelper->jsonEncode(array('success' => $message))); - } catch (Exception $e) { - $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); - $this->getResponse()->setBody($coreHelper->jsonEncode( - array('error' => $this->_helper->__('Theme is not assigned')) - )); - $response = array( - 'error' => true, - 'message' => $this->_helper->__('Theme is not assigned') - ); - } - $this->getResponse()->setBody($coreHelper->jsonEncode($response)); - } - - /** - * Rename title action - */ - public function quickEditAction() - { - $themeId = (int)$this->getRequest()->getParam('theme_id'); - $themeTitle = (string)$this->getRequest()->getParam('theme_title'); - - /** @var $coreHelper Mage_Core_Helper_Data */ - $coreHelper = $this->_objectManager->get('Mage_Core_Helper_Data'); - - try { - /** @var $theme Mage_Core_Model_Theme */ - $theme = $this->_objectManager->get('Mage_Core_Model_Theme'); - if (!($themeId && $theme->load($themeId)->getId())) { - Mage::throwException($this->__('The theme was not found.')); - } - if (!$theme->isVirtual()) { - Mage::throwException($this->__('This theme is not editable.')); - } - $theme->setThemeTitle($themeTitle); - $theme->save(); - $this->getResponse()->setBody($coreHelper->jsonEncode(array('success' => true))); - } catch (Mage_Core_Exception $e) { - $this->getResponse()->setBody($coreHelper->jsonEncode(array( - 'error' => true, - 'message' => $e->getMessage() - ))); - } catch (Exception $e) { - $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); - $this->getResponse()->setBody($coreHelper->jsonEncode( - array('error' => true, 'message' => $this->__('Theme is not saved')) - )); - } - } - - /** - * Get layout xml - */ - public function getLayoutUpdateAction() - { - $historyData = Mage::app()->getRequest()->getPost('historyData'); - if (!$historyData) { - $this->getResponse()->setBody(Mage::helper('Mage_Core_Helper_Data')->jsonEncode( - array(Mage_Core_Model_Message::ERROR => array($this->__('Invalid post data'))) - )); - return; - } - - try { - $layoutUpdate = $this->_compactHistory($historyData); - $this->getResponse()->setBody(Mage::helper('Mage_Core_Helper_Data')->jsonEncode(array( - Mage_Core_Model_Message::SUCCESS => array($layoutUpdate) - ))); - } catch (Mage_Core_Exception $e) { - $this->getResponse()->setBody(Mage::helper('Mage_Core_Helper_Data')->jsonEncode( - array(Mage_Core_Model_Message::ERROR => array($e->getMessage())) - )); - } - } - - /** - * Save temporary layout update - */ - public function saveTemporaryLayoutUpdateAction() - { - $themeId = (int)$this->_getSession()->getData('theme_id'); - /** @var $coreHelper Mage_Core_Helper_Data */ - $coreHelper = $this->_objectManager->get('Mage_Core_Helper_Data'); - - try { - if (!is_numeric($themeId)) { - throw new InvalidArgumentException('Theme id is not valid'); - } - - if ($this->getRequest()->has('layoutUpdate')) { - $this->_saveLayoutUpdate( - $this->getRequest()->getParam('layoutUpdate'), - $this->getRequest()->getParam('handle'), - $themeId, - true - ); - } - $this->getResponse()->setBody($coreHelper->jsonEncode( - array('success' => $this->__('Temporary layout update saved')) - )); - } catch (Exception $e) { - $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); - $this->getResponse()->setBody($coreHelper->jsonEncode( - array('error' => $this->__('Temporary layout update not saved')) - )); - } - } - - /** - * Display available theme list. Only when no customized themes - */ - public function firstEntranceAction() - { - $this->_doSelectionTheme('index'); - } - - /** - * Set page title - */ - protected function _setTitle() - { - $this->_title($this->__('System'))->_title($this->__('Design'))->_title($this->__('Editor')); - } - - /** - * Whether the current user has enough permissions to execute an action - * - * @return bool - */ - protected function _isAllowed() - { - return $this->_objectManager->get('Mage_Core_Model_Authorization')->isAllowed('Mage_DesignEditor::editor'); - } - - /** - * Compact history - * - * @param array $layoutUpdate - * @param string|null $xml - * @return string - */ - protected function _compactHistory($layoutUpdate, $xml = null) - { - /** @var $historyModel Mage_DesignEditor_Model_History */ - $historyModel = $this->_objectManager->create('Mage_DesignEditor_Model_History'); - /** @var $historyCompactModel Mage_DesignEditor_Model_History_Compact */ - $historyCompactModel = $this->_objectManager->create('Mage_DesignEditor_Model_History_Compact'); - /** @var $layoutRenderer Mage_DesignEditor_Model_History_Renderer_LayoutUpdate */ - $layoutRenderer = $this->_objectManager->create('Mage_DesignEditor_Model_History_Renderer_LayoutUpdate'); - /** @var $collection Mage_DesignEditor_Model_Change_Collection */ - $collection = $historyModel->addXmlChanges($xml) - ->addChanges($layoutUpdate) - ->getChanges(); - $historyCompactModel->compact($collection); - $layoutUpdate = $historyModel->output($layoutRenderer, - Mage_DesignEditor_Model_History_Renderer_LayoutUpdate::DEFAULT_HANDLE - ); - - return $layoutUpdate; - } - - /** - * Save layout update - * - * @param array $layoutUpdate - * @param string $handle - * @param int $themeId - * @param bool $isTemporary - */ - protected function _saveLayoutUpdate($layoutUpdate, $handle, $themeId, $isTemporary = false) - { - /** @var $layoutCollection Mage_DesignEditor_Model_Resource_Layout_Update_Collection */ - $layoutCollection = $this->_objectManager - ->create('Mage_DesignEditor_Model_Resource_Layout_Update_Collection'); - $layoutCollection->addStoreFilter(Mage_Core_Model_AppInterface::ADMIN_STORE_ID) - ->addThemeFilter($themeId) - ->addFieldToFilter('handle', $handle) - ->addFieldToFilter('is_vde', true) - ->setOrder('sort_order', Varien_Data_Collection_Db::SORT_ORDER_ASC); - - $xml = ''; - if (!$isTemporary) { - /** @var $item Mage_DesignEditor_Model_Layout_Update */ - foreach ($layoutCollection as $item) { - $xml .= $item->getXml(); - } - } - - if ($xml || $layoutUpdate) { - $layoutUpdateData = array( - 'store_id' => Mage_Core_Model_AppInterface::ADMIN_STORE_ID, - 'theme_id' => $themeId, - 'handle' => $handle, - 'xml' => $this->_compactHistory($layoutUpdate, $xml), - 'is_temporary' => $isTemporary - ); - - if ($isTemporary) { - /** @var $layoutUpdateModel Mage_DesignEditor_Model_Layout_Update */ - $layoutUpdateModel = $layoutCollection->getLastItem(); - $sortOrder = 0; - if ($layoutUpdateModel->getId()) { - $sortOrder = $layoutUpdateModel->getSortOrder() + 1; - } - $layoutUpdateData['sort_order'] = $sortOrder; - $layoutUpdateModel->setData($layoutUpdateData); - } else { - /** @var $layoutUpdateModel Mage_DesignEditor_Model_Layout_Update */ - $layoutUpdateModel = $layoutCollection->getFirstItem(); - $layoutUpdateModel->addData($layoutUpdateData); - - /** @var @item Mage_DesignEditor_Model_Layout_Update */ - foreach ($layoutCollection as $item) { - if ($item->getId() != $layoutUpdateModel->getId()) { - $item->delete(); - } - } - } - $layoutUpdateModel->save(); - } - } - - /** - * Get theme customization - * - * @param Mage_Core_Model_Theme $theme - * @return Mage_Core_Model_Theme - */ - protected function _getThemeCustomization($theme) - { - /** @var $service Mage_Core_Model_Theme_Service */ - $service = $this->_objectManager->get('Mage_Core_Model_Theme_Service'); - return $service->createThemeCustomization($theme); - } - - /** - * Pass CSS files data to the block who need it for rendering - * - * @param Mage_Core_Model_Theme $theme - * @return Mage_DesignEditor_Adminhtml_System_Design_EditorController - */ - protected function _configureToolsBlock($theme) - { - /** @var $customTabBlock Mage_DesignEditor_Block_Adminhtml_Editor_Tools_Code_Custom */ - $customTabBlock = $this->getLayout()->getBlock('design_editor_tools_code_custom'); - if ($customTabBlock) { - $theme->setCustomization($this->_objectManager->create('Mage_Core_Model_Theme_Customization_Files_Css')); - $customTabBlock->setTheme($theme); - } - - /** @var $cssTabBlock Mage_DesignEditor_Block_Adminhtml_Editor_Tools_Code_Css */ - $cssTabBlock = $this->getLayout()->getBlock('design_editor_tools_code_css'); - if ($cssTabBlock) { - /** @var $helper Mage_Core_Helper_Theme */ - $helper = $this->_objectManager->get('Mage_Core_Helper_Theme'); - $cssFiles = $helper->getGroupedCssFiles($theme); - $cssTabBlock->setCssFiles($cssFiles) - ->setThemeId($theme->getId()); - } - - /** @var $jsTabBlock Mage_DesignEditor_Block_Adminhtml_Editor_Tools_Code_Js */ - $jsTabBlock = $this->getLayout()->getBlock('design_editor_tools_code_js'); - if ($jsTabBlock) { - /** @var $jsFileModel Mage_Core_Model_Theme_Customization_Files_Js */ - $jsFileModel = $this->_objectManager->create('Mage_Core_Model_Theme_Customization_Files_Js'); - $theme->setCustomization($jsFileModel); - - $jsTabBlock->setTheme($theme); - } - - return $this; - } - - /** - * Check whether is customized themes in database - * - * @return bool - */ - protected function _isFirstEntrance() - { - /** @var $themeService Mage_Core_Model_Theme_Service */ - $themeService = $this->_objectManager->get('Mage_Core_Model_Theme_Service'); - return !$themeService->isCustomizationsExist(); - } - - /** - * Load layout - * - * @param string $forwardAction - */ - protected function _doSelectionTheme($forwardAction) - { - if ($forwardAction == 'index' xor $this->_isFirstEntrance()) { - $this->_forward($forwardAction); - return; - } - - try { - $this->_setTitle(); - $this->loadLayout(); - $this->_setActiveMenu('Mage_DesignEditor::system_design_editor'); - if (!$this->_isFirstEntrance()) { - /** @var $themeService Mage_Core_Model_Theme_Service */ - $themeService = $this->_objectManager->get('Mage_Core_Model_Theme_Service'); - $this->getLayout()->getBlock('assigned.theme.list')->setCollection( - $themeService->getAssignedThemeCustomizations() - ); - $this->getLayout()->getBlock('unassigned.theme.list')->setCollection( - $themeService->getUnassignedThemeCustomizations() - ); - } - $this->renderLayout(); - } catch (Exception $e) { - $this->_getSession()->addError($this->__('Cannot load list of themes.')); - $this->_redirectUrl($this->_getRefererUrl()); - $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); - } - } - - /** - * Get current handle - * - * @return string - */ - protected function _getCurrentHandleUrl() - { - /** @var $vdeUrlModel Mage_DesignEditor_Model_Url_Handle */ - $vdeUrlModel = $this->_objectManager->get('Mage_DesignEditor_Model_Url_Handle'); - $handle = $this->_getSession()->getData(Mage_DesignEditor_Model_State::CURRENT_HANDLE_SESSION_KEY); - if (empty($handle)) { - $handle = 'default'; - } - - return $vdeUrlModel->getUrl('design/page/type', array('handle' => $handle)); - } - - /** - * Get current url - * - * @return string - */ - protected function _getCurrentUrl() - { - /** @var $vdeUrlModel Mage_DesignEditor_Model_Url_NavigationMode */ - $vdeUrlModel = $this->_objectManager->get('Mage_DesignEditor_Model_Url_NavigationMode'); - $url = $this->_getSession()->getData(Mage_DesignEditor_Model_State::CURRENT_URL_SESSION_KEY); - if (empty($url)) { - $url = ''; - } - - return $vdeUrlModel->getUrl(ltrim($url, '/')); - } -} diff --git a/app/code/core/Mage/DesignEditor/etc/adminhtml/acl.xml b/app/code/core/Mage/DesignEditor/etc/adminhtml/acl.xml deleted file mode 100644 index b2ff7745bdd15..0000000000000 --- a/app/code/core/Mage/DesignEditor/etc/adminhtml/acl.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/DesignEditor/etc/adminhtml/menu.xml b/app/code/core/Mage/DesignEditor/etc/adminhtml/menu.xml deleted file mode 100644 index 251fa7af6fbb2..0000000000000 --- a/app/code/core/Mage/DesignEditor/etc/adminhtml/menu.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - diff --git a/app/code/core/Mage/DesignEditor/etc/config.xml b/app/code/core/Mage/DesignEditor/etc/config.xml deleted file mode 100644 index 43497d7ffef16..0000000000000 --- a/app/code/core/Mage/DesignEditor/etc/config.xml +++ /dev/null @@ -1,161 +0,0 @@ - - - - - - 1.0.0.1 - true - core - - - - - - - - - - - Mage_DesignEditor - Mage_Core_Model_Resource_Setup - - - - - - - - - frontend - Mage_DesignEditor_Controller_Varien_Router_Standard - Mage_Core_Controller_Varien_Action - - - - - - - - - layout.xml - - - - - - standard - - Mage_DesignEditor - design - - - - - - - - - layout.xml - - - - - - - vde - default - - - - - - - 5 - - - - Mage_Core_Block_Template - Mage_Page_Block_ - Mage_DesignEditor_Block_ - Mage_Checkout_Block_Onepage_ - Mage_Customer_Block_Account_Navigation - Mage_Paypal_Block_Express_Review_Details - Mage_Poll_Block_ActivePoll - Mage_Sales_Block_Guest_Links - Mage_Catalog_Block_Product_Compare_Sidebar - Mage_Checkout_Block_Cart_Sidebar - Mage_Wishlist_Block_Customer_Sidebar - Mage_Reports_Block_Product_Viewed - Mage_Reports_Block_Product_Compared - Mage_Sales_Block_Reorder_Sidebar - Mage_Paypal_Block_Express_Shortcut - Mage_PaypalUk_Block_Express_Shortcut - - - Mage_Page_Block_Html_Pager - Mage_Page_Block_Switch - - - - - root - head - after_body_start -
    header
    -
    footer
    - before_body_end - top.links - top.menu -
    -
    -
    -
    - - - - - - Mage_DesignEditor_Adminhtml - - - - - - - - - - 0 0 * * * - - - Mage_DesignEditor_Model_Observer::clearLayoutUpdates - - - - -
    diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/styles.css b/app/code/core/Mage/DesignEditor/view/adminhtml/css/styles.css deleted file mode 100644 index d5f06e2ba6c46..0000000000000 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/css/styles.css +++ /dev/null @@ -1,1493 +0,0 @@ -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category design - * @package Mage_DesignEditor - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ - -/* - Actions look like buttons --------------------------------------- */ -.action-theme-preview, -.action-theme-preview:visited, -.action-theme-assign, -.action-theme-assign:visited, -.action-save, -.action-save:visited { - font-family: 'CallunaSans'; - font-size: 13px; - font-weight: 500; - color: #676056; - position: relative; - display: inline-block; - padding: 4px 10px; - margin-bottom: 0; - line-height: 18px; - text-align: center; - text-decoration: none; - text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75); - vertical-align: top; - cursor: pointer; - background: #ffffff; - background: -moz-linear-gradient(top, #ffffff 0%, #e6e6e6 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ffffff), color-stop(100%, #e6e6e6)); - background: -webkit-linear-gradient(top, #ffffff 0%, #e6e6e6 100%); - background: -o-linear-gradient(top, #ffffff 0%, #e6e6e6 100%); - background: -ms-linear-gradient(top, #ffffff 0%, #e6e6e6 100%); - background: linear-gradient(to bottom, #ffffff 0%, #e6e6e6 100%); - border: 1px solid #c0bcb8; - border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); - border-radius: 4px; - -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); - -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); - box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); - -webkit-touch-callout: none; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} - - - -/* - Actions look like links --------------------------------------- */ -#store-view-window .action-close { - background: none; - border: none; - color: #6d665e; - font-weight: normal; - font-size: 12px; - cursor: pointer; - border-bottom: 1px solid #b5b3af; -} - -#store-view-window .action-close:hover { - color: #000; - border-bottom: 1px solid #000; -} - -/* - Themes Inputs --------------------------------------- */ -.theme input[type=text] { - font: 13px/18px Arial, Helvetica, sans-serif; - display: inline-block; - height: 28px; - padding: 4px 4px; - margin: 0 0 8px; - color: #333; - background-color: #fff; - border: 1px solid #ccc; - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; - box-sizing: border-box; - border-radius: 3px; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - -webkit-transition: border linear 0.2s, box-shadow linear 0.2s; - -moz-transition: border linear 0.2s, box-shadow linear 0.2s; - -ms-transition: border linear 0.2s, box-shadow linear 0.2s; - -o-transition: border linear 0.2s, box-shadow linear 0.2s; - transition: border linear 0.2s, box-shadow linear 0.2s; -} - -.theme input[type=text]:focus { - border-color: rgba(82, 168, 236, 0.8); - outline: 0; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6); - -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6); -} - -/* - Popups --------------------------------------- */ -.fade { - display: none; - position: fixed; - left: 0; - top: 0; - right: 0; - bottom: 0; - background-color: rgba(0, 0, 0, .45); - padding: 15%; - z-index: 999; -} - -.no-rgba .fade { - background-color: #000; - -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=45)"; -} - -.fade .popup { - position: absolute; - left: 35%; - right: 35%; - display: inline-block; - padding: 0; - background: #fff; - font-size: 13px; - min-width: 440px; - box-shadow: 0 2px 10px 0 #333; - border: 0; - border-radius: 0; -} - -.fade .popup-header { - color: #676056; - padding: 18px 50px 18px 24px; - background: #f3efea; -} - -.fade .popup .popup-title { - font: 20px/1 'CallunaSans', Arial, sans-serif; - font-weight: 300; - padding-left: 0; -} - -.fade .popup .actions { - margin: 15px 0 0; -} - -.fade .popup .actions button, -.fade .popup .actions [class^="action-"] { - margin-right: 10px; - vertical-align: baseline; -} - -.fade .popup-footer { - padding: 24px; -} - -.action-close-popup { - position: absolute; - top: 20px; - right: 15px; - width: 20px; - height: 20px; - overflow: hidden; - text-indent: -999em; - cursor: pointer; -} - -.action-close-popup:before { - font-family: 'MUI-Icons'; - font-style: normal; - speak: none; - font-weight: normal; - -webkit-font-smoothing: antialiased; - content: '\e061'; /* close icon */ - font-size: 20px; - color: #676056; - position: absolute; - right: 0; - top: 0; - text-indent: 0; -} - -.action-close-popup:hover:before { - color: #000; -} - -/* - Infinite Scroll --------------------------------------- */ -.infinite_scroll { - position: relative; - max-width: 1300px; - height: 100%; - margin: 0 auto; -} - -/* - Theme Loader --------------------------------------- */ -.theme-loader { - width: 75px; - height: 75px; - border: 1px solid #f98e4e; - position: fixed; - left: 50%; - top: 50%; - margin: -50px 0 0 -50px; - background-color: rgba(255, 246, 237, .8); - text-align: center; - line-height: 100px; -} - -/* - Themes Tabs --------------------------------------- */ -/* TODO: remove after unified tabs implementation */ - -/* - Themes Tabs Panel --------------------------------------- */ -.theme-selector { - border: solid #ccc; - border-width: 0 1px 1px; - overflow: auto; -} - -.theme-selector .ui-tabs-panel { - padding: 20px 20px 0; -} - -/* - Themes --------------------------------------- */ -.themes { - margin: 0 0 40px; - padding: 0; - list-style: none; - overflow: hidden; -} - -.theme { - position: relative; - width: 30%; - float: left; - margin: 0 5% 5% 0; - padding: 40px 0 0; -} - -.eq-ie8 .theme { - margin-right: 3.33%; -} - -@media screen and (min-width: 1280px) { - .theme:nth-child(3n+3) { - margin-right: 0; - } -} - -@media screen and (max-width: 1280px) { - .theme { - width: 47%; - margin-right: 6%; - } - - .theme:nth-child(even) { - margin-right: 0; - } -} - -.theme-content { - position: relative; - border: 1px solid #cac2b5; - background: #f8f8f8; - text-align: center; - min-height: 350px; -} - -.theme-content img { - max-width: 100%; - height: 350px; -} - -.theme-data { - position: absolute; - left: 0; - top: 0; - right: 0; - bottom: 0; - opacity: 0; - text-align: left; - color: #f2ebde; - padding: 15% 10% 0; - background: #242320; - background: -moz-linear-gradient(top, #31302b 0%, #1f1e1c 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #31302b), color-stop(100%, #1f1e1c)); - background: -webkit-linear-gradient(top, #31302b 0%, #1f1e1c 100%); - background: -o-linear-gradient(top, #31302b 0%, #1f1e1c 100%); - background: -ms-linear-gradient(top, #31302b 0%, #1f1e1c 100%); - background: linear-gradient(to bottom, #31302b 0%, #1f1e1c 100%); -} - -.theme-data:hover { - -webkit-transition: opacity .5s ease-in-out; - -moz-transition: opacity .5s ease-in-out; - -ms-transition: opacity .5s ease-in-out; - -o-transition: opacity .5s ease-in-out; - transition: opacity .5s ease-in-out; - opacity: 1; -} - -.theme-title { - margin: 0; - color: #f2ebde; - font-family: 'CallunaSans', Arial, sans-serif; - font-weight: 200; - font-size: 24px; -} - -.theme-data p { - max-height: 50%; - margin: 20px 0 30px 0; - font: 14px/1.5 Arial, Helvetica, sans-serif; - color: #B9B4AA; - overflow: hidden; -} - -.theme-data .actions { - text-align: right; - position: absolute; - bottom: 30px; - left: 10%; - right: 10%; - white-space: nowrap; -} - -.theme-data .actions [class^='action-'] { - margin-left: 8px; -} - -.theme-data .action-theme-preview:hover, -.theme-data .action-theme-preview:active, -.theme-data .action-theme-assign:hover, -.theme-data .action-theme-assign:active { - background: #31302b; - border-color: #31302b; - color: #fff; - text-shadow: none; - box-shadow: none; -} - -.theme-data .action-edit, -.theme-data .action-delete, -.theme-data .action-edit:active, -.theme-data .action-delete:active { - background: none; - border: none; - text-decoration: none; - display: inline-block; - box-shadow: none; - color: #fff; - font-size: 16px; - vertical-align: middle; - padding: 5px; -} - -.theme-data .action-edit:before, -.theme-data .action-delete:before { - display: inline-block; - text-indent: 0; - font-family: 'MUI-Icons'; - font-style: normal; - speak: none; - font-weight: normal; - -webkit-font-smoothing: antialiased; - content: "\e05b"; - color: #fff; -} - -.theme-data .actions .action-delete { - margin-left: 0; -} - -.theme-data .action-delete:before { - content: "\e07f"; -} - -.theme-data .action-edit > span, -.theme-data .action-delete > span { - display: none; -} - -/* - My Customizations Tab --------------------------------------- */ -.themes-customizations .theme-data { - opacity: 1; - top: auto; - padding: 0; - height: 70px; -} - -.themes-customizations .theme-data .actions { - bottom: 20px; - left: 0; - right: 10px; -} - -.themes-customizations h3 { - margin-bottom: 16px; -} - -.themes-customizations .theme-title { - color: #000; - font-size: 18px; - position: absolute; - left: 0; - right: 50%; - top: 0; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; -} - -/* - Unassigned Themes --------------------------------------- */ -.themes-unassigned .theme-title { - right: 0; -} - -/* - Theme Title Quick Save Form --------------------------------------- */ -.edit-theme-title-form { - position: absolute; - top: 0; - left: 0; - right: 0; - display: none; -} - -.edit-theme-title-form > input[type="text"] { - width: 70%; -} - -.themes-assigned .edit-theme-title-form { - right: 50%; -} - -.themes-unassigned .edit-theme-title-form > input[type="text"] { - width: 50%; -} - -/* - Applied to storeview --------------------------------------- */ -.theme-assigned-to-storeview { - text-align: right; - position: absolute; - top: 5px; - right: 0; - left: 52%; - margin: 0; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; -} - -.theme-assigned-to-storeview span { - color: #959393; -} - -/* - Websites/Stores/Storeviews List in Popup --------------------------------------- */ -.websites, -.stores, -.storeviews { - margin: 0; - padding: 0; - list-style: none; -} - -.website { - padding: 10px 0 0; -} - -.website-title, -.store-title { - border-bottom: 1px solid #dfdfdf; - padding: 0 24px 5px; -} - -.store-title { - padding-left: 40px; -} - -.storeview { - padding-left: 60px; - margin: 0 0 5px 0; -} - -.storeview-selector-control { - margin: -3px 3px 0 0; -} - -/* - Tools Panel --------------------------------------- */ -.vde-tools { - background: #060708; - color: #fff; - position: fixed; - left: 0; - bottom: 0; - right: 0; - padding: 0 0 52px; - z-index: 900; -} - -.vde-tools-header { - position: absolute; - left: 0; - right: 0; - top: 0; - height: 52px; - background: #32312C; -} - -.vde-tools-header-inner, -.vde-tab-data, -.vde-tab-content-header, -.vde-tools-handler-container, -.vde-tools-footer-inner { - min-width: 1000px; - max-width: 1300px; - margin: 0 auto; -} - -.vde-tools-header-inner, -.vde-tools-footer-inner { - position: relative; -} - -.vde-tools.opened .vde-tools-header-inner:before, -.vde-tools.opened .vde-tools-footer-inner:before, -.custom-code .textarea-container:before, -.custom-code .textarea-container:after { - position: absolute; - left: 0; - top: 52px; - right: 0; - height: 10px; - background: url(Mage_DesignEditor::images/vde-panel-top-shadow.png) repeat-x; - content: ''; - z-index: 1; -} - -.vde-tools.opened .vde-tools-footer-inner:before, -.custom-code .textarea-container:after { - top: -10px; - background-position: 0 -10px; -} - -.vde-tools-header .action-close { - position: absolute; - top: 17px; - right: -7px; - background: none; - border: none; - font-weight: normal; - cursor: pointer; - color: #f2ebde; - z-index: 2; -} - -.vde-tools-header .action-close:hover { - color: #fff; -} - -.vde-tools-header .action-close span { - display: none; -} - -.vde-tools-header .action-close:before { - font-family: 'MUI-Icons'; - font-style: normal; - speak: none; - font-weight: normal; - -webkit-font-smoothing: antialiased; - content: '\e061'; /* close icon */ - font-size: 20px; -} - -.vde-tools-content { - position: relative; - height: 0; - overflow: hidden; -} - -.vde-tools-footer { - position: absolute; - bottom: 0; - left: 0; - right: 0; - background: #32312C; - height: 52px; - z-index: 1001; -} - -.vde-tab-content-inner.hasScroll .vde-tab-data { - left: 9px; -} - -.vde-tools .ui-resizable-handle { - position: absolute; - font-size: 0.1px; - display: block; -} - -.vde-tools .ui-resizable-n { - cursor: n-resize; - width: 10px; - height: 16px; - top: 17px; - left: 0; - background: url(Mage_DesignEditor::images/vde-tools-panel-draggable-handler-bg.png) no-repeat; -} - -.vde-tab-controls { - margin: 0; - padding: 0; - list-style: none; -} - -.vde-tab-controls > .item { - display: inline-block; -} - -.vde-tools-footer .vde-tab-controls > .item > a { - display: inline-block; - width: 52px; - height: 52px; - line-height: 52px; - text-align: center; - -moz-transition: background-color .3s ease; - -webkit-transition: background-color .3s ease; - transition: background-color .3s ease; -} - -.vde-tab-controls > .item > a span { - display: block; - overflow: hidden; - text-indent: -999em; - width: 30px; - height: 27px; - background: url(Mage_DesignEditor::images/vde-tools-main-tabs-icons-sprite.png) no-repeat; - margin: 12px auto 0; -} - -.vde-tab-controls > .item-design > a span { - background-position: 2px 0; -} - -.vde-tab-controls > .item-block > a span { - background-position: -28px 0; -} - -.vde-tab-controls > .item-settings > a span { - background-position: -58px 0; -} - -.vde-tab-controls > .item-code > a span { - background-position: -88px 0; -} - -.vde-tab-controls > .item-design > a:hover span { - background-position: 2px -27px; -} - -.vde-tab-controls > .item-block > a:hover span { - background-position: -28px -27px; -} - -.vde-tab-controls > .item-settings > a:hover span { - background-position: -58px -27px; -} - -.vde-tab-controls > .item-code > a:hover span { - background-position: -88px -27px; -} - -.vde-tab-controls > .item.active > a { - background-color: #000; -} - -.tab-panel { - position: relative; - display: none; -} - -.tab-panel.active { - display: block; -} - -.vde-tools-content-inner { - position: relative; -} - -.vde-tools-content-inner > .vde-tab-content { - -} - -.vde-tools-handler-container { - position: relative; -} - -.vde-tab-content-title { - font: 20px/52px "CallunaSans", Arial, sans-serif; - font-weight: 400; - color: #f2ebde; - text-shadow: 0 -1px 1px #000; - float: left; - margin: 0 28px 0 22px; -} - -.vde-tab-content-inner { - position: relative; - height: 348px; - overflow-y: auto; - background: #000; -} - -.vde-tab-data { - position: relative; - padding: 50px 0; - color: #f2ebde; -} - -.vde-tab-data .title { - font: 24px/1.333 "CallunaSans", Arial, sans-serif; - font-weight: 500; - color: #f2ebde; - margin: 0; -} - -.vde-tab-data .action-download, -.vde-tab-data .action-delete, -.vde-tab-data .action-edit { - display: inline-block; - margin-left: 10px; - float: right; - color: #9f978b; - background: none; - border: none; - padding: 0; - text-decoration: none; - -moz-transition: color .5s ease; - -webkit-transition: color .5s ease; - transition: color .5s ease; -} - -.vde-tab-data .action-download:hover, -.vde-tab-data .action-download:focus, -.vde-tab-data .action-delete:hover, -.vde-tab-data .action-delete:focus, -.vde-tab-data .action-edit:hover, -.vde-tab-data .action-edit:focus { - color: #fff; -} - -.vde-tab-data .action-download:before, -.vde-tab-data .action-delete:before, -.vde-tab-data .action-edit:before { - font-family: 'MUI-Icons'; - font-style: normal; - speak: none; - font-weight: normal; - -webkit-font-smoothing: antialiased; - content: '\e073'; /* download icon (arrow down) */ - font-size: 16px; -} - -.vde-tab-data .action-download span, -.vde-tab-data .action-delete span, -.vde-tab-data .action-edit span { - display: none; -} - -.vde-tab-data .action-delete:before { - content: '\e07f'; /* trash icon */ -} - -.vde-tab-data .action-edit:before { - content: '\e05b'; /* edit icon */ -} - -.vde-tab-content-header .vde-tab-controls { - padding: 8px 0 4px; -} - -.vde-tab-content-header .vde-tab-controls > .item { - float: left; - margin-right: 3px; -} - -.vde-tab-content-header .vde-tab-controls > .item > a { - display: inline-block; - font: 13px "CallunaSans", Arial, sans-serif; - font-weight: 600; - line-height: 40px; - text-align: center; - height: 40px; - padding: 0 22px; - background: #000; - border-radius: 5px; - color: #ccc; - text-transform: uppercase; - text-decoration: none; -} - -.vde-tab-content-header .vde-tab-controls > .item.active > a { - height: 44px; - border-radius: 5px 5px 0 0; -} - -/* - Files List Block --------------------------------------- */ -.files-list { - display: block; - float: left; - margin-left: 14.127659574%; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - -ms-box-sizing: border-box; - box-sizing: border-box; - width: 23.914893614%; - min-height: 250px; -} - -.files-wrapper .files-list:first-child, -.files-wrapper .files-list:nth-child(3n+1) { - margin-left: 0; -} - -.files-list-header { - position: relative; - margin: 0 0 13px; - padding-right: 20px; - white-space: nowrap; -} - -.files-list-header > .title { - margin: 0; - width: 100%; - overflow: hidden; - text-overflow: ellipsis; -} -.custom-file > .action-add, -.files-list-header > .action-add { - display: inline-block; - position: absolute; - top: 3px; - right: 0; - margin: 6px 0 0 0; - padding: 0; - width: 16px; - height: 16px; - line-height: 16px; - text-align: center; - color: #000; - background: #9f978b; - border-radius: 4px; - text-decoration: none; - -moz-transition: background .5s ease; - -webkit-transition: background .5s ease; - transition: background .5s ease; - overflow: hidden; -} - -.custom-file > .action-add .field-row, -.files-list-header > .action-add .field-row { - display: block; -} - -.custom-file > .action-add input[type="file"], -.files-list-header > .action-add input[type="file"] { - position: absolute; - left:0; - right:0; - top: 0; - bottom:0; - opacity: 0; - width: 16px; - height: 16px; -} - -.custom-file > .action-add:hover, -.custom-file > .action-add:focus, -.files-list-header > .action-add:hover, -.files-list-header > .action-add:focus { - background: #fff; - border-radius: 4px; -} - -.custom-file > .action-add:before, -.files-list-header > .action-add:before { - font-family: 'MUI-Icons'; - font-style: normal; - speak: none; - font-weight: normal; - -webkit-font-smoothing: antialiased; - content: '\e02d'; /* plus icon */ - font-size: 16px; -} - -.eq-ie9 .custom-file > .action-add:before, -.eq-ie9 .files-list-header > .action-add:before { - line-height: 18px !important; -} - -.custom-file > .action-add span, -.files-list-header > .action-add span { - display: none; -} - -.custom-file > .action-add { - position: relative; -} - -.custom-file > .action-download { - top: 2px; -} - -.custom-file > .action-add:before { - font-size: 16px !important; -} - -.files-list-content .items { - margin: 0; - padding: 0; - list-style: none; -} - -.files-list-content .item { - position: relative; - padding: 10px 50px 8px 0; - border-bottom: 1px solid #31302b; - white-space: nowrap; -} - -.files-list-content .item [class^="action-"] { - position: absolute; - top: 10px; - right: 0; -} - -.files-list-content .item .action-edit { - right: 30px; -} - -.files-list-content .item .filename { - display: block; - width: 100%; - text-overflow: ellipsis; - overflow: hidden; -} - -.vde-tab-content-inner .filename { - font: bold 16px/1.333 "Helvetica", Arial, sans-serif; - vertical-align: middle; -} - -/* - JS Tabs --------------------------------------- */ -#vde-tab-js .title { - display: inline; - margin-right: 10px; -} - -#vde-tab-js .files-list-header .action-add { - position: relative; -} - -#vde-tab-js .files-list { - width: 100%; - margin: 0; -} - -#vde-tab-js .files-list .items .item { - display: inline-block; - width: 26%; - margin-right: 3%; -} - -/* - VDE Messages --------------------------------------- */ -.vde-message { - margin: -40px 0 46px; - background: url(Mage_DesignEditor::images/vde-message-bg.gif); - border-bottom: 1px solid #43423D; - border-radius: 5px; - font: 14px/1.666 Helvetica, Arial, sans-serif; -} - -.vde-message > .message-inner { - position: relative; - padding: 20px 45px 15px 20px; -} - -.vde-message .action-close { - padding: 0; - display: inline-block; - position: absolute; - top: 17px; - right: 20px; - width: 16px; - height: 16px; - line-height: 16px; - background: #201f1c; - border-radius: 4px; - color: #8b857b; - text-align: center; - border: none; - -moz-transition: all .5s ease; - -webkit-transition: all .5s ease; - transition: all .5s ease; -} - -@-moz-document url-prefix() { - .vde-message .action-close { - line-height: 14px; - } -} - -.vde-message .action-close:hover { - color: #fff; - background: #000; -} - -.vde-message .action-close:before { - font-family: 'MUI-Icons'; - font-style: normal; - speak: none; - font-weight: normal; - -webkit-font-smoothing: antialiased; - content: '\e061'; /* close icon */ - font-size: 10px; -} - -.vde-message .action-close span { - display: none; -} - -.vde-message .message-content { - -} - -/* - Custom Code --------------------------------------- */ -[class^="custom-code"] { - display: block; - float: left; - margin-left: 2.127659574%; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - -ms-box-sizing: border-box; - box-sizing: border-box; -} - -.custom-code-description { - width: 31.914893614%; - margin-left: 0; -} - -.custom-code-description .custom-file { - position: relative; -} - -.custom-code-description .title, -.custom-code-description p { - margin-bottom: 20px; -} - -.custom-code-description p { - font: 14px/18px Helvetica, Arial, sans-serif; - color: #8d857a; -} - -.custom-code-description [class^="action-"] { - position: relative; - float: right; - margin: 0 0 0 10px; -} - -.custom-code-description [class^="action-"]:before { - font-size: 18px; -} - -.custom-code { - width: 65.95744680199999%; -} - -.custom-code .textarea-container { - position: relative; - border: 1px solid #31302b; - border-radius: 5px; -} - -.custom-code .textarea-container:before, -.custom-code .textarea-container:after { - left: 30px; - right: 20px; -} - -.custom-code .textarea-container:before { - top: 0; -} - -.custom-code .textarea-container:after { - top: auto; - bottom: 5px; -} - -.custom-code textarea { - width: 100%; - background: none; - border: none; - resize: vertical; - font: 14px/18px Helvetica, Arial, sans-serif; - color: #f2ebde; - padding: 20px 0 20px 20px; -} - -.custom-code textarea:focus { - outline: none; -} - -@-moz-document url-prefix() { - .custom-code textarea { - padding-bottom: 3px; - } -} - -.custom-code .action-update { - float: right; - margin: 7px 0 0 0; -} - -.custom-code .action-update, -.custom-code .action-update:visited { - font: 14px/18px 'CallunaSans', Arial, Helvetica, sans-serif; - font-weight: 500; - color: #322e2a; - background: #dbd6ce; - display: inline-block; - padding: 5px 14px; - text-align: center; - text-decoration: none; - vertical-align: top; - cursor: pointer; - border: transparent; - border-radius: 5px; - -webkit-touch-callout: none; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} - -.custom-code .action-update:hover, -.custom-code .action-update:focus { - background: #cac2b5; - color: #322e2a; -} - -.custom-code .action-update:active, -.custom-code .action-update.active { - box-shadow: 0 1px 5px #aaa59b inset; -} - -.custom-code .action-update[disabled], -.custom-code .action-update.disabled, -.custom-code .action-update[disabled]:hover, -.custom-code .action-update.disabled:hover, -.custom-code .action-update[disabled]:focus, -.custom-code .action-update.disabled:focus, -.custom-code .action-update[disabled]:active, -.custom-code .action-update.disabled:active, -.custom-code .action-update[disabled].active, -.custom-code .action-update.disabled.active { - cursor: not-allowed; - opacity: 0.65; - background: #d9d6cf; - box-shadow: none; - text-shadow: none; -} - -/* - VDE --------------------------------------- */ - -#vde_toolbar { - position: fixed; - margin-top: -54pt; - width: 100%; - z-index: 997; - font: 10pt Arial, Helvetica, sans-serif; - color: #555; - text-align: left; - box-shadow: 0 0 4pt 1pt #cbcbcb; -} - -.vde_breadcrumbs, #vde_toolbar_row { - padding: 0 0 0 1em; - height: 26pt; - line-height: 26pt; - vertical-align: middle; -} - -.vde_breadcrumbs { - text-transform: uppercase; - background: white; -} - -#vde_toolbar_row { - background: #f0efe9; - border-top: 1pt solid #dddcd8; - border-bottom: 1pt solid #dddcd8; - position: relative; -} - -#vde_toolbar_row .vde_toolbar_cell { - float: left; - margin-left: -11pt; - margin-right: 10pt; - border-right: 1pt solid transparent; - border-left: 1pt solid transparent; - padding: 0 10pt; - position: relative; -} - -#vde_toolbar_row .vde_toolbar_cell:hover, #vde_toolbar_row .vde_toolbar_cell.active { - background-color: white; - border-right: 1pt solid #deddd9; - border-left: 1pt solid #deddd9; -} - -#vde_toolbar_buttons { - float: right; - z-index: 998; - position: relative; - line-height: 21pt; - padding: 2pt 0; -} - -.action-switch-mode { - float: left; - background: none; - border: 0; - height: 30px; - line-height: 30px; - font-weight: normal; -} - -#vde_toolbar_buttons a.vde_button, -.action-switch-mode { - display: block; - border: 1px solid #c9c6be; - box-shadow: 0 0 1pt 0 #c9c6be; - border-radius: 3pt; - padding: 0 1.7em; - color: #555; - text-decoration: none; - background-image: url(../images/button.png); - background-size: contain; - background-color: #f4f3f1 !important; - float: left; - margin-right: 3px; -} - -#vde_toolbar_buttons a.vde_button:hover, -.action-switch-mode:hover { - box-shadow: 0 0 1pt 1pt #c9c6be; - background-image: url(../images/button_hover.png); -} - -#vde_toolbar_buttons .action-theme-assign { - float: right; - margin-right: 10px; - height: 30px; -} - -#vde_toolbar .item-msg { - border-style: solid; - border-width: 1px; - padding: 4px; -} - -#vde_toolbar .error { - border-color: red; - color: red; -} - -.vde_toolbar_cell_title { - font-weight: bold; - cursor: pointer; - padding-right: 12pt; - background: url(../images/arrow_down.png) right center no-repeat; -} - -.vde_toolbar_cell.active .vde_toolbar_cell_title { - background-image: url(../images/arrow_up.png); -} - -.vde_toolbar_cell_value { - font-weight: normal; -} - -#vde_toolbar_row .vde_toolbar_cell_content, -#vde_toolbar_row .vde_toolbar_cell_content * { - color: #f0efe9; -} - -.vde_toolbar_cell_content { - display: none; - position: absolute; - top: 2.5em; - left: 0; - background: #494949; - padding: .5em 0; - z-index: 190; - min-width: 20em; - margin-top: 1pt; - border-radius: 0 0 5pt 5pt; - -moz-box-shadow: 0 1pt 2pt 1pt #6c6c6c; - -webkit-box-shadow: 0 1pt 2pt 1pt #6c6c6c; - box-shadow: 0 1pt 2pt 1pt #6c6c6c; -} - -.vde_toolbar_cell.active .vde_toolbar_cell_content { - display: block; -} - -.vde_toolbar_cell_content > div { - white-space: nowrap; - vertical-align: middle; - padding: 0 10px; -} - -.vde_toolbar_cell_content .vde_cell_list_item { - padding-left: 18pt; - cursor: pointer; -} - -.vde_toolbar_cell_content .vde_cell_list_group { - padding-left: 5pt; - font-style: italic; - cursor: default; -} - -.vde_toolbar_cell_content .vde_cell_list_item:hover, #vde_handles_tree .jstree-clicked, #vde_handles_tree .jstree-hovered { - background-color: #7b7b7b; -} - -.vde_toolbar_cell_content .checked { - background: url(../images/checked.png) no-repeat 5pt center; -} - -.vde_breadcrumbs a { - font-weight: bold; - text-decoration: none; - color: #2483c7; -} - -.vde_breadcrumbs a:hover { - text-decoration: underline; -} - -.vde_breadcrumbs .vde_breadcrumbs_separator { - margin: 0 .3em; -} - -#visual_design_editor_theme a { - display: block; - text-decoration: none; -} - -#vde_handles_hierarchy .vde_toolbar_cell_content { - padding: 1em .5em 1em 0; -} - -#vde_handles_tree { - max-height: 30em; /* max allowed height */ - overflow: hidden; /* don't display native scrollbars */ - padding-right: .5em; - text-align: left; - background-color: transparent; -} - -#vde_handles_tree li { - overflow: hidden; -} - -#vde_handles_tree a { - margin-left: .5em; - padding: .5em; - width: 100%; -} - -#vde_handles_tree .jstree-clicked, #vde_handles_tree .jstree-hovered { - border: none; -} - -#vde_handles_tree .jstree-closed > .jstree-icon { - background: url(../images/jstree_plus_minus.png) top left no-repeat; -} - -#vde_handles_tree .jstree-open > .jstree-icon { - background: url(../images/jstree_plus_minus.png) top right no-repeat; -} - -#vde_handles_tree .vde_option_fragment a { - color: #eea243; -} - -.vde_container_frame { - border: none; - margin-top: 0; - width: 100%; -} - -/* - Clearfix --------------------------------------- */ -.themes:before, -.themes:after, -.files-list-header:before, -.files-list-header:after, -.vde-tab-data > .tab-panel:before, -.vde-tab-data > .tab-panel:after, -.vde-tab-content-header:before, -.vde-tab-content-header:after, -.clearfix:before, -.clearfix:after { - content: ""; - display: table; -} - -.themes:after, -.files-list-header:after, -.vde-tab-data > .tab-panel:after, -.vde-tab-content-header:after, -.clearfix:after { - clear: both; -} - -/* - Utils --------------------------------------- */ -.hidden { - display: none; -} diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/container.phtml b/app/code/core/Mage/DesignEditor/view/adminhtml/editor/container.phtml deleted file mode 100644 index 62f6daeecfeaa..0000000000000 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/container.phtml +++ /dev/null @@ -1,32 +0,0 @@ - - - -getChildHtml('design_editor_toolbar'); ?> -getChildHtml('theme.selector.storeview'); ?> - -getChildHtml('design_editor_tools'); ?> diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/toolbar/buttons.phtml b/app/code/core/Mage/DesignEditor/view/adminhtml/editor/toolbar/buttons.phtml deleted file mode 100644 index 71f5bd883de1f..0000000000000 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/toolbar/buttons.phtml +++ /dev/null @@ -1,40 +0,0 @@ - - -
    getUiId()?>> - getSwitchModeButtonHtml(); ?> - getAssignButtonHtml(); ?> - isDesignMode()) : ?> - - __('View Layout'); ?> - - - - __('Quit'); ?> - -
    diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools.phtml b/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools.phtml deleted file mode 100644 index c590253ef5a33..0000000000000 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools.phtml +++ /dev/null @@ -1,88 +0,0 @@ - - - -
    -
    -
    - -
    -
    -
    -
    -
    - getTabs()) ?> -
    -
    - -
    - - diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/code.phtml b/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/code.phtml deleted file mode 100644 index 5ed736e0317e7..0000000000000 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/code.phtml +++ /dev/null @@ -1,47 +0,0 @@ - - -
    -
    -

    __('Scripts'); ?>

    - - -
    -
    -
    - getTabs()) ?> -
    -
    -
    - - diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/code/custom.phtml b/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/code/custom.phtml deleted file mode 100644 index 613e9586e0729..0000000000000 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/code/custom.phtml +++ /dev/null @@ -1,99 +0,0 @@ - - - -
    -
    - getChildHtml('messages') ?> -
    -
    -
    __('Custom CSS'); ?>
    -

    __('Update the custom.css file to right in order to overwrite the default styles.'); ?>

    -

    __('Or, replace, delete or download the file:'); ?>

    -
    - getCustomFileName() ?> - - - - __('Upload File'); ?> - getFormHtml() ?> - -
    -
    -
    -
    - -
    - -
    -
    - - - diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/code/js.phtml b/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/code/js.phtml deleted file mode 100644 index 457354d2e5245..0000000000000 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/code/js.phtml +++ /dev/null @@ -1,183 +0,0 @@ - - -
    -
    - getChildHtml('messages') ?> -
    -
    -
    -
    -
    getTitle() ?>
    - - __('Add Files'); ?> - getFormHtml() ?> - -
    -
    -
    -
      - getChildBlock('design.editor.tools.code.js.items')->setJsFiles($this->getJsFiles())->toHtml(); ?> -
    -
    -
    -
    -
    - -
    -
    - {{name}} ({{size}}) -
    -
    -
    -
    -
    -
    - diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/code/js/items.phtml b/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/code/js/items.phtml deleted file mode 100644 index 8165ab3ab7a34..0000000000000 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/code/js/items.phtml +++ /dev/null @@ -1,43 +0,0 @@ - - - -getJsFiles()->count()): ?> -
  • - __('No files found') ?> -
  • - - - getJsFiles() as $file): ?> -
  • - getFileName() ?> - - __('Delete file'); ?> - -
  • - - diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/design.phtml b/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/design.phtml deleted file mode 100644 index cef2ed525613d..0000000000000 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/editor/tools/design.phtml +++ /dev/null @@ -1,38 +0,0 @@ - - - -
    -
    -

    __('Design'); ?>

    -
    -
    -
    - Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat nonproident, sunt in culpa qui officia deserunt mollit anim id est laborum. -
    -
    -
    diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/js/design_editor.js b/app/code/core/Mage/DesignEditor/view/adminhtml/js/design_editor.js deleted file mode 100644 index 6c6fe8800693a..0000000000000 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/js/design_editor.js +++ /dev/null @@ -1,293 +0,0 @@ -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_DesignEditor - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ - -(function($) { - - /** - * Widget block - */ - $.widget( "vde.block", { _create: function() {}} ); - - /** - * Widget panel - */ - $.widget('vde.vde_panel', { - options: { - switchModeEvent: 'switchMode', - loadEvent: 'loaded', - cellSelector: '.vde_toolbar_cell', - handlesHierarchySelector: '#vde_handles_hierarchy', - treeSelector: '#vde_handles_tree', - viewLayoutButtonSelector: '.view-layout', - navigationModeButtonSelector: '.switch-to-navigation', - viewLayoutUrl: null, - navigationModeUrl: null, - editorFrameSelector: null - }, - - _create: function() { - this._initCells(); - this._initViewLayoutButton(); - this._bind(); - }, - - /** - * Bind handlers - * @protected - */ - _bind: function() { - var $body = $('body'); - $body.on(this.options.switchModeEvent, $.proxy(this._onSwitchMode, this)); - - $body.on(this.options.loadEvent, function() { - $body.trigger('contentUpdated'); - }); - }, - - _initCells : function() { - var self = this; - this.element.find( this.options.cellSelector ).each( function(){ - $( this ).is( self.options.handlesHierarchySelector ) ? - $( this ).vde_menu( {treeSelector : self.options.treeSelector, slimScroll:true } ) : - $( this ).vde_menu(); - }); - this.element.find( this.options.cellSelector ).vde_menu(); - }, - - _initViewLayoutButton: function() { - var button = $(this.options.viewLayoutButtonSelector); - this.options.viewLayoutUrl = button.attr('href'); - button.bind( - 'click', $.proxy(this._onViewLayoutButtonClick, this) - ); - }, - - /** - * Switch mode event handler - * @protected - */ - _onSwitchMode: function(event, data) { - if ('save_changes_url' in data) { - this.saveTemporaryLayoutChanges(data.theme_id, data.save_changes_url, data.mode_url) - } else { - document.location = data.mode_url; - } - }, - - _onViewLayoutButtonClick: function(e) { - try { - var historyObject = $(this.options.editorFrameSelector).get(0).contentWindow.vdeHistoryObject; - if (historyObject.getItems().length == 0) { - /** @todo temporary report */ - alert($.mage.__('No changes found.')); - return false; - } - var data = this._preparePostItems(historyObject.getItems()); - var compactXml = this._post(this.options.viewLayoutUrl, data); - alert(compactXml); - } catch (e) { - alert(e.message); - } finally { - return false; - } - }, - - saveTemporaryLayoutChanges: function(themeId, saveChangesUrl, modeUrl) { - try { - var historyObject = $(this.options.editorFrameSelector).get(0).contentWindow.vdeHistoryObject; - if (historyObject.getItems().length != 0) { - var frameUrl = $(this.options.editorFrameSelector).attr('src'); - var data = { - theme_id: themeId, - layoutUpdate: this._preparePostItems(historyObject.getItems()), - handle: frameUrl.split('/handle/')[1].replace(/\//g, '') - }; - $.post(saveChangesUrl, data, function() { - document.location = modeUrl; - }); - } else { - document.location = modeUrl; - } - } catch (e) { - alert(e.message); - } - }, - - _preparePostItems: function(items) { - var postData = {}; - $.each(items, function(index, item){ - postData[index] = item.getPostData(); - }); - return postData; - }, - _post: function(action, data) { - var url = action; - var postResult; - $.ajax({ - url: url, - type: 'POST', - dataType: 'JSON', - data: {historyData: data}, - async: false, - success: function(data) { - if (data.error) { - /** @todo add error validator */ - throw Error($.mage.__('Some problem with save action')); - return; - } - postResult = data.success; - }, - error: function(data) { - throw Error($.mage.__('Some problem with save action')); - } - }); - return postResult; - }, - _destroy: function() { - this.element.find( this.options.cellSelector ).each( function(i, element) { - $(element).data('vde_menu').destroy(); - }); - this._super(); - } - }); - - /** - * Widget page - */ - $.widget('vde.vde_page', { - options: { - frameSelector: 'iframe#vde_container_frame', - containerSelector: '.vde_element_wrapper.vde_container', - panelSelector: '#vde_toolbar_row', - highlightElementSelector: '.vde_element_wrapper', - highlightElementTitleSelector: '.vde_element_title', - highlightCheckboxSelector: '#vde_highlighting', - cookieHighlightingName: 'vde_highlighting', - historyToolbarSelector: '.vde_history_toolbar' - }, - editorFrame: null, - _create: function () { - var self = this; - $(this.options.frameSelector).load(function() { - self.editorFrame = $(this).contents(); - self._initPanel(); - }); - this._bind(); - this._initFrame(); - }, - _initPanel: function () { - $(this.options.panelSelector).vde_panel({editorFrameSelector: this.options.frameSelector}) - }, - _bind: function() { - $(window).on('resize', $.proxy(this._resizeFrame, this)); - }, - _resizeFrame: function() { - if ($(this.options.frameSelector).length) { - var height = $(window).innerHeight(); - var offset = $(this.options.frameSelector).offset(); - $(this.options.frameSelector).height(height - parseInt(offset.top) - 5); - } - }, - _initFrame: function() { - this._resizeFrame(); - } - }); - - /** - * Widget page highlight functionality - */ - var pageBasePrototype = $.vde.vde_page.prototype; - $.widget('vde.vde_page', $.extend({}, pageBasePrototype, { - _create: function () { - pageBasePrototype._create.apply(this, arguments); - if (this.options.highlightElementSelector) { - this._initHighlighting(); - this._bind(); - } - }, - _bind: function () { - pageBasePrototype._bind.apply(this, arguments); - var self = this; - this.element - .on('checked.vde_checkbox', function () { - self._highlight(); - }) - .on('unchecked.vde_checkbox', function () { - self._unhighlight(); - }); - }, - _initHighlighting: function () { - if (this.options.highlightCheckboxSelector) { - $(this.options.highlightCheckboxSelector) - .vde_checkbox(); - } - - this.frameChanged = false; - var self = this; - $(this.options.frameSelector).load(function() { - self.highlightBlocks = {}; - if (self.frameChanged) { - $(self.options.highlightCheckboxSelector).vde_checkbox('setChecked'); - } else { - self.frameChanged = true; - } - }); - }, - _highlight: function () { - var self = this; - this.editorFrame.find(this.options.highlightElementSelector).each(function () { - $(this) - .append(self._getChildren($(this).attr('id'))) - .show() - .children(self.options.highlightElementTitleSelector).slideDown('fast'); - }); - this.highlightBlocks = {}; - }, - _unhighlight: function () { - var self = this; - this.editorFrame.find(this.options.highlightElementSelector).each(function () { - var elem = $(this); - elem.children(self.options.highlightElementTitleSelector).slideUp('fast', function () { - var children = elem.contents(':not(' + self.options.highlightElementTitleSelector + ')'); - var parentId = elem.attr('id'); - children.each(function () { - self._storeChild(parentId, this); - }); - elem.after(children).hide(); - }); - }); - }, - _storeChild: function(parentId, child) { - if (!this.highlightBlocks[parentId]) { - this.highlightBlocks[parentId] = []; - } - this.highlightBlocks[parentId].push(child); - }, - _getChildren: function(parentId) { - return (!this.highlightBlocks[parentId]) ? [] : this.highlightBlocks[parentId]; - } - })); - -})( jQuery ); diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/js/theme-selector.js b/app/code/core/Mage/DesignEditor/view/adminhtml/js/theme-selector.js deleted file mode 100644 index 1338e666f63ca..0000000000000 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/js/theme-selector.js +++ /dev/null @@ -1,419 +0,0 @@ -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category mage - * @package mage - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ -/*jshint jquery:true*/ -(function($) { - $.widget('vde.themeSelector', { - options: { - refreshIframeEvent: 'refreshIframe', - assignEvent: 'assign', - assignSaveEvent: 'assign-save', - previewEvent: 'preview', - editEvent: 'edit', - deleteEvent: 'delete', - loadEvent: 'loaded', - storeView: { - windowSelector: '#store-view-window' - }, - closePopupBtn: '[class^="action-close"]', - assignSaveUrl: null, - afterAssignSaveUrl: null, - storesByThemes: {}, - isMultipleStoreViewMode: null, - frameSelector: 'iframe#vde_container_frame' - }, - - /** - * Identifier of a theme currently processed - * - * It is set in showStoreViews(), used and then cleared in _onAssignSave() - */ - themeId: null, - - /** - * Form creation - * @protected - */ - _create: function() { - this._bind(); - }, - - /** - * Bind handlers - * @protected - */ - _bind: function() { - $('body').on(this.options.refreshIframeEvent, $.proxy(this._onIframeRefresh, this)); - - //this.element is - this.element.on(this.options.assignEvent, $.proxy(this._onAssign, this)); - this.element.on(this.options.assignSaveEvent, $.proxy(this._onAssignSave, this)); - this.element.on(this.options.previewEvent, $.proxy(this._onPreview, this)); - this.element.on(this.options.editEvent, $.proxy(this._onEdit, this)); - this.element.on(this.options.deleteEvent, $.proxy(this._onDelete, this)); - this.element.on('click.closePopup', this.options.closePopupBtn, $.proxy(this._closePopup, this)); - this.element.on('keyup', $.proxy(function(e) { - //ESC button - if (e.keyCode === 27) { - this._closePopup(); - } - }, this)); - this.element.on(this.options.loadEvent, $.proxy(function() { - this.element.trigger('contentUpdated'); - }, this)); - }, - - /** - * Iframe refresh - * @protected - */ - _onIframeRefresh: function() { - $(this.options.frameSelector)[0].contentWindow.location.reload(true); - }, - - /** - * Preview action - * @protected - */ - _onPreview: function(event, data) { - document.location = data.preview_url; - }, - - /** - * Edit action - * @protected - */ - _onEdit: function(event, data) { - document.location = data.edit_url; - }, - - /** - * Delete action - * @protected - */ - _onDelete: function(event, data) { - deleteConfirm($.mage.__('Are you sure you want to do this?'), data.url); - }, - - _closePopup: function(event, data) { - $(this.options.storeView.windowSelector).hide(); - this.themeId = null; - }, - - /** - * Assign event handler - * @protected - */ - _onAssign: function(event, data) { - if (this.options.isMultipleStoreViewMode) { - this.showStoreViews(data.theme_id); - } else { - if (!this._confirm($.mage.__('You are about to change this theme for your live store, are you sure want to do this?'))) { - return; - } - this.assignSaveTheme(data.theme_id, null); - } - }, - - /** - * "Assign Save" button click handler - * @protected - */ - _onAssignSave: function() { - var stores = []; - var checkedValue = 1; - $(this.options.storeView.windowSelector).find('form').serializeArray().each(function(object, index) { - if (parseInt(object.value, 10) === checkedValue) { - stores.push(parseInt(object.name.match('storeviews\\[(\\d+)\\]')[1], 10)); - } - }); - - if (!this._isStoreChanged(this.themeId, stores)) { - alert($.mage.__('No stores were reassigned.')); - return; - } - - var popUp = $(this.options.storeView.windowSelector); - popUp.hide(); - - this.assignSaveTheme(this.themeId, stores); - this.themeId = null; - }, - - /** - * Check if the stores changed - * @protected - */ - _isStoreChanged: function(themeId, storesToAssign) { - var assignedStores = this.options.storesByThemes[themeId] || [] ; - return !(storesToAssign.length === assignedStores.length && - $(storesToAssign).not(assignedStores).length === 0); - }, - - /** - * Assign event handlers - * @protected - */ - _confirm: function(message) { - return confirm(message); - }, - - /** - * Show store-view selector window - * @public - */ - showStoreViews: function(themeId) { - var popUp = $(this.options.storeView.windowSelector); - var storesByThemes = this.options.storesByThemes; - popUp.find('input[type=checkbox]').each(function(index, element) { - element = $(element); - - var storeViewId = parseInt(element.attr('id').replace('storeview_', ''), 10); - element.attr('checked', - !(!storesByThemes[themeId] || storesByThemes[themeId].indexOf(storeViewId) === -1)); - - }); - this.themeId = themeId; - popUp.show(); - }, - - /** - * Send AJAX request to assign theme to store-views - * @public - */ - assignSaveTheme: function(themeId, stores) { - if (!this.options.assignSaveUrl) { - throw Error($.mage.__('Url to assign themes to store is not defined')); - } - - var data = { - theme_id: themeId, - stores: stores - }; - //TODO since we can't convert data to JSON string we use magic numbers - var DEFAULT_STORE = '-1'; - var EMPTY_STORES = '-2'; - if (data.stores === null) { - data.stores = DEFAULT_STORE; - } else if (data.stores.length === 0) { - data.stores = EMPTY_STORES; - } - - if ($(this.options.frameSelector).get(0)) { - var historyObject = $(this.options.frameSelector).get(0).contentWindow.vdeHistoryObject; - if (historyObject && historyObject.getItems().length != 0) { - data.layoutUpdate = this._preparePostItems(historyObject.getItems()); - } - var frameUrl = $(this.options.frameSelector).attr('src'); - var urlParts = frameUrl.split('handle'); - if (urlParts.length > 1) { - data.handle = frameUrl.split('handle')[1].replace(/\//g, ''); - } - } - - $('#messages').html(''); - $.ajax({ - type: 'POST', - url: this.options.assignSaveUrl, - data: data, - dataType: 'json', - success: $.proxy(function(response) { - if (response.error) { - alert($.mage.__('Error') + ': "' + response.message + '".'); - } else { - var defaultStore = 0; - var url = [ - this.options.afterAssignSaveUrl + 'store_id', - stores ? stores[0] : defaultStore, - 'theme_id', - response.themeId - ].join('/'); - this.options.storesByThemes[themeId] = stores; - - document.location = url; - } - }, this), - error: function() { - alert($.mage.__('Error: unknown error.')); - } - }); - }, - - /** - * Prepare items for post request - * - * @param items - * @return {Object} - * @private - */ - _preparePostItems: function(items) { - var postData = {}; - $.each(items, function(index, item){ - postData[index] = item.getPostData(); - }); - return postData; - } - }); - - /** - * Theme quick edit controls - */ - $.widget('vde.themeControl', { - options: { - themeData: null, - saveEventName: 'quickEditSave', - isActive: false - }, - - /** - * Bind widget events - * @protected - */ - _init: function() { - this.options._textControl.on('click.editThemeTitle', $.proxy(this._onEdit, this)); - this.options._saveTitleBtn.on('click.submitForm', $.proxy(function() { - this.options._formControl.trigger('submit'); - return false; - }, this)); - this.options._formControl.on('submit.saveThemeTitle', $.proxy(function() { - this._onSave(); - return false; - }, this)); - this.document - .on('click.cancelEditThemeTitle', $.proxy(this._onCancel, this)) - .on('keyup', $.proxy(function(e) { - //ESC button - if (e.keyCode === 27) { - this._cancelEdit(); - } - }, this)); - }, - - /** - * Widget initialization - * @protected - */ - _create: function() { - this.options._textControl = this.widget().find('.theme-title'); - this.options._inputControl = this.widget().find('.edit-theme-title-form'); - this.options._formControl = this.widget().find('.edit-theme-title-form'); - this.options._saveTitleBtn = this.widget().find('.action-save'); - this.options._control = this.widget().find('.theme-control-title'); - - this.options.themeData = this.widget().data('widget-options'); - }, - - /** - * Edit event - * @protected - */ - _onEdit: function() { - if (this.options.isActive) { - return; - } - this.options.isActive = true; - this.options._textControl.fadeOut(); - this.options._inputControl.fadeIn().focus(); - this._setThemeTitle(this.options.themeData.theme_title); - }, - - /** - * Save changed theme data - * @protected - */ - _onSave: function() { - if(!this.options.isActive) { - return; - } - var params = { - theme_id: this.options.themeData.theme_id, - theme_title: this._getThemeTitle() - }; - $('#messages').html(''); - $.ajax({ - url: this.options.url, - type: 'POST', - dataType: 'json', - data: params, - showLoader: true, - success: $.proxy(function(response) { - if (response.success) { - this.options.themeData.theme_title = this._getThemeTitle(); - this._setThemeTitle(this.options.themeData.theme_title); - } - this._cancelEdit(); - }, this), - error: $.proxy(function() { - this._cancelEdit(); - alert($.mage.__('Error: unknown error.')); - }, this) - }); - }, - - /** - * Get the entered value - * @return {string} - * @protected - */ - _getThemeTitle: function() { - return this.options._inputControl.find('input').val(); - }, - - /** - * Set the saved value - * @param title {string} - * @return {*} - * @protected - */ - _setThemeTitle: function(title) { - this.options._textControl - .text(title) - .attr('title', title); - this.options._inputControl.find('input').val(title); - return this; - }, - - /** - * Cancel saving theme title - * @param event {*} - * @protected - */ - _onCancel: function(event) { - if (this.options.isActive && this.widget().has($(event.target)).length === 0) { - this._cancelEdit(); - } - }, - - /** - * Cancel editing mode - * @protected - */ - _cancelEdit: function() { - this.options.isActive = false; - this.options._textControl.fadeIn(); - this.options._inputControl.fadeOut(); - } - }); - -})(jQuery); diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/layout.xml b/app/code/core/Mage/DesignEditor/view/adminhtml/layout.xml deleted file mode 100644 index aa3c592c99450..0000000000000 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/layout.xml +++ /dev/null @@ -1,150 +0,0 @@ - - - - - - Mage_DesignEditor::js/infinitescroll.js - Mage_DesignEditor::js/theme-selector.js - Mage_DesignEditor::css/styles.css - - - - available_themesavailable.themes.tab - customizationscustomizations.themes.tab - - - - - - - - - - - - - - - - - - - - - Mage_DesignEditor::js/infinitescroll.js - Mage_DesignEditor::js/theme-selector.js - Mage_DesignEditor::css/styles.css - - - - - - - - - - - - - - - - - - - - - - Mage_DesignEditor::editor.phtml - - - jquery/jquery.tabs.js - jquery/jstree/jquery.jstree.js - jquery/slimScroll/slimScroll.min.js - Mage_DesignEditor::js/tools-panel.js - Mage_DesignEditor::js/custom-css.js - Mage_DesignEditor::js/theme-selector.js - Mage_DesignEditor::js/base.js - Mage_DesignEditor::js/design_editor.js - Mage_Adminhtml::jquery/fileUploader/jquery.iframe-transport.js - Mage_Adminhtml::jquery/fileUploader/jquery.fileupload.js - Mage_DesignEditor::css/styles.css - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/theme/available.phtml b/app/code/core/Mage/DesignEditor/view/adminhtml/theme/available.phtml deleted file mode 100644 index 54e5bf5dc8714..0000000000000 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/theme/available.phtml +++ /dev/null @@ -1,42 +0,0 @@ - - - - -
  • -
    - <?php echo $this->getTheme()->getThemeTitle() ?> -
    -

    getTheme()->getThemeTitle() ?>

    - - -
    - getButtonsHtml() ?> -
    -
    -
    -
  • diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/theme/customized.phtml b/app/code/core/Mage/DesignEditor/view/adminhtml/theme/customized.phtml deleted file mode 100644 index 45a9594a8d944..0000000000000 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/theme/customized.phtml +++ /dev/null @@ -1,53 +0,0 @@ - - - -quoteEscape($this->getTheme()->getThemeTitle()); -?> - -
  • -
    - - getQuickSaveButton()->toHtml() ?> -
    -

    - getTheme()->getAssignedStores()): ?> -

    - __('Store View applied to: ')?> - getStoresTitles()) ?> -

    - -
    - <?php echo $themeTitle ?> -
    -
    - getButtonsHtml() ?> -
    -
    -
    -
  • diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/theme/list/customized.phtml b/app/code/core/Mage/DesignEditor/view/adminhtml/theme/list/customized.phtml deleted file mode 100644 index 6e9ddbfa250c4..0000000000000 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/theme/list/customized.phtml +++ /dev/null @@ -1,39 +0,0 @@ - - - -
    -

    getTabTitle() ?>

    -
      - getListItems(); ?> - - - -
    • __('There are no items here') ?>
    • - -
    -
    diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/theme/selector/first_entrance.phtml b/app/code/core/Mage/DesignEditor/view/adminhtml/theme/selector/first_entrance.phtml deleted file mode 100644 index 67878f72ce3dc..0000000000000 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/theme/selector/first_entrance.phtml +++ /dev/null @@ -1,36 +0,0 @@ - - - -
    -

    __('Choose a theme to start with') ?>

    -
    getChildHtml('available.theme.list') ?>
    -
    - - diff --git a/app/code/core/Mage/DesignEditor/view/frontend/js/design_editor.js b/app/code/core/Mage/DesignEditor/view/frontend/js/design_editor.js deleted file mode 100644 index 5080599dfbb05..0000000000000 --- a/app/code/core/Mage/DesignEditor/view/frontend/js/design_editor.js +++ /dev/null @@ -1,386 +0,0 @@ -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_DesignEditor - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ - -(function($) { - /** - * Widget block - */ - $.widget( "vde.block", { _create: function() {}} ); - - /** - * Widget container - */ - $.widget('vde.vde_container', $.ui.sortable, { - options: { - tolerance: 'pointer', - revert: true, - connectWithSelector: '.vde_element_wrapper.vde_container', - placeholder: 'vde_placeholder', - forcePlaceholderSize: true, - hoverClass: 'vde_container_hover', - items: '.vde_element_wrapper.vde_draggable', - helper: 'clone', - appendTo: 'body', - containerSelector: '.vde_container', - highlightClass: 'vde_highlight', - opacityClass: 'vde_opacity_enabled' - }, - _create: function() { - var self = this; - this.element.data('sortable', this); - self.options = $.extend({}, self.options, { - start: function(event, ui) { - self._highlightEmptyContainers(ui.helper); - self.element.vde_container('option', 'connectWith', $(self.options.connectWithSelector) - .not(ui.item)).vde_container('refresh'); - - self.element.addClass(self.options.hoverClass).addClass(self.options.highlightClass); - $(self.options.items).addClass(self.options.opacityClass); - ui.helper.removeClass(self.options.opacityClass); - }, - over: function(event, ui) { - $(self.options.containerSelector).removeClass(self.options.hoverClass); - self.element.addClass(self.options.hoverClass); - - self._highlightEmptyContainers(ui.helper); - }, - stop: function(event, ui) { - $(self.options.containerSelector).removeClass(self.options.hoverClass); - $('.' + self.options.highlightClass).removeClass(self.options.highlightClass); - $(self.options.items).removeClass(self.options.opacityClass); - - self._disableEmptyContainers(); - } - }); - $.ui.sortable.prototype._create.apply(this, arguments); - }, - _highlightEmptyContainers: function(originalElement) { - var self = this; - $(this.options.containerSelector).each(function (index, element) { - if ($(element).find(self.options.items + ':visible').length == 0) { - $(element).addClass(self.options.highlightClass) - .css('min-height', originalElement.outerHeight(true)); - } - }) - }, - _disableEmptyContainers: function(originalElement) { - var self = this; - $(this.options.containerSelector).each(function (index, element) { - if ($(element).find(':visible').length == 0) { - $(element).removeClass(self.options.highlightClass).css('min-height', '0px'); - } - }) - } - }); - - /** - * Widget container with ability to log "move" operations - */ - var containerBasePrototype = $.vde.vde_container.prototype; - $.widget( "vde.vde_container", $.extend({}, containerBasePrototype, { - history: null, - _onDragElementStart: function(event, ui) { - var block = ui.item; - if (this._isBlockDeeplyNested(block)) { - return; - } - - if (this._getContainer(block).data('name') != this.element.data('name')) { - throw Error('Invalid container. Event "start" should be handled only for closest container'); - } - - this.element.bind( this.getEventName('stop', 'history'), { - position: block.index() - }, $.proxy(this._onDragElementStop, this)); - }, - _onDragElementStop: function(event, ui) { - var block = ui.item; - var originContainer = this.element.data('name'); - var originPosition = event.data.position - 1; - var destinationContainer = this._getContainer(block).data('name'); - var destinationPosition = block.index() - 1; - - var containerChanged = destinationContainer != originContainer; - var sortingOrderChanged = destinationPosition != originPosition; - if (containerChanged || sortingOrderChanged) { - var change = $.fn.changeFactory.getInstance('layout'); - change.setData({ - action: 'move', - block: block.data('name'), - origin: { - container: originContainer, - order: originPosition - }, - destination: { - container: destinationContainer, - order: destinationPosition - } - }); - - // This is the dependency of Container on History - this.getHistory().addItem(change); - } - - this.element.unbind( this.getEventName('stop', 'history'), $.proxy(this._onDragElementStop, this)); - }, - _getContainer: function(item) { - return item.parent().closest(this.options.containerSelector); - }, - _isBlockDeeplyNested: function(block) { - return this._getContainer(block).attr('id') != this.element.attr('id'); - }, - getEventName: function(type, namespace) { - var name = this.widgetEventPrefix + type; - if (namespace) { - name = name + '.' + namespace; - } - return name; - }, - setHistory: function(history) { - this.history = history; - this.element.bind( this.getEventName('start', 'history'), $.proxy(this._onDragElementStart, this)); - }, - getHistory: function() { - if (!this.history) { - throw Error('History element should be set before usage'); - } - return this.history; - } - })); - - /** - * Widget history - * - * @TODO can we make this not a widget but global object? - */ - $.widget( "vde.vde_history" , { - widgetEventPrefix: 'history/', - options:{}, - items: [], - _create: function() {}, - getEventName: function(type, namespace) { - var name = this.widgetEventPrefix + type; - if (namespace) { - name = name + '.' + namespace; - } - return name; - }, - addItem: function(change) { - this.items.push(change); - this._trigger('add', null, change); - }, - getItems: function() { - return this.items; - }, - deleteItems: function() { - this.items = []; - } - }); - - /** - * Widget history toolbar - * - * @todo move out from history toolbar send POST data functionality - */ - $.widget( "vde.vde_historyToolbar" , { - options: {}, - _history: null, - _create: function() { - this._initToolbar(); - }, - _initToolbar : function() {}, - _initEventObservers: function() { - this._history.element.bind( - this._history.getEventName('add'), - $.proxy(this._onHistoryAddItem, this) - ); - }, - _onHistoryAddItem: function(e, change) { - this.addItem(change); - }, - setHistory: function(history) { - this._history = history; - this._initEventObservers(); - }, - setItems: function(items) { - //this.deleteItems(); - $.each(items, function(index, item){this.addItem(item)}); - }, - deleteItems: function() { - this.element.find('ul').empty(); - }, - addItem: function(change) { - this.element.find('ul').append('
  • ' + change.getTitle() + '
  • '); - }, - _preparePostItems: function(items) { - var postData = {}; - $.each(items, function(index, item){ - postData[index] = item.getPostData(); - }); - return postData; - }, - _post: function(action, data) { - var postResult; - $.ajax({ - url: action, - type: 'POST', - dataType: 'JSON', - data: data, - async: false, - success: function(data) { - if (data.error) { - /** @todo add error validator */ - throw Error($.mage.__('Some problem with save action')); - } - postResult = data.success; - }, - error: function() { - throw Error($.mage.__('Some problem with save action')); - } - }); - return postResult; - } - }); - - /** - * Widget page - */ - $.widget('vde.vde_connector', { - options: { - containerSelector: '.vde_element_wrapper.vde_container', - highlightElementSelector: '.vde_element_wrapper', - highlightElementTitleSelector: '.vde_element_title', - highlightCheckboxSelector: '#vde_highlighting', - historyToolbarSelector: '.vde_history_toolbar' - }, - _create: function () { - this._initContainers(); - }, - _initContainers: function () { - $(this.options.containerSelector) - .vde_container().disableSelection(); - } - }); - - /** - * Widget page history init - */ - var pagePrototype = $.vde.vde_connector.prototype; - $.widget( "vde.vde_connector", $.extend({}, pagePrototype, { - _create: function() { - pagePrototype._create.apply(this, arguments); - var history = this._initHistory(); - this._initHistoryToolbar(history); - this._initRemoveOperation(history); - this._setHistoryForContainers(history); - }, - _initHistory: function() { - // @TODO can we make this not a widget but global object? - window.vdeHistoryObject = $( window ).vde_history().data('vde_history'); - return window.vdeHistoryObject; - }, - _initHistoryToolbar: function(history) { - if (!history) { - throw new Error('History object is not set'); - } - if ($( this.options.historyToolbarSelector )) { - var toolbar = $( this.options.historyToolbarSelector).vde_historyToolbar().data('vde_historyToolbar'); - if (toolbar) { - toolbar.setHistory(history); - } - } - }, - _initRemoveOperation : function(history) { - $( this.options.highlightElementSelector ).each(function(i, element) { - var widget = $(element).vde_removable().data('vde_removable'); - widget.setHistory(history); - }); - }, - _setHistoryForContainers: function(history) { - $( this.options.containerSelector ).each(function(i, element) { - var widget = $(element).data('vde_container'); - widget.setHistory(history); - }); - }, - _destroy: function() { - //DOM structure can be missed when test executed - var toolbarContainer = $(this.options.historyToolbarSelector); - if (toolbarContainer.length) { - toolbarContainer.vde_historyToolbar('destroy'); - } - $(window).vde_history('destroy'); - if($(this.options.highlightElementSelector).is(':vde-vde_removable')) { - $(this.options.highlightElementSelector).vde_removable('destroy'); - } - if($(this.options.containerSelector).is(':vde-vde_container')) { - $(this.options.containerSelector).vde_container('destroy'); - } - pagePrototype._destroy.call(this); - } - })); - - /** - * Widget removable - */ - $.widget( "vde.vde_removable", { - options: { - relativeButtonSelector: '.vde_element_remove', - containerSelector: '.vde_container' - }, - history: null, - _create: function() { - this._initButtons(); - }, - _initButtons: function() { - var self = this; - // Remember that container can have block inside with their own remove buttons - this.element.children(this.options.relativeButtonSelector) - .css('display', 'block') - .find('a').bind('click', $.proxy(self._onRemoveButtonClick, self)); - }, - _onRemoveButtonClick: function() { - var change = $.fn.changeFactory.getInstance('layout'); - change.setData({ - action: 'remove', - block: this.element.data('name'), - container: this.element.parent().closest(this.options.containerSelector) - }); - - // This is the dependency of Removable on History - this.history.addItem(change); - this.remove(); - }, - setHistory: function(history) { - this.history = history; - }, - remove: function () { - this.element.remove(); - } - }); - - $(document).ready(function( ){ - $(window).vde_connector(); - }); -})( jQuery ); diff --git a/app/code/core/Mage/DesignEditor/view/frontend/layout.xml b/app/code/core/Mage/DesignEditor/view/frontend/layout.xml deleted file mode 100644 index 6e2a39009b68c..0000000000000 --- a/app/code/core/Mage/DesignEditor/view/frontend/layout.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - jquery/jquery.min.js - jquery/jquery-ui.js - mage/jquery-no-conflict.js - head.load.min.js - mage/mage.js - mage/decorate.js - mage/translate.js - jquery/jquery.tmpl.min.js - Mage_DesignEditor::js/design_editor.js - Mage_DesignEditor::js/form_deactivation.js - Mage_DesignEditor::js/change/layout.js - Mage_DesignEditor::css/design.css - - - - - - - diff --git a/app/code/core/Mage/Directory/Block/Data.php b/app/code/core/Mage/Directory/Block/Data.php deleted file mode 100644 index b71e61f8bc2e6..0000000000000 --- a/app/code/core/Mage/Directory/Block/Data.php +++ /dev/null @@ -1,155 +0,0 @@ - - */ -class Mage_Directory_Block_Data extends Mage_Core_Block_Template -{ - public function getLoadrRegionUrl() - { - return $this->getUrl('directory/json/childRegion'); - } - - public function getCountryCollection() - { - $collection = $this->getData('country_collection'); - if (is_null($collection)) { - $collection = Mage::getModel('Mage_Directory_Model_Country')->getResourceCollection() - ->loadByStore(); - $this->setData('country_collection', $collection); - } - - return $collection; - } - - public function getCountryHtmlSelect($defValue=null, $name='country_id', $id='country', $title='Country') - { - Magento_Profiler::start('TEST: '.__METHOD__, array('group' => 'TEST', 'method' => __METHOD__)); - if (is_null($defValue)) { - $defValue = $this->getCountryId(); - } - $cacheKey = 'DIRECTORY_COUNTRY_SELECT_STORE_'.Mage::app()->getStore()->getCode(); - if (Mage::app()->useCache('config') && $cache = Mage::app()->loadCache($cacheKey)) { - $options = unserialize($cache); - } else { - $options = $this->getCountryCollection()->toOptionArray(); - if (Mage::app()->useCache('config')) { - Mage::app()->saveCache(serialize($options), $cacheKey, array('config')); - } - } - $html = $this->getLayout()->createBlock('Mage_Core_Block_Html_Select') - ->setName($name) - ->setId($id) - ->setTitle(Mage::helper('Mage_Directory_Helper_Data')->__($title)) - ->setClass('validate-select') - ->setValue($defValue) - ->setOptions($options) - ->getHtml(); - - Magento_Profiler::stop('TEST: '.__METHOD__); - return $html; - } - - public function getRegionCollection() - { - $collection = $this->getData('region_collection'); - if (is_null($collection)) { - $collection = Mage::getModel('Mage_Directory_Model_Region')->getResourceCollection() - ->addCountryFilter($this->getCountryId()) - ->load(); - - $this->setData('region_collection', $collection); - } - return $collection; - } - - - public function getRegionHtmlSelect() - { - Magento_Profiler::start('TEST: '.__METHOD__, array('group' => 'TEST', 'method' => __METHOD__)); - $cacheKey = 'DIRECTORY_REGION_SELECT_STORE'.Mage::app()->getStore()->getId(); - if (Mage::app()->useCache('config') && $cache = Mage::app()->loadCache($cacheKey)) { - $options = unserialize($cache); - } else { - $options = $this->getRegionCollection()->toOptionArray(); - if (Mage::app()->useCache('config')) { - Mage::app()->saveCache(serialize($options), $cacheKey, array('config')); - } - } - $html = $this->getLayout()->createBlock('Mage_Core_Block_Html_Select') - ->setName('region') - ->setTitle(Mage::helper('Mage_Directory_Helper_Data')->__('State/Province')) - ->setId('state') - ->setClass('required-entry validate-state') - ->setValue(intval($this->getRegionId())) - ->setOptions($options) - ->getHtml(); - Magento_Profiler::start('TEST: '.__METHOD__, array('group' => 'TEST', 'method' => __METHOD__)); - return $html; - } - - public function getCountryId() - { - $countryId = $this->getData('country_id'); - if (is_null($countryId)) { - $countryId = Mage::helper('Mage_Core_Helper_Data')->getDefaultCountry(); - } - return $countryId; - } - - public function getRegionsJs() - { - Magento_Profiler::start('TEST: '.__METHOD__, array('group' => 'TEST', 'method' => __METHOD__)); - $regionsJs = $this->getData('regions_js'); - if (!$regionsJs) { - $countryIds = array(); - foreach ($this->getCountryCollection() as $country) { - $countryIds[] = $country->getCountryId(); - } - $collection = Mage::getModel('Mage_Directory_Model_Region')->getResourceCollection() - ->addCountryFilter($countryIds) - ->load(); - $regions = array(); - foreach ($collection as $region) { - if (!$region->getRegionId()) { - continue; - } - $regions[$region->getCountryId()][$region->getRegionId()] = array( - 'code'=>$region->getCode(), - 'name'=>$region->getName() - ); - } - $regionsJs = Mage::helper('Mage_Core_Helper_Data')->jsonEncode($regions); - } - Magento_Profiler::stop('TEST: '.__METHOD__); - return $regionsJs; - } -} diff --git a/app/code/core/Mage/Directory/Helper/Data.php b/app/code/core/Mage/Directory/Helper/Data.php deleted file mode 100644 index 69bb96e702288..0000000000000 --- a/app/code/core/Mage/Directory/Helper/Data.php +++ /dev/null @@ -1,252 +0,0 @@ - - */ -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'; - - /* - * Path to config value, which lists countries, for which state is required. - */ - const XML_PATH_STATES_REQUIRED = 'general/region/state_required'; - - /* - * Path to config value, which detects whether or not display the state for the country, if it is not required - */ - const XML_PATH_DISPLAY_ALL_STATES = 'general/region/display_all'; - - /** - * 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) { - $this->_regionCollection = Mage::getModel('Mage_Directory_Model_Region')->getResourceCollection() - ->addCountryFilter($this->getAddress()->getCountryId()) - ->load(); - } - return $this->_regionCollection; - } - - /** - * Retrieve country collection - * - * @return Mage_Directory_Model_Resource_Country_Collection - */ - public function getCountryCollection() - { - if (!$this->_countryCollection) { - $this->_countryCollection = Mage::getModel('Mage_Directory_Model_Country')->getResourceCollection() - ->loadByStore(); - } - return $this->_countryCollection; - } - - /** - * Retrieve regions data json - * - * @return string - */ - public function getRegionJson() - { - - Magento_Profiler::start('TEST: '.__METHOD__, array('group' => 'TEST', 'method' => __METHOD__)); - if (!$this->_regionJson) { - $cacheKey = 'DIRECTORY_REGIONS_JSON_STORE'.Mage::app()->getStore()->getId(); - if (Mage::app()->useCache('config')) { - $json = Mage::app()->loadCache($cacheKey); - } - if (empty($json)) { - $countryIds = array(); - foreach ($this->getCountryCollection() as $country) { - $countryIds[] = $country->getCountryId(); - } - $collection = Mage::getModel('Mage_Directory_Model_Region')->getResourceCollection() - ->addCountryFilter($countryIds) - ->load(); - $regions = array( - 'config' => array( - 'show_all_regions' => $this->getShowNonRequiredState(), - 'regions_required' => $this->getCountriesWithStatesRequired() - ) - ); - foreach ($collection as $region) { - if (!$region->getRegionId()) { - continue; - } - $regions[$region->getCountryId()][$region->getRegionId()] = array( - 'code' => $region->getCode(), - 'name' => $this->__($region->getName()) - ); - } - $json = Mage::helper('Mage_Core_Helper_Data')->jsonEncode($regions); - - if (Mage::app()->useCache('config')) { - Mage::app()->saveCache($json, $cacheKey, array('config')); - } - } - $this->_regionJson = $json; - } - - Magento_Profiler::stop('TEST: '.__METHOD__); - return $this->_regionJson; - } - - /** - * 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('Mage_Directory_Model_Currency')->load($from); - } - if (is_null($to)) { - $to = Mage::app()->getStore()->getCurrentCurrencyCode(); - } - $converted = $this->_currencyCache[$from]->convert($amount, $to); - return $converted; - } - - /** - * Return ISO2 country codes, which have optional Zip/Postal pre-configured - * - * @param bool $asJson - * @return array|string - */ - public function getCountriesWithOptionalZip($asJson = false) - { - if (null === $this->_optionalZipCountries) { - $this->_optionalZipCountries = preg_split('/\,/', - Mage::getStoreConfig(self::OPTIONAL_ZIP_COUNTRIES_CONFIG_PATH), 0, PREG_SPLIT_NO_EMPTY); - } - if ($asJson) { - return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($this->_optionalZipCountries); - } - return $this->_optionalZipCountries; - } - - /** - * Check whether zip code is optional for specified country code - * - * @param string $countryCode - * @return boolean - */ - public function isZipCodeOptional($countryCode) - { - $this->getCountriesWithOptionalZip(); - return in_array($countryCode, $this->_optionalZipCountries); - } - - /** - * Returns the list of countries, for which region is required - * - * @param boolean $asJson - * @return array - */ - public function getCountriesWithStatesRequired($asJson = false) - { - $countryList = explode(',', Mage::getStoreConfig(self::XML_PATH_STATES_REQUIRED)); - if ($asJson) { - return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($countryList); - } - return $countryList; - } - - /** - * Return flag, which indicates whether or not non required state should be shown - * - * @return bool - */ - public function getShowNonRequiredState() - { - return (boolean)Mage::getStoreConfig(self::XML_PATH_DISPLAY_ALL_STATES); - } - - /** - * Returns flag, which indicates whether region is required for specified country - * - * @param string $countryId - * @return bool - */ - public function isRegionRequired($countryId) - { - $countyList = $this->getCountriesWithStatesRequired(); - if(!is_array($countyList)) { - return false; - } - return in_array($countryId, $countyList); - } -} diff --git a/app/code/core/Mage/Directory/Model/CountryFactory.php b/app/code/core/Mage/Directory/Model/CountryFactory.php deleted file mode 100644 index 4fbec86a54ab4..0000000000000 --- a/app/code/core/Mage/Directory/Model/CountryFactory.php +++ /dev/null @@ -1,59 +0,0 @@ - - */ -class Mage_Directory_Model_CountryFactory -{ - /** - * @var Magento_ObjectManager - */ - protected $_objectManager; - - /** - * @param Magento_ObjectManager $objectManager - */ - public function __construct(Magento_ObjectManager $objectManager) - { - $this->_objectManager = $objectManager; - } - - /** - * Create new country model - * - * @param array $arguments - * @return Mage_Directory_Model_Country - */ - public function create(array $arguments = array()) - { - return $this->_objectManager->create('Mage_Directory_Model_Country', $arguments, false); - } -} diff --git a/app/code/core/Mage/Directory/etc/config.xml b/app/code/core/Mage/Directory/etc/config.xml deleted file mode 100644 index 9c64f06af3300..0000000000000 --- a/app/code/core/Mage/Directory/etc/config.xml +++ /dev/null @@ -1,153 +0,0 @@ - - - - - - 1.6.0.1 - true - core - - - - - - - - - - - Webservicex - Mage_Directory_Model_Currency_Import_Webservicex - - - - - - - - Mage_Directory - - - - - - - - - standard - - Mage_Directory - directory - - - - - - - - Mage_Directory.csv - - - - - - - - layout.xml - - - - - - - - - - Mage_Directory.csv - - - - - - - - - AZN,AZM,AFN,ALL,DZD,AOA,ARS,AMD,AWG,AUD,BSD,BHD,BDT,BBD,BYR,BZD,BMD,BTN,BOB,BAM,BWP,BRL,GBP,BND,BGN,BUK,BIF,KHR,CAD,CVE,CZK,KYD,CLP,CNY,COP,KMF,CDF,CRC,HRK,CUP,DKK,DJF,DOP,XCD,EGP,SVC,GQE,ERN,EEK,ETB,EUR,FKP,FJD,GMD,GEK,GEL,GHS,GIP,GTQ,GNF,GYD,HTG,HNL,HKD,HUF,ISK,INR,IDR,IRR,IQD,ILS,JMD,JPY,JOD,KZT,KES,KWD,KGS,LAK,LVL,LBP,LSL,LRD,LYD,LTL,MOP,MKD,MGA,MWK,MYR,MVR,LSM,MRO,MUR,MXN,MDL,MNT,MAD,MZN,MMK,NAD,NPR,ANG,TRL,TRY,NZD,NIC,NGN,KPW,NOK,OMR,PKR,PAB,PGK,PYG,PEN,PHP,PLN,QAR,RHD,RON,ROL,RUB,RWF,SHP,STD,SAR,RSD,SCR,SLL,SGD,SKK,SBD,SOS,ZAR,KRW,LKR,SDG,SRD,SZL,SEK,CHF,SYP,TWD,TJS,TZS,THB,TOP,TTD,TND,TMM,USD,UGX,UAH,AED,UYU,UZS,VUV,VEB,VEF,VND,CHE,CHW,XOF,XPF,WST,YER,ZMK,ZWD - - - - - USD,EUR - USD - USD - - - 100 - - - 0 - - general - currency_import_error_email_template - - - - - HK,IE,MO,PA - AF,AL,DZ,AS,AD,AO,AI,AQ,AG,AR,AM,AW,AU,AT,AX,AZ,BS,BH,BD,BB,BY,BE,BZ,BJ,BM,BL,BT,BO,BA,BW,BV,BR,IO,VG,BN,BG,BF,BI,KH,CM,CA,CD,CV,KY,CF,TD,CL,CN,CX,CC,CO,KM,CG,CK,CR,HR,CU,CY,CZ,DK,DJ,DM,DO,EC,EG,SV,GQ,ER,EE,ET,FK,FO,FJ,FI,FR,GF,PF,TF,GA,GM,GE,DE,GG,GH,GI,GR,GL,GD,GP,GU,GT,GN,GW,GY,HT,HM,HN,HK,HU,IS,IM,IN,ID,IR,IQ,IE,IL,IT,CI,JE,JM,JP,JO,KZ,KE,KI,KW,KG,LA,LV,LB,LS,LR,LY,LI,LT,LU,ME,MF,MO,MK,MG,MW,MY,MV,ML,MT,MH,MQ,MR,MU,YT,FX,MX,FM,MD,MC,MN,MS,MA,MZ,MM,NA,NR,NP,NL,AN,NC,NZ,NI,NE,NG,NU,NF,KP,MP,NO,OM,PK,PW,PA,PG,PY,PE,PH,PN,PL,PS,PT,PR,QA,RE,RO,RS,RU,RW,SH,KN,LC,PM,VC,WS,SM,ST,SA,SN,SC,SL,SG,SK,SI,SB,SO,ZA,GS,KR,ES,LK,SD,SR,SJ,SZ,SE,CH,SY,TL,TW,TJ,TZ,TH,TG,TK,TO,TT,TN,TR,TM,TC,TV,VI,UG,UA,AE,GB,US,UM,UY,UZ,VU,VA,VE,VN,WF,EH,YE,ZM,ZW - US - - - %A, %B %e %Y [%I:%M %p] - %a, %b %e %Y [%I:%M %p] - %m/%d/%y [%I:%M %p] - %A, %B %e %Y - %a, %b %e %Y - %m/%d/%y - en - - - - - - - - Mage_Directory_Model_Observer::scheduledUpdateCurrencyRates - - - - - diff --git a/app/code/core/Mage/Downloadable/Helper/File.php b/app/code/core/Mage/Downloadable/Helper/File.php deleted file mode 100644 index 058a14537aee7..0000000000000 --- a/app/code/core/Mage/Downloadable/Helper/File.php +++ /dev/null @@ -1,780 +0,0 @@ - - */ -class Mage_Downloadable_Helper_File extends Mage_Core_Helper_Abstract -{ - public function __construct(Mage_Core_Model_Translate $translator, Mage_Core_Model_Config $config) - { - parent::__construct($translator); - $nodes = $config->getNode('global/mime/types'); - if ($nodes) { - $nodes = (array)$nodes; - foreach ($nodes as $key => $value) { - self::$_mimeTypes[$key] = $value; - } - } - } - - /** - * Checking file for moving and move it - * - * @param string $baseTmpPath - * @param string $basePath - * @param array $file - * @return string - */ - public function moveFileFromTmp($baseTmpPath, $basePath, $file) - { - if (isset($file[0])) { - $fileName = $file[0]['file']; - if ($file[0]['status'] == 'new') { - try { - $fileName = $this->_moveFileFromTmp( - $baseTmpPath, $basePath, $file[0]['file'] - ); - } catch (Exception $e) { - Mage::throwException(Mage::helper('Mage_Downloadable_Helper_Data')->__('An error occurred while saving the file(s).')); - } - } - return $fileName; - } - return ''; - } - - /** - * Move file from tmp path to base path - * - * @param string $baseTmpPath - * @param string $basePath - * @param string $file - * @return string - */ - protected function _moveFileFromTmp($baseTmpPath, $basePath, $file) - { - $ioObject = new Varien_Io_File(); - $destDirectory = dirname($this->getFilePath($basePath, $file)); - try { - $ioObject->open(array('path'=>$destDirectory)); - } catch (Exception $e) { - $ioObject->mkdir($destDirectory, 0777, true); - $ioObject->open(array('path'=>$destDirectory)); - } - - if (strrpos($file, '.tmp') == strlen($file)-4) { - $file = substr($file, 0, strlen($file)-4); - } - - $destFile = dirname($file) . $ioObject->dirsep() - . Mage_Core_Model_File_Uploader::getNewFileName($this->getFilePath($basePath, $file)); - - Mage::helper('Mage_Core_Helper_File_Storage_Database')->copyFile( - $this->getFilePath($baseTmpPath, $file), - $this->getFilePath($basePath, $destFile) - ); - - $result = $ioObject->mv( - $this->getFilePath($baseTmpPath, $file), - $this->getFilePath($basePath, $destFile) - ); - return str_replace($ioObject->dirsep(), '/', $destFile); - } - - /** - * Return full path to file - * - * @param string $path - * @param string $file - * @return string - */ - public function getFilePath($path, $file) - { - $file = $this->_prepareFileForPath($file); - - if(substr($file, 0, 1) == DS) { - return $path . DS . substr($file, 1); - } - - return $path . DS . $file; - } - - /** - * Replace slashes with directory separator - * - * @param string $file - * @return string - */ - protected function _prepareFileForPath($file) - { - return str_replace('/', DS, $file); - } - - /** - * Return file name form file path - * - * @param string $pathFile - * @return string - */ - public function getFileFromPathFile($pathFile) - { - $file = ''; - - $file = substr($pathFile, strrpos($this->_prepareFileForPath($pathFile), DS)+1); - - return $file; - } - - public function getFileType($filePath) - { - $ext = substr($filePath, strrpos($filePath, '.')+1); - return $this->_getFileTypeByExt($ext); - } - - protected function _getFileTypeByExt($ext) - { - $type = 'x' . $ext; - if (isset(self::$_mimeTypes[$type])) { - return self::$_mimeTypes[$type]; - } - return 'application/octet-stream'; - } - - public function getAllFileTypes() - { - return array_values(self::getAllMineTypes()); - } - - public function getAllMineTypes() - { - return self::$_mimeTypes; - } - - protected static $_mimeTypes = - array( - 'x123' => 'application/vnd.lotus-1-2-3', - 'x3dml' => 'text/vnd.in3d.3dml', - 'x3g2' => 'video/3gpp2', - 'x3gp' => 'video/3gpp', - 'xace' => 'application/x-ace-compressed', - 'xacu' => 'application/vnd.acucobol', - 'xaep' => 'application/vnd.audiograph', - 'xai' => 'application/postscript', - 'xaif' => 'audio/x-aiff', - - 'xaifc' => 'audio/x-aiff', - 'xaiff' => 'audio/x-aiff', - 'xami' => 'application/vnd.amiga.ami', - 'xapr' => 'application/vnd.lotus-approach', - 'xasf' => 'video/x-ms-asf', - 'xaso' => 'application/vnd.accpac.simply.aso', - 'xasx' => 'video/x-ms-asf', - 'xatom' => 'application/atom+xml', - 'xatomcat' => 'application/atomcat+xml', - - 'xatomsvc' => 'application/atomsvc+xml', - 'xatx' => 'application/vnd.antix.game-component', - 'xau' => 'audio/basic', - 'xavi' => 'video/x-msvideo', - 'xbat' => 'application/x-msdownload', - 'xbcpio' => 'application/x-bcpio', - 'xbdm' => 'application/vnd.syncml.dm+wbxml', - 'xbh2' => 'application/vnd.fujitsu.oasysprs', - 'xbmi' => 'application/vnd.bmi', - - 'xbmp' => 'image/bmp', - 'xbox' => 'application/vnd.previewsystems.box', - 'xboz' => 'application/x-bzip2', - 'xbtif' => 'image/prs.btif', - 'xbz' => 'application/x-bzip', - 'xbz2' => 'application/x-bzip2', - 'xcab' => 'application/vnd.ms-cab-compressed', - 'xccxml' => 'application/ccxml+xml', - 'xcdbcmsg' => 'application/vnd.contact.cmsg', - - 'xcdkey' => 'application/vnd.mediastation.cdkey', - 'xcdx' => 'chemical/x-cdx', - 'xcdxml' => 'application/vnd.chemdraw+xml', - 'xcdy' => 'application/vnd.cinderella', - 'xcer' => 'application/pkix-cert', - 'xcgm' => 'image/cgm', - 'xchat' => 'application/x-chat', - 'xchm' => 'application/vnd.ms-htmlhelp', - 'xchrt' => 'application/vnd.kde.kchart', - - 'xcif' => 'chemical/x-cif', - 'xcii' => 'application/vnd.anser-web-certificate-issue-initiation', - 'xcil' => 'application/vnd.ms-artgalry', - 'xcla' => 'application/vnd.claymore', - 'xclkk' => 'application/vnd.crick.clicker.keyboard', - 'xclkp' => 'application/vnd.crick.clicker.palette', - 'xclkt' => 'application/vnd.crick.clicker.template', - 'xclkw' => 'application/vnd.crick.clicker.wordbank', - 'xclkx' => 'application/vnd.crick.clicker', - - 'xclp' => 'application/x-msclip', - 'xcmc' => 'application/vnd.cosmocaller', - 'xcmdf' => 'chemical/x-cmdf', - 'xcml' => 'chemical/x-cml', - 'xcmp' => 'application/vnd.yellowriver-custom-menu', - 'xcmx' => 'image/x-cmx', - 'xcom' => 'application/x-msdownload', - 'xconf' => 'text/plain', - 'xcpio' => 'application/x-cpio', - - 'xcpt' => 'application/mac-compactpro', - 'xcrd' => 'application/x-mscardfile', - 'xcrl' => 'application/pkix-crl', - 'xcrt' => 'application/x-x509-ca-cert', - 'xcsh' => 'application/x-csh', - 'xcsml' => 'chemical/x-csml', - 'xcss' => 'text/css', - 'xcsv' => 'text/csv', - 'xcurl' => 'application/vnd.curl', - - 'xcww' => 'application/prs.cww', - 'xdaf' => 'application/vnd.mobius.daf', - 'xdavmount' => 'application/davmount+xml', - 'xdd2' => 'application/vnd.oma.dd2+xml', - 'xddd' => 'application/vnd.fujixerox.ddd', - 'xdef' => 'text/plain', - 'xder' => 'application/x-x509-ca-cert', - 'xdfac' => 'application/vnd.dreamfactory', - 'xdis' => 'application/vnd.mobius.dis', - - 'xdjv' => 'image/vnd.djvu', - 'xdjvu' => 'image/vnd.djvu', - 'xdll' => 'application/x-msdownload', - 'xdna' => 'application/vnd.dna', - 'xdoc' => 'application/msword', - 'xdot' => 'application/msword', - 'xdp' => 'application/vnd.osgi.dp', - 'xdpg' => 'application/vnd.dpgraph', - 'xdsc' => 'text/prs.lines.tag', - - 'xdtd' => 'application/xml-dtd', - 'xdvi' => 'application/x-dvi', - 'xdwf' => 'model/vnd.dwf', - 'xdwg' => 'image/vnd.dwg', - 'xdxf' => 'image/vnd.dxf', - 'xdxp' => 'application/vnd.spotfire.dxp', - 'xecelp4800' => 'audio/vnd.nuera.ecelp4800', - 'xecelp7470' => 'audio/vnd.nuera.ecelp7470', - 'xecelp9600' => 'audio/vnd.nuera.ecelp9600', - - 'xecma' => 'application/ecmascript', - 'xedm' => 'application/vnd.novadigm.edm', - 'xedx' => 'application/vnd.novadigm.edx', - 'xefif' => 'application/vnd.picsel', - 'xei6' => 'application/vnd.pg.osasli', - 'xeml' => 'message/rfc822', - 'xeol' => 'audio/vnd.digital-winds', - 'xeot' => 'application/vnd.ms-fontobject', - 'xeps' => 'application/postscript', - - 'xesf' => 'application/vnd.epson.esf', - 'xetx' => 'text/x-setext', - 'xexe' => 'application/x-msdownload', - 'xext' => 'application/vnd.novadigm.ext', - 'xez' => 'application/andrew-inset', - 'xez2' => 'application/vnd.ezpix-album', - 'xez3' => 'application/vnd.ezpix-package', - 'xfbs' => 'image/vnd.fastbidsheet', - 'xfdf' => 'application/vnd.fdf', - - 'xfe_launch' => 'application/vnd.denovo.fcselayout-link', - 'xfg5' => 'application/vnd.fujitsu.oasysgp', - 'xfli' => 'video/x-fli', - 'xflo' => 'application/vnd.micrografx.flo', - 'xflw' => 'application/vnd.kde.kivio', - 'xflx' => 'text/vnd.fmi.flexstor', - 'xfly' => 'text/vnd.fly', - 'xfnc' => 'application/vnd.frogans.fnc', - 'xfpx' => 'image/vnd.fpx', - - 'xfsc' => 'application/vnd.fsc.weblaunch', - 'xfst' => 'image/vnd.fst', - 'xftc' => 'application/vnd.fluxtime.clip', - 'xfti' => 'application/vnd.anser-web-funds-transfer-initiation', - 'xfvt' => 'video/vnd.fvt', - 'xfzs' => 'application/vnd.fuzzysheet', - 'xg3' => 'image/g3fax', - 'xgac' => 'application/vnd.groove-account', - 'xgdl' => 'model/vnd.gdl', - - 'xghf' => 'application/vnd.groove-help', - 'xgif' => 'image/gif', - 'xgim' => 'application/vnd.groove-identity-message', - 'xgph' => 'application/vnd.flographit', - 'xgram' => 'application/srgs', - 'xgrv' => 'application/vnd.groove-injector', - 'xgrxml' => 'application/srgs+xml', - 'xgtar' => 'application/x-gtar', - 'xgtm' => 'application/vnd.groove-tool-message', - - 'xgtw' => 'model/vnd.gtw', - 'xh261' => 'video/h261', - 'xh263' => 'video/h263', - 'xh264' => 'video/h264', - 'xhbci' => 'application/vnd.hbci', - 'xhdf' => 'application/x-hdf', - 'xhlp' => 'application/winhlp', - 'xhpgl' => 'application/vnd.hp-hpgl', - 'xhpid' => 'application/vnd.hp-hpid', - - 'xhps' => 'application/vnd.hp-hps', - 'xhqx' => 'application/mac-binhex40', - 'xhtke' => 'application/vnd.kenameaapp', - 'xhtm' => 'text/html', - 'xhtml' => 'text/html', - 'xhvd' => 'application/vnd.yamaha.hv-dic', - 'xhvp' => 'application/vnd.yamaha.hv-voice', - 'xhvs' => 'application/vnd.yamaha.hv-script', - 'xice' => '#x-conference/x-cooltalk', - - 'xico' => 'image/x-icon', - 'xics' => 'text/calendar', - 'xief' => 'image/ief', - 'xifb' => 'text/calendar', - 'xifm' => 'application/vnd.shana.informed.formdata', - 'xigl' => 'application/vnd.igloader', - 'xigx' => 'application/vnd.micrografx.igx', - 'xiif' => 'application/vnd.shana.informed.interchange', - 'ximp' => 'application/vnd.accpac.simply.imp', - - 'xims' => 'application/vnd.ms-ims', - 'xin' => 'text/plain', - 'xipk' => 'application/vnd.shana.informed.package', - 'xirm' => 'application/vnd.ibm.rights-management', - 'xirp' => 'application/vnd.irepository.package+xml', - 'xitp' => 'application/vnd.shana.informed.formtemplate', - 'xivp' => 'application/vnd.immervision-ivp', - 'xivu' => 'application/vnd.immervision-ivu', - 'xjad' => 'text/vnd.sun.j2me.app-descriptor', - - 'xjam' => 'application/vnd.jam', - 'xjava' => 'text/x-java-source', - 'xjisp' => 'application/vnd.jisp', - 'xjlt' => 'application/vnd.hp-jlyt', - 'xjoda' => 'application/vnd.joost.joda-archive', - 'xjpe' => 'image/jpeg', - 'xjpeg' => 'image/jpeg', - 'xjpg' => 'image/jpeg', - 'xjpgm' => 'video/jpm', - - 'xjpgv' => 'video/jpeg', - 'xjpm' => 'video/jpm', - 'xjs' => 'application/javascript', - 'xjson' => 'application/json', - 'xkar' => 'audio/midi', - 'xkarbon' => 'application/vnd.kde.karbon', - 'xkfo' => 'application/vnd.kde.kformula', - 'xkia' => 'application/vnd.kidspiration', - 'xkml' => 'application/vnd.google-earth.kml+xml', - - 'xkmz' => 'application/vnd.google-earth.kmz', - 'xkon' => 'application/vnd.kde.kontour', - 'xksp' => 'application/vnd.kde.kspread', - 'xlatex' => 'application/x-latex', - 'xlbd' => 'application/vnd.llamagraphics.life-balance.desktop', - 'xlbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml', - 'xles' => 'application/vnd.hhe.lesson-player', - 'xlist' => 'text/plain', - 'xlog' => 'text/plain', - - 'xlrm' => 'application/vnd.ms-lrm', - 'xltf' => 'application/vnd.frogans.ltf', - 'xlvp' => 'audio/vnd.lucent.voice', - 'xlwp' => 'application/vnd.lotus-wordpro', - 'xm13' => 'application/x-msmediaview', - 'xm14' => 'application/x-msmediaview', - 'xm1v' => 'video/mpeg', - 'xm2a' => 'audio/mpeg', - 'xm3a' => 'audio/mpeg', - - 'xm3u' => 'audio/x-mpegurl', - 'xm4u' => 'video/vnd.mpegurl', - 'xmag' => 'application/vnd.ecowin.chart', - 'xmathml' => 'application/mathml+xml', - 'xmbk' => 'application/vnd.mobius.mbk', - 'xmbox' => 'application/mbox', - 'xmc1' => 'application/vnd.medcalcdata', - 'xmcd' => 'application/vnd.mcd', - 'xmdb' => 'application/x-msaccess', - - 'xmdi' => 'image/vnd.ms-modi', - 'xmesh' => 'model/mesh', - 'xmfm' => 'application/vnd.mfmp', - 'xmgz' => 'application/vnd.proteus.magazine', - 'xmid' => 'audio/midi', - 'xmidi' => 'audio/midi', - 'xmif' => 'application/vnd.mif', - 'xmime' => 'message/rfc822', - 'xmj2' => 'video/mj2', - - 'xmjp2' => 'video/mj2', - 'xmlp' => 'application/vnd.dolby.mlp', - 'xmmd' => 'application/vnd.chipnuts.karaoke-mmd', - 'xmmf' => 'application/vnd.smaf', - 'xmmr' => 'image/vnd.fujixerox.edmics-mmr', - 'xmny' => 'application/x-msmoney', - 'xmov' => 'video/quicktime', - 'xmovie' => 'video/x-sgi-movie', - 'xmp2' => 'audio/mpeg', - - 'xmp2a' => 'audio/mpeg', - 'xmp3' => 'audio/mpeg', - 'xmp4' => 'video/mp4', - 'xmp4a' => 'audio/mp4', - 'xmp4s' => 'application/mp4', - 'xmp4v' => 'video/mp4', - 'xmpc' => 'application/vnd.mophun.certificate', - 'xmpe' => 'video/mpeg', - 'xmpeg' => 'video/mpeg', - - 'xmpg' => 'video/mpeg', - 'xmpg4' => 'video/mp4', - 'xmpga' => 'audio/mpeg', - 'xmpkg' => 'application/vnd.apple.installer+xml', - 'xmpm' => 'application/vnd.blueice.multipass', - 'xmpn' => 'application/vnd.mophun.application', - 'xmpp' => 'application/vnd.ms-project', - 'xmpt' => 'application/vnd.ms-project', - 'xmpy' => 'application/vnd.ibm.minipay', - - 'xmqy' => 'application/vnd.mobius.mqy', - 'xmrc' => 'application/marc', - 'xmscml' => 'application/mediaservercontrol+xml', - 'xmseq' => 'application/vnd.mseq', - 'xmsf' => 'application/vnd.epson.msf', - 'xmsh' => 'model/mesh', - 'xmsi' => 'application/x-msdownload', - 'xmsl' => 'application/vnd.mobius.msl', - 'xmsty' => 'application/vnd.muvee.style', - - 'xmts' => 'model/vnd.mts', - 'xmus' => 'application/vnd.musician', - 'xmvb' => 'application/x-msmediaview', - 'xmwf' => 'application/vnd.mfer', - 'xmxf' => 'application/mxf', - 'xmxl' => 'application/vnd.recordare.musicxml', - 'xmxml' => 'application/xv+xml', - 'xmxs' => 'application/vnd.triscape.mxs', - 'xmxu' => 'video/vnd.mpegurl', - - 'xn-gage' => 'application/vnd.nokia.n-gage.symbian.install', - 'xngdat' => 'application/vnd.nokia.n-gage.data', - 'xnlu' => 'application/vnd.neurolanguage.nlu', - 'xnml' => 'application/vnd.enliven', - 'xnnd' => 'application/vnd.noblenet-directory', - 'xnns' => 'application/vnd.noblenet-sealer', - 'xnnw' => 'application/vnd.noblenet-web', - 'xnpx' => 'image/vnd.net-fpx', - 'xnsf' => 'application/vnd.lotus-notes', - - 'xoa2' => 'application/vnd.fujitsu.oasys2', - 'xoa3' => 'application/vnd.fujitsu.oasys3', - 'xoas' => 'application/vnd.fujitsu.oasys', - 'xobd' => 'application/x-msbinder', - 'xoda' => 'application/oda', - 'xodc' => 'application/vnd.oasis.opendocument.chart', - 'xodf' => 'application/vnd.oasis.opendocument.formula', - 'xodg' => 'application/vnd.oasis.opendocument.graphics', - 'xodi' => 'application/vnd.oasis.opendocument.image', - - 'xodp' => 'application/vnd.oasis.opendocument.presentation', - 'xods' => 'application/vnd.oasis.opendocument.spreadsheet', - 'xodt' => 'application/vnd.oasis.opendocument.text', - 'xogg' => 'application/ogg', - 'xoprc' => 'application/vnd.palm', - 'xorg' => 'application/vnd.lotus-organizer', - 'xotc' => 'application/vnd.oasis.opendocument.chart-template', - 'xotf' => 'application/vnd.oasis.opendocument.formula-template', - 'xotg' => 'application/vnd.oasis.opendocument.graphics-template', - - 'xoth' => 'application/vnd.oasis.opendocument.text-web', - 'xoti' => 'application/vnd.oasis.opendocument.image-template', - 'xotm' => 'application/vnd.oasis.opendocument.text-master', - 'xots' => 'application/vnd.oasis.opendocument.spreadsheet-template', - 'xott' => 'application/vnd.oasis.opendocument.text-template', - 'xoxt' => 'application/vnd.openofficeorg.extension', - 'xp10' => 'application/pkcs10', - 'xp7r' => 'application/x-pkcs7-certreqresp', - 'xp7s' => 'application/pkcs7-signature', - - 'xpbd' => 'application/vnd.powerbuilder6', - 'xpbm' => 'image/x-portable-bitmap', - 'xpcl' => 'application/vnd.hp-pcl', - 'xpclxl' => 'application/vnd.hp-pclxl', - 'xpct' => 'image/x-pict', - 'xpcx' => 'image/x-pcx', - 'xpdb' => 'chemical/x-pdb', - 'xpdf' => 'application/pdf', - 'xpfr' => 'application/font-tdpfr', - - 'xpgm' => 'image/x-portable-graymap', - 'xpgn' => 'application/x-chess-pgn', - 'xpgp' => 'application/pgp-encrypted', - 'xpic' => 'image/x-pict', - 'xpki' => 'application/pkixcmp', - 'xpkipath' => 'application/pkix-pkipath', - 'xplb' => 'application/vnd.3gpp.pic-bw-large', - 'xplc' => 'application/vnd.mobius.plc', - 'xplf' => 'application/vnd.pocketlearn', - - 'xpls' => 'application/pls+xml', - 'xpml' => 'application/vnd.ctc-posml', - 'xpng' => 'image/png', - 'xpnm' => 'image/x-portable-anymap', - 'xportpkg' => 'application/vnd.macports.portpkg', - 'xpot' => 'application/vnd.ms-powerpoint', - 'xppd' => 'application/vnd.cups-ppd', - 'xppm' => 'image/x-portable-pixmap', - 'xpps' => 'application/vnd.ms-powerpoint', - - 'xppt' => 'application/vnd.ms-powerpoint', - 'xpqa' => 'application/vnd.palm', - 'xprc' => 'application/vnd.palm', - 'xpre' => 'application/vnd.lotus-freelance', - 'xprf' => 'application/pics-rules', - 'xps' => 'application/postscript', - 'xpsb' => 'application/vnd.3gpp.pic-bw-small', - 'xpsd' => 'image/vnd.adobe.photoshop', - 'xptid' => 'application/vnd.pvi.ptid1', - - 'xpub' => 'application/x-mspublisher', - 'xpvb' => 'application/vnd.3gpp.pic-bw-var', - 'xpwn' => 'application/vnd.3m.post-it-notes', - 'xqam' => 'application/vnd.epson.quickanime', - 'xqbo' => 'application/vnd.intu.qbo', - 'xqfx' => 'application/vnd.intu.qfx', - 'xqps' => 'application/vnd.publishare-delta-tree', - 'xqt' => 'video/quicktime', - 'xra' => 'audio/x-pn-realaudio', - - 'xram' => 'audio/x-pn-realaudio', - 'xrar' => 'application/x-rar-compressed', - 'xras' => 'image/x-cmu-raster', - 'xrcprofile' => 'application/vnd.ipunplugged.rcprofile', - 'xrdf' => 'application/rdf+xml', - 'xrdz' => 'application/vnd.data-vision.rdz', - 'xrep' => 'application/vnd.businessobjects', - 'xrgb' => 'image/x-rgb', - 'xrif' => 'application/reginfo+xml', - - 'xrl' => 'application/resource-lists+xml', - 'xrlc' => 'image/vnd.fujixerox.edmics-rlc', - 'xrm' => 'application/vnd.rn-realmedia', - 'xrmi' => 'audio/midi', - 'xrmp' => 'audio/x-pn-realaudio-plugin', - 'xrms' => 'application/vnd.jcp.javame.midlet-rms', - 'xrnc' => 'application/relax-ng-compact-syntax', - 'xrpss' => 'application/vnd.nokia.radio-presets', - 'xrpst' => 'application/vnd.nokia.radio-preset', - - 'xrq' => 'application/sparql-query', - 'xrs' => 'application/rls-services+xml', - 'xrsd' => 'application/rsd+xml', - 'xrss' => 'application/rss+xml', - 'xrtf' => 'application/rtf', - 'xrtx' => 'text/richtext', - 'xsaf' => 'application/vnd.yamaha.smaf-audio', - 'xsbml' => 'application/sbml+xml', - 'xsc' => 'application/vnd.ibm.secure-container', - - 'xscd' => 'application/x-msschedule', - 'xscm' => 'application/vnd.lotus-screencam', - 'xscq' => 'application/scvp-cv-request', - 'xscs' => 'application/scvp-cv-response', - 'xsdp' => 'application/sdp', - 'xsee' => 'application/vnd.seemail', - 'xsema' => 'application/vnd.sema', - 'xsemd' => 'application/vnd.semd', - 'xsemf' => 'application/vnd.semf', - - 'xsetpay' => 'application/set-payment-initiation', - 'xsetreg' => 'application/set-registration-initiation', - 'xsfs' => 'application/vnd.spotfire.sfs', - 'xsgm' => 'text/sgml', - 'xsgml' => 'text/sgml', - 'xsh' => 'application/x-sh', - 'xshar' => 'application/x-shar', - 'xshf' => 'application/shf+xml', - 'xsilo' => 'model/mesh', - - 'xsit' => 'application/x-stuffit', - 'xsitx' => 'application/x-stuffitx', - 'xslt' => 'application/vnd.epson.salt', - 'xsnd' => 'audio/basic', - 'xspf' => 'application/vnd.yamaha.smaf-phrase', - 'xspl' => 'application/x-futuresplash', - 'xspot' => 'text/vnd.in3d.spot', - 'xspp' => 'application/scvp-vp-response', - 'xspq' => 'application/scvp-vp-request', - - 'xsrc' => 'application/x-wais-source', - 'xsrx' => 'application/sparql-results+xml', - 'xssf' => 'application/vnd.epson.ssf', - 'xssml' => 'application/ssml+xml', - 'xstf' => 'application/vnd.wt.stf', - 'xstk' => 'application/hyperstudio', - 'xstr' => 'application/vnd.pg.format', - 'xsus' => 'application/vnd.sus-calendar', - 'xsusp' => 'application/vnd.sus-calendar', - - 'xsv4cpio' => 'application/x-sv4cpio', - 'xsv4crc' => 'application/x-sv4crc', - 'xsvd' => 'application/vnd.svd', - 'xswf' => 'application/x-shockwave-flash', - 'xtao' => 'application/vnd.tao.intent-module-archive', - 'xtar' => 'application/x-tar', - 'xtcap' => 'application/vnd.3gpp2.tcap', - 'xtcl' => 'application/x-tcl', - 'xtex' => 'application/x-tex', - - 'xtext' => 'text/plain', - 'xtif' => 'image/tiff', - 'xtiff' => 'image/tiff', - 'xtmo' => 'application/vnd.tmobile-livetv', - 'xtorrent' => 'application/x-bittorrent', - 'xtpl' => 'application/vnd.groove-tool-template', - 'xtpt' => 'application/vnd.trid.tpt', - 'xtra' => 'application/vnd.trueapp', - 'xtrm' => 'application/x-msterminal', - - 'xtsv' => 'text/tab-separated-values', - 'xtxd' => 'application/vnd.genomatix.tuxedo', - 'xtxf' => 'application/vnd.mobius.txf', - 'xtxt' => 'text/plain', - 'xumj' => 'application/vnd.umajin', - 'xunityweb' => 'application/vnd.unity', - 'xuoml' => 'application/vnd.uoml+xml', - 'xuri' => 'text/uri-list', - 'xuris' => 'text/uri-list', - - 'xurls' => 'text/uri-list', - 'xustar' => 'application/x-ustar', - 'xutz' => 'application/vnd.uiq.theme', - 'xuu' => 'text/x-uuencode', - 'xvcd' => 'application/x-cdlink', - 'xvcf' => 'text/x-vcard', - 'xvcg' => 'application/vnd.groove-vcard', - 'xvcs' => 'text/x-vcalendar', - 'xvcx' => 'application/vnd.vcx', - - 'xvis' => 'application/vnd.visionary', - 'xviv' => 'video/vnd.vivo', - 'xvrml' => 'model/vrml', - 'xvsd' => 'application/vnd.visio', - 'xvsf' => 'application/vnd.vsf', - 'xvss' => 'application/vnd.visio', - 'xvst' => 'application/vnd.visio', - 'xvsw' => 'application/vnd.visio', - 'xvtu' => 'model/vnd.vtu', - - 'xvxml' => 'application/voicexml+xml', - 'xwav' => 'audio/x-wav', - 'xwax' => 'audio/x-ms-wax', - 'xwbmp' => 'image/vnd.wap.wbmp', - 'xwbs' => 'application/vnd.criticaltools.wbs+xml', - 'xwbxml' => 'application/vnd.wap.wbxml', - 'xwcm' => 'application/vnd.ms-works', - 'xwdb' => 'application/vnd.ms-works', - 'xwks' => 'application/vnd.ms-works', - - 'xwm' => 'video/x-ms-wm', - 'xwma' => 'audio/x-ms-wma', - 'xwmd' => 'application/x-ms-wmd', - 'xwmf' => 'application/x-msmetafile', - 'xwml' => 'text/vnd.wap.wml', - 'xwmlc' => 'application/vnd.wap.wmlc', - 'xwmls' => 'text/vnd.wap.wmlscript', - 'xwmlsc' => 'application/vnd.wap.wmlscriptc', - 'xwmv' => 'video/x-ms-wmv', - - 'xwmx' => 'video/x-ms-wmx', - 'xwmz' => 'application/x-ms-wmz', - 'xwpd' => 'application/vnd.wordperfect', - 'xwpl' => 'application/vnd.ms-wpl', - 'xwps' => 'application/vnd.ms-works', - 'xwqd' => 'application/vnd.wqd', - 'xwri' => 'application/x-mswrite', - 'xwrl' => 'model/vrml', - 'xwsdl' => 'application/wsdl+xml', - - 'xwspolicy' => 'application/wspolicy+xml', - 'xwtb' => 'application/vnd.webturbo', - 'xwvx' => 'video/x-ms-wvx', - 'xx3d' => 'application/vnd.hzn-3d-crossword', - 'xxar' => 'application/vnd.xara', - 'xxbd' => 'application/vnd.fujixerox.docuworks.binder', - 'xxbm' => 'image/x-xbitmap', - 'xxdm' => 'application/vnd.syncml.dm+xml', - 'xxdp' => 'application/vnd.adobe.xdp+xml', - - 'xxdw' => 'application/vnd.fujixerox.docuworks', - 'xxenc' => 'application/xenc+xml', - 'xxfdf' => 'application/vnd.adobe.xfdf', - 'xxfdl' => 'application/vnd.xfdl', - 'xxht' => 'application/xhtml+xml', - 'xxhtml' => 'application/xhtml+xml', - 'xxhvml' => 'application/xv+xml', - 'xxif' => 'image/vnd.xiff', - 'xxla' => 'application/vnd.ms-excel', - - 'xxlc' => 'application/vnd.ms-excel', - 'xxlm' => 'application/vnd.ms-excel', - 'xxls' => 'application/vnd.ms-excel', - 'xxlt' => 'application/vnd.ms-excel', - 'xxlw' => 'application/vnd.ms-excel', - 'xxml' => 'application/xml', - 'xxo' => 'application/vnd.olpc-sugar', - 'xxop' => 'application/xop+xml', - 'xxpm' => 'image/x-xpixmap', - - 'xxpr' => 'application/vnd.is-xpr', - 'xxps' => 'application/vnd.ms-xpsdocument', - 'xxsl' => 'application/xml', - 'xxslt' => 'application/xslt+xml', - 'xxsm' => 'application/vnd.syncml+xml', - 'xxspf' => 'application/xspf+xml', - 'xxul' => 'application/vnd.mozilla.xul+xml', - 'xxvm' => 'application/xv+xml', - 'xxvml' => 'application/xv+xml', - - 'xxwd' => 'image/x-xwindowdump', - 'xxyz' => 'chemical/x-xyz', - 'xzaz' => 'application/vnd.zzazz.deck+xml', - 'xzip' => 'application/zip', - 'xzmm' => 'application/vnd.handheld-entertainment+xml', - 'xodt' => 'application/x-vnd.oasis.opendocument.spreadsheet' - ); -} diff --git a/app/code/core/Mage/Downloadable/etc/adminhtml/acl.xml b/app/code/core/Mage/Downloadable/etc/adminhtml/acl.xml deleted file mode 100644 index 64fcebaa5c585..0000000000000 --- a/app/code/core/Mage/Downloadable/etc/adminhtml/acl.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Downloadable/etc/adminhtml/menu.xml b/app/code/core/Mage/Downloadable/etc/adminhtml/menu.xml deleted file mode 100644 index a776340083e19..0000000000000 --- a/app/code/core/Mage/Downloadable/etc/adminhtml/menu.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - diff --git a/app/code/core/Mage/Downloadable/etc/config.xml b/app/code/core/Mage/Downloadable/etc/config.xml deleted file mode 100644 index 126dae0c99fe9..0000000000000 --- a/app/code/core/Mage/Downloadable/etc/config.xml +++ /dev/null @@ -1,274 +0,0 @@ - - - - - - 1.6.0.0.3 - true - core - - - - - - - - - - - - - - - - - - - - - Mage_Downloadable - Mage_Catalog_Model_Resource_Setup - - - - - - - - - Mage_Downloadable_Model_Product_Type - 1 - Mage_Downloadable_Model_Product_Price - 0 - Mage_Downloadable_Model_Resource_Indexer_Price - 0 - - - - - - - - - - - - - - - - - - - - - - - - Mage_Downloadable_Model_Sales_Order_Pdf_Items_Invoice - - - Mage_Downloadable_Model_Sales_Order_Pdf_Items_Creditmemo - - - - - - - - - Mage_Downloadable.csv - - - - - - - - - - - - - - - - - layout.xml - - - - - - - - Mage_Downloadable_Model_Observer - prepareProductSave - - - - - - - Mage_Downloadable_Model_Observer - duplicateProduct - - - - - - - Mage_Downloadable_Model_Observer - saveDownloadableOrderItem - - - - - - - Mage_Downloadable_Model_Observer - setLinkStatus - - - - - - - Mage_Downloadable_Model_Observer - transitionProductType - - - - - - - - - standard - - Mage_Downloadable - downloadable - - - - - /downloadable/customer/ - /downloadable/download/ - - - - - - Mage_Downloadable.csv - - - - - - - - layout.xml - - - - - - - - Mage_Downloadable_Model_Observer - saveDownloadableOrderItem - - - - - - - Mage_Downloadable_Model_Observer - setLinkStatus - - - - - - - Mage_Downloadable_Model_Observer - setHasDownloadableProducts - - - - - - - Mage_Downloadable_Model_Observer - setHasDownloadableProducts - - - - - - - Mage_Downloadable_Model_Observer - isAllowedGuestCheckout - - - - - - - Mage_Downloadable_Model_Observer - initOptionRenderer - - - - - - - - - - - Mage_Downloadable_Adminhtml - - - - - - - - - 0 - 9 - Samples - Links - 1 - inline - 1 - - - - diff --git a/app/code/core/Mage/Downloadable/view/adminhtml/product/edit/downloadable.phtml b/app/code/core/Mage/Downloadable/view/adminhtml/product/edit/downloadable.phtml deleted file mode 100644 index 31af293dcf3f6..0000000000000 --- a/app/code/core/Mage/Downloadable/view/adminhtml/product/edit/downloadable.phtml +++ /dev/null @@ -1,255 +0,0 @@ - - - - - -
    getMessageHtml() ?>
    - -
    -getChildHtml('accordion') ?> -
    -
    -
    -
    -isReadonly()): ?> - - diff --git a/app/code/core/Mage/Downloadable/view/adminhtml/sales/items/column/downloadable/creditmemo/name.phtml b/app/code/core/Mage/Downloadable/view/adminhtml/sales/items/column/downloadable/creditmemo/name.phtml deleted file mode 100644 index e659175c7086c..0000000000000 --- a/app/code/core/Mage/Downloadable/view/adminhtml/sales/items/column/downloadable/creditmemo/name.phtml +++ /dev/null @@ -1,62 +0,0 @@ - - -getItem()): ?> -
    getName() ?>
    -
    helper('Mage_Sales_Helper_Data')->__('SKU') ?>: ', Mage::helper('Mage_Catalog_Helper_Data')->splitSku($this->escapeHtml($this->getSku()))); ?>
    - getOrderOptions()): ?> -
    - getOrderOptions() as $_option): ?> -
    -
    - - - - truncate($_option['value'], 55, '', $_remainder);?> - - ... - - - -
    - -
    - - getLinks()): ?> -
    -
    getLinksTitle(); ?>
    - getLinks()->getPurchasedItems() as $_link): ?> -
    escapeHtml($_link->getLinkTitle()); ?>
    - -
    - - escapeHtml($_item->getDescription()) ?> - diff --git a/app/code/core/Mage/Downloadable/view/adminhtml/sales/items/column/downloadable/invoice/name.phtml b/app/code/core/Mage/Downloadable/view/adminhtml/sales/items/column/downloadable/invoice/name.phtml deleted file mode 100644 index a10d8f29df54d..0000000000000 --- a/app/code/core/Mage/Downloadable/view/adminhtml/sales/items/column/downloadable/invoice/name.phtml +++ /dev/null @@ -1,62 +0,0 @@ - - -getItem()): ?> -
    getName() ?>
    -
    helper('Mage_Sales_Helper_Data')->__('SKU') ?>: ', Mage::helper('Mage_Catalog_Helper_Data')->splitSku($this->escapeHtml($this->getSku()))); ?>
    - getOrderOptions()): ?> -
    - getOrderOptions() as $_option): ?> -
    -
    - - - - truncate($_option['value'], 55, '', $_remainder);?> - - ... - - - -
    - -
    - - getLinks()): ?> -
    -
    getLinksTitle(); ?>
    - getLinks()->getPurchasedItems() as $_link): ?> -
    escapeHtml($_link->getLinkTitle()); ?> (getNumberOfDownloadsBought()?$_link->getNumberOfDownloadsBought():Mage::helper('Mage_Downloadable_Helper_Data')->__('Unlimited') ?>)
    - -
    - - escapeHtml($_item->getDescription()) ?> - diff --git a/app/code/core/Mage/Downloadable/view/adminhtml/sales/items/column/downloadable/name.phtml b/app/code/core/Mage/Downloadable/view/adminhtml/sales/items/column/downloadable/name.phtml deleted file mode 100644 index 5759a7340fe29..0000000000000 --- a/app/code/core/Mage/Downloadable/view/adminhtml/sales/items/column/downloadable/name.phtml +++ /dev/null @@ -1,62 +0,0 @@ - - -getItem()): ?> -
    getName() ?>
    -
    helper('Mage_Sales_Helper_Data')->__('SKU') ?>: ', Mage::helper('Mage_Catalog_Helper_Data')->splitSku($this->escapeHtml($this->getSku()))); ?>
    - getOrderOptions()): ?> -
    - getOrderOptions() as $_option): ?> -
    -
    - - - - truncate($_option['value'], 55, '', $_remainder);?> - - ... - - - -
    - -
    - - getLinks()): ?> -
    -
    getLinksTitle(); ?>
    - getLinks()->getPurchasedItems() as $_link): ?> -
    escapeHtml($_link->getLinkTitle()) ?> (getNumberOfDownloadsUsed() . ' / ' . ($_link->getNumberOfDownloadsBought()?$_link->getNumberOfDownloadsBought():Mage::helper('Mage_Downloadable_Helper_Data')->__('U')) ?>)
    - -
    - - escapeHtml($_item->getDescription()) ?> - diff --git a/app/code/core/Mage/Downloadable/view/adminhtml/sales/order/creditmemo/create/items/renderer/downloadable.phtml b/app/code/core/Mage/Downloadable/view/adminhtml/sales/order/creditmemo/create/items/renderer/downloadable.phtml deleted file mode 100644 index f984966c63400..0000000000000 --- a/app/code/core/Mage/Downloadable/view/adminhtml/sales/order/creditmemo/create/items/renderer/downloadable.phtml +++ /dev/null @@ -1,139 +0,0 @@ - -getItem() ?> -setPriceDataObject($_item); ?> - - getColumnHtml($_item, 'downloadable') ?> - - helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - helper('Mage_Tax_Helper_Data')->__('Excl. Tax'); ?>: - - displayPriceAttribute('price') ?> - - - helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - helper('Mage_Tax_Helper_Data')->__('Incl. Tax'); ?>: - - getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 0, 'sales')): // including ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 1, 'sales')): // incl. + weee ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> -
    - - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)); ?> - getApplied($_item) as $tax): ?> - + : currency($tax['amount'],true,true); ?>
    - -
    - getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 2, 'sales')): // excl. + weee + final ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)); ?> -
    - getApplied($_item) as $tax): ?> - : currency($tax['amount'],true,true); ?>
    - - - __('Total'); ?>: - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - - - displayPriceInclTax($_item); ?> - -
    - - - getColumnHtml($_item, 'qty') ?> - canParentReturnToStock($_item)) : ?> - - canReturnItemToStock($_item)) : ?> - getBackToStock()):?> checked/> - - - - - canEditQty()) : ?> - - - getQty()*1 ?> - - - - - - helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - helper('Mage_Tax_Helper_Data')->__('Excl. Tax'); ?>: - - displayPriceAttribute('row_total') ?> - - - helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - helper('Mage_Tax_Helper_Data')->__('Incl. Tax'); ?>: - - - getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 0, 'sales')): // including ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 1, 'sales')): // incl. + weee ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> -
    - - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)); ?> - getApplied($_item) as $tax): ?> - + : currency($tax['row_amount'],true,true); ?>
    - -
    - getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 2, 'sales')): // excl. + weee + final ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)); ?> -
    - getApplied($_item) as $tax): ?> - : currency($tax['row_amount'],true,true); ?>
    - - - __('Total'); ?>: - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - - - displaySubtotalInclTax($_item); ?> - - -
    - - displayPriceAttribute('tax_amount') ?> - displayPriceAttribute('discount_amount') ?> - - displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseTaxAmount()-$_item->getBaseDiscountAmount()+$_item->getWeeeTaxAppliedAmount(), - $_item->getRowTotal()+$_item->getTaxAmount()-$_item->getDiscountAmount()+$_item->getWeeeTaxAppliedAmount() - ) ?> - - diff --git a/app/code/core/Mage/Downloadable/view/adminhtml/sales/order/creditmemo/view/items/renderer/downloadable.phtml b/app/code/core/Mage/Downloadable/view/adminhtml/sales/order/creditmemo/view/items/renderer/downloadable.phtml deleted file mode 100644 index 9fa313210d074..0000000000000 --- a/app/code/core/Mage/Downloadable/view/adminhtml/sales/order/creditmemo/view/items/renderer/downloadable.phtml +++ /dev/null @@ -1,123 +0,0 @@ - -getItem() ?> -setPriceDataObject($_item) ?> - - getColumnHtml($_item, 'downloadable') ?> - - helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - helper('Mage_Tax_Helper_Data')->__('Excl. Tax'); ?>: - - displayPriceAttribute('price') ?> - - - helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - helper('Mage_Tax_Helper_Data')->__('Incl. Tax'); ?>: - - getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 0, 'sales')): // including ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 1, 'sales')): // incl. + weee ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> -
    - - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)); ?> - getApplied($_item) as $tax): ?> - + : currency($tax['amount'],true,true); ?>
    - -
    - getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 2, 'sales')): // excl. + weee + final ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)); ?> -
    - getApplied($_item) as $tax): ?> - : currency($tax['amount'],true,true); ?>
    - - - __('Total'); ?>: - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - - - displayPriceInclTax($_item); ?> - -
    - - - getQty()*1 ?> - - helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - helper('Mage_Tax_Helper_Data')->__('Excl. Tax'); ?>: - - displayPriceAttribute('row_total') ?> - - - helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - helper('Mage_Tax_Helper_Data')->__('Incl. Tax'); ?>: - - - getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 0, 'sales')): // including ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 1, 'sales')): // incl. + weee ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> -
    - - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)); ?> - getApplied($_item) as $tax): ?> - + : currency($tax['row_amount'],true,true); ?>
    - -
    - getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 2, 'sales')): // excl. + weee + final ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)); ?> -
    - getApplied($_item) as $tax): ?> - : currency($tax['row_amount'],true,true); ?>
    - - - __('Total'); ?>: - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - - - displaySubtotalInclTax($_item); ?> - -
    - - - displayPriceAttribute('tax_amount') ?> - displayPriceAttribute('discount_amount') ?> - - displayPrices( - $_item->getBaseRowTotal()-$_item->getBaseDiscountAmount()+$_item->getBaseTaxAmount(), - $_item->getRowTotal()-$_item->getDiscountAmount()+$_item->getTaxAmount()+$_item->getWeeeTaxAppliedAmount() - ) ?> - - diff --git a/app/code/core/Mage/Downloadable/view/adminhtml/sales/order/invoice/create/items/renderer/downloadable.phtml b/app/code/core/Mage/Downloadable/view/adminhtml/sales/order/invoice/create/items/renderer/downloadable.phtml deleted file mode 100644 index 421931d13b91b..0000000000000 --- a/app/code/core/Mage/Downloadable/view/adminhtml/sales/order/invoice/create/items/renderer/downloadable.phtml +++ /dev/null @@ -1,133 +0,0 @@ - -getItem() ?> -setPriceDataObject($_item)?> - - getColumnHtml($_item, 'downloadable') ?> - - helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - helper('Mage_Tax_Helper_Data')->__('Excl. Tax'); ?>: - - displayPriceAttribute('price') ?> - - - helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - helper('Mage_Tax_Helper_Data')->__('Incl. Tax'); ?>: - - getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 0, 'sales')): // including ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 1, 'sales')): // incl. + weee ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> -
    - - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)); ?> - getApplied($_item) as $tax): ?> - + : currency($tax['amount'],true,true); ?>
    - -
    - getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 2, 'sales')): // excl. + weee + final ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)); ?> -
    - getApplied($_item) as $tax): ?> - : currency($tax['amount'],true,true); ?>
    - - - __('Total'); ?>: - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - - - displayPriceInclTax($_item); ?> - -
    - - - getColumnHtml($_item, 'qty') ?> - - canEditQty()) : ?> - - - getQty()*1 ?> - - - - helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - helper('Mage_Tax_Helper_Data')->__('Excl. Tax'); ?>: - - displayPriceAttribute('row_total') ?> - - - helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - helper('Mage_Tax_Helper_Data')->__('Incl. Tax'); ?>: - - - getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 0, 'sales')): // including ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 1, 'sales')): // incl. + weee ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> -
    - - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)); ?> - getApplied($_item) as $tax): ?> - + : currency($tax['row_amount'],true,true); ?>
    - -
    - getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 2, 'sales')): // excl. + weee + final ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)); ?> -
    - getApplied($_item) as $tax): ?> - : currency($tax['row_amount'],true,true); ?>
    - - - __('Total'); ?>: - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - - - displaySubtotalInclTax($_item); ?> - - -
    - - - displayPriceAttribute('tax_amount') ?> - displayPriceAttribute('discount_amount') ?> - - displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseTaxAmount()-$_item->getBaseDiscountAmount(), - $_item->getRowTotal()+$_item->getTaxAmount()-$_item->getDiscountAmount()+$_item->getWeeeTaxAppliedRowAmount() - ) ?> - - diff --git a/app/code/core/Mage/Downloadable/view/adminhtml/sales/order/invoice/view/items/renderer/downloadable.phtml b/app/code/core/Mage/Downloadable/view/adminhtml/sales/order/invoice/view/items/renderer/downloadable.phtml deleted file mode 100644 index 5717fe5fee454..0000000000000 --- a/app/code/core/Mage/Downloadable/view/adminhtml/sales/order/invoice/view/items/renderer/downloadable.phtml +++ /dev/null @@ -1,123 +0,0 @@ - -getItem() ?> -setPriceDataObject($_item) ?> - - getColumnHtml($_item, 'downloadable') ?> - - helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - helper('Mage_Tax_Helper_Data')->__('Excl. Tax'); ?>: - - displayPriceAttribute('price') ?> - - - helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - helper('Mage_Tax_Helper_Data')->__('Incl. Tax'); ?>: - - getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 0, 'sales')): // including ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 1, 'sales')): // incl. + weee ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> -
    - - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)); ?> - getApplied($_item) as $tax): ?> - + : currency($tax['amount'],true,true); ?>
    - -
    - getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 2, 'sales')): // excl. + weee + final ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)); ?> -
    - getApplied($_item) as $tax): ?> - : currency($tax['amount'],true,true); ?>
    - - - __('Total'); ?>: - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - - - displayPriceInclTax($_item); ?> - -
    - - - getQty()*1 ?> - - helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - helper('Mage_Tax_Helper_Data')->__('Excl. Tax'); ?>: - - displayPriceAttribute('row_total') ?> - - - helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - helper('Mage_Tax_Helper_Data')->__('Incl. Tax'); ?>: - - - getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 0, 'sales')): // including ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 1, 'sales')): // incl. + weee ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> -
    - - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)); ?> - getApplied($_item) as $tax): ?> - + : currency($tax['row_amount'],true,true); ?>
    - -
    - getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 2, 'sales')): // excl. + weee + final ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)); ?> -
    - getApplied($_item) as $tax): ?> - : currency($tax['row_amount'],true,true); ?>
    - - - __('Total'); ?>: - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - - - displaySubtotalInclTax($_item); ?> - -
    - - - displayPriceAttribute('tax_amount') ?> - displayPriceAttribute('discount_amount') ?> - - displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseTaxAmount()-$_item->getBaseDiscountAmount()+$_item->getWeeeTaxAppliedAmount(), - $_item->getRowTotal()+$_item->getTaxAmount()-$_item->getDiscountAmount()+$_item->getWeeeTaxAppliedAmount() - ) ?> - - diff --git a/app/code/core/Mage/Downloadable/view/adminhtml/sales/order/view/items/renderer/downloadable.phtml b/app/code/core/Mage/Downloadable/view/adminhtml/sales/order/view/items/renderer/downloadable.phtml deleted file mode 100644 index 443c6670739e3..0000000000000 --- a/app/code/core/Mage/Downloadable/view/adminhtml/sales/order/view/items/renderer/downloadable.phtml +++ /dev/null @@ -1,146 +0,0 @@ - -getItem() ?> -setPriceDataObject($_item) ?> -canDisplayGiftmessage()): ?> class="border"> - - canDisplayContainer()): ?> -
    - -
    - getColumnHtml($_item, 'downloadable') ?> -
    - canDisplayContainer()): ?> -
    - - - getStatus() ?> - displayPriceAttribute('original_price') ?> - - helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - helper('Mage_Tax_Helper_Data')->__('Excl. Tax'); ?>: - - displayPriceAttribute('price') ?> - - - helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - helper('Mage_Tax_Helper_Data')->__('Incl. Tax'); ?>: - - getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 0, 'sales')): // including ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 1, 'sales')): // incl. + weee ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> -
    - - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)); ?> - getApplied($_item) as $tax): ?> - + : currency($tax['amount'],true,true); ?>
    - -
    - getWeeeTaxAppliedAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 2, 'sales')): // excl. + weee + final ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)); ?> -
    - getApplied($_item) as $tax): ?> - : currency($tax['amount'],true,true); ?>
    - - - __('Total'); ?>: - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - - - displayPriceInclTax($_item); ?> - -
    - - - getColumnHtml($_item, 'qty') ?> - - - helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - helper('Mage_Tax_Helper_Data')->__('Excl. Tax'); ?>: - - displayPriceAttribute('row_total') ?> - - - helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - helper('Mage_Tax_Helper_Data')->__('Incl. Tax'); ?>: - - - getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 0, 'sales')): // including ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 1, 'sales')): // incl. + weee ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> -
    - - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)); ?> - getApplied($_item) as $tax): ?> - + : currency($tax['row_amount'],true,true); ?>
    - -
    - getWeeeTaxAppliedRowAmount() && Mage::helper('Mage_Weee_Helper_Data')->typeOfDisplay($_item, 2, 'sales')): // excl. + weee + final ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)); ?> -
    - getApplied($_item) as $tax): ?> - : currency($tax['row_amount'],true,true); ?>
    - - - __('Total'); ?>: - helper('Mage_Checkout_Helper_Data')->formatPrice($this->helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - - - displaySubtotalInclTax($_item); ?> - - - -
    - - - displayPriceAttribute('tax_amount') ?> - displayTaxPercent($_item) ?> - displayPriceAttribute('discount_amount') ?> - - displayPrices( - $_item->getBaseRowTotal() - $_item->getBaseDiscountAmount() + $_item->getBaseTaxAmount(), - $_item->getRowTotal() - $_item->getDiscountAmount() + $_item->getTaxAmount() + $_item->getWeeeTaxAppliedRowAmount() - ); ?> - - diff --git a/app/code/core/Mage/Downloadable/view/frontend/checkout/cart/item/default.phtml b/app/code/core/Mage/Downloadable/view/frontend/checkout/cart/item/default.phtml deleted file mode 100644 index 200afa0296821..0000000000000 --- a/app/code/core/Mage/Downloadable/view/frontend/checkout/cart/item/default.phtml +++ /dev/null @@ -1,277 +0,0 @@ - -getItem(); - $canApplyMsrp = Mage::helper('Mage_Catalog_Helper_Data')->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM); -?> - - <?php echo $this->escapeHtml($this->getProductName()) ?> - -

    escapeHtml($this->getProductName()) ?>

    - getOptionList()):?> -
    - - getFormatedOptionValue($_option) ?> -
    escapeHtml($_option['label']) ?>
    - class="truncated"> - -
    -
    -
    escapeHtml($_option['label']) ?>
    -
    -
    -
    - - - -
    - - - getLinks()): ?> -
    -
    getLinksTitle() ?>
    - -
    escapeHtml($link->getTitle()) ?>
    - -
    - - - - getMessages()): ?> - -
    - * escapeHtml($message['text']) ?> -
    - - - - - __('Edit') ?> - - helper('Mage_Wishlist_Helper_Data')->isAllowInCart()) : ?> - - __('Move'); ?> - - - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> colspan="2"> - - __('See price before order confirmation.'); ?> - getId(); ?> - __("What's this?"); ?> - - - - - - - helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - -
    - - - typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?> - - helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()) ?> - - -
    - - - getApplied($_item)): ?> - - - - typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - __('Total'); ?>: helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?> -
    - - - - - helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item); ?> - typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - -
    - - - typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?> - - helper('Mage_Checkout_Helper_Data')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?> - - -
    - getApplied($_item)): ?> - - - - typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - __('Total incl. tax'); ?>: helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?> -
    - - - - - - - - - helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()) && !$_item->getNoSubtotal()): ?> - - typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - -
    - - - - -- - - typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> - - helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()) ?> - - - -
    - getApplied($_item)): ?> - - - - typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - __('Total'); ?>: helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> -
    - - - - - helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()) && !$_item->getNoSubtotal()): ?> - - helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item); ?> - typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - -
    - - - - -- - - typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - - helper('Mage_Checkout_Helper_Data')->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> - - - -
    - - - getApplied($_item)): ?> - - - - typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - __('Total incl. tax'); ?>: helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> -
    - - - - - __('Remove Item') ?> - diff --git a/app/code/core/Mage/Downloadable/view/frontend/checkout/multishipping/item/downloadable.phtml b/app/code/core/Mage/Downloadable/view/frontend/checkout/multishipping/item/downloadable.phtml deleted file mode 100644 index 6a408e5a3cafe..0000000000000 --- a/app/code/core/Mage/Downloadable/view/frontend/checkout/multishipping/item/downloadable.phtml +++ /dev/null @@ -1,57 +0,0 @@ - -

    escapeHtml($this->getProductName()) ?>

    - -getOptionList()):?> -
    - - getFormatedOptionValue($_option) ?> -
    escapeHtml($_option['label']) ?>
    - class="truncated"> - -
    -
    -
    escapeHtml($_option['label']) ?>
    -
    -
    -
    - - - -
    - - - - getLinks()): ?> -
    -
    getLinksTitle() ?>
    - -
    escapeHtml($link->getTitle()); ?>
    - -
    - - diff --git a/app/code/core/Mage/Downloadable/view/frontend/checkout/onepage/review/item.phtml b/app/code/core/Mage/Downloadable/view/frontend/checkout/onepage/review/item.phtml deleted file mode 100644 index 1cfbd30c9b4e6..0000000000000 --- a/app/code/core/Mage/Downloadable/view/frontend/checkout/onepage/review/item.phtml +++ /dev/null @@ -1,246 +0,0 @@ - -getItem()?> - -

    escapeHtml($this->getProductName()) ?>

    - - getOptionList()):?> -
    - - getFormatedOptionValue($_option) ?> -
    escapeHtml($_option['label']) ?>
    - class="truncated"> - -
    -
    -
    escapeHtml($_option['label']) ?>
    -
    -
    -
    - - - -
    - - getLinks()): ?> -
    -
    getLinksTitle() ?>
    - -
    escapeHtml($link->getTitle()) ?>
    - -
    - - - - helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - -
    - - - typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?> - - helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()) ?> - - -
    - - - getApplied($_item)): ?> - - - - typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - __('Total'); ?>:
    helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>
    -
    - - - - - helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Checkout_Helper_Data')->getPriceInclTax($_item); ?> - typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - -
    - - - typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?> - - helper('Mage_Checkout_Helper_Data')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?> - - -
    - getApplied($_item)): ?> - - - - typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - __('Total incl. tax'); ?>:
    helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?>
    -
    - - - - - getQty() ?> - helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - -
    - - - typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> - - helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()) ?> - - -
    - getApplied($_item)): ?> - - - - typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - __('Total'); ?>:
    helper('Mage_Checkout_Helper_Data')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?>
    -
    - - - - - helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax() || $this->helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - - helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($_item); ?> - typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - -
    - - - typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - - helper('Mage_Checkout_Helper_Data')->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> - - -
    - - - getApplied($_item)): ?> - - - - typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> -
    - __('Total incl. tax'); ?>:
    helper('Mage_Checkout_Helper_Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
    -
    - - - - - diff --git a/app/code/core/Mage/Downloadable/view/frontend/sales/order/creditmemo/items/renderer/downloadable.phtml b/app/code/core/Mage/Downloadable/view/frontend/sales/order/creditmemo/items/renderer/downloadable.phtml deleted file mode 100644 index dfe668fd2226b..0000000000000 --- a/app/code/core/Mage/Downloadable/view/frontend/sales/order/creditmemo/items/renderer/downloadable.phtml +++ /dev/null @@ -1,307 +0,0 @@ - -getItem() ?> -getItem()->getOrderItem()->getOrder() ?> - -

    escapeHtml($_item->getName()) ?>

    - getItemOptions()): ?> -
    - -
    escapeHtml($_option['label']) ?>
    - getPrintStatus()): ?> - getFormatedOptionValue($_option) ?> - class="truncated"> - -
    -
    -
    escapeHtml($_option['label']) ?>
    -
    -
    -
    - - - -
    escapeHtml( (isset($_option['print_value']) ? $_option['print_value'] : $_option['value']) ) ?>
    - - -
    - - - - getLinks()): ?> -
    -
    getLinksTitle() ?>
    - getPurchasedItems() as $link): ?> -
    escapeHtml($link->getLinkTitle()); ?>
    - -
    - - - - escapeHtml($_item->getDescription()) ?> - helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $_item->getOrderItem()) && $_item->getGiftMessageId()): ?> -
    __('Gift Message') ?> - - - escapeHtml(Mage::helper('Mage_Core_Helper_String')->splitInjection($this->getSku())) ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Excl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> - - getOrder()->formatPrice($this->getItem()->getPrice()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?>
    -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Incl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - helper('Mage_Checkout_Helper_Data')->getPriceInclTax($this->getItem()); ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> - - getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?>
    -
    - - -
    - - - getQty()*1 ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Excl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> - - getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?>
    -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Incl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($this->getItem()); ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?> - - getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxRowDisposition()) ?> - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?>
    -
    - - - -
    - - - formatPrice(-$_item->getDiscountAmount()) ?> - - formatPrice($_item->getRowTotal()-$_item->getDiscountAmount()+$_item->getTaxAmount()+$_item->getWeeeTaxAppliedRowAmount()) ?> - - diff --git a/app/code/core/Mage/Downloadable/view/frontend/sales/order/invoice/items/renderer/downloadable.phtml b/app/code/core/Mage/Downloadable/view/frontend/sales/order/invoice/items/renderer/downloadable.phtml deleted file mode 100644 index 9dcdbd8877c9f..0000000000000 --- a/app/code/core/Mage/Downloadable/view/frontend/sales/order/invoice/items/renderer/downloadable.phtml +++ /dev/null @@ -1,307 +0,0 @@ - -getItem() ?> -getItem()->getOrderItem()->getOrder() ?> - -

    escapeHtml($_item->getName()) ?>

    - getItemOptions()): ?> -
    - -
    escapeHtml($_option['label']) ?>
    - getPrintStatus()): ?> - getFormatedOptionValue($_option) ?> - class="truncated"> - - -
    -
    -
    escapeHtml($_option['label']) ?>
    -
    -
    -
    - - - -
    escapeHtml( (isset($_option['print_value']) ? $_option['print_value'] : $_option['value']) ) ?>
    - - -
    - - - - getLinks()): ?> -
    -
    getLinksTitle() ?>
    - getPurchasedItems() as $link): ?> -
    escapeHtml($link->getLinkTitle()); ?>
    - -
    - - - - escapeHtml($_item->getDescription()) ?> - helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $_item->getOrderItem()) && $_item->getGiftMessageId()): ?> -
    __('Gift Message') ?> - - - escapeHtml(Mage::helper('Mage_Core_Helper_String')->splitInjection($this->getSku())) ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Excl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> - - getOrder()->formatPrice($this->getItem()->getPrice()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?>
    -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Incl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - helper('Mage_Checkout_Helper_Data')->getPriceInclTax($this->getItem()); ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> - - getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?>
    -
    - - -
    - - - getQty()*1 ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Excl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> - - getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?>
    -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Incl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($this->getItem()); ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?> - - getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxRowDisposition()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?>
    -
    - - - - - -
    - - - diff --git a/app/code/core/Mage/Downloadable/view/frontend/sales/order/items/renderer/downloadable.phtml b/app/code/core/Mage/Downloadable/view/frontend/sales/order/items/renderer/downloadable.phtml deleted file mode 100644 index c3b951468221f..0000000000000 --- a/app/code/core/Mage/Downloadable/view/frontend/sales/order/items/renderer/downloadable.phtml +++ /dev/null @@ -1,329 +0,0 @@ - -getItem() ?> - -

    escapeHtml($_item->getName()) ?>

    - getItemOptions()): ?> -
    - -
    escapeHtml($_option['label']) ?>
    - getPrintStatus()): ?> - getFormatedOptionValue($_option) ?> - class="truncated"> - - -
    -
    -
    escapeHtml($_option['label']) ?>
    -
    -
    -
    - - - -
    escapeHtml( (isset($_option['print_value']) ? $_option['print_value'] : $_option['value']) ) ?>
    - - -
    - - - - getLinks()): ?> -
    -
    getLinksTitle() ?>
    - getPurchasedItems() as $link): ?> -
    escapeHtml($link->getLinkTitle()); ?>
    - -
    - - - - escapeHtml($_item->getDescription()) ?> - helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $_item) && $_item->getGiftMessageId()): ?> -
    __('Gift Message') ?> - - - escapeHtml(Mage::helper('Mage_Core_Helper_String')->splitInjection($this->getSku())) ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Excl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> - - getOrder()->formatPrice($this->getItem()->getPrice()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?>
    -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Incl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - helper('Mage_Checkout_Helper_Data')->getPriceInclTax($this->getItem()); ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> - - getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?>
    -
    - - -
    - - - - - getItem()->getQtyOrdered() > 0): ?> - __('Ordered'); ?>: getItem()->getQtyOrdered()*1 ?>
    - - getItem()->getQtyShipped() > 0): ?> - __('Shipped'); ?>: getItem()->getQtyShipped()*1 ?>
    - - getItem()->getQtyCanceled() > 0): ?> - __('Canceled'); ?>: getItem()->getQtyCanceled()*1 ?>
    - - getItem()->getQtyRefunded() > 0): ?> - __('Refunded'); ?>: getItem()->getQtyRefunded()*1 ?>
    - -
    - - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Excl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> - - getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?>
    -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displayCartPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displayCartBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Incl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($this->getItem()); ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?> - - getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxRowDisposition()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?>
    -
    - - - - - -
    - - - - diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Main/Abstract.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Main/Abstract.php deleted file mode 100644 index 13f051d5b1348..0000000000000 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Main/Abstract.php +++ /dev/null @@ -1,223 +0,0 @@ - - */ -abstract class Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract extends Mage_Adminhtml_Block_Widget_Form -{ - protected $_attribute = null; - - public function setAttributeObject($attribute) - { - $this->_attribute = $attribute; - return $this; - } - - public function getAttributeObject() - { - if (null === $this->_attribute) { - return Mage::registry('entity_attribute'); - } - return $this->_attribute; - } - - /** - * Preparing default form elements for editing attribute - * - * @return Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract - */ - protected function _prepareForm() - { - $attributeObject = $this->getAttributeObject(); - - $form = new Varien_Data_Form(array( - 'id' => 'edit_form', - 'action' => $this->getData('action'), - 'method' => 'post' - )); - - $fieldset = $form->addFieldset('base_fieldset', - array('legend'=>Mage::helper('Mage_Eav_Helper_Data')->__('Attribute Properties')) - ); - if ($attributeObject->getAttributeId()) { - $fieldset->addField('attribute_id', 'hidden', array( - 'name' => 'attribute_id', - )); - } - - $this->_addElementTypes($fieldset); - - $yesno = Mage::getModel('Mage_Backend_Model_Config_Source_Yesno')->toOptionArray(); - - $validateClass = sprintf('validate-code validate-length maximum-length-%d', - Mage_Eav_Model_Entity_Attribute::ATTRIBUTE_CODE_MAX_LENGTH); - $fieldset->addField('attribute_code', 'text', array( - 'name' => 'attribute_code', - 'label' => Mage::helper('Mage_Eav_Helper_Data')->__('Attribute Code'), - 'title' => Mage::helper('Mage_Eav_Helper_Data')->__('Attribute Code'), - 'note' => Mage::helper('Mage_Eav_Helper_Data')->__('For internal use. Must be unique with no spaces. Maximum length of attribute code must be less then %s symbols', Mage_Eav_Model_Entity_Attribute::ATTRIBUTE_CODE_MAX_LENGTH), - 'class' => $validateClass, - 'required' => true, - )); - - $inputTypes = Mage::getModel('Mage_Eav_Model_Adminhtml_System_Config_Source_Inputtype')->toOptionArray(); - - $fieldset->addField('frontend_input', 'select', array( - 'name' => 'frontend_input', - 'label' => Mage::helper('Mage_Eav_Helper_Data')->__('Catalog Input Type for Store Owner'), - 'title' => Mage::helper('Mage_Eav_Helper_Data')->__('Catalog Input Type for Store Owner'), - 'value' => 'text', - 'values'=> $inputTypes - )); - - $fieldset->addField('default_value_text', 'text', array( - 'name' => 'default_value_text', - 'label' => Mage::helper('Mage_Eav_Helper_Data')->__('Default Value'), - 'title' => Mage::helper('Mage_Eav_Helper_Data')->__('Default Value'), - 'value' => $attributeObject->getDefaultValue(), - )); - - $fieldset->addField('default_value_yesno', 'select', array( - 'name' => 'default_value_yesno', - 'label' => Mage::helper('Mage_Eav_Helper_Data')->__('Default Value'), - 'title' => Mage::helper('Mage_Eav_Helper_Data')->__('Default Value'), - 'values' => $yesno, - 'value' => $attributeObject->getDefaultValue(), - )); - - $dateFormat = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); - $fieldset->addField('default_value_date', 'date', array( - 'name' => 'default_value_date', - 'label' => Mage::helper('Mage_Eav_Helper_Data')->__('Default Value'), - 'title' => Mage::helper('Mage_Eav_Helper_Data')->__('Default Value'), - 'image' => $this->getViewFileUrl('images/grid-cal.gif'), - 'value' => $attributeObject->getDefaultValue(), - 'date_format' => $dateFormat - )); - - $fieldset->addField('default_value_textarea', 'textarea', array( - 'name' => 'default_value_textarea', - 'label' => Mage::helper('Mage_Eav_Helper_Data')->__('Default Value'), - 'title' => Mage::helper('Mage_Eav_Helper_Data')->__('Default Value'), - 'value' => $attributeObject->getDefaultValue(), - )); - - $fieldset->addField('is_unique', 'select', array( - 'name' => 'is_unique', - 'label' => Mage::helper('Mage_Eav_Helper_Data')->__('Unique Value'), - 'title' => Mage::helper('Mage_Eav_Helper_Data')->__('Unique Value (not shared with other products)'), - 'note' => Mage::helper('Mage_Eav_Helper_Data')->__('Not shared with other products'), - 'values' => $yesno, - )); - - $fieldset->addField('is_required', 'select', array( - 'name' => 'is_required', - 'label' => Mage::helper('Mage_Eav_Helper_Data')->__('Values Required'), - 'title' => Mage::helper('Mage_Eav_Helper_Data')->__('Values Required'), - 'values' => $yesno, - )); - - $fieldset->addField('frontend_class', 'select', array( - 'name' => 'frontend_class', - 'label' => Mage::helper('Mage_Eav_Helper_Data')->__('Input Validation for Store Owner'), - 'title' => Mage::helper('Mage_Eav_Helper_Data')->__('Input Validation for Store Owner'), - 'values'=> Mage::helper('Mage_Eav_Helper_Data')->getFrontendClasses( - $attributeObject->getEntityType()->getEntityTypeCode() - ) - )); - - if ($attributeObject->getId()) { - $form->getElement('attribute_code')->setDisabled(1); - $form->getElement('frontend_input')->setDisabled(1); - if (!$attributeObject->getIsUserDefined()) { - $form->getElement('is_unique')->setDisabled(1); - } - } - - $this->setForm($form); - - return parent::_prepareForm(); - } - - /** - * Initialize form fileds values - * - * @return Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract - */ - protected function _initFormValues() - { - Mage::dispatchEvent('adminhtml_block_eav_attribute_edit_form_init', array('form' => $this->getForm())); - $this->getForm() - ->addValues($this->getAttributeObject()->getData()); - return parent::_initFormValues(); - } - - /** - * This method is called before rendering HTML - * - * @return Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract - */ - protected function _beforeToHtml() - { - parent::_beforeToHtml(); - $attributeObject = $this->getAttributeObject(); - if ($attributeObject->getId()) { - $form = $this->getForm(); - $disableAttributeFields = Mage::helper('Mage_Eav_Helper_Data') - ->getAttributeLockedFields($attributeObject->getEntityType()->getEntityTypeCode()); - if (isset($disableAttributeFields[$attributeObject->getAttributeCode()])) { - foreach ($disableAttributeFields[$attributeObject->getAttributeCode()] as $field) { - if ($elm = $form->getElement($field)) { - $elm->setDisabled(1); - $elm->setReadonly(1); - } - } - } - } - return $this; - } - - /** - * Processing block html after rendering - * Adding js block to the end of this block - * - * @param string $html - * @return string - */ - protected function _afterToHtml($html) - { - $jsScripts = $this->getLayout() - ->createBlock('Mage_Eav_Block_Adminhtml_Attribute_Edit_Js')->toHtml(); - return $html.$jsScripts; - } - -} diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid/Abstract.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid/Abstract.php deleted file mode 100644 index b44b8b3b7de1c..0000000000000 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid/Abstract.php +++ /dev/null @@ -1,103 +0,0 @@ - - */ -abstract class Mage_Eav_Block_Adminhtml_Attribute_Grid_Abstract extends Mage_Adminhtml_Block_Widget_Grid -{ - - protected function _construct() - { - parent::_construct(); - $this->setId('attributeGrid'); - $this->setDefaultSort('attribute_code'); - $this->setDefaultDir('ASC'); - } - - /** - * Prepare default grid column - * - * @return Mage_Eav_Block_Adminhtml_Attribute_Grid_Abstract - */ - protected function _prepareColumns() - { - parent::_prepareColumns(); - - $this->addColumn('attribute_code', array( - 'header'=>Mage::helper('Mage_Eav_Helper_Data')->__('Attribute Code'), - 'sortable'=>true, - 'index'=>'attribute_code' - )); - - $this->addColumn('frontend_label', array( - 'header'=>Mage::helper('Mage_Eav_Helper_Data')->__('Attribute Label'), - 'sortable'=>true, - 'index'=>'frontend_label' - )); - - $this->addColumn('is_required', array( - 'header'=>Mage::helper('Mage_Eav_Helper_Data')->__('Required'), - 'sortable'=>true, - 'index'=>'is_required', - 'type' => 'options', - 'options' => array( - '1' => Mage::helper('Mage_Eav_Helper_Data')->__('Yes'), - '0' => Mage::helper('Mage_Eav_Helper_Data')->__('No'), - ), - 'align' => 'center', - )); - - $this->addColumn('is_user_defined', array( - 'header'=>Mage::helper('Mage_Eav_Helper_Data')->__('System'), - 'sortable'=>true, - 'index'=>'is_user_defined', - 'type' => 'options', - 'align' => 'center', - 'options' => array( - '0' => Mage::helper('Mage_Eav_Helper_Data')->__('Yes'), // intended reverted use - '1' => Mage::helper('Mage_Eav_Helper_Data')->__('No'), // intended reverted use - ), - )); - - return $this; - } - - /** - * Return url of given row - * - * @return string - */ - public function getRowUrl($row) - { - return $this->getUrl('*/*/edit', array('attribute_id' => $row->getAttributeId())); - } - -} diff --git a/app/code/core/Mage/Eav/Model/Config.php b/app/code/core/Mage/Eav/Model/Config.php deleted file mode 100644 index 1f3a8dbfcb0dd..0000000000000 --- a/app/code/core/Mage/Eav/Model/Config.php +++ /dev/null @@ -1,709 +0,0 @@ - $object) - * - * @var array - */ - protected $_objects; - - /** - * References between codes and identifiers - * - * array ( - * 'attributes'=> array ($attributeId => $attributeCode), - * 'entities' => array ($entityId => $entityCode) - * ) - * - * @var array - */ - protected $_references; - - /** - * Cache flag - * - * @var unknown_type - */ - protected $_isCacheEnabled = null; - - /** - * Array of attributes objects used in collections - * - * @var array - */ - protected $_collectionAttributes = array(); - - /** - * Reset object state - * - * @return Mage_Eav_Model_Config - */ - public function clear() - { - $this->_entityData = null; - $this->_attributeData = null; - $this->_objects = null; - $this->_references = null; - $this->_preloadedAttributes = array(); - $this->_initializedAttributes = array(); - $this->_attributeCodes = array(); - return $this; - } - - /** - * Get object by identifier - * - * @param mixed $id - * @return mixed - */ - protected function _load($id) - { - return isset($this->_objects[$id]) ? $this->_objects[$id] : null; - } - - /** - * Associate object with identifier - * - * @param mixed $obj - * @param mixed $id - * @return Mage_Eav_Model_Config - */ - protected function _save($obj, $id) - { - $this->_objects[$id] = $obj; - return $this; - } - - /** - * Specify reference for entity type id - * - * @param int $id - * @param string $code - * @return Mage_Eav_Model_Config - */ - protected function _addEntityTypeReference($id, $code) - { - $this->_references['entity'][$id] = $code; - return $this; - } - - /** - * Get entity type code by id - * - * @param int $id - * @return string - */ - protected function _getEntityTypeReference($id) - { - return isset($this->_references['entity'][$id]) ? $this->_references['entity'][$id] : null; - } - - /** - * Specify reference between entity attribute id and attribute code - * - * @param int $id - * @param string $code - * @param string $entityTypeCode - * @return Mage_Eav_Model_Config - */ - protected function _addAttributeReference($id, $code, $entityTypeCode) - { - $this->_references['attribute'][$entityTypeCode][$id] = $code; - return $this; - } - - /** - * Get attribute code by attribute id - * - * @param int $id - * @param string $entityTypeCode - * @return string - */ - protected function _getAttributeReference($id, $entityTypeCode) - { - if (isset($this->_references['attribute'][$entityTypeCode][$id])) { - return $this->_references['attribute'][$entityTypeCode][$id]; - } - return null; - } - - /** - * Get internal cache key for entity type code - * - * @param string $code - * @return string - */ - protected function _getEntityKey($code) - { - return 'ENTITY/' . $code; - } - - /** - * Get internal cache key for attribute object cache - * - * @param string $entityTypeCode - * @param string $attributeCode - * @return string - */ - protected function _getAttributeKey($entityTypeCode, $attributeCode) - { - return 'ATTRIBUTE/' . $entityTypeCode . '/' . $attributeCode; - } - - /** - * Check EAV cache availability - * - * @return bool - */ - protected function _isCacheEnabled() - { - if ($this->_isCacheEnabled === null) { - $this->_isCacheEnabled = Mage::app()->useCache('eav'); - } - return $this->_isCacheEnabled; - } - - /** - * Initialize all entity types data - * - * @return Mage_Eav_Model_Config - */ - protected function _initEntityTypes() - { - if (is_array($this->_entityData)) { - return $this; - } - Magento_Profiler::start('EAV: '.__METHOD__, array('group' => 'EAV', 'method' => __METHOD__)); - - /** - * try load information about entity types from cache - */ - if ($this->_isCacheEnabled() - && ($cache = Mage::app()->loadCache(self::ENTITIES_CACHE_ID))) { - - $this->_entityData = unserialize($cache); - foreach ($this->_entityData as $typeCode => $data) { - $typeId = $data['entity_type_id']; - $this->_addEntityTypeReference($typeId, $typeCode); - } - Magento_Profiler::stop('EAV: '.__METHOD__); - return $this; - } - - $entityTypesData = Mage::getModel('Mage_Eav_Model_Entity_Type')->getCollection()->getData(); - $types = array(); - - /** - * prepare entity type data - */ - foreach ($entityTypesData as $typeData) { - if (!isset($typeData['attribute_model'])) { - $typeData['attribute_model'] = 'Mage_Eav_Model_Entity_Attribute'; - } - - $typeCode = $typeData['entity_type_code']; - $typeId = $typeData['entity_type_id']; - - $this->_addEntityTypeReference($typeId, $typeCode); - $types[$typeCode] = $typeData; - } - - $this->_entityData = $types; - - if ($this->_isCacheEnabled()) { - Mage::app()->saveCache(serialize($this->_entityData), self::ENTITIES_CACHE_ID, - array('eav', Mage_Eav_Model_Entity_Attribute::CACHE_TAG) - ); - } - Magento_Profiler::stop('EAV: '.__METHOD__); - return $this; - } - - /** - * Get entity type object by entity type code/identifier - * - * @param mixed $code - * @return Mage_Eav_Model_Entity_Type - */ - public function getEntityType($code) - { - if ($code instanceof Mage_Eav_Model_Entity_Type) { - return $code; - } - Magento_Profiler::start('EAV: '.__METHOD__, array('group' => 'EAV', 'method' => __METHOD__)); - - if (is_numeric($code)) { - $entityCode = $this->_getEntityTypeReference($code); - if ($entityCode !== null) { - $code = $entityCode; - } - } - - $entityKey = $this->_getEntityKey($code); - $entityType = $this->_load($entityKey); - if ($entityType) { - Magento_Profiler::stop('EAV: '.__METHOD__); - return $entityType; - } - - - $entityType = Mage::getModel('Mage_Eav_Model_Entity_Type'); - if (isset($this->_entityData[$code])) { - $entityType->setData($this->_entityData[$code]); - } else { - if (is_numeric($code)) { - $entityType->load($code); - } else { - $entityType->loadByCode($code); - } - - if (!$entityType->getId()) { - Mage::throwException(Mage::helper('Mage_Eav_Helper_Data')->__('Invalid entity_type specified: %s', $code)); - } - } - $this->_addEntityTypeReference($entityType->getId(), $entityType->getEntityTypeCode()); - $this->_save($entityType, $entityKey); - - Magento_Profiler::stop('EAV: '.__METHOD__); - return $entityType; - } - - /** - * Initialize all attributes for entity type - * - * @param string $entityType - * @return Mage_Eav_Model_Config - */ - protected function _initAttributes($entityType) - { - $entityType = $this->getEntityType($entityType); - $entityTypeCode = $entityType->getEntityTypeCode(); - - if (isset($this->_initializedAttributes[$entityTypeCode])) { - return $this; - } - Magento_Profiler::start('EAV: '.__METHOD__, array('group' => 'EAV', 'method' => __METHOD__)); - - $attributesInfo = Mage::getResourceModel($entityType->getEntityAttributeCollection()) - ->setEntityTypeFilter($entityType) - ->getData(); - - $codes = array(); - foreach ($attributesInfo as $attribute) { - $this->_createAttribute($entityType, $attribute); - $codes[] = $attribute['attribute_code']; - } - - $entityType->setAttributeCodes($codes); - $this->_initializedAttributes[$entityTypeCode] = true; - - Magento_Profiler::stop('EAV: '.__METHOD__); - return $this; - } - - /** - * Get attribute by code for entity type - * - * @param mixed $entityType - * @param mixed $code - * @return Mage_Eav_Model_Entity_Attribute_Abstract|false - */ - public function getAttribute($entityType, $code) - { - if ($code instanceof Mage_Eav_Model_Entity_Attribute_Interface) { - return $code; - } - - Magento_Profiler::start('EAV: '.__METHOD__, array('group' => 'EAV', 'method' => __METHOD__)); - - $entityTypeCode = $this->getEntityType($entityType)->getEntityTypeCode(); - $entityType = $this->getEntityType($entityType); - - /** - * Validate attribute code - */ - if (is_numeric($code)) { - $attributeCode = $this->_getAttributeReference($code, $entityTypeCode); - if ($attributeCode) { - $code = $attributeCode; - } - } - $attributeKey = $this->_getAttributeKey($entityTypeCode, $code); - - /** - * Try use loaded attribute - */ - $attribute = $this->_load($attributeKey); - if ($attribute) { - Magento_Profiler::stop('EAV: '.__METHOD__); - return $attribute; - } - - if (isset($this->_attributeData[$entityTypeCode][$code])) { - $data = $this->_attributeData[$entityTypeCode][$code]; - unset($this->_attributeData[$entityTypeCode][$code]); - $attribute = Mage::getModel($data['attribute_model'], array('data' => $data)); - } else { - if (is_numeric($code)) { - $attribute = Mage::getModel($entityType->getAttributeModel())->load($code); - if ($attribute->getEntityTypeId() != $entityType->getId()) { - return false; - } - $attributeKey = $this->_getAttributeKey($entityTypeCode, $attribute->getAttributeCode()); - } else { - $attribute = Mage::getModel($entityType->getAttributeModel()) - ->loadByCode($entityType, $code) - ->setAttributeCode($code); - } - } - - if ($attribute) { - $entity = $entityType->getEntity(); - if ($entity && in_array($attribute->getAttributeCode(), $entity->getDefaultAttributes())) { - $attribute->setBackendType(Mage_Eav_Model_Entity_Attribute_Abstract::TYPE_STATIC) - ->setIsGlobal(1); - } - $attribute->setEntityType($entityType) - ->setEntityTypeId($entityType->getId()); - $this->_addAttributeReference($attribute->getId(), $attribute->getAttributeCode(), $entityTypeCode); - $this->_save($attribute, $attributeKey); - } - Magento_Profiler::stop('EAV: '.__METHOD__); - - return $attribute; - } - - /** - * Get codes of all entity type attributes - * - * @param mixed $entityType - * @param Varien_Object $object - * @return array - */ - public function getEntityAttributeCodes($entityType, $object = null) - { - $entityType = $this->getEntityType($entityType); - $attributeSetId = 0; - if (($object instanceof Varien_Object) && $object->getAttributeSetId()) { - $attributeSetId = $object->getAttributeSetId(); - } - $storeId = 0; - if (($object instanceof Varien_Object) && $object->getStoreId()) { - $storeId = $object->getStoreId(); - } - $cacheKey = sprintf('%d-%d', $entityType->getId(), $attributeSetId); - if (isset($this->_attributeCodes[$cacheKey])) { - return $this->_attributeCodes[$cacheKey]; - } - - if ($attributeSetId) { - $attributesInfo = Mage::getResourceModel($entityType->getEntityAttributeCollection()) - ->setEntityTypeFilter($entityType) - ->setAttributeSetFilter($attributeSetId) - ->addStoreLabel($storeId) - ->getData(); - $attributes = array(); - foreach ($attributesInfo as $attributeData) { - $attributes[] = $attributeData['attribute_code']; - $this->_createAttribute($entityType, $attributeData); - } - } else { - $this->_initAttributes($entityType); - $attributes = $this->getEntityType($entityType)->getAttributeCodes(); - } - - $this->_attributeCodes[$cacheKey] = $attributes; - - return $attributes; - } - - /** - * Preload entity type attributes for performance optimization - * - * @param mixed $entityType - * @param mixed $attributes - * @return Mage_Eav_Model_Config - */ - public function preloadAttributes($entityType, $attributes) - { - if (is_string($attributes)) { - $attributes = array($attributes); - } - - $entityType = $this->getEntityType($entityType); - $entityTypeCode = $entityType->getEntityTypeCode(); - - if (!isset($this->_preloadedAttributes[$entityTypeCode])) { - $this->_preloadedAttributes[$entityTypeCode] = $attributes; - } else { - $attributes = array_diff($attributes, $this->_preloadedAttributes[$entityTypeCode]); - $this->_preloadedAttributes[$entityTypeCode] = array_merge($this->_preloadedAttributes[$entityTypeCode], - $attributes - ); - } - - if (empty($attributes)) { - return $this; - } - Magento_Profiler::start('EAV: '.__METHOD__ . ':'.$entityTypeCode, - array('group' => 'EAV', 'method' => __METHOD__, 'entity_type_code' => $entityTypeCode)); - - $attributesInfo = Mage::getResourceModel($entityType->getEntityAttributeCollection()) - ->setEntityTypeFilter($entityType) - ->setCodeFilter($attributes) - ->getData(); - - if (!$attributesInfo) { - Magento_Profiler::stop('EAV: '.__METHOD__ . ':'.$entityTypeCode); - return $this; - } - - $attributesData = $codes = array(); - - foreach ($attributesInfo as $attribute) { - if (empty($attribute['attribute_model'])) { - $attribute['attribute_model'] = $entityType->getAttributeModel(); - } - - $attributeCode = $attribute['attribute_code']; - $attributeId = $attribute['attribute_id']; - - $this->_addAttributeReference($attributeId, $attributeCode, $entityTypeCode); - $attributesData[$attributeCode] = $attribute; - $codes[] = $attributeCode; - } - - $this->_attributeData[$entityTypeCode] = $attributesData; - - Magento_Profiler::stop('EAV: '.__METHOD__ . ':'.$entityTypeCode); - - return $this; - } - - /** - * Get attribute object for colection usage - * - * @param mixed $entityType - * @param string $attribute - * @return Mage_Eav_Model_Entity_Attribute_Abstract|null - */ - public function getCollectionAttribute($entityType, $attribute) - { - $entityType = $this->getEntityType($entityType); - $entityTypeCode = $entityType->getEntityTypeCode(); - - if (is_numeric($attribute)) { - $attribute = $this->_getAttributeReference($attribute, $entityTypeCode); - if (!$attribute) { - return null; - } - } - - $attributeKey = $this->_getAttributeKey($entityTypeCode, $attribute); - $attributeObject = $this->_load($attributeKey); - if ($attributeObject) { - return $attributeObject; - } - - return $this->getAttribute($entityType, $attribute); - } - - /** - * Prepare attributes for usage in EAV collection - * - * @param mixed $entityType - * @param array $attributes - * @return Mage_Eav_Model_Config - */ - public function loadCollectionAttributes($entityType, $attributes) - { - $entityType = $this->getEntityType($entityType); - $entityTypeCode = $entityType->getEntityTypeCode(); - - if (!isset($this->_collectionAttributes[$entityTypeCode])) { - $this->_collectionAttributes[$entityTypeCode] = array(); - } - $loadedAttributes = array_keys($this->_collectionAttributes[$entityTypeCode]); - $attributes = array_diff($attributes, $loadedAttributes); - - foreach ($attributes as $k => $attribute) { - if (is_numeric($attribute)) { - $attribute = $this->_getAttributeReference($attribute, $entityTypeCode); - } - $attributeKey = $this->_getAttributeKey($entityTypeCode, $attribute); - if ($this->_load($attributeKey)) { - unset($attributes[$k]); - } - } - - if (empty($attributes)) { - return $this; - } - $attributeCollection = $entityType->getEntityAttributeCollection(); - $attributesInfo = Mage::getResourceModel($attributeCollection) - ->useLoadDataFields() - ->setEntityTypeFilter($entityType) - ->setCodeFilter($attributes) - ->getData(); - - foreach ($attributesInfo as $attributeData) { - $attribute = $this->_createAttribute($entityType, $attributeData); - $this->_collectionAttributes[$entityTypeCode][$attribute->getAttributeCode()] =$attribute; - } - - return $this; - } - - /** - * Create attribute from attribute data array - * - * @param string $entityType - * @param array $attributeData - * @return Mage_Eav_Model_Entity_Attribute_Abstract - */ - protected function _createAttribute($entityType, $attributeData) - { - $entityType = $this->getEntityType($entityType); - $entityTypeCode = $entityType->getEntityTypeCode(); - - $attributeKey = $this->_getAttributeKey($entityTypeCode, $attributeData['attribute_code']); - $attribute = $this->_load($attributeKey); - if ($attribute) { - $existsFullAttribute = $attribute->hasIsRequired(); - $fullAttributeData = array_key_exists('is_required', $attributeData); - - if ($existsFullAttribute || (!$existsFullAttribute && !$fullAttributeData)) { - return $attribute; - } - } - - if (!empty($attributeData['attribute_model'])) { - $model = $attributeData['attribute_model']; - } else { - $model = $entityType->getAttributeModel(); - } - $attribute = Mage::getModel($model)->setData($attributeData); - $this->_addAttributeReference( - $attributeData['attribute_id'], - $attributeData['attribute_code'], - $entityTypeCode - ); - $attributeKey = $this->_getAttributeKey($entityTypeCode, $attributeData['attribute_code']); - $this->_save($attribute, $attributeKey); - - return $attribute; - } - - /** - * Validate attribute data from import - * - * @param array $attributeData - * @return bool - */ - protected function _validateAttributeData($attributeData = null) - { - if (!is_array($attributeData)) { - return false; - } - $requiredKeys = array( - 'attribute_id', - 'attribute_code', - 'entity_type_id', - 'attribute_model' - ); - foreach ($requiredKeys as $key) { - if (!array_key_exists($key, $attributeData)) { - return false; - } - } - - return true; - } - - /** - * Import attributes data from external source - * - * @param string|Mage_Eav_Model_Entity_Type $entityType - * @param array $attributes - * @return Mage_Eav_Model_Config - */ - public function importAttributesData($entityType, array $attributes) - { - $entityType = $this->getEntityType($entityType); - foreach ($attributes as $attributeData) { - if (!$this->_validateAttributeData($attributeData)) { - continue; - } - $this->_createAttribute($entityType, $attributeData); - } - - return $this; - } -} diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute.php b/app/code/core/Mage/Eav/Model/Entity/Attribute.php deleted file mode 100644 index 3576d8845a328..0000000000000 --- a/app/code/core/Mage/Eav/Model/Entity/Attribute.php +++ /dev/null @@ -1,365 +0,0 @@ - - */ -class Mage_Eav_Model_Entity_Attribute extends Mage_Eav_Model_Entity_Attribute_Abstract -{ - /** - * Prefix of model events names - * - * @var string - */ - protected $_eventPrefix = 'eav_entity_attribute'; - - CONST ATTRIBUTE_CODE_MAX_LENGTH = 30; - - /** - * Parameter name in event - * - * In observe method you can use $observer->getEvent()->getAttribute() in this case - * - * @var string - */ - protected $_eventObject = 'attribute'; - - const CACHE_TAG = 'EAV_ATTRIBUTE'; - protected $_cacheTag = 'EAV_ATTRIBUTE'; - - /** - * Retrieve default attribute backend model by attribute code - * - * @return string - */ - protected function _getDefaultBackendModel() - { - switch ($this->getAttributeCode()) { - case 'created_at': - return 'Mage_Eav_Model_Entity_Attribute_Backend_Time_Created'; - - case 'updated_at': - return 'Mage_Eav_Model_Entity_Attribute_Backend_Time_Updated'; - - case 'store_id': - return 'Mage_Eav_Model_Entity_Attribute_Backend_Store'; - - case 'increment_id': - return 'Mage_Eav_Model_Entity_Attribute_Backend_Increment'; - } - - return parent::_getDefaultBackendModel(); - } - - /** - * Retrieve default attribute frontend model - * - * @return string - */ - protected function _getDefaultFrontendModel() - { - return parent::_getDefaultFrontendModel(); - } - - /** - * Retrieve default attribute source model - * - * @return string - */ - protected function _getDefaultSourceModel() - { - if ($this->getAttributeCode() == 'store_id') { - return 'Mage_Eav_Model_Entity_Attribute_Source_Store'; - } - return parent::_getDefaultSourceModel(); - } - - /** - * Delete entity - * - * @return Mage_Eav_Model_Resource_Entity_Attribute - */ - public function deleteEntity() - { - return $this->_getResource()->deleteEntity($this); - } - - /** - * Load entity_attribute_id into $this by $this->attribute_set_id - * - * @return Mage_Core_Model_Abstract - */ - public function loadEntityAttributeIdBySet() - { - // load attributes collection filtered by attribute_id and attribute_set_id - $filteredAttributes = $this->getResourceCollection() - ->setAttributeSetFilter($this->getAttributeSetId()) - ->addFieldToFilter('entity_attribute.attribute_id', $this->getId()) - ->load(); - if (count($filteredAttributes) > 0) { - // getFirstItem() can be used as we can have one or zero records in the collection - $this->setEntityAttributeId($filteredAttributes->getFirstItem()->getEntityAttributeId()); - } - return $this; - } - - /** - * Prepare data for save - * - * @return Mage_Eav_Model_Entity_Attribute - */ - protected function _beforeSave() - { - // prevent overriding product data - if (isset($this->_data['attribute_code']) - && Mage::getModel('Mage_Catalog_Model_Product')->isReservedAttribute($this)) - { - throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('The attribute code \'%s\' is reserved by system. Please try another attribute code', $this->_data['attribute_code'])); - } - - /** - * Check for maximum attribute_code length - */ - if(isset($this->_data['attribute_code']) && - !Zend_Validate::is($this->_data['attribute_code'], - 'StringLength', - array('max' => self::ATTRIBUTE_CODE_MAX_LENGTH)) - ) { - throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Maximum length of attribute code must be less then %s symbols', self::ATTRIBUTE_CODE_MAX_LENGTH)); - } - - $defaultValue = $this->getDefaultValue(); - $hasDefaultValue = ((string)$defaultValue != ''); - - if ($this->getBackendType() == 'decimal' && $hasDefaultValue) { - if (!Zend_Locale_Format::isNumber($defaultValue, - array('locale' => Mage::app()->getLocale()->getLocaleCode())) - ) { - throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Invalid default decimal value')); - } - - try { - $filter = new Zend_Filter_LocalizedToNormalized( - array('locale' => Mage::app()->getLocale()->getLocaleCode()) - ); - $this->setDefaultValue($filter->filter($defaultValue)); - } catch (Exception $e) { - throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Invalid default decimal value')); - } - } - - if ($this->getBackendType() == 'datetime') { - if (!$this->getBackendModel()) { - $this->setBackendModel('Mage_Eav_Model_Entity_Attribute_Backend_Datetime'); - } - - if (!$this->getFrontendModel()) { - $this->setFrontendModel('Mage_Eav_Model_Entity_Attribute_Frontend_Datetime'); - } - - // save default date value as timestamp - if ($hasDefaultValue) { - $format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); - try { - $defaultValue = Mage::app()->getLocale()->date($defaultValue, $format, null, false)->toValue(); - $this->setDefaultValue($defaultValue); - } catch (Exception $e) { - throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Invalid default date')); - } - } - } - - if ($this->getBackendType() == 'gallery') { - if (!$this->getBackendModel()) { - $this->setBackendModel('Mage_Eav_Model_Entity_Attribute_Backend_Default'); - } - } - - return parent::_beforeSave(); - } - - /** - * Save additional data - * - * @return Mage_Eav_Model_Entity_Attribute - */ - protected function _afterSave() - { - $this->_getResource()->saveInSetIncluding($this); - return parent::_afterSave(); - } - - /** - * Detect backend storage type using frontend input type - * - * @param string $type frontend_input field value - * @return string backend_type field value - */ - public function getBackendTypeByInput($type) - { - $field = null; - switch ($type) { - case 'text': - case 'gallery': - case 'media_image': - case 'multiselect': - $field = 'varchar'; - break; - - case 'image': - case 'textarea': - $field = 'text'; - break; - - case 'date': - $field = 'datetime'; - break; - - case 'select': - case 'boolean': - $field = 'int'; - break; - - case 'price': - case 'weight': - $field = 'decimal'; - break; - } - - return $field; - } - - /** - * Detect default value using frontend input type - * - * @param string $type frontend_input field name - * @return string default_value field value - */ - public function getDefaultValueByInput($type) - { - $field = ''; - switch ($type) { - case 'select': - case 'gallery': - case 'media_image': - break; - case 'multiselect': - $field = null; - break; - - case 'text': - case 'price': - case 'image': - case 'weight': - $field = 'default_value_text'; - break; - - case 'textarea': - $field = 'default_value_textarea'; - break; - - case 'date': - $field = 'default_value_date'; - break; - - case 'boolean': - $field = 'default_value_yesno'; - break; - } - - return $field; - } - - /** - * Retrieve attribute codes by frontend type - * - * @param string $type - * @return array - */ - public function getAttributeCodesByFrontendType($type) - { - return $this->getResource()->getAttributeCodesByFrontendType($type); - } - - /** - * Return array of labels of stores - * - * @return array - */ - public function getStoreLabels() - { - if (!$this->getData('store_labels')) { - $storeLabel = $this->getResource()->getStoreLabelsByAttributeId($this->getId()); - $this->setData('store_labels', $storeLabel); - } - return $this->getData('store_labels'); - } - - /** - * Return store label of attribute - * - * @return string - */ - public function getStoreLabel($storeId = null) - { - if ($this->hasData('store_label')) { - return $this->getData('store_label'); - } - $store = Mage::app()->getStore($storeId); - $label = false; - if (!$store->isAdmin()) { - $labels = $this->getStoreLabels(); - if (isset($labels[$store->getId()])) { - return $labels[$store->getId()]; - } - } - return $this->getFrontendLabel(); - } - - /** - * Get attribute sort weight - * - * @param int $setId - * @return float - */ - public function getSortWeight($setId) - { - $groupSortWeight = isset($this->_data['attribute_set_info'][$setId]['group_sort']) - ? (float) $this->_data['attribute_set_info'][$setId]['group_sort'] * 1000 - : 0.0; - $sortWeight = isset($this->_data['attribute_set_info'][$setId]['sort']) - ? (float)$this->_data['attribute_set_info'][$setId]['sort'] * 0.0001 - : 0.0; - return $groupSortWeight + $sortWeight; - } -} diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Group.php b/app/code/core/Mage/Eav/Model/Entity/Attribute/Group.php deleted file mode 100644 index 6765852c2bcb0..0000000000000 --- a/app/code/core/Mage/Eav/Model/Entity/Attribute/Group.php +++ /dev/null @@ -1,75 +0,0 @@ - - */ -class Mage_Eav_Model_Entity_Attribute_Group extends Mage_Core_Model_Abstract -{ - /** - * Resource initialization - */ - protected function _construct() - { - $this->_init('Mage_Eav_Model_Resource_Entity_Attribute_Group'); - } - - /** - * Checks if current attribute group exists - * - * @return boolean - */ - public function itemExists() - { - return $this->_getResource()->itemExists($this); - } - - /** - * Delete groups - * - * @return Mage_Eav_Model_Entity_Attribute_Group - */ - public function deleteGroups() - { - return $this->_getResource()->deleteGroups($this); - } -} diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Set.php b/app/code/core/Mage/Eav/Model/Entity/Attribute/Set.php deleted file mode 100644 index 6df875e7c0ff0..0000000000000 --- a/app/code/core/Mage/Eav/Model/Entity/Attribute/Set.php +++ /dev/null @@ -1,331 +0,0 @@ - - */ -class Mage_Eav_Model_Entity_Attribute_Set extends Mage_Core_Model_Abstract -{ - /** - * Resource instance - * - * @var Mage_Eav_Model_Resource_Entity_Attribute_Set - */ - protected $_resource; - - /** - * Helper instance - * - * @var Mage_Core_Helper_Abstract - */ - protected $_helperInstance; - - /** - * Prefix of model events names - * @var string - */ - protected $_eventPrefix = 'eav_entity_attribute_set'; - - /** - * Initialize data - * - * @param array $data - */ - public function __construct( - Mage_Core_Model_Event_Manager $eventDispatcher, - Mage_Core_Model_Cache $cacheManager, - Mage_Core_Model_Resource_Abstract $resource = null, - Varien_Data_Collection_Db $resourceCollection = null, - array $data = array() - ) { - if (isset($data['helper'])) { - $this->_helperInstance = $data['helper']; - unset($data['helper']); - } - - parent::__construct($eventDispatcher, $cacheManager, $resource, $resourceCollection, $data); - } - - /** - * Initialize resource model - * - */ - protected function _construct() - { - $this->_init('Mage_Eav_Model_Resource_Entity_Attribute_Set'); - } - - /** - * Init attribute set from skeleton (another attribute set) - * - * @param int $skeletonId - * @return Mage_Eav_Model_Entity_Attribute_Set - */ - public function initFromSkeleton($skeletonId) - { - $groups = Mage::getModel('Mage_Eav_Model_Entity_Attribute_Group') - ->getResourceCollection() - ->setAttributeSetFilter($skeletonId) - ->load(); - - $newGroups = array(); - foreach ($groups as $group) { - $newGroup = clone $group; - $newGroup->setId(null) - ->setAttributeSetId($this->getId()) - ->setDefaultId($group->getDefaultId()); - - $groupAttributesCollection = Mage::getModel('Mage_Eav_Model_Entity_Attribute') - ->getResourceCollection() - ->setAttributeGroupFilter($group->getId()) - ->load(); - - $newAttributes = array(); - foreach ($groupAttributesCollection as $attribute) { - $newAttribute = Mage::getModel('Mage_Eav_Model_Entity_Attribute') - ->setId($attribute->getId()) - //->setAttributeGroupId($newGroup->getId()) - ->setAttributeSetId($this->getId()) - ->setEntityTypeId($this->getEntityTypeId()) - ->setSortOrder($attribute->getSortOrder()); - $newAttributes[] = $newAttribute; - } - $newGroup->setAttributes($newAttributes); - $newGroups[] = $newGroup; - } - $this->setGroups($newGroups); - - return $this; - } - - /** - * Collect data for save - * - * @param array $data - * @return Mage_Eav_Model_Entity_Attribute_Set - */ - public function organizeData($data) - { - $modelGroupArray = array(); - $modelAttributeArray = array(); - $attributeIds = array(); - if ($data['attributes']) { - $ids = array(); - foreach ($data['attributes'] as $attribute) { - $ids[] = $attribute[0]; - } - $attributeIds = Mage::getResourceSingleton('Mage_Eav_Model_Resource_Entity_Attribute') - ->getValidAttributeIds($ids); - } - if( $data['groups'] ) { - foreach ($data['groups'] as $group) { - $modelGroup = Mage::getModel('Mage_Eav_Model_Entity_Attribute_Group'); - $modelGroup->setId(is_numeric($group[0]) && $group[0] > 0 ? $group[0] : null) - ->setAttributeGroupName($group[1]) - ->setAttributeSetId($this->getId()) - ->setSortOrder($group[2]); - - if( $data['attributes'] ) { - foreach( $data['attributes'] as $attribute ) { - if( $attribute[1] == $group[0] && in_array($attribute[0], $attributeIds) ) { - $modelAttribute = Mage::getModel('Mage_Eav_Model_Entity_Attribute'); - $modelAttribute->setId($attribute[0]) - ->setAttributeGroupId($attribute[1]) - ->setAttributeSetId($this->getId()) - ->setEntityTypeId($this->getEntityTypeId()) - ->setSortOrder($attribute[2]); - $modelAttributeArray[] = $modelAttribute; - } - } - $modelGroup->setAttributes($modelAttributeArray); - $modelAttributeArray = array(); - } - $modelGroupArray[] = $modelGroup; - } - $this->setGroups($modelGroupArray); - } - - - if( $data['not_attributes'] ) { - $modelAttributeArray = array(); - foreach( $data['not_attributes'] as $attributeId ) { - $modelAttribute = Mage::getModel('Mage_Eav_Model_Entity_Attribute'); - - $modelAttribute->setEntityAttributeId($attributeId); - $modelAttributeArray[] = $modelAttribute; - } - $this->setRemoveAttributes($modelAttributeArray); - } - - if( $data['removeGroups'] ) { - $modelGroupArray = array(); - foreach( $data['removeGroups'] as $groupId ) { - $modelGroup = Mage::getModel('Mage_Eav_Model_Entity_Attribute_Group'); - $modelGroup->setId($groupId); - - $modelGroupArray[] = $modelGroup; - } - $this->setRemoveGroups($modelGroupArray); - } - $this->setAttributeSetName($data['attribute_set_name']) - ->setEntityTypeId($this->getEntityTypeId()); - - return $this; - } - - /** - * Validate attribute set name - * - * @return bool - * @throws Mage_Eav_Exception - */ - public function validate() - { - $attributeSetName = $this->getAttributeSetName(); - if ($attributeSetName == '') { - throw Mage::exception('Mage_Eav', - $this->_helper('Mage_Eav_Helper_Data')->__('Attribute set name is empty.') - ); - } - - if (!$this->_getResource()->validate($this, $attributeSetName)) { - throw Mage::exception('Mage_Eav', - $this->_helper('Mage_Eav_Helper_Data')->__('Attribute set with the "%s" name already exists.', $attributeSetName) - ); - } - - return true; - } - - /** - * Add set info to attributes - * - * @param string|Mage_Eav_Model_Entity_Type $entityType - * @param array $attributes - * @param int $setId - * @return Mage_Eav_Model_Entity_Attribute_Set - */ - public function addSetInfo($entityType, array $attributes, $setId = null) - { - $attributeIds = array(); - $config = Mage::getSingleton('Mage_Eav_Model_Config'); - $entityType = $config->getEntityType($entityType); - foreach ($attributes as $attribute) { - $attribute = $config->getAttribute($entityType, $attribute); - if ($setId && is_array($attribute->getAttributeSetInfo($setId))) { - continue; - } - if (!$attribute->getAttributeId()) { - continue; - } - $attributeIds[] = $attribute->getAttributeId(); - } - - if ($attributeIds) { - $setInfo = $this->_getResource() - ->getSetInfo($attributeIds, $setId); - - foreach ($attributes as $attribute) { - $attribute = $config->getAttribute($entityType, $attribute); - if (!$attribute->getAttributeId()) { - continue; - } - if (!in_array($attribute->getAttributeId(), $attributeIds)) { - continue; - } - if (is_numeric($setId)) { - $attributeSetInfo = $attribute->getAttributeSetInfo(); - if (!is_array($attributeSetInfo)) { - $attributeSetInfo = array(); - } - if (isset($setInfo[$attribute->getAttributeId()][$setId])) { - $attributeSetInfo[$setId] = $setInfo[$attribute->getAttributeId()][$setId]; - } - $attribute->setAttributeSetInfo($attributeSetInfo); - } else { - if (isset($setInfo[$attribute->getAttributeId()])) { - $attribute->setAttributeSetInfo($setInfo[$attribute->getAttributeId()]); - } - else { - $attribute->setAttributeSetInfo(array()); - } - } - } - } - - return $this; - } - - /** - * Return default Group Id for current or defined Attribute Set - * - * @param int $setId - * @return int|null - */ - public function getDefaultGroupId($setId = null) - { - if ($setId === null) { - $setId = $this->getId(); - } - - return $setId ? $this->_getResource()->getDefaultGroupId($setId) : null; - } - - /** - * Retrieve helper instance by specified helper name - * - * @param string $helperName - * @return Mage_Core_Helper_Abstract - */ - protected function _helper($helperName) - { - return $this->_helperInstance instanceof $helperName ? $this->_helperInstance : Mage::helper($helperName); - } - - /** - * Get resource instance - * - * @return Mage_Core_Model_Resource_Db_Abstract - */ - protected function _getResource() - { - return $this->_resource ?: parent::_getResource(); - } -} diff --git a/app/code/core/Mage/Eav/Model/Entity/Setup.php b/app/code/core/Mage/Eav/Model/Entity/Setup.php deleted file mode 100644 index 59587fee20f40..0000000000000 --- a/app/code/core/Mage/Eav/Model/Entity/Setup.php +++ /dev/null @@ -1,1506 +0,0 @@ - - */ -class Mage_Eav_Model_Entity_Setup extends Mage_Core_Model_Resource_Setup -{ - /** - * Application cache model - * - * @var Mage_Core_Model_Cache - */ - protected $_cache; - - /** - * @param Mage_Core_Model_Config_Resource $resourcesConfig - * @param Mage_Core_Model_Config_Modules $modulesConfig - * @param Mage_Core_Model_Resource $resource - * @param Mage_Core_Model_Config_Modules_Reader $modulesReader - * @param Mage_Core_Model_Cache $cache - * @param string $resourceName - */ - public function __construct( - Mage_Core_Model_Config_Resource $resourcesConfig, - Mage_Core_Model_Config_Modules $modulesConfig, - Mage_Core_Model_Resource $resource, - Mage_Core_Model_Config_Modules_Reader $modulesReader, - Mage_Core_Model_Cache $cache, - $resourceName - ) - { - parent::__construct($resourcesConfig, $modulesConfig, $resource, $modulesReader, $resourceName); - $this->_cache = $cache; - } - - /** - * General Attribute Group Name - * - * @var string - */ - protected $_generalGroupName = 'General'; - - /** - * Default attribute group name to id pairs - * - * @var array - */ - public $defaultGroupIdAssociations = array( - 'General' => 1 - ); - - /** - * Default attribute group name - * - * @var string - */ - protected $_defaultGroupName = 'Default'; - - /** - * Default attribute set name - * - * @var string - */ - protected $_defaultAttributeSetName = 'Default'; - - /** - * List of excluded attribute set ids - * - * @var array - */ - protected $_excludedAttributeSetIds = array(); - - /** - * Clean cache - * - * @return Mage_Eav_Model_Entity_Setup - */ - public function cleanCache() - { - $this->_cache->clean(array('eav')); - return $this; - } - - /** - * Install Default Group Ids - * - * @return Mage_Eav_Model_Entity_Setup - */ - public function installDefaultGroupIds() - { - $setIds = $this->getAllAttributeSetIds(); - foreach ($this->defaultGroupIdAssociations as $defaultGroupName => $defaultGroupId) { - foreach ($setIds as $set) { - $groupId = $this->getTableRow('eav_attribute_group', - 'attribute_group_name', $defaultGroupName, 'attribute_group_id', 'attribute_set_id', $set - ); - if (!$groupId) { - $groupId = $this->getTableRow('eav_attribute_group', - 'attribute_set_id', $set, 'attribute_group_id' - ); - } - $this->updateTableRow('eav_attribute_group', - 'attribute_group_id', $groupId, 'default_id', $defaultGroupId - ); - } - } - - return $this; - } - - -/******************* ENTITY TYPES *****************/ - - /** - * Add an entity type - * - * If already exists updates the entity type with params data - * - * @param string $code - * @param array $params - * @return Mage_Eav_Model_Entity_Setup - */ - public function addEntityType($code, array $params) - { - $data = array( - 'entity_type_code' => $code, - 'entity_model' => $params['entity_model'], - 'attribute_model' => $this->_getValue($params, 'attribute_model'), - 'entity_table' => $this->_getValue($params, 'table', 'eav_entity'), - 'value_table_prefix' => $this->_getValue($params, 'table_prefix'), - 'entity_id_field' => $this->_getValue($params, 'id_field'), - 'increment_model' => $this->_getValue($params, 'increment_model'), - 'increment_per_store' => $this->_getValue($params, 'increment_per_store', 0), - 'increment_pad_length' => $this->_getValue($params, 'increment_pad_length', 8), - 'increment_pad_char' => $this->_getValue($params, 'increment_pad_char', 0), - 'additional_attribute_table' => $this->_getValue($params, 'additional_attribute_table'), - 'entity_attribute_collection' => $this->_getValue($params, 'entity_attribute_collection'), - ); - - if ($this->getEntityType($code, 'entity_type_id')) { - $this->updateEntityType($code, $data); - } else { - $this->_conn->insert($this->getTable('eav_entity_type'), $data); - } - - if (!empty($params['default_group'])) { - $defaultGroup = $params['default_group']; - } else { - $defaultGroup = $this->_defaultGroupName; - } - - $this->addAttributeSet($code, $this->_defaultAttributeSetName); - $this->addAttributeGroup($code, $this->_defaultGroupName, $this->getGeneralGroupName()); - - return $this; - } - - /** - * Update entity row - * - * @param string $code - * @param string $field - * @param string $value - * @return Mage_Eav_Model_Entity_Setup - */ - public function updateEntityType($code, $field, $value = null) - { - $this->updateTableRow('eav_entity_type', - 'entity_type_id', $this->getEntityTypeId($code), $field, $value - ); - return $this; - } - - /** - * Retrieve Entity Type Data - * - * @param int|string $id - * @param string $field - * @return mixed - */ - public function getEntityType($id, $field = null) - { - return $this->getTableRow('eav_entity_type', - is_numeric($id) ? 'entity_type_id' : 'entity_type_code', $id, $field - ); - } - - /** - * Retrieve Entity Type Id By Id or Code - * - * @param mixed $entityTypeId - * @return int - */ - public function getEntityTypeId($entityTypeId) - { - if (!is_numeric($entityTypeId)) { - $entityTypeId = $this->getEntityType($entityTypeId, 'entity_type_id'); - } - if (!is_numeric($entityTypeId)) { - throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Wrong entity ID')); - } - - return $entityTypeId; - } - - /** - * Remove entity type by Id or Code - * - * @param mixed $id - * @return Mage_Eav_Model_Entity_Setup - */ - public function removeEntityType($id) - { - if (is_numeric($id)) { - $this->deleteTableRow('eav_entity_type', 'entity_type_id', $id); - } else { - $this->deleteTableRow('eav_entity_type', 'entity_type_code', (string)$id); - } - - return $this; - } - -/******************* ATTRIBUTE SETS *****************/ - - /** - * Retrieve Attribute Set Sort order - * - * @param mixed $entityTypeId - * @param int $sortOrder - * @return int - */ - public function getAttributeSetSortOrder($entityTypeId, $sortOrder = null) - { - if (!is_numeric($sortOrder)) { - $bind = array('entity_type_id' => $this->getEntityTypeId($entityTypeId)); - $select = $this->_conn->select() - ->from($this->getTable('eav_attribute_set'), 'MAX(sort_order)') - ->where('entity_type_id = :entity_type_id'); - - $sortOrder = $this->_conn->fetchOne($select, $bind) + 1; - } - - return $sortOrder; - } - - /** - * Add Attribute Set - * - * @param mixed $entityTypeId - * @param string $name - * @param int $sortOrder - * @return Mage_Eav_Model_Entity_Setup - */ - public function addAttributeSet($entityTypeId, $name, $sortOrder = null) - { - $data = array( - 'entity_type_id' => $this->getEntityTypeId($entityTypeId), - 'attribute_set_name' => $name, - 'sort_order' => $this->getAttributeSetSortOrder($entityTypeId, $sortOrder), - ); - - $setId = $this->getAttributeSet($entityTypeId, $name, 'attribute_set_id'); - if ($setId) { - $this->updateAttributeSet($entityTypeId, $setId, $data); - } else { - $this->_conn->insert($this->getTable('eav_attribute_set'), $data); - - $this->addAttributeGroup($entityTypeId, $name, $this->getGeneralGroupName()); - } - - return $this; - } - - /** - * Update attribute set data - * - * @param mixed $entityTypeId - * @param int $id - * @param string $field - * @param mixed $value - * @return Mage_Eav_Model_Entity_Setup - */ - public function updateAttributeSet($entityTypeId, $id, $field, $value = null) - { - $this->updateTableRow('eav_attribute_set', - 'attribute_set_id', $this->getAttributeSetId($entityTypeId, $id), - $field, $value, - 'entity_type_id', $this->getEntityTypeId($entityTypeId) - ); - return $this; - } - - /** - * Retrieve Attribute set data by id or name - * - * @param mixed $entityTypeId - * @param mixed $id - * @param string $field - * @return mixed - */ - public function getAttributeSet($entityTypeId, $id, $field = null) - { - return $this->getTableRow('eav_attribute_set', - is_numeric($id) ? 'attribute_set_id' : 'attribute_set_name', $id, - $field, - 'entity_type_id', $this->getEntityTypeId($entityTypeId) - ); - } - - /** - * Retrieve Attribute Set Id By Id or Name - * - * @throws Mage_Eav_Exception - * @param mixed $entityTypeId - * @param mixed $setId - * @return int - */ - public function getAttributeSetId($entityTypeId, $setId) - { - if (!is_numeric($setId)) { - $setId = $this->getAttributeSet($entityTypeId, $setId, 'attribute_set_id'); - } - if (!is_numeric($setId)) { - throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Wrong attribute set ID')); - } - - return $setId; - } - - /** - * Remove Attribute Set - * - * @param mixed $entityTypeId - * @param mixed $id - * @return Mage_Eav_Model_Entity_Setup - */ - public function removeAttributeSet($entityTypeId, $id) - { - $this->deleteTableRow('eav_attribute_set', 'attribute_set_id', $this->getAttributeSetId($entityTypeId, $id)); - return $this; - } - - /** - * Set Default Attribute Set to Entity Type - * - * @param mixed $entityType - * @return Mage_Eav_Model_Entity_Setup - */ - public function setDefaultSetToEntityType($entityType, $attributeSet = 'Default') - { - $entityTypeId = $this->getEntityTypeId($entityType); - $setId = $this->getAttributeSetId($entityTypeId, $attributeSet); - $this->updateEntityType($entityTypeId, 'default_attribute_set_id', $setId); - return $this; - } - - /** - * Get identifiers of all attribute sets - * - * @return array - */ - public function getAllAttributeSetIds($entityTypeId = null) - { - $select = $this->_conn->select() - ->from($this->getTable('eav_attribute_set'), 'attribute_set_id'); - - $bind = array(); - if ($entityTypeId !== null) { - $bind['entity_type_id'] = $this->getEntityTypeId($entityTypeId); - $select->where('entity_type_id = :entity_type_id'); - } - - return $this->_conn->fetchCol($select, $bind); - } - - /** - * Retrieve Default Attribute Set for Entity Type - * - * @param string|int $entityType - * @return int - */ - public function getDefaultAttributeSetId($entityType) - { - $bind = array('entity_type' => $entityType); - if (is_numeric($entityType)) { - $where = 'entity_type_id = :entity_type'; - } else { - $where = 'entity_type_code = :entity_type'; - } - $select = $this->getConnection()->select() - ->from($this->getTable('eav_entity_type'), 'default_attribute_set_id') - ->where($where); - - return $this->getConnection()->fetchOne($select, $bind); - } - -/******************* ATTRIBUTE GROUPS *****************/ - - /** - * Retrieve Attribute Group Sort order - * - * @param mixed $entityTypeId - * @param mixed $setId - * @param int $sortOrder - * @return int - */ - public function getAttributeGroupSortOrder($entityTypeId, $setId, $sortOrder = null) - { - if (!is_numeric($sortOrder)) { - $bind = array('attribute_set_id' => $this->getAttributeSetId($entityTypeId, $setId)); - $select = $this->_conn->select() - ->from($this->getTable('eav_attribute_group'), 'MAX(sort_order)') - ->where('attribute_set_id = :attribute_set_id'); - - $sortOrder = $this->_conn->fetchOne($select, $bind) + 1; - } - - return $sortOrder; - } - - /** - * Add Attribute Group - * - * @param mixed $entityTypeId - * @param mixed $setId - * @param string $name - * @param int $sortOrder - * @return Mage_Eav_Model_Entity_Setup - */ - public function addAttributeGroup($entityTypeId, $setId, $name, $sortOrder = null) - { - $setId = $this->getAttributeSetId($entityTypeId, $setId); - $data = array( - 'attribute_set_id' => $setId, - 'attribute_group_name' => $name, - ); - - if (isset($this->defaultGroupIdAssociations[$name])) { - $data['default_id'] = $this->defaultGroupIdAssociations[$name]; - } - - if ($sortOrder !== null) { - $data['sort_order'] = $sortOrder; - } - - $groupId = $this->getAttributeGroup($entityTypeId, $setId, $name, 'attribute_group_id'); - if ($groupId) { - $this->updateAttributeGroup($entityTypeId, $setId, $groupId, $data); - } else { - if ($sortOrder === null) { - $data['sort_order'] = $this->getAttributeGroupSortOrder($entityTypeId, $setId, $sortOrder); - } - $this->_conn->insert($this->getTable('eav_attribute_group'), $data); - } - - return $this; - } - - /** - * Update Attribute Group Data - * - * @param mixed $entityTypeId - * @param mixed $setId - * @param mixed $id - * @param string $field - * @param mixed $value - * @return Mage_Eav_Model_Entity_Setup - */ - public function updateAttributeGroup($entityTypeId, $setId, $id, $field, $value = null) - { - $this->updateTableRow('eav_attribute_group', - 'attribute_group_id', $this->getAttributeGroupId($entityTypeId, $setId, $id), - $field, $value, - 'attribute_set_id', $this->getAttributeSetId($entityTypeId, $setId) - ); - - return $this; - } - - /** - * Retrieve Attribute Group Data - * - * @param mixed $entityTypeId - * @param mixed $setId - * @param mixed $id - * @param string $field - * @return mixed - */ - public function getAttributeGroup($entityTypeId, $setId, $id, $field = null) - { - $searchId = $id; - if (is_numeric($id)) { - $searchField = 'attribute_group_id'; - } else { - if (isset($this->defaultGroupIdAssociations[$id])) { - $searchField = 'default_id'; - $searchId = $this->defaultGroupIdAssociations[$id]; - } else { - $searchField = 'attribute_group_name'; - } - } - - return $this->getTableRow('eav_attribute_group', - $searchField, $searchId, $field, - 'attribute_set_id', $this->getAttributeSetId($entityTypeId, $setId) - ); - } - - /** - * Retrieve Attribute Group Id by Id or Name - * - * @param mixed $entityTypeId - * @param mixed $setId - * @param mixed $groupId - * @return Mage_Eav_Model_Entity_Setup - */ - public function getAttributeGroupId($entityTypeId, $setId, $groupId) - { - if (!is_numeric($groupId)) { - $groupId = $this->getAttributeGroup($entityTypeId, $setId, $groupId, 'attribute_group_id'); - } - - if (!is_numeric($groupId)) { - $groupId = $this->getDefaultAttributeGroupId($entityTypeId, $setId); - } - - if (!is_numeric($groupId)) { - throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Wrong attribute group ID')); - } - return $groupId; - } - - /** - * Remove Attribute Group By Id or Name - * - * @param mixed $entityTypeId - * @param mixed $setId - * @param mixed $id - * @return Mage_Eav_Model_Entity_Setup - */ - public function removeAttributeGroup($entityTypeId, $setId, $id) - { - $this->deleteTableRow( - 'eav_attribute_group', - 'attribute_group_id', - $this->getAttributeGroupId($entityTypeId, $setId, $id) - ); - return $this; - } - - /** - * Retrieve Default Attribute Group Id By Entity Type and Attribute Set - * - * @param string|int $entityType - * @param int $attributeSetId - * @return int - */ - public function getDefaultAttributeGroupId($entityType, $attributeSetId = null) - { - $entityType = $this->getEntityTypeId($entityType); - if (!is_numeric($attributeSetId)) { - $attributeSetId = $this->getDefaultAttributeSetId($entityType); - } - $bind = array('attribute_set_id' => $attributeSetId); - $select = $this->getConnection()->select() - ->from($this->getTable('eav_attribute_group'), 'attribute_group_id') - ->where('attribute_set_id = :attribute_set_id') - ->order(array('default_id ' . Varien_Db_Select::SQL_DESC, 'sort_order')) - ->limit(1); - - return $this->getConnection()->fetchOne($select, $bind); - } - -/******************* ATTRIBUTES *****************/ - - /** - * Retrieve value from array by key or return default value - * - * @param array $array - * @param string $key - * @param string $default - * @return string - */ - protected function _getValue($array, $key, $default = null) - { - if (isset($array[$key]) && is_bool($array[$key])) { - $array[$key] = (int) $array[$key]; - } - return isset($array[$key]) ? $array[$key] : $default; - } - - /** - * Prepare attribute values to save - * - * @param array $attr - * @return array - */ - protected function _prepareValues($attr) - { - $data = array( - 'backend_model' => $this->_getValue($attr, 'backend'), - 'backend_type' => $this->_getValue($attr, 'type', 'varchar'), - 'backend_table' => $this->_getValue($attr, 'table'), - 'frontend_model' => $this->_getValue($attr, 'frontend'), - 'frontend_input' => $this->_getValue($attr, 'input', 'text'), - 'frontend_label' => $this->_getValue($attr, 'label'), - 'frontend_class' => $this->_getValue($attr, 'frontend_class'), - 'source_model' => $this->_getValue($attr, 'source'), - 'is_required' => $this->_getValue($attr, 'required', 1), - 'is_user_defined' => $this->_getValue($attr, 'user_defined', 0), - 'default_value' => $this->_getValue($attr, 'default'), - 'is_unique' => $this->_getValue($attr, 'unique', 0), - 'note' => $this->_getValue($attr, 'note'), - 'is_global' => $this->_getValue($attr, 'global', - Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL - ), - ); - - return $data; - } - - /** - * Validate attribute data before insert into table - * - * @param array $data - * @throws Mage_Eav_Exception - * @return true - */ - protected function _validateAttributeData($data) - { - $attributeCodeMaxLength = Mage_Eav_Model_Entity_Attribute::ATTRIBUTE_CODE_MAX_LENGTH; - - if (isset($data['attribute_code']) && - !Zend_Validate::is($data['attribute_code'], 'StringLength', array('max' => $attributeCodeMaxLength))) - { - throw Mage::exception('Mage_Eav', - Mage::helper('Mage_Eav_Helper_Data')->__('Maximum length of attribute code must be less then %s symbols', $attributeCodeMaxLength) - ); - } - - return true; - } - - /** - * Add attribute to an entity type - * - * If attribute is system will add to all existing attribute sets - * - * @param string|integer $entityTypeId - * @param string $code - * @param array $attr - * @return Mage_Eav_Model_Entity_Setup - */ - public function addAttribute($entityTypeId, $code, array $attr) - { - $entityTypeId = $this->getEntityTypeId($entityTypeId); - $data = array_merge( - array( - 'entity_type_id' => $entityTypeId, - 'attribute_code' => $code - ), - $this->_prepareValues($attr) - ); - - $this->_validateAttributeData($data); - - $sortOrder = isset($attr['sort_order']) ? $attr['sort_order'] : null; - $attributeId = $this->getAttribute($entityTypeId, $code, 'attribute_id'); - if ($attributeId) { - $this->updateAttribute($entityTypeId, $attributeId, $data, null, $sortOrder); - } else { - $this->_insertAttribute($data); - } - - if (!empty($attr['group']) || empty($attr['user_defined'])) { - $select = $this->_conn->select() - ->from($this->getTable('eav_attribute_set')) - ->where('entity_type_id = :entity_type_id'); - if (!empty($this->_excludedAttributeSetIds)) { - $select->where('attribute_set_id NOT IN (?)', $this->_excludedAttributeSetIds); - } - $sets = $this->_conn->fetchAll($select, array('entity_type_id' => $entityTypeId)); - foreach ($sets as $set) { - if (!empty($attr['group'])) { - $this->addAttributeGroup($entityTypeId, $set['attribute_set_id'], - $attr['group']); - $this->addAttributeToSet($entityTypeId, $set['attribute_set_id'], - $attr['group'], $code, $sortOrder); - } else { - $this->addAttributeToSet($entityTypeId, $set['attribute_set_id'], - $this->getGeneralGroupName(), $code, $sortOrder); - } - } - } - - if (isset($attr['option']) && is_array($attr['option'])) { - $option = $attr['option']; - $option['attribute_id'] = $this->getAttributeId($entityTypeId, $code); - $this->addAttributeOption($option); - } - - return $this; - } - - /** - * Set attribute set ids which should be excluded for attributes assigning - * - * @param array $ids - * @return Mage_Eav_Model_Entity_Setup - */ - public function setExcludedAttributeSetIds(array $ids) - { - $this->_excludedAttributeSetIds = $ids; - return $this; - } - - /** - * Add Attribure Option - * - * @param array $option - */ - public function addAttributeOption($option) - { - $optionTable = $this->getTable('eav_attribute_option'); - $optionValueTable = $this->getTable('eav_attribute_option_value'); - - if (isset($option['value'])) { - foreach ($option['value'] as $optionId => $values) { - $intOptionId = (int) $optionId; - if (!empty($option['delete'][$optionId])) { - if ($intOptionId) { - $condition = array('option_id =?' => $intOptionId); - $this->_conn->delete($optionTable, $condition); - } - continue; - } - - if (!$intOptionId) { - $data = array( - 'attribute_id' => $option['attribute_id'], - 'sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0, - ); - $this->_conn->insert($optionTable, $data); - $intOptionId = $this->_conn->lastInsertId($optionTable); - } else { - $data = array( - 'sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0, - ); - $this->_conn->update($optionTable, $data, array('option_id=?' => $intOptionId)); - } - - // Default value - if (!isset($values[0])) { - Mage::throwException(Mage::helper('Mage_Eav_Helper_Data')->__('Default option value is not defined')); - } - $condition = array('option_id =?' => $intOptionId); - $this->_conn->delete($optionValueTable, $condition); - foreach ($values as $storeId => $value) { - $data = array( - 'option_id' => $intOptionId, - 'store_id' => $storeId, - 'value' => $value, - ); - $this->_conn->insert($optionValueTable, $data); - } - } - } else if (isset($option['values'])) { - foreach ($option['values'] as $sortOrder => $label) { - // add option - $data = array( - 'attribute_id' => $option['attribute_id'], - 'sort_order' => $sortOrder, - ); - $this->_conn->insert($optionTable, $data); - $intOptionId = $this->_conn->lastInsertId($optionTable); - - $data = array( - 'option_id' => $intOptionId, - 'store_id' => 0, - 'value' => $label, - ); - $this->_conn->insert($optionValueTable, $data); - } - } - } - - /** - * Update Attribute data and Attribute additional data - * - * @param mixed $entityTypeId - * @param mixed $id - * @param string $field - * @param mixed $value - * @param int $sortOrder - * @return Mage_Eav_Model_Entity_Setup - */ - public function updateAttribute($entityTypeId, $id, $field, $value = null, $sortOrder = null) - { - $this->_updateAttribute($entityTypeId, $id, $field, $value, $sortOrder); - $this->_updateAttributeAdditionalData($entityTypeId, $id, $field, $value); - return $this; - } - - /** - * Update Attribute data - * - * @param mixed $entityTypeId - * @param mixed $id - * @param string $field - * @param mixed $value - * @param int $sortOrder - * @return Mage_Eav_Model_Entity_Setup - */ - protected function _updateAttribute($entityTypeId, $id, $field, $value = null, $sortOrder = null) - { - if ($sortOrder !== null) { - $this->updateTableRow('eav_entity_attribute', - 'attribute_id', $this->getAttributeId($entityTypeId, $id), - 'sort_order', $sortOrder - ); - } - - $attributeFields = $this->_getAttributeTableFields(); - if (is_array($field)) { - $bind = array(); - foreach ($field as $k => $v) { - if (isset($attributeFields[$k])) { - $bind[$k] = $this->getConnection()->prepareColumnValue($attributeFields[$k], $v); - } - } - if (!$bind) { - return $this; - } - $field = $bind; - } else { - if (!isset($attributeFields[$field])) { - return $this; - } - } - - $this->updateTableRow('eav_attribute', - 'attribute_id', $this->getAttributeId($entityTypeId, $id), - $field, $value, - 'entity_type_id', $this->getEntityTypeId($entityTypeId) - ); - - return $this; - } - - /** - * Update Attribute Additional data - * - * @param mixed $entityTypeId - * @param mixed $id - * @param string $field - * @param mixed $value - * @return Mage_Eav_Model_Entity_Setup - */ - protected function _updateAttributeAdditionalData($entityTypeId, $id, $field, $value = null) - { - $additionalTable = $this->getEntityType($entityTypeId, 'additional_attribute_table'); - if (!$additionalTable) { - return $this; - } - $additionalTableExists = $this->getConnection()->isTableExists($this->getTable($additionalTable)); - if ($additionalTable && $additionalTableExists) { - $attributeFields = $this->getConnection()->describeTable($this->getTable($additionalTable)); - if (is_array($field)) { - $bind = array(); - foreach ($field as $k => $v) { - if (isset($attributeFields[$k])) { - $bind[$k] = $this->getConnection()->prepareColumnValue($attributeFields[$k], $v); - } - } - if (!$bind) { - return $this; - } - $field = $bind; - } else { - if (!isset($attributeFields[$field])) { - return $this; - } - } - $this->updateTableRow($this->getTable($additionalTable), - 'attribute_id', $this->getAttributeId($entityTypeId, $id), - $field, $value - ); - } - - return $this; - } - - /** - * Retrieve Attribute Data By Id or Code - * - * @param mixed $entityTypeId - * @param mixed $id - * @param string $field - * @return mixed - */ - public function getAttribute($entityTypeId, $id, $field = null) - { - $additionalTable = $this->getEntityType($entityTypeId, 'additional_attribute_table'); - $entityTypeId = $this->getEntityTypeId($entityTypeId); - $idField = is_numeric($id) ? 'attribute_id' : 'attribute_code'; - if (!$additionalTable) { - return $this->getTableRow('eav_attribute', $idField, $id, $field, 'entity_type_id', $entityTypeId); - } - - $mainTable = $this->getTable('eav_attribute'); - if (empty($this->_setupCache[$mainTable][$entityTypeId][$id])) { - $additionalTable = $this->getTable($additionalTable); - $bind = array( - 'id' => $id, - 'entity_type_id' => $entityTypeId - ); - $select = $this->_conn->select() - ->from(array('main' => $mainTable)) - ->join( - array('additional' => $additionalTable), - 'main.attribute_id = additional.attribute_id') - ->where("main.{$idField} = :id") - ->where('main.entity_type_id = :entity_type_id'); - - $row = $this->_conn->fetchRow($select, $bind); - if (!$row) { - $this->_setupCache[$mainTable][$entityTypeId][$id] = false; - } else { - $this->_setupCache[$mainTable][$entityTypeId][$row['attribute_id']] = $row; - $this->_setupCache[$mainTable][$entityTypeId][$row['attribute_code']] = $row; - } - } - - $row = $this->_setupCache[$mainTable][$entityTypeId][$id]; - if ($field !== null) { - return isset($row[$field]) ? $row[$field] : false; - } - - return $row; - } - - /** - * Retrieve Attribute Id Data By Id or Code - * - * @param mixed $entityTypeId - * @param mixed $id - * @return int - */ - public function getAttributeId($entityTypeId, $id) - { - if (!is_numeric($id)) { - $id = $this->getAttribute($entityTypeId, $id, 'attribute_id'); - } - if (!is_numeric($id)) { - return false; - } - return $id; - } - - /** - * Return table name for eav attribute - * - * @param int|string $entityTypeId Entity Type id or Entity Type code - * @param int|string $id Attribute id or Attribute code - * @return string - */ - public function getAttributeTable($entityTypeId, $id) - { - $entityKeyName = is_numeric($entityTypeId) ? 'entity_type_id' : 'entity_type_code'; - $attributeKeyName = is_numeric($id) ? 'attribute_id' : 'attribute_code'; - - $bind = array( - 'id' => $id, - 'entity_type_id' => $entityTypeId - ); - $select = $this->getConnection()->select() - ->from( - array('entity_type' => $this->getTable('eav_entity_type')), - array('entity_table')) - ->join( - array('attribute' => $this->getTable('eav_attribute')), - 'attribute.entity_type_id = entity_type.entity_type_id', - array('backend_type')) - ->where("entity_type.{$entityKeyName} = :entity_type_id") - ->where("attribute.{$attributeKeyName} = :id") - ->limit(1); - - $result = $this->getConnection()->fetchRow($select, $bind); - if ($result) { - $table = $this->getTable($result['entity_table']); - if ($result['backend_type'] != 'static') { - $table .= '_' . $result['backend_type']; - } - return $table; - } - - return false; - } - - /** - * Remove Attribute - * - * @param mixed $entityTypeId - * @param mixed $code - * @return Mage_Eav_Model_Entity_Setup - */ - public function removeAttribute($entityTypeId, $code) - { - $mainTable = $this->getTable('eav_attribute'); - $attribute = $this->getAttribute($entityTypeId, $code); - if ($attribute) { - $this->deleteTableRow('eav_attribute', 'attribute_id', $attribute['attribute_id']); - if (isset($this->_setupCache[$mainTable][$attribute['entity_type_id']][$attribute['attribute_code']])) { - unset($this->_setupCache[$mainTable][$attribute['entity_type_id']][$attribute['attribute_code']]); - } - } - return $this; - } - - /** - * Retrieve Attribute Sort Order - * - * @param mixed $entityTypeId - * @param mixed $setId - * @param mixed $groupId - * @param int $sortOrder - * @return Mage_Eav_Model_Entity_Setup - */ - public function getAttributeSortOrder($entityTypeId, $setId, $groupId, $sortOrder = null) - { - if (!is_numeric($sortOrder)) { - $bind = array('attribute_group_id' => $this->getAttributeGroupId($entityTypeId, $setId, $groupId)); - $select = $this->_conn->select() - ->from($this->getTable('eav_entity_attribute'), 'MAX(sort_order)') - ->where('attribute_group_id = :attribute_group_id'); - - $sortOrder = $this->_conn->fetchOne($select, $bind) + 1; - } - - return $sortOrder; - } - - /** - * Add Attribute to All Groups on Attribute Set - * - * @param mixed $entityTypeId - * @param mixed $setId - * @param mixed $groupId - * @param mixed $attributeId - * @param int $sortOrder - * @return Mage_Eav_Model_Entity_Setup - */ - public function addAttributeToSet($entityTypeId, $setId, $groupId, $attributeId, $sortOrder=null) - { - $entityTypeId = $this->getEntityTypeId($entityTypeId); - $setId = $this->getAttributeSetId($entityTypeId, $setId); - $groupId = $this->getAttributeGroupId($entityTypeId, $setId, $groupId); - $attributeId = $this->getAttributeId($entityTypeId, $attributeId); - $table = $this->getTable('eav_entity_attribute'); - - $bind = array( - 'attribute_set_id' => $setId, - 'attribute_id' => $attributeId - ); - $select = $this->_conn->select() - ->from($table) - ->where('attribute_set_id = :attribute_set_id') - ->where('attribute_id = :attribute_id'); - $result = $this->_conn->fetchRow($select, $bind); - - if ($result) { - if ($result['attribute_group_id'] != $groupId) { - $where = array('entity_attribute_id =?' => $result['entity_attribute_id']); - $data = array('attribute_group_id' => $groupId); - $this->_conn->update($table, $data, $where); - } - } else { - $data = array( - 'entity_type_id' => $entityTypeId, - 'attribute_set_id' => $setId, - 'attribute_group_id' => $groupId, - 'attribute_id' => $attributeId, - 'sort_order' => $this->getAttributeSortOrder($entityTypeId, $setId, $groupId, $sortOrder), - ); - - $this->_conn->insert($table, $data); - } - - return $this; - } - - /** - * Add or update attribute to group - * - * @param int|string $entityType - * @param int|string $setId - * @param int|string $groupId - * @param int|string $attributeId - * @param int $sortOrder - * @return Mage_Eav_Model_Entity_Setup - */ - public function addAttributeToGroup($entityType, $setId, $groupId, $attributeId, $sortOrder = null) - { - $entityType = $this->getEntityTypeId($entityType); - $setId = $this->getAttributeSetId($entityType, $setId); - $groupId = $this->getAttributeGroupId($entityType, $setId, $groupId); - $attributeId = $this->getAttributeId($entityType, $attributeId); - - $data = array( - 'entity_type_id' => $entityType, - 'attribute_set_id' => $setId, - 'attribute_group_id' => $groupId, - 'attribute_id' => $attributeId, - ); - - $bind = array( - 'entity_type_id' => $entityType, - 'attribute_set_id' => $setId, - 'attribute_id' => $attributeId - ); - $select = $this->getConnection()->select() - ->from($this->getTable('eav_entity_attribute')) - ->where('entity_type_id = :entity_type_id') - ->where('attribute_set_id = :attribute_set_id') - ->where('attribute_id = :attribute_id'); - $row = $this->getConnection()->fetchRow($select, $bind); - if ($row) { - // update - if ($sortOrder !== null) { - $data['sort_order'] = $sortOrder; - } - - $this->getConnection()->update( - $this->getTable('eav_entity_attribute'), - $data, - $this->getConnection()->quoteInto('entity_attribute_id=?', $row['entity_attribute_id']) - ); - } else { - if ($sortOrder === null) { - $select = $this->getConnection()->select() - ->from($this->getTable('eav_entity_attribute'), 'MAX(sort_order)') - ->where('entity_type_id = :entity_type_id') - ->where('attribute_set_id = :attribute_set_id') - ->where('attribute_id = :attribute_id'); - - $sortOrder = $this->getConnection()->fetchOne($select, $bind) + 10; - } - $sortOrder = is_numeric($sortOrder) ? $sortOrder : 1; - $data['sort_order'] = $sortOrder; - $this->getConnection()->insert($this->getTable('eav_entity_attribute'), $data); - } - - return $this; - } - -/******************* BULK INSTALL *****************/ - - /** - * Install entities - * - * @param array $entities - * @return Mage_Eav_Model_Entity_Setup - */ - public function installEntities($entities = null) - { - $this->cleanCache(); - - if ($entities === null) { - $entities = $this->getDefaultEntities(); - } - - foreach ($entities as $entityName=>$entity) { - $this->addEntityType($entityName, $entity); - - $frontendPrefix = isset($entity['frontend_prefix']) ? $entity['frontend_prefix'] : ''; - $backendPrefix = isset($entity['backend_prefix']) ? $entity['backend_prefix'] : ''; - $sourcePrefix = isset($entity['source_prefix']) ? $entity['source_prefix'] : ''; - - if (is_array($entity['attributes']) && !empty($entity['attributes'])) { - foreach ($entity['attributes'] as $attrCode => $attr) { - if (!empty($attr['backend'])) { - if ('_' === $attr['backend']) { - $attr['backend'] = $backendPrefix; - } elseif ('_' === $attr['backend']{0}) { - $attr['backend'] = $backendPrefix.$attr['backend']; - } else { - $attr['backend'] = $attr['backend']; - } - } - if (!empty($attr['frontend'])) { - if ('_' === $attr['frontend']) { - $attr['frontend'] = $frontendPrefix; - } elseif ('_' === $attr['frontend']{0}) { - $attr['frontend'] = $frontendPrefix.$attr['frontend']; - } else { - $attr['frontend'] = $attr['frontend']; - } - } - if (!empty($attr['source'])) { - if ('_' === $attr['source']) { - $attr['source'] = $sourcePrefix; - } elseif ('_' === $attr['source']{0}) { - $attr['source'] = $sourcePrefix . $attr['source']; - } else { - $attr['source'] = $attr['source']; - } - } - - $this->addAttribute($entityName, $attrCode, $attr); - } - } - $this->setDefaultSetToEntityType($entityName); - } - - return $this; - } - - -/****************************** CREATE ENTITY TABLES ***********************************/ - - /** - * Create entity tables - * - * @param string $baseName - * @param array $options - * - no-main - * - no-default-types - * - types - * @return unknown - */ - public function createEntityTables($baseTableName, array $options = array()) - { - $isNoCreateMainTable = $this->_getValue($options, 'no-main', false); - $isNoDefaultTypes = $this->_getValue($options, 'no-default-types', false); - $customTypes = $this->_getValue($options, 'types', array()); - $tables = array(); - - if (!$isNoCreateMainTable) { - /** - * Create table main eav table - */ - $connection = $this->getConnection(); - $mainTable = $connection - ->newTable($this->getTable($baseTableName)) - ->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( - 'identity' => true, - 'nullable' => false, - 'primary' => true, - ), 'Entity Id') - ->addColumn('entity_type_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ), 'Entity Type Id') - ->addColumn('attribute_set_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ), 'Attribute Set Id') - ->addColumn('increment_id', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array( - 'nullable' => false, - 'default' => '', - ), 'Increment Id') - ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ), 'Store Id') - ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array( - 'nullable' => false, - ), 'Created At') - ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array( - 'nullable' => false, - ), 'Updated At') - ->addColumn('is_active', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( - 'unsigned' => true, - 'nullable' => false, - 'default' => '1', - ), 'Defines Is Entity Active') - ->addIndex($this->getIdxName($baseTableName, array('entity_type_id')), - array('entity_type_id')) - ->addIndex($this->getIdxName($baseTableName, array('store_id')), - array('store_id')) - ->addForeignKey($this->getFkName($baseTableName, 'entity_type_id', 'eav_entity_type', 'entity_type_id'), - 'entity_type_id', $this->getTable('eav_entity_type'), 'entity_type_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE) - ->addForeignKey($this->getFkName($baseTableName, 'store_id', 'core_store', 'store_id'), - 'store_id', $this->getTable('core_store'), 'store_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE) - ->setComment('Eav Entity Main Table'); - - $tables[$this->getTable($baseTableName)] = $mainTable; - } - - $types = array(); - if (!$isNoDefaultTypes) { - $types = array( - 'datetime' => array(Varien_Db_Ddl_Table::TYPE_DATETIME, null), - 'decimal' => array(Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4'), - 'int' => array(Varien_Db_Ddl_Table::TYPE_INTEGER, null), - 'text' => array(Varien_Db_Ddl_Table::TYPE_TEXT, '64k'), - 'varchar' => array(Varien_Db_Ddl_Table::TYPE_TEXT, '255'), - 'char' => array(Varien_Db_Ddl_Table::TYPE_TEXT, '255') - ); - } - - if (!empty($customTypes)) { - foreach ($customTypes as $type => $fieldType) { - if (count($fieldType) != 2) { - throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Wrong type definition for %s', $type)); - } - $types[$type] = $fieldType; - } - } - - /** - * Create table array($baseTableName, $type) - */ - foreach ($types as $type => $fieldType) { - $eavTableName = array($baseTableName, $type); - - $eavTable = $connection->newTable($this->getTable($eavTableName)); - $eavTable - ->addColumn('value_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( - 'identity' => true, - 'nullable' => false, - 'primary' => true, - ), 'Value Id') - ->addColumn('entity_type_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ), 'Entity Type Id') - ->addColumn('attribute_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ), 'Attribute Id') - ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ), 'Store Id') - ->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ), 'Entity Id') - ->addColumn('value', $fieldType[0], $fieldType[1], array( - 'nullable' => false, - ), 'Attribute Value') - ->addIndex($this->getIdxName($eavTableName, array('entity_type_id')), - array('entity_type_id')) - ->addIndex($this->getIdxName($eavTableName, array('attribute_id')), - array('attribute_id')) - ->addIndex($this->getIdxName($eavTableName, array('store_id')), - array('store_id')) - ->addIndex($this->getIdxName($eavTableName, array('entity_id')), - array('entity_id')); - if ($type !== 'text') { - $eavTable->addIndex($this->getIdxName($eavTableName, array('attribute_id', 'value')), - array('attribute_id', 'value')); - $eavTable->addIndex($this->getIdxName($eavTableName, array('entity_type_id', 'value')), - array('entity_type_id', 'value')); - } - - $eavTable - ->addForeignKey($this->getFkName($eavTableName, 'entity_id', $baseTableName, 'entity_id'), - 'entity_id', $this->getTable($baseTableName), 'entity_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE) - ->addForeignKey($this->getFkName($eavTableName, 'entity_type_id', 'eav_entity_type', 'entity_type_id'), - 'entity_type_id', $this->getTable('eav_entity_type'), 'entity_type_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE) - ->addForeignKey($this->getFkName($eavTableName, 'store_id', 'core_store', 'store_id'), - 'store_id', $this->getTable('core_store'), 'store_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE) - ->setComment('Eav Entity Value Table'); - - $tables[$this->getTable($eavTableName)] = $eavTable; - } - - $connection->beginTransaction(); - try { - foreach ($tables as $tableName => $table) { - $connection->createTable($table); - } - $connection->commit(); - } catch (Exception $e) { - $connection->rollBack(); - throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Can\'t create table: %s', $tableName)); - } - - return $this; - } - - /** - * Retrieve attribute table fields - * - * @return array - */ - protected function _getAttributeTableFields() - { - return $this->getConnection()->describeTable($this->getTable('eav_attribute')); - } - - /** - * Insert attribute and filter data - * - * @param array $data - * @return Mage_Eav_Model_Entity_Setup - */ - protected function _insertAttribute(array $data) - { - $bind = array(); - - $fields = $this->_getAttributeTableFields(); - - foreach ($data as $k => $v) { - if (isset($fields[$k])) { - $bind[$k] = $this->getConnection()->prepareColumnValue($fields[$k], $v); - } - } - if (!$bind) { - return $this; - } - - $this->getConnection()->insert($this->getTable('eav_attribute'), $bind); - $attributeId = $this->getConnection()->lastInsertId($this->getTable('eav_attribute')); - $this->_insertAttributeAdditionalData( - $data['entity_type_id'], - array_merge(array('attribute_id' => $attributeId), $data) - ); - - return $this; - } - - /** - * Insert attribute additional data - * - * @param int $entityTypeId - * @param array $data - * @return Mage_Eav_Model_Entity_Setup - */ - protected function _insertAttributeAdditionalData($entityTypeId, array $data) - { - $additionalTable = $this->getEntityType($entityTypeId, 'additional_attribute_table'); - if (!$additionalTable) { - return $this; - } - $additionalTableExists = $this->getConnection()->isTableExists($this->getTable($additionalTable)); - if ($additionalTable && $additionalTableExists) { - $bind = array(); - $fields = $this->getConnection()->describeTable($this->getTable($additionalTable)); - foreach ($data as $k => $v) { - if (isset($fields[$k])) { - $bind[$k] = $this->getConnection()->prepareColumnValue($fields[$k], $v); - } - } - if (!$bind) { - return $this; - } - $this->getConnection()->insert($this->getTable($additionalTable), $bind); - } - - return $this; - } - - /** - * Retrieve general group name - * - * @return string - */ - public function getGeneralGroupName() - { - return $this->_generalGroupName; - } -} diff --git a/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Group.php b/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Group.php deleted file mode 100755 index 223e578959cca..0000000000000 --- a/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Group.php +++ /dev/null @@ -1,140 +0,0 @@ - - */ -class Mage_Eav_Model_Resource_Entity_Attribute_Group extends Mage_Core_Model_Resource_Db_Abstract -{ - /** - * Resource initialization - */ - protected function _construct() - { - $this->_init('eav_attribute_group', 'attribute_group_id'); - } - - /** - * Checks if attribute group exists - * - * @param Mage_Eav_Model_Entity_Attribute_Group $object - * @return boolean - */ - public function itemExists($object) - { - $adapter = $this->_getReadAdapter(); - $bind = array( - 'attribute_set_id' => $object->getAttributeSetId(), - 'attribute_group_name' => $object->getAttributeGroupName() - ); - $select = $adapter->select() - ->from($this->getMainTable()) - ->where('attribute_set_id = :attribute_set_id') - ->where('attribute_group_name = :attribute_group_name'); - - return $adapter->fetchRow($select, $bind) > 0; - } - - /** - * Perform actions before object save - * - * @param Mage_Core_Model_Abstract $object - * @return Mage_Core_Model_Resource_Db_Abstract - */ - protected function _beforeSave(Mage_Core_Model_Abstract $object) - { - if (!$object->getSortOrder()) { - $object->setSortOrder($this->_getMaxSortOrder($object) + 1); - } - return parent::_beforeSave($object); - } - - /** - * Perform actions after object save - * - * @param Mage_Core_Model_Abstract $object - * @return Mage_Core_Model_Resource_Db_Abstract - */ - protected function _afterSave(Mage_Core_Model_Abstract $object) - { - if ($object->getAttributes()) { - foreach ($object->getAttributes() as $attribute) { - $attribute->setAttributeGroupId($object->getId()); - $attribute->save(); - } - } - - return parent::_afterSave($object); - } - - /** - * Retreive max sort order - * - * @param Mage_Core_Model_Abstract $object - * @return int - */ - protected function _getMaxSortOrder($object) - { - $adapter = $this->_getReadAdapter(); - $bind = array(':attribute_set_id' => $object->getAttributeSetId()); - $select = $adapter->select() - ->from($this->getMainTable(), new Zend_Db_Expr("MAX(sort_order)")) - ->where('attribute_set_id = :attribute_set_id'); - - return $adapter->fetchOne($select, $bind); - } - - /** - * Set any group default if old one was removed - * - * @param integer $attributeSetId - * @return Mage_Eav_Model_Resource_Entity_Attribute_Group - */ - public function updateDefaultGroup($attributeSetId) - { - $adapter = $this->_getWriteAdapter(); - $bind = array(':attribute_set_id' => $attributeSetId); - $select = $adapter->select() - ->from($this->getMainTable(), $this->getIdFieldName()) - ->where('attribute_set_id = :attribute_set_id') - ->order('default_id ' . Varien_Data_Collection::SORT_ORDER_DESC) - ->limit(1); - - $groupId = $adapter->fetchOne($select, $bind); - - if ($groupId) { - $data = array('default_id' => 1); - $where = array('attribute_group_id =?' => $groupId); - $adapter->update($this->getMainTable(), $data, $where); - } - - return $this; - } -} diff --git a/app/code/core/Mage/Eav/etc/config.xml b/app/code/core/Mage/Eav/etc/config.xml deleted file mode 100644 index ff216ea6de764..0000000000000 --- a/app/code/core/Mage/Eav/etc/config.xml +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - 1.6.0.1 - true - core - - - - - - - - - - Mage_Eav - Mage_Eav_Model_Entity_Setup - - - - - - - - Entity types declaration cache. - eav - - - - - - - - - - - - - - Mage_Eav.csv - - - - - - - - - - - Mage_Eav.csv - - - - - - - - - - text - - date - boolean - multiselect - - - - - - diff --git a/app/code/core/Mage/GiftMessage/Block/Message/Inline.php b/app/code/core/Mage/GiftMessage/Block/Message/Inline.php deleted file mode 100644 index c4e86a0d0d505..0000000000000 --- a/app/code/core/Mage/GiftMessage/Block/Message/Inline.php +++ /dev/null @@ -1,297 +0,0 @@ - - */ -class Mage_GiftMessage_Block_Message_Inline extends Mage_Core_Block_Template -{ - - protected $_entity = null; - protected $_type = null; - protected $_giftMessage = null; - - protected $_template = 'inline.phtml'; - - /** - * Set entity - * - * @return mixed - */ - public function setEntity($entity) - { - $this->_entity = $entity; - return $this; - } - - /** - * Get entity - * - * @return mixed - */ - public function getEntity() - { - return $this->_entity; - } - - /** - * Set type - * - * @param string $type - * @return Mage_GiftMessage_Block_Message_Inline - */ - public function setType($type) - { - $this->_type = $type; - return $this; - } - - /** - * Get type - * - * @return string - */ - public function getType() - { - return $this->_type; - } - - /** - * Check if entity has gift message - * - * @return bool - */ - public function hasGiftMessage() - { - return $this->getEntity()->getGiftMessageId() > 0; - } - - /** - * Init message - * - * @return Mage_GiftMessage_Block_Message_Inline - */ - protected function _initMessage() - { - $this->_giftMessage = $this->helper('Mage_GiftMessage_Helper_Message')->getGiftMessage( - $this->getEntity()->getGiftMessageId() - ); - return $this; - } - - /** - * Get default value for From field - * - * @return string - */ - public function getDefaultFrom() - { - if (Mage::getSingleton('Mage_Customer_Model_Session')->isLoggedIn()) { - return Mage::getSingleton('Mage_Customer_Model_Session')->getCustomer()->getName(); - } else { - return $this->getEntity()->getBillingAddress()->getName(); - } - } - - /** - * Get default value for To field - * - * @return string - */ - public function getDefaultTo() - { - if ($this->getEntity()->getShippingAddress()) { - return $this->getEntity()->getShippingAddress()->getName(); - } else { - return $this->getEntity()->getName(); - } - } - - /** - * Retrieve message - * - * @param mixed $entity - * @return string - */ - public function getMessage($entity=null) - { - if (is_null($this->_giftMessage)) { - $this->_initMessage(); - } - - if ($entity) { - if (!$entity->getGiftMessage()) { - $entity->setGiftMessage( - $this->helper('Mage_GiftMessage_Helper_Message')->getGiftMessage($entity->getGiftMessageId()) - ); - } - return $entity->getGiftMessage(); - } - - return $this->_giftMessage; - } - - /** - * Retrieve items - * - * @return array - */ - public function getItems() - { - if (!$this->getData('items')) { - $items = array(); - - $entityItems = $this->getEntity()->getAllItems(); - Mage::dispatchEvent('gift_options_prepare_items', array('items' => $entityItems)); - - foreach ($entityItems as $item) { - if ($item->getParentItem()) { - continue; - } - if ($this->isItemMessagesAvailable($item) || $item->getIsGiftOptionsAvailable()) { - $items[] = $item; - } - } - $this->setData('items', $items); - } - return $this->getData('items'); - } - - /** - * Retrieve additional url - * - * @return bool - */ - public function getAdditionalUrl() - { - return $this->getUrl('*/*/getAdditional'); - } - - /** - * Check if items are available - * - * @return bool - */ - public function isItemsAvailable() - { - return count($this->getItems()) > 0; - } - - /** - * Return items count - * - * @return int - */ - public function countItems() - { - return count($this->getItems()); - } - - /** - * Check if items has messages - * - * @return bool - */ - public function getItemsHasMesssages() - { - foreach ($this->getItems() as $item) { - if ($item->getGiftMessageId()) { - return true; - } - } - return false; - } - - /** - * Check if entity has message - * - * @return bool - */ - public function getEntityHasMessage() - { - return $this->getEntity()->getGiftMessageId() > 0; - } - - /** - * Return escaped value - * - * @param string $value - * @param string $defaultValue - * @return string - */ - public function getEscaped($value, $defaultValue='') - { - return $this->escapeHtml(trim($value)!='' ? $value : $defaultValue); - } - - /** - * Check availability of giftmessages for specified entity - * - * @return bool - */ - public function isMessagesAvailable() - { - return Mage::helper('Mage_GiftMessage_Helper_Message')->isMessagesAvailable('quote', $this->getEntity()); - } - - /** - * Check availability of giftmessages for specified entity item - * - * @return bool - */ - public function isItemMessagesAvailable($item) - { - $type = substr($this->getType(), 0, 5) == 'multi' ? 'address_item' : 'item'; - return Mage::helper('Mage_GiftMessage_Helper_Message')->isMessagesAvailable($type, $item); - } - - /** - * Product thumbnail image url getter - * - * @param Mage_Core_Model_Product $product - * @return string - */ - public function getThumbnailUrl($product) - { - return (string) $this->helper('Mage_Catalog_Helper_Image')->init($product, 'thumbnail')->resize($this->getThumbnailSize()); - } - - /** - * Thumbnail image size getter - * - * @return int - */ - public function getThumbnailSize() - { - return $this->getVar('product_thumbnail_image_size', 'Mage_Catalog'); - } - -} diff --git a/app/code/core/Mage/GiftMessage/etc/config.xml b/app/code/core/Mage/GiftMessage/etc/config.xml deleted file mode 100644 index 33685a71fe9ab..0000000000000 --- a/app/code/core/Mage/GiftMessage/etc/config.xml +++ /dev/null @@ -1,217 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - - Mage_GiftMessage - Mage_GiftMessage_Model_Resource_Setup - - - - - - - - - - - - - - - - - 0 - 0 - - - - - - - - - Mage_GiftMessage.csv - - - - - - - - - model - Mage_GiftMessage_Model_Observer - salesEventConvertQuoteItemToOrderItem - - - - - - - model - Mage_GiftMessage_Model_Observer - salesEventConvertQuoteAddressToOrder - - - - - - - model - Mage_GiftMessage_Model_Observer - salesEventConvertQuoteToOrder - - - - - - - model - Mage_GiftMessage_Model_Observer - checkoutEventCreateOrder - - - - - - - model - Mage_GiftMessage_Model_Observer - salesEventOrderToQuote - - - - - - - model - Mage_GiftMessage_Model_Observer - salesEventOrderItemToQuoteItem - - - - - - - - layout.xml - - - - - - - - - - model - Mage_GiftMessage_Model_Observer - salesEventConvertQuoteItemToOrderItem - - - - - - - model - Mage_GiftMessage_Model_Observer - salesEventConvertQuoteAddressToOrder - - - - - - - model - Mage_GiftMessage_Model_Observer - salesEventConvertQuoteToOrder - - - - - - - model - Mage_GiftMessage_Model_Observer - checkoutEventCreateGiftMessage - - - - - - - model - Mage_GiftMessage_Model_Observer - checkoutEventCreateGiftMessage - - - - - - - model - Mage_GiftMessage_Model_Observer - salesEventOrderToQuote - - - - - - - standard - - Mage_GiftMessage - giftmessage - - - - - - - - Mage_GiftMessage.csv - - - - - - diff --git a/app/code/core/Mage/GiftMessage/view/adminhtml/popup.phtml b/app/code/core/Mage/GiftMessage/view/adminhtml/popup.phtml deleted file mode 100644 index 9ad21fb333aba..0000000000000 --- a/app/code/core/Mage/GiftMessage/view/adminhtml/popup.phtml +++ /dev/null @@ -1,56 +0,0 @@ - - -getChildHtml()) :?> - - - - - - diff --git a/app/code/core/Mage/GiftMessage/view/adminhtml/sales/order/create/giftoptions.phtml b/app/code/core/Mage/GiftMessage/view/adminhtml/sales/order/create/giftoptions.phtml deleted file mode 100644 index 1ce55b88c34b2..0000000000000 --- a/app/code/core/Mage/GiftMessage/view/adminhtml/sales/order/create/giftoptions.phtml +++ /dev/null @@ -1,53 +0,0 @@ - - -getItem() ?> - - getChildHtml('', false));?> - - - - - -
    - -
    - - - - - - - - - - - diff --git a/app/code/core/Mage/GiftMessage/view/adminhtml/sales/order/view/giftoptions.phtml b/app/code/core/Mage/GiftMessage/view/adminhtml/sales/order/view/giftoptions.phtml deleted file mode 100644 index 3f1a3fd375ea9..0000000000000 --- a/app/code/core/Mage/GiftMessage/view/adminhtml/sales/order/view/giftoptions.phtml +++ /dev/null @@ -1,53 +0,0 @@ - - -getChildHtml('', false)); ?> - -getItem() ?> - - - - -
    - -
    - - - - - - - - - - - - diff --git a/app/code/core/Mage/GiftMessage/view/frontend/inline.phtml b/app/code/core/Mage/GiftMessage/view/frontend/inline.phtml deleted file mode 100644 index 4c6e0eb909d09..0000000000000 --- a/app/code/core/Mage/GiftMessage/view/frontend/inline.phtml +++ /dev/null @@ -1,334 +0,0 @@ - -getDontDisplayContainer()): ?> - - -isMessagesAvailable() || $this->isItemsAvailable()): ?> -getType()): ?> - -
    -

    __('Do you have any gift items in your order?'); ?>

    -

    - getItemsHasMesssages() || $this->getEntityHasMessage()): ?> checked="checked" class="checkbox" /> - -

    -
    -
    -
    - isMessagesAvailable()): ?> -

    __('Gift Options for the Entire Order.'); ?>

    -

    - getEntityHasMessage()): ?> checked="checked" class="checkbox" /> - -

    - - - isItemsAvailable()): ?> -

    __('Gift Options for Individual Items'); ?>

    -

    - getItemsHasMesssages()): ?> checked="checked" class="checkbox" /> - -

    -
    -

    __('You can leave this box blank if you do not wish to add a gift message for the item.') ?>

    -
      - getItems() as $_index=>$_item): ?> - getProduct() ?> -
    1. -
      -

      - <?php echo $this->escapeHtml($_product->getName()) ?> -

      -

      __('Item %d of %d', $_index+1, $this->countItems()) ?>

      -
      -
      -
      -
      escapeHtml($_product->getName()) ?>
      - -
        -
      • -
        - -
        - -
        -
        -
        - -
        - -
        -
        -
      • -
      • - -
        - -
        -
      • -
      - -
      -
      -
    2. - -
    -
    - -
    -
    - - - - - - -
    -

    __('Do you have any gift items in your order?'); ?>

    -

    - getItemsHasMesssages() || $this->getEntityHasMessage()): ?> checked="checked" class="checkbox" /> - -

    -
    -
    -
    - isMessagesAvailable()): ?> -

    __('Gift Options for this address.'); ?>

    -

    - getEntityHasMessage()): ?> checked="checked" class="checkbox" /> - -

    -
    -

    __('You can leave this box blank if you do not wish to add a gift message for this address.') ?>

    - -
      -
    • -
      - -
      - -
      -
      -
      - -
      - -
      -
      -
    • -
    • - -
      - -
      -
    • -
    - -
    - - isItemsAvailable()): ?> -

    __('Gift Options for Individual Items'); ?>

    -

    - getItemsHasMesssages()): ?> checked="checked" class="checkbox" /> - -

    -
    -

    __('You can leave this box blank if you do not wish to add a gift message for the item.') ?>

    -
      - getItems() as $_index=>$_item): ?> - getProduct() ?> -
    1. -
      -

      getThumbnailUrl($_product) ?>" width="getThumbnailSize()?>" height="getThumbnailSize()?>" alt="escapeHtml($_product->getName()) ?>" title="escapeHtml($_product->getName()) ?>" />

      -

      __('Item %d of %d', $_index+1, $this->countItems()) ?>

      -
      -
      -
      - - -
      escapeHtml($_product->getName()) ?>
      -
        -
      • -
        - -
        - -
        -
        -
        - -
        - -
        -
        -
      • -
      • - -
        - -
        -
      • -
      - -
      -
      -
    2. - -
    -
    - -
    -
    - - - - diff --git a/app/code/core/Mage/GoogleAnalytics/etc/adminhtml/acl.xml b/app/code/core/Mage/GoogleAnalytics/etc/adminhtml/acl.xml deleted file mode 100644 index 3885164311a46..0000000000000 --- a/app/code/core/Mage/GoogleAnalytics/etc/adminhtml/acl.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/GoogleAnalytics/etc/config.xml b/app/code/core/Mage/GoogleAnalytics/etc/config.xml deleted file mode 100644 index 0be8ae6b88778..0000000000000 --- a/app/code/core/Mage/GoogleAnalytics/etc/config.xml +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - - Mage_GoogleAnalytics.csv - - - - - - - - - Mage_GoogleAnalytics_Model_Observer - setGoogleAnalyticsOnOrderSuccessPageView - - - - - - - Mage_GoogleAnalytics_Model_Observer - setGoogleAnalyticsOnOrderSuccessPageView - - - - - - - Mage_GoogleAnalytics_Model_Observer - injectAnalyticsInGoogleCheckoutLink - - - - - - - - layout.xml - - - - - - - - - - Mage_GoogleAnalytics.csv - - - - - - diff --git a/app/code/core/Mage/GoogleCheckout/etc/adminhtml/acl.xml b/app/code/core/Mage/GoogleCheckout/etc/adminhtml/acl.xml deleted file mode 100644 index d2a5cab8a7156..0000000000000 --- a/app/code/core/Mage/GoogleCheckout/etc/adminhtml/acl.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/GoogleCheckout/etc/config.xml b/app/code/core/Mage/GoogleCheckout/etc/config.xml deleted file mode 100644 index 5255a2e4b4eb1..0000000000000 --- a/app/code/core/Mage/GoogleCheckout/etc/config.xml +++ /dev/null @@ -1,165 +0,0 @@ - - - - - - 1.6.0.1 - true - core - - - - - - - - - - - - - - - - - - - - - Mage_GoogleCheckout - Mage_GoogleCheckout_Model_Resource_Setup - - - - - - - /googlecheckout/redirect/ - /googlecheckout/api/beacon/ - /googlecheckout/api/ - - - - - - Mage_GoogleCheckout.csv - - - - - - - standard - - Mage_GoogleCheckout - googlecheckout - - - - - - - layout.xml - - - - - - - - - - Mage_GoogleCheckout.csv - - - - - - - - - model - Mage_GoogleCheckout_Model_Observer - salesOrderShipmentTrackSaveAfter - - - - - - - model - Mage_GoogleCheckout_Model_Observer - salesOrderShipmentSaveAfter - - - - - - - - - 1 - Mage_GoogleCheckout_Model_Shipping - - - - - 1 - Mage_GoogleCheckout_Model_Payment - Google Checkout - - - - - - - 0 - 0 - 1 - Google Checkout - - - COMMERCIAL - 0 - 10 - 10 - 10 - - - 0 - 0 - 0 - - - 1 - OPTIMISTIC - email - - - - diff --git a/app/code/core/Mage/GoogleOptimizer/etc/config.xml b/app/code/core/Mage/GoogleOptimizer/etc/config.xml deleted file mode 100644 index d29c662f33ff0..0000000000000 --- a/app/code/core/Mage/GoogleOptimizer/etc/config.xml +++ /dev/null @@ -1,251 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - - Mage_GoogleOptimizer - - - - - - - - Mage_GoogleOptimizer_Model_Observer - appendToPageGoogleOptimizerScripts - - - - - - - - - - - - - - - - - Mage_GoogleOptimizer_Adminhtml - - - - - - - - - - - Mage_GoogleOptimizer.csv - - - - - - - - layout.xml - - - - - - - - Mage_GoogleOptimizer_Model_Observer - appendToProductGoogleOptimizerScripts - - - - - - - Mage_GoogleOptimizer_Model_Observer - appendToCategoryGoogleOptimizerScripts - - - - - - - Mage_GoogleOptimizer_Model_Observer - assignHandlers - - - - - - - - - - - Mage_GoogleOptimizer.csv - - - - - - - - - Mage_GoogleOptimizer_Model_Observer - appendToProductGoogleOptimizerScripts - - - - - - - Mage_GoogleOptimizer_Model_Observer - prepareProductGoogleOptimizerScripts - - - - - - - Mage_GoogleOptimizer_Model_Observer - saveProductGoogleOptimizerScripts - - - - - - - Mage_GoogleOptimizer_Model_Observer - deleteProductGoogleOptimizerScripts - - - - - - - Mage_GoogleOptimizer_Model_Observer - appendToCategoryGoogleOptimizerScripts - - - - - - - Mage_GoogleOptimizer_Model_Observer - prepareCategoryGoogleOptimizerScripts - - - - - - - Mage_GoogleOptimizer_Model_Observer - saveCategoryGoogleOptimizerScripts - - - - - - - Mage_GoogleOptimizer_Model_Observer - deleteCategoryGoogleOptimizerScripts - - - - - - - Mage_GoogleOptimizer_Model_Observer - addCategoryGoogleOptimizerTab - - - - - - - Mage_GoogleOptimizer_Model_Observer - appendToPageGoogleOptimizerScripts - - - - - - - Mage_GoogleOptimizer_Model_Observer - preparePageGoogleOptimizerScripts - - - - - - - Mage_GoogleOptimizer_Model_Observer - savePageGoogleOptimizerScripts - - - - - - - Mage_GoogleOptimizer_Model_Observer - deletePageGoogleOptimizerScripts - - - - - - - - layout.xml - - - - - - - - 0 - - - - diff --git a/app/code/core/Mage/GoogleOptimizer/view/adminhtml/js.phtml b/app/code/core/Mage/GoogleOptimizer/view/adminhtml/js.phtml deleted file mode 100644 index d9a97226cd629..0000000000000 --- a/app/code/core/Mage/GoogleOptimizer/view/adminhtml/js.phtml +++ /dev/null @@ -1,177 +0,0 @@ - - diff --git a/app/code/core/Mage/GoogleOptimizer/view/adminhtml/layout.xml b/app/code/core/Mage/GoogleOptimizer/view/adminhtml/layout.xml deleted file mode 100644 index 6d99dca6c2e15..0000000000000 --- a/app/code/core/Mage/GoogleOptimizer/view/adminhtml/layout.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - googleoptimizertab_googleoptimizer - - - - - - - - - - googleoptimizertab_googleoptimizer - - - - - - - - - - - - - - - - - - - cms_page_edit_tabs - addTab - - googleoptimizer_section - Mage_GoogleOptimizer_Block_Adminhtml_Cms_Page_Edit_Tab_Googleoptimizer - - - - js - googleoptimizer_js - Mage_GoogleOptimizer_Block_Js - - - - - - - - - \ No newline at end of file diff --git a/app/code/core/Mage/GoogleShopping/Block/Adminhtml/Types/Edit/Attributes.php b/app/code/core/Mage/GoogleShopping/Block/Adminhtml/Types/Edit/Attributes.php deleted file mode 100644 index 88033575fa80a..0000000000000 --- a/app/code/core/Mage/GoogleShopping/Block/Adminhtml/Types/Edit/Attributes.php +++ /dev/null @@ -1,198 +0,0 @@ - - */ -class Mage_GoogleShopping_Block_Adminhtml_Types_Edit_Attributes - extends Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element -{ - - protected $_template = 'types/edit/attributes.phtml'; - - /** - * Preparing global layout - * - * @return Mage_Core_Block_Abstract - */ - protected function _prepareLayout() - { - $this->addChild('add_button', 'Mage_Adminhtml_Block_Widget_Button', array( - 'label' => Mage::helper('Mage_GoogleShopping_Helper_Data')->__('Add New Attribute'), - 'class' => 'add', - 'id' => 'add_new_attribute', - 'on_click' => 'gContentAttribute.add()' - )); - $this->addChild('delete_button', 'Mage_Adminhtml_Block_Widget_Button', array( - 'label' => Mage::helper('Mage_GoogleShopping_Helper_Data')->__('Remove'), - 'class' => 'delete delete-product-option', - 'on_click' => 'gContentAttribute.remove(event)' - )); - - return parent::_prepareLayout(); - } - - /** - * Get attributes select field id - * - * @return string - */ - public function getFieldId() - { - return 'gcontent_attribute'; - } - - /** - * Get attributes select field name - * - * @return string - */ - public function getFieldName () - { - return 'attributes'; - } - - /** - * Build HTML code for select element which contains all available Google's attributes - * - * @return string - */ - public function getGcontentAttributesSelectHtml() - { - $options[] = array('label' => $this->__('Custom attribute, no mapping')); - - $attributesTree = Mage::getSingleton('Mage_GoogleShopping_Model_Config') - ->getAttributesByCountry($this->getTargetCountry()); - - foreach ($attributesTree as $destination => $attributes) { - $options[] = array( - 'label' => $destination, - 'is_group' => true, - ); - foreach ($attributes as $attribute => $params) { - $options[$attribute] = array('label' => $params['name']); - if ((int)$params['required'] == 1) { - $options[$attribute]['style'] = 'color: #940000;'; - } - } - $options[] = array( - 'is_group' => true, - 'is_close' => true - ); - } - - $select = $this->getLayout()->createBlock('Mage_GoogleShopping_Block_Adminhtml_Types_Edit_Select') - ->setId($this->getFieldId().'_{{index}}_gattribute') - ->setName($this->getFieldName().'[{{index}}][gcontent_attribute]') - ->setOptions($options); - - return $this->_toOneLineString($select->toHtml()); - } - - /** - * Build HTML select element of attribute set attributes - * - * @param boolean $escapeJsQuotes - * @return string - */ - public function getAttributesSelectHtml($escapeJsQuotes = false) - { - $select = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Html_Select') - ->setId($this->getFieldId().'_{{index}}_attribute') - ->setName($this->getFieldName().'[{{index}}][attribute_id]') - ->setOptions($this->_getAttributes($this->getAttributeSetId(), $escapeJsQuotes)); - return $select->getHtml(); - } - - /** - * Get HTML code for button "Add New Attribute" - * - * @return string - */ - public function getAddButtonHtml() - { - return $this->getChildHtml('add_button'); - } - - /** - * Get HTML code for button "Remove" - * - * @return string - */ - public function getDeleteButtonHtml() - { - return $this->getChildHtml('delete_button'); - } - - /** - * Get attributes of an attribute set - * Skip attributes not needed for Google Content - * - * @param int $setId - * @param boolean $escapeJsQuotes - * @return array - */ - public function _getAttributes($setId, $escapeJsQuotes = false) - { - $attributes = Mage::getModel('Mage_GoogleShopping_Model_Attribute')->getAllowedAttributes($setId); - $result = array(); - - foreach ($attributes as $attribute) { - /* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */ - $result[$attribute->getAttributeId()] = $escapeJsQuotes - ? $this->jsQuoteEscape($attribute->getFrontendLabel()) - : $attribute->getFrontendLabel(); - } - return $result; - } - - /** - * Encode the mixed $data into the JSON format - * - * @param mixed $data - * @return string - */ - protected function _toJson($data) - { - return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($data); - } - - /** - * Format string to one line, cut symbols \n and \r - * - * @param string $string - * @return string - */ - protected function _toOneLineString($string) - { - return str_replace(array("\r\n", "\n", "\r"), "", $string); - } - -} diff --git a/app/code/core/Mage/GoogleShopping/etc/adminhtml/acl.xml b/app/code/core/Mage/GoogleShopping/etc/adminhtml/acl.xml deleted file mode 100644 index bd42549fa65c3..0000000000000 --- a/app/code/core/Mage/GoogleShopping/etc/adminhtml/acl.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/GoogleShopping/etc/adminhtml/menu.xml b/app/code/core/Mage/GoogleShopping/etc/adminhtml/menu.xml deleted file mode 100644 index 04b795a959461..0000000000000 --- a/app/code/core/Mage/GoogleShopping/etc/adminhtml/menu.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - diff --git a/app/code/core/Mage/GoogleShopping/etc/config.xml b/app/code/core/Mage/GoogleShopping/etc/config.xml deleted file mode 100644 index f1b9db926ed8b..0000000000000 --- a/app/code/core/Mage/GoogleShopping/etc/config.xml +++ /dev/null @@ -1,383 +0,0 @@ - - - - - - 1.6.0.0.1 - true - core - - - - - - - - - - Mage_GoogleShopping - - - - - - - - - - Mage_GoogleShopping_Adminhtml - - - - - - - - - - - Mage_GoogleShopping.csv - - - - - - - - - Mage_GoogleShopping_Model_Observer - saveProductItem - - - - - - - Mage_GoogleShopping_Model_Observer - deleteProductItem - - - - - - - Mage_GoogleShopping_Model_Observer - checkSynchronizationOperations - - - - - - - - layout.xml - - - - - - - - US - HOSTED_OR_GOOGLE - - - - - Australia - en - AUD - Australian Dollar - -
    - Brazil - pt - pt_BR - BRL - Brazilian Real -
    - - China - zh_CN - CNY - Chinese Yuan Renminbi - - - France - fr - EUR - Euro - - - Germany - de - de_DE - EUR - Euro - - - Italy - it - EUR - Euro - - - Japan - ja - JPY - Japanese Yen - - - Netherlands - nl - EUR - Euro - - - Spain - es - EUR - Euro - - - Switzerland - de - de_CH - CHF - Swiss Franc - - - United Kingdom - en - en_GB - GBP - British Pound Sterling - - - United States - en - en_US - USD - US Dollar - -
    - - - ProductSearch - ProductAds - CommerceSearch - - - - - - - <name>Title</name> - <required>1</required> - - - Description - 1 - - - Expiration date - 0 - - - Adult - 0 - - - - - Condition - 1 - - - Price - 1 - - - Sale Price - 0 - US - - - Sale Price Effective From Date - 0 - US - - - Sale Price Effective To Date - 0 - US - - - Age Group - 1 - - - Brand - 1 - - - Color - 1 - - - Gender - 1 - - - Manufacturer\'s Part Number (MPN) - 1 - - - Online Only - 0 - - - GTIN - 1 - - - Product Type (Category) - 0 - - - Product Review Average - 0 - - - Product Review Count - 0 - - - Shipping Weight - 0 - - - Size - 1 - - - Material - 1 - - - Pattern/Graphic - 1 - - - - - Grouping - 0 - - - Labels - 0 - - - Redirect - 0 - - - Query Param - 0 - - - - - - - - - - - - - - - - - <name/> - - - - - - - - - - <link/> - <content/> - <price/> - <image_link/> - <condition/> - <target_country/> - <content_language/> - <destinations/> - <availability/> - <google_product_category/> - <product_type/> - </base_attributes> - </googleshopping> - </google> - </default> -</config> diff --git a/app/code/core/Mage/GoogleShopping/view/adminhtml/types/edit/attributes.phtml b/app/code/core/Mage/GoogleShopping/view/adminhtml/types/edit/attributes.phtml deleted file mode 100644 index a9db4733eaa53..0000000000000 --- a/app/code/core/Mage/GoogleShopping/view/adminhtml/types/edit/attributes.phtml +++ /dev/null @@ -1,129 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category design - * @package default_default - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ -?> - -<?php if ($this->getAttributeSetSelected()): ?> -<script type="text/javascript"> -//<![CDATA[ -Gcontent = {}; -Gcontent.Attribute = Class.create(); -Gcontent.Attribute.prototype = { - idLabel : '<?php echo $this->getFieldId() ?>', - top : '', - templateSyntax : /(^|.|\r|\n)({{(\w+)}})/, - templateText : '', - itemsCount : 0, - initialize : function(template) { - this.templateText = template; - this.top = $('gcontent_attribute_top'); - }, - - add : function(data) { - if(!data){ - data = {}; - } - this.top = $('gcontent_attribute_top'); - - data.index = this.itemsCount++; - this.template = new Template(this.templateText, this.templateSyntax); - Element.insert(this.top, {'after':this.template.evaluate(data)}); - this.top = $(this.idLabel + '_' + data.index); - - //set selected type - if (data.attribute_id) { - $A($(this.idLabel + '_'+data.index+'_attribute').options).each(function(option){ - if (option.value==data.attribute_id) option.selected = true; - }); - } - - //set selected is_require - if (data.gcontent_attribute) { - $A($(this.idLabel + '_'+data.index+'_gattribute').options).each(function(option){ - if (option.value==data.gcontent_attribute) option.selected = true; - }); - } - return data.index; - }, - - remove : function(event) { - var element = $(Event.findElement(event, 'div')); - if(element){ - Element.select(element, '.delete').each(function(elem){elem.value='1'}); - Element.select(element, ['input', 'select']).each(function(elem){elem.hide(); elem.className = '';}); - Element.hide(element); - } - } -} - -var attributesSelectTemplate = '<div id="<?php echo $this->getFieldId() ?>_{{index}}" class="option-box"> ' + - '<table class="option-header" cellpadding="0" cellspacing="0">' + - '<thead>' + - '<tr>' + - '<th class="opt-type"><?php echo Mage::helper('Mage_GoogleShopping_Helper_Data')->__('Attribute') ?></th>' + - '<th class="opt-req"><?php echo Mage::helper('Mage_GoogleShopping_Helper_Data')->__('Google Content Attribute') ?></th>' + - '<th> </th>' + - '</tr>' + - '</thead>' + - '<tbody>' + - '<tr>' + - '<td><?php echo $this->getAttributesSelectHtml(true) ?>' + - '<input type="hidden" name="<?php echo $this->getFieldName() ?>[{{index}}][delete]" value="" class="delete">' + - '</td>' + - '<td><?php echo $this->getGcontentAttributesSelectHtml() ?></td>' + - '<td> ' + <?php echo Mage::helper('Mage_Core_Helper_Data')->jsonEncode($this->getDeleteButtonHtml()) ?> + '</td>' + - '</tr>' + - '</tbody>' + - '</table>' + -'</div>'; -var optionIndex = 0; -gContentAttribute = new Gcontent.Attribute(attributesSelectTemplate); -//]]> -</script> - -<div class="entry-edit custom-options bundle" id="gcontent_attributes_container"> - <div class="entry-edit-head"> - <h4><?php echo $this->__('Attributes') ?></h4> - <div class="right"><?php echo $this->getAddButtonHtml() ?></div> - </div> - - <div id="gcontent_attribute" class="box"> - <div id="gcontent_attribute_top"></div> - </div> -</div> - -<?php if ($this->getAttributesData()): ?> -<script type="text/javascript"> -//<![CDATA[ - <?php foreach ($this->getAttributesData() as $data): ?> - gContentAttribute.add(<?php echo $this->_toJson($data) ?>); - <?php endforeach; ?> -//]]> -</script> -<?php endif; ?> - -<?php else: ?> - <?php echo Mage::helper('Mage_GoogleShopping_Helper_Data')->__("Please, select Attribute Set to load attributes") ?> -<?php endif; ?> diff --git a/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Filter.php b/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Filter.php deleted file mode 100644 index 191a0464db810..0000000000000 --- a/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Filter.php +++ /dev/null @@ -1,348 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_ImportExport - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/** - * Export filter block - * - * @category Mage - * @package Mage_ImportExport - * @author Magento Core Team <core@magentocommerce.com> - */ -class Mage_ImportExport_Block_Adminhtml_Export_Filter extends Mage_Adminhtml_Block_Widget_Grid -{ - /** - * Helper object. - * - * @var Mage_Core_Helper_Abstract - */ - protected $_helper; - - /** - * Set grid parameters. - */ - protected function _construct() - { - parent::_construct(); - - $this->_helper = Mage::helper('Mage_ImportExport_Helper_Data'); - - $this->setRowClickCallback(null); - $this->setId('export_filter_grid'); - $this->setDefaultSort('attribute_code'); - $this->setDefaultDir('ASC'); - $this->setPagerVisibility(false); - $this->setDefaultLimit(null); - $this->setUseAjax(true); - } - - /** - * Date 'from-to' filter HTML with values - * - * @param Mage_Eav_Model_Entity_Attribute $attribute - * @param mixed $value - * @return string - */ - protected function _getDateFromToHtmlWithValue(Mage_Eav_Model_Entity_Attribute $attribute, $value) - { - $arguments = array( - 'name' => $this->getFilterElementName($attribute->getAttributeCode()) . '[]', - 'id' => $this->getFilterElementId($attribute->getAttributeCode()), - 'class' => 'input-text input-text-range-date', - 'date_format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT), - 'image' => $this->getViewFileUrl('images/grid-cal.gif') - ); - /** @var $selectBlock Mage_Core_Block_Html_Date */ - $dateBlock = $this->_layout->getBlockFactory()->createBlock('Mage_Core_Block_Html_Date', $arguments); - $fromValue = null; - $toValue = null; - if (is_array($value) && count($value) == 2) { - $fromValue = $this->_helper->escapeHtml(reset($value)); - $toValue = $this->_helper->escapeHtml(next($value)); - } - - - return '<strong>' . Mage::helper('Mage_ImportExport_Helper_Data')->__('From') . ':</strong> ' - . $dateBlock->setValue($fromValue)->getHtml() - . ' <strong>' . Mage::helper('Mage_ImportExport_Helper_Data')->__('To') . ':</strong> ' - . $dateBlock->setId($dateBlock->getId() . '_to')->setValue($toValue)->getHtml(); - } - - /** - * Input text filter HTML with value - * - * @param Mage_Eav_Model_Entity_Attribute $attribute - * @param mixed $value - * @return string - */ - protected function _getInputHtmlWithValue(Mage_Eav_Model_Entity_Attribute $attribute, $value) - { - $html = '<input type="text" name="' . $this->getFilterElementName($attribute->getAttributeCode()) - . '" class="input-text input-text-export-filter"'; - if ($value) { - $html .= ' value="' . $this->_helper->escapeHtml($value) . '"'; - } - - return $html . ' />'; - } - - /** - * Multiselect field filter HTML with selected values - * - * @param Mage_Eav_Model_Entity_Attribute $attribute - * @param mixed $value - * @return string - */ - protected function _getMultiSelectHtmlWithValue(Mage_Eav_Model_Entity_Attribute $attribute, $value) - { - if ($attribute->getFilterOptions()) { - $options = $attribute->getFilterOptions(); - } else { - $options = $attribute->getSource()->getAllOptions(false); - - foreach ($options as $key => $optionParams) { - if ('' === $optionParams['value']) { - unset($options[$key]); - break; - } - } - } - if (($size = count($options))) { - $arguments = array( - 'name' => $this->getFilterElementName($attribute->getAttributeCode()). '[]', - 'id' => $this->getFilterElementId($attribute->getAttributeCode()), - 'class' => 'multiselect multiselect-export-filter', - 'extra_params' => 'multiple="multiple" size="' . ($size > 5 ? 5 : ($size < 2 ? 2 : $size)) - ); - /** @var $selectBlock Mage_Core_Block_Html_Select */ - $selectBlock = $this->_layout->getBlockFactory()->createBlock('Mage_Core_Block_Html_Select', $arguments); - return $selectBlock->setOptions($options) - ->setValue($value) - ->getHtml(); - } else { - return Mage::helper('Mage_ImportExport_Helper_Data') - ->__('Attribute does not has options, so filtering is impossible'); - } - } - - /** - * Number 'from-to' field filter HTML with selected value. - * - * @param Mage_Eav_Model_Entity_Attribute $attribute - * @param mixed $value - * @return string - */ - protected function _getNumberFromToHtmlWithValue(Mage_Eav_Model_Entity_Attribute $attribute, $value) - { - $fromValue = null; - $toValue = null; - $name = $this->getFilterElementName($attribute->getAttributeCode()); - if (is_array($value) && count($value) == 2) { - $fromValue = $this->_helper->escapeHtml(reset($value)); - $toValue = $this->_helper->escapeHtml(next($value)); - } - - return '<strong>' . Mage::helper('Mage_ImportExport_Helper_Data')->__('From') . ':</strong> ' - . '<input type="text" name="' . $name . '[]" class="input-text input-text-range"' - . ' value="' . $fromValue . '"/> ' - . '<strong>' . Mage::helper('Mage_ImportExport_Helper_Data')->__('To') - . ':</strong> <input type="text" name="' . $name - . '[]" class="input-text input-text-range" value="' . $toValue . '" />'; - } - - /** - * Select field filter HTML with selected value. - * - * @param Mage_Eav_Model_Entity_Attribute $attribute - * @param mixed $value - * @return string - */ - protected function _getSelectHtmlWithValue(Mage_Eav_Model_Entity_Attribute $attribute, $value) - { - if ($attribute->getFilterOptions()) { - $options = array(); - - foreach ($attribute->getFilterOptions() as $value => $label) { - $options[] = array('value' => $value, 'label' => $label); - } - } else { - $options = $attribute->getSource()->getAllOptions(false); - } - if (($size = count($options))) { - // add empty vaue option - $firstOption = reset($options); - - if ('' === $firstOption['value']) { - $options[key($options)]['label'] = ''; - } else { - array_unshift($options, array('value' => '', 'label' => '')); - } - $arguments = array( - 'name' => $this->getFilterElementName($attribute->getAttributeCode()), - 'id' => $this->getFilterElementId($attribute->getAttributeCode()), - 'class' => 'select select-export-filter' - ); - /** @var $selectBlock Mage_Core_Block_Html_Select */ - $selectBlock = $this->_layout->getBlockFactory()->createBlock('Mage_Core_Block_Html_Select', $arguments); - return $selectBlock->setOptions($options) - ->setValue($value) - ->getHtml(); - } else { - return Mage::helper('Mage_ImportExport_Helper_Data') - ->__('Attribute does not has options, so filtering is impossible'); - } - } - - /** - * Add columns to grid - * - * @return Mage_ImportExport_Block_Adminhtml_Export_Filter - */ - protected function _prepareColumns() - { - parent::_prepareColumns(); - - $this->addColumn('skip', array( - 'header' => Mage::helper('Mage_ImportExport_Helper_Data')->__('Skip'), - 'type' => 'checkbox', - 'name' => 'skip', - 'field_name' => Mage_ImportExport_Model_Export::FILTER_ELEMENT_SKIP . '[]', - 'filter' => false, - 'sortable' => false, - 'align' => 'center', - 'index' => 'attribute_id' - )); - $this->addColumn('frontend_label', array( - 'header' => Mage::helper('Mage_ImportExport_Helper_Data')->__('Attribute Label'), - 'index' => 'frontend_label', - 'sortable' => false, - )); - $this->addColumn('attribute_code', array( - 'header' => Mage::helper('Mage_ImportExport_Helper_Data')->__('Attribute Code'), - 'index' => 'attribute_code' - )); - $this->addColumn('filter', array( - 'header' => Mage::helper('Mage_ImportExport_Helper_Data')->__('Filter'), - 'sortable' => false, - 'filter' => false, - 'frame_callback' => array($this, 'decorateFilter') - )); - - if ($this->hasOperation()) { - $operation = $this->getOperation(); - $skipAttr = $operation->getSkipAttr(); - if ($skipAttr) { - $this->getColumn('skip') - ->setData('values', $skipAttr); - } - $filter = $operation->getExportFilter(); - if ($filter) { - $this->getColumn('filter') - ->setData('values', $filter); - } - } - - return $this; - } - - /** - * Create filter fields for 'Filter' column. - * - * @param mixed $value - * @param Mage_Eav_Model_Entity_Attribute $row - * @param Varien_Object $column - * @param boolean $isExport - * @return string - */ - public function decorateFilter($value, Mage_Eav_Model_Entity_Attribute $row, Varien_Object $column, $isExport) - { - $value = null; - $values = $column->getValues(); - if (is_array($values) && isset($values[$row->getAttributeCode()])) { - $value = $values[$row->getAttributeCode()]; - } - switch (Mage_ImportExport_Model_Export::getAttributeFilterType($row)) { - case Mage_ImportExport_Model_Export::FILTER_TYPE_SELECT: - $cell = $this->_getSelectHtmlWithValue($row, $value); - break; - case Mage_ImportExport_Model_Export::FILTER_TYPE_INPUT: - $cell = $this->_getInputHtmlWithValue($row, $value); - break; - case Mage_ImportExport_Model_Export::FILTER_TYPE_DATE: - $cell = $this->_getDateFromToHtmlWithValue($row, $value); - break; - case Mage_ImportExport_Model_Export::FILTER_TYPE_NUMBER: - $cell = $this->_getNumberFromToHtmlWithValue($row, $value); - break; - default: - $cell = Mage::helper('Mage_ImportExport_Helper_Data')->__('Unknown attribute filter type'); - } - return $cell; - } - - /** - * Element filter ID getter. - * - * @param string $attributeCode - * @return string - */ - public function getFilterElementId($attributeCode) - { - return Mage_ImportExport_Model_Export::FILTER_ELEMENT_GROUP . "_{$attributeCode}"; - } - - /** - * Element filter full name getter. - * - * @param string $attributeCode - * @return string - */ - public function getFilterElementName($attributeCode) - { - return Mage_ImportExport_Model_Export::FILTER_ELEMENT_GROUP . "[{$attributeCode}]"; - } - - /** - * Get row edit URL. - * - * @return string|boolean - */ - public function getRowUrl($row) - { - return false; - } - - /** - * Prepare collection by setting page number, sorting etc.. - * - * @param Varien_Data_Collection $collection - * @return Mage_Eav_Model_Resource_Entity_Attribute_Collection - */ - public function prepareCollection(Varien_Data_Collection $collection) - { - $this->setCollection($collection); - return $this->getCollection(); - } -} diff --git a/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Edit/Before.php b/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Edit/Before.php deleted file mode 100644 index c7f565c418988..0000000000000 --- a/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Edit/Before.php +++ /dev/null @@ -1,124 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_ImportExport - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/** - * Block before edit form - * - * @category Mage - * @package Mage_ImportExport - * @author Magento Core Team <core@magentocommerce.com> - */ -class Mage_ImportExport_Block_Adminhtml_Import_Edit_Before extends Mage_Backend_Block_Template -{ - /** - * Core helper - * - * @var Mage_Core_Helper_Data - */ - protected $_coreHelper; - - /** - * Basic import model - * - * @var Mage_ImportExport_Model_Import - */ - protected $_importModel; - - /** - * Constructor - * - * @param Mage_Core_Controller_Request_Http $request - * @param Mage_Core_Model_Layout $layout - * @param Mage_Core_Model_Event_Manager $eventManager - * @param Mage_Backend_Model_Url $urlBuilder - * @param Mage_Core_Model_Translate $translator - * @param Mage_Core_Model_Cache $cache - * @param Mage_Core_Model_Design_Package $designPackage - * @param Mage_Core_Model_Session $session - * @param Mage_Core_Model_Store_Config $storeConfig - * @param Mage_Core_Controller_Varien_Front $frontController - * @param Mage_Core_Model_Factory_Helper $helperFactory - * @param Mage_Core_Model_Dir $dirs - * @param Mage_Core_Model_Logger $logger - * @param Magento_Filesystem $filesystem - * @param Mage_Core_Helper_Data $coreHelper - * @param Mage_ImportExport_Model_Import $importModel - * @param array $data - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) - */ - public function __construct( Mage_Core_Controller_Request_Http $request, - Mage_Core_Model_Layout $layout, - Mage_Core_Model_Event_Manager $eventManager, - Mage_Backend_Model_Url $urlBuilder, - Mage_Core_Model_Translate $translator, - Mage_Core_Model_Cache $cache, - Mage_Core_Model_Design_Package $designPackage, - Mage_Core_Model_Session $session, - Mage_Core_Model_Store_Config $storeConfig, - Mage_Core_Controller_Varien_Front $frontController, - Mage_Core_Model_Factory_Helper $helperFactory, - Mage_Core_Model_Dir $dirs, - Mage_Core_Model_Logger $logger, - Magento_Filesystem $filesystem, - Mage_Core_Helper_Data $coreHelper, - Mage_ImportExport_Model_Import $importModel, - array $data = array() - ) { - parent::__construct($request, $layout, $eventManager, $urlBuilder, $translator, $cache, $designPackage, - $session, $storeConfig, $frontController, $helperFactory, $dirs, $logger, $filesystem, $data - ); - $this->_coreHelper = $coreHelper; - $this->_importModel = $importModel; - } - - /** - * Returns json-encoded entity behaviors array - * - * @return string - */ - public function getEntityBehaviors() - { - $importModel = $this->_importModel; - $behaviors = $importModel::getEntityBehaviors(); - foreach ($behaviors as $entityCode => $behavior) { - $behaviors[$entityCode] = $behavior['code']; - } - return $this->_coreHelper->jsonEncode($behaviors); - } - - /** - * Return json-encoded list of existing behaviors - * - * @return string - */ - public function getUniqueBehaviors() - { - $importModel = $this->_importModel; - $uniqueBehaviors = $importModel::getUniqueEntityBehaviors(); - return $this->_coreHelper->jsonEncode(array_keys($uniqueBehaviors)); - } -} diff --git a/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Edit/Form.php b/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Edit/Form.php deleted file mode 100644 index 224295ea36987..0000000000000 --- a/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Edit/Form.php +++ /dev/null @@ -1,105 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_ImportExport - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/** - * Import edit form block - * - * @category Mage - * @package Mage_ImportExport - * @author Magento Core Team <core@magentocommerce.com> - */ -class Mage_ImportExport_Block_Adminhtml_Import_Edit_Form extends Mage_Adminhtml_Block_Widget_Form -{ - /** - * Add fieldsets - * - * @return Mage_ImportExport_Block_Adminhtml_Import_Edit_Form - */ - protected function _prepareForm() - { - $helper = Mage::helper('Mage_ImportExport_Helper_Data'); - $form = new Varien_Data_Form(array( - 'id' => 'edit_form', - 'action' => $this->getUrl('*/*/validate'), - 'method' => 'post', - 'enctype' => 'multipart/form-data' - )); - - // base fieldset - /** @var $importEntity Mage_ImportExport_Model_Source_Import_Entity */ - $importEntity = Mage::getModel('Mage_ImportExport_Model_Source_Import_Entity'); - $fieldsets['base'] = $form->addFieldset('base_fieldset', array('legend' => $helper->__('Import Settings'))); - $fieldsets['base']->addField('entity', 'select', array( - 'name' => 'entity', - 'title' => $helper->__('Entity Type'), - 'label' => $helper->__('Entity Type'), - 'required' => true, - 'onchange' => 'varienImport.handleEntityTypeSelector();', - 'values' => $importEntity->toOptionArray() - )); - - // add behaviour fieldsets - $uniqueBehaviors = Mage_ImportExport_Model_Import::getUniqueEntityBehaviors(); - foreach ($uniqueBehaviors as $behaviorCode => $behaviorClass) { - $fieldsets[$behaviorCode] = $form->addFieldset( - $behaviorCode .'_fieldset', - array( - 'legend' => $helper->__('Import Behavior'), - 'style' => 'display:none', - ) - ); - /** @var $behaviorSource Mage_ImportExport_Model_Source_Import_BehaviorAbstract */ - $behaviorSource = Mage::getModel($behaviorClass); - $fieldsets[$behaviorCode]->addField($behaviorCode, 'select', array( - 'name' => 'behavior', - 'title' => $helper->__('Import Behavior'), - 'label' => $helper->__('Import Behavior'), - 'required' => true, - 'disabled' => true, - 'values' => $behaviorSource->toOptionArray() - )); - } - - // fieldset for file uploading - $fieldsets['upload'] = $form->addFieldset('upload_file_fieldset', - array( - 'legend' => $helper->__('File to Import'), - 'style' => 'display:none' - ) - ); - $fieldsets['upload']->addField(Mage_ImportExport_Model_Import::FIELD_NAME_SOURCE_FILE, 'file', array( - 'name' => Mage_ImportExport_Model_Import::FIELD_NAME_SOURCE_FILE, - 'label' => $helper->__('Select File to Import'), - 'title' => $helper->__('Select File to Import'), - 'required' => true - )); - - $form->setUseContainer(true); - $this->setForm($form); - - return parent::_prepareForm(); - } -} diff --git a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php deleted file mode 100644 index 405d5450a9cfa..0000000000000 --- a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php +++ /dev/null @@ -1,203 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_ImportExport - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/** - * Import controller - * - * @category Mage - * @package Mage_ImportExport - * @author Magento Core Team <core@magentocommerce.com> - */ -class Mage_ImportExport_Adminhtml_ImportController extends Mage_Adminhtml_Controller_Action -{ - /** - * Custom constructor. - * - * @return void - */ - protected function _construct() - { - // Define module dependent translate - $this->setUsedModuleName('Mage_ImportExport'); - } - - /** - * Initialize layout. - * - * @return Mage_ImportExport_Adminhtml_ImportController - */ - protected function _initAction() - { - $this->_title($this->__('Import/Export')) - ->loadLayout() - ->_setActiveMenu('Mage_ImportExport::system_convert_import'); - - return $this; - } - - /** - * Check access (in the ACL) for current user. - * - * @return bool - */ - protected function _isAllowed() - { - return Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_ImportExport::import'); - } - - /** - * Index action - */ - public function indexAction() - { - $this->_getSession()->addNotice(Mage::helper('Mage_ImportExport_Helper_Data')->getMaxUploadSizeMessage()); - $this->_initAction()->_title($this->__('Import'))->_addBreadcrumb($this->__('Import'), $this->__('Import')); - $this->renderLayout(); - } - - /** - * Start import process action - * - * @return null - */ - public function startAction() - { - $data = $this->getRequest()->getPost(); - if ($data) { - $this->loadLayout(false); - - /** @var $resultBlock Mage_ImportExport_Block_Adminhtml_Import_Frame_Result */ - $resultBlock = $this->getLayout()->getBlock('import.frame.result'); - /** @var $importModel Mage_ImportExport_Model_Import */ - $importModel = Mage::getModel('Mage_ImportExport_Model_Import'); - - try { - $importModel->importSource(); - $importModel->invalidateIndex(); - $resultBlock->addAction('show', 'import_validation_container') - ->addAction('innerHTML', 'import_validation_container_header', $this->__('Status')); - } catch (Exception $e) { - $resultBlock->addError($e->getMessage()); - $this->renderLayout(); - return; - } - $resultBlock->addAction('hide', array('edit_form', 'upload_button', 'messages')) - ->addSuccess($this->__('Import successfully done.')); - $this->renderLayout(); - } else { - $this->_redirect('*/*/index'); - } - } - - /** - * Validate uploaded files action - */ - public function validateAction() - { - $data = $this->getRequest()->getPost(); - if ($data) { - $this->loadLayout(false); - /** @var $resultBlock Mage_ImportExport_Block_Adminhtml_Import_Frame_Result */ - $resultBlock = $this->getLayout()->getBlock('import.frame.result'); - // common actions - $resultBlock->addAction('show', 'import_validation_container') - ->addAction('clear', array( - Mage_ImportExport_Model_Import::FIELD_NAME_SOURCE_FILE, - Mage_ImportExport_Model_Import::FIELD_NAME_IMG_ARCHIVE_FILE) - ); - - try { - /** @var $import Mage_ImportExport_Model_Import */ - $import = Mage::getModel('Mage_ImportExport_Model_Import')->setData($data); - $source = Mage_ImportExport_Model_Import_Adapter::findAdapterFor($import->uploadSource()); - $validationResult = $import->validateSource($source); - - if (!$import->getProcessedRowsCount()) { - $resultBlock->addError($this->__('File does not contain data. Please upload another one')); - } else { - if (!$validationResult) { - if ($import->getProcessedRowsCount() == $import->getInvalidRowsCount()) { - $resultBlock->addNotice( - $this->__('File is totally invalid. Please fix errors and re-upload file') - ); - } elseif ($import->getErrorsCount() >= $import->getErrorsLimit()) { - $resultBlock->addNotice( - $this->__('Errors limit (%d) reached. Please fix errors and re-upload file', - $import->getErrorsLimit() - ) - ); - } else { - if ($import->isImportAllowed()) { - $resultBlock->addNotice( - $this->__('Please fix errors and re-upload file or simply press "Import" button to skip rows with errors'), - true - ); - } else { - $resultBlock->addNotice( - $this->__('File is partially valid, but import is not possible'), false - ); - } - } - // errors info - foreach ($import->getErrors() as $errorCode => $rows) { - $error = $errorCode . ' ' . $this->__('in rows:') . ' ' . implode(', ', $rows); - $resultBlock->addError($error); - } - } else { - if ($import->isImportAllowed()) { - $resultBlock->addSuccess( - $this->__('File is valid! To start import process press "Import" button'), true - ); - } else { - $resultBlock->addError( - $this->__('File is valid, but import is not possible'), false - ); - } - } - $resultBlock->addNotice($import->getNotices()); - $resultBlock->addNotice( - $this->__('Checked rows: %d, checked entities: %d, invalid rows: %d, total errors: %d', - $import->getProcessedRowsCount(), $import->getProcessedEntitiesCount(), - $import->getInvalidRowsCount(), $import->getErrorsCount() - ) - ); - } - } catch (Exception $e) { - $resultBlock->addNotice($this->__('Please fix errors and re-upload file')) - ->addError($e->getMessage()); - } - $this->renderLayout(); - } elseif ($this->getRequest()->isPost() && empty($_FILES)) { - $this->loadLayout(false); - $resultBlock = $this->getLayout()->getBlock('import.frame.result'); - $resultBlock->addError($this->__('File was not uploaded')); - $this->renderLayout(); - } else { - $this->_getSession()->addError($this->__('Data is invalid or file is not uploaded')); - $this->_redirect('*/*/index'); - } - } -} diff --git a/app/code/core/Mage/ImportExport/etc/adminhtml/acl.xml b/app/code/core/Mage/ImportExport/etc/adminhtml/acl.xml deleted file mode 100644 index 3f6b44650e054..0000000000000 --- a/app/code/core/Mage/ImportExport/etc/adminhtml/acl.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_ImportExport - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <resource id="Mage_Adminhtml::admin"> - <resource id="Mage_Adminhtml::system"> - <resource id="Mage_Adminhtml::convert" module="Mage_ImportExport"> - <resource id="Mage_ImportExport::import" title="Import" sortOrder="10" /> - <resource id="Mage_ImportExport::export" title="Export" sortOrder="20" /> - </resource> - </resource> - </resource> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/ImportExport/etc/config.xml b/app/code/core/Mage/ImportExport/etc/config.xml deleted file mode 100644 index 73fbe0e0c5ba6..0000000000000 --- a/app/code/core/Mage/ImportExport/etc/config.xml +++ /dev/null @@ -1,164 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_ImportExport - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <modules> - <Mage_ImportExport> - <version>1.6.0.4</version> - <active>true</active> - <codePool>core</codePool> - <depends> - <Mage_Catalog/> - </depends> - </Mage_ImportExport> - </modules> - <global> - <resources> - <importexport_setup> - <setup> - <module>Mage_ImportExport</module> - <class>Mage_ImportExport_Model_Resource_Setup</class> - </setup> - </importexport_setup> - </resources> - <importexport module="Mage_ImportExport"> - <import_entities> - <catalog_product translate="label"> - <model_token>Mage_ImportExport_Model_Import_Entity_Product</model_token> - <label>Products</label> - <behavior_token>Mage_ImportExport_Model_Source_Import_Behavior_Basic</behavior_token> - </catalog_product> - <customer_composite translate="label"> - <model_token>Mage_ImportExport_Model_Import_Entity_CustomerComposite</model_token> - <label>Customers</label> - <behavior_token>Mage_ImportExport_Model_Source_Import_Behavior_Basic</behavior_token> - </customer_composite> - <customer translate="label"> - <model_token>Mage_ImportExport_Model_Import_Entity_Eav_Customer</model_token> - <label>Customers Main File</label> - <behavior_token>Mage_ImportExport_Model_Source_Import_Behavior_Custom</behavior_token> - </customer> - <customer_address translate="label"> - <model_token>Mage_ImportExport_Model_Import_Entity_Eav_Customer_Address</model_token> - <label>Customer Addresses</label> - <behavior_token>Mage_ImportExport_Model_Source_Import_Behavior_Custom</behavior_token> - </customer_address> - </import_entities> - <export_entities> - <catalog_product translate="label"> - <model_token>Mage_ImportExport_Model_Export_Entity_Product</model_token> - <label>Products</label> - </catalog_product> - <customer translate="label"> - <model_token>Mage_ImportExport_Model_Export_Entity_Eav_Customer</model_token> - <label>Customers Main File</label> - </customer> - <customer_address translate="label"> - <model_token>Mage_ImportExport_Model_Export_Entity_Eav_Customer_Address</model_token> - <label>Customer Addresses</label> - </customer_address> - </export_entities> - <export_file_formats> - <csv translate="label"> - <model_token>Mage_ImportExport_Model_Export_Adapter_Csv</model_token> - <label>CSV</label> - </csv> - </export_file_formats> - <import_product_types> - <simple>Mage_ImportExport_Model_Import_Entity_Product_Type_Simple</simple> - <configurable>Mage_ImportExport_Model_Import_Entity_Product_Type_Configurable</configurable> - <virtual>Mage_ImportExport_Model_Import_Entity_Product_Type_Simple</virtual> - <grouped>Mage_ImportExport_Model_Import_Entity_Product_Type_Grouped</grouped> - </import_product_types> - <export_product_types> - <simple>Mage_ImportExport_Model_Export_Entity_Product_Type_Simple</simple> - <configurable>Mage_ImportExport_Model_Export_Entity_Product_Type_Configurable</configurable> - <virtual>Mage_ImportExport_Model_Export_Entity_Product_Type_Simple</virtual> - <grouped>Mage_ImportExport_Model_Export_Entity_Product_Type_Grouped</grouped> - </export_product_types> - </importexport> - </global> - <admin> - <routers> - <adminhtml> - <args> - <modules> - <importexport before="Mage_Adminhtml">Mage_ImportExport_Adminhtml</importexport> - </modules> - </args> - </adminhtml> - </routers> - </admin> - <adminhtml> - <layout> - <updates> - <importexport module="Mage_ImportExport"> - <file>layout.xml</file> - </importexport> - </updates> - </layout> - <translate> - <modules> - <Mage_ImportExport> - <files> - <default>Mage_ImportExport.csv</default> - </files> - </Mage_ImportExport> - </modules> - </translate> - </adminhtml> - <default> - <general> - <file> - <importexport_local_valid_paths> - <available> - <export_xml>var/export/*/*.xml</export_xml> - <export_csv>var/export/*/*.csv</export_csv> - <import_xml>var/import/*/*.xml</import_xml> - <import_csv>var/import/*/*.csv</import_csv> - </available> - </importexport_local_valid_paths> - <bunch_size>100</bunch_size> - </file> - </general> - <export> - <customer_page_size> - <customer>10000</customer> - <address>5000</address> - </customer_page_size> - </export> - <import> - <format_v1> - <page_size>5000</page_size> - </format_v1> - <format_v2> - <page_size>10000</page_size> - <bunch_size>100</bunch_size> - </format_v2> - </import> - </default> -</config> diff --git a/app/code/core/Mage/Index/Model/EntryPoint/Shell.php b/app/code/core/Mage/Index/Model/EntryPoint/Shell.php deleted file mode 100644 index 9f6b7111411d6..0000000000000 --- a/app/code/core/Mage/Index/Model/EntryPoint/Shell.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -class Mage_Index_Model_EntryPoint_Shell extends Mage_Core_Model_EntryPointAbstract -{ - /** - * @param string $baseDir - * @param array $params - */ - public function __construct($baseDir, array $params = array()) - { - $entryPoint = $params['entryPoint']; - unset($params['entryPoint']); - parent::__construct($baseDir, $params); - $this->_objectManager->setConfiguration(array( - 'Mage_Index_Model_Shell' => array( - 'parameters' => array( - 'entryPoint' => $entryPoint, - ) - ) - )); - } - - /** - * Process request to application - */ - public function processRequest() - { - /** @var $shell Mage_Index_Model_Shell */ - $shell = $this->_objectManager->create('Mage_Index_Model_Shell'); - $shell->run(); - if ($shell->hasErrors()) { - exit(1); - } - } -} diff --git a/app/code/core/Mage/Index/Model/Lock/Storage.php b/app/code/core/Mage/Index/Model/Lock/Storage.php deleted file mode 100644 index 9df3af7dccf7b..0000000000000 --- a/app/code/core/Mage/Index/Model/Lock/Storage.php +++ /dev/null @@ -1,82 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Index - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/** - * Lock file storage for index processes - */ -class Mage_Index_Model_Lock_Storage -{ - /** - * @var Mage_Core_Model_Dir - */ - protected $_dirs; - - /** - * @var Mage_Index_Model_Process_FileFactory - */ - protected $_fileFactory; - - /** - * File handlers by process IDs - * - * @var array - */ - protected $_fileHandlers = array(); - - /** - * @param Mage_Core_Model_Dir $dirs - * @param Mage_Index_Model_Process_FileFactory $fileFactory - */ - public function __construct( - Mage_Core_Model_Dir $dirs, - Mage_Index_Model_Process_FileFactory $fileFactory - ) { - $this->_dirs = $dirs; - $this->_fileFactory = $fileFactory; - } - - /** - * Get file handler by process ID - * - * @param $processId - * @return Mage_Index_Model_Process_File - */ - public function getFile($processId) - { - if (!isset($this->_fileHandlers[$processId])) { - $file = $this->_fileFactory->createFromArray(); - $varDirectory = $this->_dirs->getDir(Mage_Core_Model_Dir::VAR_DIR) . DIRECTORY_SEPARATOR . 'locks'; - $file->setAllowCreateFolders(true); - - $file->open(array('path' => $varDirectory)); - $fileName = 'index_process_' . $processId . '.lock'; - $file->streamOpen($fileName); - $file->streamWrite(date('r')); - $this->_fileHandlers[$processId] = $file; - } - return $this->_fileHandlers[$processId]; - } -} diff --git a/app/code/core/Mage/Index/etc/adminhtml/acl.xml b/app/code/core/Mage/Index/etc/adminhtml/acl.xml deleted file mode 100644 index 81e24f3df699d..0000000000000 --- a/app/code/core/Mage/Index/etc/adminhtml/acl.xml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Index - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <resource id="Mage_Adminhtml::admin"> - <resource id="Mage_Adminhtml::system"> - <resource id="Mage_Index::index" title="Index Management" /> - </resource> - </resource> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/Index/etc/adminhtml/menu.xml b/app/code/core/Mage/Index/etc/adminhtml/menu.xml deleted file mode 100644 index cafa5bef9f326..0000000000000 --- a/app/code/core/Mage/Index/etc/adminhtml/menu.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Index - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <menu> - <add id="Mage_Index::system_index" title="Index Management" module="Mage_Index" sortOrder="92" parent="Mage_Adminhtml::system" action="adminhtml/process/list" resource="Mage_Index::index"/> - </menu> -</config> diff --git a/app/code/core/Mage/Index/etc/config.xml b/app/code/core/Mage/Index/etc/config.xml deleted file mode 100644 index 1d729c6839365..0000000000000 --- a/app/code/core/Mage/Index/etc/config.xml +++ /dev/null @@ -1,141 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Index - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <modules> - <Mage_Index> - <version>1.6.0.0</version> - <active>true</active> - <codePool>core</codePool> - <depends> - <Mage_Core/> - </depends> - </Mage_Index> - </modules> - <global> - <resources> - <index_setup> - <setup> - <module>Mage_Index</module> - <class>Mage_Index_Model_Resource_Setup</class> - </setup> - </index_setup> - </resources> - <index> - <indexer> - - </indexer> - </index> - <events> - <store_save_commit_after> - <observers> - <index> - <class>Mage_Index_Model_Observer</class> - <method>processStoreSave</method> - </index> - </observers> - </store_save_commit_after> - <store_group_save_commit_after> - <observers> - <index> - <class>Mage_Index_Model_Observer</class> - <method>processStoreGroupSave</method> - </index> - </observers> - </store_group_save_commit_after> - <website_save_commit_after> - <observers> - <index> - <class>Mage_Index_Model_Observer</class> - <method>processWebsiteSave</method> - </index> - </observers> - </website_save_commit_after> - <store_delete_commit_after> - <observers> - <index> - <class>Mage_Index_Model_Observer</class> - <method>processStoreDelete</method> - </index> - </observers> - </store_delete_commit_after> - <store_group_delete_commit_after> - <observers> - <index> - <class>Mage_Index_Model_Observer</class> - <method>processStoreGroupDelete</method> - </index> - </observers> - </store_group_delete_commit_after> - <website_delete_commit_after> - <observers> - <index> - <class>Mage_Index_Model_Observer</class> - <method>processWebsiteDelete</method> - </index> - </observers> - </website_delete_commit_after> - <core_config_data_save_commit_after> - <observers> - <index> - <class>Mage_Index_Model_Observer</class> - <method>processConfigDataSave</method> - </index> - </observers> - </core_config_data_save_commit_after> - </events> - </global> - <admin> - <routers> - <adminhtml> - <args> - <modules> - <Mage_Index before="Mage_Adminhtml">Mage_Index_Adminhtml</Mage_Index> - </modules> - </args> - </adminhtml> - </routers> - </admin> - <adminhtml> - <layout> - <updates> - <index module="Mage_Index"> - <file>layout.xml</file> - </index> - </updates> - </layout> - <translate> - <modules> - <Mage_Index> - <files> - <default>Mage_Index.csv</default> - </files> - </Mage_Index> - </modules> - </translate> - </adminhtml> -</config> diff --git a/app/code/core/Mage/Install/Model/EntryPoint/Console.php b/app/code/core/Mage/Install/Model/EntryPoint/Console.php deleted file mode 100644 index cd812e280ca98..0000000000000 --- a/app/code/core/Mage/Install/Model/EntryPoint/Console.php +++ /dev/null @@ -1,103 +0,0 @@ -<?php -/** - * Console entry point - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -class Mage_Install_Model_EntryPoint_Console extends Mage_Core_Model_EntryPointAbstract -{ - /** - * @param string $baseDir - * @param array $params - */ - public function __construct($baseDir, array $params = array()) - { - $this->_params = $this->_buildInitParams($params); - parent::__construct($baseDir, $this->_params); - } - - /** - * Customize application init parameters - * - * @param array $args - * @return array - */ - protected function _buildInitParams(array $args) - { - if (!empty($args[Mage_Install_Model_Installer_Console::OPTION_URIS])) { - $args[MAGE::PARAM_APP_URIS] = - unserialize(base64_decode($args[Mage_Install_Model_Installer_Console::OPTION_URIS])); - } - if (!empty($args[Mage_Install_Model_Installer_Console::OPTION_DIRS])) { - $args[Mage::PARAM_APP_DIRS] = - unserialize(base64_decode($args[Mage_Install_Model_Installer_Console::OPTION_DIRS])); - } - return $args; - } - - /** - * Run http application - */ - public function processRequest() - { - /** - * @var $installer Mage_Install_Model_Installer_Console - */ - $installer = $this->_objectManager->get( - 'Mage_Install_Model_Installer_Console', - array('installArgs' => $this->_params) - ); - if (isset($this->_params['show_locales'])) { - var_export($installer->getAvailableLocales()); - } else if (isset($this->_params['show_currencies'])) { - var_export($installer->getAvailableCurrencies()); - } else if (isset($this->_params['show_timezones'])) { - var_export($installer->getAvailableTimezones()); - } else if (isset($this->_params['show_install_options'])) { - var_export($installer->getAvailableInstallOptions()); - } else { - if (isset($this->_params['config']) && file_exists($this->_params['config'])) { - $config = (array) include($this->_params['config']); - $this->_params = array_merge((array)$config, $this->_params); - } - $isUninstallMode = isset($this->_params['uninstall']); - if ($isUninstallMode) { - $result = $installer->uninstall(); - } else { - $result = $installer->install($this->_params); - } - if (!$installer->hasErrors()) { - if ($isUninstallMode) { - $msg = $result ? - 'Uninstalled successfully' : - 'Ignoring attempt to uninstall non-installed application'; - } else { - $msg = 'Installed successfully' . ($result ? ' (encryption key "' . $result . '")' : ''); - } - echo $msg . PHP_EOL; - } else { - echo implode(PHP_EOL, $installer->getErrors()) . PHP_EOL; - exit(1); - } - } - } -} diff --git a/app/code/core/Mage/Install/etc/config.xml b/app/code/core/Mage/Install/etc/config.xml deleted file mode 100644 index 633cfc8568492..0000000000000 --- a/app/code/core/Mage/Install/etc/config.xml +++ /dev/null @@ -1,100 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Install - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <modules> - <Mage_Install> - <version>0.7.0</version> - <active>true</active> - <codePool>core</codePool> - <depends> - <Mage_Core/> - </depends> - </Mage_Install> - </modules> - <frontend> - <secure_url> - <install>/install/wizard/checkSecureHost</install> - </secure_url> - <routers> - <install> - <use>standard</use> - <args> - <module>Mage_Install</module> - <frontName>install</frontName> - </args> - </install> - </routers> - </frontend> - <install> - <databases> - <mysql4> - <type>pdo_mysql</type> - <initStatements>SET NAMES utf8</initStatements> - <min_version>4.1.20</min_version> - <extensions> - <pdo_mysql/> - </extensions> - </mysql4> - </databases> - <events> - <controller_action_predispatch> - <observers> - <checkConnection> - <class>Mage_Core_Model_Resource</class> - <method>checkDbConnection</method> - </checkConnection> - </observers> - </controller_action_predispatch> - <core_locale_set_locale> - <observers> - <bind_locale> - <class>Mage_Install_Model_Observer</class> - <method>bindLocale</method> - </bind_locale> - </observers> - </core_locale_set_locale> - </events> - <translate> - <modules> - <Mage_Install> - <files> - <default>Mage_Install.csv</default> - </files> - </Mage_Install> - </modules> - </translate> - <layout> - <updates> - <install module="Mage_Install"> - <file>layout.xml</file> - </install> - </updates> - </layout> - <eula_file>LICENSE.html</eula_file> - </install> -</config> diff --git a/app/code/core/Mage/Install/view/install/page.phtml b/app/code/core/Mage/Install/view/install/page.phtml deleted file mode 100644 index 00705e93de037..0000000000000 --- a/app/code/core/Mage/Install/view/install/page.phtml +++ /dev/null @@ -1,123 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category design - * @package default_default - * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ -?> -<?php -/** - * Template for Mage_Page_Block_Html - */ -?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> - <title><?php echo Mage::helper('Mage_Install_Helper_Data')->__('Magento Installation Wizard') ?> - - - - - - - - - - - - - - - - helper('Mage_Core_Helper_Js')->getTranslatorScript() ?> - - - - -
    -
    -
    -

    - <?php echo Mage::helper('Mage_Install_Helper_Data')->__('Magento') ?> -

    - - getChildHtml('topSearch') ?> - -
    - -
    - getChildHtml('topRightLinks') ?> -
    -
    - -
    -
    - getChildHtml('topMenu') ?> -
    - - - -getChildHtml('store') ?> -
    -
    - getChildHtml('breadcrumbs') ?> - - -
    - getChildHtml('left') ?> -
    -
    - - getChildHtml('global_messages') ?> - - - getChildHtml('content') ?> - -
    -
    - -
    - - - - - - - diff --git a/app/code/core/Mage/Log/Model/EntryPoint/Shell.php b/app/code/core/Mage/Log/Model/EntryPoint/Shell.php deleted file mode 100644 index 7d12fbea43814..0000000000000 --- a/app/code/core/Mage/Log/Model/EntryPoint/Shell.php +++ /dev/null @@ -1,55 +0,0 @@ -_objectManager->setConfiguration(array( - 'Mage_Log_Model_Shell' => array( - 'parameters' => array( - 'entryPoint' => $entryPoint, - ) - ) - )); - } - - /** - * Process request to application - */ - public function processRequest() - { - /** @var $shell Mage_Log_Model_Shell */ - $shell = $this->_objectManager->create('Mage_Log_Model_Shell'); - $shell->run(); - } - -} diff --git a/app/code/core/Mage/Log/etc/config.xml b/app/code/core/Mage/Log/etc/config.xml deleted file mode 100644 index f93d6f09e9956..0000000000000 --- a/app/code/core/Mage/Log/etc/config.xml +++ /dev/null @@ -1,160 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - - - - - - - Googlebot/1.0 (googlebot@googlebot.com http://googlebot.com/) - Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) - Googlebot/2.1 (+http://www.googlebot.com/bot.html) - - - - - Mage_Log - - - - - - - - - - - Mage_Log_Model_Visitor - initByRequest - - - - - - - Mage_Log_Model_Visitor - saveByRequest - - - - - - - Mage_Log_Model_Visitor - bindCustomerLogin - - - - - - - Mage_Log_Model_Visitor - bindCustomerLogout - - - - - - - Mage_Log_Model_Visitor - bindQuoteCreate - - - - - - - Mage_Log_Model_Visitor - bindQuoteDestroy - - - - - - - - - - - Mage_Log.csv - - - - - - - - - 60 - - - - - 180 - 0 - - - - - - - - Mage_Log_Model_Cron::logClean - - - - - diff --git a/app/code/core/Mage/Media/etc/config.xml b/app/code/core/Mage/Media/etc/config.xml deleted file mode 100644 index 47b8aea1af09f..0000000000000 --- a/app/code/core/Mage/Media/etc/config.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - - Mage_Media.csv - - - - - - - - - standard - - Mage_Media - media - - - - - - - - Mage_Media.csv - - - - - - diff --git a/app/code/core/Mage/Newsletter/etc/adminhtml/acl.xml b/app/code/core/Mage/Newsletter/etc/adminhtml/acl.xml deleted file mode 100644 index fa0e2ed9e16dd..0000000000000 --- a/app/code/core/Mage/Newsletter/etc/adminhtml/acl.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Newsletter/etc/adminhtml/menu.xml b/app/code/core/Mage/Newsletter/etc/adminhtml/menu.xml deleted file mode 100644 index 8f75080536920..0000000000000 --- a/app/code/core/Mage/Newsletter/etc/adminhtml/menu.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - diff --git a/app/code/core/Mage/Newsletter/etc/config.xml b/app/code/core/Mage/Newsletter/etc/config.xml deleted file mode 100644 index a9d92123d5e85..0000000000000 --- a/app/code/core/Mage/Newsletter/etc/config.xml +++ /dev/null @@ -1,186 +0,0 @@ - - - - - - 1.6.0.2 - true - core - - - - - - - - - - - - - Mage_Newsletter - - - - - - Mage_Newsletter_Model_Template_Filter - - - - - - - - Mage_Newsletter_Model_Observer - subscribeCustomer - - - - - - - Mage_Newsletter_Model_Observer - customerDeleted - - - - - - - - - Mage_Newsletter.csv - - - - - - - - layout.xml - - - - - - - - - - Mage_Newsletter_Model_Observer - subscribeCustomer - - - - - - - Mage_Newsletter_Model_Observer - customerDeleted - - - - - - - standard - - Mage_Newsletter - newsletter - - - - - - - - Mage_Newsletter.csv - - - - - - - - layout.xml - - - - - /newsletter/manage/ - - - - - - 1 - 0 - support - newsletter_subscription_confirm_email_template - general - newsletter_subscription_success_email_template - support - newsletter_subscription_un_email_template - - - 0 - - - - - - - - */5 * * * * - - - Mage_Newsletter_Model_Observer::scheduledSend - - - - - diff --git a/app/code/core/Mage/Newsletter/view/adminhtml/layout.xml b/app/code/core/Mage/Newsletter/view/adminhtml/layout.xml deleted file mode 100644 index 8bca1fb972803..0000000000000 --- a/app/code/core/Mage/Newsletter/view/adminhtml/layout.xml +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - queueGrid - Mage_Newsletter_Model_Resource_Queue_Grid_Collection - start_at - DESC - 1 - 1 - - - - - */*/edit - - getId - - - - - -
    ID
    - queue_id - 10px -
    -
    - - -
    Queue Start
    - datetime - queue_start_at - 1 - ---- -
    -
    - - -
    Queue Finish
    - datetime - queue_finish_at - 1 - ---- -
    -
    - - -
    Subject
    - newsletter_subject -
    -
    - - -
    Status
    - queue_status - options - Mage_Newsletter_Model_Queue_Options_Status - 100px -
    -
    - - - - -
    Processed
    - number - subscribers_sent -
    -
    - - -
    Recipients
    - number - subscribers_total -
    -
    - - -
    Action
    - 0 - 0 - 1 - 100px - Mage_Adminhtml_Block_Newsletter_Queue_Grid_Renderer_Action -
    -
    -
    -
    -
    -
    -
    diff --git a/app/code/core/Mage/Oauth/etc/config.xml b/app/code/core/Mage/Oauth/etc/config.xml deleted file mode 100644 index 4ff1e61dee9a2..0000000000000 --- a/app/code/core/Mage/Oauth/etc/config.xml +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - 1.0.0.0 - true - core - - - - - - - - - - - - - Mage_Oauth - Mage_Oauth_Model_Resource_Setup - - - - - - - - Mage_Oauth_Model_Observer - afterCustomerLogin - - - - - - - Mage_Oauth_Model_Observer - afterAdminLogin - - - - - - - Mage_Oauth_Model_Observer - afterAdminLoginFailed - - - - - - - - - - - - Mage_Oauth_Adminhtml - - - - - - - - - - - Mage_Oauth.csv - - - - - - - - layout.xml - - - - - - - - standard - - Mage_Oauth - oauth - - - - - - - layout.xml - - - - - - - - Mage_Oauth.csv - - - - - - - - - 100 - 120 - - - general - - - - - diff --git a/app/code/core/Mage/Oauth/sql/oauth_setup/install-1.0.0.0.php b/app/code/core/Mage/Oauth/sql/oauth_setup/install-1.0.0.0.php deleted file mode 100644 index 1fd81d078c59e..0000000000000 --- a/app/code/core/Mage/Oauth/sql/oauth_setup/install-1.0.0.0.php +++ /dev/null @@ -1,198 +0,0 @@ -startSetup(); - -/** @var $adapter Varien_Db_Adapter_Pdo_Mysql */ -$adapter = $installer->getConnection(); - -/** - * Create table 'oauth_consumer' - */ -$table = $adapter->newTable($installer->getTable('oauth_consumer')) - ->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( - 'identity' => true, - 'unsigned' => true, - 'nullable' => false, - 'primary' => true, - ), 'Entity Id') - ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array( - 'nullable' => false, - 'default' => Varien_Db_Ddl_Table::TIMESTAMP_INIT - ), 'Created At') - ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array( - 'nullable' => true - ), 'Updated At') - ->addColumn('name', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array( - 'nullable' => false - ), 'Name of consumer') - ->addColumn('key', Varien_Db_Ddl_Table::TYPE_TEXT, Mage_Oauth_Model_Consumer::KEY_LENGTH, array( - 'nullable' => false - ), 'Key code') - ->addColumn('secret', Varien_Db_Ddl_Table::TYPE_TEXT, Mage_Oauth_Model_Consumer::SECRET_LENGTH, array( - 'nullable' => false - ), 'Secret code') - ->addColumn('callback_url', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(), 'Callback URL') - ->addColumn('rejected_callback_url', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array( - 'nullable' => false - ), 'Rejected callback URL') - ->addIndex( - $installer->getIdxName( - $installer->getTable('oauth_consumer'), - array('key'), - Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE - ), - array('key'), - array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)) - ->addIndex( - $installer->getIdxName( - $installer->getTable('oauth_consumer'), - array('secret'), - Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE - ), - array('secret'), - array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)) - ->addIndex($installer->getIdxName('oauth_consumer', array('created_at')), array('created_at')) - ->addIndex($installer->getIdxName('oauth_consumer', array('updated_at')), array('updated_at')) - ->setComment('OAuth Consumers'); -$adapter->createTable($table); - -/** - * Create table 'oauth_token' - */ -$table = $adapter->newTable($installer->getTable('oauth_token')) - ->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( - 'identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true, - ), 'Entity ID') - ->addColumn('consumer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( - 'unsigned' => true, - 'nullable' => false - ), 'Consumer ID') - ->addColumn('admin_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( - 'unsigned' => true, - 'nullable' => true - ), 'Admin user ID') - ->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( - 'unsigned' => true, - 'nullable' => true - ), 'Customer user ID') - ->addColumn('type', Varien_Db_Ddl_Table::TYPE_TEXT, 16, array( - 'nullable' => false - ), 'Token Type') - ->addColumn('token', Varien_Db_Ddl_Table::TYPE_TEXT, Mage_Oauth_Model_Token::LENGTH_TOKEN, array( - 'nullable' => false - ), 'Token') - ->addColumn('secret', Varien_Db_Ddl_Table::TYPE_TEXT, Mage_Oauth_Model_Token::LENGTH_SECRET, array( - 'nullable' => false - ), 'Token Secret') - ->addColumn('verifier', Varien_Db_Ddl_Table::TYPE_TEXT, Mage_Oauth_Model_Token::LENGTH_VERIFIER, array( - 'nullable' => true - ), 'Token Verifier') - ->addColumn('callback_url', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array( - 'nullable' => false - ), 'Token Callback URL') - ->addColumn('revoked', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( - 'unsigned' => true, - 'nullable' => false, - 'default' => 0, - ), 'Is Token revoked') - ->addColumn('authorized', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( - 'unsigned' => true, - 'nullable' => false, - 'default' => 0, - ), 'Is Token authorized') - ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array( - 'nullable' => false, - 'default' => Varien_Db_Ddl_Table::TIMESTAMP_INIT - ), 'Token creation timestamp') - ->addIndex( - $installer->getIdxName( - $installer->getTable('oauth_token'), - array('consumer_id'), - Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX - ), - array('consumer_id'), - array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX)) - ->addIndex( - $installer->getIdxName( - $installer->getTable('oauth_token'), - array('token'), - Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE - ), - array('token'), - array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)) - ->addForeignKey( - $installer->getFkName('oauth_token', 'admin_id', $installer->getTable('admin_user'), 'user_id'), - 'admin_id', - $installer->getTable('admin_user'), - 'user_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, - Varien_Db_Ddl_Table::ACTION_CASCADE) - ->addForeignKey( - $installer->getFkName('oauth_token', 'consumer_id', 'oauth_consumer', 'entity_id'), - 'consumer_id', - $installer->getTable('oauth_consumer'), - 'entity_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, - Varien_Db_Ddl_Table::ACTION_CASCADE) - ->addForeignKey( - $installer->getFkName('oauth_token', 'customer_id', $installer->getTable('customer_entity'), 'entity_id'), - 'customer_id', - $installer->getTable('customer_entity'), - 'entity_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, - Varien_Db_Ddl_Table::ACTION_CASCADE) - ->setComment('OAuth Tokens'); -$adapter->createTable($table); - -/** - * Create table 'oauth_nonce - */ -$table = $adapter->newTable($installer->getTable('oauth_nonce')) - ->addColumn('nonce', Varien_Db_Ddl_Table::TYPE_TEXT, 32, array( - 'nullable' => false - ), 'Nonce String') - ->addColumn('timestamp', Varien_Db_Ddl_Table::TYPE_INTEGER, 10, array( - 'unsigned' => true, - 'nullable' => false - ), 'Nonce Timestamp') - ->addIndex( - $installer->getIdxName( - $installer->getTable('oauth_nonce'), - array('nonce'), - Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE - ), - array('nonce'), - array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)) - ->setOption('type', 'MyISAM'); -$adapter->createTable($table); - -$installer->endSetup(); diff --git a/app/code/core/Mage/Ogone/etc/config.xml b/app/code/core/Mage/Ogone/etc/config.xml deleted file mode 100644 index c36aa985337b3..0000000000000 --- a/app/code/core/Mage/Ogone/etc/config.xml +++ /dev/null @@ -1,147 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - - Mage_Ogone - - - core_setup - - - - - core_write - - - - - core_read - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - layout.xml - - - - - /ogone/api - - - - standard - - Mage_Ogone - ogone - - - - - - - - Mage_Ogone.csv - - - - - - - - - Mage_Ogone_Model_Api - Ogone - - authorize - sha256 - - https://secure.ogone.com/ncol/test/orderstandard.asp - pending_ogone - cancel_ogone - decline_ogone - processing_ogone - processed_ogone - waiting_authorozation - - - - diff --git a/app/code/core/Mage/Page/Block/Html/Head.php b/app/code/core/Mage/Page/Block/Html/Head.php deleted file mode 100644 index 619157c348e91..0000000000000 --- a/app/code/core/Mage/Page/Block/Html/Head.php +++ /dev/null @@ -1,470 +0,0 @@ - - */ -class Mage_Page_Block_Html_Head extends Mage_Core_Block_Template -{ - /** - * Block template - * - * @var string - */ - protected $_template = 'html/head.phtml'; - - /** - * Chunks of title (necessary for backend) - * - * @var array - */ - protected $_titleChunks; - - /** - * Page title without prefix and suffix when not chunked - * - * @var string - */ - protected $_pureTitle; - /** - * Add CSS file to HEAD entity - * - * @param string $name - * @param string $params - * @param string|null $if - * @param string|null $cond - * @return Mage_Page_Block_Html_Head - */ - public function addCss($name, $params = '', $if = null, $cond = null) - { - $params = 'rel="stylesheet" type="text/css"' . ($params ? ' ' . trim($params) : ' media="all"'); - return $this->_addItem('css', $name, $params, $if, $cond); - } - - /** - * Add JavaScript file to HEAD entity - * - * @param string $name - * @param string $params - * @param string|null $if - * @param string|null $cond - * @return Mage_Page_Block_Html_Head - */ - public function addJs($name, $params = '', $if = null, $cond = null) - { - return $this->_addItem('js', $name, $params, $if, $cond); - } - - /** - * Add CSS file for Internet Explorer only to HEAD entity - * - * @param string $name - * @param string $params - * @param string|null $cond - * @return Mage_Page_Block_Html_Head - */ - public function addCssIe($name, $params = '', $cond = null) - { - return $this->addCss($name, $params, 'IE', $cond); - } - - /** - * Add JavaScript file for Internet Explorer only to HEAD entity - * - * @param string $name - * @param string $params - * @param string|null $cond - * @return Mage_Page_Block_Html_Head - */ - public function addJsIe($name, $params = '', $cond = null) - { - return $this->addJs($name, $params, 'IE', $cond); - } - - /** - * Add RSS element to HEAD entity - * - * @param string $title - * @param string $href - * @return Mage_Page_Block_Html_Head - */ - public function addRss($title, $href) - { - return $this->_addItem('link', $href, 'rel="alternate" type="application/rss+xml" title="' . $title . '"'); - } - - /** - * Add Link element to HEAD entity - * - * @param string $rel forward link types - * @param string $href URI for linked resource - * @return Mage_Page_Block_Html_Head - */ - public function addLinkRel($rel, $href) - { - return $this->_addItem('link', $href, 'rel="' . $rel . '"'); - } - - /** - * Add HEAD Item - * - * @param string $type - * @param string $name - * @param string $params - * @param string|null $if - * @param string|null $cond - * @return Mage_Page_Block_Html_Head - * @throws Magento_Exception - */ - protected function _addItem($type, $name, $params = '', $if = null, $cond = null) - { - if (empty($name)) { - throw new Magento_Exception('File name must be not empty.'); - } - $this->_data['items'][$type . '/' . $name] = array( - 'type' => $type, - 'name' => $name, - 'params' => trim($params), - 'if' => $if, - 'cond' => $cond, - ); - return $this; - } - - /** - * Remove Item from HEAD entity - * - * @param string $type - * @param string $name - * @return Mage_Page_Block_Html_Head - */ - public function removeItem($type, $name) - { - unset($this->_data['items'][$type . '/' . $name]); - return $this; - } - - /** - * Render HTML for the added head items - * - * @return string - */ - public function getCssJsHtml() - { - $lines = array(); - $meta = array(); - foreach ($this->_data['items'] as $item) { - if (!is_null($item['cond']) && !$this->getData($item['cond'])) { - continue; - } - $contentType = $item['type']; - $group = $item['if'] . '|' . (empty($item['params']) ? '_' : $item['params']) . '|' . $contentType; - $meta[$group] = array($item['if'], (string)$item['params'], $contentType); - $lines[$group][] = $item['name']; - } - - $html = ''; - foreach ($lines as $group => $items) { - list($if, $params, $contentType) = $meta[$group]; - if (!empty($if)) { - $html .= '' . "\n"; - } - } - return $html; - } - - /** - * Generate css links - * - * @param array $items - * @param array $params - * @return string - */ - protected function _generateCssHtml($items, $params) - { - $html = ''; - $pattern = '' . "\n"; - try { - foreach (Mage::getDesign()->getOptimalCssUrls($items) as $url) { - $html .= sprintf($pattern, $params, $url); - } - } catch (Magento_Exception $e) { - $html .= sprintf($pattern, $params, $this->_getNotFoundUrl()); - } - return $html; - } - - /** - * Generate js links - * - * @param array $items - * @param array $params - * @return string - */ - protected function _generateJsHtml($items, $params) - { - $html = ''; - $pattern = '' . "\n"; - try { - foreach (Mage::getDesign()->getOptimalJsUrls($items) as $url) { - $html .= sprintf($pattern, $params, $url); - } - } catch (Magento_Exception $e) { - $html .= sprintf($pattern, $params, $this->_getNotFoundUrl()); - } - return $html; - } - - /** - * Retrieve Content Type - * - * @return string - */ - public function getContentType() - { - if (empty($this->_data['content_type'])) { - $this->_data['content_type'] = $this->getMediaType() . '; charset=' . $this->getCharset(); - } - return $this->_data['content_type']; - } - - /** - * Retrieve Media Type - * - * @return string - */ - public function getMediaType() - { - if (empty($this->_data['media_type'])) { - $this->_data['media_type'] = Mage::getStoreConfig('design/head/default_media_type'); - } - return $this->_data['media_type']; - } - - /** - * Retrieve Charset - * - * @return string - */ - public function getCharset() - { - if (empty($this->_data['charset'])) { - $this->_data['charset'] = Mage::getStoreConfig('design/head/default_charset'); - } - return $this->_data['charset']; - } - - /** - * Set title element text - * - * @param string|array $title - * @return Mage_Page_Block_Html_Head - */ - public function setTitle($title) - { - if (is_array($title)) { - $this->_titleChunks = $title; - $title = implode(' / ', $title); - } else { - $this->_pureTitle = $title; - } - $this->_data['title'] = Mage::getStoreConfig('design/head/title_prefix') . ' ' . $title - . ' ' . Mage::getStoreConfig('design/head/title_suffix'); - return $this; - } - - /** - * Retrieve title element text (encoded) - * - * @return string - */ - public function getTitle() - { - if (empty($this->_data['title'])) { - $this->_data['title'] = $this->getDefaultTitle(); - } - return htmlspecialchars(html_entity_decode(trim($this->_data['title']), ENT_QUOTES, 'UTF-8')); - } - - /** - * Same as getTitle(), but return only first item from chunk for backend pages - * - * @return mixed|string - */ - public function getShortTitle() - { - if (!empty($this->_titleChunks)) { - return reset($this->_titleChunks); - } else { - return $this->_pureTitle; - } - } - - /** - * Retrieve default title text - * - * @return string - */ - public function getDefaultTitle() - { - return Mage::getStoreConfig('design/head/default_title'); - } - - /** - * Retrieve content for description tag - * - * @return string - */ - public function getDescription() - { - if (empty($this->_data['description'])) { - $this->_data['description'] = Mage::getStoreConfig('design/head/default_description'); - } - return $this->_data['description']; - } - - /** - * Retrieve content for keyvords tag - * - * @return string - */ - public function getKeywords() - { - if (empty($this->_data['keywords'])) { - $this->_data['keywords'] = Mage::getStoreConfig('design/head/default_keywords'); - } - return $this->_data['keywords']; - } - - /** - * Retrieve URL to robots file - * - * @return string - */ - public function getRobots() - { - if (empty($this->_data['robots'])) { - $this->_data['robots'] = Mage::getStoreConfig('design/search_engine_robots/default_robots'); - } - return $this->_data['robots']; - } - - /** - * Get miscellaneous scripts/styles to be included in head before head closing tag - * - * @return string - */ - public function getIncludes() - { - if (empty($this->_data['includes'])) { - $this->_data['includes'] = Mage::getStoreConfig('design/head/includes'); - } - return $this->_data['includes']; - } - - /** - * Getter for path to Favicon - * - * @return string - */ - public function getFaviconFile() - { - if (empty($this->_data['favicon_file'])) { - $this->_data['favicon_file'] = $this->_getFaviconFile(); - } - return $this->_data['favicon_file']; - } - - /** - * Retrieve path to Favicon - * - * @return string - */ - protected function _getFaviconFile() - { - $folderName = Mage_Backend_Model_Config_Backend_Image_Favicon::UPLOAD_DIR; - $storeConfig = Mage::getStoreConfig('design/head/shortcut_icon'); - $faviconFile = Mage::getBaseUrl('media') . $folderName . '/' . $storeConfig; - $absolutePath = Mage::getBaseDir('media') . '/' . $folderName . '/' . $storeConfig; - - if (!is_null($storeConfig) && $this->_isFile($absolutePath)) { - $url = $faviconFile; - } else { - $url = $this->getViewFileUrl('Mage_Page::favicon.ico'); - } - return $url; - } - - /** - * If DB file storage is on - find there, otherwise - just file_exists - * - * @param string $filename - * @return bool - */ - protected function _isFile($filename) - { - if (Mage::helper('Mage_Core_Helper_File_Storage_Database')->checkDbUsage() && !is_file($filename)) { - Mage::helper('Mage_Core_Helper_File_Storage_Database')->saveFileToFilesystem($filename); - } - return is_file($filename); - } - - /** - * Retrieve locale code - * - * @return string - */ - public function getLocale() - { - return substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2); - } -} diff --git a/app/code/core/Mage/Page/etc/config.xml b/app/code/core/Mage/Page/etc/config.xml deleted file mode 100644 index 93ad69a77358e..0000000000000 --- a/app/code/core/Mage/Page/etc/config.xml +++ /dev/null @@ -1,165 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - - - page_empty - - - - - page_one_column - 1 - - - - - page_two_columns_left - - - - - page_two_columns_right - - - - - page_three_columns - - - - - - - - - - Mage_Page.csv - - - - - - - - layout.xml - - - layout_addons.xml - - - - - - - - - - Mage_Page.csv - - - - - - - - - - - Mage_Page.csv - - - - - - - - - Magento Commerce - Default Description - Magento, Varien, E-commerce - text/html - utf-8 - - - INDEX,FOLLOW - - - - -
    - Magento Commerce - Default welcome msg! -
    -
    - &copy; 2012 Magento Demo Store. All Rights Reserved. -
    -
    - - - - favicon - - - -
    -
    diff --git a/app/code/core/Mage/Page/view/adminhtml/title.phtml b/app/code/core/Mage/Page/view/adminhtml/title.phtml deleted file mode 100644 index 6d7025b4d5df9..0000000000000 --- a/app/code/core/Mage/Page/view/adminhtml/title.phtml +++ /dev/null @@ -1,35 +0,0 @@ - -
    -
    -

    getPageTitle(); ?>

    -
    -
    \ No newline at end of file diff --git a/app/code/core/Mage/PageCache/Helper/Data.php b/app/code/core/Mage/PageCache/Helper/Data.php deleted file mode 100644 index c9884a707a82c..0000000000000 --- a/app/code/core/Mage/PageCache/Helper/Data.php +++ /dev/null @@ -1,190 +0,0 @@ - - */ -class Mage_PageCache_Helper_Data extends Mage_Core_Helper_Abstract -{ - /** - * Paths to external cache config options - */ - const XML_PATH_EXTERNAL_CACHE_ENABLED = 'system/external_page_cache/enabled'; - const XML_PATH_EXTERNAL_CACHE_LIFETIME = 'system/external_page_cache/cookie_lifetime'; - const XML_PATH_EXTERNAL_CACHE_CONTROL = 'system/external_page_cache/control'; - - /** - * Path to external cache controls - */ - const XML_PATH_EXTERNAL_CACHE_CONTROLS = 'global/external_cache/controls'; - - /** - * Cookie name for disabling external caching - */ - const NO_CACHE_COOKIE = 'external_no_cache'; - - /** - * Cookie name for locking the NO_CACHE_COOKIE for modification - */ - const NO_CACHE_LOCK_COOKIE = 'external_no_cache_cookie_locked'; - - /** - * @var bool - */ - protected $_isNoCacheCookieLocked = false; - - /** - * Initialize 'no cache' cookie locking - * - * @param Mage_Core_Model_Translate $translator - */ - function __construct(Mage_Core_Model_Translate $translator) - { - parent::__construct($translator); - $this->_isNoCacheCookieLocked = (bool)$this->_getCookie()->get(self::NO_CACHE_LOCK_COOKIE); - } - - /** - * Retrieve the cookie model instance - * - * @return Mage_Core_Model_Cookie - */ - protected function _getCookie() - { - return Mage::getSingleton('Mage_Core_Model_Cookie'); - } - - /** - * Check whether external cache is enabled - * - * @return bool - */ - public function isEnabled() - { - return (bool)Mage::getStoreConfig(self::XML_PATH_EXTERNAL_CACHE_ENABLED); - } - - /** - * Return all available external cache controls - * - * @return array - */ - public function getCacheControls() - { - $controls = Mage::app()->getConfig()->getNode(self::XML_PATH_EXTERNAL_CACHE_CONTROLS); - return $controls->asCanonicalArray(); - } - - /** - * Initialize proper external cache control model - * - * @throws Mage_Core_Exception - * @return Mage_PageCache_Model_Control_Interface - */ - public function getCacheControlInstance() - { - $usedControl = Mage::getStoreConfig(self::XML_PATH_EXTERNAL_CACHE_CONTROL); - if ($usedControl) { - foreach ($this->getCacheControls() as $control => $info) { - if ($control == $usedControl && !empty($info['class'])) { - return Mage::getSingleton($info['class']); - } - } - } - Mage::throwException($this->__('Failed to load external cache control')); - } - - /** - * Disable caching on external storage side by setting special cookie, if the cookie has not been locked - * - * @param int|null $lifetime - * @return Mage_PageCache_Helper_Data - */ - public function setNoCacheCookie($lifetime = null) - { - if ($this->_isNoCacheCookieLocked) { - return $this; - } - $lifetime = $lifetime !== null ? $lifetime : Mage::getStoreConfig(self::XML_PATH_EXTERNAL_CACHE_LIFETIME); - if ($this->_getCookie()->get(self::NO_CACHE_COOKIE)) { - $this->_getCookie()->renew(self::NO_CACHE_COOKIE, $lifetime); - } else { - $this->_getCookie()->set(self::NO_CACHE_COOKIE, '1', $lifetime); - } - return $this; - } - - /** - * Remove the 'no cache' cookie, if it has not been locked - * - * @return Mage_PageCache_Helper_Data - */ - public function removeNoCacheCookie() - { - if (!$this->_isNoCacheCookieLocked) { - $this->_getCookie()->delete(self::NO_CACHE_COOKIE); - } - return $this; - } - - /** - * Disable modification of the 'no cache' cookie - * - * @return Mage_PageCache_Helper_Data - */ - public function lockNoCacheCookie() - { - $this->_getCookie()->set(self::NO_CACHE_LOCK_COOKIE, '1', 0); - $this->_isNoCacheCookieLocked = true; - return $this; - } - - /** - * Enable modification of the 'no cache' cookie - * - * @return Mage_PageCache_Helper_Data - */ - public function unlockNoCacheCookie() - { - $this->_getCookie()->delete(self::NO_CACHE_LOCK_COOKIE); - $this->_isNoCacheCookieLocked = false; - return $this; - } - - /** - * Returns a lifetime of cookie for external cache - * - * @return string Time in seconds - */ - public function getNoCacheCookieLifetime() - { - return Mage::getStoreConfig(self::XML_PATH_EXTERNAL_CACHE_LIFETIME); - } -} diff --git a/app/code/core/Mage/PageCache/etc/config.xml b/app/code/core/Mage/PageCache/etc/config.xml deleted file mode 100644 index ba29b59a2cf71..0000000000000 --- a/app/code/core/Mage/PageCache/etc/config.xml +++ /dev/null @@ -1,139 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - - Mage_PageCache_Model_Control_Zend - - - - - - - - Mage_PageCache_Model_Observer - setNoCacheCookie - - - - - - - Mage_PageCache_Model_Observer - deleteNoCacheCookie - - - - - - - - - - layout.xml - - - - - - - - Mage_PageCache.csv - - - - - - - - - - layout.xml - - - - - - - - Mage_PageCache_Model_Observer - processPreDispatch - - - - - - - - - - - - - - - - - - - - - - - - - - Mage_PageCache_Adminhtml - - - - - - - - - 0 - zend_page_cache - 3600 - - - - diff --git a/app/code/core/Mage/Paygate/etc/config.xml b/app/code/core/Mage/Paygate/etc/config.xml deleted file mode 100644 index 2575d59e6023f..0000000000000 --- a/app/code/core/Mage/Paygate/etc/config.xml +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - Mage_Paygate - - - - - - - - - - Mage_Paygate.csv - - - - - - - - /paygate/authorizenet_payment - - - - - - Mage_Paygate.csv - - - - - - - standard - - Mage_Paygate - paygate - - - - - - - - - - Mage_Paygate_Adminhtml - - - - - - - - - 0 - AE,VI,MC,DI - https://secure.authorize.net/gateway/transact.dll - 0 - 0 - - - Mage_Paygate_Model_Authorizenet - processing - authorize - 1 - Credit Card (Authorize.net) - - 0 - USD - 1 - - - - diff --git a/app/code/core/Mage/Payment/etc/adminhtml/acl.xml b/app/code/core/Mage/Payment/etc/adminhtml/acl.xml deleted file mode 100644 index 4a59706eed75d..0000000000000 --- a/app/code/core/Mage/Payment/etc/adminhtml/acl.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Payment/etc/config.xml b/app/code/core/Mage/Payment/etc/config.xml deleted file mode 100644 index 38b460c8a8891..0000000000000 --- a/app/code/core/Mage/Payment/etc/config.xml +++ /dev/null @@ -1,207 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - - Mage_Payment - - - - - - - - AE - American Express - 0 - - - VI - Visa - 10 - - - MC - MasterCard - 20 - - - DI - Discover - 30 - - - SM - Maestro/Switch - 40 - - - SO - Solo - 45 - - - JCB - JCB - 50 - - - OT - Other - 1000 - - - - - Offline Payment Methods - - - - - - - Mage_Payment_Model_Observer salesOrderBeforeSave - - - - - - - Mage_Payment_Model_Observer - beforeOrderPaymentSave - - - - - - - - - - - Mage_Payment.csv - - - - - - - - - Mage_Payment_Model_Observer prepareProductRecurringProfileOptions - - - - - - - - layout.xml - - - - - - - - - - Mage_Payment.csv - - - - - - - - - 0 - AE,VI,MC,DI - Mage_Payment_Model_Method_Ccsave - pending - Credit Card (saved) - 0 - offline - - - 1 - Mage_Payment_Model_Method_Checkmo - pending - Check / Money order - 0 - offline - - - 1 - Mage_Payment_Model_Method_Free - pending - No Payment Information Required - 0 - 1 - offline - - - 0 - Mage_Payment_Model_Method_Purchaseorder - pending - Purchase Order - 0 - offline - - - 0 - Mage_Payment_Model_Method_Banktransfer - pending - Bank Transfer Payment - 0 - offline - - - 0 - Mage_Payment_Model_Method_Cashondelivery - pending - Cash On Delivery - 0 - offline - - - - diff --git a/app/code/core/Mage/Payment/view/adminhtml/info/default.phtml b/app/code/core/Mage/Payment/view/adminhtml/info/default.phtml deleted file mode 100644 index ff4cebb2e6590..0000000000000 --- a/app/code/core/Mage/Payment/view/adminhtml/info/default.phtml +++ /dev/null @@ -1,45 +0,0 @@ - - -escapeHtml($this->getMethod()->getTitle()) ?> - -getSpecificInformation()):?> - - $_value):?> - - - - - -
    escapeHtml($_label)?>:getValueAsArray($_value, true), "\n"))?>
    - - -getChildHtml()?> diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Report/Grid.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Report/Grid.php deleted file mode 100644 index d975e2b0a4638..0000000000000 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Report/Grid.php +++ /dev/null @@ -1,144 +0,0 @@ - - */ -class Mage_Paypal_Block_Adminhtml_Settlement_Report_Grid extends Mage_Adminhtml_Block_Widget_Grid -{ - /** - * Retain filter parameters in session - * - * @var bool - */ - protected $_saveParametersInSession = true; - - /** - * Constructor - * Set main configuration of grid - */ - protected function _construct() - { - parent::_construct(); - $this->setId('settlementGrid'); - $this->setUseAjax(true); - } - - /** - * Prepare collection for grid - * @return Mage_Paypal_Block_Adminhtml_Settlement_Grid - */ - protected function _prepareCollection() - { - $collection = Mage::getResourceModel('Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection'); - $this->setCollection($collection); - if (!$this->getParam($this->getVarNameSort())) { - $collection->setOrder('row_id', 'desc'); - } - return parent::_prepareCollection(); - } - - /** - * Prepare grid columns - * @return Mage_Paypal_Block_Adminhtml_Settlement_Grid - */ - protected function _prepareColumns() - { - $settlement = Mage::getSingleton('Mage_Paypal_Model_Report_Settlement'); - $this->addColumn('report_date', array( - 'header' => $settlement->getFieldLabel('report_date'), - 'index' => 'report_date', - 'type' => 'date' - )); - $this->addColumn('account_id', array( - 'header' => $settlement->getFieldLabel('account_id'), - 'index' => 'account_id' - )); - $this->addColumn('transaction_id', array( - 'header' => $settlement->getFieldLabel('transaction_id'), - 'index' => 'transaction_id' - )); - $this->addColumn('invoice_id', array( - 'header' => $settlement->getFieldLabel('invoice_id'), - 'index' => 'invoice_id' - )); - $this->addColumn('paypal_reference_id', array( - 'header' => $settlement->getFieldLabel('paypal_reference_id'), - 'index' => 'paypal_reference_id' - )); - $this->addColumn('transaction_event_code', array( - 'header' => $settlement->getFieldLabel('transaction_event'), - 'index' => 'transaction_event_code', - 'type' => 'options', - 'options' => Mage::getModel('Mage_Paypal_Model_Report_Settlement_Row')->getTransactionEvents() - )); - $this->addColumn('transaction_initiation_date', array( - 'header' => $settlement->getFieldLabel('transaction_initiation_date'), - 'index' => 'transaction_initiation_date', - 'type' => 'datetime' - )); - $this->addColumn('transaction_completion_date', array( - 'header' => $settlement->getFieldLabel('transaction_completion_date'), - 'index' => 'transaction_completion_date', - 'type' => 'datetime' - )); - $this->addColumn('gross_transaction_amount', array( - 'header' => $settlement->getFieldLabel('gross_transaction_amount'), - 'index' => 'gross_transaction_amount', - 'type' => 'currency', - 'currency' => 'gross_transaction_currency', - )); - $this->addColumn('fee_amount', array( - 'header' => $settlement->getFieldLabel('fee_amount'), - 'index' => 'fee_amount', - 'type' => 'currency', - 'currency' => 'gross_transaction_currency', - )); - return parent::_prepareColumns(); - } - - /** - * Return grid URL - * @return string - */ - public function getGridUrl() - { - return $this->getUrl('*/*/grid'); - } - - /** - * Return item view URL - * @return string - */ - public function getRowUrl($item) - { - return $this->getUrl('*/*/details', array('id' => $item->getId())); - } -} diff --git a/app/code/core/Mage/Paypal/Controller/Express/Abstract.php b/app/code/core/Mage/Paypal/Controller/Express/Abstract.php deleted file mode 100644 index f8d744b86eb6c..0000000000000 --- a/app/code/core/Mage/Paypal/Controller/Express/Abstract.php +++ /dev/null @@ -1,493 +0,0 @@ - array($this->_configMethod)); - $this->_config = Mage::getModel($this->_configType, $parameters); - } - - /** - * Start Express Checkout by requesting initial token and dispatching customer to PayPal - */ - public function startAction() - { - try { - $this->_initCheckout(); - - if ($this->_getQuote()->getIsMultiShipping()) { - $this->_getQuote()->setIsMultiShipping(false); - $this->_getQuote()->removeAllAddresses(); - } - - $customer = Mage::getSingleton('Mage_Customer_Model_Session')->getCustomer(); - if ($customer && $customer->getId()) { - $this->_checkout->setCustomerWithAddressChange( - $customer, $this->_getQuote()->getBillingAddress(), $this->_getQuote()->getShippingAddress() - ); - } - - // billing agreement - $isBARequested = (bool)$this->getRequest() - ->getParam(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT); - if ($customer && $customer->getId()) { - $this->_checkout->setIsBillingAgreementRequested($isBARequested); - } - - // giropay - $this->_checkout->prepareGiropayUrls( - Mage::getUrl('checkout/onepage/success'), - Mage::getUrl('paypal/express/cancel'), - Mage::getUrl('checkout/onepage/success') - ); - - $token = $this->_checkout->start(Mage::getUrl('*/*/return'), Mage::getUrl('*/*/cancel')); - if ($token && $url = $this->_checkout->getRedirectUrl()) { - $this->_initToken($token); - $this->getResponse()->setRedirect($url); - return; - } - } catch (Mage_Core_Exception $e) { - $this->_getCheckoutSession()->addError($e->getMessage()); - } catch (Exception $e) { - $this->_getCheckoutSession()->addError($this->__('Unable to start Express Checkout.')); - Mage::logException($e); - } - - $this->_redirect('checkout/cart'); - } - - /** - * Return shipping options items for shipping address from request - */ - public function shippingOptionsCallbackAction() - { - try { - $quoteId = $this->getRequest()->getParam('quote_id'); - $this->_quote = Mage::getModel('Mage_Sales_Model_Quote')->load($quoteId); - $this->_initCheckout(); - $response = $this->_checkout->getShippingOptionsCallbackResponse($this->getRequest()->getParams()); - $this->getResponse()->setBody($response); - } catch (Exception $e) { - Mage::logException($e); - } - } - - /** - * Cancel Express Checkout - */ - public function cancelAction() - { - try { - $this->_initToken(false); - // TODO verify if this logic of order cancellation is deprecated - // if there is an order - cancel it - $orderId = $this->_getCheckoutSession()->getLastOrderId(); - $order = ($orderId) ? Mage::getModel('Mage_Sales_Model_Order')->load($orderId) : false; - if ($order && $order->getId() && $order->getQuoteId() == $this->_getCheckoutSession()->getQuoteId()) { - $order->cancel()->save(); - $this->_getCheckoutSession() - ->unsLastQuoteId() - ->unsLastSuccessQuoteId() - ->unsLastOrderId() - ->unsLastRealOrderId() - ->addSuccess($this->__('Express Checkout and Order have been canceled.')) - ; - } else { - $this->_getCheckoutSession()->addSuccess($this->__('Express Checkout has been canceled.')); - } - } catch (Mage_Core_Exception $e) { - $this->_getCheckoutSession()->addError($e->getMessage()); - } catch (Exception $e) { - $this->_getCheckoutSession()->addError($this->__('Unable to cancel Express Checkout.')); - Mage::logException($e); - } - - $this->_redirect('checkout/cart'); - } - - /** - * Return from PayPal and dispatch customer to order review page - */ - public function returnAction() - { - try { - $this->_initCheckout(); - $this->_checkout->returnFromPaypal($this->_initToken()); - $this->_redirect('*/*/review'); - return; - } - catch (Mage_Core_Exception $e) { - Mage::getSingleton('Mage_Checkout_Model_Session')->addError($e->getMessage()); - } - catch (Exception $e) { - Mage::getSingleton('Mage_Checkout_Model_Session')->addError($this->__('Unable to process Express Checkout approval.')); - Mage::logException($e); - } - $this->_redirect('checkout/cart'); - } - - /** - * Review order after returning from PayPal - */ - public function reviewAction() - { - try { - $this->_initCheckout(); - $this->_checkout->prepareOrderReview($this->_initToken()); - $this->loadLayout(); - $this->_initLayoutMessages('Mage_Paypal_Model_Session'); - $reviewBlock = $this->getLayout()->getBlock('paypal.express.review'); - $reviewBlock->setQuote($this->_getQuote()); - $reviewBlock->getChildBlock('details')->setQuote($this->_getQuote()); - if ($reviewBlock->getChildBlock('shipping_method')) { - $reviewBlock->getChildBlock('shipping_method')->setQuote($this->_getQuote()); - } - $this->renderLayout(); - return; - } - catch (Mage_Core_Exception $e) { - Mage::getSingleton('Mage_Checkout_Model_Session')->addError($e->getMessage()); - } - catch (Exception $e) { - Mage::getSingleton('Mage_Checkout_Model_Session')->addError( - $this->__('Unable to initialize Express Checkout review.') - ); - Mage::logException($e); - } - $this->_redirect('checkout/cart'); - } - - /** - * Dispatch customer back to PayPal for editing payment information - */ - public function editAction() - { - try { - $this->getResponse()->setRedirect($this->_config->getExpressCheckoutEditUrl($this->_initToken())); - } - catch (Mage_Core_Exception $e) { - $this->_getSession()->addError($e->getMessage()); - $this->_redirect('*/*/review'); - } - } - - /** - * Update shipping method (combined action for ajax and regular request) - */ - public function saveShippingMethodAction() - { - try { - $isAjax = $this->getRequest()->getParam('isAjax'); - $this->_initCheckout(); - $this->_checkout->updateShippingMethod($this->getRequest()->getParam('shipping_method')); - if ($isAjax) { - $this->loadLayout('paypal_express_review_details'); - $this->getResponse()->setBody($this->getLayout()->getBlock('root') - ->setQuote($this->_getQuote()) - ->toHtml()); - return; - } - } catch (Mage_Core_Exception $e) { - $this->_getSession()->addError($e->getMessage()); - } catch (Exception $e) { - $this->_getSession()->addError($this->__('Unable to update shipping method.')); - Mage::logException($e); - } - if ($isAjax) { - $this->getResponse()->setBody(''); - } else { - $this->_redirect('*/*/review'); - } - } - - /** - * Update Order (combined action for ajax and regular request) - */ - public function updateShippingMethodsAction() - { - try { - $this->_initCheckout(); - $this->_checkout->prepareOrderReview($this->_initToken()); - $this->loadLayout('paypal_express_review'); - - $this->getResponse()->setBody($this->getLayout()->getBlock('express.review.shipping.method') - ->setQuote($this->_getQuote()) - ->toHtml()); - return; - } catch (Mage_Core_Exception $e) { - $this->_getSession()->addError($e->getMessage()); - } catch (Exception $e) { - $this->_getSession()->addError($this->__('Unable to update Order data.')); - Mage::logException($e); - } - $this->getResponse()->setBody(''); - } - - /** - * Update Order (combined action for ajax and regular request) - */ - public function updateOrderAction() - { - try { - $isAjax = $this->getRequest()->getParam('isAjax'); - $this->_initCheckout(); - $this->_checkout->updateOrder($this->getRequest()->getParams()); - if ($isAjax) { - $this->loadLayout('paypal_express_review_details'); - $this->getResponse()->setBody($this->getLayout()->getBlock('root') - ->setQuote($this->_getQuote()) - ->toHtml()); - return; - } - } catch (Mage_Core_Exception $e) { - $this->_getSession()->addError($e->getMessage()); - } catch (Exception $e) { - $this->_getSession()->addError($this->__('Unable to update Order data.')); - Mage::logException($e); - } - if ($isAjax) { - $this->getResponse()->setBody(''); - } else { - $this->_redirect('*/*/review'); - } - } - - /** - * Submit the order - */ - public function placeOrderAction() - { - try { - $requiredAgreements = Mage::helper('Mage_Checkout_Helper_Data')->getRequiredAgreementIds(); - if ($requiredAgreements) { - $postedAgreements = array_keys($this->getRequest()->getPost('agreement', array())); - if (array_diff($requiredAgreements, $postedAgreements)) { - Mage::throwException(Mage::helper('Mage_Paypal_Helper_Data')->__('Please agree to all the terms and conditions before placing the order.')); - } - } - - $this->_initCheckout(); - $this->_checkout->place($this->_initToken()); - - // prepare session to success or cancellation page - $session = $this->_getCheckoutSession(); - $session->clearHelperData(); - - // "last successful quote" - $quoteId = $this->_getQuote()->getId(); - $session->setLastQuoteId($quoteId)->setLastSuccessQuoteId($quoteId); - - // an order may be created - $order = $this->_checkout->getOrder(); - if ($order) { - $session->setLastOrderId($order->getId()) - ->setLastRealOrderId($order->getIncrementId()); - // as well a billing agreement can be created - $agreement = $this->_checkout->getBillingAgreement(); - if ($agreement) { - $session->setLastBillingAgreementId($agreement->getId()); - } - } - - // recurring profiles may be created along with the order or without it - $profiles = $this->_checkout->getRecurringPaymentProfiles(); - if ($profiles) { - $ids = array(); - foreach($profiles as $profile) { - $ids[] = $profile->getId(); - } - $session->setLastRecurringProfileIds($ids); - } - - // redirect if PayPal specified some URL (for example, to Giropay bank) - $url = $this->_checkout->getRedirectUrl(); - if ($url) { - $this->getResponse()->setRedirect($url); - return; - } - $this->_initToken(false); // no need in token anymore - $this->_redirect('checkout/onepage/success'); - return; - } - catch (Mage_Core_Exception $e) { - $this->_getSession()->addError($e->getMessage()); - } - catch (Exception $e) { - $this->_getSession()->addError($this->__('Unable to place the order.')); - Mage::logException($e); - } - $this->_redirect('*/*/review'); - } - - /** - * Instantiate quote and checkout - * @throws Mage_Core_Exception - */ - private function _initCheckout() - { - $quote = $this->_getQuote(); - if (!$quote->hasItems() || $quote->getHasError()) { - $this->getResponse()->setHeader('HTTP/1.1','403 Forbidden'); - Mage::throwException(Mage::helper('Mage_Paypal_Helper_Data')->__('Unable to initialize Express Checkout.')); - } - - $parameters = array( - 'params' => array( - 'quote' => $quote, - 'config' => $this->_config, - ), - ); - $this->_checkout = Mage::getSingleton($this->_checkoutType, $parameters); - } - - /** - * Search for proper checkout token in request or session or (un)set specified one - * Combined getter/setter - * - * @param string $setToken - * @return Mage_Paypal_ExpressController|string - */ - protected function _initToken($setToken = null) - { - if (null !== $setToken) { - if (false === $setToken) { - // security measure for avoid unsetting token twice - if (!$this->_getSession()->getExpressCheckoutToken()) { - Mage::throwException($this->__('PayPal Express Checkout Token does not exist.')); - } - $this->_getSession()->unsExpressCheckoutToken(); - } else { - $this->_getSession()->setExpressCheckoutToken($setToken); - } - return $this; - } - if ($setToken = $this->getRequest()->getParam('token')) { - if ($setToken !== $this->_getSession()->getExpressCheckoutToken()) { - Mage::throwException($this->__('Wrong PayPal Express Checkout Token specified.')); - } - } else { - $setToken = $this->_getSession()->getExpressCheckoutToken(); - } - return $setToken; - } - - /** - * PayPal session instance getter - * - * @return Mage_PayPal_Model_Session - */ - private function _getSession() - { - return Mage::getSingleton('Mage_Paypal_Model_Session'); - } - - /** - * Return checkout session object - * - * @return Mage_Checkout_Model_Session - */ - private function _getCheckoutSession() - { - return Mage::getSingleton('Mage_Checkout_Model_Session'); - } - - /** - * Return checkout quote object - * - * @return Mage_Sale_Model_Quote - */ - private function _getQuote() - { - if (!$this->_quote) { - $this->_quote = $this->_getCheckoutSession()->getQuote(); - } - return $this->_quote; - } - - /** - * Redirect to login page - * - */ - public function redirectLogin() - { - $this->setFlag('', 'no-dispatch', true); - $this->getResponse()->setRedirect( - Mage::helper('Mage_Core_Helper_Url')->addRequestParam( - Mage::helper('Mage_Customer_Helper_Data')->getLoginUrl(), - array('context' => 'checkout') - ) - ); - } -} diff --git a/app/code/core/Mage/Paypal/etc/adminhtml/acl.xml b/app/code/core/Mage/Paypal/etc/adminhtml/acl.xml deleted file mode 100644 index 805ef1ab1f228..0000000000000 --- a/app/code/core/Mage/Paypal/etc/adminhtml/acl.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Paypal/etc/adminhtml/menu.xml b/app/code/core/Mage/Paypal/etc/adminhtml/menu.xml deleted file mode 100644 index 35ca92550ace0..0000000000000 --- a/app/code/core/Mage/Paypal/etc/adminhtml/menu.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - diff --git a/app/code/core/Mage/Paypal/etc/config.xml b/app/code/core/Mage/Paypal/etc/config.xml deleted file mode 100644 index 23e9711886695..0000000000000 --- a/app/code/core/Mage/Paypal/etc/config.xml +++ /dev/null @@ -1,285 +0,0 @@ - - - - - - 1.6.0.2 - true - core - - - - - - - - - - - - Mage_Paypal - Mage_Paypal_Model_Resource_Setup - - - - - - - - - - - - - - - - - SM - Switch/Maestro - 60 - - - SO - Solo - 61 - - - - - - - PayPal - - - - - - /paypal/express - /paypal/standard - - - - standard - - Mage_Paypal - paypal - - - - - - - - Mage_Paypal.csv - - - - - - - - layout.xml - - - - - paypal/express/callbackshippingoptions - - - - - - Mage_Paypal_Model_Observer - saveOrderAfterSubmit - - - - - - - Mage_Paypal_Model_Observer - setResponseAfterSaveOrder - - - - - - - - - - - Mage_Paypal.csv - - - - - - - - layout.xml - - - - - - - - - - - - dynamic - - - - - - - - - 1 - - - - - - Mage_Paypal_Model_Express - PayPal Express Checkout - Authorization - Mark - 1 - 1 - 1 - never - paypal - 3 - 29 - 1 - - - Mage_Paypal_Model_Direct - PayPal Direct Payment - Authorization - VI,MC - 1 - paypal - - - Mage_Paypal_Model_Standard - PayPal Website Payments Standard - Sale - 1 - paypal - - - PayPal Express Checkout Payflow Edition - Authorization - 1 - 1 - 1 - paypal - - - PayPal Direct Payment Payflow Edition - Authorization - VI,MC,AE - 1 - paypal - - - Mage_Paypal_Model_Payflowpro - Payflow Pro - Authorization - AE,VI - 1 - C - MEDIUM - - - paypal - - - 1 - 1 - Mage_Paypal_Model_Method_Agreement - PayPal Billing Agreement - paypal - - - Mage_Paypal_Model_Payflowlink - Authorization - HIGH - - paypal - Credit Card - - - Mage_Paypal_Model_Payflowadvanced - Authorization - HIGH - - paypal - Credit Card - PayPal - PayPal - PayPal - - - Mage_Paypal_Model_Hostedpro - Payment by cards or by PayPal account - Authorization - paypal - 0 - - - - - - - - Mage_Paypal_Model_Observer::fetchReports - - - - - - - - - - Mage_Paypal_Adminhtml - - - - - - diff --git a/app/code/core/Mage/Paypal/view/frontend/express/review/address.phtml b/app/code/core/Mage/Paypal/view/frontend/express/review/address.phtml deleted file mode 100644 index 0c99a344b8b26..0000000000000 --- a/app/code/core/Mage/Paypal/view/frontend/express/review/address.phtml +++ /dev/null @@ -1,154 +0,0 @@ - -getFieldNamePrefix();?> -
    -
      -
    • -
      - -
        -
      • getLayout()->createBlock('Mage_Customer_Block_Widget_Name')->setObject($this->getAddress()->getFirstname() ? $this->getAddress() : $this->getQuote()->getCustomer())->setForceUseCustomerRequiredAttributes(!$this->isCustomerLoggedIn())->setFieldIdFormat($prefix . ':%s')->setFieldNameFormat($prefix . '[%s]')->toHtml() ?>
      • -
      • -
        - -
        - -
        -
        - isCustomerLoggedIn() && !$this->getHideEmailAddress()): ?> -
        - -
        - -
        -
        - -
      • - helper('Mage_Customer_Helper_Address')->getAttributeValidationClass('street'); ?> -
      • - -
        - -
        -
      • - - helper('Mage_Customer_Helper_Address')->getStreetLines(); $_i <= $_n; $_i++): ?> -
      • -
        - -
        -
      • - - helper('Mage_Customer_Helper_Address')->isVatAttributeVisible()) : ?> -
      • - -
        - -
        -
      • - -
      • -
        - -
        - -
        -
        -
        - -
        - - -
        -
        -
      • -
      • -
        - -
        - -
        -
        -
        - -
        - getCountryHtmlSelect($prefix) ?> -
        -
        -
      • -
      • -
        - -
        - -
        -
        -
        - -
        - -
        -
        -
      • - getChildHtml('form.additional.info'); ?> - getShowAsShippingCheckbox()): ?> -
      • -
        -
        - getAddress()->getSameAsBilling()):?>checked="checked"/> -
        - -
        -
      • - -
      -
      -
    • -
    -
    - diff --git a/app/code/core/Mage/Paypal/view/frontend/hss/js.phtml b/app/code/core/Mage/Paypal/view/frontend/hss/js.phtml deleted file mode 100644 index f8a21c7eae376..0000000000000 --- a/app/code/core/Mage/Paypal/view/frontend/hss/js.phtml +++ /dev/null @@ -1,66 +0,0 @@ - -
    - diff --git a/app/code/core/Mage/Paypal/view/frontend/hss/review/button.phtml b/app/code/core/Mage/Paypal/view/frontend/hss/review/button.phtml deleted file mode 100644 index a8fdb59acf29f..0000000000000 --- a/app/code/core/Mage/Paypal/view/frontend/hss/review/button.phtml +++ /dev/null @@ -1,27 +0,0 @@ - - diff --git a/app/code/core/Mage/Paypal/view/frontend/layout.xml b/app/code/core/Mage/Paypal/view/frontend/layout.xml deleted file mode 100644 index 03d3325b691f0..0000000000000 --- a/app/code/core/Mage/Paypal/view/frontend/layout.xml +++ /dev/null @@ -1,240 +0,0 @@ - - - - - - - 1 - - - - - - 1 - - - - - - - - - - - - - - - - - - defaultMage_Checkout_Block_Cart_Item_Renderer - groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped - configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable - - - - - - - Mage_Paypal::review.js - - - - - - - - - defaultMage_Checkout_Block_Cart_Item_Renderer - groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped - configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable - - - - - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - after - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/PaypalUk/etc/config.xml b/app/code/core/Mage/PaypalUk/etc/config.xml deleted file mode 100644 index 07f5242190213..0000000000000 --- a/app/code/core/Mage/PaypalUk/etc/config.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - - - - Mage_PaypalUk - - - - - - - /paypaluk/express - - - - standard - - Mage_PaypalUk - paypaluk - - - - - - - - Mage_PaypalUk.csv - - - - - - - - layout.xml - - - - - - - - - - Mage_PaypalUk.csv - - - - - - - - - Mage_PaypalUk_Model_Express - - - Mage_PaypalUk_Model_Direct - - - - diff --git a/app/code/core/Mage/PaypalUk/view/frontend/layout.xml b/app/code/core/Mage/PaypalUk/view/frontend/layout.xml deleted file mode 100644 index 5f6f5973a84a4..0000000000000 --- a/app/code/core/Mage/PaypalUk/view/frontend/layout.xml +++ /dev/null @@ -1,151 +0,0 @@ - - - - - - - 1 - - - - - 1 - - - - - - - - - - - - - - paypaluk - - defaultMage_Checkout_Block_Cart_Item_Renderer - groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped - configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable - - - - - - - Mage_Paypal::review.js - - - - - - - defaultMage_Checkout_Block_Cart_Item_Renderer - groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped - configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable - - - - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - after - - - - - - - - - - diff --git a/app/code/core/Mage/Persistent/etc/adminhtml/acl.xml b/app/code/core/Mage/Persistent/etc/adminhtml/acl.xml deleted file mode 100644 index 367ca4c34abc8..0000000000000 --- a/app/code/core/Mage/Persistent/etc/adminhtml/acl.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Persistent/etc/config.xml b/app/code/core/Mage/Persistent/etc/config.xml deleted file mode 100644 index 4b9eee2632179..0000000000000 --- a/app/code/core/Mage/Persistent/etc/config.xml +++ /dev/null @@ -1,300 +0,0 @@ - - - - - - 1.0.0.0 - true - core - - - - - - - - - - - Mage_Persistent - - - - - - - /persistent/index/saveMethod - - - - standard - - Mage_Persistent - persistent - - - - - - - layout.xml - - - - - - - - Mage_Persistent_Model_Observer_Session - synchronizePersistentOnLogin - - - - - - - Mage_Persistent_Model_Observer_Session - synchronizePersistentOnLogout - - - - - - - Mage_Persistent_Model_Observer_Session - synchronizePersistentInfo - - - - - - - Mage_Persistent_Model_Observer_Session - setRememberMeCheckedStatus - - - - - - - Mage_Persistent_Model_Observer_Session - setRememberMeCheckedStatus - - - Mage_Persistent_Model_Observer - customerAuthenticatedEvent - - - - - - - Mage_Persistent_Model_Observer - applyPersistentData - - - - - - - Mage_Persistent_Model_Observer - emulateQuote - - - Mage_Persistent_Model_Observer_Session - renewCookie - - - Mage_Persistent_Model_Observer - checkExpirePersistentQuote - - - Mage_Persistent_Model_Observer - emulateCustomer - - - - - - - Mage_Persistent_Model_Observer - disableGuestCheckout - - - - - - - Mage_Persistent_Model_Observer - customerAuthenticatedEvent - - - - - - - Mage_Persistent_Model_Observer - preventClearCheckoutSession - - - - - - - Mage_Persistent_Model_Observer - makePersistentQuoteGuest - - - - - - - Mage_Persistent_Model_Observer - setQuotePersistentData - - - - - - - Mage_Persistent_Model_Observer - setLoadPersistentQuote - - - - - - - Mage_Persistent_Model_Observer_Session - setRememberMeCheckedStatus - - - - - - - Mage_Persistent_Model_Observer - removePersistentCookie - - - - - - - Mage_Persistent_Model_Observer - preventExpressCheckout - - - - - - - Mage_Persistent_Model_Observer - preventExpressCheckout - - - - - - - Mage_Persistent_Model_Observer - preventExpressCheckout - - - - - - - Mage_Persistent_Model_Observer - preventExpressCheckout - - - - - - - Mage_Persistent_Model_Observer - applyBlockPersistentData - - - - - - - Mage_Persistent_Model_Observer - updateCustomerCookies - - - - - - - - - Mage_Persistent.csv - - - - - - - - - - - Mage_Persistent.csv - - - - - - - - - 0 - 31536000 - 1 - 1 - 1 - 1 - - - - - - - - 0 0 * * * - - - Mage_Persistent_Model_Observer::clearExpiredCronJob - - - - - diff --git a/app/code/core/Mage/Persistent/view/frontend/checkout/onepage/billing.phtml b/app/code/core/Mage/Persistent/view/frontend/checkout/onepage/billing.phtml deleted file mode 100644 index 2f777b7c96880..0000000000000 --- a/app/code/core/Mage/Persistent/view/frontend/checkout/onepage/billing.phtml +++ /dev/null @@ -1,241 +0,0 @@ - -
    -
    -
      - customerHasAddresses()): ?> -
    • - -
      - getAddressesHtmlSelect('billing') ?> -
      -
    • - -
    • customerHasAddresses()): ?> style="display:none;"> -
      - -
        -
      • getLayout()->createBlock('Mage_Customer_Block_Widget_Name')->setObject($this->getAddress()->getFirstname() ? $this->getAddress() : $this->getQuote()->getCustomer())->setForceUseCustomerRequiredAttributes(!$this->isCustomerLoggedIn())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
      • -
      • -
        - -
        - -
        -
        - isCustomerLoggedIn()): ?> -
        - -
        - -
        -
        - -
      • - helper('Mage_Customer_Helper_Address')->getAttributeValidationClass('street'); ?> -
      • - -
        - -
        -
      • - - helper('Mage_Customer_Helper_Address')->getStreetLines(); $_i <= $_n; $_i++): ?> -
      • -
        - -
        -
      • - - helper('Mage_Customer_Helper_Address')->isVatAttributeVisible()) : ?> -
      • - -
        - -
        -
      • - -
      • -
        - -
        - -
        -
        -
        - -
        - - -
        -
        -
      • -
      • -
        - -
        - -
        -
        -
        - -
        - getCountryHtmlSelect('billing') ?> -
        -
        -
      • -
      • -
        - -
        - -
        -
        -
        - -
        - -
        -
        -
      • - isCustomerLoggedIn()): ?> - - getLayout()->createBlock('Mage_Customer_Block_Widget_Dob') ?> - getLayout()->createBlock('Mage_Customer_Block_Widget_Gender') ?> - isEnabled() || $_gender->isEnabled()): ?> -
      • - isEnabled()): ?> -
        - setDate($this->getQuote()->getCustomerDob())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?> -
        - - isEnabled()): ?> -
        - setGender($this->getQuote()->getCustomerGender())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?> -
        - -
      • - - - isTaxvatEnabled()):?> -
      • getTaxvatHtml() ?>
      • - - -
      • -
        - -
        - -
        -
        -
        - -
        - -
        -
        -
      • - getChildHtml('persistent.remember.me'); ?> - - isCustomerLoggedIn() && $this->customerHasAddresses()):?> -
      • - getAddress()->getSaveInAddressBook()):?> checked="checked" class="checkbox" /> -
      • - -
      • - - getChildHtml('form.additional.info'); ?> -
      - getChildHtml('persistent.remember.me.tooltip'); ?> -
      -
    • - canShip()): ?> -
    • - isUseBillingAddressForShipping()) {?> checked="checked" title="__('Ship to this address') ?>" onclick="$('shipping:same_as_billing').checked = true;" class="radio" />
    • -
    • - isUseBillingAddressForShipping()) {?> checked="checked" title="__('Ship to different address') ?>" onclick="$('shipping:same_as_billing').checked = false;" class="radio" /> -
    • - -
    - canShip()): ?> - - -
    -

    __('* Required Fields') ?>

    - - -
    -
    -
    - - \ No newline at end of file diff --git a/app/code/core/Mage/Persistent/view/frontend/checkout/onepage/login.phtml b/app/code/core/Mage/Persistent/view/frontend/checkout/onepage/login.phtml deleted file mode 100644 index 18efcac5ce551..0000000000000 --- a/app/code/core/Mage/Persistent/view/frontend/checkout/onepage/login.phtml +++ /dev/null @@ -1,154 +0,0 @@ - - -
    - getChildHtml('login_before')?> -
    -

    isAllowedGuestCheckout() ): ?>__('Checkout as a Guest or Register') ?>__('Register to Create an Account') ?>

    - isAllowedGuestCheckout() ): ?> -

    __('Register with us for future convenience:') ?>

    - -

    __('Register and save time!') ?>
    - __('Register with us for future convenience:') ?>

    -
      -
    • __('Fast and easy check out') ?>
    • -
    • __('Easy access to your order history and status') ?>
    • -
    - - isAllowedGuestCheckout() ): ?> -
      - isAllowedGuestCheckout() ): ?> -
    • - getQuote()->getCheckoutMethod()==Mage_Checkout_Model_Type_Onepage::METHOD_GUEST): ?> checked="checked" class="radio" /> -
    • - -
    • - getQuote()->getCheckoutMethod()==Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER || !$this->isAllowedGuestCheckout()): ?> checked="checked" class="radio" /> -
    • -
    -

    __('Register and save time!') ?>

    -

    __('Register with us for future convenience:') ?>

    -
      -
    • __('Fast and easy check out') ?>
    • -
    • __('Easy access to your order history and status') ?>
    • -
    - - - -
    -
    -

    __('Login') ?>

    - getMessagesBlock()->getGroupedHtml() ?> -
    -
    -

    __('Already registered?') ?>

    -

    __('Please log in below:') ?>

    -
      -
    • - -
      - -
      -
    • -
    • - -
      - -
      -
    • - getChildHtml('login.form.additional.info'); ?> - getChildHtml('persistent.remember.me'); ?> -
    - -
    -
    -
    -
    -
    -
    -
    -

     

    - isAllowedGuestCheckout()): ?> - - helper('Mage_Checkout_Helper_Data')->isCustomerMustBeLogged()): ?> - - -
    - -
    - -
    -
    -
    -
    -

    __('* Required Fields') ?>

    - __('Forgot your password?') ?> - -
    -
    -
    - -getRequest()->getParam('register'); - if ($registerParam || $registerParam === ''): -?> - - diff --git a/app/code/core/Mage/Persistent/view/frontend/customer/form/login.phtml b/app/code/core/Mage/Persistent/view/frontend/customer/form/login.phtml deleted file mode 100644 index 6861d70fbd6e8..0000000000000 --- a/app/code/core/Mage/Persistent/view/frontend/customer/form/login.phtml +++ /dev/null @@ -1,103 +0,0 @@ - - - diff --git a/app/code/core/Mage/Poll/etc/adminhtml/acl.xml b/app/code/core/Mage/Poll/etc/adminhtml/acl.xml deleted file mode 100644 index d9654e818fe56..0000000000000 --- a/app/code/core/Mage/Poll/etc/adminhtml/acl.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Poll/etc/adminhtml/menu.xml b/app/code/core/Mage/Poll/etc/adminhtml/menu.xml deleted file mode 100644 index 00166060b76dd..0000000000000 --- a/app/code/core/Mage/Poll/etc/adminhtml/menu.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - diff --git a/app/code/core/Mage/Poll/etc/config.xml b/app/code/core/Mage/Poll/etc/config.xml deleted file mode 100644 index f7d2e421a67cb..0000000000000 --- a/app/code/core/Mage/Poll/etc/config.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - standard - - Mage_Poll - poll - - - - - - - - Mage_Poll.csv - - - - - - - - layout.xml - - - - - - - - - - Mage_Poll.csv - - - - - - - - - - Mage_Poll - - - - - diff --git a/app/code/core/Mage/ProductAlert/Block/Email/Stock.php b/app/code/core/Mage/ProductAlert/Block/Email/Stock.php deleted file mode 100644 index 31f38116d77ae..0000000000000 --- a/app/code/core/Mage/ProductAlert/Block/Email/Stock.php +++ /dev/null @@ -1,83 +0,0 @@ - - */ -class Mage_ProductAlert_Block_Email_Stock extends Mage_ProductAlert_Block_Email_Abstract -{ - - protected $_template = 'email/stock.phtml'; - - /** - * Product thumbnail image url getter - * - * @param Mage_Core_Model_Product $product - * @return string - */ - public function getThumbnailUrl($product) - { - return (string) $this->helper('Mage_Catalog_Helper_Image')->init($product, 'thumbnail')->resize($this->getThumbnailSize()); - } - - /** - * Thumbnail image size getter - * - * @return int - */ - public function getThumbnailSize() - { - return $this->getVar('product_thumbnail_image_size', 'Mage_Catalog'); - } - - /** - * Retrive unsubscribe url for product - * - * @param int $productId - * @return string - */ - public function getProductUnsubscribeUrl($productId) - { - $params = $this->_getUrlParams(); - $params['product'] = $productId; - return $this->getUrl('productalert/unsubscribe/stock', $params); - } - - /** - * Retrieve unsubscribe url for all products - * - * @return string - */ - public function getUnsubscribeUrl() - { - return $this->getUrl('productalert/unsubscribe/stockAll', $this->_getUrlParams()); - } -} diff --git a/app/code/core/Mage/ProductAlert/etc/config.xml b/app/code/core/Mage/ProductAlert/etc/config.xml deleted file mode 100644 index fc536e02b86f7..0000000000000 --- a/app/code/core/Mage/ProductAlert/etc/config.xml +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - - Mage_ProductAlert - - - - - - - - - - - Mage_ProductAlert.csv - - - - - - - - - - - Mage_ProductAlert.csv - - - - - - - - layout.xml - - - - - - standard - - Mage_ProductAlert - productalert - - - - - - - - 0 - 0 - catalog_productalert_email_price_template - catalog_productalert_email_stock_template - general - - - - catalog_productalert_cron_error_email_template - general - - - - - - - - Mage_ProductAlert_Model_Observer::process - - - - - diff --git a/app/code/core/Mage/Rating/etc/adminhtml/acl.xml b/app/code/core/Mage/Rating/etc/adminhtml/acl.xml deleted file mode 100644 index feceedd12039a..0000000000000 --- a/app/code/core/Mage/Rating/etc/adminhtml/acl.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Rating/etc/config.xml b/app/code/core/Mage/Rating/etc/config.xml deleted file mode 100644 index 4b1cb0c1fc8f5..0000000000000 --- a/app/code/core/Mage/Rating/etc/config.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - 1.6.0.1 - true - core - - - - - - - - - - - Mage_Rating - - - - - - - - - - Mage_Rating.csv - - - - - - - - - - - Mage_Rating.csv - - - - - - - - - Mage_Rating_Model_Observer - processProductAfterDeleteEvent - - - - - - diff --git a/app/code/core/Mage/Reports/etc/adminhtml/acl.xml b/app/code/core/Mage/Reports/etc/adminhtml/acl.xml deleted file mode 100644 index c6ad442048997..0000000000000 --- a/app/code/core/Mage/Reports/etc/adminhtml/acl.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Reports/etc/adminhtml/menu.xml b/app/code/core/Mage/Reports/etc/adminhtml/menu.xml deleted file mode 100644 index 7214464e3d592..0000000000000 --- a/app/code/core/Mage/Reports/etc/adminhtml/menu.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Reports/etc/config.xml b/app/code/core/Mage/Reports/etc/config.xml deleted file mode 100644 index 84be33d2f5d71..0000000000000 --- a/app/code/core/Mage/Reports/etc/config.xml +++ /dev/null @@ -1,194 +0,0 @@ - - - - - - 1.6.0.0.2 - true - core - - - - - - - - - - - - - Mage_Reports - - - - - - - - Mage_Reports_Model_Event_Observer - eventClean - - - - - - - - - - layout.xml - - - - - - - - Mage_Reports.csv - - - - - - - - - - - Mage_Reports.csv - - - - - - - - layout.xml - - - - - - - - Mage_Reports_Model_Event_Observer - catalogProductCompareRemoveProduct - - - - - - - Mage_Reports_Model_Event_Observer - customerLogin - - - - - - - Mage_Reports_Model_Event_Observer - customerLogout - - - - - - - Mage_Reports_Model_Event_Observer - catalogProductView - - - - - - - Mage_Reports_Model_Event_Observer - sendfriendProduct - - - - - - - Mage_Reports_Model_Event_Observer - catalogProductCompareAddProduct - - - - - - - Mage_Reports_Model_Event_Observer - catalogProductCompareClear - - - - - - - Mage_Reports_Model_Event_Observer - checkoutCartAddProduct - - - - - - - Mage_Reports_Model_Event_Observer - wishlistAddProduct - - - - - - - Mage_Reports_Model_Event_Observer - wishlistShare - - - - - - - - - website - 5 - 5 - - - - - 1,1 - 1 - - - - diff --git a/app/code/core/Mage/Reports/view/adminhtml/grid.phtml b/app/code/core/Mage/Reports/view/adminhtml/grid.phtml deleted file mode 100644 index aeca15f579185..0000000000000 --- a/app/code/core/Mage/Reports/view/adminhtml/grid.phtml +++ /dev/null @@ -1,149 +0,0 @@ - -getColumns()); -?> -getCollection()): ?> -canDisplayContainer()): ?> -
    - - getMessagesBlock()->getGroupedHtml() ?> - -getStoreSwitcherVisibility() || $this->getDateFilterVisibility()): ?> - getStoreSwitcherVisibility()): ?> - getStoreSwitcherHtml() ?> - -
    - getChildBlock('grid.export')): ?> -
    - getChildHtml('grid.export');?> -
    - - - getDateFilterVisibility()): ?> -
    -
    - - -
    -
    - -
    - - -
    -
    - -
    - __('Show By') ?>: - - getRefreshButtonHtml() ?> -
    - -
    - -
    - -
    -
    - - - getChildHtml('grid.columnSet'); ?> -
    -
    -
    -
    -canDisplayContainer()): ?> - - - \ No newline at end of file diff --git a/app/code/core/Mage/Reports/view/adminhtml/layout.xml b/app/code/core/Mage/Reports/view/adminhtml/layout.xml deleted file mode 100644 index 3cbd9943bb1c6..0000000000000 --- a/app/code/core/Mage/Reports/view/adminhtml/layout.xml +++ /dev/null @@ -1,615 +0,0 @@ - - - - - - - - 0 - 0 - gridReport - Mage_Reports_Model_Resource_Report_Collection - - - - 0 - - */*/* - - null - - - - - - - - - */*/exportCsv - - - - */*/exportExcel - - - - - - - - 0 - No records found for this period. - No records found for this period. - - - -
    Period
    - 100px - 0 - text - period - period - 1 - Total -
    -
    -
    -
    -
    -
    - - - - - - gridOrdersCustomer - Mage_Reports_Model_Resource_Customer_Orders_Collection_Initial - - - - - - - */*/exportOrdersCsv - - - */*/exportOrdersExcel - - - - - - - 1 - - - -
    Customer Name
    - 0 - text - name - name -
    -
    - - -
    Number of Orders
    - 100px - 0 - number - orders_count - sum - orders_count -
    -
    - - -
    Average Order Amount
    - 200px - 0 - currency - orders_sum_amount/orders_count - orders_avg_amount - orders_avg_amount -
    -
    - - -
    Total Order Amount
    - 200px - right - 0 - currency - sum - orders_sum_amount - orders_sum_amount -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - gridProductsSold - Mage_Reports_Model_Resource_Product_Sold_Collection_Initial - - - - - - - */*/exportSoldCsv - - - */*/exportSoldExcel - - - - - - - report_product_sold - 1 - - - -
    Product Name
    - text - order_items_name - name -
    -
    - - -
    Quantity Ordered
    - 120px - right - sum - number - ordered_qty - ordered_qty - sum -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - gridTotalsCustomer - Mage_Reports_Model_Resource_Customer_Totals_Collection_Initial - - - - - - - */*/exportTotalsCsv - - - */*/exportTotalsExcel - - - - - - - 1 - gridTotalsCustomerSet - - - - - - - - - - - - - - - - - - - - - - - - - - gridAccounts - Mage_Reports_Model_Resource_Accounts_Collection_Initial - - - - - - - */*/exportAccountsCsv - - - */*/exportAccountsExcel - - - - - - - gridAccounts - 1 - - - -
    Number of New Accounts
    - accounts - sum - number - accounts -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - customers_grid - review_cnt - desc - Mage_Reports_Model_Resource_Review_Customer_Collection - - - - - - */*/exportCustomerCsv - - - - */*/exportCustomerExcel - - - - - - - - 0 - customers_grid - - */catalog_product_review - - getCustomerId - - - - - -
    Customer Name
    - customer_name - text - customer_name - Guest -
    -
    - - -
    Number Of Reviews
    - 40px - right - text - review_cnt -
    -
    - - -
    Action
    - 100px - center - 0 - 0 - 1 - Mage_Adminhtml_Block_Report_Grid_Column_Renderer_Customer - action -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - gridProducts - review_cnt - desc - Mage_Reports_Model_Resource_Review_Product_Collection - - - - - - */*/exportProductCsv - - - - */*/exportProductExcel - - - - - - - - 0 - gridProducts - - */catalog_product_review - - getrId - - - - - -
    ID
    - 50px - entity_id - text - entity_id -
    -
    - - -
    Product Name
    - text - name -
    -
    - - -
    Number of Reviews
    - 50px - right - review_cnt - review_cnt -
    -
    - - -
    Avg. Rating
    - 50px - right - avg_rating - avg_rating -
    -
    - - -
    Avg. Approved Rating
    - 50px - right - avg_rating_approved - avg_rating_approved -
    -
    - - -
    Last Review
    - 150px - datetime - last_created - last_created -
    -
    - - -
    Action
    - 100px - center - 0 - 0 - Mage_Adminhtml_Block_Report_Grid_Column_Renderer_Product - action - 1 -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - gridRefreshStatistics - 0 - 0 - 0 - Mage_Reports_Model_Resource_Refresh_Collection - - - - id - code - 1 - - - - */*/refreshLifetime - Are you sure you want to refresh lifetime statistics? There can be performance impact during this operation. - - - - */*/refreshRecent - Are you sure you want to refresh statistics for last day? - 1 - - - - - - - 0 - gridRefreshStatistics - - - -
    Report
    - string - 150 - 0 - report - report -
    -
    - - -
    Description
    - string - 0 - comment - comment -
    -
    - - -
    Updated At
    - datetime - 200 - 0 - updated_at - updated_at - undefined -
    -
    -
    -
    -
    -
    -
    -
    diff --git a/app/code/core/Mage/Review/etc/adminhtml/acl.xml b/app/code/core/Mage/Review/etc/adminhtml/acl.xml deleted file mode 100644 index 25b6297f78170..0000000000000 --- a/app/code/core/Mage/Review/etc/adminhtml/acl.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Review/etc/adminhtml/menu.xml b/app/code/core/Mage/Review/etc/adminhtml/menu.xml deleted file mode 100644 index d3fc17a608b47..0000000000000 --- a/app/code/core/Mage/Review/etc/adminhtml/menu.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Review/etc/config.xml b/app/code/core/Mage/Review/etc/config.xml deleted file mode 100644 index c60a6b301f8ac..0000000000000 --- a/app/code/core/Mage/Review/etc/config.xml +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - - Mage_Review - - - - - - - - - - Mage_Review.csv - - - - - - - - - Mage_Review_Model_Observer - processProductAfterDeleteEvent - - - - - - - - - standard - - Mage_Review - review - - - - - - - - Mage_Review.csv - - - - - - - - layout.xml - - - - - - - - model - Mage_Review_Model_Observer - tagProductCollectionLoadAfter - - - - - - - model - Mage_Review_Model_Observer - catalogBlockProductCollectionBeforeToHtml - - - - - - /review/customer/ - - - - - - 1 - - - - diff --git a/app/code/core/Mage/Review/view/frontend/layout.xml b/app/code/core/Mage/Review/view/frontend/layout.xml deleted file mode 100644 index d73fb3aff3cbb..0000000000000 --- a/app/code/core/Mage/Review/view/frontend/layout.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - reviewsreview/customer - - - - - - - - - - - - - - - - - - - - - - - - varien/product.js - varien/configurable.js - - - - - - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Rss/etc/adminhtml/acl.xml b/app/code/core/Mage/Rss/etc/adminhtml/acl.xml deleted file mode 100644 index a3c6639d1549c..0000000000000 --- a/app/code/core/Mage/Rss/etc/adminhtml/acl.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Rss/etc/config.xml b/app/code/core/Mage/Rss/etc/config.xml deleted file mode 100644 index c61f4a0caf128..0000000000000 --- a/app/code/core/Mage/Rss/etc/config.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - - - - - - - - - Mage_Rss.csv - - - - - - - - layout.xml - - - - - - - - - - Mage_Rss.csv - - - - - - /rss/catalog/review - /rss/order/new - /rss/catalog/notifystock - - - - standard - - Mage_Rss - rss - - - - - - - layout.xml - - - - - diff --git a/app/code/core/Mage/Rule/etc/config.xml b/app/code/core/Mage/Rule/etc/config.xml deleted file mode 100644 index c2a4346de5ece..0000000000000 --- a/app/code/core/Mage/Rule/etc/config.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - - Mage_Rule.csv - - - - - - - - - - - Mage_Rule.csv - - - - - - diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/Grid.php b/app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/Grid.php deleted file mode 100644 index baa08ce4806aa..0000000000000 --- a/app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/Grid.php +++ /dev/null @@ -1,155 +0,0 @@ - - */ -class Mage_Sales_Block_Adminhtml_Billing_Agreement_Grid extends Mage_Adminhtml_Block_Widget_Grid -{ - /** - * Set grid params - */ - protected function _construct() - { - parent::_construct(); - $this->setId('billing_agreements'); - $this->setUseAjax(true); - $this->setDefaultSort('agreement_id'); - $this->setDefaultDir('DESC'); - $this->setSaveParametersInSession(true); - } - - /** - * Retrieve grid url - * - * @return string - */ - public function getGridUrl() - { - return $this->getUrl('*/sales_billing_agreement/grid', array('_current' => true)); - } - - /** - * Retrieve row url - * - * @return string - */ - public function getRowUrl($item) - { - return $this->getUrl('*/sales_billing_agreement/view', array('agreement' => $item->getAgreementId())); - } - - /** - * Prepare collection for grid - * - * @return Mage_Adminhtml_Block_Widget_Grid - */ - protected function _prepareCollection() - { - $collection = Mage::getResourceModel('Mage_Sales_Model_Resource_Billing_Agreement_Collection') - ->addCustomerDetails(); - $this->setCollection($collection); - return parent::_prepareCollection(); - } - - /** - * Add columns to grid - * - * @return Mage_Adminhtml_Block_Widget_Grid - */ - protected function _prepareColumns() - { - $this->addColumn('agreement_id', array( - 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('ID'), - 'index' => 'agreement_id', - 'type' => 'text' - )); - - $this->addColumn('customer_email', array( - 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Customer Email'), - 'index' => 'customer_email', - 'type' => 'text' - )); - - $this->addColumn('customer_firstname', array( - 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Customer Name'), - 'index' => 'customer_firstname', - 'type' => 'text', - 'escape' => true - )); - - $this->addColumn('customer_lastname', array( - 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Customer Last Name'), - 'index' => 'customer_lastname', - 'type' => 'text', - 'escape' => true - )); - - $this->addColumn('method_code', array( - 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Payment Method'), - 'index' => 'method_code', - 'type' => 'options', - 'options' => Mage::helper('Mage_Payment_Helper_Data')->getAllBillingAgreementMethods() - )); - - $this->addColumn('reference_id', array( - 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Reference ID'), - 'index' => 'reference_id', - 'type' => 'text' - )); - - $this->addColumn('status', array( - 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Status'), - 'index' => 'status', - 'type' => 'options', - 'options' => Mage::getSingleton('Mage_Sales_Model_Billing_Agreement')->getStatusesArray() - )); - - $this->addColumn('created_at', array( - 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Created At'), - 'index' => 'agreement_created_at', - 'width' => 1, - 'type' => 'datetime', - 'align' => 'center', - 'default' => $this->__('N/A'), - 'html_decorators' => array('nobr') - )); - - $this->addColumn('updated_at', array( - 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Updated At'), - 'index' => 'agreement_updated_at', - 'width' => 1, - 'type' => 'datetime', - 'align' => 'center', - 'default' => $this->__('N/A'), - 'html_decorators' => array('nobr') - )); - - return parent::_prepareColumns(); - } -} diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/Edit/Form.php b/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/Edit/Form.php deleted file mode 100644 index 1714903667360..0000000000000 --- a/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/Edit/Form.php +++ /dev/null @@ -1,240 +0,0 @@ -_parentElement = $element; - return $this; - } - - /** - * Setter for current product - * - * @param Mage_Catalog_Model_Product $product - */ - public function setProductEntity(Mage_Catalog_Model_Product $product) - { - $this->_product = $product; - return $this; - } - - /** - * Instantiate a recurring payment profile to use it as a helper - */ - protected function _construct() - { - $this->_profile = Mage::getSingleton('Mage_Sales_Model_Recurring_Profile'); - return parent::_construct(); - } - - /** - * Prepare and render the form - * - * @return string - */ - protected function _toHtml() - { - // TODO: implement $this->_isReadonly setting - $form = $this->_prepareForm(); - if ($this->_product && $this->_product->getRecurringProfile()) { - $form->setValues($this->_product->getRecurringProfile()); - } - return $form->toHtml(); - } - - /** - * Instantiate form and fields - * - * @return Varien_Data_Form - */ - protected function _prepareForm() - { - $form = new Varien_Data_Form(); - $form->setFieldsetRenderer( - $this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset') - ); - $form->setFieldsetElementRenderer($this->getLayout() - ->createBlock('Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element')); - - /** - * if there is a parent element defined, it will be replaced by a hidden element with the same name - * and overriden by the form elements - * It is needed to maintain HTML consistency of the parent element's form - */ - if ($this->_parentElement) { - $form->setHtmlIdPrefix($this->_parentElement->getHtmlId()) - ->setFieldNameSuffix($this->_parentElement->getName()); - $form->addField('', 'hidden', array('name' => '')); - } - - $noYes = array(Mage::helper('Mage_Adminhtml_Helper_Data')->__('No'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Yes')); - - // schedule - $schedule = $form->addFieldset('schedule_fieldset', array( - 'legend' => Mage::helper('Mage_Sales_Helper_Data')->__('Schedule'), - 'disabled' => $this->_isReadOnly - )); - $schedule->addField('start_date_is_editable', 'select', array( - 'name' => 'start_date_is_editable', - 'label' => Mage::helper('Mage_Sales_Helper_Data')->__('Customer Can Define Start Date'), - 'comment' => Mage::helper('Mage_Sales_Helper_Data')->__('Whether buyer can define the date when billing for the profile begins.'), - 'options' => $noYes, - 'disabled' => $this->_isReadOnly - )); - $this->_addField($schedule, 'schedule_description'); - $this->_addField($schedule, 'suspension_threshold'); - $this->_addField($schedule, 'bill_failed_later', array('options' => $noYes), 'select'); - - // billing - $billing = $form->addFieldset('billing_fieldset', array( - 'legend' => Mage::helper('Mage_Sales_Helper_Data')->__('Billing'), - 'disabled' => $this->_isReadOnly - )); - $this->_addField($billing, 'period_unit', array( - 'options' => $this->_getPeriodUnitOptions(Mage::helper('Mage_Adminhtml_Helper_Data')->__('-- Please Select --')), - ), 'select'); - $this->_addField($billing, 'period_frequency'); - $this->_addField($billing, 'period_max_cycles'); - - // trial - $trial = $form->addFieldset('trial_fieldset', array( - 'legend' => Mage::helper('Mage_Sales_Helper_Data')->__('Trial Period'), - 'disabled' => $this->_isReadOnly - )); - $this->_addField($trial, 'trial_period_unit', array( - 'options' => $this->_getPeriodUnitOptions(Mage::helper('Mage_Adminhtml_Helper_Data')->__('-- Not Selected --')), - ), 'select'); - $this->_addField($trial, 'trial_period_frequency'); - $this->_addField($trial, 'trial_period_max_cycles'); - $this->_addField($trial, 'trial_billing_amount'); - - // initial fees - $initial = $form->addFieldset('initial_fieldset', array( - 'legend' => Mage::helper('Mage_Sales_Helper_Data')->__('Initial Fees'), - 'disabled' => $this->_isReadOnly - )); - $this->_addField($initial, 'init_amount'); - $this->_addField($initial, 'init_may_fail', array('options' => $noYes), 'select'); - - return $form; - } - - /** - * Add a field to the form or fieldset - * Form and fieldset have same abstract - * - * @param Varien_Data_Form|Varien_Data_Form_Element_Fieldset $formOrFieldset - * @param string $elementName - * @param array $options - * @param string $type - * @return Varien_Data_Form_Element_Abstract - */ - protected function _addField($formOrFieldset, $elementName, $options = array(), $type = 'text') - { - $options = array_merge($options, array( - 'name' => $elementName, - 'label' => $this->_profile->getFieldLabel($elementName), - 'note' => $this->_profile->getFieldComment($elementName), - 'disabled' => $this->_isReadOnly, - )); - if (in_array($elementName, array('period_unit', 'period_frequency'))) { - $options['required'] = true; - } - return $formOrFieldset->addField($elementName, $type, $options); - } - - /** - * Getter for period unit options with "Please Select" label - * - * @return array - */ - protected function _getPeriodUnitOptions($emptyLabel) - { - return array_merge(array('' => $emptyLabel), - $this->_profile->getAllPeriodUnits() - ); - } - - /** - * Set readonly flag - * - * @param boolean $isReadonly - * @return Mage_Sales_Block_Adminhtml_Recurring_Profile_Edit_Form - */ - public function setIsReadonly($isReadonly) - { - $this->_isReadOnly = $isReadonly; - return $this; - } - - /** - * Get readonly flag - * - * @return boolean - */ - public function getIsReadonly() - { - return $this->_isReadOnly; - } -} diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Config.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo/Config.php deleted file mode 100644 index 485399f8146e9..0000000000000 --- a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Config.php +++ /dev/null @@ -1,50 +0,0 @@ - - */ -class Mage_Sales_Model_Order_Creditmemo_Config extends Mage_Sales_Model_Order_Total_Config_Base -{ - /** - * Cache key for collectors - * - * @var string - */ - protected $_collectorsCacheKey = 'sorted_order_creditmemo_collectors'; - - /** - * Constructor - */ - public function __construct() - { - parent::__construct(Mage::getConfig()->getNode('global/sales/order_creditmemo')); - } -} diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice/Config.php b/app/code/core/Mage/Sales/Model/Order/Invoice/Config.php deleted file mode 100644 index b5858875c641a..0000000000000 --- a/app/code/core/Mage/Sales/Model/Order/Invoice/Config.php +++ /dev/null @@ -1,50 +0,0 @@ - - */ -class Mage_Sales_Model_Order_Invoice_Config extends Mage_Sales_Model_Order_Total_Config_Base -{ - /** - * Cache key for collectors - * - * @var string - */ - protected $_collectorsCacheKey = 'sorted_order_invoice_collectors'; - - /** - * Constructor - */ - public function __construct() - { - parent::__construct(Mage::getConfig()->getNode('global/sales/order_invoice')); - } -} diff --git a/app/code/core/Mage/Sales/Model/Quote/Address.php b/app/code/core/Mage/Sales/Model/Quote/Address.php deleted file mode 100644 index 935efaad3a029..0000000000000 --- a/app/code/core/Mage/Sales/Model/Quote/Address.php +++ /dev/null @@ -1,1185 +0,0 @@ - - */ -class Mage_Sales_Model_Quote_Address extends Mage_Customer_Model_Address_Abstract -{ - const RATES_FETCH = 1; - const RATES_RECALCULATE = 2; - - /** - * Prefix of model events - * - * @var string - */ - protected $_eventPrefix = 'sales_quote_address'; - - /** - * Name of event object - * - * @var string - */ - protected $_eventObject = 'quote_address'; - - /** - * Quote object - * - * @var Mage_Sales_Model_Quote - */ - protected $_items = null; - - /** - * Quote object - * - * @var Mage_Sales_Model_Quote - */ - protected $_quote = null; - - /** - * Sales Quote address rates - * - * @var Mage_Sales_Model_Quote_Address_Rate - */ - protected $_rates = null; - - /** - * Total models collector - * - * @var Mage_Sales_Model_Quote_Address_Totla_Collector - */ - protected $_totalCollector = null; - - /** - * Total data as array - * - * @var array - */ - protected $_totals = array(); - - protected $_totalAmounts = array(); - protected $_baseTotalAmounts = array(); - - /** - * Whether to segregate by nominal items only - * - * @var bool - */ - protected $_nominalOnly = null; - - /** - * Initialize resource - */ - protected function _construct() - { - $this->_init('Mage_Sales_Model_Resource_Quote_Address'); - } - - /** - * Initialize quote identifier before save - * - * @return Mage_Sales_Model_Quote_Address - */ - protected function _beforeSave() - { - parent::_beforeSave(); - if ($this->getQuote()) { - $quoteId = $this->getQuote()->getId(); - if ($quoteId) { - $this->setQuoteId($quoteId); - } else { - $this->_dataSaveAllowed = false; - } - $this->setCustomerId($this->getQuote()->getCustomerId()); - /** - * Init customer address id if customer address is assigned - */ - if ($this->getCustomerAddress()) { - $this->setCustomerAddressId($this->getCustomerAddress()->getId()); - } - } - if ($this->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_SHIPPING - && $this->getSameAsBilling() === null - ) { - $this->setSameAsBilling(1); - } - return $this; - } - - /** - * Save child collections - * - * @return Mage_Sales_Model_Quote_Address - */ - protected function _afterSave() - { - parent::_afterSave(); - if (null !== $this->_items) { - $this->getItemsCollection()->save(); - } - if (null !== $this->_rates) { - $this->getShippingRatesCollection()->save(); - } - return $this; - } - - /** - * Declare adress quote model object - * - * @param Mage_Sales_Model_Quote $quote - * @return Mage_Sales_Model_Quote_Address - */ - public function setQuote(Mage_Sales_Model_Quote $quote) - { - $this->_quote = $quote; - $this->setQuoteId($quote->getId()); - return $this; - } - - /** - * Retrieve quote object - * - * @return Mage_Sales_Model_Quote - */ - public function getQuote() - { - return $this->_quote; - } - - /** - * Import quote address data from customer address object - * - * @param Mage_Customer_Model_Address $address - * @return Mage_Sales_Model_Quote_Address - */ - public function importCustomerAddress(Mage_Customer_Model_Address $address) - { - Mage::helper('Mage_Core_Helper_Data')->copyFieldset('customer_address', 'to_quote_address', $address, $this); - $email = null; - if ($address->hasEmail()) { - $email = $address->getEmail(); - } - elseif ($address->getCustomer()) { - $email = $address->getCustomer()->getEmail(); - } - if ($email) { - $this->setEmail($email); - } - return $this; - } - - /** - * Export data to customer address object - * - * @return Mage_Customer_Model_Address - */ - public function exportCustomerAddress() - { - $address = Mage::getModel('Mage_Customer_Model_Address'); - Mage::helper('Mage_Core_Helper_Data')->copyFieldset('sales_convert_quote_address', 'to_customer_address', $this, $address); - return $address; - } - - /** - * Import address data from order address - * - * @param Mage_Sales_Model_Order_Address $address - * @return Mage_Sales_Model_Quote_Address - */ - public function importOrderAddress(Mage_Sales_Model_Order_Address $address) - { - $this->setAddressType($address->getAddressType()) - ->setCustomerId($address->getCustomerId()) - ->setCustomerAddressId($address->getCustomerAddressId()) - ->setEmail($address->getEmail()); - - Mage::helper('Mage_Core_Helper_Data')->copyFieldset('sales_convert_order_address', 'to_quote_address', $address, $this); - - return $this; - } - - /** - * Convert object to array - * - * @param array $arrAttributes - * @return array - */ - public function toArray(array $arrAttributes = array()) - { - $arr = parent::toArray($arrAttributes); - $arr['rates'] = $this->getShippingRatesCollection()->toArray($arrAttributes); - $arr['items'] = $this->getItemsCollection()->toArray($arrAttributes); - foreach ($this->getTotals() as $k=>$total) { - $arr['totals'][$k] = $total->toArray(); - } - return $arr; - } - - /** - * Retrieve address items collection - * - * @return Mage_Eav_Model_Entity_Collection_Abstract - */ - public function getItemsCollection() - { - if (is_null($this->_items)) { - $this->_items = Mage::getModel('Mage_Sales_Model_Quote_Address_Item')->getCollection() - ->setAddressFilter($this->getId()); - - if ($this->getId()) { - foreach ($this->_items as $item) { - $item->setAddress($this); - } - } - } - return $this->_items; - } - - /** - * Get all available address items - * - * @return array - */ - public function getAllItems() - { - // We calculate item list once and cache it in three arrays - all items, nominal, non-nominal - $cachedItems = $this->_nominalOnly ? 'nominal' : ($this->_nominalOnly === false ? 'nonnominal' : 'all'); - $key = 'cached_items_' . $cachedItems; - if (!$this->hasData($key)) { - // For compatibility we will use $this->_filterNominal to divide nominal items from non-nominal - // (because it can be overloaded) - // So keep current flag $this->_nominalOnly and restore it after cycle - $wasNominal = $this->_nominalOnly; - $this->_nominalOnly = true; // Now $this->_filterNominal() will return positive values for nominal items - - $quoteItems = $this->getQuote()->getItemsCollection(); - $addressItems = $this->getItemsCollection(); - - $items = array(); - $nominalItems = array(); - $nonNominalItems = array(); - if ($this->getQuote()->getIsMultiShipping() && $addressItems->count() > 0) { - foreach ($addressItems as $aItem) { - if ($aItem->isDeleted()) { - continue; - } - - if (!$aItem->getQuoteItemImported()) { - $qItem = $this->getQuote()->getItemById($aItem->getQuoteItemId()); - if ($qItem) { - $aItem->importQuoteItem($qItem); - } - } - $items[] = $aItem; - if ($this->_filterNominal($aItem)) { - $nominalItems[] = $aItem; - } else { - $nonNominalItems[] = $aItem; - } - } - } else { - /* - * For virtual quote we assign items only to billing address, otherwise - only to shipping address - */ - $addressType = $this->getAddressType(); - $canAddItems = $this->getQuote()->isVirtual() - ? ($addressType == self::TYPE_BILLING) - : ($addressType == self::TYPE_SHIPPING); - - if ($canAddItems) { - foreach ($quoteItems as $qItem) { - if ($qItem->isDeleted()) { - continue; - } - $items[] = $qItem; - if ($this->_filterNominal($qItem)) { - $nominalItems[] = $qItem; - } else { - $nonNominalItems[] = $qItem; - } - } - } - } - - // Cache calculated lists - $this->setData('cached_items_all', $items); - $this->setData('cached_items_nominal', $nominalItems); - $this->setData('cached_items_nonnominal', $nonNominalItems); - - $this->_nominalOnly = $wasNominal; // Restore original value before we changed it - } - - $items = $this->getData($key); - return $items; - } - - /** - * Getter for all non-nominal items - * - * @return array - */ - public function getAllNonNominalItems() - { - $this->_nominalOnly = false; - $result = $this->getAllItems(); - $this->_nominalOnly = null; - return $result; - } - - /** - * Getter for all nominal items - * - * @return array - */ - public function getAllNominalItems() - { - $this->_nominalOnly = true; - $result = $this->getAllItems(); - $this->_nominalOnly = null; - return $result; - } - - /** - * Segregate by nominal criteria - * - * true: get nominals only - * false: get non-nominals only - * null: get all - * - * @param Mage_Sales_Model_Quote_Item_Abstract - * @return Mage_Sales_Model_Quote_Item_Abstract|false - */ - protected function _filterNominal($item) - { - return (null === $this->_nominalOnly) - || ((false === $this->_nominalOnly) && !$item->isNominal()) - || ((true === $this->_nominalOnly) && $item->isNominal()) - ? $item : false; - } - - /** - * Retrieve all visible items - * - * @return array - */ - public function getAllVisibleItems() - { - $items = array(); - foreach ($this->getAllItems() as $item) { - if (!$item->getParentItemId()) { - $items[] = $item; - } - } - return $items; - } - - /** - * Retrieve item quantity by id - * - * @param int $itemId - * @return float|int - */ - public function getItemQty($itemId = 0) - { - if ($this->hasData('item_qty')) { - return $this->getData('item_qty'); - } - - $qty = 0; - if ($itemId == 0) { - foreach ($this->getAllItems() as $item) { - $qty += $item->getQty(); - } - } else { - $item = $this->getItemById($itemId); - if ($item) { - $qty = $item->getQty(); - } - } - return $qty; - } - - /** - * Check Quote address has Items - * - * @return bool - */ - public function hasItems() - { - return sizeof($this->getAllItems())>0; - } - - /** - * Get address item object by id without - * - * @param int $itemId - * @return Mage_Sales_Model_Quote_Address_Item - */ - public function getItemById($itemId) - { - foreach ($this->getItemsCollection() as $item) { - if ($item->getId()==$itemId) { - return $item; - } - } - return false; - } - - /** - * Get prepared not deleted item - * - * @param $itemId - * @return Mage_Sales_Model_Quote_Address_Item - */ - public function getValidItemById($itemId) - { - foreach ($this->getAllItems() as $item) { - if ($item->getId()==$itemId) { - return $item; - } - } - return false; - } - - /** - * Retrieve item object by quote item Id - * - * @param int $itemId - * @return Mage_Sales_Model_Quote_Address_Item - */ - public function getItemByQuoteItemId($itemId) - { - foreach ($this->getItemsCollection() as $item) { - if ($item->getQuoteItemId()==$itemId) { - return $item; - } - } - return false; - } - - /** - * Remove item from collection - * - * @param int $itemId - * @return Mage_Sales_Model_Quote_Address - */ - public function removeItem($itemId) - { - $item = $this->getItemById($itemId); - if ($item) { - $item->isDeleted(true); - } - return $this; - } - - /** - * Add item to address - * - * @param Mage_Sales_Model_Quote_Item_Abstract $item - * @param int $qty - * @return Mage_Sales_Model_Quote_Address - */ - public function addItem(Mage_Sales_Model_Quote_Item_Abstract $item, $qty=null) - { - if ($item instanceof Mage_Sales_Model_Quote_Item) { - if ($item->getParentItemId()) { - return $this; - } - $addressItem = Mage::getModel('Mage_Sales_Model_Quote_Address_Item') - ->setAddress($this) - ->importQuoteItem($item); - $this->getItemsCollection()->addItem($addressItem); - - if ($item->getHasChildren()) { - foreach ($item->getChildren() as $child) { - $addressChildItem = Mage::getModel('Mage_Sales_Model_Quote_Address_Item') - ->setAddress($this) - ->importQuoteItem($child) - ->setParentItem($addressItem); - $this->getItemsCollection()->addItem($addressChildItem); - } - } - } - else { - $addressItem = $item; - $addressItem->setAddress($this); - if (!$addressItem->getId()) { - $this->getItemsCollection()->addItem($addressItem); - } - } - - if ($qty) { - $addressItem->setQty($qty); - } - return $this; - } - - /** - * Retrieve collection of quote shipping rates - * - * @return Mage_Eav_Model_Entity_Collection_Abstract - */ - public function getShippingRatesCollection() - { - if (is_null($this->_rates)) { - $this->_rates = Mage::getModel('Mage_Sales_Model_Quote_Address_Rate')->getCollection() - ->setAddressFilter($this->getId()); - if ($this->getQuote()->hasNominalItems(false)) { - $this->_rates->setFixedOnlyFilter(true); - } - if ($this->getId()) { - foreach ($this->_rates as $rate) { - $rate->setAddress($this); - } - } - } - return $this->_rates; - } - - /** - * Retrieve all address shipping rates - * - * @return array - */ - public function getAllShippingRates() - { - $rates = array(); - foreach ($this->getShippingRatesCollection() as $rate) { - if (!$rate->isDeleted()) { - $rates[] = $rate; - } - } - return $rates; - } - - /** - * Retrieve all grouped shipping rates - * - * @return array - */ - public function getGroupedAllShippingRates() - { - $rates = array(); - foreach ($this->getShippingRatesCollection() as $rate) { - if (!$rate->isDeleted() && $rate->getCarrierInstance()) { - if (!isset($rates[$rate->getCarrier()])) { - $rates[$rate->getCarrier()] = array(); - } - - $rates[$rate->getCarrier()][] = $rate; - $rates[$rate->getCarrier()][0]->carrier_sort_order = $rate->getCarrierInstance()->getSortOrder(); - } - } - uasort($rates, array($this, '_sortRates')); - return $rates; - } - - /** - * Sort rates recursive callback - * - * @param array $a - * @param array $b - * @return int - */ - protected function _sortRates($a, $b) - { - if ((int)$a[0]->carrier_sort_order < (int)$b[0]->carrier_sort_order) { - return -1; - } - elseif ((int)$a[0]->carrier_sort_order > (int)$b[0]->carrier_sort_order) { - return 1; - } - else { - return 0; - } - } - - /** - * Retrieve shipping rate by identifier - * - * @param int $rateId - * @return Mage_Sales_Model_Quote_Address_Rate | false - */ - public function getShippingRateById($rateId) - { - foreach ($this->getShippingRatesCollection() as $rate) { - if ($rate->getId()==$rateId) { - return $rate; - } - } - return false; - } - - /** - * Retrieve shipping rate by code - * - * @param string $code - * @return Mage_Sales_Model_Quote_Address_Rate - */ - public function getShippingRateByCode($code) - { - foreach ($this->getShippingRatesCollection() as $rate) { - if ($rate->getCode()==$code) { - return $rate; - } - } - return false; - } - - /** - * Mark all shipping rates as deleted - * - * @return Mage_Sales_Model_Quote_Address - */ - public function removeAllShippingRates() - { - foreach ($this->getShippingRatesCollection() as $rate) { - $rate->isDeleted(true); - } - return $this; - } - - /** - * Add shipping rate - * - * @param Mage_Sales_Model_Quote_Address_Rate $rate - * @return Mage_Sales_Model_Quote_Address - */ - public function addShippingRate(Mage_Sales_Model_Quote_Address_Rate $rate) - { - $rate->setAddress($this); - $this->getShippingRatesCollection()->addItem($rate); - return $this; - } - - /** - * Collecting shipping rates by address - * - * @return Mage_Sales_Model_Quote_Address - */ - public function collectShippingRates() - { - if (!$this->getCollectShippingRates()) { - return $this; - } - - $this->setCollectShippingRates(false); - - $this->removeAllShippingRates(); - - if (!$this->getCountryId()) { - return $this; - } - - $found = $this->requestShippingRates(); - if (!$found) { - $this->setShippingAmount(0) - ->setBaseShippingAmount(0) - ->setShippingMethod('') - ->setShippingDescription(''); - } - - return $this; - } - - /** - * Request shipping rates for entire address or specified address item - * Returns true if current selected shipping method code corresponds to one of the found rates - * - * @param Mage_Sales_Model_Quote_Item_Abstract $item - * @return bool - */ - public function requestShippingRates(Mage_Sales_Model_Quote_Item_Abstract $item = null) - { - /** @var $request Mage_Shipping_Model_Rate_Request */ - $request = Mage::getModel('Mage_Shipping_Model_Rate_Request'); - $request->setAllItems($item ? array($item) : $this->getAllItems()); - $request->setDestCountryId($this->getCountryId()); - $request->setDestRegionId($this->getRegionId()); - $request->setDestRegionCode($this->getRegionCode()); - /** - * need to call getStreet with -1 - * to get data in string instead of array - */ - $request->setDestStreet($this->getStreet(-1)); - $request->setDestCity($this->getCity()); - $request->setDestPostcode($this->getPostcode()); - $request->setPackageValue($item ? $item->getBaseRowTotal() : $this->getBaseSubtotal()); - $packageValueWithDiscount = $item - ? $item->getBaseRowTotal() - $item->getBaseDiscountAmount() - : $this->getBaseSubtotalWithDiscount(); - $request->setPackageValueWithDiscount($packageValueWithDiscount); - $request->setPackageWeight($item ? $item->getRowWeight() : $this->getWeight()); - $request->setPackageQty($item ? $item->getQty() : $this->getItemQty()); - - /** - * Need for shipping methods that use insurance based on price of physical products - */ - $packagePhysicalValue = $item - ? $item->getBaseRowTotal() - : $this->getBaseSubtotal() - $this->getBaseVirtualAmount(); - $request->setPackagePhysicalValue($packagePhysicalValue); - - $request->setFreeMethodWeight($item ? 0 : $this->getFreeMethodWeight()); - - /** - * Store and website identifiers need specify from quote - */ - /*$request->setStoreId(Mage::app()->getStore()->getId()); - $request->setWebsiteId(Mage::app()->getStore()->getWebsiteId());*/ - - $request->setStoreId($this->getQuote()->getStore()->getId()); - $request->setWebsiteId($this->getQuote()->getStore()->getWebsiteId()); - $request->setFreeShipping($this->getFreeShipping()); - /** - * Currencies need to convert in free shipping - */ - $request->setBaseCurrency($this->getQuote()->getStore()->getBaseCurrency()); - $request->setPackageCurrency($this->getQuote()->getStore()->getCurrentCurrency()); - $request->setLimitCarrier($this->getLimitCarrier()); - - $request->setBaseSubtotalInclTax($this->getBaseSubtotalInclTax()); - - $result = Mage::getModel('Mage_Shipping_Model_Shipping')->collectRates($request)->getResult(); - - $found = false; - if ($result) { - $shippingRates = $result->getAllRates(); - - foreach ($shippingRates as $shippingRate) { - $rate = Mage::getModel('Mage_Sales_Model_Quote_Address_Rate') - ->importShippingRate($shippingRate); - if (!$item) { - $this->addShippingRate($rate); - } - - if ($this->getShippingMethod() == $rate->getCode()) { - if ($item) { - $item->setBaseShippingAmount($rate->getPrice()); - } else { - /** - * possible bug: this should be setBaseShippingAmount(), - * see Mage_Sales_Model_Quote_Address_Total_Shipping::collect() - * where this value is set again from the current specified rate price - * (looks like a workaround for this bug) - */ - $this->setShippingAmount($rate->getPrice()); - } - - $found = true; - } - } - } - return $found; - } - - /** - * Get totals collector model - * - * @return Mage_Sales_Model_Quote_Address_Total_Collector - */ - public function getTotalCollector() - { - if ($this->_totalCollector === null) { - $this->_totalCollector = Mage::getSingleton( - 'Mage_Sales_Model_Quote_Address_Total_Collector', - array('store' => $this->getQuote()->getStore()) - ); - } - return $this->_totalCollector; - } - - /** - * Collect address totals - * - * @return Mage_Sales_Model_Quote_Address - */ - public function collectTotals() - { - Mage::dispatchEvent($this->_eventPrefix . '_collect_totals_before', array($this->_eventObject => $this)); - foreach ($this->getTotalCollector()->getCollectors() as $model) { - $model->collect($this); - } - Mage::dispatchEvent($this->_eventPrefix . '_collect_totals_after', array($this->_eventObject => $this)); - return $this; - } - - /** - * Get address totals as array - * - * @return array - */ - public function getTotals() - { - foreach ($this->getTotalCollector()->getRetrievers() as $model) { - $model->fetch($this); - } - return $this->_totals; - } - - /** - * Add total data or model - * - * @param Mage_Sales_Model_Quote_Total|array $total - * @return Mage_Sales_Model_Quote_Address - */ - public function addTotal($total) - { - if (is_array($total)) { - $totalInstance = Mage::getModel('Mage_Sales_Model_Quote_Address_Total') - ->setData($total); - } elseif ($total instanceof Mage_Sales_Model_Quote_Total) { - $totalInstance = $total; - } - $totalInstance->setAddress($this); - $this->_totals[$totalInstance->getCode()] = $totalInstance; - return $this; - } - - /** - * Rewrite clone method - * - * @return Mage_Sales_Model_Quote_Address - */ - public function __clone() - { - $this->setId(null); - } - - /** - * Validate minimum amount - * - * @return bool - */ - public function validateMinimumAmount() - { - $storeId = $this->getQuote()->getStoreId(); - if (!Mage::getStoreConfigFlag('sales/minimum_order/active', $storeId)) { - return true; - } - - if ($this->getQuote()->getIsVirtual() && $this->getAddressType() == self::TYPE_SHIPPING) { - return true; - } - elseif (!$this->getQuote()->getIsVirtual() && $this->getAddressType() != self::TYPE_SHIPPING) { - return true; - } - - $amount = Mage::getStoreConfig('sales/minimum_order/amount', $storeId); - if ($this->getBaseSubtotalWithDiscount() < $amount) { - return false; - } - return true; - } - - /** - * Retrieve applied taxes - * - * @return array - */ - public function getAppliedTaxes() - { - return unserialize($this->getData('applied_taxes')); - } - - /** - * Set applied taxes - * - * @param array $data - * @return Mage_Sales_Model_Quote_Address - */ - public function setAppliedTaxes($data) - { - return $this->setData('applied_taxes', serialize($data)); - } - - /** - * Set shipping amount - * - * @param float $value - * @param bool $alreadyExclTax - * @return Mage_Sales_Model_Quote_Address - */ - public function setShippingAmount($value, $alreadyExclTax = false) - { - return $this->setData('shipping_amount', $value); - } - - /** - * Set base shipping amount - * - * @param float $value - * @param bool $alreadyExclTax - * @return Mage_Sales_Model_Quote_Address - */ - public function setBaseShippingAmount($value, $alreadyExclTax = false) - { - return $this->setData('base_shipping_amount', $value); - } - - /** - * Set total amount value - * - * @param string $code - * @param float $amount - * @return Mage_Sales_Model_Quote_Address - */ - public function setTotalAmount($code, $amount) - { - $this->_totalAmounts[$code] = $amount; - if ($code != 'subtotal') { - $code = $code.'_amount'; - } - $this->setData($code, $amount); - return $this; - } - - /** - * Set total amount value in base store currency - * - * @param string $code - * @param float $amount - * @return Mage_Sales_Model_Quote_Address - */ - public function setBaseTotalAmount($code, $amount) - { - $this->_baseTotalAmounts[$code] = $amount; - if ($code != 'subtotal') { - $code = $code.'_amount'; - } - $this->setData('base_'.$code, $amount); - return $this; - } - - /** - * Add amount total amount value - * - * @param string $code - * @param float $amount - * @return Mage_Sales_Model_Quote_Address - */ - public function addTotalAmount($code, $amount) - { - $amount = $this->getTotalAmount($code)+$amount; - $this->setTotalAmount($code, $amount); - return $this; - } - - /** - * Add amount total amount value in base store currency - * - * @param string $code - * @param float $amount - * @return Mage_Sales_Model_Quote_Address - */ - public function addBaseTotalAmount($code, $amount) - { - $amount = $this->getBaseTotalAmount($code)+$amount; - $this->setBaseTotalAmount($code, $amount); - return $this; - } - - /** - * Get total amount value by code - * - * @param string $code - * @return float - */ - public function getTotalAmount($code) - { - if (isset($this->_totalAmounts[$code])) { - return $this->_totalAmounts[$code]; - } - return 0; - } - - /** - * Get total amount value by code in base store curncy - * - * @param string $code - * @return float - */ - public function getBaseTotalAmount($code) - { - if (isset($this->_baseTotalAmounts[$code])) { - return $this->_baseTotalAmounts[$code]; - } - return 0; - } - - /** - * Get all total amount values - * - * @return array - */ - public function getAllTotalAmounts() - { - return $this->_totalAmounts; - } - - /** - * Get all total amount values in base currency - * - * @return array - */ - public function getAllBaseTotalAmounts() - { - return $this->_baseTotalAmounts; - } - - /** - * Get subtotal amount with applied discount in base currency - * - * @return float - */ - public function getBaseSubtotalWithDiscount() - { - return $this->getBaseSubtotal()+$this->getBaseDiscountAmount(); - } - - /** - * Get subtotal amount with applied discount - * - * @return float - */ - public function getSubtotalWithDiscount() - { - return $this->getSubtotal()+$this->getDiscountAmount(); - } -} diff --git a/app/code/core/Mage/Sales/Model/Quote/Item.php b/app/code/core/Mage/Sales/Model/Quote/Item.php deleted file mode 100644 index 4171690f5a6a8..0000000000000 --- a/app/code/core/Mage/Sales/Model/Quote/Item.php +++ /dev/null @@ -1,911 +0,0 @@ - - */ -class Mage_Sales_Model_Quote_Item extends Mage_Sales_Model_Quote_Item_Abstract -{ - /** - * Prefix of model events names - * - * @var string - */ - protected $_eventPrefix = 'sales_quote_item'; - - /** - * Parameter name in event - * - * In observe method you can use $observer->getEvent()->getObject() in this case - * - * @var string - */ - protected $_eventObject = 'item'; - - /** - * Quote model object - * - * @var Mage_Sales_Model_Quote - */ - protected $_quote; - - /** - * Item options array - * - * @var array - */ - protected $_options = array(); - - /** - * Item options by code cache - * - * @var array - */ - protected $_optionsByCode = array(); - - /** - * Not Represent options - * - * @var array - */ - protected $_notRepresentOptions = array('info_buyRequest'); - - /** - * Flag stating that options were successfully saved - * - */ - protected $_flagOptionsSaved = null; - - /** - * Array of errors associated with this quote item - * - * @var Mage_Sales_Model_Status_List - */ - protected $_errorInfos; - - /** - * @param Mage_Core_Model_Event_Manager $eventDispatcher - * @param Mage_Core_Model_Cache $cacheManager - * @param Mage_Sales_Model_Status_ListFactory $statusListFactory - * @param Mage_Core_Model_Resource_Abstract $resource - * @param Varien_Data_Collection_Db $resourceCollection - * @param array $data - */ - public function __construct( - Mage_Core_Model_Event_Manager $eventDispatcher, - Mage_Core_Model_Cache $cacheManager, - Mage_Sales_Model_Status_ListFactory $statusListFactory, - Mage_Core_Model_Resource_Abstract $resource = null, - Varien_Data_Collection_Db $resourceCollection = null, - array $data = array() - ) { - $this->_errorInfos = $statusListFactory->create(); - parent::__construct($eventDispatcher, $cacheManager, $resource, $resourceCollection, $data); - } - - - /** - * Initialize resource model - * - */ - protected function _construct() - { - $this->_init('Mage_Sales_Model_Resource_Quote_Item'); - } - - /** - * Quote Item Before Save prepare data process - * - * @return Mage_Sales_Model_Quote_Item - */ - protected function _beforeSave() - { - parent::_beforeSave(); - $this->setIsVirtual($this->getProduct()->getIsVirtual()); - if ($this->getQuote()) { - $this->setQuoteId($this->getQuote()->getId()); - } - return $this; - } - - /** - * Retrieve address model - * - * @return Mage_Sales_Model_Quote_Address - */ - public function getAddress() - { - if ($this->getQuote()->getItemsQty() == $this->getQuote()->getVirtualItemsQty()) { - $address = $this->getQuote()->getBillingAddress(); - } else { - $address = $this->getQuote()->getShippingAddress(); - } - - return $address; - } - - /** - * Declare quote model object - * - * @param Mage_Sales_Model_Quote $quote - * @return Mage_Sales_Model_Quote_Item - */ - public function setQuote(Mage_Sales_Model_Quote $quote) - { - $this->_quote = $quote; - $this->setQuoteId($quote->getId()); - return $this; - } - - /** - * Retrieve quote model object - * - * @return Mage_Sales_Model_Quote - */ - public function getQuote() - { - return $this->_quote; - } - - /** - * Prepare quantity - * - * @param float|int $qty - * @return int|float - */ - protected function _prepareQty($qty) - { - $qty = Mage::app()->getLocale()->getNumber($qty); - $qty = ($qty > 0) ? $qty : 1; - return $qty; - } - - /** - * Adding quantity to quote item - * - * @param float $qty - * @return Mage_Sales_Model_Quote_Item - */ - public function addQty($qty) - { - $oldQty = $this->getQty(); - $qty = $this->_prepareQty($qty); - - /** - * We can't modify quontity of existing items which have parent - * This qty declared just once duering add process and is not editable - */ - if (!$this->getParentItem() || !$this->getId()) { - $this->setQtyToAdd($qty); - $this->setQty($oldQty+$qty); - } - return $this; - } - - /** - * Declare quote item quantity - * - * @param float $qty - * @return Mage_Sales_Model_Quote_Item - */ - public function setQty($qty) - { - $qty = $this->_prepareQty($qty); - $oldQty = $this->_getData('qty'); - $this->setData('qty', $qty); - - Mage::dispatchEvent('sales_quote_item_qty_set_after', array('item'=>$this)); - - if ($this->getQuote() && $this->getQuote()->getIgnoreOldQty()) { - return $this; - } - if ($this->getUseOldQty()) { - $this->setData('qty', $oldQty); - } - - return $this; - } - - /** - * Retrieve option product with Qty - * - * Return array - * 'qty' => the qty - * 'product' => the product model - * - * @return array - */ - public function getQtyOptions() - { - $qtyOptions = $this->getData('qty_options'); - if (is_null($qtyOptions)) { - $productIds = array(); - $qtyOptions = array(); - foreach ($this->getOptions() as $option) { - /** @var $option Mage_Sales_Model_Quote_Item_Option */ - if (is_object($option->getProduct()) - && $option->getProduct()->getId() != $this->getProduct()->getId() - ) { - $productIds[$option->getProduct()->getId()] = $option->getProduct()->getId(); - } - } - - foreach ($productIds as $productId) { - $option = $this->getOptionByCode('product_qty_' . $productId); - if ($option) { - $qtyOptions[$productId] = $option; - } - } - - $this->setData('qty_options', $qtyOptions); - } - - return $qtyOptions; - } - - /** - * Set option product with Qty - * - * @param $qtyOptions - * @return Mage_Sales_Model_Quote_Item - */ - public function setQtyOptions($qtyOptions) - { - return $this->setData('qty_options', $qtyOptions); - } - - /** - * Setup product for quote item - * - * @param Mage_Catalog_Model_Product $product - * @return Mage_Sales_Model_Quote_Item - */ - public function setProduct($product) - { - if ($this->getQuote()) { - $product->setStoreId($this->getQuote()->getStoreId()); - $product->setCustomerGroupId($this->getQuote()->getCustomerGroupId()); - } - $this->setData('product', $product) - ->setProductId($product->getId()) - ->setProductType($product->getTypeId()) - ->setSku($this->getProduct()->getSku()) - ->setName($product->getName()) - ->setWeight($this->getProduct()->getWeight()) - ->setTaxClassId($product->getTaxClassId()) - ->setBaseCost($product->getCost()) - ->setIsRecurring($product->getIsRecurring()) - ; - - if ($product->getStockItem()) { - $this->setIsQtyDecimal($product->getStockItem()->getIsQtyDecimal()); - } - - Mage::dispatchEvent('sales_quote_item_set_product', array( - 'product' => $product, - 'quote_item'=>$this - )); - - -// if ($options = $product->getCustomOptions()) { -// foreach ($options as $option) { -// $this->addOption($option); -// } -// } - return $this; - } - - /** - * Check product representation in item - * - * @param Mage_Catalog_Model_Product $product - * @return bool - */ - public function representProduct($product) - { - $itemProduct = $this->getProduct(); - if (!$product || $itemProduct->getId() != $product->getId()) { - return false; - } - - /** - * Check maybe product is planned to be a child of some quote item - in this case we limit search - * only within same parent item - */ - $stickWithinParent = $product->getStickWithinParent(); - if ($stickWithinParent) { - if ($this->getParentItem() !== $stickWithinParent) { - return false; - } - } - - // Check options - $itemOptions = $this->getOptionsByCode(); - $productOptions = $product->getCustomOptions(); - - if(!$this->compareOptions($itemOptions, $productOptions)){ - return false; - } - if(!$this->compareOptions($productOptions, $itemOptions)){ - return false; - } - return true; - } - - /** - * Check if two options array are identical - * First options array is prerogative - * Second options array checked against first one - * - * @param array $options1 - * @param array $options2 - * @return bool - */ - public function compareOptions($options1, $options2) - { - foreach ($options1 as $option) { - $code = $option->getCode(); - if (in_array($code, $this->_notRepresentOptions )) { - continue; - } - if ( !isset($options2[$code]) - || ($options2[$code]->getValue() === null) - || $options2[$code]->getValue() != $option->getValue()) { - return false; - } - } - return true; - } - - /** - * Compare item - * - * @param Mage_Sales_Model_Quote_Item $item - * @return bool - */ - public function compare($item) - { - if ($this->getProductId() != $item->getProductId()) { - return false; - } - foreach ($this->getOptions() as $option) { - if (in_array($option->getCode(), $this->_notRepresentOptions)) { - continue; - } - if ($itemOption = $item->getOptionByCode($option->getCode())) { - $itemOptionValue = $itemOption->getValue(); - $optionValue = $option->getValue(); - - // dispose of some options params, that can cramp comparing of arrays - if (is_string($itemOptionValue) && is_string($optionValue)) { - $_itemOptionValue = @unserialize($itemOptionValue); - $_optionValue = @unserialize($optionValue); - if (is_array($_itemOptionValue) && is_array($_optionValue)) { - $itemOptionValue = $_itemOptionValue; - $optionValue = $_optionValue; - // looks like it does not break bundle selection qty - unset($itemOptionValue['qty'], $itemOptionValue['uenc']); - unset($optionValue['qty'], $optionValue['uenc']); - } - } - - if ($itemOptionValue != $optionValue) { - return false; - } - } - else { - return false; - } - } - return true; - } - - /** - * Get item product type - * - * @return string - */ - public function getProductType() - { - if ($option = $this->getOptionByCode('product_type')) { - return $option->getValue(); - } - if ($product = $this->getProduct()) { - return $product->getTypeId(); - } - return $this->_getData('product_type'); - } - - /** - * Return real product type of item - * - * @return unknown - */ - public function getRealProductType() - { - return $this->_getData('product_type'); - } - - /** - * Convert Quote Item to array - * - * @param array $arrAttributes - * @return array - */ - public function toArray(array $arrAttributes=array()) - { - $data = parent::toArray($arrAttributes); - - if ($product = $this->getProduct()) { - $data['product'] = $product->toArray(); - } - return $data; - } - - /** - * Initialize quote item options - * - * @param array $options - * @return Mage_Sales_Model_Quote_Item - */ - public function setOptions($options) - { - foreach ($options as $option) { - $this->addOption($option); - } - return $this; - } - - /** - * Get all item options - * - * @return array - */ - public function getOptions() - { - return $this->_options; - } - - /** - * Get all item options as array with codes in array key - * - * @return array - */ - public function getOptionsByCode() - { - return $this->_optionsByCode; - } - - /** - * Add option to item - * - * @param Mage_Sales_Model_Quote_Item_Option|Varien_Object $option - * @return Mage_Sales_Model_Quote_Item - */ - public function addOption($option) - { - if (is_array($option)) { - $option = Mage::getModel('Mage_Sales_Model_Quote_Item_Option')->setData($option) - ->setItem($this); - } - elseif (($option instanceof Varien_Object) && !($option instanceof Mage_Sales_Model_Quote_Item_Option)) { - $option = Mage::getModel('Mage_Sales_Model_Quote_Item_Option')->setData($option->getData()) - ->setProduct($option->getProduct()) - ->setItem($this); - } - elseif($option instanceof Mage_Sales_Model_Quote_Item_Option) { - $option->setItem($this); - } - else { - Mage::throwException(Mage::helper('Mage_Sales_Helper_Data')->__('Invalid item option format.')); - } - - if ($exOption = $this->getOptionByCode($option->getCode())) { - $exOption->addData($option->getData()); - } - else { - $this->_addOptionCode($option); - $this->_options[] = $option; - } - return $this; - } - - /** - * Can specify specific actions for ability to change given quote options values - * Exemple: cataloginventory decimal qty validation may change qty to int, - * so need to change quote item qty option value. - * - * @param Varien_Object $option - * @param int|float|null $value - * @return Mage_Sales_Model_Quote_Item - */ - public function updateQtyOption(Varien_Object $option, $value) - { - $optionProduct = $option->getProduct(); - $options = $this->getQtyOptions(); - - if (isset($options[$optionProduct->getId()])) { - $options[$optionProduct->getId()]->setValue($value); - } - - $this->getProduct()->getTypeInstance() - ->updateQtyOption($this->getOptions(), $option, $value, $this->getProduct()); - - return $this; - } - - /** - *Remove option from item options - * - * @param string $code - * @return Mage_Sales_Model_Quote_Item - */ - public function removeOption($code) - { - $option = $this->getOptionByCode($code); - if ($option) { - $option->isDeleted(true); - } - return $this; - } - - /** - * Register option code - * - * @param Mage_Sales_Model_Quote_Item_Option $option - * @return Mage_Sales_Model_Quote_Item - */ - protected function _addOptionCode($option) - { - if (!isset($this->_optionsByCode[$option->getCode()])) { - $this->_optionsByCode[$option->getCode()] = $option; - } - else { - Mage::throwException(Mage::helper('Mage_Sales_Helper_Data')->__('An item option with code %s already exists.', $option->getCode())); - } - return $this; - } - - /** - * Get item option by code - * - * @param string $code - * @return Mage_Sales_Model_Quote_Item_Option || null - */ - public function getOptionByCode($code) - { - if (isset($this->_optionsByCode[$code]) && !$this->_optionsByCode[$code]->isDeleted()) { - return $this->_optionsByCode[$code]; - } - return null; - } - - /** - * Checks that item model has data changes. - * Call save item options if model isn't need to save in DB - * - * @return boolean - */ - protected function _hasModelChanged() - { - if (!$this->hasDataChanges()) { - return false; - } - - return $this->_getResource()->hasDataChanged($this); - } - - /** - * Save item options - * - * @return Mage_Sales_Model_Quote_Item - */ - protected function _saveItemOptions() - { - foreach ($this->_options as $index => $option) { - if ($option->isDeleted()) { - $option->delete(); - unset($this->_options[$index]); - unset($this->_optionsByCode[$option->getCode()]); - } else { - $option->save(); - } - } - - $this->_flagOptionsSaved = true; // Report to watchers that options were saved - - return $this; - } - - /** - * Save model plus its options - * Ensures saving options in case when resource model was not changed - */ - public function save() - { - $hasDataChanges = $this->hasDataChanges(); - $this->_flagOptionsSaved = false; - - parent::save(); - - if ($hasDataChanges && !$this->_flagOptionsSaved) { - $this->_saveItemOptions(); - } - } - - /** - * Save item options after item saved - * - * @return Mage_Sales_Model_Quote_Item - */ - protected function _afterSave() - { - $this->_saveItemOptions(); - return parent::_afterSave(); - } - - /** - * Clone quote item - * - * @return Mage_Sales_Model_Quote_Item - */ - public function __clone() - { - parent::__clone(); - $options = $this->getOptions(); - $this->_quote = null; - $this->_options = array(); - $this->_optionsByCode = array(); - foreach ($options as $option) { - $this->addOption(clone $option); - } - return $this; - } - - /** - * Returns formatted buy request - object, holding request received from - * product view page with keys and options for configured product - * - * @return Varien_Object - */ - public function getBuyRequest() - { - $option = $this->getOptionByCode('info_buyRequest'); - $buyRequest = new Varien_Object($option ? unserialize($option->getValue()) : null); - - // Overwrite standard buy request qty, because item qty could have changed since adding to quote - $buyRequest->setOriginalQty($buyRequest->getQty()) - ->setQty($this->getQty() * 1); - - return $buyRequest; - } - - /** - * Sets flag, whether this quote item has some error associated with it. - * - * @param bool $flag - * @return Mage_Sales_Model_Quote_Item - */ - protected function _setHasError($flag) - { - return $this->setData('has_error', $flag); - } - - /** - * Sets flag, whether this quote item has some error associated with it. - * When TRUE - also adds 'unknown' error information to list of quote item errors. - * When FALSE - clears whole list of quote item errors. - * It's recommended to use addErrorInfo() instead - to be able to remove error statuses later. - * - * @param bool $flag - * @return Mage_Sales_Model_Quote_Item - * @see addErrorInfo() - */ - public function setHasError($flag) - { - if ($flag) { - $this->addErrorInfo(); - } else { - $this->_clearErrorInfo(); - } - return $this; - } - - /** - * Clears list of errors, associated with this quote item. - * Also automatically removes error-flag from oneself. - * - * @return Mage_Sales_Model_Quote_Item - */ - protected function _clearErrorInfo() - { - $this->_errorInfos->clear(); - $this->_setHasError(false); - return $this; - } - - /** - * Adds error information to the quote item. - * Automatically sets error flag. - * - * @param string|null $origin Usually a name of module, that embeds error - * @param int|null $code Error code, unique for origin, that sets it - * @param string|null $message Error message - * @param Varien_Object|null $additionalData Any additional data, that caller would like to store - * @return Mage_Sales_Model_Quote_Item - */ - public function addErrorInfo($origin = null, $code = null, $message = null, $additionalData = null) - { - $this->_errorInfos->addItem($origin, $code, $message, $additionalData); - if ($message !== null) { - $this->setMessage($message); - } - $this->_setHasError(true); - - return $this; - } - - /** - * Retrieves all error infos, associated with this item - * - * @return array - */ - public function getErrorInfos() - { - return $this->_errorInfos->getItems(); - } - - /** - * Removes error infos, that have parameters equal to passed in $params. - * $params can have following keys (if not set - then any item is good for this key): - * 'origin', 'code', 'message' - * - * @param array $params - * @return Mage_Sales_Model_Quote_Item - */ - public function removeErrorInfosByParams($params) - { - $removedItems = $this->_errorInfos->removeItemsByParams($params); - foreach ($removedItems as $item) { - if ($item['message'] !== null) { - $this->removeMessageByText($item['message']); - } - } - - if (!$this->_errorInfos->getItems()) { - $this->_setHasError(false); - } - - return $this; - } -} diff --git a/app/code/core/Mage/Sales/etc/adminhtml/acl.xml b/app/code/core/Mage/Sales/etc/adminhtml/acl.xml deleted file mode 100644 index dcea205e35dd9..0000000000000 --- a/app/code/core/Mage/Sales/etc/adminhtml/acl.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Sales/etc/adminhtml/menu.xml b/app/code/core/Mage/Sales/etc/adminhtml/menu.xml deleted file mode 100644 index 90712a76f1b16..0000000000000 --- a/app/code/core/Mage/Sales/etc/adminhtml/menu.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Sales/etc/config.xml b/app/code/core/Mage/Sales/etc/config.xml deleted file mode 100644 index 83cb5f4ada36b..0000000000000 --- a/app/code/core/Mage/Sales/etc/config.xml +++ /dev/null @@ -1,713 +0,0 @@ - - - - - - 1.6.0.9 - true - core - - - - - - - - - - - - - - Mage_Sales - Mage_Sales_Model_Resource_Setup - - - - - - - - global/sales/quote/item/product_attributes - - - - - - - - - Mage_Sales_Model_Quote_Address_Total_Nominal - subtotal - - - Mage_Sales_Model_Quote_Address_Total_Subtotal - nominal - grand_total - - - Mage_Sales_Model_Quote_Address_Total_Shipping - subtotal,freeshipping,tax_subtotal - grand_total - - - Mage_Sales_Model_Quote_Address_Total_Grand - subtotal - - - Mage_Sales_Model_Quote_Address_Total_Msrp - - - - - Mage_Sales_Model_Quote_Address_Total_Nominal_Recurring_Initial - 10 - - - Mage_Sales_Model_Quote_Address_Total_Nominal_Recurring_Trial - 50 - - - Mage_Sales_Model_Quote_Address_Total_Nominal_Subtotal - 250 - - - Mage_Sales_Model_Quote_Address_Total_Nominal_Shipping - 1250 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - - - - - - - - - - - 1 - - - - - - - 1 - - - - - - - 1 - - - - - - - 1 - - - - - - - 1 - - - - - - - - 1 - - - - - - - Mage_Sales_Model_Order_Invoice_Total_Subtotal - - - Mage_Sales_Model_Order_Invoice_Total_Discount - subtotal - - - Mage_Sales_Model_Order_Invoice_Total_Shipping - subtotal,discount - grand_total,tax - - - Mage_Sales_Model_Order_Invoice_Total_Tax - subtotal - - - Mage_Sales_Model_Order_Invoice_Total_Grand - shipping - - - Mage_Sales_Model_Order_Invoice_Total_Cost - discount - grand_total - - - - - - - Mage_Sales_Model_Order_Creditmemo_Total_Subtotal - - - Mage_Sales_Model_Order_Creditmemo_Total_Shipping - subtotal,discount - grand_total,tax - - - Mage_Sales_Model_Order_Creditmemo_Total_Tax - subtotal - - - Mage_Sales_Model_Order_Creditmemo_Total_Discount - subtotal - - - Mage_Sales_Model_Order_Creditmemo_Total_Grand - shipping,subtotal - - - Mage_Sales_Model_Order_Creditmemo_Total_Cost - discount - grand_total - - - - - - - Mage_Sales_Model_Order_Pdf_Items_Invoice_Default - Mage_Sales_Model_Order_Pdf_Items_Invoice_Grouped - - - Mage_Sales_Model_Order_Pdf_Items_Shipment_Default - - - Mage_Sales_Model_Order_Pdf_Items_Creditmemo_Default - Mage_Sales_Model_Order_Pdf_Items_Creditmemo_Grouped - - - - Subtotal - subtotal - 7 - 1 - 100 - - - Discount - discount_amount - - discount_description - 7 - 0 - 200 - - - Shipping & Handling - shipping_amount - 7 - 0 - 400 - - - Adjustment Refund - adjustment_positive - 7 - 0 - 500 - - - Adjustment Fee - adjustment_negative - 7 - 0 - 600 - - - Grand Total - grand_total - 8 - 1 - 700 - - - - - - - - Mage_Sales_Model_Observer - addVatRequestParamsOrderComment - - - - - - - - /sales/ - - - - standard - - Mage_Sales - sales - - - - - - - - Mage_Sales.csv - - - - - - - - layout.xml - - - billing_agreement.xml - - - recurring_profile.xml - - - - - - - - Mage_Sales_Model_Observer - changeQuoteCustomerGroupId - - - - - - - Mage_Sales_Model_Observer - restoreQuoteCustomerGroupId - - - - - - - Mage_Sales_Model_Observer - setQuoteCanApplyMsrp - - - - - - - - - - - Mage_Sales.csv - - - - - - - - - Mage_Sales_Model_Observer - substractQtyFromQuotes - - - - - - - Mage_Sales_Model_Observer - markQuotesRecollectOnCatalogRules - - - - - - - Mage_Sales_Model_Observer - markQuotesRecollectOnCatalogRules - - - - - - - Mage_Sales_Model_Observer - catalogProductSaveAfter - - - - - - - Mage_Sales_Model_Observer - catalogProductStatusUpdate - - - - - - - Mage_Sales_Model_Observer - prepareProductEditFormRecurringProfile - - - - - - - Mage_Sales_Model_Observer - restrictAdminBillingAgreementUsage - - - - - - - Mage_Sales_Model_Observer - customerSaveAfter - - - - - - - - - 20 - 100 - 30 - 10 - 40 - - - 1 - - - - - 1 - - sales_email_order_guest_template - sales - bcc - - - 1 - - sales_email_order_comment_guest_template - sales - bcc - - - 1 - - sales_email_invoice_guest_template - sales - bcc - - - 1 - - sales_email_invoice_comment_guest_template - sales - bcc - - - 1 - - sales_email_shipment_guest_template - sales - bcc - - - 1 - - sales_email_shipment_comment_guest_template - sales - bcc - - - 1 - - sales_email_creditmemo_guest_template - sales - bcc - - - 1 - - sales_email_creditmemo_comment_guest_template - sales - bcc - - - - - 1 - - - 1 - - - 1 - - - - 0 - - - - - - - 0 0 * * * - - - Mage_Sales_Model_Observer::cleanExpiredQuotes - - - - - 0 0 * * * - - - Mage_Sales_Model_Observer::aggregateSalesReportOrderData - - - - - 0 0 * * * - - - Mage_Sales_Model_Observer::aggregateSalesReportShipmentData - - - - - 0 0 * * * - - - Mage_Sales_Model_Observer::aggregateSalesReportInvoicedData - - - - - 0 0 * * * - - - Mage_Sales_Model_Observer::aggregateSalesReportRefundedData - - - - - 0 0 * * * - - - Mage_Sales_Model_Observer::aggregateSalesReportBestsellersData - - - - - diff --git a/app/code/core/Mage/Sales/view/adminhtml/billing/agreement/view/tab/info.phtml b/app/code/core/Mage/Sales/view/adminhtml/billing/agreement/view/tab/info.phtml deleted file mode 100644 index 1a084fafe9961..0000000000000 --- a/app/code/core/Mage/Sales/view/adminhtml/billing/agreement/view/tab/info.phtml +++ /dev/null @@ -1,63 +0,0 @@ - -
    -
    -

    __('General Information'); ?>

    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    __('Reference ID'); ?>escapeHtml($this->getReferenceId()) ?>
    __('Customer'); ?> - - getCustomerEmail() ?> - -
    __('Status'); ?>getStatus() ?>
    __('Created At'); ?>getCreatedAt(); ?>
    __('Updated At'); ?>getUpdatedAt(); ?>
    -
    -
    diff --git a/app/code/core/Mage/Sales/view/frontend/order/creditmemo.phtml b/app/code/core/Mage/Sales/view/frontend/order/creditmemo.phtml deleted file mode 100644 index af2b15acb1cbd..0000000000000 --- a/app/code/core/Mage/Sales/view/frontend/order/creditmemo.phtml +++ /dev/null @@ -1,63 +0,0 @@ - -
    -helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order', $this->getOrder())): ?> - - - getChildHtml('creditmemo_items') ?> - -
    diff --git a/app/code/core/Mage/Sales/view/frontend/order/creditmemo/items/renderer/default.phtml b/app/code/core/Mage/Sales/view/frontend/order/creditmemo/items/renderer/default.phtml deleted file mode 100644 index 2c14f267f2f0e..0000000000000 --- a/app/code/core/Mage/Sales/view/frontend/order/creditmemo/items/renderer/default.phtml +++ /dev/null @@ -1,302 +0,0 @@ - -getItem() ?> -getItem()->getOrderItem()->getOrder() ?> - -

    escapeHtml($_item->getName()) ?>

    - getItemOptions()): ?> -
    - -
    escapeHtml($_option['label']) ?>
    - getPrintStatus()): ?> - getFormatedOptionValue($_option) ?> - class="truncated"> - -
    -
    -
    escapeHtml($_option['label']) ?>
    -
    -
    -
    - - - -
    escapeHtml( (isset($_option['print_value']) ? $_option['print_value'] : $_option['value']) ) ?>
    - - -
    - - getProductAdditionalInformationBlock(); ?> - - setItem($_item->getOrderItem())->toHtml(); ?> - - escapeHtml($_item->getDescription()) ?> - helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $_item->getOrderItem()) && $_item->getGiftMessageId()): ?> - __('Gift Message') ?> - - - escapeHtml(Mage::helper('Mage_Core_Helper_String')->splitInjection($this->getSku())) ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Excl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> - - getOrder()->formatPrice($this->getItem()->getPrice()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?>
    -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Incl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - helper('Mage_Checkout_Helper_Data')->getPriceInclTax($this->getItem()); ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> - - getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?>
    -
    - - -
    - - - getQty()*1 ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Excl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> - - getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?>
    -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Incl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($this->getItem()); ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?> - - getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxRowDisposition()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?>
    -
    - - - - - -
    - - - formatPrice(-$_item->getDiscountAmount()) ?> - - formatPrice($_item->getRowTotal()-$_item->getDiscountAmount()+$_item->getTaxAmount()+$_item->getWeeeTaxAppliedRowAmount()) ?> - - diff --git a/app/code/core/Mage/Sales/view/frontend/order/invoice.phtml b/app/code/core/Mage/Sales/view/frontend/order/invoice.phtml deleted file mode 100644 index 58ae2f74d8b95..0000000000000 --- a/app/code/core/Mage/Sales/view/frontend/order/invoice.phtml +++ /dev/null @@ -1,63 +0,0 @@ - -
    -helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order', $this->getOrder())): ?> - - - getChildHtml('invoice_items') ?> - -
    diff --git a/app/code/core/Mage/Sales/view/frontend/order/invoice/items/renderer/default.phtml b/app/code/core/Mage/Sales/view/frontend/order/invoice/items/renderer/default.phtml deleted file mode 100644 index 1044080afcd7f..0000000000000 --- a/app/code/core/Mage/Sales/view/frontend/order/invoice/items/renderer/default.phtml +++ /dev/null @@ -1,299 +0,0 @@ - -getItem() ?> -getItem()->getOrderItem()->getOrder() ?> - -

    escapeHtml($_item->getName()) ?>

    - getItemOptions()): ?> -
    - -
    escapeHtml($_option['label']) ?>
    - getPrintStatus()): ?> - getFormatedOptionValue($_option) ?> - class="truncated"> - - -
    -
    -
    escapeHtml($_option['label']) ?>
    -
    -
    -
    - - - -
    escapeHtml( (isset($_option['print_value']) ? $_option['print_value'] : $_option['value']) ) ?>
    - - -
    - - getProductAdditionalInformationBlock(); ?> - - setItem($_item->getOrderItem())->toHtml(); ?> - - escapeHtml($_item->getDescription()) ?> - helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $_item->getOrderItem()) && $_item->getGiftMessageId()): ?> - __('Gift Message') ?> - - - escapeHtml(Mage::helper('Mage_Core_Helper_String')->splitInjection($this->getSku())) ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Excl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> - - getOrder()->formatPrice($this->getItem()->getPrice()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?>
    -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Incl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - helper('Mage_Checkout_Helper_Data')->getPriceInclTax($this->getItem()); ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> - - getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?>
    -
    - - -
    - - - getQty()*1 ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Excl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> - - getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?>
    -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Incl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($this->getItem()); ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?> - - getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxRowDisposition()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?>
    -
    - - - - - -
    - - - diff --git a/app/code/core/Mage/Sales/view/frontend/order/items.phtml b/app/code/core/Mage/Sales/view/frontend/order/items.phtml deleted file mode 100644 index 2c3e4ccd03c78..0000000000000 --- a/app/code/core/Mage/Sales/view/frontend/order/items.phtml +++ /dev/null @@ -1,69 +0,0 @@ - -getOrder() ?> - - - - - - - - - - - - - - - - - getChildHtml('order_totals') ?> - - getItemsCollection(); ?> - - count(); ?> - - getParentItem()) continue; ?> - - getItemHtml($_item) ?> - helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $_item) && $_item->getGiftMessageId()): ?> - - helper('Mage_GiftMessage_Helper_Message')->getGiftMessageForEntity($_item); ?> - - - - - -
    __('Product Name') ?>__('SKU') ?>__('Price') ?>__('Qty') ?>__('Subtotal') ?>
    - diff --git a/app/code/core/Mage/Sales/view/frontend/order/items/renderer/default.phtml b/app/code/core/Mage/Sales/view/frontend/order/items/renderer/default.phtml deleted file mode 100644 index c632ea6d0d58d..0000000000000 --- a/app/code/core/Mage/Sales/view/frontend/order/items/renderer/default.phtml +++ /dev/null @@ -1,323 +0,0 @@ - -getItem() ?> - -

    escapeHtml($_item->getName()) ?>

    - getItemOptions()): ?> -
    - -
    escapeHtml($_option['label']) ?>
    - getPrintStatus()): ?> - getFormatedOptionValue($_option) ?> - class="truncated"> - - -
    -
    -
    escapeHtml($_option['label']) ?>
    -
    -
    -
    - - - -
    - escapeHtml( (isset($_option['print_value']) ? $_option['print_value'] : $_option['value']) )) ?> -
    - - -
    - - getProductAdditionalInformationBlock(); ?> - - setItem($_item)->toHtml(); ?> - - escapeHtml($_item->getDescription()) ?> - helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $_item) && $_item->getGiftMessageId()): ?> - __('Gift Message') ?> - - - escapeHtml(Mage::helper('Mage_Core_Helper_String')->splitInjection($this->getSku())) ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Excl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> - - getOrder()->formatPrice($this->getItem()->getPrice()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?>
    -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Incl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - helper('Mage_Checkout_Helper_Data')->getPriceInclTax($this->getItem()); ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> - - getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?>
    -
    - - -
    - - - - - getItem()->getQtyOrdered() > 0): ?> - __('Ordered'); ?>: getItem()->getQtyOrdered()*1 ?>
    - - getItem()->getQtyShipped() > 0): ?> - __('Shipped'); ?>: getItem()->getQtyShipped()*1 ?>
    - - getItem()->getQtyCanceled() > 0): ?> - __('Canceled'); ?>: getItem()->getQtyCanceled()*1 ?>
    - - getItem()->getQtyRefunded() > 0): ?> - __('Refunded'); ?>: getItem()->getQtyRefunded()*1 ?>
    - -
    - - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceExclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Excl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> - - getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - __('Total'); ?>:
    getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?>
    -
    - - -
    -
    - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices() || $this->helper('Mage_Tax_Helper_Data')->displaySalesPriceInclTax()): ?> - - helper('Mage_Tax_Helper_Data')->displaySalesBothPrices()): ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - __('Incl. Tax'); ?>: - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - helper('Mage_Checkout_Helper_Data')->getSubtotalInclTax($this->getItem()); ?> - typeOfDisplay($this->getItem(), array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - - - - typeOfDisplay($this->getItem(), array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?> - - getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxRowDisposition()) ?> - - - - - - getApplied($this->getItem())): ?> - - - - typeOfDisplay($this->getItem(), 2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - - __('Total incl. tax'); ?>:
    getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?>
    -
    - - - - - -
    - - - - diff --git a/app/code/core/Mage/Sales/view/frontend/order/shipment.phtml b/app/code/core/Mage/Sales/view/frontend/order/shipment.phtml deleted file mode 100644 index 134aaa3dbbef4..0000000000000 --- a/app/code/core/Mage/Sales/view/frontend/order/shipment.phtml +++ /dev/null @@ -1,63 +0,0 @@ - -
    -helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order', $this->getOrder())): ?> - - - getChildHtml('shipment_items') ?> - -
    diff --git a/app/code/core/Mage/Sales/view/frontend/order/shipment/items.phtml b/app/code/core/Mage/Sales/view/frontend/order/shipment/items.phtml deleted file mode 100644 index d1d53c43aeaa1..0000000000000 --- a/app/code/core/Mage/Sales/view/frontend/order/shipment/items.phtml +++ /dev/null @@ -1,89 +0,0 @@ - -getOrder() ?> - -getShipmentsCollection() as $_shipment): ?> -

    __('Shipment #') ?>getIncrementId(); ?> | __('Print Shipment') ?>

    -getTracksCollection(); ?> -count()): ?> - - - - - - - - - - -
    - __('Track this shipment') ?> -
    __('Tracking Number(s):') ?>  - count(); - foreach($tracks as $track): ?> - isCustom()): ?> - escapeHtml($track->getNumber()) ?> - - escapeHtml($track->getNumber()) ?> - - , - -
    - - -

    __('Items Shipped') ?>

    - - - - - - - - - - - - getAllItems(); ?> - - - getOrderItem()->getParentItem()) continue; ?> - - getItemHtml($_item) ?> - - -
    __('Product Name') ?>__('SKU') ?>__('Qty Shipped') ?>
    - -getCommentsHtml($_shipment)?> - diff --git a/app/code/core/Mage/Sales/view/frontend/order/shipment/items/renderer/default.phtml b/app/code/core/Mage/Sales/view/frontend/order/shipment/items/renderer/default.phtml deleted file mode 100644 index af24b6fbd4736..0000000000000 --- a/app/code/core/Mage/Sales/view/frontend/order/shipment/items/renderer/default.phtml +++ /dev/null @@ -1,65 +0,0 @@ - -getItem() ?> -getItem()->getOrderItem()->getOrder() ?> - -

    escapeHtml($_item->getName()) ?>

    - getItemOptions()): ?> -
    - -
    escapeHtml($_option['label']) ?>
    - getPrintStatus()): ?> - getFormatedOptionValue($_option) ?> - class="truncated"> - - -
    -
    -
    escapeHtml($_option['label']) ?>
    -
    -
    -
    - - - -
    escapeHtml( (isset($_option['print_value']) ? $_option['print_value'] : $_option['value']) ) ?>
    - - -
    - - getProductAdditionalInformationBlock(); ?> - - setItem($_item->getOrderItem())->toHtml(); ?> - - escapeHtml($_item->getDescription()) ?> - helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order_item', $_item->getOrderItem()) && $_item->getGiftMessageId()): ?> - __('Gift Message') ?> - - - escapeHtml(Mage::helper('Mage_Core_Helper_String')->splitInjection($this->getSku())) ?> - getQty()*1 ?> - diff --git a/app/code/core/Mage/Sales/view/frontend/order/view.phtml b/app/code/core/Mage/Sales/view/frontend/order/view.phtml deleted file mode 100644 index a64109b0b52bb..0000000000000 --- a/app/code/core/Mage/Sales/view/frontend/order/view.phtml +++ /dev/null @@ -1,92 +0,0 @@ - -
    - helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('items', $this->getOrder())): ?> - - - getOrder() ?> -

    __('Items Ordered') ?> - getTracksCollection()->count()) : ?> - | __('Track your order') ?> - -

    - - getChildHtml('order_items') ?> - - helper('Mage_GiftMessage_Helper_Message')->getIsMessagesAvailable('order', $_order) && $_order->getGiftMessageId()): ?> -
    -

    __('Gift Message for This Order') ?>

    - helper('Mage_GiftMessage_Helper_Message')->getGiftMessageForEntity($_order); ?> -
    -
    __('From:') ?> escapeHtml($_giftMessage->getSender()) ?>
    -
    __('To:') ?> escapeHtml($_giftMessage->getRecipient()) ?>
    -
    helper('Mage_GiftMessage_Helper_Message')->getEscapedGiftMessage($_order) ?>
    -
    -
    - - getOrder()->getVisibleStatusHistory() ?> - -
    -

    __('About Your Order') ?>

    -
    - -
    formatDate($_historyItem->getCreatedAtStoreDate(), 'medium', true) ?>
    -
    escapeHtml($_historyItem->getComment()) ?>
    - -
    -
    - - -
    diff --git a/app/code/core/Mage/Sales/view/frontend/reorder/sidebar.phtml b/app/code/core/Mage/Sales/view/frontend/reorder/sidebar.phtml deleted file mode 100644 index cddbc649425a0..0000000000000 --- a/app/code/core/Mage/Sales/view/frontend/reorder/sidebar.phtml +++ /dev/null @@ -1,77 +0,0 @@ - - -getItems()?> - -
    -
    - __('My Orders') ?> -
    -
    -
    -

    __('Last Ordered Items') ?>

    -
      - - -
    1. - isItemAvailableForReorder($_item)): ?> - - - - -

      escapeHtml($_item->getName()) ?>

      -
    2. - -
    - -
    -
    - - - - __('View All'); ?> -
    -
    -
    -
    -getPagerHtml(); ?> - - diff --git a/app/code/core/Mage/SalesRule/Model/Rule.php b/app/code/core/Mage/SalesRule/Model/Rule.php deleted file mode 100644 index dd31dea106f2e..0000000000000 --- a/app/code/core/Mage/SalesRule/Model/Rule.php +++ /dev/null @@ -1,565 +0,0 @@ - - */ -class Mage_SalesRule_Model_Rule extends Mage_Rule_Model_Abstract -{ - /** - * Free Shipping option "For matching items only" - */ - const FREE_SHIPPING_ITEM = 1; - - /** - * Free Shipping option "For shipment with matching items" - */ - const FREE_SHIPPING_ADDRESS = 2; - - /** - * Coupon types - */ - const COUPON_TYPE_NO_COUPON = 1; - const COUPON_TYPE_SPECIFIC = 2; - const COUPON_TYPE_AUTO = 3; - - /** - * Rule type actions - */ - const TO_PERCENT_ACTION = 'to_percent'; - const BY_PERCENT_ACTION = 'by_percent'; - const TO_FIXED_ACTION = 'to_fixed'; - const BY_FIXED_ACTION = 'by_fixed'; - const CART_FIXED_ACTION = 'cart_fixed'; - const BUY_X_GET_Y_ACTION = 'buy_x_get_y'; - - /** - * Store coupon code generator instance - * - * @var Mage_SalesRule_Model_Coupon_CodegeneratorInterface - */ - protected static $_couponCodeGenerator; - - /** - * Prefix of model events names - * - * @var string - */ - protected $_eventPrefix = 'salesrule_rule'; - - /** - * Parameter name in event - * - * In observe method you can use $observer->getEvent()->getRule() in this case - * - * @var string - */ - protected $_eventObject = 'rule'; - - /** - * Contain sores labels - * - * @deprecated after 1.6.2.0 - * - * @var array - */ - protected $_labels = array(); - - /** - * Rule's primary coupon - * - * @var Mage_SalesRule_Model_Coupon - */ - protected $_primaryCoupon; - - /** - * Rule's subordinate coupons - * - * @var array of Mage_SalesRule_Model_Coupon - */ - protected $_coupons; - - /** - * Coupon types cache for lazy getter - * - * @var array - */ - protected $_couponTypes; - - /** - * Store already validated addresses and validation results - * - * @var array - */ - protected $_validatedAddresses = array(); - - /** - * Set resource model and Id field name - */ - protected function _construct() - { - parent::_construct(); - $this->_init('Mage_SalesRule_Model_Resource_Rule'); - $this->setIdFieldName('rule_id'); - } - - /** - * Returns code mass generator instance for auto generated specific coupons - * - * @return Mage_SalesRule_Model_Coupon_MassgneratorInterface - */ - public static function getCouponMassGenerator() - { - return Mage::getSingleton('Mage_SalesRule_Model_Coupon_Massgenerator'); - } - - /** - * Set coupon code and uses per coupon - * - * @return Mage_SalesRule_Model_Rule - */ - protected function _afterLoad() - { - $this->setCouponCode($this->getPrimaryCoupon()->getCode()); - if ($this->getUsesPerCoupon() !== null && !$this->getUseAutoGeneration()) { - $this->setUsesPerCoupon($this->getPrimaryCoupon()->getUsageLimit()); - } - return parent::_afterLoad(); - } - - /** - * Save/delete coupon - * - * @return Mage_SalesRule_Model_Rule - */ - protected function _afterSave() - { - $couponCode = trim($this->getCouponCode()); - if (strlen($couponCode) - && $this->getCouponType() == self::COUPON_TYPE_SPECIFIC - && !$this->getUseAutoGeneration() - ) { - $this->getPrimaryCoupon() - ->setCode($couponCode) - ->setUsageLimit($this->getUsesPerCoupon() ? $this->getUsesPerCoupon() : null) - ->setUsagePerCustomer($this->getUsesPerCustomer() ? $this->getUsesPerCustomer() : null) - ->setExpirationDate($this->getToDate()) - ->save(); - } else { - $this->getPrimaryCoupon()->delete(); - } - - parent::_afterSave(); - return $this; - } - - /** - * Initialize rule model data from array. - * Set store labels if applicable. - * - * @param array $data - * - * @return Mage_SalesRule_Model_Rule - */ - public function loadPost(array $data) - { - parent::loadPost($data); - - if (isset($data['store_labels'])) { - $this->setStoreLabels($data['store_labels']); - } - - return $this; - } - - /** - * Get rule condition combine model instance - * - * @return Mage_SalesRule_Model_Rule_Condition_Combine - */ - public function getConditionsInstance() - { - return Mage::getModel('Mage_SalesRule_Model_Rule_Condition_Combine'); - } - - /** - * Get rule condition product combine model instance - * - * @return Mage_SalesRule_Model_Rule_Condition_Product_Combine - */ - public function getActionsInstance() - { - return Mage::getModel('Mage_SalesRule_Model_Rule_Condition_Product_Combine'); - } - - /** - * Returns code generator instance for auto generated coupons - * - * @return Mage_SalesRule_Model_Coupon_CodegeneratorInterface - */ - public static function getCouponCodeGenerator() - { - if (!self::$_couponCodeGenerator) { - return Mage::getSingleton('Mage_SalesRule_Model_Coupon_Codegenerator', - array('data' => array('length' => 16))); - } - return self::$_couponCodeGenerator; - } - - /** - * Set code generator instance for auto generated coupons - * - * @param Mage_SalesRule_Model_Coupon_CodegeneratorInterface - */ - public static function setCouponCodeGenerator(Mage_SalesRule_Model_Coupon_CodegeneratorInterface $codeGenerator) - { - self::$_couponCodeGenerator = $codeGenerator; - } - - /** - * Retrieve rule's primary coupon - * - * @return Mage_SalesRule_Model_Coupon - */ - public function getPrimaryCoupon() - { - if ($this->_primaryCoupon === null) { - $this->_primaryCoupon = Mage::getModel('Mage_SalesRule_Model_Coupon'); - $this->_primaryCoupon->loadPrimaryByRule($this->getId()); - $this->_primaryCoupon->setRule($this)->setIsPrimary(true); - } - return $this->_primaryCoupon; - } - - /** - * Get sales rule customer group Ids - * - * @return array - */ - public function getCustomerGroupIds() - { - if (!$this->hasCustomerGroupIds()) { - $customerGroupIds = $this->_getResource()->getCustomerGroupIds($this->getId()); - $this->setData('customer_group_ids', (array)$customerGroupIds); - } - return $this->_getData('customer_group_ids'); - } - - /** - * Get Rule label by specified store - * - * @param Mage_Core_Model_Store|int|bool|null $store - * - * @return string|bool - */ - public function getStoreLabel($store = null) - { - $storeId = Mage::app()->getStore($store)->getId(); - $labels = (array)$this->getStoreLabels(); - - if (isset($labels[$storeId])) { - return $labels[$storeId]; - } elseif (isset($labels[0]) && $labels[0]) { - return $labels[0]; - } - - return false; - } - - /** - * Set if not yet and retrieve rule store labels - * - * @return array - */ - public function getStoreLabels() - { - if (!$this->hasStoreLabels()) { - $labels = $this->_getResource()->getStoreLabels($this->getId()); - $this->setStoreLabels($labels); - } - - return $this->_getData('store_labels'); - } - - /** - * Retrieve subordinate coupons - * - * @return array of Mage_SalesRule_Model_Coupon - */ - public function getCoupons() - { - if ($this->_coupons === null) { - $collection = Mage::getResourceModel('Mage_SalesRule_Model_Resource_Coupon_Collection'); - /** @var Mage_SalesRule_Model_Resource_Coupon_Collection */ - $collection->addRuleToFilter($this); - $this->_coupons = $collection->getItems(); - } - return $this->_coupons; - } - - /** - * Retrieve coupon types - * - * @return array - */ - public function getCouponTypes() - { - if ($this->_couponTypes === null) { - $this->_couponTypes = array( - Mage_SalesRule_Model_Rule::COUPON_TYPE_NO_COUPON => Mage::helper('Mage_SalesRule_Helper_Data')->__('No Coupon'), - Mage_SalesRule_Model_Rule::COUPON_TYPE_SPECIFIC => Mage::helper('Mage_SalesRule_Helper_Data')->__('Specific Coupon'), - ); - $transport = new Varien_Object(array( - 'coupon_types' => $this->_couponTypes, - 'is_coupon_type_auto_visible' => false - )); - Mage::dispatchEvent('salesrule_rule_get_coupon_types', array('transport' => $transport)); - $this->_couponTypes = $transport->getCouponTypes(); - if ($transport->getIsCouponTypeAutoVisible()) { - $this->_couponTypes[Mage_SalesRule_Model_Rule::COUPON_TYPE_AUTO] = Mage::helper('Mage_SalesRule_Helper_Data')->__('Auto'); - } - } - return $this->_couponTypes; - } - - /** - * Acquire coupon instance - * - * @param bool $saveNewlyCreated Whether or not to save newly created coupon - * @param int $saveAttemptCount Number of attempts to save newly created coupon - * - * @return Mage_SalesRule_Model_Coupon|null - */ - public function acquireCoupon($saveNewlyCreated = true, $saveAttemptCount = 10) - { - if ($this->getCouponType() == self::COUPON_TYPE_NO_COUPON) { - return null; - } - if ($this->getCouponType() == self::COUPON_TYPE_SPECIFIC) { - return $this->getPrimaryCoupon(); - } - /** @var Mage_SalesRule_Model_Coupon $coupon */ - $coupon = Mage::getModel('Mage_SalesRule_Model_Coupon'); - $coupon->setRule($this) - ->setIsPrimary(false) - ->setUsageLimit($this->getUsesPerCoupon() ? $this->getUsesPerCoupon() : null) - ->setUsagePerCustomer($this->getUsesPerCustomer() ? $this->getUsesPerCustomer() : null) - ->setExpirationDate($this->getToDate()); - - $couponCode = self::getCouponCodeGenerator()->generateCode(); - $coupon->setCode($couponCode); - - $ok = false; - if (!$saveNewlyCreated) { - $ok = true; - } else if ($this->getId()) { - for ($attemptNum = 0; $attemptNum < $saveAttemptCount; $attemptNum++) { - try { - $coupon->save(); - } catch (Exception $e) { - if ($e instanceof Mage_Core_Exception || $coupon->getId()) { - throw $e; - } - $coupon->setCode( - $couponCode . - self::getCouponCodeGenerator()->getDelimiter() . - sprintf('%04u', rand(0, 9999)) - ); - continue; - } - $ok = true; - break; - } - } - if (!$ok) { - Mage::throwException(Mage::helper('Mage_SalesRule_Helper_Data')->__('Can\'t acquire coupon.')); - } - - return $coupon; - } - - /** - * Check cached validation result for specific address - * - * @param Mage_Sales_Model_Quote_Address $address - * @return bool - */ - public function hasIsValidForAddress($address) - { - $addressId = $this->_getAddressId($address); - return isset($this->_validatedAddresses[$addressId]) ? true : false; - } - - /** - * Set validation result for specific address to results cache - * - * @param Mage_Sales_Model_Quote_Address $address - * @param bool $validationResult - * @return Mage_SalesRule_Model_Rule - */ - public function setIsValidForAddress($address, $validationResult) - { - $addressId = $this->_getAddressId($address); - $this->_validatedAddresses[$addressId] = $validationResult; - return $this; - } - - /** - * Get cached validation result for specific address - * - * @param Mage_Sales_Model_Quote_Address $address - * @return bool - */ - public function getIsValidForAddress($address) - { - $addressId = $this->_getAddressId($address); - return isset($this->_validatedAddresses[$addressId]) ? $this->_validatedAddresses[$addressId] : false; - } - - /** - * Return id for address - * - * @param Mage_Sales_Model_Quote_Address $address - * @return string - */ - private function _getAddressId($address) { - if($address instanceof Mage_Sales_Model_Quote_Address) { - return $address->getId(); - } - return $address; - } - - - - - - /** - * Collect all product attributes used in serialized rule's action or condition - * - * @deprecated after 1.6.2.0 use Mage_SalesRule_Model_Resource_Rule::getProductAttributes() instead - * - * @param string $serializedString - * - * @return array - */ - protected function _getUsedAttributes($serializedString) - { - return $this->_getResource()->getProductAttributes($serializedString); - } - - /** - * @deprecated after 1.6.2.0 - * - * @param string $format - * - * @return string - */ - public function toString($format='') - { - return ''; - } - - /** - * Returns rule as an array for admin interface - * - * @deprecated after 1.6.2.0 - * - * @param array $arrAttributes - * - * Output example: - * array( - * 'name'=>'Example rule', - * 'conditions'=>{condition_combine::toArray} - * 'actions'=>{action_collection::toArray} - * ) - * - * @return array - */ - public function toArray(array $arrAttributes = array()) - { - return parent::toArray($arrAttributes); - } -} diff --git a/app/code/core/Mage/SalesRule/etc/adminhtml/acl.xml b/app/code/core/Mage/SalesRule/etc/adminhtml/acl.xml deleted file mode 100644 index 5efbf0949d804..0000000000000 --- a/app/code/core/Mage/SalesRule/etc/adminhtml/acl.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/SalesRule/etc/adminhtml/menu.xml b/app/code/core/Mage/SalesRule/etc/adminhtml/menu.xml deleted file mode 100644 index 523c00af48870..0000000000000 --- a/app/code/core/Mage/SalesRule/etc/adminhtml/menu.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - diff --git a/app/code/core/Mage/SalesRule/etc/config.xml b/app/code/core/Mage/SalesRule/etc/config.xml deleted file mode 100644 index 08588f98225f6..0000000000000 --- a/app/code/core/Mage/SalesRule/etc/config.xml +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - 1.6.0.4 - true - core - - - - - - - - - - - - Mage_SalesRule - Mage_Sales_Model_Resource_Setup - - - - - - - - Mage_SalesRule_Model_Observer - salesOrderAfterPlace - - - - - - - Mage_SalesRule_Model_Observer - addProductAttributes - - - - - - - Mage_SalesRule_Model_Observer - addSalesRuleNameToOrder - - - - - - - - - Mage_SalesRule_Model_Quote_Freeshipping - subtotal - tax_subtotal,shipping - - - Mage_SalesRule_Model_Quote_Discount - subtotal,shipping - grand_total - - - - - Mage_SalesRule_Model_Quote_Nominal_Discount - 550 - - - - - - - - - - ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 - ABCDEFGHIJKLMNOPQRSTUVWXYZ - 0123456789 - - - - - - - - - - Mage_SalesRule.csv - - - - - - - - - Mage_SalesRule_Model_Observer - catalogAttributeDeleteAfter - - - - - - - Mage_SalesRule_Model_Observer - catalogAttributeSaveAfter - - - - - - - - - - - Mage_SalesRule.csv - - - - - - - - - - 0 0 * * * - - - Mage_SalesRule_Model_Observer::aggregateSalesReportCouponsData - - - - - - - - 12 - 1 - - - - diff --git a/app/code/core/Mage/Sendfriend/etc/config.xml b/app/code/core/Mage/Sendfriend/etc/config.xml deleted file mode 100644 index 5e87330c446ed..0000000000000 --- a/app/code/core/Mage/Sendfriend/etc/config.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - Mage_Sendfriend - Mage_Sendfriend_Model_Resource_Setup - - - - - - - - - - - Mage_Sendfriend.csv - - - - - - - - - - - Mage_Sendfriend_Model_Observer - register - - - - - - - standard - - Mage_Sendfriend - sendfriend - - - - - - - layout.xml - - - - - - - - Mage_Sendfriend.csv - - - - - - - - - 1 - - 0 - 5 - 5 - 0 - - - - \ No newline at end of file diff --git a/app/code/core/Mage/Sendfriend/view/frontend/layout.xml b/app/code/core/Mage/Sendfriend/view/frontend/layout.xml deleted file mode 100644 index 9619dd00bd358..0000000000000 --- a/app/code/core/Mage/Sendfriend/view/frontend/layout.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - varien/product.js - - - - - - diff --git a/app/code/core/Mage/Shipping/Model/Config.php b/app/code/core/Mage/Shipping/Model/Config.php deleted file mode 100644 index a9ca31932a8b9..0000000000000 --- a/app/code/core/Mage/Shipping/Model/Config.php +++ /dev/null @@ -1,125 +0,0 @@ - $carrierConfig) { - if (Mage::getStoreConfigFlag('carriers/'.$code.'/active', $store)) { - $carrierModel = $this->_getCarrier($code, $carrierConfig, $store); - if ($carrierModel) { - $carriers[$code] = $carrierModel; - } - } - } - return $carriers; - } - - /** - * Retrieve all system carriers - * - * @param mixed $store - * @return array - */ - public function getAllCarriers($store = null) - { - $carriers = array(); - $config = Mage::getStoreConfig('carriers', $store); - foreach ($config as $code => $carrierConfig) { - $model = $this->_getCarrier($code, $carrierConfig, $store); - if ($model) { - $carriers[$code] = $model; - } - } - return $carriers; - } - - /** - * Retrieve carrier model instance by carrier code - * - * @param string $carrierCode - * @param mixed $store - * @return Mage_Usa_Model_Shipping_Carrier_Abstract - */ - public function getCarrierInstance($carrierCode, $store = null) - { - $carrierConfig = Mage::getStoreConfig('carriers/'.$carrierCode, $store); - if (!empty($carrierConfig)) { - return $this->_getCarrier($carrierCode, $carrierConfig, $store); - } - return false; - } - - /** - * Get carrier model object - * - * @param string $code - * @param array $config - * @param mixed $store - * @return Mage_Shipping_Model_Carrier_Abstract - */ - protected function _getCarrier($code, $config, $store = null) - { - if (!isset($config['model'])) { - return false; - } - $modelName = $config['model']; - - /** - * Added protection from not existing models usage. - * Related with module uninstall process - */ - try { - $carrier = Mage::getModel($modelName); - } catch (Exception $e) { - Mage::logException($e); - return false; - } - $carrier->setId($code)->setStore($store); - self::$_carriers[$code] = $carrier; - return self::$_carriers[$code]; - } -} diff --git a/app/code/core/Mage/Shipping/etc/adminhtml/acl.xml b/app/code/core/Mage/Shipping/etc/adminhtml/acl.xml deleted file mode 100644 index 06ccdc08f0216..0000000000000 --- a/app/code/core/Mage/Shipping/etc/adminhtml/acl.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Shipping/etc/config.xml b/app/code/core/Mage/Shipping/etc/config.xml deleted file mode 100644 index 888d0734d85ee..0000000000000 --- a/app/code/core/Mage/Shipping/etc/config.xml +++ /dev/null @@ -1,133 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - - Mage_Shipping - - - - - - - - - - Mage_Shipping.csv - - - - - - - - - - - Mage_Shipping.csv - - - - - - - standard - - Mage_Shipping - shipping - - - - - - - layout.xml - - - - - - - - - US - 90034 - 12 - - - - - 1 - 0 - Mage_Shipping_Model_Carrier_Flatrate - Fixed - 5.00 - Flat Rate - I - This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us. - F - - - 0 - 0 - 50 - Mage_Shipping_Model_Carrier_Freeshipping - Free - Free Shipping - This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us. - - - 0 - 0 - package_weight - 1 - Mage_Shipping_Model_Carrier_Tablerate - Table Rate - Best Way - This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us. - F - - - - diff --git a/app/code/core/Mage/Sitemap/etc/adminhtml/acl.xml b/app/code/core/Mage/Sitemap/etc/adminhtml/acl.xml deleted file mode 100644 index 519cf7e00c533..0000000000000 --- a/app/code/core/Mage/Sitemap/etc/adminhtml/acl.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Sitemap/etc/adminhtml/menu.xml b/app/code/core/Mage/Sitemap/etc/adminhtml/menu.xml deleted file mode 100644 index 01666991b7e66..0000000000000 --- a/app/code/core/Mage/Sitemap/etc/adminhtml/menu.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - diff --git a/app/code/core/Mage/Sitemap/etc/config.xml b/app/code/core/Mage/Sitemap/etc/config.xml deleted file mode 100644 index 3d52824166186..0000000000000 --- a/app/code/core/Mage/Sitemap/etc/config.xml +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - Mage_Sitemap - - - - - - - - - - - Mage_Sitemap.csv - - - - - - - - layout.xml - - - - - - - - 50000 - 10485760 - - - 0.25 - daily - - - 0.5 - daily - - - 1 - daily - all - - - 0 - - sitemap_generate_error_email_template - general - - - 0 - - - - - - - - Mage_Sitemap_Model_Observer::scheduledGenerateSitemaps - - - - - diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/Tag.php b/app/code/core/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/Tag.php deleted file mode 100644 index 85dff9eccc9a3..0000000000000 --- a/app/code/core/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/Tag.php +++ /dev/null @@ -1,193 +0,0 @@ - - * - * @method Mage_Tag_Block_Adminhtml_Catalog_Product_Edit_Tab_Tag setTitle() setTitle(string $title) - * @method array getTitle() getTitle() - */ - -class Mage_Tag_Block_Adminhtml_Catalog_Product_Edit_Tab_Tag - extends Mage_Backend_Block_Template - implements Mage_Backend_Block_Widget_Tab_Interface -{ - /** - * Id of current tab - */ - const TAB_ID = 'tags'; - - /** - * Array of data helpers - * - * @var array - */ - protected $_helpers; - - /** - * Authentication session - * - * @var Mage_Core_Model_Authorization - */ - protected $_authSession; - - /** - * Set identifier and title - * - * @param Mage_Core_Controller_Request_Http $request - * @param Mage_Core_Model_Layout $layout - * @param Mage_Core_Model_Event_Manager $eventManager - * @param Mage_Backend_Model_Url $urlBuilder - * @param Mage_Core_Model_Translate $translator - * @param Mage_Core_Model_Cache $cache - * @param Mage_Core_Model_Design_Package $designPackage - * @param Mage_Core_Model_Session $session - * @param Mage_Core_Model_Store_Config $storeConfig - * @param Mage_Core_Controller_Varien_Front $frontController - * @param Mage_Core_Model_Factory_Helper $helperFactory - * @param Mage_Core_Model_Dir $dirs - * @param Mage_Core_Model_Logger $logger - * @param Magento_Filesystem $filesystem - * @param Mage_Core_Model_Authorization $authSession - * @param array $data - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) - */ - public function __construct(Mage_Core_Controller_Request_Http $request, - Mage_Core_Model_Layout $layout, - Mage_Core_Model_Event_Manager $eventManager, - Mage_Backend_Model_Url $urlBuilder, - Mage_Core_Model_Translate $translator, - Mage_Core_Model_Cache $cache, - Mage_Core_Model_Design_Package $designPackage, - Mage_Core_Model_Session $session, - Mage_Core_Model_Store_Config $storeConfig, - Mage_Core_Controller_Varien_Front $frontController, - Mage_Core_Model_Factory_Helper $helperFactory, - Mage_Core_Model_Dir $dirs, - Mage_Core_Model_Logger $logger, - Magento_Filesystem $filesystem, - Mage_Core_Model_Authorization $authSession, - array $data = array() - ) { - parent::__construct($request, $layout, $eventManager, $urlBuilder, $translator, $cache, $designPackage, - $session, $storeConfig, $frontController, $helperFactory, $dirs, $logger, $filesystem, $data - ); - - if (isset($data['helpers'])) { - $this->_helpers = $data['helpers']; - } - - $this->_authSession = $authSession; - $this->setId(self::TAB_ID); - $this->setTitle($this->_helper('Mage_Tag_Helper_Data')->__('Product Tags')); - } - - /** - * Helper getter - * - * @param string $helperName - * @return Mage_Core_Helper_Abstract - */ - protected function _helper($helperName) - { - return isset($this->_helpers[$helperName]) ? $this->_helpers[$helperName] : Mage::helper($helperName); - } - - /** - * Tab label getter - * - * @return string - */ - public function getTabLabel() - { - return $this->getTitle(); - } - - /** - * Tab title getter - * - * @return string - */ - public function getTabTitle() - { - return $this->getTitle(); - } - - /** - * Check whether tab can be showed - * - * @return bool - */ - public function canShowTab() - { - return $this->_authSession->isAllowed('Mage_Tag::tag'); - } - - /** - * Check whether tab should be hidden - * - * @return bool - */ - public function isHidden() - { - return false; - } - - /** - * Tab class getter - * - * @return string - */ - public function getTabClass() - { - return 'ajax'; - } - - /** - * Tab URL getter - * - * @return string - */ - public function getTabUrl() - { - return $this->getUrl('*/*/tagGrid', array('_current' => true)); - } - - /** - * Retrieve id of tab after which current tab will be rendered - * - * @return string - */ - public function getAfter() - { - return 'reviews'; - } -} diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/Tag/Customer.php b/app/code/core/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/Tag/Customer.php deleted file mode 100644 index b8e8837857492..0000000000000 --- a/app/code/core/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/Tag/Customer.php +++ /dev/null @@ -1,194 +0,0 @@ - - * - * @method Mage_Tag_Block_Adminhtml_Catalog_Product_Edit_Tab_Tag_Customer setTitle() setTitle(string $title) - * @method array getTitle() getTitle() - */ - -class Mage_Tag_Block_Adminhtml_Catalog_Product_Edit_Tab_Tag_Customer - extends Mage_Backend_Block_Template - implements Mage_Backend_Block_Widget_Tab_Interface -{ - /** - * Id of current tab - */ - const TAB_ID = 'customers_tags'; - - /** - * Array of data helpers - * - * @var array - */ - protected $_helpers; - - /** - * Authentication session - * - * @var Mage_Core_Model_Authorization - */ - protected $_authSession; - - /** - * Set identifier and title - * - * @param Mage_Core_Controller_Request_Http $request - * @param Mage_Core_Model_Layout $layout - * @param Mage_Core_Model_Event_Manager $eventManager - * @param Mage_Backend_Model_Url $urlBuilder - * @param Mage_Core_Model_Translate $translator - * @param Mage_Core_Model_Cache $cache - * @param Mage_Core_Model_Design_Package $designPackage - * @param Mage_Core_Model_Session $session - * @param Mage_Core_Model_Store_Config $storeConfig - * @param Mage_Core_Controller_Varien_Front $frontController - * @param Mage_Core_Model_Factory_Helper $helperFactory - * @param Mage_Core_Model_Dir $dirs - * @param Mage_Core_Model_Logger $logger - * @param Magento_Filesystem $filesystem, - * @param Mage_Core_Model_Authorization $authSession - * @param array $data - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) - */ - public function __construct( - Mage_Core_Controller_Request_Http $request, - Mage_Core_Model_Layout $layout, - Mage_Core_Model_Event_Manager $eventManager, - Mage_Backend_Model_Url $urlBuilder, - Mage_Core_Model_Translate $translator, - Mage_Core_Model_Cache $cache, - Mage_Core_Model_Design_Package $designPackage, - Mage_Core_Model_Session $session, - Mage_Core_Model_Store_Config $storeConfig, - Mage_Core_Controller_Varien_Front $frontController, - Mage_Core_Model_Factory_Helper $helperFactory, - Mage_Core_Model_Dir $dirs, - Mage_Core_Model_Logger $logger, - Magento_Filesystem $filesystem, - Mage_Core_Model_Authorization $authSession, - array $data = array() - ) { - parent::__construct($request, $layout, $eventManager, $urlBuilder, $translator, $cache, $designPackage, - $session, $storeConfig, $frontController, $helperFactory, $dirs, $logger, $filesystem, $data - ); - - if (isset($data['helpers'])) { - $this->_helpers = $data['helpers']; - } - - $this->_authSession = $authSession; - $this->setId(self::TAB_ID); - $this->setTitle($this->_helper('Mage_Tag_Helper_Data')->__('Customers Tagged Product')); - } - - /** - * Helper getter - * - * @param string $helperName - * @return Mage_Core_Helper_Abstract - */ - protected function _helper($helperName) - { - return isset($this->_helpers[$helperName]) ? $this->_helpers[$helperName] : Mage::helper($helperName); - } - - /** - * Tab label getter - * - * @return string - */ - public function getTabLabel() - { - return $this->getTitle(); - } - - /** - * Tab title getter - * - * @return string - */ - public function getTabTitle() - { - return $this->getTitle(); - } - - /** - * Check whether tab can be showed - * - * @return bool - */ - public function canShowTab() - { - return $this->_authSession->isAllowed('Mage_Tag::tag'); - } - - /** - * Check whether tab should be hidden - * - * @return bool - */ - public function isHidden() - { - return false; - } - - /** - * Tab class getter - * - * @return string - */ - public function getTabClass() - { - return 'ajax'; - } - - /** - * Tab URL getter - * - * @return string - */ - public function getTabUrl() - { - return $this->getUrl('*/*/tagCustomerGrid', array('_current' => true)); - } - - /** - * Retrieve id of tab after which current tab will be rendered - * - * @return string - */ - public function getAfter() - { - return 'reviews'; - } -} diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Customer/Edit/Tab/Tag.php b/app/code/core/Mage/Tag/Block/Adminhtml/Customer/Edit/Tab/Tag.php deleted file mode 100644 index 355bb0961b457..0000000000000 --- a/app/code/core/Mage/Tag/Block/Adminhtml/Customer/Edit/Tab/Tag.php +++ /dev/null @@ -1,213 +0,0 @@ -_authSession = $authSession; - if (isset($data['helpers'])) { - $this->_helpers = $data['helpers']; - } - $this->setId('tags'); - $this->setTitle($this->_helper('Mage_Tag_Helper_Data')->__('Product Tags')); - } - - /** - * Set customer object - * - * @param Mage_Customer_Model_Customer $customer - */ - public function setCustomer(Mage_Customer_Model_Customer $customer) - { - $this->_customer = $customer; - } - - /** - * Retrieve current customer instance - * - * @return Mage_Customer_Model_Customer - */ - public function getCustomer() - { - if (!$this->_customer) { - $this->_customer = Mage::registry('current_customer'); - } - - return $this->_customer; - } - - /** - * Helper getter - * - * @param string $helperName - * @return Mage_Core_Helper_Abstract - */ - protected function _helper($helperName) - { - return isset($this->_helpers[$helperName]) ? $this->_helpers[$helperName] : Mage::helper($helperName); - } - - /** - * Tab label getter - * - * @return string - */ - public function getTabLabel() - { - return $this->getTitle(); - } - - /** - * Tab title getter - * - * @return string - */ - public function getTabTitle() - { - return $this->getTitle(); - } - - /** - * Check whether tab can be showed - * - * @return bool - */ - public function canShowTab() - { - if (!$this->getCustomer()) { - return false; - } - return $this->getCustomer()->getId() && $this->_authSession->isAllowed('Mage_Tag::tag'); - } - - /** - * Check whether tab should be hidden - * - * @return bool - */ - public function isHidden() - { - return false; - } - - /** - * Place current tab after "Product Reviews" - * - * @return string - */ - public function getAfter() - { - return 'reviews'; - } - - /** - * Tab class getter - * - * @return string - */ - public function getTabClass() - { - return 'ajax'; - } - - /** - * Tab URL getter - * - * @return string - */ - public function getTabUrl() - { - return $this->getUrl('*/customer/productTags', array('_current' => true)); - } -} diff --git a/app/code/core/Mage/Tag/Block/Adminhtml/Report/Popular/Grid.php b/app/code/core/Mage/Tag/Block/Adminhtml/Report/Popular/Grid.php deleted file mode 100644 index 12203e47275da..0000000000000 --- a/app/code/core/Mage/Tag/Block/Adminhtml/Report/Popular/Grid.php +++ /dev/null @@ -1,110 +0,0 @@ - - */ -class Mage_Tag_Block_Adminhtml_Report_Popular_Grid extends Mage_Adminhtml_Block_Widget_Grid -{ - - protected function _construct() - { - parent::_construct(); - $this->setId('grid'); - } - - protected function _prepareCollection() - { - - if ($this->getRequest()->getParam('website')) { - $storeId = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds(); - } else if ($this->getRequest()->getParam('group')) { - $storeId = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds(); - } else if ($this->getRequest()->getParam('store')) { - $storeId = (int)$this->getRequest()->getParam('store'); - } else { - $storeId = ''; - } - - $collection = Mage::getResourceModel('Mage_Tag_Model_Resource_Reports_Collection') - ->addPopularity($storeId) - ->addStatusFilter(Mage_Tag_Model_Tag::STATUS_APPROVED); - - $this->setCollection($collection); - return parent::_prepareCollection(); - } - - protected function _prepareColumns() - { - $this->addColumn('name', array( - 'header' =>Mage::helper('Mage_Tag_Helper_Data')->__('Tag Name'), - 'index' =>'name' - )); - - $this->addColumn('taged', array( - 'header' =>Mage::helper('Mage_Tag_Helper_Data')->__('Popularity'), - 'width' =>'50px', - 'align' =>'right', - 'index' =>'popularity' - )); - - $this->addColumn('action', - array( - 'header' => Mage::helper('Mage_Tag_Helper_Data')->__('Action'), - 'width' => '100%', - 'type' => 'action', - 'getter' => 'getId', - 'actions' => array( - array( - 'caption' => Mage::helper('Mage_Tag_Helper_Data')->__('Show Details'), - 'url' => array( - 'base'=>'*/*/tagDetail' - ), - 'field' => 'id' - ) - ), - 'is_system' => true, - 'filter' => false, - 'sortable' => false, - 'index' => 'stores', - )); - $this->setFilterVisibility(false); - - $this->addExportType('*/*/exportPopularCsv', Mage::helper('Mage_Tag_Helper_Data')->__('CSV')); - $this->addExportType('*/*/exportPopularExcel', Mage::helper('Mage_Tag_Helper_Data')->__('Excel XML')); - - return parent::_prepareColumns(); - } - - public function getRowUrl($row) - { - return $this->getUrl('*/*/tagDetail', array('id'=>$row->getTagId())); - } -} diff --git a/app/code/core/Mage/Tag/Block/Customer/View.php b/app/code/core/Mage/Tag/Block/Customer/View.php deleted file mode 100644 index 2088731953570..0000000000000 --- a/app/code/core/Mage/Tag/Block/Customer/View.php +++ /dev/null @@ -1,183 +0,0 @@ - - */ -class Mage_Tag_Block_Customer_View extends Mage_Catalog_Block_Product_Abstract -{ - /** - * Tagged Product Collection - * - * @var Mage_Tag_Model_Resource_Product_Collection - */ - protected $_collection; - - /** - * Current Tag object - * - * @var Mage_Tag_Model_Tag - */ - protected $_tagInfo; - - /** - * Initialize block - * - */ - protected function _construct() - { - parent::_construct(); - $this->setTagId(Mage::registry('tagId')); - } - - /** - * Retrieve current Tag object - * - * @return Mage_Tag_Model_Tag - */ - public function getTagInfo() - { - if (is_null($this->_tagInfo)) { - $this->_tagInfo = Mage::getModel('Mage_Tag_Model_Tag') - ->load($this->getTagId()); - } - return $this->_tagInfo; - } - - /** - * Retrieve Tagged Product Collection items - * - * @return array - */ - public function getMyProducts() - { - return $this->_getCollection()->getItems(); - } - - /** - * Retrieve count of Tagged Product(s) - * - * @return int - */ - public function getCount() - { - return sizeof($this->getMyProducts()); - } - - /** - * Retrieve Product Info URL - * - * @param int $productId - * @return string - */ - public function getReviewUrl($productId) - { - return Mage::getUrl('review/product/list', array('id' => $productId)); - } - - /** - * Preparing block layout - * - * @return Mage_Tag_Block_Customer_View - */ - protected function _prepareLayout() - { - $toolbar = $this->getLayout() - ->createBlock('Mage_Page_Block_Html_Pager', 'customer_tag_list.toolbar') - ->setCollection($this->_getCollection()); - - $this->setChild('toolbar', $toolbar); - return parent::_prepareLayout(); - } - - /** - * Retrieve Toolbar block HTML - * - * @return string - */ - public function getToolbarHtml() - { - return $this->getChildHtml('toolbar'); - } - - /** - * Retrieve Current Mode - * - * @return string - */ - public function getMode() - { - return $this->getChildBlock('toolbar')->getCurrentMode(); - } - - /** - * Retrieve Tagged product(s) collection - * - * @return Mage_Tag_Model_Resource_Product_Collection - */ - protected function _getCollection() - { - if (is_null($this->_collection)) { - $this->_collection = Mage::getModel('Mage_Tag_Model_Tag') - ->getEntityCollection() - ->addTagFilter($this->getTagId()) - ->addCustomerFilter(Mage::getSingleton('Mage_Customer_Model_Session')->getCustomerId()) - ->addStoreFilter(Mage::app()->getStore()->getId()) - ->addAttributeToSelect(Mage::getSingleton('Mage_Catalog_Model_Config')->getProductAttributes()) - ->setActiveFilter() - ->setVisibility(Mage::getSingleton('Mage_Catalog_Model_Product_Visibility')->getVisibleInSiteIds()); - } - return $this->_collection; - } - - /** - * Product image url getter - * - * @param Mage_Core_Model_Product $product - * @return string - */ - public function getImageUrl($product) - { - return (string) $this->helper('Mage_Catalog_Helper_Image')->init($product, 'small_image') - ->resize($this->getImageSize()); - } - - /** - * Product image size getter - * - * @return int - */ - public function getImageSize() - { - return $this->getVar('product_image_size', 'Mage_Tag'); - } - -} diff --git a/app/code/core/Mage/Tag/etc/adminhtml/acl.xml b/app/code/core/Mage/Tag/etc/adminhtml/acl.xml deleted file mode 100644 index 825135e577152..0000000000000 --- a/app/code/core/Mage/Tag/etc/adminhtml/acl.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Tag/etc/adminhtml/menu.xml b/app/code/core/Mage/Tag/etc/adminhtml/menu.xml deleted file mode 100644 index 3c55af4099c3e..0000000000000 --- a/app/code/core/Mage/Tag/etc/adminhtml/menu.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Tag/etc/config.xml b/app/code/core/Mage/Tag/etc/config.xml deleted file mode 100644 index a1a9209761167..0000000000000 --- a/app/code/core/Mage/Tag/etc/config.xml +++ /dev/null @@ -1,156 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - - - - Mage_Tag - - - - - - - Mage_Tag_Model_Indexer_Summary - - - - - - - - Mage_Tag_Model_Session - - - - - - - - - - - Mage_Tag_Rss - - - - - standard - - Mage_Tag - tag - - - - - - - - Mage_Tag.csv - - - - - - - - layout.xml - - - rss.xml - - - - - /tag/customer/ - - - - - - - - Mage_Tag_Adminhtml - - - - - - - - - - - model - Mage_Tag_Model_Tag - productDeleteEventAction - - - - - - - - - Mage_Tag.csv - - - - - - - - product.xml - - - customer.xml - - - tag.xml - - - report.xml - - - - - diff --git a/app/code/core/Mage/Tag/view/adminhtml/tag/edit/container.phtml b/app/code/core/Mage/Tag/view/adminhtml/tag/edit/container.phtml deleted file mode 100644 index 877bb5b8898d6..0000000000000 --- a/app/code/core/Mage/Tag/view/adminhtml/tag/edit/container.phtml +++ /dev/null @@ -1,53 +0,0 @@ - -getFormInitScripts() ?> -
    - getHeaderHtml() ?> -

    getButtonsHtml('header') ?>

    -
    -isSingleStoreMode() ): ?> - getStoreSwitcherHtml() ?> - - -
    - getFormHtml() ?> - - getTagAssignAccordionHtml() ?> - -
    - -hasFooterButtons()): ?> - - - -getFormScripts() ?> -getAcordionsHtml() ?> diff --git a/app/code/core/Mage/Tax/Helper/Data.php b/app/code/core/Mage/Tax/Helper/Data.php deleted file mode 100644 index 5789d35467c37..0000000000000 --- a/app/code/core/Mage/Tax/Helper/Data.php +++ /dev/null @@ -1,905 +0,0 @@ -_config = Mage::getSingleton('Mage_Tax_Model_Config'); - } - - /** - * Return max postcode length to create search templates - * - * @return integer $len - */ - public function getPostCodeSubStringLength() - { - $len = (int)$this->_postCodeSubStringLength; - if ($len <= 0) { - $len = 10; - } - return $len; - } - - /** - * Get tax configuration object - * - * @return Mage_Tax_Model_Config - */ - public function getConfig() - { - return $this->_config; - } - - /** - * Get tax calculation object - * - * @return Mage_Tac_Model_Calculation - */ - public function getCalculator() - { - if ($this->_calculator === null) { - $this->_calculator = Mage::getSingleton('Mage_Tax_Model_Calculation'); - } - return $this->_calculator; - } - - /** - * Get product price including store convertion rate - * - * @param Mage_Catalog_Model_Product $product - * @param null|string $format - * @return float|string - */ - public function getProductPrice($product, $format=null) - { - try { - $value = $product->getPrice(); - $value = Mage::app()->getStore()->convertPrice($value, $format); - } catch (Exception $e){ - $value = $e->getMessage(); - } - return $value; - } - - /** - * Check if product prices inputed include tax - * - * @param mix $store - * @return bool - */ - public function priceIncludesTax($store=null) - { - return $this->_config->priceIncludesTax($store) || $this->_config->getNeedUseShippingExcludeTax(); - } - - /** - * Check what taxes should be applied after discount - * - * @param mixed $store - * @return bool - */ - public function applyTaxAfterDiscount($store=null) - { - return $this->_config->applyTaxAfterDiscount($store); - } - - /** - * Output - * - * @param boolean $includes - */ - public function getIncExcText($flag, $store=null) - { - if ($flag) { - $s = $this->__('Incl. Tax'); - } else { - $s = $this->__('Excl. Tax'); - } - return $s; - } - - /** - * Get product price display type - * 1 - Excluding tax - * 2 - Including tax - * 3 - Both - * - * @param mixed $store - * @return int - */ - public function getPriceDisplayType($store = null) - { - return $this->_config->getPriceDisplayType($store); - } - - /** - * Check if necessary do product price conversion - * If it necessary will be returned conversion type (minus or plus) - * - * @param mixed $store - * @return false | int - */ - public function needPriceConversion($store = null) - { - $res = false; - if ($this->priceIncludesTax($store)) { - switch ($this->getPriceDisplayType($store)) { - case Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX: - case Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH: - return self::PRICE_CONVERSION_MINUS; - case Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX: - $res = true; - } - } else { - switch ($this->getPriceDisplayType($store)) { - case Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX: - case Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH: - return self::PRICE_CONVERSION_PLUS; - case Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX: - $res = false; - } - } - - if ($res === false) { - $res = $this->displayTaxColumn($store); - } - return $res; - } - - /** - * Check if need display full tax summary information in totals block - * - * @param mixed $store - * @return bool - */ - public function displayFullSummary($store = null) - { - return $this->_config->displayCartFullSummary($store); - } - - /** - * Check if need display zero tax in subtotal - * - * @param mixed $store - * @return bool - */ - public function displayZeroTax($store = null) - { - return $this->_config->displayCartZeroTax($store); - } - - /** - * Check if need display cart prices included tax - * - * @param mixed $store - * @return bool - */ - public function displayCartPriceInclTax($store = null) - { - return $this->_config->displayCartPricesInclTax($store); - } - - /** - * Check if need display cart prices excluding price - * - * @param mixed $store - * @return bool - */ - public function displayCartPriceExclTax($store = null) - { - return $this->_config->displayCartPricesExclTax($store); - } - - /** - * Check if need display cart prices excluding and including tax - * - * @param mixed $store - * @return bool - */ - public function displayCartBothPrices($store = null) - { - return $this->_config->displayCartPricesBoth($store); - } - - /** - * Check if need display order prices included tax - * - * @param mixed $store - * @return bool - */ - public function displaySalesPriceInclTax($store = null) - { - return $this->_config->displaySalesPricesInclTax($store); - } - - /** - * Check if need display order prices excluding price - * - * @param mixed $store - * @return bool - */ - public function displaySalesPriceExclTax($store = null) - { - return $this->_config->displaySalesPricesExclTax($store); - } - - /** - * Check if need display order prices excluding and including tax - * - * @param mixed $store - * @return bool - */ - public function displaySalesBothPrices($store = null) - { - return $this->_config->displaySalesPricesBoth($store); - } - - - /** - * Check if we need display price include and exclude tax for order/invoice subtotal - * - * @param mixed $store - * @return bool - */ - public function displaySalesSubtotalBoth($store = null) - { - return $this->_config->displaySalesSubtotalBoth($store); - } - - /** - * Check if we need display price include tax for order/invoice subtotal - * - * @param mixed $store - * @return bool - */ - public function displaySalesSubtotalInclTax($store = null) - { - return $this->_config->displaySalesSubtotalInclTax($store); - } - - /** - * Check if we need display price exclude tax for order/invoice subtotal - * - * @param mixed $store - * @return bool - */ - public function displaySalesSubtotalExclTax($store = null) - { - return $this->_config->displaySalesSubtotalExclTax($store); - } - - /** - * Check if need display tax column in for shopping cart/order items - * - * @param mixed $store - * @return bool - */ - public function displayTaxColumn($store = null) - { - return $this->_config->displayCartPricesBoth(); - } - - /** - * Get prices javascript format json - * - * @param mixed $store - * @return string - */ - public function getPriceFormat($store = null) - { - Mage::app()->getLocale()->emulate($store); - $priceFormat = Mage::app()->getLocale()->getJsPriceFormat(); - Mage::app()->getLocale()->revert(); - if ($store) { - $priceFormat['pattern'] = Mage::app()->getStore($store)->getCurrentCurrency()->getOutputFormat(); - } - return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($priceFormat); - } - - /** - * Get all tax rates JSON for all product tax classes of specific store - * - * array( - * value_{$productTaxVlassId} => $rate - * ) - * @return string - */ - public function getAllRatesByProductClass($store=null) - { - return $this->_getAllRatesByProductClass($store); - } - - - /** - * Get all tax rates JSON for all product tax classes of specific store - * - * array( - * value_{$productTaxVlassId} => $rate - * ) - * @return string - */ - protected function _getAllRatesByProductClass($store=null) - { - $result = array(); - $calc = Mage::getSingleton('Mage_Tax_Model_Calculation'); - $rates = $calc->getRatesForAllProductTaxClasses($calc->getRateOriginRequest($store)); - - foreach ($rates as $class=>$rate) { - $result["value_{$class}"] = $rate; - } - - return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($result); - } - - /** - * Get product price with all tax settings processing - * - * @param Mage_Catalog_Model_Product $product - * @param float $price inputed product price - * @param bool $includingTax return price include tax flag - * @param null|Mage_Customer_Model_Address $shippingAddress - * @param null|Mage_Customer_Model_Address $billingAddress - * @param null|int $ctc customer tax class - * @param mixed $store - * @param bool $priceIncludesTax flag what price parameter contain tax - * @return float - */ - public function getPrice($product, $price, $includingTax = null, $shippingAddress = null, $billingAddress = null, - $ctc = null, $store = null, $priceIncludesTax = null - ) { - if (!$price) { - return $price; - } - $store = Mage::app()->getStore($store); - if (!$this->needPriceConversion($store)) { - return $store->roundPrice($price); - } - if (is_null($priceIncludesTax)) { - $priceIncludesTax = $this->priceIncludesTax($store); - } - - $percent = $product->getTaxPercent(); - $includingPercent = null; - - $taxClassId = $product->getTaxClassId(); - if (is_null($percent)) { - if ($taxClassId) { - $request = Mage::getSingleton('Mage_Tax_Model_Calculation') - ->getRateRequest($shippingAddress, $billingAddress, $ctc, $store); - $percent = Mage::getSingleton('Mage_Tax_Model_Calculation') - ->getRate($request->setProductClassId($taxClassId)); - } - } - if ($taxClassId && $priceIncludesTax) { - $request = Mage::getSingleton('Mage_Tax_Model_Calculation')->getRateRequest(false, false, false, $store); - $includingPercent = Mage::getSingleton('Mage_Tax_Model_Calculation') - ->getRate($request->setProductClassId($taxClassId)); - } - - if ($percent === false || is_null($percent)) { - if ($priceIncludesTax && !$includingPercent) { - return $price; - } - } - - $product->setTaxPercent($percent); - - if (!is_null($includingTax)) { - if ($priceIncludesTax) { - if ($includingTax) { - /** - * Recalculate price include tax in case of different rates - */ - if ($includingPercent != $percent) { - $price = $this->_calculatePrice($price, $includingPercent, false); - /** - * Using regular rounding. Ex: - * price incl tax = 52.76 - * store tax rate = 19.6% - * customer tax rate= 19% - * - * price excl tax = 52.76 / 1.196 = 44.11371237 ~ 44.11 - * tax = 44.11371237 * 0.19 = 8.381605351 ~ 8.38 - * price incl tax = 52.49531773 ~ 52.50 != 52.49 - * - * that why we need round prices excluding tax before applying tax - * this calculation is used for showing prices on catalog pages - */ - if ($percent != 0) { - $price = $this->getCalculator()->round($price); - $price = $this->_calculatePrice($price, $percent, true); - } - } - } else { - $price = $this->_calculatePrice($price, $includingPercent, false); - } - } else { - if ($includingTax) { - $price = $this->_calculatePrice($price, $percent, true); - } - } - } else { - if ($priceIncludesTax) { - switch ($this->getPriceDisplayType($store)) { - case Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX: - case Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH: - $price = $this->_calculatePrice($price, $includingPercent, false); - break; - - case Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX: - $price = $this->_calculatePrice($price, $includingPercent, false); - $price = $this->_calculatePrice($price, $percent, true); - break; - } - } else { - switch ($this->getPriceDisplayType($store)) { - case Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX: - $price = $this->_calculatePrice($price, $percent, true); - break; - - case Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH: - case Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX: - break; - } - } - } - return $store->roundPrice($price); - } - - /** - * Check if we have display in catalog prices including tax - * - * @return bool - */ - public function displayPriceIncludingTax() - { - return $this->getPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX; - } - - /** - * Check if we have display in catalog prices excluding tax - * - * @return bool - */ - public function displayPriceExcludingTax() - { - return $this->getPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX; - } - - /** - * Check if we have display in catalog prices including and excluding tax - * - * @return bool - */ - public function displayBothPrices() - { - return $this->getPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH; - } - - /** - * Calculate price imcluding/excluding tax base on tax rate percent - * - * @param float $price - * @param float $percent - * @param bool $type true - for calculate price including tax and false if price excluding tax - * @return float - */ - protected function _calculatePrice($price, $percent, $type) - { - $calculator = Mage::getSingleton('Mage_Tax_Model_Calculation'); - if ($type) { - $taxAmount = $calculator->calcTaxAmount($price, $percent, false, false); - return $price + $taxAmount; - } else { - $taxAmount = $calculator->calcTaxAmount($price, $percent, true, false); - return $price - $taxAmount; - } - } - - public function getIncExcTaxLabel($flag) - { - $text = $this->getIncExcText($flag); - return $text ? ' ('.$text.')' : ''; - } - - public function shippingPriceIncludesTax($store = null) - { - return $this->_config->shippingPriceIncludesTax($store); - } - - public function getShippingPriceDisplayType($store = null) - { - return $this->_config->getShippingPriceDisplayType($store); - } - - public function displayShippingPriceIncludingTax() - { - return $this->getShippingPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX; - } - - public function displayShippingPriceExcludingTax() - { - return $this->getShippingPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX; - } - - public function displayShippingBothPrices() - { - return $this->getShippingPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH; - } - - public function getShippingTaxClass($store) - { - return $this->_config->getShippingTaxClass($store); - } - - /** - * Get shipping price - * - * @return float - */ - public function getShippingPrice($price, $includingTax = null, $shippingAddress = null, $ctc = null, $store = null) - { - $pseudoProduct = new Varien_Object(); - $pseudoProduct->setTaxClassId($this->getShippingTaxClass($store)); - - $billingAddress = false; - if ($shippingAddress && $shippingAddress->getQuote() && $shippingAddress->getQuote()->getBillingAddress()) { - $billingAddress = $shippingAddress->getQuote()->getBillingAddress(); - } - - $price = $this->getPrice( - $pseudoProduct, - $price, - $includingTax, - $shippingAddress, - $billingAddress, - $ctc, - $store, - $this->shippingPriceIncludesTax($store) - ); - return $price; - } - - public function getPriceTaxSql($priceField, $taxClassField) - { - if (!$this->priceIncludesTax() && $this->displayPriceExcludingTax()) { - return ''; - } - - $request = Mage::getSingleton('Mage_Tax_Model_Calculation')->getRateRequest(false, false, false); - $defaultTaxes = Mage::getSingleton('Mage_Tax_Model_Calculation')->getRatesForAllProductTaxClasses($request); - - $request = Mage::getSingleton('Mage_Tax_Model_Calculation')->getRateRequest(); - $currentTaxes = Mage::getSingleton('Mage_Tax_Model_Calculation')->getRatesForAllProductTaxClasses($request); - - $defaultTaxString = $currentTaxString = ''; - - $rateToVariable = array( - 'defaultTaxString'=>'defaultTaxes', - 'currentTaxString'=>'currentTaxes', - ); - foreach ($rateToVariable as $rateVariable=>$rateArray) { - if ($$rateArray && is_array($$rateArray)) { - $$rateVariable = ''; - foreach ($$rateArray as $classId=>$rate) { - if ($rate) { - $$rateVariable .= sprintf("WHEN %d THEN %12.4f ", $classId, $rate/100); - } - } - if ($$rateVariable) { - $$rateVariable = "CASE {$taxClassField} {$$rateVariable} ELSE 0 END"; - } - } - } - - $result = ''; - - if ($this->priceIncludesTax()) { - if ($defaultTaxString) { - $result = "-({$priceField}/(1+({$defaultTaxString}))*{$defaultTaxString})"; - } - if (!$this->displayPriceExcludingTax() && $currentTaxString) { - $result .= "+(({$priceField}{$result})*{$currentTaxString})"; - } - } else { - if ($this->displayPriceIncludingTax()) { - if ($currentTaxString) { - $result .= "+({$priceField}*{$currentTaxString})"; - } - } - } - return $result; - } - - /** - * Join tax class - * @param Varien_Db_Select $select - * @param int $storeId - * @param string $priceTable - * @return Mage_Tax_Helper_Data - */ - public function joinTaxClass($select, $storeId, $priceTable = 'main_table') - { - $taxClassAttribute = Mage::getModel('Mage_Eav_Model_Entity_Attribute') - ->loadByCode(Mage_Catalog_Model_Product::ENTITY, 'tax_class_id'); - $joinConditionD = implode(' AND ',array( - "tax_class_d.entity_id = {$priceTable}.entity_id", - $select->getAdapter()->quoteInto('tax_class_d.attribute_id = ?', (int)$taxClassAttribute->getId()), - 'tax_class_d.store_id = 0' - )); - $joinConditionC = implode(' AND ',array( - "tax_class_c.entity_id = {$priceTable}.entity_id", - $select->getAdapter()->quoteInto('tax_class_c.attribute_id = ?', (int)$taxClassAttribute->getId()), - $select->getAdapter()->quoteInto('tax_class_c.store_id = ?', (int)$storeId) - )); - $select - ->joinLeft( - array('tax_class_d' => $taxClassAttribute->getBackend()->getTable()), - $joinConditionD, - array()) - ->joinLeft( - array('tax_class_c' => $taxClassAttribute->getBackend()->getTable()), - $joinConditionC, - array()); - - return $this; - } - - /** - * Get configuration setting "Apply Discount On Prices Including Tax" value - * - * @param null|int $store - * @return 0|1 - */ - public function discountTax($store=null) - { - return $this->_config->discountTax($store); - } - - /** - * Get value of "Apply Tax On" custom/original price configuration settings - * - * @param $store - * @return 0|1 - */ - public function getTaxBasedOn($store = null) - { - return Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_BASED_ON, $store); - } - - /** - * Check if tax can be applied to custom price - * - * @param $store - * @return bool - */ - public function applyTaxOnCustomPrice($store = null) - { - return ((int) Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_APPLY_ON, $store) == 0); - } - - /** - * Check if tax should be applied just to original price - * - * @param $store - * @return bool - */ - public function applyTaxOnOriginalPrice($store = null) - { - return ((int) Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_APPLY_ON, $store) == 1); - } - - /** - * Get taxes/discounts calculation sequence. - * This sequence depends on "Catalog price include tax", "Apply Tax After Discount" - * and "Apply Discount On Prices Including Tax" configuration options. - * - * @param null|int|string|Mage_Core_Model_Store $store - * @return string - */ - public function getCalculationSequence($store=null) - { - return $this->_config->getCalculationSequence($store); - } - - /** - * Get tax caclulation algorithm code - * - * @param null|int $store - * @return string - */ - public function getCalculationAgorithm($store=null) - { - return $this->_config->getAlgorithm($store); - } - - /** - * Get calculated taxes for each tax class - * - * This method returns array with format: - * array( - * $index => array( - * 'tax_amount' => $taxAmount, - * 'base_tax_amount' => $baseTaxAmount, - * 'hidden_tax_amount' => $hiddenTaxAmount - * 'title' => $title - * 'percent' => $percent - * ) - * ) - * - * @param Mage_Sales_Model_Order $source - * @return array - */ - public function getCalculatedTaxes($source) - { - if (Mage::registry('current_invoice')) { - $current = Mage::registry('current_invoice'); - } elseif (Mage::registry('current_creditmemo')) { - $current = Mage::registry('current_creditmemo'); - } else { - $current = $source; - } - - $taxClassAmount = array(); - if ($current && $source) { - foreach($current->getItemsCollection() as $item) { - $taxCollection = Mage::getResourceModel('Mage_Tax_Model_Resource_Sales_Order_Tax_Item') - ->getTaxItemsByItemId( - $item->getOrderItemId() ? $item->getOrderItemId() : $item->getItemId() - ); - - foreach ($taxCollection as $tax) { - $taxClassId = $tax['tax_id']; - $percent = $tax['tax_percent']; - - $price = $item->getRowTotal(); - $basePrice = $item->getBaseRowTotal(); - if ($this->applyTaxAfterDiscount($item->getStoreId())) { - $price = $price - $item->getDiscountAmount() + $item->getHiddenTaxAmount(); - $basePrice = $basePrice - $item->getBaseDiscountAmount() + $item->getBaseHiddenTaxAmount(); - } - - if (isset($taxClassAmount[$taxClassId])) { - $taxClassAmount[$taxClassId]['tax_amount'] += $price * $percent / 100; - $taxClassAmount[$taxClassId]['base_tax_amount'] += $basePrice * $percent / 100; - } else { - $taxClassAmount[$taxClassId]['tax_amount'] = $price * $percent / 100; - $taxClassAmount[$taxClassId]['base_tax_amount'] = $basePrice * $percent / 100; - $taxClassAmount[$taxClassId]['title'] = $tax['title']; - $taxClassAmount[$taxClassId]['percent'] = $tax['percent']; - } - } - } - - foreach ($taxClassAmount as $key=>$tax) { - if ($tax['tax_amount'] == 0 && $tax['base_tax_amount'] == 0) { - unset($taxClassAmount[$key]); - } - } - - $taxClassAmount = array_values($taxClassAmount); - } - - return $taxClassAmount; - } - - /** - * Get calculated Shipping & Handling Tax - * - * This method returns array with format: - * array( - * $index => array( - * 'tax_amount' => $taxAmount, - * 'base_tax_amount' => $baseTaxAmount, - * 'hidden_tax_amount' => $hiddenTaxAmount - * 'title' => $title - * 'percent' => $percent - * ) - * ) - * - * @param Mage_Sales_Model_Order $source - * @return array - */ - public function getShippingTax($source) - { - if (Mage::registry('current_invoice')) { - $current = Mage::registry('current_invoice'); - } elseif (Mage::registry('current_creditmemo')) { - $current = Mage::registry('current_creditmemo'); - } else { - $current = $source; - } - - $taxClassAmount = array(); - if ($current && $source) { - if ($current->getShippingTaxAmount() != 0 && $current->getBaseShippingTaxAmount() != 0) { - $taxClassAmount[0]['tax_amount'] = $current->getShippingTaxAmount(); - $taxClassAmount[0]['base_tax_amount'] = $current->getBaseShippingTaxAmount(); - if ($current->getShippingHiddenTaxAmount() > 0) { - $taxClassAmount[0]['hidden_tax_amount'] = $current->getShippingHiddenTaxAmount(); - } - $taxClassAmount[0]['title'] = $this->__('Shipping & Handling Tax'); - $taxClassAmount[0]['percent'] = NULL; - } - } - - return $taxClassAmount; - } - - /** - * Retrieve default customer tax class from config - */ - public function getDefaultCustomerTaxClass() - { - return Mage::getStoreConfig(self::CONFIG_DEFAULT_CUSTOMER_TAX_CLASS); - } - - /** - * Retrieve default product tax class from config - */ - public function getDefaultProductTaxClass() - { - return Mage::getStoreConfig(self::CONFIG_DEFAULT_PRODUCT_TAX_CLASS); - } - -} diff --git a/app/code/core/Mage/Tax/Model/Calculation/Rule.php b/app/code/core/Mage/Tax/Model/Calculation/Rule.php deleted file mode 100644 index 924a96399e489..0000000000000 --- a/app/code/core/Mage/Tax/Model/Calculation/Rule.php +++ /dev/null @@ -1,223 +0,0 @@ - - */ -class Mage_Tax_Model_Calculation_Rule extends Mage_Core_Model_Abstract -{ - protected $_ctcs = null; - protected $_ptcs = null; - protected $_rates = null; - - protected $_ctcModel = null; - protected $_ptcModel = null; - protected $_rateModel = null; - - protected $_calculationModel = null; - - /** - * Helper - * - * @var Mage_Tax_Helper_Data - */ - protected $_helper; - - /** - * Tax Model Class - * - * @var Mage_Tax_Model_Class - */ - protected $_taxClass; - - /** - * Varien model constructor - */ - public function __construct( - Mage_Core_Model_Event_Manager $eventDispatcher, - Mage_Core_Model_Cache $cacheManager, - Mage_Tax_Helper_Data $taxHelper, - Mage_Tax_Model_Class $taxClass, - Mage_Core_Model_Resource_Abstract $resource = null, - Varien_Data_Collection_Db $resourceCollection = null, - array $data = array() - ) { - parent::__construct( - $eventDispatcher, - $cacheManager, - $resource, - $resourceCollection, - $data - ); - - $this->_init('Mage_Tax_Model_Resource_Calculation_Rule'); - - $this->_helper = $taxHelper; - $this->_taxClass = $taxClass; - } - - /** - * After save rule - * Redeclared for populate rate calculations - * - * @return Mage_Tax_Model_Calculation_Rule - */ - protected function _afterSave() - { - parent::_afterSave(); - $this->saveCalculationData(); - Mage::dispatchEvent('tax_settings_change_after'); - return $this; - } - - /** - * After rule delete - * redeclared for dispatch tax_settings_change_after event - * - * @return Mage_Tax_Model_Calculation_Rule - */ - protected function _afterDelete() - { - Mage::dispatchEvent('tax_settings_change_after'); - return parent::_afterDelete(); - } - - public function saveCalculationData() - { - $ctc = $this->getData('tax_customer_class'); - $ptc = $this->getData('tax_product_class'); - $rates = $this->getData('tax_rate'); - - Mage::getSingleton('Mage_Tax_Model_Calculation')->deleteByRuleId($this->getId()); - foreach ($ctc as $c) { - foreach ($ptc as $p) { - foreach ($rates as $r) { - $dataArray = array( - 'tax_calculation_rule_id' =>$this->getId(), - 'tax_calculation_rate_id' =>$r, - 'customer_tax_class_id' =>$c, - 'product_tax_class_id' =>$p, - ); - Mage::getSingleton('Mage_Tax_Model_Calculation')->setData($dataArray)->save(); - } - } - } - } - - public function getCalculationModel() - { - if (is_null($this->_calculationModel)) { - $this->_calculationModel = Mage::getSingleton('Mage_Tax_Model_Calculation'); - } - return $this->_calculationModel; - } - - public function getRates() - { - return $this->getCalculationModel()->getRates($this->getId()); - } - - public function getCustomerTaxClasses() - { - return $this->getCalculationModel()->getCustomerTaxClasses($this->getId()); - } - - public function getProductTaxClasses() - { - return $this->getCalculationModel()->getProductTaxClasses($this->getId()); - } - - /** - * Check Customer Tax Class and if it is empty - use defaults - * - * @return int|array|null - */ - public function getCustomerTaxClassWithDefault() - { - $customerClasses = $this->getAllOptionsForClass(Mage_Tax_Model_Class::TAX_CLASS_TYPE_CUSTOMER); - if (empty($customerClasses)) { - return null; - } - - $configValue = $this->_helper->getDefaultCustomerTaxClass(); - if (!empty($configValue)) { - return $configValue; - } - - $firstClass = array_shift($customerClasses); - return isset($firstClass['value']) ? $firstClass['value'] : null; - } - - /** - * Check Product Tax Class and if it is empty - use defaults - * - * @return int|array|null - */ - public function getProductTaxClassWithDefault() - { - $productClasses = $this->getAllOptionsForClass(Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT); - if (empty($productClasses)) { - return null; - } - - $configValue = $this->_helper->getDefaultProductTaxClass(); - if (!empty($configValue)) { - return $configValue; - } - - $firstClass = array_shift($productClasses); - return isset($firstClass['value']) ? $firstClass['value'] : null; - } - - /** - * Get all possible options for specified class name (customer|product) - * - * @param string $classFilter - * @return array - */ - public function getAllOptionsForClass($classFilter) { - $classes = $this->_taxClass - ->getCollection() - ->setClassTypeFilter($classFilter) - ->toOptionArray(); - - return $classes; - } -} - diff --git a/app/code/core/Mage/Tax/Model/Class/Source/Product.php b/app/code/core/Mage/Tax/Model/Class/Source/Product.php deleted file mode 100644 index 3da5f98f2daa0..0000000000000 --- a/app/code/core/Mage/Tax/Model/Class/Source/Product.php +++ /dev/null @@ -1,117 +0,0 @@ -_options)) { - $this->_options = Mage::getResourceModel('Mage_Tax_Model_Resource_Class_Collection') - ->addFieldToFilter('class_type', Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT) - ->load() - ->toOptionArray(); - } - - $options = $this->_options; - array_unshift($options, array('value'=>'0', 'label'=>Mage::helper('Mage_Tax_Helper_Data')->__('None'))); - if ($withEmpty) { - array_unshift($options, array('value'=>'', 'label'=>Mage::helper('Mage_Tax_Helper_Data')->__('-- Please Select --'))); - } - return $options; - } - - /** - * Get a text for option value - * - * @param string|integer $value - * @return string - */ - public function getOptionText($value) - { - $options = $this->getAllOptions(false); - - foreach ($options as $item) { - if ($item['value'] == $value) { - return $item['label']; - } - } - return false; - } - - /** - * Convert to options array - * - * @return array - */ - public function toOptionArray() - { - return $this->getAllOptions(); - } - - /** - * Retrieve flat column definition - * - * @return array - */ - public function getFlatColums() - { - $attributeCode = $this->getAttribute()->getAttributeCode(); - $column = array( - 'unsigned' => true, - 'default' => null, - 'extra' => null - ); - - if (Mage::helper('Mage_Core_Helper_Data')->useDbCompatibleMode()) { - $column['type'] = 'int'; - $column['is_null'] = true; - } else { - $column['type'] = Varien_Db_Ddl_Table::TYPE_INTEGER; - $column['nullable'] = true; - $column['comment'] = $attributeCode . ' tax column'; - } - - return array($attributeCode => $column); - } - - /** - * Retrieve Select for update attribute value in flat table - * - * @param int $store - * @return Varien_Db_Select|null - */ - public function getFlatUpdateSelect($store) - { - return Mage::getResourceModel('Mage_Eav_Model_Resource_Entity_Attribute_Option') - ->getFlatUpdateSelect($this->getAttribute(), $store, false); - } -} diff --git a/app/code/core/Mage/Tax/data/tax_setup/data-install-1.6.0.0.php b/app/code/core/Mage/Tax/data/tax_setup/data-install-1.6.0.0.php deleted file mode 100644 index e5c0be9f75b93..0000000000000 --- a/app/code/core/Mage/Tax/data/tax_setup/data-install-1.6.0.0.php +++ /dev/null @@ -1,101 +0,0 @@ - 2, - 'class_name' => 'Taxable Goods', - 'class_type' => Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT - ), - array( - 'class_id' => 3, - 'class_name' => 'Retail Customer', - 'class_type' => Mage_Tax_Model_Class::TAX_CLASS_TYPE_CUSTOMER - ) -); -foreach ($data as $row) { - $installer->getConnection()->insertForce($installer->getTable('tax_class'), $row); -} - -/** - * install tax calculation rule - */ -$data = array( - 'tax_calculation_rule_id' => 1, - 'code' => 'Retail Customer-Taxable Goods-Rate 1', - 'priority' => 1, - 'position' => 1 -); -$installer->getConnection()->insertForce($installer->getTable('tax_calculation_rule'), $data); - -/** - * install tax calculation rates - */ -$data = array( - array( - 'tax_calculation_rate_id' => 1, - 'tax_country_id' => 'US', - 'tax_region_id' => 12, - 'tax_postcode' => '*', - 'code' => 'US-CA-*-Rate 1', - 'rate' => '8.2500' - ), - array( - 'tax_calculation_rate_id' => 2, - 'tax_country_id' => 'US', - 'tax_region_id' => 43, - 'tax_postcode' => '*', - 'code' => 'US-NY-*-Rate 1', - 'rate' => '8.3750' - ) -); -foreach ($data as $row) { - $installer->getConnection()->insertForce($installer->getTable('tax_calculation_rate'), $row); -} - -/** - * install tax calculation - */ -$data = array( - array( - 'tax_calculation_rate_id' => 1, - 'tax_calculation_rule_id' => 1, - 'customer_tax_class_id' => 3, - 'product_tax_class_id' => 2 - ), - array( - 'tax_calculation_rate_id' => 2, - 'tax_calculation_rule_id' => 1, - 'customer_tax_class_id' => 3, - 'product_tax_class_id' => 2 - ) -); -$installer->getConnection()->insertMultiple($installer->getTable('tax_calculation'), $data); - diff --git a/app/code/core/Mage/Tax/data/tax_setup/data-upgrade-1.6.0.3-1.6.0.4.php b/app/code/core/Mage/Tax/data/tax_setup/data-upgrade-1.6.0.3-1.6.0.4.php deleted file mode 100644 index cd1331c7cb531..0000000000000 --- a/app/code/core/Mage/Tax/data/tax_setup/data-upgrade-1.6.0.3-1.6.0.4.php +++ /dev/null @@ -1,41 +0,0 @@ - 'catalog_setup') -); - -$entityTypeId = $catalogInstaller->getEntityTypeId(Mage_Catalog_Model_Product::ENTITY); -$attribute = $catalogInstaller->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'tax_class_id'); - -$catalogInstaller->addAttributeToSet( - $entityTypeId, - $catalogInstaller->getAttributeSetId($entityTypeId, 'Minimal'), - $catalogInstaller->getGeneralGroupName(), - $attribute['attribute_id'] -); diff --git a/app/code/core/Mage/Tax/etc/adminhtml/acl.xml b/app/code/core/Mage/Tax/etc/adminhtml/acl.xml deleted file mode 100644 index 9533ff25070ca..0000000000000 --- a/app/code/core/Mage/Tax/etc/adminhtml/acl.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Tax/etc/adminhtml/menu.xml b/app/code/core/Mage/Tax/etc/adminhtml/menu.xml deleted file mode 100644 index c758dc3317de9..0000000000000 --- a/app/code/core/Mage/Tax/etc/adminhtml/menu.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - diff --git a/app/code/core/Mage/Tax/etc/config.xml b/app/code/core/Mage/Tax/etc/config.xml deleted file mode 100644 index 13fd2d77cab84..0000000000000 --- a/app/code/core/Mage/Tax/etc/config.xml +++ /dev/null @@ -1,241 +0,0 @@ - - - - - - 1.6.0.5 - true - core - - - - - - - - - - - Mage_Tax - Mage_Tax_Model_Resource_Setup - - - - - - - - Mage_Tax_Model_Observer - salesEventConvertQuoteAddressToOrder - - - - - - - Mage_Tax_Model_Observer - salesEventOrderAfterSave - - - - - - - Mage_Tax_Model_Observer - addTaxPercentToProductCollection - - - - - - - Mage_Tax_Model_Observer - quoteCollectTotalsBefore - - - - - - - - - Mage_Tax_Model_Sales_Total_Quote_Subtotal - freeshipping - tax,discount - - - Mage_Tax_Model_Sales_Total_Quote_Shipping - shipping - tax,discount - - - Mage_Tax_Model_Sales_Total_Quote_Tax - subtotal,shipping - grand_total - Mage_Tax_Block_Checkout_Tax - Mage_Adminhtml_Block_Sales_Order_Create_Totals_Tax - - - Mage_Tax_Block_Checkout_Subtotal - Mage_Adminhtml_Block_Sales_Order_Create_Totals_Subtotal - - - Mage_Tax_Block_Checkout_Shipping - Mage_Adminhtml_Block_Sales_Order_Create_Totals_Shipping - - - Mage_Tax_Block_Checkout_Discount - Mage_Adminhtml_Block_Sales_Order_Create_Totals_Discount - - - Mage_Tax_Block_Checkout_Grandtotal - Mage_Adminhtml_Block_Sales_Order_Create_Totals_Grandtotal - - - - - Mage_Tax_Model_Sales_Total_Quote_Nominal_Subtotal - 500 - - - Mage_Tax_Model_Sales_Total_Quote_Nominal_Tax - 750 - - - - - - - - Mage_Tax_Model_Sales_Pdf_Subtotal - - - Mage_Tax_Model_Sales_Pdf_Shipping - - - Mage_Tax_Model_Sales_Pdf_Grandtotal - - - Tax - tax_amount - Mage_Tax_Model_Sales_Pdf_Tax - 7 - 0 - 300 - - - - - - - - - - - - - - - - - - - Mage_Tax.csv - - - - - - - - - - - Mage_Tax.csv - - - - - - - - - - - - TOTAL_BASE_CALCULATION - 0 - 0 - shipping - 0 - 0 - 0 - 0 - - - US - 0 - * - - - 1 - 1 - - - 1 - 1 - 1 - 1 - 0 - 0 - 0 - - - 1 - 1 - 1 - 1 - 0 - 0 - 0 - - - - - - - - 0 0 * * * - - - Mage_Tax_Model_Observer::aggregateSalesReportTaxData - - - - - diff --git a/app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme.php b/app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme.php deleted file mode 100644 index 81021666e4b39..0000000000000 --- a/app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme.php +++ /dev/null @@ -1,52 +0,0 @@ -_blockGroup = 'Mage_Theme'; - $this->_controller = 'Adminhtml_System_Design_Theme'; - $this->_updateButton('add', 'label', $this->__('Add New Theme')); - } - - /** - * Prepare header for container - * - * @return string - */ - public function getHeaderText() - { - return $this->__('Themes'); - } -} diff --git a/app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/Css.php b/app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/Css.php deleted file mode 100644 index 3e5bfb3ad8634..0000000000000 --- a/app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/Css.php +++ /dev/null @@ -1,326 +0,0 @@ -_uploaderService = $uploaderService; - } - - /** - * Create a form element with necessary controls - * - * @return Mage_Theme_Block_Adminhtml_System_Design_Theme_Edit_Tab_Css - */ - protected function _prepareForm() - { - $form = new Varien_Data_Form(); - $this->setForm($form); - $this->_addThemeCssFieldset(); - - $this->_customCssFile = $this->_getCurrentTheme() - ->getCustomizationData(Mage_Core_Model_Theme_Customization_Files_Css::TYPE)->getFirstItem(); - - $this->_addCustomCssFieldset(); - - $formData['custom_css_content'] = $this->_customCssFile->getContent(); - - /** @var $session Mage_Backend_Model_Session */ - $session = $this->_objectManager->get('Mage_Backend_Model_Session'); - $cssFileContent = $session->getThemeCustomCssData(); - if ($cssFileContent) { - $formData['custom_css_content'] = $cssFileContent; - $session->unsThemeCustomCssData(); - } - $form->addValues($formData); - parent::_prepareForm(); - return $this; - } - - /** - * Set theme css fieldset - * - * @return Mage_Theme_Block_Adminhtml_System_Design_Theme_Edit_Tab_Css - */ - protected function _addThemeCssFieldset() - { - $form = $this->getForm(); - $themeFieldset = $form->addFieldset('theme_css', array( - 'legend' => $this->__('Theme CSS'), - 'class' => 'fieldset-wide' - )); - $this->_addElementTypes($themeFieldset); - foreach ($this->getFiles() as $groupName => $files) { - foreach ($files as &$file) { - $file = $this->_convertFileData($file); - } - $themeFieldset->addField('theme_css_view_' . $groupName, 'links', array( - 'label' => $groupName, - 'title' => $groupName, - 'name' => 'links', - 'values' => $files, - )); - } - - return $this; - } - - /** - * Prepare file items for output on page for download - * - * @param Mage_Core_Model_Theme_File $file - * @return array - */ - protected function _convertFileData($file) - { - return array( - 'href' => $this->getDownloadUrl($file['id'], $this->_getCurrentTheme()->getId()), - 'label' => $file['id'], - 'title' => $file['safePath'], - 'delimiter' => '
    ' - ); - } - - /** - * Set custom css fieldset - * - * @return Mage_Theme_Block_Adminhtml_System_Design_Theme_Edit_Tab_Css - */ - protected function _addCustomCssFieldset() - { - $form = $this->getForm(); - $themeFieldset = $form->addFieldset('custom_css', array( - 'legend' => $this->__('Custom CSS'), - 'class' => 'fieldset-wide' - )); - $this->_addElementTypes($themeFieldset); - - $themeFieldset->addField('css_file_uploader', 'css_file', array( - 'name' => 'css_file_uploader', - 'label' => $this->__('Select CSS File to Upload'), - 'title' => $this->__('Select CSS File to Upload'), - 'accept' => 'text/css', - 'note' => $this->_getUploadCssFileNote() - )); - - $themeFieldset->addField('css_uploader_button', 'button', array( - 'name' => 'css_uploader_button', - 'value' => $this->__('Upload CSS File'), - 'disabled' => 'disabled', - )); - - $downloadButtonConfig = array( - 'name' => 'css_download_button', - 'value' => $this->__('Download CSS File'), - 'onclick' => "setLocation('" . $this->getUrl('*/*/downloadCustomCss', array( - 'theme_id' => $this->_getCurrentTheme()->getId())) . "');" - ); - if (!$this->_customCssFile->getContent()) { - $downloadButtonConfig['disabled'] = 'disabled'; - } - $themeFieldset->addField('css_download_button', 'button', $downloadButtonConfig); - - /** @var $imageButton Mage_Backend_Block_Widget_Button */ - $imageButton = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Button') - ->setData(array( - 'id' => 'css_images_manager', - 'label' => $this->__('Manage'), - 'class' => 'button', - 'onclick' => "MediabrowserUtility.openDialog('" - . $this->getUrl('*/system_design_wysiwyg_files/index', array( - 'target_element_id' => 'custom_css_content', - Mage_Theme_Helper_Storage::PARAM_THEME_ID => $this->_getCurrentTheme()->getId(), - Mage_Theme_Helper_Storage::PARAM_CONTENT_TYPE => Mage_Theme_Model_Wysiwyg_Storage::TYPE_IMAGE - )) - . "', null, null,'" - . $this->quoteEscape( - $this->__('Upload Images...'), true - ) - . "');" - )); - - $themeFieldset->addField('css_browse_image_button', 'note', array( - 'label' => $this->__("Images Assets"), - 'text' => $imageButton->toHtml() - )); - - /** @var $fontButton Mage_Backend_Block_Widget_Button */ - $fontButton = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Button') - ->setData(array( - 'id' => 'css_fonts_manager', - 'label' => $this->__('Manage'), - 'class' => 'button', - 'onclick' => "MediabrowserUtility.openDialog('" - . $this->getUrl('*/system_design_wysiwyg_files/index', array( - 'target_element_id' => 'custom_css_content', - Mage_Theme_Helper_Storage::PARAM_THEME_ID => $this->_getCurrentTheme()->getId(), - Mage_Theme_Helper_Storage::PARAM_CONTENT_TYPE => Mage_Theme_Model_Wysiwyg_Storage::TYPE_FONT - )) - . "', null, null,'" - . $this->quoteEscape( - $this->__('Upload fonts...'), true - ) - . "');", - )); - - $themeFieldset->addField('css_browse_font_button', 'note', array( - 'label' => $this->__("Fonts Assets"), - 'text' => $fontButton->toHtml() - )); - - $themeFieldset->addField('custom_css_content', 'textarea', array( - 'label' => $this->__('Edit custom.css'), - 'title' => $this->__('Edit custom.css'), - 'name' => 'custom_css_content', - )); - - return $this; - } - - /** - * Get note string for css file to Upload - * - * @return string - */ - protected function _getUploadCssFileNote() - { - $messages = array( - $this->__('Allowed file types *.css.'), - $this->__('The file you upload will replace the existing custom.css file (shown below).') - ); - $maxFileSize = $this->_objectManager->get('Magento_File_Size')->getMaxFileSizeInMb(); - if ($maxFileSize) { - $messages[] = $this->__('Max file size to upload %sM', $maxFileSize); - } else { - $messages[] = $this->__('System doesn\'t allow to get file upload settings'); - } - - return implode('
    ', $messages); - } - - /** - * Set additional form field type for theme preview image - * - * @return array - */ - protected function _getAdditionalElementTypes() - { - $linksElement = 'Mage_Theme_Block_Adminhtml_System_Design_Theme_Edit_Form_Element_Links'; - $fileElement = 'Mage_Theme_Block_Adminhtml_System_Design_Theme_Edit_Form_Element_File'; - return array('links' => $linksElement, 'css_file' => $fileElement); - } - - /** - * Return Tab label - * - * @return string - */ - public function getTabLabel() - { - return $this->__('CSS Editor'); - } - - /** - * Get url to downlaod CSS file - * - * @param string $fileId - * @return string - */ - public function getDownloadUrl($fileId, $themeId) - { - return $this->getUrl('*/*/downloadCss', array( - 'theme_id' => $themeId, - 'file' => $this->_helperFactory->get('Mage_Theme_Helper_Data')->urlEncode($fileId) - )); - } -} diff --git a/app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/TabAbstract.php b/app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/TabAbstract.php deleted file mode 100644 index 468a1e9bfd045..0000000000000 --- a/app/code/core/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/TabAbstract.php +++ /dev/null @@ -1,124 +0,0 @@ -_objectManager = $objectManager; - } - - /** - * Get theme that is edited currently - * - * @return Mage_Core_Model_Theme - */ - protected function _getCurrentTheme() - { - return Mage::registry('current_theme'); - } - - /** - * Return Tab title - * - * @return string - */ - public function getTabTitle() - { - return $this->getTabLabel(); - } - - /** - * Can show tab in tabs - * - * @return boolean - */ - public function canShowTab() - { - return $this->_getCurrentTheme()->isVirtual() && $this->_getCurrentTheme()->getId(); - } - - /** - * Tab is hidden - * - * @return boolean - */ - public function isHidden() - { - return false; - } -} diff --git a/app/code/core/Mage/Theme/Helper/Data.php b/app/code/core/Mage/Theme/Helper/Data.php deleted file mode 100644 index 70a4531198850..0000000000000 --- a/app/code/core/Mage/Theme/Helper/Data.php +++ /dev/null @@ -1,73 +0,0 @@ - 'http://mage2.com/pub/media/theme/frontend/_theme15/en_US/Mage_Cms/widgets.css' - * ) - * - * @param Mage_Core_Model_Theme $theme - * @return array - */ - public function getCssFiles($theme) - { - $arguments = array( - 'area' => $theme->getArea(), - 'theme' => $theme->getId() - ); - /** @var $layoutMerge Mage_Core_Model_Layout_Merge */ - $layoutMerge = Mage::getModel('Mage_Core_Model_Layout_Merge', array('arguments' => $arguments)); - $layoutElement = $layoutMerge->getFileLayoutUpdatesXml(); - - $xpathRefs = '//reference[@name="head"]/action[@method="addCss" or @method="addCssIe"]/*[1]'; - $xpathBlocks = '//block[@type="Mage_Page_Block_Html_Head"]/action[@method="addCss" or @method="addCssIe"]/*[1]'; - $files = array_merge( - $layoutElement->xpath($xpathRefs), - $layoutElement->xpath($xpathBlocks) - ); - - $design = Mage::getDesign(); - $params = array( - 'area' => $theme->getArea(), - 'themeModel' => $theme, - 'skipProxy' => true - ); - $urls = array(); - foreach ($files as $file) { - $urls[(string)$file] = $design->getViewFile($file, $params); - } - - return $urls; - } -} diff --git a/app/code/core/Mage/Theme/Helper/Storage.php b/app/code/core/Mage/Theme/Helper/Storage.php deleted file mode 100644 index 0e700084007c7..0000000000000 --- a/app/code/core/Mage/Theme/Helper/Storage.php +++ /dev/null @@ -1,322 +0,0 @@ -_filesystem = $filesystem; - $this->_session = $session; - $this->_themeFactory = $themeFactory; - - $this->_filesystem->setIsAllowCreateDirectories(true); - $this->_filesystem->ensureDirectoryExists($this->getStorageRoot()); - } - - /** - * Convert path to id - * - * @param string $path - * @return string - */ - public function convertPathToId($path) - { - $path = str_replace($this->getStorageRoot(), '', $path); - return $this->urlEncode($path); - } - - /** - * Convert id to path - * - * @param string $value - * @return string - */ - public function convertIdToPath($value) - { - $path = $this->urlDecode($value); - if (!strstr($path, $this->getStorageRoot())) { - $path = $this->getStorageRoot() . $path; - } - return $path; - } - - /** - * Get short file name - * - * @param string $filename - * @param int $maxLength - * @return string - */ - public function getShortFilename($filename, $maxLength = 20) - { - return strlen($filename) <= $maxLength ? $filename : substr($filename, 0, $maxLength) . '...'; - } - - /** - * Get storage root directory - * - * @return string - */ - public function getStorageRoot() - { - if (null === $this->_storageRoot) { - $this->_storageRoot = implode(Magento_Filesystem::DIRECTORY_SEPARATOR, array( - Magento_Filesystem::fixSeparator($this->_getTheme()->getCustomizationPath()), - Mage_Core_Model_Theme_Files::PATH_PREFIX_CUSTOMIZED, - $this->getStorageType() - )); - } - return $this->_storageRoot; - } - - /** - * Get theme module for custom static files - * - * @return Mage_Core_Model_Theme - * @throws InvalidArgumentException - */ - protected function _getTheme() - { - $themeId = $this->_getRequest()->getParam(self::PARAM_THEME_ID); - $theme = $this->_themeFactory->create(); - if (!$themeId || $themeId && !$theme->load($themeId)->getId()) { - throw new InvalidArgumentException('Theme was not found.'); - } - return $theme; - } - - /** - * Get storage type - * - * @return string - * @throws Magento_Exception - */ - public function getStorageType() - { - $allowedTypes = array( - Mage_Theme_Model_Wysiwyg_Storage::TYPE_FONT, - Mage_Theme_Model_Wysiwyg_Storage::TYPE_IMAGE - ); - $type = (string)$this->_getRequest()->getParam(self::PARAM_CONTENT_TYPE); - if (!in_array($type, $allowedTypes)) { - throw new Magento_Exception('Invalid type'); - } - return $type; - } - - /** - * Relative url to static content - * - * @return string - */ - public function getRelativeUrl() - { - $pathPieces = array('..', $this->getStorageType()); - $node = $this->_getRequest()->getParam(self::PARAM_NODE); - if ($node !== self::NODE_ROOT) { - $node = $this->urlDecode($node); - $nodes = explode( - Magento_Filesystem::DIRECTORY_SEPARATOR, - trim($node, Magento_Filesystem::DIRECTORY_SEPARATOR) - ); - $pathPieces = array_merge($pathPieces, $nodes); - } - $pathPieces[] = $this->urlDecode($this->_getRequest()->getParam(self::PARAM_FILENAME)); - return implode('/', $pathPieces); - } - - /** - * Get current path - * - * @return string - */ - public function getCurrentPath() - { - if (!$this->_currentPath) { - $currentPath = $this->getStorageRoot(); - $path = $this->_getRequest()->getParam(self::PARAM_NODE); - if ($path && $path !== self::NODE_ROOT) { - $path = $this->convertIdToPath($path); - if ($this->_filesystem->isDirectory($path) - && $this->_filesystem->isPathInDirectory($path, $currentPath) - ) { - $currentPath = $this->_filesystem->getAbsolutePath($path); - } - } - $this->_currentPath = $currentPath; - } - return $this->_currentPath; - } - - /** - * Get thumbnail directory for path - * - * @param string $path - * @return string - */ - public function getThumbnailDirectory($path) - { - return pathinfo($path, PATHINFO_DIRNAME) . Magento_Filesystem::DIRECTORY_SEPARATOR - . Mage_Theme_Model_Wysiwyg_Storage::THUMBNAIL_DIRECTORY; - } - - /** - * Get thumbnail path in current directory by image name - * - * @param $imageName - * @return string - * @throws InvalidArgumentException - */ - public function getThumbnailPath($imageName) - { - $imagePath = $this->getCurrentPath() . Magento_Filesystem::DIRECTORY_SEPARATOR . $imageName; - if (!$this->_filesystem->has($imagePath) - || !$this->_filesystem->isPathInDirectory($imagePath, $this->getStorageRoot()) - ) { - throw new InvalidArgumentException('The image not found.'); - } - return $this->getThumbnailDirectory($imagePath) . Magento_Filesystem::DIRECTORY_SEPARATOR - . pathinfo($imageName, PATHINFO_BASENAME); - } - - /** - * Request params for selected theme - * - * @return array - */ - public function getRequestParams() - { - $themeId = $this->_getRequest()->getParam(self::PARAM_THEME_ID); - $contentType = $this->_getRequest()->getParam(self::PARAM_CONTENT_TYPE); - $node = $this->_getRequest()->getParam(self::PARAM_NODE); - return array( - self::PARAM_THEME_ID => $themeId, - self::PARAM_CONTENT_TYPE => $contentType, - self::PARAM_NODE => $node - ); - } - - /** - * Get allowed extensions by type - * - * @return array - * @throws Magento_Exception - */ - public function getAllowedExtensionsByType() - { - switch ($this->getStorageType()) { - case Mage_Theme_Model_Wysiwyg_Storage::TYPE_FONT: - $extensions = array('ttf', 'otf', 'eot', 'svg', 'woff'); - break; - case Mage_Theme_Model_Wysiwyg_Storage::TYPE_IMAGE: - $extensions = array('jpg', 'jpeg', 'gif', 'png', 'xbm', 'wbmp'); - break; - default: - throw new Magento_Exception('Invalid type'); - } - - return $extensions; - } - - /** - * Get session model - * - * @return Mage_Backend_Model_Session - */ - public function getSession() - { - return $this->_session; - } -} diff --git a/app/code/core/Mage/Theme/Model/Uploader/Service.php b/app/code/core/Mage/Theme/Model/Uploader/Service.php deleted file mode 100644 index eb156959113ff..0000000000000 --- a/app/code/core/Mage/Theme/Model/Uploader/Service.php +++ /dev/null @@ -1,262 +0,0 @@ -_fileIo = $fileIo; - $this->_fileSize = $fileSize; - $this->_filesJs = $filesJs; - $this->_objectManager = $objectManager; - parent::__construct($eventDispatcher, $cacheManager, $resource, $resourceCollection, $data); - } - - /** - * Upload css file - * - * @param string $file - Key in the $_FILES array - * @return Mage_Theme_Model_Uploader_Service - * @throws Mage_Core_Exception - */ - public function uploadCssFile($file) - { - /** @var $fileUploader Mage_Core_Model_File_Uploader */ - $fileUploader = Mage::getObjectManager()->get('Mage_Core_Model_File_Uploader', array($file)); - $fileUploader->setAllowedExtensions(array('css')); - $fileUploader->setAllowRenameFiles(true); - $fileUploader->setAllowCreateFolders(true); - - $isValidFileSize = $this->_validateFileSize($fileUploader->getFileSize(), $this->getCssUploadMaxSize()); - if (!$isValidFileSize) { - Mage::throwException($this->_objectManager->get('Mage_Core_Helper_Data')->__( - 'CSS file size should be less than %sM.', $this->getCssUploadMaxSizeInMb() - )); - } - - $file = $fileUploader->validateFile(); - $this->setFilePath($file['tmp_name']); - return $this; - } - - /** - * Upload js file - * - * @param string $file - Key in the $_FILES array - * @param Mage_Core_Model_Theme $theme - * @param bool $saveAsTmp - * @return Mage_Theme_Model_Uploader_Service - * @throws Mage_Core_Exception - */ - public function uploadJsFile($file, $theme, $saveAsTmp = true) - { - /** @var $fileUploader Mage_Core_Model_File_Uploader */ - $fileUploader = Mage::getObjectManager()->get('Mage_Core_Model_File_Uploader', array($file)); - $fileUploader->setAllowedExtensions(array('js')); - $fileUploader->setAllowRenameFiles(true); - $fileUploader->setAllowCreateFolders(true); - - $isValidFileSize = $this->_validateFileSize($fileUploader->getFileSize(), $this->getJsUploadMaxSize()); - if (!$isValidFileSize) { - Mage::throwException($this->_objectManager->get('Mage_Core_Helper_Data')->__( - 'JS file size should be less than %sM.', $this->getJsUploadMaxSizeInMb() - )); - } - - $file = $fileUploader->validateFile(); - $this->setFilePath($file['tmp_name']); - $file['content'] = $this->getFileContent(); - - $this->_filesJs->saveJsFile($theme, $file, $saveAsTmp); - - return $this; - } - - /** - * Get js files object - * - * @return Mage_Core_Model_Theme_Customization_Files_Js - */ - public function getJsFiles() - { - return $this->_filesJs; - } - - /** - * Get uploaded file content - * - * @return string - */ - public function getFileContent() - { - return $this->_fileIo->read($this->getFilePath()); - } - - /** - * Get css upload max size - * - * @return int - */ - public function getCssUploadMaxSize() - { - return $this->_getMaxUploadSize(self::XML_PATH_CSS_UPLOAD_LIMIT); - } - - /** - * Get js upload max size - * - * @return int - */ - public function getJsUploadMaxSize() - { - return $this->_getMaxUploadSize(self::XML_PATH_JS_UPLOAD_LIMIT); - } - - /** - * Get max upload size - * - * @param string $node - * @return int - */ - protected function _getMaxUploadSize($node) - { - $maxCssUploadSize = $this->_fileSize->convertSizeToInteger( - (string)Mage::getConfig()->getNode($node) - ); - $maxIniUploadSize = $this->_fileSize->getMaxFileSize(); - return min($maxCssUploadSize, $maxIniUploadSize); - } - - /** - * Get css upload max size in megabytes - * - * @return float - */ - public function getCssUploadMaxSizeInMb() - { - return $this->_fileSize->getFileSizeInMb($this->getCssUploadMaxSize()); - } - - /** - * Get js upload max size in megabytes - * - * @return float - */ - public function getJsUploadMaxSizeInMb() - { - return $this->_fileSize->getFileSizeInMb($this->getJsUploadMaxSize()); - } - - /** - * Validate max file size - * - * @param int $fileSize - * @param int $maxFileSize - * @return bool - */ - protected function _validateFileSize($fileSize, $maxFileSize) - { - if ($fileSize > $maxFileSize) { - return false; - } - return true; - } -} diff --git a/app/code/core/Mage/Theme/Model/Wysiwyg/Storage.php b/app/code/core/Mage/Theme/Model/Wysiwyg/Storage.php deleted file mode 100644 index 9d1f615df3720..0000000000000 --- a/app/code/core/Mage/Theme/Model/Wysiwyg/Storage.php +++ /dev/null @@ -1,315 +0,0 @@ -_filesystem = $filesystem; - $this->_filesystem->setIsAllowCreateDirectories(true); - $this->_helper = $helper; - $this->_objectManager = $objectManager; - } - - /** - * Upload file - * - * @param string $targetPath - * @return bool - * @throws Mage_Core_Exception - */ - public function uploadFile($targetPath) - { - /** @var $uploader Mage_Core_Model_File_Uploader */ - $uploader = $this->_objectManager->create('Mage_Core_Model_File_Uploader', array('file')); - $uploader->setAllowedExtensions($this->_helper->getAllowedExtensionsByType()); - $uploader->setAllowRenameFiles(true); - $uploader->setFilesDispersion(false); - $result = $uploader->save($targetPath); - - if (!$result) { - Mage::throwException($this->_helper->__('Cannot upload file.') ); - } - - $this->_createThumbnail( - $targetPath . Magento_Filesystem::DIRECTORY_SEPARATOR . $uploader->getUploadedFileName() - ); - - $result['cookie'] = array( - 'name' => $this->_helper->getSession()->getSessionName(), - 'value' => $this->_helper->getSession()->getSessionId(), - 'lifetime' => $this->_helper->getSession()->getCookieLifetime(), - 'path' => $this->_helper->getSession()->getCookiePath(), - 'domain' => $this->_helper->getSession()->getCookieDomain() - ); - - return $result; - } - - /** - * Create thumbnail for image and save it to thumbnails directory - * - * @param string $source - * @return bool|string Resized filepath or false if errors were occurred - */ - public function _createThumbnail($source) - { - if (self::TYPE_IMAGE != $this->_helper->getStorageType() || !$this->_filesystem->isFile($source) - || !$this->_filesystem->isReadable($source) - ) { - return false; - } - $thumbnailDir = $this->_helper->getThumbnailDirectory($source); - $thumbnailPath = $thumbnailDir . Magento_Filesystem::DIRECTORY_SEPARATOR . pathinfo($source, PATHINFO_BASENAME); - try { - $this->_filesystem->ensureDirectoryExists($thumbnailDir); - $adapter = $this->_objectManager->get('Mage_Core_Helper_Data')->getImageAdapterType(); - $image = Varien_Image_Adapter::factory($adapter); - $image->open($source); - $image->keepAspectRatio(true); - $image->resize(self::THUMBNAIL_WIDTH, self::THUMBNAIL_HEIGHT); - $image->save($thumbnailPath); - } catch (Magento_Filesystem_Exception $e) { - $this->_objectManager->get('Mage_Core_Model_Logger')->logException($e); - return false; - } - - if ($this->_filesystem->isFile($thumbnailPath)) { - return $thumbnailPath; - } - return false; - } - - /** - * Create folder - * - * @param string $name - * @param string $path - * @return array - * @throws Mage_Core_Exception - */ - public function createFolder($name, $path) - { - if (!preg_match(self::DIRECTORY_NAME_REGEXP, $name)) { - Mage::throwException($this->_helper->__('Invalid folder name.')); - } - if (!$this->_filesystem->isWritable($path)) { - $path = $this->_helper->getStorageRoot(); - } - - $newPath = $path . Magento_Filesystem::DIRECTORY_SEPARATOR . $name; - - if ($this->_filesystem->has($newPath)) { - Mage::throwException($this->_helper->__('A directory with the same name already exists.')); - } - - $this->_filesystem->ensureDirectoryExists($newPath); - - $result = array( - 'name' => $name, - 'short_name' => $this->_helper->getShortFilename($name), - 'path' => str_replace($this->_helper->getStorageRoot(), '', $newPath), - 'id' => $this->_helper->convertPathToId($newPath) - ); - - return $result; - } - - /** - * Delete file - * - * @param string $file - * @return Mage_Theme_Model_Wysiwyg_Storage - */ - public function deleteFile($file) - { - $file = $this->_helper->urlDecode($file); - $path = $this->_helper->getSession()->getStoragePath(); - - $_filePath = $this->_filesystem->getAbsolutePath($path . Magento_Filesystem::DIRECTORY_SEPARATOR . $file); - $_thumbnailPath = $this->_helper->getThumbnailDirectory($_filePath) - . Magento_Filesystem::DIRECTORY_SEPARATOR - . $file; - - if ($this->_filesystem->isPathInDirectory($_filePath, $path) - && $this->_filesystem->isPathInDirectory($_filePath, $this->_helper->getStorageRoot()) - ) { - $this->_filesystem->delete($_filePath); - $this->_filesystem->delete($_thumbnailPath); - } - return $this; - } - - /** - * Get directory collection - * - * @param string $currentPath - * @return array - * @throws Mage_Core_Exception - */ - public function getDirsCollection($currentPath) - { - if (!$this->_filesystem->has($currentPath)) { - Mage::throwException($this->_helper->__('A directory with the name not exists.')); - } - - $paths = $this->_filesystem->searchKeys($currentPath, '*'); - $directories = array(); - foreach ($paths as $path) { - if ($this->_filesystem->isDirectory($path)) { - $directories[] = $path; - } - } - return $directories; - } - - /** - * Get files collection - * - * @return array - */ - public function getFilesCollection() - { - $paths = $this->_filesystem->searchKeys($this->_helper->getCurrentPath(), '*'); - $files = array(); - $requestParams = $this->_helper->getRequestParams(); - $storageType = $this->_helper->getStorageType(); - foreach ($paths as $path) { - if (!$this->_filesystem->isFile($path)) { - continue; - } - $fileName = pathinfo($path, PATHINFO_BASENAME); - $file = array( - 'text' => $fileName, - 'id' => $this->_helper->urlEncode($fileName) - ); - if (self::TYPE_IMAGE == $storageType) { - $requestParams['file'] = $fileName; - $file['thumbnailParams'] = $requestParams; - } - $files[] = $file; - } - return $files; - } - - /** - * Get directories tree array - * - * @return array - */ - public function getTreeArray() - { - $directories = $this->getDirsCollection($this->_helper->getCurrentPath()); - $resultArray = array(); - foreach ($directories as $path) { - $resultArray[] = array( - 'text' => $this->_helper->getShortFilename(pathinfo($path, PATHINFO_BASENAME), 20), - 'id' => $this->_helper->convertPathToId($path), - 'cls' => 'folder' - ); - } - return $resultArray; - } - - /** - * Delete directory - * - * @param string $path - * @return bool - * @throws Mage_Core_Exception - */ - public function deleteDirectory($path) - { - $rootCmp = rtrim($this->_helper->getStorageRoot(), Magento_Filesystem::DIRECTORY_SEPARATOR); - $pathCmp = rtrim($path, Magento_Filesystem::DIRECTORY_SEPARATOR); - - if ($rootCmp == $pathCmp) { - Mage::throwException($this->_helper->__('Cannot delete root directory %s.', $path)); - } - - return $this->_filesystem->delete($path); - } -} diff --git a/app/code/core/Mage/Theme/etc/adminhtml/acl.xml b/app/code/core/Mage/Theme/etc/adminhtml/acl.xml deleted file mode 100644 index 8a9f2f28634a5..0000000000000 --- a/app/code/core/Mage/Theme/etc/adminhtml/acl.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Theme/etc/adminhtml/menu.xml b/app/code/core/Mage/Theme/etc/adminhtml/menu.xml deleted file mode 100644 index d3b238ccd4087..0000000000000 --- a/app/code/core/Mage/Theme/etc/adminhtml/menu.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - diff --git a/app/code/core/Mage/Theme/etc/config.xml b/app/code/core/Mage/Theme/etc/config.xml deleted file mode 100644 index bc5834bbd49bf..0000000000000 --- a/app/code/core/Mage/Theme/etc/config.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - 2M - - - 2M - - - - - - - admin - - - Mage_Theme_Adminhtml - - - - - - - - - - layout.xml - - - - - diff --git a/app/code/core/Mage/Theme/view/adminhtml/tabs/fieldset/js.phtml b/app/code/core/Mage/Theme/view/adminhtml/tabs/fieldset/js.phtml deleted file mode 100644 index 21e0a45c95dfc..0000000000000 --- a/app/code/core/Mage/Theme/view/adminhtml/tabs/fieldset/js.phtml +++ /dev/null @@ -1,53 +0,0 @@ - - - -
    -
    - -
    -
    - {{name}} ({{size}}) -
    -
    -
    -
    -
    -
    - -
      - getChildBlock('theme.edit.tabs.tab.js.items')->setJsFiles($this->getJsFiles())->toHtml(); ?> -
    - - diff --git a/app/code/core/Mage/Theme/view/adminhtml/tabs/js.phtml b/app/code/core/Mage/Theme/view/adminhtml/tabs/js.phtml deleted file mode 100644 index 32ce6fcb1a6b9..0000000000000 --- a/app/code/core/Mage/Theme/view/adminhtml/tabs/js.phtml +++ /dev/null @@ -1,121 +0,0 @@ - - -getFormHtml(); ?> - - diff --git a/app/code/core/Mage/Usa/etc/adminhtml/system.xml b/app/code/core/Mage/Usa/etc/adminhtml/system.xml deleted file mode 100644 index 49c2894db9b9f..0000000000000 --- a/app/code/core/Mage/Usa/etc/adminhtml/system.xml +++ /dev/null @@ -1,698 +0,0 @@ - - - - -
    - - - - - - - - Mage_Backend_Model_Config_Source_Yesno - - - - Mage_Usa_Model_Shipping_Carrier_Dhl_Source_Method - 1 - - - - - - - Mage_Backend_Model_Config_Source_Enabledisable - - - - validate-number validate-zero-or-greater - - - - Mage_Backend_Model_Config_Source_Yesno - - - - Mage_Usa_Model_Shipping_Carrier_Dhl_Source_Dutypaymenttype - - - - free-method - Mage_Usa_Model_Shipping_Carrier_Dhl_Source_Freemethod - - - - - - - Mage_Shipping_Model_Source_HandlingType - - - - Mage_Shipping_Model_Source_HandlingAction - - - - validate-number validate-zero-or-greater - - - - validate-number validate-zero-or-greater - - - - Mage_Backend_Model_Config_Backend_Encrypted - - - - Mage_Backend_Model_Config_Backend_Encrypted - - - - Mage_Usa_Model_Shipping_Carrier_Abstract_Source_Requesttype - - - - Mage_Usa_Model_Shipping_Carrier_Dhl_Source_Shipmenttype - - - - Mage_Backend_Model_Config_Backend_Encrypted - - - - Mage_Backend_Model_Config_Backend_Encrypted - - - - - - - - - - shipping-applicable-country - Mage_Shipping_Model_Config_Source_Allspecificcountries - - - - Mage_Directory_Model_Config_Source_Country - 1 - - - - shipping-skip-hide - Mage_Backend_Model_Config_Source_Yesno - - - - - - - Mage_Backend_Model_Config_Source_Yesno - - - - validate-number validate-zero-or-greater - - - - Mage_Usa_Model_Shipping_Carrier_Dhl_Source_Protection_Value - - - - Used only when "Additional Protection Value" is set to "Configuration". Can contain only numeric amount. - - - - Mage_Usa_Model_Shipping_Carrier_Dhl_Source_Protection_Rounding - - - - Mage_Backend_Model_Config_Source_Yesno - - - - - - - - - - - - - Mage_Backend_Model_Config_Source_Locale_Weekdays - 1 - - - - Mage_Backend_Model_Config_Source_Locale_Weekdays - 1 - - - - Mage_Backend_Model_Config_Source_Yesno - - - - - - - Mage_Backend_Model_Config_Source_Yesno - - - - - - - Mage_Backend_Model_Config_Backend_Encrypted - Please make sure to use only digits here. No dashes are allowed. - - - - Mage_Backend_Model_Config_Backend_Encrypted - - - - Mage_Backend_Model_Config_Backend_Encrypted - - - - Mage_Backend_Model_Config_Backend_Encrypted - - - - Mage_Backend_Model_Config_Source_Yesno - - - - Mage_Usa_Model_Shipping_Carrier_Abstract_Source_Requesttype - - - - Mage_Usa_Model_Shipping_Carrier_Fedex_Source_Packaging - - - - Mage_Usa_Model_Shipping_Carrier_Fedex_Source_Dropoff - - - - validate-number validate-zero-or-greater - - - - Mage_Shipping_Model_Source_HandlingType - - - - Mage_Shipping_Model_Source_HandlingAction - - - - validate-number validate-zero-or-greater - - - - Mage_Backend_Model_Config_Source_Yesno - - - - Mage_Usa_Model_Shipping_Carrier_Fedex_Source_Method - 1 - - - - The field is applicable if the Smart Post method is selected. - - - - free-method - Mage_Usa_Model_Shipping_Carrier_Fedex_Source_Freemethod - - - - Mage_Backend_Model_Config_Source_Enabledisable - - - - validate-number validate-zero-or-greater - - - - - - - shipping-applicable-country - Mage_Shipping_Model_Config_Source_Allspecificcountries - - - - Mage_Directory_Model_Config_Source_Country - 1 - - - - Mage_Backend_Model_Config_Source_Yesno - - - - shipping-skip-hide - Mage_Backend_Model_Config_Source_Yesno - - - - - - - - - - Mage_Backend_Model_Config_Backend_Encrypted - - - - Mage_Backend_Model_Config_Source_Yesno - - - - Mage_Usa_Model_Shipping_Carrier_Ups_Source_Method - 1 - - - - Mage_Usa_Model_Shipping_Carrier_Abstract_Source_Requesttype - - - - Mage_Usa_Model_Shipping_Carrier_Ups_Source_Container - - - - Mage_Backend_Model_Config_Source_Enabledisable - - - - validate-number validate-zero-or-greater - - - - Mage_Usa_Model_Shipping_Carrier_Ups_Source_DestType - - - - free-method - Mage_Usa_Model_Shipping_Carrier_Ups_Source_Freemethod - - - - - - - - - - Mage_Shipping_Model_Source_HandlingType - - - - Mage_Shipping_Model_Source_HandlingAction - - - - validate-number validate-zero-or-greater - - - - validate-number validate-zero-or-greater - - - - validate-number validate-zero-or-greater - - - - Mage_Usa_Model_Shipping_Carrier_Ups_Source_OriginShipment - - - - Mage_Backend_Model_Config_Backend_Encrypted - - - - Mage_Usa_Model_Shipping_Carrier_Ups_Source_Pickup - - - - - - - - - - - - - Mage_Usa_Model_Shipping_Carrier_Ups_Source_Type - - - - Mage_Usa_Model_Shipping_Carrier_Ups_Source_Unitofmeasure - - - - Mage_Backend_Model_Config_Backend_Encrypted - - - - Mage_Backend_Model_Config_Source_Yesno - - - - Required for negotiated rates; 6-character UPS. - - - - shipping-applicable-country - Mage_Shipping_Model_Config_Source_Allspecificcountries - - - - Mage_Directory_Model_Config_Source_Country - 1 - - - - shipping-skip-hide - Mage_Backend_Model_Config_Source_Yesno - - - - - - - Enables/Disables SSL verification of Magento server by UPS. - Mage_Usa_Model_Shipping_Carrier_Abstract_Source_Mode - - - - Mage_Backend_Model_Config_Source_Yesno - - - - - - - Mage_Backend_Model_Config_Source_Yesno - - - - - - - - - - - - - Mage_Backend_Model_Config_Backend_Encrypted - - - - Mage_Backend_Model_Config_Backend_Encrypted - - - - Mage_Usa_Model_Shipping_Carrier_Abstract_Source_Mode - - - - Mage_Usa_Model_Shipping_Carrier_Abstract_Source_Requesttype - - - - Mage_Usa_Model_Shipping_Carrier_Usps_Source_Container - - - - Mage_Usa_Model_Shipping_Carrier_Usps_Source_Size - - - - - LARGE - - - - - - LARGE - - - - - - LARGE - - - - - - LARGE - - - - - Mage_Usa_Model_Shipping_Carrier_Usps_Source_Machinable - - - - validate-number validate-zero-or-greater - - - - Mage_Shipping_Model_Source_HandlingType - - - - Mage_Shipping_Model_Source_HandlingAction - - - - validate-number validate-zero-or-greater - - - - Mage_Usa_Model_Shipping_Carrier_Usps_Source_Method - 1 - - - - free-method - Mage_Usa_Model_Shipping_Carrier_Usps_Source_Freemethod - - - - Mage_Backend_Model_Config_Source_Enabledisable - - - - validate-number validate-zero-or-greater - - - - - - - shipping-applicable-country - Mage_Shipping_Model_Config_Source_Allspecificcountries - - - - Mage_Directory_Model_Config_Source_Country - 1 - - - - Mage_Backend_Model_Config_Source_Yesno - - - - shipping-skip-hide - Mage_Backend_Model_Config_Source_Yesno - - - - - - - - - - Mage_Backend_Model_Config_Source_Yesno - - - - - - - - - - Mage_Backend_Model_Config_Backend_Encrypted - - - - Mage_Backend_Model_Config_Backend_Encrypted - - - - - - - Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Contenttype - - - - Mage_Shipping_Model_Source_HandlingType - - - - "Per Order" allows single handling fee for entire order. "Per Package" allows individual handling fee for each package. - Mage_Shipping_Model_Source_HandlingAction - - - - validate-number validate-zero-or-greater - - - - Allows breaking total order weight into smaller pieces if it exeeds 70 kg to ensure accurate calculation of shipping charges. - Mage_Backend_Model_Config_Source_Yesno - - - - Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Unitofmeasure - Mage_Usa_Block_Adminhtml_Dhl_Unitofmeasure - - - - Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Size - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Doc - - D - - - - - Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Nondoc - - N - - - - - Package ready time after order submission (in hours) - - - - - - - free-method - Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Freedoc - - D - - - - - free-method - Mage_Usa_Model_Shipping_Carrier_Dhl_International_Source_Method_Freenondoc - - N - - - - - Mage_Backend_Model_Config_Source_Enabledisable - - - - validate-number validate-zero-or-greater - - - - shipping-applicable-country - Mage_Shipping_Model_Config_Source_Allspecificcountries - - - - Mage_Directory_Model_Config_Source_Country - 1 - - - - shipping-skip-hide - Mage_Backend_Model_Config_Source_Yesno - - - - - - - Mage_Backend_Model_Config_Source_Yesno - - -
    -
    -
    diff --git a/app/code/core/Mage/Usa/etc/config.xml b/app/code/core/Mage/Usa/etc/config.xml deleted file mode 100644 index 0de804f9a652c..0000000000000 --- a/app/code/core/Mage/Usa/etc/config.xml +++ /dev/null @@ -1,229 +0,0 @@ - - - - - - 1.6.0.1 - true - core - - - - - - - - - - - Mage_Usa - - - - - - - - Mage_Usa_Model_Shipping_Carrier_Ups - - - Mage_Usa_Model_Shipping_Carrier_Usps - - - Mage_Usa_Model_Shipping_Carrier_Fedex - - - Mage_Usa_Model_Shipping_Carrier_Dhl - - - Mage_Usa_Model_Shipping_Carrier_Dhl_International - - - - - - - - - - - - - - - Mage_Usa.csv - - - - - - - - - - - Mage_Usa.csv - - - - - - - - - - dhl - - - - - - - 0 - 0 - IE,E SAT,E 10:30AM,E,N,S,G - Big Box - - R - G - https://eCommerce.airborne.com/ApiLandingTest.asp - - Mage_Usa_Model_Shipping_Carrier_Dhl - - 0 - P - - - DHL (Deprecated) - This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us. - 150 - F - O - 1,2,3,4,5,6 - 1,2,3,4,5 - 0 - - - - - - - 0 - 0 - 0 - 0 - EUROPE_FIRST_INTERNATIONAL_PRIORITY,FEDEX_1_DAY_FREIGHT,FEDEX_2_DAY_FREIGHT,FEDEX_2_DAY,FEDEX_2_DAY_AM,FEDEX_3_DAY_FREIGHT,FEDEX_EXPRESS_SAVER,FEDEX_GROUND,FIRST_OVERNIGHT,GROUND_HOME_DELIVERY,INTERNATIONAL_ECONOMY,INTERNATIONAL_ECONOMY_FREIGHT,INTERNATIONAL_FIRST,INTERNATIONAL_GROUND,INTERNATIONAL_PRIORITY,INTERNATIONAL_PRIORITY_FREIGHT,PRIORITY_OVERNIGHT,SMART_POST,STANDARD_OVERNIGHT,FEDEX_FREIGHT,FEDEX_NATIONAL_FREIGHT - - REGULAR_PICKUP - FEDEX_GROUND - 0 - Mage_Usa_Model_Shipping_Carrier_Fedex - YOUR_PACKAGING - Federal Express - This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us. - 150 - F - O - - - - 0 - 0 - 1DM,1DML,1DA,1DAL,1DAPI,1DP,1DPL,2DM,2DML,2DA,2DAL,3DS,GND,GNDCOM,GNDRES,STD,XPR,WXS,XPRL,XDM,XDML,XPD,01,02,03,07,08,11,12,14,54,59,65 - Shipments Originating in United States - 0 - CP - - RES - GND - http://www.ups.com/using/services/rave/qcostcgi.cgi - https://onlinetools.ups.com/ups.app/xml/Rate - 0 - Mage_Usa_Model_Shipping_Carrier_Ups - CC - United Parcel Service - https://www.ups.com/ups.app/xml/Track - LBS - - - This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us. - 0.1 - 150 - F - O - 0 - 1 - UPS - - - 0 - 0 - Bound Printed Matter,Express Mail,Express Mail Flat Rate Envelope,Express Mail Flat Rate Envelope Hold For Pickup,Express Mail Flat-Rate Envelope Sunday/Holiday Guarantee,Express Mail Hold For Pickup,Express Mail International,Express Mail International Flat Rate Envelope,Express Mail PO to PO,Express Mail Sunday/Holiday Guarantee,First-Class Mail International Large Envelope,First-Class Mail International Letter,First-Class Mail International Package,First-Class Mail International Parcel,First-Class,First-Class Mail,First-Class Mail Flat,First-Class Mail Large Envelope,First-Class Mail International,First-Class Mail Letter,First-Class Mail Parcel,First-Class Mail Package,Global Express Guaranteed (GXG),Global Express Guaranteed Non-Document Non-Rectangular,Global Express Guaranteed Non-Document Rectangular,Library Mail,Media Mail,Parcel Post,Priority Mail,Priority Mail Small Flat Rate Box,Priority Mail Medium Flat Rate Box,Priority Mail Large Flat Rate Box,Priority Mail Flat Rate Box,Priority Mail Flat Rate Envelope,Priority Mail International,Priority Mail International Flat Rate Box,Priority Mail International Flat Rate Envelope,Priority Mail International Small Flat Rate Box,Priority Mail International Medium Flat Rate Box,Priority Mail International Large Flat Rate Box,USPS GXG Envelopes - VARIABLE - - - http://production.shippingapis.com/ShippingAPI.dll - https://secure.shippingapis.com/ShippingAPI.dll - 0 - - true - Bound Printed Matter,Express Mail,Express Mail Flat Rate Envelope,Express Mail Flat Rate Envelope Hold For Pickup,Express Mail Flat-Rate Envelope Sunday/Holiday Guarantee,Express Mail Hold For Pickup,Express Mail International,Express Mail International Flat Rate Envelope,Express Mail PO to PO,Express Mail Sunday/Holiday Guarantee,First-Class Mail International Large Envelope,First-Class Mail International Letters,First-Class Mail International Package,First-Class Mail International Parcel,First-Class,First-Class Mail,First-Class Mail Flat,First-Class Mail Large Envelope,First-Class Mail International,First-Class Mail Letter,First-Class Mail Parcel,First-Class Mail Package,Global Express Guaranteed (GXG),Global Express Guaranteed Non-Document Non-Rectangular,Global Express Guaranteed Non-Document Rectangular,Library Mail,Media Mail,Parcel Post,Priority Mail,Priority Mail Small Flat Rate Box,Priority Mail Medium Flat Rate Box,Priority Mail Large Flat Rate Box,Priority Mail Flat Rate Box,Priority Mail Flat Rate Envelope,Priority Mail International,Priority Mail International Flat Rate Box,Priority Mail International Flat Rate Envelope,Priority Mail International Small Flat Rate Box,Priority Mail International Medium Flat Rate Box,Priority Mail International Large Flat Rate Box,USPS GXG Envelopes - Mage_Usa_Model_Shipping_Carrier_Usps - REGULAR - United States Postal Service - - - 0 - This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us. - 70 - F - O - - - Mage_Usa_Model_Shipping_Carrier_Dhl_International - - 0 - DHL - 0 - 1,3,4,8,P,Q,E,F,H,J,M,V,Y - 2,5,6,7,9,B,C,D,U,K,L,G,W,I,N,O,R,S,T,X - G - https://xmlpi-ea.dhl.com/XMLShippingServlet - - - N - This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us. - 1 - K - R - F - O - - - - diff --git a/app/code/core/Mage/User/Block/Role/Tab/Edit.php b/app/code/core/Mage/User/Block/Role/Tab/Edit.php deleted file mode 100644 index 745c4652458be..0000000000000 --- a/app/code/core/Mage/User/Block/Role/Tab/Edit.php +++ /dev/null @@ -1,201 +0,0 @@ - - */ -class Mage_User_Block_Role_Tab_Edit extends Mage_Backend_Block_Widget_Form - implements Mage_Backend_Block_Widget_Tab_Interface -{ - - protected $_template = 'role/edit.phtml'; - - /** - * Get tab label - * - * @return string - */ - public function getTabLabel() - { - return Mage::helper('Mage_User_Helper_Data')->__('Role Resources'); - } - - /** - * Get tab title - * - * @return string - */ - public function getTabTitle() - { - return $this->getTabLabel(); - } - - /** - * Whether tab is available - * - * @return bool - */ - public function canShowTab() - { - return true; - } - - /** - * Whether tab is visible - * - * @return bool - */ - public function isHidden() - { - return false; - } - - - /** - * Class constructor - * - */ - protected function _construct() - { - parent::_construct(); - - $rid = Mage::app()->getRequest()->getParam('rid', false); - - $acl = Mage::getSingleton('Mage_Core_Model_Acl_Builder', - array('data' => - array( - 'areaConfig' => Mage::getConfig()->getAreaConfig(), - 'objectFactory' => Mage::getConfig() - ) - ) - )->getAcl(); - $rulesSet = Mage::getResourceModel('Mage_User_Model_Resource_Rules_Collection')->getByRoles($rid)->load(); - - $selectedResourceIds = array(); - - foreach ($rulesSet->getItems() as $item) { - $itemResourceId = $item->getResource_id(); - if ($acl->has($itemResourceId) && $item->getPermission() == 'allow') { - array_push($selectedResourceIds, $itemResourceId); - } - } - - $this->setSelectedResources($selectedResourceIds); - - - } - - /** - * Check if everything is allowed - * - * @return boolean - */ - public function isEverythingAllowed() - { - return in_array(Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL, $this->getSelectedResources()); - } - - /** - * Get Json Representation of Resource Tree - * - * @return string - */ - public function getResTreeJson() - { - - /** @var $aclConfig Mage_Backend_Model_Acl_Config */ - $aclConfig = Mage::getSingleton('Mage_Backend_Model_Acl_Config'); - $resources = $aclConfig->getAclResources(); - - $adminNode = $resources->item(1); - $rootArray = $this->_getNodeJson($adminNode, 1); - - $json = Mage::helper('Mage_Core_Helper_Data')->jsonEncode( - isset($rootArray['children']) ? $rootArray['children'] : array() - ); - - return $json; - } - - /** - * Compare two nodes of the Resource Tree - * - * @param array $a - * @param array $b - * @return boolean - */ - protected function _sortTree($nodeA, $nodeB) - { - return $nodeA['sortOrder']<$nodeB['sortOrder'] ? -1 : ($nodeA['sortOrder']>$nodeB['sortOrder'] ? 1 : 0); - } - - /** - * Get Node Json - * - * @param mixed $node - * @param int $level - * @return array - */ - protected function _getNodeJson(DomElement $node, $level = 0) - { - $item = array(); - $selres = $this->getSelectedResources(); - if ($level != 0) { - $item['text'] = Mage::helper('Mage_User_Helper_Data')->__((string)$node->getAttribute('title')); - // @codingStandardsIgnoreStart - $item['sortOrder'] = $node->hasAttribute('sortOrder') ? (string)$node->getAttribute('sortOrder') : 0; - // @codingStandardsIgnoreEnd - $item['id'] = (string)$node->getAttribute('id'); - - if (in_array($item['id'], $selres)) { - $item['checked'] = true; - } - } - $children = $node->childNodes; - if (!empty($children)) { - $item['children'] = array(); - //$item['cls'] = 'fiche-node'; - foreach ($children as $child) { - if ($child instanceof DOMElement) { - if (!(string)$child->getAttribute('title')) { - continue; - } - if ($level != 0) { - $item['children'][] = $this->_getNodeJson($child, $level+1); - } else { - $item = $this->_getNodeJson($child, $level+1); - } - } - } - usort($item['children'], array($this, '_sortTree')); - } - return $item; - } -} diff --git a/app/code/core/Mage/User/etc/adminhtml/acl.xml b/app/code/core/Mage/User/etc/adminhtml/acl.xml deleted file mode 100644 index 3bfbeecbc258c..0000000000000 --- a/app/code/core/Mage/User/etc/adminhtml/acl.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/User/etc/adminhtml/menu.xml b/app/code/core/Mage/User/etc/adminhtml/menu.xml deleted file mode 100644 index 2f11018523e69..0000000000000 --- a/app/code/core/Mage/User/etc/adminhtml/menu.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - diff --git a/app/code/core/Mage/User/etc/config.xml b/app/code/core/Mage/User/etc/config.xml deleted file mode 100644 index b4a12dcc124d6..0000000000000 --- a/app/code/core/Mage/User/etc/config.xml +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - 1.6.1.3 - true - core - - - - - - - Mage_User_Model_User - - - Mage_User_Model_Acl_Loader_Rule - Mage_User_Model_Acl_Loader_Role - - - - - - - Mage_User - - - - - - 0 - 0 - - Mage_User_Model_User - - - - - - - admin_emails_forgot_email_template - general - 1 - - - - - - - - - Mage_User_Adminhtml - - - - - - - - - - layout.xml - - - - - diff --git a/app/code/core/Mage/User/view/adminhtml/role/edit.phtml b/app/code/core/Mage/User/view/adminhtml/role/edit.phtml deleted file mode 100644 index dca29c33aa652..0000000000000 --- a/app/code/core/Mage/User/view/adminhtml/role/edit.phtml +++ /dev/null @@ -1,150 +0,0 @@ - - - - -getChildHtml(); ?> - - - -
    - __('Roles Resources') ?> - -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - - - diff --git a/app/code/core/Mage/User/view/adminhtml/role/info.phtml b/app/code/core/Mage/User/view/adminhtml/role/info.phtml deleted file mode 100644 index 11bdf33604166..0000000000000 --- a/app/code/core/Mage/User/view/adminhtml/role/info.phtml +++ /dev/null @@ -1,38 +0,0 @@ - -
    - getBackButtonHtml() ?> - getResetButtonHtml() ?> - getDeleteButtonHtml() ?> - getSaveButtonHtml() ?> -
    -
    - getBlockHtml('formkey')?> -
    - diff --git a/app/code/core/Mage/Webapi/Block/Adminhtml/Role/Edit/Tab/Resource.php b/app/code/core/Mage/Webapi/Block/Adminhtml/Role/Edit/Tab/Resource.php deleted file mode 100644 index 4c07225d798ae..0000000000000 --- a/app/code/core/Mage/Webapi/Block/Adminhtml/Role/Edit/Tab/Resource.php +++ /dev/null @@ -1,160 +0,0 @@ -_authorizationConfig = $authorizationConfig; - $this->_ruleResource = $ruleResource; - } - - /** - * Prepare Form. - * - * @return Mage_Webapi_Block_Adminhtml_Role_Edit_Tab_Resource - */ - protected function _prepareForm() - { - $this->_aclResourcesTree = $this->_authorizationConfig->getAclResourcesAsArray(false); - $selectedResources = $this->_getSelectedResourcesIds(); - - if ($selectedResources) { - $selResourcesCallback = function (&$resourceItem) use ($selectedResources, &$selResourcesCallback) { - if (in_array($resourceItem['id'], $selectedResources)) { - $resourceItem['checked'] = true; - } - if (!empty($resourceItem['children'])) { - array_walk($resourceItem['children'], $selResourcesCallback); - } - }; - array_walk($this->_aclResourcesTree, $selResourcesCallback); - } - - return parent::_prepareForm(); - } - - /** - * Check whether resource access is set to "All". - * - * @return bool - */ - public function isEverythingAllowed() - { - return in_array(Mage_Webapi_Model_Authorization::API_ACL_RESOURCES_ROOT_ID, $this->_getSelectedResourcesIds()); - } - - /** - * Get ACL resources tree. - * - * @return string - */ - public function getResourcesTree() - { - return $this->_aclResourcesTree; - } - - /** - * Get selected ACL resources of given API role. - * - * @return array - */ - protected function _getSelectedResourcesIds() - { - $apiRole = $this->getApiRole(); - if (null === $this->_selResourcesIds && $apiRole && $apiRole->getId()) { - $this->_selResourcesIds = $this->_ruleResource->getResourceIdsByRole($apiRole->getRoleId()); - } - return (array)$this->_selResourcesIds; - } -} diff --git a/app/code/core/Mage/Webapi/Controller/Dispatcher/Soap/Authentication.php b/app/code/core/Mage/Webapi/Controller/Dispatcher/Soap/Authentication.php deleted file mode 100644 index 32f74f6ee6adc..0000000000000 --- a/app/code/core/Mage/Webapi/Controller/Dispatcher/Soap/Authentication.php +++ /dev/null @@ -1,95 +0,0 @@ -_helper = $helper; - $this->_tokenFactory = $usernameTokenFactory; - $this->_roleLocator = $roleLocator; - } - - /** - * Authenticate user. - * - * @param stdClass $usernameToken WS-Security UsernameToken object - * @throws Mage_Webapi_Exception If authentication failed - */ - public function authenticate($usernameToken) - { - try { - $token = $this->_tokenFactory->createFromArray(); - $request = $usernameToken; - // @codingStandardsIgnoreStart - $user = $token->authenticate($request->Username, $request->Password, $request->Created, $request->Nonce); - // @codingStandardsIgnoreEnd - $this->_roleLocator->setRoleId($user->getRoleId()); - } catch (Mage_Webapi_Model_Soap_Security_UsernameToken_NonceUsedException $e) { - throw new Mage_Webapi_Exception( - $this->_helper->__('WS-Security UsernameToken Nonce is already used.'), - Mage_Webapi_Exception::HTTP_BAD_REQUEST - ); - } catch (Mage_Webapi_Model_Soap_Security_UsernameToken_TimestampRefusedException $e) { - throw new Mage_Webapi_Exception( - $this->_helper->__('WS-Security UsernameToken Created timestamp is refused.'), - Mage_Webapi_Exception::HTTP_BAD_REQUEST - ); - } catch (Mage_Webapi_Model_Soap_Security_UsernameToken_InvalidCredentialException $e) { - throw new Mage_Webapi_Exception( - $this->_helper->__('Invalid Username or Password.'), - Mage_Webapi_Exception::HTTP_BAD_REQUEST - ); - } catch (Mage_Webapi_Model_Soap_Security_UsernameToken_InvalidDateException $e) { - throw new Mage_Webapi_Exception( - $this->_helper->__('Invalid UsernameToken Created date.'), - Mage_Webapi_Exception::HTTP_BAD_REQUEST - ); - } - } -} diff --git a/app/code/core/Mage/Webapi/Helper/Data.php b/app/code/core/Mage/Webapi/Helper/Data.php deleted file mode 100644 index 0a5eb6fad3915..0000000000000 --- a/app/code/core/Mage/Webapi/Helper/Data.php +++ /dev/null @@ -1,202 +0,0 @@ -_configHelper = $configHelper; - } - - /** - * Web API ACL resources tree root ID. - */ - const RESOURCES_TREE_ROOT_ID = '__root__'; - - /** - * Reformat request data to be compatible with method specified interface:
    - * - sort arguments in correct order
    - * - set default values for omitted arguments - * - instantiate objects of necessary classes - * - * @param string|object $classOrObject Resource class name - * @param string $methodName Resource method name - * @param array $requestData Data to be passed to method - * @param Mage_Webapi_Model_ConfigAbstract $apiConfig - * @return array Array of prepared method arguments - * @throws Mage_Webapi_Exception - */ - public function prepareMethodParams( - $classOrObject, - $methodName, - $requestData, - Mage_Webapi_Model_ConfigAbstract $apiConfig - ) { - $methodReflection = self::createMethodReflection($classOrObject, $methodName); - $methodData = $apiConfig->getMethodMetadata($methodReflection); - $methodArguments = array(); - if (isset($methodData['interface']['in']['parameters']) - && is_array($methodData['interface']['in']['parameters']) - ) { - foreach ($methodData['interface']['in']['parameters'] as $paramName => $paramData) { - if (isset($requestData[$paramName])) { - $methodArguments[$paramName] = $this->_formatParamData( - $requestData[$paramName], - $paramData['type'], - $apiConfig - ); - } elseif (!$paramData['required']) { - $methodArguments[$paramName] = $paramData['default']; - } else { - throw new Mage_Webapi_Exception($this->__('Required parameter "%s" is missing.', $paramName), - Mage_Webapi_Exception::HTTP_BAD_REQUEST); - } - } - } - return $methodArguments; - } - - /** - * Format $data according to specified $dataType recursively. - * - * Instantiate objects of proper classes and set data to its fields. - * - * @param mixed $data - * @param string $dataType - * @param Mage_Webapi_Model_ConfigAbstract $apiConfig - * @return mixed - * @throws LogicException If specified $dataType is invalid - * @throws Mage_Webapi_Exception If required fields do not have values specified in $data - */ - protected function _formatParamData($data, $dataType, Mage_Webapi_Model_ConfigAbstract $apiConfig) - { - if ($this->_configHelper->isTypeSimple($dataType) || is_null($data)) { - $formattedData = $data; - } elseif ($this->_configHelper->isArrayType($dataType)) { - $formattedData = $this->_formatArrayData($data, $dataType, $apiConfig); - } else { - $formattedData = $this->_formatComplexObjectData($data, $dataType, $apiConfig); - } - return $formattedData; - } - - /** - * Format data of array type. - * - * @param array $data - * @param string $dataType - * @param Mage_Webapi_Model_ConfigAbstract $apiConfig - * @return array - * @throws Mage_Webapi_Exception If passed data is not an array - */ - protected function _formatArrayData($data, $dataType, $apiConfig) - { - $itemDataType = $this->_configHelper->getArrayItemType($dataType); - $formattedData = array(); - if (!is_array($data)) { - throw new Mage_Webapi_Exception( - $this->__('Data corresponding to "%s" type is expected to be an array.', $dataType), - Mage_Webapi_Exception::HTTP_BAD_REQUEST - ); - } - foreach ($data as $itemData) { - $formattedData[] = $this->_formatParamData($itemData, $itemDataType, $apiConfig); - } - return $formattedData; - } - - /** - * Format data as object of the specified class. - * - * @param array|object $data - * @param string $dataType - * @param Mage_Webapi_Model_ConfigAbstract $apiConfig - * @return object Object of required data type - * @throws LogicException If specified $dataType is invalid - * @throws Mage_Webapi_Exception If required fields does not have values specified in $data - */ - protected function _formatComplexObjectData($data, $dataType, $apiConfig) - { - $dataTypeMetadata = $apiConfig->getTypeData($dataType); - $typeToClassMap = $apiConfig->getTypeToClassMap(); - if (!isset($typeToClassMap[$dataType])) { - throw new LogicException(sprintf('Specified data type "%s" does not match any class.', $dataType)); - } - $complexTypeClass = $typeToClassMap[$dataType]; - if (is_object($data) && (get_class($data) == $complexTypeClass)) { - /** In case of SOAP the object creation is performed by soap server. */ - return $data; - } - $complexDataObject = new $complexTypeClass(); - if (!is_array($data)) { - throw new Mage_Webapi_Exception( - $this->__('Data corresponding to "%s" type is expected to be an array.', $dataType), - Mage_Webapi_Exception::HTTP_BAD_REQUEST - ); - } - foreach ($dataTypeMetadata['parameters'] as $fieldName => $fieldMetadata) { - if (isset($data[$fieldName])) { - $fieldValue = $data[$fieldName]; - } elseif (($fieldMetadata['required'] == false)) { - $fieldValue = $fieldMetadata['default']; - } else { - throw new Mage_Webapi_Exception($this->__('Value of "%s" attribute is required.', $fieldName), - Mage_Webapi_Exception::HTTP_BAD_REQUEST); - } - $complexDataObject->$fieldName = $this->_formatParamData( - $fieldValue, - $fieldMetadata['type'], - $apiConfig - ); - } - return $complexDataObject; - } - - /** - * Create Zend method reflection object. - * - * @param string|object $classOrObject - * @param string $methodName - * @return Zend\Server\Reflection\ReflectionMethod - */ - public static function createMethodReflection($classOrObject, $methodName) - { - $methodReflection = new \ReflectionMethod($classOrObject, $methodName); - $classReflection = new \ReflectionClass($classOrObject); - $zendClassReflection = new Zend\Server\Reflection\ReflectionClass($classReflection); - $zendMethodReflection = new Zend\Server\Reflection\ReflectionMethod($zendClassReflection, $methodReflection); - return $zendMethodReflection; - } -} diff --git a/app/code/core/Mage/Webapi/Model/Authorization/Config/Reader/Factory.php b/app/code/core/Mage/Webapi/Model/Authorization/Config/Reader/Factory.php deleted file mode 100644 index e269ca3881875..0000000000000 --- a/app/code/core/Mage/Webapi/Model/Authorization/Config/Reader/Factory.php +++ /dev/null @@ -1,53 +0,0 @@ -_objectManager = $objectManager; - } - - /** - * Return new Mage_Webapi_Model_Authorization_Config_Reader - * - * @param array $arguments - * @return Mage_Webapi_Model_Authorization_Config_Reader - */ - public function createReader(array $arguments = array()) - { - return $this->_objectManager->create(self::READER_CLASS_NAME, $arguments, false); - } -} diff --git a/app/code/core/Mage/Webapi/Model/Authorization/Role/Factory.php b/app/code/core/Mage/Webapi/Model/Authorization/Role/Factory.php deleted file mode 100644 index 2d6fcba26b1c2..0000000000000 --- a/app/code/core/Mage/Webapi/Model/Authorization/Role/Factory.php +++ /dev/null @@ -1,53 +0,0 @@ -_objectManager = $objectManager; - } - - /** - * Return new ACL role model. - * - * @param array $arguments - * @return Mage_Webapi_Model_Authorization_Role - */ - public function createRole(array $arguments = array()) - { - return $this->_objectManager->create(self::ROLE_CLASS_NAME, $arguments, false); - } -} diff --git a/app/code/core/Mage/Webapi/Model/Soap/Security/UsernameToken/Factory.php b/app/code/core/Mage/Webapi/Model/Soap/Security/UsernameToken/Factory.php deleted file mode 100644 index e6a46977c72a7..0000000000000 --- a/app/code/core/Mage/Webapi/Model/Soap/Security/UsernameToken/Factory.php +++ /dev/null @@ -1,51 +0,0 @@ -_objectManager = $objectManager; - } - - /** - * Create username token. - * - * @param array $arguments - * @return Mage_Webapi_Model_Soap_Security_usernameToken - */ - public function createFromArray($arguments = array()) - { - return $this->_objectManager->create('Mage_Webapi_Model_Soap_Security_UsernameToken', $arguments); - } -} diff --git a/app/code/core/Mage/Webapi/Model/Soap/Wsdl/Factory.php b/app/code/core/Mage/Webapi/Model/Soap/Wsdl/Factory.php deleted file mode 100644 index 1e422943c52fc..0000000000000 --- a/app/code/core/Mage/Webapi/Model/Soap/Wsdl/Factory.php +++ /dev/null @@ -1,59 +0,0 @@ -_objectManager = $objectManager; - } - - /** - * Create WSDL builder instance. - * - * @param string $wsdlName - * @param string $endpointUrl - * @return Mage_Webapi_Model_Soap_Wsdl - */ - public function create($wsdlName, $endpointUrl) - { - return $this->_objectManager->create( - 'Mage_Webapi_Model_Soap_Wsdl', - array( - 'name' => $wsdlName, - 'uri' => $endpointUrl, - ), - false - ); - } -} diff --git a/app/code/core/Mage/Webapi/etc/adminhtml/acl.xml b/app/code/core/Mage/Webapi/etc/adminhtml/acl.xml deleted file mode 100644 index 1c5bffe04ed81..0000000000000 --- a/app/code/core/Mage/Webapi/etc/adminhtml/acl.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Webapi/etc/adminhtml/menu.xml b/app/code/core/Mage/Webapi/etc/adminhtml/menu.xml deleted file mode 100644 index 0dbadc30ed3d2..0000000000000 --- a/app/code/core/Mage/Webapi/etc/adminhtml/menu.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - diff --git a/app/code/core/Mage/Webapi/etc/config.xml b/app/code/core/Mage/Webapi/etc/config.xml deleted file mode 100644 index d90be7a2f4807..0000000000000 --- a/app/code/core/Mage/Webapi/etc/config.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - 1.0.0.3 - true - core - - - - - - - - - - - webapi - Mage_Webapi_Controller_Front - - Mage_Webapi_Controller_ActionAbstract - - Magento_Authorization_Policy_Acl - Mage_Webapi_Model_Authorization_Loader_Resource - Mage_Webapi_Model_Authorization_Loader_Role - Mage_Webapi_Model_Authorization_Loader_Rule - Mage_Webapi_Model_Authorization_RoleLocator - - - - - - - Mage_Webapi - - - - - - - - REST and SOAP configurations, generated WSDL file. - WEBSERVICE - - - - - - - - - - application/json - Mage_Webapi_Controller_Request_Rest_Interpreter_Json - - - - - application/xml - Mage_Webapi_Controller_Request_Rest_Interpreter_Xml - - - application/xhtml+xml - Mage_Webapi_Controller_Request_Rest_Interpreter_Xml - - - text/xml - Mage_Webapi_Controller_Request_Rest_Interpreter_Xml - - - - - - - - */* - Mage_Webapi_Controller_Response_Rest_Renderer_Json - - - application/json - Mage_Webapi_Controller_Response_Rest_Renderer_Json - - - - - text/xml - Mage_Webapi_Controller_Response_Rest_Renderer_Xml - - - application/xml - Mage_Webapi_Controller_Response_Rest_Renderer_Xml - - - application/xhtml+xml - Mage_Webapi_Controller_Response_Rest_Renderer_Xml - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - Mage_Webapi_Model_Authorization_Config - - - - - - - - - - Mage_Webapi_Adminhtml - - - - - - - - - - layout.xml - - - - - diff --git a/app/code/core/Mage/Weee/Block/Renderer/Weee/Tax.php b/app/code/core/Mage/Weee/Block/Renderer/Weee/Tax.php deleted file mode 100644 index b44a38b5ed54e..0000000000000 --- a/app/code/core/Mage/Weee/Block/Renderer/Weee/Tax.php +++ /dev/null @@ -1,157 +0,0 @@ - - */ -class Mage_Weee_Block_Renderer_Weee_Tax extends Mage_Adminhtml_Block_Widget implements Varien_Data_Form_Element_Renderer_Interface -{ - - protected $_element = null; - protected $_countries = null; - protected $_websites = null; - - protected $_template = 'renderer/tax.phtml'; - - public function getProduct() - { - return Mage::registry('product'); - } - - public function render(Varien_Data_Form_Element_Abstract $element) - { - $this->setElement($element); - $this->_setAddButton(); - return $this->toHtml(); - } - - public function setElement(Varien_Data_Form_Element_Abstract $element) - { - $this->_element = $element; - return $this; - } - - public function getElement() - { - return $this->_element; - } - - public function getValues() - { - $values =array(); - $data = $this->getElement()->getValue(); - - if (is_array($data) && count($data)) { - usort($data, array($this, '_sortWeeeTaxes')); - $values = $data; - } - return $values; - } - - protected function _sortWeeeTaxes($a, $b) - { - if ($a['website_id']!=$b['website_id']) { - return $a['website_id']<$b['website_id'] ? -1 : 1; - } - if ($a['country']!=$b['country']) { - return $a['country']<$b['country'] ? -1 : 1; - } - return 0; - } - - public function getWebsiteCount() - { - return count($this->getWebsites()); - } - - public function isMultiWebsites() - { - return !Mage::app()->hasSingleStore(); - } - - public function getCountries() - { - if (is_null($this->_countries)) { - $this->_countries = Mage::getModel('Mage_Directory_Model_Config_Source_Country') - ->toOptionArray(); - } - - return $this->_countries; - } - - public function getWebsites() - { - if (!is_null($this->_websites)) { - return $this->_websites; - } - $websites = array(); - $websites[0] = array( - 'name' => $this->__('All Websites'), - 'currency' => Mage::app()->getBaseCurrencyCode() - ); - - if (!Mage::app()->hasSingleStore() && !$this->getElement()->getEntityAttribute()->isScopeGlobal()) { - if ($storeId = $this->getProduct()->getStoreId()) { - $website = Mage::app()->getStore($storeId)->getWebsite(); - $websites[$website->getId()] = array( - 'name' => $website->getName(), - 'currency' => $website->getConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE), - ); - } else { - foreach (Mage::app()->getWebsites() as $website) { - if (!in_array($website->getId(), $this->getProduct()->getWebsiteIds())) { - continue; - } - $websites[$website->getId()] = array( - 'name' => $website->getName(), - 'currency' => $website->getConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE), - ); - } - } - } - $this->_websites = $websites; - return $this->_websites; - } - - protected function _setAddButton() - { - $this->addChild('add_button', 'Mage_Adminhtml_Block_Widget_Button', array( - 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Add Tax'), - 'onclick' => "weeeTaxControl.addItem('".$this->getElement()->getHtmlId()."')", - 'class' => 'add' - )); - } - - public function getAddButtonHtml() - { - return $this->getChildHtml('add_button'); - } - -} diff --git a/app/code/core/Mage/Weee/etc/config.xml b/app/code/core/Mage/Weee/etc/config.xml deleted file mode 100644 index 0b677c2c9eb21..0000000000000 --- a/app/code/core/Mage/Weee/etc/config.xml +++ /dev/null @@ -1,211 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - - - Mage_Weee - Mage_Weee_Model_Resource_Setup - - - - - - - - model - Mage_Weee_Model_Observer - assignBackendModelToAttribute - - - - - - - Mage_Weee_Model_Observer - updateDiscountPercents - - - - - - - Mage_Weee_Model_Observer - updateConfigurableProductOptions - - - - - - - Mage_Weee_Model_Observer - updateBundleProductOptions - - - - - - - - - Mage_Weee_Model_Total_Quote_Weee - subtotal,tax_subtotal - tax,discount - - - - - Mage_Weee_Model_Total_Quote_Nominal_Weee - 600 - - - - - - - Mage_Weee_Model_Total_Invoice_Weee - subtotal,tax,discount,grand_total,cost_total,shipping - - - - - - - - Mage_Weee_Model_Total_Creditmemo_Weee - subtotal - tax,discount,grand_total - - - - - - - - - - - Mage_Weee_Model_Observer - setWeeeRendererInForm - - - - - - - Mage_Weee_Model_Observer - updateExcludedFieldList - - - - - - - model - Mage_Weee_Model_Observer - addWeeeTaxAttributeType - - - - - - - Mage_Weee_Model_Observer - updateElementTypes - - - - - - - - - Mage_Weee.csv - - - - - - - - - 50 - - - - - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - - - - - - weee - - - - - - - - - layout.xml - - - - - - - - Mage_Weee.csv - - - - - - diff --git a/app/code/core/Mage/Weee/view/adminhtml/renderer/tax.phtml b/app/code/core/Mage/Weee/view/adminhtml/renderer/tax.phtml deleted file mode 100644 index 624ab37cb8728..0000000000000 --- a/app/code/core/Mage/Weee/view/adminhtml/renderer/tax.phtml +++ /dev/null @@ -1,196 +0,0 @@ - -getElement()->getHtmlId() ?> -getElement()->getClass() ?> -getElement()->getName() ?> -isMultiWebsites(); ?> - - getElement()->getLabel() ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    style="display:none">__('Website') ?>__('Country/State') ?> *__('Tax') ?> *__('Action') ?>
    style="display:none"> - - - -
    - -
    - - - - -
    style="display:none">getAddButtonHtml() ?>
    - - - - diff --git a/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Options.php b/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Options.php deleted file mode 100644 index 1850aca64f69c..0000000000000 --- a/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Options.php +++ /dev/null @@ -1,227 +0,0 @@ - - */ - -class Mage_Widget_Block_Adminhtml_Widget_Options extends Mage_Adminhtml_Block_Widget_Form -{ - /** - * Element type used by default if configuration is omitted - * @var string - */ - protected $_defaultElementType = 'text'; - - /** - * Translation helper instance, defined by the widget type declaration root config node - * @var Mage_Core_Helper_Abstract - */ - protected $_translationHelper = null; - - /** - * Prepare Widget Options Form and values according to specified type - * - * widget_type must be set in data before - * widget_values may be set before to render element values - */ - protected function _prepareForm() - { - $this->getForm()->setUseContainer(false); - $this->addFields(); - return $this; - } - - /** - * Form getter/instantiation - * - * @return Varien_Data_Form - */ - public function getForm() - { - if ($this->_form instanceof Varien_Data_Form) { - return $this->_form; - } - $form = new Varien_Data_Form(); - $this->setForm($form); - return $form; - } - - /** - * Fieldset getter/instantiation - * - * @return Varien_Data_Form_Element_Fieldset - */ - public function getMainFieldset() - { - if ($this->_getData('main_fieldset') instanceof Varien_Data_Form_Element_Fieldset) { - return $this->_getData('main_fieldset'); - } - $mainFieldsetHtmlId = 'options_fieldset' . md5($this->getWidgetType()); - $this->setMainFieldsetHtmlId($mainFieldsetHtmlId); - $fieldset = $this->getForm()->addFieldset($mainFieldsetHtmlId, array( - 'legend' => $this->helper('Mage_Widget_Helper_Data')->__('Widget Options'), - 'class' => 'fieldset-wide', - )); - $this->setData('main_fieldset', $fieldset); - - // add dependence javascript block - $block = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Form_Element_Dependence'); - $this->setChild('form_after', $block); - - return $fieldset; - } - - /** - * Add fields to main fieldset based on specified widget type - * - * @return Mage_Adminhtml_Block_Widget_Form - */ - public function addFields() - { - // get configuration node and translation helper - if (!$this->getWidgetType()) { - Mage::throwException($this->__('Widget Type is not specified')); - } - $config = Mage::getSingleton('Mage_Widget_Model_Widget')->getConfigAsObject($this->getWidgetType()); - if (!$config->getParameters()) { - return $this; - } - $module = $config->getModule(); - $this->_translationHelper = Mage::helper($module ? $module : 'Mage_Widget_Helper_Data'); - foreach ($config->getParameters() as $parameter) { - $this->_addField($parameter); - } - - return $this; - } - - /** - * Add field to Options form based on parameter configuration - * - * @param Varien_Object $parameter - * @return Varien_Data_Form_Element_Abstract - */ - protected function _addField($parameter) - { - $form = $this->getForm(); - $fieldset = $this->getMainFieldset(); //$form->getElement('options_fieldset'); - - // prepare element data with values (either from request of from default values) - $fieldName = $parameter->getKey(); - $data = array( - 'name' => $form->addSuffixToName($fieldName, 'parameters'), - 'label' => $this->_translationHelper->__($parameter->getLabel()), - 'required' => $parameter->getRequired(), - 'class' => 'widget-option', - 'note' => $this->_translationHelper->__($parameter->getDescription()), - ); - - if ($values = $this->getWidgetValues()) { - $data['value'] = (isset($values[$fieldName]) ? $values[$fieldName] : ''); - } - else { - $data['value'] = $parameter->getValue(); - //prepare unique id value - if ($fieldName == 'unique_id' && $data['value'] == '') { - $data['value'] = md5(microtime(1)); - } - } - - // prepare element dropdown values - if ($values = $parameter->getValues()) { - // dropdown options are specified in configuration - $data['values'] = array(); - foreach ($values as $option) { - $data['values'][] = array( - 'label' => $this->_translationHelper->__($option['label']), - 'value' => $option['value'] - ); - } - } - // otherwise, a source model is specified - elseif ($sourceModel = $parameter->getSourceModel()) { - $data['values'] = Mage::getModel($sourceModel)->toOptionArray(); - } - - // prepare field type or renderer - $fieldRenderer = null; - $fieldType = $parameter->getType(); - // hidden element - if (!$parameter->getVisible()) { - $fieldType = 'hidden'; - } - // just an element renderer - elseif ($fieldType && $this->_isClassName($fieldType)) { - $fieldRenderer = $this->getLayout()->createBlock($fieldType); - $fieldType = $this->_defaultElementType; - } - - // instantiate field and render html - $field = $fieldset->addField($this->getMainFieldsetHtmlId() . '_' . $fieldName, $fieldType, $data); - if ($fieldRenderer) { - $field->setRenderer($fieldRenderer); - } - - // extra html preparations - if ($helper = $parameter->getHelperBlock()) { - $helperBlock = $this->getLayout()->createBlock($helper->getType(), '', $helper->getData()); - if ($helperBlock instanceof Varien_Object) { - $helperBlock->setConfig($helper->getData()) - ->setFieldsetId($fieldset->getId()) - ->setTranslationHelper($this->_translationHelper) - ->prepareElementHtml($field); - } - } - - // dependencies from other fields - $dependenceBlock = $this->getChildBlock('form_after'); - $dependenceBlock->addFieldMap($field->getId(), $fieldName); - if ($parameter->getDepends()) { - foreach ($parameter->getDepends() as $from => $row) { - $values = isset($row['values']) ? array_values($row['values']) : (string)$row['value']; - $dependenceBlock->addFieldDependence($fieldName, $from, $values); - } - } - - return $field; - } - - /** - * Checks whether $fieldType is a class name of custom renderer, and not just a type of input element - * - * @param string $fieldType - * @return bool - */ - protected function _isClassName($fieldType) - { - return preg_match('/[A-Z]/', $fieldType) > 0; - } -} diff --git a/app/code/core/Mage/Widget/Model/Template/Filter.php b/app/code/core/Mage/Widget/Model/Template/Filter.php deleted file mode 100644 index db33c8e2affdf..0000000000000 --- a/app/code/core/Mage/Widget/Model/Template/Filter.php +++ /dev/null @@ -1,78 +0,0 @@ - - */ -class Mage_Widget_Model_Template_Filter extends Mage_Cms_Model_Template_Filter -{ - /** - * Generate widget - * - * @param array $construction - * @return string - */ - public function widgetDirective($construction) - { - $params = $this->_getIncludeParameters($construction[2]); - - // Determine what name block should have in layout - $name = null; - if (isset($params['name'])) { - $name = $params['name']; - } - - // validate required parameter type or id - if (!empty($params['type'])) { - $type = $params['type']; - } elseif (!empty($params['id'])) { - $preconfigured = Mage::getResourceSingleton('Mage_Widget_Model_Resource_Widget') - ->loadPreconfiguredWidget($params['id']); - $type = $preconfigured['widget_type']; - $params = $preconfigured['parameters']; - } else { - return ''; - } - - // we have no other way to avoid fatal errors for type like 'cms/widget__link', '_cms/widget_link' etc. - $xml = Mage::getSingleton('Mage_Widget_Model_Widget')->getXmlElementByType($type); - if ($xml === null) { - return ''; - } - - // define widget block and check the type is instance of Widget Interface - $widget = Mage::app()->getLayout()->createBlock($type, $name, $params); - if (!$widget instanceof Mage_Widget_Block_Interface) { - return ''; - } - - return $widget->toHtml(); - } -} diff --git a/app/code/core/Mage/Widget/etc/adminhtml/acl.xml b/app/code/core/Mage/Widget/etc/adminhtml/acl.xml deleted file mode 100644 index b9ce063f0fbbe..0000000000000 --- a/app/code/core/Mage/Widget/etc/adminhtml/acl.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Widget/etc/adminhtml/menu.xml b/app/code/core/Mage/Widget/etc/adminhtml/menu.xml deleted file mode 100644 index 60406ef26d817..0000000000000 --- a/app/code/core/Mage/Widget/etc/adminhtml/menu.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - diff --git a/app/code/core/Mage/Widget/etc/config.xml b/app/code/core/Mage/Widget/etc/config.xml deleted file mode 100644 index a7f6adea97737..0000000000000 --- a/app/code/core/Mage/Widget/etc/config.xml +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - 1.6.0.2 - true - core - - - - - - - - - - Mage_Widget - - - - - - Mage_Widget_Model_Template_Filter - - - Mage_Widget_Model_Template_Filter - - - - - - - - - - - - - - layout.xml - - - - - - - - - - Mage_Widget.csv - - - - - - - - layout.xml - - - - - - - - Mage_Widget_Model_Observer - prepareWidgetsPluginConfig - - - - - - - - - - - Mage_Widget_Adminhtml - - - - - - diff --git a/app/code/core/Mage/Wishlist/Block/Abstract.php b/app/code/core/Mage/Wishlist/Block/Abstract.php deleted file mode 100644 index f62ffa70efa2a..0000000000000 --- a/app/code/core/Mage/Wishlist/Block/Abstract.php +++ /dev/null @@ -1,425 +0,0 @@ - - */ -abstract class Mage_Wishlist_Block_Abstract extends Mage_Catalog_Block_Product_Abstract -{ - /** - * Wishlist Product Items Collection - * - * @var Mage_Wishlist_Model_Resource_Item_Collection - */ - protected $_collection; - - /** - * Store wishlist Model - * - * @var Mage_Wishlist_Model_Wishlist - */ - protected $_wishlist; - - /** - * List of block settings to render prices for different product types - * - * @var array - */ - protected $_itemPriceBlockTypes = array(); - - /** - * List of block instances to render prices for different product types - * - * @var array - */ - protected $_cachedItemPriceBlocks = array(); - - /** - * Internal constructor, that is called from real constructor - * - */ - protected function _construct() - { - parent::_construct(); - $this->addItemPriceBlockType( - 'default', - 'Mage_Wishlist_Block_Render_Item_Price', - 'render/item/price.phtml' - ); - } - - /** - * Retrieve Wishlist Data Helper - * - * @return Mage_Wishlist_Helper_Data - */ - protected function _getHelper() - { - return Mage::helper('Mage_Wishlist_Helper_Data'); - } - - /** - * Retrieve Customer Session instance - * - * @return Mage_Customer_Model_Session - */ - protected function _getCustomerSession() - { - return Mage::getSingleton('Mage_Customer_Model_Session'); - } - - /** - * Retrieve Wishlist model - * - * @return Mage_Wishlist_Model_Wishlist - */ - protected function _getWishlist() - { - return $this->_getHelper()->getWishlist(); - } - - /** - * Prepare additional conditions to collection - * - * @param Mage_Wishlist_Model_Resource_Item_Collection $collection - * @return Mage_Wishlist_Block_Customer_Wishlist - */ - protected function _prepareCollection($collection) - { - return $this; - } - - /** - * Create wishlist item collection - * - * @return Mage_Wishlist_Model_Resource_Item_Collection - */ - protected function _createWishlistItemCollection() - { - return $this->_getWishlist()->getItemCollection(); - } - - /** - * Retrieve Wishlist Product Items collection - * - * @return Mage_Wishlist_Model_Resource_Item_Collection - */ - public function getWishlistItems() - { - if (is_null($this->_collection)) { - $this->_collection = $this->_createWishlistItemCollection(); - $this->_prepareCollection($this->_collection); - } - - return $this->_collection; - } - - /** - * Retrieve wishlist instance - * - * @return Mage_Wishlist_Model_Wishlist - */ - public function getWishlistInstance() - { - return $this->_getWishlist(); - } - - /** - * Retrieve URL for Removing item from wishlist - * - * @param Mage_Catalog_Model_Product|Mage_Wishlist_Model_Item $item - * - * @return string - */ - public function getItemRemoveUrl($item) - { - return $this->_getHelper()->getRemoveUrl($item); - } - - /** - * Retrieve Add Item to shopping cart URL - * - * @param string|Mage_Catalog_Model_Product|Mage_Wishlist_Model_Item $item - * @return string - */ - public function getItemAddToCartUrl($item) - { - return $this->_getHelper()->getAddToCartUrl($item); - } - - /** - * Retrieve Add Item to shopping cart URL from shared wishlist - * - * @param string|Mage_Catalog_Model_Product|Mage_Wishlist_Model_Item $item - * @return string - */ - public function getSharedItemAddToCartUrl($item) - { - return $this->_getHelper()->getSharedAddToCartUrl($item); - } - - /** - * Retrieve URL for adding Product to wishlist - * - * @param Mage_Catalog_Model_Product $product - * @return string - */ - public function getAddToWishlistUrl($product) - { - return $this->_getHelper()->getAddUrl($product); - } - - /** - * Returns item configure url in wishlist - * - * @param Mage_Catalog_Model_Product|Mage_Wishlist_Model_Item $product - * - * @return string - */ - public function getItemConfigureUrl($product) - { - if ($product instanceof Mage_Catalog_Model_Product) { - $id = $product->getWishlistItemId(); - } else { - $id = $product->getId(); - } - $params = array('id' => $id); - - return $this->getUrl('wishlist/index/configure/', $params); - } - - - /** - * Retrieve Escaped Description for Wishlist Item - * - * @param Mage_Catalog_Model_Product $item - * @return string - */ - public function getEscapedDescription($item) - { - if ($item->getDescription()) { - return $this->escapeHtml($item->getDescription()); - } - return ' '; - } - - /** - * Check Wishlist item has description - * - * @param Mage_Catalog_Model_Product $item - * @return bool - */ - public function hasDescription($item) - { - return trim($item->getDescription()) != ''; - } - - /** - * Retrieve formated Date - * - * @param string $date - * @return string - */ - public function getFormatedDate($date) - { - return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM); - } - - /** - * Check is the wishlist has a salable product(s) - * - * @return bool - */ - public function isSaleable() - { - foreach ($this->getWishlistItems() as $item) { - if ($item->getProduct()->isSaleable()) { - return true; - } - } - - return false; - } - - /** - * Retrieve wishlist loaded items count - * - * @return int - */ - public function getWishlistItemsCount() - { - return $this->_getWishlist()->getItemsCount(); - } - - /** - * Retrieve Qty from item - * - * @param Mage_Wishlist_Model_Item|Mage_Catalog_Model_Product $item - * @return float - */ - public function getQty($item) - { - $qty = $item->getQty() * 1; - if (!$qty) { - $qty = 1; - } - return $qty; - } - - /** - * Check is the wishlist has items - * - * @return bool - */ - public function hasWishlistItems() - { - return $this->getWishlistItemsCount() > 0; - } - - /** - * Adds special block to render price for item with specific product type - * - * @param string $type - * @param string $block - * @param string $template - */ - public function addItemPriceBlockType($type, $block = '', $template = '') - { - if ($type) { - $this->_itemPriceBlockTypes[$type] = array( - 'block' => $block, - 'template' => $template - ); - } - } - - /** - * Returns block to render item with some product type - * - * @param string $productType - * @return Mage_Core_Block_Template - */ - protected function _getItemPriceBlock($productType) - { - if (!isset($this->_itemPriceBlockTypes[$productType])) { - $productType = 'default'; - } - - if (!isset($this->_cachedItemPriceBlocks[$productType])) { - $blockType = $this->_itemPriceBlockTypes[$productType]['block']; - $template = $this->_itemPriceBlockTypes[$productType]['template']; - $block = $this->getLayout()->createBlock($blockType) - ->setTemplate($template); - $this->_cachedItemPriceBlocks[$productType] = $block; - } - return $this->_cachedItemPriceBlocks[$productType]; - } - - /** - * Returns product price block html - * Overwrites parent price html return to be ready to show configured, partially configured and - * non-configured products - * - * @param Mage_Catalog_Model_Product $product - * @param bool $displayMinimalPrice - * @param string $idSuffix - * - * @return string - */ - public function getPriceHtml($product, $displayMinimalPrice = false, $idSuffix = '') - { - $type_id = $product->getTypeId(); - if (Mage::helper('Mage_Catalog_Helper_Data')->canApplyMsrp($product)) { - $realPriceHtml = $this->_preparePriceRenderer($type_id) - ->setProduct($product) - ->setDisplayMinimalPrice($displayMinimalPrice) - ->setIdSuffix($idSuffix) - ->setIsEmulateMode(true) - ->toHtml(); - $product->setAddToCartUrl($this->getAddToCartUrl($product)); - $product->setRealPriceHtml($realPriceHtml); - $type_id = $this->_mapRenderer; - } - - return $this->_preparePriceRenderer($type_id) - ->setProduct($product) - ->setDisplayMinimalPrice($displayMinimalPrice) - ->setIdSuffix($idSuffix) - ->toHtml(); - } - - /** - * Retrieve URL to item Product - * - * @param Mage_Wishlist_Model_Item|Mage_Catalog_Model_Product $item - * @param array $additional - * @return string - */ - public function getProductUrl($item, $additional = array()) - { - if ($item instanceof Mage_Catalog_Model_Product) { - $product = $item; - } else { - $product = $item->getProduct(); - } - $buyRequest = $item->getBuyRequest(); - if (is_object($buyRequest)) { - $config = $buyRequest->getSuperProductConfig(); - if ($config && !empty($config['product_id'])) { - $product = Mage::getModel('Mage_Catalog_Model_Product') - ->setStoreId(Mage::app()->getStore()->getStoreId()) - ->load($config['product_id']); - } - } - return parent::getProductUrl($product, $additional); - } - - /** - * Product image url getter - * - * @param Mage_Core_Model_Product $product - * @return string - */ - public function getImageUrl($product) - { - return (string) $this->helper('Mage_Catalog_Helper_Image')->init($product, 'small_image')->resize($this->getImageSize()); - } - - /** - * Product image size getter - * - * @return int - */ - public function getImageSize() - { - return $this->getVar('product_image_size', 'Mage_Wishlist'); - } -} diff --git a/app/code/core/Mage/Wishlist/etc/adminhtml/acl.xml b/app/code/core/Mage/Wishlist/etc/adminhtml/acl.xml deleted file mode 100644 index 2de1c53c8fd3a..0000000000000 --- a/app/code/core/Mage/Wishlist/etc/adminhtml/acl.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/app/code/core/Mage/Wishlist/etc/config.xml b/app/code/core/Mage/Wishlist/etc/config.xml deleted file mode 100644 index f69b9d64768c0..0000000000000 --- a/app/code/core/Mage/Wishlist/etc/config.xml +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - 1.6.0.0 - true - core - - - - - - - - - - - Mage_Wishlist - - - - - - - - - Mage_Wishlist_Model_Observer - processCartUpdateBefore - - - - - - - Mage_Wishlist_Model_Observer - processAddToCart - - - - - - - - - - - - - - - - - - standard - - Mage_Wishlist - wishlist - - - - - - - - Mage_Wishlist.csv - - - - - - - - layout.xml - - - - - - - - Mage_Wishlist_Model_Observer - customerLogin - - - - - - - Mage_Wishlist_Model_Observer - customerLogout - - - - - - /wishlist/ - - - - - - - - Mage_Wishlist.csv - - - - - - - - layout.xml - - - - - - - - 1 - - - general - wishlist_email_email_template - - - - diff --git a/app/design/adminhtml/default/backend/Mage_Backend/images/admin-add-product-btn-bg.png b/app/design/adminhtml/default/backend/Mage_Backend/images/admin-add-product-btn-bg.png deleted file mode 100644 index 7c775956dcc6a..0000000000000 Binary files a/app/design/adminhtml/default/backend/Mage_Backend/images/admin-add-product-btn-bg.png and /dev/null differ diff --git a/app/design/adminhtml/default/backend/Mage_Backend/images/datagrid-dropdown-arrow.png b/app/design/adminhtml/default/backend/Mage_Backend/images/datagrid-dropdown-arrow.png deleted file mode 100644 index 280925e29a242..0000000000000 Binary files a/app/design/adminhtml/default/backend/Mage_Backend/images/datagrid-dropdown-arrow.png and /dev/null differ diff --git a/app/design/adminhtml/default/backend/Mage_Backend/images/datagrid-sorted-th-arrows.png b/app/design/adminhtml/default/backend/Mage_Backend/images/datagrid-sorted-th-arrows.png deleted file mode 100644 index 4d73368ed7079..0000000000000 Binary files a/app/design/adminhtml/default/backend/Mage_Backend/images/datagrid-sorted-th-arrows.png and /dev/null differ diff --git a/app/design/adminhtml/default/backend/css/admin.css b/app/design/adminhtml/default/backend/css/admin.css index 745cc07a397ff..c829976404f98 100644 --- a/app/design/adminhtml/default/backend/css/admin.css +++ b/app/design/adminhtml/default/backend/css/admin.css @@ -27,40 +27,40 @@ @font-face { font-family: 'CallunaSans'; - src: url('Mage_Backend::fonts/calluna/CallunaSansLight-webfont.woff'); - src: url('Mage_Backend::fonts/calluna/CallunaSansLight-webfont.eot?#iefix') format('embedded-opentype'), url('Mage_Backend::fonts/calluna/CallunaSansLight-webfont.svg#webfont85gDAx2H') format('svg'), url('Mage_Backend::fonts/calluna/CallunaSansLight-webfont.woff') format('woff'), url('Mage_Backend::fonts/calluna/CallunaSansLight-webfont.ttf') format('truetype'); + src: url('../fonts/calluna/CallunaSansLight-webfont.woff'); + src: url('../fonts/calluna/CallunaSansLight-webfont.eot?#iefix') format('embedded-opentype'), url('../fonts/calluna/CallunaSansLight-webfont.svg#webfont85gDAx2H') format('svg'), url('../fonts/calluna/CallunaSansLight-webfont.woff') format('woff'), url('../fonts/calluna/CallunaSansLight-webfont.ttf') format('truetype'); font-style: normal; font-weight: 200; } @font-face { font-family: 'CallunaSans'; - src: url('Mage_Backend::fonts/calluna/CallunaSansRegular-webfont.woff'); - src: url('Mage_Backend::fonts/calluna/CallunaSansRegular-webfont.eot?#iefix') format('embedded-opentype'), url('Mage_Backend::fonts/calluna/CallunaSansRegular-webfont.svg#webfont85gDAx2D') format('svg'), url('Mage_Backend::fonts/calluna/CallunaSansRegular-webfont.woff') format('woff'), url('Mage_Backend::fonts/calluna/CallunaSansRegular-webfont.ttf') format('truetype'); + src: url('../fonts/calluna/CallunaSansRegular-webfont.woff'); + src: url('../fonts/calluna/CallunaSansRegular-webfont.eot?#iefix') format('embedded-opentype'), url('../fonts/calluna/CallunaSansRegular-webfont.svg#webfont85gDAx2D') format('svg'), url('../fonts/calluna/CallunaSansRegular-webfont.woff') format('woff'), url('../fonts/calluna/CallunaSansRegular-webfont.ttf') format('truetype'); font-style: normal; font-weight: 400; } @font-face { font-family: 'CallunaSans'; - src: url('Mage_Backend::fonts/calluna/CallunaSansSemiBold-webfont.woff'); - src: url('Mage_Backend::fonts/calluna/CallunaSansSemiBold-webfont.eot?#iefix') format('embedded-opentype'), url('Mage_Backend::fonts/calluna/CallunaSansSemiBold-webfont.svg#webfont85gDAx2A') format('svg'), url('Mage_Backend::fonts/calluna/CallunaSansSemiBold-webfont.woff') format('woff'), url('Mage_Backend::fonts/calluna/CallunaSansSemiBold-webfont.ttf') format('truetype'); + src: url('../fonts/calluna/CallunaSansSemiBold-webfont.woff'); + src: url('../fonts/calluna/CallunaSansSemiBold-webfont.eot?#iefix') format('embedded-opentype'), url('../fonts/calluna/CallunaSansSemiBold-webfont.svg#webfont85gDAx2A') format('svg'), url('../fonts/calluna/CallunaSansSemiBold-webfont.woff') format('woff'), url('../fonts/calluna/CallunaSansSemiBold-webfont.ttf') format('truetype'); font-style: normal; font-weight: 500; } @font-face { font-family: 'CallunaSans'; - src: url('Mage_Backend::fonts/calluna/CallunaSansBold-webfont.woff'); - src: url('Mage_Backend::fonts/calluna/CallunaSansBold-webfont.eot?#iefix') format('embedded-opentype'), url('Mage_Backend::fonts/calluna/CallunaSansBold-webfont.svg#webfont85gDAx2C') format('svg'), url('Mage_Backend::fonts/calluna/CallunaSansBold-webfont.woff') format('woff'), url('Mage_Backend::fonts/calluna/CallunaSansBold-webfont.ttf') format('truetype'); + src: url('../fonts/calluna/CallunaSansBold-webfont.woff'); + src: url('../fonts/calluna/CallunaSansBold-webfont.eot?#iefix') format('embedded-opentype'), url('../fonts/calluna/CallunaSansBold-webfont.svg#webfont85gDAx2C') format('svg'), url('../fonts/calluna/CallunaSansBold-webfont.woff') format('woff'), url('../fonts/calluna/CallunaSansBold-webfont.ttf') format('truetype'); font-style: normal; font-weight: 600; } @font-face { font-family: 'admin-icons'; - src: url('Mage_Backend::fonts/icons/admin-icons.eot'); - src: url('Mage_Backend::fonts/icons/admin-icons.eot?#iefix') format('embedded-opentype'), url('Mage_Backend::fonts/icons/admin-icons.svg#admin-icons') format('svg'), url('Mage_Backend::fonts/icons/admin-icons.woff') format('woff'), url('Mage_Backend::fonts/icons/admin-icons.ttf') format('truetype'); + src: url('../fonts/icons/admin-icons.eot'); + src: url('../fonts/icons/admin-icons.eot?#iefix') format('embedded-opentype'), url('../fonts/icons/admin-icons.svg#admin-icons') format('svg'), url('../fonts/icons/admin-icons.woff') format('woff'), url('../fonts/icons/admin-icons.ttf') format('truetype'); font-weight: normal; font-style: normal; } @@ -80,7 +80,7 @@ body, html { body { position: relative; - background: url(Mage_Backend::images/body-bg.jpg); + background: url(../images/body-bg.jpg); height: auto; } @@ -129,7 +129,9 @@ input[type=submit].primary:visited, input[type=reset].primary:visited, button.primary:visited, .primary, -.primary:visited { +.primary:visited, +.popup-window .add-widget, +.popup-window .add-widget:visited { color: #fff; background: #f47b20; } @@ -143,7 +145,9 @@ input[type=submit].primary:focus, input[type=reset].primary:focus, button.primary:focus, .primary:hover, -.primary:focus { +.primary:focus, +.popup-window .add-widget:hover, +.popup-window .add-widget:focus { background: #e2701a; color: #fff; text-shadow: 0 -1px 2px #955326; @@ -158,7 +162,8 @@ input[type=submit].primary.active, input[type=reset].primary.active, button.primary.active, .primary:active, -.primary.active { +.primary.active, +.popup-window .add-widget:active { box-shadow: 0 1px 5px #955326 inset; } @@ -196,60 +201,188 @@ button.primary.disabled, /* Reset 'button view' for actions -------------------------------------- */ +.customer-current-activity .action-refresh, +.customer-current-activity .action-refresh, .pager .action-next, .pager .action-previous, .pager .action-next:hover, .pager .action-previous:hover, -.action-.delete, -.action-.delete:hover, -.action-.delete:active, -.action-.delete.active, -.action-.delete:disabled, +.data-table .action-.delete, +.data-table .action-.delete:hover, +.data-table .action-.delete:active, +.data-table .action-.delete.active, +.data-table .action-delete, +.data-table .action-delete:hover, +.data-table .action-delete:active, +.data-table .action-delete.active, #product-variations-matrix .action-choose, #product-variations-matrix .action-choose:hover, #product-variations-matrix .action-choose:active, #product-variations-matrix .action-choose.active, -#product-variations-matrix .action-choose:disabled, +#product-variations-matrix .action-choose[disabled], +.action-manage-images, +.action-manage-images:hover, +.action-manage-images:active, +.action-manage-images.active, +.action-manage-images[disabled], +.mage-new-category-dialog .action-cancel, +.mage-new-category-dialog .action-cancel:hover, +.mage-new-category-dialog .action-cancel:active, +.mage-new-category-dialog .action-cancel.active, +.mage-new-category-dialog .action-cancel[disabled], +.image-panel .action-close, +.image-panel .action-close:hover, +.image-panel .action-close:active, +.image-panel .action-close.active, +.image-panel .action-close[disabled], +.image-panel-controls .action-remove, +.image-panel-controls .action-remove:hover, +.image-panel-controls .action-remove:active, +.image-panel-controls .action-remove.active, +.image-panel-controls .action-remove[disabled], +.vde-image-sizing .action-connect, +.vde-image-sizing .action-connect:hover, +.vde-image-sizing .action-connect:active, +.vde-image-sizing .action-connect.active, +.vde-image-sizing .action-connect:disabled, +.suggest-expandable .action-show-all, +.suggest-expandable .action-show-all:hover, +.suggest-expandable .action-show-all:active, +.suggest-expandable .action-show-all.active, +.suggest-expandable .action-show-all[disabled], .fieldset-wrapper-title .action-add, .fieldset-wrapper-title .action-add:hover, .fieldset-wrapper-title .action-add:active, .fieldset-wrapper-title .action-add.active, -.fieldset-wrapper-title .action-add:disabled, -#store-view-window [class^='action-close'], -#store-view-window [class^='action-close']:hover, -#store-view-window [class^='action-close']:active, -#store-view-window [class^='action-close'].active, -#store-view-window [class^='action-close']:disabled, +.fieldset-wrapper-title .action-add[disabled], .custom-file > .action-add, .custom-file > .action-add:hover, .custom-file > .action-add:active, .custom-file > .action-add.active, -.custom-file > .action-add:disabled, +.custom-file > .action-add[disabled], .vde-tools-header .action-close, .vde-tools-header .action-close:hover, .vde-tools-header .action-close:active, .vde-tools-header .action-close.active, +.image .action-delete, +.image .action-delete:hover, +.image .action-delete:active, +.image .action-delete.active, +.fieldset-wrapper-title .actions .action-delete, +.fieldset-wrapper-title .actions .action-delete:hover, +.fieldset-wrapper-title .actions .action-delete:active, +.fieldset-wrapper-title .actions .action-delete.active, +.address-list-item-actions .action-delete, +.address-list-item-actions .action-delete:hover, +.address-list-item-actions .action-delete:active, +.address-list-item-actions .action-delete.active, +.notification .action-close, +.notification .action-close:hover, +.notification .action-close:active, +.notification .action-close.active { + border: none; + border-radius: 0; + background: none; + margin: 0; + padding: 0; + box-shadow: none; + text-shadow: none; +} + +.data-table .action-.delete:disabled, +.data-table .action-delete:disabled, +#product-variations-matrix .action-choose:disabled, +.image-panel .action-close:disabled, +.image-panel-controls .action-remove:disabled, +.suggest-expandable .action-show-all:disabled, +.fieldset-wrapper-title .action-add:disabled, +#store-view-window [class^='action-close'], +#store-view-window [class^='action-close']:hover, +#store-view-window [class^='action-close']:active, +#store-view-window [class^='action-close'].active, +#store-view-window [class^='action-close']:disabled, +.custom-file > .action-add:disabled, +.image .action-delete, +.image .action-delete:hover, +.image .action-delete:active, +.image .action-delete.active, +.fieldset-wrapper-title .actions .action-delete, +.fieldset-wrapper-title .actions .action-delete:hover, +.fieldset-wrapper-title .actions .action-delete:active, +.fieldset-wrapper-title .actions .action-delete.active, +.address-list-item-actions .action-delete, +.address-list-item-actions .action-delete:hover, +.address-list-item-actions .action-delete:active, +.address-list-item-actions .action-delete.active, +.notification .action-close, +.notification .action-close:hover, +.notification .action-close:active, +.notification .action-close.active { + border: none; + border-radius: 0; + background: none; + margin: 0; + padding: 0; + box-shadow: none; + text-shadow: none; +} + +.data-table .action-.delete:disabled, +.data-table .action-delete:disabled, +#product-variations-matrix .action-choose:disabled, +.image-panel .action-close:disabled, +.image-panel-controls .action-remove:disabled, +.suggest-expandable .action-show-all:disabled, +.fieldset-wrapper-title .action-add:disabled, +#store-view-window [class^='action-close'], +#store-view-window [class^='action-close']:hover, +#store-view-window [class^='action-close']:active, +#store-view-window [class^='action-close'].active, +#store-view-window [class^='action-close']:disabled, +.custom-file > .action-add:disabled, .vde-tools-header .action-close:disabled, -.action-delete, -.action-delete:hover, -.action-delete:active, -.action-delete.active, -.action-delete:disabled, +.vde-image-sizing .action-reset, +.vde-image-sizing .action-reset:hover, +.vde-image-sizing .action-reset:active, +.vde-image-sizing .action-reset.active, +.vde-image-sizing .action-reset[disabled], +.image .action-delete:disabled, +.fieldset-wrapper-title .actions .action-delete:disabled, +.address-list-item-actions .action-delete:disabled, [class^=" adminhtml-catalog-product-"] .page-actions .action-back, [class^=" adminhtml-catalog-product-"] .page-actions .action-back:hover, [class^=" adminhtml-catalog-product-"] .page-actions .action-back:active, [class^=" adminhtml-catalog-product-"] .page-actions .action-back.active, -[class^=" adminhtml-catalog-product-"] .page-actions .action-back:disabled, +[class^=" adminhtml-catalog-product-"] .page-actions .action-back[disabled], +[class^=" adminhtml-newsletter-"] .page-actions .action-back, +[class^=" adminhtml-newsletter-"] .page-actions .action-back:hover, +[class^=" adminhtml-newsletter-"] .page-actions .action-back:active, +[class^=" adminhtml-newsletter-"] .page-actions .action-back.active, +[class^=" adminhtml-newsletter-"] .page-actions .action-back[disabled], .notifications [class^="action-"], .notifications [class^="action-"]:hover, .notifications [class^="action-"]:active, .notifications [class^="action-"].active, -.notifications [class^="action-"]:disabled, +.notifications [class^="action-"][disabled], .notification .action-close, .notification .action-close:hover, .notification .action-close:active, .notification .action-close.active, -.notification .action-close:disabled { +.notification .action-close[disabled] { + border: none; + border-radius: 0; + background: none; + margin: 0; + padding: 0; + box-shadow: none; + text-shadow: none; +} + +.vde-image-sizing .action-connect, +.vde-image-sizing .action-connect:hover, +.vde-image-sizing .action-connect:active, +.vde-image-sizing .action-connect.active, +.vde-image-sizing .action-connect:disabled { border: none; border-radius: 0; background: none; @@ -259,6 +392,24 @@ button.primary.disabled, text-shadow: none; } +/* + Actions as links +-------------------------------------- */ +.mage-new-category-dialog .action-cancel { + background: none; + border: none; + color: #6d665e; + font-weight: normal; + font-size: 12px; + cursor: pointer; + text-decoration: underline; +} + +.mage-new-category-dialog .action-cancel:hover { + color: #000; + border-bottom-color: #000; +} + /* Fileupload button -------------------------------------- */ @@ -276,6 +427,7 @@ button.primary.disabled, right: 0; bottom: 0; opacity: 0; + font-size: 10em; } /* @@ -295,11 +447,7 @@ button.primary.disabled, border-radius: 3px; background: #fff; box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2); - z-index: 1; -} - -.dropdown-menu > li { - white-space: nowrap; + z-index: 990; } .dropdown-menu > li, @@ -310,12 +458,12 @@ button.primary.disabled, .dropdown-menu > li.selected, .ui-autocomplete > li.selected { - background: #f5f5f5; + background: #eef8fc; } .dropdown-menu > li:hover, .ui-autocomplete > li:hover { - background: #f5f5f5; + background: #eef8fc; } .dropdown-menu > li:last-child, @@ -362,10 +510,7 @@ button.primary.disabled, position: relative; display: inline-block; vertical-align: top; - margin: 0 6px 6px 0; - width: 72.5%; - padding: 2px; - padding-right: 30px; + width: 100%; background-color: #fff; border: 1px solid #ccc; border-radius: 3px; @@ -374,6 +519,30 @@ button.primary.disabled, box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); } +.mage-suggest:after { + position: absolute; + top: 0; + right: 3px; + bottom: 0; + width: 22px; + text-align: center; + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: '\e01f'; /* search icon */ + font-size: 20px; + color: #b2b2b2; +} + +.mage-suggest input[type="search"] { + width: 100%; + border: none; + background: none; + padding-right: 30px; +} + .mage-suggest-dropdown { position: absolute; left: 0; @@ -387,12 +556,177 @@ button.primary.disabled, z-index: 990; } -.mage-suggest-dropdown .jstree { - padding: 5px; +.mage-suggest-dropdown ul { + margin: 0; + padding: 0; + list-style: none; } -.mage-suggest-dropdown .jstree a { - line-height: 1.666; +.mage-suggest-dropdown li { + border-bottom: 1px solid #e5e5e5; + padding: 0; +} + +.mage-suggest-dropdown li a { + display: block; +} + +.mage-suggest-dropdown li a, +.mage-suggest-dropdown .jstree li a:hover, +.mage-suggest-dropdown .jstree .jstree-hovered, +.mage-suggest-dropdown .jstree .jstree-clicked { + padding: 6px 10px 5px; + text-decoration: none; + color: #333; +} + +.mage-suggest-dropdown .jstree li a:hover, +.mage-suggest-dropdown .jstree .jstree-hovered, +.mage-suggest-dropdown .jstree .jstree-clicked { + border: none; +} + +.mage-suggest-dropdown li a.ui-state-focus { + background: #f5f5f5; +} + +.mage-suggest-dropdown .jstree li { + border-bottom: 0; +} + +.mage-suggest-dropdown .jstree li a { + display: inline-block; +} + +.mage-suggest-dropdown .jstree .mage-suggest-selected > a { + color: #000000; + background: #F1FFEB; +} + +.mage-suggest-dropdown .jstree .mage-suggest-selected > a:hover, +.mage-suggest-dropdown .jstree .mage-suggest-selected > .jstree-hovered, +.mage-suggest-dropdown .jstree .mage-suggest-selected > .jstree-clicked, +.mage-suggest-dropdown .jstree .mage-suggest-selected.mage-suggest-not-active > .jstree-hovered, +.mage-suggest-dropdown .jstree .mage-suggest-selected.mage-suggest-not-active > .jstree-clicked { + background: #E5FFD9; +} + +.mage-suggest-dropdown .jstree .mage-suggest-not-active > a { + color: #D4D4D4; +} + +.mage-suggest-dropdown .jstree .mage-suggest-not-active > a:hover, +.mage-suggest-dropdown .jstree .mage-suggest-not-active > .jstree-hovered, +.mage-suggest-dropdown .jstree .mage-suggest-not-active > .jstree-clicked { + background: #F5F5F5; +} + +.mage-suggest-dropdown .category-path { + font-size: 11px; + margin-left: 10px; + color: #9ba8b5; +} + +.suggest-expandable .actions-split .action-toggle { + background: none; + border: none; + box-shadow: none; + color: #676056; + font-size: 12px; + padding: 5px 4px; +} + +.suggest-expandable .actions-split .action-toggle span { + display: inline; +} + +.suggest-expandable .actions-split .action-toggle:before { + display: inline-block; + float: right; + margin-left: 4px; + font-size: 13px; + color: #b2b0ad; +} + +.suggest-expandable .actions-split .action-toggle:hover:before { + color: #7e7e7e; +} + +.suggest-expandable .dropdown-menu { + margin: 1px 0 0; + left: 0; + right: auto; + width: 221px; +} + +.suggest-expandable .mage-suggest { + border: none; +} + +.suggest-expandable .mage-suggest:after { + top: 6px; + right: 6px; +} + +.suggest-expandable .mage-suggest-inner .title { + margin: 0; + padding: 0 10px 4px; + text-transform: uppercase; + color: #a6a098; + font-size: 12px; + border-bottom: 1px solid #e5e5e5; +} + +.suggest-expandable .mage-suggest-inner > input[type="search"] { + position: relative; + margin: 6px 5px 5px; + padding-right: 20px; + border: 1px solid #ccc; + width: 211px; + z-index: 1; +} + +.suggest-expandable .mage-suggest-inner > input.ui-autocomplete-loading, +.suggest-expandable .mage-suggest-inner > input.mage-suggest-state-loading { + background: #fff url(../mui/images/ajax-loader-small.gif) no-repeat 190px 50%; +} + +.suggest-expandable .mage-suggest-dropdown { + position: relative; + border: none; + box-shadow: none; + background: none; + margin: 0; + top: auto; +} + +.suggest-expandable .mage-suggest-dropdown ul { + margin: 0; + padding: 0; + list-style: none; +} + +.suggest-expandable .action-show-all, +.suggest-expandable .action-show-all:hover, +.suggest-expandable .action-show-all:active, +.suggest-expandable .action-show-all:focus, +.suggest-expandable .action-show-all[disabled] { + border-top: 1px solid #e5e5e5; + display: block; + width: 100%; + padding: 8px 10px 10px; + text-align: left; + font: 12px/1.333 Arial, Verdana, sans-serif; + color: #676056; +} + +.page-actions .suggest-expandable { + float: left; + margin-top: 1px; +} + +.page-actions.fixed #product-template-suggest-container { + margin-left: 148px; } /* @@ -444,19 +778,35 @@ button.primary.disabled, .actions-split.active .dropdown-menu { display: block; + white-space: nowrap; +} + +.actions-split.active .dropdown-menu > li { + padding: 0; +} + +.actions-split.active .dropdown-menu > li > .item { + display: block; + padding: 6px 10px 5px; } /* Action delete icon -------------------------------------- */ /* TODO: replase ".action-.delete" to ".action-delete" after buttons refactoring */ -.action-.delete span, -.action-delete span { +.data-table .action-.delete span, +.data-table .action-delete span, +.image .action-delete span, +.fieldset-wrapper-title .actions .action-delete span, +.address-list-item-actions .action-delete span { display: none; } -.action-.delete:before, -.action-delete:before { +.data-table .action-.delete:before, +.data-table .action-delete:before, +.image .action-delete:before, +.fieldset-wrapper-title .actions .action-delete:before, +.address-list-item-actions .action-delete:before { font-family: 'MUI-Icons'; font-style: normal; speak: none; @@ -467,39 +817,42 @@ button.primary.disabled, color: #b7b3ad; } -.action-.delete:hover:before, -.action-delete:hover:before { +.data-table .action-.delete:hover:before, +.data-table .action-delete:hover:before, +.image .action-delete:hover:before, +.fieldset-wrapper-title .actions .action-delete:hover:before, +.address-list-item-actions .action-delete:hover:before { color: #7e7e7e; } -input.action-.delete[type="button"], -input.action-.delete[type="submit"], -input.action-.delete[type="reset"], -button.action-.delete, -input.action-.delete[type="button"]:visited, -input.action-.delete[type="submit"]:visited, -input.action-.delete[type="reset"]:visited, -button.action-.delete:visited, -input.action-.delete[type="button"]:hover, -input.action-.delete[type="submit"]:hover, -input.action-.delete[type="reset"]:hover, -button.action-.delete:hover, -input.action-.delete[type="button"]:active, -input.action-.delete[type="submit"]:active, -input.action-.delete[type="reset"]:active, -button.action-.delete:active { +.data-table input.action-.delete[type="button"], +.data-table input.action-.delete[type="submit"], +.data-table input.action-.delete[type="reset"], +.data-table button.action-.delete, +.data-table input.action-.delete[type="button"]:visited, +.data-table input.action-.delete[type="submit"]:visited, +.data-table input.action-.delete[type="reset"]:visited, +.data-table button.action-.delete:visited, +.data-table input.action-.delete[type="button"]:hover, +.data-table input.action-.delete[type="submit"]:hover, +.data-table input.action-.delete[type="reset"]:hover, +.data-table button.action-.delete:hover, +.data-table input.action-.delete[type="button"]:active, +.data-table input.action-.delete[type="submit"]:active, +.data-table input.action-.delete[type="reset"]:active, +.data-table button.action-.delete:active { background: transparent; padding: 3px 7px 0; } -input.action-.delete[type=button]:hover:before, -input.action-.delete[type=submit]:hover:before, -input.action-.delete[type=reset]:hover:before, -button.action-.delete:hover:before, -input.action-.delete[type=button]:focus:before, -input.action-.delete[type=submit]:focus:before, -input.action-.delete[type=reset]:focus:before, -button.action-.delete:focus:before { +.data-table input.action-.delete[type=button]:hover:before, +.data-table input.action-.delete[type=submit]:hover:before, +.data-table input.action-.delete[type=reset]:hover:before, +.data-table button.action-.delete:hover:before, +.data-table input.action-.delete[type=button]:focus:before, +.data-table input.action-.delete[type=submit]:focus:before, +.data-table input.action-.delete[type=reset]:focus:before, +.data-table button.action-.delete:focus:before { background: transparent; color: #a5a29d; } @@ -560,12 +913,7 @@ textarea, -webkit-box-sizing: border-box; box-sizing: border-box; border-radius: 4px; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - -webkit-transition: border linear 0.5s, box-shadow linear 0.2s; - -moz-transition: border linear 0.5s, box-shadow linear 0.2s; - -ms-transition: border linear 0.5s, box-shadow linear 0.2s; - -o-transition: border linear 0.5s, box-shadow linear 0.2s; - transition: border linear 0.5s, box-shadow linear 0.2s; + box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); } textarea, @@ -578,11 +926,6 @@ select { margin: 0 0 8px; border: 1px solid #ccc; border-radius: 4px; - -webkit-transition: border linear 0.5s, box-shadow linear 0.2s; - -moz-transition: border linear 0.5s, box-shadow linear 0.2s; - -ms-transition: border linear 0.5s, box-shadow linear 0.2s; - -o-transition: border linear 0.5s, box-shadow linear 0.2s; - transition: border linear 0.5s, box-shadow linear 0.2s; } select[multiple], @@ -627,6 +970,12 @@ textarea[readonly] { cursor: not-allowed; background-color: #eee; border-color: #ddd; + color:#676056; +} + +select[disabled].multiselect > option[selected] { + color: #fff; + background: #6d6d6d; } textarea:-moz-placeholder, @@ -659,12 +1008,23 @@ option.placeholder { .form-inline .label { width: 20%; + padding-top: 6px; +} + +.form-inline .label ~ .control { + width: 60%; } -.form-inline .label + .control { +.form-inline .no-label .control { + margin-left: 20%; width: 60%; } +fieldset.field [class^='fields-group-'] .field .control { + width: auto; + margin: 0 0 0 20px; +} + .form-inline .field-service { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; @@ -684,16 +1044,26 @@ option.placeholder { margin-bottom: 5px; } +.form-inline .field-service .checkbox { + margin: 0; + vertical-align: middle; +} + .control > input { width: 100%; } +.control > input[type="button"] { + width: auto; +} + .control > input.hasDatepicker { width: 130px; } .control > input[type="radio"], -.control > input[type="checkbox"] { +.control > input[type="checkbox"], +.control > input[type="file"] { width: auto; } @@ -715,6 +1085,42 @@ option.placeholder { vertical-align: middle; } +.nobr { + white-space: nowrap; +} + +/* + Form Validation +-------------------------------------- */ +label.mage-error { + color: red; + text-align: left; +} + +textarea.mage-error, +select.mage-error, +input.mage-error { + border-color: #fa7973 !important; + box-shadow: 0 0 8px rgba(250, 121, 115, 0.6) !important; +} + +input.mage-error ~ .addafter { + border-color: #fa7973 !important; + box-shadow: 0 0 8px rgba(250, 121, 115, 0.6) !important; +} + +/* + Forms for Store Scope +-------------------------------------- */ +.form-inline .field-store_id .label + .control, +.form-inline .field-store_ids .label + .control, +.form-inline .field-website_ids .label + .control, +.form-inline .field-website_id .label + .control, +.form-inline .field-select_stores .label + .control, +.form-inline .field-stores .label + .control { + width: auto; +} + /* Forms styles -------------------------------------- */ @@ -753,23 +1159,8 @@ option.placeholder { margin: 0 0 18px; } -.fieldset-wrapper { - padding-bottom: 2px; -} - .fieldset-wrapper > .fieldset-wrapper-title { float: none; - border-bottom: none; - margin-bottom: 0; -} - -.fieldset-wrapper.opened { - padding-bottom: 18px; -} - -.fieldset-wrapper.opened > .fieldset-wrapper-title { - border-bottom: 1px solid #ededed; - margin-bottom: 18px; } .fieldset-wrapper > .fieldset-wrapper-title .title, @@ -778,17 +1169,37 @@ option.placeholder { font-size: 18px; color: #666; font-weight: normal; - padding: 7px 0 10px 10px; + padding: 7px 0 10px; display: inline-block; } -.fieldset-wrapper-title > .title[data-toggle="collapse"] { +/* Collapsable fieldset-wrapper */ +.collapsable-wrapper { + padding-bottom: 2px; +} + +.collapsable-wrapper.opened { + padding-bottom: 18px; +} + +.collapsable-wrapper > .fieldset-wrapper-title { + border-bottom: none; + margin-bottom: 0; +} + +.collapsable-wrapper.opened > .fieldset-wrapper-title { + border-bottom: 1px solid #ededed; + margin-bottom: 18px; +} + +.collapsable-wrapper .fieldset-wrapper-title > .title { position: relative; padding-left: 22px; cursor: pointer; + float: left; } -.fieldset-wrapper-title > .title[data-toggle="collapse"]:before { +.collapsable-wrapper .fieldset-wrapper-title > .title:before { position: absolute; left: 0; top: 7px; @@ -801,12 +1212,12 @@ option.placeholder { color: #b2b0ad; } -.fieldset-wrapper-title > .title[data-toggle="collapse"]:hover:before { - color: #7e7e7e; +.collapsable-wrapper.opened > .fieldset-wrapper-title > .title:before { + content: '\e02c'; /* arrow down icon */ } -.fieldset-wrapper.opened > .fieldset-wrapper-title > .title:before { - content: '\e02c'; /* arrow down icon */ +.collapsable-wrapper .fieldset-wrapper-title > .title:hover:before { + color: #7e7e7e; } /* Fieldset styles in another fieldset */ @@ -844,6 +1255,7 @@ option.placeholder { -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; + min-height: 39px; } .fieldset .fieldset-wrapper .fieldset-wrapper-title .actions, @@ -864,33 +1276,25 @@ option.placeholder { top: 9px; } -.fieldset .fieldset-wrapper-title .draggable-handle, -.fieldset-wrapper .fieldset-wrapper-title .draggable-handle { - position: absolute; - left: 10px; - top: 12px; +.fieldset-wrapper-content .fieldset > .title { + margin-top: 0; + padding-left: 22px; +} + +.fieldset-wrapper .draggable-handle, +.fieldset .draggable-handle { width: 8px; height: 14px; line-height: 14px; - background: none; + background: url(Mage_Backend::images/dragable-handler-vertical.gif) no-repeat 0 0; cursor: pointer; color: #b2b0ad; } -.fieldset .fieldset-wrapper-title .draggable-handle:hover, -.fieldset-wrapper .fieldset-wrapper-title .draggable-handle:hover { - color: #7e7e7e; -} - -.fieldset .fieldset-wrapper-title .draggable-handle:before, -.fieldset-wrapper .fieldset-wrapper-title .draggable-handle:before { - font-family: 'MUI-Icons'; - font-style: normal; - speak: none; - font-weight: normal; - -webkit-font-smoothing: antialiased; - content: '\e022'; - font-size: 16px; +.fieldset-wrapper-title > .draggable-handle { + position: absolute; + left: 10px; + top: 12px; } .fieldset .fieldset-wrapper .fieldset-wrapper-content, @@ -899,15 +1303,18 @@ option.placeholder { } /* Sortable fieldsets */ -.ui-sortable .entry-edit .fieldset-wrapper-title { +.ui-sortable .entry-edit .fieldset-wrapper-title, +#product_options_container_top .fieldset-wrapper-title { padding-left: 30px; } .ui-sortable .entry-edit .fieldset-wrapper-title > .title { } -.fieldset-wrapper-title > .actions { +.fieldset-wrapper-title > .actions, +.fieldset .legend > .actions { float: right; + padding-top: 8px; } .fieldset > .legend + br { @@ -926,13 +1333,35 @@ option.placeholder { margin: 0 0 29px; } -.fieldset .legend > span { +.eq-ie8 .fieldset-alt, +.eq-ie8 .fieldset-alt > .fieldset { + display: block; + width: 100%; +} + +.eq-ie8 .fieldset-alt > .field { + display: inline-block; +} + +.fieldset .comment { + margin: 0 0 29px 10px; } .fieldset .field { margin: 0 0 29px; } +.fieldset .field .options-list { + list-style: none; + margin: 0; + padding: 0; +} + +.fieldset .field .options-list input[type="checkbox"], +.fieldset .field .options-list input[type="radio"] { + margin-right: 5px; +} + [class^="fields-group-"] .field { margin-bottom: 0; } @@ -955,10 +1384,73 @@ option.placeholder { .fieldset .control .addon .textarea { border-radius: 4px; width: 100%; + resize: vertical; } .fieldset > .field > input[type="checkbox"] { - margin-top: 10px; + margin-top: 12px; +} + +.fieldset-alt { + position: relative; + display: table-row; + border: 0; + padding: 0; + margin-bottom: 20px; + width: 100%; +} + +.fieldset-alt > .field { + display: table-cell; + vertical-align: top; + padding-right: 4%; +} + +.fieldset-alt > .field.no-display { + display: none; +} + +.fieldset-alt .field > .label { + display: block; + width: 100%; + clear: both; + text-align: left; + margin: 0 0 10px; +} + +.fieldset-alt .label + .control { + width: 100%; +} + +.fieldset-alt .field-option-title { + width: 50%; +} + +.fieldset-alt .field-option-store-view { + width: 20%; +} + +.fieldset-alt .field-option-input-type { + width: 20%; +} + +.fieldset-alt .field-option-input-type select { + width: 100%; +} + +.fieldset-alt .field-option-req { + width: 105px; + white-space: nowrap; +} + +.fieldset-alt .field-option-req .control { + position: relative; + top: 32px; +} + +.fieldset-alt .field-option-position, +.fieldset-alt .field-option-position .control { + width: 60px; } /* "Use default" checkbox */ @@ -981,6 +1473,69 @@ option.placeholder { color: #7e7e7e; } +/* + Custom Multiselect +-------------------------------------- */ +.multiselect-alt { + margin: 0; + padding: 0; + list-style: none; + border: 1px solid #ccc; + border-radius: 5px; + color: #333; +} + +.multiselect-alt .item { + position: relative; + border-top: 1px solid #fff; + cursor: pointer; +} + +.multiselect-alt .item:first-child { + border-top: 0; +} + +.multiselect-alt .item.selected { + background: #d7ebf5; +} + +.multiselect-alt .item.selected:hover { + background: #afdef2; +} + +.multiselect-alt label { + display: block; + cursor: pointer; + padding: 6px 25px 5px; +} + +.multiselect-alt .item.selected label:before { + position: absolute; + left: 8px; + top: 1px; + bottom: 0; + width: 10px; + line-height: 28px; + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: '\e01e'; /* checked icon */ + text-align: center; + color: #7ba4b1; + font-size: 9px; + text-shadow: 0 -1px 1px #60727b; +} + +.multiselect-alt input[type="checkbox"] { + width: 0; + height: 0; + opacity: 0; + margin: 0; + padding: 0; +} + /* Form item with table -------------------------------------- */ @@ -1005,27 +1560,24 @@ option.placeholder { border-width: 1px 0 1px 1px; } -.addon input:focus + label { +.addon input:focus ~ .addafter { border-color: #75b9f0; box-shadow: 0 0 8px rgba(82, 168, 236, 0.6); - -webkit-transition: border linear 0.5s, box-shadow linear 0.2s; - -moz-transition: border linear 0.5s, box-shadow linear 0.2s; - -ms-transition: border linear 0.5s, box-shadow linear 0.2s; - -o-transition: border linear 0.5s, box-shadow linear 0.2s; - transition: border linear 0.5s, box-shadow linear 0.2s; } -.addon input + label strong { +.addon input ~ .addafter strong { background: #fff; display: block; - line-height: 25px; - margin: 1px 3px 0 -2px; + line-height: 24px; + margin: 0 3px 0 -2px; padding-left: 4px; padding-right: 4px; position: relative; + font-size: 12px; + top: 0; } -.addon input:focus + label strong { +.addon input:focus ~ .addafter strong { margin-top: 0; } @@ -1038,6 +1590,18 @@ option.placeholder { box-shadow: 0 1px 0 rgba(0, 0, 0, 0.075) inset; } +.field .control input[type='text'][disabled], +.field .control input[type='text'][disabled] ~ .addafter { + background-color: #fff; + border-color: #eee; + box-shadow: none; + color: #999; +} + +.field .control input[type='text'][disabled] ~ .addafter strong { + background-color: #fff; +} + .field-price .addon, .field-special_price .addon, .field-msrp .addon { @@ -1082,16 +1646,16 @@ option.placeholder { box-shadow: 0 0 8px rgba(82, 168, 236, 0.6); } -.field-price input:focus + label, -.field-special_price input:focus + label, -.field-msrp input:focus + label { +.field-price input:focus ~ label.addafter, +.field-special_price input:focus ~ label.addafter, +.field-msrp input:focus ~ label.addafter { box-shadow: 0 0 8px rgba(82, 168, 236, 0.6); } -.field-price input + label strong, -.field-special_price input + label strong, -.field-msrp input + label strong { - margin-left: 3px; +.field-price input ~ label.addafter strong, +.field-special_price input ~ label.addafter strong, +.field-msrp input ~ label.addafter strong { + margin-left: 2px; margin-right: -2px; } @@ -1221,8 +1785,7 @@ table .dropdown-menu li { } table tbody tr td:first-child input[type="checkbox"] { - margin-left: 5px; - margin-top: 0; + margin: 0; } table tbody tr:nth-child(odd) td, @@ -1244,6 +1807,21 @@ table tbody tr:nth-child(odd):hover th { background-color: #fff; } +/* + X-tree styles +-------------------------------------- */ +.x-tree-node .leaf .x-tree-node-icon { + background-image: url(../images/fam_leaf.png); +} + +.x-tree-node .system-leaf .x-tree-node-icon { + background-image: url(../images/fam_application_form_delete.png); +} + +.x-tree-node-ct { + overflow: hidden; +} + /* Styles for "js" tooltip with positionings -------------------------------------- */ @@ -1442,6 +2020,10 @@ table tbody tr:nth-child(odd):hover th { border-radius: 8px; } +.wrapper-popup { + padding: 0 10px; +} + .fade .popup .popup-inner { padding: 20px; border-radius: 3px; @@ -1483,50 +2065,56 @@ table tbody tr:nth-child(odd):hover th { -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)"; } -/* Old loading popup */ -/* TODO: remove this popup after refactoring of "varienLoader.js" file */ +/* Loading mask */ .loading-old, .loading-mask { - border: 1px solid #d85909; - position: fixed; - z-index: 1003; - width: 200px !important; - height: auto !important; - background: rgba(255, 255, 255, .8); - left: 50% !important; - top: 40% !important; - margin-left: -100px; - color: #d85909; - font-size: 14px; - font-weight: bold; - text-align: center; - padding: 100px 0 10px; + background: rgba(255, 255, 255, .4); + z-index: 999; } -.loading-old:after, -.loading-mask:after { - position: absolute; - left: 50%; - top: 40%; - background-image: url(../mui/images/ajax-loader-big.gif); - width: 64px; - height: 64px; - margin: -32px 0 0 -32px; - content: ''; - z-index: 2; +.loading-old { + position: fixed; + left: 0; + top: 0; + right: 0; + bottom: 0; } .loading-old .loader, .loading-mask .loader { - position: relative !important; - left: auto !important; - top: auto !important; + position: absolute; + margin: auto; + left: 0; + top: 0; + right: 0; + bottom: 0; + width: 160px; + height: 160px; + color: #5e5b56; + font-size: 14px; + font-weight: bold; + text-align: center; + background: #e5e2dd url(../mui/images/ajax-loader-big.gif) no-repeat 50% 30%; + border-radius: 5px; + opacity: .95; +} + +.eq-ie8 .loading-old .loader { + bottom: auto; + right: auto; + margin: auto; + left: auto; } .loading-mask img { display: none; } +.loading-old p, +.loading-mask p { + margin-top: 118px; +} + .eq-ie8 .loading-old, .eq-ie8 .loading-mask { background: #fff; @@ -2017,9 +2605,7 @@ table tbody tr:nth-child(odd):hover th { z-index: 2; } -/*.navigation .level-0.item-stores > a span:before, */ -/* TODO: place the gear icon to the "Stores" nav item when it appears */ -.navigation .level-0.item-system > a span:before { +.navigation .level-0.item-stores > a span:before { position: absolute; left: -22px; top: -1px; @@ -2057,11 +2643,14 @@ table tbody tr:nth-child(odd):hover th { Login page -------------------------------------- */ -.page-login { +.page-login form { + border: 1px solid #b5dcd6; + border-radius: 5px; } .page-login .fieldset { - border-color: #B5DCD6; + border: none; + margin: 0; } .page-login .footer-content { @@ -2171,6 +2760,8 @@ table tbody tr:nth-child(odd):hover th { color: #676056; display: inline-block; margin: 0; + width: 100%; + word-wrap: break-word; } .page-title-inner .title > h3 { @@ -2394,6 +2985,7 @@ table tbody tr:nth-child(odd):hover th { -------------------------------------- */ .wrapper { padding: 0 0 60px; + min-width: 1000px; } .page-content { @@ -2442,7 +3034,7 @@ table tbody tr:nth-child(odd):hover th { .col-1-layout { position: relative; background: #f5f2ed; - border: 1px solid #b7b2a6; + border: 1px solid #d5d0ca; border-radius: 5px; min-width: 960px; max-width: 1300px; @@ -2461,9 +3053,15 @@ table tbody tr:nth-child(odd):hover th { left: 20%; top: 0; bottom: 0; - width: 1px; + width: 6px; + margin-left: -7px; content: ''; - box-shadow: -2px 0 7px #777; + background: -moz-linear-gradient(left, rgba(0,0,0,0) 0%, rgba(0,0,0,0.06) 100%); /* FF3.6+ */ + background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(0,0,0,0)), color-stop(100%,rgba(0,0,0,0.06))); /* Chrome,Safari4+ */ + background: -webkit-linear-gradient(left, rgba(0,0,0,0) 0%,rgba(0,0,0,0.06) 100%); /* Chrome10+,Safari5.1+ */ + background: -o-linear-gradient(left, rgba(0,0,0,0) 0%,rgba(0,0,0,0.06) 100%); /* Opera 11.10+ */ + background: -ms-linear-gradient(left, rgba(0,0,0,0) 0%,rgba(0,0,0,0.06) 100%); /* IE10+ */ + background: linear-gradient(to right, rgba(0,0,0,0) 0%,rgba(0,0,0,0.06) 100%); /* W3C */ z-index: 2; } @@ -2473,7 +3071,7 @@ table tbody tr:nth-child(odd):hover th { } .adminhtml-dashboard-index .main-col { - width: 58%; + width: 60%; } /* Sidebar and main column vertical separator */ @@ -2483,7 +3081,7 @@ table tbody tr:nth-child(odd):hover th { top: 0; bottom: 0; width: 1px; - background: #d2ccc2; + background: #ded9d3; content: ''; } @@ -2506,15 +3104,22 @@ table tbody tr:nth-child(odd):hover th { /* Sidebar title and store view switcher*/ /* TODO: temporary styles */ .side-col h3, -.side-col > .switcher { +.side-col > .store-switcher { padding: 0 17px; + margin-top: 16px; +} + +.side-col .ui-tabs h3 { + margin-bottom: 5px; + color: #524c44; + text-shadow: 0 1px 0 #fff; } -.side-col > .switcher { - padding-top: 20px; +.side-col > .store-switcher { + padding-top: 6px; } -.side-col > .switcher > a { +.side-col > .store-switcher > a { white-space: nowrap; } @@ -2522,6 +3127,38 @@ table tbody tr:nth-child(odd):hover th { Universal Sidebar Tabs -------------------------------------- */ /* TODO: for "Product" page only while refactoring */ + +.side-col .ui-tabs .ui-accordion-header { + position: relative; + margin: 10px 0 0; + padding: 5px 20px; + cursor: pointer; + color: #524c44; + text-shadow: 0 1px 0 #fff; +} + +.side-col .ui-accordion-header:before { + position: absolute; + left: 4px; + top: 7px; + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: '\e02a'; /* arrow right icon */ + font-size: 14px; + color: #ada79e; +} + +.side-col .ui-accordion-header:hover:before { + color: #777; +} + +.side-col .ui-accordion-header-active:before { + content: '\e02c'; /* arrow down icon */ +} + .side-col .tabs { margin: 0 0 30px; padding: 0; @@ -2530,10 +3167,18 @@ table tbody tr:nth-child(odd):hover th { font-weight: 500; } +.side-col > .ui-tabs > .tabs:first-child > li:first-child > a { + border-top-left-radius: 5px; +} + .side-col .tabs > li { border-bottom: 1px solid #e5e1db; } +.side-col .tabs > li:first-child { + border-top: 1px solid #e5e1db; +} + .side-col .tabs > li a { position: relative; display: block; @@ -2561,7 +3206,8 @@ table tbody tr:nth-child(odd):hover th { box-shadow: 0 1px 2px #ccc inset; } -.side-col .tabs > .ui-state-active a:after { +.side-col .tabs > .ui-state-active a:after, +.side-col .tabs > .ui-state-active a:before { position: absolute; top: 50%; right: 0; @@ -2574,12 +3220,55 @@ table tbody tr:nth-child(odd):hover th { -webkit-font-smoothing: antialiased; content: '\e02b'; /* left turned triangle icon */ font-size: 22px; - text-shadow: -1px 1px 0 #bdbbb7; color: #f5f2ed; overflow: hidden; + z-index: 4; +} + +.side-col .tabs > .ui-state-active a:before { + color: #bdbbb7; + margin-top: -13px; z-index: 3; } +.side-col .tabs span.error, +.side-col .tabs span.loader { + display: none; + position: absolute; + right: 12px; + top: 7px; + width: 16px; + height: 16px; + font-size: 16px; +} + +.side-col .tab-item-link.changed { + font-style: italic; +} + +.side-col .tab-item-link.error span.error, +.side-col .ui-tabs-loading span.loader { + display: block; +} + +.side-col .tab-item-link.error span.error:after { + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: '\e006'; /* warning icon */ + color: #d87e34; +} + +.side-col .ui-tabs-loading span.loader:after { + background: url(../mui/images/ajax-loader-small.gif) no-repeat 50% 50%; + display: block; + content: ''; + width: 16px; + height: 16px; +} + /* TODO: styles for navigation on System > Configuration page */ /* @@ -2623,15 +3312,6 @@ table tbody tr:nth-child(odd):hover th { box-shadow: 1px 0 3px #aaa; } -/* Tabs Loading Spinner */ -.side-col .tabs .loading, -.tabs-horiz .loading { - display: none; - position: absolute; - left: 50%; - margin-top: 9px; -} - /* System -> Configuration page navigation in sidebar -------------------------------------- */ @@ -2739,10 +3419,17 @@ table tbody tr:nth-child(odd):hover th { -moz-user-select: none; -ms-user-select: none; user-select: none; + cursor: pointer; + display: inline-block; + overflow: hidden; } -.switcher strong { - vertical-align: top; +.switcher input[type="checkbox"] { + position: absolute; + left: -999em; +} + +.switcher-label { font-family: "CallunaSans", Arial, sans-serif; font-size: 12px; font-weight: 600; @@ -2751,31 +3438,45 @@ table tbody tr:nth-child(odd):hover th { text-transform: uppercase; } -.switcher input[type="checkbox"] { - width: 1px; - height: 1px; - opacity: 0; - margin: 0; -} - -.switcher input:focus + span { - outline: 1px dotted grey; +.switcher-label:before { + content: attr(data-text-off); } -.switcher span { +.switcher-label:after { display: inline-block; + margin-left: 10px; + vertical-align: bottom; width: 34px; height: 17px; - background: url(Mage_Backend::images/switcher.png) no-repeat; + background: url(../images/switcher.png) no-repeat; + content: ''; +} + +.switcher input[type="checkbox"]:focus + .switcher-label:after { + border-color: #75b9f0; } -.switcher input:checked + span { +.switcher input[type="checkbox"]:checked + .switcher-label:after { background-position: -34px 0; } -/* TODO: IE8 fix for :checked attr */ -.eq-ie8 .switcher input.checked + span { +.switcher input[type="checkbox"]:checked + .switcher-label:before { + content: attr(data-text-on); +} + +.eq-ie8 .switcher-label:after { + content: 'off'; + overflow: hidden; + white-space: nowrap; + text-indent: 100%; +} +.eq-ie8 .switcher.checked .switcher-label:after { background-position: -34px 0; + content: 'on'; +} + +.eq-ie8 .switcher.checked .switcher-label:before { + content: attr(data-text-on); } /* @@ -2797,6 +3498,14 @@ table tbody tr:nth-child(odd):hover th { margin: 6px 10px 0 0; } +.page-actions .store-switcher { + float: left; +} + +.adminhtml-catalog-product-index .page-actions { + padding-top: 0; +} + /* TODO: refactor trees */ .x-tree ul { margin: 0; @@ -2804,7 +3513,7 @@ table tbody tr:nth-child(odd):hover th { } .page-actions.fixed { - padding: 0 1px; + padding: 0 21px; position: fixed; top: 0; left: 0; @@ -2813,19 +3522,21 @@ table tbody tr:nth-child(odd):hover th { } .page-actions.fixed .page-actions-inner { - background: #f7f2ec; - background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIxJSIgc3RvcC1jb2xvcj0iI2Y3ZjJlYyIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjYwJSIgc3RvcC1jb2xvcj0iI2ZjZmFmNyIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNmZmZmZmYiIHN0b3Atb3BhY2l0eT0iMCIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+); - background: -moz-linear-gradient(top, rgba(247, 242, 236, 1) 1%, rgba(252, 250, 247, 1) 70%, rgba(255, 255, 255, 0) 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(1%, rgba(247, 242, 236, 1)), color-stop(70%, rgba(252, 250, 247, 1)), color-stop(100%, rgba(255, 255, 255, 0))); - background: -webkit-linear-gradient(top, rgba(247, 242, 236, 1) 1%, rgba(252, 250, 247, 1) 70%, rgba(255, 255, 255, 0) 100%); - background: -o-linear-gradient(top, rgba(247, 242, 236, 1) 1%, rgba(252, 250, 247, 1) 70%, rgba(255, 255, 255, 0) 100%); - background: -ms-linear-gradient(top, rgba(247, 242, 236, 1) 1%, rgba(252, 250, 247, 1) 70%, rgba(255, 255, 255, 0) 100%); - background: linear-gradient(to bottom, rgba(247, 242, 236, 1) 1%, rgba(252, 250, 247, 1) 70%, rgba(255, 255, 255, 0) 100%); + background: -moz-linear-gradient(top, rgba(245,242,237,1) 0%, rgba(245,242,237,1) 56%, rgba(245,242,237,0) 100%); /* FF3.6+ */ + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(245,242,237,1)), color-stop(56%,rgba(245,242,237,1)), color-stop(100%,rgba(245,242,237,0))); /* Chrome,Safari4+ */ + background: -webkit-linear-gradient(top, rgba(245,242,237,1) 0%,rgba(245,242,237,1) 56%,rgba(245,242,237,0) 100%); /* Chrome10+,Safari5.1+ */ + background: -o-linear-gradient(top, rgba(245,242,237,1) 0%,rgba(245,242,237,1) 56%,rgba(245,242,237,0) 100%); /* Opera 11.10+ */ + background: -ms-linear-gradient(top, rgba(245,242,237,1) 0%,rgba(245,242,237,1) 56%,rgba(245,242,237,0) 100%); /* IE10+ */ + background: linear-gradient(to bottom, rgba(245,242,237,1) 0%,rgba(245,242,237,1) 56%,rgba(245,242,237,0) 100%); /* W3C */ padding: 11px 20px 11px; min-height: 36px; margin: 0 auto; min-width: 916px; - max-width: 1258px; + max-width: 1259px; +} + +.lt-ie9 .page-actions.fixed .page-actions-inner { + background: #f5f2ed; } .page-actions.fixed .page-actions-inner:before { @@ -2834,6 +3545,9 @@ table tbody tr:nth-child(odd):hover th { font-family: 'CallunaSans'; font-size: 20px; max-width: 50%; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } /* @@ -2841,6 +3555,10 @@ table tbody tr:nth-child(odd):hover th { -------------------------------------- */ /* Grid - General */ +.grid-container { + margin-bottom: 10px; +} + .grid { border-bottom: 0; font-size: 13px; @@ -2884,6 +3602,7 @@ table tbody tr:nth-child(odd):hover th { .grid th, .grid td { padding: 2px 4px 2px 4px; + vertical-align: top; } .grid th { @@ -2904,15 +3623,9 @@ table tbody tr:nth-child(odd):hover th { } .grid table td { - font-size: 14px; border: solid #c0bbaf; - border-width: 0 1px 1px 0; - padding: 10px 10px 5px; -} - -.grid table td:first-child, -.grid table td:last-child { border-width: 0 1px 1px; + padding: 5px; } .grid table.border td { @@ -2961,11 +3674,6 @@ table tbody tr:nth-child(odd):hover th { border-bottom: 1px solid #dadfe0; } -[id$='Grid'] { - font-family: 'CallunaSans'; - font-weight: 400; -} - /* Grid - Pager and Buttons row -------------------------------------- */ @@ -2980,8 +3688,8 @@ table tbody tr:nth-child(odd):hover th { background: -o-linear-gradient(top, rgba(246, 243, 236, 1) 0%, rgba(237, 234, 225, 1) 100%); background: -ms-linear-gradient(top, rgba(246, 243, 236, 1) 0%, rgba(237, 234, 225, 1) 100%); background: linear-gradient(to bottom, rgba(246, 243, 236, 1) 0%, rgba(237, 234, 225, 1) 100%); - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#f6f3ec', endColorstr = '#edeae1', GradientType = 0); - padding: 10px 10px 5px; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f6f3ec', endColorstr='#edeae1', GradientType=0); + padding: 7px 8px 8px; position: relative; } @@ -3066,6 +3774,11 @@ table tbody tr:nth-child(odd):hover th { width: 22px; } +.grid-actions .pager img { + width: auto; + height: auto; +} + /* TODO: refactor validation fields styles after approved design comes */ .grid-actions .validation-advice { background: #f3dcd8; @@ -3092,11 +3805,17 @@ table tbody tr:nth-child(odd):hover th { margin-left: -3px; } -/* Grid - Headings */ +.grid-actions .link-feed { + white-space: nowrap; +} + +/* + Grid - Headings +-------------------------------------- */ .grid tr.headings th { font-size: 13px; border-right: 1px solid #837f79; - padding: 0 1px; + padding: 0; vertical-align: bottom; } @@ -3106,15 +3825,18 @@ table tbody tr:nth-child(odd):hover th { .grid tr.headings th > span { display: block; - border-bottom: 5px solid transparent; - padding: 5px 10px; + font-weight: 500; + border-bottom: 2px solid transparent; + padding: 5px 5px 2px; + white-space: nowrap; } .grid tr.headings th:hover > span { border-color: #504841; } -.grid tr.headings th.no-link:hover > span { +.grid tr.headings th.no-link:hover > span, +.grid tr.headings th.col-select:hover > span { border-color: transparent; } @@ -3174,27 +3896,68 @@ table tbody tr:nth-child(odd):hover th { } .grid .filter th { - padding: 10px 8px 5px; + padding: 5px; border-right: 1px solid #837F79; vertical-align: top; white-space: normal; } .grid .filter input.input-text { - padding: 2px; - height: 24px; + background: #5e5a52; + border-radius: 2px; + border: none; + color: #bcb795; + padding: 0 5px; + height: 20px; width: 99%; } +.grid .filter input.input-text::-webkit-input-placeholder { + color: #858376 !important; + text-transform: lowercase; +} + +.grid .filter input.input-text:-moz-placeholder { + color: #858376 !important; + text-transform: lowercase; +} + +.grid .filter input.input-text::-moz-placeholder { + color: #858376 !important; + text-transform: lowercase; +} + +:-ms-input-placeholder { + color: #858376 !important; + text-transform: lowercase; +} + .grid .filter select { - padding: 2px; + background: #5e5a52; + border-radius: 2px; + border: none; + color: #bcb795; + margin: 0; + padding: 0; + height: 20px; width: 99%; } +.grid td select { + font-family: Arial, Helvetica, sans-serif; + font-size: 13px; + padding: 4px 4px 5px; + text-align: left; +} + +.grid .action-select { + background: #fff; + border: 1px solid #ccc; + margin: 0; +} + .grid .filter .range .range-line { margin-bottom: 3px; - overflow: hidden; - width: 100px; } .grid .filter .range div.date { @@ -3202,22 +3965,16 @@ table tbody tr:nth-child(odd):hover th { } .grid .filter .range input { - float: right; - width: 56px; margin-top: 0; + vertical-align: middle; } .grid .filter .range select { - float: right; - width: 56px; - margin-top: 0; + margin: 0; } -.grid .filter .range .label { - display: block; - width: 36px; - float: left; - padding-left: 2px; +.grid .filter .date { + position: relative; } .grid .filter .date img { @@ -3225,6 +3982,34 @@ table tbody tr:nth-child(odd):hover th { height: 15px; cursor: pointer; vertical-align: middle; + margin-left: 5px; + position: relative; + z-index: 2; + opacity: 0; +} + +.eq-ie8 .grid .filter .date img { + filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0); +} + +.grid .filter .date:before { + position: absolute; + left: 61px; + top: 2px; + margin-top: 0; + text-shadow: none; + width: 16px; + height: 16px; + line-height: 16px; + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + font-size: 16px; + content: '\e06a'; /* icon calendar */ + color: #cac3b4; + z-index: 1; } .grid .head-massaction select { @@ -3233,30 +4018,35 @@ table tbody tr:nth-child(odd):hover th { /* Grid - Mass Action */ .massaction { - color: #CAC3B4; - padding: 12px 10px; + color: #cac3b4; + padding: 7px 8px; background: #666158; - box-shadow: 0 2px 3px 0 #504d46 inset, 0 -2px 3px 0 #504d46 inset; + box-shadow: 0 1px 2px 0 #504d46 inset, 0 -1px 2px 0 #504d46 inset; overflow: hidden; } +.eq-ie8 .massaction { + border-bottom: 2px solid #504d46; +} + .massaction ul { list-style: none; margin: 0; - padding: 4px 0 0; + padding: 6px 0 0; } .massaction li { display: inline-block; } -.massaction li:after { +.massaction li:before { + color: #837F79; content: '|'; display: inline-block; margin: 0 5px; } -.massaction li:last-child:after { +.massaction li:first-child:before { display: none; } @@ -3273,7 +4063,10 @@ table tbody tr:nth-child(odd):hover th { } .massaction .entry-edit fieldset select { + border-radius: 2px; + padding: 3px; margin: 0; + vertical-align: middle; } .massaction .entry-edit fieldset select.validation-failed { @@ -3281,12 +4074,23 @@ table tbody tr:nth-child(odd):hover th { background: #faebe7; } -.massaction .entry-edit .field-row, -.massaction .entry-edit .outer-span { +.massaction .entry-edit .field-row { display: inline-block; vertical-align: middle; } +.eq-ie8 .massaction .entry-edit .field-row:first-child { + margin-right: 1px; +} + +.eq-ie8 .massaction .entry-edit .field-row { + display: inline; +} + +.massaction .entry-edit .field-row button { + padding: 3px 10px; +} + .massaction .entry-edit .outer-span .entry-edit { float: none; } @@ -3295,7 +4099,10 @@ table tbody tr:nth-child(odd):hover th { color: #cac3b4; line-height: 26px; margin: 0 5px 0 20px; - vertical-align: top; + padding: 0; + vertical-align: middle; + width: auto; + float: none; } .massaction .entry-edit .validation-advice { @@ -3307,6 +4114,10 @@ table tbody tr:nth-child(odd):hover th { text-decoration: none; } +.massaction a:hover { + color: #fff; +} + /* Grid Footer */ .grid table tfoot tr { background: #656156; @@ -3325,7 +4136,12 @@ table tbody tr:nth-child(odd):hover th { } .grid table.border tfoot tr td { - background: #d7e5ef; + background: #656156; +} + +.grid .col-price, +.grid .col-number { + text-align: right; } /* Dynamic Grid */ @@ -3367,10 +4183,66 @@ tr.dynamic-grid input.input-text { } /* - Table columns styles + TODO: change ids to 'table.data' after refactoring of all templates for grids + Manage Products Grid -------------------------------------- */ -.col-no-records { - text-align: center; +#cross_sell_product_grid table.data, +#up_sell_product_grid table.data, +#related_product_grid table.data, +#productGrid_table, +.ui-dialog .data { + word-wrap: break-word; + table-layout: fixed; +} + +table .col-draggable { + width: 1%; +} + +table .col-default, +table .col-select, +table .col-qty, +table .col-actions, +table .col-id { + width: 5%; +} + +table .col-visibility, +table .col-status, +table .col-websites, +table .col-position { + width: 7%; +} + +table .col-type, +table .col-price { + width: 8%; +} + +table .col-name, +table .col-sku { + width: 15%; +} + +table .col-attr-name { + width: 120px; +} + +table .col-draggable .draggable-handle { + position: relative; + top: 0; + float: left; +} + +.grid table .col-id, +.grid table thead th.col-price, +.grid table thead th.col-qty, +.grid table thead th.col-number { + text-align: left; +} + +.ui-dialog .selection-search table .col-select { + width: 25px; } /* @@ -3395,7 +4267,6 @@ tr.dynamic-grid input.input-text { } .data-table td, -.data-table tbody tr:not(:last-child) td, .data-table tbody tr td { background: #fff; padding: 5px 7px; @@ -3405,12 +4276,15 @@ tr.dynamic-grid input.input-text { border-width: 0 0 1px; } +.eq-ie8 .data-table td, +.eq-ie8 .data-table tbody tr td { + border-width: 0 0 1px; +} + .data-table tbody tr.selected td, .data-table tbody tr.selected th, .data-table tbody tr:hover td, -.data-table tbody tr:hover th, -.data-table tbody tr:nth-child(odd) th, -.data-table tbody tr:nth-child(odd):hover th { +.data-table tbody tr:hover th { background: #fff; } @@ -3419,10 +4293,18 @@ tr.dynamic-grid input.input-text { background: #fbfaf6; } +.data-table tbody tr.odd td { + background: #fbfaf6; +} + .data-table tfoot tr:last-child td { border: 0; } +.eq-ie8 .data-table tfoot tr td { + border: none; +} + .data-table input[type="text"] { width: 98%; padding-left: 1%; @@ -3491,31 +4373,122 @@ tr.dynamic-grid input.input-text { .data-table .actions-split.active .dropdown-menu { border-top-right-radius: 0; } + +/* + Data table - alternative view +-------------------------------------- */ +.invitation_information .data-table, +.invitee_information .data-table, +.inviter_information .data-table, +.customer-information .data-table, +.order-information .data-table, +.order-account-information .data-table, +.adminhtml-rma-new .data-table { + width: 100%; +} + +.invitation_information .data-table tbody tr th, +.invitee_information .data-table tbody tr th, +.inviter_information .data-table tbody tr th, +.customer-information .data-table tbody tr th, +.order-information .data-table tbody tr th, +.order-account-information .data-table tbody tr th, +.adminhtml-rma-new .data-table tbody tr th, +[class^=" adminhtml-sales-transactions-"] .data-table tbody tr th, +[class^=" adminhtml-sales-"] .order-payment-method .data-table tbody tr th, +[class^=" adminhtml-sales-billing-agreement-"] .log-details .data-table tbody tr th{ + font-weight: bold; +} + +.invitation_information .data-table tbody tr td, +.invitation_information .data-table tbody tr th, +.invitee_information .data-table tbody tr td, +.invitee_information .data-table tbody tr th, +.inviter_information .data-table tbody tr td, +.inviter_information .data-table tbody tr th, +.customer-information .data-table tbody tr td, +.customer-information .data-table tbody tr th, +.order-information .data-table tbody tr td, +.order-information .data-table tbody tr th, +.order-account-information .data-table tbody tr td, +.order-account-information .data-table tbody tr th, +[class^=" adminhtml-rma-"] .data-table tbody tr td, +[class^=" adminhtml-rma-"] .data-table tbody tr th, +[class^=" adminhtml-sales-transactions-"] .data-table tbody tr th, +[class^=" adminhtml-sales-transactions-"] .data-table tbody tr td, +[class^=" adminhtml-sales-"] .order-payment-method .data-table tbody tr th, +[class^=" adminhtml-sales-"] .order-payment-method .data-table tbody tr td, +[class^=" adminhtml-sales-billing-agreement-"] .log-details .data-table tbody tr th, +[class^=" adminhtml-sales-billing-agreement-"] .log-details .data-table tbody tr td { + background-color: #fff; + border: 0; + padding: 9px 10px 10px; + color: #666; + vertical-align: top; +} + +.invitation_information .data-table tbody tr:nth-child(2n+1) td, +.invitation_information .data-table tbody tr:nth-child(2n+1) th, +.invitee_information .data-table tbody tr:nth-child(2n+1) td, +.invitee_information .data-table tbody tr:nth-child(2n+1) th, +.inviter_information .data-table tbody tr:nth-child(2n+1) td, +.inviter_information .data-table tbody tr:nth-child(2n+1) th, +.customer-information .data-table tbody tr:nth-child(2n+1) td, +.customer-information .data-table tbody tr:nth-child(2n+1) th, +.order-information .data-table tbody tr:nth-child(2n+1) td, +.order-information .data-table tbody tr:nth-child(2n+1) th, +.order-account-information .data-table tbody tr:nth-child(2n+1) td, +.order-account-information .data-table tbody tr:nth-child(2n+1) th, +[class^=" adminhtml-rma-"] .data-table tbody tr:nth-child(2n+1) td, +[class^=" adminhtml-rma-"] .data-table tbody tr:nth-child(2n+1) th, +[class^=" adminhtml-sales-transactions-"] .data-table tbody tr:nth-child(2n+1) th, +[class^=" adminhtml-sales-transactions-"] .data-table tbody tr:nth-child(2n+1) td, +[class^=" adminhtml-sales-"] .order-payment-method .data-table tbody tr:nth-child(2n+1) th, +[class^=" adminhtml-sales-"] .order-payment-method .data-table tbody tr:nth-child(2n+1) td, +[class^=" adminhtml-sales-billing-agreement-"] .log-details .data-table tbody tr:nth-child(2n+1) th, +[class^=" adminhtml-sales-billing-agreement-"] .log-details .data-table tbody tr:nth-child(2n+1) td { + background-color: #fbfaf6; +} + /* Content alignments in tables -------------------------------------- */ /* left */ +.col-website, .col-name, .col-sku, .col-color, -.col-size { +.col-size, +.col-product, +.col-comment { text-align: left; } /* center */ .col-include, +.col-price, .col-display, .col-image, .col-price, -.col-change-price { +.col-change-price +.col-no-records, +.col-select, +.col-change-price, +.col-default, +.col-uqty { text-align: center; } /* right */ .col-qty, .col-weight, -.col-actions { +.col-actions, +.col-price, +.col-price > input, +.col-id, +.col-total, +.col-average { text-align: right; } @@ -3624,6 +4597,31 @@ tr.dynamic-grid input.input-text { content: "\2605\0000a0"; } +/* + Tree Store Scope +-------------------------------------- */ +.tree-store-scope .buttons-set { + margin-bottom: 9px; +} + +.tree-store-scope .buttons-set button { + margin-right: 4px; +} + +.tree-store-scope .field { + margin: 0 0 5px; +} + +.tree-store-scope .field .label { + padding-top: 0; +} + +.tree-store-scope .field input[type="checkbox"] { + margin-right: 3px; + position: relative; + top: 2px; +} + /* Widgets -------------------------------------- */ @@ -3670,11 +4668,12 @@ tr.dynamic-grid input.input-text { } .widget-layout-updates .chooser_container { - padding: 0 10px 18px; + padding: 0 10px; + margin-bottom: 18px; } .widget-layout-updates .chooser_container p { - margin: 0; + margin: 0 0 18px; } .widget-layout-updates .chooser_container p img, @@ -3682,6 +4681,46 @@ tr.dynamic-grid input.input-text { vertical-align: middle; } +/* + Preview window +-------------------------------------- */ +.preview-window { + background: #fff; +} + +.preview-window .toolbar { + background: #f5f2ed; + padding: 20px; +} + +.preview-window .toolbar .switcher { + margin: 0; +} + +.preview-window .toolbar .switcher span { + background: none; + width: auto; +} + +/* + Global 'No Products found' block +-------------------------------------- */ +.no-products-message { + background: #fbfaf6; + padding: 12px; + text-align: center; + font-size: 12px; + color: #666; + margin-bottom: 13px; +} + +/* + WYSIWYG +-------------------------------------- */ +.action-wysiwyg { + margin: 10px 0; +} + /* Clearfix -------------------------------------- */ @@ -3731,3 +4770,4 @@ tr.dynamic-grid input.input-text { .grid-actions:after, .fieldset-wrapper-title:after { clear: both; +} diff --git a/app/design/adminhtml/default/backend/css/debug.css b/app/design/adminhtml/default/backend/css/debug.css index ce33734e796d2..3278cbc600dde 100644 --- a/app/design/adminhtml/default/backend/css/debug.css +++ b/app/design/adminhtml/default/backend/css/debug.css @@ -60,11 +60,8 @@ ul.messages > li { } ul.messages li li { - padding: 10px 26px 10px 32px; - border: 0; - -moz-border-radius: 0; - -webkit-border-radius: 0; - border-radius: 0; + padding: 10px 26px 10px 35px; + border-radius: 5px; color: #676056; text-shadow: none; position: relative; @@ -79,7 +76,7 @@ ul.messages li li:first-child { ul.messages li li:before { position: absolute; - left: 8px; + left: 11px; top: 50%; margin-top: -11px; background: none; @@ -109,8 +106,8 @@ ul.messages li.error-msg li:before { } ul.messages li.success-msg li { - border-color: #185b00; - background: #e6ecc0; + border-color: #ceceb6; + background: #e4eecb; color: #185b00; } @@ -119,83 +116,91 @@ ul.messages li.success-msg li:before { color: #185b00; } -label.mage-error { - color: red; -} - /* Accordion ------------------------*/ .accordion { - background: #fff; - border: 1px solid #eae6e0; - border-radius: 5px; margin: 0 0 8px; padding: 0; } .accordion > dt, -.accordion .collapseable { +.accordion > dd.open, +.accordion .collapseable, +.accordion .collapseable.open + input + fieldset { + background: #fff; + border: 1px solid #eae6e0; + border-radius: 5px; + margin: 0 0 8px; + padding: 5px 18px 2px; position: relative; - margin: 0 10px; +} + +.accordion > dt + dd { + display: none; +} + +.accordion > dt.open, +.accordion .collapseable.open { + margin: 0; + border-bottom: 0; + border-radius: 5px 5px 0 0; +} + +.accordion > dt + dd.open, +.accordion .collapseable.open + input + fieldset { + padding: 25px 18px 18px; + display: block; + border-top: 0; + border-radius: 0 0 5px 5px; } .accordion > dt a, .accordion .collapseable > a { color: #666; display: block; - padding: 15px 17px 10px 10px; + padding: 7px 0 10px 22px; font-family: 'CallunaSans', Arial, sans-serif; font-size: 18px; text-decoration: none; - margin: 0 8px; + position: relative; + cursor: pointer; } -.accordion .collapseable a.open { - border-bottom: 1px solid #eee; +.accordion .collapseable.open a, +.accordion dt.open a { + border-bottom: 1px solid #ededed; } .accordion > dt a:before, .accordion .collapseable > a:before { - float: right; - content: "\e02c"; - color: #b2aa9d; - display: inline-block; + position: absolute; + left: 0; + top: 7px; font-family: 'MUI-Icons'; font-style: normal; speak: none; font-weight: normal; -webkit-font-smoothing: antialiased; + content: '\e02a'; /* arrow right icon */ + color: #b2b0ad; } .accordion > dt.open a:before, -.accordion .collapseable a.open:before { - content: "\e029"; +.accordion .collapseable.open a:before { + content: '\e02c'; /* arrow down icon */ +} +.accordion > dt a:hover:before, +.accordion .collapseable > a:hover:before { + color: #7e7e7e; } .accordion > dt + dd { display: none; } -.accordion > dt + .open { - display: block; - border-top: 1px solid #EDEDED; - margin: 0 10px; - padding: 17px 8px; -} - -.accordion > dd + dt, -.accordion .collapseable { - border-top: 1px solid #eee; -} - -.accordion > .open + dt, -.accordion .collapseable:first-child { - border: none; -} - .accordion > dt + .open:empty { - background: url(../mui/images/ajax-loader-big.gif) no-repeat center; + background: #fff url(../mui/images/ajax-loader-big.gif) no-repeat center; height: 100px; } @@ -209,14 +214,11 @@ label.mage-error { /* TODO: arrange configuration tables */ .accordion .collapseable.disabled { - margin: 0; - border-color: #fff; + background: #f1f1f1; } .accordion .collapseable.disabled > a { - background: #f1f1f1; cursor: not-allowed; - padding: 14px 27px; } .accordion .collapseable.disabled > a:before { @@ -238,6 +240,7 @@ label.mage-error { .accordion .config .label { float: none; width: 25%; + text-align: right; } .accordion .config td { @@ -245,7 +248,6 @@ label.mage-error { border: 0; padding: 8px 15px 0 0; vertical-align: top; - text-align: left; } .accordion .paypal-selection-simplified { @@ -338,13 +340,15 @@ label.mage-error { } /* TODO: styles for required TH fields */ -th.required:before { +th.required:after { color: red; content: "*"; + margin-left: 5px; } /* TODO: set color for messages in Cache Storage Management */ .grid-severity-critical, +.grid-severity-major, .grid-severity-notice, .grid-severity-minor { display: block; @@ -354,6 +358,12 @@ th.required:before { } .grid-severity-critical { + border-color: #6e1313; + background: #f7bfbf; + color: #6e1313; +} + +.grid-severity-major { border-color: #963535; background: #f3dcd8; color: #963535; @@ -365,15 +375,6 @@ th.required:before { color: #185b00; } -/* TODO: Store views tree */ -.tree-store-scope .field { - margin: 0; -} - -.tree-store-scope .field .label { - padding-top: 0; -} - /* Sales -------------------------------------- */ @@ -444,31 +445,31 @@ th.required:before { position: relative; z-index: 1; padding: 0; + border: 0; text-align: center; } .adminhtml-sales-order-index .page-actions .add > span { text-indent: -999em; display: block; - padding: 0; + width: 36px; + height: 36px; } .adminhtml-sales-order-index .page-actions .add > span:before { - display: block; text-indent: 0; content: '+'; font-weight: normal; - font-size: 36px; + font-size: 38px; color: #fff; position: absolute; - line-height: 36px; + line-height: 28px; height: 36px; width: 36px; overflow: hidden; text-align: center; - top: -4px; - left: -1px; - vertical-align: top; + top: 0; + left: 0; } .adminhtml-sales-order-index .grid-actions { @@ -483,6 +484,8 @@ th.required:before { background: transparent; border: 0; border-radius: 0; + max-width: 1300px; + min-width: 960px; } .sidebar-actions { @@ -493,6 +496,10 @@ th.required:before { margin: 0 0 5px; } +.adminhtml-sales-order-create-index .grid table .action-configure { + float: right; +} + /* Product -------------------------------------- */ @@ -615,3 +622,10 @@ th.required:before { background: url(../mui/images/ajax-loader-small.gif) no-repeat left center; padding-left: 20px; } + +/* + URL Rewrite +-------------------------------------- */ +.field-url-rewrite-option-select { + padding-top: 13px; +} diff --git a/app/design/adminhtml/default/backend/css/header.css b/app/design/adminhtml/default/backend/css/header.css index 0a3173f2f694b..aed02e24e0ee5 100644 --- a/app/design/adminhtml/default/backend/css/header.css +++ b/app/design/adminhtml/default/backend/css/header.css @@ -46,7 +46,7 @@ min-width: 960px; max-width: 1300px; margin: 0 auto; - padding: 6px 0 7px; + padding: 7px 0; } .header .logo { @@ -130,6 +130,7 @@ border-bottom: 1px solid #f7e4d0; color: #8C867E; font: 11px/13px Arial, Helvetica, sans-serif; + white-space: normal; } .header-panel .dropdown-menu > li:first-child:before, diff --git a/app/design/adminhtml/default/backend/css/pages.css b/app/design/adminhtml/default/backend/css/pages.css index dde4fc07561a9..8c77e43f954c4 100644 --- a/app/design/adminhtml/default/backend/css/pages.css +++ b/app/design/adminhtml/default/backend/css/pages.css @@ -22,6 +22,7 @@ */ /* +<<<<<<< HEAD Sales -------------------------------------- */ @@ -68,389 +69,35 @@ margin-top: 20px; } -/* - Product Creation --------------------------------------- */ - -/* Action "Back" as cross */ -[class^=" adminhtml-catalog-product-"] .page-actions .action-back, -[class^=" adminhtml-catalog-product-"] .page-actions .action-back:hover, -[class^=" adminhtml-catalog-product-"] .page-actions .action-back:active { - overflow: hidden; - padding: 5px 6px 3px; - margin-left: 12px; - color: #7a7976;; -} - -[class^=" adminhtml-catalog-product-"] .page-actions .action-back:hover { - color: #000; -} - -[class^=" adminhtml-catalog-product-"] .page-actions .action-back.mage-error { - color: #b57c72; -} - -[class^=" adminhtml-catalog-product-"] .page-actions .action-back:before { - display: inline-block; - font-family: 'MUI-Icons'; - font-style: normal; - speak: none; - font-weight: normal; - -webkit-font-smoothing: antialiased; - content: '\e07d'; /* close icon */ - font-size: 16px; -} - -[class^=" adminhtml-catalog-product-"] .page-actions .action-back span { - display: inline-block; - overflow: hidden; - text-indent: -999em; -} - -.page-actions .switcher { - display: inline-block; - vertical-align: top; - margin: 6px 6px; -} - -.page-actions .action-.delete { - margin-top: 2px; -} - -/* Image Management */ -.images { - position: relative; - border: 2px dotted #CCC; - border-radius: 5px; - padding: 5px; -} - -.image { - position: relative; - width: 120px; - height: 120px; - border: 1px solid #ccc; - border-radius: 4px; - float: left; - margin: 0 10px 10px 0; - overflow: hidden; - background: #fff; -} - -.image > img { - width: 120px; - height: 120px; -} - -.image.base-image:before { - position: absolute; - top: 5px; - left: 0; - right: 0; - padding: 5px 0; - background: #d56d27; - text-align: center; - text-transform: uppercase; - text-shadow: 0 1px 2px #000; - font-size: 9px; - font-weight: bold; - color: #fff; - content: attr(data-image-label); - letter-spacing: 1px; - -moz-transform: rotate(-45deg) translate3d(0, 0, 0); - -webkit-transform: rotate(-45deg) translate3d(0, 0, 0); - transform: rotate(-45deg) translate3d(0, 0, 0); - margin-left: -90px; -} - -.image[data-image-hidden]:after { - position: absolute; - left: 0; - right: 0; - top: 0; - bottom: 0; - background: rgba(247, 242, 236, .8); - content: attr(data-image-hidden); - text-align: center; - text-transform: uppercase; - color: #a69a8f; - font: 18px/120px 'CallunaSans', Arial, sans-serif; - font-weight: 500; - z-index: 1; -} - -.image .actions { - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - padding-top: 70px; - text-align: center; - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} - -.image .actions [class^="action-"], -.image[data-image-hidden]:hover .actions [class^="action-"] { - visibility: hidden; -} - -.image:hover .actions [class^="action-"], -.image[data-image-hidden]:hover .actions .action-delete { - visibility: visible; -} - -.image .action-delete { - position: absolute; - top: 2px; - right: 2px; - z-index: 2; -} - -.image .action-make-main { - margin-bottom: 10px; -} - -.draggable-handle { - position: relative; - display: block; - width: 14px; - height: 8px; - cursor: move; - margin: 0 auto; - background: url(Mage_Backend::images/draggable-handle-bg.gif) no-repeat; - z-index: 2; -} - -.image-placeholder { - background: #fff url('Mage_Adminhtml::images/image-placeholder.png') no-repeat 50% 0%; -} - -.image-placeholder input[type="file"] { - position: absolute; - opacity: 0; - border: 100px solid; -} - -.image-placeholder-text { - padding: 72px 5px 0; - font-size: 11px; - font-weight: bold; - line-height: 1.333; - text-align: center; - color: #cac8c4; -} - -/* action in fieldset wrapper */ -.fieldset-wrapper-title .action-add, -.fieldset-wrapper-title .action-add:hover, -.fieldset-wrapper-title .action-add:focus, -.fieldset-wrapper-title .action-add:active, -.fieldset-wrapper-title .action-add:hover { - font-size: 12px; - color: #a29c94; - text-decoration: underline; - margin: 8px 20px 0 0; -} - -.fieldset-wrapper-title .action-add:hover { - color: #000; -} - -.fieldset-wrapper-title .action-add span { -} - -/* Quantity filed on product */ -.field-quantity_and_stock_status { -} - -.field-quantity_and_stock_status input[type="text"] { - width: 36%; - margin-right: 15px; -} - -.field-quantity_and_stock_status select { - vertical-align: middle; -} - -/* Weight field */ -.field-weight { -} - -.field-weight .field:first-child { - width: 36%; - margin-right: 15px; -} - -.field-weight .choice input { - margin-right: 5px; -} - -/* Variations Search Field */ -#variations-search-field { - margin-bottom: 16px; -} - -#variations-search-field > .control { - position: relative; - width: 42%; -} - -#variations-search-field > .control:after { - position: absolute; - top: 0; - right: 3px; - bottom: 0; - width: 22px; - text-align: center; - font-family: 'MUI-Icons'; - font-style: normal; - speak: none; - font-weight: normal; - -webkit-font-smoothing: antialiased; - content: '\e01f'; /* search icon */ - font-size: 20px; - color: #b2b2b2; -} - -#variations-search-field > .control > input { - padding-right: 25px; -} - -#configurable-attributes-container .field-variation > .label { - margin-left: -7px; -} - -#configurable-attributes-container .field-variation > .control { - width: 43%; -} - -#configurable-attributes-container { - margin-bottom: 23px; -} - -#configurable-attributes-container .col-name { - width: 45%; -} - -#configurable-attributes-container .pricing-value { - text-align: right; -} - -#generate-variations-button { - margin-bottom: 18px; -} - -#product-variations-matrix > .title { - margin-bottom: 10px; -} - -#product-variations-matrix .action-upload { - background: #fff; - border-radius: 0; - border: 1px solid #b7b2a7; - padding: 0; - width: 31px; - height: 31px; - line-height: 30px; - text-align: center; - color: #9f9a91; - overflow: hidden; -} - -#product-variations-matrix .action-upload:hover { - color: #7e7e7e; -} - -#product-variations-matrix .action-upload:before { - font-family: 'MUI-Icons'; - font-style: normal; - speak: none; - font-weight: normal; - -webkit-font-smoothing: antialiased; - content: '\e02d'; /* plus icon */ - font-size: 22px; -} - -#product-variations-matrix .action-upload span, -#product-variations-matrix .action-choose span { - display: none; -} - -#product-variations-matrix .action-choose { - color:#b8b3a7; - float: right; - margin-left: 5px; -} -#product-variations-matrix .action-choose:hover { - color:#7e7e7e; -} -#product-variations-matrix .action-choose:before { - font-family: 'MUI-Icons'; - font-style: normal; - speak: none; - font-weight: normal; - -webkit-font-smoothing: antialiased; - content: '\e040'; /* user icon */ -} - -#product-variations-matrix .col-name > a + .action-choose:before { - content: '\e03f'; /* user icon */ - color: #a09a8c; -} - /* Customer ---------------------------------------*/ -.customer-iformation:before, -.customer-iformation:after { +.customer-information:before, +.customer-information:after { content: ""; display: table; } -.customer-iformation:after { +.customer-information:after { clear: both; } -.customer-iformation table, -.customer-iformation address { +.customer-information .data-table, +.customer-information address { width: 48.5%; } -.customer-iformation table { +.customer-information .data-table { float: left; width: 48.5%; } -.customer-iformation address { +.customer-information address { padding-top: 4px; line-height: 2.2; float: right; } -.customer-iformation table tbody tr th { - font-weight: bold; -} - -.customer-iformation table tbody tr td, -.customer-iformation table tbody tr th { - background-color: #fff; - border: 0; - padding: 9px 10px 10px; - color: #666; - vertical-align: top; -} - -.customer-iformation table tbody tr:nth-child(2n+1) td, -.customer-iformation table tbody tr:nth-child(2n+1) th { - background-color: #fbfaf6; -} - .address-list { list-style: none; width: 278px; @@ -475,6 +122,7 @@ padding-left: 12px; } +.address-list li.active:before, .address-list li.active:after { position: absolute; font-family: 'MUI-Icons'; @@ -490,10 +138,20 @@ text-indent: -6px; top: 50%; margin-top: -5px; - text-shadow: 2px 0 0 #d9d2ca; + z-index: 2; +} + +.address-list li.active:before { + color:#d9d2ca; + right: -11px; z-index: 1; } +.address-list li.adress-list-actions:before, +.address-list li.adress-list-actions:after { + display: none; +} + .address-list li.adress-list-actions { padding: 20px 0 0 0; border: 0; @@ -506,10 +164,6 @@ padding: 0; } -.address-list li.adress-list-actions:after { - display: none; -} - .address-list .label { float: none; width: auto; @@ -550,6 +204,11 @@ border: 1px solid #dad1c8; background: #fff; box-shadow: 0 2px 1px 0 rgba(217, 210, 202, 0.5); + padding-left: 10px; +} + +.address-item-edit-content .fieldset:last-child { + margin-bottom: 29px; } .address-item-edit .legend { @@ -566,6 +225,39 @@ padding: 0 0 18px 20%; } +/* + Invitations +--------------------------------------*/ +.invitee_information, +.inviter_information { + width: 48.9362%; +} +.invitee_information { + float: left; +} +.inviter_information { + float: right; +} +.invitation_information .data-table th, +.invitee_information .data-table th, +.inviter_information .data-table th { + width: 20%; + white-space: nowrap; +} +.invitation_information .data-table textarea, +.invitation_information .data-table input { + width: 100%; +} +.invitations-history ul { + margin: 0; + padding-left: 25px; +} +.invitations-history ul .status:before { + display:inline-block; + content: "|"; + margin: 0 10px; +} + /* CMS -> Polls -------------------------------------- */ @@ -582,59 +274,2045 @@ .field-poll_answers_container .action-add { margin-top: 7px; } +.field-poll_answers_container .data-table tbody tr td { + vertical-align: top; +} /* - Reports + CMS -> Banners -------------------------------------- */ -.reports-title .page-actions { - float: right; + +/* Banner Properties */ +#banner_properties_customer_segment_ids { + min-width: 20%; } -.reports-title .store-switcher { - padding: 14px 0 18px; +/* + CMS -> Manage Hierarchy +-------------------------------------- */ + +.cms-hierarchy .cms-scope { + float: right; + margin-right: 25px; + position: relative; + top: 2px; } -.reports-content select { - width: 160px; +.cms-hierarchy #tree-container { + margin: 5px 0 10px 0; } -.reports-content input.hasDatepicker { - width: 133px; +.cms-hierarchy .buttons-set { + margin-bottom: 10px; } -/* TODO: refactor when validation design is ready */ -.reports-content .required .control { +.cms-hierarchy #cms_page_grid_container .actions { position: relative; + top: 4px; } -.reports-content input.hasDatepicker + label.mage-error { - left: 0; - position: absolute; - top: 30px; +.cms-hierarchy .cms-hierarchy-tree { + width: 48.93617020799999%; + float: left; + margin: 10px 0 8px 0; } -.reports-title:before, -.reports-title:after { - content: ""; - display: table; +.cms-hierarchy .cms-hierarchy-node { + width: 48.93617020799999%; + float: left; + margin: 10px 0 8px 2.127659574%; } -.reports-title:after { +.cms-hierarchy #cms_page_grid_container { clear: both; } +.cms-hierarchy .store-switcher { + position: relative; + top: 10px; +} + +.cms-hierarchy .store-switcher label { + margin-right: 8px; +} + +/* + CMS -> Banners +-------------------------------------- */ + +/* Content */ + +.field-store_default_content .buttons-set { + margin-bottom: 9px; +} + +.field-store_default_content .buttons-set button { + margin-right: 4px; +} + +.field-store_0_content_use input[type="checkbox"] { + margin-right: 3px; + position: relative; + top: 2px; +} + +/* + CMS -> Static Blocks +-------------------------------------- */ + +#buttonsblock_content.buttons-set { + margin-bottom: 9px; +} + +#buttonsblock_content.buttons-set button { + margin-right: 4px; +} + +/* + CMS -> Manage Content +-------------------------------------- */ + +/* Content */ + +.cms-manage-content-actions .buttons-set { + margin-bottom: 9px; +} + +.cms-manage-content-actions .buttons-set button { + margin-right: 4px; +} + +.cms-manage-content-actions textarea { + width: 100%; +} + +/* + Reports +-------------------------------------- */ +.reports-title .page-actions { + float: right; +} + +.reports-title .store-switcher { + padding: 14px 0 18px; +} + +.reports-content select { + width: 160px; +} + +.reports-content input.hasDatepicker { + width: 133px; +} + +/* TODO: refactor when validation design is ready */ +.reports-content .required .control { + position: relative; +} + +.reports-content input.hasDatepicker + label.mage-error { + left: 0; + position: absolute; + top: 30px; +} + +.reports-title:before, +.reports-title:after { + content: ""; + display: table; +} + +.reports-title:after { + clear: both; +} + +/* + Reports - Customer Reviews +-------------------------------------- */ +.adminhtml-report-review-customer .col-qty, +.adminhtml-report-review-customer .col-actions { + width: 85px; +} + +/* + Reports - Product Reviews +-------------------------------------- */ + +.adminhtml-report-review-product .col-id { + width: 35px; +} + +.adminhtml-report-review-product .col-qty, +.adminhtml-report-review-product .col-rating, +.adminhtml-report-review-product .col-avg-rating, +.adminhtml-report-review-product .col-actions { + text-align: right; + width: 85px; +} + +.adminhtml-report-review-product .col-date { + width: 140px; +} + +.adminhtml-report-review-product .col-rating { + width: 104px; +} + +/* + Reports - New Accounts +-------------------------------------- */ + +.adminhtml-report-customer-accounts .col-period { + white-space: nowrap; + width: 70px; +} + +/* + Reports - Refresh Statistics +-------------------------------------- */ + +.adminhtml-report-statistics-index .col-period { + white-space: nowrap; + width: 140px; +} + +.adminhtml-report-statistics-index .col-select { + width: 25px; +} + +/* + Reports - Products Ordered +-------------------------------------- */ +.adminhtml-report-product-sold .col-period { + white-space: nowrap; + width: 70px; +} + +.adminhtml-report-product-sold .col-qty { + width: 110px; +} + +/* + Reports - Customers by Orders Total +-------------------------------------- */ +.adminhtml-report-customer-totals .col-period { + white-space: nowrap; + width: 70px; +} + +.adminhtml-report-customer-totals .col-qty { + width: 65px; +} + +.adminhtml-report-customer-totals .col-rating { + width: 100px; +} + +/* + Reports - Tag by popular +-------------------------------------- */ +.adminhtml-report-tag-popular .col-qty, +.adminhtml-report-tag-popular .col-actions { + width: 80px; +} + +/* + Reports - Tag by customer +-------------------------------------- */ +.adminhtml-report-tag-customer .col-id { + width: 35px; +} + +.adminhtml-report-tag-customer .col-qty, +.adminhtml-report-tag-customer .col-actions { + width: 80px; +} + +/* + Reports - Tag by product +-------------------------------------- */ +.adminhtml-report-tag-product .col-id { + width: 35px; +} + +.adminhtml-report-tag-product .col-actions { + width: 70px; +} + +.adminhtml-report-tag-product .col-unique-numbers, +.adminhtml-report-tag-product .col-total-numbers { + text-align: right; + width: 95px +} + +/* + Reports - Customers by Number of Orders +-------------------------------------- */ +.adminhtml-report-customer-orders .col-period { + white-space: nowrap; + width: 70px; +} + +.adminhtml-report-customer-orders .col-qty, +.adminhtml-report-customer-orders .col-average, +.adminhtml-report-customer-orders .col-total { + width: 105px; +} + +/* + Reports - Customers by Orders Total +-------------------------------------- */ +.adminhtml-report-customer-totals .col-period { + white-space: nowrap; + width: 70px; +} + +.adminhtml-report-customer-totals .col-qty, +.adminhtml-report-customer-totals .col-average, +.adminhtml-report-customer-totals .col-total { + width: 105px; +} + +/* + Reports - Customer's wishlists +-------------------------------------- */ +.adminhtml-report-customer-wishlist-wishlist .col-period { + width: 70px; +} + +.adminhtml-report-customer-wishlist-wishlist .col-whishlist-qty, +.adminhtml-report-customer-wishlist-wishlist .col-available-qty, +.adminhtml-report-customer-wishlist-wishlist .col-qty-diff { + text-align: right; + width: 100px; +} + +.adminhtml-report-customer-wishlist-wishlist .grid .range { + text-align: left; +} + +/* + Reports - Customer Segment Report +-------------------------------------- */ +.filter-segments { + list-style: none; + padding: 0; +} + +.adminhtml-report-customer-customersegment-detail .col-id { + width: 35px; +} + +.adminhtml-report-customer-customersegment-detail .col-period { + white-space: nowrap; + width: 70px; +} + +.adminhtml-report-customer-customersegment-detail .col-zip { + width: 50px; +} + +/* + Reports - Most Viewed +-------------------------------------- */ +.adminhtml-report-product-viewed .col-period { + white-space: nowrap; + width: 70px; +} + +.adminhtml-report-product-viewed .col-qty, +.adminhtml-report-product-viewed .col-price { + white-space: nowrap; + width: 80px; +} + +/* + Reports - Search Terms +-------------------------------------- */ +.adminhtml-report-search .col-id { + width: 35px; +} + +.adminhtml-report-search th.col-results, +.adminhtml-report-search th.col-hits { + text-align: left; + width: 117px; +} + +.adminhtml-report-search td.col-results, +.adminhtml-report-search td.col-hits { + text-align: right; + width: 117px; +} + +.adminhtml-report-search .col-results .range-line:first-child, +.adminhtml-report-search .col-hits .range-line:first-child { + float: left; + margin-right: 3px; +} + +/* + Reports - Bestsellers +-------------------------------------- */ + +.adminhtml-report-sales-bestsellers .col-period { + white-space: nowrap; + width: 70px; +} + +.adminhtml-report-sales-bestsellers .col-qty, +.adminhtml-report-sales-bestsellers .col-price { + width: 80px; +} + +/* + Reports - Downloads +-------------------------------------- */ +.adminhtml-report-product-downloads .col-qty, +.adminhtml-report-product-downloads .col-price { + width: 80px; +} + +/* + Reports - Order Conversion Rate +-------------------------------------- */ +.adminhtml-report-invitation-order .col-period { + white-space: nowrap; + width: 70px; +} + +.adminhtml-report-invitation-order .col-inv-sent, +.adminhtml-report-invitation-order .col-inv-acc, +.adminhtml-report-invitation-order .col-acc, +.adminhtml-report-invitation-order .col-rate { + text-align: right; + width: 23%; +} + +/* + Reports - Invitations - Customer +-------------------------------------- */ +.adminhtml-report-invitation-customer .col-id { + width: 35px; +} + +.adminhtml-report-invitation-customer .col-period { + white-space: nowrap; + width: 70px; +} + +.adminhtml-report-invitation-customer .col-inv-sent, +.adminhtml-report-invitation-customer .col-inv-acc { + text-align: right; + width: 120px; +} + +/* + Reports - Invitations - General +-------------------------------------- */ +.adminhtml-report-invitation-index .col-period { + white-space: nowrap; +} + +.adminhtml-report-invitation-index .col-inv-sent, +.adminhtml-report-invitation-index .col-inv-acc, +.adminhtml-report-invitation-index .col-inv-disc, +.adminhtml-report-invitation-index .col-inv-acc-rate, +.adminhtml-report-invitation-index .col-inv-disc-rate { + text-align: right; + width: 19%; +} + +/* + Reports - Abandoned Carts +-------------------------------------- */ + +.adminhtml-report-shopcart-abandoned .col-ip, +.adminhtml-report-shopcart-abandoned .col-subtotal, +.adminhtml-report-shopcart-abandoned .col-number, +.adminhtml-report-shopcart-abandoned .col-coupon { + text-align: right; +} + +.adminhtml-report-shopcart-abandoned .col-ip { + width: 105px; +} + +.adminhtml-report-shopcart-abandoned .col-subtotal { + width: 65px; +} + +/* + Reports - Products in Carts +-------------------------------------- */ +.adminhtml-report-shopcart-product .col-id { + width: 35px; +} + +.adminhtml-report-shopcart-product .col-carts, +.adminhtml-report-shopcart-product .col-qty, +.adminhtml-report-shopcart-product .col-price { + text-align: right; + width: 80px; +} + +/* + Reports - Refunds +-------------------------------------- */ + +.adminhtml-report-sales-refunded .col-period { + white-space: nowrap; + width: 70px; +} + +.adminhtml-report-sales-refunded .col-ref-total, +.adminhtml-report-sales-refunded .col-ref-online, +.adminhtml-report-sales-refunded .col-ref-offline { + text-align: right; + width: 23%; +} + +/* + Reports - Shipping +-------------------------------------- */ + +.adminhtml-report-sales-shipping .col-period { + white-space: nowrap; + width: 70px; +} + +.adminhtml-report-sales-shipping .col-qty, +.adminhtml-report-sales-shipping .col-total-sales-shipping, +.adminhtml-report-sales-shipping .col-total-shipping { + text-align: right; + width: 115px; +} + +/* + Reports - Invoiced +-------------------------------------- */ + +.adminhtml-report-sales-invoiced .col-period { + white-space: nowrap; + width: 70px; +} + +.adminhtml-report-sales-invoiced .col-qty, +.adminhtml-report-sales-invoiced .col-invoiced, +.adminhtml-report-sales-invoiced .col-total-invoiced, +.adminhtml-report-sales-invoiced .col-total-invoiced-paid, +.adminhtml-report-sales-invoiced .col-total-invoiced-not-paid { + text-align: right; + width: 19%; +} + +/* + Reports - Tax +-------------------------------------- */ + +.adminhtml-report-sales-tax .col-period { + white-space: nowrap; + width: 70px; +} + +.adminhtml-report-sales-tax .col-rate, +.adminhtml-report-sales-tax .col-qty, +.adminhtml-report-sales-tax .col-tax-amount { + text-align: right; + width: 105px; +} + +/* + Reports - Orders +-------------------------------------- */ +.adminhtml-report-sales-sales .col-period { + white-space: nowrap; + width: 70px; +} + +.adminhtml-report-sales-sales .col-orders, +.adminhtml-report-sales-sales .col-sales-items, +.adminhtml-report-sales-sales .col-sales-total, +.adminhtml-report-sales-sales .col-invoiced, +.adminhtml-report-sales-sales .col-refunded, +.adminhtml-report-sales-sales .col-sales-tax, +.adminhtml-report-sales-sales .col-sales-shipping, +.adminhtml-report-sales-sales .col-sales-discount, +.adminhtml-report-sales-sales .col-canceled { + text-align: right; + width: 10.5%; +} + +/* + Reports - Coupons +-------------------------------------- */ +/* TODO: re-check styles for coupons table after coupons functionality will have been repaired */ +.adminhtml-report-sales-coupons .col-period { + white-space: nowrap; + width: 70px; +} + +.adminhtml-report-sales-coupons .col-sales, +.adminhtml-report-sales-coupons .col-users, +.adminhtml-report-sales-coupons .col-sales-discount, +.adminhtml-report-sales-coupons .col-total-amount, +.adminhtml-report-sales-coupons .col-subtotal, +.adminhtml-report-sales-coupons .col-discount, +.adminhtml-report-sales-coupons .col-total { + text-align: right; +} + +/* + Reports - Customer Segments +-------------------------------------- */ + +.adminhtml-report-customer-customersegment-segment .col-id { + width: 35px; +} + +.adminhtml-report-customer-customersegment-segment .col-status { + width: 65px; +} + +.adminhtml-report-customer-customersegment-segment .col-qty { + width: 145px; +} + +.adminhtml-report-customer-customersegment-segment .col-segment, +.adminhtml-report-customer-customersegment-segment .col-website { + width: 35%; +} + +.adminhtml-report-customer-customersegment-segment .col-select { + width: 45px; +} + +/* + Reports - Low Stock +-------------------------------------- */ + +.adminhtml-report-product-lowstock .col-qty { + width: 10%; +} + +.adminhtml-report-product-lowstock .range { + white-space: nowrap; +} + +.adminhtml-report-product-lowstock .range-line { + display: inline-block; +} +.adminhtml-report-product-lowstock .range-line:first-child { + margin-right: 5px; +} + +.adminhtml-report-product-lowstock .col-product { + width: 65%; +} + +.adminhtml-report-product-lowstock .col-sku { + width: 25%; +} + +/* + Reports - PayPal Settlement Reports +-------------------------------------- */ + +.adminhtml-paypal-reports-index .col-amount, +.adminhtml-paypal-reports-index .col-fee-amount { + text-align: right; +} + +/* + Newsletter +-------------------------------------- */ +[class^=" adminhtml-newsletter-"] .page-actions .action-back { + float: right; +} + +/* + Newsletter Templates +-------------------------------------- */ +.adminhtml-newsletter-template-index .col-id { + width: 35px; +} + +.adminhtml-newsletter-template-index .col-actions { + width: 80px; +} + +.adminhtml-newsletter-template-index .col-type { + width: 100px; +} + +.adminhtml-newsletter-template-index .col-added, +.adminhtml-newsletter-template-index .col-updated { + width: 140px; +} + +[class^=' adminhtml-newsletter-'] .buttons-set { + margin: 0 0 15px; +} + +[class^=" adminhtml-newsletter-"] .buttons-set button { + margin-right: 4px; +} + +/* + Newsletter - Queue +-------------------------------------- */ +.adminhtml-newsletter-queue-index .col-id { + width: 35px; +} + +.adminhtml-newsletter-queue-index .col-finish, +.adminhtml-newsletter-queue-index .col-start { + width: 130px; +} + +.adminhtml-newsletter-queue-index .col-status, +.adminhtml-newsletter-queue-index .col-processed, +.adminhtml-newsletter-queue-index .col-recipients { + white-space: nowrap; + width: 85px; +} + +.adminhtml-newsletter-queue-index td.col-processed, +.adminhtml-newsletter-queue-index td.col-recipients { + text-align: right; +} + +.adminhtml-newsletter-queue-index .col-actions { + width: 80px; +} + +/* + Newsletter - Subscribers +-------------------------------------- */ +.adminhtml-newsletter-subscriber-index .col-id { + width: 35px; +} + +.adminhtml-newsletter-subscriber-index .col-type { + width: 75px; +} + +.adminhtml-newsletter-subscriber-index .col-status { + white-space: nowrap; + width: 85px; +} + +/* + Newsletter - Problems +-------------------------------------- */ +.adminhtml-newsletter-problem-index .col-select { + width: 25px; +} + +.adminhtml-newsletter-problem-index .col-id { + width: 35px; +} + +.adminhtml-newsletter-problem-index .col-start { + width: 130px; +} + +.adminhtml-newsletter-problem-index .col-error-code { + width: 150px; +} + +/* + Gift Registry +--------------------------------------*/ +.table-fieldset-alt, +.type-options, +.giftregistry-custom-attributes { + margin-bottom: 20px; +} + +.table-fieldset-alt thead th, +.table-fieldset-alt tbody tr td { + border-width: 0; +} + +.table-fieldset-alt tbody tr:nth-child(odd) td, +.table-fieldset-alt tbody tr:nth-child(odd):hover td { + background: #fff; +} + +/* + System - Tax +--------------------------------------*/ +.tax-rate-popup .ui-dialog-content.ui-widget-content { + padding: 10px 10px 0; +} + +.tax-rate-popup .fieldset { + margin: 0; +} + +.tax-rate-popup .field { + margin-bottom: 20px; +} + +.tax-rate-popup .field .label { + margin: 5px 0 0 0; + width: 26%; + padding: 0 20px 0 0; + float: left; + text-align: right; + box-sizing: content-box; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + -ms-box-sizing: content-box; +} + +.tax-rate-popup .field .control { + width: 58%; + margin: 0; + float: left; +} + +.tax-rate-popup .field .control select, +.tax-rate-popup .field .control .input-text { + width: 100%; +} + +.tax-rate-popup .field-rate .control .input-text { + width: 50%; +} + +.tax-rate-popup .tax-rate-titles-note-td { + margin-left: 26%; + padding-left: 20px; +} + +/* + Tags +-------------------------------------- */ +.tag-title .page-actions { + float: right; +} + +.tag-title .store-switcher { + padding: 14px 0 18px; +} + +/* + Attribute Mapping +-------------------------------------- */ +.field-attributes_box .control-value { + width:100%; +} + +.adminhtml-googleshopping-types-new #attribute_set { + padding: 0; +} + +.adminhtml-googleshopping-types-new #gcontent_attributes_container { + margin-top: -6px; +} + +/* + Dashboard +-------------------------------------- */ +.dashboard-inner { + border:1px solid #ccc; +} + +.dashboard-container .dashboard-diagram { + margin: 20px; +} + +.dashboard-container .store-switcher { + margin: 20px 0 10px; +} + +.dashboard-container .dashboard-diagram .store-switcher { + margin-top: 0; +} + +.dashboard-diagram-nodata { + border: 1px solid #ccc; + padding: 20px 0; + text-align: center; +} + +/* + Sales +-------------------------------------- */ + +.customer-current-activity { + float: left; + width: 22%; +} + +.customer-current-activity-inner { + background: #fff; + border: 1px solid #eae6e0; + padding: 18px; + border-radius: 5px; +} + +.order-details-existing-customer { + padding-left: 1%; + position: relative; + width: 77%; + float: right; +} + +.order-billing-address, +.order-billing-method, +[class^=" adminhtml-sales-order-"] .order-history, +[class^=" adminhtml-sales-order-"] .order-comments-history, +[class^=" adminhtml-sales-order-"] .order-information, +[class^=" adminhtml-sales-order-"] .order-billing-address, +[class^=" adminhtml-sales-order-"] .order-payment-method, +[class^=" adminhtml-rma-"] .order-comments-history, +[class^=" adminhtml-rma-"] .order-shipping-address, +[class^=" adminhtml-rma-"] .rma-request-details { + float: left; + width: 49.5%; +} + +.order-shipping-address, +.order-shipping-method, +[class^=" adminhtml-sales-order-"] .order-totals, +[class^=" adminhtml-sales-order-"] .order-account-information, +[class^=" adminhtml-sales-order-"] .order-shipping-address, +[class^=" adminhtml-sales-order-"] .order-payment-method-virtual, +[class^=" adminhtml-sales-order-"] .order-shipping-method, +[class^=" adminhtml-rma-"] .rma-confirmation, +[class^=" adminhtml-rma-"] .order-shipping-method, +[class^=" adminhtml-rma-"] .order-return-address { + float: right; + width: 49%; +} + +#order-data .order-account-information { + float: none; + width: auto; +} + +#order-data .actions .action-add, +#order-data .actions .action-add:active, +#order-data .actions .action-add:hover, +#order-data .actions .action-delete, +#order-data .actions .action-delete:active, +#order-data .actions .action-delete:hover { + margin: 0 0 0 20px; +} + +#order-data .order-methods ul { + list-style: none; + margin: 0; + padding: 0; +} + +#order-data .order-methods dl, +#order-data .order-methods dt, +#order-data .order-methods dd, +#order-data .payment-methods dl, +#order-data .payment-methods dt, +#order-data .payment-methods dd { + margin: 0; + padding: 0; +} + +#order-data .order-methods dd + dt, +#order-data .payment-methods dd + dt { + margin-top: 17px; +} + +#order-data .order-methods dt, +#order-data .payment-methods dt { + margin: 0 0 8px; +} + +.order-coupons .box-left, +.order-gift-options .box-left { + float: left; + width: 49%; +} + +.order-coupons .box-right, +.order-gift-options .box-right { + float: right; + width: 49%; +} + +.ui-dialog.gift-options-popup .ui-dialog-content { + padding: 25px; +} + +.ui-dialog.gift-options-popup .ui-dialog-content h4 { + margin: 0 0 17px; +} + +.gift-options-tooltip { + background: #fff; + border-radius: 5px; + padding: 10px; + box-shadow: 0 0 3px rgba(0, 0, 0, .3); +} + +#order-data .box-left fieldset, +#order-data .box-right fieldset { + border-radius: 5px; +} + +#order-data .order-items td[colspan="8"] { + border: 1px solid #c0bbaf; +} + +.order-search-items thead th:nth-child(1) { width: 60px; } +.order-search-items thead th:nth-child(3) { width: 80px; } +.order-search-items thead th:nth-child(4) { width: 100px; } +.order-search-items thead th:nth-child(5) { width: 55px; } +.order-search-items thead th:nth-child(6) { width: 1px; } + +.adminhtml-rma-new .order-totals, +.order-comments-history .order-comments-history, +[class^=" adminhtml-rma-"] .rma-comments-history { + float: none; + width: 100%; +} + +[class^=" adminhtml-sales-order-"] .order-billing-address .actions, +[class^=" adminhtml-sales-order-"] .order-shipping-address .actions { + margin: 17px 0; +} + +[class^=" adminhtml-sales-order-"] .order-billing-address .control + label , +[class^=" adminhtml-sales-order-"] .order-shipping-address .control + label { + margin: 17px 0 0; +} + +.adminhtml-sales-order-create-index #order-message ul.messages > li, +.adminhtml-sales-order-edit-index #order-message ul.messages > li { + margin: 0 0 60px; +} + +#order-data .page-actions { padding-top: 0; } + +#order-data .store-switcher { margin: -46px 0 0; position: relative; width: 50%; } + +.create-order-sidebar-container > div + div { + border-top: 1px solid #ededed; + margin-top: 35px; +} + +.create-order-sidebar-container > div .head h5 { + margin: 17px 0 7px; +} + +.customer-current-activity-inner > h4 { + border-bottom: 1px solid #ededed; + margin-top: 0; + padding: 0 0 16px; +} + +.customer-current-activity-inner .data-table th { + font-size: 11px; +} + +.customer-current-activity .action-refresh { + float: right; +} + +.customer-current-activity .action-refresh, +.customer-current-activity .data-table .icon { + display: inline-block; + text-indent: 100%; + overflow: hidden; + height: 16px; + width: 16px; + white-space: nowrap; +} + +.customer-current-activity .action-refresh:before, +.customer-current-activity .data-table .icon:before { + content: "\e010"; + color: #c3c2be; + display: block; + text-indent: 0; + font-size: 16px; + font-family: 'MUI-Icons'; + font-style: normal; + font-weight: normal; + speak: none; + -webkit-font-smoothing: antialiased; +} + +.customer-current-activity .data-table .icon-remove:before { content: "\e07f"; } +.customer-current-activity .data-table .icon-add:before { content: "\e071"; } + +.customer-current-activity .auto-scroll { + overflow: auto; + max-height: 150px; +} + +.customer-current-activity .auto-scroll + button { + margin: 22px 0 0; +} + +.customer-current-activity .actions { + border-top: none; + margin: 20px 0 0; + padding: 0; +} + +.overlay { + background: rgba(0, 0, 0, .3); + border-radius: 5px; + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; +} + +.overlay span { + color: #111; + font-weight: bold; + position: absolute; + top: 50%; + left: 50%; + margin: -25px 0 0 -100px; + width: 200px; +} + +/* + Order view +-------------------------------------- */ +[class^=" adminhtml-sales-order-"] .fieldset-wrapper-title .actions { + float: right; + font-size: 12px; + margin: 8px 20px 0 0; +} + +[class^=" adminhtml-sales-order-"] .fieldset-wrapper-title .actions a:link, +[class^=" adminhtml-sales-order-"] .fieldset-wrapper-title .actions a:visited, +[class^=" adminhtml-sales-order-"] .fieldset-wrapper-title .actions a:hover, +[class^=" adminhtml-sales-order-"] .fieldset-wrapper-title .actions a:active { + color: #a29c94; +} + +.order-comments-history fieldset { + border: 0; + margin: 0; + padding: 0; +} + +.order-comments-history textarea, +.rma-history-form textarea { + height: 6em; + margin: 5px 0 10px; + resize: vertical; + width: 100%; +} + +.order-comments-history input[type="checkbox"] { + margin-right: 5px; +} + +.order-history-comments-options { + float: left; +} + +.order-comments-history .actions { + float: right; +} + +/* + Orders comments +-------------------------------------- */ +.note-list { + list-style: none; + padding: 0; +} + +.note-list li { + border-top: 1px solid #ededed; + padding: 9px 0; +} + +.note-list li:first-child { + border: 0; + padding-top: 13px; +} + +.note-list div { + font-size: 12px; +} + +.note-list .note-list-date, +.note-list .note-list-status, +.note-list .note-list-customer span { + font-weight: bold; +} + +.note-list .note-list-time, +.note-list .note-list-status { + border-right: 1px solid #676056; + padding: 0 5px 0 0; + margin: 0 5px 0 0; +} + +.note-list .note-list-customer { + white-space: nowrap; +} + +.note-list .note-list-comment { + margin: 5px 0 0; +} + +.note-list .note-list-customer-notapplicable { + color: #d87e34; +} + +.note-list .note-list-customer-notified { + color: #185b00; +} + +.note-list .note-list-customer-not-notified { + color: #963535; +} + +.adminhtml-giftwrapping-index th.col-id { + text-align: left; +} + +.adminhtml-giftwrapping-index .col-id, +.adminhtml-checkout-agreement-index .col-id, +[class^=" adminhtml-sales-billing-"] .col-id, +[class^=" adminhtml-sales-transactions-"] .col-id { + width: 35px; +} + +[class^=" adminhtml-sales-order-shipment-"] .col-ship, +[class^=" adminhtml-sales-"] .col-return-to-stock, +.adminhtml-rma-new .col-select { + text-align: center; + width: 35px; +} + +[class^=" adminhtml-sales-order-"] .col-status, +[class^=" adminhtml-sales-order-"] .col-price-original, +[class^=" adminhtml-sales-order-"] .col-tax-amount, +[class^=" adminhtml-sales-order-"] .col-tax-percent, +[class^=" adminhtml-sales-order-"] .col-discont, +[class^=" adminhtml-sales-order-"] .col-total, +[class^=" adminhtml-sales-order-"] .col-discount, +[class^=" adminhtml-sales-order-"] .col-tax, +[class^=" adminhtml-sales-"] .col-refunded, +[class^=" adminhtml-rma-"] .col-order, +[class^=" adminhtml-rma-"] .col-required, +[class^=" adminhtml-rma-"] .col-system, +[class^=" adminhtml-rma-"] .col-visible-on-front, +.adminhtml-checkout-agreement-index .col-status, +.adminhtml-rma-item-attribute-edit .col-position { + text-align: right; + white-space: nowrap; + width: 50px; +} + +[class^=" adminhtml-sales-order-"] .col-subtotal, +[class^=" adminhtml-sales-order-"] .col-price, +[class^=" adminhtml-rma-"] .col-price, +.adminhtml-giftwrapping-index .col-price { + text-align: right; + width: 50px; +} + +.adminhtml-sales-order-invoice-view .col-subtotal, +.adminhtml-sales-order-invoice-view .col-price { + width: 10%; +} + +[class^=" adminhtml-sales-"] .col-select, +[class^=" adminhtml-sales-"] .col-actions, +[class^=" adminhtml-rma-"] .col-select, +[class^=" adminhtml-rma-"] .col-actions, +[class^=" adminhtml-rma-"] .col-default, +.adminhtml-giftwrapping-index .col-select, +.adminhtml-giftwrapping-index .col-actions { + width: 50px; +} + +[class^=" adminhtml-sales-"] .col-qty, +[class^=" adminhtml-sales-order-"] .col-qty-invoice, +[class^=" adminhtml-sales-order-"] .col-ordered-qty, +[class^=" adminhtml-rma-"] .col-qty, +[class^=" adminhtml-rma-"] .col-condition { + width: 70px; +} +[class^=" adminhtml-sales-"] .col-refund, +[class^=" adminhtml-sales-transactions-"] .col-closed, +.adminhtml-sales-order-view .col-closed { + text-align: center; + width: 70px; +} + +[class^=" adminhtml-sales-"] .col-order-number, +[class^=" adminhtml-sales-"] .col-invoice-number, +[class^=" adminhtml-sales-"] .col-memo-number, +[class^=" adminhtml-sales-"] .col-shipment-number, +[class^=" adminhtml-sales-"] .col-rma-number, +[class^=" adminhtml-sales-"] .col-status, +[class^=" adminhtml-rma-"] .col-order-number, +[class^=" adminhtml-rma-"] .col-rma-number, +[class^=" adminhtml-sales-transactions-"] .col-order-id, +.adminhtml-giftwrapping-index .col-status, +.adminhtml-sales-order-view .col-refunded { + white-space: normal; + width: 75px; +} + +[class^=" adminhtml-sales-"] .col-order-number, +[class^=" adminhtml-sales-"] .col-rma-number, +[class^=" adminhtml-rma-"] .col-order-number, +[class^=" adminhtml-rma-"] .col-rma-number { + text-align: left; +} + +[class^=" adminhtml-sales-"] .col-gtbase, +[class^=" adminhtml-sales-"] .col-gtpurchased { + text-align: right; + width: 80px; +} + +[class^=" adminhtml-rma-"] .col-status, +[class^=" adminhtml-rma-"] .col-reason, +[class^=" adminhtml-rma-"] .col-resolution, +.adminhtml-sales-order-view .col-memo, +[class^=" adminhtml-sales-transactions-"] .col-transaction-type { + width: 100px; +} + +[class^=" adminhtml-sales-"] .col-parent-transaction-id, +[class^=" adminhtml-sales-"] .col-transaction-id { + width: 140px; +} + +[class^=" adminhtml-sales-"] .col-period, +[class^=" adminhtml-rma-"] .col-period { + white-space: nowrap; + width: 150px; +} + +[class^=" adminhtml-sales-order-shipment-"] .col-carrier { + width: 190px; +} + +.adminhtml-giftwrapping-index .col-websites, +.adminhtml-checkout-agreement-index .col-store-view { + white-space: nowrap; + width: 200px; +} + +[class^=" adminhtml-sales-transactions-"] .log-details .data-table tbody tr th, +[class^=" adminhtml-sales-transactions-"] .col-key { + width: 22%; +} + +[class^=" adminhtml-sales-order-"] .order-totals .actions, +[class^=" adminhtml-rma-"] .col-qty, +[class^=" adminhtml-rma-"] .col-qty_ordered, +.adminhtml-sales-order-view .col-refunded { + text-align: right; +} + +.adminhtml-giftwrapping-index .col-price .label, +[class^=" adminhtml-sales-order-"] .col-price .label, +[class^=" adminhtml-sales-order-"] .col-subtotal .label { + display: inline-block; + min-width: 60px; + white-space: nowrap; +} + +.adminhtml-giftwrapping-index .col-price .price-excl-tax .price, +.adminhtml-giftwrapping-index .col-price .price-incl-tax .price, +[class^=" adminhtml-sales-order-"] .col-price .price-excl-tax .price, +[class^=" adminhtml-sales-order-"] .col-price .price-incl-tax .price, +[class^=" adminhtml-sales-order-"] .col-subtotal .price-excl-tax .price, +[class^=" adminhtml-sales-order-"] .col-subtotal .price-incl-tax .price { + font-weight: bold; +} + +[class^=" adminhtml-sales-order-"] .grid .col-qty table, +[class^=" adminhtml-sales-order-"] .grid .col-qty tbody, +[class^=" adminhtml-sales-order-"] .grid .col-qty tr, +[class^=" adminhtml-sales-order-"] .grid .col-qty td, +[class^=" adminhtml-sales-order-"] .grid .col-ordered-qty table, +[class^=" adminhtml-sales-order-"] .grid .col-ordered-qty tbody, +[class^=" adminhtml-sales-order-"] .grid .col-ordered-qty tr, +[class^=" adminhtml-sales-order-"] .grid .col-ordered-qty td { + background: none; + border: 0; +} + +[class^=" adminhtml-sales-order-"] .col-ordered-qty td { + padding: 0 5px 3px; +} + +[class^=" adminhtml-sales-order-"] .grid .product-title { + font-weight: bold; +} + +[class^=" adminhtml-sales-order-"] .item-options { + margin: 5px 0 5px 10px; +} + +[class^=" adminhtml-sales-order-"] .item-options dt { + font-weight: bold; +} + +[class^=" adminhtml-sales-order-"] .item-options dd { + margin: 0 0 0 10px; +} + +.adminhtml-rma-item-attribute-edit .col-position input { + text-align: center; +} + +.order-subtotal .label { + text-align: right; +} + +.items-to-invoice { + border: 1px solid #c0bbaf; + margin-top: 13px; + width: 100%; +} + +.items-to-invoice td, +table.items-to-invoice tbody tr:hover td { + background-color: #e6e3de; + border: 0; + text-align: center; +} + +[class^=" adminhtml-sales-order-creditmemo-"] .no-items { + padding-top: 13px; + text-align: center; +} + +.items-to-invoice .grand-total { + color: #19a3d1; + font-weight: bold; +} + +.adminhtml-sales-order-shipment-new .order-totals .fieldset-wrapper { + padding-top: 18px; +} + +.adminhtml-sales-order-shipment-new .actions { + float: right; +} + +.creditmemo-totals .data-table input[type="text"] { + text-align: right; + width: 60px; +} +[class^=" adminhtml-sales-order-"] .order-subtotal .label { + width: 80%; +} + +.adminhtml-rma-new .rma-confirmation .actions { + margin-top: 10px; + text-align: right; +} + +[class^=" adminhtml-rma-"] .rma-items th.col-qty span, +.adminhtml-rma-edit .rma-items th.col-qty span { + text-align: left; + white-space: normal; +} + +.adminhtml-rma-edit .data-table .col-carrier, +[class^=" adminhtml-sales-billing-agreement-"] .log-details .data-table th { + width: 20%; +} + +.adminhtml-rma-edit .data-table .col-title { + width: 35%; +} + +.adminhtml-rma-edit .data-table .col-number { + width: 25%; +} + +[class^=" adminhtml-sales-order-"] .order-shipping-address .price, +.order-shipping-address .shipping-description-title { + font-weight: bold; +} + +[class^=" adminhtml-rma-"] .col-actions a { + cursor: pointer; + white-space: nowrap; +} + +[class^=" adminhtml-rma-"] .col-reason input[type="text"] { + margin: 5px 0 0; + width: 100%; +} + +[class^=" adminhtml-rma-"] .col-actions .separator { + margin: 0 3px; +} + +[class^=" adminhtml-sales-"] .order-payment-method .data-table { + margin-top: 15px; +} + +[class^=" adminhtml-sales-"] .order-payment-currency { + margin-top: 15px; +} + +[class^=" adminhtml-sales-"] .grid tbody td { + vertical-align: top; +} + +[class^=" adminhtml-sales-"] .grid tbody.even tr td { + background: #e6e3de; +} + +[class^=" adminhtml-sales-"] .grid tbody.odd tr td { + border-bottom: 0; + background: #f5f2ed; +} + +[class^=" adminhtml-sales-"] .grid .data { + border-bottom: 1px solid #c0bbaf; +} + +[class^=" adminhtml-sales-"] .grid td .option-label { + font-weight: bold; +} + +[class^=" adminhtml-sales-"] .grid td .option-value { + margin: 0 0 0 10px; +} + +.col-product .product_to_add { + float: right; +} +/* + Packaging for Shipping Popup +-------------------------------------- */ +#popup-window-mask, +.popup-window-mask { + background: rgba(0, 0, 0, 0.5); + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 999; +} + +.packaging-window, +.packed-window { + background: #fff; + -webkit-box-shadow: 0 3px 6px rgba(0, 0, 0, .4); + box-shadow: 0 3px 6px rgba(0, 0, 0, .4); + left: 50%; + margin: -200px 0 0 -471px; + position: fixed; + top: 50%; + width: 1000px; + z-index: 1000; +} + +.packaging-window .entry-edit-head { + padding: 3px 5px; +} + +.packaging-window .messages { + padding: 10px 26px 10px 32px; + border: 0; + -moz-border-radius: 0; + -webkit-border-radius: 0; + border-radius: 0; + color: #963535; + text-shadow: none; + position: relative; + background: #f3dcd8; + border: 1px solid #963535; + margin-top: -1px; +} + +.packaging-window .messages:before { + position: absolute; + left: 8px; + top: 50%; + margin-top: -11px; + background: none; + text-shadow: none; + width: auto; + height: auto; + border: 0; + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + font-size: 16px; + content: '\e069'; + color: #963535; +} + +.packaging-window .validation-failed { + background: #fef0ed; + border: 1px dashed #d6340e; +} + +.packaging-window .packaging-content { + overflow: auto; + overflow-x: hidden; + height: auto !important; + max-height: 400px; +} + +.packaging-window .package-options { + width: 100%; + border-top: 1px solid #ccc; + padding: 10px 0 0; + margin: 3px 0 0; +} + +.packaging-window .package-options td { + vertical-align: middle; +} + +.packaging-window .package-options .input-text { + width: 50px; +} + +.packaging-window .package_prapare { + margin-bottom: 15px; +} + +.packaging-window .package-options .customs-value { + width: 80px; +} + +.packaging-window .package-options .options-weight { + width: 75px; +} + +.packaging-window .package-options .options-units-weight { + width: 45px; +} + +.packaging-window .package-options .options-units-dimensions { + width: 45px; +} + +.packaging-window .package-options .options-content-type { + width: 120px; +} + +.packaging-window .package-options input[type=text].disabled, +.packaging-window .package-options select.disabled { + background: #eee; +} + +.packaging-window .package-options-contents { + border-top: 0; +} + +.packaging-window .package-add-products { + margin: 20px 0 0; +} + +.packaging-window .package-add-products .grid { + padding: 0; +} + +.packaging-window .package-add-products .grid button { + vertical-align: middle; +} + +.packaging-window .package-number { + font-weight: bold; +} + +.packaging-window .package-number span { + margin-left: 5px; +} + +.packed-window .entry-edit-head { + padding: 3px 5px; +} + +.packed-window .packed-content { + padding: 10px 10px 0; + overflow: auto; + max-height: 400px; +} + +.packed-window .package { + border-top: 1px solid #ededed; + margin-bottom: 30px; + padding: 10px; +} + +.packed-window .package:first-child { + border-top: 0; +} + +.package-info { + background: #e6e3de; + border: 1px solid #c0bbaf; +} + +.package-info th { + font-weight: bold; +} + +.packed-window .package-info table tbody tr td, +.packed-window .package-info table tbody tr th, +.package-info table tbody tr:nth-child(2n+1) td, +.package-info table tbody tr:nth-child(2n+1) th { + background: none; + border: 0; + padding: 5px 5px 2px; +} + +.packed-window .package .grid { + padding: 0; +} + +.packed-window .package-options { + width: 60%; +} + +.packed-window .package-options td, +.packed-window .package-options th { + padding: 1px 0; +} + +.grid .popup-window { + text-align: left; +} + +.grid tr.on-mouse td .popup-window .data-table tbody tr:nth-child(2n+1) td, +.grid table tbody tr.on-mouse:nth-child(odd):hover td .popup-window .data-table tbody tr:nth-child(2n+1) td, +.grid table tbody tr.on-mouse:nth-child(odd):hover td .popup-window .data-table tbody tr:nth-child(2n+1):hover td, +.grid table tbody tr.on-mouse:nth-child(2n+1):hover td .popup-window .data-table tbody tr:nth-child(2n+1) td, +.grid table tbody tr.on-mouse:nth-child(2n+1):hover td .popup-window .data-table tbody tr:nth-child(2n+1):hover td, +.grid table tbody tr.on-mouse:hover td .popup-window .data-table tbody tr:nth-child(2n+1), +.grid table tbody tr.on-mouse:hover th .popup-window .data-table tbody tr:nth-child(2n+1) { + background-color: #fbfaf6; +} + +.grid .popup-window { + text-align: left; +} + +.popup-window-buttons-set { + text-align: right; + padding: 25px; +} + +.popup-window-title { + background: #f3efea; + padding: 19px 20px; +} + +.popup-window-title .title { + color: #676056; + display: block; + font: 20px/1 'CallunaSans', Arial, sans-serif; +} + +.popup-window-title .actions { + float: right; +} + +.popup-window-content { + padding: 25px 25px 0; +} + +.popup-window-content > ul { + list-style: none; + padding: 0; +} + +.packaging-window .col-weight { + text-align: left; + width: 60px; +} + +.packaging-window .col-qty { + text-align: left; + width: 80px; +} + +.packed-window .col-qty, +.packed-window .col-weight, +.packed-window .col-qty_ordered { + text-align: right; + width: 70px; +} + +.packaging-window .col-select, +.packaging-window .col-measure { + text-align: center; + width: 35px; +} + +.popup-fieldset-title .title { + color: #666; + display: inline-block; + font-family: 'CallunaSans', Arial, sans-serif; + font-size: 18px; + font-weight: normal; + padding: 7px 0 10px; +} + +.popup-fieldset-title .actions { + float: right; +} + +.packaging-window select { + margin-bottom: 0; +} + +.packaging-window .col-width, +.packaging-window .col-height, +.packaging-window .col-length, +.packaging-window .data-table .col-total-weight input[type="text"] { + width: 60px; +} + +.packaging-window .col-total-weight { + white-space: nowrap; + width: 100px; +} + +.packaging-window .col-signature { + width: 160px; +} + +.packaging-window .data-table .col-actions, +.packaging-window .col-total-weight { + white-space: nowrap; +} + +.packaging-window .data-table .action-delete { + margin: 5px 0 0 5px; +} + +.packaging-window .grid tr th { + border-bottom: 1px solid #c9c2b8; +} + +.packaging-window .grid tr th:first-child, +.packaging-window .grid td:first-child, +.packaging-window .grid td:last-child { + border-left: 0; + border-right: 0; +} + +.packaging-window .data-table .col-qty-edit { + white-space: nowrap; + width: 50px; +} + +.packaging-window .data-table .col-qty-edit input[type="text"] { + width: 50px; +} + +.sp-methods > dt { + font-weight: bold; +} + +.sp-methods > dd { + margin: 5px 0 5px 15px; +} + +.sp-methods > dd > ul { + list-style: none; + padding: 0; +} + +[class^=" adminhtml-sales-order-"] .order-billing-address .packaging-window .actions, +[class^=" adminhtml-sales-order-"] .order-shipping-address .packaging-window .actions { + margin: 0; +} + +/* + Popup Configuration Popup +-------------------------------------- */ +#product_composite_configure_messages { + margin-left: 0 !important; + padding: 10px 15px; +} + +.rma-popup, .cms-popup { + background: #fff; + box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4); + cursor: default; + position: fixed; + left: 50%; + top: 50%; + z-index: 1000; +} + +.rma-popup { + width: 540px; + margin: 0 0 0 -271px; +} + +.rma-popup .entry-edit .fieldset { + border: none; +} + +.rma-popup .validation-advice, +.rma-popup label.mage-error { + margin-left: 0; +} + +.rma-popup .content { + background: #fff; + border-bottom: 1px solid #ccc; + max-height: 400px; + overflow: auto; +} + +.rma-popup .content .grid { + padding: 0; +} + +.rma-popup .content .grid table { + border-bottom: 1px solid #cbd3d4; +} + +.rma-popup .product-options { + border-bottom: 1px solid #e7e7e7; + margin: 0 0 15px; + padding: 0 0 12px; +} + +.rma-popup .product-options .required { + color: #333 !important; + font-weight: normal !important; +} + +.rma-popup .product-options .required em { + color: #d40707; +} + +.rma-popup .last-fieldset .product-options { + border: 0 none; + margin-bottom: 0; + padding-bottom: 0; +} + +.rma-popup .buttons-set { + text-align: right; + margin: 0; + overflow: hidden; + padding: 7px 10px 8px; +} + +.rma-popup .buttons-set { + width: 518px; +} + +.cms-popup .buttons-set { + width: 289px; +} + +.rma-popup .buttons-set button { + margin: 0 0 0 5px; +} + +.grid .rma-popup .form-list tr, +.grid tr.even .rma-popup .form-list tr, +.grid tr.on-mouse .rma-popup .form-list tr { + background: #fff !important; +} + +.adminhtml-giftwrapping-edit .field-image .control { + line-height: 28px; +} + +.adminhtml-giftwrapping-edit .field-image a { + display: inline-block; + margin: 0 5px 0 0; +} + +.adminhtml-giftwrapping-edit .field-image img { + vertical-align: middle; +} + +.adminhtml-giftwrapping-new .field-image .input-file, +.adminhtml-giftwrapping-edit .field-image .input-file { + display: inline-block; + margin: 0 15px 0 0; + width: auto; +} + +.adminhtml-giftwrapping-new .field-image .addafter, +.adminhtml-giftwrapping-edit .field-image .addafter { + border: 0; + box-shadow: none; + display: inline-block; + margin: 0 15px 0 0; + height: auto; + width: auto; +} + +.adminhtml-giftwrapping-new .field-image .delete-image, +.adminhtml-giftwrapping-edit .field-image .delete-image { + display: inline-block; + white-space: nowrap; +} + +.adminhtml-giftwrapping-edit .field-image .delete-image input { + margin: -3px 5px 0 0; + width: auto; + display: inline-block; +} + +.adminhtml-giftwrapping-edit .field-image .addon .delete-image input:focus + label { + border: 0; + box-shadow: none; +} + +.adminhtml-giftwrapping-edit .store-switcher { + float: left; + position: relative; + bottom: -14px; +} + /* Clearfix -------------------------------------- */ +.order-gift-options:before, +.order-gift-options:after, +.image-panel:before, +.image-panel:after, .images:before, .images:after, +.tax-rate-popup .field:before, +.tax-rate-popup .field:after, .clearfix:before, .clearfix:after { content: ""; display: table; } +.order-gift-options:after, +.image-panel:after, .images:after, +.tax-rate-popup .field:after, .clearfix:after { clear: both; } diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansBlack-webfont.eot b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansBlack-webfont.eot similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansBlack-webfont.eot rename to app/design/adminhtml/default/backend/fonts/calluna/CallunaSansBlack-webfont.eot diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBlack-webfont.svg b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansBlack-webfont.svg old mode 100755 new mode 100644 similarity index 99% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBlack-webfont.svg rename to app/design/adminhtml/default/backend/fonts/calluna/CallunaSansBlack-webfont.svg index 2e269097b5199..6c5ffea8d6a92 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBlack-webfont.svg +++ b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansBlack-webfont.svg @@ -1,244 +1,244 @@ - - - - -This is a custom SVG webfont generated by Fontspring. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + +This is a custom SVG webfont generated by Fontspring. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansBlack-webfont.ttf b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansBlack-webfont.ttf similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansBlack-webfont.ttf rename to app/design/adminhtml/default/backend/fonts/calluna/CallunaSansBlack-webfont.ttf diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansBlack-webfont.woff b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansBlack-webfont.woff similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansBlack-webfont.woff rename to app/design/adminhtml/default/backend/fonts/calluna/CallunaSansBlack-webfont.woff diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansBold-webfont.eot b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansBold-webfont.eot similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansBold-webfont.eot rename to app/design/adminhtml/default/backend/fonts/calluna/CallunaSansBold-webfont.eot diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBold-webfont.svg b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansBold-webfont.svg old mode 100755 new mode 100644 similarity index 99% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBold-webfont.svg rename to app/design/adminhtml/default/backend/fonts/calluna/CallunaSansBold-webfont.svg index d21027074de70..7c25c81683259 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansBold-webfont.svg +++ b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansBold-webfont.svg @@ -1,244 +1,244 @@ - - - - -This is a custom SVG webfont generated by Fontspring. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + +This is a custom SVG webfont generated by Fontspring. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansBold-webfont.ttf b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansBold-webfont.ttf similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansBold-webfont.ttf rename to app/design/adminhtml/default/backend/fonts/calluna/CallunaSansBold-webfont.ttf diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansBold-webfont.woff b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansBold-webfont.woff similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansBold-webfont.woff rename to app/design/adminhtml/default/backend/fonts/calluna/CallunaSansBold-webfont.woff diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansLight-webfont.eot b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansLight-webfont.eot similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansLight-webfont.eot rename to app/design/adminhtml/default/backend/fonts/calluna/CallunaSansLight-webfont.eot diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansLight-webfont.svg b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansLight-webfont.svg old mode 100755 new mode 100644 similarity index 99% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansLight-webfont.svg rename to app/design/adminhtml/default/backend/fonts/calluna/CallunaSansLight-webfont.svg index 6d39d5257985e..616b462d13547 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansLight-webfont.svg +++ b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansLight-webfont.svg @@ -1,244 +1,244 @@ - - - - -This is a custom SVG webfont generated by Fontspring. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + +This is a custom SVG webfont generated by Fontspring. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansLight-webfont.ttf b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansLight-webfont.ttf similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansLight-webfont.ttf rename to app/design/adminhtml/default/backend/fonts/calluna/CallunaSansLight-webfont.ttf diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansLight-webfont.woff b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansLight-webfont.woff similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansLight-webfont.woff rename to app/design/adminhtml/default/backend/fonts/calluna/CallunaSansLight-webfont.woff diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansRegular-webfont.eot b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansRegular-webfont.eot similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansRegular-webfont.eot rename to app/design/adminhtml/default/backend/fonts/calluna/CallunaSansRegular-webfont.eot diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansRegular-webfont.svg b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansRegular-webfont.svg old mode 100755 new mode 100644 similarity index 99% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansRegular-webfont.svg rename to app/design/adminhtml/default/backend/fonts/calluna/CallunaSansRegular-webfont.svg index 19d66bb96d160..6fd374788dfd5 --- a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansRegular-webfont.svg +++ b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansRegular-webfont.svg @@ -1,244 +1,244 @@ - - - - -This is a custom SVG webfont generated by Fontspring. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + +This is a custom SVG webfont generated by Fontspring. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansRegular-webfont.ttf b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansRegular-webfont.ttf similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansRegular-webfont.ttf rename to app/design/adminhtml/default/backend/fonts/calluna/CallunaSansRegular-webfont.ttf diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansRegular-webfont.woff b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansRegular-webfont.woff similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansRegular-webfont.woff rename to app/design/adminhtml/default/backend/fonts/calluna/CallunaSansRegular-webfont.woff diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansSemiBold-webfont.eot b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansSemiBold-webfont.eot similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansSemiBold-webfont.eot rename to app/design/adminhtml/default/backend/fonts/calluna/CallunaSansSemiBold-webfont.eot diff --git a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansSemiBold-webfont.svg b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansSemiBold-webfont.svg old mode 100755 new mode 100644 similarity index 99% rename from app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansSemiBold-webfont.svg rename to app/design/adminhtml/default/backend/fonts/calluna/CallunaSansSemiBold-webfont.svg index ef1eaf6677446..3cee70eab9e0f --- a/app/code/core/Mage/DesignEditor/view/adminhtml/css/fonts/calluna/CallunaSansSemiBold-webfont.svg +++ b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansSemiBold-webfont.svg @@ -1,243 +1,243 @@ - - - - -This is a custom SVG webfont generated by Fontspring. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + +This is a custom SVG webfont generated by Fontspring. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansSemiBold-webfont.ttf b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansSemiBold-webfont.ttf similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansSemiBold-webfont.ttf rename to app/design/adminhtml/default/backend/fonts/calluna/CallunaSansSemiBold-webfont.ttf diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansSemiBold-webfont.woff b/app/design/adminhtml/default/backend/fonts/calluna/CallunaSansSemiBold-webfont.woff similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/calluna/CallunaSansSemiBold-webfont.woff rename to app/design/adminhtml/default/backend/fonts/calluna/CallunaSansSemiBold-webfont.woff diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/icons/admin-icons.eot b/app/design/adminhtml/default/backend/fonts/icons/admin-icons.eot similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/icons/admin-icons.eot rename to app/design/adminhtml/default/backend/fonts/icons/admin-icons.eot diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/icons/admin-icons.svg b/app/design/adminhtml/default/backend/fonts/icons/admin-icons.svg similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/icons/admin-icons.svg rename to app/design/adminhtml/default/backend/fonts/icons/admin-icons.svg diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/icons/admin-icons.ttf b/app/design/adminhtml/default/backend/fonts/icons/admin-icons.ttf similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/icons/admin-icons.ttf rename to app/design/adminhtml/default/backend/fonts/icons/admin-icons.ttf diff --git a/app/design/adminhtml/default/backend/Mage_Backend/fonts/icons/admin-icons.woff b/app/design/adminhtml/default/backend/fonts/icons/admin-icons.woff similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/fonts/icons/admin-icons.woff rename to app/design/adminhtml/default/backend/fonts/icons/admin-icons.woff diff --git a/app/design/adminhtml/default/backend/Mage_Backend/images/body-bg.jpg b/app/design/adminhtml/default/backend/images/body-bg.jpg similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/images/body-bg.jpg rename to app/design/adminhtml/default/backend/images/body-bg.jpg diff --git a/app/design/adminhtml/default/backend/images/fam_application_form_delete.png b/app/design/adminhtml/default/backend/images/fam_application_form_delete.png new file mode 100644 index 0000000000000..cd305ec83b6a7 Binary files /dev/null and b/app/design/adminhtml/default/backend/images/fam_application_form_delete.png differ diff --git a/app/design/adminhtml/default/backend/images/fam_leaf.png b/app/design/adminhtml/default/backend/images/fam_leaf.png new file mode 100644 index 0000000000000..9cd988dfb177b Binary files /dev/null and b/app/design/adminhtml/default/backend/images/fam_leaf.png differ diff --git a/app/design/adminhtml/default/backend/Mage_Backend/images/switcher.png b/app/design/adminhtml/default/backend/images/switcher.png similarity index 100% rename from app/design/adminhtml/default/backend/Mage_Backend/images/switcher.png rename to app/design/adminhtml/default/backend/images/switcher.png diff --git a/app/design/adminhtml/default/backend/js/theme.js b/app/design/adminhtml/default/backend/js/theme.js index 3ffea830977b1..3910f3731e784 100644 --- a/app/design/adminhtml/default/backend/js/theme.js +++ b/app/design/adminhtml/default/backend/js/theme.js @@ -93,53 +93,76 @@ $.widget('mage.globalNavigation', { options: { menuCategory: '.level-0.parent', - menuLinks: 'a' + menuLinks: 'a', + itemsConfig: null, + hoverIntentConfig: { + interval: 100, + timeout: 700 // number = milliseconds delay before onMouseOut + } }, _create: function() { this.menu = this.element; this.menuCategory = $(this.options.menuCategory, this.menu); this.menuLinks = $(this.options.menuLinks, this.menuCategory); - - this._events(); + this._bind(); }, - _events: function() { - var self = this; - - var config = { - interval: 100, - over: self._hoverEffects, // function = onMouseOver callback (REQUIRED) - timeout: 700, // number = milliseconds delay before onMouseOut - out: self._leaveEffects // function = onMouseOut callback (REQUIRED) - }; - - this.menuCategory - .hoverIntent(config) + _menuCategoryBind: function(category, config) { + category + .hoverIntent($.extend({}, this.options.hoverIntentConfig, { + over: !config.open ? this._hoverEffects : $.noop, + out: !config.close ? this._leaveEffects : $.noop + })) .on('hover', function() { $(this) - .addClass('recent') - .siblings('.level-0') - .removeClass('recent'); -/* $(this) + .addClass('recent') .siblings('.level-0') - .removeClass('hover') - .find('> .submenu') - .hide();*/ + .removeClass('recent'); + /* $(this) + .siblings('.level-0') + .removeClass('hover') + .find('> .submenu') + .hide();*/ }); + if (config.open) { + category.on(config.open, this._hoverEffects); + } + if (config.close) { + category.on(config.close, this._leaveEffects); + } + }, + + _menuCategoryEvents: function() { + this.menuCategory.each($.proxy(function(i, category) { + var itemConfig = {}; + if (this.options.categoriesConfig) { + $.each(this.options.categoriesConfig, $.proxy(function(selector, conf) { + if ($(category).is(selector)) { + itemConfig = conf; + } + }, this)); + } + this._menuCategoryBind($(category), itemConfig); + }, this)); + }, + _bind: function() { + this._menuCategoryEvents(); this.menuLinks - .on('focus.tabFocus', function() { - $(this).closest('.level-0.parent') - .trigger('mouseenter'); + .on('focus.tabFocus', function(e) { + $(e.target).trigger('mouseenter'); }) - .on('blur.tabFocus', function() { - $(this).closest('.level-0.parent') - .trigger('mouseleave'); + .on('blur.tabFocus', function(e) { + $(e.target).trigger('mouseleave'); }); }, - _hoverEffects: function () { + _hoverEffects: function (e) { + var targetSubmenu = $(e.target).closest('.submenu'); + if(targetSubmenu.length && targetSubmenu.is(':visible')) { + return; + } var availableWidth = parseInt($(this).parent().css('width')) - $(this).position().left, submenu = $('> .submenu', this), colsWidth = 0; @@ -165,7 +188,11 @@ .slideDown('fast'); }, - _leaveEffects: function () { + _leaveEffects: function (e) { + var targetSubmenu = $(e.target).closest('.submenu'); + if(targetSubmenu.length && targetSubmenu.is(':hidden')) { + return; + } var self = $(this); $('> .submenu', this) @@ -178,13 +205,15 @@ $.widget('mage.modalPopup', { options: { popup: '.popup', - btnClose: '[data-dismiss="popup"]' + btnDismiss: '[data-dismiss="popup"]', + btnHide: '[data-hide="popup"]' }, _create: function() { this.fade = this.element; this.popup = $(this.options.popup, this.fade); - this.btnClose = $(this.options.btnClose, this.popup); + this.btnDismiss = $(this.options.btnDismiss, this.popup); + this.btnHide = $(this.options.btnHide, this.popup); this._events(); }, @@ -192,10 +221,15 @@ _events: function() { var self = this; - this.btnClose - .on('click.closeModalPopup', function() { + this.btnDismiss + .on('click.dismissModalPopup', function() { self.fade.remove(); }); + + this.btnHide + .on('click.hideModalPopup', function() { + self.fade.hide(); + }); } }); @@ -341,23 +375,25 @@ var switcherForIe8 = function() { /* Switcher for IE8 */ if ($.browser.msie && $.browser.version == '8.0') { - var checkboxSwitcher = $('.switcher input'); - - var toggleCheckboxState = function(elem) { - elem.toggleClass('checked', elem.prop('checked')); - }; - toggleCheckboxState(checkboxSwitcher); - - $('.switcher') + $('.switcher input') .on('change.toggleSwitcher', function() { - toggleCheckboxState(checkboxSwitcher); - }); + $(this) + .closest('.switcher') + .toggleClass('checked', $(this).prop('checked')); + }) + .trigger('change'); } }; $(document).ready(function() { $('.header-panel .search').globalSearch(); - $('.navigation').globalNavigation(); + $('.navigation').globalNavigation({ + categoriesConfig: { + '[data-ui-id="menu-mage-adminhtml-system"]': { + open: 'click' + } + } + }); $('.fade').modalPopup(); $('details').details(); $('.page-actions').floatingHeader(); @@ -368,6 +404,34 @@ $('.collapse:first', entry).collapse('show'); }); + // TODO: Move to VDE js widjets + $.each($('.color-box'), function(index, elem) { + $(elem).farbtastic(function(color) { + $(elem).css({ + 'backgroundColor': color + }); + $(elem).siblings('input').val(color); + }); + }); + + $('.element-color-picker input') + .on('blur', function() { + $(this).siblings('.color-box') + .removeClass('active') + .find('.farbtastic').hide(); + $(this).trigger('change.quickStyleElement'); + }); + + $('.color-box') + .on('click.showColorPicker', function() { + $(this) + .addClass('active') + .siblings('input').focus(); + $(this) + .find('.farbtastic') + .show(); + }); + switcherForIe8(); }); @@ -375,4 +439,4 @@ $('details').details(); switcherForIe8(); }); -})(window.jQuery); \ No newline at end of file +})(window.jQuery); diff --git a/app/design/adminhtml/default/backend/local.xml b/app/design/adminhtml/default/backend/local.xml index 7e39e80d11c13..505ce41d611d5 100644 --- a/app/design/adminhtml/default/backend/local.xml +++ b/app/design/adminhtml/default/backend/local.xml @@ -34,6 +34,7 @@ mui/form.css mui/components.css css/admin.css + jquery/farbtastic/css/farbtastic.css css/header.css css/pages.css mui/utils.css @@ -46,6 +47,7 @@ js/head.js jquery/jquery.dropdowns.js jquery/jquery.tabs.js + jquery/farbtastic/jquery.farbtastic.js js/theme.js js/jquery.details.js diff --git a/app/design/adminhtml/default/backend/mui/elements.css b/app/design/adminhtml/default/backend/mui/elements.css index 1eb6172f2b17b..77ffa0f173b91 100644 --- a/app/design/adminhtml/default/backend/mui/elements.css +++ b/app/design/adminhtml/default/backend/mui/elements.css @@ -39,20 +39,35 @@ line-height: 1.1; } -.tooltip .help:before { - content: "?"; - font: 11px/12px bold Arial, Verdana, sans-serif; +.tooltip .help { display: inline-block; - text-decoration: inherit; - vertical-align: top; - color: #fff; + position: relative; + margin: 7px 0 0 15px; +} + +.tooltip .help a { + display: block; + width: 14px; + height: 14px; + text-decoration: none; + text-indent: -999em; + cursor: help; +} + +.tooltip .help a:before { + position: absolute; + top: 0; + left: 0; + text-indent: 0; + font: 11px/11px bold Arial, Verdana, sans-serif; + text-align: center; + color: #aaa; height: 12px; width: 12px; - background: #666; - border-radius: 6px; - text-align: center; - text-shadow: none; - margin-right: 3px; + background: #fff; + border: 1px #aaa solid; + border-radius: 7px; + content: "?"; } .tooltip-content { @@ -95,15 +110,6 @@ z-index: 20; } -.tooltip > .help { - cursor: help; - display: inline-block; - vertical-align: top; - height: 12px; - line-height: 12px; - color: #666; -} - .tooltip:hover > .tooltip-content { display: block; } @@ -866,7 +872,7 @@ top: 50%; left: 50%; margin: -12px 0 0 -12px; - background: url(images/ajax-loader.gif) no-repeat center; + background: #fff url(images/ajax-loader.gif) no-repeat center; } .loading-message { @@ -1028,7 +1034,7 @@ table.loading:after { z-index: 999; } -.ie8 .fade { +.eq-ie8 .fade { background: transparent; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = #99000000, endColorstr = #99000000); } diff --git a/app/design/adminhtml/default/backend/mui/form.css b/app/design/adminhtml/default/backend/mui/form.css index f2f764396e222..b710de54814ba 100644 --- a/app/design/adminhtml/default/backend/mui/form.css +++ b/app/design/adminhtml/default/backend/mui/form.css @@ -137,13 +137,17 @@ span.required { .addon textarea, .addon select, .addon input { - display: table-cell; width: 100%; border-radius: 0; box-shadow: none; margin: 0; } +.ie .addon textarea, +.ie .addon select { + display:inline-block; +} + .addon textarea:first-child, .addon select:first-child, .addon input:first-child, @@ -218,30 +222,6 @@ span.required { border-radius: 0 4px 4px 0; } -.field-price .addon input:focus { - -} - -.field-price .addon .addafter { - /*background: none;*/ -} - -.field-price .addon .addafter:after { - -} - -.field-price .addon .addafter strong { - -} - -.field-price .addon input { - /*border-left: none;*/ -} - -.field-price .addon input:focus + .addafter { - -} - /* Field with note -------------------------------------- */ @@ -354,7 +334,7 @@ span.required { .control .control-value { display: inline-block; - padding: 5px 0 0; + padding: 6px 0 0; vertical-align: top; } @@ -449,7 +429,7 @@ span.required { } .control *:first-child { - margin-top: 0; + /*margin-top: 0;*/ } .nested .field { diff --git a/app/design/adminhtml/default/backend/mui/reset.css b/app/design/adminhtml/default/backend/mui/reset.css index f50fa69e596f5..863744d853c8f 100644 --- a/app/design/adminhtml/default/backend/mui/reset.css +++ b/app/design/adminhtml/default/backend/mui/reset.css @@ -384,8 +384,7 @@ input[type="submit"] { * Re-set default cursor for disabled elements. */ -button[disabled], -html input[disabled] { +button[disabled] { cursor: default; } diff --git a/app/design/adminhtml/default/backend/theme.xml b/app/design/adminhtml/default/backend/theme.xml index 2315d4040904f..08538d8d1357a 100644 --- a/app/design/adminhtml/default/backend/theme.xml +++ b/app/design/adminhtml/default/backend/theme.xml @@ -27,7 +27,7 @@ Backend - + Magento 2 backend diff --git a/app/design/adminhtml/default/basic/boxes.css b/app/design/adminhtml/default/basic/boxes.css index 7e53ce07335d1..3c7179d76bb10 100644 --- a/app/design/adminhtml/default/basic/boxes.css +++ b/app/design/adminhtml/default/basic/boxes.css @@ -349,6 +349,7 @@ table.form-edit { width:100%; } .entry-edit .entry-edit-head .tools { float:right;} .entry-edit .entry-edit-head strong, .entry-edit .entry-edit-head a { color:#fff; font-size:1em; line-height:18px; min-height:0; font-weight:bold} +.entry-edit .entry-edit-head .entry-edit-head-link {height:41px; margin:-41px 0 0; position: absolute; visibility: hidden;} .entry-edit .content { margin-left:0 !important; padding:10px 15px; } .entry-edit fieldset li, .entry-edit .fieldset li { margin:4px 0; } @@ -889,9 +890,9 @@ div.autocomplete ul li { padding:.5em .7em; min-height:32px; cursor:pointer; tex z-index: 1; } .mage-suggest.category-select .mage-suggest-inner {background: transparent; position: static; border: none; border-radius: 0px; box-shadow: none;} -.mage-suggest.category-select .category-selector-choices {background: #fff; border: 1px solid #ddd; border-radius: 5px; box-shadow: none; overflow: hidden;} -.mage-suggest.category-select .category-selector-choices li {float: left; margin: 5px 0 5px 7px;} -.mage-suggest.category-select .category-selector-search-field input { +.mage-suggest.category-select .mage-suggest-choices {background: #fff; border: 1px solid #ddd; border-radius: 5px; box-shadow: none; overflow: hidden;} +.mage-suggest.category-select .mage-suggest-choices li {float: left; margin: 5px 0 5px 7px;} +.mage-suggest.category-select .mage-suggest-search-field input { background: none repeat scroll 0 0 transparent !important; border: 0 none; box-shadow: none; diff --git a/app/design/frontend/default/blank/css/styles.css b/app/design/frontend/default/blank/css/styles.css index e8aa9c765a210..2503f58aae4d8 100644 --- a/app/design/frontend/default/blank/css/styles.css +++ b/app/design/frontend/default/blank/css/styles.css @@ -1031,7 +1031,7 @@ tr.summary-details-excluded { font-style:italic; } /*.opc .active .step-title a { display:none; }*/ .opc .step { border-top:1px solid #ddd; padding:10px; position:relative; } -.opc .step .tool-tip { right:10px; } +.opc .step .tool-tip { right:0; bottom: 0; margin: 0 0 30px 0; } .opc .order-review {} .opc .order-review .authentication {} @@ -1043,7 +1043,7 @@ tr.summary-details-excluded { font-style:italic; } .checkout-progress li.active { border-top-color:#000; color:#000; } .multiple-checkout { position:relative; } -.multiple-checkout .tool-tip { top:50%; margin-top:-120px; right:10px; } +.multiple-checkout .tool-tip { top:50%; margin-top:-70px; right:10px; } .multiple-checkout .grand-total { font-size:1.5em; text-align:right; } .multiple-checkout .grand-total big {} .multiple-checkout .grand-total .price {} diff --git a/app/design/frontend/default/demo/css/styles.css b/app/design/frontend/default/demo/css/styles.css index 8aa0e2fdd399d..3555df2486ed5 100644 --- a/app/design/frontend/default/demo/css/styles.css +++ b/app/design/frontend/default/demo/css/styles.css @@ -1256,7 +1256,7 @@ tr.summary-details-excluded { font-style:italic; } .sp-methods { margin:0 0 8px; } .sp-methods dt { margin:13px 0 5px; font-weight:bold; } .sp-methods dd {} -.sp-methods dd li { margin:5px 0; } +.sp-methods dd li { margin:5px 0; position: relative;} .sp-methods label { font-weight:bold; color:#666; } .sp-methods .price { font-weight:bold; } .sp-methods .form-list { padding-left:20px; } @@ -1387,7 +1387,7 @@ tr.summary-details-excluded { font-style:italic; } /*.opc .active .step-title a { display:none; }*/ .opc .step { border:1px solid #bbafa0; border-top:0; background:#fbfaf6 url(../images/bkg_checkout.gif) 0 0 repeat-x; padding:15px 30px; position:relative; } -.opc .step .tool-tip { right:30px; } +.opc .step .tool-tip { right:20px; bottom: 0; margin: 0 0 30px 0; } #opc-login .buttons-set { border-top:0; } #opc-login h3 { font-size:13px; border-bottom:1px solid #e4e4e4; padding-bottom:2px; text-transform:uppercase; } @@ -1423,7 +1423,7 @@ tr.summary-details-excluded { font-style:italic; } .multiple-checkout .gift-messages { margin:15px 0 0; } -.multiple-checkout .tool-tip { top:50%; margin-top:-120px; right:20px; } +.multiple-checkout .tool-tip { top:50%; margin-top:-230px; right:20px; } .multiple-checkout .col2-set, .multiple-checkout .col3-set { background:#fbfaf6 url(../images/bkg_checkout.gif) 0 0 repeat-x; border:1px solid #bbb6a5; margin:0 0 25px; padding:20px; } diff --git a/app/design/frontend/default/demo_blue/css/styles.css b/app/design/frontend/default/demo_blue/css/styles.css index ed756d7f9dd4a..210d90a432377 100644 --- a/app/design/frontend/default/demo_blue/css/styles.css +++ b/app/design/frontend/default/demo_blue/css/styles.css @@ -31,7 +31,7 @@ body { background:#4c697b url(../images/bkg_body.gif) 0 0 repeat-x; fon img { border:0; vertical-align:top; } -a,.l { color:#1e7ec8; text-decoration:underline; } +a { color:#1e7ec8; text-decoration:underline; } a:hover { text-decoration:none; } :focus { outline:0; } @@ -1217,7 +1217,7 @@ std ul, .sp-methods { margin:0 0 8px; } .sp-methods dt { margin:13px 0 5px; font-weight:bold; } .sp-methods dd {} -.sp-methods dd li { margin:5px 0; } +.sp-methods dd li { margin:5px 0; position: relative;} .sp-methods label { font-weight:bold; color:#666; } .sp-methods .price { font-weight:bold; } .sp-methods .form-list { padding-left:20px; } @@ -1348,7 +1348,7 @@ std ul, /*.opc .active .step-title a { display:none; }*/ .opc .step { border:1px solid #bbafa0; border-top:0; background:#fbfaf6 url(../images/bkg_checkout.gif) 0 0 repeat-x; padding:15px 30px; position:relative; } -.opc .step .tool-tip { right:30px; } +.opc .step .tool-tip { right:20px; bottom: 0; margin: 0 0 30px 0; } #opc-login .buttons-set { border-top:0; } #opc-login h3 { font-size:13px; border-bottom:1px solid #e4e4e4; padding-bottom:2px; text-transform:uppercase; } @@ -1384,7 +1384,7 @@ std ul, .multiple-checkout .gift-messages { margin:15px 0 0; } -.multiple-checkout .tool-tip { top:50%; margin-top:-120px; right:20px; } +.multiple-checkout .tool-tip { top:50%; margin-top:-230px; right:20px; } .multiple-checkout .col2-set, .multiple-checkout .col3-set { background:#fbfaf6 url(../images/bkg_checkout.gif) 0 0 repeat-x; border:1px solid #bbb6a5; margin:0 0 25px; padding:20px; } diff --git a/app/design/frontend/default/modern/Mage_Catalog/layout.xml b/app/design/frontend/default/modern/Mage_Catalog/layout.xml index a6be4c7d61cbe..455e4c8efd442 100644 --- a/app/design/frontend/default/modern/Mage_Catalog/layout.xml +++ b/app/design/frontend/default/modern/Mage_Catalog/layout.xml @@ -145,7 +145,6 @@ Compare products page scriptaculous/scriptaculous.js - varien/product.js @@ -163,8 +162,6 @@ Product view - varien/product.js - varien/configurable.js Mage_Catalog::zoom.css diff --git a/app/design/frontend/default/modern/Mage_Catalog/product/view/media.phtml b/app/design/frontend/default/modern/Mage_Catalog/product/view/media.phtml index 2304220d2afd6..46e31d6a32944 100644 --- a/app/design/frontend/default/modern/Mage_Catalog/product/view/media.phtml +++ b/app/design/frontend/default/modern/Mage_Catalog/product/view/media.phtml @@ -50,18 +50,14 @@ <?php echo $this->__('Zoom In') ?>

    @@ -78,16 +74,9 @@ getBaseImageIconSize()?> getGalleryImages() as $_image): ?>

  • - <?php echo $this->escapeHtml($_image->getLabel()) ?> + <?php echo $this->escapeHtml($_image->getLabel()) ?>
  • - diff --git a/app/design/frontend/default/modern/Mage_Checkout/layout.xml b/app/design/frontend/default/modern/Mage_Checkout/layout.xml index 438f22aac7edd..9062c12ec01ed 100644 --- a/app/design/frontend/default/modern/Mage_Checkout/layout.xml +++ b/app/design/frontend/default/modern/Mage_Checkout/layout.xml @@ -46,11 +46,14 @@ Default layout, loads most of the pages groupedMage_Checkout_Block_Cart_Item_Renderer_Grouped configurableMage_Checkout_Block_Cart_Item_Renderer_Configurable + + - - - + + + + diff --git a/app/design/frontend/default/modern/Mage_Page/layout.xml b/app/design/frontend/default/modern/Mage_Page/layout.xml index aaebc99fffd19..3b87652d356df 100644 --- a/app/design/frontend/default/modern/Mage_Page/layout.xml +++ b/app/design/frontend/default/modern/Mage_Page/layout.xml @@ -35,7 +35,7 @@ Default layout, loads most of the pages - jquery/jquery.min.js + jquery/jquery.js mage/jquery-no-conflict.js prototype/prototype.js lib/ccard.js @@ -92,7 +92,7 @@ Default layout, loads most of the pages - jquery/jquery.min.js + jquery/jquery.js mage/jquery-no-conflict.js prototype/prototype.js mage/translate.js diff --git a/app/design/frontend/default/modern/Mage_Review/layout.xml b/app/design/frontend/default/modern/Mage_Review/layout.xml index 071186dce36c5..aa8420a381a2f 100644 --- a/app/design/frontend/default/modern/Mage_Review/layout.xml +++ b/app/design/frontend/default/modern/Mage_Review/layout.xml @@ -60,8 +60,7 @@ Product reviews page - varien/product.js - varien/configurable.js + Mage_Catalog::zoom.css diff --git a/app/design/frontend/default/modern/Mage_Sendfriend/layout.xml b/app/design/frontend/default/modern/Mage_Sendfriend/layout.xml index 34eb32944024c..609e209120ad1 100644 --- a/app/design/frontend/default/modern/Mage_Sendfriend/layout.xml +++ b/app/design/frontend/default/modern/Mage_Sendfriend/layout.xml @@ -31,9 +31,6 @@ - - varien/product.js - diff --git a/app/design/frontend/default/modern/css/styles.css b/app/design/frontend/default/modern/css/styles.css index ebd4fb10e95dc..a4c4d8bd8a30e 100644 --- a/app/design/frontend/default/modern/css/styles.css +++ b/app/design/frontend/default/modern/css/styles.css @@ -1207,7 +1207,7 @@ tr.summary-details-excluded { font-style:italic; } .sp-methods { margin:0 0 8px; } .sp-methods dt { margin:13px 0 5px; font-weight:bold; } .sp-methods dd {} -.sp-methods dd li { margin:5px 0; } +.sp-methods dd li { margin:5px 0; position: relative;} .sp-methods label { font-weight:bold; color:#555; } .sp-methods .price { font-weight:bold; } .sp-methods .form-list { padding-left:20px; } @@ -1338,7 +1338,7 @@ tr.summary-details-excluded { font-style:italic; } .opc .active .step-title a { display:none; } .opc .step { border:1px solid #ddd; border-top:0; background:#fbfbfb; padding:15px 30px; position:relative; } -.opc .step .tool-tip { right:30px; } +.opc .step .tool-tip { right:20px; bottom: 0; margin: 0 0 30px 0; } #opc-login h3 { font-size:13px; border-bottom:1px solid #e4e4e4; padding-bottom:2px; text-transform:uppercase; } #opc-login h4 { font-size:1em; font-weight:bold; margin:0; color:#2f2f2f; } @@ -1373,7 +1373,7 @@ tr.summary-details-excluded { font-style:italic; } .multiple-checkout .gift-messages { margin:15px 0 0; } -.multiple-checkout .tool-tip { top:50%; margin-top:-120px; right:20px; } +.multiple-checkout .tool-tip { top:50%; margin-top:-230px; right:20px; } .multiple-checkout .col2-set, .multiple-checkout .col3-set { background:#fbfbfb; border:1px solid #ddd; margin:0 0 25px; padding:20px; } diff --git a/app/design/frontend/default/twig_tmpls/Mage_Catalog_View_Media.html b/app/design/frontend/default/twig_tmpls/Mage_Catalog_View_Media.html new file mode 100644 index 0000000000000..1097d71ce1cb1 --- /dev/null +++ b/app/design/frontend/default/twig_tmpls/Mage_Catalog_View_Media.html @@ -0,0 +1,40 @@ +{% if this.product.image != 'no_selection' and this.product.image %} +

    + {% set img = '' ~ this.escapeHtml(this.imageLabel()) ~ '' %} + {{ helperOutput.productAttribute(this.product, img, 'image') | raw }} +

    +

    {{ this.__('Double click on above image to view full picture') }}

    +
    + {{ this.__('Zoom Out') }} +
    + {{ this.__('Zoom In') }} +
    + +{% else %} +

    + {% set img = '' ~ this.escapeHtml(this.imageLabel) ~ '' %} + {{ helperOutput.productAttribute(this.product, img, 'image') | raw }} +

    +{% endif %} +{% if this.galleryImages is not empty %} +
    +

    {{ this.__('More Views') }}

    +
      + {% set size = this.baseImageIconSize() %} + {% for image in this.galleryImages %} +
    • + {{ this.escapeHtml(image.label) }} +
    • + {% endfor %} +
    +
    +{% endif %} diff --git a/app/design/frontend/default/twig_tmpls/Mage_Catalog_View_Type_Default.html b/app/design/frontend/default/twig_tmpls/Mage_Catalog_View_Type_Default.html new file mode 100644 index 0000000000000..7386a6a03a2bf --- /dev/null +++ b/app/design/frontend/default/twig_tmpls/Mage_Catalog_View_Type_Default.html @@ -0,0 +1,9 @@ +{% if this.displayProductStockStatus() %} + {% if this.product.available %} +

    {{ this.__('Availability:') }} {{ this.__('In stock') }}

    + {% else %} +

    {{ this.__('Availability:') }} {{ this.__('Out of stock') }}

    + {%endif %} +{% endif %} +{{ this.getChildHtml('product_type_data_extra') }} +{{ this.getPriceHtml(this.product) | raw }} diff --git a/app/etc/config.xml b/app/etc/config.xml index 02f4663fd262a..3116edbd54141 100644 --- a/app/etc/config.xml +++ b/app/etc/config.xml @@ -84,6 +84,84 @@ + + Mage_Core_Model_Db_Updater + Mage_Core_Model_App_Proxy + Mage_Core_Model_Config_Invalidator_Proxy + Mage_Core_Model_Cache_Proxy + + + + Mage_Core_Model_Cache_Types_Proxy + Mage_Core_Model_Config_Proxy + + + + + Mage_Core_Model_Config_Storage + + + + + Mage_Core_Model_Config_Cache_Proxy + + + + + Mage_Core_Model_Config_Primary + + + + + Mage_Core_Model_Config_Storage_Locales + + + + + Mage_Core_Model_Config_Storage_Modules + + + + + Mage_Core_Model_Config_Loader_Proxy + + + + + Mage_Core_Model_Config_Loader_Modules_Proxy + + + + + Mage_Core_Model_Config_Loader_Locales_Proxy + + + + + Mage_Core_Model_Config_Modules_Proxy + + + + + Mage_Core_Model_Config_Proxy + + + + + Mage_Core_Model_Config_Primary + Mage_Core_Model_Config_Modules + Mage_Core_Model_Config_Locales + + + + + Magento_Filesystem_Adapter_Local + + 0 + + + Mage_Core_Model_Url + 0 @@ -97,6 +175,14 @@ + + + + Magento_Datasource_Factory + Mage_Core_Model_Datasource_Request_Visitor + + + Mage_Core_Model_Translate_Proxy @@ -107,6 +193,9 @@ Mage_Core_Model_Event_Manager_Proxy + + 0 + diff --git a/composer.json b/composer.json index ce3ee5f9ac4d4..accd389660f02 100644 --- a/composer.json +++ b/composer.json @@ -3,11 +3,11 @@ "description": "eCommerce Platform for Growth (Community Edition)", "license": ["OSL-3.0", "AFL-3.0"], "require": { - "php": ">=5.3.0" + "php": ">=5.3.3" }, "autoload": { "psr-0": { - "": ["app/code/local", "app/code/community", "app/code/core", "lib"] + "": ["app/code", "lib"] } }, "minimum-stability": "dev" diff --git a/dev/api-tests/integration/fixture/_block/Webhook/Webhook.php b/dev/api-tests/integration/fixture/_block/Webhook/Webhook.php new file mode 100644 index 0000000000000..db002b429884a --- /dev/null +++ b/dev/api-tests/integration/fixture/_block/Webhook/Webhook.php @@ -0,0 +1,35 @@ +setName('test service ' . uniqid()) + ->setEndpointUrl('http://testservice.com/endpoint/' . uniqid()) + ->setTopics(array("customer/created", "customer/updated")) + ->setFormat('JSON') + ->setStatus('1') + ->setApiUserId('1'); + +return $webhook; \ No newline at end of file diff --git a/dev/api-tests/integration/phpunit-webhook-rest.xml b/dev/api-tests/integration/phpunit-webhook-rest.xml new file mode 100644 index 0000000000000..628df269124af --- /dev/null +++ b/dev/api-tests/integration/phpunit-webhook-rest.xml @@ -0,0 +1,88 @@ + + + + + + + testsuite/Webapi/Webhook + + + + + + + + ../../app/code/core/Mage + + + ../../app/code/core/Mage/*/sql + + ../../app/code/core/Mage/*/data + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/api-tests/integration/testsuite/Webapi/Webhook/WebhookTest.php b/dev/api-tests/integration/testsuite/Webapi/Webhook/WebhookTest.php new file mode 100644 index 0000000000000..98d9b18b5179c --- /dev/null +++ b/dev/api-tests/integration/testsuite/Webapi/Webhook/WebhookTest.php @@ -0,0 +1,191 @@ +_initWebhook(); + } + + /** + * Init webhook service model instance + * + * @return Webapi_Webhook_WebhookTest + */ + protected function _initWebhook() + { + if (null === $this->_webhook) { + $this->_webhook = require dirname(__FILE__) . '/../../../fixture/_block/Webhook/Webhook.php'; + $this->_webhook->save(); + $this->addModelToDelete($this->_webhook, true); + } + + return $this; + } + + /** + * Test creates WebHook + * + * @resourceOperation xcomMessengerWebhook::create + */ + public function testCreate() + { + $body = array( + 'name' => $this->_randomString(), + 'endpoint_url' => 'http://test.com/endpoint/' . $this->_randomString(), + 'topics' => array("customer/created", "customer/updated","product/deleted", "product/created") + ); + $response = $this->callPost(self::VERSON . '/webhooks', $body); + $this->assertEquals(Mage_Webapi_Controller_Front_Rest::HTTP_CREATED, $response->getStatus()); + $this->assertNotNull($response->getHeader('Location')); + } + + /** + * Test retrieves existing WebHook data + * + * @resourceOperation xcomMessengerWebhook::get + */ + public function testRetrieve() + { + $response = $this->callGet(self::VERSON . '/webhooks/' . $this->_webhook->getId()); + + $this->assertEquals(Mage_Webapi_Controller_Front_Rest::HTTP_OK, $response->getStatus()); + + $responseData = $response->getBody(); + $this->assertNotEmpty($responseData); + $this->assertEquals($this->_webhook->getName(), $responseData['name']); + } + + /** + * Test retrieves not existing WebHook + * + * @resourceOperation xcomMessengerWebhook::get + */ + public function testRetrieveUnavailableResource() + { + $response = $this->callGet(self::VERSON . '/webhooks/invalid_id'); + $this->assertEquals(Mage_Webapi_Exception::HTTP_NOT_FOUND, $response->getStatus()); + } + + /** + * Test retrieves existing WebHooks + * + * @resourceOperation xcomMessengerWebhook::list + */ + public function testRetrieveAll() + { + $response = $this->callGet(self::VERSON . '/webhooks'); + $this->assertEquals(Mage_Webapi_Controller_Front_Rest::HTTP_OK, $response->getStatus()); + $responseData = $response->getBody(); + $this->assertNotEmpty($responseData); + $this->assertTrue(count($responseData)>0); + } + + /** + * Test update an existing WebHook + * + * @resourceOperation xcomMessengerWebhook::update + */ + public function testUpdate() + { + $putData = array( + 'name' => $this->_randomString(), + 'endpoint_url' => 'http://test.com/endpoint/' . $this->_randomString(), + 'topics' => array("customer/created", "customer/updated") + ); + $response = $this->callPut(self::VERSON . '/webhooks/' . $this->_webhook->getId(), $putData); + + $this->assertEquals(Mage_Webapi_Controller_Front_Rest::HTTP_OK, $response->getStatus()); + + /** + * Reload webhook + * + * @@var $updatedWebhook Mage_Webhook_Model_Subscriber + */ + $updatedWebhook = Mage::getModel('Mage_Webhook_Model_Subscriber'); + $updatedWebhook->load($this->_webhook->getId()); + + foreach ($putData as $field => $expectedValue) { + if ($field === 'topics') { + $this->assertEquals($expectedValue, $updatedWebhook->getTopics()); + } else { + $this->assertEquals($expectedValue, $updatedWebhook->getData($field)); + } + } + } + + /** + * Test deletes an existing WebHook + * + * @resourceOperation xcomMessengerWebhook::delete + */ + public function testDelete() + { + $response = $this->callDelete(self::VERSON . '/webhooks/' . $this->_webhook->getId()); + + $this->assertEquals(Mage_Webapi_Controller_Front_Rest::HTTP_OK, $response->getStatus()); + + /** @var $model Mage_Webhook_Model_Subscriber */ + $model = Mage::getModel('Mage_Webhook_Model_Subscriber')->load($this->_webhook->getId()); + $this->assertEmpty($model->getId()); + } + + /** + * Test deletes not existing webhook + * + * @resourceOperation xcomMessengerWebhook::delete + */ + public function testDeleteUnavailableResource() + { + $response = $this->callDelete(self::VERSON . '/webhooks/invalid_id'); + $this->assertEquals(Mage_Webapi_Exception::HTTP_NOT_FOUND, $response->getStatus()); + } + + private function _randomString($length = 6) { + $str = ""; + $characters = array_merge(range('A','Z'), range('a','z'), range('0','9')); + $max = count($characters) - 1; + for ($i = 0; $i < $length; $i++) { + $rand = mt_rand(0, $max); + $str .= $characters[$rand]; + } + return $str; + } +} diff --git a/dev/api-tests/integration/tmp/.gitignore b/dev/api-tests/integration/tmp/.gitignore new file mode 100644 index 0000000000000..a767cafbbd864 --- /dev/null +++ b/dev/api-tests/integration/tmp/.gitignore @@ -0,0 +1 @@ +* diff --git a/dev/githooks/README.TXT b/dev/githooks/README.TXT new file mode 100644 index 0000000000000..7fb0ecd8028ed --- /dev/null +++ b/dev/githooks/README.TXT @@ -0,0 +1,10 @@ +Installing Shared Client-Side Hooks +----------------------------------- +Git hooks exist on a per repository basis and cannot be installed during normal git procedures for security reasons. +To install the existing pre-commit hook, simple run the following commands from your magento root directory: +> cp dev/githooks/precommit .git/hooks +> chmod u+x .git/hooks/pre-commit + +The pre-commit script will now run before you commit any code, and will reject your commit if the unit tests fail. +If for exceptional reasons, you need to bypass the pre-commit script, please use the following command to commit: +> git commit --no-verify \ No newline at end of file diff --git a/dev/githooks/pre-commit b/dev/githooks/pre-commit new file mode 100644 index 0000000000000..81013ac378d08 --- /dev/null +++ b/dev/githooks/pre-commit @@ -0,0 +1,8 @@ +#!/bin/sh +# +# A script to run the unit tests. +# Your environment must be setup with both php and phpUnit before this will pass + +echo Starting unit tests. Any failures will cause your commit to be rejected. + +phpunit -c $(git rev-parse --show-toplevel)/dev/tests/unit/phpunit.xml.dist diff --git a/dev/tests/integration/.gitignore b/dev/tests/integration/.gitignore index 44e6d1e813350..dd44c52ca2594 100644 --- a/dev/tests/integration/.gitignore +++ b/dev/tests/integration/.gitignore @@ -2,3 +2,5 @@ /etc/*.xml !/etc/integration-test-config.xml /tmp/ +/var/ +phpunit.php diff --git a/dev/tests/integration/etc/integration-tests-config.xml b/dev/tests/integration/etc/integration-tests-config.xml index c6650822b8543..7b3e3b294cbc4 100644 --- a/dev/tests/integration/etc/integration-tests-config.xml +++ b/dev/tests/integration/etc/integration-tests-config.xml @@ -39,9 +39,10 @@ - + Magento_Test_Cookie - + Mage_Core_Model_Datasource_Config + @@ -54,8 +55,8 @@ - - ../../../../../../../dev/tests/integration/testsuite/Mage/Core/_files/fixture.csv + + ../../../../../../dev/tests/integration/testsuite/Mage/Core/_files/fixture.csv diff --git a/dev/tests/integration/etc/local-mysql.xml.dist b/dev/tests/integration/etc/local-mysql.xml.dist index 7e7d2d42b829f..3f5c4d33fe210 100644 --- a/dev/tests/integration/etc/local-mysql.xml.dist +++ b/dev/tests/integration/etc/local-mysql.xml.dist @@ -35,7 +35,6 @@ - false diff --git a/dev/tests/integration/framework/Magento/Test/Annotation/AppIsolation.php b/dev/tests/integration/framework/Magento/Test/Annotation/AppIsolation.php index b0eae59019a79..5db758ddd64b0 100644 --- a/dev/tests/integration/framework/Magento/Test/Annotation/AppIsolation.php +++ b/dev/tests/integration/framework/Magento/Test/Annotation/AppIsolation.php @@ -26,7 +26,7 @@ */ /** - * Implementation of the @magentoAppIsolation DocBlock annotation + * Implementation of the @magentoAppIsolation DocBlock annotation - isolation of global application objects in memory */ class Magento_Test_Annotation_AppIsolation { @@ -42,11 +42,6 @@ class Magento_Test_Annotation_AppIsolation */ private $_application; - /** - * @var Zend_Cache_Core - */ - private $_cache; - /** * Constructor * @@ -63,30 +58,11 @@ public function __construct(Magento_Test_Application $application) protected function _isolateApp() { if ($this->_hasNonIsolatedTests) { - $this->_cleanupCache(); $this->_application->reinitialize(); $this->_hasNonIsolatedTests = false; } } - /** - * Remove cache polluted by other tests excluding performance critical cache (configuration, ddl) - */ - protected function _cleanupCache() - { - if (!$this->_cache) { - $this->_cache = Mage::app()->getCache(); - } - $this->_cache->clean( - Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG, - array(Mage_Core_Model_Config::CACHE_TAG, - Varien_Db_Adapter_Pdo_Mysql::DDL_CACHE_TAG, - 'DB_PDO_MSSQL_DDL', // Varien_Db_Adapter_Pdo_Mssql::DDL_CACHE_TAG - 'DB_ORACLE_DDL', // Varien_Db_Adapter_Oracle::DDL_CACHE_TAG - ) - ); - } - /** * Isolate application before running test case */ diff --git a/dev/tests/integration/framework/Magento/Test/Application.php b/dev/tests/integration/framework/Magento/Test/Application.php index 75cb909f1b0a5..76028ee5f4e2e 100644 --- a/dev/tests/integration/framework/Magento/Test/Application.php +++ b/dev/tests/integration/framework/Magento/Test/Application.php @@ -29,6 +29,8 @@ * Encapsulates application installation, initialization and uninstall * * @todo Implement MAGETWO-1689: Standard Installation Method for Integration Tests + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Magento_Test_Application { @@ -80,11 +82,11 @@ class Magento_Test_Application protected $_initParams = array(); /** - * Whether a developer mode is enabled or not + * Mode to run application * - * @var bool + * @var string */ - protected $_isDeveloperMode = false; + protected $_appMode; /** * Constructor @@ -94,27 +96,29 @@ class Magento_Test_Application * @param Varien_Simplexml_Element $localXml * @param array $globalEtcFiles * @param array $moduleEtcFiles - * @param bool $isDeveloperMode + * @param string $appMode */ public function __construct( Magento_Test_Db_DbAbstract $dbInstance, $installDir, Varien_Simplexml_Element $localXml, - array $globalEtcFiles, array $moduleEtcFiles, $isDeveloperMode + array $globalEtcFiles, array $moduleEtcFiles, $appMode ) { $this->_db = $dbInstance; $this->_localXml = $localXml; $this->_globalEtcFiles = $globalEtcFiles; $this->_moduleEtcFiles = $moduleEtcFiles; - $this->_isDeveloperMode = $isDeveloperMode; + $this->_appMode = $appMode; $this->_installDir = $installDir; $this->_installEtcDir = "$installDir/etc"; $this->_initParams = array( Mage::PARAM_APP_DIRS => array( - Mage_Core_Model_Dir::CONFIG => $this->_installEtcDir, - Mage_Core_Model_Dir::VAR_DIR => $installDir, - Mage_Core_Model_Dir::MEDIA => "$installDir/media", + Mage_Core_Model_Dir::CONFIG => $this->_installEtcDir, + Mage_Core_Model_Dir::VAR_DIR => $installDir, + Mage_Core_Model_Dir::MEDIA => "$installDir/media", + Mage_Core_Model_Dir::STATIC_VIEW => "$installDir/static", ), + Mage::PARAM_MODE => $appMode ); } @@ -164,22 +168,24 @@ public function isInstalled() public function initialize($overriddenParams = array()) { $overriddenParams[Mage::PARAM_BASEDIR] = BP; - Mage::setIsDeveloperMode($this->_isDeveloperMode); + $overriddenParams[Mage::PARAM_MODE] = $this->_appMode; Mage::$headersSentThrowsException = false; - $config = new Mage_Core_Model_ObjectManager_Config( - $this->_customizeParams($overriddenParams) - ); + $config = new Mage_Core_Model_Config_Primary(BP, $this->_customizeParams($overriddenParams)); if (!Mage::getObjectManager()) { - /** @var $app Mage_Core_Model_App */ - new Magento_Test_ObjectManager($config, BP); + $definition = new Magento_ObjectManager_Definition_Runtime(); + $definitionDecorator = new Magento_Code_Generator_DefinitionDecorator($definition); + $objectManager = new Magento_Test_ObjectManager($definitionDecorator, $config); + Mage::setObjectManager($objectManager); } else { $config->configure(Mage::getObjectManager()); + Mage::getObjectManager()->addSharedInstance($config, 'Mage_Core_Model_Config_Primary'); + Mage::getObjectManager()->addSharedInstance($config->getDirectories(), 'Mage_Core_Model_Dir'); } Mage::getObjectManager()->get('Mage_Core_Model_Resource') ->setResourceConfig(Mage::getObjectManager()->get('Mage_Core_Model_Config_Resource')); Mage::getObjectManager()->get('Mage_Core_Model_Resource') - ->setCache(Mage::getObjectManager()->get('Mage_Core_Model_Cache')); + ->setCache(Mage::getObjectManager()->get('Mage_Core_Model_CacheInterface')); } /** @@ -195,15 +201,15 @@ public function reinitialize(array $overriddenParams = array()) /** * Run application normally, but with encapsulated initialization options + * + * @param Magento_Test_Request $request + * @param Magento_Test_Response $response */ - public function run() + public function run(Magento_Test_Request $request, Magento_Test_Response $response) { $composer = Mage::getObjectManager(); $handler = $composer->get('Magento_Http_Handler_Composite'); - $handler->handle( - isset($params['request']) ? $params['request'] : $composer->get('Mage_Core_Controller_Request_Http'), - isset($params['response']) ? $params['response'] : $composer->get('Mage_Core_Controller_Response_Http') - ); + $handler->handle($request, $response); } /** @@ -228,7 +234,7 @@ public function install($adminUserName, $adminPassword, $adminRoleName) $this->_ensureDirExists($this->_installDir); $this->_ensureDirExists($this->_installEtcDir); $this->_ensureDirExists($this->_installDir . DIRECTORY_SEPARATOR . 'media'); - $this->_ensureDirExists($this->_installDir . DIRECTORY_SEPARATOR . 'theme'); + $this->_ensureDirExists($this->_installDir . DIRECTORY_SEPARATOR . 'static'); /* Copy configuration files */ $etcDirsToFilesMap = array( @@ -263,7 +269,10 @@ public function install($adminUserName, $adminPassword, $adminRoleName) $updater->updateData(); /* Enable configuration cache by default in order to improve tests performance */ - Mage::app()->getCacheInstance()->saveOptions(array('config' => 1)); + /** @var $cacheTypes Mage_Core_Model_Cache_Types */ + $cacheTypes = Mage::getObjectManager()->get('Mage_Core_Model_Cache_Types'); + $cacheTypes->setEnabled(Mage_Core_Model_Cache_Type_Config::TYPE_IDENTIFIER, true); + $cacheTypes->persist(); /* Fill installation date in local.xml to indicate that application is installed */ $localXml = file_get_contents($targetLocalXml); @@ -303,6 +312,7 @@ protected function _resetApp() $resource = Mage::registry('_singleton/Mage_Core_Model_Resource'); Mage::reset(); + Mage::setObjectManager($objectManager); Varien_Data_Form::setElementRenderer(null); Varien_Data_Form::setFieldsetRenderer(null); Varien_Data_Form::setFieldsetElementRenderer(null); diff --git a/dev/tests/integration/framework/Magento/Test/Bootstrap.php b/dev/tests/integration/framework/Magento/Test/Bootstrap.php index 98270cbfb9a4c..6298b3b2a5b85 100644 --- a/dev/tests/integration/framework/Magento/Test/Bootstrap.php +++ b/dev/tests/integration/framework/Magento/Test/Bootstrap.php @@ -114,7 +114,7 @@ public function __construct( ), $this->_settings->getAsMatchingPaths('TESTS_GLOBAL_CONFIG_FILES'), $this->_settings->getAsMatchingPaths('TESTS_MODULE_CONFIG_FILES'), - $this->_settings->getAsBoolean('TESTS_MAGENTO_DEVELOPER_MODE') + $this->_settings->get('TESTS_MAGENTO_MODE') ); } @@ -195,11 +195,11 @@ protected function _createMemoryBootstrap($memUsageLimit, $memLeakLimit) * @param array $localConfigFiles * @param array $globalConfigFiles * @param array $moduleConfigFiles - * @param bool $isDeveloperMode + * @param string $appMode * @return Magento_Test_Application */ protected function _createApplication( - array $localConfigFiles, array $globalConfigFiles, array $moduleConfigFiles, $isDeveloperMode + array $localConfigFiles, array $globalConfigFiles, array $moduleConfigFiles, $appMode ) { $localConfigXml = $this->_loadConfigFiles($localConfigFiles); $dbConfig = $localConfigXml->global->resources->default_setup->connection; @@ -217,7 +217,7 @@ protected function _createApplication( $this->_shell ); return new Magento_Test_Application( - $dbInstance, $installDir, $localConfigXml, $globalConfigFiles, $moduleConfigFiles, $isDeveloperMode + $dbInstance, $installDir, $localConfigXml, $globalConfigFiles, $moduleConfigFiles, $appMode ); } diff --git a/dev/tests/integration/framework/Magento/Test/Helper/Bootstrap.php b/dev/tests/integration/framework/Magento/Test/Helper/Bootstrap.php index fd345f57bd0ff..f9e1f5b45e212 100644 --- a/dev/tests/integration/framework/Magento/Test/Helper/Bootstrap.php +++ b/dev/tests/integration/framework/Magento/Test/Helper/Bootstrap.php @@ -136,10 +136,11 @@ public function reinitialize(array $overriddenParams = array()) * Perform the full request processing by the application instance optionally passing parameters to be overridden. * Intended to be used by the controller tests. * - * @param array $overriddenParams + * @param Magento_Test_Request $request + * @param Magento_Test_Response $response */ - public function runApp(array $overriddenParams = array()) + public function runApp(Magento_Test_Request $request, Magento_Test_Response $response) { - $this->_bootstrap->getApplication()->run($overriddenParams); + $this->_bootstrap->getApplication()->run($request, $response); } } diff --git a/dev/tests/integration/framework/Magento/Test/Helper/Memory.php b/dev/tests/integration/framework/Magento/Test/Helper/Memory.php index 0e017a9849b39..ba8807deaa49f 100644 --- a/dev/tests/integration/framework/Magento/Test/Helper/Memory.php +++ b/dev/tests/integration/framework/Magento/Test/Helper/Memory.php @@ -64,6 +64,8 @@ public function getRealMemoryUsage() $pid = getmypid(); if (self::isWindowsOs()) { $result = $this->getWinProcessMemoryUsage($pid); + } else if (self::isMacOs()) { + $result = $this->getMacProcessMemoryUsage($pid); } else { $result = $this->getUnixProcessMemoryUsage($pid); } @@ -95,6 +97,46 @@ public function getUnixProcessMemoryUsage($pid) return self::convertToBytes($result); } + /** + * Retrieve the current process' memory usage using the Mac version of the Unix + * top command line interface + * + * @link http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/top.1.html + * @param int $pid + * @return int Memory usage in bytes + */ + public function getMacProcessMemoryUsage($pid) + { + $output = $this->_shell->execute('top -pid %s -l 1 2>&1| grep PID -A 1 2>&1', array($pid)); + + $output = preg_split('/\n+/', $output, -1, PREG_SPLIT_NO_EMPTY); + $keys = preg_split('/\s+/', $output[0], -1, PREG_SPLIT_NO_EMPTY); + $values = preg_split('/\s+/', $output[1], -1, PREG_SPLIT_NO_EMPTY); + $stats = array_combine($keys, $values); + + $result = $stats['RSIZE']; // resident set size, the non-swapped physical memory + + if (is_numeric($result)) { + $result .= 'k'; // kilobytes by default + } else if (self::_endsWith($result, '+')) { + $result = substr($result, 0, -1); + } + + return self::convertToBytes($result); + } + + /** + * Tests whether the second parameter is a suffix of the first. + * + * @param string $str + * @param string $suffix + * @return boolean + */ + private static function _endsWith($str, $suffix) + { + return substr_compare($str, $suffix, -strlen($suffix), strlen($suffix)) === 0; + } + /** * Retrieve the current process' memory usage using Windows command line interface * @@ -130,6 +172,17 @@ public static function isWindowsOs() return (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'); } + /** + * Whether the operating system belongs to the Mac family + * + * @link http://php.net/manual/en/function.php-uname.php + * @return boolean + */ + public static function isMacOs() + { + return (strtoupper(PHP_OS) === 'DARWIN'); + } + /** * Convert a number optionally followed by the unit symbol (B, K, M, G, etc.) to bytes * @@ -140,7 +193,8 @@ public static function isWindowsOs() */ public static function convertToBytes($number) { - $number = str_replace(array(',', ' '), '', $number); + $number = mb_convert_encoding($number, 'ASCII'); + $number = str_replace(array(',', ' ', '?'), '', $number); $number = strtoupper($number); if (!preg_match('/^(\d+(?:\.\d+)?)([' . self::MEMORY_UNITS . ']?)$/', $number, $matches)) { throw new InvalidArgumentException("Number format '$number' is not recognized."); diff --git a/dev/tests/integration/framework/Magento/Test/ObjectManager.php b/dev/tests/integration/framework/Magento/Test/ObjectManager.php index 7d2794fdf79f9..ce532b91ae398 100644 --- a/dev/tests/integration/framework/Magento/Test/ObjectManager.php +++ b/dev/tests/integration/framework/Magento/Test/ObjectManager.php @@ -42,24 +42,32 @@ class Magento_Test_ObjectManager extends Mage_Core_Model_ObjectManager public function clearCache() { foreach ($this->_classesToDestruct as $className) { - if ($this->_di->instanceManager()->hasSharedInstance($className)) { - $object = $this->_di->instanceManager()->getSharedInstance($className); - if ($object) { - // force to cleanup circular references - $object->__destruct(); - } + if (isset($this->_sharedInstances[$className])) { + $this->_sharedInstances[$className]->__destruct(); } } - Mage::getSingleton('Mage_Core_Model_Config_Base')->destroy(); - $instanceManagerNew = new Magento_Di_InstanceManager_Zend(); - $instanceManagerNew->addSharedInstance($this, 'Magento_ObjectManager'); - if ($this->_di->instanceManager()->hasSharedInstance('Mage_Core_Model_Resource')) { - $resource = $this->_di->instanceManager()->getSharedInstance('Mage_Core_Model_Resource'); - $instanceManagerNew->addSharedInstance($resource, 'Mage_Core_Model_Resource'); + Mage_Core_Model_Config_Base::destroy(); + $sharedInstances = array('Magento_ObjectManager' => $this); + if (isset($this->_sharedInstances['Mage_Core_Model_Resource'])) { + $sharedInstances['Mage_Core_Model_Resource'] = $this->_sharedInstances['Mage_Core_Model_Resource']; } - $this->_di->setInstanceManager($instanceManagerNew); + $this->_sharedInstances = $sharedInstances; + $this->_nonShared = array(); + $this->_arguments = array(); + $this->_preferences = array(); + $this->_creationStack = array(); return $this; } + + public function addSharedInstance($instance, $className) + { + $this->_sharedInstances[$className] = $instance; + } + + public function removeSharedInstance($className) + { + unset($this->_sharedInstances[$className]); + } } diff --git a/dev/tests/integration/framework/Magento/Test/TestCase/ControllerAbstract.php b/dev/tests/integration/framework/Magento/Test/TestCase/ControllerAbstract.php index b2c851a0ccb94..238b44ca8f593 100644 --- a/dev/tests/integration/framework/Magento/Test/TestCase/ControllerAbstract.php +++ b/dev/tests/integration/framework/Magento/Test/TestCase/ControllerAbstract.php @@ -76,6 +76,12 @@ protected function setUp() { $this->_assertSessionErrors = false; $this->_objectManager = Mage::getObjectManager(); + $this->_objectManager->configure(array( + 'preferences' => array( + 'Mage_Core_Controller_Request_Http' => 'Magento_Test_Request', + 'Mage_Core_Controller_Response_Http' => 'Magento_Test_Response' + ) + )); } protected function tearDown() @@ -104,10 +110,7 @@ protected function assertPostConditions() public function dispatch($uri) { $this->getRequest()->setRequestUri($uri); - $this->_getBootstrap()->runApp(array( - 'request' => $this->getRequest(), - 'response' => $this->getResponse() - )); + $this->_getBootstrap()->runApp($this->getRequest(), $this->getResponse()); } /** @@ -119,7 +122,7 @@ public function getRequest() { if (!$this->_request) { $this->_request = new Magento_Test_Request(); - $this->_objectManager->addSharedInstance($this->_request, 'Mage_Core_Controller_Request_Http'); + $this->_objectManager->addSharedInstance($this->_request, 'Magento_Test_Request'); } return $this->_request; } @@ -133,7 +136,7 @@ public function getResponse() { if (!$this->_response) { $this->_response = new Magento_Test_Response(); - $this->_objectManager->addSharedInstance($this->_response, 'Mage_Core_Controller_Response_Http'); + $this->_objectManager->addSharedInstance($this->_response, 'Magento_Test_Response'); } return $this->_response; } diff --git a/dev/tests/integration/framework/Magento/Test/TestCase/IntegrityAbstract.php b/dev/tests/integration/framework/Magento/Test/TestCase/IntegrityAbstract.php index 4c84ee2cfcf42..aa287440b6a17 100644 --- a/dev/tests/integration/framework/Magento/Test/TestCase/IntegrityAbstract.php +++ b/dev/tests/integration/framework/Magento/Test/TestCase/IntegrityAbstract.php @@ -74,12 +74,12 @@ protected function _isFileForDisabledModule($file) /** * Returns flat array of themes currently located in system * - * @return array + * @return Mage_Core_Model_Theme[] */ protected function _getDesignThemes() { - /** @var $theme Mage_Core_Model_Theme */ - $theme = Mage::getModel('Mage_Core_Model_Theme'); - return $theme->getCollection()->getItems(); + /** @var $themeCollection Mage_Core_Model_Resource_Theme_Collection */ + $themeCollection = Mage::getObjectManager()->create('Mage_Core_Model_Resource_Theme_Collection'); + return $themeCollection->getItems(); } } diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/AppIsolationTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/AppIsolationTest.php index e661f29eadca5..b7ccd012f7a06 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/AppIsolationTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/AppIsolationTest.php @@ -31,21 +31,19 @@ class Magento_Test_Annotation_AppIsolationTest extends PHPUnit_Framework_TestCase { /** - * @var Magento_Test_Annotation_AppIsolation|PHPUnit_Framework_MockObject_MockObject + * @var Magento_Test_Annotation_AppIsolation */ protected $_object; /** - * @var Magento_Test_Application|PHPUnit_Framework_MockObject_MockObject + * @var PHPUnit_Framework_MockObject_MockObject */ protected $_application; protected function setUp() { $this->_application = $this->getMock('Magento_Test_Application', array('reinitialize'), array(), '', false); - $this->_object = $this->getMock( - 'Magento_Test_Annotation_AppIsolation', array('_cleanupCache'), array($this->_application) - ); + $this->_object = new Magento_Test_Annotation_AppIsolation($this->_application); } protected function tearDown() diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ApplicationTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ApplicationTest.php new file mode 100644 index 0000000000000..b2a4875ba40a4 --- /dev/null +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ApplicationTest.php @@ -0,0 +1,63 @@ +getMockForAbstractClass('Magento_Test_Db_DbAbstract', array(), '', false); + $installDir = '/install/dir'; + $appMode = Mage_Core_Model_App_State::MODE_DEVELOPER; + + $object = new Magento_Test_Application( + $dbInstance, + $installDir, + new Varien_Simplexml_Element(''), + array(), + array(), + $appMode + ); + + $this->assertSame($dbInstance, $object->getDbInstance(), 'Db instance is not set in Application'); + $this->assertEquals($installDir, $object->getInstallDir(), 'Install directory is not set in Application'); + + $initParams = $object->getInitParams(); + $this->assertInternalType('array', $initParams, 'Wrong initialization parameters type'); + $this->assertArrayHasKey(Mage::PARAM_APP_DIRS, $initParams, 'Directories are not configured'); + $this->assertArrayHasKey(Mage::PARAM_MODE, $initParams, 'Application mode is not configured'); + $this->assertEquals( + Mage_Core_Model_App_State::MODE_DEVELOPER, + $initParams[Mage::PARAM_MODE], + 'Wrong application mode configured' + ); + } +} diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Helper/BootstrapTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Helper/BootstrapTest.php index 63b3c460ef28d..42514bd555bcc 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Helper/BootstrapTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Helper/BootstrapTest.php @@ -188,11 +188,14 @@ public function testReinitialize() public function testRunApp() { + $requestMock = $this->getMock('Magento_Test_Request', array(), array(), '', false); + $responseMock = $this->getMock('Magento_Test_Response', array(), array(), '', false); + $this->_application ->expects($this->once()) ->method('run') - ->with($this->_fixtureInitParams) + ->with($requestMock, $responseMock) ; - $this->_object->runApp($this->_fixtureInitParams); + $this->_object->runApp($requestMock, $responseMock); } } diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ObjectManagerTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ObjectManagerTest.php index 1afcf93eb33f7..a3cd42fca7992 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ObjectManagerTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ObjectManagerTest.php @@ -26,7 +26,7 @@ */ /** - * Test class for Magento_ObjectManager_Zend + * Test class for Magento_ObjectManager_Test */ class Magento_Test_ObjectManagerTest extends PHPUnit_Framework_TestCase { @@ -43,19 +43,15 @@ class Magento_Test_ObjectManagerTest extends PHPUnit_Framework_TestCase public function testClearCache() { $resource = new stdClass; + $config = $this->getMock('Mage_Core_Model_Config_Primary', array(), array(), '', false); + $model = new Magento_Test_ObjectManager(new Magento_ObjectManager_Definition_Runtime(), $config); + $model->addSharedInstance($resource, 'Mage_Core_Model_Resource'); + $instance1 = $model->get('Magento_Test_Request'); - $instanceManager = new Magento_Di_InstanceManager_Zend(); - $instanceManager->addSharedInstance($resource, 'Mage_Core_Model_Resource'); - - $diInstance = new Magento_Di_Zend(); - $config = $this->getMock('Magento_ObjectManager_Configuration'); - $model = new Magento_Test_ObjectManager($config, null, $diInstance); - - $diInstance->setInstanceManager($instanceManager); + $this->assertSame($instance1, $model->get('Magento_Test_Request')); $this->assertSame($model, $model->clearCache()); - $this->assertNotSame($instanceManager, $diInstance->instanceManager()); - $this->assertSame($model, $diInstance->instanceManager()->getSharedInstance('Magento_ObjectManager')); - $this->assertSame($resource, $diInstance->instanceManager()->getSharedInstance('Mage_Core_Model_Resource')); - $this->assertFalse($diInstance->instanceManager()->hasSharedInstance('sharedInstance')); + $this->assertSame($model, $model->get('Magento_ObjectManager')); + $this->assertSame($resource, $model->get('Mage_Core_Model_Resource')); + $this->assertNotSame($instance1, $model->get('Magento_Test_Request')); } } diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php index a2cffc1062d7b..4bfc74d2c0126 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php @@ -31,6 +31,14 @@ class Magento_Test_TestCase_ControllerAbstractTest extends Magento_Test_TestCase protected function setUp() { + if (!Mage::getObjectManager()) { + Mage::setObjectManager( + new Magento_Test_ObjectManager( + new Magento_ObjectManager_Definition_Runtime(), + $this->getMock('Mage_Core_Model_Config_Primary', array(), array(), '', false) + ) + ); + } parent::setUp(); // emulate session messages @@ -61,7 +69,7 @@ protected function _getBootstrap() public function testGetRequest() { - $this->_objectManager = $this->getMock('Magento_ObjectManager'); + $this->_objectManager = $this->getMock('Magento_Test_ObjectManager', array(), array(), '', false); $request = $this->getRequest(); $this->assertInstanceOf('Magento_Test_Request', $request); $this->assertSame($request, $this->getRequest()); @@ -69,7 +77,7 @@ public function testGetRequest() public function testGetResponse() { - $this->_objectManager = $this->getMock('Magento_ObjectManager'); + $this->_objectManager = $this->getMock('Magento_Test_ObjectManager', array(), array(), '', false); $response = $this->getResponse(); $this->assertInstanceOf('Magento_Test_Response', $response); $this->assertSame($response, $this->getResponse()); @@ -80,7 +88,7 @@ public function testGetResponse() */ public function testAssert404NotFound() { - $this->_objectManager = $this->getMock('Magento_ObjectManager'); + $this->_objectManager = $this->getMock('Magento_Test_ObjectManager', array(), array(), '', false); $this->getRequest()->setActionName('noRoute'); $this->getResponse()->setBody( '404 Not Found test

    We are sorry, but the page you are looking for cannot be found.

    ' @@ -101,7 +109,7 @@ public function testAssert404NotFound() */ public function testAssertRedirectFailure() { - $this->_objectManager = $this->getMock('Magento_ObjectManager'); + $this->_objectManager = $this->getMock('Magento_Test_ObjectManager', array(), array(), '', false); $this->assertRedirect(); } @@ -110,7 +118,7 @@ public function testAssertRedirectFailure() */ public function testAssertRedirect() { - $this->_objectManager = $this->getMock('Magento_ObjectManager'); + $this->_objectManager = $this->getMock('Magento_Test_ObjectManager', array(), array(), '', false); /* * Prevent calling Mage_Core_Controller_Response_Http::setRedirect() because it executes Mage::dispatchEvent(), * which requires fully initialized application environment intentionally not available for unit tests diff --git a/dev/tests/integration/phpunit.xml.dist b/dev/tests/integration/phpunit.xml.dist index 1e27e538ac613..8d7a3c6c8b83d 100644 --- a/dev/tests/integration/phpunit.xml.dist +++ b/dev/tests/integration/phpunit.xml.dist @@ -31,19 +31,18 @@ testsuite - testsuite/integrity - ../../../app/code/core/Mage + ../../../app/code/Mage - ../../../app/code/core/Mage/*/sql + ../../../app/code/Mage/*/sql - ../../../app/code/core/Mage/*/data + ../../../app/code/Mage/*/data @@ -69,10 +68,13 @@ - + + + + diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Category/TreeTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Category/TreeTest.php index 29decfe9f8b17..767a54f0be2b2 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Category/TreeTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Category/TreeTest.php @@ -24,21 +24,17 @@ * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Catalog_Category_TreeTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Catalog_Category_TreeTest extends Mage_Backend_Area_TestCase { /** @var Mage_Adminhtml_Block_Catalog_Category_Tree */ protected $_block; protected function setUp() { + parent::setUp(); $this->_block = Mage::getModel('Mage_Adminhtml_Block_Catalog_Category_Tree'); } - protected function tearDown() - { - $this->_block = null; - } - public function testGetSuggestedCategoriesJson() { $this->assertEquals( diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/MainTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/MainTest.php index 32c8ebad0df31..0ce49333bc42d 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/MainTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/MainTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_MainTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_MainTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Main @@ -34,6 +34,7 @@ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_MainTest extends P protected function setUp() { + parent::setUp(); $this->_block = Mage::app()->getLayout() ->createBlock('Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Main'); } diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/AddTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/AddTest.php index 63a4dc562ac0e..767c617312051 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/AddTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/AddTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Toolbar_AddTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Toolbar_AddTest extends Mage_Backend_Area_TestCase { public function testToHtmlFormId() { diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/OptionTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/OptionTest.php index ed0bdd65c7edb..31d028445931c 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/OptionTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/OptionTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_OptionTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_OptionTest extends Mage_Backend_Area_TestCase { public function testGetOptionValuesCaching() { diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/SelectTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/SelectTest.php index 93ac04af90bd6..1e6f9262ce2a2 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/SelectTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/SelectTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_SelectTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_SelectTest extends Mage_Backend_Area_TestCase { public function testToHtmlFormId() { @@ -34,7 +34,7 @@ public function testToHtmlFormId() /** @var $block Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Select */ $block = $layout->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Select', 'select'); $html = $block->getPriceTypeSelectHtml(); - $this->assertContains('select_{{select_id}}', $html); - $this->assertContains('[{{select_id}}]', $html); + $this->assertContains('select_${select_id}', $html); + $this->assertContains('[${select_id}]', $html); } } diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/MatrixTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/MatrixTest.php index 5fa9669f91e74..a498a261e0d5c 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/MatrixTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/MatrixTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_MatrixTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_MatrixTest extends Mage_Backend_Area_TestCase { /** * @magentoAppIsolation enabled diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/ConfigTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/ConfigTest.php index 2393ec422bd28..4e0500cb00e02 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/ConfigTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/ConfigTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_ConfigTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_ConfigTest extends Mage_Backend_Area_TestCase { /** * @magentoAppIsolation enabled diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/SettingsTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/SettingsTest.php index 7f7b95e3e2e6d..889cc8f2ccee7 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/SettingsTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/SettingsTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_SettingsTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_SettingsTest extends Mage_Backend_Area_TestCase { /** * @param null|int $productId @@ -51,13 +51,15 @@ public function testGetContinueUrl($productId, $expectedUrl) Mage::register('current_product', $product); + $context = Mage::getModel('Mage_Core_Block_Template_Context', array('urlBuilder' => $urlModel)); + /** @var $layout Mage_Core_Model_Layout */ $layout = Mage::getModel('Mage_Core_Model_Layout'); /** @var $block Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Settings */ $block = $layout->createBlock( 'Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Settings', 'block', array( - 'urlBuilder' => $urlModel + 'context' => $context ) ); $this->assertEquals('url', $block->getContinueUrl()); diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/TabsTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/TabsTest.php index 012dab5db9a3e..4dd4517ea0dcb 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/TabsTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Edit/TabsTest.php @@ -24,7 +24,7 @@ * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Catalog_Product_Edit_TabsTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Catalog_Product_Edit_TabsTest extends Mage_Backend_Area_TestCase { /** * @magentoDataFixture Mage/Catalog/_files/product_simple.php diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/EditTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/EditTest.php index 02f1c94cb30c5..866897f084d51 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/EditTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/EditTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Catalog_Product_EditTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Catalog_Product_EditTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Adminhtml_Block_Catalog_Product_Edit @@ -34,6 +34,7 @@ class Mage_Adminhtml_Block_Catalog_Product_EditTest extends PHPUnit_Framework_Te protected function setUp() { + parent::setUp(); /** @var $product Mage_Catalog_Model_Product */ $product = $this->getMock('Mage_Catalog_Model_Product', array('getAttributes'), array(), '', false); $product->expects($this->any())->method('getAttributes')->will($this->returnValue(array())); diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery/ContentTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery/ContentTest.php index 4071546a4aa05..93640ed375727 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery/ContentTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery/ContentTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery_ContentTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery_ContentTest extends Mage_Backend_Area_TestCase { public function testGetUploader() { diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Weight/RendererTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Weight/RendererTest.php deleted file mode 100644 index 5b8322d46d8df..0000000000000 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Weight/RendererTest.php +++ /dev/null @@ -1,89 +0,0 @@ -setTypeInstance(Mage::getObjectManager()->create($type)); - - $block = new Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Weight_Renderer(); - - $form = new Varien_Data_Form(); - $form->setDataObject($currentProduct); - $block->setForm($form); - - $this->assertContains('checked="checked"', $block->getElementHtml(), - 'Is Virtual checkbox is not selected for virtual products'); - } - - /** - * @return array - */ - public static function virtualTypesDataProvider() - { - return array( - array('Mage_Catalog_Model_Product_Type_Virtual'), - array('Mage_Downloadable_Model_Product_Type'), - ); - } - - /** - * @param string $type - * @dataProvider physicalTypesDataProvider - */ - public function testIsVirtualUnchecked($type) - { - $currentProduct = Mage::getModel('Mage_Catalog_Model_Product'); - $currentProduct->setTypeInstance(Mage::getObjectManager()->create($type)); - - $block = new Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Weight_Renderer(); - - $form = new Varien_Data_Form(); - $form->setDataObject($currentProduct); - $block->setForm($form); - - $this->assertNotContains('checked="checked"', $block->getElementHtml(), - 'Is Virtual checkbox is selected for physical products'); - } - - /** - * @return array - */ - public static function physicalTypesDataProvider() - { - return array( - array('Mage_Catalog_Model_Product_Type_Simple'), - array('Mage_Bundle_Model_Product_Type'), - ); - } -} diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/WeightTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/WeightTest.php new file mode 100644 index 0000000000000..108c49d1aa7b8 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/WeightTest.php @@ -0,0 +1,89 @@ +setTypeInstance(Mage::getObjectManager()->create($type)); + + $block = new Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Weight(); + + $form = new Varien_Data_Form(); + $form->setDataObject($currentProduct); + $block->setForm($form); + + $this->assertContains('checked="checked"', $block->getElementHtml(), + 'Is Virtual checkbox is not selected for virtual products'); + } + + /** + * @return array + */ + public static function virtualTypesDataProvider() + { + return array( + array('Mage_Catalog_Model_Product_Type_Virtual'), + array('Mage_Downloadable_Model_Product_Type'), + ); + } + + /** + * @param string $type + * @dataProvider physicalTypesDataProvider + */ + public function testIsVirtualUnchecked($type) + { + $currentProduct = Mage::getModel('Mage_Catalog_Model_Product'); + $currentProduct->setTypeInstance(Mage::getObjectManager()->create($type)); + + $block = new Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Weight(); + + $form = new Varien_Data_Form(); + $form->setDataObject($currentProduct); + $block->setForm($form); + + $this->assertNotContains('checked="checked"', $block->getElementHtml(), + 'Is Virtual checkbox is selected for physical products'); + } + + /** + * @return array + */ + public static function physicalTypesDataProvider() + { + return array( + array('Mage_Catalog_Model_Product_Type_Simple'), + array('Mage_Bundle_Model_Product_Type'), + ); + } +} diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Options/AjaxTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Options/AjaxTest.php index 96fa0f67d1777..607cb5630c7b1 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Options/AjaxTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Catalog/Product/Options/AjaxTest.php @@ -24,7 +24,7 @@ * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Catalog_Product_Options_AjaxTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Catalog_Product_Options_AjaxTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Adminhtml_Block_Catalog_Product_Options_Ajax @@ -33,6 +33,7 @@ class Mage_Adminhtml_Block_Catalog_Product_Options_AjaxTest extends PHPUnit_Fram public function setUp() { + parent::setUp(); $this->_block = Mage::app()->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Options_Ajax'); } diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/DesignTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/DesignTest.php index e8589e890c3a1..43ae4ac90f247 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/DesignTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/DesignTest.php @@ -28,7 +28,7 @@ /** * Test class for Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Design */ -class Mage_Adminhtml_Block_Cms_Page_Edit_Tab_DesignTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Cms_Page_Edit_Tab_DesignTest extends Mage_Backend_Area_TestCase { /** * @magentoDataFixture Mage/Core/_files/init_adminhtml_design.php diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Customer/Edit/Tab/View/AccordionTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Customer/Edit/Tab/View/AccordionTest.php index cdced6bcf51f0..6a711c2fec2b3 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Customer/Edit/Tab/View/AccordionTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Customer/Edit/Tab/View/AccordionTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Customer_Edit_Tab_View_AccordionTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Customer_Edit_Tab_View_AccordionTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Adminhtml_Block_Customer_Edit_Tab_View_Accordion @@ -34,6 +34,7 @@ class Mage_Adminhtml_Block_Customer_Edit_Tab_View_AccordionTest extends PHPUnit_ protected function setUp() { + parent::setUp(); /** @var $customer Mage_Customer_Model_Customer */ $customer = Mage::getModel('Mage_Customer_Model_Customer'); $customer->load(1); @@ -43,11 +44,6 @@ protected function setUp() $this->_block = $layout->createBlock('Mage_Adminhtml_Block_Customer_Edit_Tab_View_Accordion'); } - protected function tearDown() - { - $this->_block = null; - } - /** * magentoDataFixture Mage/Customer/_files/customer.php */ diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Customer/OnlineTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Customer/OnlineTest.php index c55507431f4c2..5999fba1160d9 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Customer/OnlineTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Customer/OnlineTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Customer_OnlineTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Customer_OnlineTest extends Mage_Backend_Area_TestCase { /** * @magentoAppIsolation enabled diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Dashboard/GraphTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Dashboard/GraphTest.php index 0366e0980d445..95cdb3e21aec3 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Dashboard/GraphTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Dashboard/GraphTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Dashboard_GraphTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Dashboard_GraphTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Adminhtml_Block_Dashboard_Graph @@ -34,15 +34,11 @@ class Mage_Adminhtml_Block_Dashboard_GraphTest extends PHPUnit_Framework_TestCas protected function setUp() { + parent::setUp(); $this->_block = Mage::app()->getLayout()->createBlock('Mage_Adminhtml_Block_Dashboard_Graph'); $this->_block->setDataHelperName('Mage_Adminhtml_Helper_Dashboard_Order'); } - protected function tearDown() - { - $this->_block = null; - } - public function testGetChartUrl() { $this->assertStringStartsWith('http://chart.apis.google.com/chart', $this->_block->getChartUrl()); diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Newsletter/Queue/Edit/FormTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Newsletter/Queue/Edit/FormTest.php index 320100eb51f09..6165ba7766313 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Newsletter/Queue/Edit/FormTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Newsletter/Queue/Edit/FormTest.php @@ -28,7 +28,7 @@ /** * Test class for Mage_Adminhtml_Block_Newsletter_Queue_Edit_Form */ -class Mage_Adminhtml_Block_Newsletter_Queue_Edit_FormTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Newsletter_Queue_Edit_FormTest extends Mage_Backend_Area_TestCase { /** * @magentoDataFixture Mage/Core/_files/init_adminhtml_design.php diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Newsletter/SubscriberTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Newsletter/SubscriberTest.php index 4b229a23b7e97..9424c8ceabe94 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Newsletter/SubscriberTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Newsletter/SubscriberTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Newsletter_SubscriberTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Newsletter_SubscriberTest extends Mage_Backend_Area_TestCase { public function testGetShowQueueAdd() { diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Notification/BaseurlTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Notification/BaseurlTest.php index f08c99dcaac3e..019b3d28754be 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Notification/BaseurlTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Notification/BaseurlTest.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Notification_BaseurlTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Notification_BaseurlTest extends Mage_Backend_Area_TestCase { public function testGetConfigUrl() { diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Page/HeadTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Page/HeadTest.php index 7e87bc7e94cd3..c6715218783b4 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Page/HeadTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Page/HeadTest.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Page_HeadTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Page_HeadTest extends Mage_Backend_Area_TestCase { public function testConstruct() { diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Page/HeaderTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Page/HeaderTest.php index 891c0cfbc815e..4b8c2f38237db 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Page/HeaderTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Page/HeaderTest.php @@ -28,7 +28,7 @@ /** * Test Mage_Adminhtml_Block_Page_Header */ -class Mage_Adminhtml_Block_Page_HeaderTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Page_HeaderTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Adminhtml_Block_Page_Header @@ -37,14 +37,10 @@ class Mage_Adminhtml_Block_Page_HeaderTest extends PHPUnit_Framework_TestCase protected function setUp() { + parent::setUp(); $this->_block = Mage::app()->getLayout()->createBlock('Mage_Adminhtml_Block_Page_Header'); } - protected function tearDown() - { - $this->_block = null; - } - public function testGetHomeLink() { $expected = Mage::helper('Mage_Backend_Helper_Data')->getHomePageUrl(); diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Poll/GridTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Poll/GridTest.php index e02ba87a267c0..3b8be7d9715c4 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Poll/GridTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Poll/GridTest.php @@ -28,7 +28,7 @@ /** * Test class for Mage_Adminhtml_Block_Poll_Grid */ -class Mage_Adminhtml_Block_Poll_GridTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Poll_GridTest extends Mage_Backend_Area_TestCase { public function testPrepareColumns() { diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tab/MainTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tab/MainTest.php index cbeb45121627c..0ab705071af90 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tab/MainTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tab/MainTest.php @@ -28,7 +28,7 @@ /** * Test class for Mage_Adminhtml_Block_Promo_Catalog_Edit_Tab_Main */ -class Mage_Adminhtml_Block_Promo_Catalog_Edit_Tab_MainTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Promo_Catalog_Edit_Tab_MainTest extends Mage_Backend_Area_TestCase { /** * @magentoDataFixture Mage/Core/_files/init_adminhtml_design.php diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/LabelsTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/LabelsTest.php index 36dba811686e6..62cb6188d1540 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/LabelsTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/LabelsTest.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Promo_Quote_Edit_Tab_LabelsTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Promo_Quote_Edit_Tab_LabelsTest extends Mage_Backend_Area_TestCase { public function testConstruct() { diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/MainTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/MainTest.php index 4644dc1a7e348..b97e3be544c77 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/MainTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/MainTest.php @@ -28,7 +28,7 @@ /** * Test class for Mage_Adminhtml_Block_Promo_Quote_Edit_Tab_Main */ -class Mage_Adminhtml_Block_Promo_Quote_Edit_Tab_MainTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Promo_Quote_Edit_Tab_MainTest extends Mage_Backend_Area_TestCase { /** * @magentoDataFixture Mage/Core/_files/init_adminhtml_design.php diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Rating/Edit/Tab/FormTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Rating/Edit/Tab/FormTest.php index 5dcd7ad218b0f..7c2efb0c55f85 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Rating/Edit/Tab/FormTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Rating/Edit/Tab/FormTest.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Rating_Edit_Tab_FormTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Rating_Edit_Tab_FormTest extends Mage_Backend_Area_TestCase { public function testConstruct() { diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Filter/FormTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Filter/FormTest.php index f49a8424136d2..ae224af14ed07 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Filter/FormTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Filter/FormTest.php @@ -28,7 +28,7 @@ /** * Test class for Mage_Adminhtml_Block_Report_Filter_Form */ -class Mage_Adminhtml_Block_Report_Filter_FormTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Report_Filter_FormTest extends Mage_Backend_Area_TestCase { /** * @magentoDataFixture Mage/Core/_files/init_adminhtml_design.php diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Bestsellers/GridTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Bestsellers/GridTest.php index e67940db10d29..cf470745325a8 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Bestsellers/GridTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Bestsellers/GridTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Report_Sales_Bestsellers_GridTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Report_Sales_Bestsellers_GridTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Adminhtml_Block_Report_Sales_Bestsellers_Grid @@ -34,14 +34,10 @@ class Mage_Adminhtml_Block_Report_Sales_Bestsellers_GridTest extends PHPUnit_Fra protected function setUp() { + parent::setUp(); $this->_block = Mage::app()->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Sales_Bestsellers_Grid'); } - protected function tearDown() - { - $this->_block = null; - } - public function testGetResourceCollectionName() { $collectionName = $this->_block->getResourceCollectionName(); diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Coupons/GridTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Coupons/GridTest.php index 336704560f653..fe1243191d32f 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Coupons/GridTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Coupons/GridTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Report_Sales_Coupons_GridTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Report_Sales_Coupons_GridTest extends Mage_Backend_Area_TestCase { /** * Creates and inits block diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Invoiced/GridTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Invoiced/GridTest.php index 42285bd02b8c0..e8e3c6308cc30 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Invoiced/GridTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Invoiced/GridTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Report_Sales_Invoiced_GridTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Report_Sales_Invoiced_GridTest extends Mage_Backend_Area_TestCase { /** * Creates and inits block diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Refunded/GridTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Refunded/GridTest.php index 98cb7ab2692dc..f901a5784efad 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Refunded/GridTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Refunded/GridTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Report_Sales_Refunded_GridTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Report_Sales_Refunded_GridTest extends Mage_Backend_Area_TestCase { /** * Creates and inits block diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Sales/GridTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Sales/GridTest.php index 1998ae76a2008..92bfd5675f5ba 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Sales/GridTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Sales/GridTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Report_Sales_Sales_GridTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Report_Sales_Sales_GridTest extends Mage_Backend_Area_TestCase { /** * Creates and inits block diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Shipping/GridTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Shipping/GridTest.php index a4f96ba6a3117..9023ae0afe752 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Shipping/GridTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Shipping/GridTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Report_Sales_Shipping_GridTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Report_Sales_Shipping_GridTest extends Mage_Backend_Area_TestCase { /** * Creates and inits block diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Tax/GridTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Tax/GridTest.php index ef91e65f70c96..0fa92207704a6 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Tax/GridTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Report/Sales/Tax/GridTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Report_Sales_Tax_GridTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Report_Sales_Tax_GridTest extends Mage_Backend_Area_TestCase { /** * Creates and inits block diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Sales/Items/AbstractTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Sales/Items/AbstractTest.php index 8b0f94935cea6..8c5c5141850c7 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Sales/Items/AbstractTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Sales/Items/AbstractTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Sales_Items_AbstractTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Sales_Items_AbstractTest extends Mage_Backend_Area_TestCase { public function testGetItemExtraInfoHtml() { diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Sales/Order/Create/Form/AbstractTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Sales/Order/Create/Form/AbstractTest.php index 783f03bf178fd..94a995cdb58af 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Sales/Order/Create/Form/AbstractTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Sales/Order/Create/Form/AbstractTest.php @@ -38,20 +38,7 @@ class Mage_Adminhtml_Block_Sales_Order_Create_Form_AbstractTest public function testAddAttributesToForm() { $arguments = array( - Mage::getObjectManager()->get('Mage_Core_Controller_Request_Http'), - Mage::getObjectManager()->get('Mage_Core_Model_Layout'), - Mage::getObjectManager()->get('Mage_Core_Model_Event_Manager'), - Mage::getObjectManager()->get('Mage_Backend_Model_Url'), - Mage::getObjectManager()->get('Mage_Core_Model_Translate'), - Mage::getObjectManager()->get('Mage_Core_Model_Cache'), - Mage::getObjectManager()->get('Mage_Core_Model_Design_Package'), - Mage::getObjectManager()->get('Mage_Core_Model_Session'), - Mage::getObjectManager()->get('Mage_Core_Model_Store_Config'), - Mage::getObjectManager()->get('Mage_Core_Controller_Varien_Front'), - Mage::getObjectManager()->get('Mage_Core_Model_Factory_Helper'), - Mage::getObjectManager()->get('Mage_Core_Model_Dir'), - Mage::getObjectManager()->get('Mage_Core_Model_Logger'), - Mage::getObjectManager()->get('Magento_Filesystem'), + Mage::getObjectManager()->get('Mage_Core_Block_Template_Context') ); /** @var $block Mage_Adminhtml_Block_Sales_Order_Create_Form_Abstract */ $block = $this->getMockForAbstractClass('Mage_Adminhtml_Block_Sales_Order_Create_Form_Abstract', $arguments); diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Account/Edit/FormTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Account/Edit/FormTest.php index 76f7c39e378ef..06251bc0934a8 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Account/Edit/FormTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Account/Edit/FormTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_System_Account_Edit_FormTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_System_Account_Edit_FormTest extends Mage_Backend_Area_TestCase { public function testPrepareForm() { diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Design/Edit/Tab/GeneralTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Design/Edit/Tab/GeneralTest.php index 2a39a17b0cfee..205150f8bb260 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Design/Edit/Tab/GeneralTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Design/Edit/Tab/GeneralTest.php @@ -28,7 +28,7 @@ /** * Test class for Mage_Adminhtml_Block_System_Design_Edit_Tab_General */ -class Mage_Adminhtml_Block_System_Design_Edit_Tab_GeneralTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_System_Design_Edit_Tab_GeneralTest extends Mage_Backend_Area_TestCase { /** * @magentoDataFixture Mage/Core/_files/init_adminhtml_design.php diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/DeleteTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/DeleteTest.php index 10b30acdee612..4b21a7f64bf87 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/DeleteTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/DeleteTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_System_Store_DeleteTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_System_Store_DeleteTest extends Mage_Backend_Area_TestCase { public function testGetHeaderText() { diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/GroupTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/GroupTest.php index 9e1947c4bae30..0d88017236619 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/GroupTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/GroupTest.php @@ -28,13 +28,17 @@ /** * @magentoAppIsolation enabled */ -class Mage_Adminhtml_Block_System_Store_Edit_Form_GroupTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_System_Store_Edit_Form_GroupTest extends Mage_Backend_Area_TestCase { - /** @var Mage_Adminhtml_Block_System_Store_Edit_Form_Group */ + /** + * @var Mage_Adminhtml_Block_System_Store_Edit_Form_Group + */ protected $_block; - public static function setUpBeforeClass() + protected function setUp() { + parent::setUp(); + $registryData = array( 'store_type' => 'group', 'store_data' => Mage::getModel('Mage_Core_Model_Store_Group'), @@ -43,17 +47,8 @@ public static function setUpBeforeClass() foreach ($registryData as $key => $value) { Mage::register($key, $value); } - } - public static function tearDownAfterClass() - { - Mage::unregister('store_type'); - Mage::unregister('store_data'); - Mage::unregister('store_action'); - } - public function setUp() - { /** @var $layout Mage_Core_Model_Layout */ $layout = Mage::getModel('Mage_Core_Model_Layout'); @@ -62,6 +57,13 @@ public function setUp() $this->_block->toHtml(); } + protected function tearDown() + { + Mage::unregister('store_type'); + Mage::unregister('store_data'); + Mage::unregister('store_action'); + } + public function testPrepareForm() { $form = $this->_block->getForm(); diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/StoreTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/StoreTest.php index 40d03ccc39eae..7f7b49f489e5a 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/StoreTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/StoreTest.php @@ -28,13 +28,17 @@ /** * @magentoAppIsolation enabled */ -class Mage_Adminhtml_Block_System_Store_Edit_Form_StoreTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_System_Store_Edit_Form_StoreTest extends Mage_Backend_Area_TestCase { - /** @var Mage_Adminhtml_Block_System_Store_Edit_Form_Store */ + /** + * @var Mage_Adminhtml_Block_System_Store_Edit_Form_Store + */ protected $_block; - public static function setUpBeforeClass() + public function setUp() { + parent::setUp(); + $registryData = array( 'store_type' => 'store', 'store_data' => Mage::getModel('Mage_Core_Model_Store'), @@ -43,17 +47,7 @@ public static function setUpBeforeClass() foreach ($registryData as $key => $value) { Mage::register($key, $value); } - } - - public static function tearDownAfterClass() - { - Mage::unregister('store_type'); - Mage::unregister('store_data'); - Mage::unregister('store_action'); - } - public function setUp() - { /** @var $layout Mage_Core_Model_Layout */ $layout = Mage::getModel('Mage_Core_Model_Layout'); @@ -62,6 +56,13 @@ public function setUp() $this->_block->toHtml(); } + protected function tearDown() + { + Mage::unregister('store_type'); + Mage::unregister('store_data'); + Mage::unregister('store_action'); + } + public function testPrepareForm() { $form = $this->_block->getForm(); diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/WebsiteTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/WebsiteTest.php index ee311d53ff495..93e7070ed5396 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/WebsiteTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/WebsiteTest.php @@ -28,13 +28,17 @@ /** * @magentoAppIsolation enabled */ -class Mage_Adminhtml_Block_System_Store_Edit_Form_WebsiteTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_System_Store_Edit_Form_WebsiteTest extends Mage_Backend_Area_TestCase { - /** @var Mage_Adminhtml_Block_System_Store_Edit_Form_Website */ + /** + * @var Mage_Adminhtml_Block_System_Store_Edit_Form_Website + */ protected $_block; - public static function setUpBeforeClass() + protected function setUp() { + parent::setUp(); + $registryData = array( 'store_type' => 'website', 'store_data' => Mage::getModel('Mage_Core_Model_Website'), @@ -43,17 +47,7 @@ public static function setUpBeforeClass() foreach ($registryData as $key => $value) { Mage::register($key, $value); } - } - - public static function tearDownAfterClass() - { - Mage::unregister('store_type'); - Mage::unregister('store_data'); - Mage::unregister('store_action'); - } - public function setUp() - { /** @var $layout Mage_Core_Model_Layout */ $layout = Mage::getModel('Mage_Core_Model_Layout'); @@ -62,6 +56,13 @@ public function setUp() $this->_block->toHtml(); } + protected function tearDown() + { + Mage::unregister('store_type'); + Mage::unregister('store_data'); + Mage::unregister('store_action'); + } + public function testPrepareForm() { $form = $this->_block->getForm(); diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/EditTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/EditTest.php index 8b9c081050e3c..bd8a2ad08e33c 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/EditTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/EditTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_System_Store_EditTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_System_Store_EditTest extends Mage_Backend_Area_TestCase { public function tearDown() { diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Tax/Rate/ImportExportTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Tax/Rate/ImportExportTest.php new file mode 100644 index 0000000000000..9b20dc64221a7 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Tax/Rate/ImportExportTest.php @@ -0,0 +1,63 @@ +_block = Mage::app()->getLayout() + ->createBlock('Mage_Adminhtml_Block_Tax_Rate_ImportExport') + ->setArea('adminhtml'); + } + + protected function tearDown() + { + $this->_block = null; + } + + public function testCreateBlock() + { + $this->assertInstanceOf('Mage_Adminhtml_Block_Tax_Rate_ImportExport', $this->_block); + } + + public function testFormExists() + { + $html = $this->_block->toHtml(); + + $this->assertContains( + '
    assertContains( + ' Mage_Core_Model_App_Area::AREA_ADMINHTML)); /** @var $block Mage_Adminhtml_Block_Urlrewrite_Catalog_Category_Edit */ - $block = $layout->createBlock('Mage_Adminhtml_Block_Urlrewrite_Catalog_Category_Edit', '', $blockAttributes); + $block = $layout->createBlock( + 'Mage_Adminhtml_Block_Urlrewrite_Catalog_Category_Edit', '', array('data' => $blockAttributes) + ); $this->_checkSelector($block, $expected); $this->_checkLinks($block, $expected); diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Catalog/Category/TreeTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Catalog/Category/TreeTest.php index b7083ff326f6f..87417b19c0add 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Catalog/Category/TreeTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Catalog/Category/TreeTest.php @@ -28,7 +28,7 @@ /** * Test for Mage_Adminhtml_Block_Urlrewrite_Catalog_Category_Tree */ -class Mage_Adminhtml_Block_Urlrewrite_Catalog_Category_TreeTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Urlrewrite_Catalog_Category_TreeTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Adminhtml_Block_Urlrewrite_Catalog_Category_Tree @@ -40,6 +40,8 @@ class Mage_Adminhtml_Block_Urlrewrite_Catalog_Category_TreeTest extends PHPUnit_ */ protected function setUp() { + parent::setUp(); + $this->_treeBlock = Mage::app()->getLayout() ->createBlock('Mage_Adminhtml_Block_Urlrewrite_Catalog_Category_Tree'); } diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Catalog/Edit/FormTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Catalog/Edit/FormTest.php index 02104d6d2e68f..9163f24a9c448 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Catalog/Edit/FormTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Catalog/Edit/FormTest.php @@ -28,7 +28,7 @@ /** * Test for Mage_Adminhtml_Block_Urlrewrite_Catalog_Edit_FormTest */ -class Mage_Adminhtml_Block_Urlrewrite_Catalog_Edit_FormTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Urlrewrite_Catalog_Edit_FormTest extends Mage_Backend_Area_TestCase { /** * Get form instance @@ -41,7 +41,9 @@ protected function _getFormInstance($args = array()) /** @var $layout Mage_Core_Model_Layout */ $layout = Mage::getModel('Mage_Core_Model_Layout'); /** @var $block Mage_Adminhtml_Block_Urlrewrite_Catalog_Edit_Form */ - $block = $layout->createBlock('Mage_Adminhtml_Block_Urlrewrite_Catalog_Edit_Form', 'block', $args); + $block = $layout->createBlock( + 'Mage_Adminhtml_Block_Urlrewrite_Catalog_Edit_Form', 'block', array('data' => $args) + ); $block->toHtml(); return $block->getForm(); } diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Catalog/Product/EditTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Catalog/Product/EditTest.php index c726980072232..11b06d64dedd9 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Catalog/Product/EditTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Catalog/Product/EditTest.php @@ -28,7 +28,7 @@ /** * Test for Mage_Adminhtml_Block_Urlrewrite_Catalog_Product_Edit */ -class Mage_Adminhtml_Block_Urlrewrite_Catalog_Product_EditTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Urlrewrite_Catalog_Product_EditTest extends Mage_Backend_Area_TestCase { /** * Test prepare layout @@ -44,7 +44,9 @@ public function testPrepareLayout($blockAttributes, $expected) $layout = Mage::getModel('Mage_Core_Model_Layout', array('area' => Mage_Core_Model_App_Area::AREA_ADMINHTML)); /** @var $block Mage_Adminhtml_Block_Urlrewrite_Catalog_Product_Edit */ - $block = $layout->createBlock('Mage_Adminhtml_Block_Urlrewrite_Catalog_Product_Edit', '', $blockAttributes); + $block = $layout->createBlock( + 'Mage_Adminhtml_Block_Urlrewrite_Catalog_Product_Edit', '', array('data' => $blockAttributes) + ); $this->_checkSelector($block, $expected); $this->_checkLinks($block, $expected); diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Catalog/Product/GridTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Catalog/Product/GridTest.php index e81f9c3c49979..fec9bf0ba73ca 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Catalog/Product/GridTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Catalog/Product/GridTest.php @@ -28,7 +28,7 @@ /** * Test for Mage_Adminhtml_Block_Urlrewrite_Catalog_Product_Grid */ -class Mage_Adminhtml_Block_Urlrewrite_Catalog_Product_GridTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Urlrewrite_Catalog_Product_GridTest extends Mage_Backend_Area_TestCase { /** * Test prepare grid diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/Edit/FormTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/Edit/FormTest.php index 0d1ea50b4e1a4..f2a05f00c8437 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/Edit/FormTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/Edit/FormTest.php @@ -28,7 +28,7 @@ /** * Test for Mage_Adminhtml_Block_Urlrewrite_Cms_Page_Edit_FormTest */ -class Mage_Adminhtml_Block_Urlrewrite_Cms_Page_Edit_FormTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Urlrewrite_Cms_Page_Edit_FormTest extends Mage_Backend_Area_TestCase { /** * Get form instance @@ -41,7 +41,9 @@ protected function _getFormInstance($args = array()) /** @var $layout Mage_Core_Model_Layout */ $layout = Mage::getModel('Mage_Core_Model_Layout'); /** @var $block Mage_Adminhtml_Block_Urlrewrite_Cms_Page_Edit_Form */ - $block = $layout->createBlock('Mage_Adminhtml_Block_Urlrewrite_Cms_Page_Edit_Form', 'block', $args); + $block = $layout->createBlock( + 'Mage_Adminhtml_Block_Urlrewrite_Cms_Page_Edit_Form', 'block', array('data' => $args) + ); $block->toHtml(); return $block->getForm(); } diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/EditTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/EditTest.php index 664b2a4e209d0..d7c35951a9615 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/EditTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/EditTest.php @@ -28,7 +28,7 @@ /** * Test for Mage_Adminhtml_Block_Urlrewrite_Cms_Page_Edit */ -class Mage_Adminhtml_Block_Urlrewrite_Cms_Page_EditTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Urlrewrite_Cms_Page_EditTest extends Mage_Backend_Area_TestCase { /** * Test prepare layout @@ -44,7 +44,9 @@ public function testPrepareLayout($blockAttributes, $expected) $layout = Mage::getModel('Mage_Core_Model_Layout', array('area' => Mage_Core_Model_App_Area::AREA_ADMINHTML)); /** @var $block Mage_Adminhtml_Block_Urlrewrite_Cms_Page_Edit */ - $block = $layout->createBlock('Mage_Adminhtml_Block_Urlrewrite_Cms_Page_Edit', '', $blockAttributes); + $block = $layout->createBlock( + 'Mage_Adminhtml_Block_Urlrewrite_Cms_Page_Edit', '', array('data' => $blockAttributes) + ); $this->_checkSelector($block, $expected); $this->_checkLinks($block, $expected); diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/GridTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/GridTest.php index 588b0ed035114..5e7c2fb725a56 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/GridTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Cms/Page/GridTest.php @@ -28,7 +28,7 @@ /** * Test for Mage_Adminhtml_Block_Urlrewrite_Cms_Page_Grid */ -class Mage_Adminhtml_Block_Urlrewrite_Cms_Page_GridTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Urlrewrite_Cms_Page_GridTest extends Mage_Backend_Area_TestCase { /** * Test prepare grid diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Edit/FormTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Edit/FormTest.php index aeced04025029..fb37fe4afc5f2 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Edit/FormTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/Edit/FormTest.php @@ -28,7 +28,7 @@ /** * Test for Mage_Adminhtml_Block_Urlrewrite_Edit_FormTest */ -class Mage_Adminhtml_Block_Urlrewrite_Edit_FormTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Urlrewrite_Edit_FormTest extends Mage_Backend_Area_TestCase { /** * Get form instance @@ -41,7 +41,7 @@ protected function _getFormInstance($args = array()) /** @var $layout Mage_Core_Model_Layout */ $layout = Mage::getModel('Mage_Core_Model_Layout'); /** @var $block Mage_Adminhtml_Block_Urlrewrite_Edit_Form */ - $block = $layout->createBlock('Mage_Adminhtml_Block_Urlrewrite_Edit_Form', 'block', $args); + $block = $layout->createBlock('Mage_Adminhtml_Block_Urlrewrite_Edit_Form', 'block', array('data' => $args)); $block->toHtml(); return $block->getForm(); } diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/EditTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/EditTest.php index 6087ce16e75cb..f59f951851936 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/EditTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Urlrewrite/EditTest.php @@ -28,7 +28,7 @@ /** * Test for Mage_Adminhtml_Block_Urlrewrite_Edit */ -class Mage_Adminhtml_Block_Urlrewrite_EditTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Urlrewrite_EditTest extends Mage_Backend_Area_TestCase { /** * Test prepare layout @@ -45,7 +45,7 @@ public function testPrepareLayout($blockAttributes, $expected) $layout = Mage::getModel('Mage_Core_Model_Layout', array('area' => Mage_Core_Model_App_Area::AREA_ADMINHTML)); /** @var $block Mage_Adminhtml_Block_Urlrewrite_Edit */ - $block = $layout->createBlock('Mage_Adminhtml_Block_Urlrewrite_Edit', '', $blockAttributes); + $block = $layout->createBlock('Mage_Adminhtml_Block_Urlrewrite_Edit', '', array('data' => $blockAttributes)); $this->_checkSelector($block, $expected); $this->_checkButtons($block, $expected); diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Widget/ContainerTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Widget/ContainerTest.php index b25a5d87916ca..22bb5fd658057 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Widget/ContainerTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Widget/ContainerTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Widget_ContainerTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Widget_ContainerTest extends Mage_Backend_Area_TestCase { public function testGetButtonsHtml() { diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Widget/Form/ContainerTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Widget/Form/ContainerTest.php index 221196265c701..88ad132a9bd6b 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Widget/Form/ContainerTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Widget/Form/ContainerTest.php @@ -25,30 +25,8 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Widget_Form_ContainerTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Widget_Form_ContainerTest extends Mage_Backend_Area_TestCase { - /** - * List of block injection classes - * - * @var array - */ - protected $_blockInjections = array( - 'Mage_Core_Controller_Request_Http', - 'Mage_Core_Model_Layout', - 'Mage_Core_Model_Event_Manager', - 'Mage_Backend_Model_Url', - 'Mage_Core_Model_Translate', - 'Mage_Core_Model_Cache', - 'Mage_Core_Model_Design_Package', - 'Mage_Core_Model_Session', - 'Mage_Core_Model_Store_Config', - 'Mage_Core_Controller_Varien_Front', - 'Mage_Core_Model_Factory_Helper', - 'Mage_Core_Model_Dir', - 'Mage_Core_Model_Logger', - 'Magento_Filesystem' - ); - public function testGetFormHtml() { /** @var $layout Mage_Core_Model_Layout */ @@ -56,7 +34,7 @@ public function testGetFormHtml() // Create block with blocking _prepateLayout(), which is used by block to instantly add 'form' child /** @var $block Mage_Adminhtml_Block_Widget_Form_Container */ $block = $this->getMock('Mage_Adminhtml_Block_Widget_Form_Container', array('_prepareLayout'), - $this->_prepareConstructorArguments() + array(Mage::getModel('Mage_Core_Block_Template_Context')) ); $layout->addBlock($block, 'block'); @@ -67,18 +45,4 @@ public function testGetFormHtml() $form->setText($expectedHtml); $this->assertEquals($expectedHtml, $block->getFormHtml()); } - - /** - * List of block constructor arguments - * - * @return array - */ - protected function _prepareConstructorArguments() - { - $arguments = array(); - foreach ($this->_blockInjections as $injectionClass) { - $arguments[] = Mage::getObjectManager()->get($injectionClass); - } - return $arguments; - } } diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Widget/Grid/Massaction/ItemTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Widget/Grid/Massaction/ItemTest.php index beba4c17026b8..b3eca3f3d1aaf 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Widget/Grid/Massaction/ItemTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Widget/Grid/Massaction/ItemTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Widget_Grid_Massaction_ItemTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Widget_Grid_Massaction_ItemTest extends Mage_Backend_Area_TestCase { public function testGetAdditionalActionBlock() { diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Widget/GridTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Widget/GridTest.php index 6333e0e771eb3..8000ad118e876 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Widget/GridTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Widget/GridTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Widget_GridTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Widget_GridTest extends Mage_Backend_Area_TestCase { public function testGetMassactionBlock() { diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Widget/TabsTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Widget/TabsTest.php index 31b1f2b36b051..94220ac8aa0c4 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Widget/TabsTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/Widget/TabsTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Widget_TabsTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Widget_TabsTest extends Mage_Backend_Area_TestCase { /** * @magentoAppIsolation enabled diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Controller/ActionTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Controller/ActionTest.php index bfbe9324b7dfe..c063d7dcff662 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Controller/ActionTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Controller/ActionTest.php @@ -47,11 +47,6 @@ protected function setUp() ); } - protected function tearDown() - { - $this->_model = null; - } - public function testConstruct() { $this->assertInstanceOf('Mage_Backend_Controller_ActionAbstract', $this->_model); diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Helper/DataTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Helper/DataTest.php index 1489f28f867d9..3560bac26deae 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Helper/DataTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Helper_DataTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Helper_DataTest extends Mage_Backend_Area_TestCase { public function testConstructor() { diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Model/Sales/Order/CreateTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Model/Sales/Order/CreateTest.php index 84faede5e7110..b5331b9d89e64 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Model/Sales/Order/CreateTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Model/Sales/Order/CreateTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Model_Sales_Order_CreateTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Model_Sales_Order_CreateTest extends Mage_Backend_Area_TestCase { /** * Model instance @@ -36,13 +36,9 @@ class Mage_Adminhtml_Model_Sales_Order_CreateTest extends PHPUnit_Framework_Test public function setUp() { - /** @var _model Mage_Adminhtml_Model_Sales_Order_Create */ - $this->_model = Mage::getModel('Mage_Adminhtml_Model_Sales_Order_Create'); - } + parent::setUp(); - protected function tearDown() - { - $this->_model = null; + $this->_model = Mage::getModel('Mage_Adminhtml_Model_Sales_Order_Create'); } /** diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Model/SessionTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Model/SessionTest.php index 8f7e28e029e9e..ab23bc74b1332 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Model/SessionTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Model/SessionTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Model_SessionTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Model_SessionTest extends Mage_Backend_Area_TestCase { public function testConstructor() { diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/CacheControllerTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/CacheControllerTest.php new file mode 100644 index 0000000000000..b16e8e5ad43b6 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/CacheControllerTest.php @@ -0,0 +1,166 @@ +dispatch('backend/admin/cache/flushAll'); + + /** @var $cache Mage_Core_Model_Cache */ + $cache = Mage::getModel('Mage_Core_Model_Cache'); + /** @var $cachePool Mage_Core_Model_Cache_Frontend_Pool */ + $this->assertFalse($cache->load('APPLICATION_FIXTURE')); + + $cachePool = Mage::getModel('Mage_Core_Model_Cache_Frontend_Pool'); + /** @var $cacheFrontend Magento_Cache_FrontendInterface */ + foreach ($cachePool as $cacheFrontend) { + $this->assertFalse($cacheFrontend->getBackend()->load('NON_APPLICATION_FIXTURE')); + } + } + + /** + * @magentoDataFixture Mage/Adminhtml/controllers/_files/cache/application_cache.php + * @magentoDataFixture Mage/Adminhtml/controllers/_files/cache/non_application_cache.php + */ + public function testFlushSystemAction() + { + $this->dispatch('backend/admin/cache/flushSystem'); + + /** @var $cache Mage_Core_Model_Cache */ + $cache = Mage::getModel('Mage_Core_Model_Cache'); + /** @var $cachePool Mage_Core_Model_Cache_Frontend_Pool */ + $this->assertFalse($cache->load('APPLICATION_FIXTURE')); + + $cachePool = Mage::getModel('Mage_Core_Model_Cache_Frontend_Pool'); + /** @var $cacheFrontend Magento_Cache_FrontendInterface */ + foreach ($cachePool as $cacheFrontend) { + $this->assertSame('non-application cache data', + $cacheFrontend->getBackend()->load('NON_APPLICATION_FIXTURE')); + } + } + + /** + * @magentoDataFixture Mage/Adminhtml/controllers/_files/cache/all_types_disabled.php + * @dataProvider massActionsDataProvider + * @param array $typesToEnable + */ + public function testMassEnableAction($typesToEnable = array()) + { + $this->getRequest()->setParams(array('types' => $typesToEnable)); + $this->dispatch('backend/admin/cache/massEnable'); + + $types = array_keys(Mage::getModel('Mage_Core_Model_Cache')->getTypes()); + /** @var $cacheTypes Mage_Core_Model_Cache_Types */ + $cacheTypes = Mage::getModel('Mage_Core_Model_Cache_Types'); + foreach ($types as $type) { + if (in_array($type, $typesToEnable)) { + $this->assertTrue($cacheTypes->isEnabled($type), "Type '$type' has not been enabled"); + } else { + $this->assertFalse($cacheTypes->isEnabled($type), "Type '$type' must remain disabled"); + } + } + } + + /** + * @magentoDataFixture Mage/Adminhtml/controllers/_files/cache/all_types_enabled.php + * @dataProvider massActionsDataProvider + * @param array $typesToDisable + */ + public function testMassDisableAction($typesToDisable = array()) + { + $this->getRequest()->setParams(array('types' => $typesToDisable)); + $this->dispatch('backend/admin/cache/massDisable'); + + $types = array_keys(Mage::getModel('Mage_Core_Model_Cache')->getTypes()); + /** @var $cacheTypes Mage_Core_Model_Cache_Types */ + $cacheTypes = Mage::getModel('Mage_Core_Model_Cache_Types'); + foreach ($types as $type) { + if (in_array($type, $typesToDisable)) { + $this->assertFalse($cacheTypes->isEnabled($type), "Type '$type' has not been disabled"); + } else { + $this->assertTrue($cacheTypes->isEnabled($type), "Type '$type' must remain enabled"); + } + } + } + + /** + * @magentoDataFixture Mage/Adminhtml/controllers/_files/cache/all_types_invalidated.php + * @dataProvider massActionsDataProvider + * @param array $typesToRefresh + */ + public function testMassRefreshAction($typesToRefresh = array()) + { + $this->getRequest()->setParams(array('types' => $typesToRefresh)); + $this->dispatch('backend/admin/cache/massRefresh'); + + /** @var $cache Mage_Core_Model_Cache */ + $cache = Mage::getModel('Mage_Core_Model_Cache'); + $invalidatedTypes = array_keys($cache->getInvalidatedTypes()); + $failed = array_intersect($typesToRefresh, $invalidatedTypes); + $this->assertEmpty($failed, 'Could not refresh following cache types: ' . join(', ', $failed)); + + } + + /** + * @return array + */ + public function massActionsDataProvider() + { + return array( + 'no types' => array(array()), + 'existing types' => array(array('config', 'layout', 'block_html')), + ); + } + + /** + * @dataProvider massActionsInvalidTypesDataProvider + * @param $action + */ + public function testMassActionsInvalidTypes($action) + { + $this->getRequest()->setParams(array('types' => array('invalid_type_1', 'invalid_type_2', 'config'))); + $this->dispatch('backend/admin/cache/' . $action); + $this->assertSessionMessages( + $this->contains("Specified cache type(s) don't exist: invalid_type_1, invalid_type_2"), + Mage_Core_Model_Message::ERROR + ); + } + + /** + * @return array + */ + public function massActionsInvalidTypesDataProvider() + { + return array( + 'enable' => array('massEnable'), + 'disable' => array('massDisable'), + 'refresh' => array('massRefresh'), + ); + } +} diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/Catalog/Product/AttributeControllerTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/Catalog/Product/AttributeControllerTest.php index 9e13d09d73ea1..7c462889cb7b4 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/Catalog/Product/AttributeControllerTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/Catalog/Product/AttributeControllerTest.php @@ -36,8 +36,7 @@ public function testSaveActionApplyToDataSystemAttribute() $this->getRequest()->setPost($postData); $this->dispatch('backend/admin/catalog_product_attribute/save'); $model = new Mage_Catalog_Model_Resource_Eav_Attribute( - Mage::getModel('Mage_Core_Model_Event_Manager'), - Mage::getModel('Mage_Core_Model_Cache') + Mage::getModel('Mage_Core_Model_Context') ); $model->load($postData['attribute_id']); $this->assertNull($model->getData('apply_to')); @@ -52,8 +51,7 @@ public function testSaveActionApplyToDataUserDefinedAttribute() $this->getRequest()->setPost($postData); $this->dispatch('backend/admin/catalog_product_attribute/save'); $model = new Mage_Catalog_Model_Resource_Eav_Attribute( - Mage::getModel('Mage_Core_Model_Event_Manager'), - Mage::getModel('Mage_Core_Model_Cache') + Mage::getModel('Mage_Core_Model_Context') ); $model->load($postData['attribute_id']); $this->assertEquals('simple,configurable', $model->getData('apply_to')); @@ -69,8 +67,7 @@ public function testSaveActionApplyToData() $this->getRequest()->setPost($postData); $this->dispatch('backend/admin/catalog_product_attribute/save'); $model = new Mage_Catalog_Model_Resource_Eav_Attribute( - Mage::getModel('Mage_Core_Model_Event_Manager'), - Mage::getModel('Mage_Core_Model_Cache') + Mage::getModel('Mage_Core_Model_Context') ); $model->load($postData['attribute_id']); $this->assertEquals(array('simple', 'configurable'), $model->getApplyTo()); diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/Customer/GroupControllerTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/Customer/GroupControllerTest.php index 04c6318419702..ad9bf13e0b791 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/Customer/GroupControllerTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/Customer/GroupControllerTest.php @@ -31,6 +31,6 @@ public function testNewAction() { $this->dispatch('backend/admin/customer_group/new'); $responseBody = $this->getResponse()->getBody(); - $this->assertContains('

    New Group

    ', $responseBody); + $this->assertRegExp('/

    \s*New Group\s*<\/h1>/', $responseBody); } } diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/CustomerControllerTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/CustomerControllerTest.php index 349567fc87d11..f415cdaa3cccb 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/CustomerControllerTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/CustomerControllerTest.php @@ -58,7 +58,7 @@ public function testSaveActionWithEmptyPostData() { $this->getRequest()->setPost(array()); $this->dispatch('backend/admin/customer/save'); - $this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl . 'index/key')); + $this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl)); } public function testSaveActionWithInvalidFormData() @@ -79,7 +79,7 @@ public function testSaveActionWithInvalidFormData() * Check that customer data were set to session */ $this->assertEquals($post, Mage::getSingleton('Mage_Backend_Model_Session')->getCustomerData()); - $this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl . 'new/key')); + $this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl . 'new')); } public function testSaveActionWithInvalidCustomerAddressData() @@ -106,7 +106,7 @@ public function testSaveActionWithInvalidCustomerAddressData() * Check that customer data were set to session */ $this->assertEquals($post, Mage::getSingleton('Mage_Backend_Model_Session')->getCustomerData()); - $this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl . 'new/key')); + $this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl . 'new')); } /** @@ -162,7 +162,7 @@ public function testSaveActionWithValidCustomerDataAndValidAddressData() $this->assertCount(1, $customer->getAddressesCollection()); $this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl - . 'edit/id/' . $customer->getId() . '/back/1/key/') + . 'edit/id/' . $customer->getId() . '/back/1') ); } diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/Sales/Order/CreditmemoControllerTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/Sales/Order/CreditmemoControllerTest.php index 59acba3ac6704..84ceffe1be154 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/Sales/Order/CreditmemoControllerTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/Sales/Order/CreditmemoControllerTest.php @@ -29,10 +29,11 @@ class Mage_Adminhtml_Sales_Order_CreditmemoControllerTest extends Mage_Backend_U { /** * @magentoConfigFixture current_store cataloginventory/item_options/auto_return 1 - * @magentoDataFixture Mage/Adminhtml/controllers/Sales/_files/order_info.php + * @ magentoDataFixture Mage/Adminhtml/controllers/Sales/_files/order_info.php */ public function testAddCommentAction() { + $this->markTestIncomplete('MAGETWO-7799'); /** @var $stockItem Mage_CatalogInventory_Model_Stock_Item */ $stockItem = Mage::getModel('Mage_CatalogInventory_Model_Stock_Item'); $stockItem->loadByProduct(1); diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/Tax/RateControllerTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/Tax/RateControllerTest.php new file mode 100644 index 0000000000000..e3438721dedb2 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/Tax/RateControllerTest.php @@ -0,0 +1,93 @@ +getRequest()->setPost($postData); + + $this->dispatch('backend/admin/tax_rate/ajaxSave'); + + $jsonBody = $this->getResponse()->getBody(); + $result = Mage::helper('Mage_Core_Helper_Data')->jsonDecode($jsonBody); + + $this->assertArrayHasKey('tax_calculation_rate_id', $result); + + $rateId = $result['tax_calculation_rate_id']; + /** @var $rate Mage_Tax_Model_Calculation_Rate */ + $rate = Mage::getModel('Mage_Tax_Model_Calculation_Rate')->load($rateId, 'tax_calculation_rate_id'); + $this->assertEquals($expectedData['zip_is_range'], $rate->getZipIsRange()); + $this->assertEquals($expectedData['zip_from'], $rate->getZipFrom()); + $this->assertEquals($expectedData['zip_to'], $rate->getZipTo()); + $this->assertEquals($expectedData['tax_postcode'], $rate->getTaxPostcode()); + } + + public function ajaxSaveActionDataProvider() + { + $postData = array( + 'rate' => '10', + 'tax_country_id' => 'US', + 'tax_region_id' => '0', + ); + return array( + array( + $postData + array( + 'code' => 'Rate ' . uniqid(), + 'zip_is_range' => '1', + 'zip_from' => '10000', + 'zip_to' => '20000', + 'tax_postcode' => '*', + ), + array( + 'zip_is_range' => 1, + 'zip_from' => '10000', + 'zip_to' => '20000', + 'tax_postcode' => '10000-20000', + ) + ), + array( + $postData + array( + 'code' => 'Rate ' . uniqid(), + 'zip_is_range' => '0', + 'zip_from' => '10000', + 'zip_to' => '20000', + 'tax_postcode' => '*', + ), + array( + 'zip_is_range' => null, + 'zip_from' => null, + 'zip_to' => null, + 'tax_postcode' => '*', + ) + ), + ); + } +} diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/_files/cache/all_types_disabled.php b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/_files/cache/all_types_disabled.php new file mode 100644 index 0000000000000..70eb9fcf289a6 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/_files/cache/all_types_disabled.php @@ -0,0 +1,34 @@ +getTypes()); + +/** @var $cacheTypes Mage_Core_Model_Cache_Types */ +$cacheTypes = Mage::getObjectManager()->get('Mage_Core_Model_Cache_Types'); +foreach ($types as $type) { + $cacheTypes->setEnabled($type, false); +} +$cacheTypes->persist(); diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/_files/cache/all_types_disabled_rollback.php b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/_files/cache/all_types_disabled_rollback.php new file mode 100644 index 0000000000000..a44d4cebd5061 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/_files/cache/all_types_disabled_rollback.php @@ -0,0 +1,25 @@ +getTypes()); + +/** @var $cacheTypes Mage_Core_Model_Cache_Types */ +$cacheTypes = Mage::getObjectManager()->get('Mage_Core_Model_Cache_Types'); +foreach ($types as $type) { + $cacheTypes->setEnabled($type, true); +} +$cacheTypes->persist(); diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/_files/cache/all_types_enabled_rollback.php b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/_files/cache/all_types_enabled_rollback.php new file mode 100644 index 0000000000000..a44d4cebd5061 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/_files/cache/all_types_enabled_rollback.php @@ -0,0 +1,25 @@ +getTypes()); + +/** @var $cacheTypes Mage_Core_Model_Cache_Types */ +$cacheTypes = Mage::getModel('Mage_Core_Model_Cache_Types'); +$cache->invalidateType($types); diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/_files/cache/all_types_invalidated_rollback.php b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/_files/cache/all_types_invalidated_rollback.php new file mode 100644 index 0000000000000..a44d4cebd5061 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/_files/cache/all_types_invalidated_rollback.php @@ -0,0 +1,25 @@ +save('application data', 'APPLICATION_FIXTURE'); diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/_files/cache/application_cache_rollback.php b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/_files/cache/application_cache_rollback.php new file mode 100644 index 0000000000000..a44d4cebd5061 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/_files/cache/application_cache_rollback.php @@ -0,0 +1,25 @@ +clean(); diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/_files/cache/non_application_cache.php b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/_files/cache/non_application_cache.php new file mode 100644 index 0000000000000..3a8c078225392 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/_files/cache/non_application_cache.php @@ -0,0 +1,30 @@ +getBackend()->save('non-application cache data', 'NON_APPLICATION_FIXTURE', array('SOME_TAG')); +} diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/_files/cache/non_application_cache_rollback.php b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/_files/cache/non_application_cache_rollback.php new file mode 100644 index 0000000000000..a44d4cebd5061 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/_files/cache/non_application_cache_rollback.php @@ -0,0 +1,25 @@ +loadAreaPart(Mage_Core_Model_App_Area::AREA_ADMINHTML, Mage_Core_Model_App_Area::PART_CONFIG); + parent::setUpBeforeClass(); + } +} + diff --git a/dev/tests/integration/testsuite/Mage/Backend/Block/System/Config/FormTest.php b/dev/tests/integration/testsuite/Mage/Backend/Block/System/Config/FormTest.php index bba0a7aea3df6..01880c30ec5f4 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Block/System/Config/FormTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Block/System/Config/FormTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Backend_Block_System_Config_FormTest extends PHPUnit_Framework_TestCase +class Mage_Backend_Block_System_Config_FormTest extends Mage_Backend_Area_TestCase { public function testDependenceHtml() { @@ -133,20 +133,21 @@ public function initFieldsInheritCheckboxDataProvider() Mage::PARAM_BAN_CACHE => true, )); Mage::getConfig()->setCurrentAreaCode('adminhtml'); + Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_ADMINHTML, Mage_Core_Model_App_Area::PART_CONFIG); $configMock = $this->getMock('Mage_Core_Model_Config_Modules_Reader', array(), array(), '', false, false); $configMock->expects($this->any())->method('getModuleConfigurationFiles') ->will($this->returnValue(array(__DIR__ . '/_files/test_section_config.xml'))); $configMock->expects($this->any())->method('getModuleDir') - ->will($this->returnValue(BP . '/app/code/core/Mage/Backend/etc')); + ->will($this->returnValue(BP . '/app/code/Mage/Backend/etc')); - $structureReader = Mage::getSingleton('Mage_Backend_Model_Config_Structure_Reader', - array('moduleReader' => $configMock) - ); - /** @var Mage_Backend_Model_Config_Structure $structure */ - $structure = Mage::getSingleton('Mage_Backend_Model_Config_Structure', array( - 'structureReader' => $structureReader, + Mage::getObjectManager()->configure(array( + 'Mage_Backend_Model_Config_Structure_Reader' => array( + 'parameters' => array('moduleReader' => $configMock) + ) )); + /** @var Mage_Backend_Model_Config_Structure $structure */ + $structure = Mage::getSingleton('Mage_Backend_Model_Config_Structure'); /** @var Mage_Backend_Model_Config_Structure_Element_Section $section */ $section = $structure->getElement('test_section'); diff --git a/dev/tests/integration/testsuite/Mage/Backend/Block/TemplateTest.php b/dev/tests/integration/testsuite/Mage/Backend/Block/TemplateTest.php index 8ce854ca5fd4a..96c6d7b953e2f 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Block/TemplateTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Block/TemplateTest.php @@ -28,7 +28,7 @@ /** * Test class for Mage_Backend_Block_Template. */ -class Mage_Backend_Block_TemplateTest extends PHPUnit_Framework_TestCase +class Mage_Backend_Block_TemplateTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Backend_Block_Template @@ -37,14 +37,10 @@ class Mage_Backend_Block_TemplateTest extends PHPUnit_Framework_TestCase protected function setUp() { + parent::setUp(); $this->_block = Mage::app()->getLayout()->createBlock('Mage_Backend_Block_Template'); } - protected function tearDown() - { - $this->_block = null; - } - /** * @covers Mage_Backend_Block_Template::getFormKey */ diff --git a/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/ContainerTest.php b/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/ContainerTest.php index beef5aa82b3fa..5cee7dfb93757 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/ContainerTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/ContainerTest.php @@ -21,15 +21,15 @@ * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Backend_Block_Widget_ContainerTest extends PHPUnit_Framework_TestCase +class Mage_Backend_Block_Widget_ContainerTest extends Mage_Backend_Area_TestCase { public function testPseudoConstruct() { /** @var $block Mage_Backend_Block_Widget_Container */ - $block = Mage::app()->getLayout()->createBlock('Mage_Backend_Block_Widget_Container', '', array( + $block = Mage::app()->getLayout()->createBlock('Mage_Backend_Block_Widget_Container', '', array('data' => array( Mage_Backend_Block_Widget_Container::PARAM_CONTROLLER => 'one', Mage_Backend_Block_Widget_Container::PARAM_HEADER_TEXT => 'two', - )); + ))); $this->assertStringEndsWith('one', $block->getHeaderCssClass()); $this->assertContains('two', $block->getHeaderText()); } diff --git a/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/FormTest.php b/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/FormTest.php index a87c831d4cb6b..82f780b4eeb69 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/FormTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/FormTest.php @@ -28,7 +28,7 @@ /** * Test class for Mage_Backend_Block_Widget_Form */ -class Mage_Backend_Block_Widget_FormTest extends PHPUnit_Framework_TestCase +class Mage_Backend_Block_Widget_FormTest extends Mage_Backend_Area_TestCase { /** * @magentoDataFixture Mage/Core/_files/init_adminhtml_design.php diff --git a/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/Grid/ColumnSetTest.php b/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/Grid/ColumnSetTest.php index be07887c3ee52..99a759217588f 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/Grid/ColumnSetTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/Grid/ColumnSetTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Backend_Block_Widget_Grid_ColumnSetTest extends PHPUnit_Framework_TestCase +class Mage_Backend_Block_Widget_Grid_ColumnSetTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Backend_Block_Widget_Grid_ColumnSet @@ -44,6 +44,8 @@ class Mage_Backend_Block_Widget_Grid_ColumnSetTest extends PHPUnit_Framework_Tes protected function setUp() { + parent::setUp(); + $this->_columnMock = $this->getMock('Mage_Backend_Block_Widget_Grid_Column', array('setSortable', 'setRendererType', 'setFilterType', 'addHeaderCssClass', 'setGrid'), array(), '', false @@ -53,8 +55,9 @@ protected function setUp() array($this->_columnMock) )); + $context = Mage::getModel('Mage_Core_Block_Template_Context', array('layout' => $this->_layoutMock)); $this->_block = Mage::app()->getLayout()->createBlock( - 'Mage_Backend_Block_Widget_Grid_ColumnSet', '', array('layout' => $this->_layoutMock) + 'Mage_Backend_Block_Widget_Grid_ColumnSet', '', array('context' => $context) ); } diff --git a/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/Grid/ContainerTest.php b/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/Grid/ContainerTest.php index f4b681b657f7f..b042da0c47dde 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/Grid/ContainerTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/Grid/ContainerTest.php @@ -21,17 +21,19 @@ * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Backend_Block_Widget_Grid_ContainerTest extends PHPUnit_Framework_TestCase +class Mage_Backend_Block_Widget_Grid_ContainerTest extends Mage_Backend_Area_TestCase { public function testPseudoConstruct() { /** @var $block Mage_Backend_Block_Widget_Grid_Container */ $block = Mage::app()->getLayout()->createBlock('Mage_Backend_Block_Widget_Grid_Container', '', array( - Mage_Backend_Block_Widget_Container::PARAM_CONTROLLER => 'widget', - Mage_Backend_Block_Widget_Container::PARAM_HEADER_TEXT => 'two', - Mage_Backend_Block_Widget_Grid_Container::PARAM_BLOCK_GROUP => 'Mage_Backend', - Mage_Backend_Block_Widget_Grid_Container::PARAM_BUTTON_NEW => 'four', - Mage_Backend_Block_Widget_Grid_Container::PARAM_BUTTON_BACK => 'five', + 'data' => array( + Mage_Backend_Block_Widget_Container::PARAM_CONTROLLER => 'widget', + Mage_Backend_Block_Widget_Container::PARAM_HEADER_TEXT => 'two', + Mage_Backend_Block_Widget_Grid_Container::PARAM_BLOCK_GROUP => 'Mage_Backend', + Mage_Backend_Block_Widget_Grid_Container::PARAM_BUTTON_NEW => 'four', + Mage_Backend_Block_Widget_Grid_Container::PARAM_BUTTON_BACK => 'five', + ) )); $this->assertStringEndsWith('widget', $block->getHeaderCssClass()); $this->assertContains('two', $block->getHeaderText()); diff --git a/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/Grid/ExtendedTest.php b/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/Grid/ExtendedTest.php index 34a81dc30c0d9..a27923d9024f7 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/Grid/ExtendedTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/Grid/ExtendedTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Backend_Block_Widget_Grid_ExtendedTest extends PHPUnit_Framework_TestCase +class Mage_Backend_Block_Widget_Grid_ExtendedTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Backend_Block_Widget_Grid_Extended @@ -39,9 +39,12 @@ class Mage_Backend_Block_Widget_Grid_ExtendedTest extends PHPUnit_Framework_Test protected function setUp() { + parent::setUp(); + $this->_layoutMock = Mage::getModel('Mage_Core_Model_Layout'); + $context = Mage::getModel('Mage_Core_Block_Template_Context', array('layout' => $this->_layoutMock)); $this->_block = $this->_layoutMock->createBlock( - 'Mage_Backend_Block_Widget_Grid_Extended', 'grid', array('layout' => $this->_layoutMock) + 'Mage_Backend_Block_Widget_Grid_Extended', 'grid', array('context' => $context) ); $this->_block->addColumn('column1', @@ -52,12 +55,6 @@ protected function setUp() ); } - protected function tearDown() - { - unset($this->_layoutMock); - unset($this->_block); - } - public function testAddColumnAddsChildToColumnSet() { $this->assertInstanceOf( diff --git a/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/Grid/MassactionTest.php b/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/Grid/MassactionTest.php index 0ebf7ddb579f6..db1a810ec9aa5 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/Grid/MassactionTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/Grid/MassactionTest.php @@ -28,7 +28,7 @@ /** * @magentoDataFixture Mage/Backend/Block/_files/backend_theme.php */ -class Mage_Backend_Block_Widget_Grid_MassactionTest extends PHPUnit_Framework_TestCase +class Mage_Backend_Block_Widget_Grid_MassactionTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Backend_Block_Widget_Grid_Massaction @@ -43,6 +43,9 @@ class Mage_Backend_Block_Widget_Grid_MassactionTest extends PHPUnit_Framework_Te protected function setUp() { $this->markTestIncomplete('MAGETWO-6406'); + + parent::setUp(); + $this->_setFixtureTheme(); $this->_layout = Mage::getModel('Mage_Core_Model_Layout', array('area' => 'adminhtml')); @@ -72,12 +75,6 @@ protected function _setFixtureTheme() ); } - protected function tearDown() - { - unset($this->_layout); - unset($this->_block); - } - /** * @covers Mage_Backend_Block_Widget_Grid_Massaction::getItems * @covers Mage_Backend_Block_Widget_Grid_Massaction::getCount diff --git a/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/GridTest.php b/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/GridTest.php index 28f9eb60ef498..3e549d285678f 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/GridTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Block/Widget/GridTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Backend_Block_Widget_GridTest extends PHPUnit_Framework_TestCase +class Mage_Backend_Block_Widget_GridTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Backend_Block_Widget_Grid_ColumnSet @@ -70,13 +70,6 @@ protected function setUp() $this->_block->setNameInLayout('grid'); } - protected function tearDown() - { - $this->_block = null; - $this->_layoutMock = null; - $this->_columnSetMock = null; - } - /** * Retrieve the mocked column set block instance * @@ -86,20 +79,10 @@ protected function _getColumnSetMock() { $filesystem = new Magento_Filesystem(new Magento_Filesystem_Adapter_Local); return $this->getMock('Mage_Backend_Block_Widget_Grid_ColumnSet', array(), array( - Mage::getModel('Mage_Core_Controller_Request_Http'), - Mage::getModel('Mage_Core_Model_Layout'), - Mage::getModel('Mage_Core_Model_Event_Manager'), - Mage::getModel('Mage_Backend_Model_Url'), - Mage::getModel('Mage_Core_Model_Translate'), - Mage::getModel('Mage_Core_Model_Cache'), - Mage::getModel('Mage_Core_Model_Design_Package'), - Mage::getModel('Mage_Core_Model_Session'), - Mage::getModel('Mage_Core_Model_Store_Config'), - Mage::getModel('Mage_Core_Controller_Varien_Front'), - Mage::getModel('Mage_Core_Model_Factory_Helper'), - new Mage_Core_Model_Dir($filesystem, __DIR__), - Mage::getModel('Mage_Core_Model_Logger'), - $filesystem, + Mage::getModel('Mage_Core_Block_Template_Context', array( + 'dirs' => new Mage_Core_Model_Dir($filesystem, __DIR__), + 'filesystem' => $filesystem + )), Mage::getModel('Mage_Backend_Helper_Data'), Mage::getModel('Mage_Backend_Model_Widget_Grid_Row_UrlGeneratorFactory'), Mage::getModel('Mage_Backend_Model_Widget_Grid_SubTotals'), diff --git a/dev/tests/integration/testsuite/Mage/Backend/Block/WidgetTest.php b/dev/tests/integration/testsuite/Mage/Backend/Block/WidgetTest.php index cd5a08530fcac..c1c854daa1bc6 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Block/WidgetTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Block/WidgetTest.php @@ -28,7 +28,7 @@ /** * Test class for Mage_Backend_Block_Widget */ -class Mage_Backend_Block_WidgetTest extends PHPUnit_Framework_TestCase +class Mage_Backend_Block_WidgetTest extends Mage_Backend_Area_TestCase { /** * @covers Mage_Backend_Block_Widget::getButtonHtml diff --git a/dev/tests/integration/testsuite/Mage/Backend/Controller/ActionAbstractTest.php b/dev/tests/integration/testsuite/Mage/Backend/Controller/ActionAbstractTest.php index 44f5fa237e28f..5f5e9db926427 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Controller/ActionAbstractTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Controller/ActionAbstractTest.php @@ -37,7 +37,11 @@ class Mage_Backend_Controller_ActionAbstractTest extends Mage_Backend_Utility_Co */ public function testPreDispatchWithEmptyUrlRedirectsToStartupPage() { - $expected = Mage::getSingleton('Mage_Backend_Model_Url')->getUrl('adminhtml/dashboard'); + Mage::getConfig()->setCurrentAreaCode(Mage::helper("Mage_Backend_Helper_Data")->getAreaCode()); + /** @var $backendUrlModel Mage_Backend_Model_Url */ + $backendUrlModel = Mage::getObjectManager()->get('Mage_Backend_Model_Url'); + $url = $backendUrlModel->getStartupPageUrl(); + $expected = $backendUrlModel->getUrl($url); $this->dispatch('backend'); $this->assertRedirect($this->stringStartsWith($expected)); } @@ -87,7 +91,7 @@ public function testAclInNodes($blockName, $resource, $isLimitedAccess) $this->_auth->login(Magento_Test_Bootstrap::ADMIN_NAME, Magento_Test_Bootstrap::ADMIN_PASSWORD); /** @var $acl Magento_Acl */ - $acl = Mage::getSingleton('Mage_Core_Model_Acl_Builder')->getAcl(); + $acl = Mage::getSingleton('Mage_Core_Model_Acl_Builder')->getAcl(Mage_Core_Model_App_Area::AREA_ADMINHTML); if ($isLimitedAccess) { $acl->deny(null, $resource); } diff --git a/dev/tests/integration/testsuite/Mage/Backend/Controller/Router/DefaultTest.php b/dev/tests/integration/testsuite/Mage/Backend/Controller/Router/DefaultTest.php index 7fc4be050f264..4244655bbaf90 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Controller/Router/DefaultTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Controller/Router/DefaultTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Backend_Controller_Router_DefaultTest extends PHPUnit_Framework_TestCase +class Mage_Backend_Controller_Router_DefaultTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Backend_Controller_Router_Default @@ -39,6 +39,8 @@ class Mage_Backend_Controller_Router_DefaultTest extends PHPUnit_Framework_TestC protected function setUp() { + parent::setUp(); + $options = array( 'areaCode' => Mage::helper('Mage_Backend_Helper_Data')->getAreaCode(), 'baseController' => 'Mage_Backend_Controller_ActionAbstract', @@ -48,11 +50,6 @@ protected function setUp() $this->_model->setFront($this->_frontMock); } - protected function tearDown() - { - $this->_model = null; - } - public function testRouterCannotProcessRequestsWithWrongFrontName() { $request = $this->getMock('Mage_Core_Controller_Request_Http'); diff --git a/dev/tests/integration/testsuite/Mage/Backend/Controller/Router/Validator/DefaultTest.php b/dev/tests/integration/testsuite/Mage/Backend/Controller/Router/Validator/DefaultTest.php index 2c4fc0457de77..ab7ba29bb79c6 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Controller/Router/Validator/DefaultTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Controller/Router/Validator/DefaultTest.php @@ -28,7 +28,7 @@ /** * Test class Mage_Backend_Controller_Router_Default */ -class Mage_Backend_Controller_Router_Validator_DefaultTest extends PHPUnit_Framework_TestCase +class Mage_Backend_Controller_Router_Validator_DefaultTest extends Mage_Backend_Area_TestCase { /** * @magentoConfigFixture global/areas/adminhtml/frontName 0 diff --git a/dev/tests/integration/testsuite/Mage/Backend/Helper/DataTest.php b/dev/tests/integration/testsuite/Mage/Backend/Helper/DataTest.php index 7ad09cdd928e8..00cc1d71115f6 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Helper/DataTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Backend_Helper_DataTest extends PHPUnit_Framework_TestCase +class Mage_Backend_Helper_DataTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Backend_Helper_Data @@ -39,6 +39,9 @@ class Mage_Backend_Helper_DataTest extends PHPUnit_Framework_TestCase protected function setUp() { + parent::setUp(); + + Mage::getConfig()->setCurrentAreaCode(Mage_Core_Model_App_Area::AREA_ADMINHTML); $this->_helper = Mage::helper('Mage_Backend_Helper_Data'); } @@ -46,6 +49,7 @@ protected function tearDown() { $this->_helper = null; $this->_auth = null; + Mage::getConfig()->setCurrentAreaCode(null); } /** diff --git a/dev/tests/integration/testsuite/Mage/Backend/Model/Auth/SessionTest.php b/dev/tests/integration/testsuite/Mage/Backend/Model/Auth/SessionTest.php index 74397eb407e7c..33779898423f5 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Model/Auth/SessionTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Model/Auth/SessionTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Backend_Model_Auth_SessionTest extends PHPUnit_Framework_TestCase +class Mage_Backend_Model_Auth_SessionTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Backend_Model_Auth @@ -39,6 +39,8 @@ class Mage_Backend_Model_Auth_SessionTest extends PHPUnit_Framework_TestCase public function setUp() { + parent::setUp(); + Mage::getConfig()->setCurrentAreaCode(Mage_Core_Model_App_Area::AREA_ADMINHTML); $this->_auth = Mage::getModel('Mage_Backend_Model_Auth'); $this->_model = Mage::getModel('Mage_Backend_Model_Auth_Session'); $this->_auth->setAuthStorage($this->_model); @@ -47,6 +49,7 @@ public function setUp() protected function tearDown() { $this->_model = null; + Mage::getConfig()->setCurrentAreaCode(null); } /** diff --git a/dev/tests/integration/testsuite/Mage/Backend/Model/AuthTest.php b/dev/tests/integration/testsuite/Mage/Backend/Model/AuthTest.php index 5f772eb702846..7d11360c02a47 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Model/AuthTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Model/AuthTest.php @@ -28,7 +28,7 @@ /** * Test class for Mage_Backend_Model_Auth. */ -class Mage_Backend_Model_AuthTest extends PHPUnit_Framework_TestCase +class Mage_Backend_Model_AuthTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Backend_Model_Auth @@ -37,15 +37,12 @@ class Mage_Backend_Model_AuthTest extends PHPUnit_Framework_TestCase public function setUp() { + parent::setUp(); + Mage::app()->loadArea(Mage_Core_Model_App_Area::AREA_ADMINHTML); $this->_model = Mage::getModel('Mage_Backend_Model_Auth'); } - protected function tearDown() - { - $this->_model = null; - } - /** * @expectedException Mage_Backend_Model_Auth_Exception */ diff --git a/dev/tests/integration/testsuite/Mage/Backend/Model/Config/Backend/Admin/RobotsTest.php b/dev/tests/integration/testsuite/Mage/Backend/Model/Config/Backend/Admin/RobotsTest.php index 63335a7cfdef7..9e375b976aaac 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Model/Config/Backend/Admin/RobotsTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Model/Config/Backend/Admin/RobotsTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Backend_Model_Config_Backend_Admin_RobotsTest extends PHPUnit_Framework_TestCase +class Mage_Backend_Model_Config_Backend_Admin_RobotsTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Backend_Model_Config_Backend_Admin_Robots @@ -37,6 +37,8 @@ class Mage_Backend_Model_Config_Backend_Admin_RobotsTest extends PHPUnit_Framewo */ protected function setUp() { + parent::setUp(); + $this->_model = Mage::getModel('Mage_Backend_Model_Config_Backend_Admin_Robots'); $this->_model->setPath('design/search_engine_robots/custom_instructions'); $this->_model->afterLoad(); diff --git a/dev/tests/integration/testsuite/Mage/Backend/Model/Config/Backend/BaseurlTest.php b/dev/tests/integration/testsuite/Mage/Backend/Model/Config/Backend/BaseurlTest.php index 400449e214695..ce19e598fccd9 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Model/Config/Backend/BaseurlTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Model/Config/Backend/BaseurlTest.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Backend_Model_Config_Backend_BaseurlTest extends PHPUnit_Framework_TestCase +class Mage_Backend_Model_Config_Backend_BaseurlTest extends Mage_Backend_Area_TestCase { /** * @param string $path diff --git a/dev/tests/integration/testsuite/Mage/Backend/Model/Config/Source/Admin/PageTest.php b/dev/tests/integration/testsuite/Mage/Backend/Model/Config/Source/Admin/PageTest.php index 8300bea328f4f..a0b439ea893c1 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Model/Config/Source/Admin/PageTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Model/Config/Source/Admin/PageTest.php @@ -44,7 +44,7 @@ public function testToOptionArray() $this->assertGreaterThan(0, $optionsCount, 'There must be present menu items at the admin backend'); - $this->assertEquals('Dashboard', $options->item(0)->nodeValue, 'First element is not Dashboard'); - $this->assertContains('Configuration', $options->item($optionsCount - 1)->nodeValue); + $this->assertEquals('Mage_Adminhtml::dashboard', $options->item(0)->getAttribute('value'), + 'First element is not Dashboard'); } } diff --git a/dev/tests/integration/testsuite/Mage/Backend/Model/ConfigTest.php b/dev/tests/integration/testsuite/Mage/Backend/Model/ConfigTest.php index a489ee3bf5751..2791767a153da 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Model/ConfigTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Model/ConfigTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Backend_Model_Config_DataTest extends PHPUnit_Framework_TestCase +class Mage_Backend_Model_Config_DataTest extends Mage_Backend_Area_TestCase { /** * @covers Mage_Backend_Model_Config::save diff --git a/dev/tests/integration/testsuite/Mage/Backend/Model/MenuTest.php b/dev/tests/integration/testsuite/Mage/Backend/Model/MenuTest.php index a3cf69b69bef3..0fefa7788684b 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Model/MenuTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Model/MenuTest.php @@ -28,7 +28,7 @@ /** * Test class for Mage_Backend_Model_Auth. */ -class Mage_Backend_Model_MenuTest extends PHPUnit_Framework_TestCase +class Mage_Backend_Model_MenuTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Backend_Model_Menu @@ -37,16 +37,12 @@ class Mage_Backend_Model_MenuTest extends PHPUnit_Framework_TestCase public function setUp() { + parent::setUp(); Mage::app()->loadArea(Mage_Core_Model_App_Area::AREA_ADMINHTML); $this->_model = Mage::getModel('Mage_Backend_Model_Auth'); Mage::getConfig()->setCurrentAreaCode(Mage::helper('Mage_Backend_Helper_Data')->getAreaCode()); } - protected function tearDown() - { - $this->_model = null; - } - public function testMenuItemManipulation() { /* @var $menu Mage_Backend_Model_Menu */ @@ -55,7 +51,7 @@ public function testMenuItemManipulation() $itemFactory = Mage::getModel('Mage_Backend_Model_Menu_Item_Factory'); // Add new item in top level - $menu->add($itemFactory->createFromArray(array( + $menu->add($itemFactory->create(array( 'id' => 'Mage_Backend::system2', 'title' => 'Extended System', 'module' => 'Mage_Backend', @@ -63,7 +59,7 @@ public function testMenuItemManipulation() ))); //Add submenu - $menu->add($itemFactory->createFromArray(array( + $menu->add($itemFactory->create(array( 'id' => 'Mage_Backend::system2_acl', 'title' => 'Acl', 'module' => 'Mage_Backend', diff --git a/dev/tests/integration/testsuite/Mage/Backend/Model/ObserverTest.php b/dev/tests/integration/testsuite/Mage/Backend/Model/ObserverTest.php index 513ffd9e0836f..6a6b2f0abda4f 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Model/ObserverTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Model/ObserverTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Backend_Model_ObserverTest extends PHPUnit_Framework_TestCase +class Mage_Backend_Model_ObserverTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Backend_Model_Observer @@ -34,14 +34,10 @@ class Mage_Backend_Model_ObserverTest extends PHPUnit_Framework_TestCase public function setUp() { + parent::setUp(); $this->_model = Mage::getModel('Mage_Backend_Model_Observer'); } - protected function tearDown() - { - $this->_model = null; - } - public function testActionPreDispatchAdminNotLogged() { $this->markTestSkipped('Skipped because of authentication process moved into base controller.'); diff --git a/dev/tests/integration/testsuite/Mage/Backend/Model/SessionTest.php b/dev/tests/integration/testsuite/Mage/Backend/Model/SessionTest.php index f0e4ab520bf0a..4a5d9ced0c779 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Model/SessionTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Model/SessionTest.php @@ -29,7 +29,7 @@ * Test class for Mage_Backend_Model_Session. * */ -class Mage_Backend_Model_SessionTest extends PHPUnit_Framework_TestCase +class Mage_Backend_Model_SessionTest extends Mage_Backend_Area_TestCase { public function testContructor() { diff --git a/dev/tests/integration/testsuite/Mage/Backend/Model/UrlTest.php b/dev/tests/integration/testsuite/Mage/Backend/Model/UrlTest.php index d86423d5b6d13..18328d40195e9 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Model/UrlTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Model/UrlTest.php @@ -28,7 +28,7 @@ /** * Test class for Mage_Backend_Model_Url. */ -class Mage_Backend_Model_UrlTest extends PHPUnit_Framework_TestCase +class Mage_Backend_Model_UrlTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Backend_Model_Url @@ -37,14 +37,10 @@ class Mage_Backend_Model_UrlTest extends PHPUnit_Framework_TestCase protected function setUp() { + parent::setUp(); $this->_model = Mage::getModel('Mage_Backend_Model_Url'); } - protected function tearDown() - { - $this->_model = null; - } - /** * @covers Mage_Backend_Model_Url::getSecure */ diff --git a/dev/tests/integration/testsuite/Mage/Backend/Utility/Controller.php b/dev/tests/integration/testsuite/Mage/Backend/Utility/Controller.php index ad6daa82b4fe3..de1da6ebef8fb 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Utility/Controller.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Utility/Controller.php @@ -49,7 +49,7 @@ protected function setUp() Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_ADMINHTML, Mage_Core_Model_App_Area::PART_CONFIG); Mage::getSingleton('Mage_Backend_Model_Url')->turnOffSecretKey(); - $this->_auth = Mage::getModel('Mage_Backend_Model_Auth'); + $this->_auth = Mage::getSingleton('Mage_Backend_Model_Auth'); $this->_session = $this->_auth->getAuthStorage(); $this->_auth->login(Magento_Test_Bootstrap::ADMIN_NAME, Magento_Test_Bootstrap::ADMIN_PASSWORD); } @@ -61,6 +61,7 @@ protected function tearDown() $this->_session = null; Mage::getSingleton('Mage_Backend_Model_Url')->turnOnSecretKey(); + Mage::getConfig()->setCurrentAreaCode(null); parent::tearDown(); } diff --git a/dev/tests/integration/testsuite/Mage/Backend/controllers/Adminhtml/AuthControllerTest.php b/dev/tests/integration/testsuite/Mage/Backend/controllers/Adminhtml/AuthControllerTest.php index 5d290e6ed6b20..70d286305d053 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/controllers/Adminhtml/AuthControllerTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/controllers/Adminhtml/AuthControllerTest.php @@ -40,11 +40,19 @@ class Mage_Backend_Adminhtml_AuthControllerTest extends Magento_Test_TestCase_Co */ protected $_auth; + protected function setUp() + { + Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_ADMINHTML, Mage_Core_Model_App_Area::PART_CONFIG); + Mage::getConfig()->setCurrentAreaCode(Mage_Core_Model_App_Area::AREA_ADMINHTML); + parent::setUp(); + } + protected function tearDown() { $this->_session = null; $this->_auth = null; parent::tearDown(); + Mage::getConfig()->setCurrentAreaCode(null); } /** @@ -92,7 +100,8 @@ public function testLoggedLoginAction() $this->dispatch('backend/admin/auth/login'); /** @var $backendUrlModel Mage_Backend_Model_Url */ $backendUrlModel = Mage::getObjectManager()->get('Mage_Backend_Model_Url'); - $expected = $backendUrlModel->getUrl('adminhtml/dashboard'); + $url = $backendUrlModel->getStartupPageUrl(); + $expected = $backendUrlModel->getUrl($url); $this->assertRedirect($this->stringStartsWith($expected)); $this->_logout(); diff --git a/dev/tests/integration/testsuite/Mage/Backend/controllers/Adminhtml/IndexControllerTest.php b/dev/tests/integration/testsuite/Mage/Backend/controllers/Adminhtml/IndexControllerTest.php index 0def7b315ac1e..7bb5dbc9c2738 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/controllers/Adminhtml/IndexControllerTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/controllers/Adminhtml/IndexControllerTest.php @@ -36,10 +36,18 @@ class Mage_Backend_Adminhtml_IndexControllerTest extends Magento_Test_TestCase_C */ protected $_auth; + protected function setUp() + { + Mage::getConfig()->setCurrentAreaCode(Mage_Core_Model_App_Area::AREA_ADMINHTML); + Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_ADMINHTML, Mage_Core_Model_App_Area::PART_CONFIG); + parent::setUp(); + } + protected function tearDown() { $this->_auth = null; parent::tearDown(); + Mage::getConfig()->setCurrentAreaCode(null); } /** diff --git a/dev/tests/integration/testsuite/Mage/Bundle/Model/ProductTest.php b/dev/tests/integration/testsuite/Mage/Bundle/Model/ProductTest.php index 0d6042564565c..50fdf10ebbd0f 100644 --- a/dev/tests/integration/testsuite/Mage/Bundle/Model/ProductTest.php +++ b/dev/tests/integration/testsuite/Mage/Bundle/Model/ProductTest.php @@ -42,11 +42,6 @@ protected function setUp() $this->_model->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_BUNDLE); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetTypeId() { $this->assertEquals(Mage_Catalog_Model_Product_Type::TYPE_BUNDLE, $this->_model->getTypeId()); diff --git a/dev/tests/integration/testsuite/Mage/Captcha/Block/Captcha/DefaultTest.php b/dev/tests/integration/testsuite/Mage/Captcha/Block/Captcha/DefaultTest.php index de36e1f3a786f..84ee1d06119ff 100644 --- a/dev/tests/integration/testsuite/Mage/Captcha/Block/Captcha/DefaultTest.php +++ b/dev/tests/integration/testsuite/Mage/Captcha/Block/Captcha/DefaultTest.php @@ -52,7 +52,7 @@ public function testGetRefreshUrlWhenFrontendStore() */ public function testGetRefreshUrlWhenIsAdminStore() { - Mage::app()->getStore('admin')->setUrlClassName('Mage_Backend_Model_Url'); + Mage::app()->getStore('admin')->setUrlModel(Mage::getModel('Mage_Backend_Model_Url')); Mage::app()->setCurrentStore(Mage::app()->getStore('admin')); $this->assertContains('backend/admin/refresh/refresh', $this->_block->getRefreshUrl()); diff --git a/dev/tests/integration/testsuite/Mage/Captcha/Model/ObserverTest.php b/dev/tests/integration/testsuite/Mage/Captcha/Model/ObserverTest.php index 514fbb97db64a..5bc524cf98c87 100644 --- a/dev/tests/integration/testsuite/Mage/Captcha/Model/ObserverTest.php +++ b/dev/tests/integration/testsuite/Mage/Captcha/Model/ObserverTest.php @@ -30,6 +30,11 @@ */ class Mage_Captcha_Model_ObserverTest extends Magento_Test_TestCase_ControllerAbstract { + protected function setUp() + { + parent::setUp(); + Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_ADMINHTML, Mage_Core_Model_App_Area::PART_CONFIG); + } /** * @magentoConfigFixture admin_store admin/captcha/forms backend_login * @magentoConfigFixture admin_store admin/captcha/enable 1 diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Block/Product/AbstractTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Block/Product/AbstractTest.php index 190b77293f845..d9ef1a6e2fd43 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Block/Product/AbstractTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Block/Product/AbstractTest.php @@ -74,12 +74,6 @@ protected function setUp() $this->_block->setProduct($this->_product); } - protected function tearDown() - { - $this->_block = null; - $this->_product = null; - } - public function testGetAddToCartUrl() { $url = $this->_block->getAddToCartUrl($this->_product); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Block/Product/List/RelatedTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Block/Product/List/RelatedTest.php index 88e9950ab32e4..d9e4fc79a6222 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Block/Product/List/RelatedTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Block/Product/List/RelatedTest.php @@ -33,20 +33,45 @@ */ class Mage_Catalog_Block_Product_List_RelatedTest extends PHPUnit_Framework_TestCase { - public function testAll() - { - $product = Mage::getModel('Mage_Catalog_Model_Product'); - $product->load(2); - Mage::register('product', $product); - /** @var $block Mage_Catalog_Block_Product_List_Related */ - $block = Mage::app()->getLayout()->createBlock('Mage_Catalog_Block_Product_List_Related'); - $block->setLayout(Mage::getModel('Mage_Core_Model_Layout')); - $block->setTemplate('product/list/related.phtml'); + /** + * @var Mage_Catalog_Block_Product_List_Related + */ + protected $_block; + + /** + * @var Mage_Catalog_Model_Product + */ + protected $_product; - $html = $block->toHtml(); + protected function setUp() + { + $this->_block = Mage::getObjectManager()->create('Mage_Catalog_Block_Product_List_Related'); + $this->_block->setTemplate('Mage_Catalog::product/list/related.twig'); + $this->_product = Mage::getModel('Mage_Catalog_Model_Product'); + $this->_product->load(1); + $this->_product->setDoNotUseCategoryId(true); + $items = array(); + $items[] = array( + 'thumbnailUrl' => "", + 'thumbnailSize' => 50, + 'composite' => $this->_product->isComposite(), + 'saleable' => $this->_product->isSaleable(), + 'hasRequiredOptions' => $this->_product->getRequiredOptions(), + 'id' => $this->_product->getId(), + 'productUrl' => $this->_product->getProductUrl(), + 'name' => $this->_product->getName(), + 'product' => $this->_product + ); + $this->_block->assign(array("block" => $this->_block, "related" => array("items" => $items))); + Mage::unregister('product'); + Mage::register('product', $this->_product); + } + + public function testGetRelated() + { + $html = $this->_block->toHtml(); $this->assertNotEmpty($html); $this->assertContains('Simple Related Product', $html); /* name */ $this->assertContains('product/1/', $html); /* part of url */ - $this->assertInstanceOf('Mage_Catalog_Model_Resource_Product_Link_Product_Collection', $block->getItems()); } } diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Block/Product/ListTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Block/Product/ListTest.php index c77d0f5394e45..cef6cfed7ff91 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Block/Product/ListTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Block/Product/ListTest.php @@ -42,11 +42,6 @@ protected function setUp() $this->_block = Mage::app()->getLayout()->createBlock('Mage_Catalog_Block_Product_List'); } - protected function tearDown() - { - $this->_block = null; - } - public function testGetLayer() { $this->assertInstanceOf('Mage_Catalog_Model_Layer', $this->_block->getLayer()); @@ -98,7 +93,7 @@ public function testGetAdditionalHtml() $layout = $this->_getLayout(); /** @var $parent Mage_Catalog_Block_Product_List */ $parent = $layout->createBlock('Mage_Catalog_Block_Product_List'); - $childBlock = $layout->createBlock('Mage_Core_Block_Text', 'test', array('text' => 'test')); + $childBlock = $layout->createBlock('Mage_Core_Block_Text', 'test', array('data' => array('text' => 'test'))); $layout->setChild($parent->getNameInLayout(), $childBlock->getNameInLayout(), 'additional'); $this->assertEquals('test', $parent->getAdditionalHtml()); } diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Block/Product/NewTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Block/Product/NewTest.php index aedde4b851a46..359ca59947d0e 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Block/Product/NewTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Block/Product/NewTest.php @@ -43,11 +43,6 @@ protected function setUp() $this->_block = Mage::app()->getLayout()->createBlock('Mage_Catalog_Block_Product_New'); } - protected function tearDown() - { - $this->_block = null; - } - public function testGetCacheKeyInfo() { $info = $this->_block->getCacheKeyInfo(); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Block/Product/ViewTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Block/Product/ViewTest.php index 3e217d95b287b..015a7dee4f006 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Block/Product/ViewTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Block/Product/ViewTest.php @@ -42,6 +42,11 @@ class Mage_Catalog_Block_Product_ViewTest extends PHPUnit_Framework_TestCase */ protected $_product; + /** + * @var Mage_Catalog_Model_Datasource_Config + */ + protected $_dsConfig; + protected function setUp() { $this->_block = Mage::getObjectManager()->create('Mage_Catalog_Block_Product_View'); @@ -51,12 +56,6 @@ protected function setUp() Mage::register('product', $this->_product); } - protected function tearDown() - { - $this->_block = null; - $this->_product = null; - } - public function testSetLayout() { /** @var $layout Mage_Core_Model_Layout */ diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Helper/Category/FlatTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Helper/Category/FlatTest.php index 000469d231eb4..43a5165add1b3 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Helper/Category/FlatTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Helper/Category/FlatTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_helper = Mage::helper('Mage_Catalog_Helper_Category_Flat'); } - protected function tearDown() - { - $this->_helper = null; - } - public function testIsEnabledDefault() { $this->assertFalse($this->_helper->isEnabled()); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Helper/DataTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Helper/DataTest.php index fb63d06630e21..8bd4f18e1f12c 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Helper/DataTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_helper = Mage::helper('Mage_Catalog_Helper_Data'); } - protected function tearDown() - { - $this->_helper = null; - } - /** * @magentoDataFixture Mage/Catalog/_files/categories.php */ diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Helper/ImageTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Helper/ImageTest.php index 9342eb6ac9b7e..272baef5ef46f 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Helper/ImageTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Helper/ImageTest.php @@ -95,11 +95,6 @@ protected function setUp() $this->_helper = Mage::helper('Mage_Catalog_Helper_Image'); } - protected function tearDown() - { - $this->_helper = null; - } - /** * init() * __toString() diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Helper/OutputTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Helper/OutputTest.php index ec7301336a133..ef2819ae712cc 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Helper/OutputTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Helper/OutputTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_helper = Mage::helper('Mage_Catalog_Helper_Output'); } - protected function tearDown() - { - $this->_helper = null; - } - /** * addHandler() * getHandlers() diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Helper/Product/CompareTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Helper/Product/CompareTest.php index b62085c3135c9..922eba01b6bb5 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Helper/Product/CompareTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Helper/Product/CompareTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_helper = Mage::helper('Mage_Catalog_Helper_Product_Compare'); } - protected function tearDown() - { - $this->_helper = null; - } - /** * @magentoDataFixture Mage/Catalog/_files/multiple_products.php */ diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Helper/Product/FlatTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Helper/Product/FlatTest.php index 285094b2332f3..41055859ac276 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Helper/Product/FlatTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Helper/Product/FlatTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_helper = Mage::helper('Mage_Catalog_Helper_Product_Flat'); } - protected function tearDown() - { - $this->_helper = null; - } - public function testGetFlag() { $flag = $this->_helper->getFlag(); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Helper/Product/UrlTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Helper/Product/UrlTest.php index 3a783764cb3c0..faa9b8918989d 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Helper/Product/UrlTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Helper/Product/UrlTest.php @@ -45,11 +45,6 @@ protected function setUp() $this->_helper = Mage::helper('Mage_Catalog_Helper_Product_Url'); } - protected function tearDown() - { - $this->_helper = null; - } - public function testGetConvertTable() { $convertTable = $this->_helper->getConvertTable(); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Helper/Product/ViewTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Helper/Product/ViewTest.php index bd56fe28d6f2b..c848c214f6fea 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Helper/Product/ViewTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Helper/Product/ViewTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -require Mage::getBaseDir() . '/app/code/core/Mage/Catalog/controllers/ProductController.php'; +require Mage::getBaseDir() . '/app/code/Mage/Catalog/controllers/ProductController.php'; class Mage_Catalog_Helper_Product_ViewTest extends PHPUnit_Framework_TestCase { @@ -50,12 +50,9 @@ protected function setUp() $this->_controller = Mage::getModel( 'Mage_Catalog_ProductController', array( - $request, - new Magento_Test_Response(), - Mage::getObjectManager(), - Mage::getObjectManager()->get('Mage_Core_Controller_Varien_Front'), - Mage::getObjectManager()->get('Mage_Core_Model_Layout_Factory'), - 'frontend' + 'request' => $request, + 'response' => new Magento_Test_Response(), + 'areaCode' => 'frontend', ) ); } @@ -71,14 +68,19 @@ protected function tearDown() } /** + * @magentoDataFixture Mage/Catalog/_files/products.php * @magentoAppIsolation enabled */ public function testInitProductLayout() { $uniqid = uniqid(); + Mage::getSingleton('Mage_Core_Controller_Request_Http')->setParams(array('id' => 1)); + /** @var $product Mage_Catalog_Model_Product */ $product = Mage::getModel('Mage_Catalog_Model_Product'); - $product->setTypeId(Mage_Catalog_Model_Product_Type::DEFAULT_TYPE)->setId(99)->setUrlKey($uniqid); + $product->load(1); + $product->setUrlKey($uniqid); + $product->save(); Mage::register('product', $product); $this->_helper->initProductLayout($product, $this->_controller); @@ -95,6 +97,7 @@ public function testInitProductLayout() */ public function testPrepareAndRender() { + Mage::getSingleton('Mage_Core_Controller_Request_Http')->setParams(array('id' => 10)); $this->_helper->prepareAndRender(10, $this->_controller); $this->assertNotEmpty($this->_controller->getResponse()->getBody()); $this->assertEquals(10, Mage::getSingleton('Mage_Catalog_Model_Session')->getLastViewedProductId()); @@ -148,6 +151,7 @@ public function testGetSessionMessageModels() } // _getSessionMessageModels invokes inside prepareAndRender + Mage::getSingleton('Mage_Core_Controller_Request_Http')->setParams(array('id' => 10)); $this->_helper->prepareAndRender(10, $this->_controller); // assert messages diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Helper/ProductTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Helper/ProductTest.php index c8d5ae045d1f8..838bcaf971eaa 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Helper/ProductTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Helper/ProductTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_helper = Mage::helper('Mage_Catalog_Helper_Product'); } - protected function tearDown() - { - $this->_helper = null; - } - /** * @magentoDataFixture Mage/Catalog/_files/products.php */ @@ -63,7 +58,15 @@ public function testGetPrice() /** @var $product Mage_Catalog_Model_Product */ $product = Mage::getModel('Mage_Catalog_Model_Product'); $product->setPrice(49.95); - $this->assertEquals(49.95, $this->_helper->getPrice($product)); + // the helper->getPrice is deprecated and should throw an exception + try { + $this->_helper->getPrice($product); + $this->assertEquals("Shouldn't be able to call Mage_Catalog_Helper_Product::getPrice", + null); + } catch (Exception $ex) { + $this->assertEquals("Shouldn't call Mage_Catalog_Helper_Product::getPrice", + $ex->getMessage()); + } } public function testGetFinalPrice() @@ -71,7 +74,15 @@ public function testGetFinalPrice() /** @var $product Mage_Catalog_Model_Product */ $product = Mage::getModel('Mage_Catalog_Model_Product'); $product->setFinalPrice(49.95); - $this->assertEquals(49.95, $this->_helper->getFinalPrice($product)); + // the helper->getFinalPrice is deprecated and should throw an exception + try { + $this->_helper->getFinalPrice($product); + $this->assertEquals("Shouldn't be able to call Mage_Catalog_Helper_Product::getFinalPrice", + null); + } catch (Exception $ex) { + $this->assertEquals("Shouldn't call Mage_Catalog_Helper_Product::getFinalPrice", + $ex->getMessage()); + } } public function testGetImageUrl() diff --git a/dev/tests/integration/testsuite/Mage/Catalog/IndexerTest.php b/dev/tests/integration/testsuite/Mage/Catalog/IndexerTest.php new file mode 100644 index 0000000000000..00c85fcf35979 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Catalog/IndexerTest.php @@ -0,0 +1,105 @@ +_indexer = Mage::getModel('Mage_Index_Model_Indexer'); + } + + protected function tearDown() + { + $this->_indexer = null; + } + + public function testReindexAll() + { + $process = $this->_getProcessModel('catalog_product_price'); + $process->setStatus(Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX)->save(); + $this->assertEquals( + Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX, + $this->_getProcessModel('catalog_product_price')->getStatus() + ); + + $this->_indexer->reindexAll(); + + $this->assertEquals( + Mage_Index_Model_Process::STATUS_PENDING, + $this->_getProcessModel('catalog_product_price')->getStatus() + ); + } + + /** + * @depends testReindexAll + */ + public function testReindexRequired() + { + $process = $this->_getProcessModel('catalog_product_attribute'); + $process->setStatus(Mage_Index_Model_Process::STATUS_RUNNING)->save(); + $process = $this->_getProcessModel('catalog_product_price'); + $process->setStatus(Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX)->save(); + $this->assertEquals( + Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX, + $this->_getProcessModel('catalog_product_price')->getStatus() + ); + + $this->_indexer->reindexRequired(); + + $this->assertEquals( + Mage_Index_Model_Process::STATUS_RUNNING, + $this->_getProcessModel('catalog_product_attribute')->getStatus() + ); + $this->assertEquals( + Mage_Index_Model_Process::STATUS_PENDING, + $this->_getProcessModel('catalog_product_price')->getStatus() + ); + } + + /** + * Load and instantiate index process model + * + * We want to load it every time instead of receiving using Mage_Index_Model_Indexer::getProcessByCode() + * Because that method depends on state of the object, which does not reflect changes in database + * + * @param string $typeCode + * @return Mage_Index_Model_Process + */ + private function _getProcessModel($typeCode) + { + $process = Mage::getModel('Mage_Index_Model_Process'); + $process->load($typeCode, 'indexer_code'); + return $process; + } +} diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/AbstractTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/AbstractTest.php index 5c1cf372f1462..74a1c503df4e8 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/AbstractTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/AbstractTest.php @@ -62,11 +62,6 @@ protected function setUp() $collectionProperty->setValue($this->_model, 'Mage_Catalog_Model_Resource_Product_Collection'); } - protected function tearDown() - { - $this->_model = null; - } - /** * @covers Mage_Catalog_Model_Abstract::lockAttribute * @covers Mage_Catalog_Model_Abstract::unlockAttribute diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Category/Api/V2Test.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Category/Api/V2Test.php index 8907b50e2cc67..54ffac1022a88 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Category/Api/V2Test.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Category/Api/V2Test.php @@ -41,11 +41,6 @@ protected function setUp() Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); } - protected function tearDown() - { - $this->_model = null; - } - public function testCRUD() { // @codingStandardsIgnoreStart diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Category/ApiTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Category/ApiTest.php index 6de32d1bfb7f2..a19b90b218e47 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Category/ApiTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Category/ApiTest.php @@ -45,11 +45,6 @@ protected function setUp() Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); } - protected function tearDown() - { - $this->_model = null; - } - public function testLevel() { $default = $this->_model->level(); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Category/Attribute/ApiTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Category/Attribute/ApiTest.php index 786e21ab45f0b..405f87b12508e 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Category/Attribute/ApiTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Category/Attribute/ApiTest.php @@ -40,11 +40,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Catalog_Model_Category_Attribute_Api'); } - protected function tearDown() - { - $this->_model = null; - } - public function testItems() { $attributes = $this->_model->items(); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Category/CategoryImageTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Category/CategoryImageTest.php index 83614ff248578..425589eb70cb1 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Category/CategoryImageTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Category/CategoryImageTest.php @@ -35,33 +35,31 @@ class Mage_Catalog_Model_Category_CategoryImageTest extends PHPUnit_Framework_TestCase { /** @var int */ - protected static $_oldLogActive; + protected $_oldLogActive; /** @var string */ - protected static $_oldExceptionFile; + protected $_oldExceptionFile; /** @var string */ - protected static $_oldWriterModel; + protected $_oldWriterModel; - public static function setUpBeforeClass() + protected function setUp() { - parent::setUpBeforeClass(); - - self::$_oldLogActive = Mage::app()->getStore()->getConfig('dev/log/active'); - self::$_oldExceptionFile = Mage::app()->getStore()->getConfig('dev/log/exception_file'); - self::$_oldWriterModel = (string) Mage::getConfig()->getNode('global/log/core/writer_model'); + $this->_oldLogActive = Mage::app()->getStore()->getConfig('dev/log/active'); + $this->_oldExceptionFile = Mage::app()->getStore()->getConfig('dev/log/exception_file'); + $this->_oldWriterModel = (string) Mage::getConfig()->getNode('global/log/core/writer_model'); } - public static function tearDownAfterClass() + protected function tearDown() { - Mage::app()->getStore()->setConfig('dev/log/active', self::$_oldLogActive); - self::$_oldLogActive = null; + Mage::app()->getStore()->setConfig('dev/log/active', $this->_oldLogActive); + $this->_oldLogActive = null; - Mage::app()->getStore()->setConfig('dev/log/exception_file', self::$_oldExceptionFile); - self::$_oldExceptionFile = null; + Mage::app()->getStore()->setConfig('dev/log/exception_file', $this->_oldExceptionFile); + $this->_oldExceptionFile = null; - Mage::getConfig()->setNode('global/log/core/writer_model', self::$_oldWriterModel); - self::$_oldWriterModel = null; + Mage::getConfig()->setNode('global/log/core/writer_model', $this->_oldWriterModel); + $this->_oldWriterModel = null; /** * @TODO: refactor this test @@ -72,8 +70,6 @@ public static function tearDownAfterClass() if (class_exists('Stub_Mage_Catalog_Model_CategoryTest_Zend_Log_Writer_Stream', false)) { Stub_Mage_Catalog_Model_CategoryTest_Zend_Log_Writer_Stream::$exceptions = array(); } - - parent::tearDownAfterClass(); } /** diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/CategoryTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/CategoryTest.php index 23d15db71fbcf..854cd20c288d3 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/CategoryTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/CategoryTest.php @@ -67,6 +67,10 @@ public static function setUpBeforeClass() { self::$_objectManager = Mage::getObjectManager(); + if (Magento_Test_Helper_Bootstrap::getInstance()->getDbVendorName() != 'mysql') { + self::markTestIncomplete('Bug MAGETWO-8513'); + } + // get list of not existing tables /** @var $application Mage_Core_Model_App */ $application = self::$_objectManager->get('Mage_Core_Model_App'); @@ -140,12 +144,6 @@ protected function setUp() $this->_model = self::$_objectManager->create('Mage_Catalog_Model_Category'); } - protected function tearDown() - { - unset($this->_store); - unset($this->_model); - } - public function testGetUrlInstance() { $instance = $this->_model->getUrlInstance(); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/CategoryTreeTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/CategoryTreeTest.php index 6e72418eb2edc..07a7dc0422cb4 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/CategoryTreeTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/CategoryTreeTest.php @@ -44,11 +44,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Catalog_Model_Category'); } - protected function tearDown() - { - $this->_model = null; - } - public function testMove() { $this->_model->load(7); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/DesignTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/DesignTest.php index 2505e47e57d8e..5b1c54ce7f051 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/DesignTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/DesignTest.php @@ -40,11 +40,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Catalog_Model_Design'); } - protected function tearDown() - { - $this->_model = null; - } - /** * @dataProvider getThemeModel */ diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/AttributeTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/AttributeTest.php index 446ec76432d70..86be56f61c04b 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/AttributeTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/AttributeTest.php @@ -61,11 +61,6 @@ protected function setUp() )); } - protected function tearDown() - { - $this->_model = null; - } - public function testOptionIdNotEmpty() { $this->assertNotEmpty($this->_attributeOptionId, 'Fixture attribute option id.'); // just in case diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/CategoryTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/CategoryTest.php index e1cab5571f55a..197985d6683c3 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/CategoryTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/CategoryTest.php @@ -54,12 +54,6 @@ protected function setUp() )); } - protected function tearDown() - { - $this->_model = null; - $this->_category = null; - } - public function testGetResetValue() { $this->assertNull($this->_model->getResetValue()); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/DecimalTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/DecimalTest.php index f531cc6506f30..31794cfaf0dbf 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/DecimalTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/DecimalTest.php @@ -56,11 +56,6 @@ protected function setUp() )); } - protected function tearDown() - { - $this->_model = null; - } - public function testApplyNothing() { $this->assertEmpty($this->_model->getData('range')); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/ItemTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/ItemTest.php index 927986fa2c411..35c213ded4732 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/ItemTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/ItemTest.php @@ -45,11 +45,6 @@ protected function setUp() )); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetFilter() { $filter = $this->_model->getFilter(); @@ -72,12 +67,9 @@ public function testGetUrl() $action = Mage::getModel( 'Mage_Core_Controller_Front_Action', array( - new Magento_Test_Request(), - new Magento_Test_Response(), - Mage::getObjectManager(), - Mage::getObjectManager()->get('Mage_Core_Controller_Varien_Front'), - Mage::getObjectManager()->get('Mage_Core_Model_Layout_Factory'), - 'frontend' + 'request' => new Magento_Test_Request(), + 'response' => new Magento_Test_Response(), + 'areaCode' => 'frontend', ) ); Mage::app()->getFrontController()->setAction($action); // done in action's constructor diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/Price/AlgorithmAdvancedTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/Price/AlgorithmAdvancedTest.php index d3cd274b3531a..a4006bbbf30a5 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/Price/AlgorithmAdvancedTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/Price/AlgorithmAdvancedTest.php @@ -44,11 +44,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Catalog_Model_Layer_Filter_Price_Algorithm'); } - protected function tearDown() - { - $this->_model = null; - } - /** * Prepare price filter model * diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/Price/AlgorithmBaseTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/Price/AlgorithmBaseTest.php index 874bfcaed6730..1043eaf33b49a 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/Price/AlgorithmBaseTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/Price/AlgorithmBaseTest.php @@ -63,13 +63,6 @@ protected function setUp() ->setAttributeModel(new Varien_Object(array('attribute_code' => 'price'))); } - protected function tearDown() - { - $this->_model = null; - $this->_layer = null; - $this->_filter = null; - } - /** * @dataProvider pricesSegmentationDataProvider */ diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/PriceTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/PriceTest.php index bf37325600d8a..f8d427f40e624 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/PriceTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Layer/Filter/PriceTest.php @@ -49,11 +49,6 @@ protected function setUp() )); } - protected function tearDown() - { - $this->_model = null; - } - /** * @magentoConfigFixture current_store catalog/layered_navigation/price_range_calculation auto */ diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/LayerTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/LayerTest.php index 8d4656f5ef0c0..bb59f0fdb6165 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/LayerTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/LayerTest.php @@ -43,11 +43,6 @@ protected function setUp() $this->_model->setCurrentCategory(4); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetStateKey() { $this->assertEquals('STORE_1_CAT_4_CUSTGROUP_0', $this->_model->getStateKey()); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/ApiTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/ApiTest.php index 996e4cd2f3465..ef5a0463387bf 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/ApiTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/ApiTest.php @@ -40,11 +40,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Catalog_Model_Product_Attribute_Api'); } - protected function tearDown() - { - $this->_model = null; - } - public function testItems() { $items = $this->_model->items(4); /* default product attribute set after installation */ diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Backend/MediaTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Backend/MediaTest.php index e07a5d6922175..1cf942ad86964 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Backend/MediaTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Backend/MediaTest.php @@ -79,11 +79,6 @@ protected function setUp() ); } - protected function tearDown() - { - $this->_model = null; - } - public function testAfterLoad() { $product = Mage::getModel('Mage_Catalog_Model_Product'); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Backend/PriceTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Backend/PriceTest.php index cd60d57066a15..c1743ba111e7e 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Backend/PriceTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Backend/PriceTest.php @@ -45,11 +45,6 @@ protected function setUp() ); } - protected function tearDown() - { - $this->_model = null; - } - public function testSetScopeDefault() { /* validate result of setAttribute */ diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Backend/TierpriceTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Backend/TierpriceTest.php index 0711f76503fc8..bafc899322acb 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Backend/TierpriceTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Backend/TierpriceTest.php @@ -45,11 +45,6 @@ protected function setUp() ); } - protected function tearDown() - { - $this->_model = null; - } - public function testValidate() { $product = new Varien_Object(); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Media/ApiTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Media/ApiTest.php index 10dc22865f040..71443ee8f4302 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Media/ApiTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Media/ApiTest.php @@ -53,11 +53,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Catalog_Model_Product_Attribute_Media_Api'); } - protected function tearDown() - { - $this->_model = null; - } - public static function setUpBeforeClass() { self::$_filesDir = realpath(__DIR__ . '/../../../../_files'); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Tierprice/Api/V2Test.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Tierprice/Api/V2Test.php index fbcc8b53921aa..aa43886cc718f 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Tierprice/Api/V2Test.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Tierprice/Api/V2Test.php @@ -40,11 +40,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Catalog_Model_Product_Attribute_Tierprice_Api_V2'); } - protected function tearDown() - { - $this->_model = null; - } - /** * @expectedException Mage_Api_Exception */ diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Tierprice/ApiTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Tierprice/ApiTest.php index 3bf9a21046f9d..721b287a2bd41 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Tierprice/ApiTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Attribute/Tierprice/ApiTest.php @@ -42,11 +42,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Catalog_Model_Product_Attribute_Tierprice_Api'); } - protected function tearDown() - { - $this->_model = null; - } - public function testInfo() { $info = $this->_model->info(1); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/ImageTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/ImageTest.php index 2daac2eb86fe9..3056226b1be86 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/ImageTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/ImageTest.php @@ -57,7 +57,7 @@ public function testSaveFilePlaceholder($model) public function testGetUrlPlaceholder($model) { $this->assertStringMatchesFormat( - 'http://localhost/pub/media/theme/static/frontend/%s/Mage_Catalog/images/product/placeholder/image.jpg', + 'http://localhost/pub/static/frontend/%s/Mage_Catalog/images/product/placeholder/image.jpg', $model->getUrl() ); } diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Type/AbstractTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Type/AbstractTest.php index 6d6ec84b04d7b..d8793694aa18c 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Type/AbstractTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Type/AbstractTest.php @@ -39,11 +39,6 @@ protected function setUp() ->getMockForAbstractClass(); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetRelationInfo() { $info = $this->_model->getRelationInfo(); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Type/Configurable/AttributeTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Type/Configurable/AttributeTest.php index 6eef2cbe8d5f3..8fb81a84267d8 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Type/Configurable/AttributeTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Type/Configurable/AttributeTest.php @@ -37,10 +37,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Catalog_Model_Product_Type_Configurable_Attribute'); } - protected function tearDown() - { - $this->_model = null; - } public function testAddPrice() { $this->assertEmpty($this->_model->getPrices()); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Type/ConfigurableTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Type/ConfigurableTest.php index e594e4a5f0ef5..12128db1c28a7 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Type/ConfigurableTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Type/ConfigurableTest.php @@ -52,11 +52,6 @@ protected function setUp() $this->_product->setTypeInstance($this->_model); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetRelationInfo() { $info = $this->_model->getRelationInfo(); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Type/PriceTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Type/PriceTest.php index a0a7997a82f30..ebb8027e71413 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Type/PriceTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/Type/PriceTest.php @@ -40,11 +40,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Catalog_Model_Product_Type_Price'); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetPrice() { $this->assertEquals('test', $this->_model->getPrice(new Varien_Object(array('price' => 'test')))); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/UrlTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/UrlTest.php index add8f0bba1b68..4e88b8976f6ff 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/UrlTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Product/UrlTest.php @@ -42,11 +42,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Catalog_Model_Product_Url'); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetUrlInstance() { $instance = $this->_model->getUrlInstance(); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/ProductExternalTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/ProductExternalTest.php index 8d2d6a7d96ea8..2417ff2da1553 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/ProductExternalTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/ProductExternalTest.php @@ -45,11 +45,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Catalog_Model_Product'); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetStoreId() { $this->assertEquals(Mage::app()->getStore()->getId(), $this->_model->getStoreId()); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/ProductGettersTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/ProductGettersTest.php index b4f4d07cbd349..a6fa2a62d37d7 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/ProductGettersTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/ProductGettersTest.php @@ -45,11 +45,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Catalog_Model_Product'); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetResourceCollection() { $collection = $this->_model->getResourceCollection(); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/ProductPriceTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/ProductPriceTest.php index d1b286fbb965f..86ab76cfce504 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/ProductPriceTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/ProductPriceTest.php @@ -44,11 +44,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Catalog_Model_Product'); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetPrice() { $this->assertEmpty($this->_model->getPrice()); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/ProductTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/ProductTest.php index 223686af2d5c4..39b116a61ace9 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/ProductTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/ProductTest.php @@ -45,11 +45,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Catalog_Model_Product'); } - protected function tearDown() - { - $this->_model = null; - } - public static function tearDownAfterClass() { /** @var Mage_Catalog_Model_Product_Media_Config $config */ diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Resource/Eav/AttributeTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Resource/Eav/AttributeTest.php index 127b188b14d9a..459cb1224702b 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Resource/Eav/AttributeTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Resource/Eav/AttributeTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_model= Mage::getResourceModel('Mage_Catalog_Model_Resource_Eav_Attribute'); } - protected function tearDown() - { - $this->_model = null; - } - public function testCRUD() { $this->_model->setAttributeCode('test') diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Resource/Product/CollectionTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Resource/Product/CollectionTest.php index 28cf976163107..5b26e7e9c9907 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Resource/Product/CollectionTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Resource/Product/CollectionTest.php @@ -41,11 +41,6 @@ protected function setUp() $this->_collection = Mage::getResourceModel('Mage_Catalog_Model_Resource_Product_Collection'); } - protected function tearDown() - { - $this->_collection = null; - } - /** * @dataProvider setOrderDataProvider */ diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/Resource/UrlTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/Resource/UrlTest.php index 38c608294765e..62174c06f5e08 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/Resource/UrlTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/Resource/UrlTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_model = Mage::getResourceModel('Mage_Catalog_Model_Resource_Url'); } - protected function tearDown() - { - $this->_model = null; - } - /** * @magentoDataFixture Mage/Catalog/Model/Resource/_files/url_rewrites.php */ diff --git a/dev/tests/integration/testsuite/Mage/Catalog/Model/UrlTest.php b/dev/tests/integration/testsuite/Mage/Catalog/Model/UrlTest.php index 347ead3efeac8..321b55502e24c 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/Model/UrlTest.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/Model/UrlTest.php @@ -42,11 +42,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Catalog_Model_Url'); } - protected function tearDown() - { - $this->_model = null; - } - /** * Retrieve loaded url rewrite * diff --git a/dev/tests/integration/testsuite/Mage/Catalog/_files/product_virtual.php b/dev/tests/integration/testsuite/Mage/Catalog/_files/product_virtual.php index 008cd253ab0c3..2da2339734b76 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/_files/product_virtual.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/_files/product_virtual.php @@ -34,6 +34,7 @@ ->setName('Virtual Product') ->setSku('virtual-product') ->setPrice(10) + ->setTaxClassId(0) ->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH) ->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED) ->save(); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/controllers/_files/attribute_system.php b/dev/tests/integration/testsuite/Mage/Catalog/controllers/_files/attribute_system.php index a5321101b0749..42aa1108bf1b1 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/controllers/_files/attribute_system.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/controllers/_files/attribute_system.php @@ -26,8 +26,7 @@ */ $model = new Mage_Catalog_Model_Resource_Eav_Attribute( - Mage::getModel('Mage_Core_Model_Event_Manager'), - Mage::getModel('Mage_Core_Model_Cache') + Mage::getModel('Mage_Core_Model_Context') ); $model->setName('system_attribute') ->setId(2) diff --git a/dev/tests/integration/testsuite/Mage/Catalog/controllers/_files/attribute_system_with_applyto_data.php b/dev/tests/integration/testsuite/Mage/Catalog/controllers/_files/attribute_system_with_applyto_data.php index d79842026b3ca..a56ffc97c3de3 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/controllers/_files/attribute_system_with_applyto_data.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/controllers/_files/attribute_system_with_applyto_data.php @@ -26,8 +26,7 @@ */ $model = new Mage_Catalog_Model_Resource_Eav_Attribute( - Mage::getModel('Mage_Core_Model_Event_Manager'), - Mage::getModel('Mage_Core_Model_Cache') + Mage::getModel('Mage_Core_Model_Context') ); $model->setName('system_attribute') ->setId(3) diff --git a/dev/tests/integration/testsuite/Mage/Catalog/controllers/_files/attribute_user_defined.php b/dev/tests/integration/testsuite/Mage/Catalog/controllers/_files/attribute_user_defined.php index ea22b15b48461..1cc65daf01401 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/controllers/_files/attribute_user_defined.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/controllers/_files/attribute_user_defined.php @@ -26,8 +26,7 @@ */ $model = new Mage_Catalog_Model_Resource_Eav_Attribute( - Mage::getModel('Mage_Core_Model_Event_Manager'), - Mage::getModel('Mage_Core_Model_Cache') + Mage::getModel('Mage_Core_Model_Context') ); $model->setName('user_attribute') ->setId(1) diff --git a/dev/tests/integration/testsuite/Mage/CatalogInventory/Model/Stock/ItemTest.php b/dev/tests/integration/testsuite/Mage/CatalogInventory/Model/Stock/ItemTest.php index 5973b0fc7bf25..99b0d8cb2bf7e 100644 --- a/dev/tests/integration/testsuite/Mage/CatalogInventory/Model/Stock/ItemTest.php +++ b/dev/tests/integration/testsuite/Mage/CatalogInventory/Model/Stock/ItemTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_CatalogInventory_Model_Stock_Item'); } - protected function tearDown() - { - $this->_model = null; - } - /** * Simple product with stock item */ @@ -60,6 +55,32 @@ public static function simpleProductFixture() ->save(); } + /** + * @magentoDataFixture simpleProductFixture + */ + public function testSaveWithNullQty() + { + $this->markTestIncomplete('MAGETWO-8308'); + $this->_model + ->setProductId(1) + ->setTypeId(Mage_Catalog_Model_Product_Type::DEFAULT_TYPE) + ->setStockId(Mage_CatalogInventory_Model_Stock::DEFAULT_STOCK_ID) + ->setQty(null); + $this->_model->save(); + + $this->_model->setQty(0)->setQtyCorrection(2); + $this->_model->save(); + $this->assertEquals('2.0000', $this->_model->load(1)->getQty()); + + $this->_model->setQtyCorrection(-2); + $this->_model->save(); + $this->assertEquals('0.0000', $this->_model->load(1)->getQty()); + + $this->_model->setQty(null); + $this->_model->save(); + $this->assertEquals(null, $this->_model->load(1)->getQty()); + } + /** * @magentoDataFixture simpleProductFixture */ diff --git a/dev/tests/integration/testsuite/Mage/CatalogRule/Model/RuleTest.php b/dev/tests/integration/testsuite/Mage/CatalogRule/Model/RuleTest.php index 757c914d252b5..86b1e17e4c848 100644 --- a/dev/tests/integration/testsuite/Mage/CatalogRule/Model/RuleTest.php +++ b/dev/tests/integration/testsuite/Mage/CatalogRule/Model/RuleTest.php @@ -40,11 +40,6 @@ protected function setUp() $this->_object = Mage::getModel('Mage_CatalogRule_Model_Rule'); } - protected function tearDown() - { - $this->_object = null; - } - /** * @magentoAppIsolation enabled * @covers Mage_CatalogRule_Model_Rule::calcProductPriceRule diff --git a/dev/tests/integration/testsuite/Mage/CatalogSearch/Block/Advanced/ResultTest.php b/dev/tests/integration/testsuite/Mage/CatalogSearch/Block/Advanced/ResultTest.php index c42d920727be0..f79fe5bb4bece 100644 --- a/dev/tests/integration/testsuite/Mage/CatalogSearch/Block/Advanced/ResultTest.php +++ b/dev/tests/integration/testsuite/Mage/CatalogSearch/Block/Advanced/ResultTest.php @@ -43,12 +43,6 @@ protected function setUp() $this->_block = $this->_layout->createBlock('Mage_CatalogSearch_Block_Advanced_Result', 'block'); } - protected function tearDown() - { - $this->_layout = null; - $this->_block = null; - } - /** * @magentoAppIsolation enabled */ diff --git a/dev/tests/integration/testsuite/Mage/CatalogSearch/Block/TermTest.php b/dev/tests/integration/testsuite/Mage/CatalogSearch/Block/TermTest.php index b4959dcc3661e..b18f02aaf5a05 100644 --- a/dev/tests/integration/testsuite/Mage/CatalogSearch/Block/TermTest.php +++ b/dev/tests/integration/testsuite/Mage/CatalogSearch/Block/TermTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_block = Mage::app()->getLayout()->createBlock('Mage_CatalogSearch_Block_Term'); } - protected function tearDown() - { - $this->_block = null; - } - public function testGetSearchUrl() { $query = uniqid(); diff --git a/dev/tests/integration/testsuite/Mage/CatalogSearch/Helper/DataTest.php b/dev/tests/integration/testsuite/Mage/CatalogSearch/Helper/DataTest.php index 5ed7e986c6678..4b77a1401c13d 100644 --- a/dev/tests/integration/testsuite/Mage/CatalogSearch/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Mage/CatalogSearch/Helper/DataTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_helper = Mage::helper('Mage_CatalogSearch_Helper_Data'); } - protected function tearDown() - { - $this->_helper = null; - } - public function testGetResultUrl() { $this->assertStringEndsWith('/catalogsearch/result/', $this->_helper->getResultUrl()); @@ -69,7 +64,7 @@ public function testCheckNotesEscapesHtmlWhenQueryIsCut() /** @var $mock Mage_CatalogSearch_Helper_Data */ $mock = $this->getMock( 'Mage_CatalogSearch_Helper_Data', - array('getQueryText'), array(Mage::getObjectManager()->get('Mage_Core_Model_Translate')) + array('getQueryText'), array(Mage::getObjectManager()->get('Mage_Core_Helper_Context')) ); $mock->expects($this->any()) ->method('getQueryText') diff --git a/dev/tests/integration/testsuite/Mage/CatalogSearch/controllers/ResultControllerTest.php b/dev/tests/integration/testsuite/Mage/CatalogSearch/controllers/ResultControllerTest.php index 0b2b6941ca391..b5e025315eb0b 100644 --- a/dev/tests/integration/testsuite/Mage/CatalogSearch/controllers/ResultControllerTest.php +++ b/dev/tests/integration/testsuite/Mage/CatalogSearch/controllers/ResultControllerTest.php @@ -36,6 +36,9 @@ public function testIndexActionTranslation() $this->getRequest()->setParam('q', 'query_text'); $this->dispatch('catalogsearch/result'); + $fixtureTranslate = Mage::getSingleton('Mage_Core_Model_Translate')->translate(array('Fixture string')); + $this->assertSame('Fixture translation', $fixtureTranslate); + $responseBody = $this->getResponse()->getBody(); $this->assertNotContains('Search:', $responseBody); diff --git a/dev/tests/integration/testsuite/Mage/Checkout/Block/Cart/Item/RendererTest.php b/dev/tests/integration/testsuite/Mage/Checkout/Block/Cart/Item/RendererTest.php index 8490eb9f5c8c8..7087308d7bce0 100644 --- a/dev/tests/integration/testsuite/Mage/Checkout/Block/Cart/Item/RendererTest.php +++ b/dev/tests/integration/testsuite/Mage/Checkout/Block/Cart/Item/RendererTest.php @@ -47,11 +47,6 @@ protected function setUp() $this->_block->setItem($item); } - protected function tearDown() - { - $this->_block = null; - } - public function testThumbnail() { $size = $this->_block->getThumbnailSize(); diff --git a/dev/tests/integration/testsuite/Mage/Checkout/Block/Onepage/Payment/MethodsTest.php b/dev/tests/integration/testsuite/Mage/Checkout/Block/Onepage/Payment/MethodsTest.php index 4cb855815a324..80283fb258837 100644 --- a/dev/tests/integration/testsuite/Mage/Checkout/Block/Onepage/Payment/MethodsTest.php +++ b/dev/tests/integration/testsuite/Mage/Checkout/Block/Onepage/Payment/MethodsTest.php @@ -42,11 +42,6 @@ protected function setUp() ->createBlock('Mage_Checkout_Block_Onepage_Payment_Methods'); } - protected function tearDown() - { - $this->_block = null; - } - public function testGetMethodTitleAndMethodLabelAfterHtml() { $expectedTitle = 'Free Method'; diff --git a/dev/tests/integration/testsuite/Mage/Checkout/Model/Cart/ApiTest.php b/dev/tests/integration/testsuite/Mage/Checkout/Model/Cart/ApiTest.php index 4db0ab8eae4ae..33eb4c5197994 100644 --- a/dev/tests/integration/testsuite/Mage/Checkout/Model/Cart/ApiTest.php +++ b/dev/tests/integration/testsuite/Mage/Checkout/Model/Cart/ApiTest.php @@ -180,6 +180,7 @@ public function testCreateOrder() * Test order creation with payment method * * @magentoConfigFixture current_store payment/ccsave/active 1 + * @magentoConfigFixture current_store carriers/flatrate/active 1 * @magentoDataFixture Mage/Checkout/_files/quote_with_ccsave_payment.php * @magentoAppIsolation enabled */ diff --git a/dev/tests/integration/testsuite/Mage/Checkout/Model/Cart/Shipping/ApiTest.php b/dev/tests/integration/testsuite/Mage/Checkout/Model/Cart/Shipping/ApiTest.php index d6167a2c0977d..15b19eb4e612f 100644 --- a/dev/tests/integration/testsuite/Mage/Checkout/Model/Cart/Shipping/ApiTest.php +++ b/dev/tests/integration/testsuite/Mage/Checkout/Model/Cart/Shipping/ApiTest.php @@ -36,6 +36,7 @@ protected function setUp() /** * Test retrieving of shipping methods applicable to the shopping cart. * + * @magentoConfigFixture current_store carriers/flatrate/active 1 */ public function testGetShippingMethodsList() { @@ -65,6 +66,7 @@ public function testGetShippingMethodsList() /** * Test assigning shipping method to quote. * + * @magentoConfigFixture current_store carriers/flatrate/active 1 * @magentoDbIsolation enabled */ public function testSetShippingMethod() diff --git a/dev/tests/integration/testsuite/Mage/Checkout/controllers/MultishippingControllerTest.php b/dev/tests/integration/testsuite/Mage/Checkout/controllers/MultishippingControllerTest.php index 714406037db9a..a9a31b1a08f17 100644 --- a/dev/tests/integration/testsuite/Mage/Checkout/controllers/MultishippingControllerTest.php +++ b/dev/tests/integration/testsuite/Mage/Checkout/controllers/MultishippingControllerTest.php @@ -31,8 +31,8 @@ class Mage_Checkout_MultishippingControllerTest extends Magento_Test_TestCase_ControllerAbstract { /** - * Covers app/code/core/Mage/Checkout/Block/Multishipping/Payment/Info.php - * and app/code/core/Mage/Checkout/Block/Multishipping/Overview.php + * Covers app/code/Mage/Checkout/Block/Multishipping/Payment/Info.php + * and app/code/Mage/Checkout/Block/Multishipping/Overview.php * * @magentoDataFixture Mage/Sales/_files/quote.php * @magentoDataFixture Mage/Customer/_files/customer.php diff --git a/dev/tests/integration/testsuite/Mage/Checkout/controllers/OnepageControllerTest.php b/dev/tests/integration/testsuite/Mage/Checkout/controllers/OnepageControllerTest.php index 8d78234e4be82..a2c1ed310146f 100644 --- a/dev/tests/integration/testsuite/Mage/Checkout/controllers/OnepageControllerTest.php +++ b/dev/tests/integration/testsuite/Mage/Checkout/controllers/OnepageControllerTest.php @@ -51,7 +51,7 @@ public function testIndexAction() } /** - * Covers app/code/core/Mage/Checkout/Block/Onepage/Payment/Info.php + * Covers app/code/Mage/Checkout/Block/Onepage/Payment/Info.php */ public function testProgressAction() { diff --git a/dev/tests/integration/testsuite/Mage/Cms/Helper/PageTest.php b/dev/tests/integration/testsuite/Mage/Cms/Helper/PageTest.php index 82b6bd785a73f..bfc7382d0bc8f 100644 --- a/dev/tests/integration/testsuite/Mage/Cms/Helper/PageTest.php +++ b/dev/tests/integration/testsuite/Mage/Cms/Helper/PageTest.php @@ -41,12 +41,9 @@ public function testRenderPage() Mage::getModel( 'Mage_Core_Controller_Front_Action', array( - new Magento_Test_Request(), - new Magento_Test_Response(), - Mage::getObjectManager(), - Mage::getObjectManager()->get('Mage_Core_Controller_Varien_Front'), - Mage::getObjectManager()->get('Mage_Core_Model_Layout_Factory'), - 'frontend' + 'request' => new Magento_Test_Request(), + 'response' => new Magento_Test_Response(), + 'areaCode' => 'frontend' ) ), $page->getId() diff --git a/dev/tests/integration/testsuite/Mage/Cms/Model/Wysiwyg/ConfigTest.php b/dev/tests/integration/testsuite/Mage/Cms/Model/Wysiwyg/ConfigTest.php index 2eb1b5557838b..ede5da6bb6219 100644 --- a/dev/tests/integration/testsuite/Mage/Cms/Model/Wysiwyg/ConfigTest.php +++ b/dev/tests/integration/testsuite/Mage/Cms/Model/Wysiwyg/ConfigTest.php @@ -38,11 +38,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Cms_Model_Wysiwyg_Config'); } - protected function tearDown() - { - $this->_model = null; - } - /** * Tests that config returns valid config array in it */ diff --git a/dev/tests/integration/testsuite/Mage/Cms/Model/Wysiwyg/Images/StorageTest.php b/dev/tests/integration/testsuite/Mage/Cms/Model/Wysiwyg/Images/StorageTest.php index eaab448938390..9f3fcb86aa60e 100644 --- a/dev/tests/integration/testsuite/Mage/Cms/Model/Wysiwyg/Images/StorageTest.php +++ b/dev/tests/integration/testsuite/Mage/Cms/Model/Wysiwyg/Images/StorageTest.php @@ -59,7 +59,7 @@ public function testGetFilesCollection() $this->assertInstanceOf('Varien_Object', $item); $this->assertStringEndsWith('/1.swf', $item->getUrl()); $this->assertStringMatchesFormat( - 'http://%s/media/theme/static/adminhtml/%s/%s/%s/Mage_Cms/images/placeholder_thumbnail.jpg', + 'http://%s/static/adminhtml/%s/%s/%s/Mage_Cms/images/placeholder_thumbnail.jpg', $item->getThumbUrl() ); return; diff --git a/dev/tests/integration/testsuite/Mage/Core/Block/AbstractTest.php b/dev/tests/integration/testsuite/Mage/Core/Block/AbstractTest.php index e2fbd1dbe0581..234c8e669eb57 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Block/AbstractTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Block/AbstractTest.php @@ -44,38 +44,10 @@ class Mage_Core_Block_AbstractTest extends PHPUnit_Framework_TestCase protected function setUp() { Mage::getDesign()->setDefaultDesignTheme(); - $this->_block = $this->getMockForAbstractClass('Mage_Core_Block_Abstract', - $this->_getBlockDependencies() - ); - } - - /** - * Retrieve block dependencies - * - * @return array - */ - protected function _getBlockDependencies() - { - return array( - 'request' => Mage::getObjectManager()->create('Mage_Core_Controller_Request_Http', array(), false), - 'layout' => Mage::getObjectManager()->create('Mage_Core_Model_Layout'), - 'eventManager' => Mage::getObjectManager()->create('Mage_Core_Model_Event_Manager', array(), false), - 'urlBuilder' => Mage::getObjectManager()->create('Mage_Core_Model_Url', array(), false), - 'translator' => Mage::getObjectManager()->create('Mage_Core_Model_Translate', array(), false), - 'cache' => Mage::getObjectManager()->create('Mage_Core_Model_Cache', array(), false), - 'designPackage' => Mage::getObjectManager()->get('Mage_Core_Model_Design_Package'), - 'session' => Mage::getObjectManager()->create('Mage_Core_Model_Session', array(), false), - 'storeConfig' => Mage::getObjectManager()->create('Mage_Core_Model_Store_Config', array(), false), - 'frontController' => Mage::getObjectManager()->create('Mage_Core_Controller_Varien_Front', array(), false), - 'helperFactory' => Mage::getObjectManager()->create('Mage_Core_Model_Factory_Helper', array(), false), - 'data' => array('module_name' => 'Mage_Core') - ); - } - - protected function tearDown() - { - $this->_block = null; - $this->_layout = null; + $this->_block = $this->getMockForAbstractClass('Mage_Core_Block_Abstract', array( + Mage::getSingleton('Mage_Core_Block_Context'), + array('module_name' => 'Mage_Core') + )); } /** @@ -509,10 +481,10 @@ public function testGetUrlBase64() * * @magentoAppIsolation enabled */ - public function testGetViewUrl() + public function testGetViewFileUrl() { $this->assertStringStartsWith( - 'http://localhost/pub/media/theme/static/frontend/', $this->_block->getViewFileUrl() + 'http://localhost/pub/static/frontend/', $this->_block->getViewFileUrl() ); $this->assertStringEndsWith('css/styles.css', $this->_block->getViewFileUrl('css/styles.css')); @@ -710,7 +682,10 @@ protected function _createBlockWithLayout($name = 'block', $alias = null, ) { $mockClass = $type . 'Mock'; if (!isset(self::$_mocks[$mockClass])) { - self::$_mocks[$mockClass] = $this->getMockForAbstractClass($type, $this->_getBlockDependencies(), + self::$_mocks[$mockClass] = $this->getMockForAbstractClass($type, array( + Mage::getSingleton('Mage_Core_Block_Context'), + array('module_name' => 'Mage_Core') + ), $type . 'Mock' ); } diff --git a/dev/tests/integration/testsuite/Mage/Core/Block/TemplateTest.php b/dev/tests/integration/testsuite/Mage/Core/Block/TemplateTest.php index 858e287fb0bed..b78e8cab844df 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Block/TemplateTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Block/TemplateTest.php @@ -35,14 +35,12 @@ class Mage_Core_Block_TemplateTest extends PHPUnit_Framework_TestCase protected function setUp() { $params = array( - 'layout' => Mage::getObjectManager()->create('Mage_Core_Model_Layout', array(), false) + 'layout' => Mage::getObjectManager()->create('Mage_Core_Model_Layout', array()) + ); + $context = Mage::getObjectManager()->create('Mage_Core_Block_Template_Context', $params); + $this->_block = Mage::app()->getLayout()->createBlock('Mage_Core_Block_Template', '', + array('context' => $context) ); - $this->_block = Mage::app()->getLayout()->createBlock('Mage_Core_Block_Template', '', $params); - } - - protected function tearDown() - { - $this->_block = null; } public function testConstruct() diff --git a/dev/tests/integration/testsuite/Mage/Core/Block/Text/ListTest.php b/dev/tests/integration/testsuite/Mage/Core/Block/Text/ListTest.php index 5c49709a435cd..1d73472cfd258 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Block/Text/ListTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Block/Text/ListTest.php @@ -43,12 +43,6 @@ protected function setUp() $this->_block = $this->_layout->createBlock('Mage_Core_Block_Text_List'); } - protected function tearDown() - { - $this->_block = null; - $this->_layout = null; - } - public function testToHtml() { $children = array( diff --git a/dev/tests/integration/testsuite/Mage/Core/Block/TextTest.php b/dev/tests/integration/testsuite/Mage/Core/Block/TextTest.php index 0004480c8ea69..246f6aa802b5e 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Block/TextTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Block/TextTest.php @@ -37,11 +37,6 @@ public function setUp() $this->_block = Mage::app()->getLayout()->createBlock('Mage_Core_Block_Text'); } - public function tearDown() - { - $this->_block = null; - } - public function testSetGetText() { $this->_block->setText('text'); diff --git a/dev/tests/integration/testsuite/Mage/Core/Controller/RequestHttpTest.php b/dev/tests/integration/testsuite/Mage/Core/Controller/RequestHttpTest.php index 06d5082997954..eb1a1207c2ce4 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Controller/RequestHttpTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Controller/RequestHttpTest.php @@ -37,11 +37,6 @@ public function setUp() $this->_model = Mage::getModel('Mage_Core_Controller_Request_Http'); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetOriginalPathInfo() { $this->assertEmpty($this->_model->getOriginalPathInfo()); diff --git a/dev/tests/integration/testsuite/Mage/Core/Controller/Varien/ActionTest.php b/dev/tests/integration/testsuite/Mage/Core/Controller/Varien/ActionTest.php index 2406e0bce5bf4..9933b52e7da49 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Controller/Varien/ActionTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Controller/Varien/ActionTest.php @@ -49,11 +49,6 @@ protected function setUp() ); } - protected function tearDown() - { - $this->_model = null; - } - public function testHasAction() { $this->assertFalse($this->_model->hasAction('test')); diff --git a/dev/tests/integration/testsuite/Mage/Core/Controller/Varien/Router/AbstractTest.php b/dev/tests/integration/testsuite/Mage/Core/Controller/Varien/Router/AbstractTest.php index 143daefd5aa82..02bbadd182acb 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Controller/Varien/Router/AbstractTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Controller/Varien/Router/AbstractTest.php @@ -39,11 +39,6 @@ protected function setUp() ); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetSetFront() { $expected = Mage::getModel('Mage_Core_Controller_Varien_Front'); diff --git a/dev/tests/integration/testsuite/Mage/Core/Controller/Varien/Router/BaseTest.php b/dev/tests/integration/testsuite/Mage/Core/Controller/Varien/Router/BaseTest.php index 96e9df81db8c8..948b64f404ad7 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Controller/Varien/Router/BaseTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Controller/Varien/Router/BaseTest.php @@ -42,11 +42,6 @@ protected function setUp() $this->_model->setFront(Mage::getModel('Mage_Core_Controller_Varien_Front')); } - protected function tearDown() - { - $this->_model = null; - } - public function testCollectRoutes() { $this->_model->collectRoutes('frontend', 'standard'); diff --git a/dev/tests/integration/testsuite/Mage/Core/Helper/AbstractTest.php b/dev/tests/integration/testsuite/Mage/Core/Helper/AbstractTest.php index 88dd01337fdbd..ab17e26ef3b33 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Helper/AbstractTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Helper/AbstractTest.php @@ -35,7 +35,7 @@ class Mage_Core_Helper_AbstractTest extends PHPUnit_Framework_TestCase protected function setUp() { $this->_helper = $this->getMock('Mage_Core_Helper_Abstract', - array('_getModuleName'), array(Mage::getObjectManager()->get('Mage_Core_Model_Translate')) + array('_getModuleName'), array(Mage::getObjectManager()->get('Mage_Core_Helper_Context')) ); $this->_helper ->expects($this->any()) @@ -44,11 +44,6 @@ protected function setUp() ; } - protected function tearDown() - { - $this->_helper = null; - } - /** * @covers Mage_Core_Helper_Abstract::isModuleEnabled * @covers Mage_Core_Helper_Abstract::isModuleOutputEnabled diff --git a/dev/tests/integration/testsuite/Mage/Core/Helper/DataTest.php b/dev/tests/integration/testsuite/Mage/Core/Helper/DataTest.php index 442d9fa9b5285..60767068e3503 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Helper/DataTest.php @@ -55,11 +55,6 @@ public function setUp() $this->_dateTime->setTimezone(new DateTimeZone(self::DATE_TIMEZONE)); } - protected function tearDown() - { - $this->_helper = null; - } - public function testGetEncryptor() { $this->assertInstanceOf('Mage_Core_Model_Encryption', $this->_helper->getEncryptor()); @@ -178,11 +173,6 @@ public function testIsDevAllowedFalse() $this->assertFalse($this->_helper->isDevAllowed()); } - public function testGetCacheTypes() - { - $this->assertTrue(is_array($this->_helper->getCacheTypes())); - } - public function testCopyFieldset() { $fieldset = 'sales_copy_order'; diff --git a/dev/tests/integration/testsuite/Mage/Core/Helper/HttpTest.php b/dev/tests/integration/testsuite/Mage/Core/Helper/HttpTest.php index 7b122424df7a6..24c0645342b58 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Helper/HttpTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Helper/HttpTest.php @@ -37,11 +37,6 @@ public function setUp() $this->_helper = Mage::helper('Mage_Core_Helper_Http'); } - protected function tearDown() - { - $this->_helper = null; - } - public function testGetRemoteAddrHeaders() { $this->assertEquals(array(), $this->_helper->getRemoteAddrHeaders()); diff --git a/dev/tests/integration/testsuite/Mage/Core/Helper/JsTest.php b/dev/tests/integration/testsuite/Mage/Core/Helper/JsTest.php index bcea0a8e3f216..63657d88c1f89 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Helper/JsTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Helper/JsTest.php @@ -39,11 +39,6 @@ public function setUp() $this->_helper = Mage::helper('Mage_Core_Helper_Js'); } - protected function tearDown() - { - $this->_helper = null; - } - public function testGetTranslateJson() { $this->assertNotNull(json_decode($this->_helper->getTranslateJson())); diff --git a/dev/tests/integration/testsuite/Mage/Core/Helper/StringTest.php b/dev/tests/integration/testsuite/Mage/Core/Helper/StringTest.php index ce9c2bbe28689..b6564b0db9da3 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Helper/StringTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Helper/StringTest.php @@ -37,11 +37,6 @@ public function setUp() $this->_helper = Mage::helper('Mage_Core_Helper_String'); } - protected function tearDown() - { - $this->_helper = null; - } - /** * @covers Mage_Core_Helper_String::truncate * @covers Mage_Core_Helper_String::strlen diff --git a/dev/tests/integration/testsuite/Mage/Core/Helper/Url/RewriteTest.php b/dev/tests/integration/testsuite/Mage/Core/Helper/Url/RewriteTest.php index e59b4414d9e7f..efc3e76315eec 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Helper/Url/RewriteTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Helper/Url/RewriteTest.php @@ -37,11 +37,6 @@ public function setUp() $this->_helper = Mage::helper('Mage_Core_Helper_Url_Rewrite'); } - protected function tearDown() - { - $this->_helper = null; - } - /** * @dataProvider requestPathDataProvider */ diff --git a/dev/tests/integration/testsuite/Mage/Core/Helper/UrlTest.php b/dev/tests/integration/testsuite/Mage/Core/Helper/UrlTest.php index b5677dbdea26a..4f863bb3b90e9 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Helper/UrlTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Helper/UrlTest.php @@ -37,11 +37,6 @@ public function setUp() $this->_helper = Mage::helper('Mage_Core_Helper_Url'); } - protected function tearDown() - { - $this->_helper = null; - } - public function testGetCurrentUrl() { $_SERVER['HTTP_HOST'] = 'example.com'; diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/App/AreaTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/App/AreaTest.php index 1a8700ecedf0b..21eb5442ff146 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/App/AreaTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/App/AreaTest.php @@ -32,15 +32,15 @@ class Mage_Core_Model_App_AreaTest extends PHPUnit_Framework_TestCase */ protected $_model; - public function setUp() + public static function tearDownAfterClass() { - /** @var $_model Mage_Core_Model_App_Area */ - $this->_model = Mage::getModel('Mage_Core_Model_App_Area', array('areaCode' => 'frontend')); + Mage::app()->cleanCache(array(Mage_Core_Model_Design::CACHE_TAG)); } - protected function tearDown() + public function setUp() { - $this->_model = null; + /** @var $_model Mage_Core_Model_App_Area */ + $this->_model = Mage::getModel('Mage_Core_Model_App_Area', array('areaCode' => 'frontend')); } /** diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/AppTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/AppTest.php index c7ecf3cc22d07..0c26e66d0680b 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/AppTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/AppTest.php @@ -53,12 +53,6 @@ protected function setUp() $this->_mageModel = Mage::app(); } - protected function tearDown() - { - $this->_model = null; - $this->_mageModel = null; - } - public function testGetCookie() { $this->assertInstanceOf('Mage_Core_Model_Cookie', $this->_model->getCookie()); @@ -217,13 +211,13 @@ public function testGetFrontController() public function testGetCacheInstance() { $cache = $this->_mageModel->getCacheInstance(); - $this->assertInstanceOf('Mage_Core_Model_Cache', $cache); + $this->assertInstanceOf('Mage_Core_Model_CacheInterface', $cache); $this->assertSame($cache, $this->_mageModel->getCacheInstance()); } public function testGetCache() { - $this->assertInstanceOf('Zend_Cache_Core', $this->_mageModel->getCache()); + $this->assertInstanceOf('Magento_Cache_FrontendInterface', $this->_mageModel->getCache()); } public function testLoadSaveRemoveCache() diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/CacheTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/CacheTest.php deleted file mode 100644 index 46701ecc8bd13..0000000000000 --- a/dev/tests/integration/testsuite/Mage/Core/Model/CacheTest.php +++ /dev/null @@ -1,89 +0,0 @@ -_model = Mage::getModel('Mage_Core_Model_Cache'); - } - - public function tearDown() - { - $this->_model = null; - } - - public function testConstructorBackendDatabase() - { - $model = Mage::getModel('Mage_Core_Model_Cache', - array('options' => array('backend' => 'Database')) - ); - $backend = $model->getFrontend()->getBackend(); - $this->assertInstanceOf('Varien_Cache_Backend_Database', $backend); - } - - /** - * @param string $optionCode - * @param string $extensionRequired - * @dataProvider constructorBackendTwoLevelsDataProvider - */ - public function testConstructorBackendTwoLevels($optionCode, $extensionRequired) - { - if ($extensionRequired) { - if (!extension_loaded($extensionRequired)) { - $this->markTestSkipped("The PHP extension '{$extensionRequired}' is required for this test."); - - } - } - $model = Mage::getModel('Mage_Core_Model_Cache', - array('options' => array('backend' => $optionCode)) - ); - $backend = $model->getFrontend()->getBackend(); - $this->assertInstanceOf('Zend_Cache_Backend_TwoLevels', $backend); - } - - /** - * @return array - */ - public function constructorBackendTwoLevelsDataProvider() - { - return array( - array('Memcached', 'memcached'), - array('Memcached', 'memcache'), - ); - } - - public function testGetDbAdapter() - { - $this->assertInstanceOf('Zend_Db_Adapter_Abstract', $this->_model->getDbAdapter()); - } -} diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Config/DataTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Config/DataTest.php index 7f97a6b54d25b..cb946c14fa323 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Config/DataTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Config/DataTest.php @@ -48,11 +48,6 @@ public static function tearDownAfterClass() self::_refreshConfiguration(); } - protected function tearDown() - { - $this->_model = null; - } - /** * Remove cached configuration and reinitialize the application */ diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Config/ElementTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Config/ElementTest.php index 0af07dc09a0f5..10d462511791d 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Config/ElementTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Config/ElementTest.php @@ -64,11 +64,6 @@ protected function setUp() $this->_model = new Mage_Core_Model_Config_Element($xml); } - protected function tearDown() - { - $this->_model = null; - } - public function testIs() { $element = $this->_model->is_test; diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Config/FieldsetTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Config/FieldsetTest.php deleted file mode 100644 index 81ace5c525b03..0000000000000 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Config/FieldsetTest.php +++ /dev/null @@ -1,48 +0,0 @@ -getCache()->remove('fieldset_config'); - $config = Mage::getModel('Mage_Core_Model_Config_Fieldset'); - $this->assertInstanceOf('Mage_Core_Model_Config_Element', $config->getNode()); - - /* Load from cache */ - $this->assertTrue(Mage::app()->useCache('config')); - $config = Mage::getModel('Mage_Core_Model_Config_Fieldset'); - $this->assertInstanceOf('Mage_Core_Model_Config_Element', $config->getNode()); - - /* Generate and not save */ - Mage::app()->getCacheInstance()->banUse('config'); - $this->assertFalse(Mage::app()->useCache('config')); - $config = Mage::getModel('Mage_Core_Model_Config_Fieldset'); - $this->assertInstanceOf('Mage_Core_Model_Config_Element', $config->getNode()); - } -} diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/ConfigFactoryTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/ConfigFactoryTest.php index ce5c150da4c6c..f1dc9a3d30add 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/ConfigFactoryTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/ConfigFactoryTest.php @@ -41,11 +41,6 @@ public function setUp() $this->_model = Mage::getModel('Mage_Core_Model_Config'); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetModelInstance() { $this->assertInstanceOf('Mage_Core_Model_Config', $this->_model->getModelInstance('Mage_Core_Model_Config')); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Design/Backend/ExceptionsTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Design/Backend/ExceptionsTest.php index e7bab153622a0..4c8bc40a63807 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Design/Backend/ExceptionsTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Design/Backend/ExceptionsTest.php @@ -40,11 +40,6 @@ protected function setUp() $this->_model->setPath('design/theme/ua_regexp'); } - protected function tearDown() - { - $this->_model = null; - } - /** * Basic test, checks that saved value contains all required entries and is saved as an array * @magentoDbIsolation enabled diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Design/Fallback/List/FileTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Design/Fallback/List/FileTest.php new file mode 100644 index 0000000000000..e4db901e1f244 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Design/Fallback/List/FileTest.php @@ -0,0 +1,143 @@ +_model = Mage::getObjectManager()->create('Mage_Core_Model_Design_Fallback_List_File'); + } + + /** + * @dataProvider getPatternDirsDataProvider + */ + public function testGetPatternDirs($namespace, $module, $expectedIndexes) + { + $dir = Mage::getObjectManager()->get('Mage_Core_Model_Dir'); + + $parentTheme = Mage::getObjectManager()->create('Mage_Core_Model_Theme'); + $parentTheme->setThemePath('parent_theme_path'); + + $theme = Mage::getObjectManager()->create('Mage_Core_Model_Theme'); + $theme->setThemePath('theme_path'); + $theme->setParentTheme($parentTheme); + + $params = array( + 'theme' => $theme, + 'area' => 'area', + ); + + $params['namespace'] = $namespace; + $params['module'] = $module; + + $actualResult = $this->_model->getPatternDirs($params); + + /** + * This is array of all possible paths. Data provider returns indexes of this array as an expected result + * Indexes added for easier reading + */ + $fullExpectedResult = array( + 0 => $dir->getDir(Mage_Core_Model_Dir::THEMES) . '/area/theme_path', + 1 => $dir->getDir(Mage_Core_Model_Dir::THEMES) . '/area/theme_path/namespace_module', + 2 => $dir->getDir(Mage_Core_Model_Dir::THEMES) . '/area/parent_theme_path', + 3 => $dir->getDir(Mage_Core_Model_Dir::THEMES) . '/area/parent_theme_path/namespace_module', + 4 => $dir->getDir(Mage_Core_Model_Dir::MODULES) . '/namespace/module/view/area' + ); + + $expectedArray = array(); + foreach ($expectedIndexes as $index) { + $expectedArray[] = $fullExpectedResult[$index]; + } + + $this->assertSame($expectedArray, $actualResult); + } + + public function getPatternDirsDataProvider() + { + return array( + 'all parameters passed' => array( + 'namespace' => 'namespace', + 'module' => 'module', + array(0, 1, 2, 3, 4) + ), + 'no module parameter passed' => array( + 'namespace' => 'namespace', + 'module' => null, + array(0, 2) + ), + 'no namespace parameter passed' => array( + 'namespace' => null, + 'module' => 'module', + array(0, 2) + ), + 'no optional parameters passed' => array( + 'namespace' => null, + 'module' => null, + array(0, 2) + ), + ); + } + + /** + * @dataProvider getPatternDirsExceptionDataProvider + */ + public function testGetPatternDirsException($setParams, $expectedMessage) + { + $this->setExpectedException('InvalidArgumentException', $expectedMessage); + + $theme = Mage::getObjectManager()->create('Mage_Core_Model_Theme'); + $theme->setThemePath('theme_path'); + + $params = array( + 'theme' => $theme, + 'area' => 'area', + 'namespace' => 'namespace', + 'module' => 'module' + ); + $params = array_merge($params, $setParams); + $this->_model->getPatternDirs($params); + } + + public function getPatternDirsExceptionDataProvider() + { + return array( + 'No theme' => array( + array('theme' => null), + '$params["theme"] should be passed and should implement Mage_Core_Model_ThemeInterface' + ), + 'No area' => array( + array('area' => null), + 'Required parameter \'area\' was not passed' + ), + ); + } +} diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Design/Fallback/List/LocaleTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Design/Fallback/List/LocaleTest.php new file mode 100644 index 0000000000000..2d4244b5e0ec8 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Design/Fallback/List/LocaleTest.php @@ -0,0 +1,104 @@ +_model = Mage::getObjectManager()->create('Mage_Core_Model_Design_Fallback_List_Locale'); + } + + public function testGetPatternDirs() + { + $dir = Mage::getObjectManager()->get('Mage_Core_Model_Dir'); + + $parentTheme = Mage::getObjectManager()->create('Mage_Core_Model_Theme'); + $parentTheme->setThemePath('parent_theme_path'); + + $theme = Mage::getObjectManager()->create('Mage_Core_Model_Theme'); + $theme->setThemePath('theme_path'); + $theme->setParentTheme($parentTheme); + + $params = array( + 'theme' => $theme, + 'area' => 'area', + 'locale' => 'locale' + ); + + $actualResult = $this->_model->getPatternDirs($params); + + $expectedResult = array( + $dir->getDir(Mage_Core_Model_Dir::THEMES) . '/area/theme_path/locale/locale', + $dir->getDir(Mage_Core_Model_Dir::THEMES) . '/area/parent_theme_path/locale/locale', + ); + + $this->assertSame($expectedResult, $actualResult); + } + + /** + * @dataProvider getPatternDirsExceptionDataProvider + */ + public function testGetPatternDirsException($setParams, $expectedMessage) + { + $this->setExpectedException('InvalidArgumentException', $expectedMessage); + + $theme = Mage::getObjectManager()->create('Mage_Core_Model_Theme'); + $theme->setThemePath('theme_path'); + + $params = array( + 'theme' => $theme, + 'area' => 'area', + 'locale' => 'locale' + ); + $params = array_merge($params, $setParams); + + $this->_model->getPatternDirs($params); + } + + public function getPatternDirsExceptionDataProvider() + { + return array( + 'No theme' => array( + array('theme' => null), + '$params["theme"] should be passed and should implement Mage_Core_Model_ThemeInterface' + ), + 'No area' => array( + array('area' => null), + 'Required parameter \'area\' was not passed' + ), + 'No locale' => array( + array('locale' => null), + 'Required parameter \'locale\' was not passed' + ), + ); + } +} diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Design/Fallback/List/ViewTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Design/Fallback/List/ViewTest.php new file mode 100644 index 0000000000000..200749c078a7d --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Design/Fallback/List/ViewTest.php @@ -0,0 +1,161 @@ +_model = Mage::getObjectManager()->create('Mage_Core_Model_Design_Fallback_List_View'); + } + + /** + * @dataProvider getPatternDirsDataProvider + */ + public function testGetPatternDirs($namespace, $module, $locale, $expectedIndexes) + { + $dir = Mage::getObjectManager()->get('Mage_Core_Model_Dir'); + + $parentTheme = Mage::getObjectManager()->create('Mage_Core_Model_Theme'); + $parentTheme->setThemePath('parent_theme_path'); + + $theme = Mage::getObjectManager()->create('Mage_Core_Model_Theme'); + $theme->setThemePath('theme_path'); + $theme->setParentTheme($parentTheme); + + $params = array( + 'theme' => $theme, + 'area' => 'area', + ); + + $params['namespace'] = $namespace; + $params['module'] = $module; + $params['locale'] = $locale; + + $actualResult = $this->_model->getPatternDirs($params); + + /** + * This is array of all possible paths. Data provider returns indexes of this array as an expected result + * Indexes added for easier reading + */ + $fullExpectedResult = array( + 0 => $dir->getDir(Mage_Core_Model_Dir::THEMES) . '/area/theme_path/locale/locale', + 1 => $dir->getDir(Mage_Core_Model_Dir::THEMES) . '/area/theme_path', + 2 => $dir->getDir(Mage_Core_Model_Dir::THEMES) . '/area/theme_path/locale/locale/namespace_module', + 3 => $dir->getDir(Mage_Core_Model_Dir::THEMES) . '/area/theme_path/namespace_module', + 4 => $dir->getDir(Mage_Core_Model_Dir::THEMES) . '/area/parent_theme_path/locale/locale', + 5 => $dir->getDir(Mage_Core_Model_Dir::THEMES) . '/area/parent_theme_path', + 6 => $dir->getDir(Mage_Core_Model_Dir::THEMES) . '/area/parent_theme_path/locale/locale/namespace_module', + 7 => $dir->getDir(Mage_Core_Model_Dir::THEMES) . '/area/parent_theme_path/namespace_module', + 8 => $dir->getDir(Mage_Core_Model_Dir::MODULES) . '/namespace/module/view/area/locale/locale', + 9 => $dir->getDir(Mage_Core_Model_Dir::MODULES) . '/namespace/module/view/area', + 10 => $dir->getDir(Mage_Core_Model_Dir::PUB_LIB), + ); + + $expectedArray = array(); + foreach ($expectedIndexes as $index) { + $expectedArray[] = $fullExpectedResult[$index]; + } + + $this->assertSame($expectedArray, $actualResult); + } + + public function getPatternDirsDataProvider() + { + return array( + 'all parameters passed' => array( + 'namespace' => 'namespace', + 'module' => 'module', + 'locale' => 'locale', + range(0, 10) + ), + 'no module parameter passed' => array( + 'namespace' => 'namespace', + 'module' => null, + 'locale' => 'locale', + array(0, 1, 4, 5, 10) + ), + 'no namespace parameter passed' => array( + 'namespace' => null, + 'module' => 'module', + 'locale' => 'locale', + array(0, 1, 4, 5, 10) + ), + 'no locale parameter passed' => array( + 'namespace' => 'namespace', + 'module' => 'module', + 'locale' => null, + array(1, 3, 5, 7, 9, 10) + ), + 'no optional parameter passed' => array( + 'namespace' => null, + 'module' => null, + 'locale' => null, + array(1, 5, 10) + ), + ); + } + + /** + * @dataProvider getPatternDirsExceptionDataProvider + */ + public function testGetPatternDirsException($setParams, $expectedMessage) + { + $this->setExpectedException('InvalidArgumentException', $expectedMessage); + + $theme = Mage::getObjectManager()->create('Mage_Core_Model_Theme'); + $theme->setThemePath('theme_path'); + + $params = array( + 'theme' => $theme, + 'area' => 'area', + 'namespace' => 'namespace', + 'module' => 'module', + 'locale' => 'locale', + ); + $params = array_merge($params, $setParams); + $this->_model->getPatternDirs($params); + } + + public function getPatternDirsExceptionDataProvider() + { + return array( + 'No theme' => array( + array('theme' => null), + '$params["theme"] should be passed and should implement Mage_Core_Model_ThemeInterface' + ), + 'No area' => array( + array('area' => null), + 'Required parameter \'area\' was not passed' + ), + ); + } +} diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Design/FallbackTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Design/FallbackTest.php deleted file mode 100644 index 578f3e8265608..0000000000000 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Design/FallbackTest.php +++ /dev/null @@ -1,375 +0,0 @@ -get('Magento_Filesystem'), __DIR__); - Mage::getObjectManager()->create( - 'Mage_Core_Model_Design_Fallback', - array( - 'dirs' => $dirs, - 'params' => array() - ) - ); - } - - /** - * @covers Mage_Core_Model_Design_Fallback::getArea - * @covers Mage_Core_Model_Design_Fallback::getTheme - * @covers Mage_Core_Model_Design_Fallback::getLocale - */ - public function testGetters() - { - $theme = 't'; - $themeModel = $this->getMock('Mage_Core_Model_Theme', array('getId', 'getThemePath'), array(), '', false); - $themeModel->expects($this->any()) - ->method('getId') - ->will($this->returnValue(false)); - - $themeModel->expects($this->any()) - ->method('getThemePath') - ->will($this->returnValue($theme)); - - $dirs = new Mage_Core_Model_Dir(Mage::getObjectManager()->get('Magento_Filesystem'), __DIR__); - $stub = array( - 'themeConfig' => 'stub', - 'area' => 'a', - 'themeModel' => $themeModel, - 'locale' => 'l', - ); - $model = Mage::getObjectManager()->create( - 'Mage_Core_Model_Design_Fallback', - array( - 'dirs' => $dirs, - 'params' => $stub - ) - ); - $this->assertEquals('a', $model->getArea()); - $this->assertEquals($theme, $model->getTheme()); - $this->assertEquals('l', $model->getLocale()); - } - - /** - * Build a model to test - * - * @param string $area - * @param string $themePath - * @param string|null $locale - * @return Mage_Core_Model_Design_Fallback - */ - protected function _buildModel($area, $themePath, $locale) - { - // Prepare config with directories - $baseDir = dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'fallback'; - $viewDir = $baseDir . DIRECTORY_SEPARATOR . 'design'; - $dirs = new Mage_Core_Model_Dir( - Mage::getObjectManager()->get('Magento_Filesystem'), - $baseDir, - array(), - array(Mage_Core_Model_Dir::THEMES => $viewDir) - ); - - /** @var $collection Mage_Core_Model_Theme_Collection */ - $collection = Mage::getModel('Mage_Core_Model_Theme_Collection'); - $themeModel = $collection->setBaseDir($viewDir) - ->addDefaultPattern() - ->addFilter('theme_path', $themePath) - ->addFilter('area', $area) - ->getFirstItem(); - - // Build model - $params = array( - 'area' => $area, - 'locale' => $locale, - 'themeModel' => $themeModel, - ); - - return Mage::getObjectManager()->create('Mage_Core_Model_Design_Fallback', - array('dirs' => $dirs, 'params' => $params)); - } - - /** - * @param string $file - * @param string $area - * @param string $themePath - * @param string|null $module - * @param string|null $expectedFilename - * - * @dataProvider getFileDataProvider - */ - public function testGetFile($file, $area, $themePath, $module, $expectedFilename) - { - $model = $this->_buildModel($area, $themePath, null); - - $expectedFilename = str_replace('/', DS, $expectedFilename); - $actualFilename = $model->getFile($file, $module); - if ($expectedFilename) { - $this->assertStringMatchesFormat($expectedFilename, $actualFilename); - $this->assertFileExists($actualFilename); - } else { - $this->assertFileNotExists($actualFilename); - } - } - - /** - * @return array - */ - public function getFileDataProvider() - { - return array( - 'no default theme inheritance' => array( - 'fixture_template.phtml', 'frontend', 'package/standalone_theme', null, null - ), - 'same package & parent theme' => array( - 'fixture_template_two.phtml', 'frontend', 'package/custom_theme3', null, - "%s/frontend/package/custom_theme/fixture_template_two.phtml", - ), - 'same package & grandparent theme' => array( - 'fixture_template.phtml', 'frontend', 'package/custom_theme3', null, - "%s/frontend/package/default/fixture_template.phtml", - ), - 'parent package & parent theme' => array( - 'fixture_template_two.phtml', 'frontend', 'test/external_package_descendant', null, - "%s/frontend/package/custom_theme/fixture_template_two.phtml", - ), - 'parent package & grandparent theme' => array( - 'fixture_template.phtml', 'frontend', 'test/external_package_descendant', null, - "%s/frontend/package/default/fixture_template.phtml", - ), - 'module file inherited by scheme' => array( - 'theme_template.phtml', 'frontend', 'test/test_theme', 'Mage_Catalog', - "%s/frontend/test/default/Mage_Catalog/theme_template.phtml", - ) - ); - } - - /** - * @param string $file - * @param string $area - * @param string $themePath - * @param string $locale - * @param string|null $expectedFilename - * - * @dataProvider getLocaleFileDataProvider - */ - public function testLocaleFileFallback($file, $area, $themePath, $locale, $expectedFilename) - { - $model = $this->_buildModel($area, $themePath, $locale); - - $expectedFilename = str_replace('/', DIRECTORY_SEPARATOR, $expectedFilename); - $actualFilename = $model->getLocaleFile($file); - if ($expectedFilename) { - $this->assertStringMatchesFormat($expectedFilename, $actualFilename); - $this->assertFileExists($actualFilename); - } else { - $this->assertFileNotExists($actualFilename); - } - } - - /** - * @return array - */ - public function getLocaleFileDataProvider() - { - return array( - 'no default theme inheritance' => array( - 'fixture_translate.csv', 'frontend', 'package/standalone_theme', 'en_US', null - ), - 'parent theme' => array( - 'fixture_translate_two.csv', 'frontend', 'package/custom_theme3', 'en_US', - "%s/frontend/package/custom_theme/locale/en_US/fixture_translate_two.csv", - ), - 'grandparent theme' => array( - 'fixture_translate.csv', 'frontend', 'package/custom_theme3', 'en_US', - "%s/frontend/package/default/locale/en_US/fixture_translate.csv", - ), - ); - } - - /** - * Test for the skin files fallback - * - * @param string $file - * @param string $area - * @param string $themePath - * @param string|null $locale - * @param string|null $module - * @param string|null $expectedFilename - */ - protected function _testGetSkinFile($file, $area, $themePath, $locale, $module, $expectedFilename) - { - $model = $this->_buildModel($area, $themePath, $locale); - - $expectedFilename = str_replace('/', DIRECTORY_SEPARATOR, $expectedFilename); - $actualFilename = $model->getViewFile($file, $module); - if ($expectedFilename) { - $this->assertStringMatchesFormat($expectedFilename, $actualFilename); - $this->assertFileExists($actualFilename); - } else { - $this->assertFileNotExists($actualFilename); - } - } - - /** - * Test for the skin files fallback according to the themes inheritance - * - * @param string $file - * @param string $area - * @param string $themePath - * @param string $locale - * @param string|null $expectedFilename - * - * @dataProvider getSkinFileThemeDataProvider - */ - public function testGetSkinFileTheme($file, $area, $themePath, $locale, $expectedFilename) - { - $this->_testGetSkinFile($file, $area, $themePath, $locale, null, $expectedFilename); - } - - /** - * @return array - */ - public function getSkinFileThemeDataProvider() - { - return array( - 'no default theme inheritance' => array( - 'fixture_script_two.js', 'frontend', 'package/standalone_theme', 'en_US', - null, - ), - 'same theme & default skin' => array( - 'fixture_script_two.js', 'frontend', 'package/custom_theme', 'en_US', - "%s/frontend/package/custom_theme/fixture_script_two.js", - ), - 'parent theme & same skin' => array( - 'fixture_script.js', 'frontend', 'package/custom_theme3', 'en_US', - "%s/frontend/package/custom_theme2/fixture_script.js", - ), - 'parent theme & default skin' => array( - 'fixture_script_two.js', 'frontend', 'package/custom_theme3', 'en_US', - "%s/frontend/package/custom_theme/fixture_script_two.js", - ), - 'grandparent theme & same skin' => array( - 'fixture_script_three.js', 'frontend', 'package/custom_theme3', - 'en_US', null, - ), - 'grandparent theme & default skin' => array( - 'fixture_script_four.js', 'frontend', 'package/custom_theme3', - 'en_US', "%s/frontend/package/default/fixture_script_four.js", - ), - 'parent package & same theme & same skin' => array( - 'fixture_script.js', 'frontend/test', 'external_package_descendant', 'en_US', - null, - ), - 'parent package & same theme & default skin' => array( - 'fixture_script_two.js', 'frontend', 'test/external_package_descendant', - 'en_US', "%s/frontend/package/custom_theme/fixture_script_two.js", - ), - ); - } - - /** - * Test for the skin files localization - * - * @param string $file - * @param string $area - * @param string $themePath - * @param string $locale - * @param string|null $module - * @param string|null $expectedFilename - * - * @dataProvider getSkinFileL10nDataProvider - */ - public function testGetSkinFileL10n($file, $area, $themePath, $locale, $module, $expectedFilename) - { - $this->_testGetSkinFile($file, $area, $themePath, $locale, $module, $expectedFilename); - } - - /** - * @return array - */ - public function getSkinFileL10nDataProvider() - { - return array( - 'general skin file' => array( - 'fixture_script.js', 'frontend', 'package/custom_theme2', 'en_US', null, - "%s/frontend/package/custom_theme2/fixture_script.js" - ), - 'localized skin file' => array( - 'fixture_script.js', 'frontend', 'package/custom_theme2', 'ru_RU', null, - "%s/frontend/package/custom_theme2/locale/ru_RU/fixture_script.js", - ), - 'general modular skin file' => array( - 'fixture_script.js', 'frontend', 'package/custom_theme2', 'en_US', - 'Fixture_Module', - "%s/frontend/package/custom_theme2/fixture_script.js", - ), - 'localized modular skin file' => array( - 'fixture_script.js', 'frontend', 'package/custom_theme2', 'ru_RU', - 'Fixture_Module', - "%s/frontend/package/custom_theme2/locale/ru_RU/fixture_script.js", - ), - ); - } - - /** - * Test for the skin files fallback to the JavaScript libraries - * - * @param string $file - * @param string $area - * @param string $themePath - * @param string|null $expectedFilename - * - * @dataProvider getSkinFileJsLibDataProvider - */ - public function testGetSkinFileJsLib($file, $area, $themePath, $expectedFilename) - { - $this->_testGetSkinFile($file, $area, $themePath, 'en_US', null, $expectedFilename); - } - - /** - * @return array - */ - public function getSkinFileJsLibDataProvider() - { - return array( - 'lib file in theme' => array( - 'mage/script.js', 'frontend', 'package/custom_theme2', - "%s/frontend/package/custom_theme2/mage/script.js", - ), - 'lib file in js lib' => array( - 'mage/script.js', 'frontend', 'package/custom_theme', - '%s/pub/lib/mage/script.js', - ), - ); - } -} - diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Design/FileResolution/Strategy/FallbackTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Design/FileResolution/Strategy/FallbackTest.php new file mode 100644 index 0000000000000..a6918fdaf4f4f --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Design/FileResolution/Strategy/FallbackTest.php @@ -0,0 +1,349 @@ +_baseDir = realpath(__DIR__ . '/../../../_files/fallback'); + $this->_viewDir = $this->_baseDir . DIRECTORY_SEPARATOR . 'design'; + } + + /** + * Build a model to test + * + * @return Mage_Core_Model_Design_FileResolution_Strategy_Fallback + */ + protected function _buildModel() + { + // Prepare config with directories + $dirs = new Mage_Core_Model_Dir( + Mage::getObjectManager()->get('Magento_Filesystem'), + $this->_baseDir, + array(), + array(Mage_Core_Model_Dir::THEMES => $this->_viewDir) + ); + + $fallbackFile = new Mage_Core_Model_Design_Fallback_List_File($dirs); + $fallbackLocale = new Mage_Core_Model_Design_Fallback_List_Locale($dirs); + $fallbackViewFile = new Mage_Core_Model_Design_Fallback_List_View($dirs); + + return Mage::getObjectManager()->create( + 'Mage_Core_Model_Design_FileResolution_Strategy_Fallback', + array('dirs' => $dirs, 'fallbackFile' => $fallbackFile, 'fallbackLocale' => $fallbackLocale, + 'fallbackViewFile' => $fallbackViewFile + ) + ); + } + + /** + * Compose custom theme model with designated path + * + * @param string $area + * @param string $themePath + * @return Mage_Core_Model_Theme + */ + protected function _getThemeModel($area, $themePath) + { + /** @var $collection Mage_Core_Model_Theme_Collection */ + $collection = Mage::getModel('Mage_Core_Model_Theme_Collection'); + $themeModel = $collection->setBaseDir($this->_viewDir) + ->addDefaultPattern() + ->addFilter('theme_path', $themePath) + ->addFilter('area', $area) + ->getFirstItem(); + return $themeModel; + } + + /** + * @param string $file + * @param string $area + * @param string $themePath + * @param string|null $module + * @param string|null $expectedFilename + * + * @dataProvider getFileDataProvider + */ + public function testGetFile($file, $area, $themePath, $module, $expectedFilename) + { + $model = $this->_buildModel($area, $themePath, null); + $themeModel = $this->_getThemeModel($area, $themePath); + + $expectedFilename = str_replace('/', DS, $expectedFilename); + $actualFilename = $model->getFile($area, $themeModel, $file, $module); + if ($expectedFilename) { + $this->assertStringMatchesFormat($expectedFilename, $actualFilename); + $this->assertFileExists($actualFilename); + } else { + $this->assertFileNotExists($actualFilename); + } + } + + /** + * @return array + */ + public function getFileDataProvider() + { + return array( + 'no default theme inheritance' => array( + 'fixture_template.phtml', 'frontend', 'package/standalone_theme', null, null + ), + 'same package & parent theme' => array( + 'fixture_template_two.phtml', 'frontend', 'package/custom_theme3', null, + "%s/frontend/package/custom_theme/fixture_template_two.phtml", + ), + 'same package & grandparent theme' => array( + 'fixture_template.phtml', 'frontend', 'package/custom_theme3', null, + "%s/frontend/package/default/fixture_template.phtml", + ), + 'parent package & parent theme' => array( + 'fixture_template_two.phtml', 'frontend', 'test/external_package_descendant', null, + "%s/frontend/package/custom_theme/fixture_template_two.phtml", + ), + 'parent package & grandparent theme' => array( + 'fixture_template.phtml', 'frontend', 'test/external_package_descendant', null, + "%s/frontend/package/default/fixture_template.phtml", + ), + 'module file inherited by scheme' => array( + 'theme_template.phtml', 'frontend', 'test/test_theme', 'Mage_Catalog', + "%s/frontend/test/default/Mage_Catalog/theme_template.phtml", + ) + ); + } + + /** + * @param string $file + * @param string $area + * @param string $themePath + * @param string $locale + * @param string|null $expectedFilename + * + * @dataProvider getLocaleFileDataProvider + */ + public function testLocaleFileFallback($file, $area, $themePath, $locale, $expectedFilename) + { + $model = $this->_buildModel($area, $themePath, $locale); + $themeModel = $this->_getThemeModel($area, $themePath); + + $expectedFilename = str_replace('/', DIRECTORY_SEPARATOR, $expectedFilename); + $actualFilename = $model->getLocaleFile($area, $themeModel, $locale, $file); + if ($expectedFilename) { + $this->assertStringMatchesFormat($expectedFilename, $actualFilename); + $this->assertFileExists($actualFilename); + } else { + $this->assertFileNotExists($actualFilename); + } + } + + /** + * @return array + */ + public function getLocaleFileDataProvider() + { + return array( + 'no default theme inheritance' => array( + 'fixture_translate.csv', 'frontend', 'package/standalone_theme', 'en_US', null + ), + 'parent theme' => array( + 'fixture_translate_two.csv', 'frontend', 'package/custom_theme3', 'en_US', + "%s/frontend/package/custom_theme/locale/en_US/fixture_translate_two.csv", + ), + 'grandparent theme' => array( + 'fixture_translate.csv', 'frontend', 'package/custom_theme3', 'en_US', + "%s/frontend/package/default/locale/en_US/fixture_translate.csv", + ), + ); + } + + /** + * Test for the skin files fallback + * + * @param string $file + * @param string $area + * @param string $themePath + * @param string|null $locale + * @param string|null $module + * @param string|null $expectedFilename + */ + protected function _testGetSkinFile($file, $area, $themePath, $locale, $module, $expectedFilename) + { + $model = $this->_buildModel($area, $themePath, $locale); + $themeModel = $this->_getThemeModel($area, $themePath); + + $expectedFilename = str_replace('/', DIRECTORY_SEPARATOR, $expectedFilename); + $actualFilename = $model->getViewFile($area, $themeModel, $locale, $file, $module); + if ($expectedFilename) { + $this->assertStringMatchesFormat($expectedFilename, $actualFilename); + $this->assertFileExists($actualFilename); + } else { + $this->assertFileNotExists($actualFilename); + } + } + + /** + * Test for the skin files fallback according to the themes inheritance + * + * @param string $file + * @param string $area + * @param string $themePath + * @param string $locale + * @param string|null $expectedFilename + * + * @dataProvider getSkinFileThemeDataProvider + */ + public function testGetSkinFileTheme($file, $area, $themePath, $locale, $expectedFilename) + { + $this->_testGetSkinFile($file, $area, $themePath, $locale, null, $expectedFilename); + } + + /** + * @return array + */ + public function getSkinFileThemeDataProvider() + { + return array( + 'no default theme inheritance' => array( + 'fixture_script_two.js', 'frontend', 'package/standalone_theme', 'en_US', + null, + ), + 'same theme & default skin' => array( + 'fixture_script_two.js', 'frontend', 'package/custom_theme', 'en_US', + "%s/frontend/package/custom_theme/fixture_script_two.js", + ), + 'parent theme & same skin' => array( + 'fixture_script.js', 'frontend', 'package/custom_theme3', 'en_US', + "%s/frontend/package/custom_theme2/fixture_script.js", + ), + 'parent theme & default skin' => array( + 'fixture_script_two.js', 'frontend', 'package/custom_theme3', 'en_US', + "%s/frontend/package/custom_theme/fixture_script_two.js", + ), + 'grandparent theme & same skin' => array( + 'fixture_script_three.js', 'frontend', 'package/custom_theme3', + 'en_US', null, + ), + 'grandparent theme & default skin' => array( + 'fixture_script_four.js', 'frontend', 'package/custom_theme3', + 'en_US', "%s/frontend/package/default/fixture_script_four.js", + ), + 'parent package & same theme & same skin' => array( + 'fixture_script.js', 'frontend/test', 'external_package_descendant', 'en_US', + null, + ), + 'parent package & same theme & default skin' => array( + 'fixture_script_two.js', 'frontend', 'test/external_package_descendant', + 'en_US', "%s/frontend/package/custom_theme/fixture_script_two.js", + ), + ); + } + + /** + * Test for the skin files localization + * + * @param string $file + * @param string $area + * @param string $themePath + * @param string $locale + * @param string|null $module + * @param string|null $expectedFilename + * + * @dataProvider getSkinFileL10nDataProvider + */ + public function testGetSkinFileL10n($file, $area, $themePath, $locale, $module, $expectedFilename) + { + $this->_testGetSkinFile($file, $area, $themePath, $locale, $module, $expectedFilename); + } + + /** + * @return array + */ + public function getSkinFileL10nDataProvider() + { + return array( + 'general skin file' => array( + 'fixture_script.js', 'frontend', 'package/custom_theme2', 'en_US', null, + "%s/frontend/package/custom_theme2/fixture_script.js" + ), + 'localized skin file' => array( + 'fixture_script.js', 'frontend', 'package/custom_theme2', 'ru_RU', null, + "%s/frontend/package/custom_theme2/locale/ru_RU/fixture_script.js", + ), + 'general modular skin file' => array( + 'fixture_script.js', 'frontend', 'package/custom_theme2', 'en_US', + 'Fixture_Module', + "%s/frontend/package/custom_theme2/fixture_script.js", + ), + 'localized modular skin file' => array( + 'fixture_script.js', 'frontend', 'package/custom_theme2', 'ru_RU', + 'Fixture_Module', + "%s/frontend/package/custom_theme2/locale/ru_RU/fixture_script.js", + ), + ); + } + + /** + * Test for the skin files fallback to the JavaScript libraries + * + * @param string $file + * @param string $area + * @param string $themePath + * @param string|null $expectedFilename + * + * @dataProvider getSkinFileJsLibDataProvider + */ + public function testGetSkinFileJsLib($file, $area, $themePath, $expectedFilename) + { + $this->_testGetSkinFile($file, $area, $themePath, 'en_US', null, $expectedFilename); + } + + /** + * @return array + */ + public function getSkinFileJsLibDataProvider() + { + return array( + 'lib file in theme' => array( + 'mage/script.js', 'frontend', 'package/custom_theme2', + "%s/frontend/package/custom_theme2/mage/script.js", + ), + 'lib file in js lib' => array( + 'mage/script.js', 'frontend', 'package/custom_theme', + '%s/pub/lib/mage/script.js', + ), + ); + } +} diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Design/PackageFallbackTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Design/PackageFallbackTest.php index a9832589513e6..5d22e50ce16c7 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Design/PackageFallbackTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Design/PackageFallbackTest.php @@ -47,11 +47,6 @@ protected function setUp() $this->_model->setDesignTheme('test/default'); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetFilename() { $expected = '%s/frontend/test/default/Mage_Catalog/theme_template.phtml'; diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Design/PackageMergingTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Design/PackageMergingTest.php index 69792277a5c37..03d1ae20e9099 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Design/PackageMergingTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Design/PackageMergingTest.php @@ -79,10 +79,10 @@ protected function tearDown() */ public function testMergeFilesException() { - $this->_model->getOptimalCssUrls(array( + $this->_model->mergeFiles(array( 'css/exception.css', 'css/file.css', - )); + ), Mage_Core_Model_Design_Package::CONTENT_TYPE_CSS); $this->assertFileNotExists(self::$_themePublicDir . '/frontend/package/default/en_US/access_violation.php'); } @@ -99,13 +99,11 @@ public function testMergeFilesException() public function testMergeFiles($contentType, $files, $expectedFilename, $related = array()) { if ($contentType == Mage_Core_Model_Design_Package::CONTENT_TYPE_CSS) { - $result = $this->_model->getOptimalCssUrls($files); + $result = $this->_model->mergeFiles($files, Mage_Core_Model_Design_Package::CONTENT_TYPE_CSS); } else { - $result = $this->_model->getOptimalJsUrls($files); + $result = $this->_model->mergeFiles($files, Mage_Core_Model_Design_Package::CONTENT_TYPE_JS); } - $this->assertArrayHasKey(0, $result); - $this->assertEquals(1, count($result), 'Result must contain exactly one file.'); - $this->assertEquals($expectedFilename, basename($result[0])); + $this->assertEquals($expectedFilename, basename($result)); foreach ($related as $file) { $this->assertFileExists( self::$_themePublicDir . '/frontend/package/default/en_US/' . $file @@ -126,21 +124,13 @@ public function testMergeFiles($contentType, $files, $expectedFilename, $related public function testMergeFilesSigned($contentType, $files, $expectedFilename, $related = array()) { if ($contentType == Mage_Core_Model_Design_Package::CONTENT_TYPE_CSS) { - $result = $this->_model->getOptimalCssUrls($files); + $result = $this->_model->mergeFiles($files, Mage_Core_Model_Design_Package::CONTENT_TYPE_CSS); } else { - $result = $this->_model->getOptimalJsUrls($files); + $result = $this->_model->mergeFiles($files, Mage_Core_Model_Design_Package::CONTENT_TYPE_JS); } - $this->assertArrayHasKey(0, $result); - $this->assertEquals(1, count($result), 'Result must contain exactly one file.'); - $mergedFileName = basename($result[0]); + $mergedFileName = basename($result); $mergedFileName = preg_replace('/\?.*$/i', '', $mergedFileName); $this->assertEquals($expectedFilename, $mergedFileName); - $lastModified = array(); - preg_match('/.*\?(.*)$/i', $result[0], $lastModified); - $this->assertArrayHasKey(1, $lastModified); - $this->assertEquals(10, strlen($lastModified[1])); - $this->assertLessThanOrEqual(time(), $lastModified[1]); - $this->assertGreaterThan(1970, date('Y', $lastModified[1])); foreach ($related as $file) { $this->assertFileExists( self::$_themePublicDir . '/frontend/package/default/en_US/' . $file @@ -200,7 +190,7 @@ public function testMergeFilesModification() $this->assertFileNotExists($resultingFile); // merge first time - $this->_model->getOptimalJsUrls($files); + $this->_model->mergeFiles($files, Mage_Core_Model_Design_Package::CONTENT_TYPE_JS); $this->assertFileExists($resultingFile); } @@ -212,10 +202,10 @@ public function testCleanMergedJsCss() { $this->assertFileNotExists(self::$_viewPublicMergedDir); - $this->_model->getOptimalJsUrls(array( + $this->_model->mergeFiles(array( 'mage/calendar.js', 'scripts.js', - )); + ), Mage_Core_Model_Design_Package::CONTENT_TYPE_JS); $this->assertFileExists(self::$_viewPublicMergedDir); $filesFound = false; foreach (new RecursiveDirectoryIterator(self::$_viewPublicMergedDir) as $fileInfo) { diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Design/PackagePublicationTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Design/PackagePublicationTest.php index a9f9d3d0d341f..ec59cb789c16a 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Design/PackagePublicationTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Design/PackagePublicationTest.php @@ -43,6 +43,7 @@ protected function tearDown() $publicDir = $this->_model->getPublicDir(); $filesystem->delete($publicDir . '/adminhtml'); $filesystem->delete($publicDir . '/frontend'); + $this->_model = null; } /** @@ -52,8 +53,7 @@ public function testGetPublicDir() { /** @var $dirs Mage_Core_Model_Dir */ $dirs = Mage::getObjectManager()->get('Mage_Core_Model_Dir'); - $expectedPublicDir = $dirs->getDir(Mage_Core_Model_Dir::THEME) . DIRECTORY_SEPARATOR - . Mage_Core_Model_Design_Package::PUBLIC_BASE_THEME_DIR; + $expectedPublicDir = $dirs->getDir(Mage_Core_Model_Dir::STATIC_VIEW); $this->assertEquals($expectedPublicDir, $this->_model->getPublicDir()); } @@ -94,20 +94,16 @@ public function getViewUrlFilesDuplicationDataProvider() return array( 'theme file' => array( 'css/styles.css', - 'theme/static/frontend/test/default/en_US/css/styles.css', + 'static/frontend/test/default/en_US/css/styles.css', ), 'theme localized file' => array( 'logo.gif', - 'theme/static/frontend/test/default/fr_FR/logo.gif', + 'static/frontend/test/default/fr_FR/logo.gif', 'fr_FR', ), 'modular file' => array( - 'Module::favicon.ico', - 'theme/static/frontend/test/default/en_US/Module/favicon.ico', - ), - 'lib file' => array( - 'varien/product.js', - 'http://localhost/pub/lib/varien/product.js', + 'Namespace_Module::favicon.ico', + 'static/frontend/test/default/en_US/Namespace_Module/favicon.ico', ), 'lib folder' => array( 'varien', @@ -135,52 +131,23 @@ public function testGetViewUrlNoFilesDuplicationDataProvider() return array( 'theme css file' => array( 'css/styles.css', - 'theme/static/frontend/test/default/en_US/css/styles.css', + 'static/frontend/test/default/en_US/css/styles.css', ), 'theme file' => array( 'images/logo.gif', - 'theme/static/frontend/test/default/images/logo.gif', + 'static/frontend/test/default/images/logo.gif', ), 'theme localized file' => array( 'logo.gif', - 'theme/static/frontend/test/default/locale/fr_FR/logo.gif', + 'static/frontend/test/default/locale/fr_FR/logo.gif', 'fr_FR', ) ); } /** - * @magentoDataFixture Mage/Core/Model/_files/design/themes.php - * @magentoConfigFixture global/design/theme/allow_view_files_duplication 0 - * @magentoAppIsolation enabled - */ - public function testGetViewUrlNoFilesDuplicationWithCaching() - { - $this->_initTestTheme(); - $this->_model->setDesignTheme('test/default'); - Mage::app()->getLocale()->setLocale('en_US'); - $theme = $this->_model->getDesignTheme(); - $themeDesignParams = array('themeModel' => $theme); - $cacheKey = "frontend|{$theme->getId()}|en_US"; - Mage::app()->cleanCache(); - - $viewFile = 'images/logo.gif'; - $this->_model->getViewFileUrl($viewFile, $themeDesignParams); - $map = unserialize(Mage::app()->loadCache($cacheKey)); - $this->assertTrue(count($map) == 1); - $this->assertStringEndsWith('logo.gif', (string)array_pop($map)); - - $viewFile = 'images/logo_email.gif'; - $this->_model->getViewFileUrl($viewFile, $themeDesignParams); - $map = unserialize(Mage::app()->loadCache($cacheKey)); - $this->assertTrue(count($map) == 2); - $this->assertStringEndsWith('logo_email.gif', (string)array_pop($map)); - } - - /** - * @param string $file * @expectedException Magento_Exception - * @dataProvider getViewUrlDataExceptionProvider + * @dataProvider getViewUrlExceptionDataProvider */ public function testGetViewUrlException($file) { @@ -190,7 +157,7 @@ public function testGetViewUrlException($file) /** * @return array */ - public function getViewUrlDataExceptionProvider() + public function getViewUrlExceptionDataProvider() { return array( 'non-existing theme file' => array('path/to/non-existing-file.ext'), @@ -365,6 +332,9 @@ public function testPublishCssFileFromModule( } } + /** + * @return array + */ public function publishCssFileFromModuleDataProvider() { return array( @@ -407,7 +377,6 @@ public function publishCssFileFromModuleDataProvider() ); } - /** * Test that modified CSS file and changed resources are re-published in developer mode * @@ -449,6 +418,7 @@ protected function _testPublishResourcesAndCssWhenChangedCss($expectedPublished) Mage_Core_Model_Dir::THEMES => "$appInstallDir/media_for_change", ) )); + $this->_model = Mage::getModel('Mage_Core_Model_Design_Package'); $this->_model->setDesignTheme('test/default'); $themePath = $this->_model->getDesignTheme()->getFullPath(); $fixtureViewPath = "$appInstallDir/media_for_change/$themePath/"; @@ -558,6 +528,7 @@ protected function _initTestTheme() Mage_Core_Model_Dir::THEMES => dirname(__DIR__) . '/_files/design/' ) )); + $this->_model = Mage::getModel('Mage_Core_Model_Design_Package'); // Reinit model with new directories $this->_model->setDesignTheme('test/default'); } @@ -596,7 +567,7 @@ public function testCssWithBase64Data() ); $filePath = $this->_model->getViewFile('css/base64.css', $params); - // publicate static content + // publish static content $this->_model->getViewFileUrl('css/base64.css', $params); $this->assertFileEquals($filePath, str_replace('/', DIRECTORY_SEPARATOR, "{$publishedPath}/css/base64.css")); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Design/PackageTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Design/PackageTest.php index 8ddae5cdc5ea5..7239dcde2b0d0 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Design/PackageTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Design/PackageTest.php @@ -60,11 +60,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Core_Model_Design_Package'); } - protected function tearDown() - { - $this->_model = null; - } - /** * Emulate fixture design theme * @@ -179,109 +174,45 @@ public function extractScopeExceptionDataProvider() ); } - /** - * @magentoAppIsolation enabled - */ - public function testGetOptimalCssUrls() - { - $this->_emulateFixtureTheme(); - $expected = array( - 'http://localhost/pub/media/theme/static/frontend/test/default/en_US/css/styles.css', - 'http://localhost/pub/lib/mage/translate-inline.css', - ); - $params = array( - 'css/styles.css', - 'mage/translate-inline.css', - ); - $this->assertEquals($expected, $this->_model->getOptimalCssUrls($params)); - } - - /** - * @param array $files - * @param array $expectedFiles - * @dataProvider getOptimalCssUrlsMergedDataProvider - * @magentoConfigFixture current_store dev/css/merge_css_files 1 - * @magentoAppIsolation enabled - */ - public function testGetOptimalCssUrlsMerged($files, $expectedFiles) - { - $this->_emulateFixtureTheme(); - $this->assertEquals($expectedFiles, $this->_model->getOptimalCssUrls($files)); - } - - public function getOptimalCssUrlsMergedDataProvider() - { - return array( - array( - array('css/styles.css', 'mage/calendar.css'), - array('http://localhost/pub/media/theme/static/_merged/dce6f2a22049cd09bbfbe344fc73b037.css') - ), - array( - array('css/styles.css'), - array('http://localhost/pub/media/theme/static/frontend/test/default/en_US/css/styles.css',) - ), - ); - } /** * @magentoAppIsolation enabled */ - public function testGetOptimalJsUrls() + public function testGetViewConfig() { $this->_emulateFixtureTheme(); - $expected = array( - 'http://localhost/pub/media/theme/static/frontend/test/default/en_US/js/tabs.js', - 'http://localhost/pub/lib/jquery/jquery-ui-timepicker-addon.js', - 'http://localhost/pub/lib/mage/calendar.js', - ); - $params = array( - 'js/tabs.js', - 'jquery/jquery-ui-timepicker-addon.js', - 'mage/calendar.js', - ); - $this->assertEquals($expected, $this->_model->getOptimalJsUrls($params)); + $config = $this->_model->getViewConfig(); + $this->assertInstanceOf('Magento_Config_View', $config); + $this->assertEquals(array('var1' => 'value1', 'var2' => 'value2'), $config->getVars('Namespace_Module')); } /** - * @param array $files - * @param array $expectedFiles - * @dataProvider getOptimalJsUrlsMergedDataProvider - * @magentoConfigFixture current_store dev/js/merge_files 1 * @magentoAppIsolation enabled */ - public function testGetOptimalJsUrlsMerged($files, $expectedFiles) + public function testGetConfigCustomized() { $this->_emulateFixtureTheme(); - $this->assertEquals($expectedFiles, $this->_model->getOptimalJsUrls($files)); - } - - public function getOptimalJsUrlsMergedDataProvider() - { - return array( - array( - array('js/tabs.js', 'mage/calendar.js', 'jquery/jquery-ui-timepicker-addon.js'), - array('http://localhost/pub/media/theme/static/_merged/51cf03344697f37c2511aa0ad3391d56.js',) - ), - array( - array('mage/calendar.js'), - array('http://localhost/pub/lib/mage/calendar.js',) - ), - ); - } + $theme = $this->_model->getDesignTheme(); + $customConfigFile = $theme->getCustomViewConfigPath(); + /** @var $filesystem Magento_Filesystem */ + $filesystem = Mage::getObjectManager()->create('Magento_Filesystem'); + $filesystem->setIsAllowCreateDirectories(true); + try { + $filesystem->write($customConfigFile, ' + custom value'); - /** - * @magentoAppIsolation enabled - */ - public function testGetViewConfig() - { - $this->_emulateFixtureTheme(); - $config = $this->_model->getViewConfig(); - $this->assertInstanceOf('Magento_Config_View', $config); - $this->assertEquals(array('var1' => 'value1', 'var2' => 'value2'), $config->getVars('Namespace_Module')); + $config = $this->_model->getViewConfig(); + $this->assertInstanceOf('Magento_Config_View', $config); + $this->assertEquals(array('customVar' => 'custom value'), $config->getVars('Namespace_Module')); + } catch (Exception $e) { + $filesystem->delete($customConfigFile); + throw $e; + } + $filesystem->delete($customConfigFile); } /** - * @param bool $devMode + * @param string $appMode * @param string $file * @param string $result * @@ -290,15 +221,18 @@ public function testGetViewConfig() * @magentoConfigFixture current_store dev/static/sign 0 * @magentoAppIsolation enabled */ - public function testGetViewUrl($devMode, $file, $result) + public function testGetViewUrl($appMode, $file, $result) { + $currentAppMode = Mage::getObjectManager()->get('Mage_Core_Model_App_State')->getMode(); + if ($currentAppMode != $appMode) { + $this->markTestSkipped("Implemented to be run in {$appMode} mode"); + } $this->_emulateFixtureTheme(); - Mage::setIsDeveloperMode($devMode); $this->assertEquals($this->_model->getViewFileUrl($file), $result); } /** - * @param bool $devMode + * @param string $appMode * @param string $file * @param string $result * @@ -307,9 +241,12 @@ public function testGetViewUrl($devMode, $file, $result) * @magentoConfigFixture current_store dev/static/sign 1 * @magentoAppIsolation enabled */ - public function testGetViewUrlSigned($devMode, $file, $result) + public function testGetViewUrlSigned($appMode, $file, $result) { - Mage::setIsDeveloperMode($devMode); + $currentAppMode = Mage::getObjectManager()->get('Mage_Core_Model_App_State')->getMode(); + if ($currentAppMode != $appMode) { + $this->markTestSkipped("Implemented to be run in {$appMode} mode"); + } $url = $this->_model->getViewFileUrl($file); $this->assertEquals(strpos($url, $result), 0); $lastModified = array(); @@ -327,39 +264,39 @@ public function getViewUrlDataProvider() { return array( array( - false, + Mage_Core_Model_App_State::MODE_DEFAULT, 'Mage_Page::favicon.ico', - 'http://localhost/pub/media/theme/static/frontend/test/default/en_US/Mage_Page/favicon.ico', + 'http://localhost/pub/static/frontend/test/default/en_US/Mage_Page/favicon.ico', ), array( - true, + Mage_Core_Model_App_State::MODE_DEVELOPER, 'prototype/prototype.js', 'http://localhost/pub/lib/prototype/prototype.js' ), array( - false, + Mage_Core_Model_App_State::MODE_DEFAULT, 'prototype/prototype.js', 'http://localhost/pub/lib/prototype/prototype.min.js' ), array( - true, + Mage_Core_Model_App_State::MODE_DEVELOPER, 'Mage_Page::menu.js', - 'http://localhost/pub/media/theme/static/frontend/test/default/en_US/Mage_Page/menu.js' + 'http://localhost/pub/static/frontend/test/default/en_US/Mage_Page/menu.js' ), array( - false, + Mage_Core_Model_App_State::MODE_DEFAULT, 'Mage_Page::menu.js', - 'http://localhost/pub/media/theme/static/frontend/test/default/en_US/Mage_Page/menu.js' + 'http://localhost/pub/static/frontend/test/default/en_US/Mage_Page/menu.js' ), array( - false, + Mage_Core_Model_App_State::MODE_DEFAULT, 'Mage_Catalog::widgets.css', - 'http://localhost/pub/media/theme/static/frontend/test/default/en_US/Mage_Catalog/widgets.css' + 'http://localhost/pub/static/frontend/test/default/en_US/Mage_Catalog/widgets.css' ), array( - true, + Mage_Core_Model_App_State::MODE_DEVELOPER, 'Mage_Catalog::widgets.css', - 'http://localhost/pub/media/theme/static/frontend/test/default/en_US/Mage_Catalog/widgets.css' + 'http://localhost/pub/static/frontend/test/default/en_US/Mage_Catalog/widgets.css' ), ); } diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/DesignTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/DesignTest.php index cae63d0b885eb..f336f854a08bb 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/DesignTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/DesignTest.php @@ -37,11 +37,6 @@ public function setUp() $this->_model = Mage::getModel('Mage_Core_Model_Design'); } - protected function tearDown() - { - $this->_model = null; - } - public function testLoadChange() { $this->_model->loadChange(1); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/DirFilesystemTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/DirFilesystemTest.php index 752a2a35184b8..fa00e78021eb5 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/DirFilesystemTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/DirFilesystemTest.php @@ -159,12 +159,13 @@ public function testNewDirInWritableDir($dirCode) public function writableDirCodeDataProvider() { return array( - Mage_Core_Model_Dir::MEDIA => array(Mage_Core_Model_Dir::MEDIA), - Mage_Core_Model_Dir::VAR_DIR => array(Mage_Core_Model_Dir::VAR_DIR), - Mage_Core_Model_Dir::TMP => array(Mage_Core_Model_Dir::TMP), - Mage_Core_Model_Dir::CACHE => array(Mage_Core_Model_Dir::CACHE), - Mage_Core_Model_Dir::LOG => array(Mage_Core_Model_Dir::LOG), - Mage_Core_Model_Dir::SESSION => array(Mage_Core_Model_Dir::SESSION), + Mage_Core_Model_Dir::MEDIA => array(Mage_Core_Model_Dir::MEDIA), + Mage_Core_Model_Dir::STATIC_VIEW => array(Mage_Core_Model_Dir::STATIC_VIEW), + Mage_Core_Model_Dir::VAR_DIR => array(Mage_Core_Model_Dir::VAR_DIR), + Mage_Core_Model_Dir::TMP => array(Mage_Core_Model_Dir::TMP), + Mage_Core_Model_Dir::CACHE => array(Mage_Core_Model_Dir::CACHE), + Mage_Core_Model_Dir::LOG => array(Mage_Core_Model_Dir::LOG), + Mage_Core_Model_Dir::SESSION => array(Mage_Core_Model_Dir::SESSION), ); } } diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Email/Template/FilterTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Email/Template/FilterTest.php index 1cc31c4dde5fb..d8e5abe09c770 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Email/Template/FilterTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Email/Template/FilterTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Core_Model_Email_Template_Filter'); } - protected function tearDown() - { - $this->_model = null; - } - /** * Isolation level has been raised in order to flush themes configuration in-memory cache */ @@ -121,8 +116,8 @@ public function testLayoutDirective($area, $directiveParams, $expectedOutput) $themeId = $collection->getThemeByFullPath('frontend/test/default')->getId(); Mage::app()->getStore()->setConfig(Mage_Core_Model_Design_Package::XML_PATH_THEME_ID, $themeId); - /** @var $layout Mage_Core_Model_Layout */ $objectManager = Mage::getObjectManager(); + /** @var $layout Mage_Core_Model_Layout */ $layout = $objectManager->create('Mage_Core_Model_Layout', array('area' => $area)); $objectManager->addSharedInstance($layout, 'Mage_Core_Model_Layout'); $this->assertEquals($area, $layout->getArea()); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Email/TemplateTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Email/TemplateTest.php index 8553d4985cc31..d9dac1c4574b9 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Email/TemplateTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Email/TemplateTest.php @@ -45,8 +45,7 @@ protected function setUp() $this->_model = $this->getMockBuilder('Mage_Core_Model_Email_Template') ->setMethods(array('_getMail')) ->setConstructorArgs(array( - $this->getMockBuilder('Mage_Core_Model_Event_Manager')->disableOriginalConstructor()->getMock(), - $this->getMockBuilder('Mage_Core_Model_Cache')->disableOriginalConstructor()->getMock(), + Mage::getSingleton('Mage_Core_Model_Context'), Mage::getObjectManager()->create('Magento_Filesystem') )) ->getMock(); @@ -54,12 +53,6 @@ protected function setUp() $this->_model->setSenderName('sender')->setSenderEmail('sender@example.com')->setTemplateSubject('Subject'); } - protected function tearDown() - { - $this->_model = null; - $this->_mail = null; - } - /** * Return a disposable Zend_Mail instance * @@ -111,7 +104,7 @@ public function testDefaultTemplateAsOptionsArray() public function testGetProcessedTemplate() { $this->_setBlueThemeForFixtureStore(); - $expectedViewUrl = 'theme/static/frontend/default/demo_blue/en_US/Mage_Page/favicon.ico'; + $expectedViewUrl = 'static/frontend/default/demo_blue/en_US/Mage_Page/favicon.ico'; $this->_model->setTemplateText('{{view url="Mage_Page::favicon.ico"}}'); $this->assertStringEndsNotWith($expectedViewUrl, $this->_model->getProcessedTemplate()); $this->_model->setDesignConfig(array( @@ -141,7 +134,7 @@ public function testGetProcessedTemplateDesignChange() { $this->_model->setTemplateText('{{view url="Mage_Page::favicon.ico"}}'); $this->assertStringEndsWith( - 'theme/static/frontend/default/modern/en_US/Mage_Page/favicon.ico', + 'static/frontend/default/modern/en_US/Mage_Page/favicon.ico', $this->_model->getProcessedTemplate() ); } @@ -154,7 +147,7 @@ public function testGetProcessedTemplateDesignChange() public function testGetProcessedTemplateSubject() { $this->_setBlueThemeForFixtureStore(); - $expectedViewUrl = 'theme/static/frontend/default/demo_blue/en_US/Mage_Page/favicon.ico'; + $expectedViewUrl = 'static/frontend/default/demo_blue/en_US/Mage_Page/favicon.ico'; $this->_model->setTemplateSubject('{{view url="Mage_Page::favicon.ico"}}'); $this->assertStringEndsNotWith($expectedViewUrl, $this->_model->getProcessedTemplateSubject(array())); $this->_model->setDesignConfig(array( diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/EncryptionTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/EncryptionTest.php index 26e497accb4e8..e2f54afed5792 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/EncryptionTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/EncryptionTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Core_Model_Encryption'); } - protected function tearDown() - { - $this->_model = null; - } - public function testEncryptDecrypt() { $this->assertEquals('', $this->_model->decrypt($this->_model->encrypt(''))); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Layout/ElementTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Layout/ElementTest.php index 1bbb154fd8e30..1fd43f4435931 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Layout/ElementTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Layout/ElementTest.php @@ -32,11 +32,6 @@ class Mage_Core_Model_Layout_ElementTest extends PHPUnit_Framework_TestCase */ protected $_model; - protected function tearDown() - { - $this->_model = null; - } - public function testPrepare() { /** diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Layout/MergeTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Layout/MergeTest.php index 787f6fc13130d..972474bf4ec89 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Layout/MergeTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Layout/MergeTest.php @@ -49,11 +49,6 @@ protected function setUp() )); } - protected function tearDown() - { - $this->_model = null; - } - public function testAddUpdate() { $this->assertEmpty($this->_model->asArray()); @@ -310,7 +305,7 @@ public function testGetFileLayoutUpdatesXmlFromModule() '); $expectedXmlStr = $this->_readLayoutFileContents( - __DIR__ . '/../../../../../../../../app/code/core/Mage/Page/view/frontend/layout.xml' + __DIR__ . '/../../../../../../../../app/code/Mage/Page/view/frontend/layout.xml' ); $actualXml = $this->_model->getFileLayoutUpdatesXml(); $this->assertXmlStringEqualsXmlString($expectedXmlStr, $actualXml->asNiceXml()); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Layout/UpdateTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Layout/UpdateTest.php index eca94863c5905..73fb34a4489f7 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Layout/UpdateTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Layout/UpdateTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Core_Model_Layout_Update'); } - protected function tearDown() - { - $this->_model = null; - } - public function testConstructor() { $this->_model = Mage::getModel('Mage_Core_Model_Layout_Update'); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/LayoutTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/LayoutTest.php index d3a8d537206aa..e30ae59177377 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/LayoutTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/LayoutTest.php @@ -44,11 +44,6 @@ protected function setUp() $this->_layout = Mage::getModel('Mage_Core_Model_Layout'); } - protected function tearDown() - { - $this->_layout = null; - } - /** * @param array $inputArguments * @param string $expectedArea @@ -108,6 +103,7 @@ public function testGenerateXml() $this->getMock('Mage_Core_Model_Layout_Argument_Processor', array(), array(), '', false), $this->getMock('Mage_Core_Model_Layout_Translator', array(), array(), '', false), $this->getMock('Mage_Core_Model_Layout_ScheduledStructure', array(), array(), '', false), + $this->getMock('Magento_Datasource_Factory', array(), array(), '', false), )); $merge = $this->getMock('StdClass', array('asSimplexml')); $merge->expects($this->once())->method('asSimplexml')->will($this->returnValue(simplexml_load_string( @@ -195,7 +191,7 @@ public function testCreateBlock($blockType, $blockName, array $blockData, $expec { $expectedData = $blockData + array('type' => $blockType); - $block = $this->_layout->createBlock($blockType, $blockName, $blockData); + $block = $this->_layout->createBlock($blockType, $blockName, array('data' => $blockData)); $this->assertEquals($this->_layout, $block->getLayout()); $this->assertRegExp($expectedName, $block->getNameInLayout()); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/LocaleTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/LocaleTest.php new file mode 100644 index 0000000000000..a038f62e72c31 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Core/Model/LocaleTest.php @@ -0,0 +1,38 @@ +assertNull(Zend_Locale_Data::getCache()); + $model = new Mage_Core_Model_Locale('some_locale'); + $this->assertInstanceOf('Zend_Locale', $model->getLocale()); + $this->assertInstanceOf('Zend_Cache_Core', Zend_Locale_Data::getCache()); + } +} diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/ObserverTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/ObserverTest.php index c50b12dedc47b..6ba1f9adf1879 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/ObserverTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/ObserverTest.php @@ -30,6 +30,22 @@ */ class Mage_Core_Model_ObserverTest extends PHPUnit_Framework_TestCase { + /** + * @var Varien_Event_Observer + */ + protected $_eventObserver; + + /** + * @var Magento_Test_ObjectManager + */ + protected $_objectManager; + + protected function setUp() + { + $this->_objectManager = Mage::getObjectManager(); + $this->_eventObserver = $this->_createEventObserverForThemeRegistration(); + } + /** * Theme registration test * @@ -41,35 +57,22 @@ public function testThemeRegistration() $baseDir = 'base_dir'; $pattern = 'path_pattern'; - $eventObserver = $this->_createEventObserverForThemeRegistration(); - $eventObserver->getEvent()->setBaseDir($baseDir); - $eventObserver->getEvent()->setPathPattern($pattern); + $this->_eventObserver->getEvent()->setBaseDir($baseDir); + $this->_eventObserver->getEvent()->setPathPattern($pattern); - /** @var $objectManager Magento_Test_ObjectManager */ - $objectManager = Mage::getObjectManager(); $themeRegistration = $this->getMock( 'Mage_Core_Model_Theme_Registration', array('register'), - array($objectManager->create('Mage_Core_Model_Theme')) + array($this->_objectManager->create('Mage_Core_Model_Theme')) ); $themeRegistration->expects($this->once()) ->method('register') ->with($baseDir, $pattern); - $objectManager->addSharedInstance($themeRegistration, 'Mage_Core_Model_Theme_Registration'); + $this->_objectManager->addSharedInstance($themeRegistration, 'Mage_Core_Model_Theme_Registration'); /** @var $observer Mage_Core_Model_Observer */ - $observer = Mage::getModel('Mage_Core_Model_Observer'); - $observer->themeRegistration($eventObserver); - } - - /** - * Get theme model - * - * @return Mage_Core_Model_Theme - */ - protected function _getThemeModel() - { - return Mage::getModel('Mage_Core_Model_Theme'); + $observer = $this->_objectManager->create('Mage_Core_Model_Observer'); + $observer->themeRegistration($this->_eventObserver); } /** @@ -79,8 +82,10 @@ protected function _getThemeModel() */ protected function _createEventObserverForThemeRegistration() { - $response = Mage::getModel('Varien_Object', array('additional_options' => array())); - $event = Mage::getModel('Varien_Event', array('response_object' => $response)); - return Mage::getModel('Varien_Event_Observer', array('event' => $event)); + $response = $this->_objectManager->create('Varien_Object', array( + 'data' => array('additional_options' => array()) + )); + $event = $this->_objectManager->create('Varien_Event', array('data' => array('response_object' => $response))); + return $this->_objectManager->create('Varien_Event_Observer', array('data' => array('event' => $event))); } } diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/CacheTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/CacheTest.php index d84023c3ad4cf..3766f5a4621cd 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/CacheTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/CacheTest.php @@ -37,11 +37,6 @@ public function setUp() $this->_model = Mage::getResourceModel('Mage_Core_Model_Resource_Cache'); } - protected function tearDown() - { - $this->_model = null; - } - /** * @magentoConfigFixture global/resources/db/table_prefix prefix_ */ diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/ConfigTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/ConfigTest.php index d57e35c1e88c8..b010ea6b52d44 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/ConfigTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/ConfigTest.php @@ -37,11 +37,6 @@ public function setUp() $this->_model = Mage::getResourceModel('Mage_Core_Model_Resource_Config'); } - protected function tearDown() - { - $this->_model = null; - } - public function testSaveDeleteConfig() { $connection = $this->_model->getReadConnection(); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Db/AbstractTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Db/AbstractTest.php index e662e65d15681..beb22f2c69ba5 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Db/AbstractTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Db/AbstractTest.php @@ -41,11 +41,6 @@ public function setUp() } - protected function tearDown() - { - $this->_model = null; - } - public function testConstruct() { $resourceProperty = new ReflectionProperty(get_class($this->_model), '_resources'); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Db/Collection/AbstractTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Db/Collection/AbstractTest.php index 59b6168f0f402..0bc07577ac70e 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Db/Collection/AbstractTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Db/Collection/AbstractTest.php @@ -49,11 +49,6 @@ protected function setUp() ); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetAllIds() { $allIds = $this->_model->getAllIds(); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Entity/TableTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Entity/TableTest.php index ed364e3cb4372..54c9807a3cd1d 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Entity/TableTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Entity/TableTest.php @@ -43,11 +43,6 @@ protected function setUp() $this->_model = Mage::getResourceModel('Mage_Core_Model_Resource_Entity_Table', array('config' => $config)); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetTable() { $this->assertEquals('test_table', $this->_model->getTable()); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Helper/Mysql4Test.php b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Helper/Mysql4Test.php index 87893b3382238..addcec6d5d5de 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Helper/Mysql4Test.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Helper/Mysql4Test.php @@ -50,12 +50,6 @@ protected function setUp() $this->_select = $collection->getSelect(); } - protected function tearDown() - { - $this->_model = null; - $this->_select = null; - } - public function testCastField() { $this->assertEquals('test', $this->_model->castField('test')); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/IteratorTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/IteratorTest.php index 624d42c61e147..e1bb5a246933f 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/IteratorTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/IteratorTest.php @@ -44,11 +44,6 @@ public function setUp() $this->_model = Mage::getResourceModel('Mage_Core_Model_Resource_Iterator'); } - protected function tearDown() - { - $this->_model = null; - } - public function testWalk() { $collection = Mage::getResourceModel('Mage_Core_Model_Resource_Store_Collection'); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/LayoutTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/LayoutTest.php index 50f3b998a24cf..82a3f70d05761 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/LayoutTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/LayoutTest.php @@ -37,11 +37,6 @@ public function setUp() $this->_model = Mage::getResourceModel('Mage_Core_Model_Resource_Layout_Update'); } - protected function tearDown() - { - $this->_model = null; - } - public function testFetchUpdatesByHandle() { $this->assertEmpty($this->_model->fetchUpdatesByHandle('test', array('test' => 'test'))); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/SessionTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/SessionTest.php index 99d8c4182a9e6..1389bc758543b 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/SessionTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/SessionTest.php @@ -107,15 +107,6 @@ public function setUp() } } - protected function tearDown() - { - unset($this->_objectManager); - unset($this->_model); - unset($this->_connection); - unset($this->_sessionTable); - unset($this->_sessionData); - } - public function testHasConnection() { $this->assertTrue($this->_model->hasConnection()); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/SetupTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/SetupTest.php index 1f00b55ae1a52..b39d7aa43f2b6 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/SetupTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/SetupTest.php @@ -39,11 +39,6 @@ public function setUp() ); } - protected function tearDown() - { - $this->_model = null; - } - public function testSetTable() { $this->_model->setTable('test_name', 'test_real_name'); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Store/CollectionTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Store/CollectionTest.php index 7cf065032420a..247acec4363e9 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Store/CollectionTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Store/CollectionTest.php @@ -37,11 +37,6 @@ public function setUp() $this->_collection = Mage::getResourceModel('Mage_Core_Model_Resource_Store_Collection'); } - protected function tearDown() - { - $this->_collection = null; - } - public function testSetGetLoadDefault() { $this->assertFalse($this->_collection->getLoadDefault()); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Theme/CollectionTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Theme/CollectionTest.php index f6180a00f9e29..e3ba441337d57 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Theme/CollectionTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/Theme/CollectionTest.php @@ -75,54 +75,111 @@ public function testGetThemeByFullPath($fullPath, $shouldExist) $this->assertEquals($shouldExist, $hasFound, $message); } + /** + * @return array + */ + public function getThemeByFullPathDataProvider() + { + return array( + array('test_area/test/default', true), + array('test_area2/test/pro', true), + array('test_area/test/pro', false), + array('test_area2/test/default', false), + array('', false), + array('test_area', false), + array('test_area/test', false), + array('test_area/test/something', false), + ); + } + /** * @magentoDataFixture setThemeFixture * @magentoDbIsolation enabled + * @dataProvider addAreaFilterDataProvider + * @covers Mage_Core_Model_Theme::addAreaFilter */ - public function testAddAreaFilter() + public function testAddAreaFilter($area, $themeCount) { /** @var $themeCollection Mage_Core_Model_Resource_Theme_Collection */ $themeCollection = Mage::getObjectManager()->create('Mage_Core_Model_Resource_Theme_Collection'); - $themeCollection->addAreaFilter('test_area'); - $this->assertEquals(1, count($themeCollection)); + $themeCollection->addAreaFilter($area); + $this->assertCount($themeCount, $themeCollection); + } - /** @var $themeCollection Mage_Core_Model_Resource_Theme_Collection */ - $themeCollection = Mage::getObjectManager()->create('Mage_Core_Model_Resource_Theme_Collection'); - $themeCollection->addAreaFilter('test_area2'); - $this->assertEquals(1, count($themeCollection)); + /** + * @return array + */ + public function addAreaFilterDataProvider() + { + return array( + array('area' => 'test_area', 'themeCount' => 1), + array('area' => 'test_area2', 'themeCount' => 1), + array('area' => 'test_area4', 'themeCount' => 0) + ); + } + /** + * @magentoDataFixture setThemeFixture + * @magentoDbIsolation enabled + * @dataProvider addTypeFilterDataProvider + * @covers Mage_Core_Model_Theme::addTypeFilter + */ + public function testAddTypeFilter($themeType, $themeCount) + { /** @var $themeCollection Mage_Core_Model_Resource_Theme_Collection */ $themeCollection = Mage::getObjectManager()->create('Mage_Core_Model_Resource_Theme_Collection'); $themeCollection->addAreaFilter('test_area3'); - $this->assertEquals(0, count($themeCollection)); + if ($themeType !== false) { + $themeCollection->addTypeFilter($themeType); + } + $this->assertCount($themeCount, $themeCollection); } - public function getThemeByFullPathDataProvider() + /** + * @return array + */ + public function addTypeFilterDataProvider() { return array( - array('test_area/test/default', true), - array('test_area2/test/pro', true), - array('test_area/test/pro', false), - array('test_area2/test/default', false), - array('', false), - array('test_area', false), - array('test_area/test', false), - array('test_area/test/something', false), + array('themeType' => Mage_Core_Model_Theme::TYPE_PHYSICAL, 'themeCount' => 1), + array('themeType' => Mage_Core_Model_Theme::TYPE_VIRTUAL, 'themeCount' => 1), + array('themeType' => Mage_Core_Model_Theme::TYPE_STAGING, 'themeCount' => 1), + array('themeType' => false, 'themeCount' => 3) ); } + /** + * @magentoDataFixture setThemeFixture + * @magentoDbIsolation enabled + * @covers Mage_Core_Model_Theme::filterVisibleThemes + */ + public function testFilterVisibleThemes() + { + /** @var $themeCollection Mage_Core_Model_Resource_Theme_Collection */ + $themeCollection = Mage::getObjectManager()->create('Mage_Core_Model_Resource_Theme_Collection'); + $themeCollection->addAreaFilter('test_area3')->filterVisibleThemes(); + $this->assertCount(2, $themeCollection); + /** @var $theme Mage_Core_Model_Theme */ + foreach ($themeCollection as $theme) { + $this->assertTrue(in_array( + $theme->getType(), + array(Mage_Core_Model_Theme::TYPE_PHYSICAL, Mage_Core_Model_Theme::TYPE_VIRTUAL) + )); + } + } + /** * @magentoDataFixture setInheritedThemeFixture */ public function testCheckParentInThemes() { - $collection = self::_getThemesCollection()->checkParentInThemes(); + $collection = self::_getThemesCollection(); //->checkParentInThemes(); foreach (self::getInheritedThemeList() as $themeData) { $fullPath = $themeData['area'] . '/' . $themeData['theme_path']; $parentIdActual = $collection->clear()->getThemeByFullPath($fullPath)->getParentId(); if ($themeData['parent_id']) { $parentFullPath = trim($themeData['parent_id'], '{}'); - $parentIdExpected = $collection->clear()->getThemeByFullPath($parentFullPath)->getId(); + $parentIdExpected = (int)$collection->clear()->getThemeByFullPath($parentFullPath)->getId(); $this->assertEquals( $parentIdActual, $parentIdExpected, @@ -157,6 +214,9 @@ public static function setThemeFixture() return $themeCollection->save(); } + /** + * @throws Exception + */ public static function setInheritedThemeFixture() { $fixture = self::getInheritedThemeList(); @@ -166,14 +226,8 @@ public static function setInheritedThemeFixture() $themeModel = Mage::getObjectManager()->create('Mage_Core_Model_Theme'); $themeModel->setData($themeData); - //if ($themeModel->getFullPath() == 'test1/test1') - - if ($themeData['parent_id'] && $themeData['parent_id'] == sprintf('{%s}', $themeModel->getFullPath())) { - if (isset($idByPath[$themeModel->getFullPath()])) { - $themeModel->setParentId($idByPath[$themeModel->getFullPath()]); - } else { - throw new Exception('Broken test, theme_id not found by full_name'); - } + if ($themeData['parent_id'] && isset($idByPath[$themeData['parent_id']])) { + $themeModel->setParentId($idByPath[$themeData['parent_id']]); } $themeModel->save(); @@ -198,7 +252,8 @@ public static function getThemeList() 'magento_version_from' => '2.0.0.0', 'magento_version_to' => '*', 'is_featured' => '1', - 'area' => 'test_area' + 'area' => 'test_area', + 'type' => Mage_Core_Model_Theme::TYPE_PHYSICAL, ), array( 'parent_id' => '0', @@ -209,11 +264,51 @@ public static function getThemeList() 'magento_version_from' => '2.0.0.0', 'magento_version_to' => '*', 'is_featured' => '1', - 'area' => 'test_area2' + 'area' => 'test_area2', + 'type' => Mage_Core_Model_Theme::TYPE_VIRTUAL, ), + array( + 'parent_id' => '0', + 'theme_path' => 'test/fixed1', + 'theme_version' => '2.0.0.0', + 'theme_title' => 'Theme test 1', + 'preview_image' => 'test_default.jpg', + 'magento_version_from' => '2.0.0.0', + 'magento_version_to' => '*', + 'is_featured' => '1', + 'area' => 'test_area3', + 'type' => Mage_Core_Model_Theme::TYPE_STAGING, + ), + array( + 'parent_id' => '0', + 'theme_path' => 'test/fixed2', + 'theme_version' => '2.0.0.0', + 'theme_title' => 'Theme test 2', + 'preview_image' => 'test_default.jpg', + 'magento_version_from' => '2.0.0.0', + 'magento_version_to' => '*', + 'is_featured' => '1', + 'area' => 'test_area3', + 'type' => Mage_Core_Model_Theme::TYPE_PHYSICAL, + ), + array( + 'parent_id' => '0', + 'theme_path' => 'test/fixed3', + 'theme_version' => '2.0.0.0', + 'theme_title' => 'Theme test 3', + 'preview_image' => 'test_default.jpg', + 'magento_version_from' => '2.0.0.0', + 'magento_version_to' => '*', + 'is_featured' => '1', + 'area' => 'test_area3', + 'type' => Mage_Core_Model_Theme::TYPE_VIRTUAL, + ) ); } + /** + * @return array + */ public static function getInheritedThemeList() { return array( @@ -226,10 +321,11 @@ public static function getInheritedThemeList() 'magento_version_from' => '2.0.0.0', 'magento_version_to' => '*', 'is_featured' => '1', - 'area' => 'area51' + 'area' => 'area51', + 'type' => Mage_Core_Model_Theme::TYPE_PHYSICAL ), array( - 'parent_id' => '{area51/test1/test1}', + 'parent_id' => 'area51/test1/test1', 'theme_path' => 'test1/test2', 'theme_version' => '2.0.0.0', 'theme_title' => 'Test2', @@ -237,10 +333,11 @@ public static function getInheritedThemeList() 'magento_version_from' => '2.0.0.0', 'magento_version_to' => '*', 'is_featured' => '1', - 'area' => 'area51' + 'area' => 'area51', + 'type' => Mage_Core_Model_Theme::TYPE_VIRTUAL ), array( - 'parent_id' => '{area51/test1/test2}', + 'parent_id' => 'area51/test1/test2', 'theme_path' => 'test1/test3', 'theme_version' => '2.0.0.0', 'theme_title' => 'Test3', @@ -248,10 +345,11 @@ public static function getInheritedThemeList() 'magento_version_from' => '2.0.0.0', 'magento_version_to' => '*', 'is_featured' => '1', - 'area' => 'area51' + 'area' => 'area51', + 'type' => Mage_Core_Model_Theme::TYPE_VIRTUAL ), array( - 'parent_id' => '{area51/test1/test0}', + 'parent_id' => 'area51/test1/test0', 'theme_path' => 'test1/test4', 'theme_version' => '2.0.0.0', 'theme_title' => 'Test4', @@ -259,7 +357,8 @@ public static function getInheritedThemeList() 'magento_version_from' => '2.0.0.0', 'magento_version_to' => '*', 'is_featured' => '1', - 'area' => 'area51' + 'area' => 'area51', + 'type' => Mage_Core_Model_Theme::TYPE_VIRTUAL ), ); } diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/TransactionTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/TransactionTest.php index 63f5b1ab17c7a..d4774654bfcfa 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Resource/TransactionTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Resource/TransactionTest.php @@ -37,11 +37,6 @@ public function setUp() $this->_model = Mage::getResourceModel('Mage_Core_Model_Resource_Transaction'); } - protected function tearDown() - { - $this->_model = null; - } - public function testSaveDelete() { $first = Mage::getModel('Mage_Core_Model_Store_Group'); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/ResourceMysqlTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/ResourceMysqlTest.php index 3182199811741..d49af2d637e31 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/ResourceMysqlTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/ResourceMysqlTest.php @@ -40,11 +40,6 @@ public function setUp() $this->_model = Mage::getModel('Mage_Core_Model_Resource'); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetConnectionTypeInstance() { $this->assertInstanceOf( diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/ResourceTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/ResourceTest.php index 67ea705eb7691..fd9437278be18 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/ResourceTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/ResourceTest.php @@ -35,11 +35,6 @@ public function setUp() $this->_model = Mage::getModel('Mage_Core_Model_Resource'); } - protected function tearDown() - { - $this->_model = null; - } - /** * @magentoConfigFixture global/resources/db/table_prefix prefix_ */ diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Session/AbstractTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Session/AbstractTest.php index 53bdd18570dba..47c9895453ef9 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Session/AbstractTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Session/AbstractTest.php @@ -37,11 +37,6 @@ public function setUp() $this->_model = $this->getMockForAbstractClass('Mage_Core_Model_Session_Abstract'); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetCookie() { $cookie = $this->_model->getCookie(); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Store/GroupTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Store/GroupTest.php index 96a086c6e78c5..4f5c0f3be1f40 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Store/GroupTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Store/GroupTest.php @@ -34,14 +34,7 @@ class Mage_Core_Model_Store_GroupTest extends PHPUnit_Framework_TestCase public function setUp() { - $eventDispatcher = Mage::getObjectManager()->get('Mage_Core_Model_Event_Manager'); - $cacheManager = Mage::getObjectManager()->get('Mage_Core_Model_Cache'); - $this->_model = new Mage_Core_Model_Store_Group($eventDispatcher, $cacheManager); - } - - public function tearDown() - { - $this->_model = null; + $this->_model = Mage::getModel('Mage_Core_Model_Store_Group'); } public function testSetGetWebsite() diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/StoreTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/StoreTest.php index 91f75ef3bfa73..cf6d26d7ca0fa 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/StoreTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/StoreTest.php @@ -35,8 +35,9 @@ class Mage_Core_Model_StoreTest extends PHPUnit_Framework_TestCase public function setUp() { $params = array( - 'eventDispatcher' => Mage::getObjectManager()->get('Mage_Core_Model_Event_Manager'), - 'cacheManager' => Mage::getObjectManager()->get('Mage_Core_Model_Cache') + 'context' => Mage::getObjectManager()->get('Mage_Core_Model_Context'), + 'configCacheType' => Mage::getObjectManager()->get('Mage_Core_Model_Cache_Type_Config'), + 'urlModel' => Mage::getObjectManager()->get('Mage_Core_Model_Url'), ); $this->_model = $this->getMock( @@ -46,11 +47,6 @@ public function setUp() ); } - protected function tearDown() - { - $this->_model = null; - } - /** * @dataProvider loadDataProvider */ @@ -141,6 +137,10 @@ public function getBaseUrlDataProvider() array(Mage_Core_Model_Store::URL_TYPE_DIRECT_LINK, false, true, 'http://localhost/index.php/'), array(Mage_Core_Model_Store::URL_TYPE_DIRECT_LINK, true, false, 'http://localhost/'), array(Mage_Core_Model_Store::URL_TYPE_DIRECT_LINK, true, true, 'http://localhost/'), + array(Mage_Core_Model_Store::URL_TYPE_STATIC, false, false, 'http://localhost/pub/static/'), + array(Mage_Core_Model_Store::URL_TYPE_STATIC, false, true, 'http://localhost/pub/static/'), + array(Mage_Core_Model_Store::URL_TYPE_STATIC, true, false, 'http://localhost/pub/static/'), + array(Mage_Core_Model_Store::URL_TYPE_STATIC, true, true, 'http://localhost/pub/static/'), array(Mage_Core_Model_Store::URL_TYPE_LIB, false, false, 'http://localhost/pub/lib/'), array(Mage_Core_Model_Store::URL_TYPE_LIB, false, true, 'http://localhost/pub/lib/'), array(Mage_Core_Model_Store::URL_TYPE_LIB, true, false, 'http://localhost/pub/lib/'), @@ -162,6 +162,10 @@ public function testGetBaseUrlInPub() )); $this->_model->load('default'); + $this->assertEquals( + 'http://localhost/static/', + $this->_model->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_STATIC) + ); $this->assertEquals( 'http://localhost/lib/', $this->_model->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LIB) @@ -339,32 +343,4 @@ public function testSaveValidationLimitation() Mage::app()->getStore()->setId(Mage_Core_Model_App::ADMIN_STORE_ID); $this->_model->save(); } - - /** - * - * @dataProvider getUrlClassNameDataProvider - * @param $urlClassName - * @param $expectedModel - */ - public function testGetUrlModel($urlClassName, $expectedModel) - { - $urlModel = $this->_model->setUrlClassName($urlClassName) - ->getUrlModel(); - $this->assertEquals($expectedModel, get_class($urlModel)); - } - - public function getUrlClassNameDataProvider() - { - return array( - array( - null,'Mage_Core_Model_Url' - ), - array( - 'Mage_Core_Model_Url', 'Mage_Core_Model_Url' - ), - array( - 'Mage_Backend_Model_Url', 'Mage_Backend_Model_Url' - ), - ); - } } diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Theme/FileTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Theme/FileTest.php new file mode 100644 index 0000000000000..d85298ce1b187 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Theme/FileTest.php @@ -0,0 +1,99 @@ +_model = Mage::getObjectManager()->create('Mage_Core_Model_Theme_File'); + /** @var $themeModel Mage_Core_Model_Theme */ + $themeModel = Mage::getObjectManager()->create('Mage_Core_Model_Theme'); + $this->_theme = $themeModel->getCollection()->getFirstItem(); + $this->_data = array( + 'file_path' => 'main.css', + 'file_type' => 'css', + 'content' => 'content files', + 'order' => 0, + 'theme' => $this->_theme, + 'theme_id' => $this->_theme->getId(), + ); + } + + protected function tearDown() + { + $this->_model = null; + $this->_data = array(); + $this->_theme = null; + } + + /** + * Test crud operations for theme files model using valid data + */ + public function testCrud() + { + $this->_model->setData($this->_data); + + $crud = new Magento_Test_Entity($this->_model, array('file_path' => 'rename.css')); + $crud->testCrud(); + } + + public function testGetFullPath() + { + $this->assertNull($this->_model->getFullPath()); + + $this->_model->setData($this->_data); + $this->_model->setId('test'); + $this->assertStringEndsWith('main.css', $this->_model->getFullPath()); + } + + public function testGetAsset() + { + $this->assertNull($this->_model->getAsset()); + $this->_model->setData($this->_data); + $this->_model->setId('test'); + + $asset = $this->_model->getAsset(); + $this->assertInstanceOf('Mage_Core_Model_Page_Asset_PublicFile', $asset); + $assetTwo = $this->_model->getAsset(); + $this->assertNotSame($asset, $assetTwo, '"getAsset()" must return new instance every time'); + } +} diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Theme/Files/JsTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Theme/Files/JsTest.php index e7baf47033070..15456f4175efd 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Theme/Files/JsTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Theme/Files/JsTest.php @@ -84,8 +84,8 @@ public function testSaveData($data) $jsFileModel->setDataForSave($file->getId()); $jsFileModel->saveData($theme); - /** @var $updatedFile Mage_Core_Model_Theme_Files */ - $updatedFile = Mage::getObjectManager()->create('Mage_Core_Model_Theme_Files'); + /** @var $updatedFile Mage_Core_Model_Theme_File */ + $updatedFile = Mage::getObjectManager()->create('Mage_Core_Model_Theme_File'); $updatedFile->load($file->getId()); $this->assertFalse((bool)$updatedFile->getIsTemporary()); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Theme/FilesTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Theme/FilesTest.php deleted file mode 100644 index ee249815115e8..0000000000000 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Theme/FilesTest.php +++ /dev/null @@ -1,65 +0,0 @@ -create('Mage_Core_Model_Theme_Files'); - $filesData = $this->_getThemeFilesValidData(); - - /** @var $themeModel Mage_Core_Model_Theme */ - $themeModel = Mage::getObjectManager()->create('Mage_Core_Model_Theme'); - $theme = $themeModel->getCollection()->getFirstItem(); - - $filesData['theme_id'] = $theme->getId(); - $filesModel->setData($filesData); - - $crud = new Magento_Test_Entity($filesModel, array('file_path' => 'rename.css')); - $crud->testCrud(); - } - - /** - * Get theme files valid data - * - * @return array - */ - protected function _getThemeFilesValidData() - { - return array( - 'file_name' => 'main.css', - 'file_type' => 'css', - 'content' => 'content files', - 'order' => 0, - ); - } - -} diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Theme/RegistrationTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Theme/RegistrationTest.php new file mode 100644 index 0000000000000..1d04e3f384ad3 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Theme/RegistrationTest.php @@ -0,0 +1,117 @@ +_theme = Mage::getModel('Mage_Core_Model_Theme'); + $this->_model = $this->getMockBuilder('Mage_Core_Model_Theme_Registration') + ->setMethods(null) + ->setConstructorArgs(array('theme' => $this->_theme)); + } + + /** + * Register themes by pattern + * Use this method only with database isolation + * + * @return Mage_Core_Model_Theme_RegistrationTest + */ + protected function registerThemes() + { + $basePath = realpath(__DIR__ . '/../_files/design'); + $pathPattern = implode(DIRECTORY_SEPARATOR, array('frontend', '*', '*', 'theme.xml')); + $this->_model->getMock()->register($basePath, $pathPattern); + return $this; + } + + /** + * Use this method only with database isolation + * + * @return Mage_Core_Model_Theme + */ + protected function _getTestTheme() + { + $theme = $this->_theme->getCollection()->getThemeByFullPath( + implode(Mage_Core_Model_Theme::PATH_SEPARATOR, array('frontend', 'test', 'test_theme')) + ); + $this->assertNotEmpty($theme->getId()); + return $theme; + } + + /** + * @magentoDbIsolation enabled + */ + public function testVirtualByVirtualRelation() + { + $this->registerThemes(); + $theme = $this->_getTestTheme(); + + $virtualTheme = clone $this->_theme; + $virtualTheme->setData($theme->getData())->setId(null); + $virtualTheme->setType(Mage_Core_Model_Theme::TYPE_VIRTUAL)->save(); + + $subVirtualTheme = clone $this->_theme; + $subVirtualTheme->setData($theme->getData())->setId(null); + $subVirtualTheme->setParentId($virtualTheme->getId())->setType(Mage_Core_Model_Theme::TYPE_VIRTUAL)->save(); + + $this->registerThemes(); + $parentId = $subVirtualTheme->getParentId(); + $subVirtualTheme->load($subVirtualTheme->getId()); + $this->assertNotEquals($parentId, $subVirtualTheme->getParentId()); + } + + /** + * @magentoDbIsolation enabled + */ + public function testPhysicalThemeElimination() + { + $this->registerThemes(); + $theme = $this->_getTestTheme(); + + $testTheme = clone $this->_theme; + $testTheme->setData($theme->getData())->setThemePath('empty')->setId(null); + $testTheme->setType(Mage_Core_Model_Theme::TYPE_PHYSICAL)->save(); + + $this->registerThemes(); + $testTheme->load($testTheme->getId()); + $this->assertNotEquals((int)$testTheme->getType(), Mage_Core_Model_Theme::TYPE_PHYSICAL); + } +} \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Theme/ServiceTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Theme/ServiceTest.php index 574e7478212aa..89972227fc165 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Theme/ServiceTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Theme/ServiceTest.php @@ -31,14 +31,13 @@ class Mage_Core_Model_Theme_ServiceTest extends PHPUnit_Framework_TestCase { /** - * @covers Mage_Core_Model_Theme_Service::getThemes + * @covers Mage_Core_Model_Theme_Service::getPhysicalThemes */ - public function testGetThemes() + public function testGetPhysicalThemesPerPage() { - Mage::getConfig(); /** @var $themeService Mage_Core_Model_Theme_Service */ $themeService = Mage::getObjectManager()->create('Mage_Core_Model_Theme_Service'); - $collection = $themeService->getThemes(1, Mage_Core_Model_Resource_Theme_Collection::DEFAULT_PAGE_SIZE); + $collection = $themeService->getPhysicalThemes(1, Mage_Core_Model_Resource_Theme_Collection::DEFAULT_PAGE_SIZE); $this->assertLessThanOrEqual( Mage_Core_Model_Resource_Theme_Collection::DEFAULT_PAGE_SIZE, $collection->count() @@ -46,11 +45,30 @@ public function testGetThemes() /** @var $theme Mage_Core_Model_Theme */ foreach ($collection as $theme) { - $this->assertEquals('frontend', $theme->getArea()); - $this->assertFalse($theme->isVirtual()); + $this->assertEquals(Mage_Core_Model_App_Area::AREA_FRONTEND, $theme->getArea()); + $this->assertEquals(Mage_Core_Model_Theme::TYPE_PHYSICAL, $theme->getType()); } } + /** + * @covers Mage_Core_Model_Theme_Service::getPhysicalThemes + */ + public function testGetPhysicalThemes() + { + /** @var $themeService Mage_Core_Model_Theme_Service */ + $themeService = Mage::getObjectManager()->create('Mage_Core_Model_Theme_Service'); + $collection = $themeService->getPhysicalThemes(); + + $this->assertGreaterThan(0, $collection->count()); + + /** @var $theme Mage_Core_Model_Theme */ + foreach ($collection as $theme) { + $this->assertEquals(Mage_Core_Model_App_Area::AREA_FRONTEND, $theme->getArea()); + $this->assertEquals(Mage_Core_Model_Theme::TYPE_PHYSICAL, $theme->getType()); + } + } + + /** * @magentoAppIsolation enabled * @magentoDbIsolation enabled @@ -63,7 +81,7 @@ public function testAssignThemeToStores() /** @var $themeService Mage_Core_Model_Theme_Service */ $themeService = Mage::getObjectManager()->create('Mage_Core_Model_Theme_Service'); /** @var $physicalTheme Mage_Core_Model_Theme_Service */ - $physicalTheme = $themeService->getThemes(1, 1)->fetchItem(); + $physicalTheme = $themeService->getPhysicalThemes(1, 1)->fetchItem(); $this->assertTrue((bool)$physicalTheme->getId(), 'Physical theme is not loaded'); $storeView = Mage::app()->getAnyStoreView()->getId(); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/ThemeTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/ThemeTest.php index d5e0080082322..fdd5a35456b1d 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/ThemeTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/ThemeTest.php @@ -93,81 +93,32 @@ public function _expectedThemeDataFromConfiguration() protected function _getThemeValidData() { return array( - 'theme_code' => 'space', 'area' => 'space_area', 'theme_title' => 'Space theme', 'theme_version' => '2.0.0.0', 'parent_id' => null, - 'parent_theme_path' => null, 'is_featured' => false, 'magento_version_from' => '2.0.0.0-dev1', 'magento_version_to' => '*', 'theme_path' => 'default/space', 'preview_image' => 'images/preview.png', + 'type' => Mage_Core_Model_Theme::TYPE_VIRTUAL ); } /** - * Test is virtual + * Test is theme present in file system * * @magentoAppIsolation enabled + * @covers Mage_Core_Model_Theme::isPresentInFilesystem */ - public function testIsVirtual() + public function testIsPresentInFilesystem() { /** @var $themeModel Mage_Core_Model_Theme */ $themeModel = Mage::getObjectManager()->create('Mage_Core_Model_Theme'); $themeModel->setData($this->_getThemeValidData()); - $this->assertTrue($themeModel->isVirtual()); - } - - /** - * Test id deletable - * - * @dataProvider isDeletableDataProvider - * @param bool $isVirtual - */ - public function testIsDeletable($isVirtual) - { - $themeModel = $this->getMock('Mage_Core_Model_Theme', array('isVirtual'), array(), '', false); - $themeModel->expects($this->once()) - ->method('isVirtual') - ->will($this->returnValue($isVirtual)); - $this->assertEquals($isVirtual, $themeModel->isDeletable()); - } - - /** - * @return array - */ - public function isDeletableDataProvider() - { - return array(array(true), array(false)); - } - - public function testIsThemeCompatible() - { - /** @var $themeModel Mage_Core_Model_Theme */ - $themeModel = Mage::getModel('Mage_Core_Model_Theme'); - - $themeModel->setMagentoVersionFrom('2.0.0.0')->setMagentoVersionTo('*'); - $this->assertFalse($themeModel->isThemeCompatible()); - - $themeModel->setMagentoVersionFrom('1.0.0.0')->setMagentoVersionTo('*'); - $this->assertTrue($themeModel->isThemeCompatible()); - } - - public function testCheckThemeCompatible() - { - /** @var $themeModel Mage_Core_Model_Theme */ - $themeModel = Mage::getModel('Mage_Core_Model_Theme'); - - $themeModel->setMagentoVersionFrom('2.0.0.0')->setMagentoVersionTo('*')->setThemeTitle('Title'); - $themeModel->checkThemeCompatible(); - $this->assertEquals('Title (incompatible version)', $themeModel->getThemeTitle()); - - $themeModel->setMagentoVersionFrom('1.0.0.0')->setMagentoVersionTo('*')->setThemeTitle('Title'); - $themeModel->checkThemeCompatible(); - $this->assertEquals('Title', $themeModel->getThemeTitle()); + $this->assertTrue(!$themeModel->isPresentInFilesystem()); } public function testGetLabelsCollection() @@ -175,9 +126,10 @@ public function testGetLabelsCollection() /** @var $themeModel Mage_Core_Model_Theme */ $themeModel = Mage::getModel('Mage_Core_Model_Theme'); - /** @var $expectedCollection Mage_Core_Model_Theme_Collection */ + /** @var $expectedCollection Mage_Core_Model_Resource_Theme_Collection */ $expectedCollection = Mage::getModel('Mage_Core_Model_Resource_Theme_Collection'); - $expectedCollection->addFilter('area', 'frontend'); + $expectedCollection->addAreaFilter(Mage_Core_Model_App_Area::AREA_FRONTEND) + ->filterVisibleThemes(); $expectedItemsCount = count($expectedCollection); @@ -196,7 +148,8 @@ public function testChildRelation() /** @var $theme Mage_Core_Model_Theme */ /** @var $currentTheme Mage_Core_Model_Theme */ $theme = Mage::getObjectManager()->get('Mage_Core_Model_Theme'); - foreach ($theme->getCollection() as $currentTheme) { + $collection = $theme->getCollection()->addTypeFilter(Mage_Core_Model_Theme::TYPE_VIRTUAL); + foreach ($collection as $currentTheme) { $parentTheme = $currentTheme->getParentTheme(); if (!empty($parentTheme)) { $this->assertTrue($parentTheme->hasChildThemes()); @@ -218,8 +171,8 @@ public function testJsCustomization($filesData, $expectedData) $themeModel = $theme->getCollection()->getFirstItem(); foreach ($filesData as $fileData) { - /** @var $filesModel Mage_Core_Model_Theme_Files */ - $filesModel = Mage::getObjectManager()->create('Mage_Core_Model_Theme_Files'); + /** @var $filesModel Mage_Core_Model_Theme_File */ + $filesModel = Mage::getObjectManager()->create('Mage_Core_Model_Theme_File'); $fileData['theme_id'] = $themeModel->getId(); $filesModel->setData($fileData) ->save(); @@ -229,7 +182,7 @@ public function testJsCustomization($filesData, $expectedData) $filesJs = Mage::getObjectManager()->create('Mage_Core_Model_Theme_Customization_Files_Js'); $themeFilesCollection = $themeModel->setCustomization($filesJs) ->getCustomizationData(Mage_Core_Model_Theme_Customization_Files_Js::TYPE); - $this->assertInstanceOf('Mage_Core_Model_Resource_Theme_Files_Collection', $themeFilesCollection); + $this->assertInstanceOf('Mage_Core_Model_Resource_Theme_File_Collection', $themeFilesCollection); $themeFiles = $themeFilesCollection->toArray(); foreach ($themeFiles['items'] as &$themeFile) { $this->assertEquals($themeModel->getId(), $themeFile['theme_id']); @@ -249,25 +202,25 @@ public function getJsCustomizationProvider() 'filesData' => array( array( 'file_path' => 'test_1.js', - 'file_type' => Mage_Core_Model_Theme_Files::TYPE_JS, + 'file_type' => Mage_Core_Model_Theme_File::TYPE_JS, 'content' => 'content 1', 'sort_order' => '1' ), array( 'file_path' => 'test_2.js', - 'file_type' => Mage_Core_Model_Theme_Files::TYPE_JS, + 'file_type' => Mage_Core_Model_Theme_File::TYPE_JS, 'content' => 'content 2', 'sort_order' => '3' ), array( 'file_path' => 'test_3.js', - 'file_type' => Mage_Core_Model_Theme_Files::TYPE_JS, + 'file_type' => Mage_Core_Model_Theme_File::TYPE_JS, 'content' => 'content 3', 'sort_order' => '2' ), array( 'file_path' => 'test_not_js.js', - 'file_type' => Mage_Core_Model_Theme_Files::TYPE_CSS, + 'file_type' => Mage_Core_Model_Theme_File::TYPE_CSS, 'content' => 'content css', 'sort_order' => '' ) @@ -275,21 +228,21 @@ public function getJsCustomizationProvider() 'expectedData' => array( array( 'file_path' => 'test_1.js', - 'file_type' => Mage_Core_Model_Theme_Files::TYPE_JS, + 'file_type' => Mage_Core_Model_Theme_File::TYPE_JS, 'content' => 'content 1', 'sort_order' => '1', 'is_temporary' => '0' ), array( 'file_path' => 'test_3.js', - 'file_type' => Mage_Core_Model_Theme_Files::TYPE_JS, + 'file_type' => Mage_Core_Model_Theme_File::TYPE_JS, 'content' => 'content 3', 'sort_order' => '2', 'is_temporary' => '0' ), array( 'file_path' => 'test_2.js', - 'file_type' => Mage_Core_Model_Theme_Files::TYPE_JS, + 'file_type' => Mage_Core_Model_Theme_File::TYPE_JS, 'content' => 'content 2', 'sort_order' => '3', 'is_temporary' => '0' diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Translate/ExprTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Translate/ExprTest.php index 3c7bfcae2277e..7c9650d59df9b 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Translate/ExprTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Translate/ExprTest.php @@ -43,11 +43,6 @@ public function setUp() ); } - protected function tearDown() - { - $this->_model = null; - } - public function testConstructor() { $this->assertEquals($this->_expectedText, $this->_model->getText()); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Translate/InlineTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Translate/InlineTest.php index b89f241b69811..724efcfdcc542 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Translate/InlineTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Translate/InlineTest.php @@ -47,11 +47,6 @@ public function setUp() Mage::app()->getStore($this->_storeId)->setConfig('dev/translate_inline/active', true); } - protected function tearDown() - { - $this->_model = null; - } - public function testIsAllowed() { $this->assertTrue($this->_model->isAllowed()); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Translate/StringTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Translate/StringTest.php index 1c656cbaa0a0e..f9773ef96bc34 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Translate/StringTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Translate/StringTest.php @@ -37,11 +37,6 @@ public function setUp() $this->_model = Mage::getModel('Mage_Core_Model_Translate_String'); } - protected function tearDown() - { - $this->_model = null; - } - public function testConstructor() { $this->assertInstanceOf('Mage_Core_Model_Resource_Translate_String', $this->_model->getResource()); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/TranslateTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/TranslateTest.php index 72898162dd3e3..8d5c8fd61e640 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/TranslateTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/TranslateTest.php @@ -51,6 +51,8 @@ public function setUp() array( Mage::getSingleton('Mage_Core_Model_Config_Modules_Reader'), Mage::getSingleton('Magento_Filesystem'), + Mage::getSingleton('Mage_Core_Model_Design_FileResolution_StrategyPool'), + new Mage_Core_Model_App_State(), ) ); $this->_designModel->expects($this->any()) @@ -59,15 +61,10 @@ public function setUp() Mage::getConfig()->setModuleDir('Mage_Core', 'locale', dirname(__FILE__) . '/_files/Mage/Core/locale'); Mage::getConfig()->setModuleDir('Mage_Catalog', 'locale', dirname(__FILE__) . '/_files/Mage/Catalog/locale'); - $this->_model = Mage::getModel('Mage_Core_Model_Translate', array($this->_designModel)); + $this->_model = Mage::getModel('Mage_Core_Model_Translate', array('designPackage' => $this->_designModel)); $this->_model->init('frontend'); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetModulesConfig() { /** @var $modulesConfig Mage_Core_Model_Config_Element */ @@ -83,7 +80,7 @@ public function testGetModulesConfig() ' Mage_Core.csv - ../../../../../../../dev/tests/integration/testsuite/Mage/Core/_files/fixture.csv + ../../../../../../dev/tests/integration/testsuite/Mage/Core/_files/fixture.csv ', $modulesConfig->$checkedNode->asXML() @@ -148,7 +145,12 @@ public function testTranslate($inputText, $expectedTranslation) $filesystem = new Magento_Filesystem(new Magento_Filesystem_Adapter_Local); $this->_designModel = $this->getMock('Mage_Core_Model_Design_Package', array('getLocaleFileName', 'getDesignTheme'), - array(Mage::getSingleton('Mage_Core_Model_Config_Modules_Reader'), $filesystem) + array( + Mage::getSingleton('Mage_Core_Model_Config_Modules_Reader'), + $filesystem, + Mage::getSingleton('Mage_Core_Model_Design_FileResolution_StrategyPool'), + new Mage_Core_Model_App_State(), + ) ); $this->_designModel->expects($this->any()) ->method('getLocaleFileName') @@ -160,7 +162,7 @@ public function testTranslate($inputText, $expectedTranslation) Mage::getConfig()->setModuleDir('Mage_Core', 'locale', dirname(__FILE__) . '/_files/Mage/Core/locale'); Mage::getConfig()->setModuleDir('Mage_Catalog', 'locale', dirname(__FILE__) . '/_files/Mage/Catalog/locale'); - $this->_model = Mage::getModel('Mage_Core_Model_Translate', array($this->_designModel)); + $this->_model = Mage::getModel('Mage_Core_Model_Translate', array('designPackage' => $this->_designModel)); $this->_model->init('frontend'); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Url/RewriteTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Url/RewriteTest.php index 973f677a6fa5f..93c0732dee1c0 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Url/RewriteTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Url/RewriteTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Core_Model_Url_Rewrite'); } - protected function tearDown() - { - $this->_model = null; - } - public function testLoadByRequestPath() { $this->_model->setStoreId(Mage::app()->getDefaultStoreView()->getId()) diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/UrlTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/UrlTest.php index 9de2a0cbc272f..476a78640fb01 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/UrlTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/UrlTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Core_Model_Url'); } - protected function tearDown() - { - $this->_model = null; - } - public function testParseUrl() { $url = 'http://user:password@www.example.com:80/manual/3.5/?one=1&two=2#skeleton-generator.test'; @@ -165,6 +160,32 @@ public function testGetBaseUrlConfigured($params, $expectedUrl) $this->assertEquals($expectedUrl, $actualUrl); } + /** + * Check that url type is restored to default after call getBaseUrl with type specified in params + */ + public function testGetBaseUrlWithTypeRestoring() + { + /** + * Get base ull with default type + */ + $this->assertEquals('http://localhost/index.php/', $this->_model->getBaseUrl(), 'Incorrect link url'); + + /** + * Set specified type + */ + $this->_model->setType(Mage_Core_Model_Store::URL_TYPE_WEB); + $webUrl = $this->_model->getBaseUrl(); + $this->assertEquals('http://localhost/', $webUrl, 'Incorrect web url'); + $this->assertEquals('http://localhost/index.php/', $this->_model->getBaseUrl(), 'Incorrect link url'); + + /** + * Get url with type specified in params + */ + $mediaUrl = $this->_model->getBaseUrl(array('_type' => Mage_Core_Model_Store::URL_TYPE_MEDIA)); + $this->assertEquals('http://localhost/pub/media/', $mediaUrl, 'Incorrect media url'); + $this->assertEquals('http://localhost/index.php/', $this->_model->getBaseUrl(), 'Incorrect link url'); + } + public function getBaseUrlConfiguredDataProvider() { return array( diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/Variable/ConfigTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/Variable/ConfigTest.php index 54dc4513e56d9..2603abcc81db2 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/Variable/ConfigTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/Variable/ConfigTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Core_Model_Variable_Config'); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetWysiwygJsPluginSrc() { $src = $this->_model->getWysiwygJsPluginSrc(); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/VariableTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/VariableTest.php index 3ad9bab7be85a..4855528c0944d 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/VariableTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/VariableTest.php @@ -37,11 +37,6 @@ public function setUp() $this->_model = Mage::getModel('Mage_Core_Model_Variable'); } - public function tearDown() - { - $this->_model = null; - } - public function testGetSetStoreId() { $this->_model->setStoreId(1); diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/WebsiteTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/WebsiteTest.php index 03b3e4742f8b8..9c5fecd2ab796 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/WebsiteTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/WebsiteTest.php @@ -38,11 +38,6 @@ public function setUp() $this->_model->load(1); } - protected function tearDown() - { - $this->_model = null; - } - public function testLoad() { /* Test loading by id */ diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/_files/design/frontend/test/default/Module/favicon.ico b/dev/tests/integration/testsuite/Mage/Core/Model/_files/design/frontend/test/default/Namespace_Module/favicon.ico similarity index 100% rename from dev/tests/integration/testsuite/Mage/Core/Model/_files/design/frontend/test/default/Module/favicon.ico rename to dev/tests/integration/testsuite/Mage/Core/Model/_files/design/frontend/test/default/Namespace_Module/favicon.ico diff --git a/dev/tests/integration/testsuite/Mage/Core/Utility/Layout.php b/dev/tests/integration/testsuite/Mage/Core/Utility/Layout.php index 22af5c68a1e11..63e536db481c6 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Utility/Layout.php +++ b/dev/tests/integration/testsuite/Mage/Core/Utility/Layout.php @@ -87,13 +87,16 @@ public function getLayoutFromFixture($layoutUpdatesFile, array $args = array()) public function getLayoutDependencies() { return array( - 'blockFactory' => Mage::getObjectManager()->create('Mage_Core_Model_BlockFactory', array(), false), - 'structure' => Mage::getObjectManager()->create('Magento_Data_Structure', array(), false), + 'blockFactory' => Mage::getObjectManager()->create('Mage_Core_Model_BlockFactory', array()), + 'structure' => Mage::getObjectManager()->create('Magento_Data_Structure', array()), 'argumentProcessor' => Mage::getObjectManager()->create('Mage_Core_Model_Layout_Argument_Processor', - array(), false + array() ), - 'translator' => Mage::getObjectManager()->create('Mage_Core_Model_Layout_Translator', array(), false), + 'translator' => Mage::getObjectManager()->create('Mage_Core_Model_Layout_Translator', array()), 'scheduledStructure' => Mage::getObjectManager()->create('Mage_Core_Model_Layout_ScheduledStructure', + array() + ), + 'dataSourceFactory' => Mage::getObjectManager()->create('Magento_Datasource_Factory', array(), false ) ); diff --git a/dev/tests/integration/testsuite/Mage/Core/Utility/LayoutTest.php b/dev/tests/integration/testsuite/Mage/Core/Utility/LayoutTest.php index 9698e9381b27a..a99536a015342 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Utility/LayoutTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Utility/LayoutTest.php @@ -42,11 +42,6 @@ protected function setUp() $this->_utility = new Mage_Core_Utility_Layout($this); } - protected function tearDown() - { - $this->_utility = null; - } - /** * Assert that the actual layout update instance represents the expected layout update file * diff --git a/dev/tests/integration/testsuite/Mage/Core/_files/fixture.csv b/dev/tests/integration/testsuite/Mage/Core/_files/fixture.csv index 35cf9a868f156..297c90f5e6ec9 100644 --- a/dev/tests/integration/testsuite/Mage/Core/_files/fixture.csv +++ b/dev/tests/integration/testsuite/Mage/Core/_files/fixture.csv @@ -1,2 +1,3 @@ "Search:","Fixture search:" "Search entire store here...","Fixture search entire store here..." +"Fixture string","Fixture translation" diff --git a/dev/tests/integration/testsuite/Mage/Core/_files/layout_update.php b/dev/tests/integration/testsuite/Mage/Core/_files/layout_update.php index 12afe9838e624..4312ae5b7bc09 100644 --- a/dev/tests/integration/testsuite/Mage/Core/_files/layout_update.php +++ b/dev/tests/integration/testsuite/Mage/Core/_files/layout_update.php @@ -36,6 +36,7 @@ ->setThemeTitle('Test Theme') ->setMagentoVersionFrom('2.0.0.0') ->setMagentoVersionTo('*') + ->setType(Mage_Core_Model_Theme::TYPE_VIRTUAL) ->save(); /** @var $updateNotTemporary Mage_Core_Model_Layout_Update */ diff --git a/dev/tests/integration/testsuite/Mage/Core/_files/media_for_change.php b/dev/tests/integration/testsuite/Mage/Core/_files/media_for_change.php index 6be003d01b986..dd1c2fc9d2571 100644 --- a/dev/tests/integration/testsuite/Mage/Core/_files/media_for_change.php +++ b/dev/tests/integration/testsuite/Mage/Core/_files/media_for_change.php @@ -26,7 +26,7 @@ */ Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_ADMINHTML, Mage_Core_Model_App_Area::PART_CONFIG); $designDir = Magento_Test_Helper_Bootstrap::getInstance()->getAppInstallDir() . '/media_for_change'; -$themeDir = $designDir . DIRECTORY_SEPARATOR . '/frontend/test/default'; +$themeDir = $designDir . DIRECTORY_SEPARATOR . 'frontend/test/default'; $sourcePath = dirname(__DIR__) . '/Model/_files/design/frontend/test/publication/'; mkdir($themeDir . '/images', 0777, true); diff --git a/dev/tests/integration/testsuite/Mage/Cron/Model/ObserverTest.php b/dev/tests/integration/testsuite/Mage/Cron/Model/ObserverTest.php index 219c7d58d8b62..402d8ab4171d8 100644 --- a/dev/tests/integration/testsuite/Mage/Cron/Model/ObserverTest.php +++ b/dev/tests/integration/testsuite/Mage/Cron/Model/ObserverTest.php @@ -38,11 +38,6 @@ public function setUp() $this->_model->dispatch('this argument is not used'); } - protected function tearDown() - { - $this->_model = null; - } - public function testDispatchScheduled() { $collection = Mage::getResourceModel('Mage_Cron_Model_Resource_Schedule_Collection'); diff --git a/dev/tests/integration/testsuite/Mage/Customer/Block/Account/Dashboard/InfoTest.php b/dev/tests/integration/testsuite/Mage/Customer/Block/Account/Dashboard/InfoTest.php index fb525c4ca1443..8c7cdc308c579 100644 --- a/dev/tests/integration/testsuite/Mage/Customer/Block/Account/Dashboard/InfoTest.php +++ b/dev/tests/integration/testsuite/Mage/Customer/Block/Account/Dashboard/InfoTest.php @@ -37,11 +37,6 @@ public function setUp() $this->_block = Mage::app()->getLayout()->createBlock('Mage_Customer_Block_Account_Dashboard_Info'); } - public function tearDown() - { - $this->_block = null; - } - public function testGetSubscriptionObject() { $object = $this->_block->getSubscriptionObject(); diff --git a/dev/tests/integration/testsuite/Mage/Customer/Block/Account/LinkTest.php b/dev/tests/integration/testsuite/Mage/Customer/Block/Account/LinkTest.php index 0a657fa1c0619..1438ef77e7ed8 100644 --- a/dev/tests/integration/testsuite/Mage/Customer/Block/Account/LinkTest.php +++ b/dev/tests/integration/testsuite/Mage/Customer/Block/Account/LinkTest.php @@ -47,12 +47,6 @@ public function setUp() $this->_links = $layout->getBlock('links'); } - protected function tearDown() - { - $this->_block = null; - $this->_links = null; - } - public function testAddAccountLink() { $this->assertEmpty($this->_links->getLinks()); diff --git a/dev/tests/integration/testsuite/Mage/Customer/Block/Widget/GenderTest.php b/dev/tests/integration/testsuite/Mage/Customer/Block/Widget/GenderTest.php index 92317a3085a42..77f45315cb5a4 100644 --- a/dev/tests/integration/testsuite/Mage/Customer/Block/Widget/GenderTest.php +++ b/dev/tests/integration/testsuite/Mage/Customer/Block/Widget/GenderTest.php @@ -37,11 +37,6 @@ public function setUp() $this->_block = Mage::app()->getLayout()->createBlock('Mage_Customer_Block_Widget_Gender'); } - public function tearDown() - { - $this->_block = null; - } - public function testGetGenderOptions() { $options = $this->_block->getGenderOptions(); diff --git a/dev/tests/integration/testsuite/Mage/Customer/Model/Address/ConfigTest.php b/dev/tests/integration/testsuite/Mage/Customer/Model/Address/ConfigTest.php index 689b3128a58c0..9541b49ea1dff 100644 --- a/dev/tests/integration/testsuite/Mage/Customer/Model/Address/ConfigTest.php +++ b/dev/tests/integration/testsuite/Mage/Customer/Model/Address/ConfigTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_model= Mage::getModel('Mage_Customer_Model_Address_Config'); } - protected function tearDown() - { - $this->_model = null; - } - /** * @magentoAppIsolation enabled * @magentoDataFixture Mage/Customer/_files/address_formats.php diff --git a/dev/tests/integration/testsuite/Mage/Customer/Model/FormTest.php b/dev/tests/integration/testsuite/Mage/Customer/Model/FormTest.php index ad4ab67e42504..265bd9882ed11 100644 --- a/dev/tests/integration/testsuite/Mage/Customer/Model/FormTest.php +++ b/dev/tests/integration/testsuite/Mage/Customer/Model/FormTest.php @@ -38,11 +38,6 @@ protected function setUp() $this->_model->setFormCode('customer_account_create'); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetAttributes() { $attributes = $this->_model->getAttributes(); diff --git a/dev/tests/integration/testsuite/Mage/Customer/Model/GroupTest.php b/dev/tests/integration/testsuite/Mage/Customer/Model/GroupTest.php index 47bab6d44fb62..dbc1cca574b7b 100644 --- a/dev/tests/integration/testsuite/Mage/Customer/Model/GroupTest.php +++ b/dev/tests/integration/testsuite/Mage/Customer/Model/GroupTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_model= Mage::getModel('Mage_Customer_Model_Group'); } - protected function tearDown() - { - $this->_model = null; - } - public function testCRUD() { $this->_model->setCustomerGroupCode('test'); diff --git a/dev/tests/integration/testsuite/Mage/DesignEditor/Model/Config/QuickStylesTest.php b/dev/tests/integration/testsuite/Mage/DesignEditor/Model/Config/QuickStylesTest.php new file mode 100644 index 0000000000000..24e296b196c9b --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/DesignEditor/Model/Config/QuickStylesTest.php @@ -0,0 +1,121 @@ +_design = Mage::getObjectManager()->get('Mage_Core_Model_Design_Package'); + $this->_design->setDesignTheme('package/test', Mage_Core_Model_Design_Package::DEFAULT_AREA); + $quickStylesPath = $this->_design->getFilename('Mage_DesignEditor::controls/quick_styles.xml'); + $this->assertFileExists($quickStylesPath); + $this->_model = Mage::getObjectManager()->create('Mage_DesignEditor_Model_Config_Control_QuickStyles', + array('configFiles' => array($quickStylesPath))); + } + + /** + * Test control data + * + * @magentoDataFixture Mage/DesignEditor/Model/_files/design/themes.php + * @dataProvider getTestDataProvider + * @magentoAppIsolation enabled + * @param string $controlName + * @param array $expectedControlData + */ + public function testLoadConfiguration($controlName, $expectedControlData) + { + $this->assertEquals($expectedControlData, $this->_model->getControlData($controlName)); + } + + /** + * Data provider with sample data for test controls + * + * @return array + */ + public function getTestDataProvider() + { + return array( + array('headers', array( + 'type' => 'logo', + 'layoutParams' => array('title' => 'Headers', 'column' => 'left'), + 'components' => array ( + 'logo-picker' => array ( + 'type' => 'color-picker', + 'selector' => '.body .div', + 'attribute' => 'background-color', + 'var' => 'Mage_DesignEditor::test_var_key1', + ), + 'font-selector' => array ( + 'type' => 'font-selector', + 'selector' => '*', + 'attribute' => 'font-family', + 'options' => array('Arial, Verdana, Georgia', 'Tahoma'), + 'var' => 'Mage_DesignEditor::test_var_key2', + ), + 'test-control' => array ( + 'type' => 'test-control', + 'components' => array ( + 'image-uploader' => array ( + 'type' => 'logo-uploader', + 'selector' => '.test-logo-1', + 'attribute' => 'background-image', + 'var' => 'Mage_DesignEditor::test_var_key3', + ) + ) + ) + ) + )), + array('logo-uploader', array( + 'type' => 'logo-uploader', + 'selector' => '.test-logo-2', + 'attribute' => 'background-image', + 'layoutParams' => array('title' => 'Logo Uploader', 'column' => 'center'), + 'var' => 'Mage_DesignEditor::test_var_key4', + )), + array('background-color-picker', array( + 'type' => 'color-picker', + 'layoutParams' => array('title' => 'Background Color', 'column' => 'right'), + 'selector' => '.body .div', + 'attribute' => 'background-color', + 'var' => 'Mage_DesignEditor::test_var_key5', + )), + ); + } +} diff --git a/dev/tests/integration/testsuite/Mage/DesignEditor/Model/Editor/Tools/Controls/ConfigurationTest.php b/dev/tests/integration/testsuite/Mage/DesignEditor/Model/Editor/Tools/Controls/ConfigurationTest.php new file mode 100644 index 0000000000000..1179776c5127d --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/DesignEditor/Model/Editor/Tools/Controls/ConfigurationTest.php @@ -0,0 +1,169 @@ +_design = Mage::getObjectManager()->get('Mage_Core_Model_Design_Package'); + $this->_design->setDesignTheme('package/test_child', Mage_Core_Model_Design_Package::DEFAULT_AREA); + $this->_configFactory = Mage::getObjectManager()->create( + 'Mage_DesignEditor_Model_Editor_Tools_Controls_Factory' + ); + } + + /** + * Test control data + * + * @magentoDataFixture Mage/DesignEditor/Model/_files/design/themes.php + * @dataProvider getConfigurationTypes + * @magentoAppIsolation enabled + */ + public function testLoadConfigurations($type, $controlName, $controlData) + { + $configuration = $this->_configFactory->create($type, Mage::getDesign()->getDesignTheme()); + $this->assertEquals($controlData, $configuration->getControlData($controlName)); + } + + /** + * Data provider with sample data for test controls + * + * @return array + */ + public function getConfigurationTypes() + { + return array( + array(Mage_DesignEditor_Model_Editor_Tools_Controls_Factory::TYPE_QUICK_STYLES, 'logo-uploader', array( + 'type' => 'logo-uploader', + 'layoutParams' => array('title' => 'Logo Uploader', 'column' => 'center'), + 'attribute' => 'background-image', + 'selector' => '.test-logo-2', + 'var' => 'Mage_DesignEditor::test_var_key4', + 'value' => 'test_child_value4', + 'default' => 'test_value4' + )), + array(Mage_DesignEditor_Model_Editor_Tools_Controls_Factory::TYPE_QUICK_STYLES, 'background-color-picker', + array( + 'type' => 'color-picker', + 'layoutParams' => array('title' => 'Background Color', 'column' => 'right'), + 'selector' => '.body .div', + 'attribute' => 'background-color', + 'var' => 'Mage_DesignEditor::test_var_key5', + 'value' => 'test_child_value5', + 'default' => 'test_value5' + ) + ), + array(Mage_DesignEditor_Model_Editor_Tools_Controls_Factory::TYPE_IMAGE_SIZING, 'product-list', array( + 'type' => 'image-sizing', + 'layoutParams' => array('title' => 'Up Sell Product List'), + 'components' => array( + 'image-type' => array( + 'type' => 'image-type', + 'var' => 'Mage_DesignEditor::test_var_key1', + 'value' => 'test_child_value1', + 'default' => 'test_value1' + ), + 'image-height' => array( + 'type' => 'image-height', + 'var' => 'Mage_DesignEditor::test_var_key2', + 'value' => 'test_child_value2', + 'default' => 'test_value2' + ), + 'image-width' => array( + 'type' => 'image-width', + 'var' => 'Mage_DesignEditor::test_var_key3', + 'value' => 'test_child_value3', + 'default' => 'test_value3' + ), + ) + )) + ); + } + + /** + * Test control data + * + * @magentoDataFixture Mage/DesignEditor/Model/_files/design/themes.php + * @dataProvider getSaveDataProvider + * @magentoAppIsolation enabled + */ + public function testSaveConfiguration($saveData, $xpathData) + { + $type = Mage_DesignEditor_Model_Editor_Tools_Controls_Factory::TYPE_QUICK_STYLES; + $theme = Mage::getDesign()->getDesignTheme(); + $configuration = $this->_configFactory->create($type, $theme); + $configuration->saveData($saveData); + $this->assertFileExists($theme->getCustomViewConfigPath()); + + $actual = new DOMDocument(); + $actual->load($theme->getCustomViewConfigPath()); + $domXpath = new DOMXPath($actual); + foreach ($xpathData as $xpath => $isEmpty) { + if ($isEmpty) { + $this->assertEmpty($domXpath->query($xpath)->item(0)); + } else { + $this->assertNotEmpty($domXpath->query($xpath)->item(0)); + } + } + } + + /** + * Data provider for testing save functionality + * + * @return array + */ + public function getSaveDataProvider() + { + return array( + array( + array( + 'background-color-picker' => 'test_saved_value1', + 'logo-uploader' => 'test_saved_value2', + 'image-uploader-empty' => 'test_saved_value_empty', + ), + array( + '//var[text() = "test_saved_value1"]' => false, + '//var[text() = "test_saved_value2"]' => false, + '//var[text() = "test_saved_value_empty"]' => true, + ) + ) + ); + } +} diff --git a/dev/tests/integration/testsuite/Mage/DesignEditor/Model/ObserverTest.php b/dev/tests/integration/testsuite/Mage/DesignEditor/Model/ObserverTest.php new file mode 100644 index 0000000000000..e1b9fec96f677 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/DesignEditor/Model/ObserverTest.php @@ -0,0 +1,98 @@ +getLayout(); + /** @var $headBlock Mage_Page_Block_Html_Head */ + $headBlock = $layout->createBlock('Mage_Page_Block_Html_Head', 'head'); + $headBlock->setData('vde_design_mode', $designMode); + + $objectManager = Mage::getObjectManager(); + + /** @var $page Mage_Core_Model_Page */ + $page = $objectManager->get('Mage_Core_Model_Page'); + + /** @var $pageAssets Mage_Page_Model_Asset_GroupedCollection */ + $pageAssets = $page->getAssets(); + + $fixtureAssets = array( + array('name' => 'test_css', 'type' => Mage_Core_Model_Design_Package::CONTENT_TYPE_CSS, + 'params' => array()), + array('name' => 'test_css_vde', 'type' => Mage_Core_Model_Design_Package::CONTENT_TYPE_CSS, + 'params' => array('flag_name' => 'vde_design_mode')), + array('name' => 'test_js', 'type' => Mage_Core_Model_Design_Package::CONTENT_TYPE_JS, + 'params' => array()), + array('name' => 'test_js_vde', 'type' => Mage_Core_Model_Design_Package::CONTENT_TYPE_JS, + 'params' => array('flag_name' => 'vde_design_mode')), + ); + + foreach ($fixtureAssets as $asset) { + $pageAssets->add( + $asset['name'], + $objectManager->create('Mage_Core_Model_Page_Asset_ViewFile', array( + 'file' => 'some_file', + 'contentType' => $asset['type'], + )), + $asset['params'] + ); + } + + /** @var $eventManager Mage_Core_Model_Event_Manager */ + $eventManager = $objectManager->get('Mage_Core_Model_Event_Manager')->addEventArea($area); + $eventManager->dispatch('controller_action_layout_generate_blocks_after', array('layout' => $layout)); + + $actualAssets = array_keys($pageAssets->getAll()); + $this->assertEquals($expectedAssets, $actualAssets); + } + + /** + * @return array + */ + public function cleanJsDataProvider() + { + return array( + 'vde area - design mode' => array('vde', '1', array('test_css', 'test_css_vde', 'test_js_vde')), + 'vde area - non design mode' => array('vde', '0', + array('test_css', 'test_css_vde', 'test_js', 'test_js_vde')), + 'default area - design mode' => array('default', '1', + array('test_css', 'test_css_vde', 'test_js', 'test_js_vde')), + 'default area - non design mode' => array('default', '0', + array('test_css', 'test_css_vde', 'test_js', 'test_js_vde')), + ); + } +} diff --git a/dev/tests/integration/testsuite/Mage/DesignEditor/Model/_files/design/frontend/package/test/Mage_DesignEditor/controls/image_sizing.xml b/dev/tests/integration/testsuite/Mage/DesignEditor/Model/_files/design/frontend/package/test/Mage_DesignEditor/controls/image_sizing.xml new file mode 100644 index 0000000000000..2f43208e9ea86 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/DesignEditor/Model/_files/design/frontend/package/test/Mage_DesignEditor/controls/image_sizing.xml @@ -0,0 +1,48 @@ + + + + + + image-sizing + + + image-type + Mage_DesignEditor::test_var_key1 + + + image-height + Mage_DesignEditor::test_var_key2 + + + image-width + Mage_DesignEditor::test_var_key3 + + + + diff --git a/dev/tests/integration/testsuite/Mage/DesignEditor/Model/_files/design/frontend/package/test/Mage_DesignEditor/controls/quick_styles.xml b/dev/tests/integration/testsuite/Mage/DesignEditor/Model/_files/design/frontend/package/test/Mage_DesignEditor/controls/quick_styles.xml new file mode 100644 index 0000000000000..658712fb5f859 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/DesignEditor/Model/_files/design/frontend/package/test/Mage_DesignEditor/controls/quick_styles.xml @@ -0,0 +1,81 @@ + + + + + + logo + + + + color-picker + + background-color + Mage_DesignEditor::test_var_key1 + + + + font-selector + + font-family + + + + + Mage_DesignEditor::test_var_key2 + + + + test-control + + + + logo-uploader + .test-logo-1 + background-image + Mage_DesignEditor::test_var_key3 + + + + + + + + logo-uploader + .test-logo-2 + background-image + Mage_DesignEditor::test_var_key4 + + + + color-picker + + background-color + Mage_DesignEditor::test_var_key5 + + diff --git a/dev/tests/integration/testsuite/Mage/DesignEditor/Model/_files/design/frontend/package/test/theme.xml b/dev/tests/integration/testsuite/Mage/DesignEditor/Model/_files/design/frontend/package/test/theme.xml new file mode 100644 index 0000000000000..afa894ef4485e --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/DesignEditor/Model/_files/design/frontend/package/test/theme.xml @@ -0,0 +1,38 @@ + + + + Default + + Default + + + + + + diff --git a/dev/tests/integration/testsuite/Mage/DesignEditor/Model/_files/design/frontend/package/test/view.xml b/dev/tests/integration/testsuite/Mage/DesignEditor/Model/_files/design/frontend/package/test/view.xml new file mode 100644 index 0000000000000..30575d856e1a6 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/DesignEditor/Model/_files/design/frontend/package/test/view.xml @@ -0,0 +1,36 @@ + + + + + test_value1 + test_value2 + test_value3 + test_value4 + test_value5 + + diff --git a/dev/tests/integration/testsuite/Mage/DesignEditor/Model/_files/design/frontend/package/test_child/theme.xml b/dev/tests/integration/testsuite/Mage/DesignEditor/Model/_files/design/frontend/package/test_child/theme.xml new file mode 100644 index 0000000000000..d4d550a5363d1 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/DesignEditor/Model/_files/design/frontend/package/test_child/theme.xml @@ -0,0 +1,38 @@ + + + + Default + + Default Child + + + + + + diff --git a/dev/tests/integration/testsuite/Mage/DesignEditor/Model/_files/design/frontend/package/test_child/view.xml b/dev/tests/integration/testsuite/Mage/DesignEditor/Model/_files/design/frontend/package/test_child/view.xml new file mode 100644 index 0000000000000..20a476ad68ede --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/DesignEditor/Model/_files/design/frontend/package/test_child/view.xml @@ -0,0 +1,36 @@ + + + + + test_child_value1 + test_child_value2 + test_child_value3 + test_child_value4 + test_child_value5 + + diff --git a/dev/tests/integration/testsuite/Mage/DesignEditor/Model/_files/design/themes.php b/dev/tests/integration/testsuite/Mage/DesignEditor/Model/_files/design/themes.php new file mode 100644 index 0000000000000..c4cebb92fb1f4 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/DesignEditor/Model/_files/design/themes.php @@ -0,0 +1,42 @@ +reinitialize(array( + Mage::PARAM_APP_DIRS => array( + Mage_Core_Model_Dir::THEMES => dirname(__DIR__) . '/design' + ) +)); + +Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_ADMINHTML, Mage_Core_Model_App_Area::PART_CONFIG); + +/** @var $registration Mage_Core_Model_Theme_Registration */ +$registration = Mage::getModel('Mage_Core_Model_Theme_Registration'); +$registration->register( + __DIR__, + implode(DIRECTORY_SEPARATOR, array('*', '*', '*', 'theme.xml')) +); + diff --git a/dev/tests/integration/testsuite/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorControllerTest.php b/dev/tests/integration/testsuite/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorControllerTest.php index 7058c320db8a1..13aa22f92c13a 100644 --- a/dev/tests/integration/testsuite/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorControllerTest.php +++ b/dev/tests/integration/testsuite/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorControllerTest.php @@ -88,9 +88,13 @@ public function testIndexAction() public function testLaunchActionSingleStoreWrongThemeId() { - $this->getRequest()->setParam('theme_id', 999); + $wrongThemeId = 999; + $this->getRequest()->setParam('theme_id', $wrongThemeId); $this->dispatch('backend/admin/system_design_editor/launch'); - $this->assertSessionMessages($this->equalTo(array('The theme was not found.')), Mage_Core_Model_Message::ERROR); + $this->assertSessionMessages($this->equalTo( + array('Theme "' . $wrongThemeId . '" was not found.')), + Mage_Core_Model_Message::ERROR + ); $expected = 'http://localhost/index.php/backend/admin/system_design_editor/index/'; $this->assertRedirect($this->stringStartsWith($expected)); } diff --git a/dev/tests/integration/testsuite/Mage/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractTest.php b/dev/tests/integration/testsuite/Mage/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractTest.php index 477d27ce120df..387e61fa3a1f6 100644 --- a/dev/tests/integration/testsuite/Mage/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractTest.php +++ b/dev/tests/integration/testsuite/Mage/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractTest.php @@ -42,24 +42,11 @@ public function testPrepareForm() $model->setEntityTypeId($entityType->getId()); Mage::register('entity_attribute', $model); - $arguments = array( - Mage::getObjectManager()->get('Mage_Core_Controller_Request_Http'), - Mage::getObjectManager()->get('Mage_Core_Model_Layout'), - Mage::getObjectManager()->get('Mage_Core_Model_Event_Manager'), - Mage::getObjectManager()->get('Mage_Backend_Model_Url'), - Mage::getObjectManager()->get('Mage_Core_Model_Translate'), - Mage::getObjectManager()->get('Mage_Core_Model_Cache'), - Mage::getObjectManager()->get('Mage_Core_Model_Design_Package'), - Mage::getObjectManager()->get('Mage_Core_Model_Session'), - Mage::getObjectManager()->get('Mage_Core_Model_Store_Config'), - Mage::getObjectManager()->get('Mage_Core_Controller_Varien_Front'), - Mage::getObjectManager()->get('Mage_Core_Model_Factory_Helper'), - Mage::getObjectManager()->get('Mage_Core_Model_Dir'), - Mage::getObjectManager()->get('Mage_Core_Model_Logger'), - Mage::getObjectManager()->get('Magento_Filesystem'), - ); - $block = $this->getMockForAbstractClass('Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract', $arguments) - ->setLayout(Mage::getObjectManager()->create('Mage_Core_Model_Layout')); + $block = $this->getMockForAbstractClass( + 'Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract', + array(Mage::getSingleton('Mage_Core_Block_Template_Context')) + ) + ->setLayout(Mage::getObjectManager()->create('Mage_Core_Model_Layout')); $method = new ReflectionMethod( 'Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract', '_prepareForm'); diff --git a/dev/tests/integration/testsuite/Mage/Eav/Model/Resource/Entity/Attribute/CollectionTest.php b/dev/tests/integration/testsuite/Mage/Eav/Model/Resource/Entity/Attribute/CollectionTest.php index f5ec8ebf4c903..91b0ea147aa38 100644 --- a/dev/tests/integration/testsuite/Mage/Eav/Model/Resource/Entity/Attribute/CollectionTest.php +++ b/dev/tests/integration/testsuite/Mage/Eav/Model/Resource/Entity/Attribute/CollectionTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_model = Mage::getResourceModel('Mage_Eav_Model_Resource_Entity_Attribute_Collection'); } - protected function tearDown() - { - $this->_model = null; - } - /** * Returns array of set ids, present in collection attributes * diff --git a/dev/tests/integration/testsuite/Mage/GiftMessage/Block/Message/InlineTest.php b/dev/tests/integration/testsuite/Mage/GiftMessage/Block/Message/InlineTest.php index cb3aca13e3436..436603976cd5d 100644 --- a/dev/tests/integration/testsuite/Mage/GiftMessage/Block/Message/InlineTest.php +++ b/dev/tests/integration/testsuite/Mage/GiftMessage/Block/Message/InlineTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_block = Mage::app()->getLayout()->createBlock('Mage_GiftMessage_Block_Message_Inline'); } - protected function tearDown() - { - $this->_block = null; - } - /** * @magentoDataFixture Mage/Catalog/_files/product_with_image.php * @magentoDataFixture Mage/Core/_files/frontend_default_theme.php diff --git a/dev/tests/integration/testsuite/Mage/GoogleShopping/Block/Adminhtml/Items/ProductTest.php b/dev/tests/integration/testsuite/Mage/GoogleShopping/Block/Adminhtml/Items/ProductTest.php index 32e615d64a859..5c7850a1ef0e6 100644 --- a/dev/tests/integration/testsuite/Mage/GoogleShopping/Block/Adminhtml/Items/ProductTest.php +++ b/dev/tests/integration/testsuite/Mage/GoogleShopping/Block/Adminhtml/Items/ProductTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_GoogleShopping_Block_Adminhtml_Items_ProductTest extends PHPUnit_Framework_TestCase +class Mage_GoogleShopping_Block_Adminhtml_Items_ProductTest extends Mage_Backend_Area_TestCase { public function testBeforeToHtml() { diff --git a/dev/tests/integration/testsuite/Mage/ImportExport/Block/Adminhtml/Export/Edit/FormTest.php b/dev/tests/integration/testsuite/Mage/ImportExport/Block/Adminhtml/Export/Edit/FormTest.php index 082a888debf23..c0d6ff1f8d2e1 100644 --- a/dev/tests/integration/testsuite/Mage/ImportExport/Block/Adminhtml/Export/Edit/FormTest.php +++ b/dev/tests/integration/testsuite/Mage/ImportExport/Block/Adminhtml/Export/Edit/FormTest.php @@ -28,7 +28,7 @@ /** * Test class for block Mage_ImportExport_Block_Adminhtml_Export_Edit_Form */ -class Mage_ImportExport_Block_Adminhtml_Export_Edit_FormTest extends PHPUnit_Framework_TestCase +class Mage_ImportExport_Block_Adminhtml_Export_Edit_FormTest extends Mage_Backend_Area_TestCase { /** * Testing model @@ -58,14 +58,10 @@ class Mage_ImportExport_Block_Adminhtml_Export_Edit_FormTest extends PHPUnit_Fra public function setUp() { + parent::setUp(); $this->_model = Mage::app()->getLayout()->createBlock('Mage_ImportExport_Block_Adminhtml_Export_Edit_Form'); } - public function tearDown() - { - unset($this->_model); - } - /** * Test preparing of form * diff --git a/dev/tests/integration/testsuite/Mage/ImportExport/Block/Adminhtml/Import/Edit/FormTest.php b/dev/tests/integration/testsuite/Mage/ImportExport/Block/Adminhtml/Import/Edit/FormTest.php index 6e477c2b0a099..d345b5e1383da 100644 --- a/dev/tests/integration/testsuite/Mage/ImportExport/Block/Adminhtml/Import/Edit/FormTest.php +++ b/dev/tests/integration/testsuite/Mage/ImportExport/Block/Adminhtml/Import/Edit/FormTest.php @@ -28,14 +28,14 @@ /** * Tests for block Mage_ImportExport_Block_Adminhtml_Import_Edit_FormTest */ -class Mage_ImportExport_Block_Adminhtml_Import_Edit_FormTest extends PHPUnit_Framework_TestCase +class Mage_ImportExport_Block_Adminhtml_Import_Edit_FormTest extends Mage_Backend_Area_TestCase { /** * List of expected fieldsets in import edit form * * @var array */ - protected static $_expectedFieldsets = array( + protected $_expectedFieldsets = array( 'base_fieldset', 'upload_file_fieldset', ); @@ -45,19 +45,14 @@ class Mage_ImportExport_Block_Adminhtml_Import_Edit_FormTest extends PHPUnit_Fra * * @static */ - public static function setUpBeforeClass() + protected function setUp() { $uniqueBehaviors = Mage_ImportExport_Model_Import::getUniqueEntityBehaviors(); foreach (array_keys($uniqueBehaviors) as $behavior) { - self::$_expectedFieldsets[] = $behavior . '_fieldset'; + $this->_expectedFieldsets[] = $behavior . '_fieldset'; } } - public static function tearDownAfterClass() - { - self::$_expectedFieldsets = null; - } - /** * Test content of form after _prepareForm */ @@ -81,11 +76,11 @@ public function testPrepareForm() $formElements = $form->getElements(); foreach ($formElements as $element) { /** @var $element Varien_Data_Form_Element_Abstract */ - if (in_array($element->getId(), self::$_expectedFieldsets)) { + if (in_array($element->getId(), $this->_expectedFieldsets)) { $formFieldsets[] = $element; } } - $this->assertSameSize(self::$_expectedFieldsets, $formFieldsets); + $this->assertSameSize($this->_expectedFieldsets, $formFieldsets); foreach ($formFieldsets as $fieldset) { $this->assertInstanceOf('Varien_Data_Form_Element_Fieldset', $fieldset, 'Incorrect fieldset class.'); } diff --git a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Export/Entity/Eav/Customer/AddressTest.php b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Export/Entity/Eav/Customer/AddressTest.php index 7cb2383a31430..1535c47f13a8f 100644 --- a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Export/Entity/Eav/Customer/AddressTest.php +++ b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Export/Entity/Eav/Customer/AddressTest.php @@ -55,14 +55,6 @@ protected function setUp() } } - protected function tearDown() - { - unset($this->_model); - unset($this->_websites); - - parent::tearDown(); - } - /** * Test export method */ diff --git a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Export/Entity/Eav/CustomerTest.php b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Export/Entity/Eav/CustomerTest.php index f143bc7b58dc3..1aff7439fb7cd 100644 --- a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Export/Entity/Eav/CustomerTest.php +++ b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Export/Entity/Eav/CustomerTest.php @@ -40,11 +40,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_ImportExport_Model_Export_Entity_Eav_Customer'); } - protected function tearDown() - { - unset($this->_model); - } - /** * Test export method * diff --git a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Export/Entity/EavAbstractTest.php b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Export/Entity/EavAbstractTest.php index 4c89c7e677e54..662ea21bb3be9 100644 --- a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Export/Entity/EavAbstractTest.php +++ b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Export/Entity/EavAbstractTest.php @@ -64,11 +64,6 @@ protected function setUp() $this->_model->__construct(); } - protected function tearDown() - { - unset($this->_model); - } - /** * Test for method getEntityTypeId() */ diff --git a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Export/Entity/ProductTest.php b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Export/Entity/ProductTest.php index ab1f0ee49fe79..1091c449bbb0d 100644 --- a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Export/Entity/ProductTest.php +++ b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Export/Entity/ProductTest.php @@ -32,27 +32,6 @@ class Mage_ImportExport_Model_Export_Entity_ProductTest extends PHPUnit_Framewor */ protected $_model; - /** - * Store old display_errors ini option value here - * - * @var int - */ - protected $_oldDisplayErrors; - - /** - * Store old error_reporting ini option value here - * - * @var int - */ - protected $_oldErrorLevel; - - /** - * Store old isDeveloperMode value here - * - * @var boolean - */ - protected $_oldIsDeveloperMode; - /** * Stock item attributes which must be exported * @@ -86,36 +65,13 @@ protected function setUp() parent::setUp(); $this->_model = Mage::getModel('Mage_ImportExport_Model_Export_Entity_Product'); - - $this->_oldDisplayErrors = ini_get('display_errors'); - $this->_oldErrorLevel = error_reporting(); - $this->_oldIsDeveloperMode = Mage::getIsDeveloperMode(); - } - - protected function tearDown() - { - ini_set('display_errors', $this->_oldDisplayErrors); - error_reporting($this->_oldErrorLevel); - Mage::setIsDeveloperMode($this->_oldIsDeveloperMode); - unset($this->_model); - - parent::tearDown(); } /** - * Test that there is no notice in _updateDataWithCategoryColumns() - * - * @covers Mage_ImportExport_Model_Export_Entity_Product::_updateDataWithCategoryColumns - * * @magentoDataFixture Mage/ImportExport/_files/product.php */ public function testExport() { - // we have to set strict error reporting mode and enable mage developer mode to convert notice to exception - error_reporting(E_ALL | E_STRICT); - ini_set('display_errors', 1); - Mage::setIsDeveloperMode(true); - $this->_model->setWriter(Mage::getModel('Mage_ImportExport_Model_Export_Adapter_Csv')); $this->assertNotEmpty($this->_model->export()); } diff --git a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Export/EntityAbstractTest.php b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Export/EntityAbstractTest.php index d2ff4b7e9e32f..07562ad660a63 100644 --- a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Export/EntityAbstractTest.php +++ b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Export/EntityAbstractTest.php @@ -41,12 +41,6 @@ protected function setUp() $this->_model = $this->getMockForAbstractClass('Mage_ImportExport_Model_Export_EntityAbstract'); } - protected function tearDown() - { - unset($this->_model); - parent::tearDown(); - } - /** * Check methods which provide ability to manage errors */ diff --git a/dev/tests/integration/testsuite/Mage/ImportExport/Model/ExportTest.php b/dev/tests/integration/testsuite/Mage/ImportExport/Model/ExportTest.php index efd3690c86e28..bb63f066143e6 100644 --- a/dev/tests/integration/testsuite/Mage/ImportExport/Model/ExportTest.php +++ b/dev/tests/integration/testsuite/Mage/ImportExport/Model/ExportTest.php @@ -39,11 +39,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_ImportExport_Model_Export'); } - protected function tearDown() - { - unset($this->_model); - } - /** * Test method '_getEntityAdapter' in case when entity is valid * diff --git a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/CustomerCompositeTest.php b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/CustomerCompositeTest.php index 4cc99f94594fa..83af8b4b0b81b 100644 --- a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/CustomerCompositeTest.php +++ b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/CustomerCompositeTest.php @@ -105,12 +105,6 @@ protected function setUp() ->create('Mage_ImportExport_Model_Import_Entity_CustomerComposite'); } - protected function tearDown() - { - unset($this->_objectManager); - unset($this->_entityAdapter); - } - /** * Assertion of current customer and address data * diff --git a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php index 06f0a6d85cdb6..11756f90428a3 100644 --- a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php +++ b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php @@ -99,14 +99,6 @@ public function setUp() $this->_entityAdapter = new $this->_testClassName(); } - /** - * Unset entity adapter - */ - public function tearDown() - { - unset($this->_entityAdapter); - } - /** * Test constructor * diff --git a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/Eav/CustomerImportTest.php b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/Eav/CustomerImportTest.php index 61760cc3e6528..3d0e7162dd381 100644 --- a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/Eav/CustomerImportTest.php +++ b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/Eav/CustomerImportTest.php @@ -44,13 +44,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_ImportExport_Model_Import_Entity_Eav_Customer'); } - protected function tearDown() - { - unset($this->_model); - - parent::tearDown(); - } - /** * Test importData() method * diff --git a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/Eav/CustomerValidateTest.php b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/Eav/CustomerValidateTest.php index e31ab4b3742e0..8bbd00a0fa671 100644 --- a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/Eav/CustomerValidateTest.php +++ b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/Eav/CustomerValidateTest.php @@ -75,15 +75,6 @@ protected function setUp() ); } - /** - * Unset created data during tests - */ - protected function tearDown() - { - unset($this->_model, $this->_customerData); - parent::tearDown(); - } - /** * Test which check duplicated data validation */ diff --git a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/EavAbstractTest.php b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/EavAbstractTest.php index 0a929c294135f..2c94290c15ee1 100644 --- a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/EavAbstractTest.php +++ b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/EavAbstractTest.php @@ -47,15 +47,6 @@ protected function setUp() '', false); } - /** - * Unset created data during test - */ - protected function tearDown() - { - unset($this->_model); - parent::tearDown(); - } - /** * Test for method getAttributeOptions() */ diff --git a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/Product/Type/AbstractTest.php b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/Product/Type/AbstractTest.php index b63b1b196b6b7..ba66b59a6a501 100644 --- a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/Product/Type/AbstractTest.php +++ b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/Product/Type/AbstractTest.php @@ -45,11 +45,6 @@ public function setUp() ); } - protected function tearDown() - { - $this->_model = null; - } - /** * @dataProvider prepareAttributesWithDefaultValueForSaveDataProvider */ diff --git a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/ProductTest.php b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/ProductTest.php index 504210938ceca..1c011197f7302 100644 --- a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/ProductTest.php +++ b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/ProductTest.php @@ -44,11 +44,6 @@ public function setUp() $this->_model = Mage::getModel('Mage_ImportExport_Model_Import_Entity_Product'); } - public function tearDown() - { - unset($this->_model); - } - /** * Options for assertion * diff --git a/dev/tests/integration/testsuite/Mage/ImportExport/Model/ImportTest.php b/dev/tests/integration/testsuite/Mage/ImportExport/Model/ImportTest.php index b48386640fbce..b84a6a92ac4c4 100644 --- a/dev/tests/integration/testsuite/Mage/ImportExport/Model/ImportTest.php +++ b/dev/tests/integration/testsuite/Mage/ImportExport/Model/ImportTest.php @@ -76,11 +76,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_ImportExport_Model_Import'); } - protected function tearDown() - { - unset($this->_model); - } - /** * @covers Mage_ImportExport_Model_Import::_getEntityAdapter */ diff --git a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Resource/Import/DataTest.php b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Resource/Import/DataTest.php index fb10da2bf5ca1..ae850c918b101 100644 --- a/dev/tests/integration/testsuite/Mage/ImportExport/Model/Resource/Import/DataTest.php +++ b/dev/tests/integration/testsuite/Mage/ImportExport/Model/Resource/Import/DataTest.php @@ -44,13 +44,6 @@ protected function setUp() $this->_model = Mage::getResourceModel('Mage_ImportExport_Model_Resource_Import_Data'); } - protected function tearDown() - { - unset($this->_model); - - parent::tearDown(); - } - /** * Test getUniqueColumnData() in case when in data stored in requested column is unique */ diff --git a/dev/tests/integration/testsuite/Mage/Install/Model/InstallerTest.php b/dev/tests/integration/testsuite/Mage/Install/Model/InstallerTest.php index cb13656fdf4ca..c737246ca7bb9 100644 --- a/dev/tests/integration/testsuite/Mage/Install/Model/InstallerTest.php +++ b/dev/tests/integration/testsuite/Mage/Install/Model/InstallerTest.php @@ -59,11 +59,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Install_Model_Installer'); } - protected function tearDown() - { - $this->_model = null; - } - /** * Emulate configuration directory for the installer config model. * Method usage should be accompanied with '@magentoAppIsolation enabled' because of the object manager pollution. @@ -175,4 +170,27 @@ public function testGetValidEncryptionKeyRandom() $this->assertRegExp('/^[a-f0-9]{32}$/', $actualKey); $this->assertNotEquals($actualKey, $this->_model->getValidEncryptionKey()); } + + /** + * @magentoAppIsolation enabled + * @magentoDataFixture Mage/Adminhtml/controllers/_files/cache/all_types_disabled.php + */ + public function testFinish() + { + $this->_emulateInstallerConfigDir(self::$_tmpDir); + $configFile = Magento_Test_Helper_Bootstrap::getInstance()->getAppInstallDir() . '/etc/local.xml'; + copy($configFile, self::$_tmpConfigFile); + + $this->_model->finish(); + + /** @var $cacheTypes Mage_Core_Model_Cache_Types */ + $cacheTypes = Mage::getModel('Mage_Core_Model_Cache_Types'); + $types = array_keys(Mage::getModel('Mage_Core_Model_Cache')->getTypes()); + foreach ($types as $type) { + $this->assertTrue( + $cacheTypes->isEnabled($type), + "'$type' cache type has not been enabled after installation" + ); + } + } } diff --git a/dev/tests/integration/testsuite/Mage/Install/controllers/WizardControllerTest.php b/dev/tests/integration/testsuite/Mage/Install/controllers/WizardControllerTest.php index 2949f8f1e90b4..594c83f86f651 100644 --- a/dev/tests/integration/testsuite/Mage/Install/controllers/WizardControllerTest.php +++ b/dev/tests/integration/testsuite/Mage/Install/controllers/WizardControllerTest.php @@ -30,77 +30,86 @@ class Mage_Install_WizardControllerTest extends Magento_Test_TestCase_Controller /** * @var string */ - protected static $_mediaDir; + protected static $_tmpDir; /** - * @var string + * @var array */ - protected static $_themeDir; + protected static $_params = array(); public static function setUpBeforeClass() { - parent::setUpBeforeClass(); - self::$_mediaDir = Mage::getBaseDir(Mage_Core_Model_Dir::MEDIA); - self::$_themeDir = self::$_mediaDir . DIRECTORY_SEPARATOR . 'theme'; - } - - public function setUp() - { - // emulate non-installed application - Magento_Test_Helper_Bootstrap::getInstance()->reinitialize(array( - Mage::PARAM_CUSTOM_LOCAL_CONFIG - => sprintf(Mage_Core_Model_Config_Primary::CONFIG_TEMPLATE_INSTALL_DATE, 'invalid') - )); - parent::setUp(); - } - - public function tearDown() - { - if (is_dir(self::$_mediaDir)) { - chmod(self::$_mediaDir, 0777); - } - if (is_dir(self::$_themeDir)) { - chmod(self::$_themeDir, 0777); + $tmpDir = Magento_Test_Helper_Bootstrap::getInstance()->getAppInstallDir() . DIRECTORY_SEPARATOR . __CLASS__; + if (is_file($tmpDir)) { + unlink($tmpDir); + } elseif (is_dir($tmpDir)) { + Varien_Io_File::rmdirRecursive($tmpDir); } - parent::tearDown(); + // deliberately create a file instead of directory to emulate broken access to static directory + touch($tmpDir); + self::$_tmpDir = $tmpDir; + + // emulate invalid installation date, so that application will think it is not installed + self::$_params = array(Mage::PARAM_CUSTOM_LOCAL_CONFIG + => sprintf(Mage_Core_Model_Config_Primary::CONFIG_TEMPLATE_INSTALL_DATE, 'invalid') + ); } public function testPreDispatch() { + Magento_Test_Helper_Bootstrap::getInstance()->reinitialize(self::$_params); + Mage::getObjectManager()->configure(array( + 'preferences' => array( + 'Mage_Core_Controller_Request_Http' => 'Magento_Test_Request', + 'Mage_Core_Controller_Response_Http' => 'Magento_Test_Response' + ) + )); $this->dispatch('install/wizard'); $this->assertEquals(200, $this->getResponse()->getHttpResponseCode()); } - public function testPreDispatchNonWritableTheme() + /** + * @param string $action + * @dataProvider actionsDataProvider + * @expectedException Magento_BootstrapException + */ + public function testPreDispatchImpossibleToRenderPage($action) { - $this->_testInstallProhibitedWhenNonWritable(self::$_themeDir); + $params = self::$_params; + $params[Mage::PARAM_APP_DIRS][Mage_Core_Model_Dir::STATIC_VIEW] = self::$_tmpDir; + Magento_Test_Helper_Bootstrap::getInstance()->reinitialize($params); + Mage::getObjectManager()->configure(array( + 'preferences' => array( + 'Mage_Core_Controller_Request_Http' => 'Magento_Test_Request', + 'Mage_Core_Controller_Response_Http' => 'Magento_Test_Response' + ) + )); + $this->dispatch("install/wizard/{$action}"); } /** - * Tests that when $nonWritableDir folder is read-only, the installation controller prohibits continuing - * installation and points to fix issue with theme directory. - * - * @param string $nonWritableDir + * @return array */ - protected function _testInstallProhibitedWhenNonWritable($nonWritableDir) + public function actionsDataProvider() { - if (file_exists($nonWritableDir) && !is_dir($nonWritableDir)) { - $this->markTestSkipped("Incorrect file structure. $nonWritableDir should be a directory"); - } - - if (is_dir($nonWritableDir)) { - chmod($nonWritableDir, 0444); - } else { - mkdir($nonWritableDir, 0444); - } - - if (is_writable($nonWritableDir)) { - $this->markTestSkipped("Current OS doesn't support setting write-access for folders via mode flags"); - } - - $this->dispatch('install/wizard'); - - $this->assertEquals(503, $this->getResponse()->getHttpResponseCode()); - $this->assertContains(self::$_themeDir, $this->getResponse()->getBody()); + return array( + array('index'), + array('begin'), + array('beginPost'), + array('locale'), + array('localeChange'), + array('localePost'), + array('download'), + array('downloadPost'), + array('downloadAuto'), + array('install'), + array('downloadManual'), + array('config'), + array('configPost'), + array('installDb'), + array('administrator'), + array('administratorPost'), + array('end'), + ); } } diff --git a/dev/tests/integration/testsuite/Mage/Log/Model/Resource/ShellTest.php b/dev/tests/integration/testsuite/Mage/Log/Model/Resource/ShellTest.php index 56ba41d12d0f7..d206f9994bcdd 100644 --- a/dev/tests/integration/testsuite/Mage/Log/Model/Resource/ShellTest.php +++ b/dev/tests/integration/testsuite/Mage/Log/Model/Resource/ShellTest.php @@ -37,11 +37,6 @@ public function setUp() $this->_model = Mage::getResourceModel('Mage_Log_Model_Resource_Shell'); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetTablesInfo() { $tables = $this->_model->getTablesInfo(); diff --git a/dev/tests/integration/testsuite/Mage/Newsletter/Model/QueueTest.php b/dev/tests/integration/testsuite/Mage/Newsletter/Model/QueueTest.php index d0dfbcf422f35..3c2232efd5c8a 100644 --- a/dev/tests/integration/testsuite/Mage/Newsletter/Model/QueueTest.php +++ b/dev/tests/integration/testsuite/Mage/Newsletter/Model/QueueTest.php @@ -44,10 +44,10 @@ public function testSendPerSubscriber() $subscriberOne->expects($this->any())->method('send'); $subscriberTwo = clone $subscriberOne; $subscriberOne->expects($this->once())->method('setBodyHTML')->with( - $this->stringEndsWith('/theme/static/frontend/default/demo_blue/en_US/images/logo.gif') + $this->stringEndsWith('/static/frontend/default/demo_blue/en_US/images/logo.gif') ); $subscriberTwo->expects($this->once())->method('setBodyHTML')->with( - $this->stringEndsWith('/theme/static/frontend/default/demo/de_DE/images/logo.gif') + $this->stringEndsWith('/static/frontend/default/demo/de_DE/images/logo.gif') ); $emailTemplate = $this->getMock('Mage_Core_Model_Email_Template', array('_getMail'), array(), '', false); diff --git a/dev/tests/integration/testsuite/Mage/Newsletter/Model/TemplateTest.php b/dev/tests/integration/testsuite/Mage/Newsletter/Model/TemplateTest.php index 0f72096e62e74..0977a45914cc2 100644 --- a/dev/tests/integration/testsuite/Mage/Newsletter/Model/TemplateTest.php +++ b/dev/tests/integration/testsuite/Mage/Newsletter/Model/TemplateTest.php @@ -40,11 +40,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Newsletter_Model_Template'); } - protected function tearDown() - { - $this->_model = null; - } - /** * @magentoConfigFixture install/design/theme/full_name default/basic * @magentoConfigFixture adminhtml/design/theme/full_name default/basic diff --git a/dev/tests/integration/testsuite/Mage/Page/Block/Html/BreadcrumbsTest.php b/dev/tests/integration/testsuite/Mage/Page/Block/Html/BreadcrumbsTest.php index d3d331a5dcf35..5514d46b99f8f 100644 --- a/dev/tests/integration/testsuite/Mage/Page/Block/Html/BreadcrumbsTest.php +++ b/dev/tests/integration/testsuite/Mage/Page/Block/Html/BreadcrumbsTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_block = Mage::app()->getLayout()->createBlock('Mage_Page_Block_Html_Breadcrumbs'); } - protected function tearDown() - { - $this->_block = null; - } - public function testAddCrumb() { $this->assertEmpty($this->_block->toHtml()); diff --git a/dev/tests/integration/testsuite/Mage/Page/Block/Html/FooterTest.php b/dev/tests/integration/testsuite/Mage/Page/Block/Html/FooterTest.php index ee9451821bca7..b91a6aa2c4d40 100644 --- a/dev/tests/integration/testsuite/Mage/Page/Block/Html/FooterTest.php +++ b/dev/tests/integration/testsuite/Mage/Page/Block/Html/FooterTest.php @@ -38,11 +38,6 @@ protected function setUp() $this->_theme = Mage::getDesign()->getDesignTheme(); } - protected function tearDown() - { - $this->_theme = null; - } - public function testGetCacheKeyInfo() { $block = Mage::app()->getLayout()->createBlock('Mage_Page_Block_Html_Footer'); diff --git a/dev/tests/integration/testsuite/Mage/Page/Block/Html/HeadTest.php b/dev/tests/integration/testsuite/Mage/Page/Block/Html/HeadTest.php index bf0c1f79cc1db..2ba49d175ecaa 100644 --- a/dev/tests/integration/testsuite/Mage/Page/Block/Html/HeadTest.php +++ b/dev/tests/integration/testsuite/Mage/Page/Block/Html/HeadTest.php @@ -32,13 +32,9 @@ class Mage_Page_Block_Html_HeadTest extends PHPUnit_Framework_TestCase */ private $_block = null; - public static function setUpBeforeClass() - { - Mage::getDesign()->setDesignTheme('default/demo', 'frontend'); - } - protected function setUp() { + Mage::getDesign()->setDesignTheme('default/demo', 'frontend'); $this->_block = Mage::app()->getLayout()->createBlock('Mage_Page_Block_Html_Head'); } @@ -47,53 +43,26 @@ protected function tearDown() $this->_block = null; } - public function testAddCss() - { - $this->assertEmpty($this->_block->getItems()); - $this->_block->addCss('test.css'); - $this->assertEquals(array('css/test.css' => array( - 'type' => 'css', - 'name' => 'test.css', - 'params' => 'rel="stylesheet" type="text/css" media="all"', - 'if' => null, - 'cond' => null, - )), $this->_block->getItems() - ); - } - /** - * @expectedException Magento_Exception + * @expectedException InvalidArgumentException + * @expectedExceptionMessage Parameter 'file' must not be empty + * @magentoAppIsolation enabled */ public function testAddCssException() { $this->_block->addCss(''); } - public function testGetCssJsHtmlBadLink() - { - $this->_block->addJs('varien/js.js') - ->addJs('varien/form.js', '', 'lt IE 7') - ->addCss('not_exist_folder/wrong_bad_file.xyz') - ->addCss('css/styles.css', ' media="print" ') - ->addJs('not_exist_folder/wrong_bad_file2.xyz'); - - $this->assertEquals('' . "\n" . '' . "\n" . '' . "\n" - . '' - . "\n", $this->_block->getCssJsHtml()); - } - + /** + * @magentoAppIsolation enabled + */ public function testGetCssJsHtml() { $this->_block->addJs('zero.js', '', null, 'nonexisting_condition') ->addJs('varien/js.js') ->addJs('Mage_Bundle::bundle.js') ->addCss('tiny_mce/themes/advanced/skins/default/ui.css') - ->addCss('css/styles.css', ' media="print" ') + ->addCss('css/styles.css', 'media="print"') ->addRss('RSS Feed', 'http://example.com/feed.xml') ->addLinkRel('next', 'http://example.com/page1.html') ->addJs('varien/form.js', '', 'lt IE 7') @@ -101,12 +70,12 @@ public function testGetCssJsHtml() $this->assertEquals( '' . "\n" . '' . "\n" . '' . "\n" . '' + . 'href="http://localhost/pub/static/frontend/default/demo/en_US/css/styles.css" />' . "\n" . '' . "\n" @@ -118,8 +87,48 @@ public function testGetCssJsHtml() ); } + /** + * @magentoAppIsolation enabled + */ + public function testGetCssJsHtmlBadLink() + { + $this->_block->addCss('not_exist_folder/wrong_bad_file.xyz') + ->addJs('not_exist_folder/wrong_bad_file2.xyz'); + + $this->assertEquals('' . "\n" + . '' + . "\n", + $this->_block->getCssJsHtml()); + } + + /** + * Both existing and non-existent JS and CSS links are specified + * @magentoAppIsolation enabled + */ + public function testGetCssJsHtmlMixedLinks() + { + $this->_block->addJs('varien/js.js') + ->addJs('varien/form.js', '', 'lt IE 7') + ->addCss('not_exist_folder/wrong_bad_file.xyz') + ->addCss('css/styles.css', 'media="print"') + ->addJs('not_exist_folder/wrong_bad_file2.xyz'); + + $this->assertEquals('' + . "\n" . '' + . "\n" . '' . "\n" + . '' . "\n" + . '' + . "\n", $this->_block->getCssJsHtml()); + } + /** * Test getRobots default value + * @magentoAppIsolation enabled */ public function testGetRobotsDefaultValue() { @@ -130,6 +139,7 @@ public function testGetRobotsDefaultValue() * Test getRobots * * @magentoConfigFixture default_store design/search_engine_robots/default_robots INDEX,NOFOLLOW + * @magentoAppIsolation enabled */ public function testGetRobots() { diff --git a/dev/tests/integration/testsuite/Mage/Page/Block/HtmlTest.php b/dev/tests/integration/testsuite/Mage/Page/Block/HtmlTest.php index 7eda712c0f0ff..b2ae1f67680d7 100644 --- a/dev/tests/integration/testsuite/Mage/Page/Block/HtmlTest.php +++ b/dev/tests/integration/testsuite/Mage/Page/Block/HtmlTest.php @@ -43,12 +43,12 @@ public function testGetPrintLogoUrl($configData, $returnValue) ->method('getBaseUrl') ->will($this->returnValue('http://localhost/pub/media/')); - $arguments = array( + $context = Mage::getModel('Mage_Core_Block_Template_Context', array( 'storeConfig' => $storeConfig, 'urlBuilder' => $urlBuilder, - ); + )); - $block = Mage::getObjectManager()->create('Mage_Page_Block_Html', $arguments); + $block = Mage::getObjectManager()->create('Mage_Page_Block_Html', array('context' => $context)); $this->assertEquals($returnValue, $block->getPrintLogoUrl()); } diff --git a/dev/tests/integration/testsuite/Mage/PageCache/Helper/DataTest.php b/dev/tests/integration/testsuite/Mage/PageCache/Helper/DataTest.php index e5b2359b1ee3f..b500773cc2561 100644 --- a/dev/tests/integration/testsuite/Mage/PageCache/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Mage/PageCache/Helper/DataTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_helper = Mage::helper('Mage_PageCache_Helper_Data'); } - protected function tearDown() - { - $this->_helper = null; - } - public function testSetNoCacheCookie() { /** @var $cookie Mage_Core_Model_Cookie */ diff --git a/dev/tests/integration/testsuite/Mage/PageCache/Model/ObserverTest.php b/dev/tests/integration/testsuite/Mage/PageCache/Model/ObserverTest.php index 54dc64cca2b56..4a709bc4c95d2 100644 --- a/dev/tests/integration/testsuite/Mage/PageCache/Model/ObserverTest.php +++ b/dev/tests/integration/testsuite/Mage/PageCache/Model/ObserverTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_observer = Mage::getModel('Mage_PageCache_Model_Observer'); } - protected function tearDown() - { - $this->_observer = null; - } - /** * @magentoConfigFixture current_store system/external_page_cache/enabled 1 */ diff --git a/dev/tests/integration/testsuite/Mage/Paypal/Model/IpnTest.php b/dev/tests/integration/testsuite/Mage/Paypal/Model/IpnTest.php index 03871a1d02fc8..7ad6e695f1f5b 100644 --- a/dev/tests/integration/testsuite/Mage/Paypal/Model/IpnTest.php +++ b/dev/tests/integration/testsuite/Mage/Paypal/Model/IpnTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Paypal_Model_Ipn'); } - protected function tearDown() - { - $this->_model = null; - } - /** * @param string $currencyCode * @dataProvider currencyProvider diff --git a/dev/tests/integration/testsuite/Mage/ProductAlert/Block/Email/StockTest.php b/dev/tests/integration/testsuite/Mage/ProductAlert/Block/Email/StockTest.php index 58538d5e39dd4..53661c2500afb 100644 --- a/dev/tests/integration/testsuite/Mage/ProductAlert/Block/Email/StockTest.php +++ b/dev/tests/integration/testsuite/Mage/ProductAlert/Block/Email/StockTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_block = Mage::app()->getLayout()->createBlock('Mage_ProductAlert_Block_Email_Stock'); } - protected function tearDown() - { - $this->_block = null; - } - /** * @magentoDataFixture Mage/Core/_files/frontend_default_theme.php * @magentoDataFixture Mage/Catalog/_files/product_with_image.php diff --git a/dev/tests/integration/testsuite/Mage/Reports/Block/Adminhtml/GridTest.php b/dev/tests/integration/testsuite/Mage/Reports/Block/Adminhtml/GridTest.php index 98d9bb3cf3cd1..57e150a00c2de 100644 --- a/dev/tests/integration/testsuite/Mage/Reports/Block/Adminhtml/GridTest.php +++ b/dev/tests/integration/testsuite/Mage/Reports/Block/Adminhtml/GridTest.php @@ -28,7 +28,7 @@ /** * Test class for Mage_Reports_Block_Adminhtml_Grid */ -class Mage_Reports_Block_Adminhtml_GridTest extends PHPUnit_Framework_TestCase +class Mage_Reports_Block_Adminhtml_GridTest extends Mage_Backend_Area_TestCase { public function testGetDateFormat() { diff --git a/dev/tests/integration/testsuite/Mage/Review/controllers/ProductControllerTest.php b/dev/tests/integration/testsuite/Mage/Review/controllers/ProductControllerTest.php index 005d658711db2..cf383552640f5 100644 --- a/dev/tests/integration/testsuite/Mage/Review/controllers/ProductControllerTest.php +++ b/dev/tests/integration/testsuite/Mage/Review/controllers/ProductControllerTest.php @@ -36,7 +36,7 @@ public function testListActionDesign($productId, $expectedDesign) $this->getRequest()->setParam('id', $productId); $this->dispatch('review/product/list'); $result = $this->getResponse()->getBody(); - $this->assertContains("media/theme/static/frontend/{$expectedDesign}/en_US/Mage_Page/favicon.ico", $result); + $this->assertContains("static/frontend/{$expectedDesign}/en_US/Mage_Page/favicon.ico", $result); } /** diff --git a/dev/tests/integration/testsuite/Mage/Rss/controllers/CatalogControllerTest.php b/dev/tests/integration/testsuite/Mage/Rss/controllers/CatalogControllerTest.php index 9ad5099c4dcb6..36403bb8ac3be 100644 --- a/dev/tests/integration/testsuite/Mage/Rss/controllers/CatalogControllerTest.php +++ b/dev/tests/integration/testsuite/Mage/Rss/controllers/CatalogControllerTest.php @@ -27,6 +27,11 @@ class Mage_Rss_CatalogControllerTest extends Magento_Test_TestCase_ControllerAbstract { + protected function setUp() + { + parent::setUp(); + Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_ADMINHTML, Mage_Core_Model_App_Area::PART_CONFIG); + } /** * @param string $action * @dataProvider actionNoFeedDataProvider diff --git a/dev/tests/integration/testsuite/Mage/Rss/controllers/OrderControllerTest.php b/dev/tests/integration/testsuite/Mage/Rss/controllers/OrderControllerTest.php index 63f6dc71fec65..a5d5cfbaac60e 100644 --- a/dev/tests/integration/testsuite/Mage/Rss/controllers/OrderControllerTest.php +++ b/dev/tests/integration/testsuite/Mage/Rss/controllers/OrderControllerTest.php @@ -27,6 +27,11 @@ class Mage_Rss_OrderControllerTest extends Magento_Test_TestCase_ControllerAbstract { + protected function setUp() + { + parent::setUp(); + Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_ADMINHTML, Mage_Core_Model_App_Area::PART_CONFIG); + } /** * Reuse URI for "new" action */ diff --git a/dev/tests/integration/testsuite/Mage/Sales/Block/Adminhtml/Report/Filter/Form/CouponTest.php b/dev/tests/integration/testsuite/Mage/Sales/Block/Adminhtml/Report/Filter/Form/CouponTest.php index 25bbaefc66cbb..7594f517c6d6c 100644 --- a/dev/tests/integration/testsuite/Mage/Sales/Block/Adminhtml/Report/Filter/Form/CouponTest.php +++ b/dev/tests/integration/testsuite/Mage/Sales/Block/Adminhtml/Report/Filter/Form/CouponTest.php @@ -28,7 +28,7 @@ /** * Test for Mage_Index_Model_Lock_Storage */ -class Mage_Sales_Block_Adminhtml_Report_Filter_Form_CouponTest extends PHPUnit_Framework_TestCase +class Mage_Sales_Block_Adminhtml_Report_Filter_Form_CouponTest extends Mage_Backend_Area_TestCase { /** * Application object @@ -39,14 +39,10 @@ class Mage_Sales_Block_Adminhtml_Report_Filter_Form_CouponTest extends PHPUnit_F protected function setUp() { + parent::setUp(); $this->_application = Mage::getObjectManager()->get('Mage_Core_Model_App'); } - protected function tearDown() - { - unset($this->_application); - } - /** * @covers Mage_Sales_Block_Adminhtml_Report_Filter_Form_Coupon::_afterToHtml */ diff --git a/dev/tests/integration/testsuite/Mage/Sales/Block/Order/CommentsTest.php b/dev/tests/integration/testsuite/Mage/Sales/Block/Order/CommentsTest.php index d605ed5b32d79..9fa0d6fa9b24d 100644 --- a/dev/tests/integration/testsuite/Mage/Sales/Block/Order/CommentsTest.php +++ b/dev/tests/integration/testsuite/Mage/Sales/Block/Order/CommentsTest.php @@ -37,11 +37,6 @@ public function setUp() $this->_block = Mage::app()->getLayout()->createBlock('Mage_Sales_Block_Order_Comments'); } - protected function tearDown() - { - $this->_block = null; - } - /** * @param mixed $commentedEntity * @param string $expectedClass diff --git a/dev/tests/integration/testsuite/Mage/Sales/Block/Order/Creditmemo/ItemsTest.php b/dev/tests/integration/testsuite/Mage/Sales/Block/Order/Creditmemo/ItemsTest.php index a6ae2a7431d3c..f749b602af3dd 100644 --- a/dev/tests/integration/testsuite/Mage/Sales/Block/Order/Creditmemo/ItemsTest.php +++ b/dev/tests/integration/testsuite/Mage/Sales/Block/Order/Creditmemo/ItemsTest.php @@ -49,13 +49,6 @@ public function setUp() $this->_creditmemo = Mage::getModel('Mage_Sales_Model_Order_Creditmemo'); } - protected function tearDown() - { - $this->_layout = null; - $this->_block = null; - $this->_creditmemo = null; - } - public function testGetTotalsHtml() { $childBlock = $this->_layout->addBlock('Mage_Core_Block_Text', 'creditmemo_totals', 'block'); diff --git a/dev/tests/integration/testsuite/Mage/Sales/Block/Order/Invoice/ItemsTest.php b/dev/tests/integration/testsuite/Mage/Sales/Block/Order/Invoice/ItemsTest.php index 1b90ed76833e1..354282ad8858a 100644 --- a/dev/tests/integration/testsuite/Mage/Sales/Block/Order/Invoice/ItemsTest.php +++ b/dev/tests/integration/testsuite/Mage/Sales/Block/Order/Invoice/ItemsTest.php @@ -49,13 +49,6 @@ public function setUp() $this->_invoice = Mage::getModel('Mage_Sales_Model_Order_Invoice'); } - protected function tearDown() - { - $this->_layout = null; - $this->_block = null; - $this->_invoice = null; - } - public function testGetInvoiceTotalsHtml() { $childBlock = $this->_layout->addBlock('Mage_Core_Block_Text', 'invoice_totals', 'block'); diff --git a/dev/tests/integration/testsuite/Mage/Sales/Block/Order/TotalsTest.php b/dev/tests/integration/testsuite/Mage/Sales/Block/Order/TotalsTest.php index 48bb7fb4e1a50..09ed838b4c586 100644 --- a/dev/tests/integration/testsuite/Mage/Sales/Block/Order/TotalsTest.php +++ b/dev/tests/integration/testsuite/Mage/Sales/Block/Order/TotalsTest.php @@ -27,25 +27,6 @@ class Mage_Sales_Block_Order_TotalsTest extends PHPUnit_Framework_TestCase { - /** - * List of block injection classes - * - * @var array - */ - protected $_blockInjections = array( - 'Mage_Core_Controller_Request_Http', - 'Mage_Core_Model_Layout', - 'Mage_Core_Model_Event_Manager', - 'Mage_Core_Model_Url', - 'Mage_Core_Model_Translate', - 'Mage_Core_Model_Cache', - 'Mage_Core_Model_Design_Package', - 'Mage_Core_Model_Session', - 'Mage_Core_Model_Store_Config', - 'Mage_Core_Controller_Varien_Front', - 'Mage_Core_Model_Factory_Helper' - ); - public function testToHtmlChildrenInitialized() { /** @var $layout Mage_Core_Model_Layout */ @@ -54,40 +35,22 @@ public function testToHtmlChildrenInitialized() $block->setOrder(Mage::getModel('Mage_Sales_Model_Order')) ->setTemplate('order/totals.phtml'); - $childOne = $this->getMock('Mage_Core_Block_Text', array('initTotals'), - $this->_prepareConstructorArguments() - ); + $context = Mage::getSingleton('Mage_Core_Block_Context'); + $childOne = $this->getMock('Mage_Core_Block_Text', array('initTotals'), array($context)); $childOne->expects($this->once()) ->method('initTotals'); $layout->addBlock($childOne, 'child1', 'block'); - $childTwo = $this->getMock('Mage_Core_Block_Text', array('initTotals'), - $this->_prepareConstructorArguments() - ); + $childTwo = $this->getMock('Mage_Core_Block_Text', array('initTotals'), array($context)); $childTwo->expects($this->once()) ->method('initTotals'); $layout->addBlock($childTwo, 'child2', 'block'); - $childThree = $this->getMock('Mage_Core_Block_Text', array('initTotals'), - $this->_prepareConstructorArguments()); + $childThree = $this->getMock('Mage_Core_Block_Text', array('initTotals'), array($context)); $childThree->expects($this->once()) ->method('initTotals'); $layout->addBlock($childThree, 'child3', 'block'); $block->toHtml(); } - - /** - * List of block constructor arguments - * - * @return array - */ - protected function _prepareConstructorArguments() - { - $arguments = array(); - foreach ($this->_blockInjections as $injectionClass) { - $arguments[] = Mage::getModel($injectionClass); - } - return $arguments; - } } diff --git a/dev/tests/integration/testsuite/Mage/Sales/Block/Recurring/Profile/ViewTest.php b/dev/tests/integration/testsuite/Mage/Sales/Block/Recurring/Profile/ViewTest.php index dd8fb038b0803..fc1e45c56c5e6 100644 --- a/dev/tests/integration/testsuite/Mage/Sales/Block/Recurring/Profile/ViewTest.php +++ b/dev/tests/integration/testsuite/Mage/Sales/Block/Recurring/Profile/ViewTest.php @@ -53,7 +53,6 @@ public function setUp() public function tearDown() { - Mage::unregister('current_recurring_profile'); $this->_profile = null; $this->_block = null; diff --git a/dev/tests/integration/testsuite/Mage/Sales/_files/quote.php b/dev/tests/integration/testsuite/Mage/Sales/_files/quote.php index 073a3b5a34077..16d22ac7330cc 100644 --- a/dev/tests/integration/testsuite/Mage/Sales/_files/quote.php +++ b/dev/tests/integration/testsuite/Mage/Sales/_files/quote.php @@ -32,6 +32,7 @@ ->setName('Simple Product') ->setSku('simple') ->setPrice(10) + ->setTaxClassId(0) ->setStockData( array( 'use_config_manage_stock' => 1, diff --git a/dev/tests/integration/testsuite/Mage/Shipping/Helper/DataTest.php b/dev/tests/integration/testsuite/Mage/Shipping/Helper/DataTest.php index 165588faae829..3fd05aeffcc28 100644 --- a/dev/tests/integration/testsuite/Mage/Shipping/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Mage/Shipping/Helper/DataTest.php @@ -37,11 +37,6 @@ public function setUp() $this->_helper = Mage::helper('Mage_Shipping_Helper_Data'); } - protected function tearDown() - { - $this->_helper = null; - } - /** * @param string $modelName * @param string $getIdMethod diff --git a/dev/tests/integration/testsuite/Mage/Sitemap/Helper/DataTest.php b/dev/tests/integration/testsuite/Mage/Sitemap/Helper/DataTest.php index b96f4301f7f53..d46fe88bb1df8 100644 --- a/dev/tests/integration/testsuite/Mage/Sitemap/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Mage/Sitemap/Helper/DataTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_helper = Mage::helper('Mage_Sitemap_Helper_Data'); } - protected function tearDown() - { - unset($this->_helper); - } - /** * @magentoConfigFixture default_store sitemap/limit/max_lines 10 */ diff --git a/dev/tests/integration/testsuite/Mage/Tag/Block/Customer/ViewTest.php b/dev/tests/integration/testsuite/Mage/Tag/Block/Customer/ViewTest.php index c6340cdf04be2..0fcbef87afb3f 100644 --- a/dev/tests/integration/testsuite/Mage/Tag/Block/Customer/ViewTest.php +++ b/dev/tests/integration/testsuite/Mage/Tag/Block/Customer/ViewTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_block = Mage::getObjectManager()->create('Mage_Tag_Block_Customer_View'); } - protected function tearDown() - { - $this->_block = null; - } - public function testGetMode() { /** @var $layout Mage_Core_Model_Layout */ diff --git a/dev/tests/integration/testsuite/Mage/Tag/Block/Product/ResultTest.php b/dev/tests/integration/testsuite/Mage/Tag/Block/Product/ResultTest.php index 0110f25be82ee..17a29e6d12d30 100644 --- a/dev/tests/integration/testsuite/Mage/Tag/Block/Product/ResultTest.php +++ b/dev/tests/integration/testsuite/Mage/Tag/Block/Product/ResultTest.php @@ -52,20 +52,16 @@ protected function setUp() $this->_layout = Mage::getModel('Mage_Core_Model_Layout'); $this->_layout->addBlock('Mage_Core_Block_Text', 'root'); $this->_layout->addBlock('Mage_Core_Block_Text', 'head'); - $this->_block = $this->_layout->createBlock('Mage_Tag_Block_Product_Result', 'test', + $context = Mage::getObjectManager()->create('Mage_Core_Block_Template_Context', array('layout' => $this->_layout) ); + $this->_block = $this->_layout->createBlock('Mage_Tag_Block_Product_Result', 'test', + array('context' => $context) + ); $this->_child = Mage::getObjectManager()->create('Mage_Core_Block_Text'); $this->_layout->addBlock($this->_child, 'search_result_list', 'test'); } - protected function tearDown() - { - $this->_block = null; - $this->_layout = null; - $this->_child = null; - } - public function testSetListOrders() { $this->assertEmpty($this->_child->getData('available_orders')); diff --git a/dev/tests/integration/testsuite/Mage/Tag/Model/TagTest.php b/dev/tests/integration/testsuite/Mage/Tag/Model/TagTest.php index e0381196c8ac5..4574ea5f5dc87 100644 --- a/dev/tests/integration/testsuite/Mage/Tag/Model/TagTest.php +++ b/dev/tests/integration/testsuite/Mage/Tag/Model/TagTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_model= Mage::getModel('Mage_Tag_Model_Tag'); } - protected function tearDown() - { - $this->_model = null; - } - /** * @magentoAppIsolation enabled */ diff --git a/dev/tests/integration/testsuite/Mage/Tax/Model/Calculation/RuleTest.php b/dev/tests/integration/testsuite/Mage/Tax/Model/Calculation/RuleTest.php index 58779ea169ad0..f5e1f5fd5562e 100644 --- a/dev/tests/integration/testsuite/Mage/Tax/Model/Calculation/RuleTest.php +++ b/dev/tests/integration/testsuite/Mage/Tax/Model/Calculation/RuleTest.php @@ -39,8 +39,7 @@ class Mage_Tax_Model_Calculation_RuleTest extends PHPUnit_Framework_TestCase public function testGetCustomerTaxClassWithDefaultFirstValue() { $model = new Mage_Tax_Model_Calculation_Rule( - Mage::getModel('Mage_Core_Model_Event_Manager'), - Mage::getModel('Mage_Core_Model_Cache'), + Mage::getModel('Mage_Core_Model_Context'), Mage::helper('Mage_Tax_Helper_Data'), $this->_getTaxClassMock( 'getCustomerClasses', @@ -61,8 +60,7 @@ public function testGetCustomerTaxClassWithDefaultFirstValue() public function testGetCustomerTaxClassWithDefaultFromConfig() { $model = new Mage_Tax_Model_Calculation_Rule( - Mage::getModel('Mage_Core_Model_Event_Manager'), - Mage::getModel('Mage_Core_Model_Cache'), + Mage::getModel('Mage_Core_Model_Context'), Mage::helper('Mage_Tax_Helper_Data'), $this->_getTaxClassMock( 'getCustomerClasses', @@ -83,8 +81,7 @@ public function testGetCustomerTaxClassWithDefaultFromConfig() public function testGetProductTaxClassWithDefaultFirstValue() { $model = new Mage_Tax_Model_Calculation_Rule( - Mage::getModel('Mage_Core_Model_Event_Manager'), - Mage::getModel('Mage_Core_Model_Cache'), + Mage::getModel('Mage_Core_Model_Context'), Mage::helper('Mage_Tax_Helper_Data'), $this->_getTaxClassMock( 'getProductClasses', @@ -105,8 +102,7 @@ public function testGetProductTaxClassWithDefaultFirstValue() public function testGetProductTaxClassWithDefaultFromConfig() { $model = new Mage_Tax_Model_Calculation_Rule( - Mage::getModel('Mage_Core_Model_Event_Manager'), - Mage::getModel('Mage_Core_Model_Cache'), + Mage::getModel('Mage_Core_Model_Context'), Mage::helper('Mage_Tax_Helper_Data'), $this->_getTaxClassMock( 'getProductClasses', @@ -127,8 +123,7 @@ public function testGetProductTaxClassWithDefaultFromConfig() public function testGetAllOptions($classFilter, $expected) { $model = new Mage_Tax_Model_Calculation_Rule( - Mage::getModel('Mage_Core_Model_Event_Manager'), - Mage::getModel('Mage_Core_Model_Cache'), + Mage::getModel('Mage_Core_Model_Context'), Mage::helper('Mage_Tax_Helper_Data'), Mage::getModel('Mage_Tax_Model_Class'), null, @@ -187,8 +182,7 @@ protected function _getTaxClassMock($callback, $filter) 'Mage_Tax_Model_Class', array('getCollection'), array( - Mage::getModel('Mage_Core_Model_Event_Manager'), - Mage::getModel('Mage_Core_Model_Cache') + Mage::getModel('Mage_Core_Model_Context'), ), '', true @@ -235,4 +229,4 @@ public function getProductClasses() ) ); } -} \ No newline at end of file +} diff --git a/dev/tests/integration/testsuite/Mage/Tax/Model/ConfigTest.php b/dev/tests/integration/testsuite/Mage/Tax/Model/ConfigTest.php index e7ab0c3880bbd..880de61352467 100644 --- a/dev/tests/integration/testsuite/Mage/Tax/Model/ConfigTest.php +++ b/dev/tests/integration/testsuite/Mage/Tax/Model/ConfigTest.php @@ -34,11 +34,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Tax_Model_Config'); } - protected function tearDown() - { - $this->_model = null; - } - public function testSetPriceIncludesTax() { $this->assertFalse($this->_model->priceIncludesTax()); diff --git a/dev/tests/integration/testsuite/Mage/Tax/Model/Rate/CsvImportHandlerTest.php b/dev/tests/integration/testsuite/Mage/Tax/Model/Rate/CsvImportHandlerTest.php new file mode 100644 index 0000000000000..c984c2f2918d7 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Tax/Model/Rate/CsvImportHandlerTest.php @@ -0,0 +1,77 @@ +_importHandler = Mage::getModel('Mage_Tax_Model_Rate_CsvImportHandler'); + } + + protected function tearDown() + { + $this->_importHandler = null; + } + + /** + * @magentoDbIsolation enabled + */ + public function testImportFromCsvFileWithCorrectData() + { + $importFileName = __DIR__ . DIRECTORY_SEPARATOR . '_files' + . DIRECTORY_SEPARATOR . 'correct_rates_import_file.csv'; + $this->_importHandler->importFromCsvFile(array('tmp_name' => $importFileName)); + + // assert that both tax rates, specified in import file, have been imported correctly + $importedRuleCA = Mage::getModel('Mage_Tax_Model_Calculation_Rate')->loadByCode('US-CA-*-Rate Import Test'); + $this->assertNotEmpty($importedRuleCA->getId()); + $this->assertEquals(8.25, (float)$importedRuleCA->getRate()); + $this->assertEquals('US', $importedRuleCA->getTaxCountryId()); + + $importedRuleFL = Mage::getModel('Mage_Tax_Model_Calculation_Rate')->loadByCode('US-FL-*-Rate Import Test'); + $this->assertNotEmpty($importedRuleFL->getId()); + $this->assertEquals(15, (float)$importedRuleFL->getRate()); + $this->assertEquals('US', $importedRuleFL->getTaxCountryId()); + } + + /** + * @magentoDbIsolation enabled + * @expectedException Mage_Core_Exception + * @expectedExceptionMessage One of the countries has invalid code. + */ + public function testImportFromCsvFileThrowsExceptionWhenCountryCodeIsInvalid() + { + $importFileName = __DIR__ . DIRECTORY_SEPARATOR . '_files' + . DIRECTORY_SEPARATOR . 'rates_import_file_incorrect_country.csv'; + $this->_importHandler->importFromCsvFile(array('tmp_name' => $importFileName)); + } +} diff --git a/dev/tests/integration/testsuite/Mage/Tax/Model/Rate/_files/correct_rates_import_file.csv b/dev/tests/integration/testsuite/Mage/Tax/Model/Rate/_files/correct_rates_import_file.csv new file mode 100644 index 0000000000000..2c63dc259d96d --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Tax/Model/Rate/_files/correct_rates_import_file.csv @@ -0,0 +1,3 @@ +"Code","Country","State","Zip/Post Code","Rate","Zip/Post is Range","Range From","Range To","default" +"US-CA-*-Rate Import Test","US","CA","","8.2500","","","","" +"US-FL-*-Rate Import Test","US","FL","","15.0000","","","","" diff --git a/dev/tests/integration/testsuite/Mage/Tax/Model/Rate/_files/rates_import_file_incorrect_country.csv b/dev/tests/integration/testsuite/Mage/Tax/Model/Rate/_files/rates_import_file_incorrect_country.csv new file mode 100644 index 0000000000000..c555c3f1c09fe --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Tax/Model/Rate/_files/rates_import_file_incorrect_country.csv @@ -0,0 +1,2 @@ +"Code","Country","State","Zip/Post Code","Rate","Zip/Post is Range","Range From","Range To","default" +"Wrong Rate Import Test","ZZ","FL","","15.0000","","","","" diff --git a/dev/tests/integration/testsuite/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/GeneralTest.php b/dev/tests/integration/testsuite/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/GeneralTest.php index 012dfd66cfcba..d7bc9ef9082e6 100644 --- a/dev/tests/integration/testsuite/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/GeneralTest.php +++ b/dev/tests/integration/testsuite/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/GeneralTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Theme_Block_Adminhtml_System_Design_Theme_Edit_Tab_GeneralTest extends PHPUnit_Framework_TestCase +class Mage_Theme_Block_Adminhtml_System_Design_Theme_Edit_Tab_GeneralTest extends Mage_Backend_Area_TestCase { /** @var Mage_Core_Model_Layout */ protected $_layout; @@ -38,18 +38,13 @@ class Mage_Theme_Block_Adminhtml_System_Design_Theme_Edit_Tab_GeneralTest extend protected function setUp() { + parent::setUp(); $this->_layout = Mage::getModel('Mage_Core_Model_Layout'); $this->_theme = Mage::getModel('Mage_Core_Model_Theme'); + $this->_theme->setType(Mage_Core_Model_Theme::TYPE_VIRTUAL); $this->_block = $this->_layout->createBlock('Mage_Theme_Block_Adminhtml_System_Design_Theme_Edit_Tab_General'); } - protected function tearDown() - { - $this->_theme = null; - $this->_layout = null; - $this->_block = null; - } - public function testToHtmlPreviewImageNote() { Mage::register('current_theme', $this->_theme); diff --git a/dev/tests/integration/testsuite/Mage/Theme/controllers/Adminhtml/System/Design/ThemeControllerTets.php b/dev/tests/integration/testsuite/Mage/Theme/controllers/Adminhtml/System/Design/ThemeControllerTets.php new file mode 100644 index 0000000000000..680254d8e0d09 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Theme/controllers/Adminhtml/System/Design/ThemeControllerTets.php @@ -0,0 +1,88 @@ +_filesystem = $this->_objectManager->get('Magento_Filesystem'); + $this->_dirs = $this->_objectManager->get('Mage_Core_Model_Dir'); + } + + /** + * Test upload JS file + */ + public function testUploadJsAction() + { + $_FILES = array( + 'js_files_uploader' => array( + 'name' => 'simple-js-file.js', + 'type' => 'application/x-javascript', + 'tmp_name' => $this->_prepareFileForUploading(), + 'error' => '0', + 'size' => '28' + ) + ); + + $theme = $this->_objectManager->create('Mage_Core_Model_Theme')->getCollection()->getFirstItem(); + + $this->getRequest()->setPost('id', $theme->getId()); + $this->dispatch('backend/admin/system_design_theme/uploadjs'); + $output = $this->getResponse()->getBody(); + $this->assertContains('error:false', $output); + $this->assertContains('simple-js-file.js', $output); + } + + /** + * Prepare file for uploading + * + * @return string + */ + protected function _prepareFileForUploading() + { + /** + * Copy file to writable directory. + * Uploader can copy(upload) and then remove this temporary file. + */ + $fileName = implode(DIRECTORY_SEPARATOR, array(__DIR__, '_files', 'simple-js-file.js')); + $varDir = $this->_dirs->getDir(Mage_Core_Model_Dir::VAR_DIR); + $destinationFilePath = $varDir . DIRECTORY_SEPARATOR . 'simple-js-file.js'; + + $this->_filesystem->copy($fileName, $destinationFilePath); + $this->_filesystem->has($destinationFilePath); + + return $destinationFilePath; + } +} diff --git a/dev/tests/integration/testsuite/Mage/Theme/controllers/Adminhtml/System/Design/_files/simple-js-file.js b/dev/tests/integration/testsuite/Mage/Theme/controllers/Adminhtml/System/Design/_files/simple-js-file.js new file mode 100644 index 0000000000000..875749aa55237 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Theme/controllers/Adminhtml/System/Design/_files/simple-js-file.js @@ -0,0 +1,26 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_Theme + * @subpackage integration_tests + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +alert('to be or not to be'); diff --git a/dev/tests/integration/testsuite/Mage/Usa/Block/Adminhtml/Dhl/UnitofmeasureTest.php b/dev/tests/integration/testsuite/Mage/Usa/Block/Adminhtml/Dhl/UnitofmeasureTest.php index 552e6cf4f5755..60efb17adae10 100644 --- a/dev/tests/integration/testsuite/Mage/Usa/Block/Adminhtml/Dhl/UnitofmeasureTest.php +++ b/dev/tests/integration/testsuite/Mage/Usa/Block/Adminhtml/Dhl/UnitofmeasureTest.php @@ -21,15 +21,20 @@ * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Usa_Block_Adminhtml_Dhl_UnitofmeasureTest extends PHPUnit_Framework_TestCase +class Mage_Usa_Block_Adminhtml_Dhl_UnitofmeasureTest extends Mage_Backend_Area_TestCase { /** * @magentoAppIsolation enabled */ public function testToHtml() { + Mage::getObjectManager()->configure(array( + 'Mage_Core_Model_Layout' => array( + 'parameters' => array('area' => 'adminhtml') + ) + )); /** @var $layout Mage_Core_Model_Layout */ - $layout = Mage::getSingleton('Mage_Core_Model_Layout', array('area' => 'adminhtml')); + $layout = Mage::getSingleton('Mage_Core_Model_Layout'); /** @var $block Mage_Usa_Block_Adminhtml_Dhl_Unitofmeasure */ $block = $layout->createBlock('Mage_Usa_Block_Adminhtml_Dhl_Unitofmeasure'); $this->assertNotEmpty($block->toHtml()); diff --git a/dev/tests/integration/testsuite/Mage/Usa/Model/Shipping/Carrier/UpsTest.php b/dev/tests/integration/testsuite/Mage/Usa/Model/Shipping/Carrier/UpsTest.php new file mode 100644 index 0000000000000..65cf667aa6138 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Usa/Model/Shipping/Carrier/UpsTest.php @@ -0,0 +1,60 @@ +assertEquals($object->getShipAcceptUrl(), 'https://wwwcie.ups.com/ups.app/xml/ShipAccept'); + } + + /** + * Test ship accept url for live site + * + * @magentoConfigFixture current_store carriers/ups/is_account_live 1 + */ + public function testGetShipAcceptUrlLive() + { + $object = new Mage_Usa_Model_Shipping_Carrier_Ups(); + $this->assertEquals($object->getShipAcceptUrl(), 'https://onlinetools.ups.com/ups.app/xml/ShipAccept'); + } + + public function testGetShipConfirmUrl() + { + $object = new Mage_Usa_Model_Shipping_Carrier_Ups(); + $this->assertEquals($object->getShipConfirmUrl(), 'https://wwwcie.ups.com/ups.app/xml/ShipConfirm'); + } + + /** + * Test ship accept url for live site + * + * @magentoConfigFixture current_store carriers/ups/is_account_live 1 + */ + public function testGetShipConfirmUrlLive() + { + $object = new Mage_Usa_Model_Shipping_Carrier_Ups(); + $this->assertEquals($object->getShipConfirmUrl(), 'https://onlinetools.ups.com/ups.app/xml/ShipConfirm'); + } +} diff --git a/dev/tests/integration/testsuite/Mage/User/Block/Role/Grid/UserTest.php b/dev/tests/integration/testsuite/Mage/User/Block/Role/Grid/UserTest.php index 020678bcf783c..2a2fe51c45ad5 100644 --- a/dev/tests/integration/testsuite/Mage/User/Block/Role/Grid/UserTest.php +++ b/dev/tests/integration/testsuite/Mage/User/Block/Role/Grid/UserTest.php @@ -38,11 +38,6 @@ public function setUp() $this->_block = $layout->createBlock('Mage_User_Block_Role_Grid_User'); } - protected function tearDown() - { - $this->_block= null; - } - public function testPreparedCollection() { $this->_block->toHtml(); diff --git a/dev/tests/integration/testsuite/Mage/User/Block/Role/Tab/EditTest.php b/dev/tests/integration/testsuite/Mage/User/Block/Role/Tab/EditTest.php index d34b85286ef6b..9d0c79b6ff2b9 100644 --- a/dev/tests/integration/testsuite/Mage/User/Block/Role/Tab/EditTest.php +++ b/dev/tests/integration/testsuite/Mage/User/Block/Role/Tab/EditTest.php @@ -43,11 +43,6 @@ public function setUp() $this->_block = Mage::getObjectManager()->create('Mage_User_Block_Role_Tab_Edit'); } - protected function tearDown() - { - $this->_block = null; - } - public function testConstructor() { $this->assertNotEmpty($this->_block->getSelectedResources()); diff --git a/dev/tests/integration/testsuite/Mage/User/Helper/DataTest.php b/dev/tests/integration/testsuite/Mage/User/Helper/DataTest.php index 9c5c7b7957588..e06ad0ad0895a 100644 --- a/dev/tests/integration/testsuite/Mage/User/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Mage/User/Helper/DataTest.php @@ -38,11 +38,6 @@ protected function setUp() $this->_helper = Mage::helper('Mage_User_Helper_Data'); } - protected function tearDown() - { - $this->_helper = null; - } - /** * Test generate unique token for reset password confirmation link * diff --git a/dev/tests/integration/testsuite/Mage/User/Model/Resource/Role/CollectionTest.php b/dev/tests/integration/testsuite/Mage/User/Model/Resource/Role/CollectionTest.php index d4755bcfc0625..5559ca3e02d5e 100644 --- a/dev/tests/integration/testsuite/Mage/User/Model/Resource/Role/CollectionTest.php +++ b/dev/tests/integration/testsuite/Mage/User/Model/Resource/Role/CollectionTest.php @@ -39,11 +39,6 @@ protected function setUp() $this->_collection = Mage::getResourceModel('Mage_User_Model_Resource_Role_Collection'); } - protected function tearDown() - { - $this->_collection = null; - } - public function testSetUserFilter() { $user = Mage::getModel('Mage_User_Model_User'); diff --git a/dev/tests/integration/testsuite/Mage/User/Model/Resource/Role/User/CollectionTest.php b/dev/tests/integration/testsuite/Mage/User/Model/Resource/Role/User/CollectionTest.php index d109018ba69d7..827472864e3ef 100644 --- a/dev/tests/integration/testsuite/Mage/User/Model/Resource/Role/User/CollectionTest.php +++ b/dev/tests/integration/testsuite/Mage/User/Model/Resource/Role/User/CollectionTest.php @@ -39,11 +39,6 @@ protected function setUp() $this->_collection = Mage::getResourceModel('Mage_User_Model_Resource_Role_User_Collection'); } - protected function tearDown() - { - $this->_collection = null; - } - public function testSelectQueryInitialized() { $this->assertContains('user_id > 0', $this->_collection->getSelect()->__toString()); diff --git a/dev/tests/integration/testsuite/Mage/User/Model/Resource/Rules/CollectionTest.php b/dev/tests/integration/testsuite/Mage/User/Model/Resource/Rules/CollectionTest.php index c4f91a4d59570..cb49735613668 100644 --- a/dev/tests/integration/testsuite/Mage/User/Model/Resource/Rules/CollectionTest.php +++ b/dev/tests/integration/testsuite/Mage/User/Model/Resource/Rules/CollectionTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_collection = Mage::getResourceModel('Mage_User_Model_Resource_Rules_Collection'); } - protected function tearDown() - { - $this->_collection = null; - } - public function testGetByRoles() { $user = Mage::getModel('Mage_User_Model_User'); diff --git a/dev/tests/integration/testsuite/Mage/User/Model/Resource/UserTest.php b/dev/tests/integration/testsuite/Mage/User/Model/Resource/UserTest.php index d11ea5a35f40f..6ad2ae3ba96f8 100644 --- a/dev/tests/integration/testsuite/Mage/User/Model/Resource/UserTest.php +++ b/dev/tests/integration/testsuite/Mage/User/Model/Resource/UserTest.php @@ -31,11 +31,6 @@ protected function setUp() $this->_model = Mage::getResourceSingleton('Mage_User_Model_Resource_User'); } - protected function tearDown() - { - $this->_model = null; - } - /** * No node - no limitation */ diff --git a/dev/tests/integration/testsuite/Mage/User/Model/RoleTest.php b/dev/tests/integration/testsuite/Mage/User/Model/RoleTest.php index 2f7f53865519f..8214d40eadb7c 100644 --- a/dev/tests/integration/testsuite/Mage/User/Model/RoleTest.php +++ b/dev/tests/integration/testsuite/Mage/User/Model/RoleTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_User_Model_Role'); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetUsersCollection() { $this->assertInstanceOf('Mage_User_Model_Resource_Role_User_Collection', $this->_model->getUsersCollection()); diff --git a/dev/tests/integration/testsuite/Mage/User/Model/RulesTest.php b/dev/tests/integration/testsuite/Mage/User/Model/RulesTest.php index 669e46876b49a..aad570d1f57a6 100644 --- a/dev/tests/integration/testsuite/Mage/User/Model/RulesTest.php +++ b/dev/tests/integration/testsuite/Mage/User/Model/RulesTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_User_Model_Rules'); } - protected function tearDown() - { - $this->_model = null; - } - /** * @magentoDbIsolation enabled */ diff --git a/dev/tests/integration/testsuite/Mage/User/Model/UserTest.php b/dev/tests/integration/testsuite/Mage/User/Model/UserTest.php index da5972c76100e..1710076d2cf77 100644 --- a/dev/tests/integration/testsuite/Mage/User/Model/UserTest.php +++ b/dev/tests/integration/testsuite/Mage/User/Model/UserTest.php @@ -42,11 +42,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_User_Model_User'); } - protected function tearDown() - { - $this->_model = null; - } - /** * @magentoDbIsolation enabled */ diff --git a/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/FormTestAbstract.php b/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/FormTestAbstract.php index 4422ea3538490..4dcb070e91b8e 100644 --- a/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/FormTestAbstract.php +++ b/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/FormTestAbstract.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Webapi_Block_Adminhtml_FormTestAbstract extends PHPUnit_Framework_TestCase +class Mage_Webapi_Block_Adminhtml_FormTestAbstract extends Mage_Backend_Area_TestCase { /** * Form class must be defined in children. @@ -59,6 +59,7 @@ class Mage_Webapi_Block_Adminhtml_FormTestAbstract extends PHPUnit_Framework_Tes protected function setUp() { + parent::setUp(); $this->_objectManager = Mage::getObjectManager(); $this->_urlBuilder = $this->getMockBuilder('Mage_Backend_Model_Url') ->disableOriginalConstructor() @@ -66,7 +67,7 @@ protected function setUp() $this->_layout = $this->_objectManager->get('Mage_Core_Model_Layout'); $this->_blockFactory = $this->_objectManager->get('Mage_Core_Model_BlockFactory'); $this->_block = $this->_blockFactory->createBlock($this->_formClass, array( - 'urlBuilder' => $this->_urlBuilder + 'context' => Mage::getModel('Mage_Core_Block_Template_Context', array('urlBuilder' => $this->_urlBuilder)) )); $this->_layout->addBlock($this->_block); } diff --git a/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/Role/Edit/Tab/MainTest.php b/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/Role/Edit/Tab/MainTest.php index 4af05990574bb..73bf3086da039 100644 --- a/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/Role/Edit/Tab/MainTest.php +++ b/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/Role/Edit/Tab/MainTest.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Webapi_Block_Adminhtml_Role_Edit_Tab_MainTest extends PHPUnit_Framework_TestCase +class Mage_Webapi_Block_Adminhtml_Role_Edit_Tab_MainTest extends Mage_Backend_Area_TestCase { /** * @var Magento_Test_ObjectManager @@ -47,6 +47,8 @@ class Mage_Webapi_Block_Adminhtml_Role_Edit_Tab_MainTest extends PHPUnit_Framewo protected function setUp() { + parent::setUp(); + $this->_objectManager = Mage::getObjectManager(); $this->_layout = $this->_objectManager->get('Mage_Core_Model_Layout'); $this->_blockFactory = $this->_objectManager->get('Mage_Core_Model_BlockFactory'); diff --git a/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/Role/Edit/Tab/ResourceTest.php b/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/Role/Edit/Tab/ResourceTest.php index 76d918f3ea21d..674717acacdc2 100644 --- a/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/Role/Edit/Tab/ResourceTest.php +++ b/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/Role/Edit/Tab/ResourceTest.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Webapi_Block_Adminhtml_Role_Edit_Tab_ResourceTest extends PHPUnit_Framework_TestCase +class Mage_Webapi_Block_Adminhtml_Role_Edit_Tab_ResourceTest extends Mage_Backend_Area_TestCase { /** * @var Magento_Test_ObjectManager @@ -57,6 +57,8 @@ class Mage_Webapi_Block_Adminhtml_Role_Edit_Tab_ResourceTest extends PHPUnit_Fra protected function setUp() { + parent::setUp(); + $this->_authorizationConfig = $this->getMockBuilder('Mage_Webapi_Model_Authorization_Config') ->disableOriginalConstructor() ->setMethods(array('getAclResourcesAsArray')) diff --git a/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/User/Edit/Tab/MainTest.php b/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/User/Edit/Tab/MainTest.php index 0df9ce33c94dc..719ad2bf0b965 100644 --- a/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/User/Edit/Tab/MainTest.php +++ b/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/User/Edit/Tab/MainTest.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Webapi_Block_Adminhtml_User_Edit_Tab_MainTest extends PHPUnit_Framework_TestCase +class Mage_Webapi_Block_Adminhtml_User_Edit_Tab_MainTest extends Mage_Backend_Area_TestCase { /** * @var Magento_Test_ObjectManager @@ -47,6 +47,8 @@ class Mage_Webapi_Block_Adminhtml_User_Edit_Tab_MainTest extends PHPUnit_Framewo protected function setUp() { + parent::setUp(); + $this->_objectManager = Mage::getObjectManager(); $this->_layout = $this->_objectManager->get('Mage_Core_Model_Layout'); $this->_blockFactory = $this->_objectManager->get('Mage_Core_Model_BlockFactory'); diff --git a/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/User/Edit/TabsTest.php b/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/User/Edit/TabsTest.php index d07cb7f778c65..c1b5022ea0577 100644 --- a/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/User/Edit/TabsTest.php +++ b/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/User/Edit/TabsTest.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Webapi_Block_Adminhtml_User_Edit_TabsTest extends PHPUnit_Framework_TestCase +class Mage_Webapi_Block_Adminhtml_User_Edit_TabsTest extends Mage_Backend_Area_TestCase { /** * @var Magento_Test_ObjectManager @@ -42,6 +42,8 @@ class Mage_Webapi_Block_Adminhtml_User_Edit_TabsTest extends PHPUnit_Framework_T protected function setUp() { + parent::setUp(); + $this->_objectManager = Mage::getObjectManager(); $this->_layout = $this->_objectManager->get('Mage_Core_Model_Layout'); $this->_block = $this->_layout->createBlock('Mage_Webapi_Block_Adminhtml_User_Edit_Tabs', diff --git a/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/User/EditTest.php b/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/User/EditTest.php index a98babbaa951b..42c0d3d5936c1 100644 --- a/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/User/EditTest.php +++ b/dev/tests/integration/testsuite/Mage/Webapi/Block/Adminhtml/User/EditTest.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Webapi_Block_Adminhtml_User_EditTest extends PHPUnit_Framework_TestCase +class Mage_Webapi_Block_Adminhtml_User_EditTest extends Mage_Backend_Area_TestCase { /** * @var Magento_Test_ObjectManager @@ -45,19 +45,13 @@ class Mage_Webapi_Block_Adminhtml_User_EditTest extends PHPUnit_Framework_TestCa */ protected function setUp() { + parent::setUp(); + $this->_objectManager = Mage::getObjectManager(); $this->_layout = Mage::getObjectManager()->get('Mage_Core_Model_Layout'); $this->_block = $this->_layout->createBlock('Mage_Webapi_Block_Adminhtml_User_Edit'); } - /** - * Clear block. - */ - protected function tearDown() - { - unset($this->_objectManager, $this->_layout, $this->_block); - } - /** * Test _beforeToHtml method. */ diff --git a/dev/tests/integration/testsuite/Mage/Webapi/Helper/DataTest.php b/dev/tests/integration/testsuite/Mage/Webapi/Helper/DataTest.php index f8e6b43ac7dab..46b0a5b38b7f0 100644 --- a/dev/tests/integration/testsuite/Mage/Webapi/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Mage/Webapi/Helper/DataTest.php @@ -42,41 +42,24 @@ class Mage_Webapi_Helper_DataTest extends PHPUnit_Framework_TestCase protected $_helper; /** @var Mage_Webapi_Model_ConfigAbstract */ - protected static $_apiConfig; + protected $_apiConfig; protected function setUp() { $this->_helper = Mage::getObjectManager()->get('Mage_Webapi_Helper_Data'); - parent::setUp(); - } - - /** - * @return Mage_Webapi_Model_ConfigAbstract - */ - protected function _getApiConfig() - { - if (!self::$_apiConfig) { - $objectManager = Mage::getObjectManager(); - /** Prepare arguments for SUT constructor. */ - $pathToFixtures = __DIR__ . '/../_files/autodiscovery'; - /** @var Mage_Webapi_Model_Config_Reader_Soap $reader */ - $reader = $objectManager->get( - 'Mage_Webapi_Model_Config_Reader_Soap', - array( - 'cache' => $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false) - ) - ); - $reader->setDirectoryScanner(new Zend\Code\Scanner\DirectoryScanner($pathToFixtures)); - /** Initialize SUT. */ - self::$_apiConfig = $objectManager->create('Mage_Webapi_Model_Config_Soap', array('reader' => $reader)); - } - return self::$_apiConfig; - } - - public static function tearDownAfterClass() - { - self::$_apiConfig = null; - parent::tearDownAfterClass(); + $objectManager = Mage::getObjectManager(); + /** Prepare arguments for SUT constructor. */ + $pathToFixtures = __DIR__ . '/../_files/autodiscovery'; + /** @var Mage_Webapi_Model_Config_Reader_Soap $reader */ + $reader = $objectManager->create( + 'Mage_Webapi_Model_Config_Reader_Soap', + array( + 'cache' => $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false) + ) + ); + $reader->setDirectoryScanner(new Zend\Code\Scanner\DirectoryScanner($pathToFixtures)); + /** Initialize SUT. */ + $this->_apiConfig = $objectManager->create('Mage_Webapi_Model_Config_Soap', array('reader' => $reader)); } /** @@ -92,7 +75,7 @@ public function testPrepareMethodParamsPositive( $requestData, $expectedResult = array() ) { - $actualResult = $this->_helper->prepareMethodParams($class, $methodName, $requestData, $this->_getApiConfig()); + $actualResult = $this->_helper->prepareMethodParams($class, $methodName, $requestData, $this->_apiConfig); $this->assertEquals($expectedResult, $actualResult, "The array of arguments was prepared incorrectly."); } @@ -183,7 +166,7 @@ public function testPrepareMethodParamsArrayExpectedException() 'Vendor_Module_Controller_Webapi_Resource_Subresource', 'createV1', array('param1' => 1, 'param2' => 2, 'param3' => 'not_array', 'param4' => 4), - $this->_getApiConfig() + $this->_apiConfig ); } @@ -201,7 +184,7 @@ public function testPrepareMethodParamsComplexTypeArrayExpectedException() 'Vendor_Module_Controller_Webapi_Resource_Subresource', 'updateV1', array('param1' => 1, 'param2' => 'Non array complex data'), - $this->_getApiConfig() + $this->_apiConfig ); } @@ -221,7 +204,7 @@ public function testPrepareMethodParamsNegative( $exceptionMessage ) { $this->setExpectedException($exceptionClass, $exceptionMessage); - $this->_helper->prepareMethodParams($class, $methodName, $requestData, $this->_getApiConfig()); + $this->_helper->prepareMethodParams($class, $methodName, $requestData, $this->_apiConfig); } public static function dataProviderForTestPrepareMethodParamsNegative() diff --git a/dev/tests/integration/testsuite/Mage/Webapi/Model/Acl/RoleTest.php b/dev/tests/integration/testsuite/Mage/Webapi/Model/Acl/RoleTest.php index a491dd257cee7..e0aac7cb24d64 100644 --- a/dev/tests/integration/testsuite/Mage/Webapi/Model/Acl/RoleTest.php +++ b/dev/tests/integration/testsuite/Mage/Webapi/Model/Acl/RoleTest.php @@ -45,14 +45,6 @@ protected function setUp() $this->_model = $this->_objectManager->create('Mage_Webapi_Model_Acl_Role'); } - /** - * Cleanup model instance. - */ - protected function tearDown() - { - unset($this->_objectManager, $this->_model); - } - /** * Test Web API Role CRUD. */ diff --git a/dev/tests/integration/testsuite/Mage/Webapi/Model/Acl/RuleTest.php b/dev/tests/integration/testsuite/Mage/Webapi/Model/Acl/RuleTest.php index b10fb7f3cd0ca..322d0f38f2df0 100644 --- a/dev/tests/integration/testsuite/Mage/Webapi/Model/Acl/RuleTest.php +++ b/dev/tests/integration/testsuite/Mage/Webapi/Model/Acl/RuleTest.php @@ -48,14 +48,6 @@ protected function setUp() $this->_model = $this->_objectManager->create('Mage_Webapi_Model_Acl_Rule'); } - /** - * Cleanup model instance. - */ - protected function tearDown() - { - unset($this->_objectManager, $this->_model); - } - /** * Test Web API Role CRUD. */ diff --git a/dev/tests/integration/testsuite/Mage/Webapi/Model/Acl/UserTest.php b/dev/tests/integration/testsuite/Mage/Webapi/Model/Acl/UserTest.php index c347ebb66c554..e9141b63a3d6e 100644 --- a/dev/tests/integration/testsuite/Mage/Webapi/Model/Acl/UserTest.php +++ b/dev/tests/integration/testsuite/Mage/Webapi/Model/Acl/UserTest.php @@ -51,14 +51,6 @@ protected function setUp() $this->_model = $this->_objectManager->create('Mage_Webapi_Model_Acl_User'); } - /** - * Cleanup model instance. - */ - protected function tearDown() - { - unset($this->_objectManager, $this->_model); - } - /** * Test Web API User CRUD. */ diff --git a/dev/tests/integration/testsuite/Mage/Webapi/Model/Config/Reader/Rest/RouteGeneratorTest.php b/dev/tests/integration/testsuite/Mage/Webapi/Model/Config/Reader/Rest/RouteGeneratorTest.php index 7a40b108e9abe..d063ee74e94bc 100644 --- a/dev/tests/integration/testsuite/Mage/Webapi/Model/Config/Reader/Rest/RouteGeneratorTest.php +++ b/dev/tests/integration/testsuite/Mage/Webapi/Model/Config/Reader/Rest/RouteGeneratorTest.php @@ -46,7 +46,7 @@ protected function setUp() $helper = $this->getMock( 'Mage_Webapi_Helper_Config', array('__'), - array(Mage::getObjectManager()->get('Mage_Core_Model_Translate')) + array(Mage::getObjectManager()->get('Mage_Core_Helper_Context')) ); $this->_model = new Mage_Webapi_Model_Config_Reader_Rest_RouteGenerator($helper); } diff --git a/dev/tests/integration/testsuite/Mage/Webapi/Model/Config/RestTest.php b/dev/tests/integration/testsuite/Mage/Webapi/Model/Config/RestTest.php index 11fef66ce4fb4..0ecbce8012277 100644 --- a/dev/tests/integration/testsuite/Mage/Webapi/Model/Config/RestTest.php +++ b/dev/tests/integration/testsuite/Mage/Webapi/Model/Config/RestTest.php @@ -46,32 +46,19 @@ class Mage_Webapi_Model_Config_RestTest extends PHPUnit_Framework_TestCase /** * @var Mage_Webapi_Model_Config_Rest */ - protected static $_apiConfig; + protected $_apiConfig; /** * App mock clone usage helps to improve performance. It is required because mock will be removed in tear down. * * @var Mage_Core_Model_App */ - protected static $_appClone; + protected $_appClone; - public static function tearDownAfterClass() + protected function setUp() { - self::$_apiConfig = null; - self::$_appClone = null; - parent::tearDownAfterClass(); - } - - /** - * @return Mage_Webapi_Model_Config_Rest - */ - protected function _getModel() - { - if (!self::$_apiConfig) { - $pathToFixtures = __DIR__ . '/../../_files/autodiscovery'; - self::$_apiConfig = $this->_createResourceConfig($pathToFixtures); - } - return self::$_apiConfig; + $pathToFixtures = __DIR__ . '/../../_files/autodiscovery'; + $this->_apiConfig = $this->_createResourceConfig($pathToFixtures); } public function testGetAllResourcesVersions() @@ -80,7 +67,7 @@ public function testGetAllResourcesVersions() 'vendorModuleResource' => array('V1', 'V2', 'V3', 'V4', 'V5'), 'vendorModuleResourceSubresource' => array('V1', 'V2', 'V4') ); - $allResourcesVersions = $this->_getModel()->getAllResourcesVersions(); + $allResourcesVersions = $this->_apiConfig->getAllResourcesVersions(); $this->assertEquals($expectedResult, $allResourcesVersions, "The list of all resources versions is incorrect."); } @@ -90,7 +77,7 @@ public function testGetMethodMetadataDataNotAvailable() 'InvalidArgumentException', 'The "update" method of "vendorModuleInvalidInterface" resource in version "V2" is not registered.' ); - $this->_getModel()->getMethodMetadata( + $this->_apiConfig->getMethodMetadata( $this->_createMethodReflection( 'Vendor_Module_Controller_Webapi_Invalid_Interface', 'updateV2' @@ -100,7 +87,7 @@ public function testGetMethodMetadataDataNotAvailable() public function testGetRestRoutes() { - $actualRoutes = $this->_getModel()->getAllRestRoutes(); + $actualRoutes = $this->_apiConfig->getAllRestRoutes(); $expectedRoutesCount = 16; /** @@ -126,7 +113,7 @@ public function testGetRestRoutes() public function testGetRestRouteToItem() { $expectedRoute = '/:resourceVersion/vendorModuleResources/subresources/:id'; - $this->assertEquals($expectedRoute, $this->_getModel()->getRestRouteToItem('vendorModuleResourceSubresource')); + $this->assertEquals($expectedRoute, $this->_apiConfig->getRestRouteToItem('vendorModuleResourceSubresource')); } public function testGetRestRouteToItemInvalidArguments() @@ -136,12 +123,12 @@ public function testGetRestRouteToItemInvalidArguments() 'InvalidArgumentException', sprintf('No route to the item of "%s" resource was found.', $resourceName) ); - $this->_getModel()->getRestRouteToItem($resourceName); + $this->_apiConfig->getRestRouteToItem($resourceName); } public function testGetMethodRestRoutes() { - $actualRoutes = $this->_getModel()->getMethodRestRoutes('vendorModuleResourceSubresource', 'create', 'v1'); + $actualRoutes = $this->_apiConfig->getMethodRestRoutes('vendorModuleResourceSubresource', 'create', 'v1'); $this->assertCount(5, $actualRoutes, "Routes quantity does not match expected one."); foreach ($actualRoutes as $actualRoute) { $this->assertInstanceOf('Mage_Webapi_Controller_Router_Route_Rest', $actualRoute); @@ -156,7 +143,7 @@ public function testGetMethodRestRoutesException() 'InvalidArgumentException', sprintf('"%s" resource does not have any REST routes for "%s" method.', $resourceName, $methodName) ); - $this->_getModel()->getMethodRestRoutes($resourceName, $methodName, 'v1'); + $this->_apiConfig->getMethodRestRoutes($resourceName, $methodName, 'v1'); } /** @@ -169,23 +156,30 @@ protected function _createResourceConfig($pathToResources) { $objectManager = Mage::getObjectManager(); /** Prepare arguments for SUT constructor. */ - /** @var Mage_Core_Model_Cache $cache */ - $cache = $this->getMockBuilder('Mage_Core_Model_Cache')->disableOriginalConstructor()->getMock(); + /** @var Mage_Core_Model_CacheInterface $cache */ + $cache = $this->getMock('Mage_Core_Model_CacheInterface'); $configMock = $this->getMockBuilder('Mage_Core_Model_Config')->disableOriginalConstructor()->getMock(); $configMock->expects($this->any())->method('getAreaFrontName')->will( $this->returnValue(self::WEBAPI_AREA_FRONT_NAME) ); $appMock = $this->getMockBuilder('Mage_Core_Model_App')->disableOriginalConstructor()->getMock(); $appMock->expects($this->any())->method('getConfig')->will($this->returnValue($configMock)); - self::$_appClone = clone $appMock; + $this->_appClone = clone $appMock; + $objectManager->configure(array( + 'Mage_Webapi_Model_Config_Reader_Rest' => array( + 'parameters' => array( + 'cache' => $cache + ) + ) + )); /** @var Mage_Webapi_Model_Config_Reader_Rest $reader */ - $reader = $objectManager->get('Mage_Webapi_Model_Config_Reader_Rest', array('cache' => $cache)); + $reader = $objectManager->get('Mage_Webapi_Model_Config_Reader_Rest'); $reader->setDirectoryScanner(new Zend\Code\Scanner\DirectoryScanner($pathToResources)); /** Initialize SUT. */ $apiConfig = $objectManager->create( 'Mage_Webapi_Model_Config_Rest', - array('reader' => $reader, 'application' => self::$_appClone) + array('reader' => $reader, 'application' => $this->_appClone) ); return $apiConfig; } diff --git a/dev/tests/integration/testsuite/Mage/Webapi/Model/Config/Soap/DataTest.php b/dev/tests/integration/testsuite/Mage/Webapi/Model/Config/Soap/DataTest.php index dde8592d4ef5b..42f9ab4d9d523 100644 --- a/dev/tests/integration/testsuite/Mage/Webapi/Model/Config/Soap/DataTest.php +++ b/dev/tests/integration/testsuite/Mage/Webapi/Model/Config/Soap/DataTest.php @@ -50,8 +50,8 @@ protected function setUp() { $fixtureDir = __DIR__ . '/../../../_files/Controller/Webapi/'; $directoryScanner = new \Zend\Code\Scanner\DirectoryScanner($fixtureDir); - /** @var Mage_Core_Model_Cache $cache */ - $cache = $this->getMockBuilder('Mage_Core_Model_Cache')->disableOriginalConstructor()->getMock(); + /** @var Mage_Core_Model_CacheInterface $cache */ + $cache = $this->getMock('Mage_Core_Model_CacheInterface'); /** @var Mage_Core_Model_App $app */ $app = $this->getMockBuilder('Mage_Core_Model_App')->disableOriginalConstructor()->getMock(); $appConfig = Mage::app()->getConfig(); diff --git a/dev/tests/integration/testsuite/Mage/Webapi/Model/Config/SoapTest.php b/dev/tests/integration/testsuite/Mage/Webapi/Model/Config/SoapTest.php index f5dfec47c8464..28d37ab13efb1 100644 --- a/dev/tests/integration/testsuite/Mage/Webapi/Model/Config/SoapTest.php +++ b/dev/tests/integration/testsuite/Mage/Webapi/Model/Config/SoapTest.php @@ -49,24 +49,12 @@ class Mage_Webapi_Model_Config_SoapTest extends PHPUnit_Framework_TestCase /** * @var Mage_Webapi_Model_Config_Soap */ - protected static $_apiConfig; + protected $_apiConfig; - public static function tearDownAfterClass() + protected function setUp() { - self::$_apiConfig = null; - parent::tearDownAfterClass(); - } - - /** - * @return Mage_Webapi_Model_Config_Soap - */ - protected function _getModel() - { - if (!self::$_apiConfig) { - $pathToFixtures = __DIR__ . '/../../_files/autodiscovery'; - self::$_apiConfig = $this->_createResourceConfig($pathToFixtures); - } - return self::$_apiConfig; + $pathToFixtures = __DIR__ . '/../../_files/autodiscovery'; + $this->_apiConfig = $this->_createResourceConfig($pathToFixtures); } /** @@ -82,7 +70,7 @@ public function testGetResourceNameByOperationPositive( $expectedResourceName, $message = 'Resource name was identified incorrectly by given operation.' ) { - $actualResourceName = $this->_getModel()->getResourceNameByOperation($operation, $resourceVersion); + $actualResourceName = $this->_apiConfig->getResourceNameByOperation($operation, $resourceVersion); $this->assertEquals($expectedResourceName, $actualResourceName, $message); } @@ -130,7 +118,7 @@ public function testGetResourceNameByOperationNegative( $expectedResourceName, $message = 'Resource name was identified incorrectly by given operation.' ) { - $actualResourceName = $this->_getModel()->getResourceNameByOperation($operation, $resourceVersion); + $actualResourceName = $this->_apiConfig->getResourceNameByOperation($operation, $resourceVersion); $this->assertEquals($expectedResourceName, $actualResourceName, $message); } @@ -158,7 +146,7 @@ public function testGetResourceNameByOperationException($operation, $resourceVer 'InvalidArgumentException', sprintf('The "%s" is not a valid API resource operation name.', $operation) ); - $this->_getModel()->getResourceNameByOperation($operation, $resourceVersion); + $this->_apiConfig->getResourceNameByOperation($operation, $resourceVersion); } public function dataProviderTestGetResourceNameByOperationException() @@ -182,7 +170,7 @@ public function testGetMethodNameByOperation( $expectedResourceName, $message = 'Resource name was identified incorrectly by given operation.' ) { - $actualResourceName = $this->_getModel()->getMethodNameByOperation($operation, $resourceVersion); + $actualResourceName = $this->_apiConfig->getMethodNameByOperation($operation, $resourceVersion); $this->assertEquals($expectedResourceName, $actualResourceName, $message); } @@ -222,7 +210,7 @@ public function testGetMethodNameByOperationException($operation, $resourceVersi 'InvalidArgumentException', sprintf('The "%s" is not a valid API resource operation name.', $operation) ); - $this->_getModel()->getMethodNameByOperation($operation, $resourceVersion); + $this->_apiConfig->getMethodNameByOperation($operation, $resourceVersion); } public function dataProviderTestGetMethodNameByOperationException() @@ -235,7 +223,7 @@ public function dataProviderTestGetMethodNameByOperationException() public function testGetControllerClassByOperationNamePositive() { - $actualController = $this->_getModel()->getControllerClassByOperationName('vendorModuleResourceList'); + $actualController = $this->_apiConfig->getControllerClassByOperationName('vendorModuleResourceList'); $message = 'Controller class was identified incorrectly by given operation.'; $this->assertEquals('Vendor_Module_Controller_Webapi_Resource', $actualController, $message); } @@ -250,7 +238,7 @@ public function testGetControllerClassByOperationNameNegative($operation) 'InvalidArgumentException', sprintf('The "%s" is not a valid API resource operation name.', $operation) ); - $this->_getModel()->getControllerClassByOperationName($operation); + $this->_apiConfig->getControllerClassByOperationName($operation); } public function dataProviderTestGetControllerClassByOperationNameNegative() @@ -267,7 +255,7 @@ public function testGetControllerClassByOperationNameWithException() 'LogicException', 'Resource "resourceWithoutControllerAndModule" must have associated controller class.' ); - $this->_getModel()->getControllerClassByOperationName('resourceWithoutControllerAndModuleGet'); + $this->_apiConfig->getControllerClassByOperationName('resourceWithoutControllerAndModuleGet'); } /** @@ -279,7 +267,7 @@ public function testGetResourceMaxVersion($resourceName, $expectedMaxVersion) { $this->assertEquals( $expectedMaxVersion, - $this->_getModel()->getResourceMaxVersion($resourceName), + $this->_apiConfig->getResourceMaxVersion($resourceName), "Resource maximum available version was identified incorrectly." ); } @@ -299,12 +287,12 @@ public function testGetResourceMaxVersionException() 'InvalidArgumentException', sprintf('Resource "%s" does not exist.', $resourceName) ); - $this->_getModel()->getResourceMaxVersion($resourceName); + $this->_apiConfig->getResourceMaxVersion($resourceName); } public function testGetResource() { - $resourceData = $this->_getModel()->getResourceDataMerged('vendorModuleResource', 'v1'); + $resourceData = $this->_apiConfig->getResourceDataMerged('vendorModuleResource', 'v1'); $this->assertTrue(isset($resourceData['methods']['create']), "Information about methods is not available."); $this->assertTrue( isset($resourceData['methods']['create']['interface']['in']['parameters']['requiredField']), @@ -319,18 +307,18 @@ public function testGetResource() public function testGetResourceInvalidResourceName() { $this->setExpectedException('RuntimeException', 'Unknown resource "invalidResource".'); - $this->_getModel()->getResourceDataMerged('invalidResource', 'v1'); + $this->_apiConfig->getResourceDataMerged('invalidResource', 'v1'); } public function testGetResourceInvalidVersion() { $this->setExpectedException('RuntimeException', 'Unknown version "V100" for resource "vendorModuleResource".'); - $this->_getModel()->getResourceDataMerged('vendorModuleResource', 'v100'); + $this->_apiConfig->getResourceDataMerged('vendorModuleResource', 'v100'); } public function testGetTypeData() { - $actualDataType = $this->_getModel()->getTypeData('VendorModuleCustomerAddressData'); + $actualDataType = $this->_apiConfig->getTypeData('VendorModuleCustomerAddressData'); $expectedDataType = array( 'documentation' => 'Tests fixture for Auto Discovery functionality. Customer address entity.', 'parameters' => array( @@ -363,7 +351,7 @@ public function testGetTypeDataInvalidName() 'InvalidArgumentException', 'Data type "InvalidDataTypeName" was not found in config.' ); - $this->_getModel()->getTypeData('InvalidDataTypeName'); + $this->_apiConfig->getTypeData('InvalidDataTypeName'); } public function testGetAllResourcesVersions() @@ -372,7 +360,7 @@ public function testGetAllResourcesVersions() 'vendorModuleResource' => array('V1', 'V2', 'V3', 'V4', 'V5'), 'vendorModuleResourceSubresource' => array('V1', 'V2', 'V4') ); - $allResourcesVersions = $this->_getModel()->getAllResourcesVersions(); + $allResourcesVersions = $this->_apiConfig->getAllResourcesVersions(); $this->assertEquals($expectedResult, $allResourcesVersions, "The list of all resources versions is incorrect."); } @@ -382,7 +370,7 @@ public function testGetMethodMetadataDataNotAvailable() 'InvalidArgumentException', 'The "update" method of "vendorModuleInvalidInterface" resource in version "V2" is not registered.' ); - $this->_getModel()->getMethodMetadata( + $this->_apiConfig->getMethodMetadata( $this->_createMethodReflection( 'Vendor_Module_Controller_Webapi_Invalid_Interface', 'updateV2' @@ -444,7 +432,7 @@ public function testExtractDataInvalidDeprecationPolicy() */ public function testGetDeprecationPolicy($resource, $method, $version, $expectedResult, $deprecationFormat) { - $actualResult = $this->_getModel()->getDeprecationPolicy($resource, $method, $version); + $actualResult = $this->_apiConfig->getDeprecationPolicy($resource, $method, $version); $this->assertEquals( $expectedResult, $actualResult, @@ -523,7 +511,7 @@ public static function dataProviderForTestGetDeprecationPolicy() public function testGetDeprecationPolicyException($resource, $method, $version, $expectedMessage) { $this->setExpectedException('InvalidArgumentException', $expectedMessage); - $this->_getModel()->getDeprecationPolicy($resource, $method, $version); + $this->_apiConfig->getDeprecationPolicy($resource, $method, $version); } public static function dataProviderForTestGetDeprecationPolicyException() @@ -550,10 +538,13 @@ protected function _createResourceConfig($pathToResources) { $objectManager = Mage::getObjectManager(); /** Prepare arguments for SUT constructor. */ - /** @var Mage_Core_Model_Cache $cache */ - $cache = $this->getMockBuilder('Mage_Core_Model_Cache')->disableOriginalConstructor()->getMock(); + /** @var Mage_Core_Model_CacheInterface $cache */ + $cache = $this->getMock('Mage_Core_Model_CacheInterface'); + /** @var Mage_Webapi_Model_Config_Reader_Soap $reader */ - $reader = $objectManager->get('Mage_Webapi_Model_Config_Reader_Soap', array('cache' => $cache)); + $reader = $objectManager->create('Mage_Webapi_Model_Config_Reader_Soap', array( + 'cache' => $cache + )); $reader->setDirectoryScanner(new Zend\Code\Scanner\DirectoryScanner($pathToResources)); /** Initialize SUT. */ diff --git a/dev/tests/integration/testsuite/Mage/Webapi/Model/Resource/Acl/RuleTest.php b/dev/tests/integration/testsuite/Mage/Webapi/Model/Resource/Acl/RuleTest.php index d16419e7e657c..9c559c9b9458c 100644 --- a/dev/tests/integration/testsuite/Mage/Webapi/Model/Resource/Acl/RuleTest.php +++ b/dev/tests/integration/testsuite/Mage/Webapi/Model/Resource/Acl/RuleTest.php @@ -43,11 +43,6 @@ protected function setUp() $this->_ruleResource = $this->_objectManager->get('Mage_Webapi_Model_Resource_Acl_Rule'); } - protected function tearDown() - { - unset($this->_objectManager, $this->_ruleResource); - } - /** * Test for Mage_Webapi_Model_Resource_Acl_Role::getRolesIds(). */ diff --git a/dev/tests/integration/testsuite/Mage/Webapi/Model/Soap/AutoDiscoverTest.php b/dev/tests/integration/testsuite/Mage/Webapi/Model/Soap/AutoDiscoverTest.php index f5c96eb0a5b21..e0cb2d5101f69 100644 --- a/dev/tests/integration/testsuite/Mage/Webapi/Model/Soap/AutoDiscoverTest.php +++ b/dev/tests/integration/testsuite/Mage/Webapi/Model/Soap/AutoDiscoverTest.php @@ -87,17 +87,17 @@ protected function setUp() $app = $this->getMockBuilder('Mage_Core_Model_App')->disableOriginalConstructor()->getMock(); $objectManager = Mage::getObjectManager(); $this->_helper = $objectManager->get('Mage_Webapi_Helper_Config'); - $reader = $objectManager->get( + $reader = $objectManager->create( 'Mage_Webapi_Model_Config_Reader_Soap', array( - 'cache' => $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false) + 'cache' => $this->getMock('Mage_Core_Model_CacheInterface', array(), array(), '', false) ) ); $reader->setDirectoryScanner($directoryScanner); $this->_config = new Mage_Webapi_Model_Config_Soap($reader, $this->_helper, $app); $objectManager->addSharedInstance($this->_config, 'Mage_Webapi_Model_Config_Soap'); $wsdlFactory = new Mage_Webapi_Model_Soap_Wsdl_Factory($objectManager); - $cache = $this->getMockBuilder('Mage_Core_Model_Cache')->disableOriginalConstructor()->getMock(); + $cache = $this->getMock('Mage_Core_Model_CacheInterface'); $this->_autoDiscover = new Mage_Webapi_Model_Soap_AutoDiscover( $this->_config, $wsdlFactory, @@ -117,18 +117,6 @@ protected function setUp() parent::setUp(); } - protected function tearDown() - { - $this->_config = null; - $this->_autoDiscover = null; - $this->_helper = null; - $this->_resourceName = null; - $this->_resourceData = null; - $this->_dom = null; - $this->_xpath = null; - } - - /** * Test WSDL operations Generation. * Generate WSDL XML using AutoDiscover and prepared config. diff --git a/dev/tests/integration/testsuite/Mage/Webapi/Model/Soap/Security/UsernameTokenTest.php b/dev/tests/integration/testsuite/Mage/Webapi/Model/Soap/Security/UsernameTokenTest.php index 4a213b5c27941..0bb7b62fc83bf 100644 --- a/dev/tests/integration/testsuite/Mage/Webapi/Model/Soap/Security/UsernameTokenTest.php +++ b/dev/tests/integration/testsuite/Mage/Webapi/Model/Soap/Security/UsernameTokenTest.php @@ -53,15 +53,6 @@ protected function setUp() $this->_user->load('test_username', 'api_key'); } - /** - * Clean up. - */ - protected function tearDown() - { - unset($this->_objectManager); - unset($this->_user); - } - /** * Test positive authentication with text password type. */ diff --git a/dev/tests/integration/testsuite/Mage/Webapi/Model/Soap/ServerTest.php b/dev/tests/integration/testsuite/Mage/Webapi/Model/Soap/ServerTest.php index 091d243b9f303..87a18308d928c 100644 --- a/dev/tests/integration/testsuite/Mage/Webapi/Model/Soap/ServerTest.php +++ b/dev/tests/integration/testsuite/Mage/Webapi/Model/Soap/ServerTest.php @@ -51,15 +51,6 @@ protected function setUp() parent::setUp(); } - protected function tearDown() - { - unset($this->_applicationMock); - unset($this->_requestMock); - unset($this->_domDocumentFactory); - unset($this->_storeMock); - parent::tearDown(); - } - /** * Test SOAP server construction with WSDL cache enabling. */ diff --git a/dev/tests/integration/testsuite/Mage/Webhook/Helper/DataTest.php b/dev/tests/integration/testsuite/Mage/Webhook/Helper/DataTest.php new file mode 100644 index 0000000000000..90c85365d9f72 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Webhook/Helper/DataTest.php @@ -0,0 +1,132 @@ +markTestIncomplete("This test hasn't been adopted for refactored code."); + + $this->_prepareService(); + + $helper = Mage::helper('Mage_Webhook_Helper_Data'); + $helper->dispatchEvent('test/hook', array('testData' => 'testValue')); + + //TODO: check subscriber + + } + + /** + * Test for only part which is used by the queue + */ + public function testSendMessageToSubscriber() + { + // TODO: complete it + $this->markTestIncomplete("This test hasn't been adopted for refactored code."); + + $service = $this->_prepareService(); + + $event = Mage::getModel('Mage_Webhook_Model_Event') + ->setHookName('test/hook') + ->setStatus(Mage_Webhook_Model_Event::READY_TO_SEND) + ->save(); + + Mage::getModel('Mage_Webhook_Model_Message') + ->setFormat('json') + ->setBody(array('testData2' => 'testValue2')) + ->setHeaders(array('TestHeader2' => 'value2')) + ->setEventId($event->getId()) + ->save(); + + $helper = Mage::helper('Mage_Webhook_Helper_Data'); + $helper->sendMessageToSubscriber($event, $service); + + //TODO: check subscriber + + } + + protected function _prepareService() + { + // add new hooks for the tests + $this->_addHook('test/hook', array( + 'label' => 'Test Hook', + 'message' => 'Test_Hook_Message_Helper_Data', + )); + + // add new format for tests + Mage::getConfig()->setNode('global/xcom_messenger/formats/json/label', 'Test Format'); + Mage::getConfig()->setNode('global/xcom_messenger/formats/json/status', 'enabled'); + + // save new service which is subscribed to new hook and use new format + $service = Mage::getModel('Mage_Webhook_Model_Subscriber') + ->setName('Test tervice') + ->setEndpointUrl('http://magento2-api.loc/xcom_messenger/endpoint/subscriber?asdf'. + Mage::helper('Mage_Core_Helper_Data')->uniqHash()) + ->setTopics(array('test/hook')) + ->setAuthenticationType('hmac') + ->setTransport('endpoint') + ->setFormat('json') + ->setAuthenticationOption('secret', 'qa123123') + ->save(); + + return $service; + } + + protected function _addHook($name, $options) + { + Mage::getConfig()->setNode('global/xcom_messenger/webhooks/'. $name, null); + foreach ($options as $key => $value) { + Mage::getConfig()->setNode('global/xcom_messenger/webhooks/'. $name . '/' . $key, $value); + } + } +} + +class Test_Hook_Message_Helper_Data implements Mage_Webhook_Model_Mapper_Interface +{ + public function __construct() + { + } + + public function getData() + { + return (object) array('test' => 'value'); + } + + public function getHeaders() + { + return array('TestHeader' => 'value'); + } + + public function getTopic() + { + return 'test/hook'; + } +} diff --git a/dev/tests/integration/testsuite/Mage/Webhook/Model/Mapper/DefaultTest.php b/dev/tests/integration/testsuite/Mage/Webhook/Model/Mapper/DefaultTest.php new file mode 100644 index 0000000000000..12e6506521c98 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Webhook/Model/Mapper/DefaultTest.php @@ -0,0 +1,64 @@ +_objectManager = Mage::getObjectManager(); + } + + public function testDefaultMapper() + { + $data = array( + 'objectA' => new Varien_Object(array('key1' => 'val1', 'key2' => 'val2')), + 'objectB' => new Varien_Object(array('keyB' => 'valueB')) + ); + + $this->_objectManager->get('Mage_Core_Model_Config'); + $mapper = Mage::getModel('Mage_Webhook_Model_Mapper_Factory', $this->_objectManager) + ->getMapperFactory('default', $this->_objectManager->get('Mage_Core_Model_Config') + ->getNode('global/webhook/mappings')) + ->getMapper('some/topic', $data, $this->_objectManager->get('Mage_Core_Model_Config') + ->getNode('global/webhook/mappings/default/options')); + + $this->assertEquals('some/topic', $mapper->getTopic()); + $this->assertEquals(array(Mage_Webhook_Model_Mapper_Default::TOPIC_HEADER => 'some/topic'), + $mapper->getHeaders()); + + $expectedData = array( + 'objectA' => array('key1' => 'val1', 'key2' => 'val2'), + 'objectB' => array('keyB' => 'valueB') + ); + $this->assertEquals($expectedData, $mapper->getData()); + } + + protected function tearDown() + { + unset($this->_objectManager); + } +} diff --git a/dev/tests/integration/testsuite/Mage/Webhook/Model/Resource/Subscriber/CollectionTest.php b/dev/tests/integration/testsuite/Mage/Webhook/Model/Resource/Subscriber/CollectionTest.php new file mode 100644 index 0000000000000..94ac344b8778e --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Webhook/Model/Resource/Subscriber/CollectionTest.php @@ -0,0 +1,148 @@ +_subscribers[] = Mage::getModel('Mage_Webhook_Model_Subscriber') + ->setName('Test subscriber1') + ->setEndpointUrl( + 'http://magento2-api.loc/xcom_messenger/endpoint/subscriber?' . Mage::helper('Mage_Core_Helper_Data') + ->uniqHash()) + ->setTopics(array('test')) + ->setAuthenticationType('oauth') + ->setTransport('endpoint') + ->setMapping('testMapping') + ->setStatus(1) + ->save(); + + // create new test subscriber + $this->_subscribers[] = Mage::getModel('Mage_Webhook_Model_Subscriber') + ->setName('Test subscriber2') + ->setEndpointUrl( + 'http://magento2-api.loc/xcom_messenger/endpoint/subscriber?' . Mage::helper('Mage_Core_Helper_Data') + ->uniqHash()) + ->setTopics(array('test')) + ->setAuthenticationType('oauth') + ->setTransport('endpoint') + ->setMapping('testMapping') + ->setStatus(1) + ->save(); + + // create new test subscriber + $this->_subscribers[] = Mage::getModel('Mage_Webhook_Model_Subscriber') + ->setName('Test subscriber3') + ->setEndpointUrl( + 'http://magento2-api.loc/xcom_messenger/endpoint/subscriber?' . Mage::helper('Mage_Core_Helper_Data') + ->uniqHash()) + ->setTopics(array('customer/created')) + ->setAuthenticationType('oauth') + ->setTransport('endpoint') + ->setMapping('default') + ->setStatus(1) + ->save(); + + // create new test subscriber + $this->_subscribers[] = Mage::getModel('Mage_Webhook_Model_Subscriber') + ->setName('Test subscriber4') + ->setEndpointUrl( + 'http://magento2-api.loc/xcom_messenger/endpoint/subscriber?' . Mage::helper('Mage_Core_Helper_Data') + ->uniqHash()) + ->setTopics(array('test')) + ->setAuthenticationType('oauth') + ->setTransport('endpoint') + ->setMapping('default') + ->setStatus(0) + ->save(); + } + + public function tearDown() + { + foreach ($this->_subscribers as $subscriber) { + $subscriber->delete(); + } + } + + public function testGetSubscribers() + { + /** @var $subscriberCollection Mage_Webhook_Model_Resource_Subscriber_Collection */ + $subscriberCollection = Mage::getModel('Mage_Webhook_Model_Resource_Subscriber_Collection'); + $subscribers = $subscriberCollection->getItems(); + $this->assertEquals(4, count($subscribers)); + } + + public function testGetActiveSubscribers() + { + /** @var $subscriberCollection Mage_Webhook_Model_Resource_Subscriber_Collection */ + $subscriberCollection = Mage::getModel('Mage_Webhook_Model_Resource_Subscriber_Collection'); + $subscribers = $subscriberCollection->addIsActiveFilter(true)->getItems(); + $this->assertEquals(3, count($subscribers)); + } + + public function testGetInactiveSubscribers() + { + /** @var $subscriberCollection Mage_Webhook_Model_Resource_Subscriber_Collection */ + $subscriberCollection = Mage::getModel('Mage_Webhook_Model_Resource_Subscriber_Collection'); + $subscribers = $subscriberCollection->addIsActiveFilter(false)->getItems(); + $this->assertEquals(1, count($subscribers)); + } + + public function testGetTestTopicSubscribers() + { + /** @var $subscriberCollection Mage_Webhook_Model_Resource_Subscriber_Collection */ + $subscriberCollection = Mage::getModel('Mage_Webhook_Model_Resource_Subscriber_Collection'); + $subscribers = $subscriberCollection->addTopicFilter('test')->getItems(); + $this->assertEquals(3, count($subscribers)); + } + + public function testGetCustomerCreatedTopicSubscribers() + { + /** @var $subscriberCollection Mage_Webhook_Model_Resource_Subscriber_Collection */ + $subscriberCollection = Mage::getModel('Mage_Webhook_Model_Resource_Subscriber_Collection'); + $subscribers = $subscriberCollection->addTopicFilter('customer/created')->getItems(); + $this->assertEquals(1, count($subscribers)); + } + + public function testGetTestMappingSubscribers() + { + /** @var $subscriberCollection Mage_Webhook_Model_Resource_Subscriber_Collection */ + $subscriberCollection = Mage::getModel('Mage_Webhook_Model_Resource_Subscriber_Collection'); + $subscribers = $subscriberCollection->addMappingFilter('testMapping')->getItems(); + $this->assertEquals(2, count($subscribers)); + } + + public function testGetDefaultMappingSubscribers() + { + /** @var $subscriberCollection Mage_Webhook_Model_Resource_Subscriber_Collection */ + $subscriberCollection = Mage::getModel('Mage_Webhook_Model_Resource_Subscriber_Collection'); + $subscribers = $subscriberCollection->addMappingFilter('default')->getItems(); + $this->assertEquals(2, count($subscribers)); + } +} diff --git a/dev/tests/integration/testsuite/Mage/Webhook/Model/SubscriberTest.php b/dev/tests/integration/testsuite/Mage/Webhook/Model/SubscriberTest.php new file mode 100644 index 0000000000000..d5f370909af8c --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Webhook/Model/SubscriberTest.php @@ -0,0 +1,85 @@ +_subscriber = Mage::getModel('Mage_Webhook_Model_Subscriber'); + $this->assertEmpty($this->_subscriber->getTopics(), "New subscriber shouldn't be subscribed on any hooks."); + + // add new hooks for the tests + Mage::getConfig()->setNode('global/webhook/webhooks/test/hook/message/webapi', 'Test_Hook_Message_Subscriber'); + Mage::getConfig()->setNode('global/webhook/webhooks/test/hook/label', 'Test Hook'); + + $this->_subscriber->setTopics(array('test/hook', 'test/bbb')); + // TODO: doesn't allow to add hooks which arent exists in the config + $this->assertEquals(array('test/hook', 'test/bbb'), $this->_subscriber->getTopics()); + $this->_subscriber->save(); + + // check if the hooks are persist + $loadedSubscriber = $this->_getSubscriber($this->_subscriber->getId()); + + $this->assertEquals(array('test/hook'), $loadedSubscriber->getTopics()); + } + + protected function _getSubscriber($subscriberId) + { + $subscriber = Mage::getModel('Mage_Webhook_Model_Subscriber'); + return $subscriber->load($subscriberId); + } + + protected function tearDown() + { + $this->_subscriber->delete(); + } +} + +class Test_Hook_Message_Subscriber implements Mage_Webhook_Model_Mapper_Interface +{ + public function __construct() + { + } + + public function getData() + { + return array('test' => 'value'); + } + + public function getHeaders() + { + return array('TestHeader' => 'value'); + } + + public function getTopic() + { + return 'some/topic'; + } +} diff --git a/dev/tests/integration/testsuite/Mage/Weee/Model/ObserverTest.php b/dev/tests/integration/testsuite/Mage/Weee/Model/ObserverTest.php index 2b9153c231bf5..1987109f35ddb 100644 --- a/dev/tests/integration/testsuite/Mage/Weee/Model/ObserverTest.php +++ b/dev/tests/integration/testsuite/Mage/Weee/Model/ObserverTest.php @@ -37,11 +37,6 @@ public function setUp() $this->_model = Mage::getModel('Mage_Weee_Model_Observer'); } - protected function tearDown() - { - $this->_model = null; - } - /** * @magentoConfigFixture current_store tax/weee/enable 1 * @magentoDataFixture Mage/Weee/_files/product_with_fpt.php diff --git a/dev/tests/integration/testsuite/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Chooser/ContainerTest.php b/dev/tests/integration/testsuite/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Chooser/ContainerTest.php index 99462c65d491a..45526be410f5e 100644 --- a/dev/tests/integration/testsuite/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Chooser/ContainerTest.php +++ b/dev/tests/integration/testsuite/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Chooser/ContainerTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Chooser_ContainerTest extends PHPUnit_Framework_TestCase +class Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Chooser_ContainerTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Chooser_Container @@ -34,16 +34,13 @@ class Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Chooser_ContainerTest ext protected function setUp() { + parent::setUp(); + $this->_block = Mage::app()->getLayout()->createBlock( 'Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Chooser_Container' ); } - protected function tearDown() - { - $this->_block = null; - } - public function testSetGetAllowedContainers() { $this->assertEmpty($this->_block->getAllowedContainers()); diff --git a/dev/tests/integration/testsuite/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Chooser/LayoutTest.php b/dev/tests/integration/testsuite/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Chooser/LayoutTest.php index 671315b6237e3..96d94e68b4c6d 100644 --- a/dev/tests/integration/testsuite/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Chooser/LayoutTest.php +++ b/dev/tests/integration/testsuite/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Chooser/LayoutTest.php @@ -25,37 +25,28 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Chooser_LayoutTest extends PHPUnit_Framework_TestCase +class Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Chooser_LayoutTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Chooser_Layout|PHPUnit_Framework_MockObject_MockObject */ protected $_block; - protected $_blockInjections = array( - 'Mage_Core_Controller_Request_Http', - 'Mage_Core_Model_Layout', - 'Mage_Core_Model_Event_Manager', - 'Mage_Backend_Model_Url', - 'Mage_Core_Model_Translate', - 'Mage_Core_Model_Cache', - 'Mage_Core_Model_Design_Package', - 'Mage_Core_Model_Session', - 'Mage_Core_Model_Store_Config', - 'Mage_Core_Controller_Varien_Front', - 'Mage_Core_Model_Factory_Helper' - ); - protected function setUp() { + parent::setUp(); + $layoutUtility = new Mage_Core_Utility_Layout($this); $pageTypesFixture = __DIR__ . '/_files/_page_types_with_containers.xml'; - $args = array_merge($this->_prepareConstructorArguments(), array(array( - 'name' => 'page_type', - 'id' => 'page_types_select', - 'class' => 'page-types-select', - 'title' => 'Page Types Select', - ))); + $args = array( + 'context' => Mage::getSingleton('Mage_Core_Block_Template_Context'), + 'data' => array( + 'name' => 'page_type', + 'id' => 'page_types_select', + 'class' => 'page-types-select', + 'title' => 'Page Types Select', + ) + ); $this->_block = $this->getMock( 'Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Chooser_Layout', array('_getLayoutMerge'), $args @@ -70,26 +61,8 @@ protected function setUp() ; } - protected function tearDown() - { - $this->_block = null; - } - public function testToHtml() { $this->assertXmlStringEqualsXmlFile(__DIR__ . '/_files/page_types_select.html', $this->_block->toHtml()); } - /** - * List of block constructor arguments - * - * @return array - */ - protected function _prepareConstructorArguments() - { - $arguments = array(); - foreach ($this->_blockInjections as $injectionClass) { - $arguments[] = Mage::getModel($injectionClass); - } - return $arguments; - } } diff --git a/dev/tests/integration/testsuite/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Tab/Main/LayoutTest.php b/dev/tests/integration/testsuite/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Tab/Main/LayoutTest.php index ada1fae53044a..08770a73dd61a 100644 --- a/dev/tests/integration/testsuite/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Tab/Main/LayoutTest.php +++ b/dev/tests/integration/testsuite/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Tab/Main/LayoutTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Tab_Main_LayoutTest extends PHPUnit_Framework_TestCase +class Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Tab_Main_LayoutTest extends Mage_Backend_Area_TestCase { /** * @var Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Tab_Main_Layout @@ -34,6 +34,8 @@ class Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Tab_Main_LayoutTest exten protected function setUp() { + parent::setUp(); + $this->_block = Mage::app()->getLayout()->createBlock( 'Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Tab_Main_Layout', '', @@ -42,11 +44,6 @@ protected function setUp() $this->_block->setLayout(Mage::app()->getLayout()); } - protected function tearDown() - { - $this->_block = null; - } - /** * @magentoAppIsolation enabled */ diff --git a/dev/tests/integration/testsuite/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Tab/MainTest.php b/dev/tests/integration/testsuite/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Tab/MainTest.php index d2c608ed2b365..b05267fafa289 100644 --- a/dev/tests/integration/testsuite/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Tab/MainTest.php +++ b/dev/tests/integration/testsuite/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Tab/MainTest.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Tab_MainTest extends PHPUnit_Framework_TestCase +class Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Tab_MainTest extends Mage_Backend_Area_TestCase { public function testPackageThemeElement() { diff --git a/dev/tests/integration/testsuite/Mage/Widget/Model/Widget/ConfigTest.php b/dev/tests/integration/testsuite/Mage/Widget/Model/Widget/ConfigTest.php index a76c4b4e28300..1949abfbc420d 100644 --- a/dev/tests/integration/testsuite/Mage/Widget/Model/Widget/ConfigTest.php +++ b/dev/tests/integration/testsuite/Mage/Widget/Model/Widget/ConfigTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Widget_Model_Widget_Config'); } - protected function tearDown() - { - $this->_model = null; - } - /** * App isolation is enabled, because we change current area and design * diff --git a/dev/tests/integration/testsuite/Mage/Widget/Model/Widget/InstanceTest.php b/dev/tests/integration/testsuite/Mage/Widget/Model/Widget/InstanceTest.php index e6a583eecde1d..145dc2a98402d 100644 --- a/dev/tests/integration/testsuite/Mage/Widget/Model/Widget/InstanceTest.php +++ b/dev/tests/integration/testsuite/Mage/Widget/Model/Widget/InstanceTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Widget_Model_Widget_Instance'); } - protected function tearDown() - { - $this->_model = null; - } - public function testSetGetType() { $this->assertEmpty($this->_model->getType()); diff --git a/dev/tests/integration/testsuite/Mage/Widget/Model/WidgetTest.php b/dev/tests/integration/testsuite/Mage/Widget/Model/WidgetTest.php index d0251795f31b0..0fa339ec3d06a 100644 --- a/dev/tests/integration/testsuite/Mage/Widget/Model/WidgetTest.php +++ b/dev/tests/integration/testsuite/Mage/Widget/Model/WidgetTest.php @@ -37,11 +37,6 @@ protected function setUp() $this->_model = Mage::getModel('Mage_Widget_Model_Widget'); } - protected function tearDown() - { - $this->_model = null; - } - public function testGetWidgetsArray() { $declaredWidgets = $this->_model->getWidgetsArray(); @@ -66,7 +61,8 @@ public function testGetWidgetsArray() public function testGetPlaceholderImageUrl($type, $expectedFile) { Mage::getDesign()->setDesignTheme('default/basic', 'adminhtml'); - $expectedPubFile = Mage::getBaseDir('media') . "/theme/static/adminhtml/default/basic/en_US/{$expectedFile}"; + $expectedPubFile = Mage::getBaseDir(Mage_Core_Model_Dir::STATIC_VIEW) + . "/adminhtml/default/basic/en_US/{$expectedFile}"; if (file_exists($expectedPubFile)) { unlink($expectedPubFile); } diff --git a/dev/tests/integration/testsuite/Mage/Wishlist/Block/AbstractTest.php b/dev/tests/integration/testsuite/Mage/Wishlist/Block/AbstractTest.php index 75986b558d7ab..9cb839fdb46ad 100644 --- a/dev/tests/integration/testsuite/Mage/Wishlist/Block/AbstractTest.php +++ b/dev/tests/integration/testsuite/Mage/Wishlist/Block/AbstractTest.php @@ -32,32 +32,12 @@ class Mage_Wishlist_Block_AbstractTest extends PHPUnit_Framework_TestCase */ protected $_block; - protected $_blockInjections = array( - 'Mage_Core_Controller_Request_Http', - 'Mage_Core_Model_Layout', - 'Mage_Core_Model_Event_Manager', - 'Mage_Core_Model_Url', - 'Mage_Core_Model_Translate', - 'Mage_Core_Model_Cache', - 'Mage_Core_Model_Design_Package', - 'Mage_Core_Model_Session', - 'Mage_Core_Model_Store_Config', - 'Mage_Core_Controller_Varien_Front', - 'Mage_Core_Model_Factory_Helper', - 'Mage_Core_Model_Dir', - 'Mage_Core_Model_Logger', - 'Magento_Filesystem', - ); - protected function setUp() { - $this->_block = $this->getMockForAbstractClass('Mage_Wishlist_Block_Abstract', - $this->_prepareConstructorArguments()); - } - - protected function tearDown() - { - $this->_block = null; + $this->_block = $this->getMockForAbstractClass( + 'Mage_Wishlist_Block_Abstract', + array(Mage::getSingleton('Mage_Core_Block_Template_Context')) + ); } /** @@ -76,19 +56,4 @@ public function testImage() $this->assertContains('/'.$size, $this->_block->getImageUrl($product)); $this->assertStringEndsWith('magento_image.jpg', $this->_block->getImageUrl($product)); } - - /** - * List of block constructor arguments - * - * @return array - */ - protected function _prepareConstructorArguments() - { - $arguments = array(); - foreach ($this->_blockInjections as $injectionClass) { - $arguments[] = Mage::getObjectManager()->get($injectionClass); - } - return $arguments; - } } - diff --git a/dev/tests/integration/testsuite/Mage/Wishlist/Block/Customer/Wishlist/Item/ColumnTest.php b/dev/tests/integration/testsuite/Mage/Wishlist/Block/Customer/Wishlist/Item/ColumnTest.php index 0517e5716e50c..0b4d45c9d5ab8 100644 --- a/dev/tests/integration/testsuite/Mage/Wishlist/Block/Customer/Wishlist/Item/ColumnTest.php +++ b/dev/tests/integration/testsuite/Mage/Wishlist/Block/Customer/Wishlist/Item/ColumnTest.php @@ -44,12 +44,6 @@ protected function setUp() $this->_layout->addBlock('Mage_Core_Block_Text', 'child', 'test'); } - protected function tearDown() - { - $this->_layout = null; - $this->_block = null; - } - public function testToHtml() { $item = new StdClass; diff --git a/dev/tests/integration/testsuite/Mage/Wishlist/Block/Customer/Wishlist/ItemsTest.php b/dev/tests/integration/testsuite/Mage/Wishlist/Block/Customer/Wishlist/ItemsTest.php index 21e2c72f98467..0a72265b59101 100644 --- a/dev/tests/integration/testsuite/Mage/Wishlist/Block/Customer/Wishlist/ItemsTest.php +++ b/dev/tests/integration/testsuite/Mage/Wishlist/Block/Customer/Wishlist/ItemsTest.php @@ -27,47 +27,16 @@ class Mage_Wishlist_Block_Customer_Wishlist_ItemsTest extends PHPUnit_Framework_TestCase { - /** - * @var Mage_Wishlist_Block_Abstract - */ - protected $_blockInjections = array( - 'Mage_Core_Controller_Request_Http', - 'Mage_Core_Model_Layout', - 'Mage_Core_Model_Event_Manager', - 'Mage_Core_Model_Url', - 'Mage_Core_Model_Translate', - 'Mage_Core_Model_Cache', - 'Mage_Core_Model_Design_Package', - 'Mage_Core_Model_Session', - 'Mage_Core_Model_Store_Config', - 'Mage_Core_Controller_Varien_Front', - 'Mage_Core_Model_Factory_Helper' - ); - public function testGetColumns() { $layout = Mage::getModel('Mage_Core_Model_Layout'); $block = $layout->addBlock('Mage_Wishlist_Block_Customer_Wishlist_Items', 'test'); $child = $this->getMock('Mage_Core_Block_Text', array('isEnabled'), - $this->_prepareConstructorArguments()); + array(Mage::getSingleton('Mage_Core_Block_Context'))); $child->expects($this->any()) ->method('isEnabled') ->will($this->returnValue(true)); $layout->addBlock($child, 'child', 'test'); $this->assertSame(array($child), $block->getColumns()); } - - /** - * List of block constructor arguments - * - * @return array - */ - protected function _prepareConstructorArguments() - { - $arguments = array(); - foreach ($this->_blockInjections as $injectionClass) { - $arguments[] = Mage::getModel($injectionClass); - } - return $arguments; - } } diff --git a/dev/tests/integration/testsuite/MageTest.php b/dev/tests/integration/testsuite/MageTest.php index c1540fb3cdb8e..ef937019ffec3 100644 --- a/dev/tests/integration/testsuite/MageTest.php +++ b/dev/tests/integration/testsuite/MageTest.php @@ -132,17 +132,6 @@ public function testLogException() $this->expectOutputRegex('/' . $msg . '/'); } - /** - * @magentoAppIsolation enabled - */ - public function testReset() - { - Mage::setIsDeveloperMode(true); - $this->assertTrue(Mage::getIsDeveloperMode()); - Mage::reset(); - $this->assertFalse(Mage::getIsDeveloperMode()); - } - /** * @magentoAppIsolation enabled * diff --git a/dev/tests/integration/testsuite/Magento/Di/Generator/TestAsset/ParentClassWithNamespace.php b/dev/tests/integration/testsuite/Magento/Code/Generator/TestAsset/ParentClassWithNamespace.php similarity index 97% rename from dev/tests/integration/testsuite/Magento/Di/Generator/TestAsset/ParentClassWithNamespace.php rename to dev/tests/integration/testsuite/Magento/Code/Generator/TestAsset/ParentClassWithNamespace.php index 4efe23e62688a..cb58908b5883c 100644 --- a/dev/tests/integration/testsuite/Magento/Di/Generator/TestAsset/ParentClassWithNamespace.php +++ b/dev/tests/integration/testsuite/Magento/Code/Generator/TestAsset/ParentClassWithNamespace.php @@ -19,13 +19,13 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Di + * @package Magento_Code * @subpackage unit_tests * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Di\Generator\TestAsset; +namespace Magento\Code\Generator\TestAsset; use Zend\Code\Generator\DocBlockGenerator; class ParentClassWithNamespace diff --git a/dev/tests/integration/testsuite/Magento/Di/Generator/TestAsset/ParentClassWithoutNamespace.php b/dev/tests/integration/testsuite/Magento/Code/Generator/TestAsset/ParentClassWithoutNamespace.php similarity index 96% rename from dev/tests/integration/testsuite/Magento/Di/Generator/TestAsset/ParentClassWithoutNamespace.php rename to dev/tests/integration/testsuite/Magento/Code/Generator/TestAsset/ParentClassWithoutNamespace.php index 16c0fb409d017..f920de79ffe68 100644 --- a/dev/tests/integration/testsuite/Magento/Di/Generator/TestAsset/ParentClassWithoutNamespace.php +++ b/dev/tests/integration/testsuite/Magento/Code/Generator/TestAsset/ParentClassWithoutNamespace.php @@ -19,7 +19,7 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Di + * @package Magento_Code * @subpackage unit_tests * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) @@ -27,7 +27,7 @@ use Zend\Code\Generator\DocBlockGenerator; -class Magento_Di_Generator_TestAsset_ParentClassWithoutNamespace +class Magento_Code_Generator_TestAsset_ParentClassWithoutNamespace { /** * Public parent method diff --git a/dev/tests/integration/testsuite/Magento/Di/Generator/TestAsset/SourceClassWithNamespace.php b/dev/tests/integration/testsuite/Magento/Code/Generator/TestAsset/SourceClassWithNamespace.php similarity index 97% rename from dev/tests/integration/testsuite/Magento/Di/Generator/TestAsset/SourceClassWithNamespace.php rename to dev/tests/integration/testsuite/Magento/Code/Generator/TestAsset/SourceClassWithNamespace.php index 99f089ad7a287..bf66077bd7b4c 100644 --- a/dev/tests/integration/testsuite/Magento/Di/Generator/TestAsset/SourceClassWithNamespace.php +++ b/dev/tests/integration/testsuite/Magento/Code/Generator/TestAsset/SourceClassWithNamespace.php @@ -19,13 +19,13 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Di + * @package Magento_Code * @subpackage unit_tests * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Di\Generator\TestAsset; +namespace Magento\Code\Generator\TestAsset; use Zend\Code\Generator\ClassGenerator; class SourceClassWithNamespace extends ParentClassWithNamespace diff --git a/dev/tests/integration/testsuite/Magento/Di/Generator/TestAsset/SourceClassWithoutNamespace.php b/dev/tests/integration/testsuite/Magento/Code/Generator/TestAsset/SourceClassWithoutNamespace.php similarity index 95% rename from dev/tests/integration/testsuite/Magento/Di/Generator/TestAsset/SourceClassWithoutNamespace.php rename to dev/tests/integration/testsuite/Magento/Code/Generator/TestAsset/SourceClassWithoutNamespace.php index 421066cb24aa1..ec384d53e70c7 100644 --- a/dev/tests/integration/testsuite/Magento/Di/Generator/TestAsset/SourceClassWithoutNamespace.php +++ b/dev/tests/integration/testsuite/Magento/Code/Generator/TestAsset/SourceClassWithoutNamespace.php @@ -19,7 +19,7 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Di + * @package Magento_Code * @subpackage unit_tests * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) @@ -27,8 +27,8 @@ use Zend\Code\Generator\ClassGenerator; -class Magento_Di_Generator_TestAsset_SourceClassWithoutNamespace - extends Magento_Di_Generator_TestAsset_ParentClassWithoutNamespace +class Magento_Code_Generator_TestAsset_SourceClassWithoutNamespace + extends Magento_Code_Generator_TestAsset_ParentClassWithoutNamespace { /** * Public child constructor diff --git a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest.php b/dev/tests/integration/testsuite/Magento/Code/GeneratorTest.php new file mode 100644 index 0000000000000..cdc2070780e32 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Code/GeneratorTest.php @@ -0,0 +1,171 @@ +_includePath = get_include_path(); + + /** @var $dirs Mage_Core_Model_Dir */ + $dirs = Mage::getObjectManager()->get('Mage_Core_Model_Dir'); + $generationDirectory = $dirs->getDir(Mage_Core_Model_Dir::VAR_DIR) . '/generation'; + + Magento_Autoload_IncludePath::addIncludePath($generationDirectory); + + $this->_ioObject = new Magento_Code_Generator_Io( + new Varien_Io_File(), + new Magento_Autoload_IncludePath(), + $generationDirectory + ); + $this->_generator = Mage::getObjectManager()->create( + 'Magento_Code_Generator', array('ioObject' => $this->_ioObject) + ); + } + + protected function tearDown() + { + /** @var $dirs Mage_Core_Model_Dir */ + $dirs = Mage::getObjectManager()->get('Mage_Core_Model_Dir'); + $generationDirectory = $dirs->getDir(Mage_Core_Model_Dir::VAR_DIR) . '/generation'; + Varien_Io_File::rmdirRecursive($generationDirectory); + + set_include_path($this->_includePath); + unset($this->_generator); + } + + protected function _clearDocBlock($classBody) + { + return preg_replace('/(\/\*[\w\W]*)class/', 'class', $classBody); + } + + public function testGenerateClassFactoryWithoutNamespace() + { + $factoryClassName = self::CLASS_NAME_WITHOUT_NAMESPACE . 'Factory'; + $this->assertEquals( + Magento_Code_Generator::GENERATION_SUCCESS, + $this->_generator->generateClass($factoryClassName) + ); + + /** @var $factory Magento_ObjectManager_Factory */ + $factory = Mage::getObjectManager()->create($factoryClassName); + $object = $factory->create(); + $this->assertInstanceOf(self::CLASS_NAME_WITHOUT_NAMESPACE, $object); + + $content = $this->_clearDocBlock(file_get_contents($this->_ioObject->getResultFileName( + self::CLASS_NAME_WITHOUT_NAMESPACE . 'Factory') + )); + $expectedContent = $this->_clearDocBlock( + file_get_contents(__DIR__ . '/_files/generatedFactoryWithoutNamespace.php') + ); + $this->assertEquals($expectedContent, $content); + } + + public function testGenerateClassFactoryWithNamespace() + { + $factoryClassName = self::CLASS_NAME_WITH_NAMESPACE . 'Factory'; + $this->assertEquals( + Magento_Code_Generator::GENERATION_SUCCESS, + $this->_generator->generateClass($factoryClassName) + ); + + /** @var $factory Magento_ObjectManager_Factory */ + $factory = Mage::getObjectManager()->create($factoryClassName); + + $object = $factory->create(); + $this->assertInstanceOf(self::CLASS_NAME_WITH_NAMESPACE, $object); + + $content = $this->_clearDocBlock( + file_get_contents($this->_ioObject->getResultFileName(self::CLASS_NAME_WITH_NAMESPACE . 'Factory')) + ); + $expectedContent = $this->_clearDocBlock( + file_get_contents(__DIR__ . '/_files/generatedFactoryWithNamespace.php') + ); + $this->assertEquals($expectedContent, $content); + } + + public function testGenerateClassProxyWithoutNamespace() + { + $factoryClassName = self::CLASS_NAME_WITHOUT_NAMESPACE . 'Proxy'; + $this->assertEquals( + Magento_Code_Generator::GENERATION_SUCCESS, + $this->_generator->generateClass($factoryClassName) + ); + + $proxy = Mage::getObjectManager()->create($factoryClassName); + $this->assertInstanceOf(self::CLASS_NAME_WITHOUT_NAMESPACE, $proxy); + $content = $this->_clearDocBlock( + file_get_contents($this->_ioObject->getResultFileName(self::CLASS_NAME_WITHOUT_NAMESPACE . 'Proxy')) + ); + $expectedContent = $this->_clearDocBlock( + file_get_contents(__DIR__ . '/_files/generatedProxyWithoutNamespace.php') + ); + $this->assertEquals($expectedContent, $content); + } + + public function testGenerateClassProxyWithNamespace() + { + $factoryClassName = self::CLASS_NAME_WITH_NAMESPACE . 'Proxy'; + $this->assertEquals( + Magento_Code_Generator::GENERATION_SUCCESS, + $this->_generator->generateClass($factoryClassName) + ); + + $proxy = Mage::getObjectManager()->create($factoryClassName); + $this->assertInstanceOf(self::CLASS_NAME_WITH_NAMESPACE, $proxy); + + $content = $this->_clearDocBlock( + file_get_contents($this->_ioObject->getResultFileName(self::CLASS_NAME_WITH_NAMESPACE . 'Proxy')) + ); + $expectedContent = $this->_clearDocBlock( + file_get_contents(__DIR__ . '/_files/generatedProxyWithNamespace.php') + ); + $this->assertEquals($expectedContent, $content); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Code/_files/generatedFactoryWithNamespace.php b/dev/tests/integration/testsuite/Magento/Code/_files/generatedFactoryWithNamespace.php new file mode 100644 index 0000000000000..e6b7b82e685fb --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Code/_files/generatedFactoryWithNamespace.php @@ -0,0 +1,62 @@ +_objectManager = $objectManager; + } + + /** + * Create class instance with specified parameters + * + * @param array $data + * @return \Magento\Code\Generator\TestAsset\SourceClassWithNamespace + */ + public function create(array $data = array()) + { + return $this->_objectManager->create(self::CLASS_NAME, $data); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Code/_files/generatedFactoryWithoutNamespace.php b/dev/tests/integration/testsuite/Magento/Code/_files/generatedFactoryWithoutNamespace.php new file mode 100644 index 0000000000000..c90b9444389a1 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Code/_files/generatedFactoryWithoutNamespace.php @@ -0,0 +1,60 @@ +_objectManager = $objectManager; + } + + /** + * Create class instance with specified parameters + * + * @param array $data + * @return \Magento_Code_Generator_TestAsset_SourceClassWithoutNamespace + */ + public function create(array $data = array()) + { + return $this->_objectManager->create(self::CLASS_NAME, $data); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Code/_files/generatedProxyWithNamespace.php b/dev/tests/integration/testsuite/Magento/Code/_files/generatedProxyWithNamespace.php new file mode 100644 index 0000000000000..bb0b62e5826da --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Code/_files/generatedProxyWithNamespace.php @@ -0,0 +1,137 @@ +_objectManager = $objectManager; + } + + /** + * @return array + */ + public function __sleep() + { + return array('_subject'); + } + + /** + * Retrieve ObjectManager from global scope + */ + public function __wakeup() + { + $this->_objectManager = Mage::getObjectManager(); + } + + /** + * Clone proxied instance + */ + public function __clone() + { + $this->_subject = clone $this->_objectManager->get(self::CLASS_NAME); + } + + /** + * {@inheritdoc} + */ + public function publicChildMethod(\Zend\Code\Generator\ClassGenerator $classGenerator, $param1 = '', $param2 = '\\', $param3 = '\'', array $array = array()) + { + if (!$this->_subject) { + $this->_subject = $this->_objectManager->get(self::CLASS_NAME); + } + return $this->_subject->publicChildMethod($classGenerator, $param1, $param2, $param3, $array); + } + + /** + * {@inheritdoc} + */ + public function publicMethodWithReference(\Zend\Code\Generator\ClassGenerator &$classGenerator, &$param1, array &$array) + { + if (!$this->_subject) { + $this->_subject = $this->_objectManager->get(self::CLASS_NAME); + } + return $this->_subject->publicMethodWithReference($classGenerator, $param1, $array); + } + + /** + * {@inheritdoc} + */ + public function publicChildWithoutParameters() + { + if (!$this->_subject) { + $this->_subject = $this->_objectManager->get(self::CLASS_NAME); + } + return $this->_subject->publicChildWithoutParameters(); + } + + /** + * {@inheritdoc} + */ + public function publicParentMethod(\Zend\Code\Generator\DocBlockGenerator $docBlockGenerator, $param1 = '', $param2 = '\\', $param3 = '\'', array $array = array()) + { + if (!$this->_subject) { + $this->_subject = $this->_objectManager->get(self::CLASS_NAME); + } + return $this->_subject->publicParentMethod($docBlockGenerator, $param1, $param2, $param3, $array); + } + + /** + * {@inheritdoc} + */ + public function publicParentWithoutParameters() + { + if (!$this->_subject) { + $this->_subject = $this->_objectManager->get(self::CLASS_NAME); + } + return $this->_subject->publicParentWithoutParameters(); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Code/_files/generatedProxyWithoutNamespace.php b/dev/tests/integration/testsuite/Magento/Code/_files/generatedProxyWithoutNamespace.php new file mode 100644 index 0000000000000..6a796f72cb63b --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Code/_files/generatedProxyWithoutNamespace.php @@ -0,0 +1,135 @@ +_objectManager = $objectManager; + } + + /** + * @return array + */ + public function __sleep() + { + return array('_subject'); + } + + /** + * Retrieve ObjectManager from global scope + */ + public function __wakeup() + { + $this->_objectManager = Mage::getObjectManager(); + } + + /** + * Clone proxied instance + */ + public function __clone() + { + $this->_subject = clone $this->_objectManager->get(self::CLASS_NAME); + } + + /** + * {@inheritdoc} + */ + public function publicChildMethod(\Zend\Code\Generator\ClassGenerator $classGenerator, $param1 = '', $param2 = '\\', $param3 = '\'', array $array = array()) + { + if (!$this->_subject) { + $this->_subject = $this->_objectManager->get(self::CLASS_NAME); + } + return $this->_subject->publicChildMethod($classGenerator, $param1, $param2, $param3, $array); + } + + /** + * {@inheritdoc} + */ + public function publicMethodWithReference(\Zend\Code\Generator\ClassGenerator &$classGenerator, &$param1, array &$array) + { + if (!$this->_subject) { + $this->_subject = $this->_objectManager->get(self::CLASS_NAME); + } + return $this->_subject->publicMethodWithReference($classGenerator, $param1, $array); + } + + /** + * {@inheritdoc} + */ + public function publicChildWithoutParameters() + { + if (!$this->_subject) { + $this->_subject = $this->_objectManager->get(self::CLASS_NAME); + } + return $this->_subject->publicChildWithoutParameters(); + } + + /** + * {@inheritdoc} + */ + public function publicParentMethod(\Zend\Code\Generator\DocBlockGenerator $docBlockGenerator, $param1 = '', $param2 = '\\', $param3 = '\'', array $array = array()) + { + if (!$this->_subject) { + $this->_subject = $this->_objectManager->get(self::CLASS_NAME); + } + return $this->_subject->publicParentMethod($docBlockGenerator, $param1, $param2, $param3, $array); + } + + /** + * {@inheritdoc} + */ + public function publicParentWithoutParameters() + { + if (!$this->_subject) { + $this->_subject = $this->_objectManager->get(self::CLASS_NAME); + } + return $this->_subject->publicParentWithoutParameters(); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Di/Definition/CompilerDefinition/TestAsset/NoConstructor.php b/dev/tests/integration/testsuite/Magento/Di/Definition/CompilerDefinition/TestAsset/NoConstructor.php deleted file mode 100644 index 867931526ed81..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Di/Definition/CompilerDefinition/TestAsset/NoConstructor.php +++ /dev/null @@ -1,30 +0,0 @@ -_varA = $varA; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Di/Definition/CompilerDefinition/TestAsset/OneRequiredArgument.php b/dev/tests/integration/testsuite/Magento/Di/Definition/CompilerDefinition/TestAsset/OneRequiredArgument.php deleted file mode 100644 index 70c34365513ed..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Di/Definition/CompilerDefinition/TestAsset/OneRequiredArgument.php +++ /dev/null @@ -1,39 +0,0 @@ -_varA = $varA; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Di/Definition/CompilerDefinition/TestAsset/OneRequiredOneOptionalArguments.php b/dev/tests/integration/testsuite/Magento/Di/Definition/CompilerDefinition/TestAsset/OneRequiredOneOptionalArguments.php deleted file mode 100644 index 804495937da7a..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Di/Definition/CompilerDefinition/TestAsset/OneRequiredOneOptionalArguments.php +++ /dev/null @@ -1,46 +0,0 @@ -_varA = $varA; - $this->_varB = $varB; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Di/Definition/CompilerDefinition/TestAsset/TwoOptionalArguments.php b/dev/tests/integration/testsuite/Magento/Di/Definition/CompilerDefinition/TestAsset/TwoOptionalArguments.php deleted file mode 100644 index 00a3d02527af8..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Di/Definition/CompilerDefinition/TestAsset/TwoOptionalArguments.php +++ /dev/null @@ -1,46 +0,0 @@ -_varA = $varA; - $this->_varB = $varB; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Di/Definition/CompilerDefinition/TestAsset/TwoRequiredArguments.php b/dev/tests/integration/testsuite/Magento/Di/Definition/CompilerDefinition/TestAsset/TwoRequiredArguments.php deleted file mode 100644 index 2a6e8a63c666a..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Di/Definition/CompilerDefinition/TestAsset/TwoRequiredArguments.php +++ /dev/null @@ -1,46 +0,0 @@ -_varA = $varA; - $this->_varB = $varB; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Di/Definition/CompilerDefinition/ZendTest.php b/dev/tests/integration/testsuite/Magento/Di/Definition/CompilerDefinition/ZendTest.php deleted file mode 100644 index ed91be37fc529..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Di/Definition/CompilerDefinition/ZendTest.php +++ /dev/null @@ -1,46 +0,0 @@ -addDirectory(__DIR__ . '/TestAsset'); - $compiler->compile(); - - $expectedDefinitions = include (__DIR__ . '/_files/definitions.php'); - $actualDefinitions = $compiler->toArray(); - $this->assertEquals($expectedDefinitions, $actualDefinitions); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Di/Definition/CompilerDefinition/_files/definitions.php b/dev/tests/integration/testsuite/Magento/Di/Definition/CompilerDefinition/_files/definitions.php deleted file mode 100644 index 17c45e194fc2c..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Di/Definition/CompilerDefinition/_files/definitions.php +++ /dev/null @@ -1,175 +0,0 @@ - - array( - 'supertypes' => - array(), - 'instantiator' => '__construct', - 'methods' => - array(), - 'parameters' => - array(), - ), - 'Magento_Di_Definition_CompilerDefinition_TestAsset_OneOptionalArgument' => - array( - 'supertypes' => - array(), - 'instantiator' => '__construct', - 'methods' => - array( - '__construct' => true, - ), - 'parameters' => - array( - '__construct' => - array( - 'Magento_Di_Definition_CompilerDefinition_TestAsset_OneOptionalArgument::__construct:0' => - array( - 0 => 'varA', - 1 => 'Magento_Di_Definition_CompilerDefinition_TestAsset_NoConstructor', - 2 => false, - 3 => NULL, - ), - ), - ), - ), - 'Magento_Di_Definition_CompilerDefinition_TestAsset_OneRequiredArgument' => - array( - 'supertypes' => - array(), - 'instantiator' => '__construct', - 'methods' => - array( - '__construct' => true, - ), - 'parameters' => - array( - '__construct' => - array( - 'Magento_Di_Definition_CompilerDefinition_TestAsset_OneRequiredArgument::__construct:0' => - array( - 0 => 'varA', - 1 => 'Magento_Di_Definition_CompilerDefinition_TestAsset_NoConstructor', - 2 => true, - 3 => NULL, - ), - ), - ), - ), - 'Magento_Di_Definition_CompilerDefinition_TestAsset_OneRequiredOneOptionalArguments' => - array( - 'supertypes' => - array(), - 'instantiator' => '__construct', - 'methods' => - array( - '__construct' => true, - ), - 'parameters' => - array( - '__construct' => - array( - 'Magento_Di_Definition_CompilerDefinition_TestAsset_OneRequiredOneOptionalArguments::__construct:0' => - array( - 0 => 'varA', - 1 => NULL, - 2 => true, - 3 => NULL, - ), - 'Magento_Di_Definition_CompilerDefinition_TestAsset_OneRequiredOneOptionalArguments::__construct:1' => - array( - 0 => 'varB', - 1 => 'Magento_Di_Definition_CompilerDefinition_TestAsset_OneOptionalArgument', - 2 => false, - 3 => NULL, - ), - ), - ), - ), - 'Magento_Di_Definition_CompilerDefinition_TestAsset_TwoOptionalArguments' => - array( - 'supertypes' => - array(), - 'instantiator' => '__construct', - 'methods' => - array( - '__construct' => true, - ), - 'parameters' => - array( - '__construct' => - array( - 'Magento_Di_Definition_CompilerDefinition_TestAsset_TwoOptionalArguments::__construct:0' => - array( - 0 => 'varA', - 1 => NULL, - 2 => false, - 3 => 1, - ), - 'Magento_Di_Definition_CompilerDefinition_TestAsset_TwoOptionalArguments::__construct:1' => - array( - 0 => 'varB', - 1 => 'Magento_Di_Definition_CompilerDefinition_TestAsset_OneOptionalArgument', - 2 => false, - 3 => NULL, - ), - ), - ), - ), - 'Magento_Di_Definition_CompilerDefinition_TestAsset_TwoRequiredArguments' => - array( - 'supertypes' => - array(), - 'instantiator' => '__construct', - 'methods' => - array( - '__construct' => true, - ), - 'parameters' => - array( - '__construct' => - array( - 'Magento_Di_Definition_CompilerDefinition_TestAsset_TwoRequiredArguments::__construct:0' => - array( - 0 => 'varA', - 1 => 'Magento_Di_Definition_CompilerDefinition_TestAsset_NoConstructor', - 2 => true, - 3 => NULL, - ), - 'Magento_Di_Definition_CompilerDefinition_TestAsset_TwoRequiredArguments::__construct:1' => - array( - 0 => 'varB', - 1 => 'Magento_Di_Definition_CompilerDefinition_TestAsset_OneRequiredArgument', - 2 => true, - 3 => NULL, - ), - ), - ), - ), -); diff --git a/dev/tests/integration/testsuite/Magento/Di/GeneratorTest.php b/dev/tests/integration/testsuite/Magento/Di/GeneratorTest.php deleted file mode 100644 index da42f8feb9a09..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Di/GeneratorTest.php +++ /dev/null @@ -1,149 +0,0 @@ -_includePath = get_include_path(); - - /** @var $dirs Mage_Core_Model_Dir */ - $dirs = Mage::getObjectManager()->get('Mage_Core_Model_Dir'); - $generationDirectory = $dirs->getDir(Mage_Core_Model_Dir::VAR_DIR) . '/generation'; - - Magento_Autoload_IncludePath::addIncludePath($generationDirectory); - - $ioObject = new Magento_Di_Generator_Io( - new Varien_Io_File(), - new Magento_Autoload_IncludePath(), - $generationDirectory - ); - $this->_generator = Mage::getObjectManager()->get('Magento_Di_Generator', array('ioObject' => $ioObject)); - } - - protected function tearDown() - { - /** @var $dirs Mage_Core_Model_Dir */ - $dirs = Mage::getObjectManager()->get('Mage_Core_Model_Dir'); - $generationDirectory = $dirs->getDir(Mage_Core_Model_Dir::VAR_DIR) . '/generation'; - Varien_Io_File::rmdirRecursive($generationDirectory); - - set_include_path($this->_includePath); - unset($this->_generator); - } - - public function testGenerateClassFactoryWithoutNamespace() - { - $factoryClassName = self::CLASS_NAME_WITHOUT_NAMESPACE . 'Factory'; - $this->assertTrue($this->_generator->generateClass($factoryClassName)); - - /** @var $factory Magento_ObjectManager_Factory */ - $factory = Mage::getObjectManager()->create($factoryClassName); - $this->assertInstanceOf('Magento_ObjectManager_Factory', $factory); - - $object = $factory->createFromArray(); - $this->assertInstanceOf(self::CLASS_NAME_WITHOUT_NAMESPACE, $object); - } - - public function testGenerateClassFactoryWithNamespace() - { - $factoryClassName = self::CLASS_NAME_WITH_NAMESPACE . 'Factory'; - $this->assertTrue($this->_generator->generateClass($factoryClassName)); - - /** @var $factory Magento_ObjectManager_Factory */ - $factory = Mage::getObjectManager()->create($factoryClassName); - $this->assertInstanceOf('Magento_ObjectManager_Factory', $factory); - - $object = $factory->createFromArray(); - $this->assertInstanceOf(self::CLASS_NAME_WITH_NAMESPACE, $object); - } - - public function testGenerateClassProxyWithoutNamespace() - { - $factoryClassName = self::CLASS_NAME_WITHOUT_NAMESPACE . 'Proxy'; - $this->assertTrue($this->_generator->generateClass($factoryClassName)); - - $proxy = Mage::getObjectManager()->create($factoryClassName); - $this->assertInstanceOf(self::CLASS_NAME_WITHOUT_NAMESPACE, $proxy); - - $this->_verifyProxyMethods(self::CLASS_NAME_WITHOUT_NAMESPACE, $proxy); - } - - public function testGenerateClassProxyWithNamespace() - { - $factoryClassName = self::CLASS_NAME_WITH_NAMESPACE . 'Proxy'; - $this->assertTrue($this->_generator->generateClass($factoryClassName)); - - $proxy = Mage::getObjectManager()->create($factoryClassName); - $this->assertInstanceOf(self::CLASS_NAME_WITH_NAMESPACE, $proxy); - - $this->_verifyProxyMethods(self::CLASS_NAME_WITH_NAMESPACE, $proxy); - } - - /** - * @param string $class - * @param object $proxy - */ - protected function _verifyProxyMethods($class, $proxy) - { - $expectedMethods = array(); - $reflectionObject = new ReflectionClass(new $class()); - $publicMethods = $reflectionObject->getMethods(ReflectionMethod::IS_PUBLIC); - foreach ($publicMethods as $method) { - if (!($method->isConstructor() || $method->isFinal() || $method->isStatic())) { - $expectedMethods[$method->getName()] = $method->getParameters(); - } - } - - $actualMethods = array(); - $reflectionObject = new ReflectionClass($proxy); - $publicMethods = $reflectionObject->getMethods(ReflectionMethod::IS_PUBLIC); - foreach ($publicMethods as $method) { - if (!($method->isConstructor() || $method->isFinal() || $method->isStatic())) { - $actualMethods[$method->getName()] = $method->getParameters(); - } - } - - $this->assertEquals($expectedMethods, $actualMethods); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorEightArguments.php b/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorEightArguments.php deleted file mode 100644 index 64823169e6716..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorEightArguments.php +++ /dev/null @@ -1,63 +0,0 @@ -_eight = $eight; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorFiveArguments.php b/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorFiveArguments.php deleted file mode 100644 index 2d55f78fff338..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorFiveArguments.php +++ /dev/null @@ -1,54 +0,0 @@ -_five = $five; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorFourArguments.php b/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorFourArguments.php deleted file mode 100644 index ce393c2d4c303..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorFourArguments.php +++ /dev/null @@ -1,52 +0,0 @@ -_four = $four; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorNineArguments.php b/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorNineArguments.php deleted file mode 100644 index bae1df0cd7fa8..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorNineArguments.php +++ /dev/null @@ -1,65 +0,0 @@ -_nine = $nine; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorSevenArguments.php b/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorSevenArguments.php deleted file mode 100644 index 6173a45649a58..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorSevenArguments.php +++ /dev/null @@ -1,61 +0,0 @@ -_seven = $seven; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorSixArguments.php b/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorSixArguments.php deleted file mode 100644 index c1a9649737248..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorSixArguments.php +++ /dev/null @@ -1,56 +0,0 @@ -_six = $six; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorTenArguments.php b/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorTenArguments.php deleted file mode 100644 index 6151ced6103b3..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorTenArguments.php +++ /dev/null @@ -1,69 +0,0 @@ -_ten = $ten; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorThreeArguments.php b/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorThreeArguments.php deleted file mode 100644 index bac64b11432aa..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorThreeArguments.php +++ /dev/null @@ -1,50 +0,0 @@ -_three = $three; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorTwoArguments.php b/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorTwoArguments.php deleted file mode 100644 index 2553b4281e364..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorTwoArguments.php +++ /dev/null @@ -1,48 +0,0 @@ -_two = $two; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Di/TestAsset/Interface.php b/dev/tests/integration/testsuite/Magento/Di/TestAsset/Interface.php deleted file mode 100644 index d31c2b31a87c4..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Di/TestAsset/Interface.php +++ /dev/null @@ -1,30 +0,0 @@ - 'Magento_Di_TestAsset_ConstructorNoArguments', - 1 => 'Magento_Di_TestAsset_ConstructorOneArgument', - 2 => 'Magento_Di_TestAsset_ConstructorTwoArguments', - 3 => 'Magento_Di_TestAsset_ConstructorThreeArguments', - 4 => 'Magento_Di_TestAsset_ConstructorFourArguments', - 5 => 'Magento_Di_TestAsset_ConstructorFiveArguments', - 6 => 'Magento_Di_TestAsset_ConstructorSixArguments', - 7 => 'Magento_Di_TestAsset_ConstructorSevenArguments', - 8 => 'Magento_Di_TestAsset_ConstructorEightArguments', - 9 => 'Magento_Di_TestAsset_ConstructorNineArguments', - 10 => 'Magento_Di_TestAsset_ConstructorTenArguments', - ); - - /** - * Names of properties - * - * @var array - */ - protected $_numerableProperties = array( - 1 => '_one', - 2 => '_two', - 3 => '_three', - 4 => '_four', - 5 => '_five', - 6 => '_six', - 7 => '_seven', - 8 => '_eight', - 9 => '_nine', - 10 => '_ten', - ); - - public static function setUpBeforeClass() - { - $magentoDi = new Magento_Di_Zend(); - $magentoDi->instanceManager()->addTypePreference(self::TEST_INTERFACE, self::TEST_INTERFACE_IMPLEMENTATION); - $magentoDi->instanceManager()->addAlias(self::TEST_CLASS_ALIAS, self::TEST_CLASS); - self::$_objectManager = new Magento_ObjectManager_Zend(null, $magentoDi); - } - - public static function tearDownAfterClass() - { - self::$_objectManager = null; - } - - /** - * Data provider for testNewInstance - * - * @return array - */ - public function newInstanceDataProvider() - { - $data = array( - 'basic model' => array( - '$actualClassName' => self::TEST_CLASS_INJECTION, - '$properties' => array('_object' => self::TEST_CLASS), - ), - 'model with interface' => array( - '$actualClassName' => self::TEST_CLASS_WITH_INTERFACE, - '$properties' => array('_object' => self::TEST_INTERFACE_IMPLEMENTATION), - ), - 'model with alias' => array( - '$actualClassName' => self::TEST_CLASS_ALIAS, - '$properties' => array(), - '$expectedClassName' => self::TEST_CLASS, - ), - ); - - foreach ($this->_numerableClasses as $number => $className) { - $properties = array(); - for ($i = 1; $i <= $number; $i++) { - $propertyName = $this->_numerableProperties[$i]; - $properties[$propertyName] = self::TEST_CLASS; - } - $data[$number . ' arguments'] = array( - '$actualClassName' => $className, - '$properties' => $properties, - ); - } - - return $data; - } - - /** - * @param string $actualClassName - * @param array $properties - * @param string|null $expectedClassName - * - * @dataProvider newInstanceDataProvider - */ - public function testNewInstance($actualClassName, array $properties = array(), $expectedClassName = null) - { - if (!$expectedClassName) { - $expectedClassName = $actualClassName; - } - - $testObject = self::$_objectManager->create($actualClassName); - $this->assertInstanceOf($expectedClassName, $testObject); - - if ($properties) { - foreach ($properties as $propertyName => $propertyClass) { - $this->assertAttributeInstanceOf($propertyClass, $propertyName, $testObject); - } - } - } -} diff --git a/dev/tests/integration/testsuite/Magento/File/SizeTest.php b/dev/tests/integration/testsuite/Magento/File/SizeTest.php index 5d54d8ab9bda3..23e93072cfdf6 100644 --- a/dev/tests/integration/testsuite/Magento/File/SizeTest.php +++ b/dev/tests/integration/testsuite/Magento/File/SizeTest.php @@ -40,11 +40,6 @@ public function setUp() $this->_fileSize = Mage::getObjectManager()->get('Magento_File_Size'); } - protected function tearDown() - { - $this->_fileSize = null; - } - /** * @covers Mage_Core_Helper_File_Storage::getMaxFileSize * @backupStaticAttributes diff --git a/dev/tests/integration/testsuite/Magento/ObjectManager/ObjectManagerTest.php b/dev/tests/integration/testsuite/Magento/ObjectManager/ObjectManagerTest.php new file mode 100644 index 0000000000000..9c242c627ba1e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ObjectManager/ObjectManagerTest.php @@ -0,0 +1,158 @@ + 'Magento_ObjectManager_TestAsset_ConstructorNoArguments', + 1 => 'Magento_ObjectManager_TestAsset_ConstructorOneArgument', + 2 => 'Magento_ObjectManager_TestAsset_ConstructorTwoArguments', + 3 => 'Magento_ObjectManager_TestAsset_ConstructorThreeArguments', + 4 => 'Magento_ObjectManager_TestAsset_ConstructorFourArguments', + 5 => 'Magento_ObjectManager_TestAsset_ConstructorFiveArguments', + 6 => 'Magento_ObjectManager_TestAsset_ConstructorSixArguments', + 7 => 'Magento_ObjectManager_TestAsset_ConstructorSevenArguments', + 8 => 'Magento_ObjectManager_TestAsset_ConstructorEightArguments', + 9 => 'Magento_ObjectManager_TestAsset_ConstructorNineArguments', + 10 => 'Magento_ObjectManager_TestAsset_ConstructorTenArguments', + ); + + /** + * Names of properties + * + * @var array + */ + protected $_numerableProperties = array( + 1 => '_one', + 2 => '_two', + 3 => '_three', + 4 => '_four', + 5 => '_five', + 6 => '_six', + 7 => '_seven', + 8 => '_eight', + 9 => '_nine', + 10 => '_ten', + ); + + public static function setUpBeforeClass() + { + self::$_objectManager = new Magento_ObjectManager_ObjectManager(); + self::$_objectManager->configure(array( + 'preferences' => array( + self::TEST_INTERFACE => self::TEST_INTERFACE_IMPLEMENTATION + ) + )); + + } + + public static function tearDownAfterClass() + { + self::$_objectManager = null; + } + + /** + * Data provider for testNewInstance + * + * @return array + */ + public function newInstanceDataProvider() + { + $data = array( + 'basic model' => array( + '$actualClassName' => self::TEST_CLASS_INJECTION, + '$properties' => array('_object' => self::TEST_CLASS), + ), + 'model with interface' => array( + '$actualClassName' => self::TEST_CLASS_WITH_INTERFACE, + '$properties' => array('_object' => self::TEST_INTERFACE_IMPLEMENTATION), + ), + ); + + foreach ($this->_numerableClasses as $number => $className) { + $properties = array(); + for ($i = 1; $i <= $number; $i++) { + $propertyName = $this->_numerableProperties[$i]; + $properties[$propertyName] = self::TEST_CLASS; + } + $data[$number . ' arguments'] = array( + '$actualClassName' => $className, + '$properties' => $properties, + ); + } + + return $data; + } + + /** + * @param string $actualClassName + * @param array $properties + * @param string|null $expectedClassName + * + * @dataProvider newInstanceDataProvider + */ + public function testNewInstance($actualClassName, array $properties = array(), $expectedClassName = null) + { + if (!$expectedClassName) { + $expectedClassName = $actualClassName; + } + + $testObject = self::$_objectManager->create($actualClassName); + $this->assertInstanceOf($expectedClassName, $testObject); + + if ($properties) { + foreach ($properties as $propertyName => $propertyClass) { + $this->assertAttributeInstanceOf($propertyClass, $propertyName, $testObject); + } + } + } +} diff --git a/dev/tests/integration/testsuite/Magento/Di/TestAsset/Basic.php b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/Basic.php similarity index 92% rename from dev/tests/integration/testsuite/Magento/Di/TestAsset/Basic.php rename to dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/Basic.php index 31628760ab410..43301141ad7c9 100644 --- a/dev/tests/integration/testsuite/Magento/Di/TestAsset/Basic.php +++ b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/Basic.php @@ -19,12 +19,12 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Di + * @package Magento_ObjectManager * @subpackage integration_tests * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Magento_Di_TestAsset_Basic +class Magento_ObjectManager_TestAsset_Basic { } diff --git a/dev/tests/integration/testsuite/Magento/Di/TestAsset/BasicAlias.php b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/BasicAlias.php similarity index 91% rename from dev/tests/integration/testsuite/Magento/Di/TestAsset/BasicAlias.php rename to dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/BasicAlias.php index 5a01e0137fd4f..fcec30c2f3053 100644 --- a/dev/tests/integration/testsuite/Magento/Di/TestAsset/BasicAlias.php +++ b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/BasicAlias.php @@ -19,12 +19,12 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Di + * @package Magento_ObjectManager * @subpackage integration_tests * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Magento_Di_TestAsset_BasicAlias +class Magento_ObjectManager_TestAsset_BasicAlias { } diff --git a/dev/tests/integration/testsuite/Magento/Di/TestAsset/BasicInjection.php b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/BasicInjection.php similarity index 79% rename from dev/tests/integration/testsuite/Magento/Di/TestAsset/BasicInjection.php rename to dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/BasicInjection.php index 0885516d5ef06..919628c25cab1 100644 --- a/dev/tests/integration/testsuite/Magento/Di/TestAsset/BasicInjection.php +++ b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/BasicInjection.php @@ -19,23 +19,23 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Di + * @package Magento_ObjectManager * @subpackage integration_tests * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Magento_Di_TestAsset_BasicInjection +class Magento_ObjectManager_TestAsset_BasicInjection { /** - * @var Magento_Di_TestAsset_Basic + * @var Magento_ObjectManager_TestAsset_Basic */ protected $_object; /** - * @param Magento_Di_TestAsset_Basic $object + * @param Magento_ObjectManager_TestAsset_Basic $object */ - public function __construct(Magento_Di_TestAsset_Basic $object) + public function __construct(Magento_ObjectManager_TestAsset_Basic $object) { $this->_object = $object; } diff --git a/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorEightArguments.php b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorEightArguments.php new file mode 100644 index 0000000000000..ed5a37877e22f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorEightArguments.php @@ -0,0 +1,64 @@ +_eight = $eight; + } +} diff --git a/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorFiveArguments.php b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorFiveArguments.php new file mode 100644 index 0000000000000..fb9c40082bca1 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorFiveArguments.php @@ -0,0 +1,55 @@ +_five = $five; + } +} diff --git a/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorFourArguments.php b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorFourArguments.php new file mode 100644 index 0000000000000..7e167daf6b2c3 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorFourArguments.php @@ -0,0 +1,53 @@ +_four = $four; + } +} diff --git a/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorNineArguments.php b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorNineArguments.php new file mode 100644 index 0000000000000..4a1f4bf1f31d8 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorNineArguments.php @@ -0,0 +1,66 @@ +_nine = $nine; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorNoArguments.php b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorNoArguments.php similarity index 91% rename from dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorNoArguments.php rename to dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorNoArguments.php index 74622ee9bc26e..f89dac3dd987f 100644 --- a/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorNoArguments.php +++ b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorNoArguments.php @@ -19,13 +19,13 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Di + * @package Magento_ObjectManager * @subpackage integration_tests * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Magento_Di_TestAsset_ConstructorNoArguments +class Magento_ObjectManager_TestAsset_ConstructorNoArguments { /** * No arguments diff --git a/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorOneArgument.php b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorOneArgument.php similarity index 82% rename from dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorOneArgument.php rename to dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorOneArgument.php index 10cc9bf9cdfcc..4d493ccae8643 100644 --- a/dev/tests/integration/testsuite/Magento/Di/TestAsset/ConstructorOneArgument.php +++ b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorOneArgument.php @@ -19,16 +19,16 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Di + * @package Magento_ObjectManager * @subpackage integration_tests * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Magento_Di_TestAsset_ConstructorOneArgument +class Magento_ObjectManager_TestAsset_ConstructorOneArgument { /** - * @var Magento_Di_TestAsset_Basic + * @var Magento_ObjectManager_TestAsset_Basic */ protected $_one; @@ -39,10 +39,10 @@ class Magento_Di_TestAsset_ConstructorOneArgument /** * One argument * - * @param Magento_Di_TestAsset_Basic $one + * @param Magento_ObjectManager_TestAsset_Basic $one */ public function __construct( - Magento_Di_TestAsset_Basic $one + Magento_ObjectManager_TestAsset_Basic $one ) { $this->_one = $one; } diff --git a/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorSevenArguments.php b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorSevenArguments.php new file mode 100644 index 0000000000000..613a574a60352 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorSevenArguments.php @@ -0,0 +1,62 @@ +_seven = $seven; + } +} diff --git a/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorSixArguments.php b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorSixArguments.php new file mode 100644 index 0000000000000..c469f883a078a --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorSixArguments.php @@ -0,0 +1,57 @@ +_six = $six; + } +} diff --git a/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorTenArguments.php b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorTenArguments.php new file mode 100644 index 0000000000000..63442b3c4cc05 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorTenArguments.php @@ -0,0 +1,70 @@ +_ten = $ten; + } +} diff --git a/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorThreeArguments.php b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorThreeArguments.php new file mode 100644 index 0000000000000..8f9d6cc4c4160 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorThreeArguments.php @@ -0,0 +1,51 @@ +_three = $three; + } +} diff --git a/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorTwoArguments.php b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorTwoArguments.php new file mode 100644 index 0000000000000..217c1a75d8ae9 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/ConstructorTwoArguments.php @@ -0,0 +1,49 @@ +_two = $two; + } +} diff --git a/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/Interface.php b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/Interface.php new file mode 100644 index 0000000000000..20104b2273e13 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ObjectManager/TestAsset/Interface.php @@ -0,0 +1,30 @@ +_object = $object; } diff --git a/dev/tests/integration/testsuite/Phoenix/Moneybookers/Block/FormTest.php b/dev/tests/integration/testsuite/Phoenix/Moneybookers/Block/FormTest.php index c4bddbd689b74..853683df48de1 100644 --- a/dev/tests/integration/testsuite/Phoenix/Moneybookers/Block/FormTest.php +++ b/dev/tests/integration/testsuite/Phoenix/Moneybookers/Block/FormTest.php @@ -39,11 +39,6 @@ protected function setUp() $this->_block = $blockFactory->createBlock('Phoenix_Moneybookers_Block_Form'); } - protected function tearDown() - { - unset($this->_block); - } - public function testConstruct() { $this->assertStringEndsWith('form.phtml', $this->_block->getTemplate()); diff --git a/dev/tests/integration/testsuite/Varien/Cache/CoreTest.php b/dev/tests/integration/testsuite/Varien/Cache/CoreTest.php new file mode 100644 index 0000000000000..a66d473a78aba --- /dev/null +++ b/dev/tests/integration/testsuite/Varien/Cache/CoreTest.php @@ -0,0 +1,67 @@ +getMock('Zend_Cache_Backend_File'); + $config = array( + 'backend_decorators' => array( + 'test_decorator' => array( + 'class' => 'Magento_Cache_Backend_Decorator_Compression', + 'options' => array( + 'compression_threshold' => '100', + ) + ) + ) + ); + + $core = new Varien_Cache_Core($config); + $core->setBackend($mockBackend); + + $this->assertInstanceOf('Magento_Cache_Backend_Decorator_DecoratorAbstract', $core->getBackend()); + } + + /** + * @expectedException Zend_Cache_Exception + */ + public function testSetBackendException() + { + $mockBackend = $this->getMock('Zend_Cache_Backend_File'); + $config = array( + 'backend_decorators' => array( + 'test_decorator' => array( + 'class' => 'Zend_Cache_Backend', + ) + ) + ); + + $core = new Varien_Cache_Core($config); + $core->setBackend($mockBackend); + } +} diff --git a/dev/tests/integration/testsuite/Varien/Db/Adapter/Pdo/MysqlTest.php b/dev/tests/integration/testsuite/Varien/Db/Adapter/Pdo/MysqlTest.php index c7feb9cb9b26b..ee662ba8633f5 100644 --- a/dev/tests/integration/testsuite/Varien/Db/Adapter/Pdo/MysqlTest.php +++ b/dev/tests/integration/testsuite/Varien/Db/Adapter/Pdo/MysqlTest.php @@ -37,11 +37,6 @@ class Varien_Db_Adapter_Pdo_MysqlTest extends PHPUnit_Framework_TestCase */ protected $_dbAdapter = null; - protected function tearDown() - { - $this->_dbAdapter = null; - } - /** * Test lost connection re-initializing * diff --git a/dev/tests/integration/testsuite/integrity/ConfigTest.php b/dev/tests/integration/testsuite/integrity/ConfigTest.php new file mode 100644 index 0000000000000..bb64a96eb594a --- /dev/null +++ b/dev/tests/integration/testsuite/integrity/ConfigTest.php @@ -0,0 +1,66 @@ +assertObjectHasAttribute($requiredNode, $node, + "Required '$requiredNode' node is not specified for '" . $node->getName() . "' cache type"); + } + + $this->assertTrue(class_exists($node->class), + "Class '{$node->class}', specified for '" . $node->getName() . "' cache type, doesn't exist"); + $interfaces = class_implements((string) $node->class); + $this->assertContains('Magento_Cache_FrontendInterface', $interfaces, + "Class '{$node->class}', specified for '" . $node->getName() + . "' cache type, must implement 'Magento_Cache_FrontendInterface'" + ); + } + + /** + * @return array + */ + public function cacheTypesDataProvider() + { + $config = Mage::app()->getConfig(); + $nodes = array(); + /** @var $node SimpleXMLElement */ + foreach ($config->getXpath('/config/global/cache/types/*') as $node) { + $nodes[$node->getName()] = array($node); + } + + return $nodes; + } +} diff --git a/dev/tests/integration/testsuite/integrity/modular/AclConfigFilesTest.php b/dev/tests/integration/testsuite/integrity/modular/AclConfigFilesTest.php index 6ef04333c321b..1a13c7962d7c8 100644 --- a/dev/tests/integration/testsuite/integrity/modular/AclConfigFilesTest.php +++ b/dev/tests/integration/testsuite/integrity/modular/AclConfigFilesTest.php @@ -43,7 +43,7 @@ class Integrity_Modular_AclConfigFilesTest extends PHPUnit_Framework_TestCase public function setUp() { - $readerMock = $this->getMock('Magento_Acl_Config_Reader', array('getShemaFile'), array(), '', false); + $readerMock = $this->getMock('Magento_Acl_Config_Reader', array('_merge', '_extractData'), array(), '', false); $this->_schemeFile = $readerMock->getSchemaFile(); $this->_prepareFileList(); } @@ -54,7 +54,7 @@ public function setUp() protected function _prepareFileList() { if (empty($this->_fileList)) { - $this->_fileList = glob(Mage::getBaseDir('app') . '/*/*/*/*/etc/adminhtml/acl.xml'); + $this->_fileList = glob(Mage::getBaseDir('app') . '/*/*/*/etc/adminhtml/acl.xml'); } } @@ -69,7 +69,7 @@ public function testAclConfigFile($file) $result = $domConfig->validate($this->_schemeFile, $errors); $message = "Invalid XML-file: {$file}\n"; foreach ($errors as $error) { - $message .= "{$error->message} Line: {$error->line}\n"; + $message .= "$error\n"; } $this->assertTrue($result, $message); } diff --git a/dev/tests/integration/testsuite/integrity/modular/BlockInstantiationTest.php b/dev/tests/integration/testsuite/integrity/modular/BlockInstantiationTest.php new file mode 100644 index 0000000000000..82328a334bea4 --- /dev/null +++ b/dev/tests/integration/testsuite/integrity/modular/BlockInstantiationTest.php @@ -0,0 +1,105 @@ +assertTrue(class_exists($class), "Block class: {$class}"); + Mage::getConfig()->setCurrentAreaCode($area); + $block = Mage::getModel($class); + $this->assertNotNull($block); + } + + /** + * @return array + */ + public function allBlocksDataProvider() + { + $blockClass = ''; + $skipBlocks = array( + // blocks with abstract constructor arguments + // TODO: need to figure out how these typically work + "Mage_Adminhtml_Block_System_Email_Template", + "Mage_Adminhtml_Block_System_Email_Template_Edit", + "Mage_Backend_Block_System_Config_Edit", + "Mage_Backend_Block_System_Config_Form", + "Mage_Backend_Block_System_Config_Tabs", + ); + + try { + /** @var $website Mage_Core_Model_Website */ + Mage::app()->getStore()->setWebsiteId(0); + + $templateBlocks = array(); + $blockMods = Utility_Classes::collectModuleClasses('Block'); + foreach ($blockMods as $blockClass => $module) { + if (!in_array($module, $this->_getEnabledModules())) { + continue; + } + if (in_array($blockClass, $skipBlocks)) { + continue; + } + $class = new ReflectionClass($blockClass); + if ($class->isAbstract() || !$class->isSubclassOf('Mage_Core_Block_Template')) { + continue; + } + + $area = 'frontend'; + if ($module == 'Mage_Install') { + $area = 'install'; + } elseif ($module == 'Mage_Adminhtml' || strpos($blockClass, '_Adminhtml_') + || strpos($blockClass, '_Backend_') + || $class->isSubclassOf('Mage_Backend_Block_Template')) { + $area = 'adminhtml'; + } + + Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_ADMINHTML, + Mage_Core_Model_App_Area::PART_CONFIG); + + $templateBlocks[$module . ', ' . $blockClass . ', ' . $area] = + array($module, $blockClass, $area); + } + return $templateBlocks; + } catch (Exception $e) { + trigger_error("Corrupted data provider. Last known block instantiation attempt: '{$blockClass}'." + . " Exception: {$e}", E_USER_ERROR); + } + } +} diff --git a/dev/tests/integration/testsuite/integrity/modular/CodePoolConfigTest.php b/dev/tests/integration/testsuite/integrity/modular/CodePoolConfigTest.php new file mode 100644 index 0000000000000..3f87ffaec30b3 --- /dev/null +++ b/dev/tests/integration/testsuite/integrity/modular/CodePoolConfigTest.php @@ -0,0 +1,51 @@ +_config = Mage::getSingleton('Mage_Core_Model_Config'); + } + + public function testCodePoolConfigNode() + { + $result = array(); + $modulesConfig = $this->_config->getNode('modules'); + /** @var $moduleConfig Varien_Simplexml_Element */ + foreach ($modulesConfig->children() as $moduleConfig) { + if (array_key_exists('codePool', $moduleConfig->asArray())) { + $result[] = $moduleConfig->getName(); + } + } + $this->assertEquals(array(), $result, 'Specified modules contain obsolete codePool configuration'); + } +} diff --git a/dev/tests/integration/testsuite/integrity/modular/MenuConfigFilesTest.php b/dev/tests/integration/testsuite/integrity/modular/MenuConfigFilesTest.php index 5d2a8e905dbcc..dd9adf12fcca2 100644 --- a/dev/tests/integration/testsuite/integrity/modular/MenuConfigFilesTest.php +++ b/dev/tests/integration/testsuite/integrity/modular/MenuConfigFilesTest.php @@ -47,11 +47,6 @@ public function setUp() ); } - protected function tearDown() - { - $this->_model = null; - } - /** * Get Configuration File List * @return array @@ -59,7 +54,7 @@ protected function tearDown() protected function _getConfigurationFileList() { if (empty($this->_fileList)) { - foreach (glob(Mage::getBaseDir('app') . '/*/*/*/*/etc/adminhtml/menu.xml') as $file) { + foreach (glob(Mage::getBaseDir('app') . '/*/*/*/etc/adminhtml/menu.xml') as $file) { $this->_fileList[$file] = $file; } } diff --git a/dev/tests/integration/testsuite/integrity/modular/SystemConfigFilesTest.php b/dev/tests/integration/testsuite/integrity/modular/SystemConfigFilesTest.php index 754543609eb01..a2059f652e350 100644 --- a/dev/tests/integration/testsuite/integrity/modular/SystemConfigFilesTest.php +++ b/dev/tests/integration/testsuite/integrity/modular/SystemConfigFilesTest.php @@ -29,26 +29,37 @@ class Integrity_Modular_SystemConfigFilesTest extends PHPUnit_Framework_TestCase { public function testConfiguration() { - $fileList = glob(Mage::getBaseDir('app') . '/*/*/*/*/etc/adminhtml/system.xml'); + $objectManager = Mage::getObjectManager(); + + // disable config caching to not pollute it + /** @var $cacheTypes Mage_Core_Model_Cache_Types */ + $cacheTypes = $objectManager->get('Mage_Core_Model_Cache_Types'); + $cacheTypes->setEnabled(Mage_Core_Model_Cache_Type_Config::TYPE_IDENTIFIER, false); + + /** @var $dirs Mage_Core_Model_Dir */ + $dirs = $objectManager->get('Mage_Core_Model_Dir'); + $modulesDir = $dirs->getDir(Mage_Core_Model_Dir::MODULES); + + $fileList = glob($modulesDir . '/*/*/etc/adminhtml/system.xml'); + + $configMock = $this->getMock( + 'Mage_Core_Model_Config_Modules_Reader', array('getModuleConfigurationFiles', 'getModuleDir'), + array(), '', false + ); + $configMock->expects($this->any()) + ->method('getModuleConfigurationFiles') + ->will($this->returnValue($fileList)) + ; + $configMock->expects($this->any()) + ->method('getModuleDir') + ->with('etc', 'Mage_Backend') + ->will($this->returnValue($modulesDir . '/Mage/Backend/etc')) + ; try { - $configMock = $this->getMock( - 'Mage_Core_Model_Config_Modules_Reader', array('getModuleConfigurationFiles', 'getModuleDir'), - array(), '', false - ); - $configMock->expects($this->any()) - ->method('getModuleConfigurationFiles') - ->will($this->returnValue($fileList)); - $configMock->expects($this->any()) - ->method('getModuleDir') - ->will($this->returnValue(Mage::getBaseDir('app') . '/code/core/Mage/Backend/etc')); - $cacheMock = $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false); - $cacheMock->expects($this->any())->method('canUse')->will($this->returnValue(false)); - $converter = new Mage_Backend_Model_Config_Structure_Converter( - new Mage_Backend_Model_Config_Structure_Mapper_Factory(Mage::getObjectManager()) - ); - new Mage_Backend_Model_Config_Structure_Reader( - $cacheMock, $configMock, $converter, true - ); + $objectManager->create('Mage_Backend_Model_Config_Structure_Reader', array( + 'moduleReader' => $configMock, + 'runtimeValidation' => true, + )); } catch (Magento_Exception $exp) { $this->fail($exp->getMessage()); } diff --git a/dev/tests/integration/testsuite/integrity/modular/TemplateFilesTest.php b/dev/tests/integration/testsuite/integrity/modular/TemplateFilesTest.php index 54e3ead532e92..566feb8e7f77f 100644 --- a/dev/tests/integration/testsuite/integrity/modular/TemplateFilesTest.php +++ b/dev/tests/integration/testsuite/integrity/modular/TemplateFilesTest.php @@ -75,14 +75,12 @@ public function allTemplatesDataProvider() $area = 'install'; } elseif ($module == 'Mage_Adminhtml' || strpos($blockClass, '_Adminhtml_') || strpos($blockClass, '_Backend_') - || ($this->_isClassInstanceOf($blockClass, 'Mage_Backend_Block_Template')) - ) { + || $class->isSubclassOf('Mage_Backend_Block_Template')) + { $area = 'adminhtml'; } - Mage::app()->loadAreaPart( - Mage_Core_Model_App_Area::AREA_ADMINHTML, Mage_Core_Model_App_Area::AREA_ADMINHTML - ); + Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_ADMINHTML, Mage_Core_Model_App_Area::PART_CONFIG); Mage::getConfig()->setCurrentAreaCode($area); $block = Mage::getModel($blockClass); @@ -98,25 +96,4 @@ public function allTemplatesDataProvider() . " Exception: {$e}", E_USER_ERROR); } } - - /** - * @param string $blockClass - * @param string $parentClass - * @return bool - */ - protected function _isClassInstanceOf($blockClass, $parentClass) - { - $currentClass = new ReflectionClass($blockClass); - $supertypes = array(); - do { - $supertypes = array_merge($supertypes, $currentClass->getInterfaceNames()); - if (!($currentParent = $currentClass->getParentClass())) { - break; - } - $supertypes[] = $currentParent->getName(); - $currentClass = $currentParent; - } while (true); - - return in_array($parentClass, $supertypes); - } } diff --git a/dev/tests/integration/testsuite/integrity/theme/ViewFilesTest.php b/dev/tests/integration/testsuite/integrity/theme/ViewFilesTest.php index 9cfbfffeb045b..899b2014e000b 100644 --- a/dev/tests/integration/testsuite/integrity/theme/ViewFilesTest.php +++ b/dev/tests/integration/testsuite/integrity/theme/ViewFilesTest.php @@ -34,31 +34,35 @@ class Integrity_Theme_ViewFilesTest extends Magento_Test_TestCase_IntegrityAbstr */ public function testViewFilesFromThemes($theme, $file) { - $params = array( - 'area' => $theme->getArea(), - 'themeModel' => $theme - ); - $viewFile = Mage::getDesign()->getViewFile($file, $params); - $this->assertFileExists($viewFile); + try { + $params = array( + 'area' => $theme->getArea(), + 'themeModel' => $theme + ); + $viewFile = Mage::getDesign()->getViewFile($file, $params); + $this->assertFileExists($viewFile); - $fileParts = explode(Mage_Core_Model_Design_Package::SCOPE_SEPARATOR, $file); - if (count($fileParts) > 1) { - $params['module'] = $fileParts[0]; - } - if (pathinfo($file, PATHINFO_EXTENSION) == 'css') { - $errors = array(); - $content = file_get_contents($viewFile); - preg_match_all(Mage_Core_Model_Design_Package::REGEX_CSS_RELATIVE_URLS, $content, $matches); - foreach ($matches[1] as $relativePath) { - $path = $this->_addCssDirectory($relativePath, $file); - $pathFile = Mage::getDesign()->getViewFile($path, $params); - if (!is_file($pathFile)) { - $errors[] = $relativePath; - } + $fileParts = explode(Mage_Core_Model_Design_Package::SCOPE_SEPARATOR, $file); + if (count($fileParts) > 1) { + $params['module'] = $fileParts[0]; } - if (!empty($errors)) { - $this->fail('Can not find file(s): ' . implode(', ', $errors)); + if (pathinfo($file, PATHINFO_EXTENSION) == 'css') { + $errors = array(); + $content = file_get_contents($viewFile); + preg_match_all(Mage_Core_Model_Design_Package::REGEX_CSS_RELATIVE_URLS, $content, $matches); + foreach ($matches[1] as $relativePath) { + $path = $this->_addCssDirectory($relativePath, $file); + $pathFile = Mage::getDesign()->getViewFile($path, $params); + if (!is_file($pathFile)) { + $errors[] = $relativePath; + } + } + if (!empty($errors)) { + $this->fail('Can not find file(s): ' . implode(', ', $errors)); + } } + } catch (Exception $e) { + $this->fail($e->getMessage()); } } diff --git a/dev/tests/js/jsTestDriver.php.dist b/dev/tests/js/jsTestDriver.php.dist index ffdca0837731a..d7b7550186be7 100644 --- a/dev/tests/js/jsTestDriver.php.dist +++ b/dev/tests/js/jsTestDriver.php.dist @@ -34,15 +34,15 @@ return array( '/pub/lib/mage/translate.js', '/pub/lib/jquery/jquery-ui-timepicker-addon.js', '/pub/lib/jquery/jquery.tmpl.min.js', - '/app/code/core/Mage/DesignEditor/view/adminhtml/js/base.js', - '/app/code/core/Mage/DesignEditor/view/adminhtml/js/design_editor.js', - '/app/code/core/Mage/DesignEditor/view/frontend/js/change/layout.js', - '/app/code/core/Mage/DesignEditor/view/frontend/js/design_editor.js', - '/app/code/core/Mage/DesignEditor/view/frontend/js/form_deactivation.js', - '/app/code/core/Mage/DesignEditor/view/adminhtml/js/infinitescroll.js', + '/app/code/Mage/DesignEditor/view/adminhtml/js/base.js', + '/app/code/Mage/DesignEditor/view/adminhtml/js/design_editor.js', + '/app/code/Mage/DesignEditor/view/frontend/js/change/layout.js', + '/app/code/Mage/DesignEditor/view/frontend/js/design_editor.js', + '/app/code/Mage/DesignEditor/view/frontend/js/form_deactivation.js', + '/app/code/Mage/DesignEditor/view/adminhtml/js/infinitescroll.js', '/pub/lib/jquery/jstree/jquery.jstree.js', '/pub/lib/jquery/slimScroll/slimScroll.min.js', - '/app/code/core/Mage/DesignEditor/view/frontend/css/styles.css', + '/app/code/Mage/DesignEditor/view/frontend/css/styles.css', '/pub/lib/mage/cookies.js', '/pub/lib/mage/calendar.js', '/pub/lib/mage/loader.js', @@ -52,7 +52,9 @@ return array( '/pub/lib/mage/backend/button.js', '/pub/lib/mage/backend/tabs.js', '/pub/lib/mage/validation.js', - '/pub/lib/mage/validation/validation.js' + '/pub/lib/mage/validation/validation.js', + '/pub/lib/mage/backend/suggest.js' + '/pub/lib/mage/backend/tree-suggest.js' ), 'test' => array('/dev/tests/js/testsuite'), 'JsTestDriver' => '{{path_to_jstestdriver_jar}}' diff --git a/dev/tests/js/run_js_tests.php b/dev/tests/js/run_js_tests.php index c60aa73faa8f1..7a6ae5883ca0b 100644 --- a/dev/tests/js/run_js_tests.php +++ b/dev/tests/js/run_js_tests.php @@ -138,17 +138,19 @@ mkdir($testOutput); $command - = 'java -jar "' . $jsTestDriver . '" --config "' . $jsTestDriverConf . '" --port ' . $port . - ' --browser "' . $browser . '" --tests all --testOutput "' . $testOutput . '"'; + = 'java -jar "' . $jsTestDriver . '" --config "' . $jsTestDriverConf . '" --reset --port ' . $port . + ' --browser "' . $browser . '" --raiseOnFailure true --tests all --testOutput "' . $testOutput . '"'; echo $command . PHP_EOL; if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { system($command); } else { + $commandFile = __DIR__ . '/run_js_tests.sh'; + $fh = fopen($commandFile, 'w'); + $shellCommand - = '#!/bin/bash - LSOF=`/usr/sbin/lsof -i :' . $port . ' -t` + = 'LSOF=`/usr/sbin/lsof -i :' . $port . ' -t` if [ "$LSOF" != "" ]; then kill -9 $LSOF @@ -162,17 +164,21 @@ exit 1 fi - $XVFB :99 -nolisten inet6 -screen 0 1024x768x24 -ac & - PID_XVFB="$!" # take the process ID - export DISPLAY=:99.0 # set display to use that of the Xvfb + $XVFB :99 -nolisten inet6 -ac & + PID_XVFB="$!" # take the process ID + export DISPLAY=:99 # set display to use that of the Xvfb # run the tests ' . $command . ' - kill $PID_XVFB # shut down Xvfb (firefox will shut down cleanly by JsTestDriver) + kill -9 $PID_XVFB # shut down Xvfb (firefox will shut down cleanly by JsTestDriver) echo "Done."'; - system($shellCommand); + fwrite($fh, $shellCommand . PHP_EOL); + fclose($fh); + chmod($commandFile, 0750); + + exec($commandFile); } /** diff --git a/dev/tests/js/testsuite/mage/suggest/suggest-test.js b/dev/tests/js/testsuite/mage/suggest/suggest-test.js new file mode 100644 index 0000000000000..e48478b76a0b0 --- /dev/null +++ b/dev/tests/js/testsuite/mage/suggest/suggest-test.js @@ -0,0 +1,923 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category mage.js + * @package test + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +SuggestTest = TestCase('SuggestTest'); +SuggestTest.prototype.setUp = function() { + /*:DOC += */ + this.suggestElement = jQuery('#suggest'); +}; +SuggestTest.prototype.tearDown = function() { + this.suggestDestroy(); +}; +SuggestTest.prototype.suggestDestroy = function() { + if(this.suggestElement.data('suggest')) { + this.suggestElement.suggest('destroy'); + } +}; +SuggestTest.prototype.suggestCreate = function(options, element) { + return (element || this.suggestElement).suggest(options || {} ).data('suggest'); +}; +SuggestTest.prototype.uiHash = { + item: { + id: 1, + label: 'Test Label' + } +}; + +SuggestTest.prototype.testInit = function() { + this.suggestElement.suggest(); + assertTrue(this.suggestElement.is(':mage-suggest')); +}; +SuggestTest.prototype.testCreate = function() { + var suggestOptions = { + controls: { + selector: '.test', + eventsMap: { + focus: ['testfocus'], + blur: ['testblur'], + select: ['testselect'] + } + }, + showRecent: true, + storageKey: 'jsTestDriver-test-suggest-recent', + multiselect: true + }, + recentItems = [{ + id: "1", + "label": "TestLabel1" + }, + { + id: "2", + label: "TestLabel2" + }], + setTemplateExecuted, + prepareValueFieldExecuted, + renderExecuted, + bindExecuted; + + if(window.localStorage) { + localStorage.setItem(suggestOptions.storageKey, JSON.stringify(recentItems)); + } + + var suggestInstance = this.suggestCreate(suggestOptions), + nonSelectedItem = {id: '', label: ''}; + + assertEquals(suggestInstance._term, ''); + assertEquals(suggestInstance._nonSelectedItem, nonSelectedItem); + assertNull(suggestInstance._renderedContext); + assertEquals(suggestInstance._selectedItem, nonSelectedItem); + var control = suggestInstance.options.controls; + assertEquals(suggestInstance._control, control); + assertEquals(suggestInstance._recentItems, window.localStorage ? recentItems : []); + assertTrue(suggestInstance.valueField.is(':hidden')); + if(window.localStorage) { + localStorage.removeItem(suggestOptions.storageKey); + } +}; +SuggestTest.prototype.testRender = function() { + var suggestOptions = { + dropdownWrapper: '
    ', + className: 'test-suggest', + inputWrapper: '
    ' + } + + var suggestInstance = this.suggestCreate(suggestOptions); + suggestInstance._render(); + + assertTrue(suggestInstance.dropdown.hasClass('wrapper-test')); + assertTrue(suggestInstance.dropdown.is(':hidden')); + assertTrue(suggestInstance.element.closest('.test-input-wrapper').size() > 0); + assertTrue(suggestInstance.element.closest('.' + suggestOptions.className).size() > 0); + assertEquals(suggestInstance.element.attr('autocomplete'), 'off'); + + suggestOptions.appendMethod = 'before'; + this.suggestDestroy(); + suggestInstance = this.suggestCreate(suggestOptions); + suggestInstance._render(); + assertTrue(suggestInstance.element.prev().is(suggestInstance.dropdown)); + + suggestOptions.appendMethod = 'after'; + this.suggestDestroy(); + suggestInstance = this.suggestCreate(suggestOptions); + suggestInstance._render(); + assertTrue(suggestInstance.element.next().is(suggestInstance.dropdown)); +}; +SuggestTest.prototype.testCreateValueField = function() { + var suggestInstance = this.suggestCreate(), + valueField = suggestInstance._createValueField(); + assertTrue(valueField.is('input')); + assertTrue(valueField.is(':hidden')); + this.suggestDestroy(); + + suggestInstance = this.suggestCreate({multiselect: true}); + valueField = suggestInstance._createValueField(); + assertTrue(valueField.is('select')); + assertTrue(valueField.is(':hidden')); + assertEquals(valueField.attr('multiple'), 'multiple'); +}; +SuggestTest.prototype.testPrepareValueField = function() { + var suggestInstance = this.suggestCreate(), + suggestName = this.suggestElement.attr('name'); + suggestInstance._prepareValueField(); + + assertNotUndefined(suggestInstance.valueField); + assertTrue(suggestInstance.element.prev().is(suggestInstance.valueField)); + assertUndefined(suggestInstance.element.attr('name')); + assertEquals(suggestInstance.valueField.attr('name'), suggestName); + this.suggestDestroy(); + + + var valueField = jQuery(''); + jQuery('body').append(valueField); + suggestInstance = this.suggestCreate({valueField: '#suggest-single-select-value'}); + assertTrue(suggestInstance.valueField.is(valueField)); +}; +SuggestTest.prototype.testDestroy = function() { + var suggestOptions = { + inputWrapper: '
    ', + valueField: null + }, + suggestInstance = this.suggestCreate(suggestOptions), + suggestName = suggestInstance.valueField.attr('name'); + + assertNotUndefined(suggestInstance.dropdown); + assertNotUndefined(suggestInstance.valueField); + assertUndefined(this.suggestElement.attr('name')); + + this.suggestElement.suggest('destroy'); + + assertEquals(this.suggestElement.closest('.test-input-wrapper').length, 0); + assertUndefined(this.suggestElement.attr('autocomplete')); + assertEquals(this.suggestElement.attr('name'), suggestName); + assertFalse(suggestInstance.valueField.parents('html').length > 0); + assertFalse(suggestInstance.dropdown.parents('html').length > 0); +}; +SuggestTest.prototype.testValue = function() { + var value = 'test-value'; + this.suggestElement.val(value); + jQuery('body').append('
    ' + value + '
    '); + + var suggestInputInsatnce = this.suggestCreate(), + suggestDivInsatnce = this.suggestCreate(null, jQuery('#suggest-div')); + + assertEquals(suggestInputInsatnce._value(), value); + assertEquals(suggestDivInsatnce._value(), value); +}; +SuggestTest.prototype.testProxyEvents = function() { + var fakeEvent = $.extend({}, $.Event('keydown'), { + ctrlKey: false, + keyCode: $.ui.keyCode.ENTER, + which: $.ui.keyCode.ENTER + }), + suggestInstance = this.suggestCreate({controls: {selector: null}}), + ctrlKey, + keyCode, + which; + + suggestInstance.dropdown.on('keydown', function(e) { + ctrlKey = e.ctrlKey; + keyCode = e.keyCode; + which = e.which; + }); + + suggestInstance._proxyEvents(fakeEvent); + + assertEquals(ctrlKey, fakeEvent.ctrlKey); + assertEquals(keyCode, fakeEvent.keyCode); + assertEquals(which, fakeEvent.which); +}; +SuggestTest.prototype.testBind = function() { + var eventIsBinded = false, + suggestOptions = { + events: { + click: function() { + eventIsBinded = true; + } + } + }; + this.suggestCreate(suggestOptions); + + this.suggestElement.trigger('click'); + assertTrue(eventIsBinded); +}; +SuggestTest.prototype.testChange = function() { + var changeIsTriggered, + suggestInstance = this.suggestCreate(); + + suggestInstance._term = 'changed'; + this.suggestElement.on('suggestchange', function(e) { + changeIsTriggered = true; + }); + + suggestInstance._change($.Event('click')); + assertTrue(changeIsTriggered); +}; +SuggestTest.prototype.testBindDropdown = function() { + var suggestOptions = { + controls: { + eventsMap: { + focus: ['testFocus'], + blur: ['testBlur'], + select: ['testSelect'] + } + } + }, + suggestInstance = this.suggestCreate(suggestOptions), + focusTriggered, + blurTriggered, + selectTriggered; + + suggestInstance._onSelectItem = function() { + selectTriggered = true + } + suggestInstance._focusItem = function() { + focusTriggered = true + } + suggestInstance._blurItem = function() { + blurTriggered = true + } + suggestInstance._bindDropdown(); + + suggestInstance.dropdown.trigger('testFocus'); + suggestInstance.dropdown.trigger('testBlur'); + suggestInstance.dropdown.trigger('testSelect'); + + assertTrue(focusTriggered); + assertTrue(blurTriggered); + assertTrue(selectTriggered); +}; +SuggestTest.prototype.testTrigger = function() { + var propogationStopped = true, + suggestInstance = this.suggestCreate(); + + this.suggestElement + .on('suggesttestevent', function() { + return false; + }) + this.suggestElement.parent().on('suggesttestevent', function() { + propogationStopped = false; + }) + suggestInstance._trigger('testevent'); + + assertTrue(propogationStopped); +}; +SuggestTest.prototype.testFocusItem = function() { + var focusUiParam = false, + suggestInstance = this.suggestCreate(); + + this.suggestElement.on('suggestfocus', function(e, ui) { + focusUiParam = ui; + }); + + assertUndefined(suggestInstance._focused); + assertEquals(suggestInstance.element.val(), ''); + + suggestInstance._focusItem($.Event('focus'), this.uiHash); + assertEquals(suggestInstance._focused, this.uiHash.item); + assertEquals(focusUiParam, this.uiHash); + assertEquals(suggestInstance.element.val(), this.uiHash.item.label); +}; +SuggestTest.prototype.testBlurItem = function() { + var suggestInstance = this.suggestCreate(); + + suggestInstance._focusItem($.Event('focus'), this.uiHash); + assertEquals(suggestInstance._focused, this.uiHash.item); + assertEquals(suggestInstance.element.val(), this.uiHash.item.label); + + suggestInstance._blurItem(); + assertNull(suggestInstance._focused); + assertEquals(suggestInstance.element.val(), suggestInstance._term); +}; +SuggestTest.prototype.testOnSelectItem = function() { + var item = this.uiHash.item, + beforeSelect, + beforeSelectUI, + beforeSelectPropagationStopped = true, + select, + selectUI, + selectPropagationStopped = true, + suggestInstance = this.suggestCreate(); + + suggestInstance._focused = item; + this.suggestElement + .on('suggestbeforeselect', function(e, ui) { + beforeSelect = true; + beforeSelectUI = ui; + }) + .on('suggestselect', function(e, ui) { + select = true; + selectUI = ui; + }) + .parent() + .on('suggestbeforeselect', function() { + beforeSelectPropagationStopped = false; + }) + .on('suggestselect', function() { + selectPropagationStopped = false; + }); + + suggestInstance._onSelectItem($.Event('select')); + + assertTrue(beforeSelect); + assertTrue(select); + assertFalse(beforeSelectPropagationStopped); + assertFalse(selectPropagationStopped); + assertEquals(beforeSelectUI.item, item); + assertEquals(selectUI.item, item); + + beforeSelect = select = beforeSelectUI = selectUI = null; + beforeSelectPropagationStopped = selectPropagationStopped = true; + + this.suggestElement + .on('suggestbeforeselect.returnfalse', function(e, ui) { + return false; + }); + + suggestInstance._onSelectItem($.Event('select')); + assertTrue(beforeSelect); + assertNull(select); + assertTrue(beforeSelectPropagationStopped); + assertTrue(selectPropagationStopped); + assertEquals(beforeSelectUI.item, item); + assertNull(selectUI); + + beforeSelect = select = beforeSelectUI = selectUI = null; + beforeSelectPropagationStopped = selectPropagationStopped = true; + + this.suggestElement + .off('suggestbeforeselect.returnfalse') + .on('suggestselect.returnfalse', function() { + return false; + }); + + suggestInstance._onSelectItem($.Event('select')); + assertTrue(beforeSelect); + assertTrue(select); + assertFalse(beforeSelectPropagationStopped); + assertTrue(selectPropagationStopped); + assertEquals(beforeSelectUI.item, item); + assertEquals(selectUI.item, item); + + beforeSelect = select = beforeSelectUI = selectUI = null; + beforeSelectPropagationStopped = selectPropagationStopped = true; + + this.suggestElement.off('suggestselect.returnfalse'); + var event = $.Event('select'); + event.target = this.suggestElement[0]; + + suggestInstance._onSelectItem(event, item); + assertEquals(suggestInstance._focused, item); +}; +SuggestTest.prototype.testSelectItem = function() { + var suggestInstance = this.suggestCreate(); + + suggestInstance._focused = suggestInstance._term = suggestInstance._selectedItem = null; + suggestInstance.valueField.val(''); + + suggestInstance._selectItem($.Event('select')); + assertNull(suggestInstance._selectedItem); + assertNull(suggestInstance._term); + assertEquals(suggestInstance.valueField.val(), ''); + + suggestInstance._focused = this.uiHash.item; + + suggestInstance._selectItem($.Event('select')); + assertEquals(suggestInstance._selectedItem, suggestInstance._focused); + assertEquals(suggestInstance._term, suggestInstance._focused.label); + assertEquals(suggestInstance.valueField.val(), suggestInstance._focused.id); + + this.suggestDestroy(); + + var suggestOptions; + if(window.localStorage) { + suggestOptions = { + showRecent: true, + storageKey: 'jsTestDriver-test-suggest-recent' + } + suggestInstance = this.suggestCreate(suggestOptions); + suggestInstance._focused = this.uiHash.item; + + suggestInstance._selectItem($.Event('select')); + + var storedItem = localStorage.getItem(suggestOptions.storageKey); + assertEquals(storedItem, JSON.stringify([this.uiHash.item])); + localStorage.removeItem(suggestOptions.storageKey); + } +}; +SuggestTest.prototype.testSelectItemMultiselect = function() { + var suggestInstance = this.suggestCreate({multiselect: true}); + + suggestInstance._focused = suggestInstance._term = suggestInstance._selectedItem = null; + suggestInstance.valueField.val(''); + + suggestInstance._selectItem($.Event('select')); + assertNull(suggestInstance._selectedItem); + assertNull(suggestInstance._term); + assertFalse(suggestInstance.valueField.find('option').length > 0); + + suggestInstance._focused = this.uiHash.item; + var selectedElement = jQuery('
    '); + var event = $.Event('select'); + event.target = selectedElement[0]; + + suggestInstance._selectItem(event); + assertEquals(suggestInstance._selectedItem, suggestInstance._focused); + assertEquals(suggestInstance._term, ''); + assertTrue(suggestInstance._getOption(suggestInstance._focused).length > 0); + assertTrue(selectedElement.hasClass(suggestInstance.options.selectedClass)); + + suggestInstance._selectItem(event); + assertEquals(suggestInstance._selectedItem, suggestInstance._nonSelectedItem); + assertFalse(suggestInstance._getOption(suggestInstance._focused).length > 0); + assertFalse(selectedElement.hasClass(suggestInstance.options.selectedClass)); +}; +SuggestTest.prototype.testReadItemData = function() { + var testElement = jQuery('
    '), + suggestInstance = this.suggestCreate(); + assertEquals(suggestInstance._readItemData(testElement), suggestInstance._nonSelectedItem); + testElement.data('suggestOption', 'test'); + assertEquals(suggestInstance._readItemData(testElement), 'test'); +}; +SuggestTest.prototype.testIsDropdownShown = function() { + var suggestInstance = this.suggestCreate(); + suggestInstance.dropdown.hide(); + assertFalse(suggestInstance.isDropdownShown()); + suggestInstance.dropdown.show(); + assertTrue(suggestInstance.isDropdownShown()); +}; +SuggestTest.prototype.testOpen = function() { + var openTriggered = false, + suggestInstance = this.suggestCreate(); + + this.suggestElement.on('suggestopen', function() { + openTriggered = true; + }); + + suggestInstance.dropdown.show(); + suggestInstance.open($.Event('open')); + assertFalse(openTriggered); + + suggestInstance.dropdown.hide(); + suggestInstance.open($.Event('open')); + assertTrue(openTriggered); + assertTrue(suggestInstance.dropdown.is(':visible')); +}; +SuggestTest.prototype.testClose = function() { + var closeTriggered = false, + suggestInstance = this.suggestCreate(); + + suggestInstance.element.val('test'); + suggestInstance._renderedContext = 'test'; + suggestInstance.dropdown.show().append('
    '); + + this.suggestElement.on('suggestclose', function() { + closeTriggered = true; + }); + + suggestInstance.close($.Event('close')); + assertEquals(suggestInstance.element.val(), ''); + assertNull(suggestInstance._renderedContext); + assertTrue(suggestInstance.dropdown.is(':hidden')); + assertFalse(suggestInstance.dropdown.children().length > 0); + assertTrue(closeTriggered); + + suggestInstance.option.multiselect = true; + suggestInstance.element.val('test'); + suggestInstance.close($.Event('close')); + assertEquals(suggestInstance.element.val(), ''); +}; +SuggestTest.prototype.testSetTemplate = function() { + /*:DOC += */ + var suggestInstance = this.suggestCreate({template: '
    ${test}
    '}); + var html = jQuery('
    ').append($.tmpl(suggestInstance.templateName, {test: 'test'})).html(); + assertEquals(html, '
    test
    '); + + suggestInstance = this.suggestCreate({template: '#test-template'}); + html = jQuery('
    ').append(jQuery.tmpl(suggestInstance.templateName, {test: 'test'})).html(); + assertEquals(html, '
    test
    '); +}; +SuggestTest.prototype.testSearch = function() { + var searchTriggered = false, + seachPropagationStopped = true, + suggestInstance = this.suggestCreate(); + + this.suggestElement + .on('suggestsearch', function() { + searchTriggered = true; + }) + .parent() + .on('suggestsearch', function() { + seachPropagationStopped = false; + }); + + suggestInstance._term = suggestInstance._value(); + suggestInstance._selectedItem = null; + + suggestInstance.search($.Event('search')); + + assertNull(suggestInstance._selectedItem); + assertFalse(searchTriggered); + + this.suggestElement.val('test'); + suggestInstance.search($.Event('search')); + + assertEquals(suggestInstance._term, suggestInstance._value()); + assertTrue(searchTriggered); + assertFalse(seachPropagationStopped); + + searchTriggered = false; + seachPropagationStopped = true; + suggestInstance._selectedItem = null; + suggestInstance.options.minLength = 10; + this.suggestElement.val('testtest'); + + suggestInstance.search($.Event('search')); + + assertEquals(suggestInstance._selectedItem, suggestInstance._nonSelectedItem); + assertEquals(suggestInstance.valueField.val(), suggestInstance._selectedItem.id); + assertFalse(searchTriggered); + + searchTriggered = false; + seachPropagationStopped = true; + suggestInstance._selectedItem = null; + suggestInstance.options.minLength = 1; + this.suggestElement.val('test'); + + this.suggestElement + .on('suggestsearch.returnfalse', function() { + return false; + }); + + suggestInstance.search($.Event('search')); + + assertEquals(suggestInstance._term, suggestInstance._value()); + assertTrue(searchTriggered); + assertTrue(seachPropagationStopped); +}; +SuggestTest.prototype.testUderscoreSearch = function() { + var sourceLaunched = false, + sorceTerm = null, + responceExists = false, + suggestOptions = { + source: function(term, response){ + sourceLaunched = true; + sorceTerm = term; + responceExists = (response && jQuery.type(response) === 'function'); + }, + delay: null + }, + suggestInstance = this.suggestCreate(suggestOptions); + + suggestInstance._search($.Event('search'), 'test', {}); + assertTrue(sourceLaunched); + assertEquals(sorceTerm, 'test'); + assertTrue(responceExists); + assertTrue(this.suggestElement.hasClass(suggestInstance.options.loadingClass)); + assertUndefined(suggestInstance._searchTimeout); + + suggestInstance.options.delay = 100; + suggestInstance._search($.Event('search'), 'test', {}); + assertNotUndefined(suggestInstance._searchTimeout); +}; +SuggestTest.prototype.testPrepareDropdownContext = function() { + var suggestInstance = this.suggestCreate(); + + suggestInstance._items = [this.uiHash.item]; + suggestInstance._term = 'test'; + suggestInstance._selectedItem = this.uiHash.item; + + var context = suggestInstance._prepareDropdownContext({}); + + assertEquals(context.items, suggestInstance._items); + assertEquals(context.term, suggestInstance._term); + assertEquals(context.optionData(this.uiHash.item), + 'data-suggest-option="' + JSON.stringify(this.uiHash.item).replace(/"/g, '"') + '"'); + assertTrue(context.itemSelected(this.uiHash.item)); + assertNotUndefined(context.noRecordsText); + assertFalse(context.recentShown()); + assertNotUndefined(context.recentTitle); + assertNotUndefined(context.showAllTitle); + assertFalse(context.allShown()); +}; +SuggestTest.prototype.testIsItemSelected = function() { + var suggestInstance = this.suggestCreate(); + assertFalse(suggestInstance._isItemSelected(this.uiHash.item)); + suggestInstance._selectedItem = this.uiHash.item; + assertTrue(suggestInstance._isItemSelected(this.uiHash.item)); + this.suggestDestroy(); + + suggestInstance = this.suggestCreate({multiselect: true}); + assertFalse(suggestInstance._isItemSelected(this.uiHash.item)); + suggestInstance.valueField.append(''); + assertTrue(suggestInstance._isItemSelected(this.uiHash.item)); +}; +SuggestTest.prototype.testRenderDropdown = function() { + var testContext = { + test: 'test' + }, + contentUpdatedTriggered = false, + suggestOptions = { + template: '
    ${test}
    ' + }, + suggestInstance = this.suggestCreate(suggestOptions); + + suggestInstance.dropdown.on('contentUpdated', function() { + contentUpdatedTriggered = true; + }); + suggestInstance.element.addClass(suggestInstance.options.loadingClass); + + suggestInstance._renderDropdown(null, [this.uiHash.item], testContext); + + assertEquals(suggestInstance._items, [this.uiHash.item]); + assertEquals(suggestInstance.dropdown.html(), '
    test
    '); + assertTrue(contentUpdatedTriggered); + assertEquals(suggestInstance._renderedContext, suggestInstance._prepareDropdownContext(testContext)); + assertFalse(suggestInstance.element.hasClass(suggestInstance.options.loadingClass)); + assertTrue(suggestInstance.dropdown.is(':visible')); +}; +SuggestTest.prototype.testProcessResponse = function() { + var testContext = { + test: 'test' + }, + responseTriggered = false, + suggestOptions = { + template: '
    ${test}
    ' + }, + responcePropagationStopped = true, + rendererExists, + responseData, + suggestInstance = this.suggestCreate(suggestOptions); + + this.suggestElement + .on('suggestresponse', function(e, data, renderer) { + responseTriggered = true; + rendererExists = (renderer && jQuery.type(renderer) === 'function'); + responseData = data; + }) + .parent() + .on('suggestresponse', function() { + responcePropagationStopped = false; + }); + suggestInstance._processResponse($.Event('response'), [this.uiHash.item], testContext); + + assertTrue(responseTriggered); + assertTrue(rendererExists); + assertEquals(responseData, [this.uiHash.item]); + assertFalse(responcePropagationStopped); + assertEquals(suggestInstance.dropdown.html(), '
    test
    '); + + suggestInstance.dropdown.empty(); + this.suggestElement + .on('suggestresponse.returnfalse', function() { + return false; + }); + responcePropagationStopped = true; + + suggestInstance._processResponse($.Event('response'), [this.uiHash.item], testContext); + + assertTrue(responcePropagationStopped); + assertFalse(suggestInstance.dropdown.children().tength > 0); +}; +SuggestTest.prototype.testSource = function() { + var sourceArray = [this.uiHash.item], + sourceUrl = 'www.test.url', + sourceFuncExecuted = false, + responseExecuted = false, + responseItems = null, + sourceFuncTerm = "", + sourceFuncResponse = null, + ajaxData = '', + ajaxUrl = '', + sourceFunc = function(term, response) { + sourceFuncExecuted = true; + sourceFuncTerm = term; + sourceFuncResponse = (response && jQuery.type(response) === 'function'); + }, + response = function (items) { + responseExecuted = true; + responseItems = items; + }; + + var suggestInstance = this.suggestCreate({ + source: sourceArray + }); + + suggestInstance._source('test', response); + + assertTrue(responseExecuted); + assertEquals(responseItems, sourceArray); + this.suggestDestroy(); + + responseExecuted = false; + responseItems = null; + + suggestInstance = this.suggestCreate({ + source: sourceUrl, + ajaxOptions: { + beforeSend: function(xhr, settings) { + xhr.abort(); + ajaxData = settings.data; + ajaxUrl = settings.url; + settings.success(sourceArray); + } + }, + termAjaxArgument: 'test' + }); + suggestInstance._source('test', response); + + assertTrue(responseExecuted); + assertEquals(responseItems, sourceArray); + assertEquals(ajaxData, 'test=test'); + assertEquals(ajaxUrl, sourceUrl); + this.suggestDestroy(); + + responseExecuted = false; + responseItems = null; + + suggestInstance = this.suggestCreate({ + source: sourceFunc + }); + suggestInstance._source('test', response); + + assertTrue(sourceFuncExecuted); + assertEquals(sourceFuncTerm, 'test'); + assertTrue(sourceFuncResponse); +}; +SuggestTest.prototype.testAbortSearch = function() { + var searchAborted = false, + suggestInstance = this.suggestCreate(); + + this.suggestElement.addClass(suggestInstance.options.loadingClass); + suggestInstance._xhr = { + abort: function() { + searchAborted = true; + } + }; + + suggestInstance._abortSearch(); + + assertFalse(this.suggestElement.hasClass(suggestInstance.options.loadingClass)); + assertTrue(searchAborted); +}; +SuggestTest.prototype.testShowAll = function() { + var searchAborted, + showAllTerm, + showAllContext, + suggestInstance = this.suggestCreate(); + suggestInstance._abortSearch = function() { + searchAborted = true; + } + suggestInstance._search = function(e, term, context) { + showAllTerm = term; + showAllContext = context; + } + + suggestInstance._showAll(jQuery.Event('showAll')); + + assertTrue(searchAborted); + assertEquals(showAllTerm, ''); + assertEquals(showAllContext, {_allShown: true}); +}; +SuggestTest.prototype.testAddRecent = function() { + var recentItems = [ + {id: 2, label: 'Test Label 2'}, + {id: 3, label: 'Test Label 3'} + ], + suggestInstance = this.suggestCreate(); + + suggestInstance._recentItems = recentItems; + suggestInstance.options.storageKey = 'jsTestDriver-test-suggest-recent'; + suggestInstance._addRecent(this.uiHash.item); + + recentItems.unshift(this.uiHash.item); + assertEquals(recentItems, suggestInstance._recentItems); + if(window.localStorage) { + assertEquals(localStorage.getItem(suggestInstance.options.storageKey), JSON.stringify(recentItems)); + } + + suggestInstance._addRecent(this.uiHash.item); + assertEquals(recentItems, suggestInstance._recentItems); + if(window.localStorage) { + assertEquals(localStorage.getItem(suggestInstance.options.storageKey), JSON.stringify(recentItems)); + } + + suggestInstance.options.storageLimit = 1; + var newRecentItem = {id: 4, label: 'Test Label 4'}; + suggestInstance._addRecent(newRecentItem); + + assertEquals([newRecentItem], suggestInstance._recentItems); + if(window.localStorage) { + assertEquals(localStorage.getItem(suggestInstance.options.storageKey), JSON.stringify([newRecentItem])); + localStorage.removeItem(suggestInstance.options.storageKey); + } +}; +SuggestTest.prototype.testRenderMultiselect = function() { + var suggestOptions = { + multiselect: true, + multiSuggestWrapper: '
    ' + }, + suggestInstance = this.suggestCreate(suggestOptions); + + assertTrue(this.suggestElement.parent().is('#test-multisuggest-wrapper')); + assertTrue(suggestInstance.elementWrapper.is('#test-multisuggest-wrapper')); +}; +SuggestTest.prototype.testGetOptions = function() { + var suggestInstance = this.suggestCreate(); + + assertFalse(suggestInstance._getOptions().length > 0); + + var option = jQuery(''); + suggestInstance.valueField.append(option); + assertTrue(suggestInstance._getOptions().is(option)); +}; +SuggestTest.prototype.testFilterSelected = function() { + var items = [this.uiHash.item, {id: 2, label: 'Test Label2'}], + suggestInstance = this.suggestCreate(); + + suggestInstance.valueField.append(''); + assertEquals(suggestInstance._filterSelected(items), [this.uiHash.item]); +}; +SuggestTest.prototype.testCreateOption = function() { + var suggestInstance = this.suggestCreate(); + + var option = suggestInstance._createOption(this.uiHash.item); + assertEquals(jQuery('
    ').append(option).html(), + ''); + assertNotUndefined(option.data('renderedOption')); +}; +SuggestTest.prototype.testAddOption = function() { + var selectTarget = jQuery('
    '), + event = jQuery.Event('add'), + suggestInstance = this.suggestCreate(); + + event.target = selectTarget[0]; + suggestInstance._addOption(event, this.uiHash.item); + + var option = suggestInstance.valueField.find('option[value=' + this.uiHash.item.id + ']'); + assertTrue(option.length > 0); + assertTrue(option.data('selectTarget').is(selectTarget)); +}; +SuggestTest.prototype.testGetOption = function() { + var suggestInstance = this.suggestCreate(); + + assertFalse(suggestInstance._getOption(this.uiHash.item).length > 0); + + var option = jQuery(''); + suggestInstance.valueField.append(option); + assertTrue(suggestInstance._getOption(this.uiHash.item).length > 0); + assertTrue(suggestInstance._getOption(option).length > 0); +}; +SuggestTest.prototype.testRemoveLastAdded = function() { + var suggestInstance = this.suggestCreate({multiselect: true}); + + suggestInstance._addOption({}, this.uiHash.item); + assertTrue(suggestInstance.valueField.find('option').length > 0); + suggestInstance._removeLastAdded(); + assertFalse(suggestInstance.valueField.find('option').length > 0); +}; +SuggestTest.prototype.testRemoveOption = function() { + var selectTarget = jQuery('
    '), + event = jQuery.Event('select'), + suggestInstance = this.suggestCreate({multiselect: true}); + + selectTarget.addClass(suggestInstance.options.selectedClass); + event.target = selectTarget[0]; + + suggestInstance._addOption(event, this.uiHash.item); + assertTrue(suggestInstance.valueField.find('option').length > 0); + suggestInstance.removeOption(event, this.uiHash.item); + assertFalse(suggestInstance.valueField.find('option').length > 0); + assertFalse(selectTarget.hasClass(suggestInstance.options.selectedClass)); +}; +SuggestTest.prototype.testRenderOption = function() { + var suggestInstance = this.suggestCreate(); + + suggestInstance.elementWrapper = jQuery('
    ').appendTo('body'); + jQuery.template('test-choice-template', suggestInstance.options.choiceTemplate); + var testOption = jQuery.tmpl('test-choice-template', {text: this.uiHash.item.label}), + option = suggestInstance._renderOption(this.uiHash.item); + + assertTrue(option.next().is(suggestInstance.elementWrapper)); + assertEquals(jQuery('
    ').append(testOption).html(), jQuery('
    ').append(option).html()); +}; diff --git a/dev/tests/js/testsuite/mage/suggest/tree-suggest-test.js b/dev/tests/js/testsuite/mage/suggest/tree-suggest-test.js new file mode 100644 index 0000000000000..6d88f2f75a1dc --- /dev/null +++ b/dev/tests/js/testsuite/mage/suggest/tree-suggest-test.js @@ -0,0 +1,94 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category mage.js + * @package test + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +TreeSuggestTest = TestCase('TreeSuggestTest'); +TreeSuggestTest.prototype.setUp = function() { + /*:DOC += */ + this.suggestElement = jQuery('#tree-suggest'); +}; +TreeSuggestTest.prototype.tearDown = function() { + this.treeSuggestDestroy(); +}; +TreeSuggestTest.prototype.treeSuggestDestroy = function() { + if(this.suggestElement.data('treeSuggest')) { + this.suggestElement.treeSuggest('destroy'); + } +}; +TreeSuggestTest.prototype.treeSuggestCreate = function(options, element) { + return (element || this.suggestElement).treeSuggest(options || {} ).data('treeSuggest'); +}; +TreeSuggestTest.prototype.uiHash = { + item: { + id: 1, + label: 'Test Label' + } +}; +TreeSuggestTest.prototype.stub = function(instance, methodName, retVal) { + var d = $.Deferred(); + if(instance && instance[methodName]) { + instance[methodName] = function() { + d.resolve(arguments); + if(retVal) { + return retVal; + } + } + } + return d.promise(); +}; + +TreeSuggestTest.prototype.testInit = function() { + var treeSuggestInstance = this.treeSuggestCreate(); + assertTrue(this.suggestElement.is(':mage-treeSuggest')); + assertEquals(treeSuggestInstance.widgetEventPrefix, 'suggest'); +}; +TreeSuggestTest.prototype.testBind = function() { + var event = jQuery.Event('keydown'), + proxyEventsExecuted = false, + treeSuggestInstance = this.treeSuggestCreate(); + + treeSuggestInstance.dropdown.show(); + + event.keyCode = jQuery.ui.keyCode.LEFT; + this.stub(treeSuggestInstance, '_proxyEvents').done(function() { + proxyEventsExecuted = true + }); + + treeSuggestInstance.element.trigger(event); + assertTrue(proxyEventsExecuted); + + event.keyCode = $.ui.keyCode.RIGHT; + proxyEventsExecuted = false; + this.stub(treeSuggestInstance, '_proxyEvents').done(function() { + proxyEventsExecuted = true + }); + + treeSuggestInstance.dropdown.show(); + treeSuggestInstance.element.trigger(event); + assertTrue(proxyEventsExecuted); +}; +TreeSuggestTest.prototype.testFilterSelected = function() { + var treeSuggestInstance = this.treeSuggestCreate(); + assertEquals(treeSuggestInstance._filterSelected([this.uiHash.item], {_allShown: true}), [this.uiHash.item]); +}; \ No newline at end of file diff --git a/dev/tests/js/testsuite/mage/validation/validate-test.js b/dev/tests/js/testsuite/mage/validation/validate-test.js index 8757ea5e9dcbb..4d41459af2352 100644 --- a/dev/tests/js/testsuite/mage/validation/validate-test.js +++ b/dev/tests/js/testsuite/mage/validation/validate-test.js @@ -403,3 +403,95 @@ MageValidationTest.prototype.testValidateGroupedQty = function () { assertTrue($.validator.methods['validate-grouped-qty'].call(this, null, null, '#div5')); }; + +MageValidationTest.prototype.testValidateCCTypeSelect = function () { + /*:DOC += + + + + + + */ + assertTrue($.validator.methods['validate-cc-type-select'].call(this, 'VI', null, '#visa-valid')); + assertFalse($.validator.methods['validate-cc-type-select'].call(this, 'VI', null, '#visa-invalid')); + assertTrue($.validator.methods['validate-cc-type-select'].call(this, 'MC', null, '#mc-valid')); + assertFalse($.validator.methods['validate-cc-type-select'].call(this, 'MC', null, '#mc-invalid')); + assertTrue($.validator.methods['validate-cc-type-select'].call(this, 'AE', null, '#ae-valid')); + assertFalse($.validator.methods['validate-cc-type-select'].call(this, 'AE', null, '#ae-invalid')); +}; + +MageValidationTest.prototype.testValidateCCNumber = function () { + assertTrue($.validator.methods['validate-cc-number'].call(this, '4916835098995909', null, null)); + assertTrue($.validator.methods['validate-cc-number'].call(this, '5265071363284878', null, null)); + assertTrue($.validator.methods['validate-cc-number'].call(this, '6011120623356953', null, null)); + assertTrue($.validator.methods['validate-cc-number'].call(this, '371293266574617', null, null)); + assertFalse($.validator.methods['validate-cc-number'].call(this, '4916835098995901', null, null)); + assertFalse($.validator.methods['validate-cc-number'].call(this, '5265071363284870', null, null)); + assertFalse($.validator.methods['validate-cc-number'].call(this, '6011120623356951', null, null)); + assertFalse($.validator.methods['validate-cc-number'].call(this, '371293266574619', null, null)); +}; + +MageValidationTest.prototype.testValidateCCType = function () { + /*:DOC += + */ + var ccType = $('#cc-type'); + ccType.val('VI'); + assertTrue($.validator.methods['validate-cc-type'].call(this, '4916835098995909', null, '#cc-type')); + assertFalse($.validator.methods['validate-cc-type'].call(this, '5265071363284878', null, '#cc-type')); + ccType.val('MC'); + assertTrue($.validator.methods['validate-cc-type'].call(this, '5265071363284878', null, '#cc-type')); + assertFalse($.validator.methods['validate-cc-type'].call(this, '4916835098995909', null, '#cc-type')); + ccType.val('AE'); + assertTrue($.validator.methods['validate-cc-type'].call(this, '371293266574617', null, '#cc-type')); + assertFalse($.validator.methods['validate-cc-type'].call(this, '5265071363284878', null, '#cc-type')); + ccType.val('DI'); + assertTrue($.validator.methods['validate-cc-type'].call(this, '6011120623356953', null, '#cc-type')); + assertFalse($.validator.methods['validate-cc-type'].call(this, '4916835098995909', null, '#cc-type')); +}; + +MageValidationTest.prototype.testValidateCCExp = function () { + /*:DOC += + */ + var year = $('#year'), + currentTime = new Date(), + currentMonth = currentTime.getMonth() + 1, + currentYear = currentTime.getFullYear();; + year.val(currentYear); + if (currentMonth > 1) { + assertFalse($.validator.methods['validate-cc-exp'].call(this, currentMonth - 1, null, '#year')); + } + assertTrue($.validator.methods['validate-cc-exp'].call(this, currentMonth, null, '#year')); + year.val(currentYear + 1); + assertTrue($.validator.methods['validate-cc-exp'].call(this, currentMonth, null, '#year')); + +}; + +MageValidationTest.prototype.testValidateCCCvn = function () { + /*:DOC += + */ + var ccType = $('#cc-type'); + ccType.val('VI'); + assertTrue($.validator.methods['validate-cc-cvn'].call(this, '123', null, '#cc-type')); + assertFalse($.validator.methods['validate-cc-cvn'].call(this, '1234', null, '#cc-type')); + ccType.val('MC'); + assertTrue($.validator.methods['validate-cc-cvn'].call(this, '123', null, '#cc-type')); + assertFalse($.validator.methods['validate-cc-cvn'].call(this, '1234', null, '#cc-type')); + ccType.val('AE'); + assertTrue($.validator.methods['validate-cc-cvn'].call(this, '1234', null, '#cc-type')); + assertFalse($.validator.methods['validate-cc-cvn'].call(this, '123', null, '#cc-type')); + ccType.val('DI'); + assertTrue($.validator.methods['validate-cc-cvn'].call(this, '123', null, '#cc-type')); + assertFalse($.validator.methods['validate-cc-cvn'].call(this, '1234', null, '#cc-type')); +}; diff --git a/dev/tests/performance/framework/Magento/Application.php b/dev/tests/performance/framework/Magento/Application.php index da859ccb36338..d5b5243a9a35f 100644 --- a/dev/tests/performance/framework/Magento/Application.php +++ b/dev/tests/performance/framework/Magento/Application.php @@ -195,6 +195,14 @@ protected function _updateFilesystemPermissions() */ protected function _bootstrap() { + if (!Mage::getObjectManager()) { + $config = new Mage_Core_Model_Config_Primary(BP, $_SERVER); + $definitionFactory = new Mage_Core_Model_ObjectManager_DefinitionFactory(); + $definitions = $definitionFactory->create($config); + $objectManager = new Mage_Core_Model_ObjectManager($definitions, $config); + Mage::setObjectManager($objectManager); + } + /** @var $app Mage_Core_Model_App */ Mage::getObjectManager()->get('Mage_Core_Model_App'); return $this; diff --git a/dev/tests/performance/testsuite/fixtures/catalog_category.php b/dev/tests/performance/testsuite/fixtures/catalog_category.php index e541d9be0b514..77158f9f2300d 100644 --- a/dev/tests/performance/testsuite/fixtures/catalog_category.php +++ b/dev/tests/performance/testsuite/fixtures/catalog_category.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -$installer = new Mage_Catalog_Model_Resource_Setup('catalog_setup'); +$installer = $installer = Mage::getModel('Mage_Catalog_Model_Resource_Setup', array('resourceName' => 'catalog_setup')); /** * After installation system has two categories: root one with ID:1 and Default category with ID:2 */ diff --git a/dev/tests/performance/testsuite/fixtures/sales_100k_orders.php b/dev/tests/performance/testsuite/fixtures/sales_100k_orders.php index fcdc3eb007480..c4430a70f3fd1 100644 --- a/dev/tests/performance/testsuite/fixtures/sales_100k_orders.php +++ b/dev/tests/performance/testsuite/fixtures/sales_100k_orders.php @@ -33,7 +33,7 @@ 'telephone' => '11111111', 'country_id' => 'US', ); -$billingAddress = Mage::getModel('Mage_Sales_Model_Order_Address', $addressData); +$billingAddress = Mage::getModel('Mage_Sales_Model_Order_Address', array('data' => $addressData)); $shippingAddress = clone $billingAddress; $item = Mage::getModel('Mage_Sales_Model_Order_Item'); diff --git a/dev/tests/static/framework/CodingStandard/Tool/CopyPasteDetector.php b/dev/tests/static/framework/CodingStandard/Tool/CopyPasteDetector.php index a678fb3d8784f..05d1517e42d30 100644 --- a/dev/tests/static/framework/CodingStandard/Tool/CopyPasteDetector.php +++ b/dev/tests/static/framework/CodingStandard/Tool/CopyPasteDetector.php @@ -81,7 +81,7 @@ public function run(array $whiteList, array $blackList = array(), array $extensi $command = 'phpcpd' . ' --log-pmd ' . escapeshellarg($this->_reportFile) - . ' --min-lines 7' + . ' --min-lines 13' . $blackListStr . ' ' .realpath(__DIR__ . '/../../../../../../'); diff --git a/dev/tests/static/framework/bootstrap.php b/dev/tests/static/framework/bootstrap.php index 577daba0e9fbd..c31e957843b1a 100644 --- a/dev/tests/static/framework/bootstrap.php +++ b/dev/tests/static/framework/bootstrap.php @@ -25,6 +25,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -require __DIR__ . '/../../../../app/autoload.php'; -Magento_Autoload_IncludePath::addIncludePath(array(__DIR__, dirname(__DIR__) . '/testsuite')); -Utility_Files::init(new Utility_Files(realpath(__DIR__ . '/../../../..'))); +$baseDir = realpath(__DIR__ . '/../../../../'); +require $baseDir . '/app/autoload.php'; +Magento_Autoload_IncludePath::addIncludePath(array( + __DIR__, + dirname(__DIR__) . '/testsuite', + $baseDir . '/lib', +)); +Utility_Files::init(new Utility_Files($baseDir)); diff --git a/dev/tests/static/framework/tests/unit/testsuite/CodingStandard/Tool/CodeSniffer/WrapperTest.php b/dev/tests/static/framework/tests/unit/testsuite/CodingStandard/Tool/CodeSniffer/WrapperTest.php index 2958461b1cb14..b6085967e3e81 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/CodingStandard/Tool/CodeSniffer/WrapperTest.php +++ b/dev/tests/static/framework/tests/unit/testsuite/CodingStandard/Tool/CodeSniffer/WrapperTest.php @@ -29,6 +29,9 @@ class CodingStandard_Tool_CodeSniffer_WrapperTest extends PHPUnit_Framework_Test { public function testSetValues() { + if (!class_exists('PHP_CodeSniffer_CLI')) { + $this->markTestSkipped('Code Sniffer is not installed'); + } $wrapper = new CodingStandard_Tool_CodeSniffer_Wrapper(); $expected = array('some_key' => 'some_value'); $wrapper->setValues($expected); diff --git a/dev/tests/static/testsuite/Integrity/ClassesTest.php b/dev/tests/static/testsuite/Integrity/ClassesTest.php index 45a34da0292d7..fa717d7765bd5 100644 --- a/dev/tests/static/testsuite/Integrity/ClassesTest.php +++ b/dev/tests/static/testsuite/Integrity/ClassesTest.php @@ -172,7 +172,7 @@ protected function _assertClassesExist($classes) continue; } $this->assertTrue(isset(self::$_existingClasses[$class]) - || Utility_Files::init()->codePoolClassFileExists($class) + || Utility_Files::init()->classFileExists($class) ); self::$_existingClasses[$class] = 1; } catch (PHPUnit_Framework_AssertionFailedError $e) { diff --git a/dev/tests/static/testsuite/Integrity/ConfigTest.php b/dev/tests/static/testsuite/Integrity/ConfigTest.php index de669fce49405..6894e2ba113c5 100644 --- a/dev/tests/static/testsuite/Integrity/ConfigTest.php +++ b/dev/tests/static/testsuite/Integrity/ConfigTest.php @@ -57,7 +57,7 @@ public function testExistingFilesDeclared($verifiedFiles) { $root = Utility_Files::init()->getPathToSource(); $failures = array(); - foreach (glob("{$root}/app/code/*/*/*", GLOB_ONLYDIR) as $modulePath) { + foreach (glob("{$root}/app/code/*/*", GLOB_ONLYDIR) as $modulePath) { $localeFiles = glob("{$modulePath}/locale/*/*.csv"); foreach ($localeFiles as $file) { $file = realpath($file); diff --git a/dev/tests/static/testsuite/Integrity/Mage/Backend/SystemConfigTest.php b/dev/tests/static/testsuite/Integrity/Mage/Backend/SystemConfigTest.php new file mode 100644 index 0000000000000..6409aa9eb40e8 --- /dev/null +++ b/dev/tests/static/testsuite/Integrity/Mage/Backend/SystemConfigTest.php @@ -0,0 +1,50 @@ +loadXML(file_get_contents($configFile)); + $schema = Utility_Files::init()->getPathToSource() . '/app/code/Mage/Backend/etc/system_file.xsd'; + $errors = Magento_Config_Dom::validateDomDocument($dom, $schema); + if ($errors) { + $this->fail('XML-file has validation errors:' . PHP_EOL . implode(PHP_EOL . PHP_EOL, $errors)); + } + } + + /** + * @return array + */ + public function schemaDataProvider() + { + return Utility_Files::init()->getConfigFiles('adminhtml/system.xml', array()); + } +} diff --git a/dev/tests/static/testsuite/Js/_files/blacklist/core.txt b/dev/tests/static/testsuite/Js/_files/blacklist/core.txt index 57aab4e622aa2..63169500029c9 100644 --- a/dev/tests/static/testsuite/Js/_files/blacklist/core.txt +++ b/dev/tests/static/testsuite/Js/_files/blacklist/core.txt @@ -5,17 +5,17 @@ pub/lib/mage/backend/editablemultiselect.js pub/lib/mage/captcha.js pub/lib/mage/directpost.js pub/lib/mage/jquery-no-conflict.js -app/code/core/Mage/Page/view/frontend/menu.js -app/code/core/Mage/Checkout/view/frontend/multishipping/payment.js -app/code/core/Mage/Checkout/view/frontend/onepage/accordion.js -app/code/core/Mage/Checkout/view/frontend/opcheckout.js -app/code/core/Mage/Captcha/view/frontend/onepage.js -app/code/core/Mage/Adminhtml/view/adminhtml/catalog/category/edit.js -app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product/composite/configure.js -app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product.js -app/code/core/Mage/Adminhtml/view/adminhtml/promo/rules.js -app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/giftmessage.js -app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/create/scripts.js -app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/giftoptions_tooltip.js -app/code/core/Mage/Adminhtml/view/adminhtml/sales/order/shipment/packaging.js -app/code/core/Mage/Adminhtml/view/adminhtml/variables.js +app/code/Mage/Page/view/frontend/menu.js +app/code/Mage/Checkout/view/frontend/multishipping/payment.js +app/code/Mage/Checkout/view/frontend/onepage/accordion.js +app/code/Mage/Checkout/view/frontend/opcheckout.js +app/code/Mage/Captcha/view/frontend/onepage.js +app/code/Mage/Adminhtml/view/adminhtml/catalog/category/edit.js +app/code/Mage/Adminhtml/view/adminhtml/catalog/product/composite/configure.js +app/code/Mage/Adminhtml/view/adminhtml/catalog/product.js +app/code/Mage/Adminhtml/view/adminhtml/promo/rules.js +app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/giftmessage.js +app/code/Mage/Adminhtml/view/adminhtml/sales/order/create/scripts.js +app/code/Mage/Adminhtml/view/adminhtml/sales/order/giftoptions_tooltip.js +app/code/Mage/Adminhtml/view/adminhtml/sales/order/shipment/packaging.js +app/code/Mage/Adminhtml/view/adminhtml/variables.js diff --git a/dev/tests/static/testsuite/Js/_files/whitelist/core.txt b/dev/tests/static/testsuite/Js/_files/whitelist/core.txt index 0fc14b6d304c9..34403bf18adeb 100644 --- a/dev/tests/static/testsuite/Js/_files/whitelist/core.txt +++ b/dev/tests/static/testsuite/Js/_files/whitelist/core.txt @@ -1,16 +1,19 @@ pub/lib/mage -app/code/core/Mage/Install -app/code/core/Mage/Catalog -app/code/core/Mage/Newsletter -app/code/core/Mage/Page -app/code/core/Mage/PageCache -app/code/core/Mage/Poll -app/code/core/Mage/CatalogSearch -app/code/core/Mage/Checkout -app/code/core/Mage/Captcha -app/code/core/Mage/Customer -app/code/core/Mage/Downloadable -app/code/core/Mage/Persistent -app/code/core/Mage/Wishlist -app/code/core/Mage/Bundle -app/code/core/Mage/Adminhtml +app/code/Mage/Install +app/code/Mage/Catalog +app/code/Mage/Newsletter +app/code/Mage/Page +app/code/Mage/PageCache +app/code/Mage/Poll +app/code/Mage/CatalogSearch +app/code/Mage/Checkout +app/code/Mage/Captcha +app/code/Mage/Customer +app/code/Mage/Downloadable +app/code/Mage/Persistent +app/code/Mage/Wishlist +app/code/Mage/Bundle +app/code/Mage/Adminhtml +app/code/Mage/Payment +app/code/Mage/GiftMessage +app/code/Mage/Sales \ No newline at end of file diff --git a/dev/tests/static/testsuite/Legacy/ConfigTest.php b/dev/tests/static/testsuite/Legacy/ConfigTest.php index 022ebde34fc25..8a53ba7188eea 100644 --- a/dev/tests/static/testsuite/Legacy/ConfigTest.php +++ b/dev/tests/static/testsuite/Legacy/ConfigTest.php @@ -36,26 +36,12 @@ class Legacy_ConfigTest extends PHPUnit_Framework_TestCase */ public function testConfigFile($file) { - $obsoleteNodes = array( - '/config/global/fieldsets' => '', - '/config/global/cache/betatypes' => '', - '/config/admin/fieldsets' => '', - '/config/global/models/*/deprecatedNode' => '', - '/config/global/models/*/entities/*/table' => '', - '/config/global/models/*/class' => '', - '/config/global/helpers/*/class' => '', - '/config/global/blocks/*/class' => '', - '/config/global/models/*/resourceModel' => '', - '/config/adminhtml/menu' => 'Move them to adminhtml.xml.', - '/config/adminhtml/acl' => 'Move them to adminhtml.xml.', - '/config/*/events/core_block_abstract_to_html_after' => - 'Event has been replaced with "core_layout_render_element"', - '/config/*/events/catalog_controller_product_delete' => '', - '/config//observers/*/args' => 'This was an undocumented and unused feature in event subscribers', - '/config/default/design/theme' => 'Relocated to /config//design/theme', - '/config/default/web/*/base_js_url' => 'See /config/default/web/*/base_lib_url', - '/config/default/web/*/base_skin_url' => '', - ); + $obsoleteNodes = array(); + $obsoleteNodesFiles = glob(__DIR__ . '/_files/obsolete_config_nodes*.php'); + foreach ($obsoleteNodesFiles as $obsoleteNodesFile) { + $obsoleteNodes = array_merge($obsoleteNodes, include($obsoleteNodesFile)); + } + $xml = simplexml_load_file($file); foreach ($obsoleteNodes as $xpath => $suggestion) { $this->assertEmpty( diff --git a/dev/tests/static/testsuite/Legacy/LayoutTest.php b/dev/tests/static/testsuite/Legacy/LayoutTest.php index d469ed1197f1b..f4243aed9f660 100644 --- a/dev/tests/static/testsuite/Legacy/LayoutTest.php +++ b/dev/tests/static/testsuite/Legacy/LayoutTest.php @@ -131,7 +131,7 @@ public function testLayoutFile($layoutFile) $this->assertContains('::', $action->getAtrtibute('helper')); } - if (false !== strpos($layoutFile, 'app/code/core/Mage/Adminhtml/view/adminhtml/sales.xml')) { + if (false !== strpos($layoutFile, 'app/code/Mage/Adminhtml/view/adminhtml/sales.xml')) { $this->markTestIncomplete("The file {$layoutFile} has to use Mage_Core_Block_Text_List, \n" . 'there is no solution to get rid of it right now.' ); diff --git a/dev/tests/static/testsuite/Legacy/ObsoleteCodeTest.php b/dev/tests/static/testsuite/Legacy/ObsoleteCodeTest.php index b7c9325d7059e..4e71d7db814a0 100644 --- a/dev/tests/static/testsuite/Legacy/ObsoleteCodeTest.php +++ b/dev/tests/static/testsuite/Legacy/ObsoleteCodeTest.php @@ -186,47 +186,56 @@ public function jsFileDataProvider() } /** + * Assert that obsolete classes are not used in the content + * * @param string $content */ protected function _testObsoleteClasses($content) { foreach (self::$_classes as $row) { - list($entity, , $suggestion) = $row; - $this->_assertNotRegExp('/[^a-z\d_]' . preg_quote($entity, '/') . '[^a-z\d_]/iS', $content, - sprintf("Class '%s' is obsolete. Replacement suggestion: %s", $entity, $suggestion) + list($class, , $replacement) = $row; + $this->_assertNotRegExp('/[^a-z\d_]' . preg_quote($class, '/') . '[^a-z\d_]/iS', $content, + $this->_suggestReplacement(sprintf("Class '%s' is obsolete.", $class), $replacement) ); } } /** - * Determine if content should be skipped based on specified class scope + * Assert that obsolete methods or functions are not used in the content + * + * If class context is not specified, declaration/invocation of all functions or methods (of any class) + * will be matched across the board + * + * If context is specified, only the methods will be matched as follows: + * - usage of class::method + * - usage of $this, self and static within the class and its descendants * - * @param string $content - * @param string $class - * @return bool - */ - protected function _isClassSkipped($content, $class) - { - $regexp = '/(class|extends)\s+' . preg_quote($class, '/') . '(\s|;)/S'; - /* Note: strpos is used just to prevent excessive preg_match calls */ - if ($class && (!strpos($content, $class) || !preg_match($regexp, $content))) { - return true; - } - return false; - } - - /** * @param string $content */ protected function _testObsoleteMethods($content) { foreach (self::$_methods as $row) { - list($method, $class, $suggestion) = $row; - if (!$this->_isClassSkipped($content, $class)) { - $message = sprintf("Method '%s' is obsolete. Replacement suggestion: %s", $method, $suggestion); - $this->_assertNotRegExp('/this->' . preg_quote($method, '/') . '\s*\(/iS', $content, $message); - $this->_assertNotRegExp('/ion\s*' . preg_quote($method, '/') . '\s*\(/iS', $content, $message); - $this->_assertNotRegExp('/self::\s*' . preg_quote($method, '/') . '\s*\(/iS', $content, $message); + list($method, $class, $replacement) = $row; + $quotedMethod = preg_quote($method, '/'); + if ($class) { + $message = $this->_suggestReplacement("Method '{$class}::{$method}()' is obsolete.", $replacement); + // without opening parentheses to match static callbacks notation + $this->_assertNotRegExp( + '/' . preg_quote($class, '/') . '::\s*' . $quotedMethod . '[^a-z\d_]/iS', + $content, + $message + ); + if ($this->_isSubclassOf($content, $class)) { + $this->_assertNotRegExp('/function\s*' . $quotedMethod . '\s*\(/iS', $content, $message); + $this->_assertNotRegExp('/this->' . $quotedMethod . '\s*\(/iS', $content, $message); + $this->_assertNotRegExp( + '/(self|static|parent)::\s*' . $quotedMethod . '\s*\(/iS', $content, $message + ); + } + } else { + $message = $this->_suggestReplacement("Function or method '{$method}()' is obsolete.", $replacement); + $this->_assertNotRegExp('/function\s*' . $quotedMethod . '\s*\(/iS', $content, $message); + $this->_assertNotRegExp('/[^a-z\d_]' . $quotedMethod . '\s*\(/iS', $content, $message); } } } @@ -303,12 +312,18 @@ protected function _testObsoleteMethodArguments($content) protected function _testObsoleteProperties($content) { foreach (self::$_attributes as $row) { - list($attribute, $class, $suggestion) = $row; - if (!$this->_isClassSkipped($content, $class)) { - $this->_assertNotRegExp('/[^a-z\d_]' . preg_quote($attribute, '/') . '[^a-z\d_]/iS', $content, - sprintf("Class attribute '%s' is obsolete. Replacement suggestion: %s", $attribute, $suggestion) - ); + list($attribute, $class, $replacement) = $row; + if ($class) { + if (!$this->_isSubclassOf($content, $class)) { + continue; + } + $fullyQualified = "{$class}::\${$attribute}"; + } else { + $fullyQualified = $attribute; } + $this->_assertNotRegExp('/[^a-z\d_]' . preg_quote($attribute, '/') . '[^a-z\d_]/iS', $content, + $this->_suggestReplacement(sprintf("Class attribute '%s' is obsolete.", $fullyQualified), $replacement) + ); } } @@ -324,17 +339,35 @@ protected function _testObsoleteActions($content) } /** + * Assert that obsolete constants are not defined/used in the content + * + * Without class context, only presence of the literal will be checked. + * + * In context of a class, match: + * - fully qualified constant notation (with class) + * - usage with self::/parent::/static:: notation + * * @param string $content */ protected function _testObsoleteConstants($content) { foreach (self::$_constants as $row) { - list($constant, $class, $suggestion) = $row; - if (!$this->_isClassSkipped($content, $class)) { - $this->_assertNotRegExp('/[^a-z\d_]' . preg_quote($constant, '/') . '[^a-z\d_]/iS', $content, - sprintf("Constant '%s' is obsolete. Replacement suggestion: %s", $constant, $suggestion) - ); + list($constant, $class, $replacement) = $row; + if ($class) { + $fullyQualified = "{$class}::{$constant}"; + $regex = preg_quote($fullyQualified, '/'); + if ($this->_isSubclassOf($content, $class)) { + $regex .= '|' . preg_quote("self::{$constant}", '/') + . '|' . preg_quote("parent::{$constant}", '/') + . '|' . preg_quote("static::{$constant}", '/'); + } + } else { + $fullyQualified = $constant; + $regex = preg_quote($constant, '/'); } + $this->_assertNotRegExp('/[^a-z\d_]' . $regex . '[^a-z\d_]/iS', $content, + $this->_suggestReplacement(sprintf("Constant '%s' is obsolete.", $fullyQualified), $replacement) + ); } } @@ -348,6 +381,36 @@ protected function _testObsoletePropertySkipCalculate($content) ); } + /** + * Analyze contents of a file to determine whether this is declaration of or a direct descendant of specified class + * + * @param string $content + * @param string $class + * @return bool + */ + protected function _isSubclassOf($content, $class) + { + if (!$class) { + return false; + } + return (bool)preg_match('/(class|extends|implements)\s+' . preg_quote($class, '/') . '(\s|;)/S', $content); + } + + /** + * Append a "suggested replacement" part to the string + * + * @param string $original + * @param string $suggestion + * @return string + */ + private function _suggestReplacement($original, $suggestion) + { + if ($suggestion) { + return "{$original} Suggested replacement: {$suggestion}"; + } + return $original; + } + /** * Custom replacement for assertNotRegexp() * diff --git a/dev/tests/static/testsuite/Legacy/_files/obsolete_classes.php b/dev/tests/static/testsuite/Legacy/_files/obsolete_classes.php index 829ae06698275..0a8832fb09d00 100644 --- a/dev/tests/static/testsuite/Legacy/_files/obsolete_classes.php +++ b/dev/tests/static/testsuite/Legacy/_files/obsolete_classes.php @@ -576,12 +576,16 @@ array('Mage_Core_Model_Language'), array('Mage_Core_Model_Resource_Language'), array('Mage_Core_Model_Resource_Language_Collection'), + array('Mage_Core_Model_Resource_Setup_Query_Modifier'), array('Mage_Core_Model_Session_Abstract_Varien'), array('Mage_Core_Model_Session_Abstract_Zend'), array('Mage_Core_Model_Layout_Data', 'Mage_Core_Model_Layout_Update'), + array('Mage_Core_Model_Theme_Customization_Link'), array('Mage_Customer_Block_Account'), array('Mage_Customer_Model_Convert_Adapter_Customer'), array('Mage_Customer_Model_Convert_Parser_Customer'), + array('Mage_DesignEditor_Block_Page_Html_Head_Vde'), + array('Mage_DesignEditor_Block_Page_Html_Head'), array('Mage_Directory_Model_Resource_Currency_Collection'), array('Mage_Downloadable_FileController', 'Mage_Downloadable_Adminhtml_Downloadable_FileController'), array('Mage_Downloadable_Product_EditController', 'Mage_Adminhtml_Catalog_ProductController'), diff --git a/dev/tests/static/testsuite/Legacy/_files/obsolete_config_nodes.php b/dev/tests/static/testsuite/Legacy/_files/obsolete_config_nodes.php new file mode 100644 index 0000000000000..bdd2de64748c4 --- /dev/null +++ b/dev/tests/static/testsuite/Legacy/_files/obsolete_config_nodes.php @@ -0,0 +1,49 @@ + => + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +return array( + '/config/global/fieldsets' => '', + '/config/global/cache/betatypes' => '', + '/config/admin/fieldsets' => '', + '/config/global/models/*/deprecatedNode' => '', + '/config/global/models/*/entities/*/table' => '', + '/config/global/models/*/class' => '', + '/config/global/helpers/*/class' => '', + '/config/global/blocks/*/class' => '', + '/config/global/models/*/resourceModel' => '', + '/config/adminhtml/menu' => 'Move them to adminhtml.xml.', + '/config/adminhtml/acl' => 'Move them to adminhtml.xml.', + '/config/*/events/core_block_abstract_to_html_after' => + 'Event has been replaced with "core_layout_render_element"', + '/config/*/events/catalog_controller_product_delete' => '', + '/config//observers/*/args' => 'This was an undocumented and unused feature in event subscribers', + '/config/default/design/theme' => 'Relocated to /config//design/theme', + '/config/default/web/*/base_js_url' => '/config/default/web/*/base_lib_url', + '/config/default/web/*/base_skin_url' => '/config/default/web/*/base_static_url', + '/config/global/cache/types/*/tags' => 'use /config/global/cache/types/*/class node instead', + '/config/global/disable_local_modules' => '', +); diff --git a/dev/tests/static/testsuite/Legacy/_files/obsolete_constants.php b/dev/tests/static/testsuite/Legacy/_files/obsolete_constants.php index ab803ee9aa298..e2d276d301b57 100644 --- a/dev/tests/static/testsuite/Legacy/_files/obsolete_constants.php +++ b/dev/tests/static/testsuite/Legacy/_files/obsolete_constants.php @@ -28,6 +28,13 @@ return array( array('BACKORDERS_BELOW'), array('BACKORDERS_YES'), + array('CACHE_TAG', 'Mage_Api_Model_Config', 'Mage_Api_Model_Cache_Type::CACHE_TAG'), + array('CACHE_TAG', 'Mage_Core_Model_Resource_Db_Collection_Abstract', + 'Mage_Core_Model_Cache_Type_Collection::CACHE_TAG' + ), + array('CACHE_TAG', 'Mage_Rss_Block_Catalog_NotifyStock'), + array('CACHE_TAG', 'Mage_Rss_Block_Catalog_Review'), + array('CACHE_TAG', 'Mage_Rss_Block_Order_New'), array('CATEGORY_APPLY_CATEGORY_AND_PRODUCT_ONLY'), array('CATEGORY_APPLY_CATEGORY_AND_PRODUCT_RECURSIVE'), array('CATEGORY_APPLY_CATEGORY_ONLY'), @@ -59,9 +66,11 @@ array('INIT_OPTION_SCOPE_TYPE', 'Mage_Core_Model_App', 'Mage::PARAM_RUN_TYPE'), array('INIT_OPTION_URIS', 'Mage_Core_Model_App', 'Mage::PARAM_APP_URIS'), array('INSTALLER_HOST_RESPONSE', 'Mage_Install_Model_Installer'), - array('Mage_Rss_Block_Catalog_NotifyStock::CACHE_TAG'), - array('Mage_Rss_Block_Catalog_Review::CACHE_TAG'), - array('Mage_Rss_Block_Order_New::CACHE_TAG'), + array('PUBLIC_BASE_THEME_DIR', 'Mage_Core_Model_Design_PackageInterface'), + array('XML_PATH_ALLOW_MAP_UPDATE', 'Mage_Core_Model_Design_PackageInterface'), + array('FALLBACK_MAP_DIR', 'Mage_Core_Model_Design_PackageInterface'), + array('PATH_PREFIX_CUSTOMIZED', 'Mage_Core_Model_Theme_Files'), + array('PATH_PREFIX_CUSTOMIZATION', 'Mage_Core_Model_Theme'), array('REGISTRY_FORM_PARAMS_KEY', null, 'direct value'), array('SCOPE_TYPE_GROUP', 'Mage_Core_Model_App', 'Mage_Core_Model_StoreManagerInterface::SCOPE_TYPE_GROUP'), array('SCOPE_TYPE_STORE', 'Mage_Core_Model_App', 'Mage_Core_Model_StoreManagerInterface::SCOPE_TYPE_STORE'), diff --git a/dev/tests/static/testsuite/Legacy/_files/obsolete_methods.php b/dev/tests/static/testsuite/Legacy/_files/obsolete_methods.php index 56e3086327ea6..2205761b44ede 100644 --- a/dev/tests/static/testsuite/Legacy/_files/obsolete_methods.php +++ b/dev/tests/static/testsuite/Legacy/_files/obsolete_methods.php @@ -28,6 +28,7 @@ return array( array('__get', 'Varien_Object'), array('__set', 'Varien_Object'), + array('_addItem', 'Mage_Page_Block_Html_Head'), array('_addMinimalPrice', 'Mage_Catalog_Model_Resource_Product_Collection'), array('_addTaxPercents', 'Mage_Catalog_Model_Resource_Product_Collection'), array('_afterSaveCommit', 'Mage_Core_Model_Abstract'), @@ -37,6 +38,7 @@ array('_amountByIp', 'Mage_Sendfriend_Model_Sendfriend'), array('_applyClassRewrites', 'Mage_Core_Model_Config'), array('_applyCustomDesignSettings'), + array('_applyCustomizationFiles', 'Mage_Core_Model_Theme'), array('_applyDesignRecursively', 'Mage_Catalog_Model_Design'), array('_applyDesign', 'Mage_Catalog_Model_Design'), array('_avoidDoubleTransactionProcessing'), @@ -53,6 +55,8 @@ array('_decodeInput', 'Mage_Adminhtml_Catalog_ProductController'), array('_emailOrderConfirmation', 'Mage_Checkout_Model_Type_Abstract'), array('_escapeValue', 'Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Abstract'), + array('_generateCssHtml', 'Mage_Page_Block_Html_Head'), + array('_generateJsHtml', 'Mage_Page_Block_Html_Head'), array('_getAddressTaxRequest', 'Mage_Tax_Model_Sales_Total_Quote_Shipping'), array('_getAggregationPerStoreView'), array('_getAttributeFilterBlockName'), @@ -84,6 +88,7 @@ array('_getPriceFilter', 'Mage_Catalog_Block_Layer_View'), array('_getProcessor', 'Mage_Core_Model_Cache'), array('_getProductQtyForCheck', 'Mage_CatalogInventory_Model_Observer'), + array('_getPublicFileUrl', 'Mage_Core_Model_Design_Package', 'getPublicFileUrl'), array('_getRangeByType', 'Mage_Log_Model_Resource_Visitor_Collection'), array('_getRecentProductsCollection'), array('_getSHAInSet', '', 'Mage_Ogone_Model_Api::getHash'), @@ -95,6 +100,7 @@ array('_getStoreByWebsite', 'Mage_Core_Model_App'), array('_getStoreTaxRequest', 'Mage_Tax_Model_Sales_Total_Quote_Shipping'), array('_getUploadMaxFilesize', 'Mage_Catalog_Model_Product_Option_Type_File'), + array('_hookQueries', 'Mage_Core_Model_Resource_Setup'), array('_importAddress', 'Mage_Paypal_Model_Api_Nvp'), array('_inheritDesign', 'Mage_Catalog_Model_Design'), array('_initBaseConfig', 'Mage_Core_Model_App'), @@ -148,6 +154,7 @@ array('_sort', 'Mage_Backend_Model_Config_Structure_Converter'), array('_updateMediaPathUseRewrites', 'Mage_Core_Model_Store', '_getMediaScriptUrl'), array('_usePriceIncludeTax'), + array('_unhookQueries', 'Mage_Core_Model_Resource_Setup'), array('addAllowedModules', 'Mage_Core_Model_Config'), array('addBackupedFilter'), array('addConfigField', 'Mage_Core_Model_Resource_Setup'), @@ -195,6 +202,7 @@ array('baseInit', 'Mage_Core_Model_App'), array('bundlesAction', 'Mage_Adminhtml_Catalog_ProductController'), array('calcTaxAmount', 'Mage_Sales_Model_Quote_Item_Abstract'), + array('callbackQueryHook', 'Mage_Core_Model_Resource_Setup'), array('canPrint', 'Mage_Checkout_Block_Onepage_Success'), array('canTestHeaders', 'Magento_Test_Bootstrap', 'Magento_Test_Helper_Bootstrap::canTestHeaders'), array('catalogCategoryChangeProducts', 'Mage_Catalog_Model_Product_Flat_Observer'), @@ -232,6 +240,9 @@ array('fetchItemsCount', 'Mage_Wishlist_Model_Resource_Wishlist'), array('fetchRuleRatesForCustomerTaxClass'), array('fetchUpdatesByHandle', 'Mage_Core_Model_Resource_Layout', 'Mage_Core_Model_Resource_Layout_Update'), + array('flush', 'Mage_Core_Model_CacheInterface', 'Magento_Cache_FrontendInterface::clean()'), + array('flush', 'Mage_Core_Model_Cache', 'Magento_Cache_FrontendInterface::clean()'), + array('flush', 'Mage_Core_Model_Cache_Proxy', 'Magento_Cache_FrontendInterface::clean()'), array('forsedSave'), array('generateBlocks', '', 'generateElements()'), array('getAccount', 'Mage_GoogleAnalytics_Block_Ga'), @@ -264,6 +275,9 @@ array('getDataForSave', 'Mage_Wishlist_Model_Item'), array('getDataMaxSize'), array('getDataMaxSizeInBytes', 'Mage_Adminhtml_Block_Media_Uploader', 'Magento_File_Size::getMaxFileSize()'), + array('getDbAdapter', 'Mage_Core_Model_CacheInterface'), + array('getDbAdapter', 'Mage_Core_Model_Cache'), + array('getDbAdapter', 'Mage_Core_Model_Cache_Proxy'), array('getDbVendorName', 'Magento_Test_Bootstrap', 'Magento_Test_Helper_Bootstrap::getDbVendorName'), array('getDebug', 'Mage_Ogone_Model_Api'), array('getDebug', 'Mage_Paypal_Model_Api_Abstract'), @@ -317,6 +331,10 @@ array('getModuleSetup', 'Mage_Core_Model_Config'), array('getNeedUsePriceExcludeTax', '', 'Mage_Tax_Model_Config::priceIncludesTax()'), array('getOneBalanceTotal'), + array('getOptimalCssUrls', 'Mage_Core_Model_Design_Package_Proxy', 'mergeFiles()'), + array('getOptimalJsUrls', 'Mage_Core_Model_Design_Package_Proxy', 'mergeFiles()'), + array('getOptimalCssUrls', 'Mage_Core_Model_Design_Package', 'mergeFiles()'), + array('getOptimalJsUrls', 'Mage_Core_Model_Design_Package', 'mergeFiles()'), array('getOption', 'Mage_Captcha_Helper_Data', 'Mage_Core_Model_Dir::getDir()'), array('getOptions', 'Mage_Core_Model_Config'), array('getOptions', 'Mage_Core_Model_Design_Source_Design', 'Mage_Core_Model_Theme::getThemeCollectionOptionArray'), @@ -345,6 +363,7 @@ array('getQuoteItemOption', 'Mage_Catalog_Model_Product_Option_Type_Default'), array('getQuoteItem', 'Mage_Catalog_Model_Product_Option_Type_Default'), array('getQuoteOrdersHtml', 'Mage_GoogleAnalytics_Block_Ga'), + array('getRelativePath', 'Mage_Core_Model_Theme_Files'), array('getRemoveItemUrl', 'Mage_Wishlist_Block_Customer_Sidebar'), array('getReorderUrl', 'Mage_Sales_Block_Order_Info'), array('getResourceConfig', 'Mage_Config_Model_Config', 'Mage_Config_Model_Config_Resource::getResourceConfig'), @@ -382,6 +401,9 @@ array('getSuggestionsByQuery'), array('getSysTmpDir'), array('getTablePrefix', 'Mage_Core_Model_Config'), + array('getTagsByType', 'Mage_Core_Model_CacheInterface', 'Magento_Cache_Frontend_Decorator_TagScope::getTag()'), + array('getTagsByType', 'Mage_Core_Model_Cache', 'Magento_Cache_Frontend_Decorator_TagScope::getTag()'), + array('getTagsByType', 'Mage_Core_Model_Cache_Proxy', 'Magento_Cache_Frontend_Decorator_TagScope::getTag()'), array('getTaxAmount', 'Mage_Sales_Model_Quote_Item_Abstract'), array('getTaxRatesByProductClass', '', '_getAllRatesByProductClass'), array('getTempVarDir', 'Mage_Core_Model_Config', 'Mage_Core_Model_Dir::getDir()'), @@ -481,8 +503,12 @@ array('saveAction', 'Mage_Tag_CustomerController'), array('saveCache', 'Mage_Core_Model_Config'), array('saveConfig', 'Mage_Core_Model_Config'), + array('saveOptions', 'Mage_Core_Model_CacheInterface'), + array('saveOptions', 'Mage_Core_Model_Cache'), + array('saveOptions', 'Mage_Core_Model_Cache_Proxy'), array('saveRow__OLD'), array('saveSegmentCustomersFromSelect'), + array('saveUseCache'), array('sendNewPasswordEmail'), array('send', 'Mage_Newsletter_Model_Template'), array('setAnonSuffix'), @@ -493,6 +519,7 @@ array('setCustomerId', 'Mage_Customer_Model_Resource_Address'), array('setInstance', 'Magento_Test_Bootstrap', 'Magento_Test_Helper_Bootstrap::setInstance'), array('setIsAjaxRequest', 'Mage_Core_Model_Translate_Inline'), + array('setIsDeveloperMode', 'Mage', 'Initialization parameter of the application'), array('setJoinFlag', 'Mage_Tag_Model_Resource_Customer_Collection'), array('setJoinFlag', 'Mage_Tag_Model_Resource_Product_Collection'), array('setJoinFlag', 'Mage_Tag_Model_Resource_Tag_Collection'), diff --git a/dev/tests/static/testsuite/Legacy/_files/obsolete_properties.php b/dev/tests/static/testsuite/Legacy/_files/obsolete_properties.php index d914ac1a50817..675962a783d0c 100644 --- a/dev/tests/static/testsuite/Legacy/_files/obsolete_properties.php +++ b/dev/tests/static/testsuite/Legacy/_files/obsolete_properties.php @@ -26,56 +26,57 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ return array( + array('_addresses', 'Mage_Customer_Model_Customer'), + array('_addMinimalPrice', 'Mage_Catalog_Model_Resource_Product_Collection'), array('_alias', 'Mage_Core_Block_Abstract'), array('_anonSuffix'), - array('_isAnonymous'), + array('_baseDirCache', 'Mage_Core_Model_Config'), + array('_canUseLocalModules'), + array('_checkedProductsQty', 'Mage_CatalogInventory_Model_Observer'), array('_children', 'Mage_Core_Block_Abstract'), array('_childrenHtmlCache', 'Mage_Core_Block_Abstract'), array('_childGroups', 'Mage_Core_Block_Abstract'), - array('_canUseLocalModules'), + array('_combineHistory'), array('_config', 'Mage_Core_Model_Design_Package'), array('_config', 'Mage_Core_Model_Logger', '_dirs'), array('_configuration', 'Mage_Index_Model_Lock_Storage', '_dirs'), - array('_combineHistory'), + array('_currency', 'Mage_GoogleCheckout_Model_Api_Xml_Checkout'), array('_currencyNameTable'), - array('decoratedIsFirst', null, 'getDecoratedIsFirst'), - array('decoratedIsEven', null, 'getDecoratedIsEven'), - array('decoratedIsOdd', null, 'getDecoratedIsOdd'), - array('decoratedIsLast', null, 'getDecoratedIsLast'), - array('_distroServerVars'), - array('_searchTextFields'), - array('_skipFieldsByModel'), - array('_parent', 'Mage_Core_Block_Abstract'), - array('_parentBlock', 'Mage_Core_Block_Abstract'), - array('_setAttributes', 'Mage_Catalog_Model_Product_Type_Abstract'), - array('_storeFilter', 'Mage_Catalog_Model_Product_Type_Abstract'), - array('_addMinimalPrice', 'Mage_Catalog_Model_Resource_Product_Collection'), - array('_checkedProductsQty', 'Mage_CatalogInventory_Model_Observer'), - array('_baseDirCache', 'Mage_Core_Model_Config'), array('_customEtcDir', 'Mage_Core_Model_Config'), - array('static', 'Mage_Core_Model_Email_Template_Filter'), + array('_designProductSettingsApplied'), + array('_distroServerVars'), + array('_entityIdsToIncrementIds'), + array('_entityTypeIdsToTypes'), + array('_isAnonymous'), + array('_isFirstTimeProcessRun', 'Mage_SalesRule_Model_Validator'), array('_loadDefault', 'Mage_Core_Model_Resource_Store_Collection'), array('_loadDefault', 'Mage_Core_Model_Resource_Store_Group_Collection'), array('_loadDefault', 'Mage_Core_Model_Resource_Website_Collection'), - array('_addresses', 'Mage_Customer_Model_Customer'), - array('_currency', 'Mage_GoogleCheckout_Model_Api_Xml_Checkout'), - array('_saveTemplateFlag', 'Mage_Newsletter_Model_Queue'), - array('_ratingOptionTable', 'Mage_Rating_Model_Resource_Rating_Option_Collection'), - array('_entityTypeIdsToTypes'), - array('_entityIdsToIncrementIds'), - array('_isFirstTimeProcessRun', 'Mage_SalesRule_Model_Validator'), - array('_shipTable', 'Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection'), - array('_designProductSettingsApplied'), array('_option', 'Mage_Captcha_Helper_Data', '_dirs'), array('_options', 'Mage_Core_Model_Config', 'Mage_Core_Model_Dir'), array('_optionsMapping', null, 'Mage::getBaseDir($nodeKey)'), array('_order', 'Mage_Checkout_Block_Onepage_Success'), array('_order_id'), + array('_parent', 'Mage_Core_Block_Abstract'), + array('_parentBlock', 'Mage_Core_Block_Abstract'), + array('_persistentCustomerGroupId'), + array('_ratingOptionTable', 'Mage_Rating_Model_Resource_Rating_Option_Collection'), + array('_saveTemplateFlag', 'Mage_Newsletter_Model_Queue'), + array('_searchTextFields'), + array('_setAttributes', 'Mage_Catalog_Model_Product_Type_Abstract'), + array('_skipFieldsByModel'), array('_ship_id'), + array('_shipTable', 'Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection'), array('_sortedChildren'), array('_sortInstructions'), + array('_storeFilter', 'Mage_Catalog_Model_Product_Type_Abstract'), array('_substServerVars'), array('_track_id'), array('_varSubFolders', null, 'Mage_Core_Model_Dir'), array('_viewDir', 'Mage_Core_Block_Template', '_dirs'), + array('decoratedIsFirst', null, 'getDecoratedIsFirst'), + array('decoratedIsEven', null, 'getDecoratedIsEven'), + array('decoratedIsOdd', null, 'getDecoratedIsOdd'), + array('decoratedIsLast', null, 'getDecoratedIsLast'), + array('static', 'Mage_Core_Model_Email_Template_Filter'), ); diff --git a/dev/tests/static/testsuite/Legacy/_files/words_core.xml b/dev/tests/static/testsuite/Legacy/_files/words_core.xml index 22e6bd4d1002f..1ce6ef9008dab 100644 --- a/dev/tests/static/testsuite/Legacy/_files/words_core.xml +++ b/dev/tests/static/testsuite/Legacy/_files/words_core.xml @@ -49,7 +49,7 @@ CHANGELOG.markdown - app/code/core/Mage/User/data/user_setup/data-upgrade-1.6.1.1-1.6.1.2.php + app/code/Mage/User/data/user_setup/data-upgrade-1.6.1.1-1.6.1.2.php xmlconnect system/convert/gui system/convert/profiles @@ -57,7 +57,7 @@ Mage_Adminhtml::profiles - app/code/core/Mage/User/sql/user_setup/upgrade-1.6.1.2-1.6.1.3.php + app/code/Mage/User/sql/user_setup/upgrade-1.6.1.2-1.6.1.3.php xmlconnect system/convert/gui system/convert/profiles @@ -71,5 +71,73 @@ lib/Zend + + app/code/Mage/Core/Model/Theme.php + staging + + + app/code/Mage/Core/Model/Theme/Registration.php + staging + + + app/code/Mage/Core/Model/Theme/Service.php + staging + + + app/code/Mage/Core/Model/Theme/Domain/Factory.php + staging + + + app/code/Mage/Core/Model/Theme/Domain/Staging.php + staging + + + app/code/Mage/Core/Model/Theme/Domain/Virtual.php + staging + + + app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.10-1.6.0.11.php + staging + + + app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/Save.php + staging + + + app/code/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorController.php + staging + + + app/code/Mage/DesignEditor/Helper/Data.php + staging + + + dev/tests/integration/testsuite/Mage/Core/Model/Resource/Theme/CollectionTest.php + staging + + + dev/tests/unit/testsuite/Mage/Core/Model/ThemeTest.php + staging + + + dev/tests/unit/testsuite/Mage/Core/Model/Theme/Domain/StagingTest.php + staging + + + dev/tests/unit/testsuite/Mage/Core/Model/Theme/Domain/VirtualTest.php + staging + + + dev/tests/unit/testsuite/Mage/Core/Model/Theme/Copy/VirtualToStagingTest.php + staging + + + dev/tests/integration/testsuite/Mage/Core/Model/Theme/Copy/TestCase.php + staging + + + dev/tests/integration/testsuite/Mage/Core/Model/Theme/Copy/VirtualToStagingTest.php + staging + - + diff --git a/dev/tests/static/testsuite/Php/LiveCodeTest.php b/dev/tests/static/testsuite/Php/LiveCodeTest.php index 02b867447c359..a0a58b28c24a7 100644 --- a/dev/tests/static/testsuite/Php/LiveCodeTest.php +++ b/dev/tests/static/testsuite/Php/LiveCodeTest.php @@ -119,6 +119,8 @@ protected static function _readLists($globPattern) foreach (glob($globPattern) as $list) { $patterns = array_merge($patterns, file($list, FILE_IGNORE_NEW_LINES)); } + + // Expand glob patterns $result = array(); foreach ($patterns as $pattern) { if (0 === strpos($pattern, '#')) { diff --git a/dev/tests/static/testsuite/Php/_files/blacklist/common.txt b/dev/tests/static/testsuite/Php/_files/blacklist/common.txt index 7f40f50ee039f..b7c13e200ac4c 100644 --- a/dev/tests/static/testsuite/Php/_files/blacklist/common.txt +++ b/dev/tests/static/testsuite/Php/_files/blacklist/common.txt @@ -2,22 +2,23 @@ # Glob patterns are supported # Overrides the white list # -app/code/core/Mage/Backend/Model/Config.php -app/code/core/Mage/Backend/Model/Config/Structure/Converter.php -app/code/core/Mage/Backend/Model/Menu/Config.php -app/code/core/Mage/Backend/Block/Widget/Grid -app/code/core/Mage/Backend/view -app/code/core/Mage/Core/Model/Config/Data -app/code/core/Mage/Core/Model/Config/Element.php -app/code/core/Mage/DesignEditor/view -app/code/core/Mage/Webapi/view -app/code/core/Mage/User/view +app/code/Mage/Backend/Model/Config.php +app/code/Mage/Backend/Model/Config/Structure/Converter.php +app/code/Mage/Backend/Model/Menu/Config.php +app/code/Mage/Backend/Block/Widget/Grid +app/code/Mage/Backend/view +app/code/Mage/Core/Model/Config/Data +app/code/Mage/Core/Model/Config/Element.php +app/code/Mage/DesignEditor/view +app/code/Mage/Webapi/view +app/code/Mage/User/view +dev/tests/integration/testsuite/Magento/Code/_files +dev/tests/integration/testsuite/integrity/modular/BlockInstantiationTest.php dev/tests/integration/testsuite/integrity/modular/TemplateFilesTest.php dev/tests/integration/testsuite/integrity/theme/TemplateFilesTest.php dev/tests/integration/testsuite/Mage/Backend/Block/System/Config/FormStub.php dev/tests/integration/tmp dev/tests/static/testsuite/Php/Exemplar/_files/phpcs/input dev/tests/static/testsuite/Php/Exemplar/_files/phpmd/input -app/code/core/Mage/Backend/view -app/code/core/Mage/Theme/view/adminhtml/tabs/fieldset/js_items.phtml -app/code/core/Mage/Theme/view/adminhtml/browser/content/files.phtml +app/code/Mage/Theme/view/adminhtml/tabs/fieldset/js_items.phtml +app/code/Mage/Theme/view/adminhtml/browser/content/files.phtml diff --git a/dev/tests/static/testsuite/Php/_files/phpcpd/blacklist/common.txt b/dev/tests/static/testsuite/Php/_files/phpcpd/blacklist/common.txt index f198be89ef27a..a70d28e1df7cf 100644 --- a/dev/tests/static/testsuite/Php/_files/phpcpd/blacklist/common.txt +++ b/dev/tests/static/testsuite/Php/_files/phpcpd/blacklist/common.txt @@ -17,6 +17,8 @@ Mage/Paypal Mage/Paygate Mage/Downloadable Mage/Core/Model/Resource/Helper +Mage/Core/Model/Url/RewriteFactory +Mage/Core/Model/Layout/Merge/Factory Mage/Catalog/Model/Resource/Product/Indexer Mage/CatalogInventory/Model/Resource/Indexer/Stock Mage/Sales/Model/Order @@ -69,6 +71,7 @@ lib/Mage/HTTP/Client lib/Magento/Acl lib/PEAR lib/phpseclib +lib/twig12 lib/Varien/Convert Mage/Cron/Model Mage/SalesRule/Model/Resource/Report/Rule diff --git a/dev/tests/static/testsuite/Php/_files/whitelist/common.txt b/dev/tests/static/testsuite/Php/_files/whitelist/common.txt index 95d12cd5145db..44e395e2a9cd9 100644 --- a/dev/tests/static/testsuite/Php/_files/whitelist/common.txt +++ b/dev/tests/static/testsuite/Php/_files/whitelist/common.txt @@ -2,85 +2,92 @@ # Glob patterns are supported # app/bootstrap.php -app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Popup/Grid.php -app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Weight/Renderer.php -app/code/core/Mage/Adminhtml/Block/Catalog/Product/Options/Ajax.php -app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php -app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php -app/code/core/Mage/Adminhtml/Model/Observer.php -app/code/core/Mage/Adminhtml/Block/Urlrewrite -app/code/core/Mage/Adminhtml/Block/Page/System/Config/Robots/Reset.php -app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/NewCategory.php -app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Category.php -app/code/core/Mage/Adminhtml/Block/System/Store/Edit -app/code/core/Mage/Adminhtml/Block/System/Store/Edit.php -app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php -app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php -app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php -app/code/core/Mage/Backend -app/code/core/Mage/Catalog/Block/Product/Configurable -app/code/core/Mage/Catalog/Model/Product/Limitation.php -app/code/core/Mage/Catalog/Block/Product/Grouped -app/code/core/Mage/Catalog/Block/Product/TemplateSelector.php -app/code/core/Mage/Catalog/Model/Resource/Product/Collection -app/code/core/Mage/Catalog/Model/Product/Type.php -app/code/core/Mage/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php -app/code/core/Mage/Centinel/Model/State/Jcb.php -app/code/core/Mage/Cms/Controller/Router.php -app/code/core/Mage/Core/Block/Abstract.php -app/code/core/Mage/Core/Controller/Varien/ActionAbstract.php -app/code/core/Mage/Core/Controller/Varien/Action/Factory.php -app/code/core/Mage/Core/Controller/Varien/Router/Factory.php -app/code/core/Mage/Core/Controller/Varien/Action/Forward.php -app/code/core/Mage/Core/Controller/Varien/DispatchableInterface.php -app/code/core/Mage/Core/Controller/Varien/Router/Abstract.php -app/code/core/Mage/Core/data -app/code/core/Mage/Core/Model/Abstract.php -app/code/core/Mage/Core/Model/Config -app/code/core/Mage/Core/Model/Design.php -app/code/core/Mage/Core/Model/Design/Fallback -app/code/core/Mage/Core/Model/Design/Fallback.php -app/code/core/Mage/Core/Model/Design/FallbackInterface.php -app/code/core/Mage/Core/Model/Design/Source/Design.php -app/code/core/Mage/Core/Model/Dir.php -app/code/core/Mage/Core/Model/EntryPoint -app/code/core/Mage/Core/Model/Layout.php -app/code/core/Mage/Core/Model/Layout/Factory.php -app/code/core/Mage/Core/Model/Layout/Update.php -app/code/core/Mage/Core/Model/Layout/Argument -app/code/core/Mage/Core/Model/ObjectManager -app/code/core/Mage/Core/Model/Resource/Setup/Migration.php -app/code/core/Mage/Core/Model/Resource/Theme/Collection.php -app/code/core/Mage/Core/Model/Resource/Theme.php -app/code/core/Mage/Core/Model/ShellAbstract.php -app/code/core/Mage/Core/Model/Theme/Validator.php -app/code/core/Mage/Core/Model/Theme.php -app/code/core/Mage/Core/Model/Translate.php -app/code/core/Mage/Core/Model/Translate/Expr.php -app/code/core/Mage/Core/Helper/Abstract.php -app/code/core/Mage/Core/sql/core_setup/upgrade-1.6.0.3-1.6.0.4.php -app/code/core/Mage/Directory/Model/Currency/DefaultLocator.php -app/code/core/Mage/DesignEditor -app/code/core/Mage/ImportExport/Model/Import/Entity/CustomerComposite.php -app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Option.php -app/code/core/Mage/ImportExport/Model/Resource/Customer/Storage.php -app/code/core/Mage/ImportExport/Model/Resource/Import/CustomerComposite/Data.php -app/code/core/Mage/Index/Model/Indexer/Abstract.php -app/code/core/Mage/Index/Model/Shell.php -app/code/core/Mage/Log/Model/Resource/Helper -app/code/core/Mage/Log/Model/Resource/Shell.php -app/code/core/Mage/Log/Model/Shell.php -app/code/core/Mage/Page/Helper/Robots.php -app/code/core/Mage/Reports/Block/Adminhtml/Customer -app/code/core/Mage/Reports/Block/Adminhtml/Product -app/code/core/Mage/Reports/Model/Resource/Accounts -app/code/core/Mage/Reports/Model/Resource/Customer -app/code/core/Mage/Reports/Model/Resource/Report/Collection.php -app/code/core/Mage/Tag/Block/Adminhtml/Customer/Edit/Tab/Tag.php -app/code/core/Mage/Tag/Block/Catalog/Product/Rss/Link.php -app/code/core/Mage/Theme -app/code/core/Mage/User -app/code/core/Mage/Webapi +app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Popup/Grid.php +app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Weight.php +app/code/Mage/Adminhtml/Block/Catalog/Product/Options/Ajax.php +app/code/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php +app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php +app/code/Mage/Adminhtml/Model/Observer.php +app/code/Mage/Adminhtml/Block/Urlrewrite +app/code/Mage/Adminhtml/Block/Page/System/Config/Robots/Reset.php +app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/NewCategory.php +app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Category.php +app/code/Mage/Adminhtml/Block/System/Store/Edit +app/code/Mage/Adminhtml/Block/System/Store/Edit.php +app/code/Mage/Adminhtml/controllers/Report/CustomerController.php +app/code/Mage/Adminhtml/controllers/Report/ProductController.php +app/code/Mage/Adminhtml/controllers/UrlrewriteController.php +app/code/Mage/Api/Model/Cache/Type.php +app/code/Mage/Backend +app/code/Mage/Catalog/Block/Product/Configurable +app/code/Mage/Catalog/Model/Product/Limitation.php +app/code/Mage/Catalog/Block/Product/Grouped +app/code/Mage/Catalog/Block/Product/TemplateSelector.php +app/code/Mage/Catalog/Model/Resource/Product/Collection +app/code/Mage/Catalog/Model/Product/Type.php +app/code/Mage/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php +app/code/Mage/Centinel/Model/State/Jcb.php +app/code/Mage/Cms/Controller/Router.php +app/code/Mage/Core/Block/Abstract.php +app/code/Mage/Core/Controller/Varien/ActionAbstract.php +app/code/Mage/Core/Controller/Varien/Action/Factory.php +app/code/Mage/Core/Controller/Varien/Router/Factory.php +app/code/Mage/Core/Controller/Varien/Action/Forward.php +app/code/Mage/Core/Controller/Varien/DispatchableInterface.php +app/code/Mage/Core/Controller/Varien/Router/Abstract.php +app/code/Mage/Core/data +app/code/Mage/Core/Model/Abstract.php +app/code/Mage/Core/Model/Config +app/code/Mage/Core/Model/Cache +app/code/Mage/Core/Model/Design.php +app/code/Mage/Core/Model/Design/FileResolution +app/code/Mage/Core/Model/Design/Fallback +app/code/Mage/Core/Model/Design/Source/Design.php +app/code/Mage/Core/Model/Dir.php +app/code/Mage/Core/Model/EntryPoint +app/code/Mage/Core/Model/Layout.php +app/code/Mage/Core/Model/Layout/Factory.php +app/code/Mage/Core/Model/Layout/Update.php +app/code/Mage/Core/Model/Layout/Argument +app/code/Mage/Core/Model/ObjectManager +app/code/Mage/Core/Model/Page +app/code/Mage/Core/Model/Page.php +app/code/Mage/Core/Model/Resource/Setup/Migration.php +app/code/Mage/Core/Model/Resource/Theme +app/code/Mage/Core/Model/Resource/Theme.php +app/code/Mage/Core/Model/ShellAbstract.php +app/code/Mage/Core/Model/Theme +app/code/Mage/Core/Model/Theme.php +app/code/Mage/Core/Model/ThemeInterface.php +app/code/Mage/Core/Model/Translate.php +app/code/Mage/Core/Model/Translate/Expr.php +app/code/Mage/Core/Helper/Abstract.php +app/code/Mage/Core/sql/core_setup/upgrade-1.6.0.3-1.6.0.4.php +app/code/Mage/Directory/Model/Currency/DefaultLocator.php +app/code/Mage/DesignEditor +app/code/Mage/Eav/Model/Cache/Type.php +app/code/Mage/ImportExport/Model/Import/Entity/CustomerComposite.php +app/code/Mage/ImportExport/Model/Import/Entity/Product/Option.php +app/code/Mage/ImportExport/Model/Resource/Customer/Storage.php +app/code/Mage/ImportExport/Model/Resource/Import/CustomerComposite/Data.php +app/code/Mage/ImportExport/controllers/Adminhtml/ImportController.php +app/code/Mage/Index/Model/Indexer/Abstract.php +app/code/Mage/Index/Model/Shell.php +app/code/Mage/Log/Model/Resource/Helper +app/code/Mage/Log/Model/Resource/Shell.php +app/code/Mage/Log/Model/Shell.php +app/code/Mage/Page/Helper/Robots.php +app/code/Mage/Page/Model/Asset +app/code/Mage/Reports/Block/Adminhtml/Customer +app/code/Mage/Reports/Block/Adminhtml/Product +app/code/Mage/Reports/Model/Resource/Accounts +app/code/Mage/Reports/Model/Resource/Customer +app/code/Mage/Reports/Model/Resource/Report/Collection.php +app/code/Mage/Tag/Block/Adminhtml/Customer/Edit/Tab/Tag.php +app/code/Mage/Tag/Block/Catalog/Product/Rss/Link.php +app/code/Mage/Theme +app/code/Mage/User +app/code/Mage/Webapi dev/shell dev/tests/integration dev/tests/js @@ -92,3 +99,4 @@ lib/Magento lib/Varien/Convert lib/Varien/Date.php lib/Varien/Object.php +lib/Varien/Cache/Core.php diff --git a/dev/tests/static/testsuite/Utility/Classes.php b/dev/tests/static/testsuite/Utility/Classes.php index 82269c33bdaa6..26befd81624ae 100644 --- a/dev/tests/static/testsuite/Utility/Classes.php +++ b/dev/tests/static/testsuite/Utility/Classes.php @@ -166,7 +166,7 @@ public static function collectLayoutClasses(SimpleXMLElement $xml) public static function collectModuleClasses($subTypePattern = '[A-Za-z]+') { $pattern = '/^' . preg_quote(Utility_Files::init()->getPathToSource(), '/') - . '\/app\/code\/[a-z]+\/([A-Za-z]+)\/([A-Za-z]+)\/(' . $subTypePattern . '\/.+)\.php$/'; + . '\/app\/code\/([A-Za-z]+)\/([A-Za-z]+)\/(' . $subTypePattern . '\/.+)\.php$/'; $result = array(); foreach (Utility_Files::init()->getPhpFiles(true, false, false, false) as $file) { if (preg_match($pattern, $file, $matches)) { diff --git a/dev/tests/static/testsuite/Utility/Files.php b/dev/tests/static/testsuite/Utility/Files.php index be0fc6e79f513..c76dc6ed3457d 100644 --- a/dev/tests/static/testsuite/Utility/Files.php +++ b/dev/tests/static/testsuite/Utility/Files.php @@ -111,13 +111,13 @@ public function getPhpFiles($appCode = true, $otherCode = true, $templates = tru { $key = __METHOD__ . "/{$this->_path}/{$appCode}/{$otherCode}/{$templates}"; if (!isset(self::$_cache[$key])) { - $pool = $namespace = $module = $area = $package = $theme = '*'; + $namespace = $module = $area = $package = $theme = '*'; $files = array(); if ($appCode) { $files = array_merge( glob($this->_path . '/app/*.php', GLOB_NOSORT), - self::_getFiles(array("{$this->_path}/app/code/{$pool}/{$namespace}/{$module}"), '*.php') + self::_getFiles(array("{$this->_path}/app/code/{$namespace}/{$module}"), '*.php') ); } if ($otherCode) { @@ -130,7 +130,7 @@ public function getPhpFiles($appCode = true, $otherCode = true, $templates = tru } if ($templates) { $files = array_merge($files, - self::_getFiles(array("{$this->_path}/app/code/{$pool}/{$namespace}/{$module}"), '*.phtml'), + self::_getFiles(array("{$this->_path}/app/code/{$namespace}/{$module}"), '*.phtml'), self::_getFiles( array("{$this->_path}/app/design/{$area}/{$package}/{$theme}/{$namespace}_{$module}"), '*.phtml' ) @@ -171,7 +171,7 @@ public function getConfigFiles( ) { $cacheKey = __METHOD__ . '|' . $this->_path . '|' . serialize(func_get_args()); if (!isset(self::$_cache[$cacheKey])) { - $files = glob($this->_path . "/app/code/*/*/*/etc/$fileNamePattern", GLOB_NOSORT | GLOB_BRACE); + $files = glob($this->_path . "/app/code/*/*/etc/$fileNamePattern", GLOB_NOSORT | GLOB_BRACE); $files = array_filter($files, function ($file) use ($excludedFileNames) { return !in_array(basename($file), $excludedFileNames); }); @@ -188,7 +188,6 @@ public function getConfigFiles( * * An incoming array can contain the following items * array ( - * 'pool' => 'pool_name', * 'namespace' => 'namespace_name', * 'module' => 'module_name', * 'area' => 'area_name', @@ -205,7 +204,6 @@ public function getConfigFiles( public function getLayoutFiles($incomingParams = array(), $asDataSet = true) { $params = array( - 'pool' => '*', 'namespace' => '*', 'module' => '*', 'area' => '*', @@ -225,7 +223,7 @@ public function getLayoutFiles($incomingParams = array(), $asDataSet = true) $files = array(); if ($params['include_code']) { $files = self::_getFiles( - array("{$this->_path}/app/code/{$params['pool']}/{$params['namespace']}/{$params['module']}" + array("{$this->_path}/app/code/{$params['namespace']}/{$params['module']}" . "/view/{$params['area']}"), '*.xml' ); @@ -264,10 +262,10 @@ public function getJsFiles() if (isset(self::$_cache[$key])) { return self::$_cache[$key]; } - $pool = $namespace = $module = $area = $package = $theme = $skin = '*'; + $namespace = $module = $area = $package = $theme = $skin = '*'; $files = self::_getFiles( array( - "{$this->_path}/app/code/{$pool}/{$namespace}/{$module}/view/{$area}", + "{$this->_path}/app/code/{$namespace}/{$module}/view/{$area}", "{$this->_path}/app/design/{$area}/{$package}/{$theme}/skin/{$skin}", "{$this->_path}/pub/lib/{mage,varien}" ), @@ -289,7 +287,7 @@ public function getEmailTemplates() if (isset(self::$_cache[$key])) { return self::$_cache[$key]; } - $files = self::_getFiles(array($this->_path . '/app/code/*/*/*/view/email'), '*.html'); + $files = self::_getFiles(array($this->_path . '/app/code/*/*/view/email'), '*.html'); $result = self::composeDataSets($files); self::$_cache[$key] = $result; return $result; @@ -356,16 +354,16 @@ protected static function _getFiles(array $dirPatterns, $fileNamePattern) } /** - * Check if specified class exists within code pools + * Check if specified class exists * * @param string $class * @param string &$path * @return bool */ - public function codePoolClassFileExists($class, &$path = '') + public function classFileExists($class, &$path = '') { $path = implode(DIRECTORY_SEPARATOR, explode('_', $class)) . '.php'; - $directories = array('/app/code/core/', '/app/code/community/', '/app/code/local/', '/lib/'); + $directories = array('/app/code/', '/lib/'); foreach ($directories as $dir) { $fullPath = str_replace('/', DIRECTORY_SEPARATOR, $this->_path . $dir . $path); /** @@ -374,7 +372,9 @@ public function codePoolClassFileExists($class, &$path = '') */ if (realpath($fullPath) == $fullPath) { $fileContent = file_get_contents($fullPath); - if (strpos($fileContent, 'class ' . $class) !== false) { + if (strpos($fileContent, 'class ' . $class) !== false || + strpos($fileContent, 'interface ' . $class) !== false + ) { return true; } } diff --git a/dev/tests/unit/framework/Magento/Framework/TestCase.php b/dev/tests/unit/framework/Magento/Framework/TestCase.php new file mode 100644 index 0000000000000..994bd83b94613 --- /dev/null +++ b/dev/tests/unit/framework/Magento/Framework/TestCase.php @@ -0,0 +1,51 @@ +assertEquals( + $this->_normalizeNewlines($expected), + $this->_normalizeNewlines($actual), + $message, + 0, + 10, + FALSE, + $ignoreCase + ); + } + + protected function _normalizeNewlines($string) + { + $str = str_replace(array("\r\n", "\r"), "\n", $string); + return $str; + } + + public function isWindows() + { + return !substr_compare(PHP_OS, 'WIN', 0, true); + } +} \ No newline at end of file diff --git a/dev/tests/unit/framework/Magento/Test/Helper/ObjectManager.php b/dev/tests/unit/framework/Magento/Test/Helper/ObjectManager.php index 74b11836bc6f1..5e9cc270db97d 100644 --- a/dev/tests/unit/framework/Magento/Test/Helper/ObjectManager.php +++ b/dev/tests/unit/framework/Magento/Test/Helper/ObjectManager.php @@ -29,48 +29,14 @@ */ class Magento_Test_Helper_ObjectManager { - /**#@+ - * Supported entities keys. - */ - const BLOCK_ENTITY = 'block'; - const MODEL_ENTITY = 'model'; - /**#@-*/ - /** - * List of supported entities which can be initialized with their dependencies - * Example: - * array( - * 'entityName' => array( - * 'paramName' => 'Mage_Class_Name' or 'callbackMethod' - * ) - * ); + * Special cases configuration * * @var array */ - protected $_supportedEntities = array( - self::BLOCK_ENTITY => array( - 'request' => 'Mage_Core_Controller_Request_Http', - 'layout' => 'Mage_Core_Model_Layout', - 'eventManager' => 'Mage_Core_Model_Event_Manager', - 'urlBuilder' => 'Mage_Core_Model_Url', - 'translator' => '_getTranslatorMock', - 'cache' => 'Mage_Core_Model_Cache', - 'designPackage' => 'Mage_Core_Model_Design_Package', - 'session' => 'Mage_Core_Model_Session', - 'storeConfig' => 'Mage_Core_Model_Store_Config', - 'frontController' => 'Mage_Core_Controller_Varien_Front', - 'helperFactory' => 'Mage_Core_Model_Factory_Helper', - 'dirs' => 'Mage_Core_Model_Dir', - 'logger' => 'Mage_Core_Model_Logger', - 'filesystem' => 'Magento_Filesystem', - ), - self::MODEL_ENTITY => array( - 'eventDispatcher' => 'Mage_Core_Model_Event_Manager', - 'cacheManager' => 'Mage_Core_Model_Cache', - 'resource' => '_getResourceModelMock', - 'resourceCollection' => 'Varien_Data_Collection_Db', - 'filesystem' => 'Magento_Filesystem', - ) + protected $_specialCases = array( + 'Mage_Core_Model_Resource_Abstract' => '_getResourceModelMock', + 'Mage_Core_Model_Translate' => '_getTranslatorMock', ); /** @@ -91,63 +57,43 @@ public function __construct(PHPUnit_Framework_TestCase $testObject) } /** - * Get block instance - * - * @param string $className - * @param array $arguments - * @return Mage_Core_Block_Abstract - */ - public function getBlock($className, array $arguments = array()) - { - $arguments = $this->getConstructArguments(self::BLOCK_ENTITY, $className, $arguments); - return $this->_getInstanceViaConstructor($className, $arguments); - } - - /** - * Get model instance + * Get mock for argument * - * @param string $className - * @param array $arguments - * @return Mage_Core_Model_Abstract + * @param string $argClassName + * @param array $originalArguments + * @return null|object|PHPUnit_Framework_MockObject_MockObject */ - public function getModel($className, array $arguments = array()) + protected function _createArgumentMock($argClassName, array $originalArguments) { - $arguments = $this->getConstructArguments(self::MODEL_ENTITY, $className, $arguments); - return $this->_getInstanceViaConstructor($className, $arguments); + $object = null; + if ($argClassName) { + $object = $this->_processSpecialCases($argClassName, $originalArguments); + if (null === $object) { + $object = $this->_getMockWithoutConstructorCall($argClassName); + } + } + return $object; } /** - * Retrieve list of arguments that used for new block instance creation + * Process special cases * - * @param string $entityName * @param string $className * @param array $arguments - * @throws InvalidArgumentException - * @return array + * @return null|object */ - public function getConstructArguments($entityName, $className = '', array $arguments = array()) + protected function _processSpecialCases($className, $arguments) { - if (!array_key_exists($entityName, $this->_supportedEntities)) { - throw new InvalidArgumentException('Unsupported entity type'); - } - - $constructArguments = array(); - foreach ($this->_supportedEntities[$entityName] as $propertyName => $propertyType) { - if (!isset($arguments[$propertyName])) { - if (method_exists($this, $propertyType)) { - $constructArguments[$propertyName] = $this->$propertyType(); - } else { - $constructArguments[$propertyName] = $this->_getMockWithoutConstructorCall($propertyType); - } - } + $object = null; + $interfaces = class_implements($className); + if (in_array('Magento_ObjectManager_ContextInterface', $interfaces)) { + $object = $this->getObject($className, $arguments); + } elseif (isset($this->_specialCases[$className])) { + $method = $this->_specialCases[$className]; + $object = $this->$method($className); } - $constructArguments = array_merge($constructArguments, $arguments); - if ($className) { - return $this->_sortConstructorArguments($className, $constructArguments); - } else { - return $constructArguments; - } + return $object; } /** @@ -170,11 +116,12 @@ protected function _getResourceModelMock() /** * Retrieve mock of core translator model * + * @param string $className * @return Mage_Core_Model_Translate|PHPUnit_Framework_MockObject_MockObject */ - protected function _getTranslatorMock() + protected function _getTranslatorMock($className) { - $translator = $this->_testObject->getMockBuilder('Mage_Core_Model_Translate') + $translator = $this->_testObject->getMockBuilder($className) ->disableOriginalConstructor() ->setMethods(array('translate')) ->getMock(); @@ -194,54 +141,70 @@ protected function _getTranslatorMock() } /** - * Sort constructor arguments array as is defined for current class interface + * Get mock without call of original constructor * * @param string $className - * @param array $arguments - * @return array + * @return PHPUnit_Framework_MockObject_MockObject */ - protected function _sortConstructorArguments($className, array $arguments) + protected function _getMockWithoutConstructorCall($className) { - $constructArguments = array(); - $method = new ReflectionMethod($className, '__construct'); - foreach ($method->getParameters() as $parameter) { - $parameterName = $parameter->getName(); - if (isset($arguments[$parameterName])) { - $constructArguments[$parameterName] = $arguments[$parameterName]; - } else { - if ($parameter->isDefaultValueAvailable()) { - $constructArguments[$parameterName] = $parameter->getDefaultValue(); - } else { - $constructArguments[$parameterName] = null; - } - } + $class = new ReflectionClass($className); + $mock = null; + if ($class->isAbstract()) { + $mock = $this->_testObject->getMockForAbstractClass($className, array(), '', false, false); + } else { + $mock = $this->_testObject->getMock($className, array(), array(), '', false, false); } - - return $constructArguments; + return $mock; } /** - * Get mock without call of original constructor + * Get class instance * - * @param string $className - * @return PHPUnit_Framework_MockObject_MockObject + * @param $className + * @param array $arguments + * @return object */ - protected function _getMockWithoutConstructorCall($className) + public function getObject($className, array $arguments = array()) { - - return $this->_testObject->getMock($className, array(), array(), '', false); + $constructArguments = $this->getConstructArguments($className, $arguments); + $reflectionClass = new ReflectionClass($className); + return $reflectionClass->newInstanceArgs($constructArguments); } /** - * Get class instance via constructor + * Retrieve list of arguments that used for new object instance creation * * @param string $className * @param array $arguments - * @return object + * @return array */ - protected function _getInstanceViaConstructor($className, array $arguments = array()) + public function getConstructArguments($className, array $arguments = array()) { - $reflectionClass = new ReflectionClass($className); - return $reflectionClass->newInstanceArgs($arguments); + $constructArguments = array(); + $method = new ReflectionMethod($className, '__construct'); + + foreach ($method->getParameters() as $parameter) { + $parameterName = $parameter->getName(); + $argClassName = null; + $defaultValue = null; + + if (isset($arguments[$parameterName])) { + $constructArguments[$parameterName] = $arguments[$parameterName]; + continue; + } + + if ($parameter->isDefaultValueAvailable()) { + $defaultValue = $parameter->getDefaultValue(); + } + + if ($parameter->getClass()) { + $argClassName = $parameter->getClass()->getName(); + } + + $object = $this->_createArgumentMock($argClassName, $arguments); + $constructArguments[$parameterName] = null === $object ? $defaultValue : $object; + } + return $constructArguments; } } diff --git a/dev/tests/unit/framework/Magento/Test/Helper/ProxyTesting.php b/dev/tests/unit/framework/Magento/Test/Helper/ProxyTesting.php new file mode 100644 index 0000000000000..62776f0178361 --- /dev/null +++ b/dev/tests/unit/framework/Magento/Test/Helper/ProxyTesting.php @@ -0,0 +1,61 @@ +expects(new PHPUnit_Framework_MockObject_Matcher_InvokedCount(1)) + ->method($expectedMethod); + $builder = call_user_func_array(array($builder, 'with'), $expectedParams); + $builder->will(new PHPUnit_Framework_MockObject_Stub_Return($proxiedResult)); + + return call_user_func_array(array($object, $method), $params); + } +} diff --git a/dev/tests/unit/framework/Magento/Test/Listener/GarbageCleanup.php b/dev/tests/unit/framework/Magento/Test/Listener/GarbageCleanup.php new file mode 100644 index 0000000000000..6da5327befe7c --- /dev/null +++ b/dev/tests/unit/framework/Magento/Test/Listener/GarbageCleanup.php @@ -0,0 +1,101 @@ + 'Mage_Core_Model_Layout', 'eventManager' => 'Mage_Core_Model_Event_Manager', 'translator' => 'Mage_Core_Model_Translate', - 'cache' => 'Mage_Core_Model_Cache', + 'cache' => 'Mage_Core_Model_CacheInterface', 'designPackage' => 'Mage_Core_Model_Design_Package', 'session' => 'Mage_Core_Model_Session', 'storeConfig' => 'Mage_Core_Model_Store_Config', @@ -51,7 +51,7 @@ class Magento_Test_TestCase_ObjectManagerTest extends PHPUnit_Framework_TestCase */ protected $_modelDependencies = array( 'eventDispatcher' => 'Mage_Core_Model_Event_Manager', - 'cacheManager' => 'Mage_Core_Model_Cache', + 'cacheManager' => 'Mage_Core_Model_CacheInterface', 'resource' => 'Mage_Core_Model_Resource_Abstract', 'resourceCollection' => 'Varien_Data_Collection_Db' ); @@ -63,7 +63,7 @@ public function testGetBlock() { $objectManager = new Magento_Test_Helper_ObjectManager($this); /** @var $template Mage_Core_Block_Template */ - $template = $objectManager->getBlock('Mage_Core_Block_Template'); + $template = $objectManager->getObject('Mage_Core_Block_Template'); $this->assertInstanceOf('Mage_Core_Block_Template', $template); foreach ($this->_blockDependencies as $propertyName => $propertyType) { $this->assertAttributeInstanceOf($propertyType, '_' . $propertyName, $template); @@ -78,7 +78,7 @@ public function testGetBlock() $arguments = array('layout' => $layoutMock); /** @var $template Mage_Core_Block_Template */ - $template = $objectManager->getBlock('Mage_Core_Block_Template', $arguments); + $template = $objectManager->getObject('Mage_Core_Block_Template', $arguments); $this->assertEquals($area, $template->getArea()); } @@ -89,7 +89,7 @@ public function testGetModel() { $objectManager = new Magento_Test_Helper_ObjectManager($this); /** @var $model Mage_Core_Model_Config_Data */ - $model = $objectManager->getModel('Mage_Core_Model_Config_Data'); + $model = $objectManager->getObject('Mage_Core_Model_Config_Data'); $this->assertInstanceOf('Mage_Core_Model_Config_Data', $model); foreach ($this->_modelDependencies as $propertyName => $propertyType) { $this->assertAttributeInstanceOf($propertyType, '_' . $propertyName, $model); @@ -106,7 +106,7 @@ public function testGetModel() ->method('getIdFieldName') ->will($this->returnValue('id')); $arguments = array('resource' => $resourceMock); - $model = $objectManager->getModel('Mage_Core_Model_Config_Data', $arguments); + $model = $objectManager->getObject('Mage_Core_Model_Config_Data', $arguments); $this->assertFalse($model->getResource()->getDataVersion('test')); } } diff --git a/dev/tests/unit/framework/tests/unit/testsuite/Magento/Test/Helper/ProxyTestingTest.php b/dev/tests/unit/framework/tests/unit/testsuite/Magento/Test/Helper/ProxyTestingTest.php new file mode 100644 index 0000000000000..1a76468e9325b --- /dev/null +++ b/dev/tests/unit/framework/tests/unit/testsuite/Magento/Test/Helper/ProxyTestingTest.php @@ -0,0 +1,103 @@ +getMock('stdClass', array($callProxiedMethod)); + + // Create object, which reacts on called $method by calling $callProxiedMethod from proxied object + $callProxy = function () use ($proxiedObject, $callProxiedMethod, $passProxiedParams) { + return call_user_func_array(array($proxiedObject, $callProxiedMethod), $passProxiedParams); + }; + + $object = $this->getMock('stdClass', array($method)); + $builder = $object->expects($this->once()) + ->method($method); + call_user_func_array(array($builder, 'with'), $params); + $builder->will($this->returnCallback($callProxy)); + + // Test it + $helper = new Magento_Test_Helper_ProxyTesting(); + $result = $helper->invokeWithExpectations($object, $proxiedObject, $method, $params, $proxiedResult, + $proxiedMethod, $proxiedParams); + $this->assertSame($expectedResult, $result); + } + + /** + * @return array + */ + public static function invokeWithExpectationsDataProvider() + { + return array( + 'all parameters passed' => array( + 'method' => 'returnAplusB', + 'params' => array(3, 4), + 'proxiedResult' => 7, + 'proxiedMethod' => 'returnAplusB', + 'proxiedParams' => array(3, 4), + 'callProxiedMethod' => 'returnAplusB', + 'passProxiedParams' => array(3, 4), + 'expectedResult' => 7 + ), + 'proxied method and params are to be set from proxy method and params' => array( + 'method' => 'returnAplusB', + 'params' => array(3, 4), + 'proxiedResult' => 7, + 'proxiedMethod' => null, + 'proxiedParams' => null, + 'callProxiedMethod' => 'returnAplusB', + 'passProxiedParams' => array(3, 4), + 'expectedResult' => 7 + ), + 'proxy and proxied method and params differ' => array( + 'method' => 'returnAminusBminusC', + 'params' => array(10, 1, 2), + 'proxiedResult' => 7, + 'proxiedMethod' => 'returnAminusB', + 'proxiedParams' => array(10, 3), + 'callProxiedMethod' => 'returnAminusB', + 'passProxiedParams' => array(10, 3), + 'expectedResult' => 7 + ), + ); + } +} diff --git a/dev/tests/unit/phpunit.xml.dist b/dev/tests/unit/phpunit.xml.dist index 650a1af1dabd9..cc75034add9dc 100755 --- a/dev/tests/unit/phpunit.xml.dist +++ b/dev/tests/unit/phpunit.xml.dist @@ -32,5 +32,9 @@ + + + + diff --git a/dev/tests/unit/testsuite/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Weight/RendererTest.php b/dev/tests/unit/testsuite/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Weight/RendererTest.php index 3b69af28e7e7d..5a1baa18573f6 100644 --- a/dev/tests/unit/testsuite/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Weight/RendererTest.php +++ b/dev/tests/unit/testsuite/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Weight/RendererTest.php @@ -25,12 +25,12 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Weight_RendererTest extends PHPUnit_Framework_TestCase +class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_WeightTest extends PHPUnit_Framework_TestCase { const VIRTUAL_FIELD_HTML_ID = 'weight_and_type_switcher'; /** - * @var Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Weight_Renderer + * @var Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Weight */ protected $_model; @@ -54,7 +54,7 @@ public function testSetForm() $this->assertNull($this->_virtual->getLabel()); $this->assertNull($this->_virtual->getForm()); - $this->_model = new Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Weight_Renderer( + $this->_model = new Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Weight( array('element' => $this->_virtual, 'helper' => $helper) ); @@ -62,7 +62,7 @@ public function testSetForm() $this->_model->setForm($form); $this->assertEquals( - Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Weight_Renderer::VIRTUAL_FIELD_HTML_ID, + Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Weight::VIRTUAL_FIELD_HTML_ID, $this->_virtual->getId() ); $this->assertEquals('is_virtual', $this->_virtual->getName()); diff --git a/dev/tests/unit/testsuite/Mage/Adminhtml/Block/Page/System/Config/Robots/ResetTest.php b/dev/tests/unit/testsuite/Mage/Adminhtml/Block/Page/System/Config/Robots/ResetTest.php index 0864af404d6a9..1edb52c5e2069 100644 --- a/dev/tests/unit/testsuite/Mage/Adminhtml/Block/Page/System/Config/Robots/ResetTest.php +++ b/dev/tests/unit/testsuite/Mage/Adminhtml/Block/Page/System/Config/Robots/ResetTest.php @@ -43,7 +43,7 @@ class Mage_Adminhtml_Block_Page_System_Config_Robots_ResetTest extends PHPUnit_F protected function setUp() { $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); - $this->_resetRobotsBlock = $objectManagerHelper->getBlock( + $this->_resetRobotsBlock = $objectManagerHelper->getObject( 'Mage_Adminhtml_Block_Page_System_Config_Robots_Reset', array( 'application' => $this->getMock('Mage_Core_Model_App', array(), array(), '', false), diff --git a/dev/tests/unit/testsuite/Mage/Adminhtml/Block/System/Email/Template/EditTest.php b/dev/tests/unit/testsuite/Mage/Adminhtml/Block/System/Email/Template/EditTest.php index 49024f0b0f887..d8d5b0f87704c 100644 --- a/dev/tests/unit/testsuite/Mage/Adminhtml/Block/System/Email/Template/EditTest.php +++ b/dev/tests/unit/testsuite/Mage/Adminhtml/Block/System/Email/Template/EditTest.php @@ -58,11 +58,7 @@ protected function setUp() 'menuConfig' => $menuConfigMock, 'configStructure' => $this->_configStructureMock, ); - $arguments = $objectManager->getConstructArguments( - Magento_Test_Helper_ObjectManager::BLOCK_ENTITY, - 'Mage_Adminhtml_Block_System_Email_Template_Edit', - $params - ); + $arguments = $objectManager->getConstructArguments('Mage_Adminhtml_Block_System_Email_Template_Edit', $params); $urlBuilder->expects($this->any())->method('getUrl')->will($this->returnArgument(0)); $menuConfigMock->expects($this->any())->method('getMenu')->will($this->returnValue($menuMock)); @@ -98,7 +94,7 @@ protected function setUp() $layoutMock->expects($this->any())->method('helper')->will($this->returnValue($helperMock)); $helperMock->expects($this->any())->method('__')->will($this->returnArgument(0)); - $this->_block = $objectManager->getBlock('Mage_Adminhtml_Block_System_Email_Template_Edit', $arguments); + $this->_block = $objectManager->getObject('Mage_Adminhtml_Block_System_Email_Template_Edit', $arguments); } public function testGetUsedCurrentlyForPaths() diff --git a/dev/tests/unit/testsuite/Mage/Adminhtml/DashboardControllerTest.php b/dev/tests/unit/testsuite/Mage/Adminhtml/DashboardControllerTest.php index bd52faef9db65..1089676776f81 100644 --- a/dev/tests/unit/testsuite/Mage/Adminhtml/DashboardControllerTest.php +++ b/dev/tests/unit/testsuite/Mage/Adminhtml/DashboardControllerTest.php @@ -40,7 +40,7 @@ public function testTunnelAction() ); $helper->expects($this->any())->method('getChartDataHash')->will($this->returnValue($fixture)); - $objectManager = $this->getMock('Magento_ObjectManager_Zend', array('create', 'get')); + $objectManager = $this->getMock('Magento_ObjectManager'); $objectManager->expects($this->at(0)) ->method('get') ->with('Mage_Adminhtml_Helper_Dashboard_Data') @@ -76,7 +76,7 @@ public function testTunnelAction503() ); $helper->expects($this->any())->method('getChartDataHash')->will($this->returnValue($fixture)); - $objectManager = $this->getMock('Magento_ObjectManager_Zend', array('create', 'get')); + $objectManager = $this->getMock('Magento_ObjectManager'); $objectManager->expects($this->at(0)) ->method('get') ->with('Mage_Adminhtml_Helper_Dashboard_Data') @@ -103,7 +103,7 @@ public function testTunnelAction503() * * @param Mage_Core_Controller_Request_Http $request * @param Mage_Core_Controller_Response_Http|null $response - * @param Magento_ObjectManager_Zend|null $objectManager + * @param Magento_ObjectManager|null $objectManager * @return Mage_Adminhtml_DashboardController|PHPUnit_Framework_MockObject_MockObject */ protected function _factory($request, $response = null, $objectManager = null) @@ -114,7 +114,7 @@ protected function _factory($request, $response = null, $objectManager = null) $response->headersSentThrowsException = false; } if (!$objectManager) { - $objectManager = new Magento_ObjectManager_Zend; + $objectManager = new Magento_ObjectManager_ObjectManager(); } $routerFactory = $this->getMock('Mage_Core_Controller_Varien_Router_Factory', array(), array(), '', false); @@ -130,4 +130,4 @@ protected function _factory($request, $response = null, $objectManager = null) } } -require_once __DIR__ . '/../../../../../../app/code/core/Mage/Adminhtml/controllers/DashboardController.php'; +require_once __DIR__ . '/../../../../../../app/code/Mage/Adminhtml/controllers/DashboardController.php'; diff --git a/dev/tests/unit/testsuite/Mage/Backend/Block/Store/SwitcherTest.php b/dev/tests/unit/testsuite/Mage/Backend/Block/Store/SwitcherTest.php index 4579b8c7f679f..bc480c214b16c 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Block/Store/SwitcherTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Block/Store/SwitcherTest.php @@ -54,7 +54,7 @@ protected function setUp() $this->_storeGroupFactory = $this->getMock('Mage_Core_Model_Store_Group_Factory', array(), array(), '', false); $helper = new Magento_Test_Helper_ObjectManager($this); - $this->_object = $helper->getBlock('Mage_Backend_Block_Store_Switcher', array( + $this->_object = $helper->getObject('Mage_Backend_Block_Store_Switcher', array( 'urlBuilder' => $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false), 'application' => $this->_applicationModel, 'websiteFactory' => $this->_websiteFactory, diff --git a/dev/tests/unit/testsuite/Mage/Backend/Block/System/Config/EditTest.php b/dev/tests/unit/testsuite/Mage/Backend/Block/System/Config/EditTest.php index f4d73e7bfd6c7..93bc68caa0dab 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Block/System/Config/EditTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Block/System/Config/EditTest.php @@ -96,7 +96,7 @@ protected function setUp() ); $helper = new Magento_Test_Helper_ObjectManager($this); - $this->_object = $helper->getBlock('Mage_Backend_Block_System_Config_Edit', $data); + $this->_object = $helper->getObject('Mage_Backend_Block_System_Config_Edit', $data); } public function testGetSaveButtonHtml() diff --git a/dev/tests/unit/testsuite/Mage/Backend/Block/System/Config/Form/FieldTest.php b/dev/tests/unit/testsuite/Mage/Backend/Block/System/Config/Form/FieldTest.php index 412f7d29d00ec..edc8d9f7d19c4 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Block/System/Config/Form/FieldTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Block/System/Config/Form/FieldTest.php @@ -63,7 +63,7 @@ protected function setUp() 'urlBuilder' => $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false) ); $helper = new Magento_Test_Helper_ObjectManager($this); - $this->_object = $helper->getBlock('Mage_Backend_Block_System_Config_Form_Field', $data); + $this->_object = $helper->getObject('Mage_Backend_Block_System_Config_Form_Field', $data); $this->_testData = array( 'htmlId' => 'test_field_id', diff --git a/dev/tests/unit/testsuite/Mage/Backend/Block/System/Config/Form/FieldsetTest.php b/dev/tests/unit/testsuite/Mage/Backend/Block/System/Config/Form/FieldsetTest.php index 34b21ae8feb1a..1f357a1acc58a 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Block/System/Config/Form/FieldsetTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Block/System/Config/Form/FieldsetTest.php @@ -75,7 +75,7 @@ protected function setUp() ) ); $helper = new Magento_Test_Helper_ObjectManager($this); - $this->_object = $helper->getBlock('Mage_Backend_Block_System_Config_Form_Fieldset', $data); + $this->_object = $helper->getObject('Mage_Backend_Block_System_Config_Form_Fieldset', $data); $this->_testData = array( 'htmlId' => 'test_field_id', @@ -117,10 +117,12 @@ public function testRenderWithoutStoredElements() $this->_elementMock->expects($this->any())->method('getSortedElements')->will($this->returnValue(array())); - $expected = '
    '; + $expected = '
    '; - $expected .= '_testData['htmlId'] . '-link" class="entry-edit-head-link">'; + + $expected .= '' . $this->_testData['legend'] . ''; $expected .= '
    _block->getHeaderHtmlProperty()); } public function testGetHeaderHtmlPropertyWhenHeaderCssClassIsSet() { $this->_block->setData('header_css_class', 'test'); - $this->assertEquals(' class="test"', $this->_block->getHeaderHtmlProperty()); + $this->assertEquals(' class="test col-id"', $this->_block->getHeaderHtmlProperty()); } public function testAddHeaderCssClassWhenHeaderCssClassEmpty() { $this->_block->addHeaderCssClass('test'); - $this->assertEquals(' class="test"', $this->_block->getHeaderHtmlProperty()); + $this->assertEquals(' class="test col-id"', $this->_block->getHeaderHtmlProperty()); } public function testAddHeaderCssClassWhenHeaderCssClassIsSet() { $this->_block->setData('header_css_class', 'test1'); $this->_block->addHeaderCssClass('test2'); - $this->assertEquals(' class="test1 test2"', $this->_block->getHeaderHtmlProperty()); + $this->assertEquals(' class="test1 test2 col-id"', $this->_block->getHeaderHtmlProperty()); } public function testGetHeaderCssClassWhenNotSortable() { $this->_block->setData('header_css_class', 'test'); $this->_block->setSortable(false); - $this->assertEquals('test no-link', $this->_block->getHeaderCssClass()); + $this->assertEquals('test no-link col-id', $this->_block->getHeaderCssClass()); } public function testGetHeaderCssClassWhenIsSortable() { $this->_block->setData('header_css_class', 'test'); $this->_block->setSortable(true); - $this->assertEquals('test', $this->_block->getHeaderCssClass()); + $this->assertEquals('test col-id', $this->_block->getHeaderCssClass()); } public function testGetCssClassWithAlignAndEditableAndWithoutColumnCssClass() { $this->_block->setAlign('left'); $this->_block->setEditable(true); - $this->assertEquals('a-left editable', $this->_block->getCssClass()); + $this->assertEquals('a-left editable col-id', $this->_block->getCssClass()); } public function testGetCssClassWithAlignAndEditableAndWithColumnCssClass() @@ -323,12 +317,12 @@ public function testGetCssClassWithAlignAndEditableAndWithColumnCssClass() $this->_block->setEditable(true); $this->_block->setData('column_css_class', 'test'); - $this->assertEquals('a-left test editable', $this->_block->getCssClass()); + $this->assertEquals('a-left test editable col-id', $this->_block->getCssClass()); } public function testGetCssClassWithoutAlignEditableAndColumnCssClass() { - $this->assertEmpty($this->_block->getCssClass()); + $this->assertEquals(' col-id', $this->_block->getCssClass()); } public function testSetGetGrid() @@ -362,7 +356,7 @@ public function testColumnIsGrouped($groupedData, $expected) ); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); - $block = $objectManagerHelper->getBlock('Mage_Backend_Block_Widget_Grid_Column', $arguments); + $block = $objectManagerHelper->getObject('Mage_Backend_Block_Widget_Grid_Column', $arguments); $this->assertEquals($expected, $block->isGrouped()); } diff --git a/dev/tests/unit/testsuite/Mage/Backend/Block/Widget/Grid/MassactionTest.php b/dev/tests/unit/testsuite/Mage/Backend/Block/Widget/Grid/MassactionTest.php index bde6572ac4e5c..d10ca11250aa3 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Block/Widget/Grid/MassactionTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Block/Widget/Grid/MassactionTest.php @@ -93,10 +93,12 @@ protected function setUp() false ); + $this->_urlModelMock = $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false); + $arguments = array( 'layout' => $this->_layoutMock, 'request' => $this->_requestMock, - 'urlBuilder' => $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false), + 'urlBuilder' => $this->_urlModelMock, 'data' => array( 'massaction_id_field' => 'test_id', 'massaction_id_filter' => 'test_id' @@ -104,7 +106,7 @@ protected function setUp() ); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); - $this->_block = $objectManagerHelper->getBlock('Mage_Backend_Block_Widget_Grid_Massaction', $arguments); + $this->_block = $objectManagerHelper->getObject('Mage_Backend_Block_Widget_Grid_Massaction', $arguments); $this->_block->setNameInLayout('test_grid_massaction'); } @@ -141,7 +143,6 @@ public function testMassactionDefaultValues() */ public function testItemsProcessing($itemId, $item, $expectedItem) { - $this->markTestIncomplete('Need to fix DI dependencies'); $this->_urlModelMock->expects($this->any()) ->method('getBaseUrl') diff --git a/dev/tests/unit/testsuite/Mage/Backend/Helper/DataTest.php b/dev/tests/unit/testsuite/Mage/Backend/Helper/DataTest.php index fccbc93f0353f..b602ee22ee6fb 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Helper/DataTest.php @@ -41,7 +41,7 @@ public function setUp() { $this->_configMock = $this->getMock('Mage_Core_Model_Config', array(), array(), '', false, false); $this->_helper = new Mage_Backend_Helper_Data($this->_configMock, - $this->getMock('Mage_Core_Model_Translate', array(), array(), '', false, false) + $this->getMock('Mage_Core_Helper_Context', array(), array(), '', false, false) ); } diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/Acl/ConfigTest.php b/dev/tests/unit/testsuite/Mage/Backend/Model/Acl/ConfigTest.php index 8317f58f9c75b..8f1a9ebf63ffd 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Model/Acl/ConfigTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/Acl/ConfigTest.php @@ -51,7 +51,7 @@ public function setUp() { $this->_readerMock = $this->getMock('Magento_Acl_Config_Reader', array(), array(), '', false); $this->_configMock = $this->getMock('Mage_Core_Model_Config', array(), array(), '', false); - $this->_cacheMock = $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false); + $this->_cacheMock = $this->getMock('Mage_Core_Model_Cache_Type_Config', array(), array(), '', false); $this->_model = new Mage_Backend_Model_Acl_Config($this->_configMock, $this->_cacheMock, $this->getMock('Mage_Core_Model_Config_Modules_Reader', array(), array(), '', false, false) @@ -67,9 +67,6 @@ public function testGetAclResourcesWhenCacheLoadCorruptedValue() ->with($this->equalTo('Magento_Acl_Config_Reader')) ->will($this->returnValue($this->_readerMock)); - $this->_cacheMock->expects($this->exactly(2))->method('canUse') - ->with($this->equalTo('config'))->will($this->returnValue(true)); - $this->_cacheMock->expects($this->once())->method('load') ->with($this->equalTo(Mage_Backend_Model_Acl_Config::CACHE_ID)) ->will($this->returnValue(1234)); @@ -101,9 +98,6 @@ public function testGetAclResourcesWithEnabledAndCleanedUpCache() ->with($this->equalTo('Magento_Acl_Config_Reader')) ->will($this->returnValue($this->_readerMock)); - $this->_cacheMock->expects($this->exactly(2))->method('canUse') - ->with($this->equalTo('config'))->will($this->returnValue(true)); - $this->_cacheMock->expects($this->once())->method('load') ->with($this->equalTo(Mage_Backend_Model_Acl_Config::CACHE_ID)) ->will($this->returnValue(null)); @@ -125,9 +119,6 @@ public function testGetAclResourcesWithEnabledAndGeneratedCache() { $this->_configMock->expects($this->never())->method('getModelInstance'); - $this->_cacheMock->expects($this->exactly(2))->method('canUse') - ->with($this->equalTo('config'))->will($this->returnValue(true)); - $this->_cacheMock->expects($this->exactly(2))->method('load') ->with($this->equalTo(Mage_Backend_Model_Acl_Config::CACHE_ID)) ->will($this->returnValue('')); @@ -143,30 +134,5 @@ public function testGetAclResourcesWithEnabledAndGeneratedCache() $this->assertEquals($firstCall, $secondCall); } - - public function testGetAclResourcesWithDisabledCache() - { - $aclResources = new DOMDocument(); - $aclResources->loadXML(''); - - $this->_configMock->expects($this->once())->method('getModelInstance') - ->with($this->equalTo('Magento_Acl_Config_Reader')) - ->will($this->returnValue($this->_readerMock)); - - $this->_cacheMock->expects($this->exactly(4))->method('canUse') - ->with($this->equalTo('config'))->will($this->returnValue(false)); - - $this->_cacheMock->expects($this->never())->method('load'); - $this->_cacheMock->expects($this->never())->method('save'); - - $this->_readerMock->expects($this->exactly(2))->method('getAclResources') - ->will($this->returnValue($aclResources)); - - $firstCall = $this->_model->getAclResources(); - $secondCall = $this->_model->getAclResources(); - - $this->assertNotEmpty($firstCall); - $this->assertNotEmpty($secondCall); - } } diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/Config/Structure/Element/FieldTest.php b/dev/tests/unit/testsuite/Mage/Backend/Model/Config/Structure/Element/FieldTest.php index da9761850b9ec..35b651c8d2b11 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Model/Config/Structure/Element/FieldTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/Config/Structure/Element/FieldTest.php @@ -27,6 +27,8 @@ class Mage_Backend_Model_Config_Structure_Element_FieldTest extends PHPUnit_Framework_TestCase { + const FIELD_TEST_CONSTANT = "field test constant"; + /** * @var Mage_Backend_Model_Config_Structure_Element_Field */ @@ -62,6 +64,11 @@ class Mage_Backend_Model_Config_Structure_Element_FieldTest extends PHPUnit_Fram */ protected $_blockFactoryMock; + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_dsFactoryMock; + /** * @var PHPUnit_Framework_MockObject_MockObject */ @@ -82,7 +89,7 @@ public function setUp() return 'translated ' . $arg; })); $this->_factoryHelperMock = $this->getMock('Mage_Core_Model_Factory_Helper', array(), array(), '', false); - $this->_factoryHelperMock->expects($this->any())->method('get')->with('Mage_Module_Helper_Data') + $this->_factoryHelperMock->expects($this->any())->method('get') ->will($this->returnValue($helperMock)); $this->_applicationMock = $this->getMock('Mage_Core_Model_App', array(), array(), '', false); $this->_backendFactoryMock = $this->getMock( @@ -97,6 +104,9 @@ public function setUp() $this->_blockFactoryMock = $this->getMock( 'Mage_Core_Model_BlockFactory', array(), array(), '', false ); + $this->_dsFactoryMock = $this->getMock( + 'Magento_Datasource_Factory', array(), array(), '', false + ); $this->_depMapperMock = $this->getMock( 'Mage_Backend_Model_Config_Structure_Element_Dependency_Mapper', array(), array(), '', false ); @@ -108,6 +118,7 @@ public function setUp() $this->_sourceFactoryMock, $this->_commentFactoryMock, $this->_blockFactoryMock, + $this->_dsFactoryMock, $this->_depMapperMock ); } @@ -289,6 +300,49 @@ public function testHasSourceModel() $this->assertTrue($this->_model->hasSourceModel()); } + public function testHasOptionsWithSourceModel() + { + $this->assertFalse($this->_model->hasOptions()); + $this->_model->setData(array('source_model' => 'some_model'), 'scope'); + $this->assertTrue($this->_model->hasOptions()); + } + + public function testHasOptionsWithOptions() + { + $this->assertFalse($this->_model->hasOptions()); + $this->_model->setData(array('options' => 'some_option'), 'scope'); + $this->assertTrue($this->_model->hasOptions()); + } + + public function testGetOptionsWithOptions() + { + $option = array( + array('label' => 'test', 'value' => 0), + array('label' => 'test2', 'value' => 1) + ); + $expected = array( + array('label' => 'translated test', 'value' => 0), + array('label' => 'translated test2', 'value' => 1) + ); + $this->_model->setData(array('options' => array('option' => $option)), 'scope'); + $this->assertEquals($expected, $this->_model->getOptions()); + } + + public function testGetOptionsWithConstantValOptions() + { + $option = array( + array('label' => 'test', 'value' => + "{{Mage_Backend_Model_Config_Structure_Element_FieldTest::FIELD_TEST_CONSTANT}}"), + ); + $expected = array( + array('label' => 'translated test', 'value' => + Mage_Backend_Model_Config_Structure_Element_FieldTest::FIELD_TEST_CONSTANT), + ); + + $this->_model->setData(array('options' => array('option' => $option)), 'scope'); + $this->assertEquals($expected, $this->_model->getOptions()); + } + public function testGetOptionsUsesOptionsInterfaceIfNoMethodIsProvided() { $this->_model->setData(array('source_model' => 'Source_Model_Name'), 'scope'); @@ -297,7 +351,10 @@ public function testGetOptionsUsesOptionsInterfaceIfNoMethodIsProvided() ->method('create') ->with('Source_Model_Name') ->will($this->returnValue($sourceModelMock)); - $expected = array('testVar' => 'testVal'); + $expected = array( + array('label' => 'test', 'value' => 0), + array('label' => 'test2', 'value' => 1) + ); $sourceModelMock->expects($this->once()) ->method('toOptionArray') ->with(false) diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/Config/Structure/Element/FlyweightFactoryTest.php b/dev/tests/unit/testsuite/Mage/Backend/Model/Config/Structure/Element/FlyweightFactoryTest.php index eaf0fd3686d60..295de3214fbd3 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Model/Config/Structure/Element/FlyweightFactoryTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/Config/Structure/Element/FlyweightFactoryTest.php @@ -39,7 +39,7 @@ class Mage_Backend_Model_Config_Structure_Element_FlyweightFactoryTest extends P protected function setUp() { - $this->_objectManagerMock = $this->getMock('Magento_ObjectManager_Zend', array(), array(), '', false); + $this->_objectManagerMock = $this->getMock('Magento_ObjectManager'); $this->_model = new Mage_Backend_Model_Config_Structure_Element_FlyweightFactory($this->_objectManagerMock); } @@ -52,9 +52,9 @@ protected function tearDown() public function testCreate() { $this->_objectManagerMock->expects($this->any())->method('create')->will($this->returnValueMap(array( - array('Mage_Backend_Model_Config_Structure_Element_Section', array(), true, 'sectionObject'), - array('Mage_Backend_Model_Config_Structure_Element_Group', array(), true, 'groupObject'), - array('Mage_Backend_Model_Config_Structure_Element_Field', array(), true, 'fieldObject'), + array('Mage_Backend_Model_Config_Structure_Element_Section', array(), 'sectionObject'), + array('Mage_Backend_Model_Config_Structure_Element_Group', array(), 'groupObject'), + array('Mage_Backend_Model_Config_Structure_Element_Field', array(), 'fieldObject'), ))); $this->assertEquals('sectionObject', $this->_model->create('section')); $this->assertEquals('groupObject', $this->_model->create('group')); diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/Config/Structure/Element/Group/ProxyTest.php b/dev/tests/unit/testsuite/Mage/Backend/Model/Config/Structure/Element/Group/ProxyTest.php index c315186627c72..a542da0577964 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Model/Config/Structure/Element/Group/ProxyTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/Config/Structure/Element/Group/ProxyTest.php @@ -39,7 +39,7 @@ class Mage_Backend_Model_Config_Structure_Element_Group_ProxyTest extends PHPUni protected function setUp() { - $this->_objectManagerMock = $this->getMock('Magento_ObjectManager_Zend', array(), array(), '', false); + $this->_objectManagerMock = $this->getMock('Magento_ObjectManager'); $this->_model = new Mage_Backend_Model_Config_Structure_Element_Group_Proxy($this->_objectManagerMock); } diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/Config/Structure/ReaderTest.php b/dev/tests/unit/testsuite/Mage/Backend/Model/Config/Structure/ReaderTest.php index b556a0e8b72a0..fe506b3cf6fcc 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Model/Config/Structure/ReaderTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/Config/Structure/ReaderTest.php @@ -50,8 +50,7 @@ class Mage_Backend_Model_Config_Structure_ReaderTest extends PHPUnit_Framework_T public function setUp() { $this->_configMock = $this->getMock('Mage_Core_Model_Config_Modules_Reader', array(), array(), '', false); - $this->_cacheMock = $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false); - $this->_cacheMock->expects($this->any())->method('canUse')->will($this->returnValue(true)); + $this->_cacheMock = $this->getMock('Mage_Core_Model_Cache_Type_Config', array(), array(), '', false); $this->_converterMock = $this->getMock( 'Mage_Backend_Model_Config_Structure_Converter', array(), array(), '', false ); diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/BuilderTest.php b/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/BuilderTest.php index 94b3e1362d121..b4187163195c3 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/BuilderTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/BuilderTest.php @@ -74,10 +74,10 @@ public function testGetResultBuildsTreeStructure() { $item1 = $this->getMock("Mage_Backend_Model_Menu_Item", array(), array(), '', false); $item1->expects($this->once())->method('getChildren')->will($this->returnValue($this->_menuMock)); - $this->_factoryMock->expects($this->any())->method('createFromArray')->will($this->returnValue($item1)); + $this->_factoryMock->expects($this->any())->method('create')->will($this->returnValue($item1)); $item2 = $this->getMock("Mage_Backend_Model_Menu_Item", array(), array(), '', false); - $this->_factoryMock->expects($this->at(1))->method('createFromArray')->will($this->returnValue($item2)); + $this->_factoryMock->expects($this->at(1))->method('create')->will($this->returnValue($item2)); $this->_menuMock->expects($this->at(0)) ->method('add') @@ -148,7 +148,7 @@ public function testGetResultSkipsRemovedItems() public function testGetResultSkipItemsWithInvalidParent() { $item1 = $this->getMock("Mage_Backend_Model_Menu_Item", array(), array(), '', false); - $this->_factoryMock->expects($this->any())->method('createFromArray') + $this->_factoryMock->expects($this->any())->method('create') ->will($this->returnValue($item1)); $this->_model->processCommand(new Mage_Backend_Model_Menu_Builder_Command_Add(array( diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Config/MenuTest.php b/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Config/MenuTest.php index 3ee6c1b6f8186..84178a1c73d89 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Config/MenuTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Config/MenuTest.php @@ -43,7 +43,7 @@ protected function setUp() ->with('etc', 'Mage_Backend') ->will( $this->returnValue( - realpath(__DIR__ . '/../../../../../../../../../app/code/core/Mage/Backend/etc') + realpath(__DIR__ . '/../../../../../../../../../app/code/Mage/Backend/etc') ) ); } diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/ConfigTest.php b/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/ConfigTest.php index bd86e1b0fa819..e13e756a0d8d7 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/ConfigTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/ConfigTest.php @@ -34,7 +34,7 @@ class Mage_Backend_Model_Menu_ConfigTest extends PHPUnit_Framework_TestCase protected $_configMock; /** - * @var Mage_Core_Model_Cache + * @var Mage_Core_Model_CacheInterface */ protected $_cacheInstanceMock; @@ -99,17 +99,15 @@ public function setUp() array(), array(), '', false, false ); - $this->_objectManagerMock = $this->getMock( - 'Magento_ObjectManager_Zend', array('create', 'get'), array(), '', false - ); + $this->_objectManagerMock = $this->getMock('Magento_ObjectManager'); $this->_objectManagerMock->expects($this->any()) ->method('create') ->will($this->returnCallback(array($this, 'getModelInstance'))); $this->_objectManagerMock->expects($this->any()) ->method('get') - ->will($this->returnCallback(array($this, 'getModelInstance'))); + ->will($this->returnCallback(array($this, 'get'))); - $this->_cacheInstanceMock = $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false); + $this->_cacheInstanceMock = $this->getMock('Mage_Core_Model_Cache_Type_Config', array(), array(), '', false); $this->_directorDomMock = $this->getMock('Mage_Backend_Model_Menu_Director_Dom', array(), array(), '', false); @@ -157,11 +155,6 @@ public function testGetMenuConfigurationFiles() public function testGetMenuWithCachedObjectReturnsUnserializedObject() { - $this->_cacheInstanceMock->expects($this->once()) - ->method('canUse') - ->with($this->equalTo('config')) - ->will($this->returnValue(true)); - $this->_cacheInstanceMock->expects($this->once()) ->method('load') ->with($this->equalTo(Mage_Backend_Model_Menu_Config::CACHE_MENU_OBJECT)) @@ -176,12 +169,7 @@ public function testGetMenuWithCachedObjectReturnsUnserializedObject() public function testGetMenuWithNotCachedObjectBuidlsObject() { - $this->_cacheInstanceMock->expects($this->any()) - ->method('canUse') - ->with($this->equalTo('config')) - ->will($this->returnValue(true)); - - $this->_cacheInstanceMock->expects($this->at(1)) + $this->_cacheInstanceMock->expects($this->at(0)) ->method('load') ->with($this->equalTo(Mage_Backend_Model_Menu_Config::CACHE_MENU_OBJECT)) ->will($this->returnValue(false)); @@ -240,30 +228,6 @@ public function testGetMenuWhenEnabledCache() $this->_model->getMenu(); } - /** - * @covers Mage_Backend_Model_Menu_Config::getMenu - */ - public function testGetMenuWhenDisabledCache() - { - $this->_cacheInstanceMock->expects($this->any()) - ->method('canUse') - ->will($this->returnValue(false)); - - $this->_configMenuMock->expects($this->exactly(1)) - ->method('getMergedConfig') - ->will($this->returnValue($this->_domDocumentMock)); - - $this->_domDocumentMock->expects($this->exactly(1)) - ->method('saveXML') - ->will($this->returnValue('')); - - $this->_menuBuilderMock->expects($this->exactly(1)) - ->method('getResult') - ->will($this->returnValue($this->_menuMock)); - - $this->_model->getMenu(); - } - /** * @covers Mage_Backend_Model_Menu_Config::getMenu */ @@ -275,10 +239,6 @@ public function testGetMenuWhenCacheEnabledAndCleaned() ->method('getModelInstance') ->will($this->returnCallback(array($this, 'getModelInstance'))); - $this->_cacheInstanceMock->expects($this->any()) - ->method('canUse') - ->will($this->returnValue(true)); - $this->_cacheInstanceMock->expects($this->any()) ->method('load') ->will($this->returnValue(null)); @@ -291,11 +251,11 @@ public function testGetMenuWhenCacheEnabledAndCleaned() ->method('getMergedConfig') ->will($this->returnValue($this->_domDocumentMock)); - $this->_cacheInstanceMock->expects($this->at(5)) + $this->_cacheInstanceMock->expects($this->at(2)) ->method('save') ->with($this->equalTo($xmlString)); - $this->_cacheInstanceMock->expects($this->at(7)) + $this->_cacheInstanceMock->expects($this->at(3)) ->method('save') ->with($this->equalTo($this->_menuMock->serialize())); @@ -387,4 +347,15 @@ public function getModelInstance($model, $arguments) return $this->getMock($model, array(), $arguments, '', false); } } + + /** + * Callback method for mock object Mage_Core_Model_Config object + * + * @param mixed $model + * @return PHPUnit_Framework_MockObject_MockObject + */ + public function get($model) + { + return $this->getModelInstance($model, array()); + } } diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Director/DomTest.php b/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Director/DomTest.php index bdfe6a2393cb0..eb63e5c77df0a 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Director/DomTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Director/DomTest.php @@ -58,7 +58,7 @@ public function setUp() array('getId') ); - $factory = $this->getMock('Magento_ObjectManager_Zend', array(), array(), '', false); + $factory = $this->getMock('Magento_ObjectManager'); $factory->expects($this->any())->method('create')->will($this->returnValue($mockCommand)); $this->_loggerMock = $this->getMock('Mage_Core_Model_Logger', array('log'), array(), '', false); diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Item/FactoryTest.php b/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Item/FactoryTest.php index 968fa189dc5ac..956f8d243e955 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Item/FactoryTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Item/FactoryTest.php @@ -101,7 +101,7 @@ public function setUp() } - public function testCreateFromArray() + public function testCreate() { $this->_objectFactoryMock->expects($this->once()) ->method('create') @@ -121,14 +121,14 @@ public function testCreateFromArray() ) )) ); - $this->_model->createFromArray(array( + $this->_model->create(array( 'module' => 'Mage_User_Helper_Data', 'title' => 'item1', 'dependsOnModule' => 'Mage_User_Helper_Data' )); } - public function testCreateFromArrayProvidesDefaultHelper() + public function testCreateProvidesDefaultHelper() { $this->_objectFactoryMock->expects($this->once()) ->method('create') @@ -147,6 +147,6 @@ public function testCreateFromArrayProvidesDefaultHelper() ) )) ); - $this->_model->createFromArray(array()); + $this->_model->create(array()); } } diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/Widget/Grid/SubTotalsTest.php b/dev/tests/unit/testsuite/Mage/Backend/Model/Widget/Grid/SubTotalsTest.php index 6e7caa51ffdf9..1da57313bc3a6 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Model/Widget/Grid/SubTotalsTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/Widget/Grid/SubTotalsTest.php @@ -66,7 +66,7 @@ protected function setUp() ); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); - $this->_model = $objectManagerHelper->getModel('Mage_Backend_Model_Widget_Grid_SubTotals', $arguments); + $this->_model = $objectManagerHelper->getObject('Mage_Backend_Model_Widget_Grid_SubTotals', $arguments); // setup columns $columns = array( diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/Widget/Grid/TotalsTest.php b/dev/tests/unit/testsuite/Mage/Backend/Model/Widget/Grid/TotalsTest.php index 5be6ee8a77580..81ba38c061584 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Model/Widget/Grid/TotalsTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/Widget/Grid/TotalsTest.php @@ -73,7 +73,7 @@ protected function setUp() ); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); - $this->_model = $objectManagerHelper->getModel('Mage_Backend_Model_Widget_Grid_Totals', $arguments); + $this->_model = $objectManagerHelper->getObject('Mage_Backend_Model_Widget_Grid_Totals', $arguments); // setup columns $columns = array( diff --git a/dev/tests/unit/testsuite/Mage/Backend/controllers/Adminhtml/System/Config/SaveControllerTest.php b/dev/tests/unit/testsuite/Mage/Backend/controllers/Adminhtml/System/Config/SaveControllerTest.php index 41357bc575912..d8014456b1c37 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/controllers/Adminhtml/System/Config/SaveControllerTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/controllers/Adminhtml/System/Config/SaveControllerTest.php @@ -26,10 +26,10 @@ */ require_once (realpath(dirname(__FILE__) . '/../../../../../../../../../../') - . '/app/code/core/Mage/Backend/Controller/System/ConfigAbstract.php'); + . '/app/code/Mage/Backend/Controller/System/ConfigAbstract.php'); require_once (realpath(dirname(__FILE__) . '/../../../../../../../../../../') - . '/app/code/core/Mage/Backend/controllers/Adminhtml/System/Config/SaveController.php'); + . '/app/code/Mage/Backend/controllers/Adminhtml/System/Config/SaveController.php'); class Mage_Backend_Adminhtml_System_Config_SaveControllerTest extends PHPUnit_Framework_TestCase { @@ -87,7 +87,7 @@ public function setUp() { $this->_requestMock = $this->getMock('Mage_Core_Controller_Request_Http', array(), array(), '', false, false); $responseMock = $this->getMock('Mage_Core_Controller_Response_Http', array(), array(), '', false, false); - $objectManagerMock = $this->getMock('Magento_ObjectManager_Zend', array(), array(), '', false, false); + $objectManagerMock = $this->getMock('Magento_ObjectManager'); $frontControllerMock = $this->getMock('Mage_Core_Controller_Varien_Front', array(), array(), '', false, false); $authorizationMock = $this->getMock('Mage_Core_Model_Authorization', array(), array(), '', false, false); $this->_configMock = $this->getMock('Mage_Core_Model_Config', array(), array(), '', false, false); diff --git a/dev/tests/unit/testsuite/Mage/Captcha/Helper/DataTest.php b/dev/tests/unit/testsuite/Mage/Captcha/Helper/DataTest.php index 4d8583282d0ea..370dca8df5bf1 100644 --- a/dev/tests/unit/testsuite/Mage/Captcha/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Mage/Captcha/Helper/DataTest.php @@ -69,9 +69,9 @@ protected function _getHelper($store, $config) $filesystem = $this->getMock('Magento_Filesystem', array(), array(), '', false); - $translator = $this->getMock('Mage_Core_Model_Translate', array(), array(), '', false); + $context = $this->getMock('Mage_Core_Helper_Context', array(), array(), '', false); - return new Mage_Captcha_Helper_Data($this->_dirMock, $app, $config, $filesystem, $translator); + return new Mage_Captcha_Helper_Data($context, $this->_dirMock, $app, $config, $filesystem); } /** @@ -89,7 +89,7 @@ public function testGetCaptcha() ->with('customer/captcha/type') ->will($this->returnValue('zend')); - $objectManager = $this->getMock('Magento_ObjectManager_Zend', array(), array(), '', false); + $objectManager = $this->getMock('Magento_ObjectManager'); $config = $this->_getConfigStub(); $config->expects($this->once()) ->method('getModelInstance') diff --git a/dev/tests/unit/testsuite/Mage/Captcha/Model/DefaultTest.php b/dev/tests/unit/testsuite/Mage/Captcha/Model/DefaultTest.php index f390c8e44731b..3a08dd8edb081 100644 --- a/dev/tests/unit/testsuite/Mage/Captcha/Model/DefaultTest.php +++ b/dev/tests/unit/testsuite/Mage/Captcha/Model/DefaultTest.php @@ -73,7 +73,7 @@ class Mage_Captcha_Model_DefaultTest extends PHPUnit_Framework_TestCase protected $_object; /** - * @var Magento_ObjectManager_Zend + * @var Magento_ObjectManager|PHPUnit_Framework_MockObject_MockObject */ protected $_objectManager; @@ -83,7 +83,7 @@ class Mage_Captcha_Model_DefaultTest extends PHPUnit_Framework_TestCase */ protected function setUp() { - $this->_objectManager = $this->getMock('Magento_ObjectManager_Zend', array('get'), array(), '', false); + $this->_objectManager = $this->getMock('Magento_ObjectManager'); $this->_objectManager->expects($this->any()) ->method('get') ->with('Mage_Captcha_Helper_Data') diff --git a/dev/tests/unit/testsuite/Mage/Catalog/Model/ObserverTest.php b/dev/tests/unit/testsuite/Mage/Catalog/Model/ObserverTest.php index eee78a006faa9..0ed187cda9c4b 100644 --- a/dev/tests/unit/testsuite/Mage/Catalog/Model/ObserverTest.php +++ b/dev/tests/unit/testsuite/Mage/Catalog/Model/ObserverTest.php @@ -37,43 +37,45 @@ class Mage_Catalog_Model_ObserverTest extends PHPUnit_Framework_TestCase */ protected $_model; + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_requestMock; + protected function setUp() { $this->_model = new Mage_Catalog_Model_Observer(); + $this->_requestMock = $this->getMock('Mage_Core_Controller_Request_Http', array(), array(), '', false); } public function testTransitionProductTypeSimple() { - $this->markTestIncomplete('MAGETWO-4796'); $product = new Varien_Object(array('type_id' => 'simple')); - $this->_observer = new Varien_Event_Observer(array('product' => $product)); + $this->_observer = new Varien_Event_Observer(array('product' => $product, 'request' => $this->_requestMock)); $this->_model->transitionProductType($this->_observer); $this->assertEquals('simple', $product->getTypeId()); } public function testTransitionProductTypeVirtual() { - $this->markTestIncomplete('MAGETWO-4796'); $product = new Varien_Object(array('type_id' => 'virtual', 'is_virtual' => '')); - $this->_observer = new Varien_Event_Observer(array('product' => $product)); + $this->_observer = new Varien_Event_Observer(array('product' => $product, 'request' => $this->_requestMock)); $this->_model->transitionProductType($this->_observer); $this->assertEquals('virtual', $product->getTypeId()); } public function testTransitionProductTypeSimpleToVirtual() { - $this->markTestIncomplete('MAGETWO-4796'); $product = new Varien_Object(array('type_id' => 'simple', 'is_virtual' => '')); - $this->_observer = new Varien_Event_Observer(array('product' => $product)); + $this->_observer = new Varien_Event_Observer(array('product' => $product, 'request' => $this->_requestMock)); $this->_model->transitionProductType($this->_observer); $this->assertEquals('virtual', $product->getTypeId()); } public function testTransitionProductTypeVirtualToSimple() { - $this->markTestIncomplete('MAGETWO-4796'); $product = new Varien_Object(array('type_id' => 'virtual')); - $this->_observer = new Varien_Event_Observer(array('product' => $product)); + $this->_observer = new Varien_Event_Observer(array('product' => $product, 'request' => $this->_requestMock)); $this->_model->transitionProductType($this->_observer); $this->assertEquals('simple', $product->getTypeId()); } diff --git a/dev/tests/unit/testsuite/Mage/Catalog/Model/Product/Indexer/FlatTest.php b/dev/tests/unit/testsuite/Mage/Catalog/Model/Product/Indexer/FlatTest.php index e32c072004380..8ef2b63a38493 100644 --- a/dev/tests/unit/testsuite/Mage/Catalog/Model/Product/Indexer/FlatTest.php +++ b/dev/tests/unit/testsuite/Mage/Catalog/Model/Product/Indexer/FlatTest.php @@ -43,7 +43,7 @@ class Mage_Catalog_Model_Product_Indexer_FlatTest extends PHPUnit_Framework_Test public function setUp() { $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); - $this->_model = $objectManagerHelper->getModel('Mage_Catalog_Model_Product_Indexer_Flat'); + $this->_model = $objectManagerHelper->getObject('Mage_Catalog_Model_Product_Indexer_Flat'); $this->_event = $this->getMock('Mage_Index_Model_Event', array('getFlatHelper', 'getEntity', 'getType', 'getDataObject'), array(), '', false ); diff --git a/dev/tests/unit/testsuite/Mage/Catalog/Model/Resource/Product/Option/ValueTest.php b/dev/tests/unit/testsuite/Mage/Catalog/Model/Resource/Product/Option/ValueTest.php index ed419c08d1a02..22d915bc3e30c 100644 --- a/dev/tests/unit/testsuite/Mage/Catalog/Model/Resource/Product/Option/ValueTest.php +++ b/dev/tests/unit/testsuite/Mage/Catalog/Model/Resource/Product/Option/ValueTest.php @@ -19,7 +19,7 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Mage_ImportExport + * @package Mage_Catalog * @subpackage unit_tests * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) @@ -32,27 +32,6 @@ class Mage_Catalog_Model_Resource_Product_Option_ValueTest extends PHPUnit_Frame */ protected $_object; - /** - * Store old display_errors ini option value here - * - * @var int - */ - protected $_oldDisplayErrors; - - /** - * Store old error_reporting ini option value here - * - * @var int - */ - protected $_oldErrorLevel; - - /** - * Store old isDeveloperMode value here - * - * @var boolean - */ - protected $_oldIsDeveloperMode; - /** * Option value title data * @@ -66,24 +45,12 @@ class Mage_Catalog_Model_Resource_Product_Option_ValueTest extends PHPUnit_Frame protected function setUp() { - parent::setUp(); - $this->_object = new Stub_UnitTest_Mage_Catalog_Model_Resource_Product_Option_Value(); - - $this->_oldDisplayErrors = ini_get('display_errors'); - $this->_oldErrorLevel = error_reporting(); - $this->_oldIsDeveloperMode = Mage::getIsDeveloperMode(); } protected function tearDown() { - ini_set('display_errors', $this->_oldDisplayErrors); - error_reporting($this->_oldErrorLevel); - Mage::setIsDeveloperMode($this->_oldIsDeveloperMode); - unset($this->_object); - - parent::tearDown(); } /** @@ -94,18 +61,12 @@ protected function tearDown() public function testSaveValueTitles() { $object = new Stub_UnitTest_Mage_Catalog_Model_Resource_Product_Option_Value_Mage_Core_Model_Stub( - $this->getMock('Mage_Core_Model_Event_Manager', array(), array(), '', false), - $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false), + $this->getMock('Mage_Core_Model_Context', array(), array(), '', false), null, null, self::$valueTitleData ); - // we have to set strict error reporting mode and enable mage developer mode to convert notice to exception - error_reporting(E_ALL | E_STRICT); - ini_set('display_errors', 1); - Mage::setIsDeveloperMode(true); - $this->_object->saveValueTitles($object); } } diff --git a/dev/tests/unit/testsuite/Mage/Checkout/Block/Cart/Item/RendererTest.php b/dev/tests/unit/testsuite/Mage/Checkout/Block/Cart/Item/RendererTest.php index 17e1c9d678368..16444470bcf66 100644 --- a/dev/tests/unit/testsuite/Mage/Checkout/Block/Cart/Item/RendererTest.php +++ b/dev/tests/unit/testsuite/Mage/Checkout/Block/Cart/Item/RendererTest.php @@ -34,13 +34,12 @@ public function testGetProductThumbnailUrlForConfigurable() $configView = $this->getMock('Magento_Config_View', array('getVarValue'), array(), '', false); $configView->expects($this->any())->method('getVarValue')->will($this->returnValue(75)); - $filesystem = $this->getMockBuilder('Magento_Filesystem')->disableOriginalConstructor()->getMock(); $designPackage = $this->getMock( - 'Mage_Core_Model_Design_Package', array('getViewConfig'), array($filesystem), '', false + 'Mage_Core_Model_Design_Package', array('getViewConfig'), array(), '', false ); $designPackage->expects($this->any())->method('getViewConfig')->will($this->returnValue($configView)); - $configurable = $objectManagerHelper->getBlock('Mage_Checkout_Block_Cart_Item_Renderer_Configurable', + $configurable = $objectManagerHelper->getObject('Mage_Checkout_Block_Cart_Item_Renderer_Configurable', array('designPackage' => $designPackage)); $product = $this->getMock('Mage_Catalog_Model_Product', array('isConfigurable'), array(), '', false); @@ -53,10 +52,10 @@ public function testGetProductThumbnailUrlForConfigurable() $arguments = array( 'statusListFactory' => $this->getMock('Mage_Sales_Model_Status_ListFactory', array(), array(), '', false), ); - $childItem = $objectManagerHelper->getModel('Mage_Sales_Model_Quote_Item', $arguments); + $childItem = $objectManagerHelper->getObject('Mage_Sales_Model_Quote_Item', $arguments); $childItem->setData('product', $childProduct); - $item = $objectManagerHelper->getModel('Mage_Sales_Model_Quote_Item', $arguments); + $item = $objectManagerHelper->getObject('Mage_Sales_Model_Quote_Item', $arguments); $item->setData('product', $product); $item->addChild($childItem); diff --git a/dev/tests/unit/testsuite/Mage/Core/Block/AbstractTest.php b/dev/tests/unit/testsuite/Mage/Core/Block/AbstractTest.php index 21139a1daa479..8e45f1c827b75 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Block/AbstractTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Block/AbstractTest.php @@ -76,19 +76,15 @@ public function testGetVar() array(), '', false, false ); /** @var $block Mage_Core_Block_Abstract|PHPUnit_Framework_MockObject_MockObject */ - $block = $this->getMockForAbstractClass('Mage_Core_Block_Abstract', array( - $this->getMock('Mage_Core_Controller_Request_Http'), - $this->getMock('Mage_Core_Model_Layout', array(), array(), '', false, false), - $this->getMock('Mage_Core_Model_Event_Manager', array(), array(), '', false, false), - $this->getMock('Mage_Core_Model_Url', array(), array(), '', false, false), - $this->getMock('Mage_Core_Model_Translate', array(), array($design), '', false, false), - $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false), - $design, - $this->getMock('Mage_Core_Model_Session', array(), array(), '', false, false), - $this->getMock('Mage_Core_Model_Store_Config', array(), array(), '', false, false), - $this->getMock('Mage_Core_Controller_Varien_Front', array(), array(), '', false, false), - $this->getMock('Mage_Core_Model_Factory_Helper', array(), array(), '', false, false), - ), uniqid('Mage_Core_Block_Abstract_')); + $params = array( + 'designPackage' => $design, + ); + $helper = new Magento_Test_Helper_ObjectManager($this); + $block = $this->getMockForAbstractClass('Mage_Core_Block_Abstract', + $helper->getConstructArguments('Mage_Core_Block_Abstract', $params), + uniqid('Mage_Core_Block_Abstract_') + ); + $config = $this->getMock('Magento_Config_View', array('getVarValue'), array(), '', false); $design->expects($this->exactly(2))->method('getViewConfig')->will($this->returnValue($config)); $module = uniqid(); diff --git a/dev/tests/unit/testsuite/Mage/Core/Block/TemplateTest.php b/dev/tests/unit/testsuite/Mage/Core/Block/TemplateTest.php index 832854d0d04ef..452be0206d256 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Block/TemplateTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Block/TemplateTest.php @@ -32,23 +32,13 @@ public function testGetTemplateFile() $design = $this->getMock('Mage_Core_Model_Design_Package', array('getFilename'), array(), '', false); $template = 'fixture'; $area = 'areaFixture'; - $block = new Mage_Core_Block_Template( - $this->getMock('Mage_Core_Controller_Request_Http', array(), array(), '', false, false), - $this->getMock('Mage_Core_Model_Layout', array(), array(), '', false), - $this->getMock('Mage_Core_Model_Event_Manager', array(), array(), '', false, false), - $this->getMock('Mage_Core_Model_Url', array(), array(), '', false, false), - $this->getMock('Mage_Core_Model_Translate', array(), array($design), '', false, false), - $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false), - $design, - $this->getMock('Mage_Core_Model_Session', array(), array(), '', false, false), - $this->getMock('Mage_Core_Model_Store_Config', array(), array(), '', false, false), - $this->getMock('Mage_Core_Controller_Varien_Front', array(), array(), '', false, false), - $this->getMock('Mage_Core_Model_Factory_Helper', array(), array(), '', false, false), - $this->getMock('Mage_Core_Model_Dir', array(), array(), '', false), - $this->getMock('Mage_Core_Model_Logger', array(), array(), '', false), - $this->getMock('Magento_Filesystem', array(), array(), '', false), - array('template' => $template, 'area' => $area) + $arguments = array( + 'designPackage' => $design, + 'data' => array('template' => $template, 'area' => $area), ); + $helper = new Magento_Test_Helper_ObjectManager($this); + + $block = $helper->getObject('Mage_Core_Block_Template', $arguments); $params = array('module' => 'Mage_Core', 'area' => $area); $design->expects($this->once())->method('getFilename')->with($template, $params); @@ -71,27 +61,36 @@ public function testFetchView($filename, $expectedOutput) $layout = $this->getMock('Mage_Core_Model_Layout', array('isDirectOutput'), array(), '', false); $filesystem = new Magento_Filesystem(new Magento_Filesystem_Adapter_Local); $design = $this->getMock('Mage_Core_Model_Design_Package', array(), array(), '', false); - $block = $this->getMock('Mage_Core_Block_Template', array('getShowTemplateHints'), array( - $this->getMock('Mage_Core_Controller_Request_Http'), - $layout, - $this->getMock('Mage_Core_Model_Event_Manager', array(), array(), '', false, false), - $this->getMock('Mage_Core_Model_Url', array(), array(), '', false, false), - $this->getMock('Mage_Core_Model_Translate', array(), - array( - $design, - $this->getMock('Mage_Core_Model_Locale_Hierarchy_Loader', array(), array(), '', false, false) - ) - ), - $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false), - $this->getMock('Mage_Core_Model_Design_Package', array(), array(), '', false), - $this->getMock('Mage_Core_Model_Session', array(), array(), '', false, false), - $this->getMock('Mage_Core_Model_Store_Config', array(), array(), '', false, false), - $this->getMock('Mage_Core_Controller_Varien_Front', array(), array(), '', false, false), - $this->getMock('Mage_Core_Model_Factory_Helper', array(), array(), '', false, false), - $dirMock, - $this->getMock('Mage_Core_Model_Logger', array('log'), array(), '', false), - $filesystem - )); + $translator = $this->getMock('Mage_Core_Model_Translate', array(), + array( + $design, + $this->getMock('Mage_Core_Model_Locale_Hierarchy_Loader', array(), array(), '', false, false) + ) + ); + $helper = new Magento_Test_Helper_ObjectManager($this); + + $objectManagerMock = $this->getMock('Magento_ObjectManager', array('get', 'create', 'configure')); + $objectManagerMock->expects($this->any()) + ->method('get') + ->with('Mage_Core_Block_Template_Engine_Php') + ->will($this->returnValue(new Mage_Core_Block_Template_Engine_Php())); + $engineFactory = new Mage_Core_Block_Template_Engine_Factory($objectManagerMock); + + $arguments = array( + 'designPackage' => $design, + 'layout' => $layout, + 'dirs' => $dirMock, + 'filesystem' => $filesystem, + 'translator' => $translator, + 'engineFactory' => $engineFactory, + ); + + + $block = $this->getMock( + 'Mage_Core_Block_Template', + array('getShowTemplateHints'), + $helper->getConstructArguments('Mage_Core_Block_Template', $arguments) + ); $layout->expects($this->once())->method('isDirectOutput')->will($this->returnValue(false)); $this->assertSame($block, $block->assign(array('varOne' => 'value1', 'varTwo' => 'value2'))); diff --git a/dev/tests/unit/testsuite/Mage/Core/Controller/Varien/Action/FactoryTest.php b/dev/tests/unit/testsuite/Mage/Core/Controller/Varien/Action/FactoryTest.php index b211e58345182..0a607730b5191 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Controller/Varien/Action/FactoryTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Controller/Varien/Action/FactoryTest.php @@ -38,7 +38,7 @@ class Mage_Core_Controller_Varien_Action_FactoryTest extends PHPUnit_Framework_T /** * ObjectManager mock for tests * - * @var Magento_ObjectManager_Zend + * @var Magento_ObjectManager */ protected $_objectManager; @@ -51,7 +51,7 @@ class Mage_Core_Controller_Varien_Action_FactoryTest extends PHPUnit_Framework_T protected function setUp() { - $this->_objectManager = $this->getMock('Magento_ObjectManager_Zend', array('create'), array(), '', false); + $this->_objectManager = $this->getMock('Magento_ObjectManager'); } public function testConstruct() diff --git a/dev/tests/unit/testsuite/Mage/Core/Controller/Varien/Router/FactoryTest.php b/dev/tests/unit/testsuite/Mage/Core/Controller/Varien/Router/FactoryTest.php index de156222802aa..50425ed094ebb 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Controller/Varien/Router/FactoryTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Controller/Varien/Router/FactoryTest.php @@ -41,7 +41,7 @@ class Mage_Core_Controller_Varien_Router_FactoryTest extends PHPUnit_Framework_T /** * ObjectManager mock for tests * - * @var Magento_ObjectManager_Zend + * @var Magento_ObjectManager|PHPUnit_Framework_MockObject_MockObject */ protected $_objectManager; @@ -54,7 +54,7 @@ class Mage_Core_Controller_Varien_Router_FactoryTest extends PHPUnit_Framework_T protected function setUp() { - $this->_objectManager = $this->getMock('Magento_ObjectManager_Zend', array('get'), array(), '', false); + $this->_objectManager = $this->getMock('Magento_ObjectManager'); $this->_controller = new Mage_Core_Controller_Varien_Router_Factory($this->_objectManager); } @@ -66,7 +66,7 @@ public function testConstruct() public function testCreateRouterNoArguments() { $this->_objectManager->expects($this->once()) - ->method('get') + ->method('create') ->with(self::CLASS_NAME) ->will($this->returnValue('TestRouterInstance')); @@ -86,7 +86,7 @@ public function testCreateRouterWithArguments() ); $this->_objectManager->expects($this->once()) - ->method('get') + ->method('create') ->with(self::CLASS_NAME, $arguments) ->will($this->returnValue('TestRouterInstance')); diff --git a/dev/tests/unit/testsuite/Mage/Core/Helper/CookieTest.php b/dev/tests/unit/testsuite/Mage/Core/Helper/CookieTest.php index 1b5d4b8ee9856..1aac96b21dfab 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Helper/CookieTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Helper/CookieTest.php @@ -35,7 +35,7 @@ class Mage_Core_Helper_CookieTest extends PHPUnit_Framework_TestCase protected function setUp() { $this->_object = new Mage_Core_Helper_Cookie( - $this->getMock('Mage_Core_Model_Translate', array(), array(), '', false, false), + $this->getMock('Mage_Core_Helper_Context', array(), array(), '', false, false), array( 'current_store' => $this->_getStoreStub(), 'cookie_model' => $this->_getCookieStub(array(1 => 1)), @@ -48,7 +48,7 @@ public function testIsUserNotAllowSaveCookie() { $this->assertFalse($this->_object->isUserNotAllowSaveCookie()); $this->_object = new Mage_Core_Helper_Cookie( - $this->getMock('Mage_Core_Model_Translate', array(), array(), '', false, false), + $this->getMock('Mage_Core_Helper_Context', array(), array(), '', false, false), array( 'current_store' => $this->_getStoreStub(), 'cookie_model' => $this->_getCookieStub(array()), @@ -74,7 +74,7 @@ public function testGetCookieRestrictionLifetime() ->will($this->returnCallback('Mage_Core_Helper_CookieTest::getConfigMethodStub')) ->with($this->equalTo('web/cookie/cookie_restriction_lifetime')); $this->_object = new Mage_Core_Helper_Cookie( - $this->getMock('Mage_Core_Model_Translate', array(), array(), '', false, false), + $this->getMock('Mage_Core_Helper_Context', array(), array(), '', false, false), array( 'current_store' => $storeStub, 'cookie_model' => $this->_getCookieStub(array(1 => 1)), diff --git a/dev/tests/unit/testsuite/Mage/Core/Helper/HttpTest.php b/dev/tests/unit/testsuite/Mage/Core/Helper/HttpTest.php index a2ef727628347..ab00e00637a58 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Helper/HttpTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Helper/HttpTest.php @@ -35,7 +35,7 @@ class Mage_Core_Helper_HttpTest extends PHPUnit_Framework_TestCase protected function setUp() { $this->_object = new Mage_Core_Helper_Http( - $this->getMock('Mage_Core_Model_Translate', array(), array(), '', false, false) + $this->getMock('Mage_Core_Helper_Context', array(), array(), '', false, false) ); } diff --git a/dev/tests/unit/testsuite/Mage/Core/Helper/ThemeTest.php b/dev/tests/unit/testsuite/Mage/Core/Helper/ThemeTest.php index aa0f4227fd38a..72c65263c0b58 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Helper/ThemeTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Helper/ThemeTest.php @@ -53,16 +53,28 @@ public function testGetSafePath($filePath, $basePath, $expectedResult) /** @var $themeCollection Mage_Core_Model_Resource_Theme_Collection */ $themeCollection = $this->getMock('Mage_Core_Model_Resource_Theme_Collection', null, array(), '', false); - /** @var $translator Mage_Core_Model_Translate */ - $translator = $this->getMock('Mage_Core_Model_Translate', null, array(), '', false); - - $helper = new Mage_Core_Helper_Theme($design, $dirs, $layoutMergeFactory, $themeCollection, $translator); + /** @var $context Mage_Core_Helper_Context */ + $context = $this->getMock('Mage_Core_Helper_Context', null, array(), '', false); + + $themeFactory = $this->getMockBuilder('Mage_Core_Model_Theme_Factory')->disableOriginalConstructor()->getMock(); + + $helper = new Mage_Core_Helper_Theme( + $context, + $design, + $dirs, + $layoutMergeFactory, + $themeCollection, + $themeFactory + ); $result = $helper->getSafePath($filePath, $basePath); $this->assertEquals($expectedResult, $result); } + /** + * @return array + */ public function getSafePathDataProvider() { return array( @@ -112,11 +124,20 @@ public function testGetCssFiles($layoutStr, $expectedResult) /** @var $themeCollection Mage_Core_Model_Resource_Theme_Collection */ $themeCollection = $this->getMock('Mage_Core_Model_Resource_Theme_Collection', null, array(), '', false); - /** @var $translator Mage_Core_Model_Translate */ - $translator = $this->getMock('Mage_Core_Model_Translate', null, array(), '', false); + /** @var $context Mage_Core_Helper_Context */ + $context = $this->getMock('Mage_Core_Helper_Context', null, array(), '', false); + + $themeFactory = $this->getMockBuilder('Mage_Core_Model_Theme_Factory')->disableOriginalConstructor()->getMock(); // 6. Run tested method - $helper = new Mage_Core_Helper_Theme($design, $dirs, $layoutMergeFactory, $themeCollection, $translator); + $helper = new Mage_Core_Helper_Theme( + $context, + $design, + $dirs, + $layoutMergeFactory, + $themeCollection, + $themeFactory + ); $result = $helper->getCssFiles($theme); $this->assertEquals($expectedResult, $result); @@ -349,6 +370,9 @@ public function testGetGroupedCssFiles($files, $expectedResult) $this->assertEquals($expectedResult, $result); } + /** + * @return array + */ public function getGroupedCssFilesDataProvider() { $item11 = array( @@ -448,7 +472,7 @@ public function getGroupedCssFilesDataProvider() /** * depends testGetCssFiles - * @expectedException Mage_Core_Exception + * @expectedException LogicException * @expectedExceptionMessage Invalid view file directory "some_path/test.test" */ public function testGetGroupedCssFilesException() @@ -594,12 +618,14 @@ protected function _getHelper($files) /** @var $layoutMergeFactory Mage_Core_Model_Layout_Merge_Factory|PHPUnit_Framework_MockObject_MockObject */ $layoutMergeFactory = $this->getMock('Mage_Core_Model_Layout_Merge_Factory', null, array(), '', false); - /** @var $translator Mage_Core_Model_Translate */ - $translator = $this->getMock('Mage_Core_Model_Translate', null, array(), '', false); + /** @var $context Mage_Core_Helper_Context */ + $context = $this->getMock('Mage_Core_Helper_Context', null, array(), '', false); + + $themeFactory = $this->getMockBuilder('Mage_Core_Model_Theme_Factory')->disableOriginalConstructor()->getMock(); /** @var $helper Mage_Core_Helper_Theme */ $helper = $this->getMock('Mage_Core_Helper_Theme', array('getCssFiles', '__'), array( - $design, $dirs, $layoutMergeFactory, $themeCollection, $translator + $context, $design, $dirs, $layoutMergeFactory, $themeCollection, $themeFactory )); $helper->expects($this->once()) ->method('getCssFiles') diff --git a/dev/tests/unit/testsuite/Mage/Core/Helper/Url/RewriteTest.php b/dev/tests/unit/testsuite/Mage/Core/Helper/Url/RewriteTest.php index ecfcb35ffd6b9..83599c07a3b83 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Helper/Url/RewriteTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Helper/Url/RewriteTest.php @@ -65,7 +65,7 @@ protected function tearDown() public function testHasRedirectOptions($option, $expected) { $helper = new Mage_Core_Helper_Url_Rewrite( - $this->getMock('Mage_Core_Model_Translate', array(), array(), '', false, false) + $this->getMock('Mage_Core_Helper_Context', array(), array(), '', false, false) ); $mockObject = new Varien_Object(); $mockObject->setOptions($option); diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Acl/BuilderTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Acl/BuilderTest.php index 458a09eb8a9bd..9ccc0e809a5f3 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Acl/BuilderTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Acl/BuilderTest.php @@ -30,7 +30,7 @@ class Mage_Core_Model_Acl_BuilderTest extends PHPUnit_Framework_TestCase /** * @var PHPUnit_Framework_MockObject_MockObject */ - protected $_objectFactoryMock; + protected $_aclFactoryMock; /** * @var PHPUnit_Framework_MockObject_MockObject @@ -38,88 +38,47 @@ class Mage_Core_Model_Acl_BuilderTest extends PHPUnit_Framework_TestCase protected $_aclMock; /** - * @var stdClass + * @var PHPUnit_Framework_MockObject_MockObject */ - protected $_areaConfigMock; + protected $_loaderPoolMock; - public function setUp() - { - $this->_aclMock = $this->getMock('Magento_Acl'); - $this->_objectFactoryMock = $this->getMock('Mage_Core_Model_Config', array(), array(), '', false); - $this->_objectFactoryMock->expects($this->at(0)) - ->method('getModelInstance') - ->with($this->equalTo('Magento_Acl')) - ->will($this->returnValue($this->_aclMock)); - $this->_areaConfigMock = new StdClass(); - } + /** + * @var Mage_Core_Model_Acl_Builder + */ + protected $_model; - protected function _createModel($config) + protected function setUp() { - return new Mage_Core_Model_Acl_Builder(array( - 'objectFactory' => $this->_objectFactoryMock, - 'areaConfig' => $config - )); + $this->_aclMock = new Magento_Acl(); + $this->_aclFactoryMock = $this->getMock('Magento_AclFactory', array(), array(), '', false); + $this->_aclFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->_aclMock)); + $this->_loaderPoolMock = $this->getMock('Mage_Core_Model_Acl_LoaderPool', array(), array(), '', false); + $this->_model = new Mage_Core_Model_Acl_Builder($this->_aclFactoryMock, $this->_loaderPoolMock); } - public function testGetAclUsesDefaultLoadersWhenNothingSetInConfiguration() + protected function tearDown() { - $defaultLoaderMock = $this->getMock('Magento_Acl_Loader_Default'); - $defaultLoaderMock->expects($this->exactly(3)) - ->method('populateAcl') - ->with($this->equalTo($this->_aclMock)); - - $this->_objectFactoryMock->expects($this->at(1)) - ->method('getModelInstance') - ->with($this->equalTo('Magento_Acl_Loader_Default')) - ->will($this->returnValue($defaultLoaderMock)); - $this->_objectFactoryMock->expects($this->at(2)) - ->method('getModelInstance') - ->with($this->equalTo('Magento_Acl_Loader_Default')) - ->will($this->returnValue($defaultLoaderMock)); - $this->_objectFactoryMock->expects($this->at(3)) - ->method('getModelInstance') - ->with($this->equalTo('Magento_Acl_Loader_Default')) - ->will($this->returnValue($defaultLoaderMock)); - $model = $this->_createModel(array( - 'acl' => array( - 'resourceLoader' => null, - 'ruleLoader' => null, - 'roleLoader' => null, - ) - )); - - $this->assertEquals($this->_aclMock, $model->getAcl()); + unset($this->_aclMock); + unset($this->_aclFactoryMock); + unset($this->_loaderPoolMock); + unset($this->_model); } - public function testGetAclUsesLoadersProvidedInconfigurationToPopulateAcl() + public function testGetAclUsesLoadersProvidedInConfigurationToPopulateAcl() { $defaultLoaderMock = $this->getMock('Magento_Acl_Loader_Default'); $defaultLoaderMock->expects($this->exactly(3)) ->method('populateAcl') ->with($this->equalTo($this->_aclMock)); + $this->_loaderPoolMock->expects($this->once())->method('getLoadersByArea') + ->with('someArea') + ->will($this->returnValue( + new ArrayIterator(array( + $defaultLoaderMock, $defaultLoaderMock, $defaultLoaderMock + )) + )); - $this->_objectFactoryMock->expects($this->at(1)) - ->method('getModelInstance') - ->with($this->equalTo('test1')) - ->will($this->returnValue($defaultLoaderMock)); - $this->_objectFactoryMock->expects($this->at(2)) - ->method('getModelInstance') - ->with($this->equalTo('test2')) - ->will($this->returnValue($defaultLoaderMock)); - $this->_objectFactoryMock->expects($this->at(3)) - ->method('getModelInstance') - ->with($this->equalTo('test3')) - ->will($this->returnValue($defaultLoaderMock)); - - $model = $this->_createModel(array( - 'acl' => array( - 'resourceLoader' => 'test1', - 'roleLoader' => 'test2', - 'ruleLoader' => 'test3', - ) - )); - - $this->assertEquals($this->_aclMock, $model->getAcl()); + $this->assertEquals($this->_aclMock, $this->_model->getAcl('someArea')); } /** @@ -127,16 +86,10 @@ public function testGetAclUsesLoadersProvidedInconfigurationToPopulateAcl() */ public function testGetAclRethrowsException() { - $this->_objectFactoryMock->expects($this->once()) - ->method('getModelInstance') + $this->_loaderPoolMock->expects($this->once()) + ->method('getLoadersByArea') + ->with('someArea') ->will($this->throwException(new InvalidArgumentException())); - $model = $this->_createModel(array( - 'acl' => array( - 'resourceLoader' => 'default', - 'roleLoader' => 'default', - 'ruleLoader' => 'default', - ) - )); - $model->getAcl(); + $this->_model->getAcl('someArea'); } } diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/App/StateTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/App/StateTest.php new file mode 100644 index 0000000000000..744d90ec8d4b3 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/App/StateTest.php @@ -0,0 +1,71 @@ +assertEquals($mode, $model->getMode()); + } + + /** + * @return array + */ + public static function constructorDataProvider() + { + return array( + 'default mode' => array( + Mage_Core_Model_App_State::MODE_DEFAULT + ), + 'production mode' => array( + Mage_Core_Model_App_State::MODE_PRODUCTION + ), + 'developer mode' => array( + Mage_Core_Model_App_State::MODE_DEVELOPER + ), + ); + } + + /** + * @expectedException Mage_Core_Exception + * @expectedExceptionMessage Unknown application mode: unknown mode + */ + public function testConstructorException() + { + new Mage_Core_Model_App_State("unknown mode"); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/AppTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/AppTest.php index db3c821f67e11..04a7a014b4df6 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/AppTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/AppTest.php @@ -78,7 +78,7 @@ protected function setUp() $this->_configMock = $this->getMock('Mage_Core_Model_Config', array(), array(), '', false, false); $this->_frontControllerMock = $this->getMock('Mage_Core_Controller_Varien_Front', array(), array(), '', false, false); - $this->_cacheMock = $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false, false); + $this->_cacheMock = $this->getMock('Mage_Core_Model_CacheInterface', array(), array(), '', false, false); $this->_objectManagerMock = $this->getMock('Magento_ObjectManager', array(), array(), '', false, false); $this->_dbUpdaterMock = $this->getMock('Mage_Core_Model_Db_UpdaterInterface', array(), array(), '', false, false); diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Cache/Frontend/FactoryTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Cache/Frontend/FactoryTest.php new file mode 100644 index 0000000000000..910debbf325ed --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Cache/Frontend/FactoryTest.php @@ -0,0 +1,189 @@ +_buildModelForCreate(); + $result = $model->create(array('backend' => 'Zend_Cache_Backend_BlackHole')); + + $this->assertInstanceOf( + 'Magento_Cache_FrontendInterface', + $result, + 'Created object must implement Magento_Cache_FrontendInterface' + ); + $this->assertInstanceOf( + 'Varien_Cache_Core', + $result->getLowLevelFrontend(), + 'Created object must have Varien_Cache_Core frontend by default' + ); + $this->assertInstanceOf( + 'Zend_Cache_Backend_BlackHole', + $result->getBackend(), + 'Created object must have backend as configured in backend options' + ); + } + + public function testCreateOptions() + { + $model = $this->_buildModelForCreate(); + $result = $model->create(array( + 'backend' => 'Zend_Cache_Backend_Static', + 'frontend_options' => array( + 'lifetime' => 2601 + ), + 'backend_options' => array( + 'file_extension' => '.wtf' + ), + )); + + $frontend = $result->getLowLevelFrontend(); + $backend = $result->getBackend(); + + $this->assertEquals(2601, $frontend->getOption('lifetime')); + $this->assertEquals('.wtf', $backend->getOption('file_extension')); + } + + public function testCreateEnforcedOptions() + { + $model = $this->_buildModelForCreate(array('backend' => 'Zend_Cache_Backend_Static')); + $result = $model->create(array('backend' => 'Zend_Cache_Backend_BlackHole')); + + $this->assertInstanceOf('Zend_Cache_Backend_Static', $result->getBackend()); + } + + /** + * @param array $options + * @param string $expectedPrefix + * @dataProvider idPrefixDataProvider + */ + public function testIdPrefix($options, $expectedPrefix) + { + $model = $this->_buildModelForCreate(array('backend' => 'Zend_Cache_Backend_Static')); + $result = $model->create($options); + + $frontend = $result->getLowLevelFrontend(); + $this->assertEquals($expectedPrefix, $frontend->getOption('cache_id_prefix')); + } + + /** + * @return array + */ + public static function idPrefixDataProvider() + { + return array( + 'default id prefix' => array( + array( + 'backend' => 'Zend_Cache_Backend_BlackHole', + ), + 'a3c_', // start of md5('CONFIG_DIR') + ), + 'id prefix in "id_prefix" option' => array( + array( + 'backend' => 'Zend_Cache_Backend_BlackHole', + 'id_prefix' => 'id_prefix_value' + ), + 'id_prefix_value', + ), + 'id prefix in "prefix" option' => array( + array( + 'backend' => 'Zend_Cache_Backend_BlackHole', + 'prefix' => 'prefix_value' + ), + 'prefix_value', + ), + ); + } + + public function testCreateDecorators() + { + $model = $this->_buildModelForCreate( + array(), + array(array('class' => 'CacheDecoratorDummy', 'parameters' => array('param' => 'value'))) + ); + $result = $model->create(array('backend' => 'Zend_Cache_Backend_BlackHole')); + + $this->assertInstanceOf('CacheDecoratorDummy', $result); + + $params = $result->getParams(); + $this->assertArrayHasKey('param', $params); + $this->assertEquals($params['param'], 'value'); + } + + /** + * Create the model to be tested, providing it with all required dependencies + * + * @param array $enforcedOptions + * @param array $decorators + * @return Mage_Core_Model_Cache_Frontend_Factory + */ + protected function _buildModelForCreate($enforcedOptions = array(), $decorators = array()) + { + $processFrontendFunc = function ($class, $params) { + switch ($class) { + case 'Magento_Cache_Frontend_Adapter_Zend': + return new $class($params['frontend']); + case 'CacheDecoratorDummy': + $frontend = $params[0]; + unset($params[0]); + return new $class($frontend, $params); + default: + throw new Exception("Test is not designed to create {$class} objects"); + break; + } + }; + /** @var $objectManager PHPUnit_Framework_MockObject_MockObject */ + $objectManager = $this->getMock('Magento_ObjectManager', array(), array(), '', false); + $objectManager->expects($this->any()) + ->method('create') + ->will($this->returnCallback($processFrontendFunc)); + + $filesystem = $this->getMock('Magento_Filesystem', array(), array(), '', false); + $filesystem->expects($this->any()) + ->method('isDirectory') + ->will($this->returnValue(true)); + $filesystem->expects($this->any()) + ->method('isWritable') + ->will($this->returnValue(true)); + + $map = array( + array(Mage_Core_Model_Dir::CACHE, 'CACHE_DIR'), + array(Mage_Core_Model_Dir::CONFIG, 'CONFIG_DIR'), + ); + $dirs = $this->getMock('Mage_Core_Model_Dir', array('getDir'), array(), '', false); + $dirs->expects($this->any()) + ->method('getDir') + ->will($this->returnValueMap($map)); + + $model = new Mage_Core_Model_Cache_Frontend_Factory($objectManager, $filesystem, $dirs, $enforcedOptions, + $decorators); + + return $model; + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Cache/Frontend/PoolTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Cache/Frontend/PoolTest.php new file mode 100644 index 0000000000000..ddc16f8739108 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Cache/Frontend/PoolTest.php @@ -0,0 +1,171 @@ + array( + Mage_Core_Model_Dir::CONFIG => __DIR__ . '/_files' + ))); + + // Init frontend factory + $frontendFactory = $this->getMock('Mage_Core_Model_Cache_Frontend_Factory', array(), array(), '', false); + + $this->_frontendInstances = array( + Mage_Core_Model_Cache_Frontend_Pool::DEFAULT_FRONTEND_ID + => $this->getMock('Magento_Cache_FrontendInterface'), + 'resource1' => $this->getMock('Magento_Cache_FrontendInterface'), + 'resource2' => $this->getMock('Magento_Cache_FrontendInterface'), + ); + $frontendFactory->expects($this->any()) + ->method('create') + ->will( + $this->returnValueMap(array( + array( + array('data1' => 'value1', 'data2' => 'value2'), + $this->_frontendInstances[Mage_Core_Model_Cache_Frontend_Pool::DEFAULT_FRONTEND_ID] + ), + array(array('r1d1' => 'value1', 'r1d2' => 'value2'), $this->_frontendInstances['resource1']), + array(array('r2d1' => 'value1', 'r2d2' => 'value2'), $this->_frontendInstances['resource2']), + )) + ); + + // Create model + $this->_model = new Mage_Core_Model_Cache_Frontend_Pool($cacheConfig, $frontendFactory); + } + + /** + * Test that constructor delays object initialization (does not perform any initialization of its own) + */ + public function testConstructorNoInitialization() + { + $frontendFactory = $this->getMock('Mage_Core_Model_Cache_Frontend_Factory', array(), array(), '', false); + $frontendFactory + ->expects($this->never()) + ->method('create') + ; + new Mage_Core_Model_Cache_Frontend_Pool( + $this->getMock('Mage_Core_Model_Config_Primary', array(), array(), '', false), + $frontendFactory + ); + } + + public function testCurrent() + { + $this->assertEquals( + $this->_frontendInstances[Mage_Core_Model_Cache_Frontend_Pool::DEFAULT_FRONTEND_ID], + $this->_model->current() + ); + } + + public function testKey() + { + $this->assertEquals( + Mage_Core_Model_Cache_Frontend_Pool::DEFAULT_FRONTEND_ID, + $this->_model->key() + ); + } + + public function testNext() + { + $this->assertEquals( + Mage_Core_Model_Cache_Frontend_Pool::DEFAULT_FRONTEND_ID, + $this->_model->key() + ); + + $this->_model->next(); + $this->assertEquals( + 'resource1', + $this->_model->key() + ); + $this->assertSame( + $this->_frontendInstances['resource1'], + $this->_model->current() + ); + + $this->_model->next(); + $this->assertEquals( + 'resource2', + $this->_model->key() + ); + $this->assertSame( + $this->_frontendInstances['resource2'], + $this->_model->current() + ); + + $this->_model->next(); + $this->assertNull($this->_model->key()); + $this->assertFalse($this->_model->current()); + } + + public function testRewind() + { + $this->_model->next(); + $this->assertNotEquals( + Mage_Core_Model_Cache_Frontend_Pool::DEFAULT_FRONTEND_ID, + $this->_model->key() + ); + + $this->_model->rewind(); + $this->assertEquals( + Mage_Core_Model_Cache_Frontend_Pool::DEFAULT_FRONTEND_ID, + $this->_model->key() + ); + } + + public function testValid() + { + $this->assertTrue($this->_model->valid()); + + $this->_model->next(); + $this->assertTrue($this->_model->valid()); + + $this->_model->next(); + $this->_model->next(); + $this->assertFalse($this->_model->valid()); + + $this->_model->rewind(); + $this->assertTrue($this->_model->valid()); + } + + public function testGet() + { + $this->assertSame($this->_frontendInstances[Mage_Core_Model_Cache_Frontend_Pool::DEFAULT_FRONTEND_ID], + $this->_model->get(Mage_Core_Model_Cache_Frontend_Pool::DEFAULT_FRONTEND_ID)); + $this->assertSame($this->_frontendInstances['resource1'], $this->_model->get('resource1')); + $this->assertSame($this->_frontendInstances['resource2'], $this->_model->get('resource2')); + } + +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Cache/Frontend/_files/CacheDecoratorDummy.php b/dev/tests/unit/testsuite/Mage/Core/Model/Cache/Frontend/_files/CacheDecoratorDummy.php new file mode 100644 index 0000000000000..da70b1e89d2a1 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Cache/Frontend/_files/CacheDecoratorDummy.php @@ -0,0 +1,52 @@ +_params = $params; + } + + /** + * @return array + */ + public function getParams() + { + return $this->_params; + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Cache/Frontend/_files/config.xml b/dev/tests/unit/testsuite/Mage/Core/Model/Cache/Frontend/_files/config.xml new file mode 100644 index 0000000000000..60dcae6bd0f77 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Cache/Frontend/_files/config.xml @@ -0,0 +1,44 @@ + + + + + value1 + value2 + + + + value1 + value2 + + + value1 + value2 + + + + diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Cache/Type/AccessProxyTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Cache/Type/AccessProxyTest.php new file mode 100644 index 0000000000000..51567335b72d6 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Cache/Type/AccessProxyTest.php @@ -0,0 +1,74 @@ +getMock('Magento_Cache_FrontendInterface'); + + $cacheEnabler = $this->getMock('Mage_Core_Model_Cache_Types', array(), array(), '', false); + $cacheEnabler->expects($this->at(0)) + ->method('isEnabled') + ->with($identifier) + ->will($this->returnValue(false)); + $cacheEnabler->expects($this->at(1)) + ->method('isEnabled') + ->with($identifier) + ->will($this->returnValue(true)); + + $object = new Mage_Core_Model_Cache_Type_AccessProxy($frontendMock, $cacheEnabler, $identifier); + $helper = new Magento_Test_Helper_ProxyTesting(); + + // For the first call the cache is disabled - so fake default result is returned + $result = $helper->invokeWithExpectations($object, $frontendMock, $method, $params, $enabledResult); + $this->assertSame($disabledResult, $result); + + // For the second call the cache is enabled - so real cache result is returned + $result = $helper->invokeWithExpectations($object, $frontendMock, $method, $params, $enabledResult); + $this->assertSame($enabledResult, $result); + } + + /** + * @return array + */ + public static function proxyMethodDataProvider() + { + return array( + array('test', array('record_id'), false, 111), + array('load', array('record_id'), false, '111'), + array('save', array('record_value', 'record_id', array('tag'), 555), true, false), + array('remove', array('record_id'), true, false), + array('clean', array(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('tag')), true, false), + ); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Cache/Type/FrontendPoolTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Cache/Type/FrontendPoolTest.php new file mode 100644 index 0000000000000..d6358712fa116 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Cache/Type/FrontendPoolTest.php @@ -0,0 +1,119 @@ +_objectManager = $this->getMock('Magento_ObjectManager', array(), array(), '', false); + $this->_cachePool = $this->getMock('Mage_Core_Model_Cache_Frontend_Pool', array(), array(), '', false); + $this->_model = new Mage_Core_Model_Cache_Type_FrontendPool($this->_objectManager, $this->_cachePool); + } + + public function testGet() + { + $instanceMock = $this->getMock('Magento_Cache_FrontendInterface'); + $this->_cachePool->expects($this->once()) + ->method('get') + ->with('cache_type') + ->will($this->returnValue($instanceMock)); + + $accessMock = $this->getMock('Mage_Core_Model_Cache_Type_AccessProxy', array(), array(), '', false); + $this->_objectManager->expects($this->once()) + ->method('create') + ->with('Mage_Core_Model_Cache_Type_AccessProxy', + array('frontend' => $instanceMock, 'identifier' => 'cache_type')) + ->will($this->returnValue($accessMock)); + + $instance = $this->_model->get('cache_type'); + $this->assertSame($accessMock, $instance); + + // And must be cached + $instance = $this->_model->get('cache_type'); + $this->assertSame($accessMock, $instance); + } + + public function testGetFallbackToDefaultId() + { + /** + * Setup cache pool to have knowledge only about default cache instance. Also check appropriate sequence + * of calls. + */ + $defaultInstance = $this->getMock('Magento_Cache_FrontendInterface'); + $this->_cachePool->expects($this->at(0)) + ->method('get') + ->with('cache_type') + ->will($this->returnValue(null)); + $this->_cachePool->expects($this->at(1)) + ->method('get') + ->with(Mage_Core_Model_Cache_Frontend_Pool::DEFAULT_FRONTEND_ID) + ->will($this->returnValue($defaultInstance)); + + $this->_cachePool->expects($this->at(2)) + ->method('get') + ->with('another_cache_type') + ->will($this->returnValue(null)); + $this->_cachePool->expects($this->at(3)) + ->method('get') + ->with(Mage_Core_Model_Cache_Frontend_Pool::DEFAULT_FRONTEND_ID) + ->will($this->returnValue($defaultInstance)); + + /** + * Setup object manager to create new access proxies. We expect two calls. + */ + $this->_objectManager->expects($this->at(0)) + ->method('create') + ->with('Mage_Core_Model_Cache_Type_AccessProxy', + array('frontend' => $defaultInstance, 'identifier' => 'cache_type')) + ->will($this->returnValue( + $this->getMock('Mage_Core_Model_Cache_Type_AccessProxy', array(), array(), '', false) + )); + $this->_objectManager->expects($this->at(1)) + ->method('create') + ->with('Mage_Core_Model_Cache_Type_AccessProxy', + array('frontend' => $defaultInstance, 'identifier' => 'another_cache_type')) + ->will($this->returnValue( + $this->getMock('Mage_Core_Model_Cache_Type_AccessProxy', array(), array(), '', false) + )); + + $cacheInstance = $this->_model->get('cache_type'); + $anotherInstance = $this->_model->get('another_cache_type'); + $this->assertNotSame($cacheInstance, $anotherInstance, + 'Different cache instances must be returned for different identifiers'); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Cache/Type/GenericTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Cache/Type/GenericTest.php new file mode 100644 index 0000000000000..f986f5c3bfc2f --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Cache/Type/GenericTest.php @@ -0,0 +1,70 @@ +getMock('Magento_Cache_FrontendInterface'); + + $poolMock = $this->getMock('Mage_Core_Model_Cache_Type_FrontendPool', array(), array(), '', false); + $poolMock->expects($this->atLeastOnce()) + ->method('get') + ->with($className::TYPE_IDENTIFIER) + ->will($this->returnValue($frontendMock)); + + $model = new $className($poolMock); + + // Test initialization was done right + $this->assertEquals($className::CACHE_TAG, $model->getTag(), 'The tag is wrong'); + + // Test that frontend is now engaged in operations + $frontendMock->expects($this->once()) + ->method('load') + ->with(26); + $model->load(26); + } + + /** + * @return array + */ + public static function constructorDataProvider() + { + return array( + array('Mage_Core_Model_Cache_Type_Block'), + array('Mage_Core_Model_Cache_Type_Collection'), + array('Mage_Core_Model_Cache_Type_Config'), + array('Mage_Core_Model_Cache_Type_Layout'), + array('Mage_Core_Model_Cache_Type_Translate'), + array('Mage_Core_Model_Cache_Type_Block'), + ); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Cache/TypesTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Cache/TypesTest.php new file mode 100644 index 0000000000000..d53a57b2dffe4 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Cache/TypesTest.php @@ -0,0 +1,180 @@ +_buildModel($typeOptions, array(), $appInstalled, $banAll); + $actualIsEnabled = $model->isEnabled($cacheType); + $this->assertEquals($expectedIsEnabled, $actualIsEnabled); + } + + /** + * @return array + */ + public static function isEnabledDataProvider() + { + return array( + 'enabled' => array( + 'cacheType' => 'cache_type', + 'typeOptions' => array('some_type' => false, 'cache_type' => true), + 'appInstalled' => true, + 'banAll' => false, + 'expectedIsEnabled' => true, + ), + 'disabled' => array( + 'cacheType' => 'cache_type', + 'typeOptions' => array('some_type' => true, 'cache_type' => false), + 'appInstalled' => true, + 'banAll' => false, + 'expectedIsEnabled' => false, + ), + 'unknown is disabled' => array( + 'cacheType' => 'unknown_cache_type', + 'typeOptions' => array('some_type' => true), + 'appInstalled' => true, + 'banAll' => false, + 'expectedIsEnabled' => false, + ), + 'disabled, when app is not installed' => array( + 'cacheType' => 'cache_type', + 'typeOptions' => array('cache_type' => true), + 'appInstalled' => false, + 'banAll' => false, + 'expectedIsEnabled' => false, + ), + 'disabled, when all caches are banned' => array( + 'cacheType' => 'cache_type', + 'typeOptions' => array('cache_type' => true), + 'appInstalled' => true, + 'banAll' => true, + 'expectedIsEnabled' => false, + ), + ); + } + + /** + * Builds model to be tested + * + * @param array|false $cacheTypeOptions + * @param array|false $resourceTypeOptions + * @param bool $appInstalled + * @param bool $banAll + * @return Mage_Core_Model_Cache_Types + */ + protected function _buildModel( + $cacheTypeOptions, + $resourceTypeOptions = false, + $appInstalled = true, + $banAll = false + ) { + $this->_cacheFrontend = $this->getMock('Magento_Cache_FrontendInterface'); + $this->_cacheFrontend->expects($this->any()) + ->method('load') + ->with(Mage_Core_Model_Cache_Types::CACHE_ID) + ->will($this->returnValue( + $cacheTypeOptions === false ? false : serialize($cacheTypeOptions) + )); + $cacheFrontendPool = $this->getMock('Mage_Core_Model_Cache_Frontend_Pool', array(), array(), '', false); + $cacheFrontendPool->expects($this->any()) + ->method('get') + ->with(Mage_Core_Model_Cache_Frontend_Pool::DEFAULT_FRONTEND_ID) + ->will($this->returnValue($this->_cacheFrontend)); + + $this->_resource = $this->getMock('Mage_Core_Model_Resource_Cache', array(), array(), '', false); + $this->_resource->expects($this->any()) + ->method('getAllOptions') + ->will($this->returnValue($resourceTypeOptions)); + + $appState = $this->getMock('Mage_Core_Model_App_State'); + $appState->expects($this->any()) + ->method('isInstalled') + ->will($this->returnValue($appInstalled)); + + $this->_model = new Mage_Core_Model_Cache_Types($this->_resource, $cacheFrontendPool, $appState, $banAll); + + return $this->_model; + } + + /** + * The model must fetch data via its resource, if the cache type list is not cached + * (e.g. cache load result is FALSE) + */ + public function testIsEnabledFallbackToResource() + { + $model = $this->_buildModel(array(), array('cache_type' => true)); + $this->assertFalse($model->isEnabled('cache_type')); + + $model = $this->_buildModel(false, array('cache_type' => true)); + $this->assertTrue($model->isEnabled('cache_type')); + } + + public function testSetEnabledIsEnabled() + { + $model = $this->_buildModel(array('cache_type' => false)); + $model->setEnabled('cache_type', true); + $this->assertTrue($model->isEnabled('cache_type')); + + $model->setEnabled('cache_type', false); + $this->assertFalse($model->isEnabled('cache_type')); + } + + public function testPersist() + { + $cacheTypes = array('cache_type' => false); + $model = $this->_buildModel($cacheTypes); + + $this->_resource->expects($this->once()) + ->method('saveAllOptions') + ->with($cacheTypes); + $this->_cacheFrontend->expects($this->once()) + ->method('remove') + ->with(Mage_Core_Model_Cache_Types::CACHE_ID); + + $model->persist(); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/CacheTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/CacheTest.php index 4fa1debd87ff1..20b16f5d9876b 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/CacheTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/CacheTest.php @@ -32,149 +32,126 @@ class Mage_Core_Model_CacheTest extends PHPUnit_Framework_TestCase protected $_model; /** - * @var Mage_Core_Model_Config_Primary + * @var PHPUnit_Framework_MockObject_MockObject[] */ - protected $_primaryConfigMock; + protected $_cacheTypeMocks; /** * @var PHPUnit_Framework_MockObject_MockObject */ - protected $_configMock; + protected $_cacheFrontendMock; /** * @var PHPUnit_Framework_MockObject_MockObject */ - protected $_dirsMock; - - /** - * @var PHPUnit_Framework_MockObject_MockObject - */ - protected $_helperMock; - - /** - * @var PHPUnit_Framework_MockObject_MockObject - */ - protected $_helperFactoryMock; - - /** - * @var PHPUnit_Framework_MockObject_MockObject; - */ - protected $_cacheFrontend; + protected $_cacheTypesMock; protected function setUp() { - $this->_helperFactoryMock = $this->getMock('Mage_Core_Model_Factory_Helper', array(), array(), '', false); - $this->_helperMock = $this->getMock('Mage_Core_Helper_Data', array('__'), array(), '', false); - $this->_helperMock + $helperMock = $this->getMock('Mage_Core_Helper_Data', array('__'), array(), '', false); + $helperMock ->expects($this->any()) ->method('__') - ->will($this->returnArgument(0)); - $this->_helperFactoryMock->expects($this->any())->method('get')->will($this->returnValue($this->_helperMock)); - - $this->_dirsMock = $this->getMock('Mage_Core_Model_Dir', array(), array(), '', false); + ->will($this->returnArgument(0)) + ; + $helperFactoryMock = $this->getMock('Mage_Core_Model_Factory_Helper', array(), array(), '', false); + $helperFactoryMock + ->expects($this->any()) + ->method('get') + ->with('Mage_Core_Helper_Data') + ->will($this->returnValue($helperMock)) + ; - $this->_primaryConfigMock = $this->getMock('Mage_Core_Model_Config_Primary', array(), array(), '', false); + $this->_initCacheTypeMocks(); + $objectManagerMock = $this->getMockForAbstractClass('Magento_ObjectManager'); + $objectManagerMock + ->expects($this->any()) + ->method('get') + ->will($this->returnCallback(array($this, 'getTypeMock'))); - $this->_configMock = new Mage_Core_Model_Config_Base(<< - - - - - - This is Tag One - tag_one - - - - These are Tags One and Two - tag_one,tag_two - - - - - -XML + $this->_cacheFrontendMock = $this->getMockForAbstractClass( + 'Magento_Cache_FrontendInterface', array(), '', true, true, true, array('clean') ); - $this->_cacheFrontend = $this->getMock( - 'Zend_Cache_Core', array('load', 'test', 'save', 'remove', 'clean', '_getHelper') - ); + $frontendPoolMock = $this->getMock('Mage_Core_Model_Cache_Frontend_Pool', array(), array(), '', false); + $frontendPoolMock + ->expects($this->any()) + ->method('valid') + ->will($this->onConsecutiveCalls(true, false)) + ; + $frontendPoolMock + ->expects($this->any()) + ->method('current') + ->will($this->returnValue($this->_cacheFrontendMock)) + ; + $frontendPoolMock + ->expects($this->any()) + ->method('get') + ->with(Mage_Core_Model_Cache_Frontend_Pool::DEFAULT_FRONTEND_ID) + ->will($this->returnValue($this->_cacheFrontendMock)) + ; + + $this->_cacheTypesMock = $this->getMock('Mage_Core_Model_Cache_Types', array(), array(), '', false); + + $configFixture = new Mage_Core_Model_Config_Base(file_get_contents(__DIR__ . '/_files/cache_types.xml')); + + $dirsMock = $this->getMock('Mage_Core_Model_Dir', array(), array(), '', false); + $this->_model = new Mage_Core_Model_Cache( - $this->_configMock, $this->_primaryConfigMock, $this->_dirsMock, $this->_helperFactoryMock, false, array( - 'frontend' => $this->_cacheFrontend, - 'backend' => 'BlackHole', - ) + $objectManagerMock, $frontendPoolMock, $this->_cacheTypesMock, $configFixture, + $dirsMock, $helperFactoryMock ); } - protected function tearDown() + /** + * Init necessary cache type mocks + */ + protected function _initCacheTypeMocks() { - $this->_primaryConfigMock = null; - $this->_configMock = null; - $this->_dirsMock = null; - $this->_helperFactoryMock = null; - $this->_helperMock = null; - $this->_cacheFrontend = null; - $this->_model = null; + $cacheTypes = array('Magento_Cache_Frontend_Decorator_TagScope', 'Magento_Cache_Frontend_Decorator_Bare'); + foreach ($cacheTypes as $type) { + $this->_cacheTypeMocks[$type] = $this->getMock($type, array('clean'), array( + $this->getMockForAbstractClass('Magento_Cache_FrontendInterface'), 'FIXTURE_TAG' + )); + } } /** - * Force to load desired cache type options + * Callback for the object manager to get different cache type mocks * - * @param array $cacheTypeOptions + * @param string $type Class of the cache type + * @return PHPUnit_Framework_MockObject_MockObject */ - protected function _emulateCacheTypeOptions(array $cacheTypeOptions = array('config' => true)) + public function getTypeMock($type) { - $this->_cacheFrontend - ->expects($this->any()) - ->method('load') - ->with(strtoupper(Mage_Core_Model_Cache::OPTIONS_CACHE_ID)) - ->will($this->returnValue(serialize($cacheTypeOptions))) - ; + return $this->_cacheTypeMocks[$type]; } - /** - * @dataProvider constructorDataProvider - * @param array $options - * @param string $expectedBackendClass - */ - public function testConstructor(array $options, $expectedBackendClass) + protected function tearDown() { - $options += array('helper' => $this->_helperMock); - $model = new Mage_Core_Model_Cache( - $this->_configMock, $this->_primaryConfigMock, $this->_dirsMock, - $this->_helperFactoryMock, false, $options - ); - - $backend = $model->getFrontend()->getBackend(); - $this->assertInstanceOf($expectedBackendClass, $backend); + $this->_cacheTypeMocks = array(); + $this->_cacheTypesMock = null; + $this->_cacheFrontendMock = null; + $this->_model = null; } - /** - * @return array - */ - public function constructorDataProvider() + public function testConstructor() { - return array( - array(array(), 'Zend_Cache_Backend_File'), - array(array('backend' => 'File'), 'Zend_Cache_Backend_File'), - array(array('backend' => 'File', 'backend_options' => array()), 'Zend_Cache_Backend_File'), - ); + $this->assertSame($this->_cacheFrontendMock, $this->_model->getFrontend()); } public function testGetFrontend() { $frontend = $this->_model->getFrontend(); - $this->assertSame($this->_cacheFrontend, $frontend); + $this->assertSame($this->_cacheFrontendMock, $frontend); } public function testLoad() { - $this->_cacheFrontend + $this->_cacheFrontendMock ->expects($this->once()) ->method('load') - ->with('TEST_ID') + ->with('test_id') ->will($this->returnValue('test_data')) ; $this->assertEquals('test_data', $this->_model->load('test_id')); @@ -191,7 +168,7 @@ public function testLoad() */ public function testSave($inputData, $inputId, $inputTags, $expectedData, $expectedId, $expectedTags) { - $this->_cacheFrontend + $this->_cacheFrontendMock ->expects($this->once()) ->method('save') ->with($this->identicalTo($expectedData), $expectedId, $expectedTags) @@ -202,51 +179,35 @@ public function testSave($inputData, $inputId, $inputTags, $expectedData, $expec public function saveDataProvider() { $configTag = Mage_Core_Model_Config::CACHE_TAG; - $appTag = Mage_Core_Model_AppInterface::CACHE_TAG; return array( 'default tags' => array( - 'test_data', 'test_id', array(), 'test_data', 'TEST_ID', array($appTag) + 'test_data', 'test_id', array(), 'test_data', 'test_id', array() ), 'config tags' => array( - 'test_data', 'test_id', array($configTag), 'test_data', 'TEST_ID', array($configTag) + 'test_data', 'test_id', array($configTag), 'test_data', 'test_id', array($configTag) ), 'lowercase tags' => array( - 'test_data', 'test_id', array('test_tag'), 'test_data', 'TEST_ID', array('TEST_TAG', $appTag) + 'test_data', 'test_id', array('test_tag'), 'test_data', 'test_id', array('test_tag') ), 'non-string data' => array( - 1234567890, 'test_id', array(), '1234567890', 'TEST_ID', array(Mage_Core_Model_AppInterface::CACHE_TAG) + 1234567890, 'test_id', array(), '1234567890', 'test_id', array() ), ); } - public function testSaveDisallowed() - { - $model = new Mage_Core_Model_Cache( - $this->_configMock, $this->_primaryConfigMock, $this->_dirsMock, $this->_helperFactoryMock, array( - 'frontend' => $this->_cacheFrontend, - 'backend' => 'BlackHole', - 'disallow_save' => true - )); - $this->_cacheFrontend - ->expects($this->never()) - ->method('save') - ; - $model->save('test_data', 'test_id'); - } - /** * @dataProvider successFailureDataProvider * @param bool $result */ public function testRemove($result) { - $this->_cacheFrontend + $this->_cacheFrontendMock ->expects($this->once()) ->method('remove') - ->with('TEST_ID') + ->with('test_id') ->will($this->returnValue($result)) ; - $this->assertEquals($result, $this->_model->remove('test_ID')); + $this->assertEquals($result, $this->_model->remove('test_id')); } public function successFailureDataProvider() @@ -257,131 +218,75 @@ public function successFailureDataProvider() ); } - /** - * @dataProvider cleanDataProvider - * @param array $inputTags - * @param array $expectedTags - */ - public function testClean(array $inputTags, array $expectedTags) + public function testCleanByTags() { - $this->_cacheFrontend + $expectedTags = array('test_tag'); + $this->_cacheFrontendMock ->expects($this->once()) ->method('clean') ->with(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, $expectedTags) - ->will($this->returnValue(false)) - ; - $this->_model->clean($inputTags); - } - - public function cleanDataProvider() - { - return array( - 'default tags' => array(array(), array(Mage_Core_Model_AppInterface::CACHE_TAG)), - 'custom tags' => array(array('test_tag'), array('TEST_TAG')), - ); - } - - public function testCleanByConfig() - { - $this->_cacheFrontend - ->expects($this->at(0)) - ->method('clean') - ->with(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array(Mage_Core_Model_AppInterface::CACHE_TAG)) ->will($this->returnValue(true)) ; - $this->_cacheFrontend - ->expects($this->at(1)) - ->method('clean') - ->with(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array(Mage_Core_Model_Config::CACHE_TAG)) - ->will($this->returnValue(true)) - ; - $this->_model->clean(); + $this->assertTrue($this->_model->clean($expectedTags)); } - /** - * @dataProvider successFailureDataProvider - * @param bool $result - */ - public function testFlush($result) + public function testCleanByEmptyTags() { - $this->_cacheFrontend + $this->_cacheFrontendMock ->expects($this->once()) ->method('clean') - ->will($this->returnValue($result)) + ->with(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array(Mage_Core_Model_AppInterface::CACHE_TAG)) + ->will($this->returnValue(true)) ; - $this->assertEquals($result, $this->_model->flush()); + $this->assertTrue($this->_model->clean()); } - /** - * @return Mage_Core_Model_Cache - */ public function testCanUse() { - $this->_emulateCacheTypeOptions(); - $this->assertEquals(array('config' => true), $this->_model->canUse('')); + $this->_cacheTypesMock + ->expects($this->once()) + ->method('isEnabled') + ->with('config') + ->will($this->returnValue(true)) + ; $this->assertTrue($this->_model->canUse('config')); - return $this->_model; } - /** - * @depends testCanUse - * @param Mage_Core_Model_Cache $model - * @return Mage_Core_Model_CacheTest - */ - public function testBanUse(Mage_Core_Model_Cache $model) + public function testBanUse() { - $this->_emulateCacheTypeOptions(); - $this->assertTrue($model->canUse('config')); - $model->banUse('config'); - $this->assertFalse($model->canUse('config')); - return $model; - } - - /** - * @depends testBanUse - * @param Mage_Core_Model_Cache $model - */ - public function testAllowUse(Mage_Core_Model_Cache $model) - { - $this->_emulateCacheTypeOptions(); - $this->assertFalse($model->canUse('config')); - $model->allowUse('config'); - $this->assertTrue($model->canUse('config')); - } - - /** - * @dataProvider getTagsByTypeDataProvider - */ - public function testGetTagsByType($cacheType, $expectedTags) - { - $actualTags = $this->_model->getTagsByType($cacheType); - $this->assertEquals($expectedTags, $actualTags); + $this->_cacheTypesMock + ->expects($this->once()) + ->method('setEnabled') + ->with('config', false) + ; + $this->_model->banUse('config'); } - public function getTagsByTypeDataProvider() + public function testAllowUse() { - return array( - 'single tag' => array('single_tag', array('tag_one')), - 'multiple tags' => array('multiple_tags', array('tag_one', 'tag_two')), - 'non-existing' => array('non-existing', false), - ); + $this->_cacheTypesMock + ->expects($this->once()) + ->method('setEnabled') + ->with('config', true) + ; + $this->_model->allowUse('config'); } public function testGetTypes() { $expectedCacheTypes = array( - 'single_tag' => array( - 'id' => 'single_tag', - 'cache_type' => 'Tag One', - 'description' => 'This is Tag One', - 'tags' => 'TAG_ONE', + 'fixture_type_tag_scope' => array( + 'id' => 'fixture_type_tag_scope', + 'cache_type' => 'Fixture Type One', + 'description' => 'This is Fixture Type One', + 'tags' => 'FIXTURE_TAG', 'status' => 0, ), - 'multiple_tags' => array( - 'id' => 'multiple_tags', - 'cache_type' => 'Tags One and Two', - 'description' => 'These are Tags One and Two', - 'tags' => 'TAG_ONE,TAG_TWO', + 'fixture_type_bare' => array( + 'id' => 'fixture_type_bare', + 'cache_type' => 'Fixture Type Two', + 'description' => 'This is Fixture Type Two', + 'tags' => '', 'status' => 0, ), ); @@ -397,50 +302,44 @@ public function testGetTypes() public function testGetInvalidatedTypes() { - $this->_model->allowUse('single_tag'); - $this->_cacheFrontend + $this->_cacheTypesMock + ->expects($this->any()) + ->method('isEnabled') + ->will($this->returnValue(true)) + ; + $this->_cacheFrontendMock ->expects($this->once()) ->method('load') - ->with(strtoupper(Mage_Core_Model_Cache::INVALIDATED_TYPES)) - ->will($this->returnValue(serialize(array('single_tag' => 1, 'non_existing_type' => 1)))) + ->with(Mage_Core_Model_Cache::INVALIDATED_TYPES) + ->will($this->returnValue(serialize(array('fixture_type_tag_scope' => 1)))) ; $actualResult = $this->_model->getInvalidatedTypes(); $this->assertInternalType('array', $actualResult); $this->assertCount(1, $actualResult); - $this->assertArrayHasKey('single_tag', $actualResult); - $this->assertInstanceOf('Varien_Object', $actualResult['single_tag']); + $this->assertArrayHasKey('fixture_type_tag_scope', $actualResult); + $this->assertInstanceOf('Varien_Object', $actualResult['fixture_type_tag_scope']); } public function testInvalidateType() { - $this->_cacheFrontend + $this->_cacheFrontendMock ->expects($this->once()) ->method('save') - ->with(serialize(array('test' => 1)), strtoupper(Mage_Core_Model_Cache::INVALIDATED_TYPES)) + ->with(serialize(array('test' => 1)), Mage_Core_Model_Cache::INVALIDATED_TYPES) ; $this->_model->invalidateType('test'); } public function testCleanType() { - $this->_model->allowUse('single_tag'); - $this->_model->allowUse('multiple_tags'); - $this->_cacheFrontend - ->expects($this->at(0)) + $this->_cacheTypeMocks['Magento_Cache_Frontend_Decorator_TagScope'] + ->expects($this->once()) ->method('clean') - ->with(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('TAG_ONE', 'TAG_TWO')) - ; - $this->_cacheFrontend - ->expects($this->at(1)) - ->method('load') - ->with(strtoupper(Mage_Core_Model_Cache::INVALIDATED_TYPES)) - ->will($this->returnValue(serialize(array('single_tag' => 1, 'multiple_tags' => 1)))) ; - $this->_cacheFrontend - ->expects($this->at(2)) - ->method('save') - ->with(serialize(array('single_tag' => 1)), strtoupper(Mage_Core_Model_Cache::INVALIDATED_TYPES)) + $this->_cacheTypeMocks['Magento_Cache_Frontend_Decorator_Bare'] + ->expects($this->never()) + ->method('clean') ; - $this->_model->cleanType('multiple_tags'); + $this->_model->cleanType('fixture_type_tag_scope'); } } diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Config/CacheTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Config/CacheTest.php index 886f14b328723..a898bb2db9f01 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Config/CacheTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Config/CacheTest.php @@ -53,7 +53,7 @@ class Mage_Core_Model_Config_CacheTest extends PHPUnit_Framework_TestCase protected function setUp() { - $this->_cacheMock = $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false, false); + $this->_cacheMock = $this->getMock('Mage_Core_Model_Cache_Type_Config', array(), array(), '', false, false); $this->_configSectionsMock = $this->getMock('Mage_Core_Model_Config_Sections', array(), array(), '', false, false); $this->_contFactoryMock = $this->getMock('Mage_Core_Model_Config_ContainerFactory', @@ -92,14 +92,10 @@ public function testLoadWithoutConfig() public function testLoadWithConfig() { - $this->_cacheMock->expects($this->once()) - ->method('canUse') - ->with('config') - ->will($this->returnValue(true)); - $this->_cacheMock->expects($this->at(1)) + $this->_cacheMock->expects($this->at(0)) ->method('load') ->will($this->returnValue(false)); - $this->_cacheMock->expects($this->at(2)) + $this->_cacheMock->expects($this->at(1)) ->method('load') ->will($this->returnValue('test_config')); $this->_contFactoryMock->expects($this->once()) @@ -109,4 +105,78 @@ public function testLoadWithConfig() $this->assertEquals('some_instance', $this->_model->load()); } + + public function testSave() + { + $config = new Mage_Core_Model_Config_Base( + 'section 1section 2' + ); + $this->_cacheMock->expects($this->at(0)) + ->method('load') + ->with('config_global.lock') + ->will($this->returnValue(false)); + $this->_configSectionsMock->expects($this->once()) + ->method('getSections') + ->will($this->returnValue(array('section1' => 1, 'section2' => 2))); + + $this->_cacheMock->expects($this->at(1)) + ->method('save') + ->with($this->anything(), 'config_global.lock'); + $this->_cacheMock->expects($this->once()) + ->method('clean'); + $this->_cacheMock->expects($this->at(3)) + ->method('save') + ->with('section 1', 'config_global_section1'); + $this->_cacheMock->expects($this->at(4)) + ->method('save') + ->with('section 2', 'config_global_section2'); + $this->_cacheMock->expects($this->once()) + ->method('remove') + ->with('config_global.lock'); + $this->_model->save($config); + } + + public function testSaveLocked() + { + $this->_cacheMock->expects($this->at(0)) + ->method('load') + ->with('config_global.lock') + ->will($this->returnValue(true)); + $this->_cacheMock->expects($this->never()) + ->method('save'); + $this->_model->save(new Mage_Core_Model_Config_Base()); + } + + public function testClean() + { + $this->_cacheMock->expects($this->once()) + ->method('clean'); + $this->_model->clean(); + } + + public function testGetSection() + { + $this->_cacheMock->expects($this->once()) + ->method('load') + ->with('config_global_section1') + ->will($this->returnValue('')); + $this->_baseFactoryMock->expects($this->once()) + ->method('create') + ->with(''); + $this->_model->getSection('section1'); + } + + /** + * @expectedException Mage_Core_Model_Config_Cache_Exception + */ + public function testGetSectionNoSectionException() + { + $this->_cacheMock->expects($this->once()) + ->method('load') + ->with('config_global_section1') + ->will($this->returnValue(false)); + $this->_baseFactoryMock->expects($this->never()) + ->method('create'); + $this->_model->getSection('section1'); + } } diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Config/FieldsetTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Config/FieldsetTest.php new file mode 100644 index 0000000000000..a0bfd99c85c62 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Config/FieldsetTest.php @@ -0,0 +1,79 @@ +_configReaderMock = $this->getMock('Mage_Core_Model_Config_Modules_Reader', array(), array(), '', false); + $this->_cacheTypeMock = $this->getMock('Mage_Core_Model_Cache_Type_Config', array(), array(), '', false); + } + + protected function tearDown() + { + $this->_configReaderMock = null; + $this->_cacheTypeMock = null; + } + + public function testConstructorCacheExists() + { + $cachedConfig = ''; + $this->_cacheTypeMock->expects($this->once()) + ->method('load') + ->with('fieldset_config') + ->will($this->returnValue($cachedConfig)); + $model = new Mage_Core_Model_Config_Fieldset($this->_configReaderMock, $this->_cacheTypeMock); + $this->assertInstanceOf('Varien_Simplexml_Element', $model->getNode()); + } + + public function testConstructorNoCacheExists() + { + $config = new Mage_Core_Model_Config_Base(''); + $this->_cacheTypeMock->expects($this->once()) + ->method('load') + ->with('fieldset_config') + ->will($this->returnValue(false)); + $this->_configReaderMock->expects($this->once()) + ->method('loadModulesConfiguration') + ->with('fieldset.xml') + ->will($this->returnValue($config)); + $this->_cacheTypeMock->expects($this->once()) + ->method('save') + ->with("\n\n"); + $model = new Mage_Core_Model_Config_Fieldset($this->_configReaderMock, $this->_cacheTypeMock); + $this->assertInstanceOf('Varien_Simplexml_Element', $model->getNode()); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Config/Loader/LocalTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Config/Loader/LocalTest.php deleted file mode 100644 index 7c9029aa86aa8..0000000000000 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Config/Loader/LocalTest.php +++ /dev/null @@ -1,185 +0,0 @@ -_customConfig = null; - $this->_customFile = null; - $this->_dirsMock = $this->getMock('Mage_Core_Model_Dir', array(), array(), '', false, false); - $this->_protFactoryMock = $this->getMock('Mage_Core_Model_Config_BaseFactory', - array(), array(), '', false, false); - $this->_baseConfigMock = $this->getMock('Mage_Core_Model_Config_Base', array(), array(), '', false, false); - } - - protected function createModel() - { - return new Mage_Core_Model_Config_Loader_Local( - $this->_protFactoryMock, - $this->_dirsMock, - $this->_customConfig, - $this->_customFile - ); - } - - protected function tearDown() - { - unset($this->_protFactoryMock); - unset($this->_dirsMock); - unset($this->_baseConfigMock); - unset($this->_model); - } - - public function testLoadWithoutData() - { - $this->_dirsMock->expects($this->once()) - ->method('getDir') - ->with($this->equalTo(Mage_Core_Model_Dir::CONFIG)) - ->will($this->returnValue('testdir\etc')); - $this->_protFactoryMock->expects($this->never()) - ->method('create'); - $this->_baseConfigMock->expects($this->never()) - ->method('loadFile'); - $this->_baseConfigMock->expects($this->never()) - ->method('loadString'); - $this->_baseConfigMock->expects($this->never()) - ->method('extend'); - $this->createModel()->load($this->_baseConfigMock); - } - - public function testLoadWithLocalConfig() - { - $localConfigFile = realpath(__DIR__. '/../_files/testdir/etc/local.xml'); - $this->_dirsMock->expects($this->once()) - ->method('getDir') - ->with($this->equalTo(Mage_Core_Model_Dir::CONFIG)) - ->will($this->returnValue(realpath(__DIR__. '/../_files/testdir/etc'))); - $this->_protFactoryMock->expects($this->exactly(1)) - ->method('create') - ->with('') - ->will($this->returnValue($this->_baseConfigMock)); - $this->_baseConfigMock->expects($this->once()) - ->method('loadFile') - ->with($this->equalTo($localConfigFile)) - ->will($this->returnValue(true)); - $this->_baseConfigMock->expects($this->exactly(1)) - ->method('extend') - ->with($this->equalTo($this->_baseConfigMock)) - ->will($this->returnValue($this->getMockBuilder('Varien_Simplexml_Config') - ->disableOriginalConstructor()->getMock()) - ); - $this->createModel()->load($this->_baseConfigMock); - } - - public function testLoadWithCustomConfig() - { - $localConfigFile = realpath(__DIR__. '/../_files/testdir/etc/local.xml'); - $this->_customFile = 'directorytest' . DS . 'testconfig.xml'; - $localConfigExtraFile = realpath(__DIR__. '/../_files/testdir/etc/directorytest/testconfig.xml'); - $this->_dirsMock->expects($this->once()) - ->method('getDir') - ->with($this->equalTo(Mage_Core_Model_Dir::CONFIG)) - ->will($this->returnValue(realpath(__DIR__. '/../_files/testdir/etc/'))); - $this->_protFactoryMock->expects($this->exactly(2)) - ->method('create') - ->with('') - ->will($this->returnValue($this->_baseConfigMock)); - $this->_baseConfigMock->expects($this->at(0)) - ->method('loadFile') - ->with($this->equalTo($localConfigFile)) - ->will($this->returnValue(true)); - $this->_baseConfigMock->expects($this->at(1)) - ->method('loadFile') - ->with($this->equalTo($localConfigExtraFile)) - ->will($this->returnValue(true)); - $this->_baseConfigMock->expects($this->exactly(2)) - ->method('extend') - ->with($this->equalTo($this->_baseConfigMock)) - ->will($this->returnValue($this->getMockBuilder('Varien_Simplexml_Config') - ->disableOriginalConstructor()->getMock()) - ); - $this->createModel()->load($this->_baseConfigMock); - } - - public function testLoadWithExtraLocalConfig() - { - $this->_customConfig = realpath(__DIR__. '/../_files/testdir/etc/testdirectory/customconfig.xml'); - $this->_dirsMock->expects($this->once()) - ->method('getDir') - ->with($this->equalTo(Mage_Core_Model_Dir::CONFIG)) - ->will($this->returnValue(realpath(__DIR__. '/../_files/testdir/etc/testdirectory'))); - $this->_protFactoryMock->expects($this->exactly(1)) - ->method('create') - ->with('') - ->will($this->returnValue($this->_baseConfigMock)); - $this->_baseConfigMock->expects($this->never()) - ->method('loadFile'); - $this->_baseConfigMock->expects($this->exactly(1)) - ->method('loadString') - ->with($this->equalTo($this->_customConfig)) - ->will($this->returnValue(true)); - $this->_baseConfigMock->expects($this->exactly(1)) - ->method('extend') - ->with($this->equalTo($this->_baseConfigMock)) - ->will($this->returnValue($this->getMockBuilder('Varien_Simplexml_Config') - ->disableOriginalConstructor()->getMock()) - ); - $this->createModel()->load($this->_baseConfigMock); - } -} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Config/Loader/Modules/FileTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Config/Loader/Modules/FileTest.php index d74480d07f7de..5afea2d9b6b2c 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Config/Loader/Modules/FileTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Config/Loader/Modules/FileTest.php @@ -84,12 +84,12 @@ public function testLoadConfigurationFromFile() ->method('create') ->with($this->equalTo('')) ->will($this->returnValue($this->_baseConfigMock)); - $this->_modulesConfigMock->expects($this->exactly(2)) + + $this->_modulesConfigMock->expects($this->once()) ->method('getNode') - ->will($this->returnValueMap(array( - array('modules', $nodes), - array('modules/mod1/codePool', 'core') - ))); + ->with('modules') + ->will($this->returnValue($nodes)); + $result = $this->_model->loadConfigurationFromFile($this->_modulesConfigMock, $fileName, null, null, array()); $this->assertInstanceOf('Mage_Core_Model_Config_Base', $result); } @@ -99,18 +99,19 @@ public function testLoadConfigurationFromFileMergeToObject() $nodes = new Mage_Core_Model_Config_Element('1'); $modulesConfigMock = $this->getMock('Mage_Core_Model_ConfigInterface', array(), array(), '', false, false); $fileName = 'acl.xml'; + $mergeToObject = $this->getMock('Mage_Core_Model_Config_Base', array(), array(), '', false, false); $mergeModel = null; $configCache = array(); - $modulesConfigMock->expects($this->exactly(2)) + $modulesConfigMock->expects($this->once()) ->method('getNode') ->will($this->returnValue($nodes) ); - $this->_protFactoryMock->expects($this->exactly(1)) + $this->_protFactoryMock->expects($this->once()) ->method('create') ->with($this->equalTo('')) - ->will($this->returnValue($mergeToObject) - ); + ->will($this->returnValue($mergeToObject)); + $this->_model->loadConfigurationFromFile($modulesConfigMock, $fileName, $mergeToObject, $mergeModel, $configCache); } @@ -121,6 +122,6 @@ public function testGetModuleDirWithData() $type = 'etc'; $path = realpath(__DIR__. '/../../_files/testdir/etc'); $this->_model->setModuleDir($moduleName, $type, $path); - $this->assertEquals($path, $this->_model->getModuleDir($this->_modulesConfigMock, $type, $moduleName)); + $this->assertEquals($path, $this->_model->getModuleDir($type, $moduleName)); } } \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Config/Loader/PrimaryTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Config/Loader/PrimaryTest.php deleted file mode 100644 index 169df95653485..0000000000000 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Config/Loader/PrimaryTest.php +++ /dev/null @@ -1,134 +0,0 @@ -_simpleXmlConfig = $this->getMock('Varien_Simplexml_Config', - array('getNode'), array(), '', false, false); - $this->_protFactoryMock = $this->getMock('Mage_Core_Model_Config_BaseFactory', - array(), array(), '', false, false); - $this->_dirsMock = $this->getMock('Mage_Core_Model_Dir', array(), array(), '', false, false); - $this->_localLoaderMock = $this->getMock('Mage_Core_Model_Config_Loader_Local', - array(), array(), '', false, false); - $this->_baseConfigMock = $this->getMock('Mage_Core_Model_Config_Base', array(), array(), '', false, false); - $this->_model = new Mage_Core_Model_Config_Loader_Primary( - $this->_protFactoryMock, - $this->_dirsMock, - $this->_localLoaderMock - ); - } - - protected function tearDown() - { - unset($this->_protFactoryMock); - unset($this->_dirsMock); - unset($this->_localLoaderMock); - unset($this->_baseConfigMock); - unset($this->_model); - } - - public function testLoadWithData() - { - $this->_dirsMock->expects($this->once()) - ->method('getDir') - ->with($this->equalTo(Mage_Core_Model_Dir::CONFIG)) - ->will($this->returnValue(realpath(__DIR__. '/../_files/testdir/etc'))); - $this->_baseConfigMock->expects($this->once()) - ->method('getNode') - ->will($this->returnValue($this->getMockBuilder('Varien_Simplexml_Config'))); - $this->_protFactoryMock->expects($this->once()) - ->method('create') - ->with('') - ->will($this->returnValue($this->_baseConfigMock)); - $this->_baseConfigMock->expects($this->once()) - ->method('loadFile') - ->with($this->equalTo(realpath(__DIR__. '/../_files/testdir/etc/testconfig.xml'))) - ->will($this->returnValue(true)); - $this->_baseConfigMock->expects($this->once()) - ->method('extend') - ->with($this->equalTo($this->_baseConfigMock)) - ->will($this->returnValue($this->_simpleXmlConfig)); - $this->_localLoaderMock->expects($this->once()) - ->method('load') - ->with($this->equalTo($this->_baseConfigMock)); - $this->_model->load($this->_baseConfigMock); - } - - public function testLoadWithoutData() - { - $this->_dirsMock->expects($this->once()) - ->method('getDir') - ->with($this->equalTo(Mage_Core_Model_Dir::CONFIG)) - ->will($this->returnValue(realpath(__DIR__. '/../_files/dirtest/etc'))); - $this->_baseConfigMock->expects($this->any()) - ->method('getNode') - ->will($this->returnValue($this->getMockBuilder('Varien_Simplexml_Config'))); - $this->_protFactoryMock->expects($this->never()) - ->method('create'); - $this->_baseConfigMock->expects($this->never()) - ->method('loadFile'); - $this->_baseConfigMock->expects($this->never()) - ->method('extend'); - $this->_localLoaderMock->expects($this->once()) - ->method('load') - ->with($this->equalTo($this->_baseConfigMock)); - $this->_model->load($this->_baseConfigMock); - } -} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Config/Modules/ReaderTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Config/Modules/ReaderTest.php index 0b2f11cefd10f..58f2eab7c241c 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Config/Modules/ReaderTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Config/Modules/ReaderTest.php @@ -97,8 +97,7 @@ public function testGetModuleDir() $moduleName = 'some_module'; $this->_fileReaderMock->expects($this->once()) ->method('getModuleDir') - ->with($this->equalTo($this->_configMock), - $this->equalTo($type), + ->with($this->equalTo($type), $this->equalTo($moduleName)) ->will($this->returnValue('test_data') ); diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Config/PrimaryTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Config/PrimaryTest.php new file mode 100644 index 0000000000000..ec3cb2484268a --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Config/PrimaryTest.php @@ -0,0 +1,109 @@ +_dirMock = $this->getMock('Mage_Core_Model_Dir', array(), array(), '', false); + $this->_dirMock->expects($this->any())->method('getDir')->will($this->returnValueMap(array( + array(Mage_Core_Model_Dir::DI, '/path_to_root/var/di'), + array(Mage_Core_Model_Dir::ROOT, '/path_to_root'), + ))); + $this->_loaderMock = $this->getMock('Mage_Core_Model_Config_LoaderInterface'); + $that = $this; + $this->_loaderMock->expects($this->once())->method('load')->will($this->returnCallback( + function($config) use ($that) { + $testConfig = new Mage_Core_Model_Config_Base($that->getConfigString()); + $config->getNode()->extend($testConfig->getNode()); + } + )); + } + + protected function tearDown() + { + unset($this->_dirMock); + unset($this->_loaderMock); + unset($this->_model); + } + + public function getConfigString() + { + return $this->_configString; + } + + public function testGetDefinitionPathReturnsDefaultPathIfNothingSpecified() + { + $this->_model = new Mage_Core_Model_Config_Primary(BP, array(), $this->_dirMock, $this->_loaderMock); + $expectedPath = '/path_to_root/var/di' . DIRECTORY_SEPARATOR . 'definitions.php'; + $this->assertEquals($expectedPath, $this->_model->getDefinitionPath()); + } + + public function testGetDefinitionPathReturnsAbsolutePath() + { + $this->_configString = '' + . 'customPath' + . ''; + $this->_model = new Mage_Core_Model_Config_Primary(BP, array(), $this->_dirMock, $this->_loaderMock); + $this->assertEquals('customPath', $this->_model->getDefinitionPath()); + } + + public function testGetDefinitionPathReturnsRelativePath() + { + $this->_configString = '' + . 'customPath' + . ''; + $this->_model = new Mage_Core_Model_Config_Primary(BP, array(), $this->_dirMock, $this->_loaderMock); + $expectedPath = '/path_to_root' . DIRECTORY_SEPARATOR . 'customPath'; + $this->assertEquals($expectedPath, $this->_model->getDefinitionPath()); + } + + public function getDefinitionFormatReturnsConfiguredFormat() + { + $this->_configString = '' + . 'igbinary' + . ''; + $this->_model = new Mage_Core_Model_Config_Primary(BP, array(), $this->_dirMock, $this->_loaderMock); + $this->assertEquals('igbinary', $this->_model->getDefinitionFormat()); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/ConfigTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/ConfigTest.php index 26671b6528736..96bd3175ed3d9 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/ConfigTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/ConfigTest.php @@ -39,7 +39,6 @@ public function setUp() 1.6.0.0 false - community @@ -77,7 +76,7 @@ public function setUp() $configBase = new Mage_Core_Model_Config_Base($xml); $objectManagerMock = $this->getMock('Magento_ObjectManager'); - $objectManagerMock->expects($this->once())->method('setConfiguration')->with(array( + $objectManagerMock->expects($this->once())->method('configure')->with(array( 'Mage_Core_Model_Cache' => array( 'parameters' => array('one' => 'two') ) diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Db/UpdaterTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Db/UpdaterTest.php new file mode 100644 index 0000000000000..7afc948f97259 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Db/UpdaterTest.php @@ -0,0 +1,95 @@ +getMock('Mage_Core_Model_Config_Storage', array(), array(), '', false); + $storage->expects($this->any()) + ->method('getConfiguration') + ->will($this->returnValue($configuration)); + $modulesConfig = new Mage_Core_Model_Config_Modules($storage); + + // Data updates model + $updateCalls = $expectedUpdates ? 1 : 0; + $setupModel = $this->getMock('Mage_Core_Model_Resource_Setup', array(), array(), '', false); + $setupModel->expects($this->exactly($updateCalls)) + ->method('applyUpdates'); + $setupModel->expects($this->exactly($updateCalls)) + ->method('applyDataUpdates'); + + $factory = $this->getMock('Mage_Core_Model_Resource_SetupFactory', array(), array(), '', false); + $factory->expects($this->any()) + ->method('create') + ->will($this->returnValue($setupModel)); + + // Application state + $appState = $this->getMock('Mage_Core_Model_App_State', array(), array(), '', false); + $appState->expects($this->any()) + ->method('isInstalled') + ->will($this->returnValue(true)); + $appState->expects($this->any()) + ->method('getMode') + ->will($this->returnValue($appMode)); + $updater = new Mage_Core_Model_Db_Updater($modulesConfig, $factory, $appState); + + // Run and verify + $updater->updateScheme(); + $updater->updateData(); + } + + public static function updateSchemeAndDataConfigDataProvider() + { + $fixturePath = __DIR__ . '/_files/'; + return array( + 'updates (default config)' => array( + file_get_contents($fixturePath . 'config.xml'), + Mage_Core_Model_App_State::MODE_DEVELOPER, + true + ), + 'no updates when skipped' => array( + file_get_contents($fixturePath . 'config_skip_updates.xml'), + Mage_Core_Model_App_State::MODE_DEFAULT, + false + ), + 'updates when skipped, if in dev mode' => array( + file_get_contents($fixturePath . 'config_skip_updates.xml'), + Mage_Core_Model_App_State::MODE_DEVELOPER, + true + ), + 'skipped updates, even in dev mode' => array( + file_get_contents($fixturePath . 'config_skip_updates_even_in_dev_mode.xml'), + Mage_Core_Model_App_State::MODE_DEVELOPER, + false + ) + ); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Db/_files/config.xml b/dev/tests/unit/testsuite/Mage/Core/Model/Db/_files/config.xml new file mode 100644 index 0000000000000..6bf01ecdedb6a --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Db/_files/config.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Db/_files/config_skip_updates.xml b/dev/tests/unit/testsuite/Mage/Core/Model/Db/_files/config_skip_updates.xml new file mode 100644 index 0000000000000..c5244b872e9aa --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Db/_files/config_skip_updates.xml @@ -0,0 +1,37 @@ + + + + + + + + + + 1 + + diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Db/_files/config_skip_updates_even_in_dev_mode.xml b/dev/tests/unit/testsuite/Mage/Core/Model/Db/_files/config_skip_updates_even_in_dev_mode.xml new file mode 100644 index 0000000000000..009c84d9609c0 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Db/_files/config_skip_updates_even_in_dev_mode.xml @@ -0,0 +1,38 @@ + + + + + + + + + + 1 + 1 + + diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Design/Fallback/CachingProxyTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Design/Fallback/CachingProxyTest.php deleted file mode 100644 index e4053a3e33149..0000000000000 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Design/Fallback/CachingProxyTest.php +++ /dev/null @@ -1,157 +0,0 @@ -_tmpDir = TESTS_TEMP_DIR . DIRECTORY_SEPARATOR . 'fallback'; - mkdir($this->_tmpDir); - $this->_fallback = $this->getMock( - 'Mage_Core_Model_Design_Fallback', - array('getFile', 'getLocaleFile', 'getViewFile', 'getArea', 'getPackage', 'getTheme', 'getLocale'), - array(), - '', - false - ); - $this->_fallback->expects($this->any())->method('getArea')->will($this->returnValue('a')); - $this->_fallback->expects($this->any())->method('getPackage')->will($this->returnValue('p')); - $this->_fallback->expects($this->any())->method('getTheme')->will($this->returnValue('t')); - $this->_fallback->expects($this->any())->method('getLocale')->will($this->returnValue('l')); - $this->_model = new Mage_Core_Model_Design_Fallback_CachingProxy( - $this->_fallback, $this->_createFilesystem(), $this->_tmpDir, __DIR__, true - ); - } - - protected function tearDown() - { - Varien_Io_File::rmdirRecursive($this->_tmpDir); - } - - /** - * @expectedException InvalidArgumentException - */ - public function testConstructInvalidDir() - { - new Mage_Core_Model_Design_Fallback_CachingProxy($this->_fallback, $this->_createFilesystem(), $this->_tmpDir, - __DIR__ . '/invalid_dir'); - } - - public function testDestruct() - { - $this->_fallback->expects($this->once()) - ->method('getFile') - ->will($this->returnValue(__DIR__ . DIRECTORY_SEPARATOR . 'test.txt')); - $suffix = uniqid(); - $model = new Mage_Core_Model_Design_Fallback_CachingProxy( - $this->_fallback, - $this->_createFilesystem(), - $this->_tmpDir . DIRECTORY_SEPARATOR . $suffix, - __DIR__, - true - ); - $expectedFile = $this->_tmpDir . DIRECTORY_SEPARATOR . $suffix . DIRECTORY_SEPARATOR . 'a_t_l.ser'; - $model->getFile('does not matter'); - $this->assertFileNotExists($expectedFile); - unset($model); - $this->assertFileExists($expectedFile); - $contents = unserialize(file_get_contents($expectedFile)); - $this->assertContains('test.txt', $contents); - } - - /** - * @covers Mage_Core_Model_Design_Fallback_CachingProxy::getFile - * @covers Mage_Core_Model_Design_Fallback_CachingProxy::getLocaleFile - * @covers Mage_Core_Model_Design_Fallback_CachingProxy::getViewFile - */ - public function testProxyMethods() - { - $fileArg = 'file.txt'; - $moduleArg = 'module'; - $path = __DIR__ . DIRECTORY_SEPARATOR; - $this->_fallback->expects($this->once()) - ->method('getFile')->with($fileArg, $moduleArg)->will($this->returnValue("{$path}one")); - $this->_fallback->expects($this->once()) - ->method('getLocaleFile')->with($fileArg)->will($this->returnValue("{$path}two")); - $this->_fallback->expects($this->once()) - ->method('getViewFile')->with($fileArg, $moduleArg)->will($this->returnValue("{$path}three")); - - // Call each method twice to ensure the proxied method is called once - $this->assertEquals("{$path}one", $this->_model->getFile($fileArg, $moduleArg)); - $this->assertEquals("{$path}one", $this->_model->getFile($fileArg, $moduleArg)); - $this->assertEquals("{$path}two", $this->_model->getLocaleFile($fileArg)); - $this->assertEquals("{$path}two", $this->_model->getLocaleFile($fileArg)); - $this->assertEquals("{$path}three", $this->_model->getViewFile($fileArg, $moduleArg)); - $this->assertEquals("{$path}three", $this->_model->getViewFile($fileArg, $moduleArg)); - } - - /** - * Test that proxy caches published skin path, and further calls do not use fallback model - */ - public function testNotifyViewFilePublished() - { - $moduleArg = '...'; - $fixture = __DIR__ . DIRECTORY_SEPARATOR . uniqid(); - $anotherFixture = __DIR__ . DIRECTORY_SEPARATOR . uniqid(); - - $this->_fallback->expects($this->once())->method('getViewFile')->will($this->returnValue($fixture)); - $this->assertEquals($fixture, $this->_model->getViewFile('file.txt', $moduleArg)); - $this->assertSame( - $this->_model, $this->_model->setFilePathToMap($anotherFixture, 'file.txt', $moduleArg) - ); - $this->assertEquals($anotherFixture, $this->_model->getViewFile('file.txt', $moduleArg)); - } - - /** - * @return Magento_Filesystem - */ - protected function _createFilesystem() - { - return new Magento_Filesystem(new Magento_Filesystem_Adapter_Local()); - } -} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Design/Fallback/List/FileTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Design/Fallback/List/FileTest.php new file mode 100644 index 0000000000000..e9dfa7d8a62aa --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Design/Fallback/List/FileTest.php @@ -0,0 +1,42 @@ +getMock('Mage_Core_Model_Dir', array(), array(), '', false); + $model = new Mage_Core_Model_Design_Fallback_List_File($dirs); + + $method = new ReflectionMethod($model, '_getFallbackRules'); + $method->setAccessible(true); + $actualResult = $method->invoke($model); + $this->assertCount(2, $actualResult); + $this->assertInstanceOf('Mage_Core_Model_Design_Fallback_Rule_Theme', $actualResult[0]); + $this->assertInstanceOf('Mage_Core_Model_Design_Fallback_Rule_Simple', $actualResult[1]); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Design/Fallback/List/ListAbstractTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Design/Fallback/List/ListAbstractTest.php new file mode 100644 index 0000000000000..6f718de963e9f --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Design/Fallback/List/ListAbstractTest.php @@ -0,0 +1,73 @@ +_dirs = $this->getMock('Mage_Core_Model_Dir', array(), array(), '', false); + $this->_model = $this->getMockForAbstractClass('Mage_Core_Model_Design_Fallback_List_ListAbstract', + array($this->_dirs)); + } + + public function testConstructor() + { + $this->_model->expects($this->once())->method('_getFallbackRules'); + $this->_model->__construct($this->_dirs); + } + + public function testGetPatternDirs() + { + $ruleOne = $this->getMock('Mage_Core_Model_Design_Fallback_Rule_Simple', array('getPatternDirs'), array(), '', + false); + $ruleOne->expects($this->once()) + ->method('getPatternDirs') + ->will($this->returnValue(array(1))); + + $ruleTwo = $this->getMock('Mage_Core_Model_Design_Fallback_Rule_Simple', array('getPatternDirs'), array(), '', + false); + $ruleTwo->expects($this->once()) + ->method('getPatternDirs') + ->will($this->returnValue(array(2))); + + $rules = new ReflectionProperty($this->_model, '_rules'); + $rules->setAccessible(true); + $rules->setValue($this->_model, array($ruleOne, $ruleTwo)); + + $this->assertSame(array(1,2), $this->_model->getPatternDirs(array())); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Design/Fallback/List/LocaleTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Design/Fallback/List/LocaleTest.php new file mode 100644 index 0000000000000..63c6fb08aa97b --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Design/Fallback/List/LocaleTest.php @@ -0,0 +1,41 @@ +getMock('Mage_Core_Model_Dir', array(), array(), '', false); + $model = new Mage_Core_Model_Design_Fallback_List_Locale($dirs); + + $method = new ReflectionMethod($model, '_getFallbackRules'); + $method->setAccessible(true); + $actualResult = $method->invoke($model); + $this->assertCount(1, $actualResult); + $this->assertInstanceOf('Mage_Core_Model_Design_Fallback_Rule_Theme', $actualResult[0]); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Design/Fallback/List/ViewTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Design/Fallback/List/ViewTest.php new file mode 100644 index 0000000000000..784d689da2fd6 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Design/Fallback/List/ViewTest.php @@ -0,0 +1,44 @@ +getMock('Mage_Core_Model_Dir', array(), array(), '', false); + $model = new Mage_Core_Model_Design_Fallback_List_View($dirs); + + $method = new ReflectionMethod($model, '_getFallbackRules'); + $method->setAccessible(true); + $actualResult = $method->invoke($model); + $this->assertCount(4, $actualResult); + $this->assertInstanceOf('Mage_Core_Model_Design_Fallback_Rule_Theme', $actualResult[0]); + $this->assertInstanceOf('Mage_Core_Model_Design_Fallback_Rule_Simple', $actualResult[1]); + $this->assertInstanceOf('Mage_Core_Model_Design_Fallback_Rule_Simple', $actualResult[2]); + $this->assertInstanceOf('Mage_Core_Model_Design_Fallback_Rule_Simple', $actualResult[3]); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Design/Fallback/Rule/SimpleTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Design/Fallback/Rule/SimpleTest.php new file mode 100644 index 0000000000000..5b4d4fb1bf083 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Design/Fallback/Rule/SimpleTest.php @@ -0,0 +1,80 @@ + other text'); + $model->getPatternDirs(array()); + } + + /** + * @dataProvider getPatternDirsDataProvider + */ + public function testGetPatternDirs($pattern, $optionalParameter = null, $expectedResult = null) + { + $params = array( + 'optional_parameter' => $optionalParameter, + 'required_parameter' => 'required_parameter', + ); + $model = new Mage_Core_Model_Design_Fallback_Rule_Simple($pattern, array('optional_parameter')); + + $this->assertEquals( + $expectedResult, + $model->getPatternDirs($params) + ); + } + + public function getPatternDirsDataProvider() + { + $patternOptional = ' other text'; + $patternNoOptional = ' other text'; + + return array( + 'no optional param passed' => array( + $patternOptional, + null, + array() + ), + 'no optional param in pattern' => array( + $patternNoOptional, + 'optional_parameter', + array('required_parameter other text') + ), + 'optional params in pattern and passed' => array( + $patternOptional, + 'optional_parameter', + array('optional_parameter required_parameter other text') + ), + ); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Design/Fallback/Rule/ThemeTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Design/Fallback/Rule/ThemeTest.php new file mode 100644 index 0000000000000..1fd109e60af9a --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Design/Fallback/Rule/ThemeTest.php @@ -0,0 +1,131 @@ +getMock( + 'Mage_Core_Model_Design_Fallback_Rule_Simple', + array(), + array('pattern') + ); + + $model = new Mage_Core_Model_Design_Fallback_Rule_Theme(array($simpleRuleMockOne)); + $model->getPatternDirs(array()); + } + + public function testGetPatternDirs() + { + $parentThemePath = 'parent_package/parent_theme'; + $parentTheme = $this->getMock('Mage_Core_Model_Theme', array('getThemePath'), array(), '', false); + $parentTheme->expects($this->any()) + ->method('getThemePath') + ->will($this->returnValue($parentThemePath)); + + $themePath = 'package/theme'; + $theme = $this->getMock('Mage_Core_Model_Theme', array('getThemePath', 'getParentTheme'), array(), '', false); + $theme->expects($this->any()) + ->method('getThemePath') + ->will($this->returnValue($themePath)); + + $theme->expects($this->any()) + ->method('getParentTheme') + ->will($this->returnValue($parentTheme)); + + $patternOne = ' one'; + $patternTwo = ' two'; + + $mapOne = array( + array( + array('theme' => $theme, 'theme_path' => $theme->getThemePath()), + array('package/theme one') + ), + array( + array('theme' => $theme, 'theme_path' => $parentTheme->getThemePath()), + array('parent_package/parent_theme one') + ) + ); + + $mapTwo = array( + array( + array('theme' => $theme, 'theme_path' => $theme->getThemePath()), + array('package/theme two') + ), + array( + array('theme' => $theme, 'theme_path' => $parentTheme->getThemePath()), + array('parent_package/parent_theme two') + ) + ); + + $simpleRuleMockOne = $this->getMock( + 'Mage_Core_Model_Design_Fallback_Rule_Simple', + array('getPatternDirs'), + array($patternOne) + ); + + $simpleRuleMockTwo = $this->getMock( + 'Mage_Core_Model_Design_Fallback_Rule_Simple', + array('getPatternDirs'), + array($patternTwo) + ); + + $simpleRuleMockOne->expects($this->any()) + ->method('getPatternDirs') + ->will($this->returnValueMap($mapOne)); + + $simpleRuleMockTwo->expects($this->any()) + ->method('getPatternDirs') + ->will($this->returnValueMap($mapTwo)); + + $params = array('theme' => $theme); + $model = new Mage_Core_Model_Design_Fallback_Rule_Theme(array($simpleRuleMockOne, $simpleRuleMockTwo)); + + $expectedResult = array( + 'package/theme one', + 'package/theme two', + 'parent_package/parent_theme one', + 'parent_package/parent_theme two' + ); + + $this->assertEquals($expectedResult, $model->getPatternDirs($params)); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Design/FallbackTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Design/FallbackTest.php deleted file mode 100644 index d95b46dead044..0000000000000 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Design/FallbackTest.php +++ /dev/null @@ -1,651 +0,0 @@ -_getFileSystemMock($targetFile); - $objectManager = $this->_getObjectManagerMock(); - $dirs = $this->_getDirsMock(); - - $configModel = $this->getMock('Mage_Core_Model_Config', array('getModuleDir'), array(), '', false); - - $configModel->expects($this->any()) - ->method('getModuleDir') - ->will($this->returnValue($moduleDir)); - - $objectManager->expects($this->any()) - ->method('get') - ->with('Mage_Core_Model_Config') - ->will($this->returnValue($configModel)); - - $dirs->expects($this->any()) - ->method('getDir') - ->with(Mage_Core_Model_Dir::THEMES) - ->will($this->returnValue($designDir)); - - $data = array( - 'area' => 'area51', - 'locale' => 'en_EN', - 'themeModel' => $theme, - ); - - $fallback = new Mage_Core_Model_Design_Fallback($dirs, $objectManager, $filesystem, $data); - $filename = $fallback->getFile($file, $module); - - $this->assertEquals(str_replace('/', DIRECTORY_SEPARATOR, $expectedFileName), $filename); - } - - /** - * @return array - */ - public function getFileDataProvider() - { - $file = 'test.txt'; - $customizationPath = 'custom'; - $themePath = 'theme_path'; - $parentThemePath = 'parent_theme_path'; - - /** @var $parentTheme Mage_Core_Model_Theme */ - $parentTheme = $this->getMock('Mage_Core_Model_Theme', array('getThemePath'), array(), '', false); - $parentTheme->expects($this->any()) - ->method('getThemePath') - ->will($this->returnValue($parentThemePath)); - - /** @var $themeSimple Mage_Core_Model_Theme */ - $themeSimple = $this->getMock('Mage_Core_Model_Theme', null, array(), '', false); - - /** @var $themeCustomized Mage_Core_Model_Theme */ - $themeCustomized = $this->getMock('Mage_Core_Model_Theme', array('getCustomizationPath'), array(), '', false); - $themeCustomized->expects($this->any()) - ->method('getCustomizationPath') - ->will($this->returnValue($customizationPath)); - - /** @var $customizedPhysical Mage_Core_Model_Theme */ - $customizedPhysical = $this->getMock('Mage_Core_Model_Theme', - array('getCustomizationPath', 'getThemePath'), array(), '', false); - $customizedPhysical->expects($this->any()) - ->method('getCustomizationPath') - ->will($this->returnValue($customizationPath)); - $customizedPhysical->expects($this->any()) - ->method('getThemePath') - ->will($this->returnValue($themePath)); - - /** @var $themeInherited Mage_Core_Model_Theme */ - $themeInherited = $this->getMock('Mage_Core_Model_Theme', array('getParentTheme'), array(), '', false); - $themeInherited->expects($this->any()) - ->method('getParentTheme') - ->will($this->returnValue($parentTheme)); - - /** @var $themeComplicated Mage_Core_Model_Theme */ - $themeComplicated = $this->getMock('Mage_Core_Model_Theme', - array('getCustomizationPath', 'getThemePath', 'getParentTheme'), array(), '', false); - $themeComplicated->expects($this->any()) - ->method('getCustomizationPath') - ->will($this->returnValue($customizationPath)); - $themeComplicated->expects($this->any()) - ->method('getThemePath') - ->will($this->returnValue($themePath)); - $themeComplicated->expects($this->any()) - ->method('getParentTheme') - ->will($this->returnValue($parentTheme)); - - return array( - array($themeSimple, $file, 'module_view_dir/area51/test.txt', 'module_view_dir/area51/test.txt'), - array($themeSimple, $file, null, 'module_view_dir/area51/test.txt'), - array($themeCustomized, $file, 'custom/test.txt', 'custom/test.txt'), - array($themeCustomized, $file, 'module_view_dir/area51/test.txt', 'module_view_dir/area51/test.txt'), - array($themeCustomized, $file, null, 'module_view_dir/area51/test.txt'), - array($customizedPhysical, $file, 'custom/test.txt', 'custom/test.txt'), - array($customizedPhysical, $file, 'design_dir/area51/theme_path/test.txt', - 'design_dir/area51/theme_path/test.txt' - ), - array($customizedPhysical, $file, 'design_dir/area51/theme_path/Mage_Core11/test.txt', - 'design_dir/area51/theme_path/Mage_Core11/test.txt' - ), - array($customizedPhysical, $file, 'module_view_dir/area51/test.txt', - 'module_view_dir/area51/test.txt' - ), - array($customizedPhysical, $file, null, 'module_view_dir/area51/test.txt'), - array($themeInherited, $file, 'design_dir/area51/parent_theme_path/test.txt', - 'design_dir/area51/parent_theme_path/test.txt' - ), - array($themeInherited, $file, 'design_dir/area51/parent_theme_path/Mage_Core11/test.txt', - 'design_dir/area51/parent_theme_path/Mage_Core11/test.txt' - ), - array($themeInherited, $file, 'module_view_dir/area51/test.txt', 'module_view_dir/area51/test.txt'), - array($themeInherited, $file, null, 'module_view_dir/area51/test.txt'), - array($themeComplicated, $file, 'custom/test.txt', 'custom/test.txt'), - array($themeComplicated, $file, 'design_dir/area51/theme_path/test.txt', - 'design_dir/area51/theme_path/test.txt' - ), - array($themeComplicated, $file, 'design_dir/area51/parent_theme_path/test.txt', - 'design_dir/area51/parent_theme_path/test.txt' - ), - array($themeComplicated, $file, 'design_dir/area51/theme_path/Mage_Core11/test.txt', - 'design_dir/area51/theme_path/Mage_Core11/test.txt' - ), - array($themeComplicated, $file, 'design_dir/area51/parent_theme_path/Mage_Core11/test.txt', - 'design_dir/area51/parent_theme_path/Mage_Core11/test.txt' - ), - array($themeComplicated, $file, 'module_view_dir/area51/test.txt', 'module_view_dir/area51/test.txt'), - array($themeComplicated, $file, null, 'module_view_dir/area51/test.txt'), - ); - } - - /** - * @dataProvider getLocaleFileDataProvider - * @param Mage_Core_Model_Theme|PHPUnit_Framework_MockObject_MockObject $theme - * @param string $file - * @param string $targetFile - * @param string $expectedFileName - * @cover Mage_Core_Model_Design_Fallback::_fallback() - */ - public function testGetLocaleFile($theme, $file, $targetFile, $expectedFileName) - { - $designDir = 'design_dir'; - - $filesystem = $this->_getFileSystemMock($targetFile); - $objectManager = $this->_getObjectManagerMock(); - $dirs = $this->_getDirsMock(); - - $dirs->expects($this->any()) - ->method('getDir') - ->with(Mage_Core_Model_Dir::THEMES) - ->will($this->returnValue($designDir)); - - $data = array( - 'area' => 'area51', - 'locale' => 'en_EN', - 'themeModel' => $theme, - ); - - $fallback = new Mage_Core_Model_Design_Fallback($dirs, $objectManager, $filesystem, $data); - $filename = $fallback->getLocaleFile($file); - - $this->assertEquals(str_replace('/', DIRECTORY_SEPARATOR, $expectedFileName), $filename); - } - - /** - * @return array - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function getLocaleFileDataProvider() - { - $customizationPath = 'custom'; - $themePath = 'theme_path'; - $parentThemePath = 'parent_theme_path'; - $grandParentPath = 'grand_parent_theme_path'; - $file = 'test.txt'; - - // 0. Parent and grand parent themes - /** @var $parentTheme Mage_Core_Model_Theme */ - $parentTheme = $this->getMock('Mage_Core_Model_Theme', array('getThemePath'), array(), '', false); - $parentTheme->expects($this->any())->method('getThemePath')->will($this->returnValue($parentThemePath)); - - /** @var $grandParentTheme Mage_Core_Model_Theme */ - $grandParentTheme = $this->getMock('Mage_Core_Model_Theme', array('getThemePath'), array(), '', false); - $grandParentTheme->expects($this->any())->method('getThemePath')->will($this->returnValue($grandParentPath)); - - /** @var $parentThemeInherited Mage_Core_Model_Theme */ - $parentThemeInherited = $this->getMock('Mage_Core_Model_Theme', - array('getThemePath', 'getParentTheme'), array(), '', false); - $parentThemeInherited->expects($this->any())->method('getThemePath') - ->will($this->returnValue($parentThemePath)); - $parentThemeInherited->expects($this->any())->method('getParentTheme') - ->will($this->returnValue($grandParentTheme)); - - // 1. - /** @var $themeSimple Mage_Core_Model_Theme */ - $themeSimple = $this->getMock('Mage_Core_Model_Theme', null, array(), '', false); - - // 2. - /** @var $themeCustomized Mage_Core_Model_Theme */ - $themeCustomized = $this->getMock('Mage_Core_Model_Theme', array('getCustomizationPath'), array(), '', false); - $themeCustomized->expects($this->any())->method('getCustomizationPath') - ->will($this->returnValue($customizationPath)); - - // 3. - /** @var $customizedPhysical Mage_Core_Model_Theme */ - $customizedPhysical = $this->getMock('Mage_Core_Model_Theme', - array('getCustomizationPath', 'getThemePath'), array(), '', false); - $customizedPhysical->expects($this->any()) - ->method('getCustomizationPath') - ->will($this->returnValue($customizationPath)); - $customizedPhysical->expects($this->any()) - ->method('getThemePath') - ->will($this->returnValue($themePath)); - - // 4. - /** @var $themeInherited Mage_Core_Model_Theme */ - $themeInherited = $this->getMock('Mage_Core_Model_Theme', array('getParentTheme'), array(), '', false); - $themeInherited->expects($this->any())->method('getParentTheme')->will($this->returnValue($parentTheme)); - - // 5. - /** @var $themeComplicated Mage_Core_Model_Theme */ - $themeComplicated = $this->getMock('Mage_Core_Model_Theme', - array('getCustomizationPath', 'getThemePath', 'getParentTheme'), array(), '', false); - $themeComplicated->expects($this->any()) - ->method('getCustomizationPath') - ->will($this->returnValue($customizationPath)); - $themeComplicated->expects($this->any()) - ->method('getThemePath') - ->will($this->returnValue($themePath)); - $themeComplicated->expects($this->any()) - ->method('getParentTheme') - ->will($this->returnValue($parentTheme)); - - // 6. - /** @var $themeInheritedTwice Mage_Core_Model_Theme */ - $themeInheritedTwice = $this->getMock('Mage_Core_Model_Theme', array('getParentTheme'), array(), '', false); - $themeInheritedTwice->expects($this->any()) - ->method('getParentTheme') - ->will($this->returnValue($parentThemeInherited)); - - return array( - array($themeSimple, $file, null, ''), - array($themeCustomized, $file, 'custom/test.txt', 'custom/test.txt'), - array($themeCustomized, $file, null, 'custom/test.txt'), - array($customizedPhysical, $file, 'custom/test.txt', 'custom/test.txt'), - array($customizedPhysical, $file, 'design_dir/area51/theme_path/locale/en_EN/test.txt', - 'design_dir/area51/theme_path/locale/en_EN/test.txt' - ), - array($customizedPhysical, $file, null, 'design_dir/area51/theme_path/locale/en_EN/test.txt'), - array($themeInherited, $file, 'design_dir/area51/parent_theme_path/locale/en_EN/test.txt', - 'design_dir/area51/parent_theme_path/locale/en_EN/test.txt' - ), - array($themeInherited, $file, null, 'design_dir/area51/parent_theme_path/locale/en_EN/test.txt'), - array($themeComplicated, $file, 'custom/test.txt', 'custom/test.txt'), - array($themeComplicated, $file, 'design_dir/area51/theme_path/locale/en_EN/test.txt', - 'design_dir/area51/theme_path/locale/en_EN/test.txt' - ), - array($themeComplicated, $file, 'design_dir/area51/parent_theme_path/locale/en_EN/test.txt', - 'design_dir/area51/parent_theme_path/locale/en_EN/test.txt' - ), - array($themeComplicated, $file, null, 'design_dir/area51/parent_theme_path/locale/en_EN/test.txt'), - array($themeInheritedTwice, $file, 'design_dir/area51/parent_theme_path/locale/en_EN/test.txt', - 'design_dir/area51/parent_theme_path/locale/en_EN/test.txt' - ), - array($themeInheritedTwice, $file, 'design_dir/area51/grand_parent_theme_path/locale/en_EN/test.txt', - 'design_dir/area51/grand_parent_theme_path/locale/en_EN/test.txt' - ), - array($themeInheritedTwice, $file, null, 'design_dir/area51/grand_parent_theme_path/locale/en_EN/test.txt'), - ); - } - - /** - * @dataProvider getViewFileDataProvider - * @param Mage_Core_Model_Theme|PHPUnit_Framework_MockObject_MockObject $theme - * @param string $file - * @param string $targetFile - * @param string $expectedFileName - * @cover Mage_Core_Model_Design_Fallback::_fallback() - */ - public function testGetViewFile($theme, $file, $targetFile, $expectedFileName) - { - $designDir = 'design_dir'; - $moduleDir = 'module_view_dir'; - $jsDir = 'js_dir'; - $module = 'Mage_Core11'; - - $filesystem = $this->_getFileSystemMock($targetFile); - $objectManager = $this->_getObjectManagerMock(); - $dirs = $this->_getDirsMock(); - - $configModel = $this->getMock('Mage_Core_Model_Config', array('getModuleDir'), array(), '', false); - - $configModel->expects($this->any()) - ->method('getModuleDir') - ->with($this->equalTo('view'), $this->equalTo($module)) - ->will($this->returnValue($moduleDir)); - - $objectManager->expects($this->any()) - ->method('get') - ->with('Mage_Core_Model_Config') - ->will($this->returnValue($configModel)); - - $dirs->expects($this->at(0)) - ->method('getDir') - ->with(Mage_Core_Model_Dir::THEMES) - ->will($this->returnValue($designDir)); - - $dirs->expects($this->at(1)) - ->method('getDir') - ->with(Mage_Core_Model_Dir::PUB_LIB) - ->will($this->returnValue($jsDir)); - - $data = array( - 'area' => 'area51', - 'locale' => 'en_EN', - 'themeModel' => $theme, - ); - - $fallback = new Mage_Core_Model_Design_Fallback($dirs, $objectManager, $filesystem, $data); - $filename = $fallback->getViewFile($file, $module); - - $this->assertEquals(str_replace('/', DIRECTORY_SEPARATOR, $expectedFileName), $filename); - } - - /** - * @return array - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function getViewFileDataProvider() - { - $customizationPath = 'custom'; - $themePath = 'theme_path'; - $parentThemePath = 'parent_theme_path'; - $grandParentThemePath = 'grand_parent_theme_path'; - $file = 'test.txt'; - - // 0. Parent and grand parent themes - /** @var $parentTheme Mage_Core_Model_Theme */ - $parentTheme = $this->getMock('Mage_Core_Model_Theme', array('getThemePath'), array(), '', false); - $parentTheme->expects($this->any()) - ->method('getThemePath') - ->will($this->returnValue($parentThemePath)); - - /** @var $grandParentTheme Mage_Core_Model_Theme */ - $grandParentTheme = $this->getMock('Mage_Core_Model_Theme', array('getThemePath'), array(), '', false); - $grandParentTheme->expects($this->any()) - ->method('getThemePath') - ->will($this->returnValue($grandParentThemePath)); - - /** @var $parentThemeInherited Mage_Core_Model_Theme */ - $parentThemeInherited = $this->getMock('Mage_Core_Model_Theme', - array('getThemePath', 'getParentTheme'), array(), '', false); - $parentThemeInherited->expects($this->any()) - ->method('getThemePath') - ->will($this->returnValue($parentThemePath)); - $parentThemeInherited->expects($this->any()) - ->method('getParentTheme') - ->will($this->returnValue($grandParentTheme)); - - // 1. - /** @var $themeSimple Mage_Core_Model_Theme */ - $themeSimple = $this->getMock('Mage_Core_Model_Theme', null, array(), '', false); - - // 2. - /** @var $themeCustomized Mage_Core_Model_Theme */ - $themeCustomized = $this->getMock('Mage_Core_Model_Theme', array('getCustomizationPath'), array(), '', false); - $themeCustomized->expects($this->any()) - ->method('getCustomizationPath') - ->will($this->returnValue($customizationPath)); - - // 3. - /** @var $customizedPhysical Mage_Core_Model_Theme */ - $customizedPhysical = $this->getMock('Mage_Core_Model_Theme', - array('getCustomizationPath', 'getThemePath'), array(), '', false); - $customizedPhysical->expects($this->any()) - ->method('getCustomizationPath') - ->will($this->returnValue($customizationPath)); - $customizedPhysical->expects($this->any()) - ->method('getThemePath') - ->will($this->returnValue($themePath)); - - // 4. - /** @var $themeInherited Mage_Core_Model_Theme */ - $themeInherited = $this->getMock('Mage_Core_Model_Theme', array('getParentTheme'), array(), '', false); - $themeInherited->expects($this->any()) - ->method('getParentTheme') - ->will($this->returnValue($parentTheme)); - - // 5. - /** @var $themeComplicated Mage_Core_Model_Theme */ - $themeComplicated = $this->getMock('Mage_Core_Model_Theme', - array('getCustomizationPath', 'getThemePath', 'getParentTheme'), array(), '', false); - $themeComplicated->expects($this->any()) - ->method('getCustomizationPath') - ->will($this->returnValue($customizationPath)); - $themeComplicated->expects($this->any()) - ->method('getThemePath') - ->will($this->returnValue($themePath)); - $themeComplicated->expects($this->any()) - ->method('getParentTheme') - ->will($this->returnValue($parentTheme)); - - // 6. - /** @var $themeInheritedTwice Mage_Core_Model_Theme */ - $themeInheritedTwice = $this->getMock('Mage_Core_Model_Theme', array('getParentTheme'), array(), '', false); - $themeInheritedTwice->expects($this->any()) - ->method('getParentTheme') - ->will($this->returnValue($parentThemeInherited)); - - return array( - array($themeSimple, $file, 'module_view_dir/area51/locale/en_EN/test.txt', - 'module_view_dir/area51/locale/en_EN/test.txt' - ), - array($themeSimple, $file, 'module_view_dir/area51/test.txt', 'module_view_dir/area51/test.txt'), - array($themeSimple, $file, 'js_dir/test.txt', 'js_dir/test.txt'), - array($themeSimple, $file, null, 'js_dir/test.txt'), - array($themeCustomized, $file, 'custom/test.txt', 'custom/test.txt'), - array($themeCustomized, $file, 'module_view_dir/area51/locale/en_EN/test.txt', - 'module_view_dir/area51/locale/en_EN/test.txt' - ), - array($themeCustomized, $file, 'module_view_dir/area51/test.txt', 'module_view_dir/area51/test.txt'), - array($themeCustomized, $file, 'js_dir/test.txt', 'js_dir/test.txt'), - array($themeCustomized, $file, null, 'js_dir/test.txt'), - array($customizedPhysical, $file, 'custom/test.txt', 'custom/test.txt'), - array($customizedPhysical, $file, 'design_dir/area51/theme_path/locale/en_EN/test.txt', - 'design_dir/area51/theme_path/locale/en_EN/test.txt' - ), - array($customizedPhysical, $file, 'design_dir/area51/theme_path/test.txt', - 'design_dir/area51/theme_path/test.txt' - ), - array($customizedPhysical, $file, 'design_dir/area51/theme_path/locale/en_EN/Mage_Core11/test.txt', - 'design_dir/area51/theme_path/locale/en_EN/Mage_Core11/test.txt' - ), - array($customizedPhysical, $file, 'design_dir/area51/theme_path/Mage_Core11/test.txt', - 'design_dir/area51/theme_path/Mage_Core11/test.txt' - ), - array($customizedPhysical, $file, 'module_view_dir/area51/locale/en_EN/test.txt', - 'module_view_dir/area51/locale/en_EN/test.txt' - ), - array($customizedPhysical, $file, 'module_view_dir/area51/test.txt', - 'module_view_dir/area51/test.txt' - ), - array($customizedPhysical, $file, 'js_dir/test.txt', 'js_dir/test.txt'), - array($customizedPhysical, $file, null, 'js_dir/test.txt'), - array($themeInherited, $file, 'design_dir/area51/parent_theme_path/locale/en_EN/test.txt', - 'design_dir/area51/parent_theme_path/locale/en_EN/test.txt' - ), - array($themeInherited, $file, 'design_dir/area51/parent_theme_path/test.txt', - 'design_dir/area51/parent_theme_path/test.txt' - ), - array($themeInherited, $file, 'design_dir/area51/parent_theme_path/locale/en_EN/Mage_Core11/test.txt', - 'design_dir/area51/parent_theme_path/locale/en_EN/Mage_Core11/test.txt' - ), - array($themeInherited, $file, 'design_dir/area51/parent_theme_path/Mage_Core11/test.txt', - 'design_dir/area51/parent_theme_path/Mage_Core11/test.txt' - ), - array($themeInherited, $file, 'module_view_dir/area51/locale/en_EN/test.txt', - 'module_view_dir/area51/locale/en_EN/test.txt' - ), - array($themeInherited, $file, 'module_view_dir/area51/test.txt', 'module_view_dir/area51/test.txt'), - array($themeInherited, $file, 'js_dir/test.txt', 'js_dir/test.txt'), - array($themeInherited, $file, null, 'js_dir/test.txt'), - array($themeComplicated, $file, 'custom/test.txt', 'custom/test.txt'), - array($themeComplicated, $file, 'design_dir/area51/theme_path/locale/en_EN/test.txt', - 'design_dir/area51/theme_path/locale/en_EN/test.txt' - ), - array($themeComplicated, $file, 'design_dir/area51/theme_path/test.txt', - 'design_dir/area51/theme_path/test.txt'), - array($themeComplicated, $file, 'design_dir/area51/parent_theme_path/locale/en_EN/test.txt', - 'design_dir/area51/parent_theme_path/locale/en_EN/test.txt' - ), - array($themeComplicated, $file, 'design_dir/area51/parent_theme_path/test.txt', - 'design_dir/area51/parent_theme_path/test.txt' - ), - array($themeComplicated, $file, 'design_dir/area51/theme_path/locale/en_EN/Mage_Core11/test.txt', - 'design_dir/area51/theme_path/locale/en_EN/Mage_Core11/test.txt' - ), - array($themeComplicated, $file, 'design_dir/area51/theme_path/Mage_Core11/test.txt', - 'design_dir/area51/theme_path/Mage_Core11/test.txt' - ), - array($themeComplicated, $file, 'design_dir/area51/parent_theme_path/locale/en_EN/Mage_Core11/test.txt', - 'design_dir/area51/parent_theme_path/locale/en_EN/Mage_Core11/test.txt' - ), - array($themeComplicated, $file, 'design_dir/area51/parent_theme_path/Mage_Core11/test.txt', - 'design_dir/area51/parent_theme_path/Mage_Core11/test.txt' - ), - array($themeComplicated, $file, 'module_view_dir/area51/locale/en_EN/test.txt', - 'module_view_dir/area51/locale/en_EN/test.txt' - ), - array($themeComplicated, $file, 'module_view_dir/area51/test.txt', 'module_view_dir/area51/test.txt'), - array($themeComplicated, $file, 'js_dir/test.txt', 'js_dir/test.txt'), - array($themeComplicated, $file, null, 'js_dir/test.txt'), - array($themeInheritedTwice, $file, 'design_dir/area51/parent_theme_path/locale/en_EN/test.txt', - 'design_dir/area51/parent_theme_path/locale/en_EN/test.txt' - ), - array($themeInheritedTwice, $file, 'design_dir/area51/parent_theme_path/test.txt', - 'design_dir/area51/parent_theme_path/test.txt' - ), - array($themeInheritedTwice, $file, 'design_dir/area51/grand_parent_theme_path/locale/en_EN/test.txt', - 'design_dir/area51/grand_parent_theme_path/locale/en_EN/test.txt' - ), - array($themeInheritedTwice, $file, 'design_dir/area51/grand_parent_theme_path/test.txt', - 'design_dir/area51/grand_parent_theme_path/test.txt' - ), - array($themeInheritedTwice, $file, 'design_dir/area51/parent_theme_path/locale/en_EN/Mage_Core11/test.txt', - 'design_dir/area51/parent_theme_path/locale/en_EN/Mage_Core11/test.txt' - ), - array($themeInheritedTwice, $file, 'design_dir/area51/parent_theme_path/Mage_Core11/test.txt', - 'design_dir/area51/parent_theme_path/Mage_Core11/test.txt' - ), - array($themeInheritedTwice, $file, - 'design_dir/area51/grand_parent_theme_path/locale/en_EN/Mage_Core11/test.txt', - 'design_dir/area51/grand_parent_theme_path/locale/en_EN/Mage_Core11/test.txt' - ), - array($themeInheritedTwice, $file, 'design_dir/area51/grand_parent_theme_path/Mage_Core11/test.txt', - 'design_dir/area51/grand_parent_theme_path/Mage_Core11/test.txt' - ), - array($themeInheritedTwice, $file, 'module_view_dir/area51/locale/en_EN/test.txt', - 'module_view_dir/area51/locale/en_EN/test.txt' - ), - array($themeInheritedTwice, $file, 'module_view_dir/area51/test.txt', 'module_view_dir/area51/test.txt'), - array($themeInheritedTwice, $file, 'js_dir/test.txt', 'js_dir/test.txt'), - array($themeInheritedTwice, $file, null, 'js_dir/test.txt'), - ); - } - - /** - * @param array $data - * @return Mage_Core_Model_Config_Options|PHPUnit_Framework_MockObject_MockObject - */ - protected function _getOptionsMock(array $data) - { - /** @var $options Mage_Core_Model_Config_Options */ - $options = $this->getMock('Mage_Core_Model_Config_Options', - array('getDesignDir', 'getJsDir'), array(), '', false); - if (isset($data['designDir'])) { - $options->expects($this->any()) - ->method('getDesignDir') - ->will($this->returnValue($data['designDir'])); - } - if (isset($data['jsDir'])) { - $options->expects($this->any()) - ->method('getJsDir') - ->will($this->returnValue($data['jsDir'])); - } - - return $options; - } - - /** - * @param array $data - * @param array $methods - * @return Mage_Core_Model_Config|PHPUnit_Framework_MockObject_MockObject - */ - protected function _getAppConfigMock(array $data, $methods = array('getOptions')) - { - $options = $this->_getOptionsMock($data); - - /** @var $appConfig Mage_Core_Model_Config */ - $appConfig = $this->getMock('Mage_Core_Model_Config', $methods, array(), '', false); - $appConfig->expects($this->any()) - ->method('getOptions') - ->will($this->returnValue($options)); - - return $appConfig; - } - - /** - * @param string $targetFile - * @return Magento_Filesystem|PHPUnit_Framework_MockObject_MockObject - */ - protected function _getFileSystemMock($targetFile) - { - $targetFile = str_replace('/', DIRECTORY_SEPARATOR, $targetFile); - /** @var $filesystem Magento_Filesystem */ - $filesystem = $this->getMock('Magento_Filesystem', array('has'), array(), '', false); - $filesystem->expects($this->any()) - ->method('has') - ->will($this->returnCallback( - function ($tryFile) use ($targetFile) { - return ($tryFile == $targetFile); - } - )); - - return $filesystem; - } - - /** - * @return Magento_ObjectManager_Zend - */ - protected function _getObjectManagerMock() - { - /** @var $objectManager Magento_ObjectManager_Zend */ - $objectManager = $this->getMock('Magento_ObjectManager_Zend', array('get'), array(), '', false); - return $objectManager; - } - - /** - * @return Mage_Core_Model_Dir - */ - protected function _getDirsMock() - { - /** @var $dirs Mage_Core_Model_Dir */ - $dirs = $this->getMock('Mage_Core_Model_Dir', array('getDir'), array(), '', false); - return $dirs; - } -} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Design/FileResolution/Strategy/Fallback/CachingProxyTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Design/FileResolution/Strategy/Fallback/CachingProxyTest.php new file mode 100644 index 0000000000000..e4cee1e27cb99 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Design/FileResolution/Strategy/Fallback/CachingProxyTest.php @@ -0,0 +1,207 @@ +_tmpDir = TESTS_TEMP_DIR . DIRECTORY_SEPARATOR . 'fallback'; + mkdir($this->_tmpDir); + + $this->_fallback = $this->getMock( + 'Mage_Core_Model_Design_FileResolution_Strategy_Fallback', + array(), + array(), + '', + false + ); + + $this->_themeModel = PHPUnit_Framework_MockObject_Generator::getMock( + 'Mage_Core_Model_Theme', + array(), + array(), + '', + false, + false + ); + $this->_themeModel->expects($this->any()) + ->method('getId') + ->will($this->returnValue('t')); + + $this->_model = new Mage_Core_Model_Design_FileResolution_Strategy_Fallback_CachingProxy( + $this->_fallback, $this->_createFilesystem(), $this->_tmpDir, TESTS_TEMP_DIR, true + ); + } + + protected function tearDown() + { + Varien_Io_File::rmdirRecursive($this->_tmpDir); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testConstructInvalidDir() + { + $this->_model = new Mage_Core_Model_Design_FileResolution_Strategy_Fallback_CachingProxy( + $this->_fallback, $this->_createFilesystem(), $this->_tmpDir, TESTS_TEMP_DIR . '/invalid_dir' + ); + } + + public function testDestruct() + { + $this->_fallback->expects($this->once()) + ->method('getFile') + ->will($this->returnValue(TESTS_TEMP_DIR . DIRECTORY_SEPARATOR . 'test.txt')); + + $expectedFile = $this->_tmpDir . DIRECTORY_SEPARATOR . 'a_t_.ser'; + + $this->_model->getFile('a', $this->_themeModel, 'does not matter', 'Some_Module'); + $this->assertFileNotExists($expectedFile); + unset($this->_model); + $this->assertFileExists($expectedFile); + $contents = file_get_contents($expectedFile); + $this->assertContains('test.txt', $contents); + $this->assertContains('Some_Module', $contents); + } + + public function testDestructNoMapSaved() + { + $this->_fallback->expects($this->once()) + ->method('getFile') + ->will($this->returnValue(TESTS_TEMP_DIR . DIRECTORY_SEPARATOR . 'test.txt')); + $model = new Mage_Core_Model_Design_FileResolution_Strategy_Fallback_CachingProxy( + $this->_fallback, $this->_createFilesystem(), $this->_tmpDir, TESTS_TEMP_DIR, false + ); + + $unexpectedFile = $this->_tmpDir . DIRECTORY_SEPARATOR . 'a_t_.ser'; + + $model->getFile('a', $this->_themeModel, 'does not matter', 'Some_Module'); + unset($model); + $this->assertFileNotExists($unexpectedFile); + } + + /** + * @param string $method + * @param array $params + * @param string $expectedResult + * @dataProvider proxyMethodsDataProvider + * @covers Mage_Core_Model_Design_FileResolution_Strategy_Fallback_CachingProxy::getFile + * @covers Mage_Core_Model_Design_FileResolution_Strategy_Fallback_CachingProxy::getLocaleFile + * @covers Mage_Core_Model_Design_FileResolution_Strategy_Fallback_CachingProxy::getViewFile + */ + public function testProxyMethods($method, $params, $expectedResult) + { + $helper = new Magento_Test_Helper_ProxyTesting(); + $actualResult = $helper->invokeWithExpectations($this->_model, $this->_fallback, $method, $params, + $expectedResult); + $this->assertEquals($expectedResult, $actualResult); + } + + /** + * @return array + */ + public static function proxyMethodsDataProvider() + { + $themeModel = PHPUnit_Framework_MockObject_Generator::getMock( + 'Mage_Core_Model_Theme', + array(), + array(), + '', + false, + false + ); + + return array( + 'getFile' => array( + 'getFile', + array('area51', $themeModel, 'file.txt', 'Some_Module'), + TESTS_TEMP_DIR . DIRECTORY_SEPARATOR . 'fallback' . DIRECTORY_SEPARATOR . 'file.txt', + ), + 'getLocaleFile' => array( + 'getLocaleFile', + array('area51', $themeModel, 'sq_AL', 'file.txt'), + 'path/to/locale_file.txt', + ), + 'getViewFile' => array( + 'getViewFile', + array('area51', $themeModel, 'uk_UA', 'file.txt', 'Some_Module'), + 'path/to/view_file.txt', + ), + ); + } + + public function testSetViewFilePathToMap() + { + $materializedFilePath = TESTS_TEMP_DIR . DIRECTORY_SEPARATOR . 'path' . DIRECTORY_SEPARATOR . 'file.txt'; + + $result = $this->_model->setViewFilePathToMap('area51', $this->_themeModel, 'en_US', 'Some_Module', 'file.txt', + $materializedFilePath); + $this->assertEquals($this->_model, $result); + + $this->_fallback->expects($this->never()) + ->method('getViewFile'); + $result = $this->_model->getViewFile('area51', $this->_themeModel, 'en_US', 'file.txt', 'Some_Module'); + $this->assertEquals($materializedFilePath, $result); + } + + /** + * @return Magento_Filesystem + */ + protected function _createFilesystem() + { + return new Magento_Filesystem(new Magento_Filesystem_Adapter_Local()); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Design/FileResolution/Strategy/FallbackTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Design/FileResolution/Strategy/FallbackTest.php new file mode 100644 index 0000000000000..77efb4b24b09c --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Design/FileResolution/Strategy/FallbackTest.php @@ -0,0 +1,220 @@ +_objectManager = $this->getMock('Magento_ObjectManager'); + $this->_dirs = $this->getMock('Mage_Core_Model_Dir', array(), array(), '', false); + $this->_fallbackFile = + $this->getMock('Mage_Core_Model_Design_Fallback_List_File', array(), array($this->_dirs)); + $this->_fallbackLocale = + $this->getMock('Mage_Core_Model_Design_Fallback_List_Locale', array(), array($this->_dirs)); + $this->_fallbackViewFile = + $this->getMock('Mage_Core_Model_Design_Fallback_List_View', array(), array($this->_dirs)); + $this->_theme = $this->getMock('Mage_Core_Model_Theme', array(), array(), '', false); + } + + public function tearDown() + { + $this->_objectManager = null; + $this->_dirs = null; + $this->_fallbackFile = null; + $this->_fallbackLocale = null; + $this->_fallbackViewFile = null; + $this->_theme = null; + } + + /** + * @dataProvider getFileDataProvider + */ + public function testGetFile($fullModuleName, $namespace, $module, $targetFile, $expectedFileName) + { + $filesystem = $this->_getFileSystemMock($targetFile); + + $fallback = new Mage_Core_Model_Design_FileResolution_Strategy_Fallback($this->_objectManager, $filesystem, + $this->_dirs, $this->_fallbackFile, $this->_fallbackLocale, $this->_fallbackViewFile); + + $params = array('area' => 'area', 'theme' => $this->_theme, 'namespace' => $namespace, 'module' => $module); + + $this->_fallbackFile->expects($this->once()) + ->method('getPatternDirs') + ->with($params) + ->will($this->returnValue(array('found_folder', 'not_found_folder'))); + + $filename = $fallback->getFile('area', $this->_theme, 'file.txt', $fullModuleName); + + $this->assertEquals(str_replace('/', DIRECTORY_SEPARATOR, $expectedFileName), $filename); + } + + public function getFileDataProvider() + { + return array( + 'no module, file found' => array( + null, + null, + null, + 'found_folder/file.txt', + 'found_folder/file.txt', + ), + 'module, file found' => array( + 'Namespace_Module', + 'Namespace', + 'Module', + 'found_folder/file.txt', + 'found_folder/file.txt', + ), + 'no module, file not found' => array( + null, + null, + null, + null, + 'not_found_folder/file.txt', + ), + 'module, file not found' => array( + 'Namespace_Module', + 'Namespace', + 'Module', + null, + 'not_found_folder/file.txt', + ), + ); + } + + /** + * @dataProvider getLocaleFileDataProvider + */ + public function testGetLocaleFile($targetFile, $expectedFileName) + { + $filesystem = $this->_getFileSystemMock($targetFile); + + $fallback = new Mage_Core_Model_Design_FileResolution_Strategy_Fallback($this->_objectManager, $filesystem, + $this->_dirs, $this->_fallbackFile, $this->_fallbackLocale, $this->_fallbackViewFile); + + $params = array('area' => 'area', 'theme' => $this->_theme, 'locale' => 'locale'); + + $this->_fallbackLocale->expects($this->once()) + ->method('getPatternDirs') + ->with($params) + ->will($this->returnValue(array('found_folder', 'not_found_folder'))); + + $filename = $fallback->getLocaleFile('area', $this->_theme, 'locale', 'file.txt'); + + $this->assertEquals(str_replace('/', DIRECTORY_SEPARATOR, $expectedFileName), $filename); + } + + public function getLocaleFileDataProvider() + { + return array( + 'file found' => array( + 'found_folder/file.txt', + 'found_folder/file.txt', + ), + 'file not found' => array( + null, + 'not_found_folder/file.txt', + ) + ); + } + + /** + * @dataProvider getFileDataProvider + */ + public function testGetViewFile($fullModuleName, $namespace, $module, $targetFile, $expectedFileName) + { + $filesystem = $this->_getFileSystemMock($targetFile); + + $fallback = new Mage_Core_Model_Design_FileResolution_Strategy_Fallback($this->_objectManager, $filesystem, + $this->_dirs, $this->_fallbackFile, $this->_fallbackLocale, $this->_fallbackViewFile); + + $params = array('area' => 'area', 'theme' => $this->_theme, 'namespace' => $namespace, 'module' => $module, + 'locale' => 'locale'); + + $this->_fallbackViewFile->expects($this->once()) + ->method('getPatternDirs') + ->with($params) + ->will($this->returnValue(array('found_folder', 'not_found_folder'))); + + $filename = $fallback->getViewFile('area', $this->_theme, 'locale', 'file.txt', $fullModuleName); + + $this->assertEquals(str_replace('/', DIRECTORY_SEPARATOR, $expectedFileName), $filename); + } + + /** + * @param string $targetFile + * @return Magento_Filesystem|PHPUnit_Framework_MockObject_MockObject + */ + protected function _getFileSystemMock($targetFile) + { + $targetFile = str_replace('/', DIRECTORY_SEPARATOR, $targetFile); + /** @var $filesystem Magento_Filesystem */ + $filesystem = $this->getMock('Magento_Filesystem', array('has'), array(), '', false); + $filesystem->expects($this->any()) + ->method('has') + ->will($this->returnCallback( + function ($tryFile) use ($targetFile) { + return ($tryFile == $targetFile); + } + )); + + return $filesystem; + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Design/FileResolution/StrategyPoolTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Design/FileResolution/StrategyPoolTest.php new file mode 100644 index 0000000000000..2890726cb09b7 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Design/FileResolution/StrategyPoolTest.php @@ -0,0 +1,142 @@ +_objectManager = $this->getMock('Mage_Core_Model_ObjectManager', array(), array(), '', false); + $this->_appState = $this->getMock('Mage_Core_Model_App_State', array(), array(), '', false); + + $dirFilesystem = $this->getMock('Magento_Filesystem', array(), array(), '', false); + $dirFilesystem->expects($this->any()) + ->method('isDirectory') + ->will($this->returnValue(true)); + $dirFilesystem->expects($this->any()) + ->method('isWritable') + ->will($this->returnValue(true)); + $this->_dirs = new Mage_Core_Model_Dir($dirFilesystem, 'base_dir'); + + $this->_filesystem = $this->getMock('Magento_Filesystem', array(), array(), '', false); + + $config = $this->getMock('Mage_Core_Model_Config', array(), array(), '', false); + $config->expects($this->any()) + ->method('getNode') + ->with(Mage_Core_Model_Design_FileResolution_StrategyPool::XML_PATH_ALLOW_MAP_UPDATE) + ->will($this->returnValue('1')); + $this->_objectManager->expects($this->any()) + ->method('get') + ->with('Mage_Core_Model_Config') + ->will($this->returnValue($config)); + + $this->_model = new Mage_Core_Model_Design_FileResolution_StrategyPool($this->_objectManager, + $this->_appState, $this->_dirs, $this->_filesystem); + } + + /** + * Test, that strategy creation works and a strategy is returned. + * + * Do not test exact strategy returned, as it depends on configuration, which can be changed any time. + * + * @param string $mode + * @dataProvider getStrategyDataProvider + */ + public function testGetStrategy($mode) + { + $this->_appState->expects($this->exactly(3)) // 3 similar methods tested at once + ->method('getMode') + ->will($this->returnValue($mode)); + + $strategy = new StdClass; + $mapDir = 'base_dir/var/' . Mage_Core_Model_Design_FileResolution_StrategyPool::FALLBACK_MAP_DIR; + $mapDir = str_replace('/', DIRECTORY_SEPARATOR, $mapDir); + $map = array( + array( + 'Mage_Core_Model_Design_FileResolution_Strategy_Fallback_CachingProxy', + array( + 'mapDir' => $mapDir, + 'baseDir' => 'base_dir', + 'canSaveMap' => true + ), + $strategy + ), + array('Mage_Core_Model_Design_FileResolution_Strategy_Fallback', array(), $strategy), + ); + $this->_objectManager->expects($this->atLeastOnce()) + ->method('create') + ->will($this->returnValueMap($map)); + + // Test + $actual = call_user_func(array($this->_model, 'getFileStrategy')); + $this->assertSame($strategy, $actual); + + $actual = call_user_func(array($this->_model, 'getLocaleStrategy')); + $this->assertSame($strategy, $actual); + + $actual = call_user_func(array($this->_model, 'getViewStrategy')); + $this->assertSame($strategy, $actual); + } + + public static function getStrategyDataProvider() + { + return array( + 'default mode' => array( + Mage_Core_Model_App_State::MODE_DEFAULT + ), + 'production mode' => array( + Mage_Core_Model_App_State::MODE_PRODUCTION + ), + 'developer mode' => array( + Mage_Core_Model_App_State::MODE_DEVELOPER + ), + ); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Design/Package/ProxyTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Design/Package/ProxyTest.php new file mode 100644 index 0000000000000..c8b44cc897cf7 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Design/Package/ProxyTest.php @@ -0,0 +1,85 @@ +_objectManager = $this->getMock('Magento_ObjectManager'); + $this->_packageMock = $this->getMock('Mage_Core_Model_Design_Package', array(), array(), '', false); + $this->_objectManager->expects($this->once()) + ->method('get') + ->with('Mage_Core_Model_Design_Package') + ->will($this->returnValue($this->_packageMock)); + $this->_model = new Mage_Core_Model_Design_Package_Proxy($this->_objectManager); + } + + protected function tearDown() + { + $this->_objectManager = null; + $this->_model = null; + $this->_packageMock = null; + } + + public function testGetPublicFileUrl() + { + $this->_packageMock->expects($this->once()) + ->method('getPublicFileUrl') + ->with('file', true) + ->will($this->returnValue('return value')); + $this->assertSame('return value', $this->_model->getPublicFileUrl('file', true)); + } + + public function testGetPublicDir() + { + $this->_packageMock->expects($this->once()) + ->method('getPublicDir') + ->will($this->returnValue('return value')); + $this->assertSame('return value', $this->_model->getPublicDir()); + } + + public function testMergeFiles() + { + $this->_packageMock->expects($this->once()) + ->method('mergeFiles') + ->with(array('file1.css', 'file2.css'), 'css') + ->will($this->returnValue('return value')); + $this->assertSame('return value', $this->_model->mergeFiles(array('file1.css', 'file2.css'), 'css')); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Design/PackageFallbackTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Design/PackageFallbackTest.php index 0749e0b2275af..9f86250f90411 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Design/PackageFallbackTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Design/PackageFallbackTest.php @@ -36,17 +36,20 @@ class Mage_Core_Model_Design_PackageFallbackTest extends PHPUnit_Framework_TestC protected $_model; /** - * @var Mage_Core_Model_Design_Fallback|PHPUnit_Framework_MockObject_MockObject + * @var Mage_Core_Model_Design_FileResolution_StrategyPool|PHPUnit_Framework_MockObject_MockObject */ - protected $_fallback; + protected $_strategyPool; protected function setUp() { - $this->_model = $this->getMock('Mage_Core_Model_Design_Package', array('_updateParamDefaults', '_getFallback'), - array(), '', false - ); - $this->_fallback = $this->getMock('Mage_Core_Model_Design_Package_Fallback', - array('getFile', 'getLocaleFile', 'getViewFile') + $modulesReader = $this->getMock('Mage_Core_Model_Config_Modules_Reader', array(), array(), '', array()); + $filesystem = $this->getMock('Magento_Filesystem', array(), array(), '', array()); + $this->_strategyPool = $this->getMock('Mage_Core_Model_Design_FileResolution_StrategyPool', array(), + array(), '', false); + $appState = new Mage_Core_Model_App_State(); + + $this->_model = $this->getMock('Mage_Core_Model_Design_Package', array('_updateParamDefaults'), + array($modulesReader, $filesystem, $this->_strategyPool, $appState) ); } @@ -54,22 +57,22 @@ public function testGetFilename() { $params = array( 'area' => 'some_area', - 'package' => 'some_package', - 'theme' => 'some_theme', + 'themeModel' => $this->getMock('Mage_Core_Model_Theme', array(), array(), '', false, false), ); $file = 'Some_Module::some_file.ext'; - $expectedParams = $params + array('module' => 'Some_Module'); $expected = 'path/to/some_file.ext'; - $this->_model->expects($this->once()) - ->method('_getFallback') - ->with($expectedParams) - ->will($this->returnValue($this->_fallback)); - $this->_fallback->expects($this->once()) + $strategyMock = $this->getMock('Mage_Core_Model_Design_FileResolution_Strategy_FileInterface'); + $strategyMock->expects($this->once()) ->method('getFile') - ->with('some_file.ext', 'Some_Module') + ->with($params['area'], $params['themeModel'], 'some_file.ext', 'Some_Module') ->will($this->returnValue($expected)); + $this->_strategyPool->expects($this->once()) + ->method('getFileStrategy') + ->with(false) + ->will($this->returnValue($strategyMock)); + $actual = $this->_model->getFilename($file, $params); $this->assertEquals($expected, $actual); } @@ -78,22 +81,23 @@ public function testGetLocaleFileName() { $params = array( 'area' => 'some_area', - 'package' => 'some_package', - 'theme' => 'some_theme', + 'themeModel' => $this->getMock('Mage_Core_Model_Theme', array(), array(), '', false, false), 'locale' => 'some_locale' ); $file = 'some_file.ext'; $expected = 'path/to/some_file.ext'; - $this->_model->expects($this->once()) - ->method('_getFallback') - ->with($params) - ->will($this->returnValue($this->_fallback)); - $this->_fallback->expects($this->once()) + $strategyMock = $this->getMock('Mage_Core_Model_Design_FileResolution_Strategy_LocaleInterface'); + $strategyMock->expects($this->once()) ->method('getLocaleFile') - ->with('some_file.ext') + ->with($params['area'], $params['themeModel'], $params['locale'], 'some_file.ext') ->will($this->returnValue($expected)); + $this->_strategyPool->expects($this->once()) + ->method('getLocaleStrategy') + ->with(false) + ->will($this->returnValue($strategyMock)); + $actual = $this->_model->getLocaleFileName($file, $params); $this->assertEquals($expected, $actual); } @@ -102,23 +106,23 @@ public function testGetViewFile() { $params = array( 'area' => 'some_area', - 'package' => 'some_package', - 'theme' => 'some_theme', + 'themeModel' => $this->getMock('Mage_Core_Model_Theme', array(), array(), '', false, false), 'locale' => 'some_locale' ); $file = 'Some_Module::some_file.ext'; - $expectedParams = $params + array('module' => 'Some_Module'); $expected = 'path/to/some_file.ext'; - $this->_model->expects($this->once()) - ->method('_getFallback') - ->with($expectedParams) - ->will($this->returnValue($this->_fallback)); - $this->_fallback->expects($this->once()) + $strategyMock = $this->getMock('Mage_Core_Model_Design_FileResolution_Strategy_ViewInterface'); + $strategyMock->expects($this->once()) ->method('getViewFile') - ->with('some_file.ext', 'Some_Module') + ->with($params['area'], $params['themeModel'], $params['locale'], 'some_file.ext', 'Some_Module') ->will($this->returnValue($expected)); + $this->_strategyPool->expects($this->once()) + ->method('getViewStrategy') + ->with(false) + ->will($this->returnValue($strategyMock)); + $actual = $this->_model->getViewFile($file, $params); $this->assertEquals($expected, $actual); } diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Design/PackageTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Design/PackageTest.php new file mode 100644 index 0000000000000..8273c54ddb7f0 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Design/PackageTest.php @@ -0,0 +1,168 @@ +assertEquals($expected, $actual); + } + + /** + * @return array + */ + public static function getPublishedViewFileRelPathDataProvider() + { + return array( + 'no module' => array('a', 't', 'l', 'f', null, str_replace('/', DIRECTORY_SEPARATOR, 'a/t/f')), + 'with module' => array('a', 't', 'l', 'f', 'm', str_replace('/', DIRECTORY_SEPARATOR, 'a/t/m/f')), + ); + } + + /** + * @param Mage_Core_Model_Theme $themeModel + * @dataProvider getViewFileUrlProductionModeDataProvider + */ + public function testGetViewFileUrlProductionMode($themeModel) + { + $moduleReader = $this->getMock('Mage_Core_Model_Config_Modules_Reader', array(), array(), '', false); + + $filesystem = $this->getMock('Magento_Filesystem', array(), array(), '', false); + $filesystem->expects($this->never()) + ->method('isFile'); + $filesystem->expects($this->never()) + ->method('isDirectory'); + $filesystem->expects($this->never()) + ->method('read'); + $filesystem->expects($this->never()) + ->method('write'); + $filesystem->expects($this->never()) + ->method('copy'); + + $resolutionPool = $this->getMock('Mage_Core_Model_Design_FileResolution_StrategyPool', array(), array(), '', + false); + $appState = new Mage_Core_Model_App_State(Mage_Core_Model_App_State::MODE_PRODUCTION); + + // Create model to be tested + $expected = 'http://example.com/public_dir/a/t/m/file.js'; + $model = $this->getMock('Mage_Core_Model_Design_Package', array('getPublicDir', 'getPublicFileUrl'), + array($moduleReader, $filesystem, $resolutionPool, $appState)); + $model->expects($this->once()) + ->method('getPublicDir') + ->will($this->returnValue('public_dir')); + $model->expects($this->once()) + ->method('getPublicFileUrl') + ->with(str_replace('/', DIRECTORY_SEPARATOR, 'public_dir/a/t/m/file.js')) + ->will($this->returnValue($expected)); + + // Test + $actual = $model->getViewFileUrl('file.js', array('area' => 'a', 'themeModel' => $themeModel, 'locale' => 'l', + 'module' => 'm')); + $this->assertEquals($expected, $actual); + } + + /** + * @return array + */ + public static function getViewFileUrlProductionModeDataProvider() + { + $usualTheme = PHPUnit_Framework_MockObject_Generator::getMock( + 'Mage_Core_Model_Theme', + array(), + array(), + '', + false, + false + ); + $virtualTheme = clone $usualTheme; + $parentOfVirtualTheme = clone $usualTheme; + + $usualTheme->expects(new PHPUnit_Framework_MockObject_Matcher_InvokedCount(1)) + ->method('getThemePath') + ->will(new PHPUnit_Framework_MockObject_Stub_Return('t')); + + $parentOfVirtualTheme->expects(new PHPUnit_Framework_MockObject_Matcher_InvokedCount(1)) + ->method('getThemePath') + ->will(new PHPUnit_Framework_MockObject_Stub_Return('t')); + + $virtualTheme->expects(new PHPUnit_Framework_MockObject_Matcher_InvokedCount(1)) + ->method('getParentTheme') + ->will(new PHPUnit_Framework_MockObject_Stub_Return($parentOfVirtualTheme)); + + return array( + 'usual theme' => array( + $usualTheme + ), + 'virtual theme' => array( + $virtualTheme + ), + ); + } + + + /** + * @param string $mode + * @param bool $expected + * @dataProvider isMergingViewFilesAllowedDataProvider + */ + public function testIsMergingViewFilesAllowed($mode, $expected) + { + $moduleReader = $this->getMock('Mage_Core_Model_Config_Modules_Reader', array(), array(), '', false); + $filesystem = $this->getMock('Magento_Filesystem', array(), array(), '', false); + $appState = new Mage_Core_Model_App_State($mode); + $resolutionPool = $this->getMock('Mage_Core_Model_Design_FileResolution_StrategyPool', array(), array(), '', + false); + + $model = new Mage_Core_Model_Design_Package($moduleReader, $filesystem, $resolutionPool, $appState); + $actual = $model->isMergingViewFilesAllowed(); + $this->assertEquals($expected, $actual); + } + + /** + * @return array + */ + public static function isMergingViewFilesAllowedDataProvider() + { + return array( + 'default mode' => array(Mage_Core_Model_App_State::MODE_DEFAULT, true), + 'production mode' => array(Mage_Core_Model_App_State::MODE_PRODUCTION, false), + 'developer mode' => array(Mage_Core_Model_App_State::MODE_DEVELOPER, true), + ); + } + +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/EncryptionTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/EncryptionTest.php index cbf80642b90bf..b97d7109e4c75 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/EncryptionTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/EncryptionTest.php @@ -29,7 +29,7 @@ class Mage_Core_Model_EncryptionTest extends PHPUnit_Framework_TestCase */ public function testSetHelperGetHash($input) { - $objectManager = $this->getMock('Magento_ObjectManager_Zend', array('get'), array(), '', false); + $objectManager = $this->getMock('Magento_ObjectManager'); $objectManager->expects($this->once()) ->method('get') ->with($this->stringContains('Mage_Core_Helper_Data')) @@ -59,7 +59,7 @@ public function setHelperGetHashDataProvider() */ public function testSetHelperException() { - $objectManager = $this->getMock('Magento_ObjectManager_Zend', array(), array(), '', false); + $objectManager = $this->getMock('Magento_ObjectManager'); /** * @var Mage_Core_Model_Encryption */ diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/EntryPoint/HttpTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/EntryPoint/HttpTest.php deleted file mode 100644 index d9adc42643740..0000000000000 --- a/dev/tests/unit/testsuite/Mage/Core/Model/EntryPoint/HttpTest.php +++ /dev/null @@ -1,55 +0,0 @@ -_objectManagerMock = $this->getMock('Magento_ObjectManager'); - $this->_model = new Mage_Core_Model_EntryPoint_Http(__DIR__, array(), $this->_objectManagerMock); - } - - public function testHttpHandlerProcessesRequest() - { - $request = $this->getMock('Mage_Core_Controller_Request_Http', array(), array(), '', false); - $response = $this->getMock('Mage_Core_Controller_Response_Http', array(), array(), '', false); - $requestHandlerMock = $this->getMock('Magento_Http_HandlerInterface'); - $requestHandlerMock->expects($this->once())->method('handle')->with($request, $response); - $this->_objectManagerMock->expects($this->any())->method('get')->will($this->returnValueMap(array( - array('Mage_Core_Controller_Request_Http', array(), $request), - array('Mage_Core_Controller_Response_Http', array(), $response), - array('Magento_Http_Handler_Composite', array(), $requestHandlerMock), - ))); - $this->_model->processRequest(); - } -} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Layout/Argument/Handler/ObjectTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Layout/Argument/Handler/ObjectTest.php index 0fae95f8febf3..2cbac3e1b3d32 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Layout/Argument/Handler/ObjectTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Layout/Argument/Handler/ObjectTest.php @@ -42,7 +42,7 @@ class Mage_Core_Model_Layout_Argument_Handler_ObjectTest extends PHPUnit_Framewo protected function setUp() { - $this->_objectManagerMock = $this->getMock('Magento_ObjectManager_Zend', array('create'), array(), '', false); + $this->_objectManagerMock = $this->getMock('Magento_ObjectManager'); $this->_model = new Mage_Core_Model_Layout_Argument_Handler_Object($this->_objectManagerMock); } diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Layout/Argument/Handler/OptionsTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Layout/Argument/Handler/OptionsTest.php index a47769ab35738..88a7fe0fe15ff 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Layout/Argument/Handler/OptionsTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Layout/Argument/Handler/OptionsTest.php @@ -42,7 +42,7 @@ class Mage_Core_Model_Layout_Argument_Handler_OptionsTest extends PHPUnit_Framew protected function setUp() { - $this->_objectManagerMock = $this->getMock('Magento_ObjectManager_Zend', array('create'), array(), '', false); + $this->_objectManagerMock = $this->getMock('Magento_ObjectManager'); $this->_model = new Mage_Core_Model_Layout_Argument_Handler_Options($this->_objectManagerMock); } diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Layout/Argument/Handler/UrlTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Layout/Argument/Handler/UrlTest.php index 85667891cc196..51f2d18e2057c 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Layout/Argument/Handler/UrlTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Layout/Argument/Handler/UrlTest.php @@ -47,7 +47,7 @@ class Mage_Core_Model_Layout_Argument_Handler_UrlTest extends PHPUnit_Framework_ protected function setUp() { - $this->_objectManagerMock = $this->getMock('Magento_ObjectManager_Zend', array('create'), array(), '', false); + $this->_objectManagerMock = $this->getMock('Magento_ObjectManager'); $this->_urlModelMock = $this->getMock('Mage_Core_Model_Url', array(), array(), '', false); $this->_model = new Mage_Core_Model_Layout_Argument_Handler_Url($this->_objectManagerMock, $this->_urlModelMock diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Layout/Argument/HandlerFactoryTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Layout/Argument/HandlerFactoryTest.php index 639c2a0e3a53f..1ee5d333b7663 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Layout/Argument/HandlerFactoryTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Layout/Argument/HandlerFactoryTest.php @@ -42,7 +42,7 @@ class Mage_Core_Model_Layout_Argument_HandlerFactoryTest extends PHPUnit_Framewo protected function setUp() { - $this->_objectManagerMock = $this->getMock('Magento_ObjectManager_Zend', array('create'), array(), '', false); + $this->_objectManagerMock = $this->getMock('Magento_ObjectManager'); $this->_model = new Mage_Core_Model_Layout_Argument_HandlerFactory($this->_objectManagerMock); } diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Layout/Argument/UpdaterTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Layout/Argument/UpdaterTest.php index 848cdaad5a621..27534d9b4a014 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Layout/Argument/UpdaterTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Layout/Argument/UpdaterTest.php @@ -47,7 +47,7 @@ class Mage_Core_Model_Layout_Argument_UpdaterTest extends PHPUnit_Framework_Test protected function setUp() { - $this->_objectManagerMock = $this->getMock('Magento_ObjectManager_Zend', array('create'), array(), '', false); + $this->_objectManagerMock = $this->getMock('Magento_ObjectManager'); $this->_argUpdaterMock = $this->getMock('Mage_Core_Model_Layout_Argument_UpdaterInterface', array(), array(), '', false ); diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Layout/FactoryTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Layout/FactoryTest.php index 5c2bdf145dd99..831c7d40af094 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Layout/FactoryTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Layout/FactoryTest.php @@ -45,7 +45,7 @@ class Mage_Core_Model_Layout_FactoryTest extends PHPUnit_Framework_TestCase /** * ObjectManager mock for tests * - * @var Magento_ObjectManager + * @var PHPUnit_Framework_MockObject_MockObject */ protected $_objectManager; @@ -58,9 +58,7 @@ class Mage_Core_Model_Layout_FactoryTest extends PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManager = $this->getMock('Magento_ObjectManager_Zend', - array('hasSharedInstance', 'get', 'removeSharedInstance', 'create', 'addSharedInstance'), - array(), '', false); + $this->_objectManager = $this->getMock('Magento_ObjectManager'); $this->_model = new Mage_Core_Model_Layout_Factory($this->_objectManager); } @@ -69,104 +67,19 @@ public function testConstruct() $this->assertAttributeInstanceOf('Magento_ObjectManager', '_objectManager', $this->_model); } - public function testCreateLayoutRemoveSharedInstance() - { - $this->_arguments = array('area' => 'ArgumentArea'); - - $this->_objectManager->expects($this->once()) - ->method('hasSharedInstance') - ->with(self::CLASS_NAME) - ->will($this->returnValue(true)); - - $modelLayout = $this->getMock(self::CLASS_NAME, array('getArea'), array(), '', false); - - $this->_objectManager->expects($this->at(1)) - ->method('get') - ->with(self::CLASS_NAME) - ->will($this->returnValue($modelLayout)); - - $modelLayout->expects($this->any()) - ->method('getArea') - ->will($this->returnValue('TestArea')); - - $this->_objectManager->expects($this->once()) - ->method('removeSharedInstance') - ->with(self::CLASS_NAME); - - $newModelLayout = $this->getMock(self::CLASS_NAME, array(), array(), '', false); - - $this->_objectManager->expects($this->once()) - ->method('create') - ->with(self::CLASS_NAME, $this->_arguments, false) - ->will($this->returnValue($newModelLayout)); - - $this->_objectManager->expects($this->once()) - ->method('addSharedInstance') - ->with($newModelLayout, self::CLASS_NAME); - - $this->_objectManager->expects($this->at(5)) - ->method('get') - ->with(self::CLASS_NAME) - ->will($this->returnValue($newModelLayout)); - - $this->assertEquals($newModelLayout, $this->_model->createLayout($this->_arguments)); - } - public function testCreateLayoutNew() { $modelLayout = $this->getMock(self::CLASS_NAME, array(), array(), '', false); $this->_objectManager->expects($this->once()) - ->method('create') - ->with(self::CLASS_NAME, array(), false) - ->will($this->returnValue($modelLayout)); - - $this->_objectManager->expects($this->once()) - ->method('addSharedInstance') - ->with($modelLayout, self::CLASS_NAME); - - $this->_objectManager->expects($this->at(2)) - ->method('get') - ->with(self::CLASS_NAME) - ->will($this->returnValue($modelLayout)); - - $this->assertEquals($modelLayout, $this->_model->createLayout()); - } - - public function testCreateLayoutGetSharedInstance() - { - $this->_arguments = array('area' => 'TestArea'); + ->method('configure') + ->with(array(self::CLASS_NAME => array('parameters' => array('someParam' => 'someVal')))); $this->_objectManager->expects($this->once()) - ->method('hasSharedInstance') - ->with(self::CLASS_NAME) - ->will($this->returnValue(true)); - - $modelLayout = $this->getMock(self::CLASS_NAME, array('getArea'), array(), '', false); - - $this->_objectManager->expects($this->at(1)) - ->method('get') - ->with(self::CLASS_NAME) - ->will($this->returnValue($modelLayout)); - - $modelLayout->expects($this->any()) - ->method('getArea') - ->will($this->returnValue('TestArea')); - - $this->_objectManager->expects($this->never()) - ->method('removeSharedInstance'); - - $this->_objectManager->expects($this->never()) - ->method('create'); - - $this->_objectManager->expects($this->never()) - ->method('addSharedInstance'); - - $this->_objectManager->expects($this->at(2)) ->method('get') - ->with(self::CLASS_NAME) + ->with(Mage_Core_Model_Layout_Factory::CLASS_NAME) ->will($this->returnValue($modelLayout)); - $this->assertEquals($modelLayout, $this->_model->createLayout($this->_arguments)); + $this->assertEquals($modelLayout, $this->_model->createLayout(array('someParam' => 'someVal'))); } } diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Layout/UpdateTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Layout/UpdateTest.php index df4ed924d0ff2..83a230f54810f 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Layout/UpdateTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Layout/UpdateTest.php @@ -51,7 +51,7 @@ public function testBeforeSave() $helper = new Magento_Test_Helper_ObjectManager($this); /** @var $model Mage_Core_Model_Layout_Update */ - $model = $helper->getModel('Mage_Core_Model_Layout_Update', array('resource' => $resourceModel)); + $model = $helper->getObject('Mage_Core_Model_Layout_Update', array('resource' => $resourceModel)); $model->setId(0); // set any data to set _hasDataChanges flag $model->save(); diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/ObjectManager/ConfigTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/ObjectManager/ConfigTest.php deleted file mode 100644 index a618bb872e8ed..0000000000000 --- a/dev/tests/unit/testsuite/Mage/Core/Model/ObjectManager/ConfigTest.php +++ /dev/null @@ -1,55 +0,0 @@ -_model = new Mage_Core_Model_ObjectManager_Config($params); - } - - public function testConfigureInitializedObjectManager() - { - $configuration = $this->getMock('stdClass', array('asArray')); - $configuration->expects($this->any())->method('asArray')->will($this->returnValue(array('configuratorClass'))); - $configMock = $this->getMock('Mage_Core_Model_Config_Primary', array(), array(), '', false); - $configMock->expects($this->any())->method('getNode')->with($this->stringStartsWith('global')) - ->will($this->returnValue($configuration)); - $objectManagerMock = $this->getMock('Magento_ObjectManager'); - $objectManagerMock->expects($this->exactly(2))->method('setConfiguration'); - $objectManagerMock->expects($this->once())->method('get')->with('Mage_Core_Model_Config_Primary') - -> will($this->returnValue($configMock)); - $configuratorMock = $this->getMock('Magento_ObjectManager_Configuration'); - $configuratorMock->expects($this->once())->method('configure')->with($objectManagerMock); - $objectManagerMock->expects($this->once())->method('create')->with('configuratorClass') - ->will($this->returnValue($configuratorMock)); - $this->_model->configure($objectManagerMock); - } -} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/ObjectManagerTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/ObjectManagerTest.php deleted file mode 100644 index a8676fc2c1aa3..0000000000000 --- a/dev/tests/unit/testsuite/Mage/Core/Model/ObjectManagerTest.php +++ /dev/null @@ -1,39 +0,0 @@ -assertNull(Mage::getObjectManager()); - $configMock = $this->getMock('Magento_ObjectManager_Configuration'); - $configMock->expects($this->once()) - ->method('configure') - ->with($this->isInstanceOf('Mage_Core_Model_ObjectManager')); - $diMock = $this->getMock('Magento_Di'); - $imMock = $this->getMock('Magento_Di_InstanceManager'); - $diMock->expects($this->any())->method('instanceManager')->will($this->returnValue($imMock)); - $objectManager = new Mage_Core_Model_ObjectManager($configMock, __DIR__, $diMock); - $this->assertEquals($objectManager, Mage::getObjectManager()); - } -} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/ObserverTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/ObserverTest.php new file mode 100644 index 0000000000000..b8f5c3e8c2077 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/ObserverTest.php @@ -0,0 +1,133 @@ +_cacheFrontendMock = $this->getMockForAbstractClass('Magento_Cache_FrontendInterface'); + + $this->_frontendPoolMock = $this->getMock('Mage_Core_Model_Cache_Frontend_Pool', array(), array(), '', false); + $this->_frontendPoolMock + ->expects($this->any()) + ->method('valid') + ->will($this->onConsecutiveCalls(true, false)) + ; + $this->_frontendPoolMock + ->expects($this->any()) + ->method('current') + ->will($this->returnValue($this->_cacheFrontendMock)) + ; + + $this->_themeMock = $this->getMock('Mage_Core_Model_Theme', array('getFiles'), array(), '', false); + + $designPackageMock = $this->getMock( + 'Mage_Core_Model_Design_Package', array('getDesignTheme'), array(), '', false + ); + $designPackageMock + ->expects($this->any()) + ->method('getDesignTheme') + ->will($this->returnValue($this->_themeMock)) + ; + + $this->_assetsMock = $this->getMock('Mage_Core_Model_Page_Asset_Collection'); + + $this->_model = new Mage_Core_Model_Observer( + $this->_frontendPoolMock, $designPackageMock, new Mage_Core_Model_Page($this->_assetsMock) + ); + } + + protected function tearDown() + { + $this->_cacheFrontendMock = null; + $this->_frontendPoolMock = null; + $this->_themeMock = null; + $this->_assetsMock = null; + $this->_model = null; + } + + public function testCleanCache() + { + $cacheBackendMock = $this->getMockForAbstractClass('Zend_Cache_Backend_Interface'); + $cacheBackendMock + ->expects($this->once()) + ->method('clean') + ->with(Zend_Cache::CLEANING_MODE_OLD, array()) + ; + $this->_cacheFrontendMock + ->expects($this->once()) + ->method('getBackend') + ->will($this->returnValue($cacheBackendMock)) + ; + $cronScheduleMock = $this->getMock('Mage_Cron_Model_Schedule', array(), array(), '', false); + $this->_model->cleanCache($cronScheduleMock); + } + + public function testApplyThemeCustomization() + { + $asset = new Mage_Core_Model_Page_Asset_Remote('http://127.0.0.1/test.css'); + $file = $this->getMock('Mage_Core_Model_Theme_File', array('getAsset', 'getFilePath'), array(), '', false); + $file->expects($this->once()) + ->method('getAsset') + ->will($this->returnValue($asset)); + $file->expects($this->once()) + ->method('getFilePath') + ->will($this->returnValue('test.css')); + + $this->_themeMock->expects($this->once()) + ->method('getFiles') + ->will($this->returnValue(array($file))); + + $this->_assetsMock->expects($this->once()) + ->method('add') + ->with('test.css', $asset); + + $observer = new Varien_Event_Observer; + $this->_model->applyThemeCustomization($observer); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Page/Asset/CollectionTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Page/Asset/CollectionTest.php new file mode 100644 index 0000000000000..871e414d6a1e5 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Page/Asset/CollectionTest.php @@ -0,0 +1,83 @@ +_object = new Mage_Core_Model_Page_Asset_Collection(); + $this->_asset = new Mage_Core_Model_Page_Asset_Remote('http://127.0.0.1/magento/test.css'); + $this->_object->add('asset', $this->_asset); + } + + public function testAdd() + { + $assetNew = new Mage_Core_Model_Page_Asset_Remote('http://127.0.0.1/magento/test.js'); + $this->_object->add('asset_new', $assetNew); + $this->assertSame(array('asset' => $this->_asset, 'asset_new' => $assetNew), $this->_object->getAll()); + } + + public function testHas() + { + $this->assertTrue($this->_object->has('asset')); + $this->assertFalse($this->_object->has('non_existing_asset')); + } + + public function testAddSameInstance() + { + $this->_object->add('asset_clone', $this->_asset); + $this->assertSame(array('asset' => $this->_asset, 'asset_clone' => $this->_asset), $this->_object->getAll()); + } + + public function testAddOverrideExisting() + { + $assetOverridden = new Mage_Core_Model_Page_Asset_Remote('http://127.0.0.1/magento/test_overridden.css'); + $this->_object->add('asset', $assetOverridden); + $this->assertSame(array('asset' => $assetOverridden), $this->_object->getAll()); + } + + public function testRemove() + { + $this->_object->remove('asset'); + $this->assertSame(array(), $this->_object->getAll()); + } + + public function testGetAll() + { + $this->assertSame(array('asset' => $this->_asset), $this->_object->getAll()); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Page/Asset/MergeServiceTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Page/Asset/MergeServiceTest.php new file mode 100644 index 0000000000000..e60ca88e3c89c --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Page/Asset/MergeServiceTest.php @@ -0,0 +1,173 @@ +_objectManager = $this->getMockForAbstractClass('Magento_ObjectManager', array('create')); + + $this->_storeConfig = $this->getMock('Mage_Core_Model_Store_Config', array('getConfigFlag')); + + $this->_isMergingAllowed = true; + $this->_designPackage = $this->getMock('Mage_Core_Model_Design_Package', array(), array(), '', false); + $this->_designPackage->expects($this->any()) + ->method('isMergingViewFilesAllowed') + ->will($this->returnCallback(array($this, 'isMergingAllowed'))); + + $this->_object = new Mage_Core_Model_Page_Asset_MergeService($this->_objectManager, $this->_storeConfig, + $this->_designPackage); + } + + /** + * Return whether currently merging is allowed by mock of design package + * + * @return bool + */ + public function isMergingAllowed() + { + return $this->_isMergingAllowed; + } + + /** + * @expectedException InvalidArgumentException + * @expectedExceptionMessage Merge for content type 'unknown' is not supported. + */ + public function testGetMergedAssetsWrongContentType() + { + $this->_object->getMergedAssets(array(), 'unknown'); + } + + /** + * @param array $assets + * @param string $contentType + * @dataProvider getMergedAssets + */ + public function testGetMergedAssetsMergeDisabled(array $assets, $contentType) + { + $this->assertSame($assets, $this->_object->getMergedAssets($assets, $contentType)); + } + + /** + * @param array $assets + * @param string $contentType + * @dataProvider getMergedAssets + */ + public function testGetMergedAssetsMergeDisabledBySystem(array $assets, $contentType, $storeConfigPath) + { + // Make sure we enable the js/css merging + $this->_storeConfig + ->expects($this->any()) + ->method('getConfigFlag') + ->will($this->returnValueMap(array( + array($storeConfigPath, null, true), + ))) + ; + + // Disable merging for whole system, which must overwrite settings for js/css + $this->_isMergingAllowed = false; + + // Test + $this->assertSame($assets, $this->_object->getMergedAssets($assets, $contentType)); + } + + /** + * @param array $assets + * @param string $contentType + * @param string $storeConfigPath + * @dataProvider getMergedAssets + */ + public function testGetMergedAssetsMergeEnabled(array $assets, $contentType, $storeConfigPath) + { + $mergedAsset = $this->getMock('Mage_Core_Model_Page_Asset_AssetInterface'); + $this->_storeConfig + ->expects($this->any()) + ->method('getConfigFlag') + ->will($this->returnValueMap(array( + array($storeConfigPath, null, true), + ))) + ; + $this->_objectManager + ->expects($this->once()) + ->method('create') + ->with('Mage_Core_Model_Page_Asset_Merged', array('assets' => $assets)) + ->will($this->returnValue($mergedAsset)) + ; + $this->assertSame(array($mergedAsset), $this->_object->getMergedAssets($assets, $contentType)); + } + + public function getMergedAssets() + { + $jsAssets = array( + new Mage_Core_Model_Page_Asset_Remote('http://127.0.0.1/magento/script_one.js'), + new Mage_Core_Model_Page_Asset_Remote('http://127.0.0.1/magento/script_two.js') + ); + $cssAssets = array( + new Mage_Core_Model_Page_Asset_Remote('http://127.0.0.1/magento/style_one.css'), + new Mage_Core_Model_Page_Asset_Remote('http://127.0.0.1/magento/style_two.css') + ); + return array( + 'js' => array( + $jsAssets, + Mage_Core_Model_Design_Package::CONTENT_TYPE_JS, + Mage_Core_Model_Page_Asset_MergeService::XML_PATH_MERGE_JS_FILES, + ), + 'css' => array( + $cssAssets, + Mage_Core_Model_Design_Package::CONTENT_TYPE_CSS, + Mage_Core_Model_Page_Asset_MergeService::XML_PATH_MERGE_CSS_FILES, + ), + ); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Page/Asset/MergedTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Page/Asset/MergedTest.php new file mode 100644 index 0000000000000..18db47fd924ee --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Page/Asset/MergedTest.php @@ -0,0 +1,144 @@ +_assetJsOne = $this->getMockForAbstractClass('Mage_Core_Model_Page_Asset_MergeableInterface'); + $this->_assetJsOne->expects($this->any())->method('getContentType')->will($this->returnValue('js')); + $this->_assetJsOne->expects($this->any())->method('getSourceFile')->will($this->returnValue('script_one.js')); + + $this->_assetJsTwo = $this->getMockForAbstractClass('Mage_Core_Model_Page_Asset_MergeableInterface'); + $this->_assetJsTwo->expects($this->any())->method('getContentType')->will($this->returnValue('js')); + $this->_assetJsTwo->expects($this->any())->method('getSourceFile')->will($this->returnValue('script_two.js')); + + $this->_designPackage = $this->getMock( + 'Mage_Core_Model_Design_Package', array('mergeFiles', 'getPublicFileUrl'), array(), '', false + ); + + $this->_coreHelper = $this->getMock('Mage_Core_Helper_Data', array('isStaticFilesSigned'), array(), '', false); + + $this->_filesystem = $this->getMock('Magento_Filesystem', array('getMTime'), array(), '', false); + + $this->_object = new Mage_Core_Model_Page_Asset_Merged( + $this->_designPackage, $this->_coreHelper, $this->_filesystem, array($this->_assetJsOne, $this->_assetJsTwo) + ); + } + + /** + * @expectedException InvalidArgumentException + * @expectedExceptionMessage At least one asset has to be passed for merging. + */ + public function testConstructorNothingToMerge() + { + $this->_object = new Mage_Core_Model_Page_Asset_Merged( + $this->_designPackage, $this->_coreHelper, $this->_filesystem, array() + ); + } + + /** + * @expectedException InvalidArgumentException + * @expectedExceptionMessage Asset has to implement Mage_Core_Model_Page_Asset_MergeableInterface. + */ + public function testConstructorRequireMergeInterface() + { + $assetUrl = new Mage_Core_Model_Page_Asset_Remote('http://example.com/style.css', 'css'); + $this->_object = new Mage_Core_Model_Page_Asset_Merged( + $this->_designPackage, $this->_coreHelper, $this->_filesystem, array($this->_assetJsOne, $assetUrl) + ); + } + + /** + * @expectedException InvalidArgumentException + * @expectedExceptionMessage Content type 'css' cannot be merged with 'js'. + */ + public function testConstructorIncompatibleContentTypes() + { + $assetCss = $this->getMockForAbstractClass('Mage_Core_Model_Page_Asset_MergeableInterface'); + $assetCss->expects($this->any())->method('getContentType')->will($this->returnValue('css')); + $assetCss->expects($this->any())->method('getSourceFile')->will($this->returnValue('style.css')); + + $this->_object = new Mage_Core_Model_Page_Asset_Merged( + $this->_designPackage, $this->_coreHelper, $this->_filesystem, array($this->_assetJsOne, $assetCss) + ); + } + + public function testGetUrl() + { + $url = 'http://127.0.0.1/magento/merged.js'; + $this->_designPackage + ->expects($this->at(0)) + ->method('mergeFiles') + ->with(array('script_one.js', 'script_two.js'), 'js') + ->will($this->returnValue('merged.js')) + ; + $this->_designPackage + ->expects($this->at(1)) + ->method('getPublicFileUrl') + ->with('merged.js') + ->will($this->returnValue($url)) + ; + $this->assertEquals($url, $this->_object->getUrl()); + $this->assertEquals($url, $this->_object->getUrl(), 'URL calculation should occur only once.'); + } + + public function testGetContentType() + { + $this->assertEquals('js', $this->_object->getContentType()); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Page/Asset/PublicFileTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Page/Asset/PublicFileTest.php new file mode 100644 index 0000000000000..02c8ee96e5be0 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Page/Asset/PublicFileTest.php @@ -0,0 +1,64 @@ +_designPackage = $this->getMock( + 'Mage_Core_Model_Design_Package', array('getPublicFileUrl'), array(), '', false + ); + $this->_object = new Mage_Core_Model_Page_Asset_PublicFile($this->_designPackage, 'test/style.css', 'css'); + } + + public function testGetUrl() + { + $url = 'http://127.0.0.1/magento/test/style.css'; + $this->_designPackage + ->expects($this->once()) + ->method('getPublicFileUrl') + ->with('test/style.css') + ->will($this->returnValue($url)) + ; + $this->assertEquals($url, $this->_object->getUrl()); + } + + public function testGetContentType() + { + $this->assertEquals('css', $this->_object->getContentType()); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Page/Asset/RemoteTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Page/Asset/RemoteTest.php new file mode 100644 index 0000000000000..e75c524effa42 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Page/Asset/RemoteTest.php @@ -0,0 +1,49 @@ +_object = new Mage_Core_Model_Page_Asset_Remote('https://127.0.0.1/magento/test/style.css', 'css'); + } + + public function testGetUrl() + { + $this->assertEquals('https://127.0.0.1/magento/test/style.css', $this->_object->getUrl()); + } + + public function testGetContentType() + { + $this->assertEquals('css', $this->_object->getContentType()); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Page/Asset/ViewFileTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Page/Asset/ViewFileTest.php new file mode 100644 index 0000000000000..85fb0d77d2cae --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Page/Asset/ViewFileTest.php @@ -0,0 +1,78 @@ +_designPackage = $this->getMock( + 'Mage_Core_Model_Design_Package', array('getViewFileUrl'), array(), '', false + ); + $this->_object = new Mage_Core_Model_Page_Asset_ViewFile($this->_designPackage, 'test/script.js', 'js'); + } + + /** + * @expectedException InvalidArgumentException + * @expectedExceptionMessage Parameter 'file' must not be empty + */ + public function testConstructorException() + { + new Mage_Core_Model_Page_Asset_ViewFile($this->_designPackage, '', 'unknown'); + } + + public function testGetUrl() + { + $url = 'http://127.0.0.1/magento/test/script.js'; + $this->_designPackage + ->expects($this->once()) + ->method('getViewFileUrl') + ->with('test/script.js') + ->will($this->returnValue($url)) + ; + $this->assertEquals($url, $this->_object->getUrl()); + } + + public function testGetContentType() + { + $this->assertEquals('js', $this->_object->getContentType()); + } + + public function testGetSourceFile() + { + $this->assertEquals('test/script.js', $this->_object->getSourceFile()); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/PageTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/PageTest.php new file mode 100644 index 0000000000000..b946dc9ca5b38 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/PageTest.php @@ -0,0 +1,56 @@ +_pageAssets = new Mage_Core_Model_Page_Asset_Collection; + $this->_object = new Mage_Core_Model_Page($this->_pageAssets); + } + + protected function tearDown() + { + $this->_pageAssets = null; + $this->_object = null; + } + + public function testGetAssets() + { + $this->assertSame($this->_pageAssets, $this->_object->getAssets()); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Store/Storage/DefaultTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Store/Storage/DefaultTest.php index a020be17fd241..408636ce02951 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Store/Storage/DefaultTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Store/Storage/DefaultTest.php @@ -78,10 +78,10 @@ protected function setUp() ->method('create') ->will($this->returnValue($this->_websiteMock)); $this->_groupFactoryMock = $this->getMock('Mage_Core_Model_Store_Group_Factory', - array('createFromArray'), array(), '', false, false); + array('create'), array(), '', false, false); $this->_groupFactoryMock ->expects($this->once()) - ->method('createFromArray') + ->method('create') ->will($this->returnValue($this->_groupMock)); $this->_storeMock = $this->getMock('Mage_Core_Model_Store', array('setId', 'setCode', 'getCode'), array(), '', false, false); diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Store/StorageFactoryTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Store/StorageFactoryTest.php index 568889d0e9dc1..56c9239b71a9f 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Store/StorageFactoryTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Store/StorageFactoryTest.php @@ -67,12 +67,12 @@ class Mage_Core_Model_Store_StorageFactoryTest extends PHPUnit_Framework_TestCas /** * @var string */ - protected $_defaultStorage = 'Default_Storage_Class_Name'; + protected $_defaultStorage = 'Mage_Core_Model_Store_Storage_Default'; /** * @var string */ - protected $_dbStorage = 'Db_Storage_Class_Name'; + protected $_dbStorage = 'Mage_Core_Model_Store_Storage_Db'; /** * @var array @@ -113,7 +113,7 @@ public function testGetInNotInstalledModeWithInternalCache() $this->_objectManagerMock ->expects($this->once()) - ->method('get') + ->method('create') ->with($this->_defaultStorage) ->will($this->returnValue($this->_storage)); @@ -147,7 +147,7 @@ public function testGetInstalledModeWithInternalCache() $this->_objectManagerMock ->expects($this->once()) - ->method('get') + ->method('create') ->with($this->_dbStorage) ->will($this->returnValue($this->_storage)); @@ -177,7 +177,7 @@ public function testGetWithInvalidStorageClassName() $this->_objectManagerMock ->expects($this->once()) - ->method('get') + ->method('create') ->with($this->_dbStorage) ->will($this->returnValue($invalidObject)); diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/StoreManagerTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/StoreManagerTest.php index 88396eed747ca..0dc1fbe194bec 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/StoreManagerTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/StoreManagerTest.php @@ -1,6 +1,6 @@ _model = $this->getMockForAbstractClass('Mage_Core_Model_Template', array( - $this->getMock('Mage_Core_Model_Event_Manager', array(), array(), '', false), - $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false), - array( - 'area' => Mage_Core_Model_App_Area::AREA_FRONTEND, - 'store' => 1 + $helper = new Magento_Test_Helper_ObjectManager($this); + $this->_model = $this->getMockForAbstractClass( + 'Mage_Core_Model_Template', + $helper->getConstructArguments( + 'Mage_Core_Model_Template', + array( + 'data' => array( + 'area' => Mage_Core_Model_App_Area::AREA_FRONTEND, + 'store' => 1 + ) + ) ) - )); + ); } /** diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Theme/CopyServiceTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Theme/CopyServiceTest.php new file mode 100644 index 0000000000000..e601b138f7b96 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Theme/CopyServiceTest.php @@ -0,0 +1,189 @@ +getMock('Mage_Core_Model_Theme_File', array('delete'), array(), '', false); + $sourceFileOne->setData(array( + 'file_path' => 'fixture_file_path_one', + 'file_type' => 'fixture_file_type_one', + 'content' => 'fixture_content_one', + 'sort_order' => 10, + )); + $sourceFileTwo = $this->getMock('Mage_Core_Model_Theme_File', array('delete'), array(), '', false); + $sourceFileTwo->setData(array( + 'file_path' => 'fixture_file_path_two', + 'file_type' => 'fixture_file_type_two', + 'content' => 'fixture_content_two', + 'sort_order' => 20, + )); + $this->_sourceFiles = array($sourceFileOne, $sourceFileTwo); + $this->_sourceTheme = $this->getMock( + 'Mage_Core_Model_Theme', array('getFiles', 'getCustomizationPath'), array(), '', false + ); + + $this->_targetFiles = array( + $this->getMock('Mage_Core_Model_Theme_File', array('delete'), array(), '', false), + $this->getMock('Mage_Core_Model_Theme_File', array('delete'), array(), '', false), + ); + $this->_targetTheme = $this->getMock( + 'Mage_Core_Model_Theme', array('getFiles', 'getCustomizationPath'), array(), '', false + ); + $this->_targetTheme->setId(123); + + $this->_objectManager = $this->getMockForAbstractClass('Magento_ObjectManager'); + $this->_filesystem = $this->getMock( + 'Magento_Filesystem', array('isDirectory', 'searchKeys', 'copy'), + array($this->getMockForAbstractClass('Magento_Filesystem_AdapterInterface')) + ); + $this->_object = new Mage_Core_Model_Theme_CopyService($this->_objectManager, $this->_filesystem); + } + + protected function tearDown() + { + $this->_object = null; + $this->_filesystem = null; + $this->_objectManager = null; + $this->_sourceTheme = null; + $this->_targetTheme = null; + $this->_sourceFiles = array(); + $this->_targetFiles = array(); + } + + public function testCopyDatabaseCustomization() + { + $this->_sourceTheme->expects($this->once())->method('getFiles')->will($this->returnValue($this->_sourceFiles)); + $this->_targetTheme->expects($this->once())->method('getFiles')->will($this->returnValue($this->_targetFiles)); + + foreach ($this->_targetFiles as $targetFile) { + $targetFile->expects($this->once())->method('delete'); + } + + $newFileOne = $this->getMock('Mage_Core_Model_Theme_File', array('setData', 'save'), array(), '', false); + $newFileTwo = $this->getMock('Mage_Core_Model_Theme_File', array('setData', 'save'), array(), '', false); + $newFileOne->expects($this->at(0))->method('setData')->with(array( + 'theme_id' => 123, + 'file_path' => 'fixture_file_path_one', + 'file_type' => 'fixture_file_type_one', + 'content' => 'fixture_content_one', + 'sort_order' => 10, + )); + $newFileOne->expects($this->at(1))->method('save'); + $newFileTwo->expects($this->at(0))->method('setData')->with(array( + 'theme_id' => 123, + 'file_path' => 'fixture_file_path_two', + 'file_type' => 'fixture_file_type_two', + 'content' => 'fixture_content_two', + 'sort_order' => 20, + )); + $newFileTwo->expects($this->at(1))->method('save'); + $this->_objectManager + ->expects($this->any()) + ->method('create') + ->with('Mage_Core_Model_Theme_File') + ->will($this->onConsecutiveCalls($newFileOne, $newFileTwo)) + ; + + $this->_object->copy($this->_sourceTheme, $this->_targetTheme); + } + + public function testCopyFilesystemCustomization() + { + $this->_sourceTheme->expects($this->once())->method('getFiles')->will($this->returnValue(array())); + $this->_targetTheme->expects($this->once())->method('getFiles')->will($this->returnValue(array())); + + $this->_sourceTheme + ->expects($this->once())->method('getCustomizationPath')->will($this->returnValue('source/path')); + + $this->_targetTheme + ->expects($this->once())->method('getCustomizationPath')->will($this->returnValue('target/path')); + + $this->_filesystem + ->expects($this->at(0))->method('isDirectory')->with('source/path')->will($this->returnValue(true)); + + $this->_filesystem + ->expects($this->once()) + ->method('searchKeys') + ->with('source/path', '*') + ->will($this->returnValue(array( + 'source/path/file_one.jpg', + 'source/path/file_two.png', + ))) + ; + + $expectedCopyEvents = array( + array('source/path/file_one.jpg', 'target/path/file_one.jpg', 'source/path', 'target/path'), + array('source/path/file_two.png', 'target/path/file_two.png', 'source/path', 'target/path'), + ); + $actualCopyEvents = array(); + $recordCopyEvent = function () use (&$actualCopyEvents) { + $actualCopyEvents[] = func_get_args(); + }; + $this->_filesystem->expects($this->any())->method('copy')->will($this->returnCallback($recordCopyEvent)); + + $this->_object->copy($this->_sourceTheme, $this->_targetTheme); + + $this->assertEquals($expectedCopyEvents, $actualCopyEvents); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Theme/Customization/Files/CssTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Theme/Customization/Files/CssTest.php index 7e0c02abf22c7..e1ce36efae6dd 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Theme/Customization/Files/CssTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Theme/Customization/Files/CssTest.php @@ -55,8 +55,8 @@ public function testSaveData() ->method('addData') ->with(array( 'theme_id' => $themeId, - 'file_path' => Mage_Core_Model_Theme_Customization_Files_Css::FILE_PATH, - 'file_type' => Mage_Core_Model_Theme_Files::TYPE_CSS, + 'file_path' => 'css/custom.css', + 'file_type' => Mage_Core_Model_Theme_File::TYPE_CSS, 'content' => $cssContent )) ->will($this->returnValue($cssFile)); @@ -71,19 +71,19 @@ public function testSaveData() $themeModel = $this->_getMockThemeModel($themeId); $modelCssFile = new Mage_Core_Model_Theme_Customization_Files_Css($filesModel); - $modelCssFile->setDataForSave($cssContent); + $modelCssFile->setDataForSave(array(Mage_Core_Model_Theme_Customization_Files_Css::CUSTOM_CSS => $cssContent)); $modelCssFile->saveData($themeModel); } /** * @param int $themeId - * @param Mage_Core_Model_Theme_Files $cssFile - * @return Mage_Core_Model_Resource_Theme_Files_Collection + * @param Mage_Core_Model_Theme_File $cssFile + * @return Mage_Core_Model_Resource_Theme_File_Collection */ protected function _getMockFilesCollection($themeId, $cssFile) { $filesCollection = $this->getMock( - 'Mage_Core_Model_Resource_Theme_Files_Collection', array('addFilter', 'getFirstItem'), array(), '', false + 'Mage_Core_Model_Resource_Theme_File_Collection', array('addFilter', 'getFirstItem'), array(), '', false ); $filesCollection ->expects($this->at(0)) @@ -93,7 +93,12 @@ protected function _getMockFilesCollection($themeId, $cssFile) $filesCollection ->expects($this->at(1)) ->method('addFilter') - ->with('file_type', Mage_Core_Model_Theme_Files::TYPE_CSS) + ->with('file_type', Mage_Core_Model_Theme_File::TYPE_CSS) + ->will($this->returnValue($filesCollection)); + $filesCollection + ->expects($this->at(2)) + ->method('addFilter') + ->with('file_path', 'css/custom.css') ->will($this->returnValue($filesCollection)); $filesCollection ->expects($this->once()) @@ -117,11 +122,11 @@ protected function _getMockThemeModel($return = null) } /** - * @return PHPUnit_Framework_MockObject_MockObject|Mage_Core_Model_Theme_Files + * @return PHPUnit_Framework_MockObject_MockObject|Mage_Core_Model_Theme_File */ protected function _getMockThemeFile() { - $filesModel = $this->getMock('Mage_Core_Model_Theme_Files', array( + $filesModel = $this->getMock('Mage_Core_Model_Theme_File', array( 'addData', 'save', 'getCollection' diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Theme/Customization/Files/JsTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Theme/Customization/Files/JsTest.php index e54ad5bd586cc..8f7f02a50711d 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Theme/Customization/Files/JsTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Theme/Customization/Files/JsTest.php @@ -118,11 +118,11 @@ protected function _getMockThemeModel($return = null) } /** - * @return PHPUnit_Framework_MockObject_MockObject|Mage_Core_Model_Theme_Files + * @return PHPUnit_Framework_MockObject_MockObject|Mage_Core_Model_Theme_File */ protected function _getMockThemeFile() { - $filesModel = $this->getMock('Mage_Core_Model_Theme_Files', array( + $filesModel = $this->getMock('Mage_Core_Model_Theme_File', array( 'load', 'getId', 'getThemeId', @@ -148,8 +148,8 @@ public function testSaveDataWithReordering(array $items, array $jsOrderData, arr $themeModel = $this->_getMockThemeModel($themeId); // 3. Get files collection mock - /** @var $collection Mage_Core_Model_Resource_Theme_Files_Collection */ - $collection = $this->getMock('Mage_Core_Model_Resource_Theme_Files_Collection', + /** @var $collection Mage_Core_Model_Resource_Theme_File_Collection */ + $collection = $this->getMock('Mage_Core_Model_Resource_Theme_File_Collection', array('addFilter', 'setDefaultOrder', 'load', 'save', 'getSize'), array(), '', false ); $this->_addItems($collection, $items); @@ -162,8 +162,8 @@ public function testSaveDataWithReordering(array $items, array $jsOrderData, arr ->will($this->returnSelf()); // 4. Get files model (storage) mock - /** @var $themeFiles Mage_Core_Model_Theme_Files */ - $themeFiles = $this->getMock('Mage_Core_Model_Theme_Files', array('getCollection'), array(), '', false); + /** @var $themeFiles Mage_Core_Model_Theme_File */ + $themeFiles = $this->getMock('Mage_Core_Model_Theme_File', array('getCollection'), array(), '', false); $themeFiles->expects($this->any()) ->method('getCollection') ->will($this->returnValue($collection)); @@ -249,7 +249,7 @@ public function saveDataWithReorderingDataProvider() /** * Set items to files collection * - * @param Mage_Core_Model_Resource_Theme_Files_Collection $collection + * @param Mage_Core_Model_Resource_Theme_File_Collection $collection * @param array $items */ protected function _addItems($collection, array $items) diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Theme/Domain/FactoryTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Theme/Domain/FactoryTest.php new file mode 100644 index 0000000000000..0e2f48dc39603 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Theme/Domain/FactoryTest.php @@ -0,0 +1,76 @@ +getMock('Mage_Core_Model_Theme', array('getType'), array(), '', false); + $themeMock->expects($this->any()) + ->method('getType') + ->will($this->returnValue(Mage_Core_Model_Theme::TYPE_PHYSICAL)); + + $newThemeMock = $this->getMock('Mage_Core_Model_Theme', array(), array(), '', false); + + $objectManager = $this->getMock('Magento_ObjectManager', array(), array('create'), '', false); + $objectManager->expects($this->once()) + ->method('create') + ->with('Mage_Core_Model_Theme_Domain_Physical', array('theme' => $themeMock)) + ->will($this->returnValue($newThemeMock)); + + $themeDomainFactory = new Mage_Core_Model_Theme_Domain_Factory($objectManager); + $this->assertEquals($newThemeMock, $themeDomainFactory->create($themeMock)); + } + + /** + * @covers Mage_Core_Model_Theme_Domain_Factory::create + */ + public function testCreateWithWrongThemeType() + { + $wrongThemeType = 'wrong_theme_type'; + $themeMock = $this->getMock('Mage_Core_Model_Theme', array('getType'), array(), '', false); + $themeMock->expects($this->any()) + ->method('getType') + ->will($this->returnValue($wrongThemeType)); + + $objectManager = $this->getMock('Magento_ObjectManager', array(), array('create'), '', false); + + $themeDomainFactory = new Mage_Core_Model_Theme_Domain_Factory($objectManager); + + $this->setExpectedException( + 'Mage_Core_Exception', + sprintf('Invalid type of theme domain model "%s"', $wrongThemeType) + ); + $themeDomainFactory->create($themeMock); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Theme/Domain/StagingTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Theme/Domain/StagingTest.php new file mode 100644 index 0000000000000..5b528ba03090e --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Theme/Domain/StagingTest.php @@ -0,0 +1,49 @@ +getMock('Mage_Core_Model_Theme', array(), array(), '', false, false); + + $theme = $this->getMock('Mage_Core_Model_Theme', array('getParentTheme'), array(), '', false, false); + $theme->expects($this->once())->method('getParentTheme')->will($this->returnValue($parentTheme)); + + $themeCopyService = $this->getMock('Mage_Core_Model_Theme_CopyService', array('copy'), array(), '', false); + $themeCopyService->expects($this->once())->method('copy')->with($theme, $parentTheme); + + $object = new Mage_Core_Model_Theme_Domain_Staging($theme, $themeCopyService); + $this->assertSame($object, $object->updateFromStagingTheme()); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Theme/Domain/VirtualTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Theme/Domain/VirtualTest.php new file mode 100644 index 0000000000000..d90abb1a13162 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Theme/Domain/VirtualTest.php @@ -0,0 +1,134 @@ +getMock('Mage_Core_Model_Theme', array(), array(), '', false, false); + + $theme = $this->getMock('Mage_Core_Model_Theme', array('getStagingVersion'), array(), '', false, false); + $theme->expects($this->once())->method('getStagingVersion')->will($this->returnValue($themeStaging)); + + $themeFactory = $this->getMock('Mage_Core_Model_Theme_Factory', array('create'), array(), '', false); + $themeFactory->expects($this->never())->method('create'); + + $themeCopyService = $this->getMock('Mage_Core_Model_Theme_CopyService', array('copy'), array(), '', false); + $themeCopyService->expects($this->never())->method('copy'); + + $service = $this->getMock('Mage_Core_Model_Theme_Service', array(), array(), '', false); + + $object = new Mage_Core_Model_Theme_Domain_Virtual($theme, $themeFactory, $themeCopyService, $service); + + $this->assertSame($themeStaging, $object->getStagingTheme()); + $this->assertSame($themeStaging, $object->getStagingTheme()); + } + + /** + * Test creating staging theme + * + * @covers Mage_Core_Model_Theme_Domain_Virtual::getStagingTheme + */ + public function testGetStagingThemeNew() + { + $theme = $this->getMock('Mage_Core_Model_Theme', array('getStagingVersion'), array(), '', false, false); + $theme->expects($this->once())->method('getStagingVersion')->will($this->returnValue(null)); + /** @var $theme Varien_Object */ + $theme->setData(array( + 'id' => 'fixture_theme_id', + 'theme_version' => 'fixture_theme_version', + 'theme_title' => 'fixture_theme_title', + 'preview_image' => 'fixture_preview_image', + 'magento_version_from' => 'fixture_magento_version_from', + 'magento_version_to' => 'fixture_magento_version_to', + 'is_featured' => 'fixture_is_featured', + 'area' => 'fixture_area', + 'type' => Mage_Core_Model_Theme::TYPE_VIRTUAL + )); + + $themeStaging = $this->getMock('Mage_Core_Model_Theme', array('setData', 'save'), array(), '', false, false); + $themeStaging->expects($this->at(0))->method('setData')->with(array( + 'parent_id' => 'fixture_theme_id', + 'theme_path' => null, + 'theme_version' => 'fixture_theme_version', + 'theme_title' => 'fixture_theme_title - Staging', + 'preview_image' => 'fixture_preview_image', + 'magento_version_from' => 'fixture_magento_version_from', + 'magento_version_to' => 'fixture_magento_version_to', + 'is_featured' => 'fixture_is_featured', + 'area' => 'fixture_area', + 'type' => Mage_Core_Model_Theme::TYPE_STAGING, + )); + $themeStaging->expects($this->at(1))->method('save'); + + $themeFactory = $this->getMock('Mage_Core_Model_Theme_Factory', array(), array(), '', false); + $themeFactory->expects($this->once())->method('create')->will($this->returnValue($themeStaging)); + + $themeCopyService = $this->getMock('Mage_Core_Model_Theme_CopyService', array('copy'), array(), '', false); + $themeCopyService->expects($this->once())->method('copy')->with($theme, $themeStaging); + + $service = $this->getMock('Mage_Core_Model_Theme_Service', array(), array(), '', false); + + $object = new Mage_Core_Model_Theme_Domain_Virtual($theme, $themeFactory, $themeCopyService, $service); + + $this->assertSame($themeStaging, $object->getStagingTheme()); + $this->assertSame($themeStaging, $object->getStagingTheme()); + } + + /** + * Test for is assigned method + * + * @covers Mage_Core_Model_Theme_Domain_Virtual::isAssigned + */ + public function testIsAssigned() + { + $themeServiceMock = $this->getMock('Mage_Core_Model_Theme_Service', array(), array(), '', false); + $themeMock = $this->getMock('Mage_Core_Model_Theme', array('getCollection', 'getId'), array(), '', false, + false); + $themeServiceMock->expects($this->atLeastOnce())->method('isThemeAssignedToStore') + ->with($themeMock) + ->will($this->returnValue(true)); + $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); + $constructArguments = $objectManagerHelper->getConstructArguments('Mage_Core_Model_Theme_Domain_Virtual', + array( + 'theme' => $themeMock, + 'service' => $themeServiceMock, + ) + ); + /** @var $model Mage_Core_Model_Theme_Domain_Virtual */ + $model = $objectManagerHelper->getObject('Mage_Core_Model_Theme_Domain_Virtual', $constructArguments); + $this->assertEquals(true, $model->isAssigned()); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Theme/ImageTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Theme/ImageTest.php index 8031a5ec0e1d1..3e623de20a70e 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Theme/ImageTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Theme/ImageTest.php @@ -36,7 +36,7 @@ class Mage_Core_Model_Theme_ImageTest extends PHPUnit_Framework_TestCase protected $_model; /** - * @var Magento_ObjectManager + * @var Magento_ObjectManager|PHPUnit_Framework_MockObject_MockObject */ protected $_objectManager; @@ -85,8 +85,8 @@ protected function _getDirMock() $dirMock = $this->getMock('Mage_Core_Model_Dir', array('getDir'), array(), '', false); $dirMock->expects($this->any()) ->method('getDir') - ->with($this->equalTo(Mage_Core_Model_Dir::THEME)) - ->will($this->returnValue('pub/media/theme')); + ->with($this->equalTo(Mage_Core_Model_Dir::MEDIA)) + ->will($this->returnValue('pub/media')); $this->_objectManager->expects($this->any()) ->method('get') ->with($this->equalTo('Mage_Core_Model_Dir')) @@ -100,21 +100,32 @@ public function testSavePreviewImage() $this->assertInstanceOf('Mage_Core_Model_Theme_Image', $this->_model->savePreviewImage()); } - public function testGetImagePathOrigin() + /** + * @return string + */ + public function testGetPreviewImageDirectoryUrl() { - $dirMock = $this->_getDirMock(); - $expectedResult = $dirMock->getDir(Mage_Core_Model_Dir::THEME) . DIRECTORY_SEPARATOR - . Mage_Core_Model_Theme_Image::IMAGE_DIR_ORIGIN; - - $this->assertEquals($expectedResult, $this->_model->getImagePathOrigin()); + $store = $this->getMock('Mage_Core_Model_Store', array('getBaseUrl'), array(), '', false); + $app = $this->getMock('Mage_Core_Model_App', array('getStore'), array(), '', false); + $app->expects($this->once())->method('getStore')->will($this->returnValue($store)); + $this->_objectManager->expects($this->once()) + ->method('get') + ->with('Mage_Core_Model_App') + ->will($this->returnValue($app)); + + $store->expects($this->once())->method('getBaseUrl') + ->with(Mage_Core_Model_Store::URL_TYPE_MEDIA)->will($this->returnValue('http://example.com/media/')); + $expectedValue = 'http://example.com/media/theme/preview/'; + $this->assertEquals($expectedValue, $this->_model->getPreviewImageDirectoryUrl()); + return $expectedValue; } public function testCreatePreviewImageCopy() { - $dirMock = $this->_getDirMock(); - $filePath = $dirMock->getDir(Mage_Core_Model_Dir::THEME) . DIRECTORY_SEPARATOR - . Mage_Core_Model_Theme_Image::IMAGE_DIR_PREVIEW; - $fileName = $filePath . DIRECTORY_SEPARATOR . 'image.jpg'; + $fileName = $this->_getDirMock()->getDir(Mage_Core_Model_Dir::MEDIA) + . DIRECTORY_SEPARATOR . 'theme' + . DIRECTORY_SEPARATOR . 'preview' + . DIRECTORY_SEPARATOR . 'image.jpg'; $this->_filesystem->expects($this->any()) ->method('copy') @@ -133,61 +144,30 @@ public function testCreatePreviewImageCopy() } /** - * @param string $previewImage - * @param string $defaultImage - * @param string $expectedResult - * @dataProvider getPreviewImageUrlProvider + * @depends testGetPreviewImageDirectoryUrl */ - public function testGetPreviewImageUrl($previewImage, $defaultImage, $expectedResult) + public function testGetPreviewImageUrl($previewDirUrl) { - if (null === $previewImage) { - $designMock = $this->_getDesignMock(); - $designMock->expects($this->any()) - ->method('getViewFileUrl') - ->with($this->equalTo($defaultImage)) - ->will($this->returnArgument(0)); - } else { - $storeMock = $this->getMock('Mage_Core_Model_Store', array('getBaseUrl'), array(), '', false); - $storeMock->expects($this->atLeastOnce()) - ->method('getBaseUrl') - ->with($this->equalTo(Mage_Core_Model_Store::URL_TYPE_MEDIA)) - ->will($this->returnArgument(0)); - - $appMock = $this->getMock('Mage_Core_Model_App', array('getStore'), array(), '', false); - $appMock->expects($this->atLeastOnce()) - ->method('getStore') - ->will($this->returnValue($storeMock)); - - $this->_objectManager->expects($this->any()) - ->method('get') - ->with($this->equalTo('Mage_Core_Model_App')) - ->will($this->returnValue($appMock)); - - $themeMock = $this->getMock('Mage_Core_Model_Theme', array('getPreviewImage'), array(), '', false); - $themeMock->expects($this->any()) - ->method('getPreviewImage') - ->will($this->returnValue($previewImage)); - $this->_model->setTheme($themeMock); - } - $this->assertEquals($expectedResult, $this->_model->getPreviewImageUrl()); + /** @var $model PHPUnit_Framework_MockObject_MockObject|Mage_Core_Model_Theme_Image */ + $model = $this->getMock( + 'Mage_Core_Model_Theme_Image', array('getPreviewImageDirectoryUrl'), array(), '', false + ); + $model->expects($this->once())->method('getPreviewImageDirectoryUrl')->will($this->returnValue($previewDirUrl)); + $theme = $this->getMock('Mage_Core_Model_Theme', array('getPreviewImage'), array(), '', false); + $theme->expects($this->exactly(2))->method('getPreviewImage')->will($this->returnValue('images/logo.gif')); + $model->setTheme($theme); + $this->assertEquals('http://example.com/media/theme/preview/images/logo.gif', $model->getPreviewImageUrl()); } - /** - * @return array - */ - public function getPreviewImageUrlProvider() + public function testGetPreviewImageUrlDefault() { - return array( - array( - null, - 'Mage_Core::theme/default_preview.jpg', - 'Mage_Core::theme/default_preview.jpg', - ), - array( - 'Mage_Core::theme/default_preview.jpg', - null, - 'mediatheme/preview/Mage_Core::theme/default_preview.jpg', - ), - ); + $theme = $this->getMock('Mage_Core_Model_Theme', array('getPreviewImage'), array(), '', false); + $theme->expects($this->once())->method('getPreviewImage')->will($this->returnValue(false)); + $expectedValue = 'http://example.com/pub/static/_module/Mage_Core/theme/default_preview.jpg'; + $designPackage = $this->_getDesignMock(); + $designPackage->expects($this->once())->method('getViewFileUrl')->with('Mage_Core::theme/default_preview.jpg') + ->will($this->returnValue($expectedValue)); + $this->_model->setTheme($theme); + $this->assertEquals($expectedValue, $this->_model->getPreviewImageUrl()); } } diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Theme/ServiceTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Theme/ServiceTest.php index a3b030ab0890e..975b2c499d770 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Theme/ServiceTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Theme/ServiceTest.php @@ -31,87 +31,109 @@ class Mage_Core_Model_Theme_ServiceTest extends PHPUnit_Framework_TestCase { /** - * @covers Mage_Core_Model_Theme_Service::isPresentCustomizedThemes - * @dataProvider isIsCustomizationsExistDataProvider - * @param array $availableIsVirtual - * @param bool $expectedResult + * @var PHPUnit_Framework_MockObject_MockObject */ - public function testIsCustomizationsExist($availableIsVirtual, $expectedResult) - { - $themeCollectionMock = array(); - foreach ($availableIsVirtual as $isVirtual) { - /** @var $themeItemMock Mage_Core_Model_Theme */ - $themeItemMock = $this->getMock('Mage_Core_Model_Theme', array('isVirtual'), array(), '', false); - $themeItemMock->expects($this->any()) - ->method('isVirtual') - ->will($this->returnValue($isVirtual)); - $themeCollectionMock[] = $themeItemMock; - } + protected $_themeMock; - /** @var $themeMock Mage_Core_Model_Theme */ - $themeMock = $this->getMock('Mage_Core_Model_Theme', array('getCollection'), array(), '', false); - $themeMock->expects($this->once()) - ->method('getCollection') - ->will($this->returnValue($themeCollectionMock)); + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_themeFactoryMock; - $themeFactoryMock = $this->getMock('Mage_Core_Model_Theme_Factory', array('create'), array(), '', false); - $themeFactoryMock->expects($this->any()) - ->method('create') - ->will($this->returnValue($themeMock)); + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_configCacheTypeMock; + + /** + * @var Mage_Core_Model_Theme_Service + */ + protected $_model; - $themeService = new Mage_Core_Model_Theme_Service($themeFactoryMock, + protected function setUp() + { + /** @var $this->_themeMock Mage_Core_Model_Theme */ + $this->_themeMock = $this->getMock('Mage_Core_Model_Theme', array(), array(), '', false); + $this->_themeFactoryMock = $this->getMock('Mage_Core_Model_Theme_Factory', array('create'), array(), '', false); + $this->_themeFactoryMock->expects($this->any()) + ->method('create') + ->will($this->returnValue($this->_themeMock)); + $this->_configCacheTypeMock = $this->getMock('Mage_Core_Model_Cache_Type_Config', array(), array(), '', false); + $this->_model = new Mage_Core_Model_Theme_Service( + $this->_themeFactoryMock, + $this->getMock('Mage_Core_Model_Theme_CopyService', array(), array(), '', false), $this->getMock('Mage_Core_Model_Design_Package', array(), array(), '', false), $this->getMock('Mage_Core_Model_App', array(), array(), '', false), $this->getMock('Mage_Core_Helper_Data', array(), array(), '', false), $this->getMock('Mage_DesignEditor_Model_Resource_Layout_Update', array(), array(), '', false), $this->getMock('Mage_Core_Model_Event_Manager', array(), array(), '', false), - $this->getMock('Mage_Core_Model_Config_Storage_WriterInterface', array(), array(), '', false) + $this->getMock('Mage_Core_Model_Config_Storage_WriterInterface', array(), array(), '', false), + $this->_configCacheTypeMock ); - $this->assertEquals($expectedResult, $themeService->isCustomizationsExist()); + } + + protected function tearDown() + { + $this->_themeMock = null; + $this->_themeFactoryMock = null; + $this->_configCacheTypeMock = null; + $this->_model = null; + } + + /** + * @dataProvider isCustomizationsExistDataProvider + * @param int $countVirtualThemes + * @param bool $expectedResult + */ + public function testIsCustomizationsExist($countVirtualThemes, $expectedResult) + { + $themeCollectionMock = $this->getMockBuilder('Mage_Core_Model_Resource_Theme_Collection') + ->disableOriginalConstructor() + ->setMethods(array('addTypeFilter', 'getSize')) + ->getMock(); + + $themeCollectionMock->expects($this->once()) + ->method('addTypeFilter') + ->with(Mage_Core_Model_Theme::TYPE_VIRTUAL) + ->will($this->returnValue($themeCollectionMock)); + + $themeCollectionMock->expects($this->once()) + ->method('getSize') + ->will($this->returnValue($countVirtualThemes)); + + $this->_themeMock->expects($this->once()) + ->method('getCollection') + ->will($this->returnValue($themeCollectionMock)); + + $this->assertEquals($expectedResult, $this->_model->isCustomizationsExist()); } /** * @return array */ - public function isIsCustomizationsExistDataProvider() + public function isCustomizationsExistDataProvider() { return array( - array(array(false, false, false), false), - array(array(false, true, false), true) + array(4, true), + array(0, false) ); } /** - * @covers Mage_Core_Model_Theme_Service::assignThemeToStores * @expectedException UnexpectedValueException * @expectedExceptionMessage Theme is not recognized. Requested id: -1 */ public function testAssignThemeToStoresWrongThemeId() { - /** @var $themeMock Mage_Core_Model_Theme */ - $themeMock = $this->getMock('Mage_Core_Model_Theme', array('load', 'getId'), array(), '', false); - $themeMock->expects($this->once()) + $this->_themeMock->expects($this->once()) ->method('load') ->with($this->equalTo(-1)) - ->will($this->returnValue($themeMock)); - - $themeMock->expects($this->once()) + ->will($this->returnValue($this->_themeMock)); + $this->_themeMock->expects($this->once()) ->method('getId') ->will($this->returnValue(false)); - $themeFactoryMock = $this->getMock('Mage_Core_Model_Theme_Factory', array('create'), array(), '', false); - $themeFactoryMock->expects($this->any()) - ->method('create') - ->will($this->returnValue($themeMock)); - $themeService = new Mage_Core_Model_Theme_Service($themeFactoryMock, - $this->getMock('Mage_Core_Model_Design_Package', array(), array(), '', false), - $this->getMock('Mage_Core_Model_App', array(), array(), '', false), - $this->getMock('Mage_Core_Helper_Data', array(), array(), '', false), - $this->getMock('Mage_DesignEditor_Model_Resource_Layout_Update', array(), array(), '', false), - $this->getMock('Mage_Core_Model_Event_Manager', array(), array(), '', false), - $this->getMock('Mage_Core_Model_Config_Storage_WriterInterface', array(), array(), '', false) - ); - $themeService->assignThemeToStores(-1); + $this->_model->assignThemeToStores(-1); } /** @@ -178,11 +200,13 @@ function ($area, $params) { ->will($this->returnValue($this->getMock('Mage_Core_Model_Theme', array(), array(), '', false))); $writerMock = $this->getMock('Mage_Core_Model_Config_Storage_WriterInterface', array(), array(), '', false); + $configCacheTypeMock = $this->getMock('Mage_Core_Model_Cache_Type_Config', array(), array(), '', false); + $copyServiceMock = $this->getMock('Mage_Core_Model_Theme_CopyService', array(), array(), '', false); /** @var $themeService Mage_Core_Model_Theme_Service */ - $themeService = $this->getMock('Mage_Core_Model_Theme_Service', array('_getThemeCustomizations'), - array($themeFactoryMock, $designMock, $appMock, $helperMock, - $layoutUpdateMock, $eventManagerMock, $writerMock) - ); + $themeService = $this->getMock('Mage_Core_Model_Theme_Service', array('_getThemeCustomizations'), array( + $themeFactoryMock, $copyServiceMock, $designMock, $appMock, $helperMock, $layoutUpdateMock, + $eventManagerMock, $writerMock, $configCacheTypeMock + )); $themeService->expects($this->once()) ->method('_getThemeCustomizations') ->will($this->returnValue($themesMock)); diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Theme/ValidationTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Theme/ValidationTest.php index e01c2b03858b9..24c0855a76e1e 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Theme/ValidationTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Theme/ValidationTest.php @@ -69,9 +69,12 @@ public function testValidateWithInvalidData() $themeMock = new Varien_Object(); $themeMock->setData($this->_getThemeInvalidData()); + /** @var $helper Mage_Core_Helper_Data */ + $helper = $this->getMockBuilder('Mage_Core_Helper_Data')->disableOriginalConstructor()->getMock(); + /** @var $validatorMock Mage_Core_Model_Theme_Validator */ $validatorMock = $this->getMock( - 'Mage_Core_Model_Theme_Validator', array('_setThemeValidators'), array(), '', true + 'Mage_Core_Model_Theme_Validator', array('_setThemeValidators'), array($helper), '', true ); $codeValidators = array( diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/ThemeTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/ThemeTest.php index 8265f055268f7..89d0cf4b4d047 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/ThemeTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/ThemeTest.php @@ -36,29 +36,50 @@ class Mage_Core_Model_ThemeTest extends PHPUnit_Framework_TestCase * @param bool $fromCollection * @param string $designDir * @param string $targetPath - * @return Mage_Core_Model_Theme + * @return Mage_Core_Model_Theme|PHPUnit_Framework_MockObject_MockObject */ protected function _getThemeModel($fromCollection = false, $designDir = '', $targetPath = '') { - /** @var $themeCollection Mage_Core_Model_Resource_Theme_Collection */ - $themeCollection = $this->getMock('Mage_Core_Model_Resource_Theme_Collection', array(), array(), '', false); + $objectManager = $this->getMock('Magento_ObjectManager', array(), array(), '', false); + $dirMock = $this->getMock('Mage_Core_Model_Dir', array(), array(), '', false); + $dirMock->expects($this->any()) + ->method('getDir') + ->will($this->returnArgument(0)); + $objectManager->expects($this->any()) + ->method('get') + ->with('Mage_Core_Model_Dir') + ->will($this->returnValue($dirMock)); + + /** @var $dirs Mage_Core_Model_Dir|PHPUnit_Framework_MockObject_MockObject */ + $dirs = $this->getMock('Mage_Core_Model_Dir', array('getDir'), array(), '', false); + + $dirs->expects($this->any()) + ->method('getDir') + ->will($this->returnArgument(0)); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); - $arguments = $objectManagerHelper->getConstructArguments( - Magento_Test_Helper_ObjectManager::MODEL_ENTITY, 'Mage_Core_Model_Theme', + $arguments = $objectManagerHelper->getConstructArguments('Mage_Core_Model_Theme', array( - 'objectManager' => $this->getMock('Magento_ObjectManager', array(), array(), '', false), - 'themeFactory' => $this->getMock('Mage_Core_Model_Theme_Factory', array(), array(), '', false), - 'helper' => $this->getMock('Mage_Core_Helper_Data', array(), array(), '', false), - 'themeImage' => $this->getMock('Mage_Core_Model_Theme_Image', array(), array(), '', false), - 'resource' => $this->getMock('Mage_Core_Model_Resource_Theme', array(), array(), '', false), - 'resourceCollection' => $themeCollection + 'objectManager' => $this->getMock('Magento_ObjectManager', array(), array(), '', false), + 'themeFactory' => $this->getMock('Mage_Core_Model_Theme_Factory', array(), array(), '', false), + 'helper' => $this->getMock('Mage_Core_Helper_Data', array(), array(), '', false), + 'themeImage' => $this->getMock('Mage_Core_Model_Theme_Image', array(), array(), '', false), + //domain factory + 'dirs' => $dirs, + 'resource' => $this->getMock('Mage_Core_Model_Resource_Theme', array(), array(), '', false), + 'resourceCollection' + => $this->getMock('Mage_Core_Model_Resource_Theme_Collection', array(), array(), '', false), ) ); /** @var $themeMock Mage_Core_Model_Theme */ $reflection = new \ReflectionClass('Mage_Core_Model_Theme'); $themeMock = $reflection->newInstanceArgs($arguments); + $objectManager->expects($this->any()) + ->method('create') + ->with('Mage_Core_Model_Theme') + ->will($this->returnValue($themeMock)); + if (!$fromCollection) { return $themeMock; } @@ -85,14 +106,9 @@ protected function _getThemeModel($fromCollection = false, $designDir = '', $tar ) )); - /** @var $collectionMock Mage_Core_Model_Theme_Collection|PHPUnit_Framework_MockObject_MockObject */ - $collectionMock = $this->getMock('Mage_Core_Model_Theme_Collection', array('getNewEmptyItem'), - array($filesystemMock)); - $collectionMock->expects($this->any()) - ->method('getNewEmptyItem') - ->will($this->returnValue($themeMock)); + $themeCollection = new Mage_Core_Model_Theme_Collection($filesystemMock, $objectManager, $dirMock); - return $collectionMock->setBaseDir($designDir)->addTargetPattern($targetPath)->getFirstItem(); + return $themeCollection->setBaseDir($designDir)->addTargetPattern($targetPath)->getFirstItem(); } /** @@ -102,7 +118,6 @@ protected function _getThemeModel($fromCollection = false, $designDir = '', $tar */ public function testLoadFromConfiguration() { - $this->markTestIncomplete('MAGETWO-5625'); $targetPath = implode(DIRECTORY_SEPARATOR, array('frontend', 'default', 'iphone', 'theme.xml')); $designDir = implode(DIRECTORY_SEPARATOR, array(__DIR__, '_files')); @@ -120,7 +135,6 @@ public function testLoadFromConfiguration() */ public function testLoadInvalidConfiguration() { - $this->markTestIncomplete('MAGETWO-5625'); $targetPath = implode(DIRECTORY_SEPARATOR, array('frontend', 'default', 'iphone', 'theme_invalid.xml')); $designDir = implode(DIRECTORY_SEPARATOR, array(__DIR__, '_files')); @@ -162,4 +176,228 @@ public function testSaveThemeCustomization() $themeMock->setCustomization($jsFile); $this->assertInstanceOf('Mage_Core_Model_Theme', $themeMock->saveThemeCustomization()); } + + /** + * @dataProvider isVirtualDataProvider + * @param int $type + * @param string $isVirtual + * @covers Mage_Core_Model_Theme::isVirtual + */ + public function testIsVirtual($type, $isVirtual) + { + /** @var $themeModel Mage_Core_Model_Theme */ + $themeModel = $this->getMock('Mage_Core_Model_Theme', null, array(), '', false); + $themeModel->setType($type); + $this->assertEquals($isVirtual, $themeModel->isVirtual()); + } + + /** + * @return array + */ + public function isVirtualDataProvider() + { + return array( + array('type' => Mage_Core_Model_Theme::TYPE_VIRTUAL, 'isVirtual' => true), + array('type' => Mage_Core_Model_Theme::TYPE_STAGING, 'isVirtual' => false), + array('type' => Mage_Core_Model_Theme::TYPE_PHYSICAL, 'isVirtual' => false) + ); + } + + /** + * @dataProvider isPhysicalDataProvider + * @param int $type + * @param string $isPhysical + * @covers Mage_Core_Model_Theme::isPhysical + */ + public function testIsPhysical($type, $isPhysical) + { + /** @var $themeModel Mage_Core_Model_Theme */ + $themeModel = $this->getMock('Mage_Core_Model_Theme', null, array(), '', false); + $themeModel->setType($type); + $this->assertEquals($isPhysical, $themeModel->isPhysical()); + } + + /** + * @return array + */ + public function isPhysicalDataProvider() + { + return array( + array('type' => Mage_Core_Model_Theme::TYPE_VIRTUAL, 'isPhysical' => false), + array('type' => Mage_Core_Model_Theme::TYPE_STAGING, 'isPhysical' => false), + array('type' => Mage_Core_Model_Theme::TYPE_PHYSICAL, 'isPhysical' => true) + ); + } + + /** + * @dataProvider isVisibleDataProvider + * @param int $type + * @param string $isVisible + * @covers Mage_Core_Model_Theme::isVisible + */ + public function testIsVisible($type, $isVisible) + { + /** @var $themeModel Mage_Core_Model_Theme */ + $themeModel = $this->getMock('Mage_Core_Model_Theme', null, array(), '', false); + $themeModel->setType($type); + $this->assertEquals($isVisible, $themeModel->isVisible()); + } + + /** + * @return array + */ + public function isVisibleDataProvider() + { + return array( + array('type' => Mage_Core_Model_Theme::TYPE_VIRTUAL, 'isVisible' => true), + array('type' => Mage_Core_Model_Theme::TYPE_STAGING, 'isVisible' => false), + array('type' => Mage_Core_Model_Theme::TYPE_PHYSICAL, 'isVisible' => true) + ); + } + + /** + * Test id deletable + * + * @dataProvider isDeletableDataProvider + * @param string $themeType + * @param bool $isDeletable + * @covers Mage_Core_Model_Theme::isDeletable + */ + public function testIsDeletable($themeType, $isDeletable) + { + /** @var $themeModel Mage_Core_Model_Theme */ + $themeModel = $this->getMock('Mage_Core_Model_Theme', array('getType'), array(), '', false); + $themeModel->expects($this->once()) + ->method('getType') + ->will($this->returnValue($themeType)); + $this->assertEquals($isDeletable, $themeModel->isDeletable()); + } + + /** + * @return array + */ + public function isDeletableDataProvider() + { + return array( + array(Mage_Core_Model_Theme::TYPE_VIRTUAL, true), + array(Mage_Core_Model_Theme::TYPE_STAGING, true), + array(Mage_Core_Model_Theme::TYPE_PHYSICAL, false) + ); + } + + public function testIsThemeCompatible() + { + /** @var $themeModel Mage_Core_Model_Theme */ + $themeModel = $this->getMock('Mage_Core_Model_Theme', null, array(), '', false); + + $themeModel->setMagentoVersionFrom('2.0.0.0')->setMagentoVersionTo('*'); + $this->assertFalse($themeModel->isThemeCompatible()); + + $themeModel->setMagentoVersionFrom('1.0.0.0')->setMagentoVersionTo('*'); + $this->assertTrue($themeModel->isThemeCompatible()); + } + + /** + * @dataProvider checkThemeCompatibleDataProvider + * @covers Mage_Core_Model_Theme::checkThemeCompatible + */ + public function testCheckThemeCompatible($versionFrom, $versionTo, $title, $resultTitle) + { + $helper = $this->getMockBuilder('Mage_Core_Helper_Data') + ->disableOriginalConstructor() + ->setMethods(array('__')) + ->getMock(); + $helper->expects($this->any()) + ->method('__') + ->will($this->returnValue(sprintf('%s (incompatible version)', $title))); + + $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); + $arguments = $objectManagerHelper->getConstructArguments('Mage_Core_Model_Theme', array( + 'helper' => $helper + )); + + /** @var $themeModel Mage_Core_Model_Theme */ + $themeModel = $this->getMock('Mage_Core_Model_Theme', null, $arguments); + $themeModel->setMagentoVersionFrom($versionFrom)->setMagentoVersionTo($versionTo)->setThemeTitle($title); + $themeModel->checkThemeCompatible(); + $this->assertEquals($resultTitle, $themeModel->getThemeTitle()); + } + + /** + * @return array + */ + public function checkThemeCompatibleDataProvider() + { + return array( + array('2.0.0.0', '*', 'Title', 'Title (incompatible version)'), + array('1.0.0.0', '*', 'Title', 'Title') + ); + } + + /** + * @dataProvider getThemeFilesPathDataProvider + * @param string $type + * @param string $expectedPath + */ + public function testGetThemeFilesPath($type, $expectedPath) + { + $theme = $this->_getThemeModel(); + $theme->setId(123); + $theme->setType($type); + $theme->setArea('area51'); + $theme->setThemePath('theme_path'); + + $this->assertEquals( + $expectedPath, + $theme->getThemeFilesPath() + ); + } + + /** + * @return array + */ + public function getThemeFilesPathDataProvider() + { + return array( + array(Mage_Core_Model_Theme::TYPE_PHYSICAL, 'design/area51/theme_path'), + array(Mage_Core_Model_Theme::TYPE_VIRTUAL, 'media/theme_customization/123'), + array(Mage_Core_Model_Theme::TYPE_STAGING, 'media/theme_customization/123'), + ); + } + + /** + * @param $customizationPath + * @param $themeId + * @param $expected + * @dataProvider getCustomViewConfigDataProvider + */ + public function testGetCustomViewConfigPath($customizationPath, $themeId, PHPUnit_Framework_Constraint $expected) + { + $themeMock = $this->_getThemeModel(); + $themeMock->setData('customization_path', $customizationPath); + $themeMock->setId($themeId); + $actual = $themeMock->getCustomViewConfigPath(); + $this->assertThat($actual, $expected); + } + + /** + * @return array + */ + public function getCustomViewConfigDataProvider() + { + return array( + 'no custom path, theme is not loaded' => array( + null, null, $this->isEmpty() + ), + 'no custom path, theme is loaded' => array( + null, 'theme_id', $this->equalTo('media/theme_customization/theme_id/view.xml') + ), + 'with custom path, theme is not loaded' => array( + 'custom/path', null, $this->equalTo('custom/path/view.xml') + ), + 'with custom path, theme is loaded' => array( + 'custom/path', 'theme_id', $this->equalTo('custom/path/view.xml') + ), + ); + } } diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Url/RewriteFactoryTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Url/RewriteFactoryTest.php index 0a4a4147dc7ab..3ebcbef3943e3 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Url/RewriteFactoryTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Url/RewriteFactoryTest.php @@ -44,15 +44,15 @@ class Mage_Core_Model_Url_RewriteFactoryTest extends PHPUnit_Framework_TestCase 'key' => 'value' ); - public function testCreateFromArray() + public function testCreate() { $objectManagerMock = $this->getMock('Magento_ObjectManager', array(), array(), '', false); $objectManagerMock->expects($this->once()) ->method('create') - ->with(self::EXPECTED_CLASS_NAME, $this->_arguments, false) + ->with(self::EXPECTED_CLASS_NAME, $this->_arguments) ->will($this->returnValue(self::CREATE_RESULT)); $factory = new Mage_Core_Model_Url_RewriteFactory($objectManagerMock); - $this->assertEquals(self::CREATE_RESULT, $factory->createFromArray($this->_arguments)); + $this->assertEquals(self::CREATE_RESULT, $factory->create($this->_arguments)); } } diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Validator/FactoryTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Validator/FactoryTest.php index cf00b7b130291..e8c05d034b142 100644 --- a/dev/tests/unit/testsuite/Mage/Core/Model/Validator/FactoryTest.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Validator/FactoryTest.php @@ -56,23 +56,22 @@ class Mage_Core_Model_Validator_FactoryTest extends PHPUnit_Framework_TestCase protected function setUp() { $this->_defaultTranslator = Magento_Validator_ValidatorAbstract::getDefaultTranslator(); - $this->_objectManager = $this->getMockBuilder('Magento_ObjectManager_Zend') - ->setMethods(array('create', 'get')) - ->disableOriginalConstructor() - ->getMock(); + $this->_objectManager = $this->getMock('Magento_ObjectManager'); $this->_validatorConfig = $this->getMockBuilder('Magento_Validator_Config') ->setMethods(array('createValidatorBuilder', 'createValidator')) ->disableOriginalConstructor() ->getMock(); - $this->_objectManager->expects($this->once()) - ->method('get') - ->with('Magento_Validator_Config', array('configFiles' => array('/tmp/moduleOne/etc/validation.xml'))) - ->will($this->returnValue($this->_validatorConfig)); + $this->_objectManager->expects($this->at(0)) ->method('create') ->with('Magento_Translate_Adapter') ->will($this->returnValue(new Magento_Translate_Adapter())); + $this->_objectManager->expects($this->at(1)) + ->method('create') + ->with('Magento_Validator_Config', array('configFiles' => array('/tmp/moduleOne/etc/validation.xml'))) + ->will($this->returnValue($this->_validatorConfig)); + // Config mock $this->_config = $this->getMockBuilder('Mage_Core_Model_Config_Modules_Reader') ->setMethods(array('getModuleConfigurationFiles')) diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/_files/cache_types.xml b/dev/tests/unit/testsuite/Mage/Core/Model/_files/cache_types.xml new file mode 100644 index 0000000000000..0c519712d7eee --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/_files/cache_types.xml @@ -0,0 +1,46 @@ + + + + + + + + + This is Fixture Type One + Magento_Cache_Frontend_Decorator_TagScope + + + + This is Fixture Type Two + Magento_Cache_Frontend_Decorator_Bare + + + + + diff --git a/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/ContainerTest.php b/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/ContainerTest.php index a6a031ccce106..0e315b5e689f8 100644 --- a/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/ContainerTest.php +++ b/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/ContainerTest.php @@ -75,7 +75,7 @@ public function testGetHeaderText() { $arguments = $this->_getBlockArguments(array('expectedTranslation' => 'Visual Design Editor')); /** @var $block Mage_DesignEditor_Block_Adminhtml_Editor_Container */ - $block = $this->_helper->getBlock('Mage_DesignEditor_Block_Adminhtml_Editor_Container', $arguments); + $block = $this->_helper->getObject('Mage_DesignEditor_Block_Adminhtml_Editor_Container', $arguments); $block->getHeaderText(); } @@ -90,7 +90,7 @@ public function testGetSetFrameUrl() ); /** @var $block Mage_DesignEditor_Block_Adminhtml_Editor_Container */ - $block = $this->_helper->getBlock('Mage_DesignEditor_Block_Adminhtml_Editor_Container', $arguments); + $block = $this->_helper->getObject('Mage_DesignEditor_Block_Adminhtml_Editor_Container', $arguments); $block->setFrameUrl(self::FRAME_URL); $this->assertAttributeEquals(self::FRAME_URL, '_frameUrl', $block); $this->assertEquals(self::FRAME_URL, $block->getFrameUrl()); @@ -107,7 +107,7 @@ public function testPrepareLayout() $arguments['eventManager'] = $eventManager; /** @var $block Mage_DesignEditor_Block_Adminhtml_Editor_Container */ - $block = $this->_helper->getBlock('Mage_DesignEditor_Block_Adminhtml_Editor_Container', $arguments); + $block = $this->_helper->getObject('Mage_DesignEditor_Block_Adminhtml_Editor_Container', $arguments); $layout = $this->getMock('Mage_Core_Model_Layout', array(), array(), '', false); $block->setLayout($layout); diff --git a/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/SaveTest.php b/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/SaveTest.php new file mode 100644 index 0000000000000..8fd2bd8a574d3 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/SaveTest.php @@ -0,0 +1,259 @@ +getMock('Mage_Backend_Helper_Data', array('escapeHtml'), array(), '', false); + $helper->expects($this->any()) + ->method('escapeHtml') + ->will($this->returnArgument(0)); + + // 2. Inject helper to layout + /** @var $layout Mage_Core_Model_Layout|PHPUnit_Framework_MockObject_MockObject */ + $layout = $this->getMock('Mage_Core_Model_Layout', array('helper'), array(), '', false); + $layout->expects($this->any()) + ->method('helper') + ->with('Mage_Backend_Helper_Data') + ->will($this->returnValue($helper)); + + // 3. Get service mock + /** @var $service Mage_Backend_Helper_Data|PHPUnit_Framework_MockObject_MockObject */ + $service = $this->getMock('Mage_Backend_Helper_Data', array('escapeHtml'), array(), '', false); + + // 4. Get URL model + /** @var $urlBuilder Mage_Core_Model_Url|PHPUnit_Framework_MockObject_MockObject */ + $urlBuilder = $this->getMock('Mage_Core_Model_Url', array('getUrl'), array(), '', false); + $urlBuilder->expects($this->any()) + ->method('getUrl') + ->will($this->returnValue($this->_url)); + + //5. Run functionality + $testHelper = new Magento_Test_Helper_ObjectManager($this); + $data = array( + 'layout' => $layout, + 'service' => $service, + 'urlBuilder' => $urlBuilder + ); + $this->_block = $testHelper->getObject('Mage_DesignEditor_Block_Adminhtml_Editor_Toolbar_Buttons_Save', $data); + } + + /** + * @param Mage_Core_Model_Theme|PHPUnit_Framework_MockObject_MockObject $theme + * @param string $expected + * @param array $expectedOptions + * @dataProvider initDataProvider + */ + public function testInit($theme, $expected, $expectedOptions) + { + $block = $this->_block; + + $block->setTheme($theme); + $block->init(); + $data = $block->getData(); + $options = $block->getOptions(); + + $mainAction = json_decode($data['data_attribute']['mage-init'], true); + $this->assertNotEmpty($mainAction['button']['eventData']['confirm_message']); + $mainAction['button']['eventData']['confirm_message'] = 0; + + $this->assertEquals($expected, $mainAction); + foreach ($options as $option) { + $action = json_decode($option['data_attribute']['mage-init'], true); + + $this->assertNotEmpty($action['button']['eventData']['confirm_message']); + $action['button']['eventData']['confirm_message'] = 0; + + $isFound = false; + foreach ($expectedOptions as $expectedOption) { + try { + $this->assertEquals($expectedOption, $action); + $isFound = true; + } catch (Exception $e) { + //do nothing + } + } + + if (!$isFound) { + $this->fail(sprintf('Option [%s] is not found', $option['data_attribute']['mage-init'])); + } + } + } + + /** + * @return array + */ + public function initDataProvider() + { + return array( + 'Physical theme' => array( + $this->_getThemeMock(Mage_Core_Model_Theme::TYPE_PHYSICAL), + array( + 'button' => array( + 'event' => 'assign', + 'target' => 'body', + 'eventData' => array( + 'theme_id' => 123, + 'confirm_message' => 0 + ) + ) + ), + array() + ), + 'Virtual assigned theme' => array( + $this->_getThemeMock(Mage_Core_Model_Theme::TYPE_VIRTUAL, true), + array( + 'button' => array( + 'event' => 'save-and-assign', + 'target' => 'body', + 'eventData' => array( + 'theme_id' => 123, + 'save_url' => $this->_url, + 'confirm_message' => 0 + ) + ) + ), + array() + ), + 'Virtual unassigned theme' => array( + $this->_getThemeMock(Mage_Core_Model_Theme::TYPE_VIRTUAL, false), + array( + 'button' => array( + 'event' => 'save', + 'target' => 'body', + 'eventData' => array( + 'theme_id' => 123, + 'save_url' => $this->_url, + 'confirm_message' => 0 + ) + ), + ), + array( + array( + 'button' => array( + 'event' => 'save', + 'target' => 'body', + 'eventData' => array( + 'theme_id' => 123, + 'save_url' => $this->_url, + 'confirm_message' => 0 + ) + ), + ), + array( + 'button' => array( + 'event' => 'save-and-assign', + 'target' => 'body', + 'eventData' => array( + 'theme_id' => 123, + 'save_url' => $this->_url, + 'confirm_message' => 0 + ) + ), + ) + ) + ) + ); + } + + /** + * @expectedException InvalidArgumentException + * @expectedExceptionMessage Invalid theme of a "2" type passed to save button block + */ + public function testInitStaging() + { + // 1. Get theme mock + $stagingTheme = $this->_getThemeMock(Mage_Core_Model_Theme::TYPE_STAGING); + + $block = $this->_block; + + $block->setTheme($stagingTheme); + $block->init(); + } + + /** + * @param int $type + * @param null|bool $isAssigned + * @return Mage_Core_Model_Theme|PHPUnit_Framework_MockObject_MockObject + */ + protected function _getThemeMock($type, $isAssigned = null) + { + $themeId = 123; + + if ($type == Mage_Core_Model_Theme::TYPE_VIRTUAL) { + $theme = $this->_getVirtualThemeMock($type, $isAssigned); + } else { + $theme = $this->getMock('Mage_Core_Model_Theme', null, array(), '', false); + } + + $theme->setType($type); + $theme->setId($themeId); + + return $theme; + } + + /** + * @param int $type + * @param bool $isAssigned + * @return Mage_Core_Model_Theme|PHPUnit_Framework_MockObject_MockObject + */ + protected function _getVirtualThemeMock($type, $isAssigned) + { + // 1. Get domain model + /** @var $domainModel Mage_Core_Model_Theme_Domain_Virtual|PHPUnit_Framework_MockObject_MockObject */ + $domainModel = $this->getMock('Mage_Core_Model_Theme_Domain_Virtual', + array('isAssigned'), array(), '', false); + $domainModel->expects($this->any()) + ->method('isAssigned') + ->will($this->returnValue($isAssigned)); + + // 2. Get Theme mock + /** @var $theme Mage_Core_Model_Theme|PHPUnit_Framework_MockObject_MockObject */ + $theme = $this->getMock('Mage_Core_Model_Theme', array('getDomainModel'), array(), '', false); + $theme->expects($this->any()) + ->method('getDomainModel') + ->with($type) + ->will($this->returnValue($domainModel)); + + return $theme; + } +} diff --git a/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/ButtonsTest.php b/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/ButtonsTest.php index e40e7b514f424..75986adf13451 100644 --- a/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/ButtonsTest.php +++ b/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/ButtonsTest.php @@ -49,7 +49,7 @@ protected function setUp() 'urlBuilder' => $this->_urlBuilder ); - $this->_block = $helper->getBlock('Mage_DesignEditor_Block_Adminhtml_Editor_Toolbar_Buttons', $arguments); + $this->_block = $helper->getObject('Mage_DesignEditor_Block_Adminhtml_Editor_Toolbar_Buttons', $arguments); } public function testGetThemeId() @@ -82,7 +82,7 @@ public function testGetQuitUrl() public function testGetNavigationModeUrl() { - $this->_block->setThemeId(2); + $this->_block->setVirtualThemeId(2); $mode = Mage_DesignEditor_Model_State::MODE_NAVIGATION; $this->_urlBuilder->expects($this->once()) ->method('getUrl') @@ -96,7 +96,7 @@ public function testGetNavigationModeUrl() public function testGetDesignModeUrl() { - $this->_block->setThemeId(3); + $this->_block->setVirtualThemeId(3); $mode = Mage_DesignEditor_Model_State::MODE_DESIGN; $this->_urlBuilder->expects($this->once()) ->method('getUrl') diff --git a/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/HandlesHierarchyTest.php b/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/HandlesHierarchyTest.php index 0fae332da04eb..2d70fe55bc1d6 100644 --- a/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/HandlesHierarchyTest.php +++ b/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/Toolbar/HandlesHierarchyTest.php @@ -85,7 +85,7 @@ function($url, $parameter) { 'vdeUrlBuilder' => $vdeUrlBuilder ); - $this->_model = $objectManagerHelper->getBlock($this->_modelName, $data); + $this->_model = $objectManagerHelper->getObject($this->_modelName, $data); } protected function tearDown() diff --git a/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/CustomTest.php b/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/CustomTest.php index fe6058176a88c..e55646bfc90fd 100644 --- a/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/CustomTest.php +++ b/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/CustomTest.php @@ -42,7 +42,7 @@ public function setUp() $this->_urlBuilder = $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); - $this->_model = $objectManagerHelper->getBlock( + $this->_model = $objectManagerHelper->getObject( 'Mage_DesignEditor_Block_Adminhtml_Editor_Tools_Code_Custom', array( 'config' => $this->getMock('Mage_Core_Model_Config', array(), array(), '', false), diff --git a/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/JsTest.php b/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/JsTest.php index 4edd946b4d468..304d4fc434024 100644 --- a/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/JsTest.php +++ b/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Adminhtml/Editor/Tools/Code/JsTest.php @@ -43,7 +43,6 @@ public function setUp() $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); $constructArguments = $objectManagerHelper->getConstructArguments( - Magento_Test_Helper_ObjectManager::BLOCK_ENTITY, 'Mage_DesignEditor_Block_Adminhtml_Editor_Tools_Code_Js', array( 'config' => $this->getMock('Mage_Core_Model_Config', array(), array(), '', false), @@ -118,7 +117,7 @@ public function testGetTitle() */ public function testGetJsFiles() { - $filesCollection = $this->getMockBuilder('Mage_Core_Model_Resource_Theme_Files_Collection') + $filesCollection = $this->getMockBuilder('Mage_Core_Model_Resource_Theme_File_Collection') ->disableOriginalConstructor() ->getMock(); diff --git a/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Page/Html/Head/VdeTest.php b/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Page/Html/Head/VdeTest.php deleted file mode 100644 index 736413f45f87f..0000000000000 --- a/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Page/Html/Head/VdeTest.php +++ /dev/null @@ -1,38 +0,0 @@ -getBlock('Mage_DesignEditor_Block_Page_Html_Head_Vde'); - - $this->assertNull($block->getTemplate()); - } -} diff --git a/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Page/Html/HeadTest.php b/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Page/Html/HeadTest.php deleted file mode 100644 index bafe7bc78459e..0000000000000 --- a/dev/tests/unit/testsuite/Mage/DesignEditor/Block/Page/Html/HeadTest.php +++ /dev/null @@ -1,112 +0,0 @@ -_model); - } - - /** - * @param array $sourceItems - * @param array $vdeItems - * @param array $expectedItems - * - * @dataProvider getCssJsHtmlDataProvider - */ - public function testGetCssJsHtml(array $sourceItems, array $vdeItems = null, array $expectedItems = null) - { - $helper = new Magento_Test_Helper_ObjectManager($this); - if ($vdeItems !== null) { - /** @var $vdeHead Mage_DesignEditor_Block_Page_Html_Head_Vde */ - $vdeHead = $helper->getBlock('Mage_DesignEditor_Block_Page_Html_Head_Vde'); - $vdeHead->setData('items', $vdeItems); - - $layoutMock = $this->getMock('Mage_Core_Model_Layout', array('getBlock'), array(), '', false); - $layoutMock->expects($this->once()) - ->method('getBlock') - ->will($this->returnValue($vdeHead)); - - $this->_model = $helper->getBlock( - 'Mage_DesignEditor_Block_Page_Html_Head', - array('layout' => $layoutMock) - ); - } else { - $this->_model = $helper->getBlock('Mage_DesignEditor_Block_Page_Html_Head'); - } - $this->_model->setData('items', $sourceItems); - - $this->assertInternalType('string', $this->_model->getCssJsHtml()); - $this->assertEquals($expectedItems, $this->_model->getData('items')); - } - - /** - * Data provider for testGetCssJsHtml - * - * @return array - */ - public function getCssJsHtmlDataProvider() - { - $jsSourceItems = array( - 'js/first' => 'js first', - 'js/second' => 'js second' - ); - $cssSourceItems = array( - 'css/first' => 'css first' - ); - $sourceItems = array_merge($jsSourceItems, $cssSourceItems); - - $vdeItems = array( - 'js/first' => 'js first vde', - 'css/second' => 'css second', - ); - - return array( - 'no block' => array( - '$sourceItems' => $sourceItems, - '$vdeItems' => null, - '$expectedItems' => $sourceItems, - ), - 'no vde data' => array( - '$sourceItems' => $sourceItems, - '$vdeItems' => array(), - '$expectedItems' => $cssSourceItems, - ), - 'item merge' => array( - '$sourceItems' => $sourceItems, - '$vdeItems' => $vdeItems, - '$expectedItems' => array_merge($cssSourceItems, $vdeItems), - ), - ); - } -} diff --git a/dev/tests/unit/testsuite/Mage/DesignEditor/Controller/Varien/Router/StandardTest.php b/dev/tests/unit/testsuite/Mage/DesignEditor/Controller/Varien/Router/StandardTest.php index 9c60fb4e13339..4400bbac2c82d 100644 --- a/dev/tests/unit/testsuite/Mage/DesignEditor/Controller/Varien/Router/StandardTest.php +++ b/dev/tests/unit/testsuite/Mage/DesignEditor/Controller/Varien/Router/StandardTest.php @@ -183,7 +183,7 @@ protected function _prepareMocksForTestMatch( ) { // default mocks - not affected on method functionality $controllerFactory = $this->getMock('Mage_Core_Controller_Varien_Action_Factory', array(), array(), '', false); - $objectManager = $this->getMock('Magento_ObjectManager_Zend', array('get'), array(), '', false); + $objectManager = $this->getMock('Magento_ObjectManager'); $filesystem = $this->getMockBuilder('Magento_Filesystem')->disableOriginalConstructor()->getMock(); $helper = $this->_getHelperMock(); diff --git a/dev/tests/unit/testsuite/Mage/DesignEditor/Helper/DataTest.php b/dev/tests/unit/testsuite/Mage/DesignEditor/Helper/DataTest.php index 70edd00f0b3c5..255f806f42ee0 100644 --- a/dev/tests/unit/testsuite/Mage/DesignEditor/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Mage/DesignEditor/Helper/DataTest.php @@ -72,14 +72,21 @@ class Mage_DesignEditor_Helper_DataTest extends PHPUnit_Framework_TestCase */ protected $_translatorMock; + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_context; + protected function setUp() { $this->_translatorMock = $this->getMock('Mage_Core_Model_Translate', array(), array(), '', false); + $this->_context = new Mage_Core_Helper_Context($this->_translatorMock); } protected function tearDown() { unset($this->_model); + unset($this->_context); } public function testGetFrontName() @@ -92,7 +99,9 @@ public function testGetFrontName() ->with(Mage_DesignEditor_Helper_Data::XML_PATH_FRONT_NAME) ->will($this->returnValue($frontNameNode)); - $this->_model = new Mage_DesignEditor_Helper_Data($this->_translatorMock, $configurationMock); + $backendSession = $this->getMockBuilder('Mage_Backend_Model_Session')->disableOriginalConstructor()->getMock(); + + $this->_model = new Mage_DesignEditor_Helper_Data($this->_context, $configurationMock, $backendSession); $this->assertEquals(self::TEST_FRONT_NAME, $this->_model->getFrontName()); } @@ -106,7 +115,9 @@ public function testGetDefaultHandle() ->with(Mage_DesignEditor_Helper_Data::XML_PATH_DEFAULT_HANDLE) ->will($this->returnValue($defaultHandleNode)); - $this->_model = new Mage_DesignEditor_Helper_Data($this->_translatorMock, $configurationMock); + $backendSession = $this->getMockBuilder('Mage_Backend_Model_Session')->disableOriginalConstructor()->getMock(); + + $this->_model = new Mage_DesignEditor_Helper_Data($this->_context, $configurationMock, $backendSession); $this->assertEquals(self::TEST_DEFAULT_HANDLE, $this->_model->getDefaultHandle()); } @@ -120,7 +131,9 @@ public function testGetDisabledCacheTypes() ->with(Mage_DesignEditor_Helper_Data::XML_PATH_DISABLED_CACHE_TYPES) ->will($this->returnValue($cacheTypesNode)); - $this->_model = new Mage_DesignEditor_Helper_Data($this->_translatorMock, $configurationMock); + $backendSession = $this->getMockBuilder('Mage_Backend_Model_Session')->disableOriginalConstructor()->getMock(); + + $this->_model = new Mage_DesignEditor_Helper_Data($this->_context, $configurationMock, $backendSession); $this->assertEquals($this->_disabledCacheTypes, $this->_model->getDisabledCacheTypes()); } @@ -145,7 +158,9 @@ public function testGetElementsList($method, $xmlPath) ->with($xmlPath) ->will($this->returnValue($blockDataNode)); - $this->_model = new Mage_DesignEditor_Helper_Data($this->_translatorMock, $configurationMock); + $backendSession = $this->getMockBuilder('Mage_Backend_Model_Session')->disableOriginalConstructor()->getMock(); + + $this->_model = new Mage_DesignEditor_Helper_Data($this->_context, $configurationMock, $backendSession); $this->assertEquals($this->_elementData, $this->_model->$method()); } @@ -182,7 +197,9 @@ public function testGetDateToExpire() ->with(Mage_DesignEditor_Helper_Data::XML_PATH_DAYS_TO_EXPIRE) ->will($this->returnValue($frontNameNode)); - $this->_model = new Mage_DesignEditor_Helper_Data($this->_translatorMock, $configurationMock); + $backendSession = $this->getMockBuilder('Mage_Backend_Model_Session')->disableOriginalConstructor()->getMock(); + + $this->_model = new Mage_DesignEditor_Helper_Data($this->_context, $configurationMock, $backendSession); $this->assertEquals(self::TEST_DATE_TO_EXPIRE, $this->_model->getDaysToExpire()); } } diff --git a/dev/tests/unit/testsuite/Mage/DesignEditor/Model/Config/Control/QuickStylesTest.php b/dev/tests/unit/testsuite/Mage/DesignEditor/Model/Config/Control/QuickStylesTest.php new file mode 100644 index 0000000000000..3536eb81cdfe9 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/DesignEditor/Model/Config/Control/QuickStylesTest.php @@ -0,0 +1,53 @@ +getMockBuilder('Mage_Core_Model_Config_Modules_Reader') + ->setMethods(array('getModuleDir')) + ->disableOriginalConstructor() + ->getMock(); + + $moduleReader->expects($this->any(), $this->any()) + ->method('getModuleDir') + ->will($this->returnValue('/base_path/etc')); + + /** @var $quickStyle Mage_DesignEditor_Model_Config_Control_QuickStyles */ + $quickStyle = $this->getMock('Mage_DesignEditor_Model_Config_Control_QuickStyles', null, array( + 'moduleReader' => $moduleReader, 'configFiles' => array('sample') + ), '', false); + + $property = new ReflectionProperty($quickStyle, '_moduleReader'); + $property->setAccessible(true); + $property->setValue($quickStyle, $moduleReader); + + $this->assertStringMatchesFormat('%s/etc/quick_styles.xsd', $quickStyle->getSchemaFile()); + } +} diff --git a/dev/tests/unit/testsuite/Mage/DesignEditor/Model/Editor/QuickStyles/Renderer/BackgroundImageTest.php b/dev/tests/unit/testsuite/Mage/DesignEditor/Model/Editor/QuickStyles/Renderer/BackgroundImageTest.php new file mode 100644 index 0000000000000..39ca79cf16827 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/DesignEditor/Model/Editor/QuickStyles/Renderer/BackgroundImageTest.php @@ -0,0 +1,64 @@ +getMock( + 'Mage_DesignEditor_Model_Editor_Tools_QuickStyles_Renderer_BackgroundImage', null, array(), '', false + ); + + $this->assertEquals($expectedResult, $rendererModel->toCss($data)); + } + + /** + * @return array + */ + public function backgroundImageData() + { + return array(array( + 'expected_result' => ".header { background-image: url('path/image.gif'); }", + 'data' => array( + 'type' => 'image-uploader', + 'default' => 'bg.gif', + 'selector' => '.header', + 'attribute' => 'background-image', + 'value' => 'path/image.gif', + ), + )); + } +} diff --git a/dev/tests/unit/testsuite/Mage/DesignEditor/Model/Editor/QuickStyles/Renderer/DefaultTest.php b/dev/tests/unit/testsuite/Mage/DesignEditor/Model/Editor/QuickStyles/Renderer/DefaultTest.php new file mode 100644 index 0000000000000..47b76a41da172 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/DesignEditor/Model/Editor/QuickStyles/Renderer/DefaultTest.php @@ -0,0 +1,60 @@ +getMock( + 'Mage_DesignEditor_Model_Editor_Tools_QuickStyles_Renderer_Default', null, array(), '', false + ); + + $this->assertEquals($expectedResult, $rendererModel->toCss($data)); + } + + public function colorPickerData() + { + return array(array( + 'expected_result' => ".menu { color: red; }", + 'data' => array( + 'type' => 'color-picker', + 'default' => '#f8f8f8', + 'selector' => '.menu', + 'attribute' => 'color', + 'value' => 'red', + ), + )); + } +} diff --git a/dev/tests/unit/testsuite/Mage/DesignEditor/Model/Editor/QuickStyles/RendererTest.php b/dev/tests/unit/testsuite/Mage/DesignEditor/Model/Editor/QuickStyles/RendererTest.php new file mode 100644 index 0000000000000..d355f230e0670 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/DesignEditor/Model/Editor/QuickStyles/RendererTest.php @@ -0,0 +1,112 @@ +getMock( + 'Mage_DesignEditor_Model_Editor_Tools_QuickStyles_Renderer', null, array(), '', false + ); + + $objectManager = $this->getMock( + 'Varien_Object', array('get', 'toCss'), array(), '', false + ); + + $objectManager->expects($this->exactly(4)) + ->method('get') + ->will($this->returnValue($objectManager)); + + $objectManager->expects($this->exactly(4)) + ->method('toCss') + ->will($this->returnValue('css_string')); + + $property = new ReflectionProperty($rendererModel, '_quickStyleFactory'); + $property->setAccessible(true); + $property->setValue($rendererModel, $objectManager); + + $this->assertEquals($expectedResult, $rendererModel->render($data)); + } + + /** + * @return array + */ + public function sampleData() + { + return array(array( + 'expected_result' => "css_string\r\ncss_string\r\ncss_string\r\ncss_string\r\n", + 'data' => array( + 'header-background' => array( + 'type' => 'background', + 'components' => array( + 'header-background:color-picker' => array( + 'type' => 'color-picker', + 'default' => 'transparent', + 'selector' => '.header', + 'attribute' => 'background-color', + 'value' => '#FFFFFF' + ), + 'header-background:background-uploader' => array( + 'type' => 'background-uploader', + 'components' => array( + 'header-background:image-uploader' => array( + 'type' => 'image-uploader', + 'default' => 'bg.gif', + 'selector' => '.header', + 'attribute' => 'background-image', + 'value' => '../image.jpg' + ), + 'header-background:tile' => array( + 'type' => 'checkbox', + 'default' => 'no-repeat', + 'options' => array('no-repeat', 'repeat', 'repeat-x', 'repeat-y', 'inherit'), + 'selector' => '.header', + 'attribute' => 'background-repeat', + 'value' => 'checked' + ), + ) + ), + ) + ), + 'menu-background' => array( + 'type' => 'color-picker', + 'default' => '#f8f8f8', + 'selector' => '.menu', + 'attribute' => 'color', + 'value' => '#000000' + ), + ))); + } +} diff --git a/dev/tests/unit/testsuite/Mage/DesignEditor/Model/LayoutTest.php b/dev/tests/unit/testsuite/Mage/DesignEditor/Model/LayoutTest.php index 3b3a2778f58bf..79d7879f15780 100644 --- a/dev/tests/unit/testsuite/Mage/DesignEditor/Model/LayoutTest.php +++ b/dev/tests/unit/testsuite/Mage/DesignEditor/Model/LayoutTest.php @@ -100,7 +100,7 @@ protected function _prepareLayoutObject() $this->getMock('Mage_Core_Model_Layout_Argument_Processor', array(), array(), '', false), $this->getMock('Mage_Core_Model_Layout_Translator', array(), array(), '', false), $this->getMock('Mage_Core_Model_Layout_ScheduledStructure', array(), array(), '', false), - $this->getMock('Mage_DesignEditor_Block_Template', array(), array(), '', false), + $this->getMock('Magento_Datasource_Factory', array(), array(), '', false), $helper ); } diff --git a/dev/tests/unit/testsuite/Mage/DesignEditor/Model/ObserverTest.php b/dev/tests/unit/testsuite/Mage/DesignEditor/Model/ObserverTest.php index 9131ac524128c..328152ab595b1 100644 --- a/dev/tests/unit/testsuite/Mage/DesignEditor/Model/ObserverTest.php +++ b/dev/tests/unit/testsuite/Mage/DesignEditor/Model/ObserverTest.php @@ -106,7 +106,7 @@ public function testClearLayoutUpdates() $layoutCollection->addItem($layout); } - $objectManager = $this->getMock('Magento_ObjectManager_Zend', array('create'), array(), '', false); + $objectManager = $this->getMock('Magento_ObjectManager'); $objectManager->expects($this->at(0)) ->method('create') ->with('Mage_Core_Model_Resource_Layout_Link_Collection') @@ -116,10 +116,88 @@ public function testClearLayoutUpdates() ->with('Mage_Core_Model_Resource_Layout_Update_Collection') ->will($this->returnValue($layoutCollection)); - $cacheManager = $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false); + $cacheManager = $this->getMock('Mage_Core_Model_CacheInterface', array(), array(), '', false); // test $this->_model = new Mage_DesignEditor_Model_Observer($objectManager, $helper, $cacheManager); $this->_model->clearLayoutUpdates(); } + + public function testSaveQuickStyles() + { + $generatedContent = 'generated css content'; + + $cacheManager = $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false); + $objectManager = $this->getMock('Magento_ObjectManager'); + $helper = $this->getMock('Mage_DesignEditor_Helper_Data', array(), array(), '', false); + + /** Prepare renderer */ + $renderer = $this->getMock( + 'Mage_DesignEditor_Model_Editor_Tools_QuickStyles_Renderer', array('render'), array(), '', false + ); + + $renderer->expects($this->once()) + ->method('render') + ->will($this->returnValue($generatedContent)); + + /** Prepare CSS */ + $cssFile = $this->getMock( + 'Mage_Core_Model_Theme_Customization_Files_Css', array('setDataForSave'), array(), '', false + ); + $cssFile->expects($this->once()) + ->method('setDataForSave') + ->with(array(Mage_Core_Model_Theme_Customization_Files_Css::QUICK_STYLE_CSS => $generatedContent)) + ->will($this->returnValue($renderer)); + + /** Prepare theme */ + $theme = $this->getMock('Mage_Core_Model_Theme', array('setCustomization', 'save'), array(), '', false); + + $theme->expects($this->once()) + ->method('setCustomization') + ->with($cssFile) + ->will($this->returnValue($theme)); + + $theme->expects($this->once()) + ->method('save') + ->will($this->returnValue($theme)); + + /** Prepare configuration */ + $configuration = $this->getMock( + 'Mage_DesignEditor_Model_Editor_Tools_Controls_Configuration', + array('getControlConfig', 'getTheme'), array(), '', false + ); + $quickStyle = $this->getMock( + 'Mage_DesignEditor_Model_Config_Control_QuickStyles', array(), array(), '', false + ); + + $configuration->expects($this->once()) + ->method('getControlConfig') + ->will($this->returnValue($quickStyle)); + + $configuration->expects($this->once()) + ->method('getTheme') + ->will($this->returnValue($theme)); + + /** Prepare event */ + $event = $this->getMock('Varien_Event_Observer', array('getData'), array(), '', false); + + $event->expects($this->once()) + ->method('getData') + ->with('configuration') + ->will($this->returnValue($configuration)); + + /** Prepare observer */ + $objectManager->expects($this->at(0)) + ->method('create') + ->with('Mage_DesignEditor_Model_Editor_Tools_QuickStyles_Renderer') + ->will($this->returnValue($renderer)); + + $objectManager->expects($this->at(1)) + ->method('create') + ->with('Mage_Core_Model_Theme_Customization_Files_Css') + ->will($this->returnValue($cssFile)); + + $this->_model = new Mage_DesignEditor_Model_Observer($objectManager, $helper, $cacheManager); + $this->_model->saveQuickStyles($event); + } } diff --git a/dev/tests/unit/testsuite/Mage/DesignEditor/Model/StateTest.php b/dev/tests/unit/testsuite/Mage/DesignEditor/Model/StateTest.php index d1c71b1a352bf..f53b0729de856 100644 --- a/dev/tests/unit/testsuite/Mage/DesignEditor/Model/StateTest.php +++ b/dev/tests/unit/testsuite/Mage/DesignEditor/Model/StateTest.php @@ -95,7 +95,7 @@ class Mage_DesignEditor_Model_StateTest extends PHPUnit_Framework_TestCase protected $_dataHelper; /** - * @var Magento_ObjectManager_Zend|PHPUnit_Framework_MockObject_MockObject + * @var PHPUnit_Framework_MockObject_MockObject */ protected $_objectManager; @@ -125,16 +125,14 @@ public function setUp() $this->_urlModelFactory = $this->getMock('Mage_DesignEditor_Model_Url_Factory', array('replaceClassName'), array(), '', false ); - $this->_cacheManager = $this->getMock('Mage_Core_Model_Cache', array('canUse', 'banUse'), - array(), '', false - ); + $this->_cacheManager = $this->getMockBuilder('Mage_Core_Model_Cache')->disableOriginalConstructor()->getMock(); $this->_dataHelper = $this->getMock('Mage_DesignEditor_Helper_Data', array('getDisabledCacheTypes'), array(), '', false ); - $this->_objectManager = $this->getMock('Magento_ObjectManager_Zend', array('addAlias'), + $this->_objectManager = $this->getMock('Magento_ObjectManager'); + $this->_designPackage = $this->getMock('Mage_Core_Model_Design_Package', array('getConfigPathByArea'), array(), '', false ); - $this->_designPackage = $this->getMock('Mage_Core_Model_Design_Package', array(), array(), '', false); $this->_application = $this->getMock('Mage_Core_Model_App', array('getStore'), array(), '', false ); @@ -205,7 +203,7 @@ public function testUpdateDesignMode() ->with('vde_current_mode', Mage_DesignEditor_Model_State::MODE_DESIGN); $this->_backendSession->expects($this->once()) ->method('getData') - ->with('theme_id') + ->with(Mage_DesignEditor_Model_State::CURRENT_THEME_SESSION_KEY) ->will($this->returnValue(self::THEME_ID)); $this->_urlModelFactory->expects($this->once()) @@ -217,10 +215,11 @@ public function testUpdateDesignMode() ->with(array('area' => self::AREA_CODE), self::LAYOUT_DESIGN_CLASS_NAME); $this->_objectManager->expects($this->once()) - ->method('addAlias') - ->with(self::LAYOUT_UPDATE_RESOURCE_MODEL_CORE_CLASS_NAME, - self::LAYOUT_UPDATE_RESOURCE_MODEL_VDE_CLASS_NAME); - + ->method('configure') + ->with(array('preferences' => array( + self::LAYOUT_UPDATE_RESOURCE_MODEL_CORE_CLASS_NAME => self::LAYOUT_UPDATE_RESOURCE_MODEL_VDE_CLASS_NAME + ))); + $store = $this->getMock('Mage_Core_Model_Store', array('setConfig'), array(), '', false); $store->expects($this->once()) ->method('setConfig') @@ -240,7 +239,9 @@ public function testReset() ->with($this->logicalOr( Mage_DesignEditor_Model_State::CURRENT_HANDLE_SESSION_KEY, Mage_DesignEditor_Model_State::CURRENT_MODE_SESSION_KEY, - Mage_DesignEditor_Model_State::CURRENT_URL_SESSION_KEY + Mage_DesignEditor_Model_State::CURRENT_URL_SESSION_KEY, + Mage_DesignEditor_Model_State::VIRTUAL_THEME_SESSION_KEY, + Mage_DesignEditor_Model_State::CURRENT_THEME_SESSION_KEY )) ->will($this->returnValue($this->_backendSession)); @@ -294,9 +295,10 @@ public function testUpdateNavigationMode() ->with(array('area' => self::AREA_CODE), self::LAYOUT_NAVIGATION_CLASS_NAME); $this->_objectManager->expects($this->once()) - ->method('addAlias') - ->with(self::LAYOUT_UPDATE_RESOURCE_MODEL_CORE_CLASS_NAME, - self::LAYOUT_UPDATE_RESOURCE_MODEL_VDE_CLASS_NAME); + ->method('configure') + ->with(array('preferences' => array( + self::LAYOUT_UPDATE_RESOURCE_MODEL_CORE_CLASS_NAME => self::LAYOUT_UPDATE_RESOURCE_MODEL_VDE_CLASS_NAME + ))); $this->_model->update(self::AREA_CODE, $request, $controller); } diff --git a/dev/tests/unit/testsuite/Mage/DesignEditor/Model/Url/FactoryTest.php b/dev/tests/unit/testsuite/Mage/DesignEditor/Model/Url/FactoryTest.php index c310d9973284c..f19760d7d8c55 100644 --- a/dev/tests/unit/testsuite/Mage/DesignEditor/Model/Url/FactoryTest.php +++ b/dev/tests/unit/testsuite/Mage/DesignEditor/Model/Url/FactoryTest.php @@ -38,8 +38,7 @@ class Mage_DesignEditor_Model_Url_FactoryTest extends PHPUnit_Framework_TestCase public function setUp() { - $this->_objectManager = $this->getMock('Magento_ObjectManager_Zend', array('addAlias', 'create'), - array(), '', false); + $this->_objectManager = $this->getMock('Magento_ObjectManager'); $this->_model = new Mage_DesignEditor_Model_Url_Factory($this->_objectManager); } @@ -51,19 +50,19 @@ public function testConstruct() public function testReplaceClassName() { $this->_objectManager->expects($this->once()) - ->method('addAlias') - ->with('Mage_Core_Model_Url', 'TestClass'); + ->method('configure') + ->with(array('preferences' => array('Mage_Core_Model_Url' => 'TestClass'))); $this->assertEquals($this->_model, $this->_model->replaceClassName('TestClass')); } - public function testCreateFromArray() + public function testCreate() { $this->_objectManager->expects($this->once()) ->method('create') - ->with('Mage_Core_Model_Url', array(), false) + ->with('Mage_Core_Model_Url', array()) ->will($this->returnValue('ModelInstance')); - $this->assertEquals('ModelInstance', $this->_model->createFromArray()); + $this->assertEquals('ModelInstance', $this->_model->create()); } } diff --git a/dev/tests/unit/testsuite/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorControllerTest.php b/dev/tests/unit/testsuite/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorControllerTest.php index 4dd303360541c..fb8dbfd62307b 100644 --- a/dev/tests/unit/testsuite/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorControllerTest.php +++ b/dev/tests/unit/testsuite/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorControllerTest.php @@ -43,11 +43,9 @@ class Mage_DesignEditor_Controller_Adminhtml_System_Design_EditorControllerTest protected function setUp() { - $this->_objectManagerMock = $this->getMock('Magento_ObjectManager_Zend', - array('create', 'get'), array(), '', false); - + $this->_objectManagerMock = $this->getMock('Magento_ObjectManager'); $this->_model = $this->getMock('Mage_DesignEditor_Adminhtml_System_Design_EditorController', - array('_forward', '_title', '__', 'loadLayout', '_setActiveMenu', 'renderLayout'), + array('_forward', '_title', '__', 'loadLayout', '_setActiveMenu', 'renderLayout', 'getLayout'), array( $this->getMock('Mage_Core_Controller_Request_Http', array(), array(), '', false), $this->getMock('Mage_Core_Controller_Response_Http', array(), array(), '', false), @@ -61,9 +59,17 @@ protected function setUp() 'session' => 'session' ) )); + /** @var $layoutMock Mage_Core_Model_Layout|PHPUnit_Framework_MockObject_MockObject */ + $layoutMock = $this->getMock('Mage_Core_Model_Layout', array('getBlock'), array(), '', false); + /** @var $layoutMock Mage_Core_Model_Layout */ + $storeViewMock = $this->getMock('Mage_DesignEditor_Block_Adminhtml_Theme_Selector_StoreView', + array('setData'), array(), '', false); + $layoutMock->expects($this->any())->method('getBlock')->will($this->returnValue($storeViewMock)); + $this->_model->expects($this->any())->method('_title')->will($this->returnValue($this->_model)); $this->_model->expects($this->any())->method('loadLayout'); $this->_model->expects($this->any())->method('renderLayout'); + $this->_model->expects($this->any())->method('getLayout')->will($this->returnValue($layoutMock)); $this->_model->expects($this->any())->method('_setActiveMenu'); $this->_model->expects($this->any())->method('__'); } diff --git a/dev/tests/unit/testsuite/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/LinksTest.php b/dev/tests/unit/testsuite/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/LinksTest.php index ddf86dbc564fb..53588a0450f57 100644 --- a/dev/tests/unit/testsuite/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/LinksTest.php +++ b/dev/tests/unit/testsuite/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/LinksTest.php @@ -26,14 +26,17 @@ */ class Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_LinksTest - extends Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_TestCaseAbstract + extends PHPUnit_Framework_TestCase { + /** + * @var Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_Links + */ + protected $_block; + protected function setUp() { - parent::setUp(); - $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); - $this->_block = $objectManagerHelper->getBlock( + $this->_block = $objectManagerHelper->getObject( 'Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_Links', array( 'urlBuilder' => $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false) @@ -46,11 +49,6 @@ protected function setUp() */ public function testGetConfig() { - // we have to set strict error reporting mode and enable mage developer mode to convert notice to exception - error_reporting(E_ALL | E_STRICT); - ini_set('display_errors', 1); - Mage::setIsDeveloperMode(true); - $this->assertInstanceOf('Varien_Object', $this->_block->getConfig()); } } diff --git a/dev/tests/unit/testsuite/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/SamplesTest.php b/dev/tests/unit/testsuite/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/SamplesTest.php index c7f22c67bd3f3..075f4f0c877ef 100644 --- a/dev/tests/unit/testsuite/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/SamplesTest.php +++ b/dev/tests/unit/testsuite/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/SamplesTest.php @@ -26,14 +26,17 @@ */ class Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_SamplesTest - extends Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_TestCaseAbstract + extends PHPUnit_Framework_TestCase { + /** + * @var Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_Links + */ + protected $_block; + protected function setUp() { - parent::setUp(); - $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); - $this->_block = $objectManagerHelper->getBlock( + $this->_block = $objectManagerHelper->getObject( 'Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_Samples', array( 'urlBuilder' => $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false) @@ -46,11 +49,6 @@ protected function setUp() */ public function testGetConfig() { - // we have to set strict error reporting mode and enable mage developer mode to convert notice to exception - error_reporting(E_ALL | E_STRICT); - ini_set('display_errors', 1); - Mage::setIsDeveloperMode(true); - $this->assertInstanceOf('Varien_Object', $this->_block->getConfig()); } } diff --git a/dev/tests/unit/testsuite/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/TestCaseAbstract.php b/dev/tests/unit/testsuite/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/TestCaseAbstract.php deleted file mode 100644 index d070c80af6b81..0000000000000 --- a/dev/tests/unit/testsuite/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/TestCaseAbstract.php +++ /dev/null @@ -1,75 +0,0 @@ -_oldDisplayErrors = ini_get('display_errors'); - $this->_oldErrorLevel = error_reporting(); - $this->_oldIsDeveloperMode = Mage::getIsDeveloperMode(); - } - - protected function tearDown() - { - ini_set('display_errors', $this->_oldDisplayErrors); - error_reporting($this->_oldErrorLevel); - Mage::setIsDeveloperMode($this->_oldIsDeveloperMode); - - unset($this->_block); - } -} diff --git a/dev/tests/unit/testsuite/Mage/Downloadable/Model/Sales/Order/Pdf/Items/CreditmemoTest.php b/dev/tests/unit/testsuite/Mage/Downloadable/Model/Sales/Order/Pdf/Items/CreditmemoTest.php index bd47b188d69bf..cd5ee03cac2d4 100644 --- a/dev/tests/unit/testsuite/Mage/Downloadable/Model/Sales/Order/Pdf/Items/CreditmemoTest.php +++ b/dev/tests/unit/testsuite/Mage/Downloadable/Model/Sales/Order/Pdf/Items/CreditmemoTest.php @@ -45,10 +45,7 @@ class Mage_Downloadable_Model_Sales_Order_Pdf_Items_CreditmemoTest extends PHPUn protected function setUp() { $objectManager = new Magento_Test_Helper_ObjectManager($this); - $modelConstructorArgs = $objectManager->getConstructArguments( - Magento_Test_Helper_ObjectManager::MODEL_ENTITY, - 'Mage_Sales_Model_Order' - ); + $modelConstructorArgs = $objectManager->getConstructArguments('Mage_Sales_Model_Order'); $this->_order = $this->getMock('Mage_Sales_Model_Order', array('formatPriceTxt'), $modelConstructorArgs); $this->_order @@ -64,8 +61,8 @@ protected function setUp() array('getLinks', 'getLinksTitle'), $modelConstructorArgs ); - $translator = $this->getMock('Mage_Core_Model_Translate', array(), array(), '', false, false); - $this->_model->setStringHelper(new Mage_Core_Helper_String($translator)); + $context = $this->getMock('Mage_Core_Helper_Context', array(), array(), '', false, false); + $this->_model->setStringHelper(new Mage_Core_Helper_String($context)); $this->_model->setOrder($this->_order); $this->_model->setPdf($this->_pdf); $this->_model->setPage(new Zend_Pdf_Page('a4')); diff --git a/dev/tests/unit/testsuite/Mage/Eav/Model/Attribute/Data/TextTest.php b/dev/tests/unit/testsuite/Mage/Eav/Model/Attribute/Data/TextTest.php index 691f2c8c27f56..d132f5152e1be 100644 --- a/dev/tests/unit/testsuite/Mage/Eav/Model/Attribute/Data/TextTest.php +++ b/dev/tests/unit/testsuite/Mage/Eav/Model/Attribute/Data/TextTest.php @@ -52,9 +52,7 @@ protected function setUp() $attributeClass = 'Mage_Eav_Model_Entity_Attribute_Abstract'; $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); - $arguments = $objectManagerHelper->getConstructArguments( - Magento_Test_Helper_ObjectManager::MODEL_ENTITY, $attributeClass, array('data' => $attributeData) - ); + $arguments = $objectManagerHelper->getConstructArguments($attributeClass, array('data' => $attributeData)); /** @var $attribute Mage_Eav_Model_Entity_Attribute_Abstract|PHPUnit_Framework_MockObject_MockObject */ $attribute = $this->getMock($attributeClass, array('_init'), $arguments); diff --git a/dev/tests/unit/testsuite/Mage/Eav/Model/AttributeFactoryTest.php b/dev/tests/unit/testsuite/Mage/Eav/Model/AttributeFactoryTest.php index ff2e9162fe3e1..56f1cd7ecd606 100644 --- a/dev/tests/unit/testsuite/Mage/Eav/Model/AttributeFactoryTest.php +++ b/dev/tests/unit/testsuite/Mage/Eav/Model/AttributeFactoryTest.php @@ -44,8 +44,8 @@ class Mage_Eav_Model_AttributeFactoryTest extends PHPUnit_Framework_TestCase protected function setUp() { - /** @var $objectManagerMock Magento_ObjectManager_Zend */ - $objectManagerMock = $this->getMock('Magento_ObjectManager_Zend', array(), array(), '', false); + /** @var $objectManagerMock Magento_ObjectManager */ + $objectManagerMock = $this->getMock('Magento_ObjectManager'); $objectManagerMock->expects($this->any()) ->method('create') ->will($this->returnCallback(array($this, 'getModelInstance'))); diff --git a/dev/tests/unit/testsuite/Mage/Eav/Model/Entity/Attribute/SetTest.php b/dev/tests/unit/testsuite/Mage/Eav/Model/Entity/Attribute/SetTest.php index b295937d993ef..d2419e43b6bcc 100644 --- a/dev/tests/unit/testsuite/Mage/Eav/Model/Entity/Attribute/SetTest.php +++ b/dev/tests/unit/testsuite/Mage/Eav/Model/Entity/Attribute/SetTest.php @@ -49,7 +49,7 @@ protected function setUp() 'data' => array('helper' => $helper) ); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); - $this->_model = $objectManagerHelper->getModel('Mage_Eav_Model_Entity_Attribute_Set', $arguments); + $this->_model = $objectManagerHelper->getObject('Mage_Eav_Model_Entity_Attribute_Set', $arguments); } protected function tearDown() diff --git a/dev/tests/unit/testsuite/Mage/Eav/Model/Resource/Entity/AttributeTest.php b/dev/tests/unit/testsuite/Mage/Eav/Model/Resource/Entity/AttributeTest.php index 44abfcea38a85..cae4e7e7483db 100644 --- a/dev/tests/unit/testsuite/Mage/Eav/Model/Resource/Entity/AttributeTest.php +++ b/dev/tests/unit/testsuite/Mage/Eav/Model/Resource/Entity/AttributeTest.php @@ -53,10 +53,7 @@ public function testSaveOptionSystemAttribute() $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); /** @var $model Mage_Core_Model_Abstract */ - $arguments = $objectManagerHelper->getConstructArguments( - Magento_Test_Helper_ObjectManager::MODEL_ENTITY, - 'Mage_Core_Model_Abstract' - ); + $arguments = $objectManagerHelper->getConstructArguments('Mage_Core_Model_Abstract'); $arguments['data'] = $attributeData; $model = $this->getMock('Mage_Core_Model_Abstract', null, $arguments); $model->setDefault(array('2')); @@ -111,10 +108,7 @@ public function testSaveOptionNewUserDefinedAttribute() $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); /** @var $model Mage_Core_Model_Abstract */ - $arguments = $objectManagerHelper->getConstructArguments( - Magento_Test_Helper_ObjectManager::MODEL_ENTITY, - 'Mage_Core_Model_Abstract' - ); + $arguments = $objectManagerHelper->getConstructArguments('Mage_Core_Model_Abstract'); $arguments['data'] = $attributeData; $model = $this->getMock('Mage_Core_Model_Abstract', null, $arguments); $model->setOption(array('value' => array('option_1' => array('Backend Label', 'Frontend Label')))); @@ -175,10 +169,7 @@ public function testSaveOptionNoValue() $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); /** @var $model Mage_Core_Model_Abstract */ - $arguments = $objectManagerHelper->getConstructArguments( - Magento_Test_Helper_ObjectManager::MODEL_ENTITY, - 'Mage_Core_Model_Abstract' - ); + $arguments = $objectManagerHelper->getConstructArguments('Mage_Core_Model_Abstract'); $model = $this->getMock('Mage_Core_Model_Abstract', null, $arguments); $model->setOption('not-an-array'); diff --git a/dev/tests/unit/testsuite/Mage/ImportExport/Block/Adminhtml/Import/Edit/BeforeTest.php b/dev/tests/unit/testsuite/Mage/ImportExport/Block/Adminhtml/Import/Edit/BeforeTest.php index e6ff97bb96eae..a3f8a59158f22 100644 --- a/dev/tests/unit/testsuite/Mage/ImportExport/Block/Adminhtml/Import/Edit/BeforeTest.php +++ b/dev/tests/unit/testsuite/Mage/ImportExport/Block/Adminhtml/Import/Edit/BeforeTest.php @@ -104,7 +104,7 @@ public function setUp() 'urlBuilder' => $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false) ); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); - $this->_model = $objectManagerHelper->getBlock('Mage_ImportExport_Block_Adminhtml_Import_Edit_Before', + $this->_model = $objectManagerHelper->getObject('Mage_ImportExport_Block_Adminhtml_Import_Edit_Before', $arguments ); } diff --git a/dev/tests/unit/testsuite/Mage/ImportExport/Model/Export/Entity/Eav/Customer/AddressTest.php b/dev/tests/unit/testsuite/Mage/ImportExport/Model/Export/Entity/Eav/Customer/AddressTest.php index 5819363940720..f12f94f911b22 100644 --- a/dev/tests/unit/testsuite/Mage/ImportExport/Model/Export/Entity/Eav/Customer/AddressTest.php +++ b/dev/tests/unit/testsuite/Mage/ImportExport/Model/Export/Entity/Eav/Customer/AddressTest.php @@ -131,10 +131,7 @@ protected function _getModelDependencies() ->method('getEntityTypeCode') ->will($this->returnValue('customer_address')); foreach ($this->_attributes as $attributeData) { - $arguments = $this->_objectManager->getConstructArguments( - Magento_Test_Helper_ObjectManager::MODEL_ENTITY, - 'Mage_Eav_Model_Entity_Attribute_Abstract' - ); + $arguments = $this->_objectManager->getConstructArguments('Mage_Eav_Model_Entity_Attribute_Abstract'); $arguments['data'] = $attributeData; $attribute = $this->getMockForAbstractClass('Mage_Eav_Model_Entity_Attribute_Abstract', $arguments, '', true, true, true, array('_construct') @@ -210,10 +207,7 @@ public function getWebsites($withDefault = false) */ public function iterate(Varien_Data_Collection_Db $collection, $pageSize, array $callbacks) { - $arguments = $this->_objectManager->getConstructArguments( - Magento_Test_Helper_ObjectManager::MODEL_ENTITY, - 'Mage_Customer_Model_Customer' - ); + $arguments = $this->_objectManager->getConstructArguments('Mage_Customer_Model_Customer'); $arguments['data'] = $this->_customerData; /** @var $customer Mage_Customer_Model_Customer */ $customer = $this->getMock('Mage_Customer_Model_Customer', array('_construct'), $arguments); @@ -241,10 +235,7 @@ public function testExportItem() $this->_model->setWriter($writer); $this->_model->setParameters(array()); - $arguments = $this->_objectManager->getConstructArguments( - Magento_Test_Helper_ObjectManager::MODEL_ENTITY, - 'Mage_Core_Model_Abstract' - ); + $arguments = $this->_objectManager->getConstructArguments('Mage_Core_Model_Abstract'); $arguments['data'] = $this->_addressData; $item = $this->getMockForAbstractClass('Mage_Core_Model_Abstract', $arguments); $this->_model->exportItem($item); diff --git a/dev/tests/unit/testsuite/Mage/ImportExport/Model/Export/Entity/Eav/CustomerTest.php b/dev/tests/unit/testsuite/Mage/ImportExport/Model/Export/Entity/Eav/CustomerTest.php index 2cde59f85cd65..37d454bab3727 100644 --- a/dev/tests/unit/testsuite/Mage/ImportExport/Model/Export/Entity/Eav/CustomerTest.php +++ b/dev/tests/unit/testsuite/Mage/ImportExport/Model/Export/Entity/Eav/CustomerTest.php @@ -118,10 +118,7 @@ protected function _getModelDependencies() $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); $attributeCollection = new Varien_Data_Collection(); foreach ($this->_attributes as $attributeData) { - $arguments = $objectManagerHelper->getConstructArguments( - Magento_Test_Helper_ObjectManager::MODEL_ENTITY, - 'Mage_Eav_Model_Entity_Attribute_Abstract' - ); + $arguments = $objectManagerHelper->getConstructArguments('Mage_Eav_Model_Entity_Attribute_Abstract'); $arguments['data'] = $attributeData; $attribute = $this->getMockForAbstractClass('Mage_Eav_Model_Entity_Attribute_Abstract', $arguments, '', true, true, true, array('_construct') @@ -214,10 +211,7 @@ public function testExportItem() $this->_model->setWriter($writer); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); - $arguments = $objectManagerHelper->getConstructArguments( - Magento_Test_Helper_ObjectManager::MODEL_ENTITY, - 'Mage_Core_Model_Abstract' - ); + $arguments = $objectManagerHelper->getConstructArguments('Mage_Core_Model_Abstract'); $arguments['data'] = $this->_customerData; $item = $this->getMockForAbstractClass('Mage_Core_Model_Abstract', $arguments); diff --git a/dev/tests/unit/testsuite/Mage/ImportExport/Model/Export/Entity/ProductTest.php b/dev/tests/unit/testsuite/Mage/ImportExport/Model/Export/Entity/ProductTest.php index 62ee03280fbdd..8a461dd5a7e8b 100644 --- a/dev/tests/unit/testsuite/Mage/ImportExport/Model/Export/Entity/ProductTest.php +++ b/dev/tests/unit/testsuite/Mage/ImportExport/Model/Export/Entity/ProductTest.php @@ -32,65 +32,22 @@ class Mage_ImportExport_Model_Export_Entity_ProductTest extends PHPUnit_Framewor */ protected $_object; - /** - * Store old display_errors ini option value here - * - * @var int - */ - protected $_oldDisplayErrors; - - /** - * Store old error_reporting ini option value here - * - * @var int - */ - protected $_oldErrorLevel; - - /** - * Store old isDeveloperMode value here - * - * @var boolean - */ - protected $_oldIsDeveloperMode; - protected function setUp() { - parent::setUp(); - $this->_object = new Stub_UnitTest_Mage_ImportExport_Model_Export_Entity_Product(); - - $this->_oldDisplayErrors = ini_get('display_errors'); - $this->_oldErrorLevel = error_reporting(); - $this->_oldIsDeveloperMode = Mage::getIsDeveloperMode(); } protected function tearDown() { - ini_set('display_errors', $this->_oldDisplayErrors); - error_reporting($this->_oldErrorLevel); - Mage::setIsDeveloperMode($this->_oldIsDeveloperMode); - unset($this->_object); - - parent::tearDown(); } - /** - * Test that there is no notice in _updateDataWithCategoryColumns() - * - * @covers Mage_ImportExport_Model_Export_Entity_Product::_updateDataWithCategoryColumns - */ public function testUpdateDataWithCategoryColumnsNoCategoriesAssigned() { $dataRow = array(); $productId = 1; $rowCategories = array($productId => array()); - // we have to set strict error reporting mode and enable mage developer mode to convert notice to exception - error_reporting(E_ALL | E_STRICT); - ini_set('display_errors', 1); - Mage::setIsDeveloperMode(true); - $this->assertTrue($this->_object->updateDataWithCategoryColumns($dataRow, $rowCategories, $productId)); } } diff --git a/dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/CustomerCompositeTest.php b/dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/CustomerCompositeTest.php index 4c964309f4d85..93b3ed22af109 100644 --- a/dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/CustomerCompositeTest.php +++ b/dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/CustomerCompositeTest.php @@ -247,7 +247,7 @@ protected function _getModelDependencies() 'helpers' => array('Mage_ImportExport_Helper_Data' => $mageHelper), 'json_helper' => 'not_used', 'string_helper' => new Mage_Core_Helper_String( - $this->getMock('Mage_Core_Model_Translate', array(), array(), '', false, false) + $this->getMock('Mage_Core_Helper_Context', array(), array(), '', false, false) ), 'page_size' => 1, 'max_data_size' => 1, diff --git a/dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php b/dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php index 902bd363c4f83..185bc036dd94a 100644 --- a/dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php +++ b/dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php @@ -201,7 +201,7 @@ protected function _getModelDependencies() 'connection' => $connection, 'json_helper' => 'not_used', 'string_helper' => new Mage_Core_Helper_String( - $this->getMock('Mage_Core_Model_Translate', array(), array(), '', false, false) + $this->getMock('Mage_Core_Helper_Context', array(), array(), '', false, false) ), 'page_size' => 1, 'max_data_size' => 1, @@ -234,10 +234,7 @@ protected function _createAttrCollectionMock() $attributeCollection = $this->getMock('Varien_Data_Collection', array('getEntityTypeCode')); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); foreach ($this->_attributes as $attributeData) { - $arguments = $objectManagerHelper->getConstructArguments( - Magento_Test_Helper_ObjectManager::MODEL_ENTITY, - 'Mage_Eav_Model_Entity_Attribute_Abstract' - ); + $arguments = $objectManagerHelper->getConstructArguments('Mage_Eav_Model_Entity_Attribute_Abstract'); $arguments['data'] = $attributeData; $attribute = $this->getMockForAbstractClass('Mage_Eav_Model_Entity_Attribute_Abstract', $arguments, '', true, true, true, array('_construct', 'getBackend') @@ -264,10 +261,7 @@ protected function _createCustomerStorageMock() array(), '', false); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); foreach ($this->_customers as $customerData) { - $arguments = $objectManagerHelper->getConstructArguments( - Magento_Test_Helper_ObjectManager::MODEL_ENTITY, - 'Mage_Customer_Model_Customer' - ); + $arguments = $objectManagerHelper->getConstructArguments('Mage_Customer_Model_Customer'); $arguments['data'] = $customerData; /** @var $customer Mage_Customer_Model_Customer */ $customer = $this->getMock('Mage_Customer_Model_Customer', array('_construct'), $arguments); diff --git a/dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/EavAbstractTest.php b/dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/EavAbstractTest.php index 23290dbaf0039..074eb4f13fbe9 100644 --- a/dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/EavAbstractTest.php +++ b/dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/EavAbstractTest.php @@ -72,7 +72,7 @@ protected function _getModelDependencies() 'translator' => $translator, 'json_helper' => 'not_used', 'string_helper' => new Mage_Core_Helper_String( - $this->getMock('Mage_Core_Model_Translate', array(), array(), '', false, false) + $this->getMock('Mage_Core_Helper_Context', array(), array(), '', false, false) ), 'page_size' => 1, 'max_data_size' => 1, @@ -96,14 +96,4 @@ public function testGetEntityTypeId() { $this->assertEquals(self::ENTITY_TYPE_ID, $this->_model->getEntityTypeId()); } - - /** - * @todo implement in the scope of https://wiki.magento.com/display/MAGE2/Technical+Debt+%28Team-Donetsk-B%29 - * - * @covers Mage_ImportExport_Model_Import_Entity_EavAbstract::getAttributeOptions - */ - public function testGetAttributeOptions() - { - $this->markTestIncomplete('Technical debt - not implemented'); - } } diff --git a/dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/EntityAbstractTest.php b/dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/EntityAbstractTest.php index 44d9b988ba873..4eb165a885408 100644 --- a/dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/EntityAbstractTest.php +++ b/dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/EntityAbstractTest.php @@ -80,7 +80,7 @@ protected function _getModelDependencies() 'helpers' => array('Mage_ImportExport_Helper_Data' => $mageHelper), 'json_helper' => 'not_used', 'string_helper' => new Mage_Core_Helper_String( - $this->getMock('Mage_Core_Model_Translate', array(), array(), '', false, false) + $this->getMock('Mage_Core_Helper_Context', array(), array(), '', false, false) ), 'page_size' => 1, 'max_data_size' => 1, @@ -446,7 +446,7 @@ public function testIsAttributeValid(array $data) $registryKey = '_helper/Mage_Core_Helper_String'; if (!Mage::registry($registryKey)) { $helper = new Mage_Core_Helper_String( - $this->getMock('Mage_Core_Model_Translate', array(), array(), '', false, false) + $this->getMock('Mage_Core_Helper_Context', array(), array(), '', false, false) ); Mage::register($registryKey, $helper); } diff --git a/dev/tests/unit/testsuite/Mage/ImportExport/Model/Resource/Import/CustomerComposite/DataTest.php b/dev/tests/unit/testsuite/Mage/ImportExport/Model/Resource/Import/CustomerComposite/DataTest.php index 95c423744b8bb..eee3d3ba47abf 100644 --- a/dev/tests/unit/testsuite/Mage/ImportExport/Model/Resource/Import/CustomerComposite/DataTest.php +++ b/dev/tests/unit/testsuite/Mage/ImportExport/Model/Resource/Import/CustomerComposite/DataTest.php @@ -87,7 +87,7 @@ protected function _getDependencies($entityType, $bunchData) $data = array( 'json_helper' => new Mage_Core_Helper_Data( - $this->getMock('Mage_Core_Model_Translate', array(), array(), '', false, false), + $this->getMock('Mage_Core_Helper_Context', array(), array(), '', false, false), $this->getMock('Mage_Core_Model_Config_Modules', array(), array(), '', false, false) ), 'resource' => $resourceModelMock, diff --git a/dev/tests/unit/testsuite/Mage/Index/Model/Lock/StorageTest.php b/dev/tests/unit/testsuite/Mage/Index/Model/Lock/StorageTest.php index cf8ab3e17e474..e8671711b894c 100644 --- a/dev/tests/unit/testsuite/Mage/Index/Model/Lock/StorageTest.php +++ b/dev/tests/unit/testsuite/Mage/Index/Model/Lock/StorageTest.php @@ -68,11 +68,11 @@ public function testGetFile() ->method('streamWrite') ->with($this->isType('string')); - $fileFactory = $this->getMock('Mage_Index_Model_Process_FileFactory', array('createFromArray'), array(), '', + $fileFactory = $this->getMock('Mage_Index_Model_Process_FileFactory', array('create'), array(), '', false ); $fileFactory->expects($this->exactly(2)) - ->method('createFromArray') + ->method('create') ->will($this->returnValue($fileModel)); $storage = new Mage_Index_Model_Lock_Storage($this->_dirsMock, $fileFactory); diff --git a/dev/tests/unit/testsuite/Mage/Index/Model/Process/FileFactoryTest.php b/dev/tests/unit/testsuite/Mage/Index/Model/Process/FileFactoryTest.php index c48cdc9c78fdb..64a96d0c4ee26 100644 --- a/dev/tests/unit/testsuite/Mage/Index/Model/Process/FileFactoryTest.php +++ b/dev/tests/unit/testsuite/Mage/Index/Model/Process/FileFactoryTest.php @@ -47,15 +47,15 @@ class Mage_Index_Model_Process_FileFactoryTest extends PHPUnit_Framework_TestCas 'key' => 'value' ); - public function testCreateFromArray() + public function testCreate() { $objectManagerMock = $this->getMock('Magento_ObjectManager', array(), array(), '', false); $objectManagerMock->expects($this->once()) ->method('create') - ->with(self::EXPECTED_CLASS_NAME, $this->_arguments, false) + ->with(self::EXPECTED_CLASS_NAME, $this->_arguments) ->will($this->returnValue(self::CREATE_RESULT)); $factory = new Mage_Index_Model_Process_FileFactory($objectManagerMock); - $this->assertEquals(self::CREATE_RESULT, $factory->createFromArray($this->_arguments)); + $this->assertEquals(self::CREATE_RESULT, $factory->create($this->_arguments)); } } diff --git a/dev/tests/unit/testsuite/Mage/Index/Model/ProcessTest.php b/dev/tests/unit/testsuite/Mage/Index/Model/ProcessTest.php index 9f67333bace0e..b52fb6f0786e6 100644 --- a/dev/tests/unit/testsuite/Mage/Index/Model/ProcessTest.php +++ b/dev/tests/unit/testsuite/Mage/Index/Model/ProcessTest.php @@ -102,11 +102,6 @@ protected function _prepareMocksForTestLock($nonBlocking) */ protected function _prepareIndexProcess() { - /** @var $eventDispatcher Mage_Core_Model_Event_Manager */ - $eventDispatcher = $this->getMock('Mage_Core_Model_Event_Manager', array(), array(), '', false); - /** @var $cacheManager Mage_Core_Model_Cache */ - $cacheManager = $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false); - $lockStorage = $this->getMock('Mage_Index_Model_Lock_Storage', array('getFile'), array(), '', false); $lockStorage->expects($this->once()) ->method('getFile') @@ -118,14 +113,12 @@ protected function _prepareIndexProcess() array(), '', false, false, true, array('getIdFieldName') ); $resource->expects($this->any())->method('getIdFieldName')->will($this->returnValue('process_id')); - $this->_indexProcess = new Mage_Index_Model_Process( - $eventDispatcher, - $cacheManager, - $lockStorage, - $resource, - null, - array('process_id' => self::PROCESS_ID) - ); + $helper = new Magento_Test_Helper_ObjectManager($this); + $this->_indexProcess = $helper->getObject('Mage_Index_Model_Process', array( + 'lockStorage' => $lockStorage, + 'resource' => $resource, + 'data' => array('process_id' => self::PROCESS_ID) + )); } public function testUnlock() diff --git a/dev/tests/unit/testsuite/Mage/Install/Model/EntryPoint/UpgradeTest.php b/dev/tests/unit/testsuite/Mage/Install/Model/EntryPoint/UpgradeTest.php new file mode 100644 index 0000000000000..d55e29d98eac0 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Install/Model/EntryPoint/UpgradeTest.php @@ -0,0 +1,98 @@ +_config = $this->getMock('Mage_Core_Model_Config_Primary', array('getParam'), array(), '', false); + + $cacheFrontend = $this->getMockForAbstractClass('Magento_Cache_FrontendInterface'); + $cacheFrontend->expects($this->once())->method('clean')->with('all', array()); + $cacheFrontendPool = $this->getMock( + 'Mage_Core_Model_Cache_Frontend_Pool', array('valid', 'current'), array( + $this->_config, + $this->getMock('Mage_Core_Model_Cache_Frontend_Factory', array(), array(), '', false), + ) + ); + $cacheFrontendPool->expects($this->at(0))->method('valid')->will($this->returnValue(true)); + $cacheFrontendPool->expects($this->once())->method('current')->will($this->returnValue($cacheFrontend)); + + $update = $this->getMock('Mage_Core_Model_Db_Updater', array('updateScheme', 'updateData'), array(), '', false); + $update->expects($this->once())->method('updateScheme'); + $update->expects($this->once())->method('updateData'); + + $this->_indexer = $this->getMock( + 'Mage_Index_Model_Indexer', array('reindexAll', 'reindexRequired'), array(), '', false + ); + + $this->_objectManager = $this->getMock('Magento_ObjectManager'); + $this->_objectManager->expects($this->any())->method('get')->will($this->returnValueMap(array( + array('Mage_Core_Model_Cache_Frontend_Pool', $cacheFrontendPool), + array('Mage_Core_Model_Db_Updater', $update), + array('Mage_Core_Model_Config_Primary', $this->_config), + array('Mage_Index_Model_Indexer', $this->_indexer), + ))); + } + + /** + * @param string $reindexMode + * @param int $reindexAllCount + * @param int $reindexReqCount + * @dataProvider processRequestDataProvider + */ + public function testProcessRequest($reindexMode, $reindexAllCount, $reindexReqCount) + { + $this->_indexer->expects($this->exactly($reindexAllCount))->method('reindexAll'); + $this->_indexer->expects($this->exactly($reindexReqCount))->method('reindexRequired'); + $this->_config->expects($this->once())->method('getParam')->with(Mage_Install_Model_EntryPoint_Upgrade::REINDEX) + ->will($this->returnValue($reindexMode)); + Mage::reset(); // hack to reset object manager if it happens to be set in this class already + $upgrade = new Mage_Install_Model_EntryPoint_Upgrade($this->_config, $this->_objectManager); + $upgrade->processRequest(); + } + + public function processRequestDataProvider() + { + return array( + 'no reindex' => array('', 0, 0), + 'reindex all' => array(Mage_Install_Model_EntryPoint_Upgrade::REINDEX_ALL, 1, 0), + 'reindex required' => array(Mage_Install_Model_EntryPoint_Upgrade::REINDEX_INVALID, 0, 1), + ); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Page/Block/Html/HeadTest.php b/dev/tests/unit/testsuite/Mage/Page/Block/Html/HeadTest.php new file mode 100644 index 0000000000000..5a0de465d67da --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Page/Block/Html/HeadTest.php @@ -0,0 +1,135 @@ +_objectManager = $this->getMock('Magento_ObjectManager', array('get', 'create', 'configure')); + $this->_pageAssets = $this->getMock('Mage_Page_Model_Asset_GroupedCollection', array(), array(), '', false); + $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); + $arguments = $objectManagerHelper->getConstructArguments( + 'Mage_Page_Block_Html_Head', + array('page' => new Mage_Core_Model_Page($this->_pageAssets), 'objectManager' => $this->_objectManager) + ); + $this->_block = $objectManagerHelper->getObject('Mage_Page_Block_Html_Head', $arguments); + } + + protected function tearDown() + { + $this->_pageAssets = null; + $this->_objectManager = null; + $this->_block = null; + } + + public function testAddCss() + { + $this->_pageAssets->expects($this->once()) + ->method('add') + ->with( + Mage_Core_Model_Design_Package::CONTENT_TYPE_CSS . '/test.css', + $this->isInstanceOf('Mage_Core_Model_Page_Asset_ViewFile') + ); + $assetViewFile = $this->getMock('Mage_Core_Model_Page_Asset_ViewFile', array(), array(), '', false); + $this->_objectManager->expects($this->once('')) + ->method('create') + ->with('Mage_Core_Model_Page_Asset_ViewFile') + ->will($this->returnValue($assetViewFile)); + $this->_block->addCss('test.css'); + } + + public function testAddJs() + { + $this->_pageAssets->expects($this->once()) + ->method('add') + ->with( + Mage_Core_Model_Design_Package::CONTENT_TYPE_JS . '/test.js', + $this->isInstanceOf('Mage_Core_Model_Page_Asset_ViewFile') + ); + $assetViewFile = $this->getMock('Mage_Core_Model_Page_Asset_ViewFile', array(), array(), '', false); + $this->_objectManager->expects($this->once('')) + ->method('create') + ->with('Mage_Core_Model_Page_Asset_ViewFile') + ->will($this->returnValue($assetViewFile)); + $this->_block->addJs('test.js'); + } + + public function testAddRss() + { + $this->_pageAssets->expects($this->once()) + ->method('add') + ->with( + 'link/http://127.0.0.1/test.rss', + $this->isInstanceOf('Mage_Core_Model_Page_Asset_Remote'), + array('attributes' => 'rel="alternate" type="application/rss+xml" title="RSS Feed"') + ); + $assetRemoteFile = $this->getMock('Mage_Core_Model_Page_Asset_Remote', array(), array(), '', false); + $this->_objectManager->expects($this->once('')) + ->method('create') + ->with('Mage_Core_Model_Page_Asset_Remote') + ->will($this->returnValue($assetRemoteFile)); + + $this->_block->addRss('RSS Feed', 'http://127.0.0.1/test.rss'); + } + + public function testAddLinkRel() + { + $this->_pageAssets->expects($this->once()) + ->method('add') + ->with( + 'link/http://127.0.0.1/', + $this->isInstanceOf('Mage_Core_Model_Page_Asset_Remote'), + array('attributes' => 'rel="rel"') + ); + $assetRemoteFile = $this->getMock('Mage_Core_Model_Page_Asset_Remote', array(), array(), '', false); + $this->_objectManager->expects($this->once('')) + ->method('create') + ->with('Mage_Core_Model_Page_Asset_Remote') + ->will($this->returnValue($assetRemoteFile)); + $this->_block->addLinkRel('rel', 'http://127.0.0.1/'); + } + + public function testRemoveItem() + { + $this->_pageAssets->expects($this->once()) + ->method('remove') + ->with('css/test.css'); + $this->_block->removeItem('css', 'test.css'); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Page/Block/Html/HeaderTest.php b/dev/tests/unit/testsuite/Mage/Page/Block/Html/HeaderTest.php index a9284f645bfd3..ca08be8d851f5 100644 --- a/dev/tests/unit/testsuite/Mage/Page/Block/Html/HeaderTest.php +++ b/dev/tests/unit/testsuite/Mage/Page/Block/Html/HeaderTest.php @@ -68,7 +68,7 @@ public function testGetLogoSrc() 'helperFactory' => $helperFactory, 'dirs' => $dirsMock ); - $block = $objectManager->getBlock('Mage_Page_Block_Html_Header', $arguments); + $block = $objectManager->getObject('Mage_Page_Block_Html_Header', $arguments); $this->assertEquals('http://localhost/pub/media/logo/default/image.gif', $block->getLogoSrc()); } diff --git a/dev/tests/unit/testsuite/Mage/Page/Model/Asset/GroupedCollectionTest.php b/dev/tests/unit/testsuite/Mage/Page/Model/Asset/GroupedCollectionTest.php new file mode 100644 index 0000000000000..0e67434b68eb0 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Page/Model/Asset/GroupedCollectionTest.php @@ -0,0 +1,160 @@ +getMock('Magento_ObjectManager'); + $objectManager + ->expects($this->any()) + ->method('create') + ->with('Mage_Page_Model_Asset_PropertyGroup') + ->will($this->returnCallback(array($this, 'createAssetGroup'))) + ; + $this->_object = new Mage_Page_Model_Asset_GroupedCollection($objectManager); + $this->_asset = new Mage_Core_Model_Page_Asset_Remote('http://127.0.0.1/magento/test.css'); + $this->_object->add('asset', $this->_asset); + } + + protected function tearDown() + { + $this->_object = null; + $this->_asset = null; + } + + /** + * Return newly created asset group. Used as a stub for object manger's creation operation. + * + * @param string $class + * @param array $arguments + * @return Mage_Page_Model_Asset_PropertyGroup + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function createAssetGroup($class, array $arguments) + { + return new Mage_Page_Model_Asset_PropertyGroup($arguments['properties']); + } + + /** + * Assert that actual asset groups equal to expected ones + * + * @param array $expectedGroups + * @param array $actualGroupObjects + */ + protected function _assertGroups(array $expectedGroups, array $actualGroupObjects) + { + $this->assertInternalType('array', $actualGroupObjects); + $actualGroups = array(); + /** @var $actualGroup Mage_Page_Model_Asset_PropertyGroup */ + foreach ($actualGroupObjects as $actualGroup) { + $this->assertInstanceOf('Mage_Page_Model_Asset_PropertyGroup', $actualGroup); + $actualGroups[] = array( + 'properties' => $actualGroup->getProperties(), + 'assets' => $actualGroup->getAll(), + ); + } + $this->assertEquals($expectedGroups, $actualGroups); + } + + public function testAdd() + { + $assetNew = new Mage_Core_Model_Page_Asset_Remote('http://127.0.0.1/magento/test_new.css'); + $this->_object->add('asset_new', $assetNew, array('test_property' => 'test_value')); + $this->assertEquals(array('asset' => $this->_asset, 'asset_new' => $assetNew), $this->_object->getAll()); + } + + public function testRemove() + { + $this->_object->remove('asset'); + $this->assertEquals(array(), $this->_object->getAll()); + } + + public function testGetGroups() + { + $cssAsset = new Mage_Core_Model_Page_Asset_Remote('http://127.0.0.1/style.css', 'css'); + $jsAsset = new Mage_Core_Model_Page_Asset_Remote('http://127.0.0.1/script.js', 'js'); + $jsAssetAllowingMerge = $this->getMockForAbstractClass('Mage_Core_Model_Page_Asset_MergeableInterface'); + $jsAssetAllowingMerge->expects($this->any())->method('getContentType')->will($this->returnValue('js')); + + // assets with identical properties should be grouped together + $this->_object->add('css_asset_one', $cssAsset, array('property' => 'test_value')); + $this->_object->add('css_asset_two', $cssAsset, array('property' => 'test_value')); + + // assets with different properties should go to different groups + $this->_object->add('css_asset_three', $cssAsset, array('property' => 'different_value')); + $this->_object->add('js_asset_one', $jsAsset, array('property' => 'test_value')); + + // assets with identical properties in a different order should be grouped + $this->_object->add('js_asset_two', $jsAsset, array('property1' => 'value1', 'property2' => 'value2')); + $this->_object->add('js_asset_three', $jsAsset, array('property2' => 'value2', 'property1' => 'value1')); + + // assets allowing merge should go to separate group regardless of having identical properties + $this->_object->add('asset_allowing_merge', $jsAssetAllowingMerge, array('property' => 'test_value')); + + $expectedGroups = array( + array( + 'properties' => array('content_type' => 'unknown', 'can_merge' => false), + 'assets' => array('asset' => $this->_asset), + ), + array( + 'properties' => array('property' => 'test_value', 'content_type' => 'css', 'can_merge' => false), + 'assets' => array('css_asset_one' => $cssAsset, 'css_asset_two' => $cssAsset), + ), + array( + 'properties' => array('property' => 'different_value', 'content_type' => 'css', 'can_merge' => false), + 'assets' => array('css_asset_three' => $cssAsset), + ), + array( + 'properties' => array('property' => 'test_value', 'content_type' => 'js', 'can_merge' => false), + 'assets' => array('js_asset_one' => $jsAsset), + ), + array( + 'properties' => array( + 'property1' => 'value1', 'property2' => 'value2', 'content_type' => 'js', 'can_merge' => false, + ), + 'assets' => array('js_asset_two' => $jsAsset, 'js_asset_three' => $jsAsset), + ), + array( + 'properties' => array('property' => 'test_value', 'content_type' => 'js', 'can_merge' => true), + 'assets' => array('asset_allowing_merge' => $jsAssetAllowingMerge), + ), + ); + + $this->_assertGroups($expectedGroups, $this->_object->getGroups()); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Page/Model/Asset/PropertyGroupTest.php b/dev/tests/unit/testsuite/Mage/Page/Model/Asset/PropertyGroupTest.php new file mode 100644 index 0000000000000..6e47584812457 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Page/Model/Asset/PropertyGroupTest.php @@ -0,0 +1,50 @@ +_object = new Mage_Page_Model_Asset_PropertyGroup(array('test_property' => 'test_value')); + } + + public function testGetProperties() + { + $this->assertEquals(array('test_property' => 'test_value'), $this->_object->getProperties()); + } + + public function testGetProperty() + { + $this->assertEquals('test_value', $this->_object->getProperty('test_property')); + $this->assertNull($this->_object->getProperty('non_existing_property')); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Payment/Block/Form/ContainerTest.php b/dev/tests/unit/testsuite/Mage/Payment/Block/Form/ContainerTest.php index 12723960c5599..09900394ffbdd 100644 --- a/dev/tests/unit/testsuite/Mage/Payment/Block/Form/ContainerTest.php +++ b/dev/tests/unit/testsuite/Mage/Payment/Block/Form/ContainerTest.php @@ -36,8 +36,8 @@ class Mage_Payment_Block_Form_ContainerAbstractTest extends PHPUnit_Framework_Te public function testSetMethodFormTemplate() { $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); - $childBlockA = $objectManagerHelper->getBlock('Mage_Core_Block_Template'); - $childBlockB = $objectManagerHelper->getBlock('Mage_Core_Block_Template'); + $childBlockA = $objectManagerHelper->getObject('Mage_Core_Block_Template'); + $childBlockB = $objectManagerHelper->getObject('Mage_Core_Block_Template'); $func = function ($blockName) use ($childBlockA, $childBlockB) { switch ($blockName) { diff --git a/dev/tests/unit/testsuite/Mage/Payment/Block/Info/ContainerAbstractTest.php b/dev/tests/unit/testsuite/Mage/Payment/Block/Info/ContainerAbstractTest.php index f6deceec807ed..43a81a8316311 100644 --- a/dev/tests/unit/testsuite/Mage/Payment/Block/Info/ContainerAbstractTest.php +++ b/dev/tests/unit/testsuite/Mage/Payment/Block/Info/ContainerAbstractTest.php @@ -35,14 +35,14 @@ public function testSetInfoTemplate() $block = $this->getMock('Mage_Payment_Block_Info_ContainerAbstract', array('getChildBlock', 'getPaymentInfo'), array(), '', false); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); - $paymentInfo = $objectManagerHelper->getModel('Mage_Payment_Model_Info'); - $methodInstance = $objectManagerHelper->getModel('Mage_Payment_Model_Method_Checkmo'); + $paymentInfo = $objectManagerHelper->getObject('Mage_Payment_Model_Info'); + $methodInstance = $objectManagerHelper->getObject('Mage_Payment_Model_Method_Checkmo'); $paymentInfo->setMethodInstance($methodInstance); $block->expects($this->atLeastOnce()) ->method('getPaymentInfo') ->will($this->returnValue($paymentInfo)); - $childBlock = $objectManagerHelper->getBlock('Mage_Core_Block_Template'); + $childBlock = $objectManagerHelper->getObject('Mage_Core_Block_Template'); $block->expects($this->atLeastOnce()) ->method('getChildBlock') ->with('payment.info.checkmo') diff --git a/dev/tests/unit/testsuite/Mage/Payment/Block/Info/InstructionsTest.php b/dev/tests/unit/testsuite/Mage/Payment/Block/Info/InstructionsTest.php index a10f43e8de9b9..cb4368ee09115 100644 --- a/dev/tests/unit/testsuite/Mage/Payment/Block/Info/InstructionsTest.php +++ b/dev/tests/unit/testsuite/Mage/Payment/Block/Info/InstructionsTest.php @@ -49,8 +49,8 @@ protected function setUp() { $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); $this->_method = new Varien_Object(); - $this->_info = $objectManagerHelper->getModel('Mage_Payment_Model_Info'); - $this->_instructions = $objectManagerHelper->getBlock('Mage_Payment_Block_Info_Instructions'); + $this->_info = $objectManagerHelper->getObject('Mage_Payment_Model_Info'); + $this->_instructions = $objectManagerHelper->getObject('Mage_Payment_Block_Info_Instructions'); $this->_info->setMethodInstance($this->_method); $this->_instructions->setInfo($this->_info); diff --git a/dev/tests/unit/testsuite/Mage/Sales/Model/Config/OrderTest.php b/dev/tests/unit/testsuite/Mage/Sales/Model/Config/OrderTest.php index c502a7255b158..31b25907422ea 100644 --- a/dev/tests/unit/testsuite/Mage/Sales/Model/Config/OrderTest.php +++ b/dev/tests/unit/testsuite/Mage/Sales/Model/Config/OrderTest.php @@ -32,7 +32,9 @@ class Mage_Sales_Model_Config_OrderedTest extends PHPUnit_Framework_TestCase */ public function testGetSortedCollectorCodes($totalConfig, $expectedResult) { - $mock = $this->getMockForAbstractClass('Mage_Sales_Model_Config_Ordered'); + $mock = $this->getMockForAbstractClass('Mage_Sales_Model_Config_Ordered', array( + $this->getMock('Mage_Core_Model_Cache_Type_Config', array(), array(), '', false) + )); $method = new ReflectionMethod($mock, '_getSortedCollectorCodes'); $method->setAccessible(true); diff --git a/dev/tests/unit/testsuite/Mage/Sales/Model/Order/Invoice/Total/ShippingTest.php b/dev/tests/unit/testsuite/Mage/Sales/Model/Order/Invoice/Total/ShippingTest.php index aa2c8fc64d5fc..4a70eb25ef3b8 100644 --- a/dev/tests/unit/testsuite/Mage/Sales/Model/Order/Invoice/Total/ShippingTest.php +++ b/dev/tests/unit/testsuite/Mage/Sales/Model/Order/Invoice/Total/ShippingTest.php @@ -39,9 +39,7 @@ protected function _getInvoiceCollection(array $invoicesData) $result = new Varien_Data_Collection(); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); foreach ($invoicesData as $oneInvoiceData) { - $arguments = $objectManagerHelper->getConstructArguments( - Magento_Test_Helper_ObjectManager::MODEL_ENTITY, $className, array('data' => $oneInvoiceData) - ); + $arguments = $objectManagerHelper->getConstructArguments($className, array('data' => $oneInvoiceData)); /** @var $prevInvoice Mage_Sales_Model_Order_Invoice */ $prevInvoice = $this->getMock($className, array('_init'), $arguments); $result->addItem($prevInvoice); diff --git a/dev/tests/unit/testsuite/Mage/Sales/Model/Order/Shipment/TrackTest.php b/dev/tests/unit/testsuite/Mage/Sales/Model/Order/Shipment/TrackTest.php index 39dcf4858f3de..d41807f23beeb 100644 --- a/dev/tests/unit/testsuite/Mage/Sales/Model/Order/Shipment/TrackTest.php +++ b/dev/tests/unit/testsuite/Mage/Sales/Model/Order/Shipment/TrackTest.php @@ -35,7 +35,7 @@ class Mage_Sales_Model_Order_Shipment_TrackTest extends PHPUnit_Framework_TestCa protected function setUp() { $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); - $this->_model = $objectManagerHelper->getModel('Mage_Sales_Model_Order_Shipment_Track'); + $this->_model = $objectManagerHelper->getObject('Mage_Sales_Model_Order_Shipment_Track'); } public function testAddData() diff --git a/dev/tests/unit/testsuite/Mage/Shipping/Model/Carrier/Service/ConfigTest.php b/dev/tests/unit/testsuite/Mage/Shipping/Model/Carrier/Service/ConfigTest.php new file mode 100644 index 0000000000000..b5cfb1c9aa495 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Shipping/Model/Carrier/Service/ConfigTest.php @@ -0,0 +1,82 @@ +getConfigData($query); + + $this->assertSame($expected, $result); + } + + public function testNoConfigSet() + { + $config = new Mage_Shipping_Model_Carrier_Service_Config(array()); + + $result = $config->getConfigData('something'); + + $this->assertNull($result); + } + + public function configData() + { + return array( + 'simple' => array( + 'config' => array( + 'active' => true + ), + 'query' => 'active', + 'expected' => true, + ), + 'nested' => array( + 'config' => array( + 'active' => true, + 'something' => array( + 'very' => array( + 'nested' => 'nested value' + ) + ) + ), + 'query' => 'something/very/nested', + 'expected' => 'nested value', + ), + 'missing' => array( + 'config' => array( + 'active' => true, + ), + 'query' => 'something/that/doesnt_exist', + 'expected' => null, + ), + ); + } + +} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Mage/Shipping/Model/Carrier/Service/ResultTest.php b/dev/tests/unit/testsuite/Mage/Shipping/Model/Carrier/Service/ResultTest.php new file mode 100644 index 0000000000000..297b4c8e569f6 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Shipping/Model/Carrier/Service/ResultTest.php @@ -0,0 +1,134 @@ +_rateResult = $this->getMockBuilder('Mage_Shipping_Model_Rate_Result') + ->setMethods(array('append')) + ->getMock(); + + $this->_serviceResult = $this->getMockBuilder('Mage_Shipping_Model_Carrier_Service_Result') + ->disableOriginalConstructor() + ->setMethods(array('_getRateResult', '_getCarrierServiceMethod')) + ->getMock(); + + $this->_serviceResult->expects($this->once()) + ->method('_getRateResult') + ->will($this->returnValue($this->_rateResult)); + } + + public function testCreateRateResultNull() + { + $rateResult = $this->_serviceResult->createRateResult(null); + + $this->assertSame($this->_rateResult, $rateResult); + } + + public function testCreateRateResultEmptyArray() + { + $rateResult = $this->_serviceResult->createRateResult(array()); + + $this->assertSame($this->_rateResult, $rateResult); + } + + public function testCreateRateResultEmptyShippingMethods() + { + $rateResult = $this->_serviceResult->createRateResult(array( + 'shippingMethods' => array() + )); + + $this->assertSame($this->_rateResult, $rateResult); + } + + public function testCreateRateResultOneShippingMethod() + { + $shippingMethod1 = array('random' => 'value'); + $this->_setupCarrierServiceMethod(0, $shippingMethod1); + + $rateResult = $this->_serviceResult->createRateResult(array( + 'shippingMethods' => array( + $shippingMethod1 + ) + )); + + $this->assertSame($this->_rateResult, $rateResult); + } + + public function testCreateRateResultMultipleShippingMethod() + { + $shippingMethod1 = array('random' => 'value'); + $shippingMethod2 = array('hello' => 'world'); + + $this->_setupCarrierServiceMethod(0, $shippingMethod1); + $this->_setupCarrierServiceMethod(1, $shippingMethod2); + + $rateResult = $this->_serviceResult->createRateResult(array( + 'shippingMethods' => array( + $shippingMethod1, + $shippingMethod2, + ) + )); + + $this->assertSame($this->_rateResult, $rateResult); + } + + protected function _setupCarrierServiceMethod($atIndex, $args) + { + $serviceMethod = $this->getMockBuilder('Mage_Shipping_Model_Carrier_Service_Method') + ->disableOriginalConstructor() + ->setMethods(array('createRateResultMethod')) + ->getMock(); + + /* need to add + 1 here because of the _getRateResult call...? PHPUnit bug? */ + $this->_serviceResult->expects($this->at($atIndex + 1)) + ->method('_getCarrierServiceMethod') + ->with($args) + ->will($this->returnValue($serviceMethod)); + + $rateResult = $this->getMockBuilder('Mage_Shipping_Model_Rate_Result') + ->disableOriginalConstructor() + ->getMock(); + + $serviceMethod->expects($this->once()) + ->method('createRateResultMethod') + ->will($this->returnValue($rateResult)); + + $this->_rateResult->expects($this->at($atIndex)) + ->method('append') + ->with($rateResult); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Shipping/Model/Carrier/ServiceAdapterTest.php b/dev/tests/unit/testsuite/Mage/Shipping/Model/Carrier/ServiceAdapterTest.php new file mode 100644 index 0000000000000..7746d2e38309d --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Shipping/Model/Carrier/ServiceAdapterTest.php @@ -0,0 +1,256 @@ + 'true', 'subscriber' => self::EXTENSION_ID); + + protected $_groundShipping = array( + 'carrier' => 'ups', + 'carrier_title' => 'United Parcel Service', + 'method' => 'ground', + 'method_title' => 'UPS Ground', + 'price' => 3.25, + ); + + protected $_airShipping = array( + 'carrier' => 'ups', + 'carrier_title' => 'United Parcel Service', + 'method' => '2nd day air', + 'method_title' => 'UPS 2nd Day Air', + 'price' => 13.25, + 'cost' => 10.25 + ); + + public function setUp() + { + parent::setUp(); + + $this->_serviceFactory = $this->getMockBuilder('Magento_ObjectManager') + ->disableOriginalConstructor() + ->getMock(); + $this->_testService = $this->getMock('Mage_Shipping_Model_Carrier_Service_Interface', array('getRates')); + + $this->_serviceFactory->expects($this->any()) + ->method('create') + ->will($this->returnValue($this->_testService)); + + $this->_request = $this->getMockBuilder('Mage_Shipping_Model_Rate_Request') + ->disableOriginalConstructor() + ->getMock(); + + $this->_rateResult = $this->getMockBuilder('Mage_Shipping_Model_Rate_Result') + ->disableOriginalConstructor() + ->setMethods(array('setError')) + ->getMock(); + + $this->_serviceResult = $this->getMockBuilder('Mage_Shipping_Model_Carrier_Service_Result') + ->disableOriginalConstructor() + ->setMethods(array('createRateResult', "createErrorRateResult")) + ->getMock(); + + $this->_carrierMetadata = new Mage_Shipping_Model_Carrier_Metadata($this->_carrierCode, $this->_carrierConfig); + + $logger = $this->getMockBuilder('Mage_Core_Model_Logger') + ->disableOriginalConstructor() + ->setMethods(array('logException')) + ->getMock(); + + $this->_serviceAdapter = $this->getMockBuilder('Mage_Shipping_Model_Carrier_ServiceAdapter') + ->setConstructorArgs(array($logger, "testService", $this->_serviceFactory, $this->_serviceResult)) + ->setMethods(array('isActive', '_getCarrierMetadata', + '_constructInput', '_getRateResult', '_getServiceResult' )) + ->getMock(); + $this->_serviceAdapter->expects($this->any()) + ->method('isActive') + ->will($this->returnValue(true)); + $this->_serviceAdapter->expects($this->any()) + ->method('_constructInput') + ->will($this->returnValue($this->_mockServiceData())); + $this->_serviceAdapter->expects($this->any()) + ->method('_getCarrierMetadata') + ->will($this->returnValue($this->_carrierMetadata)); + } + + public function testCollectRatesWrapsMethods() + { + $methods = array($this->_groundShipping, $this->_airShipping); + + $rateResult = $this->_collectRates($methods); + + $this->assertSame($this->_rateResult, $rateResult); + } + + public function testCollectRatesReturnsEmptyWhenEmptyResponse() + { + $methods = array(); + + $rateResult = $this->_collectRates($methods); + + $this->assertSame($this->_rateResult, $rateResult); + } + + public function testCollectRatesReturnsMethodWhenPartialResponse() + { + $methods = array(array('carrier' => 'partial')); + + $rateResult = $this->_collectRates($methods); + + $this->assertSame($this->_rateResult, $rateResult); + } + + public function testCollectRatesReturnsEmptyWhenExceptionThrown() + { + $this->_expectExceptionThrown(); + $methods = array($this->_groundShipping, $this->_airShipping); + + $this->getMockBuilder('Mage_Core_Model_Logger') + ->disableOriginalConstructor() + ->setMethods(array('logException')) + ->getMock(); + Mage::getObjectManager(); //->addSharedInstance($logger, 'Mage_Core_Model_Logger'); + + $this->_collectRates($methods, false); + } + + public function testCollectRatesGeneratesProperServiceInput() + { + $this->_expectProperServiceInputs(); + $this->_createRateResultReturns(null); + + $this->_collectRates(); + } + + protected function _expectProperServiceInputs() + { + $this->_getEventName(); + $data = $this->_mockServiceData(); + $this->_testService->expects($this->once()) + ->method('getRates') + ->with($this->equalTo($data)); + } + + protected function _expectExceptionThrown() + { + /* this is required to stop Mage::logException from complaining */ + Mage::getObjectManager(); + + $this->_testService->expects($this->once()) + ->method('getRates') + ->will($this->throwException(new Exception('Test Exception'))); + + $this->_serviceAdapter->expects($this->once()) + ->method('_getServiceResult') + ->will($this->returnValue($this->_serviceResult)); + + $this->_serviceResult->expects($this->once()) + ->method('createErrorRateResult'); + } + + protected function _getEventName() + { + return 'shipping/get_rates'; + } + + protected function _mockServiceData() + { + $serviceData = array(); + $serviceData['carrier_configuration'] = $this->_carrierConfig; + $serviceData['rate_request'] = $this->_request; + + return $serviceData; + } + + protected function _serviceReturns($methods) + { + $output = $this->_packageOutput($methods); + $this->_testService->expects($this->once()) + ->method('getRates') + ->will($this->returnValue($output)); + return $output; + } + + protected function _createRateResultReturns($serviceOutput) + { + $this->_serviceAdapter->expects($this->once()) + ->method('_getServiceResult') + ->will($this->returnValue($this->_serviceResult)); + $this->_serviceResult->expects($this->once()) + ->method('createRateResult') + ->with($serviceOutput) + ->will($this->returnValue($this->_rateResult)); + } + + protected function _collectRates($methods = null, $expectRateResult = true) + { + if (!is_null($methods)) { + $serviceOutput = $this->_serviceReturns($methods); + if ($expectRateResult) { + $this->_createRateResultReturns($serviceOutput); + } + } + return $this->_serviceAdapter->collectRates($this->_request); + } + + protected function _packageOutput($methods) + { + $shippingMethods = array(); + foreach ($methods as $i => $method) { + $shippingMethods['method_'.$i] = $method; + } + $output = array( + 'shipping_methods' => $shippingMethods + ); + return $output; + } + +} diff --git a/dev/tests/unit/testsuite/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/TagTestCaseAbstract.php b/dev/tests/unit/testsuite/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/TagTestCaseAbstract.php index 1a56b34c1765a..b81cfcbb7407f 100644 --- a/dev/tests/unit/testsuite/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/TagTestCaseAbstract.php +++ b/dev/tests/unit/testsuite/Mage/Tag/Block/Adminhtml/Catalog/Product/Edit/Tab/TagTestCaseAbstract.php @@ -72,7 +72,7 @@ protected function setUp() 'urlBuilder' => $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false), 'data' => array('helpers' => array('Mage_Tag_Helper_Data' => $helperMock)) ); - $this->_model = $objectManagerHelper->getBlock($this->_modelName, $data); + $this->_model = $objectManagerHelper->getObject($this->_modelName, $data); } protected function tearDown() @@ -116,7 +116,7 @@ protected function _testCanShowTab() */ public function isAllowedCallback($data) { - return $data == 'Mage_Tag::tag'; + return $data == 'Mage_Tag::tag_all'; } protected function _testIsHidden() diff --git a/dev/tests/unit/testsuite/Mage/Tag/Block/Adminhtml/Customer/Edit/Tab/TagTest.php b/dev/tests/unit/testsuite/Mage/Tag/Block/Adminhtml/Customer/Edit/Tab/TagTest.php index be1e3c90dd3c9..d23fc53b98fdd 100644 --- a/dev/tests/unit/testsuite/Mage/Tag/Block/Adminhtml/Customer/Edit/Tab/TagTest.php +++ b/dev/tests/unit/testsuite/Mage/Tag/Block/Adminhtml/Customer/Edit/Tab/TagTest.php @@ -74,7 +74,7 @@ public function setUp() ) ); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); - $this->_model = $objectManagerHelper->getBlock('Mage_Tag_Block_Adminhtml_Customer_Edit_Tab_Tag', $arguments); + $this->_model = $objectManagerHelper->getObject('Mage_Tag_Block_Adminhtml_Customer_Edit_Tab_Tag', $arguments); } public function tearDown() @@ -112,7 +112,7 @@ protected function _getMockForCanShowTab($isCustomer, $isCustomerExist, $isAllow ) ); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); - $this->_model = $objectManagerHelper->getBlock('Mage_Tag_Block_Adminhtml_Customer_Edit_Tab_Tag', $arguments); + $this->_model = $objectManagerHelper->getObject('Mage_Tag_Block_Adminhtml_Customer_Edit_Tab_Tag', $arguments); if ($customer) { $this->_model->setCustomer($customer); } diff --git a/dev/tests/unit/testsuite/Mage/Tag/Block/Catalog/Product/Rss/LinkTest.php b/dev/tests/unit/testsuite/Mage/Tag/Block/Catalog/Product/Rss/LinkTest.php index 782986bc766a2..a5a5659966f1a 100644 --- a/dev/tests/unit/testsuite/Mage/Tag/Block/Catalog/Product/Rss/LinkTest.php +++ b/dev/tests/unit/testsuite/Mage/Tag/Block/Catalog/Product/Rss/LinkTest.php @@ -68,7 +68,7 @@ public function testGetLinkUrl($rssEnabled, $tagId, $existTagId, $expected) 'core_url_model' => $urlModelMock ); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); - $this->_model = $objectManagerHelper->getBlock('Mage_Tag_Block_Catalog_Product_Rss_Link', + $this->_model = $objectManagerHelper->getObject('Mage_Tag_Block_Catalog_Product_Rss_Link', array('data' => $data) ); diff --git a/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/FileTest.php b/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/FileTest.php index 642c3206a7792..244d9733fb0eb 100644 --- a/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/FileTest.php +++ b/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/FileTest.php @@ -31,7 +31,7 @@ public function testGetHtmlAttributes() { /** @var $fileBlock Mage_Theme_Block_Adminhtml_System_Design_Theme_Edit_Form_Element_File */ $helper = new Magento_Test_Helper_ObjectManager($this); - $fileBlock = $helper->getBlock('Mage_Theme_Block_Adminhtml_System_Design_Theme_Edit_Form_Element_File'); + $fileBlock = $helper->getObject('Mage_Theme_Block_Adminhtml_System_Design_Theme_Edit_Form_Element_File'); $this->assertContains('accept', $fileBlock->getHtmlAttributes()); $this->assertContains('multiple', $fileBlock->getHtmlAttributes()); } diff --git a/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/System/Design/Theme/Tab/CssTest.php b/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/System/Design/Theme/Tab/CssTest.php index c8e32bd454cdb..3f0018d2903f4 100644 --- a/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/System/Design/Theme/Tab/CssTest.php +++ b/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/System/Design/Theme/Tab/CssTest.php @@ -33,7 +33,7 @@ class Mage_Theme_Block_Adminhtml_System_Design_Theme_Tab_CssTest extends PHPUnit protected $_model; /** - * @var Magento_ObjectManager_Zend + * @var Magento_ObjectManager|PHPUnit_Framework_MockObject_MockObject */ protected $_objectManager; @@ -56,10 +56,9 @@ protected function _prepareModelArguments() $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); $filesystemHelper = new Magento_Test_Helper_FileSystem($this); - $this->_objectManager = $this->getMock('Magento_ObjectManager_Zend', array('get'), array(), '', false); - + $this->_objectManager = $this->getMock('Magento_ObjectManager'); + $constructArguments = $objectManagerHelper->getConstructArguments( - Magento_Test_Helper_ObjectManager::BLOCK_ENTITY, 'Mage_Theme_Block_Adminhtml_System_Design_Theme_Edit_Tab_Css', array( 'objectManager' => $this->_objectManager, diff --git a/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/System/Design/Theme/Tab/JsTest.php b/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/System/Design/Theme/Tab/JsTest.php index 9c9ea327544e9..80c887a428d6b 100644 --- a/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/System/Design/Theme/Tab/JsTest.php +++ b/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/System/Design/Theme/Tab/JsTest.php @@ -43,7 +43,6 @@ protected function setUp() $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); $constructArguments = $objectManagerHelper->getConstructArguments( - Magento_Test_Helper_ObjectManager::BLOCK_ENTITY, 'Mage_Theme_Block_Adminhtml_System_Design_Theme_Edit_Tab_Js', array( 'objectManager' => Mage::getObjectManager(), diff --git a/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/System/Design/Theme/TabAbstractTest.php b/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/System/Design/Theme/TabAbstractTest.php index df130f506526e..306d8dc0bcd77 100644 --- a/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/System/Design/Theme/TabAbstractTest.php +++ b/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/System/Design/Theme/TabAbstractTest.php @@ -35,10 +35,9 @@ class Mage_Theme_Block_Adminhtml_System_Design_Theme_TabAbstractTest extends PHP protected function setUp() { $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); - $objectManagerModel = $this->getMock('Magento_ObjectManager_Zend', array(), array(), '', false); + $objectManagerModel = $this->getMock('Magento_ObjectManager'); $constructArguments = $objectManagerHelper->getConstructArguments( - Magento_Test_Helper_ObjectManager::BLOCK_ENTITY, 'Mage_Theme_Block_Adminhtml_System_Design_Theme_Edit_Tab_Js', array( 'objectManager' => $objectManagerModel, diff --git a/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/ContentTest.php b/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/ContentTest.php index 2a3dfeca7ba4e..8efa80c98ead1 100644 --- a/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/ContentTest.php +++ b/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/ContentTest.php @@ -54,7 +54,6 @@ public function setUp() $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); $constructArguments = $objectManagerHelper->getConstructArguments( - Magento_Test_Helper_ObjectManager::BLOCK_ENTITY, 'Mage_Theme_Block_Adminhtml_Wysiwyg_Files_Content', array( 'urlBuilder' => $this->_urlBuilder, diff --git a/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/TreeTest.php b/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/TreeTest.php index c695d510f7f2f..915ee8ecbced7 100644 --- a/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/TreeTest.php +++ b/dev/tests/unit/testsuite/Mage/Theme/Block/Adminhtml/Wysiwyg/Files/TreeTest.php @@ -49,7 +49,6 @@ public function setUp() $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); $constructArguments = $objectManagerHelper->getConstructArguments( - Magento_Test_Helper_ObjectManager::BLOCK_ENTITY, 'Mage_Theme_Block_Adminhtml_Wysiwyg_Files_Content', array('urlBuilder' => $this->_urlBuilder) ); diff --git a/dev/tests/unit/testsuite/Mage/Theme/Helper/StorageTest.php b/dev/tests/unit/testsuite/Mage/Theme/Helper/StorageTest.php index 8151776b7c44f..04d2d0174f1ff 100644 --- a/dev/tests/unit/testsuite/Mage/Theme/Helper/StorageTest.php +++ b/dev/tests/unit/testsuite/Mage/Theme/Helper/StorageTest.php @@ -69,10 +69,15 @@ public function setUp() $this->_session = $this->getMock('Mage_Backend_Model_Session', array(), array(), '', false); $this->_themeFactory = $this->getMock('Mage_Core_Model_Theme_Factory', array('create'), array(), '', false); - $this->_storageHelper = $this->getMock('Mage_Theme_Helper_Storage', array('_getRequest'), array(), '', false); + $this->_storageHelper = $this->getMock('Mage_Theme_Helper_Storage', + array('_getRequest', 'urlDecode'), array(), '', false + ); $this->_storageHelper->expects($this->any()) ->method('_getRequest') ->will($this->returnValue($this->_request)); + $this->_storageHelper->expects($this->any()) + ->method('urlDecode') + ->will($this->returnArgument(0)); $filesystemProperty = new ReflectionProperty($this->_storageHelper, '_filesystem'); $filesystemProperty->setAccessible(true); @@ -117,23 +122,6 @@ protected function _mockCurrentPath($path) $currentPathProperty->setValue($this->_storageHelper, $path); } - /** - * @covers Mage_Theme_Helper_Storage::convertPathToId - * @covers Mage_Theme_Helper_Storage::convertIdToPath - */ - public function testConvertPathToId() - { - $this->markTestIncomplete('MAGETWO-6406'); - $storageRoot = $this->_customizationPath . Magento_Filesystem::DIRECTORY_SEPARATOR - . Mage_Theme_Model_Wysiwyg_Storage::TYPE_IMAGE; - $this->_mockStorageRoot($storageRoot); - $path = $storageRoot . Magento_Filesystem::DIRECTORY_SEPARATOR . 'some_dir'; - - $pathId = $this->_storageHelper->convertPathToId($path); - $this->assertEquals('L3NvbWVfZGly', $pathId); - $this->assertEquals($path, $this->_storageHelper->convertIdToPath($pathId)); - } - /** * @covers Mage_Theme_Helper_Storage::getShortFilename */ @@ -177,78 +165,11 @@ public function testGetStorageRoot() $expectedStorageRoot = implode(Magento_Filesystem::DIRECTORY_SEPARATOR, array( $this->_customizationPath, - Mage_Core_Model_Theme_Files::PATH_PREFIX_CUSTOMIZED, Mage_Theme_Model_Wysiwyg_Storage::TYPE_IMAGE )); $this->assertEquals($expectedStorageRoot, $this->_storageHelper->getStorageRoot()); } - /** - * @covers Mage_Theme_Helper_Storage::getRelativeUrl - */ - public function testGetRelativeUrl() - { - $this->markTestIncomplete('MAGETWO-6406'); - $imageName = 'imageName.jpg'; - $dirOne = 'some_dir'; - $dirTwo = 'test_der'; - $nodePath = Magento_Filesystem::DIRECTORY_SEPARATOR - . implode(Magento_Filesystem::DIRECTORY_SEPARATOR, array($dirOne, $dirTwo)); - - $requestMap = array( - array(Mage_Theme_Helper_Storage::PARAM_NODE, null, $this->_storageHelper->urlEncode($nodePath)), - array(Mage_Theme_Helper_Storage::PARAM_FILENAME, null, $this->_storageHelper->urlEncode($imageName)), - array(Mage_Theme_Helper_Storage::PARAM_CONTENT_TYPE, null, Mage_Theme_Model_Wysiwyg_Storage::TYPE_IMAGE) - ); - $this->_request->expects($this->any()) - ->method('getParam') - ->will($this->returnValueMap($requestMap)); - - //'../image/some_dir/test_der/imageName.jpg' - $expectedPath = implode('/', array( - '..', - Mage_Theme_Model_Wysiwyg_Storage::TYPE_IMAGE, - $dirOne, - $dirTwo, - $imageName - )); - $this->assertEquals($expectedPath, $this->_storageHelper->getRelativeUrl()); - } - - /** - * @covers Mage_Theme_Helper_Storage::getCurrentPath - */ - public function testGetCurrentPath() - { - $this->markTestIncomplete('MAGETWO-6406'); - $subPath = Magento_Filesystem::DIRECTORY_SEPARATOR . 'some_dir'; - $encodedSubPath = $this->_storageHelper->urlEncode($subPath); - $storageRoot = $this->_customizationPath . Magento_Filesystem::DIRECTORY_SEPARATOR - . Mage_Theme_Model_Wysiwyg_Storage::TYPE_IMAGE; - - $expectedPath = $storageRoot . $subPath; - $this->_request->expects($this->once()) - ->method('getParam') - ->will($this->returnValue($encodedSubPath)); - - $this->_filesystem->expects($this->atLeastOnce()) - ->method('isDirectory') - ->with($expectedPath) - ->will($this->returnValue(true)); - - $filesystem = $this->_filesystem; - $filesystem::staticExpects($this->atLeastOnce()) - ->method('isPathInDirectory')->with($expectedPath, $storageRoot) - ->will($this->returnValue(true)); - - $filesystem::staticExpects($this->atLeastOnce()) - ->method('getAbsolutePath') - ->will($this->returnArgument(0)); - - $this->_mockStorageRoot($storageRoot); - $this->assertEquals($expectedPath, $this->_storageHelper->getCurrentPath()); - } - /** * @covers Mage_Theme_Helper_Storage::getThumbnailDirectory */ diff --git a/dev/tests/unit/testsuite/Mage/Theme/Model/Uploader/ServiceTest.php b/dev/tests/unit/testsuite/Mage/Theme/Model/Uploader/ServiceTest.php new file mode 100644 index 0000000000000..c55dc40c87908 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Theme/Model/Uploader/ServiceTest.php @@ -0,0 +1,271 @@ +getMock('Mage_Theme_Model_Uploader_Service', array('_getMaxUploadSize'), array(), '', false); + + $service->expects($this->once()) + ->method('_getMaxUploadSize') + ->with(Mage_Theme_Model_Uploader_Service::XML_PATH_CSS_UPLOAD_LIMIT) + ->will($this->returnValue('5M')); + + $this->assertEquals('5M', $service->getCssUploadMaxSize()); + } + + public function testGetJsUploadMaxSize() + { + /** @var $service Mage_Theme_Model_Uploader_Service */ + $service = $this->getMock('Mage_Theme_Model_Uploader_Service', array('_getMaxUploadSize'), array(), '', false); + + $service->expects($this->once()) + ->method('_getMaxUploadSize') + ->with(Mage_Theme_Model_Uploader_Service::XML_PATH_JS_UPLOAD_LIMIT) + ->will($this->returnValue('3M')); + + $this->assertEquals('3M', $service->getJsUploadMaxSize()); + } + + public function testGetFileContent() + { + $fileName = 'file.name'; + /** @var $filesystemMock Varien_Io_File */ + $filesystemMock = $this->getMock('Varien_Io_File', array('read'), array(), '', false, false); + /** @var $service Mage_Theme_Model_Uploader_Service */ + $service = $this->getMock('Mage_Theme_Model_Uploader_Service', array('getFilePath'), array(), '', false); + + $service->expects($this->once()) + ->method('getFilePath') + ->will($this->returnValue($fileName)); + + $filesystemMock->expects($this->once()) + ->method('read') + ->with($fileName) + ->will($this->returnValue('content from my file')); + + $property = new ReflectionProperty($service, '_fileIo'); + $property->setAccessible(true); + $property->setValue($service, $filesystemMock); + + $this->assertEquals('content from my file', $service->getFileContent()); + } + + public function testUploadCssFile() + { + $file['tmp_name'] = 'file.name'; + /** @var $service Mage_Theme_Model_Uploader_Service */ + $service = $this->getMock('Mage_Theme_Model_Uploader_Service', array('_getMaxUploadSize'), array(), '', false); + + $service->expects($this->once()) + ->method('_getMaxUploadSize') + ->with(Mage_Theme_Model_Uploader_Service::XML_PATH_CSS_UPLOAD_LIMIT) + ->will($this->returnValue('5')); + + $objectManager = $this->getMock('Magento_ObjectManager', array(), array(), '', false); + $uploader = $this->getMock('Mage_Core_Model_File_Uploader', array(), array(), '', false); + + $uploader->expects($this->once()) + ->method('getFileSize') + ->will($this->returnValue('3')); + + $uploader->expects($this->once()) + ->method('validateFile') + ->will($this->returnValue($file)); + + $objectManager->expects($this->once()) + ->method('create') + ->will($this->returnValue($uploader)); + + $property = new ReflectionProperty($service, '_objectManager'); + $property->setAccessible(true); + $property->setValue($service, $objectManager); + + $this->assertEquals('file.name', $service->uploadCssFile($file)->getFilePath()); + } + + /** + * @expectedException Mage_Core_Exception + */ + public function testUploadInvalidCssFile() + { + $file['tmp_name'] = 'file.name'; + /** @var $service Mage_Theme_Model_Uploader_Service */ + $service = $this->getMock( + 'Mage_Theme_Model_Uploader_Service', array('_getMaxUploadSize', 'getCssUploadMaxSizeInMb'), + array(), '', false + ); + + $dataHelper = $this->getMock('Mage_Core_Helper_Data', array(), array(), '', false); + + $service->expects($this->once()) + ->method('_getMaxUploadSize') + ->with(Mage_Theme_Model_Uploader_Service::XML_PATH_CSS_UPLOAD_LIMIT) + ->will($this->returnValue('10')); + + $service->expects($this->once()) + ->method('getCssUploadMaxSizeInMb') + ->will($this->returnValue('10')); + + $objectManager = $this->getMock('Magento_ObjectManager', array(), array(), '', false); + $uploader = $this->getMock('Mage_Core_Model_File_Uploader', array(), array(), '', false); + + $uploader->expects($this->once()) + ->method('getFileSize') + ->will($this->returnValue('30')); + + $objectManager->expects($this->once()) + ->method('create') + ->will($this->returnValue($uploader)); + + $objectManager->expects($this->once()) + ->method('get') + ->will($this->returnValue($dataHelper)); + + $property = new ReflectionProperty($service, '_objectManager'); + $property->setAccessible(true); + $property->setValue($service, $objectManager); + + $this->assertEquals('file.name', $service->uploadCssFile($file)->getFilePath()); + } + + public function testUploadJsFile() + { + $file['tmp_name'] = 'file.name'; + + /** @var $theme Mage_Core_Model_Theme */ + $theme = $this->getMock('Mage_Core_Model_Theme', array(), array(), '', false, false); + + /** @var $service Mage_Theme_Model_Uploader_Service */ + $service = $this->getMock( + 'Mage_Theme_Model_Uploader_Service', array('_getMaxUploadSize', 'getFileContent'), array(), '', false + ); + + $fileJs = $this->getMock( + 'Mage_Core_Model_Theme_Customization_Files_Js', array(), array(), '', false + ); + + $fileJs->expects($this->once()) + ->method('saveJsFile') + ->will($this->returnValue($file)); + + $service->expects($this->once()) + ->method('_getMaxUploadSize') + ->with(Mage_Theme_Model_Uploader_Service::XML_PATH_JS_UPLOAD_LIMIT) + ->will($this->returnValue('500')); + + $service->expects($this->once()) + ->method('getFileContent') + ->will($this->returnValue('Uploaded file content')); + + $objectManager = $this->getMock('Magento_ObjectManager', array(), array(), '', false); + $uploader = $this->getMock('Mage_Core_Model_File_Uploader', array(), array(), '', false); + + $uploader->expects($this->once()) + ->method('getFileSize') + ->will($this->returnValue('499')); + + $uploader->expects($this->once()) + ->method('validateFile') + ->will($this->returnValue($file)); + + $objectManager->expects($this->once()) + ->method('create') + ->will($this->returnValue($uploader)); + + $property = new ReflectionProperty($service, '_objectManager'); + $property->setAccessible(true); + $property->setValue($service, $objectManager); + + $property = new ReflectionProperty($service, '_filesJs'); + $property->setAccessible(true); + $property->setValue($service, $fileJs); + + $this->assertEquals('file.name', $service->uploadJsFile($file, $theme)->getFilePath()); + } + + /** + * @expectedException Mage_Core_Exception + */ + public function testUploadInvalidJsFile() + { + $file['tmp_name'] = 'file.name'; + + /** @var $theme Mage_Core_Model_Theme */ + $theme = $this->getMock('Mage_Core_Model_Theme', array(), array(), '', false); + + $dataHelper = $this->getMock('Mage_Core_Helper_Data', array(), array(), '', false); + + /** @var $service Mage_Theme_Model_Uploader_Service */ + $service = $this->getMock( + 'Mage_Theme_Model_Uploader_Service', array('_getMaxUploadSize', 'getFileContent', 'getJsUploadMaxSizeInMb'), + array(), '', false + ); + + $fileJs = $this->getMock( + 'Mage_Core_Model_Theme_Customization_Files_Js', array(), array(), '', false + ); + + $service->expects($this->once()) + ->method('_getMaxUploadSize') + ->with(Mage_Theme_Model_Uploader_Service::XML_PATH_JS_UPLOAD_LIMIT) + ->will($this->returnValue('100')); + + $service->expects($this->once()) + ->method('getJsUploadMaxSizeInMb') + ->will($this->returnValue('499')); + + $objectManager = $this->getMock('Magento_ObjectManager', array(), array(), '', false); + $uploader = $this->getMock('Mage_Core_Model_File_Uploader', array(), array(), '', false); + + $uploader->expects($this->once()) + ->method('getFileSize') + ->will($this->returnValue('499')); + + $objectManager->expects($this->once()) + ->method('create') + ->will($this->returnValue($uploader)); + + $objectManager->expects($this->once()) + ->method('get') + ->will($this->returnValue($dataHelper)); + + $property = new ReflectionProperty($service, '_objectManager'); + $property->setAccessible(true); + $property->setValue($service, $objectManager); + + $property = new ReflectionProperty($service, '_filesJs'); + $property->setAccessible(true); + $property->setValue($service, $fileJs); + + $this->assertEquals('file.name', $service->uploadJsFile($file, $theme)->getFilePath()); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Theme/Model/Wysiwyg/StorageTest.php b/dev/tests/unit/testsuite/Mage/Theme/Model/Wysiwyg/StorageTest.php index 6dbfebf348d8a..6b6110d4fbca3 100644 --- a/dev/tests/unit/testsuite/Mage/Theme/Model/Wysiwyg/StorageTest.php +++ b/dev/tests/unit/testsuite/Mage/Theme/Model/Wysiwyg/StorageTest.php @@ -79,9 +79,135 @@ public function tearDown() } /** + * @covers Mage_Theme_Model_Wysiwyg_Storage::_createThumbnail + * @covers Mage_Theme_Model_Wysiwyg_Storage::uploadFile + */ + public function testUploadFile() + { + $uplaoder = $this->_prepareUploader(); + + $uplaoder->expects($this->once()) + ->method('save') + ->will($this->returnValue(array('not_empty'))); + + $this->_helperStorage->expects($this->once()) + ->method('getStorageType') + ->will($this->returnValue(Mage_Theme_Model_Wysiwyg_Storage::TYPE_IMAGE)); + + /** Prepare filesystem */ + + $this->_filesystem->expects($this->any()) + ->method('isFile') + ->will($this->returnValue(true)); + + $this->_filesystem->expects($this->once()) + ->method('isReadable') + ->will($this->returnValue(true)); + + + /** Prepare image */ + + $dataHelper = $this->getMock('Mage_Core_Helper_Data', array(), array(), '', false); + $imageAdapter= $this->getMock('Varien_Image_Adapter', array('factory'), array(), '', false); + $image = $this->getMock('Varien_Image_Adapter_Gd2', array(), array(), '', false); + + $this->_objectManager->expects($this->at(1)) + ->method('get') + ->will($this->returnValue($dataHelper)); + + $dataHelper->expects($this->once()) + ->method('getImageAdapterType') + ->will($this->returnValue(Varien_Image_Adapter::ADAPTER_GD2)); + + $image->expects($this->once()) + ->method('open') + ->will($this->returnValue(true)); + + $image->expects($this->once()) + ->method('keepAspectRatio') + ->will($this->returnValue(true)); + + $image->expects($this->once()) + ->method('resize') + ->will($this->returnValue(true)); + + $image->expects($this->once()) + ->method('save') + ->will($this->returnValue(true)); + + $imageAdapter->staticExpects($this->at(0)) + ->method('factory') + ->will($this->returnValue($image)); + + $this->_objectManager->expects($this->at(2)) + ->method('get') + ->will($this->returnValue($imageAdapter)); + + /** Prepare session */ + + $session = $this->getMock('Mage_Backend_Model_Session', array(), array(), '', false); + + $this->_helperStorage->expects($this->any()) + ->method('getSession') + ->will($this->returnValue($session)); + + $expectedResult = array( + 'not_empty', + 'cookie' => array( + 'name' => null, + 'value' => null, + 'lifetime' => null, + 'path' => null, + 'domain' => null + ) + ); + + $this->assertEquals($expectedResult, $this->_storageModel->uploadFile($this->_storageRoot)); + } + + /** + * @covers Mage_Theme_Model_Wysiwyg_Storage::uploadFile + * @expectedException Mage_Core_Exception + */ + public function testUploadInvalidFile() + { + $uplaoder = $this->_prepareUploader(); + + $uplaoder->expects($this->once()) + ->method('save') + ->will($this->returnValue(null)); + + $this->_storageModel->uploadFile($this->_storageRoot); + } + + protected function _prepareUploader() + { + $uploader = $this->getMock('Mage_Core_Model_File_Uploader', array(), array(), '', false); + + $this->_objectManager->expects($this->once()) + ->method('create') + ->will($this->returnValue($uploader)); + + $uploader->expects($this->once()) + ->method('setAllowedExtensions') + ->will($this->returnValue($uploader)); + + $uploader->expects($this->once()) + ->method('setAllowRenameFiles') + ->will($this->returnValue($uploader)); + + $uploader->expects($this->once()) + ->method('setFilesDispersion') + ->will($this->returnValue($uploader)); + + return $uploader; + } + + /** + * @dataProvider booleanCasesDataProvider * @covers Mage_Theme_Model_Wysiwyg_Storage::createFolder */ - public function testCreateFolder() + public function testCreateFolder($isWritable) { $newDirectoryName = 'dir1'; $fullNewPath = $this->_storageRoot . Magento_Filesystem::DIRECTORY_SEPARATOR . $newDirectoryName; @@ -89,7 +215,7 @@ public function testCreateFolder() $this->_filesystem->expects($this->once()) ->method('isWritable') ->with($this->_storageRoot) - ->will($this->returnValue(true)); + ->will($this->returnValue($isWritable)); $this->_filesystem->expects($this->once()) ->method('has') @@ -111,7 +237,7 @@ public function testCreateFolder() ->with($fullNewPath) ->will($this->returnValue($newDirectoryName)); - $this->_helperStorage->expects($this->once()) + $this->_helperStorage->expects($this->any()) ->method('getStorageRoot') ->will($this->returnValue($this->_storageRoot)); @@ -128,6 +254,38 @@ public function testCreateFolder() ); } + /** + * @covers Mage_Theme_Model_Wysiwyg_Storage::createFolder + * @expectedException Mage_Core_Exception + */ + public function testCreateFolderWithInvalidName() + { + $newDirectoryName = 'dir2!#$%^&'; + $this->_storageModel->createFolder($newDirectoryName, $this->_storageRoot); + } + + /** + * @covers Mage_Theme_Model_Wysiwyg_Storage::createFolder + * @expectedException Mage_Core_Exception + */ + public function testCreateFolderDirectoryAlreadyExist() + { + $newDirectoryName = 'mew'; + $fullNewPath = $this->_storageRoot . Magento_Filesystem::DIRECTORY_SEPARATOR . $newDirectoryName; + + $this->_filesystem->expects($this->once()) + ->method('isWritable') + ->with($this->_storageRoot) + ->will($this->returnValue(true)); + + $this->_filesystem->expects($this->once()) + ->method('has') + ->with($fullNewPath) + ->will($this->returnValue(true)); + + $this->_storageModel->createFolder($newDirectoryName, $this->_storageRoot); + } + /** * @covers Mage_Theme_Model_Wysiwyg_Storage::getDirsCollection */ @@ -155,6 +313,20 @@ public function testGetDirsCollection() $this->assertEquals($dirs, $this->_storageModel->getDirsCollection($this->_storageRoot)); } + /** + * @covers Mage_Theme_Model_Wysiwyg_Storage::getDirsCollection + * @expectedException Mage_Core_Exception + */ + public function testGetDirsCollectionWrongDirName() + { + $this->_filesystem->expects($this->once()) + ->method('has') + ->with($this->_storageRoot) + ->will($this->returnValue(false)); + + $this->_storageModel->getDirsCollection($this->_storageRoot); + } + /** * @covers Mage_Theme_Model_Wysiwyg_Storage::getFilesCollection */ @@ -194,6 +366,44 @@ public function testGetFilesCollection() $this->assertEquals('font2.ttf', $result[1]['text']); } + /** + * @covers Mage_Theme_Model_Wysiwyg_Storage::getFilesCollection + */ + public function testGetFilesCollectionImageType() + { + $this->_helperStorage->expects($this->once()) + ->method('getCurrentPath') + ->will($this->returnValue($this->_storageRoot)); + + $this->_helperStorage->expects($this->once()) + ->method('getStorageType') + ->will($this->returnValue(Mage_Theme_Model_Wysiwyg_Storage::TYPE_IMAGE)); + + $this->_helperStorage->expects($this->any()) + ->method('urlEncode') + ->will($this->returnArgument(0)); + + $paths = array( + $this->_storageRoot . Magento_Filesystem::DIRECTORY_SEPARATOR . 'picture1.jpg' + ); + + $this->_filesystem->expects($this->once()) + ->method('searchKeys') + ->with($this->_storageRoot, '*') + ->will($this->returnValue($paths)); + + $this->_filesystem->expects($this->once()) + ->method('isFile') + ->with($this->_storageRoot . Magento_Filesystem::DIRECTORY_SEPARATOR . 'picture1.jpg') + ->will($this->returnValue(true)); + + $result = $this->_storageModel->getFilesCollection(); + + $this->assertCount(1, $result); + $this->assertEquals('picture1.jpg', $result[0]['text']); + $this->assertEquals('picture1.jpg', $result[0]['thumbnailParams']['file']); + } + /** * @covers Mage_Theme_Model_Wysiwyg_Storage::getTreeArray */ @@ -328,4 +538,27 @@ public function testDeleteDirectory() $this->_storageModel->deleteDirectory($directoryPath); } + + /** + * @covers Mage_Theme_Model_Wysiwyg_Storage::deleteDirectory + * @expectedException Mage_Core_Exception + */ + public function testDeleteRootDirectory() + { + $directoryPath = $this->_storageRoot; + + $this->_helperStorage->expects($this->atLeastOnce()) + ->method('getStorageRoot') + ->will($this->returnValue($this->_storageRoot)); + + $this->_storageModel->deleteDirectory($directoryPath); + } + + public function booleanCasesDataProvider() + { + return array( + array(true), + array(false) + ); + } } diff --git a/dev/tests/unit/testsuite/Mage/Theme/controller/Adminhtml/System/Design/ThemeControllerTest.php b/dev/tests/unit/testsuite/Mage/Theme/controller/Adminhtml/System/Design/ThemeControllerTest.php index 8cb58bcc21a9c..48b637b481214 100644 --- a/dev/tests/unit/testsuite/Mage/Theme/controller/Adminhtml/System/Design/ThemeControllerTest.php +++ b/dev/tests/unit/testsuite/Mage/Theme/controller/Adminhtml/System/Design/ThemeControllerTest.php @@ -48,8 +48,7 @@ class Mage_Theme_Controller_Adminhtml_System_Design_ThemeControllerTest extends protected function setUp() { - $this->_objectManagerMock = $this->getMock('Magento_ObjectManager_Zend', - array('create', 'get'), array(), '', false); + $this->_objectManagerMock = $this->getMock('Magento_ObjectManager'); $this->_request = $this->getMock( 'Mage_Core_Controller_Request_Http', array('getParam', 'getPost'), array(), '', false @@ -108,7 +107,9 @@ public function testSaveAction() $filesCssMock = $this->getMock( 'Mage_Core_Model_Theme_Customization_Files_Css', array('setDataForSave'), array(), '', false ); - $filesCssMock->expects($this->at(0))->method('setDataForSave')->with($customCssContent); + $filesCssMock->expects($this->at(0))->method('setDataForSave')->with( + array(Mage_Core_Model_Theme_Customization_Files_Css::CUSTOM_CSS => $customCssContent) + ); $filesJsMock = $this->getMock( 'Mage_Core_Model_Theme_Customization_Files_Js', diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/Role/Edit/Tab/ResourceTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/Role/Edit/Tab/ResourceTest.php index 0552c3c827a52..ff76cfd1d3fc7 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/Role/Edit/Tab/ResourceTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/Role/Edit/Tab/ResourceTest.php @@ -43,7 +43,7 @@ protected function setUp() ->getMock(); $helper = new Magento_Test_Helper_ObjectManager($this); - $this->_block = $helper->getBlock('Mage_Webapi_Block_Adminhtml_Role_Edit_Tab_Resource', array( + $this->_block = $helper->getObject('Mage_Webapi_Block_Adminhtml_Role_Edit_Tab_Resource', array( // TODO: Remove injecting of 'urlBuilder' and 'authorizationConfig' after MAGETWO-5038 complete 'urlBuilder' => $this->getMockBuilder('Mage_Backend_Model_Url') ->disableOriginalConstructor() diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/Role/Edit/TabsTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/Role/Edit/TabsTest.php index 1fc1582ac2517..44ab1bed9443f 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/Role/Edit/TabsTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/Role/Edit/TabsTest.php @@ -61,7 +61,7 @@ protected function setUp() ->getMock(); $this->_helper = new Magento_Test_Helper_ObjectManager($this); - $this->_block = $this->_helper->getBlock('Mage_Webapi_Block_Adminhtml_Role_Edit_Tabs', array( + $this->_block = $this->_helper->getObject('Mage_Webapi_Block_Adminhtml_Role_Edit_Tabs', array( 'urlBuilder' => $urlBuilder, 'layout' => $this->_layout, 'request' => $this->_request @@ -89,9 +89,9 @@ public function testBeforeToHtml($apiRole, $expectedTabIds) { $this->_block->setApiRole($apiRole); - $mainBlock = $this->_helper->getBlock('Mage_Core_Block_Text'); - $resourceBlock = $this->_helper->getBlock('Mage_Core_Block_Text'); - $userBlock = $this->_helper->getBlock('Mage_Core_Block_Text'); + $mainBlock = $this->_helper->getObject('Mage_Core_Block_Text'); + $resourceBlock = $this->_helper->getObject('Mage_Core_Block_Text'); + $userBlock = $this->_helper->getObject('Mage_Core_Block_Text'); $this->_layout->expects($this->any()) ->method('getBlock') diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/Role/EditTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/Role/EditTest.php index 761bd99ac6cc2..2c4866a3d4a42 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/Role/EditTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/Role/EditTest.php @@ -67,7 +67,7 @@ protected function setUp() ->will($this->returnValue(1)); $helper = new Magento_Test_Helper_ObjectManager($this); - $this->_block = $helper->getBlock('Mage_Webapi_Block_Adminhtml_Role_Edit', array( + $this->_block = $helper->getObject('Mage_Webapi_Block_Adminhtml_Role_Edit', array( 'urlBuilder' => $this->_urlBuilder, 'layout' => $this->_layout, 'request' => $this->_request diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/RoleTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/RoleTest.php index 54a45d8be4b56..31f094bc975fa 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/RoleTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/RoleTest.php @@ -42,7 +42,7 @@ protected function setUp() ->getMock(); $helper = new Magento_Test_Helper_ObjectManager($this); - $this->_block = $helper->getBlock('Mage_Webapi_Block_Adminhtml_Role', array( + $this->_block = $helper->getObject('Mage_Webapi_Block_Adminhtml_Role', array( 'urlBuilder' => $this->_urlBuilder )); } diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/User/EditTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/User/EditTest.php index d3bdf77843397..7b6578fde80d3 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/User/EditTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/User/EditTest.php @@ -58,7 +58,7 @@ protected function setUp() ->will($this->returnValue(1)); $helper = new Magento_Test_Helper_ObjectManager($this); - $this->_block = $helper->getBlock('Mage_Webapi_Block_Adminhtml_User_Edit', array( + $this->_block = $helper->getObject('Mage_Webapi_Block_Adminhtml_User_Edit', array( // TODO: Remove injecting of 'urlBuilder' after MAGETWO-5038 complete 'urlBuilder' => $this->getMockBuilder('Mage_Backend_Model_Url') ->disableOriginalConstructor() diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/UserTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/UserTest.php index 3ee5bb31c4d55..7701985dbf2de 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/UserTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Block/Adminhtml/UserTest.php @@ -33,7 +33,7 @@ class Mage_Webapi_Block_Adminhtml_UserTest extends PHPUnit_Framework_TestCase protected function setUp() { $helper = new Magento_Test_Helper_ObjectManager($this); - $this->_block = $helper->getBlock('Mage_Webapi_Block_Adminhtml_User', array( + $this->_block = $helper->getObject('Mage_Webapi_Block_Adminhtml_User', array( // TODO: Remove injecting of 'urlBuilder' after MAGETWO-5038 complete 'urlBuilder' => $this->getMockBuilder('Mage_Backend_Model_Url') ->disableOriginalConstructor() diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Controller/Dispatcher/ErrorProcessorTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Controller/Dispatcher/ErrorProcessorTest.php index 07c33d81c87b3..d004fcb8eaafd 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Controller/Dispatcher/ErrorProcessorTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Controller/Dispatcher/ErrorProcessorTest.php @@ -164,36 +164,6 @@ public function testRenderDefaultFormat() $this->_errorProcessor->render('Message'); } - /** - * Test renderException method with Mage_Webapi_Exception. - */ - public function testRenderExecutionWebapiException() - { - $this->markTestIncomplete("Think how to replace this test."); - $_SERVER['HTTP_ACCEPT'] = 'json'; - /** Init Mage_Webapi_Exception. */ - $apiException = new Mage_Webapi_Exception('Exception message', 500); - /** Assert that jsonEncode will be executed once. */ - $this->_helperMock->expects($this->once())->method('jsonEncode'); - $this->_errorProcessor->renderException($apiException); - } - - /** - * Test renderException method with turned on developer mode. - */ - public function testRenderExecutionInDeveloperMode() - { - $this->markTestIncomplete("Think how to replace this test."); - $_SERVER['HTTP_ACCEPT'] = 'json'; - /** Init base Exception object. */ - $exception = new Exception('Message'); - /** Mock app to return enabled developer mode flag. */ - $this->_appMock->expects($this->any())->method('isDeveloperMode')->will($this->returnValue(true)); - /** Assert that jsonEncode will be executed once. */ - $this->_helperMock->expects($this->once())->method('jsonEncode'); - $this->_errorProcessor->renderException($exception); - } - /** * Test maskException method with Mage_Webapi_Exception. */ diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Controller/Dispatcher/Soap/AuthenticationTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Controller/Dispatcher/Soap/AuthenticationTest.php index c54c21f2cdd85..16583585ec933 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Controller/Dispatcher/Soap/AuthenticationTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Controller/Dispatcher/Soap/AuthenticationTest.php @@ -58,7 +58,7 @@ protected function setUp() ->getMock(); $this->_helperMock->expects($this->any())->method('__')->will($this->returnArgument(0)); $this->_tokenFactoryMock = $this->getMockBuilder('Mage_Webapi_Model_Soap_Security_UsernameToken_Factory') - ->setMethods(array('createFromArray')) + ->setMethods(array('create')) ->disableOriginalConstructor() ->getMock(); $this->_tokenMock = $this->getMockBuilder('Mage_Webapi_Model_Soap_Security_UsernameToken') @@ -67,7 +67,7 @@ protected function setUp() ->getMock(); $this->_tokenFactoryMock ->expects($this->once()) - ->method('createFromArray') + ->method('create') ->will($this->returnValue($this->_tokenMock)); $this->_roleLocatorMock = $this->getMockBuilder('Mage_Webapi_Model_Authorization_RoleLocator') ->setMethods(array('setRoleId')) @@ -101,7 +101,7 @@ public function testAuthenticate() )->will($this->returnValue($user)); $this->_tokenFactoryMock ->expects($this->once()) - ->method('createFromArray') + ->method('create') ->will($this->returnValue($this->_tokenMock)); $this->_roleLocatorMock->expects($this->once())->method('setRoleId')->with($roleId); /** Execute SUT. */ diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Controller/ResponseTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Controller/ResponseTest.php index 40efbdbc70719..f717f3e30add2 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Controller/ResponseTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Controller/ResponseTest.php @@ -45,24 +45,6 @@ protected function tearDown() parent::tearDown(); } - /** - * Test setMimeType method. - */ - public function testSetMimeType() - { - $this->markTestIncomplete('Fix test to work with output_buffering option.'); - $expectedHeader = array( - array( - 'name' => 'Content-Type', - 'value' => 'application/xml; charset=' . Mage_Webapi_Controller_Response::RESPONSE_CHARSET, - 'replace' => true, - ), - ); - $actualHeader = $this->_response->setMimeType('application/xml')->getHeaders(); - /** Assert that headers are equal */ - $this->assertEquals($expectedHeader, $actualHeader, 'Mime type is not set.'); - } - /** * Test addMessage, hasMessage, getMessage, and clearMessages methods. */ diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/Role/FactoryTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/Role/FactoryTest.php index 77184718fd239..36eb4706aa423 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/Role/FactoryTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/Role/FactoryTest.php @@ -53,7 +53,7 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->_model = $helper->getModel('Mage_Webapi_Model_Acl_Role_Factory', array( + $this->_model = $helper->getObject('Mage_Webapi_Model_Acl_Role_Factory', array( 'objectManager' => $this->_objectManager, )); } diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/Role/InRoleUserUpdaterTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/Role/InRoleUserUpdaterTest.php index 223cd2d48e84e..751451d391876 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/Role/InRoleUserUpdaterTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/Role/InRoleUserUpdaterTest.php @@ -46,7 +46,7 @@ public function testUpdate() ->with($roleId)->will($this->returnValue($expectedValues)); /** @var Mage_Webapi_Model_Acl_Role_InRoleUserUpdater $model */ - $model = $helper->getModel('Mage_Webapi_Model_Acl_Role_InRoleUserUpdater', array( + $model = $helper->getObject('Mage_Webapi_Model_Acl_Role_InRoleUserUpdater', array( 'request' => $request, 'userResource' => $userResource )); diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/Role/UsersUpdaterTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/Role/UsersUpdaterTest.php index ad460cf24caac..d5f8f698c1233 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/Role/UsersUpdaterTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/Role/UsersUpdaterTest.php @@ -85,7 +85,7 @@ public function testUpdate($roleId, $filters, $isAjax, $param) } /** @var Mage_Webapi_Model_Acl_Role_UsersUpdater $model */ - $model = $this->_helper->getModel('Mage_Webapi_Model_Acl_Role_UsersUpdater', array( + $model = $this->_helper->getObject('Mage_Webapi_Model_Acl_Role_UsersUpdater', array( 'request' => $this->_request, 'backendHelper' => $this->_backendHelper )); diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/RoleTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/RoleTest.php index 2876e7621ab87..330dca8c581a3 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/RoleTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/RoleTest.php @@ -74,9 +74,9 @@ protected function setUp() */ protected function _createModel($roleResource, $resourceCollection = null) { - return $this->_helper->getModel('Mage_Webapi_Model_Acl_Role', array( + return $this->_helper->getObject('Mage_Webapi_Model_Acl_Role', array( 'eventDispatcher' => $this->getMock('Mage_Core_Model_Event_Manager', array(), array(), '', false), - 'cacheManager' => $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false), + 'cacheManager' => $this->getMock('Mage_Core_Model_CacheInterface', array(), array(), '', false), 'resource' => $roleResource, 'resourceCollection' => $resourceCollection )); diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/RuleTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/RuleTest.php index 998376fd6aeed..70d1ab890be47 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/RuleTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/RuleTest.php @@ -74,9 +74,9 @@ protected function setUp() */ protected function _createModel($ruleResource, $resourceCollection = null) { - return $this->_helper->getModel('Mage_Webapi_Model_Acl_Rule', array( + return $this->_helper->getObject('Mage_Webapi_Model_Acl_Rule', array( 'eventDispatcher' => $this->getMock('Mage_Core_Model_Event_Manager', array(), array(), '', false), - 'cacheManager' => $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false), + 'cacheManager' => $this->getMock('Mage_Core_Model_CacheInterface', array(), array(), '', false), 'resource' => $ruleResource, 'resourceCollection' => $resourceCollection )); diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/User/FactoryTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/User/FactoryTest.php index b5528f2bd342e..73945d126120d 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/User/FactoryTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/User/FactoryTest.php @@ -53,7 +53,7 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->_model = $helper->getModel('Mage_Webapi_Model_Acl_User_Factory', array( + $this->_model = $helper->getObject('Mage_Webapi_Model_Acl_User_Factory', array( 'objectManager' => $this->_objectManager, )); } diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/User/RoleUpdaterTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/User/RoleUpdaterTest.php index 1e98fdb5a5b91..becef52bf0cf3 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/User/RoleUpdaterTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/User/RoleUpdaterTest.php @@ -56,7 +56,7 @@ public function testUpdate() ->with(array())->will($this->returnValue($userModel)); /** @var Mage_Webapi_Model_Acl_Role_InRoleUserUpdater $model */ - $model = $helper->getModel('Mage_Webapi_Model_Acl_User_RoleUpdater', array( + $model = $helper->getObject('Mage_Webapi_Model_Acl_User_RoleUpdater', array( 'request' => $request, 'userFactory' => $userFactory )); diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/UserTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/UserTest.php index 20eab86c4d355..9c903f5de003e 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/UserTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Model/Acl/UserTest.php @@ -74,9 +74,9 @@ protected function setUp() */ protected function _createModel($userResource, $resourceCollection = null) { - return $this->_helper->getModel('Mage_Webapi_Model_Acl_User', array( + return $this->_helper->getObject('Mage_Webapi_Model_Acl_User', array( 'eventDispatcher' => $this->getMock('Mage_Core_Model_Event_Manager', array(), array(), '', false), - 'cacheManager' => $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false), + 'cacheManager' => $this->getMock('Mage_Core_Model_CacheInterface', array(), array(), '', false), 'resource' => $userResource, 'resourceCollection' => $resourceCollection )); diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/Config/ReaderFactoryTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/Config/ReaderFactoryTest.php index c900120d9254e..58157b1a8b178 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/Config/ReaderFactoryTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/Config/ReaderFactoryTest.php @@ -50,7 +50,7 @@ protected function setUp() $this->_expectedObject = $this->getMock('Mage_Webapi_Model_Authorization_Config_Reader', array(), array(), '', false); - $this->_model = $helper->getModel('Mage_Webapi_Model_Authorization_Config_Reader_Factory', array( + $this->_model = $helper->getObject('Mage_Webapi_Model_Authorization_Config_Reader_Factory', array( 'objectManager' => $this->_objectManager, )); } @@ -61,7 +61,7 @@ public function testCreateReader() $this->_objectManager->expects($this->once()) ->method('create') - ->with('Mage_Webapi_Model_Authorization_Config_Reader', $arguments, false) + ->with('Mage_Webapi_Model_Authorization_Config_Reader', $arguments) ->will($this->returnValue($this->_expectedObject)); $this->assertEquals($this->_expectedObject, $this->_model->createReader($arguments)); } diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/Config/ReaderTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/Config/ReaderTest.php index 9006aecb4e5c1..2b5298967d1a0 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/Config/ReaderTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/Config/ReaderTest.php @@ -47,7 +47,7 @@ protected function setUp() ->method('getModuleDir') ->with('etc', 'Mage_Webapi') ->will($this->returnValue( - realpath(__DIR__ . '/../../../../../../../../../app/code/core/Mage/Webapi/etc')) + realpath(__DIR__ . '/../../../../../../../../../app/code/Mage/Webapi/etc')) ); $this->_reader = new Mage_Webapi_Model_Authorization_Config_Reader($this->_configMock, array($path)); diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/ConfigTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/ConfigTest.php index 5636ea6da549f..425f6b4ee558a 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/ConfigTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/ConfigTest.php @@ -67,7 +67,7 @@ protected function setUp() ->setMethods(array('getAclResources')) ->getMock(); - $this->_model = $helper->getModel('Mage_Webapi_Model_Authorization_Config', array( + $this->_model = $helper->getObject('Mage_Webapi_Model_Authorization_Config', array( 'moduleReader' => $this->_config, 'readerFactory' => $this->_readerFactory )); diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/Loader/ResourceTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/Loader/ResourceTest.php index b67d2dbbbed9e..deb4410384b16 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/Loader/ResourceTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/Loader/ResourceTest.php @@ -67,7 +67,7 @@ protected function setUp() ->method('getAclResources') ->will($this->returnValue($this->getResourceXPath()->query('/config/acl/resources/*'))); - $this->_model = $this->_helper->getModel('Mage_Webapi_Model_Authorization_Loader_Resource', array( + $this->_model = $this->_helper->getObject('Mage_Webapi_Model_Authorization_Loader_Resource', array( 'resourceFactory' => $resourceFactory, 'configuration' => $this->_config, )); diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/Loader/RoleTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/Loader/RoleTest.php index 8f95375b4b773..76af2fae40d12 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/Loader/RoleTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/Loader/RoleTest.php @@ -61,7 +61,7 @@ protected function setUp() $this->_acl = $this->getMock('Magento_Acl', array('addRole', 'deny'), array(), '', false); - $this->_model = $helper->getModel('Mage_Webapi_Model_Authorization_Loader_Role', array( + $this->_model = $helper->getObject('Mage_Webapi_Model_Authorization_Loader_Role', array( 'roleResource' => $this->_resourceModelMock, 'roleFactory' => $this->_roleFactory, )); diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/Loader/RuleTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/Loader/RuleTest.php index c63127754a0e1..25a2f07db0bb9 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/Loader/RuleTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/Loader/RuleTest.php @@ -52,7 +52,7 @@ protected function setUp() $this->_acl = $this->getMock('Magento_Acl', array('has', 'hasRole', 'allow'), array(), '', false); - $this->_model = $helper->getModel('Mage_Webapi_Model_Authorization_Loader_Rule', array( + $this->_model = $helper->getObject('Mage_Webapi_Model_Authorization_Loader_Rule', array( 'ruleResource' => $this->_ruleResource, )); } diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/RoleFactoryTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/RoleFactoryTest.php index d2841d3ffe558..2ba43a4d42b24 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/RoleFactoryTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Model/Authorization/RoleFactoryTest.php @@ -49,7 +49,7 @@ protected function setUp() $this->_expectedObject = $this->getMock('Mage_Webapi_Model_Authorization_Role', array(), array(), '', false); - $this->_model = $helper->getModel('Mage_Webapi_Model_Authorization_Role_Factory', array( + $this->_model = $helper->getObject('Mage_Webapi_Model_Authorization_Role_Factory', array( 'objectManager' => $this->_objectManager, )); } @@ -60,7 +60,7 @@ public function testCreateRole() $this->_objectManager->expects($this->once()) ->method('create') - ->with('Mage_Webapi_Model_Authorization_Role', $arguments, false) + ->with('Mage_Webapi_Model_Authorization_Role', $arguments) ->will($this->returnValue($this->_expectedObject)); $this->assertEquals($this->_expectedObject, $this->_model->createRole($arguments)); } diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Model/Resource/Acl/RoleTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Model/Resource/Acl/RoleTest.php index e9621c509b120..b2b65cf989852 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Model/Resource/Acl/RoleTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Model/Resource/Acl/RoleTest.php @@ -73,7 +73,7 @@ protected function _createModel($selectMock = null) ->withAnyParameters() ->will($this->returnValue($this->_adapter)); - return $this->_helper->getModel('Mage_Webapi_Model_Resource_Acl_Role', array( + return $this->_helper->getObject('Mage_Webapi_Model_Resource_Acl_Role', array( 'resource' => $this->_resource, 'helper' => $this->_helperData )); diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Model/Resource/Acl/RuleTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Model/Resource/Acl/RuleTest.php index 0e194f91a3381..b4cdbb8b9b962 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Model/Resource/Acl/RuleTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Model/Resource/Acl/RuleTest.php @@ -79,7 +79,7 @@ protected function _createModel($selectMock = null) ->withAnyParameters() ->will($this->returnValue($this->_adapter)); - return $this->_helper->getModel('Mage_Webapi_Model_Resource_Acl_Rule', array( + return $this->_helper->getObject('Mage_Webapi_Model_Resource_Acl_Rule', array( 'resource' => $this->_resource, 'helper' => $this->_helperData )); @@ -165,8 +165,7 @@ public function testSaveResources() // Init rule. $rule = $this->getMockBuilder('Mage_Webapi_Model_Acl_Rule') ->setConstructorArgs(array( - 'eventDispatcher' => $this->getMock('Mage_Core_Model_Event_Manager', array(), array(), '', false), - 'cacheManager' => $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false), + 'context' => $this->getMock('Mage_Core_Model_Context', array(), array(), '', false), 'resource' => $ruleResource )) ->setMethods(array('getResources')) diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Model/Resource/Acl/UserTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Model/Resource/Acl/UserTest.php index e49ecdf06039c..0278a829b969a 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Model/Resource/Acl/UserTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Model/Resource/Acl/UserTest.php @@ -68,7 +68,7 @@ protected function _createModel($selectMock = null) ->withAnyParameters() ->will($this->returnValue($this->_adapter)); - return $this->_helper->getModel('Mage_Webapi_Model_Resource_Acl_User', array( + return $this->_helper->getObject('Mage_Webapi_Model_Resource_Acl_User', array( 'resource' => $this->_resource, 'helper' => $this->_helperData )); diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Model/Soap/AutoDiscoverTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Model/Soap/AutoDiscoverTest.php index 06b20912deb87..79c89e67376c7 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Model/Soap/AutoDiscoverTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Model/Soap/AutoDiscoverTest.php @@ -33,7 +33,7 @@ class Mage_Webapi_Model_Soap_AutoDiscoverTest extends PHPUnit_Framework_TestCase /** @var Mage_Webapi_Model_Soap_AutoDiscover */ protected $_autoDiscover; - /** @var Mage_Core_Model_Cache */ + /** @var Mage_Core_Model_CacheInterface */ protected $_cacheMock; /** @var Mage_Webapi_Model_Config_Soap */ @@ -67,12 +67,12 @@ protected function setUp() $wsdlFactory = $this->getMock( 'Mage_Webapi_Model_Soap_Wsdl_Factory', array('create'), - array(new Magento_ObjectManager_Zend()) + array(new Magento_ObjectManager_ObjectManager()) ); $wsdlFactory->expects($this->any())->method('create')->will($this->returnValue($this->_wsdlMock)); $helper = $this->getMock('Mage_Webapi_Helper_Config', array('__'), array(), '', false, false); $helper->expects($this->any())->method('__')->will($this->returnArgument(0)); - $this->_cacheMock = $this->getMockBuilder('Mage_Core_Model_Cache')->disableOriginalConstructor()->getMock(); + $this->_cacheMock = $this->getMock('Mage_Core_Model_CacheInterface'); /** Initialize SUT. */ $this->_autoDiscover = new Mage_Webapi_Model_Soap_AutoDiscover( $this->_resourceConfigMock, diff --git a/dev/tests/unit/testsuite/Mage/Webapi/Model/Soap/Security/UsernameToken/NonceStorageTest.php b/dev/tests/unit/testsuite/Mage/Webapi/Model/Soap/Security/UsernameToken/NonceStorageTest.php index 38044373d0b0e..aa7bd5a3575c1 100644 --- a/dev/tests/unit/testsuite/Mage/Webapi/Model/Soap/Security/UsernameToken/NonceStorageTest.php +++ b/dev/tests/unit/testsuite/Mage/Webapi/Model/Soap/Security/UsernameToken/NonceStorageTest.php @@ -45,10 +45,7 @@ class Mage_Webapi_Model_Soap_Security_UsernameToken_NonceStorageTest extends PHP */ protected function setUp() { - $this->_cacheMock = $this->getMockBuilder('Mage_Core_Model_Cache') - ->disableOriginalConstructor() - ->setMethods(array('load', 'save')) - ->getMock(); + $this->_cacheMock = $this->getMock('Mage_Core_Model_CacheInterface'); $this->_nonceStorage = new Mage_Webapi_Model_Soap_Security_UsernameToken_NonceStorage($this->_cacheMock); } diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Controller/Webapi/WebhookTest.php b/dev/tests/unit/testsuite/Mage/Webhook/Controller/Webapi/WebhookTest.php new file mode 100644 index 0000000000000..ee29ebe1580da --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Controller/Webapi/WebhookTest.php @@ -0,0 +1,35 @@ +signer = $this->getMock('Mage_Webhook_Model_Authentication_Hmac_Sha256', array('_getDomain')); + $this->signer->expects($this->once())->method('_getDomain')->will($this->returnValue(self::DOMAIN)); + } + + public function testHeaders() + { + $this->mockApiUser = + $this->getMockBuilder('Mage_Webapi_Model_Acl_User')->disableOriginalConstructor() + ->setMethods(array('getSecret'))->getMock(); + $this->mockApiUser->expects($this->once())->method('getSecret')->will($this->returnValue(self::SHARED_SECRET)); + + $this->mockSubscriber = + $this->getMockBuilder('Mage_Webhook_Model_Subscriber')->disableOriginalConstructor()->getMock(); + $this->mockSubscriber->expects($this->once())->method('getApiUser') + ->will($this->returnValue($this->mockApiUser)); + + $request = new Mage_Webhook_Model_Transport_Http_Request(); + $request->setBody(self::BODY); + $this->assertCount(0, $request->getHeaders()); + + $headers = $this->signer->signRequest($request, $this->mockSubscriber)->getHeaders(); + + $this->assertCount(2, $request->getHeaders()); + $this->assertContains(Mage_Webhook_Model_Authentication_Abstract::DOMAIN_HEADER, array_keys($headers)); + $this->assertContains(Mage_Webhook_Model_Authentication_Hmac::HMAC_HEADER, array_keys($headers)); + $this->assertEquals(self::DOMAIN, $headers[Mage_Webhook_Model_Authentication_Abstract::DOMAIN_HEADER]); + $this->assertEquals( + hash_hmac($this->signer->getHashAlgorithm(), self::BODY, self::SHARED_SECRET), + $headers[Mage_Webhook_Model_Authentication_Hmac::HMAC_HEADER] + ); + } + + /** + * @expectedException LogicException + * @expectedMessage The shared secret cannot be a empty. + */ + public function testEmptySecret() + { + $this->mockApiUser = + $this->getMockBuilder('Mage_Webapi_Model_Acl_User')->disableOriginalConstructor() + ->setMethods(array('getSecret'))->getMock(); + $this->mockApiUser->expects($this->once())->method('getSecret')->will($this->returnValue("")); + + $this->mockSubscriber = + $this->getMockBuilder('Mage_Webhook_Model_Subscriber')->disableOriginalConstructor()->getMock(); + $this->mockSubscriber->expects($this->once())->method('getApiUser') + ->will($this->returnValue($this->mockApiUser)); + + $request = new Mage_Webhook_Model_Transport_Http_Request(); + $request->setBody(self::BODY); + $this->assertCount(0, $request->getHeaders()); + + $this->signer->signRequest($request, $this->mockSubscriber)->getHeaders(); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/Authentication/NoneTest.php b/dev/tests/unit/testsuite/Mage/Webhook/Model/Authentication/NoneTest.php new file mode 100644 index 0000000000000..26c1b6f673fc8 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/Authentication/NoneTest.php @@ -0,0 +1,63 @@ +signer = $this->getMock('Mage_Webhook_Model_Authentication_None', array('_getDomain')); + $this->signer->expects($this->once())->method('_getDomain')->will($this->returnValue(self::DOMAIN)); + $this->mockSubscriber = + $this->getMockBuilder('Mage_Webhook_Model_Subscriber')->disableOriginalConstructor()->getMock(); + } + + public function testDomainHeaderIsSet() + { + $request = new Mage_Webhook_Model_Transport_Http_Request(); + $request->setBody(self::BODY); + $this->assertCount(0, $request->getHeaders()); + + $headers = $this->signer->signRequest($request, $this->mockSubscriber)->getHeaders(); + + $this->assertCount(1, $headers); + $this->assertContains(Mage_Webhook_Model_Authentication_Abstract::DOMAIN_HEADER, + array_keys($headers)); + $this->assertEquals(self::DOMAIN, $headers[Mage_Webhook_Model_Authentication_Abstract::DOMAIN_HEADER]); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/Authorization/Config/ReaderTest.php b/dev/tests/unit/testsuite/Mage/Webhook/Model/Authorization/Config/ReaderTest.php new file mode 100644 index 0000000000000..4f6f65eb631dd --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/Authorization/Config/ReaderTest.php @@ -0,0 +1,69 @@ +_reader = new Mage_Webhook_Model_Authorization_Config_Reader(array($path)); + } + + /** + * Unset reader instance + */ + protected function tearDown() + { + unset($this->_reader); + } + + /** + * Check that correct xsd file is provided + */ + public function testGetSchemaFile() + { + $xsdPath = array(__DIR__, '..', '..', '_files', 'acl.xsd'); + $xsdPath = realpath(implode(DIRECTORY_SEPARATOR, $xsdPath)); + $actualXsdPath = $this->_reader->getSchemaFile(); + + $this->assertInternalType('string', $actualXsdPath); + $this->assertFileExists($actualXsdPath); + $this->assertXmlFileEqualsXmlFile($xsdPath, $actualXsdPath); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/Authorization/ConfigTest.php b/dev/tests/unit/testsuite/Mage/Webhook/Model/Authorization/ConfigTest.php new file mode 100644 index 0000000000000..e9204d29ba9bc --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/Authorization/ConfigTest.php @@ -0,0 +1,120 @@ +_config = $this->getMockBuilder('Mage_Core_Model_Config_Modules_Reader') + ->disableOriginalConstructor() + ->setMethods(array('getModuleConfigurationFiles')) + ->getMock(); + + $this->_readerFactory = $this->getMockBuilder('Mage_Webhook_Model_Authorization_Config_Reader_Factory') + ->disableOriginalConstructor() + ->setMethods(array('createReader')) + ->getMock(); + + $this->_configReader = $this->getMock('Magento_Acl_Config_Reader', + array('getAclResources'), array(), '', false); + + $this->_model = $helper->getObject('Mage_Webhook_Model_Authorization_Config', array( + 'moduleReader' => $this->_config, + 'readerFactory' => $this->_readerFactory + )); + + $this->_config->expects($this->any()) + ->method('getModuleConfigurationFiles') + ->will($this->returnValue(array())); + + $this->_readerFactory->expects($this->any()) + ->method('createReader') + ->will($this->returnValue($this->_configReader)); + } + + public static function getParentFromTopicProvider() + { + return array( + array('customer/updated','customer/get'), + array('catalog/updated','catalog/get'), + array('customer/created','customer/get'), + array('catalog/created','catalog/get'), + array('customer/deleted','customer/get'), + array('catalog/deleted','catalog/get') + ); + + } + /** + * test for Mage_Webhook_Model_Authorization_Config::testGetParentFromTopic + * @dataProvider getParentFromTopicProvider + */ + public function testGetParentFromTopic($topic, $expectedParent) + { + $aclResources = new DOMDocument(); + $aclFile = __DIR__ . DIRECTORY_SEPARATOR . '..' + . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'acl2.xml'; + $aclResources->load($aclFile); + + $this->_configReader->expects($this->once()) + ->method('getAclResources') + ->will($this->returnValue($aclResources)); + + $actualParent = $this->_model->getParentFromTopic($topic); + $this->assertEquals($expectedParent, $actualParent); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/Event/CallbackTest.php b/dev/tests/unit/testsuite/Mage/Webhook/Model/Event/CallbackTest.php new file mode 100644 index 0000000000000..24b171186aa5b --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/Event/CallbackTest.php @@ -0,0 +1,45 @@ +'test1'); + $headers = array('header1' => 'test2'); + $topic = 'order/created'; + $options = array(); + + $object = new Mage_Webhook_Model_Event_Callback($mapping, $bodyData, $headers, $topic, $status, $options); + + $this->assertEquals($status, $object->getStatus()); + $this->assertEquals($mapping, $object->getMapping()); + $this->assertEquals($bodyData, $object->getBodyData()); + $this->assertEquals($headers, $object->getHeaders()); + $this->assertEquals($options, $object->getOptions()); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/Event/FactoryTest.php b/dev/tests/unit/testsuite/Mage/Webhook/Model/Event/FactoryTest.php new file mode 100644 index 0000000000000..44a7c1365dc69 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/Event/FactoryTest.php @@ -0,0 +1,91 @@ +_objectManager = $this->getMock('Magento_ObjectManager'); + + $this->_object = new Mage_Webhook_Model_Event_Factory($this->_objectManager); + } + + /** + * @dataProvider eventDataDatasource + */ + public function testCreateCallbackEvent($eventData) + { + $classMock = $this->setupObjectManager('Mage_Webhook_Model_Event_Callback', $eventData); + $event = $this->_object->createEvent(Mage_Webhook_Model_Event_Interface::EVENT_TYPE_CALLBACK, $eventData); + $this->assertEquals($classMock, $event); + } + /** + * @dataProvider eventDataDatasource + */ + public function testCreateInformEvent($eventData) + { + $classMock = $this->setupObjectManager('Mage_Webhook_Model_Event', $eventData); + $event = $this->_object->createEvent(Mage_Webhook_Model_Event_Interface::EVENT_TYPE_INFORM, $eventData); + $this->assertEquals($classMock, $event); + } + + public function setupObjectManager($className, $data) + { + $classMock = $this->getMock($className, array(), array(), '', false); + $this->getMockBuilder($className) + ->disableOriginalConstructor() + ->getMock(); + $this->_objectManager->expects($this->once()) + ->method('create') + ->with($this->equalTo($className), $this->equalTo($data)) + ->will($this->returnValue($classMock)); + return $classMock; + } + + public function eventDataDatasource() + { + return array( + array( array( + 'mapping' => array(), + 'bodyData' => array(), + 'headers' => array(), + 'topic' => 'some/topic', + 'status' => Mage_Webhook_Model_Event::READY_TO_SEND + )), + array( array( + 'mapping' => array(), + 'bodyData' => array(), + 'headers' => array(), + 'topic' => 'some/topic' + )) + ); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/Event/MarshallerTest.php b/dev/tests/unit/testsuite/Mage/Webhook/Model/Event/MarshallerTest.php new file mode 100644 index 0000000000000..777ac7325dfec --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/Event/MarshallerTest.php @@ -0,0 +1,352 @@ +_topic = "randomTopic"; + + $this->_mappingsConfig = new Mage_Core_Model_Config_Element(' + + + + Stub_Mapper_Factory_Default + + + + + Stub_Mapper_Factory_Default + + '); + + $this->_queueMock = $this->getMockBuilder('Mage_Webhook_Model_Event_Queue')->disableOriginalConstructor() + ->setMethods(array('offer'))->getMock(); + + $this->_eventFactoryMock = $this->getMockBuilder('Mage_Webhook_Model_Event_Factory') + ->disableOriginalConstructor() + ->setMethods(array('createEvent'))->getMock(); + + + $this->_mapperFactoryMock = $this->getMockBuilder('Mage_Webhook_Model_Mapper_Factory') + ->disableOriginalConstructor() + ->setMethods(array('getMapperFactory')) + ->getMock(); + + $this->_subscriberColMock = + $this->getMockBuilder('Mage_Webhook_Model_Resource_Subscriber_Collection')->disableOriginalConstructor() + ->getMock(); + + $this->_subscriberColMock->expects($this->once())->method('addTopicFilter')->with($this->_topic) + ->will($this->returnSelf()); + $this->_subscriberColMock->expects($this->once())->method('addIsActiveFilter')->with(true) + ->will($this->returnSelf()); + + $this->_mockObject = $this->getMock('Mage_Webhook_Model_Event_Marshaller', + array('_getSubscriberCollection'), + array($this->_mappingsConfig, + $this->_queueMock, + $this->_mapperFactoryMock, + $this->_eventFactoryMock + )); + + $this->_mockObject->expects($this->once()) + ->method('_getSubscriberCollection') + ->will($this->returnValue($this->_subscriberColMock)); + } + + /** + * Tests when there are no subscribers for the topic. + * Expects no events to be created. + */ + public function testMarshallNoSubscribers() + { + $data = array('hello' => 'world'); + + $subscribers = array(); + $this->_subscriberColMock->expects($this->once()) + ->method('getItems') + ->will($this->returnValue($subscribers)); + + $this->assertEquals(true, $this->_mockObject->marshal($this->_topic, $data)); + } + + /** + * Tests when there is one subscriber for the topic with one mapping. + * Expects one event to be created. + */ + public function testMarshallOneSubscriber() + { + $data = array('hello' => 'world'); + $mapping = 'testMapping'; + $headers = array('h1' => 'h2'); + + $this->_subscriberCollectionExpect(array($mapping)); + $this->_createMappers(array($mapping), $data, $headers); + + $event1 = $this->_createEventMock($mapping, $data, $headers); + + $this->_eventFactoryMock->expects($this->once()) + ->method('createEvent') + ->will($this->onConsecutiveCalls($event1)); + + $this->_queueExpect(array($event1)); + + $output = $this->_mockObject->marshal($this->_topic, $data); + + $this->assertEquals(true, $output); + } + + /** + * Tests when there are two subscribers for the topic with one mapping. + * Expects one event to be created. + */ + public function testMarshallManySubscribersSameMapping() + { + $data = array('hello' => 'world'); + $mapping = 'testMapping'; + $headers = array('h1' => 'h2'); + + $this->_subscriberCollectionExpect(array($mapping, $mapping)); + $this->_createMappers(array($mapping), $data, $headers); + + $event1 = $this->_createEventMock($mapping, $data, $headers); + + $this->_eventFactoryMock->expects($this->once()) + ->method('createEvent') + ->will($this->onConsecutiveCalls($event1)); + + $this->_queueExpect(array($event1)); + + $output = $this->_mockObject->marshal($this->_topic, $data); + + $this->assertEquals(true, $output); + } + + /** + * Tests when there are two subscribers for the topic with two different mapping. + * Expects two event to be created. + */ + public function testMarshallManySubscribersDifferentMappings() + { + $data = array('hello' => 'world'); + $mapping = 'testMapping'; + $mapping2 = 'testMapping2'; + + $headers = array('h1' => 'h2'); + + $this->_subscriberCollectionExpect(array($mapping, $mapping2)); + $this->_createMappers(array($mapping, $mapping2), $data, $headers); + + $event1 = $this->_createEventMock($mapping, $data, $headers); + $event2 = $this->_createEventMock($mapping2, $data, $headers); + + $this->_eventFactoryMock->expects($this->exactly(2)) + ->method('createEvent') + ->will($this->onConsecutiveCalls($event1, $event2)); + + $this->_queueExpect(array($event1, $event2)); + + $output = $this->_mockObject->marshal($this->_topic, $data); + + $this->assertEquals(true, $output); + } + + /** + * Tests when there are 3 subscribers for the topic with two different mappings. + * Expects two event to be created. + */ + public function testMarshallManySubscribersDifferentMappingsSomeSameMapping() + { + $data = array('hello' => 'world'); + $mapping = 'testMapping'; + $mapping2 = 'testMapping2'; + + $headers = array('h1' => 'h2'); + + $this->_subscriberCollectionExpect(array($mapping, $mapping2, $mapping)); + $this->_createMappers(array($mapping, $mapping2), $data, $headers); + + $event1 = $this->_createEventMock($mapping, $data, $headers); + $event2 = $this->_createEventMock($mapping2, $data, $headers); + + $this->_eventFactoryMock->expects($this->exactly(2)) + ->method('createEvent') + ->will($this->onConsecutiveCalls($event1, $event2)); + + $this->_queueExpect(array($event1, $event2)); + + $output = $this->_mockObject->marshal($this->_topic, $data); + + $this->assertEquals(true, $output); + } + + protected function _subscriberCollectionExpect(array $subscriberMappings) + { + $subscribers = array(); + + foreach ($subscriberMappings as $subMapping) { + $subscribers[] = $this->_createSubscriber($subMapping); + } + + $this->_subscriberColMock->expects($this->once()) + ->method('getItems') + ->will($this->returnValue($subscribers)); + } + + protected function _createMappers(array $mappings, $data, $headers) + { + $counter = 0; + foreach ($mappings as $mapping) { + $actualMapperFactory = $this->getMockBuilder('Mage_Webhook_Model_Mapper_Factory_Interface') + ->disableOriginalConstructor() + ->setMethods(array('getMapper')) + ->getMock(); + + $this->_mapperFactoryMock->expects($this->at($counter)) + ->method('getMapperFactory') + ->with($mapping, $this->_mappingsConfig) + ->will($this->returnValue($actualMapperFactory)); + + $actualMapper = $this->_createMapper($data, $headers); + + $actualMapperFactory->expects($this->once()) + ->method('getMapper') + ->with($this->_topic, $data, $this->anything()) + ->will($this->returnValue($actualMapper)); + $counter++; + } + } + + protected function _queueExpect(array $events) + { + $counter = 0; + foreach ($events as $event) { + $this->_queueMock->expects($this->at($counter)) + ->method('offer') + ->with($event) + ->will($this->returnValue(true)); + $counter++; + } + } + + protected function _createSubscriber($mapping) + { + $sub = $this->getMockBuilder('Mage_Webhook_Model_Subscriber') + ->disableOriginalConstructor() + ->setMethods(array('getMapping')) + ->getMock(); + $sub->expects($this->once())->method('getMapping')->will($this->returnValue($mapping)); + + return $sub; + } + + protected function _createMapper($bodyData, $headers) + { + $actualMapper = $this->getMockBuilder('Mage_Webhook_Model_Mapper_Interface') + ->disableOriginalConstructor() + ->setMethods(array('getTopic', 'getData', 'getHeaders')) + ->getMock(); + + $actualMapper->expects($this->once()) + ->method('getTopic') + ->will($this->returnValue($this->_topic)); + + $actualMapper->expects($this->once()) + ->method('getData') + ->will($this->returnValue($bodyData)); + + $actualMapper->expects($this->once()) + ->method('getHeaders') + ->will($this->returnValue($headers)); + + return $actualMapper; + } + + protected function _createEventMock($mapping, $bodyData, $headers) + { + $eventMock = $this->getMockBuilder('Mage_Webhook_Model_Event') + ->disableOriginalConstructor() + ->setMethods(array('setTopic', 'setBodyData', 'setMapping', 'setHeaders')) + ->getMock(); + $eventMock->expects($this->once()) + ->method('setTopic') + ->with($this->_topic) + ->will($this->returnSelf()); + $eventMock->expects($this->once()) + ->method('setBodyData') + ->with($bodyData) + ->will($this->returnSelf()); + $eventMock->expects($this->once()) + ->method('setMapping') + ->with($mapping) + ->will($this->returnSelf()); + $eventMock->expects($this->once()) + ->method('setHeaders') + ->with($headers) + ->will($this->returnSelf()); + + return $eventMock; + } +} diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/Event/QueueTest.php b/dev/tests/unit/testsuite/Mage/Webhook/Model/Event/QueueTest.php new file mode 100644 index 0000000000000..eb38a5f508ba9 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/Event/QueueTest.php @@ -0,0 +1,174 @@ +_mockObject = $this->getMock('Mage_Webhook_Model_Event_Queue', + array('_getEventCollection')); + } + + /** + * Verify that a Mage_Webhook_Model_Event can be put into the queue. + */ + public function testOfferSuccess() + { + $event = $this->getMockBuilder('Mage_Webhook_Model_Event') + ->disableOriginalConstructor() + ->setMethods(array('save', 'setStatus')) + ->getMock(); + $event->expects($this->once()) + ->method('setStatus') + ->with($this->equalTo(Mage_Webhook_Model_Event::READY_TO_SEND)); + $event->expects($this->once())->method('save'); + + $this->assertEquals(true, $this->_mockObject->offer($event)); + } + + /** + * Verify that any instance of a class besides Mage_Webhook_Model_Event + * will not successfully be saved to the queue. + */ + public function testOfferFailure() + { + $event = $this->getMockBuilder('Mage_Webhook_Model_Event_Interface') + ->disableOriginalConstructor() + ->getMock(); + + $this->assertEquals(false, $this->_mockObject->offer($event)); + } + + + /** + * Verify that if the queue is empty, there won't be any object returned from poll. + */ + public function testPollNoObjects() + { + $collection = $this->getMockBuilder('Mage_Webhook_Model_Resource_Event_Collection') + ->disableOriginalConstructor() + ->setMethods(array('addFieldToFilter', 'getIterator')) + ->getMock(); + $this->_mockObject->expects($this->once())->method('_getEventCollection') + ->will($this->returnValue($collection)); + + $collection->expects($this->once())->method('addFieldToFilter')->will($this->returnSelf()); + + $iterator = $this->getMockBuilder('Iterator') + ->disableOriginalConstructor() + ->setMethods(array('valid', 'current', 'next', 'key', 'rewind')) + ->getMock(); + $collection->expects($this->once())->method('getIterator')->will($this->returnValue($iterator)); + + $iterator->expects($this->once())->method('valid')->will($this->returnValue(false)); + + $this->assertNull($this->_mockObject->poll()); + } + + /** + * Verify that if the queue has one element, that it will return. + */ + public function testPollOneEvent() + { + $collection = $this->getMockBuilder('Mage_Webhook_Model_Resource_Event_Collection') + ->disableOriginalConstructor() + ->setMethods(array('addFieldToFilter', 'getIterator')) + ->getMock(); + $this->_mockObject->expects($this->once())->method('_getEventCollection') + ->will($this->returnValue($collection)); + + $collection->expects($this->once())->method('addFieldToFilter')->will($this->returnSelf()); + + $iterator = $this->getMockBuilder('Iterator') + ->disableOriginalConstructor() + ->setMethods(array('valid', 'current', 'next', 'key', 'rewind')) + ->getMock(); + $collection->expects($this->once())->method('getIterator')->will($this->returnValue($iterator)); + + $iterator->expects($this->once())->method('valid')->will($this->returnValue(true)); + + $event = $this->getMockBuilder('Mage_Webhook_Model_Event') + ->setMethods(array('setStatus', 'save')) + ->disableOriginalConstructor() + ->getMock(); + $iterator->expects($this->once())->method('current')->will($this->returnValue($event)); + $iterator->expects($this->once())->method('next'); + + $event->expects($this->once())->method('setStatus')->with(Mage_Webhook_Model_Event::PROCESSED); + $event->expects($this->once())->method('save'); + + $this->assertSame($event, $this->_mockObject->poll()); + } + + /** + * Verify that if the queue has two element, that it will return. + */ + public function testPollTwoEvent() + { + $collection = $this->getMockBuilder('Mage_Webhook_Model_Resource_Event_Collection') + ->disableOriginalConstructor() + ->setMethods(array('addFieldToFilter', 'getIterator')) + ->getMock(); + $this->_mockObject->expects($this->once())->method('_getEventCollection') + ->will($this->returnValue($collection)); + + $collection->expects($this->once())->method('addFieldToFilter')->will($this->returnSelf()); + + $iterator = $this->getMockBuilder('Iterator') + ->disableOriginalConstructor() + ->setMethods(array('valid', 'current', 'next', 'key', 'rewind')) + ->getMock(); + $collection->expects($this->once())->method('getIterator')->will($this->returnValue($iterator)); + + $iterator->expects($this->exactly(3))->method('valid')->will($this->returnValue(true)); + $iterator->expects($this->exactly(2))->method('next'); + + $event = $this->getMockBuilder('Mage_Webhook_Model_Event') + ->setMethods(array('setStatus', 'save')) + ->disableOriginalConstructor() + ->getMock(); + $event->expects($this->once())->method('setStatus')->with(Mage_Webhook_Model_Event::PROCESSED); + $event->expects($this->once())->method('save'); + + $event2 = $this->getMockBuilder('Mage_Webhook_Model_Event') + ->setMethods(array('setStatus', 'save')) + ->disableOriginalConstructor() + ->getMock(); + $event2->expects($this->once())->method('setStatus')->with(Mage_Webhook_Model_Event::PROCESSED); + $event2->expects($this->once())->method('save'); + + $iterator->expects($this->exactly(2))->method('current')->will($this->onConsecutiveCalls($event, $event2)); + + $this->assertSame($event, $this->_mockObject->poll()); + $this->assertSame($event2, $this->_mockObject->poll()); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/Formatter/Factory/JsonTest.php b/dev/tests/unit/testsuite/Mage/Webhook/Model/Formatter/Factory/JsonTest.php new file mode 100644 index 0000000000000..3d8dc47784546 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/Formatter/Factory/JsonTest.php @@ -0,0 +1,109 @@ +mockConfig = $this->getMock('Mage_Core_Model_Config', array('getNode'), array(), '', false); + $this->mockFormatterFactory = + $this->getMockBuilder('Mage_Webhook_Model_Formatter_Factory_Json')->setMethods(array('getModel')) + ->setConstructorArgs(array($this->mockConfig))->getMock(); + } + + public function testGetFormatter() + { + $mapping = 'default'; + $this->mockConfig->expects($this->once())->method('getNode')->with( + Mage_Webhook_Model_Formatter_Factory_Json::XML_PATH_DEFAULT_OPTIONS . "format/$mapping/formatter" + )->will($this->returnValue('Mage_Webhook_Model_Formatter_Json')); + $this->mockFormatterFactory->expects($this->once())->method('getModel') + ->with('Mage_Webhook_Model_Formatter_Json') + ->will($this->returnValue(new Mage_Webhook_Model_Formatter_Json())); + $formatter = $this->mockFormatterFactory->getFormatter($mapping); + $this->assertInstanceOf('Mage_Webhook_Model_Formatter_Interface', $formatter); + } + + public function testGetDefaultFormatter() + { + $mapping = 'unknown_mapping'; + $this->mockConfig->expects($this->at(0))->method('getNode')->with( + Mage_Webhook_Model_Formatter_Factory_Json::XML_PATH_DEFAULT_OPTIONS . "format/$mapping/formatter" + )->will($this->returnValue(null)); + $this->mockConfig->expects($this->at(1))->method('getNode')->with( + Mage_Webhook_Model_Formatter_Factory_Json::XML_PATH_DEFAULT_OPTIONS . 'default_formatter' + )->will($this->returnValue('Mage_Webhook_Model_Formatter_Json')); + $this->mockFormatterFactory->expects($this->once())->method('getModel') + ->with('Mage_Webhook_Model_Formatter_Json') + ->will($this->returnValue(new Mage_Webhook_Model_Formatter_Json())); + $formatter = $this->mockFormatterFactory->getFormatter($mapping); + $this->assertInstanceOf('Mage_Webhook_Model_Formatter_Interface', $formatter); + } + + /** + * Tests the case where the config xml does not have an entry for the format name. + * @expectedException LogicException + * @expectedExceptionMessage There is no specific formatter for the format given unknown_mapping and no default + * formatter. + */ + public function testNoFormatterNorDefaultFormatter() + { + $mapping = 'unknown_mapping'; + $this->mockConfig->expects($this->at(0))->method('getNode')->with( + Mage_Webhook_Model_Formatter_Factory_Json::XML_PATH_DEFAULT_OPTIONS . "format/$mapping/formatter" + )->will($this->returnValue(null)); + $this->mockConfig->expects($this->at(1))->method('getNode')->with( + Mage_Webhook_Model_Formatter_Factory_Json::XML_PATH_DEFAULT_OPTIONS . 'default_formatter' + )->will($this->returnValue(null)); + $this->mockFormatterFactory->getFormatter($mapping); + } + + /** + * Tests the case where the config xml does not specify an object of the correct formatter class + * @expectedException LogicException + * @expectedExceptionMessage Wrong Formatter type for the model found given the format default. + */ + public function testGetFormatterWrongFormatterClass() + { + $mapping = 'default'; + $this->mockConfig->expects($this->once())->method('getNode')->with( + Mage_Webhook_Model_Formatter_Factory_Json::XML_PATH_DEFAULT_OPTIONS . "format/$mapping/formatter" + )->will($this->returnValue('Mage')); + $this->mockFormatterFactory->expects($this->once())->method('getModel')->with('Mage') + ->will($this->returnValue(new Mage())); + $this->mockFormatterFactory->getFormatter($mapping); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/Formatter/FactoryTest.php b/dev/tests/unit/testsuite/Mage/Webhook/Model/Formatter/FactoryTest.php new file mode 100644 index 0000000000000..ea65399ec027b --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/Formatter/FactoryTest.php @@ -0,0 +1,90 @@ +mockConfig = $this->getMock('Mage_Core_Model_Config', array('getNode'), array(), '', false); + $this->mockFormatterFactory = + $this->getMockBuilder('Mage_Webhook_Model_Formatter_Factory')->setMethods(array('getModel')) + ->setConstructorArgs(array($this->mockConfig))->getMock(); + } + + /** + * Tests the case where the config has and entry for the format and it is of the correct type. + */ + public function testGetFormatterFactory() + { + $this->mockConfig->expects($this->once())->method('getNode')->with( + Mage_Webhook_Model_Formatter_Factory::XML_PATH_FORMATS . 'json/formatter_factory' + )->will($this->returnValue('Mage_Webhook_Model_Formatter_Factory_Default')); + $this->mockFormatterFactory->expects($this->once())->method('getModel') + ->with('Mage_Webhook_Model_Formatter_Factory_Default') + ->will($this->returnValue(new Mage_Webhook_Model_Formatter_Factory_Json($this->mockConfig))); + $formatterFactory = $this->mockFormatterFactory + ->getFormatterFactory(Mage_Webhook_Model_Subscriber::FORMAT_JSON); + $this->assertInstanceOf('Mage_Webhook_Model_Formatter_Factory_Json', $formatterFactory); + } + + /** + * Tests the case where the config xml does not have an entry for the format name. + * @expectedException LogicException + * @expectedExceptionMessage Wrong Format name WrongFormatName. + */ + public function testGetFormatterFactoryWrongFormatName() + { + $this->mockFormatterFactory->getFormatterFactory('WrongFormatName'); + } + + /** + * Tests the case where the config xml actually has an entry for the format, + * but it is not a valid type i.e. Mage_Webhook_Model_Formatter_Factory_Interface. + * @expectedException LogicException + * @expectedExceptionMessage Wrong Formatter type for format + */ + public function testGetFormatterFactoryWrongFormatterClass() + { + $formatName = 'wrongformatname'; + $this->mockConfig->expects($this->once())->method('getNode')->with( + Mage_Webhook_Model_Formatter_Factory::XML_PATH_FORMATS . $formatName .'/formatter_factory' + )->will($this->returnValue('Mage')); + $this->mockFormatterFactory->expects($this->once())->method('getModel')->with('Mage') + ->will($this->returnValue(new Mage())); + + $this->mockFormatterFactory->getFormatterFactory($formatName); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/Formatter/JsonTest.php b/dev/tests/unit/testsuite/Mage/Webhook/Model/Formatter/JsonTest.php new file mode 100644 index 0000000000000..eef68eb50f3af --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/Formatter/JsonTest.php @@ -0,0 +1,110 @@ +_formatter = $this->getMock( + 'Mage_Webhook_Model_Formatter_Json', array( + 'newMessage', + ) + ); + $this->_formatter->expects($this->once())->method('newMessage')->will( + $this->returnValue( + $this->getMockBuilder('Mage_Webhook_Model_Message') + ->setMethods(array('_construct')) // all other methods need to work as normal + ->disableOriginalConstructor() + ->getMock())); + } + + public function beforeAfterJsonFormat() + { + return array( + array(array(), "[]"), + array( + array('a' => array('b' => 'c', 'd' => 'e'), 'f' => 'g'), "{\"a\":{\"b\":\"c\",\"d\":\"e\"},\"f\":\"g\"}" + ), + array(array(0 => new Data('public', 'protected')), "[{\"dataA\":\"public\"}]"), + array(array(0 => null), "[null]") + ); + } + + /** + * @dataProvider beforeAfterJsonFormat + * @param $input + * @param $expectedOutput + */ + public function testFormat($input, $expectedOutput) + { + $event = $this->getMock( + 'Mage_Webhook_Model_Event_Interface', array( + 'getStatus', 'getMapping', 'getHeaders', + 'getBodyData', 'getOptions', 'getTopic' + ) + ); + $event->expects($this->once())->method('getMapping')->will($this->returnValue('mapping')); + $event->expects($this->once())->method('getHeaders')->will($this->returnValue(array())); + $event->expects($this->once())->method('getBodyData')->will($this->returnValue($input)); + $message = $this->_formatter->format($event); + $this->assertEquals($expectedOutput, $message->getBody()); + $headers = $message->getHeaders(); + $this->assertCount(1, $headers); + $this->assertContains( + Mage_Webhook_Model_Formatter_Interface::CONTENT_TYPE_HEADER, + array_keys($headers) + ); + $this->assertEquals( + Mage_Webhook_Model_Formatter_Json::CONTENT_TYPE, + $headers[Mage_Webhook_Model_Formatter_Interface::CONTENT_TYPE_HEADER] + ); + $this->assertEquals('mapping', $message->getMapping()); + } +} + + +class Data +{ + public $dataA; + protected $_dataB; + + public function getB() + { + return $this->_dataB; + } + + public function __construct($first, $second) + { + $this->dataA = $first; + $this->_dataB = $second; + } +} + +; diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/Job/DispatcherTest.php b/dev/tests/unit/testsuite/Mage/Webhook/Model/Job/DispatcherTest.php new file mode 100644 index 0000000000000..c51a721f9a93c --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/Job/DispatcherTest.php @@ -0,0 +1,392 @@ +_topic = 'random/topic'; + + $this->_mockObject = $this->getMockBuilder('Mage_Webhook_Model_Job_Dispatcher') + ->disableOriginalConstructor() + ->setMethods(array('_getTransport', '_getFormatterFactory', '_getFailureHandler')) + ->getMock(); + + $this->_transportMock = $this->getMockBuilder('Mage_Webhook_Model_Transport_Interface') + ->disableOriginalConstructor() + ->setMethods(array('dispatchMessage')) + ->getMock(); + + $this->_responseMock = $this->getMockBuilder('Mage_Webhook_Model_Transport_Http_Response') + ->disableOriginalConstructor() + ->setMethods(array('isSuccessful', 'getBody')) + ->getMock(); + $this->_objectManagerMock = $this->getMock('Magento_ObjectManager_Zend', array(), array(), '', false); + } + + /** + * Tests that a job has already failed and should not be dispatched. + */ + public function testJobAlreadyFailed() + { + $job = $this->_createJobMock(null, null, Mage_Webhook_Model_Dispatch_Job::FAILED); + + $this->assertEquals(false, $this->_mockObject->dispatch($job)); + } + + /** + * Tests when a subscriber does not want the topic anymore so just + * fail the job with special code. + */ + public function testSubscriberNotSubscribedToTopicAnymore() + { + $eventMock = $this->_createEventMock(); + $subscriberMock = $this->_createSubscriberMock(false); + $job = $this->_createJobMock($eventMock, $subscriberMock, Mage_Webhook_Model_Dispatch_Job::READY_TO_SEND); + + $job->expects($this->once()) + ->method('setStatus') + ->with(Mage_Webhook_Model_Dispatch_Job::FAILED_NOT_SUBSCRIBED); + + $this->assertEquals(true, $this->_mockObject->dispatch($job)); + } + + /** + * Tests that the transport was able to send the message + */ + public function testSubscriberSendSuccess() + { + $format = "json"; + $mapping = "default"; + $eventMock = $this->_createEventMock($mapping); + $subscriberMock = $this->_createSubscriberMock(true, $format); + $job = $this->_createJobMock($eventMock, $subscriberMock, Mage_Webhook_Model_Dispatch_Job::READY_TO_SEND); + + $messageMock = $this->_createMessageMock($format, $mapping, $eventMock); + + $this->_setupTransport(true, + $messageMock, + $subscriberMock); + + $job->expects($this->once()) + ->method('setStatus') + ->with(Mage_Webhook_Model_Dispatch_Job::SUCCESS); + + $this->assertEquals(true, $this->_mockObject->dispatch($job)); + } + + /** + * Tests that the transport failed in sending the message and is now set + * to retry. + */ + public function testSubscriberSendFailureNeedToRetry() + { + $format = "json"; + $mapping = "default"; + $eventMock = $this->_createEventMock($mapping); + $subscriberMock = $this->_createSubscriberMock(true, $format); + $job = $this->_createJobMock($eventMock, $subscriberMock, Mage_Webhook_Model_Dispatch_Job::READY_TO_SEND); + + $messageMock = $this->_createMessageMock($format, $mapping, $eventMock); + + $this->_setupTransport(false, + $messageMock, + $subscriberMock); + + $job->expects($this->once()) + ->method('getRetryCount') + ->will($this->returnValue(0)); + + $job->expects($this->once()) + ->method('setRetryCount') + ->with(1); + + $job->expects($this->once()) + ->method('setRetryAt') + ->with($this->anything()); + $job->expects($this->once()) + ->method('setUpdatedAt') + ->with($this->anything()); + + $job->expects($this->once()) + ->method('setStatus') + ->with(Mage_Webhook_Model_Dispatch_Job::RETRY); + + $this->_mockObject->expects($this->once()) + ->method('_getFailureHandler') + ->will($this->returnValue(new Mage_Webhook_Model_Job_Retry_Handler())); + + $this->assertEquals(true, $this->_mockObject->dispatch($job)); + } + + /** + * Tests that the transport failed in sending the message and has retried + * way too many times so it fails. + */ + public function testSubscriberSendFailureTooManyRetries() + { + $format = "json"; + $mapping = "default"; + $eventMock = $this->_createEventMock($mapping); + $subscriberMock = $this->_createSubscriberMock(true, $format); + $job = $this->_createJobMock($eventMock, $subscriberMock, Mage_Webhook_Model_Dispatch_Job::READY_TO_SEND); + + $messageMock = $this->_createMessageMock($format, $mapping, $eventMock); + + $this->_setupTransport(false, + $messageMock, + $subscriberMock); + + $job->expects($this->once()) + ->method('getRetryCount') + ->will($this->returnValue(100000)); + + $job->expects($this->once()) + ->method('setStatus') + ->with(Mage_Webhook_Model_Dispatch_Job::FAILED); + + $this->_mockObject->expects($this->once()) + ->method('_getFailureHandler') + ->will($this->returnValue(new Mage_Webhook_Model_Job_Retry_Handler())); + + $this->assertEquals(true, $this->_mockObject->dispatch($job)); + } + + public function testDispatchCallback() + { + $event = $this->getMock('Mage_Webhook_Model_Event', array('getMapping'), array(), '', false); + $subscriber = $this->getMock('Mage_Webhook_Model_Subscriber', array('getFormat'), array(), '', false); + $subscriber->expects($this->once()) + ->method('getFormat') + ->will($this->returnValue('json')); + + $event->expects($this->once()) + ->method('getMapping') + ->will($this->returnValue('default')); + $messageMock = $this->_createMessageMock('json', 'default', $event); + + + + $this->_setupTransport(true, $messageMock, $subscriber); + + $result = $this->_mockObject->dispatchCallback($event, $subscriber); + $this->assertEquals($messageMock, $result); + } + + /** + * @expectedException Mage_Webhook_Exception + */ + public function testDispatchCallbackUnsuccessfull() + { + $event = $this->getMock('Mage_Webhook_Model_Event', array('getMapping'), array(), '', false); + $subscriber = $this->getMock('Mage_Webhook_Model_Subscriber', array('getFormat'), array(), '', false); + $subscriber->expects($this->once()) + ->method('getFormat') + ->will($this->returnValue('json')); + + $event->expects($this->once()) + ->method('getMapping') + ->will($this->returnValue('default')); + $messageMock = $this->_createMessageMock('json', 'default', $event); + + $this->_setupTransport(false, $messageMock, $subscriber); + + $this->_mockObject->dispatchCallback($event, $subscriber); + } + + protected function _createJobMock($event, $subscriber, $status) + { + $jobMock = $this->getMockBuilder('Mage_Webhook_Model_Job_Interface') + ->disableOriginalConstructor() + ->setMethods(array( + 'getEvent', + 'getSubscriber', + 'getRetryCount', + 'getStatus', + 'setStatus', + 'setRetryAt', + 'setRetryCount', + 'setUpdatedAt', + 'save' + )) + ->getMock(); + + if (!is_null($event)) { + $jobMock->expects($this->once()) + ->method('getEvent') + ->will($this->returnValue($event)); + + $jobMock->expects($this->once()) + ->method('save'); + } + + if (!is_null($subscriber)) { + $jobMock->expects($this->once()) + ->method('getSubscriber') + ->will($this->returnValue($subscriber)); + } + + $jobMock->expects($this->once()) + ->method('getStatus') + ->will($this->returnValue($status)); + + return $jobMock; + } + + protected function _createEventMock($mapping = null) + { + $eventMock = $this->getMockBuilder('Mage_Webhook_Model_Event') + ->disableOriginalConstructor() + ->setMethods(array('getTopic', 'getMapping')) + ->getMock(); + + $eventMock->expects($this->once()) + ->method('getTopic') + ->will($this->returnValue($this->_topic)); + + if (!is_null($mapping)) { + $eventMock->expects($this->once()) + ->method('getMapping') + ->will($this->returnValue($mapping)); + } + + return $eventMock; + } + + protected function _createSubscriberMock($isSubscribed, $format = null) + { + $subscriberMock = $this->getMockBuilder('Mage_Webhook_Model_Subscriber') + ->disableOriginalConstructor() + ->setMethods(array('isSubscribedToTopic', 'getFormat')) + ->getMock(); + + $subscriberMock->expects($this->once()) + ->method('isSubscribedToTopic') + ->will($this->returnValue($isSubscribed)); + + if ($isSubscribed) { + $subscriberMock->expects($this->once()) + ->method('getFormat') + ->will($this->returnValue($format)); + } + + return $subscriberMock; + } + + protected function _createMessageMock($format, $mapping, $event) + { + $formatterMock = $this->_createFormatterMock($format, $mapping); + + $messageMock = $this->getMockBuilder('Mage_Webhook_Model_Message') + ->disableOriginalConstructor() + ->getMock(); + $formatterMock->expects($this->once()) + ->method('format') + ->with($event) + ->will($this->returnValue($messageMock)); + + return $messageMock; + } + + protected function _createFormatterMock($format, $mapping) + { + $factory = $this->getMockBuilder('Mage_Webhook_Model_Formatter_Factory') + ->disableOriginalConstructor() + ->setMethods(array('getFormatterFactory')) + ->getMock(); + $this->_mockObject->expects($this->once()) + ->method('_getFormatterFactory') + ->will($this->returnValue($factory)); + + $formatterFactory = $this->getMockBuilder('Mage_Webhook_Model_FormatterFactory') + ->disableOriginalConstructor() + ->setMethods(array('getFormatter')) + ->getMock(); + $factory->expects($this->once()) + ->method('getFormatterFactory') + ->with($format) + ->will($this->returnValue($formatterFactory)); + + $formatterMock = $this->getMockBuilder('Mage_Webhook_Model_Formatter') + ->disableOriginalConstructor() + ->setMethods(array('format', 'decode')) + ->getMock(); + $formatterFactory->expects($this->once()) + ->method('getFormatter') + ->with($mapping) + ->will($this->returnValue($formatterMock)); + + $this->_mockObject->expects($this->once()) + ->method('_getFormatterFactory') + ->will($this->returnValue($factory)); + + return $formatterMock; + } + + protected function _setupTransport($status, $message, $subscriber) + { + $this->_mockObject->expects($this->once()) + ->method('_getTransport') + ->will($this->returnValue($this->_transportMock)); + $this->_transportMock->expects($this->once()) + ->method('dispatchMessage') + ->with($message, $subscriber) + ->will($this->returnValue($this->_responseMock)); + $this->_responseMock->expects($this->once()) + ->method('isSuccessful') + ->will($this->returnValue($status)); + $this->_responseMock->expects($this->any()) + ->method('getBody') + ->will($this->returnValue('{}')); + + } +} diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/Job/ProcessorTest.php b/dev/tests/unit/testsuite/Mage/Webhook/Model/Job/ProcessorTest.php new file mode 100644 index 0000000000000..2fa0931f691e0 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/Job/ProcessorTest.php @@ -0,0 +1,234 @@ +_mockObject = $this->getMock('Mage_Webhook_Model_Job_Processor', + array('getResourceSubscriberCollection', '_newDispatchJob')); + } + + protected function _createEventQueue() + { + return $this->getMockBuilder('Mage_Webhook_Model_Event_Queue') + ->disableOriginalConstructor() + ->setMethods(array('poll')) + ->getMock(); + } + + protected function _createEventForQueue() + { + return $this->getMockBuilder('Mage_Webhook_Model_Event') + ->disableOriginalConstructor() + ->getMock(); + } + + public function testCreateJobsFromQueueNone() + { + $eventQueue = $this->_createEventQueue(); + $eventQueue->expects($this->once())->method('poll')->will($this->returnValue(null)); + $this->_mockObject->createJobsFromQueue($eventQueue); + } + + public function testCreateJobsFromQueueOne() + { + $this->_mockObject = $this->getMock('Mage_Webhook_Model_Job_Processor', + array('createJobs')); + $eventQueue = $this->_createEventQueue(); + + $event1 = $this->_createEventForQueue(); + + $eventQueue->expects($this->exactly(2))->method('poll')->will($this->onConsecutiveCalls($event1, null)); + $this->_mockObject->expects($this->once())->method('createJobs')->with($event1); + $this->_mockObject->createJobsFromQueue($eventQueue); + } + + public function testCreateJobsFromQueueMany() + { + $this->_mockObject = $this->getMock('Mage_Webhook_Model_Job_Processor', + array('createJobs')); + $eventQueue = $this->_createEventQueue(); + + $event1 = $this->_createEventForQueue(); + $event2 = $this->_createEventForQueue(); + + $eventQueue->expects($this->exactly(3))->method('poll')->will($this->onConsecutiveCalls($event1, $event2, + null)); + $this->_mockObject->expects($this->at(0))->method('createJobs')->with($event1); + $this->_mockObject->expects($this->at(1))->method('createJobs')->with($event1); + $this->_mockObject->createJobsFromQueue($eventQueue); + } + + protected function _createEventForJob($topic, $format, $eventId, $numberOfIdCalls) + { + $event = $this->getMockBuilder('Mage_Webhook_Model_Event') + ->disableOriginalConstructor() + ->setMethods(array('getTopic', 'getMapping', 'getId')) + ->getMock(); + + $event->expects($this->once()) + ->method('getTopic') + ->will($this->returnValue($topic)); + $event->expects($this->once()) + ->method('getMapping') + ->will($this->returnValue($format)); + + if (!is_null($eventId)) { + $event->expects($this->exactly($numberOfIdCalls)) + ->method('getId') + ->will($this->returnValue($eventId)); + } + + return $event; + } + + protected function _createSubscriberForEvent($subId) + { + $sub = $this->getMockBuilder('Mage_Webhook_Model_Subscriber') + ->disableOriginalConstructor() + ->setMethods(array('getId')) + ->getMock(); + $sub->expects($this->once())->method('getId')->will($this->returnValue($subId)); + + return $sub; + } + + protected function _createSubscriberCollection(array $subscribers, $topic, $mapping) + { + $subscriberCollection = $this->getMockBuilder('Mage_Webhook_Model_Resource_Subscriber_Collection') + ->disableOriginalConstructor() + ->setMethods(array('getIterator', 'addTopicFilter', 'addMappingFilter', 'addIsActiveFilter')) + ->getMock(); + if (!is_null($subscribers)) { + $subscriberCollection->expects($this->once()) + ->method('getIterator') + ->will($this->returnValue(new ArrayIterator($subscribers))); + $subscriberCollection->expects($this->once()) + ->method('addTopicFilter') + ->with($topic) + ->will($this->returnSelf()); + $subscriberCollection->expects($this->once()) + ->method('addMappingFilter') + ->with($mapping) + ->will($this->returnSelf()); + $subscriberCollection->expects($this->once()) + ->method('addIsActiveFilter') + ->with(Mage_Webhook_Model_Subscriber::STATUS_ACTIVE) + ->will($this->returnSelf()); + } + + $this->_mockObject->expects($this->once()) + ->method('getResourceSubscriberCollection') + ->will($this->returnValue($subscriberCollection)); + + return $subscriberCollection; + } + + protected function _createExpectedJob($subId, $eventId) + { + $job = $this->getMockBuilder('Mage_Webhook_Model_Dispatch_Job') + ->disableOriginalConstructor() + ->setMethods(array('setSubscriberId', 'setEventId', 'setStatus', 'save')) + ->getMock(); + $job->expects($this->once())->method('setSubscriberId')->with($subId)->will($this->returnSelf()); + $job->expects($this->once())->method('setEventId')->with($eventId)->will($this->returnSelf()); + $job->expects($this->once())->method('setStatus')->with(Mage_Webhook_Model_Dispatch_Job::READY_TO_SEND) + ->will($this->returnSelf()); + $job->expects($this->once())->method('save'); + + return $job; + } + + public function testCreateJobsNone() + { + $topic = 'randomTopic'; + $mapping = 'randomMapping'; + + $event = $this->_createEventForJob($topic, $mapping, null, null); + + $subscribers = array(); + $this->_createSubscriberCollection($subscribers, $topic, $mapping); + + $this->_mockObject->createJobs($event); + } + + public function testCreateJobsOne() + { + $topic = 'randomTopic'; + $mapping = 'randomMapping'; + $eventId = 'randomId'; + + $event = $this->_createEventForJob($topic, $mapping, $eventId, 1); + + $sub1Id = 'randomSub1Id'; + $sub1 = $this->_createSubscriberForEvent($sub1Id); + + $subscribers = array($sub1); + $this->_createSubscriberCollection($subscribers, $topic, $mapping); + + $job = $this->_createExpectedJob($sub1Id, $eventId); + + $this->_mockObject->expects($this->once()) + ->method('_newDispatchJob') + ->will($this->returnValue($job)); + + $this->_mockObject->createJobs($event); + } + + public function testCreateJobsMany() + { + $topic = 'randomTopic'; + $mapping = 'randomMapping'; + $eventId = 'randomId'; + + $event = $this->_createEventForJob($topic, $mapping, $eventId, 2); + + $sub1Id = 'randomSub1Id'; + $sub1 = $this->_createSubscriberForEvent($sub1Id); + + $sub2Id = 'randomSub2Id'; + $sub2 = $this->_createSubscriberForEvent($sub2Id); + + $subscribers = array($sub1, $sub2); + $this->_createSubscriberCollection($subscribers, $topic, $mapping); + + $job1 = $this->_createExpectedJob($sub1Id, $eventId); + $job2 = $this->_createExpectedJob($sub2Id, $eventId); + + $this->_mockObject->expects($this->exactly(2)) + ->method('_newDispatchJob') + ->will($this->onConsecutiveCalls($job1, $job2)); + + $this->_mockObject->createJobs($event); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/Job/Retry/HandlerTest.php b/dev/tests/unit/testsuite/Mage/Webhook/Model/Job/Retry/HandlerTest.php new file mode 100644 index 0000000000000..da631e010b5ac --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/Job/Retry/HandlerTest.php @@ -0,0 +1,101 @@ +_jobMock = $this->getMockBuilder('Mage_Webhook_Model_Dispatch_Job') + ->disableOriginalConstructor() + ->setMethods(array( + 'getRetryCount', + 'setRetryCount', + 'setRetryAt', + 'setUpdatedAt', + 'setStatus', + 'getEvent', + 'getSubscriber', + 'getStatus' + )) + ->getMock(); + + $this->_handler = new Mage_Webhook_Model_Job_Retry_Handler(); + } + + /** + * Tests that a job which has failed for the first 8 times is given another + * chance. + */ + public function testJobGiven8Retries() + { + $retryCount = 8; + $this->_jobMock->expects($this->exactly($retryCount)) + ->method('getRetryCount') + ->will($this->onConsecutiveCalls(0, 1, 2, 3, 4, 5, 6, 7)); + + $this->_jobMock->expects($this->exactly($retryCount)) + ->method('setRetryAt') + ->with($this->anything()); + $this->_jobMock->expects($this->exactly($retryCount)) + ->method('setUpdatedAt') + ->with($this->anything()); + $this->_jobMock->expects($this->exactly($retryCount)) + ->method('setStatus') + ->with(Mage_Webhook_Model_Dispatch_Job::RETRY); + + + for ($c = 0; $c < $retryCount; $c++) { + $this->_handler->handleFailure($this->_jobMock); + } + } + + /** + * Tests that a job which has failed over 8 times is marked as failed. + */ + public function testJobFailAfter8Retries() + { + $this->_jobMock->expects($this->exactly(1)) + ->method('getRetryCount') + ->will($this->returnValue(8)); + + $this->_jobMock->expects($this->exactly(1)) + ->method('setStatus') + ->with(Mage_Webhook_Model_Dispatch_Job::FAILED); + + $this->_handler->handleFailure($this->_jobMock); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/Mapper/DefaultTest.php b/dev/tests/unit/testsuite/Mage/Webhook/Model/Mapper/DefaultTest.php new file mode 100644 index 0000000000000..f563dd0c205f7 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/Mapper/DefaultTest.php @@ -0,0 +1,124 @@ +assertEquals('some/topic', $mapper->getTopic()); + $this->assertEquals(array(Mage_Webhook_Model_Mapper_Default::TOPIC_HEADER => 'some/topic'), + $mapper->getHeaders()); + $this->assertEquals($expectedData, $mapper->getData()); + } + + public function testMappingDataCycleDetected() + { + $this->markTestSkipped('skipping to debug build break'); + $objectA = new Varien_Object(array('keyA' => 'valueA')); + $objectB = new Varien_Object(array('keyB' => 'valueB', 'object' => $objectA)); + $objectA->setObject($objectB); + + $mapper = new Mage_Webhook_Model_Mapper_Default('some/topic', array('object' => $objectA)); + + $expectedData = array( + 'object' => array( + 'keyA' => 'valueA', + 'object' => array( + 'keyB' => 'valueB', + 'object' => Mage_Webhook_Model_Mapper_Default::CYCLE_DETECTED_MARK) + )); + + $this->assertEquals($expectedData, $mapper->getData()); + } + + public function mappingDataProvider() + { + return array( + array( + array('object' => new Varien_Object(array('keyA' => 'valueA'))), + array('object' => array('keyA' => 'valueA')) + ), + + array( + array('objectA' => new Varien_Object(array('keyA' => 'valueA')), + 'objectB' => new Varien_Object(array( + 'keyB' => new Varien_Object(array( + 'keyC' => 'valueC', + 'password' => 'qa123123')) + ))), + array('objectA' => array('keyA' => 'valueA'), + 'objectB' => array( + 'keyB' => array( + 'keyC' => 'valueC', + 'password' => Mage_Webhook_Model_Mapper_Default::REDACTED))) + ), + + array( + array(), + array() + ), + array( + array(555888, 'string' => "Some text", 'not_varien_object' => $this->getMock('Mage_Core_Model_Config', + array(), array(), '', false)), + array(555888, 'string' => "Some text", 'not_varien_object' => $this->getMock('Mage_Core_Model_Config', + array(), array(), '', false)), + ), + array( + array( + array( + 'some_object' => new Varien_Object( + array( + 'keyA' => array( + new Varien_Object( + array( + 'sub_key' => 'sub_value' + ) + ) + ) + ) + ) + ) + ), + array( + array( + 'some_object' => array( + 'keyA' => array( + array( + 'sub_key' => 'sub_value' + ) + ) + ) + ) + ), + ), + ); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/Mapper/Factory/DefaultTest.php b/dev/tests/unit/testsuite/Mage/Webhook/Model/Mapper/Factory/DefaultTest.php new file mode 100644 index 0000000000000..5cb6c19117141 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/Mapper/Factory/DefaultTest.php @@ -0,0 +1,155 @@ +_objectManagerMock = $this->getMockBuilder('Magento_ObjectManager') + ->disableOriginalConstructor() + ->setMethods(array('create')) + ->getMockForAbstractClass(); + + parent::setUp(); + } + + /** + * @dataProvider getMapperProvider + */ + public function testGetMapper($configXml, $expectedMapperClass) + { + $config = new Mage_Core_Model_Config_Element($configXml); + + $this->_objectManagerMock->expects($this->any()) + ->method('create')->will($this->returnCallback(array($this, 'callbackCreateClass'))); + $defaultFactory = new Mage_Webhook_Model_Mapper_Factory_Default($this->_objectManagerMock); + $mapper = $defaultFactory->getMapper('one/two', array(), $config); + + $this->assertInstanceOf($expectedMapperClass, $mapper); + } + + public function callbackCreateClass($name) + { + $mockFactory = null; + $mockFactoryBuilder = $this->getMockBuilder($name) + ->disableOriginalConstructor() + ->setMethods(null); + if ($name == 'Mage_Webhook_Model_Mapper_Default_Factory') { + $mockFactoryBuilder->setMethods(array('getMapper')); + $mockFactory = $mockFactoryBuilder->getMock(); + $mockDefault = $this->getMockBuilder('Mage_Webhook_Model_Mapper_Default') + ->disableOriginalConstructor() + ->getMock(); + $mockFactory->expects($this->any()) + ->method('getMapper') + ->will($this->returnValue($mockDefault)); + } else { + $mockFactory = $mockFactoryBuilder->getMock(); + } + return $mockFactory; + } + + public function getMapperProvider() + { + return array( + array(' + Stub_Mapper_Default_Mapper_Factory + + + + Stub_Mapper_Topic_OneTwo_Mapper_Factory + + + + ', + 'Stub_Mapper_Topic_OneTwo_Mapper' + ), + array(' + + + + Stub_Mapper_Topic_OneTwo_Mapper_Factory + + + + ', + 'Stub_Mapper_Topic_OneTwo_Mapper' + ), + array(' + Stub_Mapper_Default_Mapper_Factory + + + + + + + ', + 'Stub_Mapper_Default_Mapper' + ), + array(' + Stub_Mapper_Default_Mapper_Factory + + + + Stub_Mapper_Wrong_Mapper_Factory_Model + + + + ', + 'Stub_Mapper_Default_Mapper' + ), + array(' + + + + + + + + ', + 'Mage_Webhook_Model_Mapper_Default' + ), + array(' + Stub_Mapper_Wrong_Mapper_Factory_Model + + + + + + + + ', + 'Mage_Webhook_Model_Mapper_Default' + ), + ); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/Mapper/FactoryTest.php b/dev/tests/unit/testsuite/Mage/Webhook/Model/Mapper/FactoryTest.php new file mode 100644 index 0000000000000..81baa00c47578 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/Mapper/FactoryTest.php @@ -0,0 +1,104 @@ +_objectManagerMock = $this->getMockBuilder('Magento_ObjectManager') + ->disableOriginalConstructor() + ->setMethods(array('create')) + ->getMockForAbstractClass(); + + $this->_mapperFactory = new Mage_Webhook_Model_Mapper_Factory($this->_objectManagerMock); + parent::setUp(); + } + + public function testGetMapperFactory() + { + $config = new Mage_Core_Model_Config_Element(' + + Stub_Mapper_Factory_Default + + '); + + $this->_objectManagerMock->expects($this->any()) + ->method('create')->with($this->equalTo('Stub_Mapper_Factory_Default')) + ->will($this->returnValue(new Stub_Mapper_Factory_Default())); + + + $defaultMapper = $this->_mapperFactory->getMapperFactory('testMapping', $config); + + $this->assertInstanceOf('Stub_Mapper_Factory_Default', $defaultMapper); + } + + /** + * @expectedException LogicException + * @expectedExceptionMessage Wrong Mapper type for mapping WrongMapperClass. + */ + public function testGetMapperFactoryWrongMapperClass() + { + $config = new Mage_Core_Model_Config_Element(' + + Stub_Mapper_Wrong_Mapper_Factory_Model + + '); + + $this->_objectManagerMock->expects($this->any()) + ->method('create')->with($this->equalTo('Stub_Mapper_Wrong_Mapper_Factory_Model')) + ->will($this->returnValue(new Stub_Mapper_Wrong_Mapper_Factory_Model())); + + $this->_mapperFactory->getMapperFactory('WrongMapperClass', $config); + } + + /** + * @expectedException LogicException + * @expectedExceptionMessage Wrong mapping name WrongMappingName. + */ + public function testGetMapperFactoryWrongMappingName() + { + $config = new Mage_Core_Model_Config_Element(' + + Stub_Mapper_Factory_Default + + '); + + $this->_objectManagerMock->expects($this->any()) + ->method('create')->with($this->equalTo('Stub_Mapper_Factory_Default')) + ->will($this->returnValue(new Stub_Mapper_Factory_Default())); + + $this->_mapperFactory->getMapperFactory('WrongMappingName', $config); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/Mapper/_files/mapper_stubs.php b/dev/tests/unit/testsuite/Mage/Webhook/Model/Mapper/_files/mapper_stubs.php new file mode 100644 index 0000000000000..1398c0adb4697 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/Mapper/_files/mapper_stubs.php @@ -0,0 +1,97 @@ +_config = $this->_createMockUnitUnderTest(); + $this->_subscriber = $this->_createMockSubscriber(); + $this->_mockHelperData(); + } + + /** + * @dataProvider dataProviderForTestUpdateSubscriberCollection + */ + public function testUpdateSubscriberCollection($params) + { + $this->_registerMocks($params); + + $this->_stubMock($params); + + $this->_setExpectations($params); + + // Run test + $this->_config->updateSubscriberCollection(); + } + + + public function dataProviderForTestUpdateSubscriberCollection() + { + return array( + array($this->_getSettingNameTest()), + array($this->_getNameMissingTest()), + array($this->_getSettingNameOnExistingSubscriberWithVersionIncrementedTest()), + array($this->_getSettingNameOnExistingSubscriberWithoutVersionTest()), + ); + } + + protected function _getSettingNameTest() + { + return array( + self::PARAM_CONFIG_NODE => $this->_createStubConfigElement( + << + + Extension Name + custom + + +XML + ), + self::PARAM_VALIDATION => array( + self::KEY_CREATED_SUBSCRIBER => array( + array( + self::INVOKE_METHOD => 'save', + self::INVOKE_EXPECTS => $this->atLeastOnce(), + ), + array( + self::INVOKE_METHOD => 'setName', + self::INVOKE_EXPECTS => $this->atLeastOnce(), + self::INVOKE_WITH_ARG => $this->equalTo('Extension Name'), + ), + array( + self::INVOKE_METHOD => 'setMapping', + self::INVOKE_EXPECTS => $this->atLeastOnce(), + self::INVOKE_WITH_ARG => $this->equalTo('custom'), + ), + ), + ), + ); + } + + protected function _getNameMissingTest() + { + return array( + self::PARAM_CONFIG_NODE => $this->_createStubConfigElement( + << + + + + +XML + ), + self::PARAM_VALIDATION => array( + self::KEY_CREATED_SUBSCRIBER => array( + array( + self::INVOKE_METHOD => 'save', + self::INVOKE_EXPECTS => $this->never(), + ), + array( + self::INVOKE_METHOD => 'setName', + self::INVOKE_EXPECTS => $this->never(), + ), + ), + ), + self::PARAM_EXPECTED_ERRORS => array( + "Invalid config data for subscriber '%s'." + ) + ); + } + + protected function _getSettingNameOnExistingSubscriberWithVersionIncrementedTest() + { + $existingSubscriber = $this->_createMockSubscriber(); + $existingSubscriber->expects($this->atLeastOnce()) + ->method('save'); + $existingSubscriber->expects($this->atLeastOnce()) + ->method('setName') + ->with($this->equalTo('Extension Name')); + $existingSubscriber->expects($this->any()) + ->method('getVersion') + ->will($this->returnValue('0.0')); + + return array( + self::PARAM_CONFIG_NODE => $this->_createStubConfigElement( + << + + Extension Name + 0.1 + + +XML + ), + self::PARAM_SUBSCRIBER_COLLECTION => $this->_createMockSubscriberCollection( + array( + 'setting_name_on_existing_subscriber_with_version_incremented' => array(&$existingSubscriber) + ) + ), + self::PARAM_VALIDATION => array( + // Make sure we never call the subscriber that's created by the createSubscriber method + self::KEY_CREATED_SUBSCRIBER => array( + array( + self::INVOKE_METHOD => 'save', + self::INVOKE_EXPECTS => $this->never(), + ), + array( + self::INVOKE_METHOD => 'setName', + self::INVOKE_EXPECTS => $this->never(), + ), + ), + ), + self::PARAM_MOCK_OBJECTS_TO_REGISTER => array( + &$existingSubscriber + ), + ); + } + + protected function _getSettingNameOnExistingSubscriberWithoutVersionTest() + { + // Make sure we never call save or setName on the existing subscriber + $existingSubscriber = $this->_createMockSubscriber(); + $existingSubscriber->expects($this->never()) + ->method('save'); + $existingSubscriber->expects($this->never()) + ->method('setName'); + + return array( + self::PARAM_CONFIG_NODE => $this->_createStubConfigElement( + << + + Extension Name + + +XML + ), + self::PARAM_SUBSCRIBER_COLLECTION => $this->_createMockSubscriberCollection( + array( + 'setting_name_on_existing_subscriber_without_version' => array(&$existingSubscriber) + ) + ), + self::PARAM_VALIDATION => array( + // Make sure we never call the subscriber that's created by the createSubscriber method + self::KEY_CREATED_SUBSCRIBER => array( + array( + self::INVOKE_METHOD => 'save', + self::INVOKE_EXPECTS => $this->never(), + ), + array( + self::INVOKE_METHOD => 'setName', + self::INVOKE_EXPECTS => $this->never(), + ), + ), + ), + self::PARAM_MOCK_OBJECTS_TO_REGISTER => array( + &$existingSubscriber + ), + ); + } + + protected function _retrieveMock($key) + { + switch ($key) { + case self::KEY_CREATED_SUBSCRIBER: + return $this->_subscriber; + case self::KEY_CONFIG: + return $this->_config; + default: + throw new InvalidArgumentException($key); + } + } + + protected function _createMockUnitUnderTest() + { + $mock = $this->getMock('Mage_Webhook_Model_Subscriber_Config', array( + '_getSubscriberConfigNode', + '_getSubscriberCollection', + '_handleErrors', + '_createSubscriber', + )); + + return $mock; + } + + protected function _createMockSubscriberCollection($idToSubscribersMap = array()) + { + $mock = $this->getMockBuilder('Mage_Webhook_Model_Resource_Subscriber_Collection') + ->disableOriginalConstructor() + ->getMock(); + + // Order matters when mocking out methods. We need the more restrictive one first. + foreach ($idToSubscribersMap as $id => $subscribers) { + $mock->expects($this->any()) + ->method('getItemsByColumnValue') + ->with('extension_id', $this->equalTo($id)) + ->will($this->returnValue($subscribers)); + } + + // Put the less restrictive stub at the end + $mock->expects($this->any()) + ->method('getItemsByColumnValue') + ->will($this->returnValue(array())); + + return $mock; + } + + protected function _createMockSubscriber() + { + // We need to define all magic methods. Once we define any method, we need to define all methods + // If we don't define any methods, then we can only stub out concrete methods, but not any + // of the magic methods, since they weren't explicitly defined. + $methods = array('setData', 'getData', 'unsetData', 'save', 'setName', 'setMapping', 'setTopics', + 'getAuthenticationOptions', 'unsetAuthenticationOption', 'getVersion', 'setVersion'); + $mock = $this->getMockBuilder('Mage_Webhook_Model_Subscriber') + ->disableOriginalConstructor() + ->setMethods($methods) + ->getMock(); + + foreach ($methods as $method) { + $mock->expects($this->any()) + ->method($method) + ->will($this->returnSelf()); + } + + return $mock; + } + + protected function _createStubConfigElement($xmlString) + { + return new Mage_Core_Model_Config_Element($xmlString); + } + + + protected function _mockHelperData() + { + // Hack needed since _config isn't set in Mage + Mage::unregister('_helper/Mage_Webhook_Helper_Data'); + $mockHelper = $this->getMockBuilder('Mage_Webhook_Helper_Data') + ->disableOriginalConstructor() + ->getMock(); + $mockHelper->expects($this->any()) + ->method('__') + ->will($this->returnArgument(0)); + Mage::register('_helper/Mage_Webhook_Helper_Data', $mockHelper); + } + + protected function _stubMock($params) + { + $this->_stubGetSubscriberConfigNode($params); + + $this->_stubGetSubscriberCollection($params); + + $this->_stubHandleErrors($params); + + $this->_stubCreateSubscriber(); + } + + protected function _stubCreateSubscriber() + { + $this->_config->expects($this->any()) + ->method('_createSubscriber') + ->will($this->returnValue($this->_subscriber)); + } + + + protected function _stubGetSubscriberConfigNode($params) + { + $configNode = $params[self::PARAM_CONFIG_NODE]; + $this->_config->expects($this->any()) + ->method('_getSubscriberConfigNode') + ->will($this->returnValue($configNode)); + } + + protected function _stubGetSubscriberCollection($params) + { + if (isset($params[self::PARAM_SUBSCRIBER_COLLECTION])) { + $subscriberCollection = $params[self::PARAM_SUBSCRIBER_COLLECTION]; + } else { + $subscriberCollection = $this->_createMockSubscriberCollection(); + } + $this->_config->expects($this->any()) + ->method('_getSubscriberCollection') + ->will($this->returnValue($subscriberCollection)); + } + + protected function _stubHandleErrors($params) + { + if (isset($params[self::PARAM_EXPECTED_ERRORS])) { + $expectedErrors = $params[self::PARAM_EXPECTED_ERRORS]; + $this->_config->expects($this->once()) + ->method('_handleErrors') + ->with($this->equalTo($expectedErrors)); + } + } + + + protected function _setExpectations($params) + { + foreach ($params[self::PARAM_VALIDATION] as $key => $expectations) { + $mock = $this->_retrieveMock($key); + + foreach ($expectations as $expectation) { + $this->_attachExpectationToMock($expectation, $mock); + } + } + } + + protected function _attachExpectationToMock($expectation, $mock) + { + $invocationMocker = $mock->expects($expectation[self::INVOKE_EXPECTS]) + ->method($expectation[self::INVOKE_METHOD]); + if (isset($expectation[self::INVOKE_WITH_ARG])) { + $invocationMocker->with($expectation[self::INVOKE_WITH_ARG]); + } elseif (isset($expectation[self::INVOKE_WITH_ARGS])) { + call_user_func_array(array($invocationMocker, 'with'), $expectation[self::INVOKE_WITH_ARGS]); + } + } + + /** + * Overriding this method so we can register mocks that were setup during the data provider step. + * Sadly our parent class has no protected interface for adding to their private mockObjects array, + * so we need to create our own copy of the parent code and run that in addition to the parent method. + */ + protected function verifyMockObjects() + { + parent::verifyMockObjects(); + foreach ($this->_mockObjects as $mockObject) { + if ($mockObject->__phpunit_hasMatchers()) { + $this->addToAssertionCount(1); + } + + $mockObject->__phpunit_verify(); + $mockObject->__phpunit_cleanup(); + } + + $this->_mockObjects = array(); + } + + protected function _registerMocks($params) + { + if (isset($params[self::PARAM_MOCK_OBJECTS_TO_REGISTER])) { + foreach ($params[self::PARAM_MOCK_OBJECTS_TO_REGISTER] as $mock) { + $this->_registerMock($mock); + } + } + } + + protected function _registerMock($mock) + { + $this->_mockObjects[] = $mock; + } + +} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/Subscriber/WebapiTest.php b/dev/tests/unit/testsuite/Mage/Webhook/Model/Subscriber/WebapiTest.php new file mode 100644 index 0000000000000..78551ed0de087 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/Subscriber/WebapiTest.php @@ -0,0 +1,104 @@ +_subscriber = $this->getMockBuilder('Mage_Webhook_Model_Subscriber') + ->disableOriginalConstructor() + ->setMethods(array('getRequiredPermissions', 'getApiUser', 'setStatus', 'save')) + ->getMock(); + $this->_webapi = $this->getMockBuilder('Mage_Webhook_Model_Subscriber_Webapi') + ->setMethods(array('_deactivate', '_getAclRuleCollection')) + ->setConstructorArgs(array($this->_subscriber))->getMock(); + } + + public function provider() + { + return array( + array( + Mage_Webhook_Model_Subscriber_WebapiTest::REQUIRED_PERMISSION, + Mage_Webhook_Model_Subscriber_WebapiTest::REQUIRED_PERMISSION, TRUE + ), + array( + Mage_Webhook_Model_Subscriber_WebapiTest::REQUIRED_PERMISSION, + Mage_Webhook_Model_Subscriber_WebapiTest::RANDOM_PERMISSION, FALSE + ) + ); + } + + /** + * @dataProvider provider + * @param $requiredPermission + * @param $actualPermission + * @param $result + */ + public function testValidate($requiredPermission, $actualPermission, $result) + { + $mockUser = $this->getMockBuilder('Mage_Webapi_Model_Acl_User')->disableOriginalConstructor() + ->setMethods(array('getRoleId'))->getMock(); + $mockUser->expects($this->once())->method('getRoleId') + ->will($this->returnValue(Mage_Webhook_Model_Subscriber_WebapiTest::ROLE_ID)); + + $this->_subscriber->expects($this->once())->method('getRequiredPermissions') + ->will($this->returnValue(array($requiredPermission))); + $this->_subscriber->expects($this->once())->method('getApiUser')->will($this->returnValue($mockUser)); + + $mockRuleCollection = + $this->getMockBuilder('Mage_Webapi_Model_Resource_Acl_Rule_Collection')->disableOriginalConstructor() + ->setMethods(array('addFieldToFilter', 'load', 'toArray'))->getMock(); + $mockRuleCollection->expects($this->once())->method('addFieldToFilter')->will($this->returnSelf()); + $mockRuleCollection->expects($this->once())->method('load')->will($this->returnSelf()); + $mockRuleCollection->expects($this->once())->method('toArray') + ->will($this->returnValue(array(array($actualPermission)))); + + $this->_webapi->expects($this->once())->method('_getAclRuleCollection') + ->will($this->returnValue($mockRuleCollection)); + + // Deactivate if no match + if (FALSE == $result) { + $this->_subscriber->expects($this->once())->method('setStatus') + ->with(Mage_Webhook_Model_Subscriber::STATUS_INACTIVE); + $this->_subscriber->expects($this->once())->method('save'); + } + + $this->assertEquals($result, $this->_webapi->validate()); + } +} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/Transport/Http/ResponseTest.php b/dev/tests/unit/testsuite/Mage/Webhook/Model/Transport/Http/ResponseTest.php new file mode 100644 index 0000000000000..4ea186f3197ab --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/Transport/Http/ResponseTest.php @@ -0,0 +1,97 @@ +_mockObject = $this->getMockBuilder('Mage_Webhook_Model_Transport_Http_Response') + ->disableOriginalConstructor() + ->setMethods(array('getStatusCode')) + ->getMock(); + } + + /** + * Tests that a response is successful with 2xx status codes. + * + * @dataProvider successStatusCodes + */ + public function testSuccess($code) + { + $this->markTestSkipped('skipping testSuccess to debug build break'); + $this->_mockObject->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue($code)); + + $output = $this->_mockObject->isSuccessful(); + + $this->assertEquals(true, $output); + } + + public function successStatusCodes() + { + $codes = array('200', '202', '299'); + return $this->_wrapCodes($codes); + } + + /** + * Tests that a response is a failure with other status codes beyond 2xx. + * + * @dataProvider failureStatusCodes + */ + public function testFailure($code) + { + $this->markTestSkipped('skipping testFailure to debug build break'); + $this->_mockObject->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue($code)); + + $output = $this->_mockObject->isSuccessful(); + + $this->assertEquals(false, $output); + } + + public function failureStatusCodes() + { + $codes = array('-1', '0', '1', '100', '199', '300', '399', '400', '499', '500', '599'); + return $this->_wrapCodes($codes); + } + + protected function _wrapCodes($codes) + { + $wrappedCodes = array(); + foreach ($codes as $code) { + $wrappedCodes[] = array($code); + } + return $wrappedCodes; + } +} diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/Webapi/EventHandlerTest.php b/dev/tests/unit/testsuite/Mage/Webhook/Model/Webapi/EventHandlerTest.php new file mode 100644 index 0000000000000..69fb3ed65ed7c --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/Webapi/EventHandlerTest.php @@ -0,0 +1,163 @@ +_subscriberFactory = $this->getMockBuilder('Mage_Webhook_Model_Subscriber_Factory') + ->disableOriginalConstructor() + ->getMock(); + $this->_resourceSubscriber = $this->getMockBuilder('Mage_Webhook_Model_Resource_Subscriber') + ->disableOriginalConstructor() + ->getMock(); + $this->_resourceAclUser = $this->getMockBuilder('Mage_Webapi_Model_Resource_Acl_User') + ->disableOriginalConstructor() + ->getMock(); + + $this->_eventHandler = new Mage_Webhook_Model_Webapi_EventHandler( + $this->_subscriberFactory, + $this->_resourceSubscriber, + $this->_resourceAclUser + ); + } + + public function testUserChanged() + { + $subscriber = $this->_createMockSubscriber(); + $this->_setMockSubscribers($subscriber); + $user = $this->_createMockUser(1); + + $this->_eventHandler->userChanged($user); + } + + public function testUserChanged_noSubscriber() + { + $user = $this->_createMockUser(1); + + $this->_eventHandler->userChanged($user); + } + + public function testRoleChanged() + { + $subscriber = $this->_createMockSubscriber(); + $this->_setMockSubscribers($subscriber); + $role = $this->_createMockRole(1); + $users = array($this->_createMockUser(2)); + $this->_setRoleUsersExpectation($users); + + $this->_eventHandler->roleChanged($role); + } + + public function testRoleChanged_twoUsers() + { + $subscriber = $this->_createMockSubscriber(); + $this->_setMockSubscribers($subscriber); + $role = $this->_createMockRole(1); + $users = array($this->_createMockUser(1), $this->_createMockUser(2)); + $this->_setRoleUsersExpectation($users); + + $this->_eventHandler->roleChanged($role); + } + + public function testRoleChanged_twoSubscribers() + { + $subscribers = array($this->_createMockSubscriber(), $this->_createMockSubscriber()); + $this->_setMockSubscribers($subscribers); + $role = $this->_createMockRole(1); + $users = array($this->_createMockUser(1)); + $this->_setRoleUsersExpectation($users); + + $this->_eventHandler->roleChanged($role); + } + + protected function _setRoleUsersExpectation($users) + { + $this->_resourceAclUser->expects($this->any()) + ->method('getRoleUsers') + ->will($this->returnValue($users)); + } + + protected function _createMockRole($roleId) + { + $role = $this->getMockBuilder('Mage_Webapi_Model_Acl_Role') + ->disableOriginalConstructor() + ->getMock(); + $role->expects($this->any()) + ->method('getRoleId') + ->will($this->returnValue($roleId)); + return $role; + } + + protected function _createMockUser($userId) + { + $user = $this->getMockBuilder('Mage_Webapi_Model_Acl_User') + ->disableOriginalConstructor() + ->getMock(); + $user->expects($this->any()) + ->method('getUserId') + ->will($this->returnValue($userId)); + return $user; + } + + protected function _createMockSubscriber() + { + $subscriber = $this->getMockBuilder('Mage_Webhook_Model_Subscriber') + ->disableOriginalConstructor() + ->getMock(); + // Validate should be called at least once + $subscriber->expects($this->once()) + ->method('validate'); + + $subscriber->expects($this->any()) + ->method('load') + ->will($this->returnSelf()); + return $subscriber; + } + + protected function _setMockSubscribers($subscribers) + { + if (!is_array($subscribers)) { + $subscribers = array($subscribers); + } + $subs = array(); + foreach ($subscribers as $subscriber) { + $i = count($subs); + $this->_subscriberFactory->expects($this->at($i)) + ->method('create') + ->will($this->returnValue($subscriber)); + $subs[] = $i; + } + + $this->_resourceSubscriber->expects($this->any()) + ->method('getApiUserSubscribers') + ->will($this->returnValue($subs)); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/_files/acl.xml b/dev/tests/unit/testsuite/Mage/Webhook/Model/_files/acl.xml new file mode 100644 index 0000000000000..0dac78c6f3343 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/_files/acl.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/_files/acl.xsd b/dev/tests/unit/testsuite/Mage/Webhook/Model/_files/acl.xsd new file mode 100644 index 0000000000000..13fe79e8f9d4d --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/_files/acl.xsd @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + Attribute id is unique under all mapped ACL resources + + + + + + + + + + + + + + + + + + + ACL Resource. Recursive complex type + + + + + + + + + + + + + + + + + ACL Resource mapping. + + + + + + + + + + + Item id attribute can has only [A-Za-z0-9_]/[A-Za-z0-9_]. Minimal length 3 symbol. Case insensitive. + + + + + + + + + + + + Item title attribute minimal length 3 symbol + + + + + + + + + + + + + Item module attribute can has only [a-z0-9_]. Minimal length 3 symbol. Case insensitive. + + + + + + + diff --git a/dev/tests/unit/testsuite/Mage/Webhook/Model/_files/acl2.xml b/dev/tests/unit/testsuite/Mage/Webhook/Model/_files/acl2.xml new file mode 100644 index 0000000000000..bfb80071f958d --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Webhook/Model/_files/acl2.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + diff --git a/dev/tests/unit/testsuite/Magento/Acl/ResourceFactoryTest.php b/dev/tests/unit/testsuite/Magento/Acl/ResourceFactoryTest.php index 80a4fc1b19a34..3c21409331a4b 100644 --- a/dev/tests/unit/testsuite/Magento/Acl/ResourceFactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Acl/ResourceFactoryTest.php @@ -49,7 +49,7 @@ protected function setUp() $this->_expectedObject = $this->getMock('Magento_Acl_Resource', array(), array(), '', false); - $this->_model = $helper->getModel('Magento_Acl_ResourceFactory', array( + $this->_model = $helper->getObject('Magento_Acl_ResourceFactory', array( 'objectManager' => $this->_objectManager, )); } @@ -59,7 +59,7 @@ public function testCreateResource() $arguments = array('5', '6'); $this->_objectManager->expects($this->once()) ->method('create') - ->with('Magento_Acl_Resource', $arguments, false) + ->with('Magento_Acl_Resource', $arguments) ->will($this->returnValue($this->_expectedObject)); $this->assertEquals($this->_expectedObject, $this->_model->createResource($arguments)); } diff --git a/dev/tests/unit/testsuite/Magento/Cache/Backend/Decorator/CompressionTest.php b/dev/tests/unit/testsuite/Magento/Cache/Backend/Decorator/CompressionTest.php new file mode 100644 index 0000000000000..b70007c8121f5 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Cache/Backend/Decorator/CompressionTest.php @@ -0,0 +1,147 @@ + $this->getMock('Zend_Cache_Backend_File'), + 'compression_threshold' => strlen($this->_testString) + ); + $this->_decorator = new Magento_Cache_Backend_Decorator_Compression($options); + } + + protected function tearDown() + { + unset($this->_decorator); + self::$_cacheStorage = array(); + } + + public function testCompressData() + { + $method = new ReflectionMethod('Magento_Cache_Backend_Decorator_Compression', '_compressData'); + $method->setAccessible(true); + + $this->assertStringStartsWith('CACHE_COMPRESSION', $method->invoke($this->_decorator, $this->_testString)); + } + + public function testDecompressData() + { + $methodCompress = new ReflectionMethod('Magento_Cache_Backend_Decorator_Compression', '_compressData'); + $methodCompress->setAccessible(true); + + $methodDecompress = new ReflectionMethod('Magento_Cache_Backend_Decorator_Compression', '_decompressData'); + $methodDecompress->setAccessible(true); + + $this->assertEquals( + $this->_testString, + $methodDecompress->invoke($this->_decorator, $methodCompress->invoke($this->_decorator, $this->_testString)) + ); + } + + public function testIsCompressionNeeded() + { + $method = new ReflectionMethod('Magento_Cache_Backend_Decorator_Compression', '_isCompressionNeeded'); + $method->setAccessible(true); + + $this->assertFalse($method->invoke($this->_decorator, $this->_testString)); + $this->assertFalse($method->invoke($this->_decorator, substr($this->_testString, 0, -1))); + $this->assertTrue($method->invoke($this->_decorator, $this->_testString . 's')); + } + + public function testIsDecompressionNeeded() + { + $prefix = 'CACHE_COMPRESSION'; + + $method = new ReflectionMethod('Magento_Cache_Backend_Decorator_Compression', '_isDecompressionNeeded'); + $method->setAccessible(true); + + $this->assertFalse($method->invoke($this->_decorator, $this->_testString)); + $this->assertFalse($method->invoke($this->_decorator, 's' . $prefix . $this->_testString)); + $this->assertTrue($method->invoke($this->_decorator, $prefix . $this->_testString)); + } + + public function testSaveLoad() + { + $cacheId = 'cacheId' . rand(1, 100); + + $backend = $this->getMock('Zend_Cache_Backend_File', array('save', 'load')); + $backend->expects($this->once()) + ->method('save') + ->will($this->returnCallback(array(__CLASS__, 'mockSave'))); + + $backend->expects($this->once()) + ->method('load') + ->will($this->returnCallback(array(__CLASS__, 'mockLoad'))); + + $options = array( + 'concrete_backend' => $backend, + 'compression_threshold' => strlen($this->_testString) + ); + + $decorator = new Magento_Cache_Backend_Decorator_Compression($options); + + $decorator->setOption('write_control', false); + $decorator->setOption('automatic_cleaning_factor', 0); + + $decorator->save($this->_testString, $cacheId); + + $this->assertArrayHasKey($cacheId, self::$_cacheStorage); + $this->assertInternalType('string', self::$_cacheStorage[$cacheId]); + + $loadedValue = $decorator->load($cacheId); + + $this->assertEquals($this->_testString, $loadedValue); + } + + public static function mockSave($data, $cacheId) + { + self::$_cacheStorage[$cacheId] = $data; + return true; + } + + public static function mockLoad($cacheId) + { + return array_key_exists($cacheId, self::$_cacheStorage) ? self::$_cacheStorage[$cacheId] : false; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Cache/Backend/Decorator/DecoratorAbstractTest.php b/dev/tests/unit/testsuite/Magento/Cache/Backend/Decorator/DecoratorAbstractTest.php new file mode 100644 index 0000000000000..b78aff19cd527 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Cache/Backend/Decorator/DecoratorAbstractTest.php @@ -0,0 +1,115 @@ +_mockBackend = $this->getMock('Zend_Cache_Backend_File'); + } + + protected function tearDown() + { + unset($this->_mockBackend); + } + + public function testConstructor() + { + $options = array('concrete_backend' => $this->_mockBackend, 'testOption' => 'testOption'); + + $decorator = $this->getMockForAbstractClass( + 'Magento_Cache_Backend_Decorator_DecoratorAbstract', + array($options) + ); + + $backendProperty = new ReflectionProperty('Magento_Cache_Backend_Decorator_DecoratorAbstract', '_backend'); + $backendProperty->setAccessible(true); + + $optionsProperty = + new ReflectionProperty('Magento_Cache_Backend_Decorator_DecoratorAbstract', '_decoratorOptions'); + $optionsProperty->setAccessible(true); + + $this->assertSame($backendProperty->getValue($decorator), $this->_mockBackend); + + $this->assertArrayNotHasKey('concrete_backend', $optionsProperty->getValue($decorator)); + $this->assertArrayNotHasKey('testOption', $optionsProperty->getValue($decorator)); + } + + /** + * @param array options + * @expectedException Zend_Cache_Exception + * @dataProvider constructorExceptionDataProvider + */ + public function testConstructorException($options) + { + $this->getMockForAbstractClass( + 'Magento_Cache_Backend_Decorator_DecoratorAbstract', + array($options) + ); + } + + public function constructorExceptionDataProvider() + { + return array( + 'empty' => array(array()), + 'wrong_class' => array(array('concrete_backend' => $this->getMock('Test_Class'))) + ); + } + + /** + * @dataProvider allMethodsDataProvider + */ + public function testAllMethods($methodName) + { + $this->_mockBackend->expects($this->once())->method($methodName); + + $decorator = $this->getMockForAbstractClass( + 'Magento_Cache_Backend_Decorator_DecoratorAbstract', + array(array('concrete_backend' => $this->_mockBackend)) + ); + + call_user_func(array($decorator, $methodName), null, null); + } + + public function allMethodsDataProvider() + { + $return = array(); + $allMethods = array('setDirectives', 'load', 'test', 'save', 'remove', 'clean', 'getIds', 'getTags', + 'getIdsMatchingTags', 'getIdsNotMatchingTags', 'getIdsMatchingAnyTags', 'getFillingPercentage', + 'getMetadatas', 'touch', 'getCapabilities', 'setOption', 'getLifetime', 'isAutomaticCleaningAvailable', + 'getTmpDir'); + foreach ($allMethods as $method) { + $return[$method] = array($method); + } + return $return; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Cache/Backend/MongoDbTest.php b/dev/tests/unit/testsuite/Magento/Cache/Backend/MongoDbTest.php index f2a8591b05068..9bac10d2df862 100644 --- a/dev/tests/unit/testsuite/Magento/Cache/Backend/MongoDbTest.php +++ b/dev/tests/unit/testsuite/Magento/Cache/Backend/MongoDbTest.php @@ -243,16 +243,20 @@ public function testGetCapabilities() */ public function testLoad($doNotTestValidity) { + include_once(__DIR__ . '/_files/MongoBinData.php'); + $cacheId = 'test_id'; $expected = 'test_data'; $validityCondition = $this->arrayHasKey('$or'); if ($doNotTestValidity) { $validityCondition = $this->logicalNot($validityCondition); } + $binData = new MongoBinData($expected, MongoBinData::BYTE_ARRAY); + $binData->bin = $expected; $this->_collection->expects($this->once()) ->method('findOne') ->with($this->logicalAnd($this->arrayHasKey('_id'), $validityCondition)) - ->will($this->returnValue(array('data' => $expected))); + ->will($this->returnValue(array('data' => $binData))); $actual = $this->_model->load($cacheId, $doNotTestValidity); $this->assertSame($expected, $actual); } @@ -294,6 +298,8 @@ public function testTestNotFound() public function testSave() { + include_once(__DIR__ . '/_files/MongoBinData.php'); + $inputAssertion = $this->logicalAnd( $this->arrayHasKey('_id'), $this->arrayHasKey('data'), diff --git a/dev/tests/unit/testsuite/Magento/Cache/Backend/_files/MongoBinData.php b/dev/tests/unit/testsuite/Magento/Cache/Backend/_files/MongoBinData.php new file mode 100644 index 0000000000000..e250b2a983bb6 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Cache/Backend/_files/MongoBinData.php @@ -0,0 +1,42 @@ +getMock('Zend_Cache_Core'); + $object = new Magento_Cache_Frontend_Adapter_Zend($frontendMock); + $helper = new Magento_Test_Helper_ProxyTesting(); + $result = $helper->invokeWithExpectations($object, $frontendMock, $method, $params, $expectedResult, $method, + $expectedParams); + $this->assertSame($expectedResult, $result); + } + + /** + * @return array + */ + public static function proxyMethodDataProvider() + { + return array( + 'test' => array('test', array('record_id'), array('RECORD_ID'), 111), + 'load' => array('load', array('record_id'), array('RECORD_ID'), '111'), + 'save' => array( + 'save', + array('record_value', 'record_id', array('tag1', 'tag2'), 555), + array('record_value', 'RECORD_ID', array('TAG1', 'TAG2'), 555), + true, + ), + 'remove' => array('remove', array('record_id'), array('RECORD_ID'), true), + 'clean mode "all"' => array( + 'clean', + array(Zend_Cache::CLEANING_MODE_ALL, array()), + array(Zend_Cache::CLEANING_MODE_ALL, array()), + true, + ), + 'clean mode "matching tag"' => array( + 'clean', + array(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('tag1', 'tag2')), + array(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('TAG1', 'TAG2')), + true, + ), + 'clean mode "matching any tag"' => array( + 'clean', + array(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('tag1', 'tag2')), + array(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('TAG1', 'TAG2')), + true, + ), + 'getBackend' => array( + 'getBackend', + array(), + array(), + PHPUnit_Framework_MockObject_Generator::getMock('Zend_Cache_Backend'), + ), + ); + } + + /** + * @param string $cleaningMode + * @param string $expectedErrorMessage + * @dataProvider cleanExceptionDataProvider + */ + public function testCleanException($cleaningMode, $expectedErrorMessage) + { + $this->setExpectedException('InvalidArgumentException', $expectedErrorMessage); + $object = new Magento_Cache_Frontend_Adapter_Zend($this->getMock('Zend_Cache_Core')); + $object->clean($cleaningMode); + } + + public function cleanExceptionDataProvider() + { + return array( + 'cleaning mode "expired"' => array( + Zend_Cache::CLEANING_MODE_OLD, + "Magento cache frontend does not support the cleaning mode 'old'.", + ), + 'cleaning mode "not matching tag"' => array( + Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG, + "Magento cache frontend does not support the cleaning mode 'notMatchingTag'.", + ), + 'non-existing cleaning mode' => array( + 'nonExisting', + "Magento cache frontend does not support the cleaning mode 'nonExisting'.", + ), + ); + } + + public function testGetLowLevelFrontend() + { + $frontendMock = $this->getMock('Zend_Cache_Core'); + $object = new Magento_Cache_Frontend_Adapter_Zend($frontendMock); + $this->assertSame($frontendMock, $object->getLowLevelFrontend()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Cache/Frontend/Decorator/BareTest.php b/dev/tests/unit/testsuite/Magento/Cache/Frontend/Decorator/BareTest.php new file mode 100644 index 0000000000000..2ffea5d512468 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Cache/Frontend/Decorator/BareTest.php @@ -0,0 +1,59 @@ +getMock('Magento_Cache_FrontendInterface'); + + $object = new Magento_Cache_Frontend_Decorator_Bare($frontendMock); + $helper = new Magento_Test_Helper_ProxyTesting(); + $result = $helper->invokeWithExpectations($object, $frontendMock, $method, $params, $expectedResult); + $this->assertSame($expectedResult, $result); + } + + /** + * @return array + */ + public static function proxyMethodDataProvider() + { + return array( + array('test', array('record_id'), 111), + array('load', array('record_id'), '111'), + array('save', array('record_value', 'record_id', array('tag'), 555), true), + array('remove', array('record_id'), true), + array('clean', array(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('tag')), true), + array('getBackend', array(), PHPUnit_Framework_MockObject_Generator::getMock('Zend_Cache_Backend')), + array('getLowLevelFrontend', array(), + PHPUnit_Framework_MockObject_Generator::getMock('Zend_Cache_Core') + ), + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Cache/Frontend/Decorator/ProfilerTest.php b/dev/tests/unit/testsuite/Magento/Cache/Frontend/Decorator/ProfilerTest.php new file mode 100644 index 0000000000000..88d7c0fc55167 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Cache/Frontend/Decorator/ProfilerTest.php @@ -0,0 +1,159 @@ +getMock('Magento_Cache_FrontendInterface'); + + $frontendMock->expects($this->any()) + ->method('getBackend') + ->will($this->returnValue($cacheBackend)); + + $frontendMock->expects($this->any()) + ->method('getLowLevelFrontend') + ->will($this->returnValue($cacheFrontend)); + + // Profiler setup + $driver = $this->getMock('Magento_Profiler_DriverInterface'); + $driver->expects($this->once()) + ->method('start') + ->with($expectedProfileId, $expectedProfilerTags); + $driver->expects($this->once()) + ->method('stop') + ->with($expectedProfileId); + Magento_Profiler::add($driver); + + // Test + $object = new Magento_Cache_Frontend_Decorator_Profiler($frontendMock, array('Zend_Cache_Backend_')); + $helper = new Magento_Test_Helper_ProxyTesting(); + $result = $helper->invokeWithExpectations($object, $frontendMock, $method, $params, $expectedResult); + $this->assertSame($expectedResult, $result); + } + + /** + * @return array + */ + public static function proxyMethodDataProvider() + { + $backend = new Zend_Cache_Backend_BlackHole;; + $adaptee = PHPUnit_Framework_MockObject_Generator::getMock('Zend_Cache_Core', array(), array(), '', false); + $lowLevelFrontend = new Magento_Cache_Frontend_Adapter_Zend($adaptee); + + return array( + array( + 'test', + array('record_id'), + $backend, + $lowLevelFrontend, + 'cache_test', + array( + 'group' => 'cache', + 'operation' => 'cache:test', + 'frontend_type' => 'Magento_Cache_Frontend_Adapter_Zend', + 'backend_type' => 'BlackHole', + ), + 111 + ), + array( + 'load', + array('record_id'), + $backend, + $lowLevelFrontend, + 'cache_load', + array( + 'group' => 'cache', + 'operation' => 'cache:load', + 'frontend_type' => 'Magento_Cache_Frontend_Adapter_Zend', + 'backend_type' => 'BlackHole', + ), + '111' + ), + array( + 'save', + array('record_value', 'record_id', array('tag'), 555), + $backend, + $lowLevelFrontend, + 'cache_save', + array( + 'group' => 'cache', + 'operation' => 'cache:save', + 'frontend_type' => 'Magento_Cache_Frontend_Adapter_Zend', + 'backend_type' => 'BlackHole', + ), + true + ), + array( + 'remove', + array('record_id'), + $backend, + $lowLevelFrontend, + 'cache_remove', + array( + 'group' => 'cache', + 'operation' => 'cache:remove', + 'frontend_type' => 'Magento_Cache_Frontend_Adapter_Zend', + 'backend_type' => 'BlackHole', + ), + true + ), + array( + 'clean', + array(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('tag')), + $backend, + $lowLevelFrontend, + 'cache_clean', + array( + 'group' => 'cache', + 'operation' => 'cache:clean', + 'frontend_type' => 'Magento_Cache_Frontend_Adapter_Zend', + 'backend_type' => 'BlackHole', + ), + true + ), + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Cache/Frontend/Decorator/TagMarkerTest.php b/dev/tests/unit/testsuite/Magento/Cache/Frontend/Decorator/TagMarkerTest.php new file mode 100644 index 0000000000000..7ad3481528256 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Cache/Frontend/Decorator/TagMarkerTest.php @@ -0,0 +1,62 @@ +_frontend = $this->getMock('Magento_Cache_FrontendInterface'); + $this->_object = new Magento_Cache_Frontend_Decorator_TagMarker($this->_frontend, $this->_tagForTests); + } + + public function testGetTag() + { + $this->assertEquals($this->_tagForTests, $this->_object->getTag()); + } + + public function testSave() + { + $this->_frontend->expects($this->once()) + ->method('save') + ->with('record_value', 'record_id', array('passed_tag', $this->_tagForTests), 111) + ->will($this->returnValue(true)); + + $result = $this->_object->save('record_value', 'record_id', array('passed_tag'), 111); + $this->assertTrue($result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Cache/Frontend/Decorator/TagScopeTest.php b/dev/tests/unit/testsuite/Magento/Cache/Frontend/Decorator/TagScopeTest.php new file mode 100644 index 0000000000000..338137c3061e8 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Cache/Frontend/Decorator/TagScopeTest.php @@ -0,0 +1,85 @@ +_cache = new CacheScopeCleanVerification(); + } + + /** + * @param string $mode + * @param array $tags + * @param array $expectedRecordsLeft + * @dataProvider cleanDataProvider + */ + public function testClean($mode, $tags, $expectedRecordsLeft) + { + $frontend = $this->getMock('Magento_Cache_FrontendInterface'); + $frontend->expects($this->any()) + ->method('clean') + ->will($this->returnCallback(array($this->_cache, 'clean'))); + + $object = new Magento_Cache_Frontend_Decorator_TagScope($frontend, $this->_tagForTests); + $object->clean($mode, $tags); + $this->assertEquals($expectedRecordsLeft, $this->_cache->getRecordIds()); + } + + public function cleanDataProvider() + { + return array( + Zend_Cache::CLEANING_MODE_ALL => array( + Zend_Cache::CLEANING_MODE_ALL, + array(), + array('elephant', 'man', 'raccoon') + ), + 'tags must be ignored in CLEANING_MODE_ALL' => array( + Zend_Cache::CLEANING_MODE_ALL, + array('big'), + array('elephant', 'man', 'raccoon') + ), + Zend_Cache::CLEANING_MODE_MATCHING_TAG => array( + Zend_Cache::CLEANING_MODE_MATCHING_TAG, + array('big'), + array('elephant', 'man', 'raccoon', 'turkey', 'pigeon') + ), + Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => array( + Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, + array('big', 'small'), + array('elephant', 'man', 'raccoon', 'turkey') + ), + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Cache/Frontend/Decorator/_files/CacheScopeCleanVerification.php b/dev/tests/unit/testsuite/Magento/Cache/Frontend/Decorator/_files/CacheScopeCleanVerification.php new file mode 100644 index 0000000000000..25b01d845bf8f --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Cache/Frontend/Decorator/_files/CacheScopeCleanVerification.php @@ -0,0 +1,79 @@ + array('mammal', 'big'), + 'man' => array('mammal', 'medium'), + 'raccoon' => array('mammal', 'small'), + 'ostrich' => array('bird', 'big'), + 'turkey' => array('bird', 'medium'), + 'pigeon' => array('bird', 'small') + ); + + /** + * Clean records according to tags and mode + * + * @param string $mode + * @param array $tags + * @return bool + */ + public function clean($mode, $tags) + { + switch ($mode) { + case Zend_Cache::CLEANING_MODE_MATCHING_TAG: + $filterFunc = function ($recTags) use ($tags) { + return (bool) array_diff($tags, $recTags); + }; + break; + case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: + $filterFunc = function ($recTags) use ($tags) { + return !array_intersect($recTags, $tags); + }; + break; + case Zend_Cache::CLEANING_MODE_ALL: + $filterFunc = function () { + return false; + }; + break; + default: + return false; + } + $this->_records = array_filter($this->_records, $filterFunc); + return true; + } + + /** + * Return id of records left + * + * @return array + */ + public function getRecordIds() + { + return array_keys($this->_records); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Di/Generator/ClassTest.php b/dev/tests/unit/testsuite/Magento/Code/Generator/ClassTest.php similarity index 75% rename from dev/tests/unit/testsuite/Magento/Di/Generator/ClassTest.php rename to dev/tests/unit/testsuite/Magento/Code/Generator/ClassTest.php index 2331bad61b08c..82d4a2a4c0dca 100644 --- a/dev/tests/unit/testsuite/Magento/Di/Generator/ClassTest.php +++ b/dev/tests/unit/testsuite/Magento/Code/Generator/ClassTest.php @@ -19,18 +19,18 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Di + * @package Magento_Code * @subpackage unit_tests * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Magento_Di_Generator_ClassTest extends PHPUnit_Framework_TestCase +class Magento_Code_Generator_ClassTest extends PHPUnit_Framework_TestCase { /** * Test class name for generation test */ - const TEST_CLASS_NAME = 'Magento_Di_Generator_TestAsset_TestGenerationClass'; + const TEST_CLASS_NAME = 'Magento_Code_Generator_TestAsset_TestGenerationClass'; /** * Expected arguments for test class constructor @@ -38,21 +38,21 @@ class Magento_Di_Generator_ClassTest extends PHPUnit_Framework_TestCase * @var array */ protected $_expectedArguments = array( - 0 => 'Magento\Di\Generator\TestAsset\ParentClass', - 1 => 'Magento\Di\Generator\TestAsset\SourceClass', + 0 => 'Magento\Code\Generator\TestAsset\ParentClass', + 1 => 'Magento\Code\Generator\TestAsset\SourceClass', 2 => 'Not_Existing_Class', ); public function testGenerateForConstructor() { - $generatorMock = $this->getMock('Magento_Di_Generator', array('generateClass'), array(), '', false); + $generatorMock = $this->getMock('Magento_Code_Generator', array('generateClass'), array(), '', false); foreach ($this->_expectedArguments as $order => $class) { $generatorMock->expects($this->at($order)) ->method('generateClass') ->with($class); } - $classGenerator = new Magento_Di_Generator_Class($generatorMock); + $classGenerator = new Magento_Code_Generator_Class($generatorMock); $classGenerator->generateForConstructor(self::TEST_CLASS_NAME); } } diff --git a/dev/tests/unit/testsuite/Magento/Code/Generator/CodeGenerator/ZendTest.php b/dev/tests/unit/testsuite/Magento/Code/Generator/CodeGenerator/ZendTest.php new file mode 100644 index 0000000000000..7e3cec5f89f6d --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Code/Generator/CodeGenerator/ZendTest.php @@ -0,0 +1,330 @@ + 'isConst', + self::FLAG_STATIC => 'isStatic', + self::FLAG_FINAL => 'isFinal', + self::FLAG_ABSTRACT => 'isAbstract', + self::FLAG_REFERENCE => 'getPassedByReference', + ); + + /** + * Doc block test data + * + * @var array + */ + protected $_docBlockData = array( + 'shortDescription' => 'test_short_description', + 'longDescription' => 'test_long_description', + 'tags' => array( + 'tag1' => array('name' => 'tag1', 'description' => 'data1'), + 'tag2' => array('name' => 'tag2', 'description' => 'data2'), + ), + ); + + /** + * Method test data + * + * @var array + */ + protected $_methodData = array( + 'testMethod1' => array( + 'name' => 'testMethod1', + 'final' => true, + 'static' => true, + 'parameters' => array( + array('name' => 'data', 'type' => 'array', 'defaultValue' => array(), 'passedByReference' => true), + ), + 'body' => 'return 1;', + 'docblock' => array( + 'shortDescription' => 'test short description' + ), + ), + '_testMethod2' => array( + 'name' => '_testMethod2', + 'visibility' => 'private', + 'abstract' => true, + 'parameters' => array( + array('name' => 'data', 'defaultValue' => 'test_default'), + array('name' => 'flag', 'defaultValue' => true), + ), + 'body' => 'return 2;', + 'docblock' => array( + 'shortDescription' => 'test short description', + 'longDescription' => 'test long description', + 'tags' => array( + 'tag1' => array('name' => 'tag1', 'description' => 'data1'), + 'tag2' => array('name' => 'tag2', 'description' => 'data2'), + ), + ), + ), + 'testMethod3' => array( + 'name' => 'testMethod3', + 'body' => 'return 3;', + ), + ); + + /** + * Property test data + * + * @var array + */ + protected $_propertyData = array( + 'TEST_CONSTANT' => array( + 'name' => 'TEST_CONSTANT', + 'const' => true, + 'defaultValue' => 'default constant value', + 'docblock' => array('shortDescription' => 'test description'), + ), + '_protectedProperty' => array( + 'name' => '_protectedProperty', + 'visibility' => 'protected', + 'static' => 'true', + 'docblock' => array( + 'shortDescription' => 'Object Manager instance', + 'tags' => array( + 'var' => array('name' => 'var', 'description' => 'tag description') + ) + ), + ), + 'publicProperty' => array( + 'name' => 'publicProperty', + ), + ); + + protected function setUp() + { + $this->_model = new Magento_Code_Generator_CodeGenerator_Zend(); + } + + protected function tearDown() + { + unset($this->_model); + } + + public function testSetClassDocBlock() + { + $this->_model->setClassDocBlock($this->_docBlockData); + $actualDocBlock = $this->_model->getDocBlock(); + + $this->_assertDocBlockData($this->_docBlockData, $actualDocBlock); + } + + /** + * @param array $expectedDocBlock + * @param Zend\Code\Generator\DocBlockGenerator $actualDocBlock + */ + protected function _assertDocBlockData( + array $expectedDocBlock, + Zend\Code\Generator\DocBlockGenerator $actualDocBlock + ) { + // assert plain string data + foreach ($expectedDocBlock as $propertyName => $propertyData) { + if (is_string($propertyData)) { + $this->assertAttributeEquals($propertyData, $propertyName, $actualDocBlock); + } + } + + // assert tags + if (isset($expectedDocBlock['tags'])) { + $expectedTagsData = $expectedDocBlock['tags']; + $actualTags = $actualDocBlock->getTags(); + $this->assertSameSize($expectedTagsData, $actualTags); + /** @var $actualTag Zend\Code\Generator\DocBlock\Tag */ + foreach ($actualTags as $actualTag) { + $tagName = $actualTag->getName(); + $this->assertArrayHasKey($tagName, $expectedTagsData); + $this->assertEquals($expectedTagsData[$tagName]['name'], $tagName); + $this->assertEquals($expectedTagsData[$tagName]['description'], $actualTag->getDescription()); + } + } + } + + public function testAddMethods() + { + $this->_model->addMethods($this->_methodData); + $actualMethods = $this->_model->getMethods(); + + $this->assertSameSize($this->_methodData, $actualMethods); + + /** @var $method Zend\Code\Generator\MethodGenerator */ + foreach ($actualMethods as $methodName => $method) { + $this->assertArrayHasKey($methodName, $this->_methodData); + $expectedMethodData = $this->_methodData[$methodName]; + + $this->assertEquals($expectedMethodData['name'], $method->getName()); + $this->assertEquals($expectedMethodData['body'], $method->getBody()); + + // assert flags + $this->_assertFlag(self::FLAG_STATIC, $expectedMethodData, $method); + $this->_assertFlag(self::FLAG_FINAL, $expectedMethodData, $method); + $this->_assertFlag(self::FLAG_ABSTRACT, $expectedMethodData, $method); + + // assert visibility + $this->_assertVisibility($expectedMethodData, $method); + + // assert parameters + if (isset($expectedMethodData['parameters'])) { + $actualParameters = $method->getParameters(); + $this->assertSameSize($expectedMethodData['parameters'], $actualParameters); + foreach ($expectedMethodData['parameters'] as $parameterData) { + $parameterName = $parameterData['name']; + $this->assertArrayHasKey($parameterName, $actualParameters); + /** @var $actualParameter Zend\Code\Generator\ParameterGenerator */ + $actualParameter = $actualParameters[$parameterName]; + $this->assertEquals($parameterName, $actualParameter->getName()); + + // assert reference flag + $this->_assertFlag(self::FLAG_REFERENCE, $parameterData, $actualParameter); + + // assert parameter type + if (isset($parameterData['type'])) { + $this->assertEquals($parameterData['type'], $actualParameter->getType()); + } + + // assert default value + if (isset($parameterData['defaultValue'])) { + /** @var $actualDefaultValue Zend\Code\Generator\ValueGenerator */ + $actualDefaultValue = $actualParameter->getDefaultValue(); + $this->assertEquals($parameterData['defaultValue'], $actualDefaultValue->getValue()); + } + } + } + + // assert docblock + if (isset($expectedMethodData['docblock'])) { + $actualDocBlock = $method->getDocBlock(); + $this->_assertDocBlockData($expectedMethodData['docblock'], $actualDocBlock); + } + } + } + + /** + * @param string $flagType + * @param array $expectedData + * @param object $actualObject + */ + protected function _assertFlag($flagType, array $expectedData, $actualObject) + { + $expectedFlagValue = isset($expectedData[$flagType]) && $expectedData[$flagType]; + $flagGetter = $this->_flagVerification[$flagType]; + $this->assertEquals($expectedFlagValue, $actualObject->{$flagGetter}()); + } + + /** + * @param array $expectedData + * @param Zend\Code\Generator\AbstractMemberGenerator $actualObject + */ + protected function _assertVisibility(array $expectedData, Zend\Code\Generator\AbstractMemberGenerator $actualObject) + { + $expectedVisibility = isset($expectedData['visibility']) ? $expectedData['visibility'] : 'public'; + $this->assertEquals($expectedVisibility, $actualObject->getVisibility()); + } + + /** + * Correct behaviour of addMethodFromGenerator is already tested in testAddMethods + * + * @expectedException InvalidArgumentException + * @expectedExceptionMessage addMethodFromGenerator() expects string for name + */ + public function testAddMethodFromGenerator() + { + $invalidMethod = new Zend\Code\Generator\MethodGenerator(); + $this->_model->addMethodFromGenerator($invalidMethod); + } + + public function testAddProperties() + { + $this->_model->addProperties($this->_propertyData); + $actualProperties = $this->_model->getProperties(); + + $this->assertSameSize($this->_propertyData, $actualProperties); + + /** @var $property Zend\Code\Generator\PropertyGenerator */ + foreach ($actualProperties as $propertyName => $property) { + $this->assertArrayHasKey($propertyName, $this->_propertyData); + $expectedPropertyData = $this->_propertyData[$propertyName]; + + $this->assertEquals($expectedPropertyData['name'], $property->getName()); + + // assert flags + $this->_assertFlag(self::FLAG_CONST, $expectedPropertyData, $property); + $this->_assertFlag(self::FLAG_STATIC, $expectedPropertyData, $property); + + // assert visibility + $this->_assertVisibility($expectedPropertyData, $property); + + // assert default value + if (isset($expectedPropertyData['defaultValue'])) { + /** @var $actualDefaultValue Zend\Code\Generator\ValueGenerator */ + $actualDefaultValue = $property->getDefaultValue(); + $this->assertEquals($expectedPropertyData['defaultValue'], $actualDefaultValue->getValue()); + } + + // assert docblock + if (isset($expectedPropertyData['docblock'])) { + $actualDocBlock = $property->getDocBlock(); + $this->_assertDocBlockData($expectedPropertyData['docblock'], $actualDocBlock); + } + } + } + + /** + * Correct behaviour of addPropertyFromGenerator is already tested in testAddProperties + * + * @expectedException InvalidArgumentException + * @expectedExceptionMessage addPropertyFromGenerator() expects string for name + */ + public function testAddPropertyFromGenerator() + { + $invalidProperty = new Zend\Code\Generator\PropertyGenerator(); + $this->_model->addPropertyFromGenerator($invalidProperty); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Di/Generator/EntityAbstractTest.php b/dev/tests/unit/testsuite/Magento/Code/Generator/EntityAbstractTest.php similarity index 87% rename from dev/tests/unit/testsuite/Magento/Di/Generator/EntityAbstractTest.php rename to dev/tests/unit/testsuite/Magento/Code/Generator/EntityAbstractTest.php index 0787c7101c40a..2a282c8d0eed9 100644 --- a/dev/tests/unit/testsuite/Magento/Di/Generator/EntityAbstractTest.php +++ b/dev/tests/unit/testsuite/Magento/Code/Generator/EntityAbstractTest.php @@ -19,13 +19,13 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Di + * @package Magento_Code * @subpackage unit_tests * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Magento_Di_Generator_EntityAbstractTest extends PHPUnit_Framework_TestCase +class Magento_Code_Generator_EntityAbstractTest extends PHPUnit_Framework_TestCase { /**#@+ * Source and result class parameters @@ -51,13 +51,13 @@ class Magento_Di_Generator_EntityAbstractTest extends PHPUnit_Framework_TestCase /** * Model under test * - * @var Magento_Di_Generator_EntityAbstract|PHPUnit_Framework_MockObject_MockObject + * @var Magento_Code_Generator_EntityAbstract|PHPUnit_Framework_MockObject_MockObject */ protected $_model; protected function setUp() { - $this->_model = $this->getMockForAbstractClass('Magento_Di_Generator_EntityAbstract'); + $this->_model = $this->getMockForAbstractClass('Magento_Code_Generator_EntityAbstract'); } protected function tearDown() @@ -70,24 +70,24 @@ public function testConstruct() // without parameters $this->assertAttributeEmpty('_sourceClassName', $this->_model); $this->assertAttributeEmpty('_resultClassName', $this->_model); - $this->assertAttributeInstanceOf('Magento_Di_Generator_Io', '_ioObject', $this->_model); - $this->assertAttributeInstanceOf('Magento_Di_Generator_CodeGenerator_Zend', '_classGenerator', $this->_model); + $this->assertAttributeInstanceOf('Magento_Code_Generator_Io', '_ioObject', $this->_model); + $this->assertAttributeInstanceOf('Magento_Code_Generator_CodeGenerator_Zend', '_classGenerator', $this->_model); $this->assertAttributeInstanceOf('Magento_Autoload_IncludePath', '_autoloader', $this->_model); // with source class name $this->_model = $this->getMockForAbstractClass( - 'Magento_Di_Generator_EntityAbstract', array(self::SOURCE_CLASS) + 'Magento_Code_Generator_EntityAbstract', array(self::SOURCE_CLASS) ); $this->assertAttributeEquals(self::SOURCE_CLASS, '_sourceClassName', $this->_model); $this->assertAttributeEquals(self::SOURCE_CLASS . 'Abstract', '_resultClassName', $this->_model); // with all arguments - $ioObject = $this->getMock('Magento_Di_Generator_Io', array(), array(), '', false); - $codeGenerator = $this->getMock('Magento_Di_Generator_CodeGenerator_Zend', array(), array(), '', false); + $ioObject = $this->getMock('Magento_Code_Generator_Io', array(), array(), '', false); + $codeGenerator = $this->getMock('Magento_Code_Generator_CodeGenerator_Zend', array(), array(), '', false); $autoloader = $this->getMock('Magento_Autoload_IncludePath', array(), array(), '', false); $this->_model = $this->getMockForAbstractClass( - 'Magento_Di_Generator_EntityAbstract', + 'Magento_Code_Generator_EntityAbstract', array(self::SOURCE_CLASS, self::RESULT_CLASS, $ioObject, $codeGenerator, $autoloader) ); $this->assertAttributeEquals(self::RESULT_CLASS, '_resultClassName', $this->_model); @@ -165,17 +165,17 @@ public function generateDataProvider() * @param bool $isValid * * @dataProvider generateDataProvider - * @covers Magento_Di_Generator_EntityAbstract::generate - * @covers Magento_Di_Generator_EntityAbstract::getErrors - * @covers Magento_Di_Generator_EntityAbstract::_getSourceClassName - * @covers Magento_Di_Generator_EntityAbstract::_getResultClassName - * @covers Magento_Di_Generator_EntityAbstract::_getDefaultResultClassName - * @covers Magento_Di_Generator_EntityAbstract::_generateCode - * @covers Magento_Di_Generator_EntityAbstract::_addError - * @covers Magento_Di_Generator_EntityAbstract::_validateData - * @covers Magento_Di_Generator_EntityAbstract::_getClassDocBlock - * @covers Magento_Di_Generator_EntityAbstract::_getGeneratedCode - * @covers Magento_Di_Generator_EntityAbstract::_fixCodeStyle + * @covers Magento_Code_Generator_EntityAbstract::generate + * @covers Magento_Code_Generator_EntityAbstract::getErrors + * @covers Magento_Code_Generator_EntityAbstract::_getSourceClassName + * @covers Magento_Code_Generator_EntityAbstract::_getResultClassName + * @covers Magento_Code_Generator_EntityAbstract::_getDefaultResultClassName + * @covers Magento_Code_Generator_EntityAbstract::_generateCode + * @covers Magento_Code_Generator_EntityAbstract::_addError + * @covers Magento_Code_Generator_EntityAbstract::_validateData + * @covers Magento_Code_Generator_EntityAbstract::_getClassDocBlock + * @covers Magento_Code_Generator_EntityAbstract::_getGeneratedCode + * @covers Magento_Code_Generator_EntityAbstract::_fixCodeStyle */ public function testGenerate( $errors = array(), @@ -200,7 +200,7 @@ public function testGenerate( } $abstractGetters = array('_getClassProperties', '_getClassMethods'); $this->_model = $this->getMockForAbstractClass( - 'Magento_Di_Generator_EntityAbstract', $arguments, '', true, true, true, $abstractGetters + 'Magento_Code_Generator_EntityAbstract', $arguments, '', true, true, true, $abstractGetters ); // we need to mock abstract methods to set correct return value type foreach ($abstractGetters as $methodName) { @@ -236,7 +236,7 @@ protected function _prepareMocksForValidateData( $makeResultFile = true, $fileExists = false ) { - $ioObject = $this->getMock('Magento_Di_Generator_Io', + $ioObject = $this->getMock('Magento_Code_Generator_Io', array( 'getResultFileName', 'makeGenerationDirectory', @@ -346,7 +346,7 @@ protected function _prepareMocksForGenerateCode($isValid) { $mocks = $this->_prepareMocksForValidateData(); - $codeGenerator = $this->getMock('Magento_Di_Generator_CodeGenerator_Zend', + $codeGenerator = $this->getMock('Magento_Code_Generator_CodeGenerator_Zend', array('setName', 'addProperties', 'addMethods', 'setClassDocBlock', 'generate'), array(), '', false ); $codeGenerator->expects($this->once()) diff --git a/dev/tests/unit/testsuite/Magento/Di/Generator/EntityTestAbstract.php b/dev/tests/unit/testsuite/Magento/Code/Generator/EntityTestAbstract.php similarity index 89% rename from dev/tests/unit/testsuite/Magento/Di/Generator/EntityTestAbstract.php rename to dev/tests/unit/testsuite/Magento/Code/Generator/EntityTestAbstract.php index 99d02c22213cf..bea223226a3f5 100644 --- a/dev/tests/unit/testsuite/Magento/Di/Generator/EntityTestAbstract.php +++ b/dev/tests/unit/testsuite/Magento/Code/Generator/EntityTestAbstract.php @@ -19,13 +19,13 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Di + * @package Magento_Code * @subpackage unit_tests * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Magento_Di_Generator_EntityTestAbstract extends PHPUnit_Framework_TestCase +class Magento_Code_Generator_EntityTestAbstract extends PHPUnit_Framework_TestCase { /**#@+ * Source and result class parameters @@ -43,11 +43,11 @@ class Magento_Di_Generator_EntityTestAbstract extends PHPUnit_Framework_TestCase protected static $_expectedMethods = array(); /** - * @return Magento_Di_Generator_Io|PHPUnit_Framework_MockObject_MockObject + * @return Magento_Code_Generator_Io|PHPUnit_Framework_MockObject_MockObject */ protected function _getIoObjectMock() { - $ioObjectMock = $this->getMock('Magento_Di_Generator_Io', + $ioObjectMock = $this->getMock('Magento_Code_Generator_Io', array('getResultFileName', 'makeGenerationDirectory', 'makeResultFileDirectory', 'fileExists', 'writeResultFile' ), array(), '', false @@ -91,12 +91,12 @@ protected function _getAutoloaderMock() /** * @param array $methodNames - * @return Magento_Di_Generator_CodeGenerator_Zend|PHPUnit_Framework_MockObject_MockObject + * @return Magento_Code_Generator_CodeGenerator_Zend|PHPUnit_Framework_MockObject_MockObject */ protected function _getCodeGeneratorMock(array $methodNames) { $codeGeneratorMock - = $this->getMock('Magento_Di_Generator_CodeGenerator_Zend', $methodNames, array(), '', false); + = $this->getMock('Magento_Code_Generator_CodeGenerator_Zend', $methodNames, array(), '', false); $codeGeneratorMock->expects($this->once()) ->method('setName') ->with(static::RESULT_CLASS) diff --git a/dev/tests/unit/testsuite/Magento/Code/Generator/FactoryTest.php b/dev/tests/unit/testsuite/Magento/Code/Generator/FactoryTest.php new file mode 100644 index 0000000000000..bca956f105a71 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Code/Generator/FactoryTest.php @@ -0,0 +1,137 @@ + '__construct', + 'parameters' => + array( + array( + 'name' => 'objectManager', + 'type' => '\\Magento_ObjectManager', + ), + ), + 'body' => '$this->_objectManager = $objectManager;', + 'docblock' => + array( + 'shortDescription' => 'Factory constructor', + 'tags' => + array( + array( + 'name' => 'param', + 'description' => '\\Magento_ObjectManager $objectManager', + ), + ), + ), + ), + array( + 'name' => 'create', + 'parameters' => + array( + array( + 'name' => 'data', + 'type' => 'array', + 'defaultValue' => + array(), + ), + ), + 'body' => 'return $this->_objectManager->create(self::CLASS_NAME, $data);', + 'docblock' => + array( + 'shortDescription' => 'Create class instance with specified parameters', + 'tags' => + array( + array( + 'name' => 'param', + 'description' => 'array $data', + ), + array( + 'name' => 'return', + 'description' => '\\ClassName', + ), + ), + ), + ), + ); + + /** + * Model under test + * + * @var Magento_Code_Generator_Factory + */ + protected $_model; + + protected function setUp() + { + $ioObjectMock = $this->_getIoObjectMock(); + + $methods = array('setImplementedInterfaces', 'setName', 'addProperties', 'addMethods', 'setClassDocBlock', + 'generate' + ); + $codeGeneratorMock = $this->_getCodeGeneratorMock($methods); + + $autoLoaderMock = $this->_getAutoloaderMock(); + + /** @var $ioObjectMock Magento_Code_Generator_Io */ + /** @var $codeGeneratorMock Magento_Code_Generator_CodeGenerator_Zend */ + /** @var $autoLoaderMock Magento_Autoload_IncludePath */ + $this->_model = new Magento_Code_Generator_Factory(self::SOURCE_CLASS, self::RESULT_CLASS, $ioObjectMock, + $codeGeneratorMock, $autoLoaderMock + ); + } + + protected function tearDown() + { + unset($this->_model); + } + + /** + * @covers Magento_Code_Generator_Factory::_generateCode + * @covers Magento_Code_Generator_Factory::_getClassMethods + */ + public function testGenerate() + { + $result = $this->_model->generate(); + $this->assertTrue($result); + $this->assertEmpty($this->_model->getErrors()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Di/Generator/IoTest.php b/dev/tests/unit/testsuite/Magento/Code/Generator/IoTest.php similarity index 95% rename from dev/tests/unit/testsuite/Magento/Di/Generator/IoTest.php rename to dev/tests/unit/testsuite/Magento/Code/Generator/IoTest.php index 046aa2b2409d9..3b6895786a283 100644 --- a/dev/tests/unit/testsuite/Magento/Di/Generator/IoTest.php +++ b/dev/tests/unit/testsuite/Magento/Code/Generator/IoTest.php @@ -19,13 +19,13 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Di + * @package Magento_Code * @subpackage unit_tests * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Magento_Di_Generator_IoTest extends PHPUnit_Framework_TestCase +class Magento_Code_Generator_IoTest extends PHPUnit_Framework_TestCase { /**#@+ * Source and result class parameters @@ -46,7 +46,7 @@ class Magento_Di_Generator_IoTest extends PHPUnit_Framework_TestCase protected $_generationDirectory; /** - * @var Magento_Di_Generator_Io + * @var Magento_Code_Generator_Io */ protected $_object; @@ -80,7 +80,7 @@ protected function setUp() ->with(self::CLASS_NAME) ->will($this->returnValue(self::CLASS_FILE_NAME)); - $this->_object = new Magento_Di_Generator_Io($this->_ioObjectMock, $this->_autoLoaderMock, + $this->_object = new Magento_Code_Generator_Io($this->_ioObjectMock, $this->_autoLoaderMock, self::GENERATION_DIRECTORY ); } diff --git a/dev/tests/unit/testsuite/Magento/Di/Generator/TestAsset/ParentClass.php b/dev/tests/unit/testsuite/Magento/Code/Generator/TestAsset/ParentClass.php similarity index 97% rename from dev/tests/unit/testsuite/Magento/Di/Generator/TestAsset/ParentClass.php rename to dev/tests/unit/testsuite/Magento/Code/Generator/TestAsset/ParentClass.php index f4f597bc8ca7c..e068e847d366f 100644 --- a/dev/tests/unit/testsuite/Magento/Di/Generator/TestAsset/ParentClass.php +++ b/dev/tests/unit/testsuite/Magento/Code/Generator/TestAsset/ParentClass.php @@ -19,13 +19,13 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Di + * @package Magento_Code * @subpackage unit_tests * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Di\Generator\TestAsset; +namespace Magento\Code\Generator\TestAsset; use Zend\Code\Generator\DocBlockGenerator; class ParentClass diff --git a/dev/tests/unit/testsuite/Magento/Di/Generator/TestAsset/SourceClass.php b/dev/tests/unit/testsuite/Magento/Code/Generator/TestAsset/SourceClass.php similarity index 97% rename from dev/tests/unit/testsuite/Magento/Di/Generator/TestAsset/SourceClass.php rename to dev/tests/unit/testsuite/Magento/Code/Generator/TestAsset/SourceClass.php index 6a4a6720e0e1b..cf9b24c8a9642 100644 --- a/dev/tests/unit/testsuite/Magento/Di/Generator/TestAsset/SourceClass.php +++ b/dev/tests/unit/testsuite/Magento/Code/Generator/TestAsset/SourceClass.php @@ -19,13 +19,13 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Di + * @package Magento_Code * @subpackage unit_tests * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Di\Generator\TestAsset; +namespace Magento\Code\Generator\TestAsset; use Zend\Code\Generator\ClassGenerator; class SourceClass extends ParentClass diff --git a/dev/tests/unit/testsuite/Magento/Di/Generator/TestAsset/TestGenerationClass.php b/dev/tests/unit/testsuite/Magento/Code/Generator/TestAsset/TestGenerationClass.php similarity index 76% rename from dev/tests/unit/testsuite/Magento/Di/Generator/TestAsset/TestGenerationClass.php rename to dev/tests/unit/testsuite/Magento/Code/Generator/TestAsset/TestGenerationClass.php index 0ce394036844e..e4de27ec0eaf7 100644 --- a/dev/tests/unit/testsuite/Magento/Di/Generator/TestAsset/TestGenerationClass.php +++ b/dev/tests/unit/testsuite/Magento/Code/Generator/TestAsset/TestGenerationClass.php @@ -19,24 +19,24 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Di + * @package Magento_Code * @subpackage unit_tests * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Magento_Di_Generator_TestAsset_TestGenerationClass +class Magento_Code_Generator_TestAsset_TestGenerationClass { /** * @SuppressWarnings(PHPMD.UnusedFormalParameter) * - * @param Magento\Di\Generator\TestAsset\ParentClass $parentClass - * @param Magento\Di\Generator\TestAsset\SourceClass $sourceClass + * @param Magento\Code\Generator\TestAsset\ParentClass $parentClass + * @param Magento\Code\Generator\TestAsset\SourceClass $sourceClass * @param Not_Existing_Class $notExistingClass */ public function __construct( - Magento\Di\Generator\TestAsset\ParentClass $parentClass, - Magento\Di\Generator\TestAsset\SourceClass $sourceClass, + Magento\Code\Generator\TestAsset\ParentClass $parentClass, + Magento\Code\Generator\TestAsset\SourceClass $sourceClass, Not_Existing_Class $notExistingClass ) { } diff --git a/dev/tests/unit/testsuite/Magento/Code/GeneratorTest.php b/dev/tests/unit/testsuite/Magento/Code/GeneratorTest.php new file mode 100644 index 0000000000000..cc46d0c72ca73 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Code/GeneratorTest.php @@ -0,0 +1,187 @@ + Magento_Code_Generator_Factory::ENTITY_TYPE, + 'proxy' => Magento_Code_Generator_Proxy::ENTITY_TYPE + ); + + /** + * Model under test + * + * @var Magento_Code_Generator + */ + protected $_model; + + /** + * @var PHPUnit_Framework_MockObject_MockObject|Magento_Code_Generator_EntityAbstract + */ + protected $_generator; + + /** + * @var PHPUnit_Framework_MockObject_MockObject|Magento_Autoload_IncludePath + */ + protected $_autoloader; + + protected function setUp() + { + $this->_generator = $this->getMockForAbstractClass('Magento_Code_Generator_EntityAbstract', + array(), '', true, true, true, array('generate') + ); + $this->_autoloader = $this->getMock('Magento_Autoload_IncludePath', + array('getFile'), array(), '', false + ); + } + + protected function tearDown() + { + unset($this->_model); + unset($this->_generator); + unset($this->_autoloader); + } + + /** + * Set generator mock to never call methods + */ + protected function _prepareGeneratorNeverCalls() + { + $this->_generator->expects($this->never()) + ->method('generate'); + } + + public function testGetGeneratedEntities() + { + $this->_model = new Magento_Code_Generator(); + $this->assertEquals(array_values($this->_expectedEntities), $this->_model->getGeneratedEntities()); + } + + /** + * @dataProvider generateValidClassDataProvider + */ + public function testGenerateClass($className, $entityType) + { + $this->_autoloader->staticExpects($this->once()) + ->method('getFile') + ->with($className . $entityType) + ->will($this->returnValue(false)); + + $this->_generator->expects($this->once()) + ->method('generate') + ->will($this->returnValue(true)); + + $this->_model = new Magento_Code_Generator($this->_generator, $this->_autoloader); + + $this->assertEquals( + Magento_Code_Generator::GENERATION_SUCCESS, + $this->_model->generateClass($className . $entityType) + ); + $this->assertAttributeEmpty('_generator', $this->_model); + } + + /** + * @dataProvider generateValidClassDataProvider + */ + public function testGenerateClassWithExistName($className, $entityType) + { + $this->_prepareGeneratorNeverCalls(); + $this->_autoloader->staticExpects($this->once()) + ->method('getFile') + ->with($className . $entityType) + ->will($this->returnValue(true)); + + $this->_model = new Magento_Code_Generator($this->_generator, $this->_autoloader); + + $this->assertEquals( + Magento_Code_Generator::GENERATION_SKIP, + $this->_model->generateClass($className . $entityType) + ); + } + + public function testGenerateClassWithWrongName() + { + $this->_prepareGeneratorNeverCalls(); + $this->_autoloader->staticExpects($this->never()) + ->method('getFile'); + + $this->_model = new Magento_Code_Generator($this->_generator, $this->_autoloader); + + $this->assertEquals( + Magento_Code_Generator::GENERATION_ERROR, + $this->_model->generateClass(self::SOURCE_CLASS)); + } + + /** + * @expectedException Magento_Exception + */ + public function testGenerateClassWithError() + { + $this->_autoloader->staticExpects($this->once()) + ->method('getFile') + ->will($this->returnValue(false)); + + $this->_generator->expects($this->once()) + ->method('generate') + ->will($this->returnValue(false)); + + $this->_model = new Magento_Code_Generator($this->_generator, $this->_autoloader); + + $expectedEntities = array_values($this->_expectedEntities); + $resultClassName = self::SOURCE_CLASS . ucfirst(array_shift($expectedEntities)); + + $this->_model->generateClass($resultClassName); + } + + /** + * Data provider for generate class tests + * + * @return array + */ + public function generateValidClassDataProvider() + { + $data = array(); + foreach ($this->_expectedEntities as $generatedEntity) { + $generatedEntity = ucfirst($generatedEntity); + $data['test class for ' . $generatedEntity] = array( + 'class name' => self::SOURCE_CLASS, + 'entity type' => $generatedEntity + ); + } + return $data; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Di/Definition/RuntimeDefinition/ZendTest.php b/dev/tests/unit/testsuite/Magento/Di/Definition/RuntimeDefinition/ZendTest.php deleted file mode 100644 index 3d8b13defa99d..0000000000000 --- a/dev/tests/unit/testsuite/Magento/Di/Definition/RuntimeDefinition/ZendTest.php +++ /dev/null @@ -1,49 +0,0 @@ -getMock('Magento_Di_Generator_Class'); - $generatorClass->expects($this->once()) - ->method('generateForConstructor') - ->with(self::TEST_CLASS_NAME); - - $model = new Magento_Di_Definition_RuntimeDefinition_Zend( - null, - array(self::TEST_CLASS_NAME), - $generatorClass - ); - $this->assertEquals(self::TEST_CLASS_INSTANTIATOR, $model->getInstantiator(self::TEST_CLASS_NAME)); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Di/Generator/CodeGenerator/ZendTest.php b/dev/tests/unit/testsuite/Magento/Di/Generator/CodeGenerator/ZendTest.php deleted file mode 100644 index a9fe7e29135ce..0000000000000 --- a/dev/tests/unit/testsuite/Magento/Di/Generator/CodeGenerator/ZendTest.php +++ /dev/null @@ -1,330 +0,0 @@ - 'isConst', - self::FLAG_STATIC => 'isStatic', - self::FLAG_FINAL => 'isFinal', - self::FLAG_ABSTRACT => 'isAbstract', - self::FLAG_REFERENCE => 'getPassedByReference', - ); - - /** - * Doc block test data - * - * @var array - */ - protected $_docBlockData = array( - 'shortDescription' => 'test_short_description', - 'longDescription' => 'test_long_description', - 'tags' => array( - 'tag1' => array('name' => 'tag1', 'description' => 'data1'), - 'tag2' => array('name' => 'tag2', 'description' => 'data2'), - ), - ); - - /** - * Method test data - * - * @var array - */ - protected $_methodData = array( - 'testMethod1' => array( - 'name' => 'testMethod1', - 'final' => true, - 'static' => true, - 'parameters' => array( - array('name' => 'data', 'type' => 'array', 'defaultValue' => array(), 'passedByReference' => true), - ), - 'body' => 'return 1;', - 'docblock' => array( - 'shortDescription' => 'test short description' - ), - ), - '_testMethod2' => array( - 'name' => '_testMethod2', - 'visibility' => 'private', - 'abstract' => true, - 'parameters' => array( - array('name' => 'data', 'defaultValue' => 'test_default'), - array('name' => 'flag', 'defaultValue' => true), - ), - 'body' => 'return 2;', - 'docblock' => array( - 'shortDescription' => 'test short description', - 'longDescription' => 'test long description', - 'tags' => array( - 'tag1' => array('name' => 'tag1', 'description' => 'data1'), - 'tag2' => array('name' => 'tag2', 'description' => 'data2'), - ), - ), - ), - 'testMethod3' => array( - 'name' => 'testMethod3', - 'body' => 'return 3;', - ), - ); - - /** - * Property test data - * - * @var array - */ - protected $_propertyData = array( - 'TEST_CONSTANT' => array( - 'name' => 'TEST_CONSTANT', - 'const' => true, - 'defaultValue' => 'default constant value', - 'docblock' => array('shortDescription' => 'test description'), - ), - '_protectedProperty' => array( - 'name' => '_protectedProperty', - 'visibility' => 'protected', - 'static' => 'true', - 'docblock' => array( - 'shortDescription' => 'Object Manager instance', - 'tags' => array( - 'var' => array('name' => 'var', 'description' => 'tag description') - ) - ), - ), - 'publicProperty' => array( - 'name' => 'publicProperty', - ), - ); - - protected function setUp() - { - $this->_model = new Magento_Di_Generator_CodeGenerator_Zend(); - } - - protected function tearDown() - { - unset($this->_model); - } - - public function testSetClassDocBlock() - { - $this->_model->setClassDocBlock($this->_docBlockData); - $actualDocBlock = $this->_model->getDocBlock(); - - $this->_assertDocBlockData($this->_docBlockData, $actualDocBlock); - } - - /** - * @param array $expectedDocBlock - * @param Zend\Code\Generator\DocBlockGenerator $actualDocBlock - */ - protected function _assertDocBlockData( - array $expectedDocBlock, - Zend\Code\Generator\DocBlockGenerator $actualDocBlock - ) { - // assert plain string data - foreach ($expectedDocBlock as $propertyName => $propertyData) { - if (is_string($propertyData)) { - $this->assertAttributeEquals($propertyData, $propertyName, $actualDocBlock); - } - } - - // assert tags - if (isset($expectedDocBlock['tags'])) { - $expectedTagsData = $expectedDocBlock['tags']; - $actualTags = $actualDocBlock->getTags(); - $this->assertSameSize($expectedTagsData, $actualTags); - /** @var $actualTag Zend\Code\Generator\DocBlock\Tag */ - foreach ($actualTags as $actualTag) { - $tagName = $actualTag->getName(); - $this->assertArrayHasKey($tagName, $expectedTagsData); - $this->assertEquals($expectedTagsData[$tagName]['name'], $tagName); - $this->assertEquals($expectedTagsData[$tagName]['description'], $actualTag->getDescription()); - } - } - } - - public function testAddMethods() - { - $this->_model->addMethods($this->_methodData); - $actualMethods = $this->_model->getMethods(); - - $this->assertSameSize($this->_methodData, $actualMethods); - - /** @var $method Zend\Code\Generator\MethodGenerator */ - foreach ($actualMethods as $methodName => $method) { - $this->assertArrayHasKey($methodName, $this->_methodData); - $expectedMethodData = $this->_methodData[$methodName]; - - $this->assertEquals($expectedMethodData['name'], $method->getName()); - $this->assertEquals($expectedMethodData['body'], $method->getBody()); - - // assert flags - $this->_assertFlag(self::FLAG_STATIC, $expectedMethodData, $method); - $this->_assertFlag(self::FLAG_FINAL, $expectedMethodData, $method); - $this->_assertFlag(self::FLAG_ABSTRACT, $expectedMethodData, $method); - - // assert visibility - $this->_assertVisibility($expectedMethodData, $method); - - // assert parameters - if (isset($expectedMethodData['parameters'])) { - $actualParameters = $method->getParameters(); - $this->assertSameSize($expectedMethodData['parameters'], $actualParameters); - foreach ($expectedMethodData['parameters'] as $parameterData) { - $parameterName = $parameterData['name']; - $this->assertArrayHasKey($parameterName, $actualParameters); - /** @var $actualParameter Zend\Code\Generator\ParameterGenerator */ - $actualParameter = $actualParameters[$parameterName]; - $this->assertEquals($parameterName, $actualParameter->getName()); - - // assert reference flag - $this->_assertFlag(self::FLAG_REFERENCE, $parameterData, $actualParameter); - - // assert parameter type - if (isset($parameterData['type'])) { - $this->assertEquals($parameterData['type'], $actualParameter->getType()); - } - - // assert default value - if (isset($parameterData['defaultValue'])) { - /** @var $actualDefaultValue Zend\Code\Generator\ValueGenerator */ - $actualDefaultValue = $actualParameter->getDefaultValue(); - $this->assertEquals($parameterData['defaultValue'], $actualDefaultValue->getValue()); - } - } - } - - // assert docblock - if (isset($expectedMethodData['docblock'])) { - $actualDocBlock = $method->getDocBlock(); - $this->_assertDocBlockData($expectedMethodData['docblock'], $actualDocBlock); - } - } - } - - /** - * @param string $flagType - * @param array $expectedData - * @param object $actualObject - */ - protected function _assertFlag($flagType, array $expectedData, $actualObject) - { - $expectedFlagValue = isset($expectedData[$flagType]) && $expectedData[$flagType]; - $flagGetter = $this->_flagVerification[$flagType]; - $this->assertEquals($expectedFlagValue, $actualObject->{$flagGetter}()); - } - - /** - * @param array $expectedData - * @param Zend\Code\Generator\AbstractMemberGenerator $actualObject - */ - protected function _assertVisibility(array $expectedData, Zend\Code\Generator\AbstractMemberGenerator $actualObject) - { - $expectedVisibility = isset($expectedData['visibility']) ? $expectedData['visibility'] : 'public'; - $this->assertEquals($expectedVisibility, $actualObject->getVisibility()); - } - - /** - * Correct behaviour of addMethodFromGenerator is already tested in testAddMethods - * - * @expectedException InvalidArgumentException - * @expectedExceptionMessage addMethodFromGenerator() expects string for name - */ - public function testAddMethodFromGenerator() - { - $invalidMethod = new Zend\Code\Generator\MethodGenerator(); - $this->_model->addMethodFromGenerator($invalidMethod); - } - - public function testAddProperties() - { - $this->_model->addProperties($this->_propertyData); - $actualProperties = $this->_model->getProperties(); - - $this->assertSameSize($this->_propertyData, $actualProperties); - - /** @var $property Zend\Code\Generator\PropertyGenerator */ - foreach ($actualProperties as $propertyName => $property) { - $this->assertArrayHasKey($propertyName, $this->_propertyData); - $expectedPropertyData = $this->_propertyData[$propertyName]; - - $this->assertEquals($expectedPropertyData['name'], $property->getName()); - - // assert flags - $this->_assertFlag(self::FLAG_CONST, $expectedPropertyData, $property); - $this->_assertFlag(self::FLAG_STATIC, $expectedPropertyData, $property); - - // assert visibility - $this->_assertVisibility($expectedPropertyData, $property); - - // assert default value - if (isset($expectedPropertyData['defaultValue'])) { - /** @var $actualDefaultValue Zend\Code\Generator\ValueGenerator */ - $actualDefaultValue = $property->getDefaultValue(); - $this->assertEquals($expectedPropertyData['defaultValue'], $actualDefaultValue->getValue()); - } - - // assert docblock - if (isset($expectedPropertyData['docblock'])) { - $actualDocBlock = $property->getDocBlock(); - $this->_assertDocBlockData($expectedPropertyData['docblock'], $actualDocBlock); - } - } - } - - /** - * Correct behaviour of addPropertyFromGenerator is already tested in testAddProperties - * - * @expectedException InvalidArgumentException - * @expectedExceptionMessage addPropertyFromGenerator() expects string for name - */ - public function testAddPropertyFromGenerator() - { - $invalidProperty = new Zend\Code\Generator\PropertyGenerator(); - $this->_model->addPropertyFromGenerator($invalidProperty); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Di/Generator/FactoryTest.php b/dev/tests/unit/testsuite/Magento/Di/Generator/FactoryTest.php deleted file mode 100644 index 48cd6c2c00e01..0000000000000 --- a/dev/tests/unit/testsuite/Magento/Di/Generator/FactoryTest.php +++ /dev/null @@ -1,146 +0,0 @@ - '__construct', - 'parameters' => - array( - array( - 'name' => 'objectManager', - 'type' => '\\Magento_ObjectManager', - ), - ), - 'body' => '$this->_objectManager = $objectManager;', - 'docblock' => - array( - 'shortDescription' => 'Factory constructor', - 'tags' => - array( - array( - 'name' => 'param', - 'description' => '\\Magento_ObjectManager $objectManager', - ), - ), - ), - ), - array( - 'name' => 'createFromArray', - 'parameters' => - array( - array( - 'name' => 'data', - 'type' => 'array', - 'defaultValue' => - array(), - ), - ), - 'body' => 'return $this->_objectManager->create(self::CLASS_NAME, $data, false);', - 'docblock' => - array( - 'shortDescription' => 'Create class instance with specified parameters', - 'tags' => - array( - array( - 'name' => 'param', - 'description' => 'array $data', - ), - array( - 'name' => 'return', - 'description' => '\\ClassName', - ), - ), - ), - ), - ); - - /** - * Model under test - * - * @var Magento_Di_Generator_Factory - */ - protected $_model; - - protected function setUp() - { - $ioObjectMock = $this->_getIoObjectMock(); - - $methods = array('setImplementedInterfaces', 'setName', 'addProperties', 'addMethods', 'setClassDocBlock', - 'generate' - ); - $codeGeneratorMock = $this->_getCodeGeneratorMock($methods); - $codeGeneratorMock->expects($this->once()) - ->method('setImplementedInterfaces') - ->with(array(self::FACTORY_INTERFACE)) - ->will($this->returnSelf()); - - $autoLoaderMock = $this->_getAutoloaderMock(); - - /** @var $ioObjectMock Magento_Di_Generator_Io */ - /** @var $codeGeneratorMock Magento_Di_Generator_CodeGenerator_Zend */ - /** @var $autoLoaderMock Magento_Autoload_IncludePath */ - $this->_model = new Magento_Di_Generator_Factory(self::SOURCE_CLASS, self::RESULT_CLASS, $ioObjectMock, - $codeGeneratorMock, $autoLoaderMock - ); - } - - protected function tearDown() - { - unset($this->_model); - } - - /** - * @covers Magento_Di_Generator_Factory::_generateCode - * @covers Magento_Di_Generator_Factory::_getClassMethods - */ - public function testGenerate() - { - $result = $this->_model->generate(); - $this->assertTrue($result); - $this->assertEmpty($this->_model->getErrors()); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Di/Generator/ProxyTest.php b/dev/tests/unit/testsuite/Magento/Di/Generator/ProxyTest.php deleted file mode 100644 index 5c0a84eeb3974..0000000000000 --- a/dev/tests/unit/testsuite/Magento/Di/Generator/ProxyTest.php +++ /dev/null @@ -1,241 +0,0 @@ - '__construct', - 'parameters' => - array( - array( - 'name' => 'objectManager', - 'type' => '\\Magento_ObjectManager', - ), - ), - 'body' => '$this->_objectManager = $objectManager;', - 'docblock' => - array( - 'shortDescription' => 'Proxy constructor', - 'tags' => - array( - array( - 'name' => 'param', - 'description' => '\\Magento_ObjectManager $objectManager', - ), - ), - ), - ), - array( - 'name' => 'publicChildMethod', - 'parameters' => - array( - array( - 'name' => 'classGenerator', - 'passedByReference' => false, - 'type' => '\\Zend\\Code\\Generator\\ClassGenerator', - ), - array( - 'name' => 'param1', - 'passedByReference' => false, - 'defaultValue' => '', - ), - array( - 'name' => 'param2', - 'passedByReference' => false, - 'defaultValue' => '\\\\', - ), - array( - 'name' => 'param3', - 'passedByReference' => false, - 'defaultValue' => '\'', - ), - array( - 'name' => 'array', - 'passedByReference' => false, - 'type' => 'array', - 'defaultValue' => - array(), - ), - ), - 'body' => 'return $this->_objectManager->get(self::CLASS_NAME)->publicChildMethod($classGenerator, $param1, $param2, $param3, $array, $param5);', - 'docblock' => - array( - 'shortDescription' => '{@inheritdoc}', - ), - ), - array( - 'name' => 'publicMethodWithReference', - 'parameters' => - array( - array( - 'name' => 'classGenerator', - 'passedByReference' => true, - 'type' => '\\Zend\\Code\\Generator\\ClassGenerator', - ), - array( - 'name' => 'array', - 'passedByReference' => true, - 'type' => 'array', - ), - ), - 'body' => 'return $this->_objectManager->get(self::CLASS_NAME)->publicMethodWithReference($classGenerator, $array);', - 'docblock' => - array( - 'shortDescription' => '{@inheritdoc}', - ), - ), - array( - 'name' => 'publicChildWithoutParameters', - 'parameters' => - array(), - 'body' => 'return $this->_objectManager->get(self::CLASS_NAME)->publicChildWithoutParameters();', - 'docblock' => - array( - 'shortDescription' => '{@inheritdoc}', - ), - ), - array( - 'name' => 'publicParentMethod', - 'parameters' => - array( - array( - 'name' => 'docBlockGenerator', - 'passedByReference' => false, - 'type' => '\\Zend\\Code\\Generator\\DocBlockGenerator', - ), - array( - 'name' => 'param1', - 'passedByReference' => false, - 'defaultValue' => '', - ), - array( - 'name' => 'param2', - 'passedByReference' => false, - 'defaultValue' => '\\\\', - ), - array( - 'name' => 'param3', - 'passedByReference' => false, - 'defaultValue' => '\'', - ), - array( - 'name' => 'array', - 'passedByReference' => false, - 'type' => 'array', - 'defaultValue' => - array(), - ), - ), - 'body' => 'return $this->_objectManager->get(self::CLASS_NAME)->publicParentMethod($docBlockGenerator, $param1, $param2, $param3, $array);', - 'docblock' => - array( - 'shortDescription' => '{@inheritdoc}', - ), - ), - array( - 'name' => 'publicParentWithoutParameters', - 'parameters' => - array(), - 'body' => 'return $this->_objectManager->get(self::CLASS_NAME)->publicParentWithoutParameters();', - 'docblock' => - array( - 'shortDescription' => '{@inheritdoc}', - ), - ), - ); - // @codingStandardsIgnoreEnd - - /** - * Model under test - * - * @var Magento_Di_Generator_Factory - */ - protected $_model; - - protected function setUp() - { - // add param with null default value - $value = new \Zend\Code\Generator\ValueGenerator(null, \Zend\Code\Generator\ValueGenerator::TYPE_NULL); - static::$_expectedMethods[1]['parameters'][5] = array( - 'name' => 'param5', - 'passedByReference' => false, - 'defaultValue' => $value, - ); - $ioObjectMock = $this->_getIoObjectMock(); - - $methods = array('setExtendedClass', 'setName', 'addProperties', 'addMethods', 'setClassDocBlock', 'generate'); - $codeGeneratorMock = $this->_getCodeGeneratorMock($methods); - $codeGeneratorMock->expects($this->once()) - ->method('setExtendedClass') - ->with('\\'. self::SOURCE_CLASS) - ->will($this->returnSelf()); - - $autoLoaderMock = $this->_getAutoloaderMock(); - - /** @var $ioObjectMock Magento_Di_Generator_Io */ - /** @var $codeGeneratorMock Magento_Di_Generator_CodeGenerator_Zend */ - /** @var $autoLoaderMock Magento_Autoload_IncludePath */ - $this->_model = new Magento_Di_Generator_Proxy(self::SOURCE_CLASS, self::RESULT_CLASS, $ioObjectMock, - $codeGeneratorMock, $autoLoaderMock - ); - } - - protected function tearDown() - { - unset($this->_model); - } - - /** - * @covers Magento_Di_Generator_Proxy::_getClassMethods - * @covers Magento_Di_Generator_Proxy::_generateCode - * @covers Magento_Di_Generator_Proxy::_getMethodInfo - * @covers Magento_Di_Generator_Proxy::_getMethodParameterInfo - * @covers Magento_Di_Generator_Proxy::_escapeDefaultValue - * @covers Magento_Di_Generator_Proxy::_getMethodBody - */ - public function testGenerate() - { - $result = $this->_model->generate(); - $this->assertTrue($result); - $this->assertEmpty($this->_model->getErrors()); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Di/GeneratorTest.php b/dev/tests/unit/testsuite/Magento/Di/GeneratorTest.php deleted file mode 100644 index 470f95acdb6b6..0000000000000 --- a/dev/tests/unit/testsuite/Magento/Di/GeneratorTest.php +++ /dev/null @@ -1,179 +0,0 @@ - Magento_Di_Generator_Factory::ENTITY_TYPE, - 'proxy' => Magento_Di_Generator_Proxy::ENTITY_TYPE - ); - - /** - * Model under test - * - * @var Magento_Di_Generator - */ - protected $_model; - - /** - * @var PHPUnit_Framework_MockObject_MockObject|Magento_Di_Generator_EntityAbstract - */ - protected $_generator; - - /** - * @var PHPUnit_Framework_MockObject_MockObject|Magento_Autoload_IncludePath - */ - protected $_autoloader; - - protected function setUp() - { - $this->_generator = $this->getMockForAbstractClass('Magento_Di_Generator_EntityAbstract', - array(), '', true, true, true, array('generate') - ); - $this->_autoloader = $this->getMock('Magento_Autoload_IncludePath', - array('getFile'), array(), '', false - ); - } - - protected function tearDown() - { - unset($this->_model); - unset($this->_generator); - unset($this->_autoloader); - } - - /** - * Set generator mock to never call methods - */ - protected function _prepareGeneratorNeverCalls() - { - $this->_generator->expects($this->never()) - ->method('generate'); - } - - public function testGetGeneratedEntities() - { - $this->_model = new Magento_Di_Generator(); - $this->assertEquals(array_values($this->_expectedEntities), $this->_model->getGeneratedEntities()); - } - - /** - * @dataProvider generateValidClassDataProvider - */ - public function testGenerateClass($className, $entityType) - { - $this->_autoloader->staticExpects($this->once()) - ->method('getFile') - ->with($className . $entityType) - ->will($this->returnValue(false)); - - $this->_generator->expects($this->once()) - ->method('generate') - ->will($this->returnValue(true)); - - $this->_model = new Magento_Di_Generator($this->_generator, $this->_autoloader); - - $this->assertTrue($this->_model->generateClass($className . $entityType)); - $this->assertAttributeEmpty('_generator', $this->_model); - } - - /** - * @dataProvider generateValidClassDataProvider - */ - public function testGenerateClassWithExistName($className, $entityType) - { - $this->_prepareGeneratorNeverCalls(); - $this->_autoloader->staticExpects($this->once()) - ->method('getFile') - ->with($className . $entityType) - ->will($this->returnValue(true)); - - $this->_model = new Magento_Di_Generator($this->_generator, $this->_autoloader); - - $this->assertFalse($this->_model->generateClass($className . $entityType)); - } - - public function testGenerateClassWithWrongName() - { - $this->_prepareGeneratorNeverCalls(); - $this->_autoloader->staticExpects($this->never()) - ->method('getFile'); - - $this->_model = new Magento_Di_Generator($this->_generator, $this->_autoloader); - - $this->assertFalse($this->_model->generateClass(self::SOURCE_CLASS)); - } - - /** - * @expectedException Magento_Exception - */ - public function testGenerateClassWithError() - { - $this->_autoloader->staticExpects($this->once()) - ->method('getFile') - ->will($this->returnValue(false)); - - $this->_generator->expects($this->once()) - ->method('generate') - ->will($this->returnValue(false)); - - $this->_model = new Magento_Di_Generator($this->_generator, $this->_autoloader); - - $expectedEntities = array_values($this->_expectedEntities); - $resultClassName = self::SOURCE_CLASS . ucfirst(array_shift($expectedEntities)); - - $this->_model->generateClass($resultClassName); - } - - /** - * Data provider for generate class tests - * - * @return array - */ - public function generateValidClassDataProvider() - { - $data = array(); - foreach ($this->_expectedEntities as $generatedEntity) { - $generatedEntity = ucfirst($generatedEntity); - $data['test class for ' . $generatedEntity] = array( - 'class name' => self::SOURCE_CLASS, - 'entity type' => $generatedEntity - ); - } - return $data; - } -} diff --git a/dev/tests/unit/testsuite/Magento/Di/InstanceManager/ZendTest.php b/dev/tests/unit/testsuite/Magento/Di/InstanceManager/ZendTest.php deleted file mode 100644 index 2996a0dd3aa63..0000000000000 --- a/dev/tests/unit/testsuite/Magento/Di/InstanceManager/ZendTest.php +++ /dev/null @@ -1,89 +0,0 @@ -assertAttributeEmpty(self::SHARED_ATTRIBUTE, $instanceManager); - - $testObject = new Varien_Object(); - $instanceManager->addSharedInstance($testObject, self::TEST_ALIAS); - $this->assertAttributeEquals( - array(self::TEST_ALIAS => $testObject), - self::SHARED_ATTRIBUTE, - $instanceManager - ); - - $instanceManager->removeSharedInstance(self::TEST_ALIAS); - $this->assertAttributeEmpty(self::SHARED_ATTRIBUTE, $instanceManager); - } - - public function testAddTypePreference() - { - $generatorMock = $this->getMock('Magento_Di_Generator', array('generateClass'), array(), '', false); - $generatorMock->expects($this->once()) - ->method('generateClass') - ->with(self::TEST_CLASS); - - $instanceManager = new Magento_Di_InstanceManager_Zend($generatorMock); - $this->assertInstanceOf( - 'Magento_Di_InstanceManager_Zend', - $instanceManager->addTypePreference('Interface', self::TEST_CLASS) - ); - } - - public function testSetParameters() - { - $generatorMock = $this->getMock('Magento_Di_Generator', array('generateClass'), array(), '', false); - $generatorMock->expects($this->once()) - ->method('generateClass') - ->with(self::TEST_CLASS); - - $instanceManager = new Magento_Di_InstanceManager_Zend($generatorMock); - $instanceManager->setParameters('Class', array('parameter' => self::TEST_CLASS)); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Di/ZendTest.php b/dev/tests/unit/testsuite/Magento/Di/ZendTest.php deleted file mode 100644 index ad9819ec34e81..0000000000000 --- a/dev/tests/unit/testsuite/Magento/Di/ZendTest.php +++ /dev/null @@ -1,640 +0,0 @@ - array( - '_eventDispatcher' => 'Mage_Core_Model_Event_Manager', - '_cacheManager' => 'Mage_Core_Model_Cache', - ), - self::TEST_CLASS_BLOCK => array( - '_request' => 'Mage_Core_Controller_Request_Http', - '_layout' => 'Mage_Core_Model_Layout', - '_eventManager' => 'Mage_Core_Model_Event_Manager', - '_urlBuilder' => 'Mage_Core_Model_Url', - '_translator' => 'Mage_Core_Model_Translate', - '_cache' => 'Mage_Core_Model_Cache', - '_designPackage' => 'Mage_Core_Model_Design_Package', - '_session' => 'Mage_Core_Model_Session', - '_storeConfig' => 'Mage_Core_Model_Store_Config', - '_frontController' => 'Mage_Core_Controller_Varien_Front', - '_helperFactory' => 'Mage_Core_Model_Factory_Helper', - ), - ); - - /** - * List of expected cached classes - * - * @var array - */ - protected $_cachedInstances = array( - self::TEST_CLASS_MODEL => array( - 'eventManager' => 'Mage_Core_Model_Event_Manager', - 'cache' => 'Mage_Core_Model_Cache', - ), - self::TEST_CLASS_BLOCK => array( - 'eventManager' => 'Mage_Core_Model_Event_Manager', - 'urlBuilder' => 'Mage_Core_Model_Url', - 'cache' => 'Mage_Core_Model_Cache', - 'request' => 'Mage_Core_Controller_Request_Http', - 'layout' => 'Mage_Core_Model_Layout', - 'translate' => 'Mage_Core_Model_Translate', - 'design' => 'Mage_Core_Model_Design_Package', - 'session' => 'Mage_Core_Model_Session', - 'storeConfig' => 'Mage_Core_Model_Store_Config', - 'frontController' => 'Mage_Core_Controller_Varien_Front', - 'helperFactory' => 'Mage_Core_Model_Factory_Helper', - ), - ); - - /** - * Construct parameters full definition - * - * @var array - */ - protected $_constructParameters = array( - self::TEST_CLASS_MODEL => array( - '::__construct:0' => array('eventDispatcher', 'Mage_Core_Model_Event_Manager', true, null), - '::__construct:1' => array('cacheManager', 'Mage_Core_Model_Cache', true, null), - '::__construct:2' => array('resource', 'Mage_Core_Model_Resource_Abstract', false, null), - '::__construct:3' => array('resourceCollection', 'Varien_Data_Collection_Db', false, null), - '::__construct:4' => array('data', null, false, array()), - ), - ); - - /** - * Test data value to assert test expectations - * - * @var array - */ - protected $_expectedDataValue = array('key' => 'value'); - - /** - * List of shared instances - * - * @var array - */ - protected $_sharedInstances = array(); - - /** - * Flag if class mocks exist - * - * @var bool - */ - protected static $_isClassMocks = false; - - protected function setUp() - { - $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); - if (!self::$_isClassMocks) { - $this->getMockForAbstractClass( - self::PARENT_CLASS_MODEL, - $objectManagerHelper->getConstructArguments( - Magento_Test_Helper_ObjectManager::MODEL_ENTITY, - self::PARENT_CLASS_MODEL - ), - self::TEST_CLASS_MODEL, false - ); - $this->getMockForAbstractClass(self::PARENT_CLASS_BLOCK, - $objectManagerHelper->getConstructArguments( - Magento_Test_Helper_ObjectManager::BLOCK_ENTITY, - self::PARENT_CLASS_BLOCK - ), - self::TEST_CLASS_BLOCK, false - ); - self::$_isClassMocks = true; - } - } - - protected function tearDown() - { - unset($this->_model); - } - - /** - * Data provider for testNewInstanceWithoutDefinitions - * - * @return array - */ - public function newInstanceWithoutDefinitionsDataProvider() - { - return array( - 'shared model instance with arguments' => array( - '$className' => self::TEST_CLASS_MODEL, - '$arguments' => array(1 => 'value_1'), - '$isShared' => true, - ), - 'shared model instance without arguments' => array( - '$className' => self::TEST_CLASS_MODEL, - '$arguments' => array(), - '$isShared' => true, - ), - 'not shared model instance' => array( - '$className' => self::TEST_CLASS_MODEL, - '$arguments' => array(), - '$isShared' => false, - ), - 'not shared block instance' => array( - '$className' => self::TEST_CLASS_BLOCK, - '$arguments' => array(), - '$isShared' => false, - ), - 'not shared other class instance' => array( - '$className' => self::TEST_CLASS_OTHER, - '$arguments' => array(), - '$isShared' => false, - ), - ); - } - - /** - * @param string $className - * @param array $arguments - * @param bool $isShared - * - * @dataProvider newInstanceWithoutDefinitionsDataProvider - */ - public function testNewInstanceWithoutDefinitions($className, array $arguments = array(), $isShared = true) - { - // assert object instantiation - $this->_prepareMockForNewInstanceWithoutDefinitions($className, $arguments, $isShared); - $testObject = $this->_model->newInstance($className, $arguments, $isShared); - switch ($className) { - case self::TEST_CLASS_MODEL: - $this->_assertTestModel($testObject, $arguments); - break; - - case self::TEST_CLASS_BLOCK: - $this->_assertTestBlock($testObject, $arguments); - break; - - case self::TEST_CLASS_OTHER: - default: - $this->assertInstanceOf($className, $testObject); - break; - } - $this->assertAttributeEmpty('instanceContext', $this->_model); - - // assert cache - if (isset($this->_cachedInstances[$className])) { - $expectedCache = array(); - foreach ($this->_cachedInstances[$className] as $class) { - $this->assertArrayHasKey($class, $this->_sharedInstances); - $expectedCache[$class] = $this->_sharedInstances[$class]; - } - $this->assertAttributeEquals($expectedCache, '_cachedInstances', $this->_model); - } - } - - /** - * Prepares all mocks for testNewInstanceWithoutDefinitions - * - * @param string $className - * @param bool $isShared - * @param array $arguments - */ - protected function _prepareMockForNewInstanceWithoutDefinitions( - $className, array $arguments = array(), $isShared = true - ) { - $definitions = $this->getMock('Zend\Di\DefinitionList', array('hasClass'), array(), '', false); - $definitions->expects($this->once()) - ->method('hasClass') - ->will($this->returnValue(false)); - - $instanceManager = $this->getMock( - 'Magento_Di_InstanceManager_Zend', - array('hasSharedInstance', 'getSharedInstance', 'addSharedInstanceWithParameters', 'addSharedInstance') - ); - $instanceManager->expects($this->any()) - ->method('hasSharedInstance') - ->will($this->returnValue(true)); - $instanceManager->expects($this->any()) - ->method('getSharedInstance') - ->will($this->returnCallback(array($this, 'callbackGetSharedInstance'))); - - if ($isShared) { - if ($arguments) { - $instanceManager->expects($this->once()) - ->method('addSharedInstanceWithParameters') - ->with($this->isInstanceOf($className), $className, $arguments); - $instanceManager->expects($this->never()) - ->method('addSharedInstance'); - } else { - $instanceManager->expects($this->never()) - ->method('addSharedInstanceWithParameters'); - $instanceManager->expects($this->once()) - ->method('addSharedInstance') - ->with($this->isInstanceOf($className), $className); - } - } else { - $instanceManager->expects($this->never()) - ->method('addSharedInstanceWithParameters'); - $instanceManager->expects($this->never()) - ->method('addSharedInstance'); - } - - $this->_model = new Magento_Di_Zend($definitions, $instanceManager); - } - - /** - * Invokes when DI class calls $this->get('') - * - * @param $classOrAlias - * @return PHPUnit_Framework_MockObject_MockObject|object - */ - public function callbackGetSharedInstance($classOrAlias) - { - $this->_sharedInstances[$classOrAlias] = $this->getMock($classOrAlias, array(), array(), '', false); - return $this->_sharedInstances[$classOrAlias]; - } - - /** - * Assert test model object - * - * @param object $modelInstance - * @param array $arguments - */ - protected function _assertTestModel($modelInstance, array $arguments = array()) - { - $this->assertInstanceOf(self::TEST_CLASS_MODEL, $modelInstance); - - foreach ($this->_propertyTypes[self::TEST_CLASS_MODEL] as $propertyName => $propertyClass) { - $this->assertAttributeInstanceOf($propertyClass, $propertyName, $modelInstance); - } - $this->assertAttributeSame(null, '_resource', $modelInstance); - $this->assertAttributeSame(null, '_resourceCollection', $modelInstance); - $this->assertAttributeSame($arguments, '_data', $modelInstance); - } - - /** - * Assert test block object - * - * @param object $blockInstance - * @param array $arguments - */ - protected function _assertTestBlock($blockInstance, array $arguments = array()) - { - $this->assertInstanceOf(self::TEST_CLASS_BLOCK, $blockInstance); - - foreach ($this->_propertyTypes[self::TEST_CLASS_BLOCK] as $propertyName => $propertyClass) { - $this->assertAttributeInstanceOf($propertyClass, $propertyName, $blockInstance); - } - $this->assertAttributeSame($arguments, '_data', $blockInstance); - } - - // @codingStandardsIgnoreStart - /** - * @expectedException Zend\Di\Exception\ClassNotFoundException - * @expectedExceptionMessage Class (specified by alias Mage_Test_Model_TestStub) Mage_Test_Model_TestStub_Other could not be located in provided definitions. - */ - // @codingStandardsIgnoreEnd - public function testNewInstanceNoDefinitionException() - { - $this->_prepareMockForNewInstanceExceptions(true); - $this->_model->newInstance(self::TEST_CLASS_MODEL); - } - - /** - * @expectedException Zend\Di\Exception\RuntimeException - */ - public function testNewInstanceInvalidInstantiatorArray() - { - $this->_prepareMockForNewInstanceExceptions(false, array(self::TEST_CLASS_MODEL, 'testMethod')); - $this->_model->newInstance(self::TEST_CLASS_MODEL); - } - - /** - * @expectedException Zend\Di\Exception\RuntimeException - * @expectedExceptionMessage Invalid instantiator of type "string" for "Mage_Test_Model_TestStub". - */ - public function testNewInstanceInvalidInstantiatorNotArray() - { - $this->_prepareMockForNewInstanceExceptions(false, 'test string'); - $this->_model->newInstance(self::TEST_CLASS_MODEL); - } - - /** - * Prepares all mocks for tests with exceptions - * - * @param bool $noDefinition - * @param string|array $invalidInstantiator - */ - protected function _prepareMockForNewInstanceExceptions($noDefinition = false, $invalidInstantiator = null) - { - $definitions = $this->getMock( - 'Zend\Di\DefinitionList', array('hasClass', 'getInstantiator'), array(), '', false - ); - if ($noDefinition) { - $definitions->expects($this->exactly(2)) - ->method('hasClass') - ->will($this->returnCallback(array($this, 'callbackHasClassForExceptions'))); - } elseif ($invalidInstantiator) { - $definitions->expects($this->exactly(2)) - ->method('hasClass') - ->will($this->returnValue(true)); - $definitions->expects($this->once()) - ->method('getInstantiator') - ->will($this->returnValue($invalidInstantiator)); - } - - $instanceManager = $this->getMock('Magento_Di_InstanceManager_Zend', array('hasAlias', 'getClassFromAlias')); - $instanceManager->expects($this->once()) - ->method('hasAlias') - ->will($this->returnValue($noDefinition)); - if ($noDefinition) { - $instanceManager->expects($this->once()) - ->method('getClassFromAlias') - ->will($this->returnValue(self::TEST_CLASS_MODEL . '_Other')); - } - - $this->_model = new Magento_Di_Zend($definitions, $instanceManager); - } - - /** - * @param string $className - * @return bool - */ - public function callbackHasClassForExceptions($className) - { - return $className == self::TEST_CLASS_MODEL; - } - - /** - * Data provider for testNewInstanceWithDefinitionsWithoutResolve - * - * @return array - */ - public function newInstanceWithDefinitionsWithoutResolveDataProvider() - { - $testClassOther = self::TEST_CLASS_OTHER; - - return array( - 'shared with arguments' => array( - '$instantiator' => self::CONSTRUCT_METHOD, - '$className' => self::TEST_CLASS_OTHER, - '$arguments' => array(2 => 'test string'), - '$isShared' => true, - ), - 'shared without arguments' => array( - '$instantiator' => self::CONSTRUCT_METHOD, - '$className' => self::TEST_CLASS_OTHER, - '$arguments' => array(), - '$isShared' => true, - ), - 'not shared' => array( - '$instantiator' => self::CONSTRUCT_METHOD, - '$className' => self::TEST_CLASS_OTHER, - '$arguments' => array(), - '$isShared' => false, - ), - 'not shared callback' => array( - '$instantiator' => array(new $testClassOther(), 'setOrigData'), // setOrigData returns object itself - '$className' => self::TEST_CLASS_OTHER, - '$arguments' => array(), - '$isShared' => false, - ), - ); - } - - /** - * @param string|array $instantiator - * @param string $className - * @param array $arguments - * @param bool $isShared - * - * @dataProvider newInstanceWithDefinitionsWithoutResolveDataProvider - */ - public function testNewInstanceWithDefinitionsWithoutResolve( - $instantiator, $className, array $arguments = array(), $isShared = true - ) { - $this->_prepareMockForNewInstanceWithDefinitionsWithoutResolve( - $instantiator, $className, $arguments, $isShared - ); - - $testObject = $this->_model->newInstance($className, $arguments, $isShared); - $this->assertInstanceOf($className, $testObject); - $this->assertAttributeEmpty('instanceContext', $this->_model); - } - - /** - * Prepares all mocks for testNewInstanceWithDefinitionsWithoutResolve - * - * @param string|array $instantiator - * @param string $className - * @param array $arguments - * @param bool $isShared - */ - protected function _prepareMockForNewInstanceWithDefinitionsWithoutResolve( - $instantiator, $className, array $arguments = array(), $isShared = true - ) { - $definitions = $this->getMock( - 'Zend\Di\DefinitionList', array('hasClass', 'getInstantiator', 'hasMethodParameters', 'hasMethod'), - array(), '', false - ); - $definitions->expects($this->exactly(2)) - ->method('hasClass') - ->will($this->returnValue(true)); - $definitions->expects($this->once()) - ->method('getInstantiator') - ->will($this->returnValue($instantiator)); - - if (is_array($instantiator)) { - $definitions->expects($this->never()) - ->method('hasMethodParameters'); - $definitions->expects($this->once()) - ->method('hasMethod') - ->with(get_class($instantiator[0]), $instantiator[1]) - ->will($this->returnValue(false)); - } else { - $definitions->expects($this->once()) - ->method('hasMethodParameters') - ->will($this->returnValue(false)); - } - - $instanceManager = $this->getMock( - 'Magento_Di_InstanceManager_Zend', array('hasAlias', 'addSharedInstanceWithParameters', 'addSharedInstance') - ); - $instanceManager->expects($this->any()) - ->method('hasAlias') - ->will($this->returnValue(false)); - - if ($isShared) { - if ($arguments) { - $instanceManager->expects($this->once()) - ->method('addSharedInstanceWithParameters') - ->with($this->isInstanceOf($className), $className, $arguments); - $instanceManager->expects($this->never()) - ->method('addSharedInstance'); - } else { - $instanceManager->expects($this->never()) - ->method('addSharedInstanceWithParameters'); - $instanceManager->expects($this->once()) - ->method('addSharedInstance') - ->with($this->isInstanceOf($className), $className); - } - } else { - $instanceManager->expects($this->never()) - ->method('addSharedInstanceWithParameters'); - $instanceManager->expects($this->never()) - ->method('addSharedInstance'); - } - - $this->_model = new Magento_Di_Zend($definitions, $instanceManager); - } - - /** - * Data provider for testNewInstanceWithDefinitionsWithResolve - * - * @return array - */ - public function testNewInstanceWithDefinitionsWithResolveDataProvider() - { - return array( - 'model with data in new array format' => array( - '$arguments' => array('data' => $this->_expectedDataValue) - ), - 'model with data in new numeric format' => array( - '$arguments' => array(4 => $this->_expectedDataValue) - ), - 'model with data in old format' => array( - '$arguments' => $this->_expectedDataValue - ), - ); - } - - /** - * @param array $arguments - * - * @dataProvider testNewInstanceWithDefinitionsWithResolveDataProvider - */ - public function testNewInstanceWithDefinitionsWithResolve(array $arguments) - { - $className = self::TEST_CLASS_MODEL . '_Alias'; - $classAlias = self::TEST_CLASS_MODEL; - $this->_prepareMockForNewInstanceWithDefinitionsWithResolve($classAlias); - - $testModel = $this->_model->newInstance($className, $arguments, false); - $this->assertInstanceOf($classAlias, $testModel); - $this->assertAttributeEquals($this->_expectedDataValue, '_data', $testModel); - } - - /** - * Prepares all mocks for testNewInstanceWithDefinitionsWithResolve - * - * @param string $className - */ - protected function _prepareMockForNewInstanceWithDefinitionsWithResolve($className) - { - $definitions = $this->getMock( - 'Zend\Di\DefinitionList', - array( - 'hasClass', - 'getInstantiator', - 'hasMethodParameters', - 'getMethodParameters' - ), - array(), '', false - ); - $definitions->expects($this->any()) - ->method('hasClass') - ->will($this->returnValue(true)); - $definitions->expects($this->any()) - ->method('getInstantiator') - ->will($this->returnValue('__construct')); - - $definitions->expects($this->any()) - ->method('hasMethodParameters') - ->with($className, self::CONSTRUCT_METHOD) - ->will($this->returnValue(true)); - - $constructParameters = array(); - foreach ($this->_constructParameters[$className] as $key => $data) { - $key = $className . $key; - $constructParameters[$key] = $data; - } - $definitions->expects($this->once()) - ->method('getMethodParameters') - ->with($className, self::CONSTRUCT_METHOD) - ->will($this->returnValue($constructParameters)); - - $instanceManager = $this->getMock( - 'Magento_Di_InstanceManager_Zend', array('hasAlias', 'getClassFromAlias', 'hasSharedInstance', - 'getSharedInstance' - ) - ); - $instanceManager->expects($this->any()) - ->method('hasAlias') - ->will($this->returnValue(true)); - $instanceManager->expects($this->any()) - ->method('getClassFromAlias') - ->will($this->returnValue($className)); - $instanceManager->expects($this->any()) - ->method('hasSharedInstance') - ->will($this->returnValue(true)); - $instanceManager->expects($this->any()) - ->method('getSharedInstance') - ->will($this->returnCallback(array($this, 'callbackGetSharedInstance'))); - - $this->_model = new Magento_Di_Zend($definitions, $instanceManager); - } -} diff --git a/dev/tests/unit/testsuite/Magento/ObjectManager/ObjectManagerTest.php b/dev/tests/unit/testsuite/Magento/ObjectManager/ObjectManagerTest.php new file mode 100644 index 0000000000000..445abe5b86b67 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/ObjectManager/ObjectManagerTest.php @@ -0,0 +1,248 @@ +_object = new Magento_ObjectManager_ObjectManager( + $definitions + ); + } + + public function testCreateCreatesNewInstanceEveryTime() + { + $object1 = $this->_object->create('Magento_Test_Di_Child'); + $this->assertInstanceOf('Magento_Test_Di_Child', $object1); + $object2 = $this->_object->create('Magento_Test_Di_Child'); + $this->assertInstanceOf('Magento_Test_Di_Child', $object2); + $this->assertNotSame($object1, $object2); + } + + public function testGetCreatesNewInstanceOnlyOnce() + { + $object1 = $this->_object->get('Magento_Test_Di_Child'); + $this->assertInstanceOf('Magento_Test_Di_Child', $object1); + $object2 = $this->_object->get('Magento_Test_Di_Child'); + $this->assertInstanceOf('Magento_Test_Di_Child', $object2); + $this->assertSame($object1, $object2); + } + + public function testCreateCreatesPreferredImplementation() + { + $this->_object->configure(array( + 'preferences' => array( + 'Magento_Test_Di_Interface' => 'Magento_Test_Di_Parent', + 'Magento_Test_Di_Parent' => 'Magento_Test_Di_Child' + ) + )); + $interface = $this->_object->create('Magento_Test_Di_Interface'); + $parent = $this->_object->create('Magento_Test_Di_Parent'); + $child = $this->_object->create('Magento_Test_Di_Child'); + $this->assertInstanceOf('Magento_Test_Di_Child', $interface); + $this->assertInstanceOf('Magento_Test_Di_Child', $parent); + $this->assertInstanceOf('Magento_Test_Di_Child', $child); + $this->assertNotSame($interface, $parent); + $this->assertNotSame($interface, $child); + } + + public function testGetCreatesPreferredImplementation() + { + $this->_object->configure(array( + 'preferences' => array( + 'Magento_Test_Di_Interface' => 'Magento_Test_Di_Parent', + 'Magento_Test_Di_Parent' => 'Magento_Test_Di_Child' + ) + )); + $interface = $this->_object->get('Magento_Test_Di_Interface'); + $parent = $this->_object->get('Magento_Test_Di_Parent'); + $child = $this->_object->get('Magento_Test_Di_Child'); + $this->assertInstanceOf('Magento_Test_Di_Child', $interface); + $this->assertInstanceOf('Magento_Test_Di_Child', $parent); + $this->assertInstanceOf('Magento_Test_Di_Child', $child); + $this->assertSame($interface, $parent); + $this->assertSame($interface, $child); + } + + /** + * @expectedException BadMethodCallException + * @expectedExceptionMessage Missing required argument $scalar for Magento_Test_Di_Aggregate_Parent + */ + public function testCreateThrowsExceptionIfRequiredConstructorParameterIsNotProvided() + { + $this->_object->configure(array( + 'preferences' => array( + 'Magento_Test_Di_Interface' => 'Magento_Test_Di_Parent', + 'Magento_Test_Di_Parent' => 'Magento_Test_Di_Child' + ) + )); + $this->_object->create('Magento_Test_Di_Aggregate_Parent'); + } + + public function testCreateResolvesScalarParametersAutomatically() + { + $this->_object->configure(array( + 'preferences' => array( + 'Magento_Test_Di_Interface' => 'Magento_Test_Di_Parent', + 'Magento_Test_Di_Parent' => 'Magento_Test_Di_Child' + ), + 'Magento_Test_Di_Aggregate_Parent' => array( + 'parameters' => array( + 'child' => 'Magento_Test_Di_Child_A', + 'scalar' => 'scalarValue' + ) + ) + )); + /** @var $result Magento_Test_Di_Aggregate_Parent */ + $result = $this->_object->create('Magento_Test_Di_Aggregate_Parent'); + $this->assertInstanceOf('Magento_Test_Di_Aggregate_Parent', $result); + $this->assertInstanceOf('Magento_Test_Di_Child', $result->interface); + $this->assertInstanceOf('Magento_Test_Di_Child', $result->parent); + $this->assertInstanceOf('Magento_Test_Di_Child_A', $result->child); + $this->assertEquals('scalarValue', $result->scalar); + $this->assertEquals('1', $result->optionalScalar); + } + + /** + * @param array $arguments + * @dataProvider createResolvesScalarCallTimeParametersAutomaticallyDataProvider + */ + public function testCreateResolvesScalarCallTimeParametersAutomatically(array $arguments) + { + $this->_object->configure(array( + 'preferences' => array( + 'Magento_Test_Di_Interface' => 'Magento_Test_Di_Parent', + 'Magento_Test_Di_Parent' => 'Magento_Test_Di_Child' + ), + )); + /** @var $result Magento_Test_Di_Aggregate_Child */ + $result = $this->_object->create('Magento_Test_Di_Aggregate_Child', $arguments); + $this->assertInstanceOf('Magento_Test_Di_Aggregate_Child', $result); + $this->assertInstanceOf('Magento_Test_Di_Child', $result->interface); + $this->assertInstanceOf('Magento_Test_Di_Child', $result->parent); + $this->assertInstanceOf('Magento_Test_Di_Child_A', $result->child); + $this->assertEquals('scalarValue', $result->scalar); + $this->assertEquals('secondScalarValue', $result->secondScalar); + $this->assertEquals('1', $result->optionalScalar); + $this->assertEquals('secondOptionalValue', $result->secondOptionalScalar); + } + + public function createResolvesScalarCallTimeParametersAutomaticallyDataProvider() + { + return array( + 'named binding' => array( + array( + 'child' => 'Magento_Test_Di_Child_A', + 'scalar' => 'scalarValue', + 'secondScalar' => 'secondScalarValue', + 'secondOptionalScalar' => 'secondOptionalValue' + ) + ), + 'positional binding' => array( + array( + 2 => 'Magento_Test_Di_Child_A', + 'secondOptionalScalar' => 'secondOptionalValue', + 4 => 'secondScalarValue', + 3 => 'scalarValue', + ) + ), + ); + } + + /** + * @expectedException InvalidArgumentException + * @expectedExceptionMessage Ambiguous argument $child: positional and named binding is used at the same time. + */ + public function testCreateResolveParametersAmbiguity() + { + $this->_object->create('Magento_Test_Di_Aggregate_WithOptional', array( + 1 => 'Magento_Test_Di_Child_A', + 'child' => 'Magento_Test_Di_Child_A', + )); + } + + public function testGetCreatesSharedInstancesEveryTime() + { + $this->_object->configure(array( + 'preferences' => array( + 'Magento_Test_Di_Interface' => 'Magento_Test_Di_Parent', + 'Magento_Test_Di_Parent' => 'Magento_Test_Di_Child' + ), + 'Magento_Test_Di_Interface' => array( + 'shared' => 0 + ), + 'Magento_Test_Di_Aggregate_Parent' => array( + 'parameters' => array( + 'scalar' => 'scalarValue' + ) + ) + )); + /** @var $result Magento_Test_Di_Aggregate_Parent */ + $result = $this->_object->create('Magento_Test_Di_Aggregate_Parent'); + $this->assertInstanceOf('Magento_Test_Di_Aggregate_Parent', $result); + $this->assertInstanceOf('Magento_Test_Di_Child', $result->interface); + $this->assertInstanceOf('Magento_Test_Di_Child', $result->parent); + $this->assertInstanceOf('Magento_Test_Di_Child', $result->child); + $this->assertNotSame($result->interface, $result->parent); + $this->assertNotSame($result->interface, $result->child); + $this->assertSame($result->parent, $result->child); + } + + /** + * @expectedException LogicException + * @expectedExceptionMessage Magento_Test_Di_Aggregate_Parent depends on Magento_Test_Di_Child_Circular + */ + public function testGetDetectsCircularDependency() + { + $this->_object->configure(array( + 'preferences' => array( + 'Magento_Test_Di_Interface' => 'Magento_Test_Di_Parent', + 'Magento_Test_Di_Parent' => 'Magento_Test_Di_Child_Circular' + ), + )); + $this->_object->create('Magento_Test_Di_Aggregate_Parent'); + } + + public function testCreateIgnoresOptionalArguments() + { + $instance = $this->_object->create('Magento_Test_Di_Aggregate_WithOptional'); + $this->assertNull($instance->parent); + $this->assertNull($instance->child); + } +} diff --git a/dev/tests/unit/testsuite/Magento/ObjectManager/ZendTest.php b/dev/tests/unit/testsuite/Magento/ObjectManager/ZendTest.php deleted file mode 100644 index 502e11888a30a..0000000000000 --- a/dev/tests/unit/testsuite/Magento/ObjectManager/ZendTest.php +++ /dev/null @@ -1,362 +0,0 @@ - 'value_1', - 'argument_2' => 'value_2', - ); - - /** - * ObjectManager instance for tests - * - * @var Magento_ObjectManager_Zend - */ - protected $_objectManager; - - /** - * @var Mage_Core_Model_Config|PHPUnit_Framework_MockObject_MockObject - */ - protected $_magentoConfig; - - /** - * @var Zend\Di\InstanceManager|PHPUnit_Framework_MockObject_MockObject - */ - protected $_instanceManager; - - /** - * @var Magento_Di_Zend|PHPUnit_Framework_MockObject_MockObject - */ - protected $_diInstance; - - protected function tearDown() - { - unset($this->_objectManager); - unset($this->_magentoConfig); - unset($this->_instanceManager); - unset($this->_diInstance); - } - - public function testConstructWithDiObject() - { - $diInstance = $this->getMock('Magento_Di_Zend', - array('instanceManager') - ); - $instanceManager = $this->getMock('Magento_Di_InstanceManager_Zend', array('addSharedInstance'), - array(), '', false - ); - $diInstance->expects($this->once()) - ->method('instanceManager') - ->will($this->returnValue($instanceManager)); - $instanceManager->expects($this->once()) - ->method('addSharedInstance') - ->will($this->returnCallback(array($this, 'verifyAddSharedInstanceCallback'))); - - $model = new Magento_ObjectManager_Zend(null, $diInstance); - $this->assertAttributeInstanceOf(get_class($diInstance), '_di', $model); - } - - public function testCreate() - { - $this->_prepareObjectManagerForGetCreateTests(true); - $actualObject = $this->_objectManager->create(self::CLASS_NAME, $this->_arguments); - $this->assertEquals(self::OBJECT_CREATE, $actualObject); - } - - public function testGet() - { - $this->_prepareObjectManagerForGetCreateTests(false); - $actualObject = $this->_objectManager->get(self::CLASS_NAME, $this->_arguments); - $this->assertEquals(self::OBJECT_GET, $actualObject); - } - - /** - * Create Magento_ObjectManager_Zend instance - * - * @param bool $mockNewInstance - */ - protected function _prepareObjectManagerForGetCreateTests($mockNewInstance = false) - { - $this->_magentoConfig = $this->getMock('Mage_Core_Model_Config', - array('loadBase'), array(), '', false); - $this->_magentoConfig->expects($this->any()) - ->method('loadBase') - ->will($this->returnSelf()); - - $this->_instanceManager = $this->getMock('Magento_Di_InstanceManager_Zend', array('addSharedInstance'), - array(), '', false - ); - $this->_diInstance = $this->getMock('Magento_Di_Zend', - array('instanceManager', 'newInstance', 'get', 'setDefinitionList') - ); - $this->_diInstance->expects($this->any()) - ->method('instanceManager') - ->will($this->returnValue($this->_instanceManager)); - if ($mockNewInstance) { - $this->_diInstance->expects($this->once()) - ->method('newInstance') - ->will($this->returnCallback(array($this, 'verifyCreate'))); - } else { - $this->_diInstance->expects($this->once()) - ->method('get') - ->will($this->returnCallback(array($this, 'verifyGet'))); - } - - $this->_objectManager = new Magento_ObjectManager_Zend(null, $this->_diInstance); - } - - /** - * Callback to use instead InstanceManager::addSharedInstance - * - * @param object $instance - * @param string $classOrAlias - */ - public function verifyAddSharedInstanceCallback($instance, $classOrAlias) - { - $this->assertInstanceOf('Magento_ObjectManager_Zend', $instance); - $this->assertEquals('Magento_ObjectManager', $classOrAlias); - } - - /** - * Callback to use instead Di::get - * - * @param string $className - * @param array $arguments - * @return Mage_Core_Model_Config - */ - public function getCallback($className, array $arguments = array()) - { - $this->assertEquals('Mage_Core_Model_Config', $className); - $this->assertEmpty($arguments); - return $this->_magentoConfig; - } - - /** - * Callback method for Magento_Di_Zend::newInstance - * - * @param string $className - * @param array $arguments - * @return string - */ - public function verifyCreate($className, array $arguments = array()) - { - $this->assertEquals(self::CLASS_NAME, $className); - $this->assertEquals($this->_arguments, $arguments); - - return self::OBJECT_CREATE; - } - - /** - * Callback method for Magento_Di_Zend::get - * - * @param string $className - * @param array $arguments - * @return string|Mage_Core_Model_Config - */ - public function verifyGet($className, array $arguments = array()) - { - if ($className == 'Mage_Core_Model_Config') { - return $this->_magentoConfig; - } - - $this->assertEquals(self::CLASS_NAME, $className); - $this->assertEquals($this->_arguments, $arguments); - - return self::OBJECT_GET; - } - - public function testAddSharedInstance() - { - $object = new Varien_Object(); - $alias = 'Varien_Object_Alias'; - - $this->_prepareObjectManagerForAddSharedInstance($object, $alias); - $this->_objectManager->addSharedInstance($object, $alias); - } - - /** - * Prepare all required mocks for addSharedInstance - * - * @param object $instance - * @param string $classOrAlias - */ - protected function _prepareObjectManagerForAddSharedInstance($instance, $classOrAlias) - { - $diInstance = $this->getMock('Magento_Di_Zend', array('instanceManager')); - $instanceManager = $this->getMock( - 'Magento_Di_InstanceManager_Zend', array('addSharedInstance'), array(), '', false - ); - - $instanceManager->expects($this->exactly(2)) - ->method('addSharedInstance'); - $instanceManager->expects($this->at(1)) - ->method('addSharedInstance') - ->with($instance, $classOrAlias); - $diInstance->expects($this->exactly(2)) - ->method('instanceManager') - ->will($this->returnValue($instanceManager)); - - $this->_objectManager = new Magento_ObjectManager_Zend(null, $diInstance); - } - - public function testRemoveSharedInstance() - { - $alias = 'Varien_Object_Alias'; - - $this->_prepareObjectManagerForRemoveSharedInstance($alias); - $this->_objectManager->removeSharedInstance($alias); - } - - /** - * Prepare all required mocks for removeSharedInstance - * - * @param string $classOrAlias - */ - protected function _prepareObjectManagerForRemoveSharedInstance($classOrAlias) - { - $diInstance = $this->getMock('Magento_Di_Zend', array('instanceManager')); - $instanceManager = $this->getMock( - 'Magento_Di_InstanceManager_Zend', array('addSharedInstance', 'removeSharedInstance'), array(), '', - false - ); - - $instanceManager->expects($this->any()) - ->method('addSharedInstance') - ->will($this->returnSelf()); - $instanceManager->expects($this->once()) - ->method('removeSharedInstance') - ->with($classOrAlias); - $diInstance->expects($this->exactly(2)) - ->method('instanceManager') - ->will($this->returnValue($instanceManager)); - - $this->_objectManager = new Magento_ObjectManager_Zend(null, $diInstance); - } - - public function testHasSharedInstance() - { - $alias = 'Varien_Object_Alias'; - - $this->_prepareObjectManagerForHasSharedInstance($alias); - $this->_objectManager->hasSharedInstance($alias); - } - - /** - * Prepare all required mocks for hasSharedInstance - * - * @param string $classOrAlias - */ - protected function _prepareObjectManagerForHasSharedInstance($classOrAlias) - { - $diInstance = $this->getMock('Magento_Di_Zend', array('instanceManager')); - $instanceManager = $this->getMock( - 'Magento_Di_InstanceManager_Zend', array('hasSharedInstance'), array(), '', - false - ); - $instanceManager->expects($this->once()) - ->method('hasSharedInstance') - ->with($classOrAlias); - $diInstance->expects($this->exactly(2)) - ->method('instanceManager') - ->will($this->returnValue($instanceManager)); - - $this->_objectManager = new Magento_ObjectManager_Zend(null, $diInstance); - } - - public function testAddAlias() - { - $alias = 'Varien_Object_Alias'; - - $diInstance = $this->getMock('Magento_Di_Zend', array('instanceManager')); - $instanceManager = $this->getMock( - 'Magento_Di_InstanceManager_Zend', array('addSharedInstance', 'removeSharedInstance', 'addAlias'), - array(), '', false - ); - - $diInstance->expects($this->any()) - ->method('instanceManager') - ->will($this->returnValue($instanceManager)); - $instanceManager->expects($this->any()) - ->method('addSharedInstance') - ->will($this->returnSelf()); - - $this->_objectManager = new Magento_ObjectManager_Zend(null, $diInstance); - - $instanceManager->expects($this->once()) - ->method('addAlias') - ->with($alias, self::CLASS_NAME, array()); - - $this->_objectManager->addAlias($alias, self::CLASS_NAME); - } - - public function testGetClassFromAlias() - { - $alias = 'Varien_Object_Alias'; - - $diInstance = $this->getMock('Magento_Di_Zend', array('instanceManager')); - $instanceManager = $this->getMock( - 'Magento_Di_InstanceManager_Zend', array('addSharedInstance', 'removeSharedInstance', 'getClassFromAlias'), - array(), '', false - ); - - $diInstance->expects($this->any()) - ->method('instanceManager') - ->will($this->returnValue($instanceManager)); - $instanceManager->expects($this->any()) - ->method('addSharedInstance') - ->will($this->returnSelf()); - - $this->_objectManager = new Magento_ObjectManager_Zend(null, $diInstance); - - $instanceManager->expects($this->once()) - ->method('getClassFromAlias') - ->with($alias); - - $this->_objectManager->getClassFromAlias($alias); - } -} diff --git a/dev/tests/unit/testsuite/Magento/_files/Aggregate/Child.php b/dev/tests/unit/testsuite/Magento/_files/Aggregate/Child.php new file mode 100644 index 0000000000000..408c2961aa2d2 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/_files/Aggregate/Child.php @@ -0,0 +1,44 @@ +secondScalar = $secondScalar; + $this->secondOptionalScalar = $secondOptionalScalar; + } + +} diff --git a/dev/tests/unit/testsuite/Magento/_files/Aggregate/Interface.php b/dev/tests/unit/testsuite/Magento/_files/Aggregate/Interface.php new file mode 100644 index 0000000000000..9631522949ff6 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/_files/Aggregate/Interface.php @@ -0,0 +1,26 @@ +interface = $interface; + $this->parent = $parent; + $this->child = $child; + $this->scalar = $scalar; + $this->optionalScalar = $optionalScalar; + } +} diff --git a/dev/tests/unit/testsuite/Magento/_files/Aggregate/WithOptional.php b/dev/tests/unit/testsuite/Magento/_files/Aggregate/WithOptional.php new file mode 100644 index 0000000000000..b37a1ae60fc79 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/_files/Aggregate/WithOptional.php @@ -0,0 +1,35 @@ +parent = $parent; + $this->child = $child; + } +} diff --git a/dev/tests/unit/testsuite/Magento/_files/Child.php b/dev/tests/unit/testsuite/Magento/_files/Child.php new file mode 100644 index 0000000000000..a674338ce5137 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/_files/Child.php @@ -0,0 +1,26 @@ +_mockBackend = $this->getMock('Zend_Cache_Backend_File'); + } + + protected function tearDown() + { + unset($this->_mockBackend); + } + + public function testSetBackendDefault() + { + $core = new Varien_Cache_Core(); + $core->setBackend($this->_mockBackend); + + $this->assertNotInstanceOf('Magento_Cache_Backend_Decorator_DecoratorAbstract', $core->getBackend()); + $this->assertEquals($this->_mockBackend, $core->getBackend()); + } + + /** + * @dataProvider setBackendExceptionProvider + * @expectedException Zend_Cache_Exception + */ + public function testSetBackendException($decorators) + { + $core = new Varien_Cache_Core(array('backend_decorators' => $decorators)); + $core->setBackend($this->_mockBackend); + } + + public function setBackendExceptionProvider() + { + return array( + 'string' => array('string'), + 'decorator setting is not an array' => array(array('decorator' => 'string')), + 'decorator setting is empty array' => array(array('decorator' => array())), + 'no class index in array' => array(array('decorator' => array('somedata'))), + 'non-existing class passed' => array(array('decorator' => array('class' => 'NonExistingClass'))), + ); + } + + public function testSaveDisabled() + { + $backendMock = $this->getMock('Zend_Cache_Backend_BlackHole'); + $backendMock->expects($this->never()) + ->method('save'); + $frontend = new Varien_Cache_Core(array('disable_save' => true)); + $frontend->setBackend($backendMock); + $result = $frontend->save('data', 'id'); + $this->assertTrue($result); + } +} diff --git a/dev/tests/unit/testsuite/Varien/ObjectTest.php b/dev/tests/unit/testsuite/Varien/ObjectTest.php index b00fccdd29155..0cca0247cad0e 100644 --- a/dev/tests/unit/testsuite/Varien/ObjectTest.php +++ b/dev/tests/unit/testsuite/Varien/ObjectTest.php @@ -28,7 +28,7 @@ /** * Varien_Object test case. */ -class Varien_ObjectTest extends PHPUnit_Framework_TestCase +class Varien_ObjectTest extends Magento_Framework_TestCase { /** * @var Varien_Object @@ -296,25 +296,25 @@ public function testToXml() '; - $this->assertEquals($xml, $this->_object->toXml()); + $this->assertXmlStringEqualsXmlString($xml, $this->_object->toXml()); $xml = ' '; - $this->assertEquals($xml, $this->_object->toXml(array('key2'))); + $this->assertXmlStringEqualsXmlString($xml, $this->_object->toXml(array('key2'))); $xml = ' '; - $this->assertEquals($xml, $this->_object->toXml(array(), 'my_item')); + $this->assertXmlStringEqualsXmlString($xml, $this->_object->toXml(array(), 'my_item')); $xml = ' '; - $this->assertEquals($xml, $this->_object->toXml(array(), false)); + $this->assertEqualNormalizingNewlines($xml, $this->_object->toXml(array(), false)); $xml = ' @@ -322,7 +322,7 @@ public function testToXml() '; - $this->assertEquals($xml, $this->_object->toXml(array(), 'item', true)); + $this->assertXmlStringEqualsXmlString($xml, $this->_object->toXml(array(), 'item', true)); $xml = ' @@ -330,7 +330,7 @@ public function testToXml() value2 '; - $this->assertEquals($xml, $this->_object->__toXml(array(), 'item', true, false)); + $this->assertXmlStringEqualsXmlString($xml, $this->_object->__toXml(array(), 'item', true, false)); } /** diff --git a/dev/tests/unit/testsuite/Varien/Simplexml/ConfigTest.php b/dev/tests/unit/testsuite/Varien/Simplexml/ConfigTest.php new file mode 100644 index 0000000000000..15077fa0963a8 --- /dev/null +++ b/dev/tests/unit/testsuite/Varien/Simplexml/ConfigTest.php @@ -0,0 +1,34 @@ +1'; + $config = new Varien_Simplexml_Config; + $this->assertFalse($config->loadString('')); + $this->assertTrue($config->loadString($xml)); + $this->assertXmlStringEqualsXmlString($xml, $config->getXmlString()); + } +} diff --git a/dev/tests/unit/testsuite/Varien/Simplexml/ElementTest.php b/dev/tests/unit/testsuite/Varien/Simplexml/ElementTest.php index 91d4e9985bd30..7dd2619aa39ed 100644 --- a/dev/tests/unit/testsuite/Varien/Simplexml/ElementTest.php +++ b/dev/tests/unit/testsuite/Varien/Simplexml/ElementTest.php @@ -79,7 +79,7 @@ public function testAsNiceXmlMixedData() XML; - $this->assertEquals($expected, $xml->asNiceXml()); + $this->assertXmlStringEqualsXmlString($expected, $xml->asNiceXml()); } } diff --git a/dev/tests/unit/testsuite/tools/Di/Code/Scanner/ArrayScannerTest.php b/dev/tests/unit/testsuite/tools/Di/Code/Scanner/ArrayScannerTest.php new file mode 100644 index 0000000000000..7c624e36bd7fd --- /dev/null +++ b/dev/tests/unit/testsuite/tools/Di/Code/Scanner/ArrayScannerTest.php @@ -0,0 +1,56 @@ +_model = new Magento\Tools\Di\Code\Scanner\ArrayScanner(); + $this->_testDir = str_replace('\\', '/', realpath(dirname(__FILE__) . '/../../') . '/_files'); + } + + public function testCollectEntities() + { + $actual = $this->_model->collectEntities(array($this->_testDir . '/additional.php')); + $expected = array( + 'Some_Model_Proxy', + 'Some_Model_EntityFactory' + ); + $this->assertEquals($expected, $actual); + } +} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/tools/Di/Code/Scanner/CompositeScannerTest.php b/dev/tests/unit/testsuite/tools/Di/Code/Scanner/CompositeScannerTest.php new file mode 100644 index 0000000000000..07747c6b787b6 --- /dev/null +++ b/dev/tests/unit/testsuite/tools/Di/Code/Scanner/CompositeScannerTest.php @@ -0,0 +1,76 @@ +_model = new Magento\Tools\Di\Code\Scanner\CompositeScanner(); + } + + public function testScan() + { + $phpFiles = array( + 'one/file/php', + 'two/file/php', + ); + $configFiles = array( + 'one/file/config', + 'two/file/config', + ); + $files = array( + 'php' => $phpFiles, + 'config' => $configFiles, + ); + + $scannerPhp = $this->getMock('Magento\Tools\Di\Code\Scanner\ScannerInterface'); + $scannerXml = $this->getMock('Magento\Tools\Di\Code\Scanner\ScannerInterface'); + + $scannerPhp->expects($this->once()) + ->method('collectEntities') + ->with($phpFiles) + ->will($this->returnValue(array('Model_OneProxy', 'Model_TwoFactory'))); + + $scannerXml->expects($this->once()) + ->method('collectEntities') + ->with($configFiles) + ->will($this->returnValue(array('Model_OneProxy', 'Model_ThreeFactory'))); + + $this->_model->addChild($scannerPhp, 'php'); + $this->_model->addChild($scannerXml, 'config'); + + $actual = $this->_model->collectEntities($files); + $expected = array('Model_OneProxy', 'Model_TwoFactory', 'Model_ThreeFactory'); + + $this->assertEquals($expected, array_values($actual)); + } +} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/tools/Di/Code/Scanner/DirectoryScannerTest.php b/dev/tests/unit/testsuite/tools/Di/Code/Scanner/DirectoryScannerTest.php new file mode 100644 index 0000000000000..571396b920fc4 --- /dev/null +++ b/dev/tests/unit/testsuite/tools/Di/Code/Scanner/DirectoryScannerTest.php @@ -0,0 +1,84 @@ +_model = new Magento\Tools\Di\Code\Scanner\DirectoryScanner(); + $this->_testDir = str_replace('\\', '/', realpath(dirname(__FILE__) . '/../../') . '/_files'); + } + + public function testScan() + { + $filePatterns = array( + 'php' => '/.*\.php$/', + 'etc' => '/\/app\/etc\/.*\.xml$/', + 'config' => '/\/etc\/(config([a-z0-9\.]*)?|adminhtml\/system)\.xml$/', + 'view' => '/\/view\/[a-z0-9A-Z\/\.]*\.xml$/', + 'design' => '/\/app\/design\/[a-z0-9A-Z\/\.]*\.xml$/', + ); + + $actual = $this->_model->scan($this->_testDir, $filePatterns); + $expected = array( + 'php' => array( + $this->_testDir . '/additional.php', + $this->_testDir . '/app/bootstrap.php', + $this->_testDir . '/app/code/Mage/SomeModule/Helper/Test.php', + $this->_testDir . '/app/code/Mage/SomeModule/Model/Test.php', + ), + 'config' => array( + $this->_testDir . '/app/code/Mage/SomeModule/etc/adminhtml/system.xml', + $this->_testDir . '/app/code/Mage/SomeModule/etc/config.xml' + ), + 'view' => array( + $this->_testDir . '/app/code/Mage/SomeModule/view/frontend/layout.xml', + ), + 'design' => array( + $this->_testDir . '/app/design/adminhtml/default/backend/layout.xml', + ), + 'etc' => array( + $this->_testDir . '/app/etc/additional.xml', + $this->_testDir . '/app/etc/config.xml', + ), + ); + $this->assertEquals(sort($expected['php']), sort($actual['php']), 'Incorrect php files list'); + $this->assertEquals(sort($expected['config']), sort($actual['config']), 'Incorrect config files list'); + $this->assertEquals(sort($expected['view']), sort($actual['view']), 'Incorrect view files list'); + $this->assertEquals(sort($expected['design']), sort($actual['design']), 'Incorrect design files list'); + $this->assertEquals(sort($expected['etc']), sort($actual['etc']), 'Incorrect etc files list'); + } +} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/tools/Di/Code/Scanner/PhpScannerTest.php b/dev/tests/unit/testsuite/tools/Di/Code/Scanner/PhpScannerTest.php new file mode 100644 index 0000000000000..f4a55e1c0d511 --- /dev/null +++ b/dev/tests/unit/testsuite/tools/Di/Code/Scanner/PhpScannerTest.php @@ -0,0 +1,70 @@ +_model = new Magento\Tools\Di\Code\Scanner\PhpScanner(); + $this->_testDir = str_replace('\\', '/', realpath(dirname(__FILE__) . '/../../') . '/_files'); + $this->_testFiles = array( + $this->_testDir . '/app/code/Mage/SomeModule/Helper/Test.php', + $this->_testDir . '/app/code/Mage/SomeModule/Model/Test.php', + $this->_testDir . '/app/bootstrap.php', + ); + } + + public function testCollectEntities() + { + $actual = $this->_model->collectEntities($this->_testFiles); + $expected = array( + 'Mage_SomeModule_ElementFactory', + 'Mage_SomeModule_Element_Proxy', + 'Mage_SomeModule_BlockFactory', + 'Mage_SomeModule_ModelFactory', + 'Mage_SomeModule_Model_BlockFactory', + 'Mage_Bootstrap_ModelFactory', + ); + $this->assertEquals($expected, $actual); + } +} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/tools/Di/Code/Scanner/XmlScannerTest.php b/dev/tests/unit/testsuite/tools/Di/Code/Scanner/XmlScannerTest.php new file mode 100644 index 0000000000000..047976582e1b9 --- /dev/null +++ b/dev/tests/unit/testsuite/tools/Di/Code/Scanner/XmlScannerTest.php @@ -0,0 +1,71 @@ +_model = new Magento\Tools\Di\Code\Scanner\XmlScanner(); + $this->_testDir = str_replace('\\', '/', realpath(dirname(__FILE__) . '/../../') . '/_files'); + $this->_testFiles = array( + $this->_testDir . '/app/code/Mage/SomeModule/etc/adminhtml/system.xml', + $this->_testDir . '/app/code/Mage/SomeModule/etc/config.xml', + $this->_testDir . '/app/code/Mage/SomeModule/view/frontend/layout.xml', + $this->_testDir . '/app/etc/config.xml' + + ); + } + + public function testCollectEntities() + { + $actual = $this->_model->collectEntities($this->_testFiles); + $expected = array( + 'Mage_Backend_Block_System_Config_Form_Fieldset_Modules_DisableOutput_Proxy', + 'Mage_Core_Model_App_Proxy', + 'Mage_Core_Model_Cache_Proxy', + 'Mage_Backend_Block_Menu_Proxy', + 'Mage_Core_Model_StoreManager_Proxy', + ); + $this->assertEquals($expected, $actual); + } +} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/tools/Di/_files/additional.php b/dev/tests/unit/testsuite/tools/Di/_files/additional.php new file mode 100644 index 0000000000000..8f9d86989e330 --- /dev/null +++ b/dev/tests/unit/testsuite/tools/Di/_files/additional.php @@ -0,0 +1,28 @@ +_factory = $factory; + $this->_proxy = $proxy; + } + + /** + * @return Mage_SomeModule_Block_Proxy + */ + public function test(ModelFactory $factory) + { + return Mage::getModel('Mage_SomeModule_BlockFactory', array('data' => $factory)); + } +} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/tools/Di/_files/app/code/Mage/SomeModule/Model/Test.php b/dev/tests/unit/testsuite/tools/Di/_files/app/code/Mage/SomeModule/Model/Test.php new file mode 100644 index 0000000000000..c6d25323f9f7f --- /dev/null +++ b/dev/tests/unit/testsuite/tools/Di/_files/app/code/Mage/SomeModule/Model/Test.php @@ -0,0 +1,43 @@ + $factory)); + } + + /** + * @param Mage_SomeModule_ModelFactory $factory + * @param array $data + */ + public function test(Mage_SomeModule_ModelFactory $factory, array $data = array()) + { + /** + * Mage::getModel('Mage_SomeModule_Model_Comment_BlockFactory', array('factory' => $factory)); + */ + Mage::getModel('Mage_SomeModule_Model_BlockFactory', array('factory' => $factory, 'data' => $data)); + } +} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/tools/Di/_files/app/code/Mage/SomeModule/etc/additional.xml b/dev/tests/unit/testsuite/tools/Di/_files/app/code/Mage/SomeModule/etc/additional.xml new file mode 100644 index 0000000000000..8b9b5053fab46 --- /dev/null +++ b/dev/tests/unit/testsuite/tools/Di/_files/app/code/Mage/SomeModule/etc/additional.xml @@ -0,0 +1,26 @@ + + + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/tools/Di/_files/app/code/Mage/SomeModule/etc/adminhtml/config.xml b/dev/tests/unit/testsuite/tools/Di/_files/app/code/Mage/SomeModule/etc/adminhtml/config.xml new file mode 100644 index 0000000000000..8b9b5053fab46 --- /dev/null +++ b/dev/tests/unit/testsuite/tools/Di/_files/app/code/Mage/SomeModule/etc/adminhtml/config.xml @@ -0,0 +1,26 @@ + + + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/tools/Di/_files/app/code/Mage/SomeModule/etc/adminhtml/system.xml b/dev/tests/unit/testsuite/tools/Di/_files/app/code/Mage/SomeModule/etc/adminhtml/system.xml new file mode 100644 index 0000000000000..e63d99a36dc67 --- /dev/null +++ b/dev/tests/unit/testsuite/tools/Di/_files/app/code/Mage/SomeModule/etc/adminhtml/system.xml @@ -0,0 +1,38 @@ + + + + +
    + + advanced + Mage_Adminhtml::advanced + + + Mage_Backend_Block_System_Config_Form_Fieldset_Modules_DisableOutput_Proxy + +
    +
    +
    diff --git a/dev/tests/unit/testsuite/tools/Di/_files/app/code/Mage/SomeModule/etc/config.xml b/dev/tests/unit/testsuite/tools/Di/_files/app/code/Mage/SomeModule/etc/config.xml new file mode 100644 index 0000000000000..ac6ad5d63a34b --- /dev/null +++ b/dev/tests/unit/testsuite/tools/Di/_files/app/code/Mage/SomeModule/etc/config.xml @@ -0,0 +1,36 @@ + + + + + + + Mage_Core_Model_App_Proxy + + Mage_Core_Model_Cache_Proxy + + + + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/tools/Di/_files/app/code/Mage/SomeModule/view/frontend/layout.xml b/dev/tests/unit/testsuite/tools/Di/_files/app/code/Mage/SomeModule/view/frontend/layout.xml new file mode 100644 index 0000000000000..37f352d7411fa --- /dev/null +++ b/dev/tests/unit/testsuite/tools/Di/_files/app/code/Mage/SomeModule/view/frontend/layout.xml @@ -0,0 +1,32 @@ + + + + + + + + + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/tools/Di/_files/app/design/adminhtml/default/backend/layout.xml b/dev/tests/unit/testsuite/tools/Di/_files/app/design/adminhtml/default/backend/layout.xml new file mode 100644 index 0000000000000..8b9b5053fab46 --- /dev/null +++ b/dev/tests/unit/testsuite/tools/Di/_files/app/design/adminhtml/default/backend/layout.xml @@ -0,0 +1,26 @@ + + + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/tools/Di/_files/app/etc/additional.xml b/dev/tests/unit/testsuite/tools/Di/_files/app/etc/additional.xml new file mode 100644 index 0000000000000..8b9b5053fab46 --- /dev/null +++ b/dev/tests/unit/testsuite/tools/Di/_files/app/etc/additional.xml @@ -0,0 +1,26 @@ + + + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/tools/Di/_files/app/etc/config.xml b/dev/tests/unit/testsuite/tools/Di/_files/app/etc/config.xml new file mode 100644 index 0000000000000..31f4e56eff12a --- /dev/null +++ b/dev/tests/unit/testsuite/tools/Di/_files/app/etc/config.xml @@ -0,0 +1,36 @@ + + + + + + + + Mage_Core_Model_StoreManager_Proxy + + + + + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/tools/migration/Acl/GeneratorTest.php b/dev/tests/unit/testsuite/tools/migration/Acl/GeneratorTest.php index 7e9ba62ec971e..f4f4e139298e7 100644 --- a/dev/tests/unit/testsuite/tools/migration/Acl/GeneratorTest.php +++ b/dev/tests/unit/testsuite/tools/migration/Acl/GeneratorTest.php @@ -280,7 +280,7 @@ public function testGetResultDomDocument() $dom = $this->_model->getResultDomDocument(); $expectedDom = new DOMDocument(); $expectedDom->formatOutput = true; - $this->assertEquals($expectedDocument, $dom->saveXML($dom->documentElement)); + $this->assertXmlStringEqualsXmlString($expectedDocument, $dom->saveXML($dom->documentElement)); } public function testParseAdminhtmlFiles() diff --git a/dev/tests/unit/testsuite/tools/migration/System/Configuration/GeneratorTest.php b/dev/tests/unit/testsuite/tools/migration/System/Configuration/GeneratorTest.php index 2fcb1fb98f281..912a9b242bbec 100644 --- a/dev/tests/unit/testsuite/tools/migration/System/Configuration/GeneratorTest.php +++ b/dev/tests/unit/testsuite/tools/migration/System/Configuration/GeneratorTest.php @@ -34,7 +34,7 @@ . '/tools/migration/System/Configuration/Formatter.php'; -class Tools_Migration_System_Configuration_GeneratorTest extends PHPUnit_Framework_TestCase +class Tools_Migration_System_Configuration_GeneratorTest extends Magento_Framework_TestCase { /** * @var Tools_Migration_System_Configuration_Generator @@ -74,6 +74,9 @@ protected function setUp() public function testCreateConfigurationGeneratesConfiguration() { $dom = new DOMDocument(); + // On some machines formatOutput and preserveWhiteSpace must be set before calling loadXML + $dom->formatOutput = true; + $dom->preserveWhiteSpace = false; $dom->loadXML( preg_replace('/\n|\s{4}/', '', file_get_contents(__DIR__ . '/_files/convertedConfiguration.xml')) ); @@ -81,8 +84,6 @@ public function testCreateConfigurationGeneratesConfiguration() foreach ($stripComments->query('//comment()') as $comment) { $comment->parentNode->removeChild($comment); } - $dom->formatOutput = true; - $dom->preserveWhiteSpace = false; $expectedXml = $dom->saveXML(); $this->_fileManagerMock->expects($this->once())->method('write') @@ -103,7 +104,7 @@ function($xml) { $this->_loggerMock->expects($this->once())->method('add')->with( 'someFile', - Tools_Migration_System_Configuration_LoggerAbstract:: FILE_KEY_VALID + Tools_Migration_System_Configuration_LoggerAbstract::FILE_KEY_VALID ); $this->_model->createConfiguration('someFile', include __DIR__ . '/_files/mappedConfiguration.php'); diff --git a/dev/tests/unit/testsuite/tools/migration/System/Configuration/ParserTest.php b/dev/tests/unit/testsuite/tools/migration/System/Configuration/ParserTest.php index 9f1002f2fb52e..f9f1f595d5876 100644 --- a/dev/tests/unit/testsuite/tools/migration/System/Configuration/ParserTest.php +++ b/dev/tests/unit/testsuite/tools/migration/System/Configuration/ParserTest.php @@ -30,7 +30,7 @@ /** * Tools_Migration_System_Configuration_Parser test case */ -class Tools_Migration_System_Configuration_ParserTest extends PHPUnit_Framework_TestCase +class Tools_Migration_System_Configuration_ParserTest extends Magento_Framework_TestCase { /** * @var Tools_Migration_System_Configuration_Parser @@ -99,24 +99,24 @@ public function testParseDomNodes() */ XMLCOMMENT; - $expected = array( - 'comment' => $comment, - 'sections' => array( - 'some_section' => array( - 'label' => array('#text' => 'Section Name'), - 'tab' => array('#text' => 'test'), - 'frontend_type' => array('#text' => 'text'), - 'sort_order' => array('#text' => '140'), - 'show_in_default' => array('#text' => '1'), - 'show_in_website' => array('#text' => '1'), - 'show_in_store' => array('#text' => '1'), - 'resource' => array('#text' => 'Mage_Some::resource'), - '@attributes' => array('translate' => 'label', 'module' => 'Mage_Some') - ) + $sections = array( + 'some_section' => array( + 'label' => array('#text' => 'Section Name'), + 'tab' => array('#text' => 'test'), + 'frontend_type' => array('#text' => 'text'), + 'sort_order' => array('#text' => '140'), + 'show_in_default' => array('#text' => '1'), + 'show_in_website' => array('#text' => '1'), + 'show_in_store' => array('#text' => '1'), + 'resource' => array('#text' => 'Mage_Some::resource'), + '@attributes' => array('translate' => 'label', 'module' => 'Mage_Some') ) ); $dom = new DOMDocument(); $dom->loadXML($xml); - $this->assertEquals($expected, $this->_parser->parse($dom)); + + $parsedXml = $this->_parser->parse($dom); + $this->assertEqualNormalizingNewlines($comment, $parsedXml['comment']); + $this->assertEquals($sections, $parsedXml['sections']); } } diff --git a/dev/tests/unit/testsuite/tools/view/Generator/CopyRuleTest.php b/dev/tests/unit/testsuite/tools/view/Generator/CopyRuleTest.php new file mode 100644 index 0000000000000..206cf64a83541 --- /dev/null +++ b/dev/tests/unit/testsuite/tools/view/Generator/CopyRuleTest.php @@ -0,0 +1,154 @@ +_filesystem = $this->getMock('Magento_Filesystem', array('searchKeys', 'isDirectory'), array( + $this->getMockForAbstractClass('Magento_Filesystem_AdapterInterface') + )); + $this->_themeCollection = $this->getMock('Mage_Core_Model_Theme_Collection', array('isLoaded'), array( + $this->_filesystem, + $this->getMockForAbstractClass('Magento_ObjectManager'), + new Mage_Core_Model_Dir($this->_filesystem, __DIR__) + )); + $this->_themeCollection->expects($this->any())->method('isLoaded')->will($this->returnValue(true)); + $this->_fallbackRule = $this->getMockForAbstractClass('Mage_Core_Model_Design_Fallback_Rule_RuleInterface'); + $this->_object = new Generator_CopyRule($this->_filesystem, $this->_themeCollection, $this->_fallbackRule); + } + + protected function tearDown() + { + $this->_object = null; + $this->_filesystem = null; + $this->_themeCollection = null; + $this->_fallbackRule = null; + } + + /** + * @param array $fixtureThemes + * @param array $patternDirMap + * @param array $filesystemGlobMap + * @param array $expectedResult + * @dataProvider getCopyRulesDataProvider + */ + public function testGetCopyRules( + array $fixtureThemes, array $patternDirMap, array $filesystemGlobMap, array $expectedResult + ) { + foreach ($fixtureThemes as $theme) { + $this->_themeCollection->addItem($theme); + } + $this->_fallbackRule + ->expects($this->atLeastOnce()) + ->method('getPatternDirs') + ->will($this->returnValueMap($patternDirMap)) + ; + $this->_filesystem + ->expects($this->atLeastOnce()) + ->method('searchKeys') + ->will($this->returnValueMap($filesystemGlobMap)) + ; + $this->_filesystem + ->expects($this->atLeastOnce()) + ->method('isDirectory') + ->will($this->returnValue(true)) + ; + $this->assertEquals($expectedResult, $this->_object->getCopyRules()); + } + + public function getCopyRulesDataProvider() + { + $fixture = require __DIR__ . '/_files/fixture_themes.php'; + + $patternDirMap = array(); + $filesystemGlobMap = array(); + foreach ($fixture as $fixtureInfo) { + $patternDirMap[] = $fixtureInfo['pattern_dir_map']; + $filesystemGlobMap[] = $fixtureInfo['filesystem_glob_map']; + } + + return array( + 'reverse fallback traversal' => array( + array($fixture['theme_customizing_one_module']['theme']), + $patternDirMap, + $filesystemGlobMap, + $fixture['theme_customizing_one_module']['expected_result'], + ), + 'themes in the same area' => array( + array( + $fixture['theme_customizing_one_module']['theme'], + $fixture['theme_customizing_two_modules']['theme'] + ), + $patternDirMap, + $filesystemGlobMap, + array_merge( + $fixture['theme_customizing_one_module']['expected_result'], + $fixture['theme_customizing_two_modules']['expected_result'] + ), + ), + 'themes in different areas' => array( + array( + $fixture['theme_customizing_one_module']['theme'], + $fixture['theme_customizing_no_modules']['theme'] + ), + $patternDirMap, + $filesystemGlobMap, + array_merge( + $fixture['theme_customizing_one_module']['expected_result'], + $fixture['theme_customizing_no_modules']['expected_result'] + ), + ), + 'mixed directory separators in fallback pattern' => array( + array($fixture['fallback_pattern_mixing_slashes']['theme']), + $patternDirMap, + $filesystemGlobMap, + $fixture['fallback_pattern_mixing_slashes']['expected_result'], + ), + ); + } +} diff --git a/dev/tests/unit/testsuite/tools/view/Generator/ThemeDeploymentTest.php b/dev/tests/unit/testsuite/tools/view/Generator/ThemeDeploymentTest.php new file mode 100644 index 0000000000000..9466b11fd53ed --- /dev/null +++ b/dev/tests/unit/testsuite/tools/view/Generator/ThemeDeploymentTest.php @@ -0,0 +1,188 @@ +_tmpDir = TESTS_TEMP_DIR . DIRECTORY_SEPARATOR . 'tool_theme_deployment'; + mkdir($this->_tmpDir); + } + + protected function tearDown() + { + Varien_Io_File::rmdirRecursive($this->_tmpDir); + } + + /** + * @param string $permitted + * @param string $forbidden + * @param string $exceptionMessage + * @dataProvider constructorExceptionDataProvider + */ + public function testConstructorException($permitted, $forbidden, $exceptionMessage) + { + $this->setExpectedException('Magento_Exception', $exceptionMessage); + new Generator_ThemeDeployment($this->_tmpDir, $permitted, $forbidden); + } + + public static function constructorExceptionDataProvider() + { + $conflictPermitted = __DIR__ . '/_files/ThemeDeployment/constructor_exception/permitted.php'; + $conflictForbidden = __DIR__ . '/_files/ThemeDeployment/constructor_exception/forbidden.php'; + return array( + 'no permitted config' => array( + 'non_existing_config.txt', + $conflictForbidden, + 'Config file does not exist: non_existing_config.txt', + ), + 'no forbidden config' => array( + $conflictPermitted, + 'non_existing_config.txt', + 'Config file does not exist: non_existing_config.txt', + ), + 'config conflicts' => array( + $conflictPermitted, + $conflictForbidden, + 'Conflicts: the following extensions are added both to permitted and forbidden lists: ' . + 'conflict1, conflict2', + ), + ); + } + + public function testRun() + { + $permitted = __DIR__ . '/_files/ThemeDeployment/run/permitted.php'; + $forbidden = __DIR__ . '/_files/ThemeDeployment/run/forbidden.php'; + $fixture = include __DIR__ . '/_files/ThemeDeployment/run/fixture.php'; + + $object = new Generator_ThemeDeployment($this->_tmpDir, $permitted, $forbidden); + $object->run($fixture['copyRules']); + + // Verify expected paths + $actualPaths = $this->_getRelativePaths($this->_tmpDir); + $actualPaths = $this->_canonizePathArray($actualPaths); + $expectedPaths = $this->_canonizePathArray($fixture['expectedRelPaths']); + $this->assertEquals($expectedPaths, $actualPaths, "Actual result of copying is different from expected paths"); + + // Verify content of files + foreach ($fixture['expectedFileContent'] as $relFile => $expectedContent) { + $actualContent = trim(file_get_contents($this->_tmpDir . '/' . $relFile)); + $this->assertEquals($expectedContent, $actualContent, "Actual content is wrong in file {$relFile}"); + } + } + + /** + * Recursively go through directory and compose relative paths of all its files + * + * @param string $dir + * @return array + */ + protected function _getRelativePaths($dir) + { + $dirLen = strlen($dir); + $files = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS) + ); + $result = array(); + foreach ($files as $file) { + $result[] = substr($file, $dirLen + 1); + } + return $result; + } + + /** + * Process $paths, sorting them and making system separator in them + * + * @param array $paths + * @return array + */ + protected function _canonizePathArray($paths) + { + rsort($paths, SORT_STRING); + foreach ($paths as &$path) { + $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path); + } + return $paths; + } + + public function testRunInDryRun() + { + $permitted = __DIR__ . '/_files/ThemeDeployment/run/permitted.php'; + $forbidden = __DIR__ . '/_files/ThemeDeployment/run/forbidden.php'; + $fixture = include __DIR__ . '/_files/ThemeDeployment/run/fixture.php'; + + $object = new Generator_ThemeDeployment($this->_tmpDir, $permitted, $forbidden, true); + $object->run($fixture['copyRules']); + + $actualPaths = $this->_getRelativePaths($this->_tmpDir); + $this->assertEmpty($actualPaths, 'Nothing must be copied/created in dry-run mode'); + } + + + /** + * @expectedException Magento_Exception + * @expectedExceptionMessage The file extension "php" must be added either to the permitted or forbidden list + */ + public function testRunWithUnknownExtension() + { + $permitted = __DIR__ . '/_files/ThemeDeployment/run/permitted.php'; + $forbidden = __DIR__ . '/_files/ThemeDeployment/run/forbidden_without_php.php'; + $fixture = include __DIR__ . '/_files/ThemeDeployment/run/fixture.php'; + + $object = new Generator_ThemeDeployment($this->_tmpDir, $permitted, $forbidden, true); + $object->run($fixture['copyRules']); + } + + public function testRunWithCasedExtension() + { + $permitted = __DIR__ . '/_files/ThemeDeployment/run/permitted_cased_js.php'; + + $object = new Generator_ThemeDeployment($this->_tmpDir, $permitted); + $copyRules = array( + array( + 'source' => __DIR__ . '/_files/ThemeDeployment/run/source_cased_js', + 'destinationContext' => array( + 'area' => 'frontend', + 'locale' => 'not_important', + 'themePath' => 'theme_path', + 'module' => null + ), + ), + ); + $object->run($copyRules); + $this->assertFileExists( + $this->_tmpDir . '/frontend/theme_path/file.JS' + ); + } +} diff --git a/dev/tests/unit/testsuite/tools/view/Generator/_files/ThemeDeployment/constructor_exception/forbidden.php b/dev/tests/unit/testsuite/tools/view/Generator/_files/ThemeDeployment/constructor_exception/forbidden.php new file mode 100644 index 0000000000000..ea81d751bccf1 --- /dev/null +++ b/dev/tests/unit/testsuite/tools/view/Generator/_files/ThemeDeployment/constructor_exception/forbidden.php @@ -0,0 +1,33 @@ + $sourceDir . '/frontend/package1/theme11', + 'destinationContext' => array( + 'area' => 'frontend', + 'locale' => 'not_important', + 'themePath' => 'package1/inherited_theme', + 'module' => null + ), + ), + array( + 'source' => $sourceDir . '/frontend/package1/theme12', + 'destinationContext' => array( + 'area' => 'frontend', + 'locale' => 'not_important', + 'themePath' => 'package1/theme12', + 'module' => null + ), + ), + array( + 'source' => $sourceDir . '/frontend/package2/theme21', + 'destinationContext' => array( + 'area' => 'frontend', + 'locale' => 'not_important', + 'themePath' => 'package1/inherited_theme', + 'module' => null + ), + ), + array( + 'source' => $sourceDir . '/frontend/package3/theme31', + 'destinationContext' => array( + 'area' => 'frontend', + 'locale' => 'not_important', + 'themePath' => 'package3/theme31', + 'module' => null + ), + ), + array( + 'source' => $sourceDir . '/Some_Module', + 'destinationContext' => array( + 'area' => 'adminhtml', + 'locale' => 'not_important', + 'themePath' => 'package4/theme41', + 'module' => 'Some_Module' + ), + ), +); + +// Relative expected paths, of what files must exist in destination dir, after running the tool +$expectedRelPaths = array( + 'frontend/package1/inherited_theme/Mage_Catalog/resource.png', + 'frontend/package1/inherited_theme/subdir/subdir.css', + 'frontend/package1/inherited_theme/subdir/subdir.js', + 'frontend/package1/inherited_theme/overwritten.css', + 'frontend/package1/inherited_theme/public.css', + 'frontend/package1/inherited_theme/theme21_file.js', + 'frontend/package1/theme12/theme12_file.js', + 'frontend/package3/theme31/theme31_file.css', + 'adminhtml/package4/theme41/Some_Module/theme41_file.css', +); + +// Expected file contents, so we can check overwriting and proper css expansion +$expectedFileContent = array( + 'frontend/package1/inherited_theme/overwritten.css' => 'Overwritten by next theme', + 'frontend/package1/inherited_theme/public.css' => 'a {background:url(Mage_Catalog/resource.png)}', + 'frontend/package1/inherited_theme/subdir/subdir.css' => "div {background:url(images/somefile.png)}\n" + . 'a {background:url(../Mage_Catalog/resource.png)}' +); + +// Return fixture +return array( + 'copyRules' => $copyRules, + 'expectedRelPaths' => $expectedRelPaths, + 'expectedFileContent' => $expectedFileContent, +); diff --git a/dev/tests/unit/testsuite/tools/view/Generator/_files/ThemeDeployment/run/forbidden.php b/dev/tests/unit/testsuite/tools/view/Generator/_files/ThemeDeployment/run/forbidden.php new file mode 100644 index 0000000000000..f89807ff02f9f --- /dev/null +++ b/dev/tests/unit/testsuite/tools/view/Generator/_files/ThemeDeployment/run/forbidden.php @@ -0,0 +1,31 @@ + 'area_one', + 'theme_path' => 'fixture/theme_one', +)); +$themeTwo = new Varien_Object(array( + 'area' => 'area_one', + 'theme_path' => 'fixture/theme_two', +)); +$themeThree = new Varien_Object(array( + 'area' => 'area_two', + 'theme_path' => 'fixture/theme_three', +)); +$themeFour = new Varien_Object(array( + 'area' => 'area_two', + 'theme_path' => 'fixture/theme_four', +)); + +return array( + 'theme_customizing_one_module' => array( + 'theme' => $themeOne, + 'pattern_dir_map' => array( + array('namespace' => '%namespace%', 'module' => '%module%', 'area' => 'area_one', 'theme' => $themeOne), + array( + '/base/dir/area_one/fixture/theme_one', + '/base/dir/area_one/fixture/theme_one/%namespace%_%module%', + ), + ), + 'filesystem_glob_map' => array( + '/base/dir/area_one/fixture/theme_one/', '*_*', array('/base/dir/area_one/fixture/theme_one/Mage_Core') + ), + 'expected_result' => array( + array( + 'source' => '/base/dir/area_one/fixture/theme_one/Mage_Core', + 'destinationContext' => array( + 'area' => 'area_one', + 'themePath' => 'fixture/theme_one', + 'locale' => null, + 'module' => 'Mage_Core', + ), + ), + array( + 'source' => '/base/dir/area_one/fixture/theme_one', + 'destinationContext' => array( + 'area' => 'area_one', + 'themePath' => 'fixture/theme_one', + 'locale' => null, + 'module' => null, + ), + ), + ), + ), + 'theme_customizing_two_modules' => array( + 'theme' => $themeTwo, + 'pattern_dir_map' => array( + array('namespace' => '%namespace%', 'module' => '%module%', 'area' => 'area_one', 'theme' => $themeTwo), + array( + '/base/dir/area_one/fixture/theme_two', + '/base/dir/area_one/fixture/theme_two/%namespace%_%module%', + ), + ), + 'filesystem_glob_map' => array( + '/base/dir/area_one/fixture/theme_two/', '*_*', + array( + '/base/dir/area_one/fixture/theme_two/Fixture_ModuleOne', + '/base/dir/area_one/fixture/theme_two/Fixture_ModuleTwo', + ) + ), + 'expected_result' => array( + array( + 'source' => '/base/dir/area_one/fixture/theme_two/Fixture_ModuleOne', + 'destinationContext' => array( + 'area' => 'area_one', + 'themePath' => 'fixture/theme_two', + 'locale' => null, + 'module' => 'Fixture_ModuleOne', + ), + ), + array( + 'source' => '/base/dir/area_one/fixture/theme_two/Fixture_ModuleTwo', + 'destinationContext' => array( + 'area' => 'area_one', + 'themePath' => 'fixture/theme_two', + 'locale' => null, + 'module' => 'Fixture_ModuleTwo', + ), + ), + array( + 'source' => '/base/dir/area_one/fixture/theme_two', + 'destinationContext' => array( + 'area' => 'area_one', + 'themePath' => 'fixture/theme_two', + 'locale' => null, + 'module' => null, + ), + ), + ), + ), + 'theme_customizing_no_modules' => array( + 'theme' => $themeThree, + 'pattern_dir_map' => array( + array('namespace' => '%namespace%', 'module' => '%module%', 'area' => 'area_two', 'theme' => $themeThree), + array( + '/base/dir/area_two/fixture/theme_three', + '/base/dir/area_two/fixture/theme_three/%namespace%_%module%', + ), + ), + 'filesystem_glob_map' => array( + '/base/dir/area_two/fixture/theme_three/', '*_*', array() + ), + 'expected_result' => array( + array( + 'source' => '/base/dir/area_two/fixture/theme_three', + 'destinationContext' => array( + 'area' => 'area_two', + 'themePath' => 'fixture/theme_three', + 'locale' => null, + 'module' => null, + ) + ), + ), + ), + 'fallback_pattern_mixing_slashes' => array( + 'theme' => $themeFour, + 'pattern_dir_map' => array( + array('namespace' => '%namespace%', 'module' => '%module%', 'area' => 'area_two', 'theme' => $themeFour), + array( + '/base/dir/area_two\\fixture\\theme_four', + '/base/dir/area_two\\fixture\\theme_four\\%namespace%_%module%', + ), + ), + 'filesystem_glob_map' => array( + '/base/dir/area_two/fixture/theme_four/', '*_*', array() + ), + 'expected_result' => array( + array( + 'source' => '/base/dir/area_two/fixture/theme_four', + 'destinationContext' => array( + 'area' => 'area_two', + 'themePath' => 'fixture/theme_four', + 'locale' => null, + 'module' => null, + ) + ), + ), + ), +); diff --git a/dev/tools/Di/Code/Scanner/ArrayScanner.php b/dev/tools/Di/Code/Scanner/ArrayScanner.php new file mode 100644 index 0000000000000..7cd45bb3b6549 --- /dev/null +++ b/dev/tools/Di/Code/Scanner/ArrayScanner.php @@ -0,0 +1,46 @@ +_children[$type] = $scanner; + } + + /** + * Scan files + * + * @param array $files + * @return array + */ + public function collectEntities(array $files) + { + $output = array(); + foreach ($this->_children as $type => $scanner) { + $output = array_merge($output, $scanner->collectEntities($files[$type])); + } + $output = array_unique($output); + return $output; + } +} diff --git a/dev/tools/Di/Code/Scanner/DirectoryScanner.php b/dev/tools/Di/Code/Scanner/DirectoryScanner.php new file mode 100644 index 0000000000000..837792c55b84a --- /dev/null +++ b/dev/tools/Di/Code/Scanner/DirectoryScanner.php @@ -0,0 +1,55 @@ +isDir()) { + continue; + } + + foreach ($patterns as $type => $pattern) { + $filePath = str_replace('\\', '/', $file->getRealPath()); + if (preg_match($pattern, $filePath)) { + $output[$type][] = $filePath; + break; + } + } + } + return $output; + } +} diff --git a/dev/tools/Di/Code/Scanner/FileScanner.php b/dev/tools/Di/Code/Scanner/FileScanner.php new file mode 100644 index 0000000000000..ed6ad0f32a037 --- /dev/null +++ b/dev/tools/Di/Code/Scanner/FileScanner.php @@ -0,0 +1,67 @@ +_prepareContent($content); + $matches = array(); + if (preg_match_all($this->_pattern, $content, $matches)) { + $output = array_merge($output, $matches[1]); + } + } + $output = array_unique($output); + return $output; + } + + /** + * Prepare file content + * + * @param string $content + * @return string + */ + protected function _prepareContent($content) + { + return $content; + } +} diff --git a/dev/tools/Di/Code/Scanner/PhpScanner.php b/dev/tools/Di/Code/Scanner/PhpScanner.php new file mode 100644 index 0000000000000..76298b8e1f3d9 --- /dev/null +++ b/dev/tools/Di/Code/Scanner/PhpScanner.php @@ -0,0 +1,64 @@ +]{1}([A-Z]{1}[a-zA-Z0-9]*_[A-Z]{1}[a-zA-Z0-9_]*(Proxy|Factory))[\n\'"<>]{1}/'; + + /** + * Prepare xml file content + * + * @param string $content + * @return string + */ + protected function _prepareContent($content) + { + $dom = new \DOMDocument(); + $dom->loadXML($content); + + $xpath = new \DOMXPath($dom); + /** @var $comment \DOMComment */ + foreach ($xpath->query('//comment()') as $comment) { + $comment->parentNode->removeChild($comment); + } + $output = $dom->saveXML(); + + return $output; + } +} diff --git a/dev/tools/Di/Compiler/Directory.php b/dev/tools/Di/Compiler/Directory.php new file mode 100644 index 0000000000000..c7d3a302ecd22 --- /dev/null +++ b/dev/tools/Di/Compiler/Directory.php @@ -0,0 +1,108 @@ +_log = $log; + set_error_handler(array($this, 'errorHandler'), E_STRICT); + } + + /** + * @param int $errno + * @param string $errstr + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function errorHandler($errno, $errstr) + { + $this->_log->add(Log::COMPILATION_ERROR, $this->_current, $errstr); + } + + /** + * @param string $path + */ + public function compile($path) + { + $rdi = new \RecursiveDirectoryIterator(realpath($path)); + $recursiveIterator = new \RecursiveIteratorIterator($rdi, 1); + /** @var $item \SplFileInfo */ + foreach ($recursiveIterator as $item) { + if ($item->isFile() && pathinfo($item->getRealPath(), PATHINFO_EXTENSION) == 'php') { + $fileScanner = new FileScanner($item->getRealPath()); + $classNames = $fileScanner->getClassNames(); + foreach ($classNames as $className) { + $this->_current = $className; + if (!class_exists($className)) { + require_once $item->getRealPath(); + } + try { + $signatureReader = new \Magento_Code_Reader_ClassReader(); + $this->_definitions[$className] = $signatureReader->getConstructor($className); + } catch (\ReflectionException $e) { + $this->_log->add(Log::COMPILATION_ERROR, $className, $e->getMessage()); + } + $this->_processedClasses[$className] = 1; + } + } + } + } + + /** + * Retrieve compilation result + * + * @return array + */ + public function getResult() + { + return $this->_definitions; + } +} diff --git a/dev/tools/Di/Compiler/Log/Log.php b/dev/tools/Di/Compiler/Log/Log.php new file mode 100644 index 0000000000000..874ca1918971f --- /dev/null +++ b/dev/tools/Di/Compiler/Log/Log.php @@ -0,0 +1,74 @@ +_writer = $writer; + } + + /** + * Add log message + * + * @param string $type + * @param string $key + * @param string $message + */ + public function add($type, $key, $message = '') + { + $this->_entries[$type][$key][] = $message; + } + + /** + * Write entries + */ + public function report() + { + $this->_writer->write($this->_entries); + } +} diff --git a/dev/tools/Di/Compiler/Log/Writer/Console.php b/dev/tools/Di/Compiler/Log/Writer/Console.php new file mode 100644 index 0000000000000..5a87701e4e7fb --- /dev/null +++ b/dev/tools/Di/Compiler/Log/Writer/Console.php @@ -0,0 +1,60 @@ + 'Generated classes:', + Log::GENERATION_ERROR => 'Errors during class generation:', + Log::COMPILATION_ERROR => 'Errors during compilation:' + ); + + /** + * Output log data + * + * @param array $data + */ + public function write(array $data) + { + foreach ($data as $type => $classes) { + echo $this->_messages[$type] . "\n"; + foreach ($classes as $className => $messages) { + echo "\t" . $className . "\n"; + if (count($messages)) { + foreach ($messages as $message) { + if ($message) { + echo "\t\t - " . $message . "\n"; + } + } + } + } + } + } +} diff --git a/dev/tools/Di/Compiler/Log/Writer/Quiet.php b/dev/tools/Di/Compiler/Log/Writer/Quiet.php new file mode 100644 index 0000000000000..725c726377bc0 --- /dev/null +++ b/dev/tools/Di/Compiler/Log/Writer/Quiet.php @@ -0,0 +1,36 @@ +_serializer = $serializer; + } + + /** + * Compress array definitions + * + * @param array $definitions + * @return mixed + */ + public function compress(array $definitions) + { + $signatureList = new Compressor\UniqueList(); + $resultDefinitions = array(); + foreach ($definitions as $className => $definition) { + $resultDefinitions[$className] = null; + if ($definition && count($definition)) { + $resultDefinitions[$className] = $signatureList->getNumber($definition); + } + } + + $signatures = $signatureList->asArray(); + foreach ($signatures as $key => $signature) { + $signatures[$key] = $this->_serializer->serialize($signature); + } + return $this->_serializer->serialize(array($signatures, $resultDefinitions)); + } +} diff --git a/dev/tools/Di/Definition/Compressor/UniqueList.php b/dev/tools/Di/Definition/Compressor/UniqueList.php new file mode 100644 index 0000000000000..40b6c97d994e7 --- /dev/null +++ b/dev/tools/Di/Definition/Compressor/UniqueList.php @@ -0,0 +1,60 @@ +_items)) { + return array_search($item, $this->_items); + } else { + $this->_items[] = $item; + return count($this->_items) - 1; + } + } + + /** + * Represent list as array + * + * @return array + */ + public function asArray() + { + return $this->_items; + } +} diff --git a/dev/tools/Di/Definition/Reader.php b/dev/tools/Di/Definition/Reader.php new file mode 100644 index 0000000000000..7a2290c87ef83 --- /dev/null +++ b/dev/tools/Di/Definition/Reader.php @@ -0,0 +1,56 @@ +getConstructor(); + if ($constructor) { + $result = array(); + /** @var $parameter \ReflectionParameter */ + foreach ($constructor->getParameters() as $parameter) { + $result[] = array( + $parameter->getName(), + ($parameter->getClass() !== null) ? $parameter->getClass()->getName() : null, + !$parameter->isOptional(), + $parameter->isOptional() ? + $parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null : + null + ); + } + } + return $result; + } +} diff --git a/dev/tools/Di/Definition/Serializer/Igbinary.php b/dev/tools/Di/Definition/Serializer/Igbinary.php new file mode 100644 index 0000000000000..1d689b22e0467 --- /dev/null +++ b/dev/tools/Di/Definition/Serializer/Igbinary.php @@ -0,0 +1,45 @@ + BP, - Mage::PARAM_BAN_CACHE => true - )), BP); - $this->_config = $objectManager->get('Mage_Core_Model_Config'); - - $this->_initCommonDependencies(); - } - - /** - * Compile module definitions - * - * @param string $moduleDir - * @return array - */ - public function compileModule($moduleDir) - { - $moduleDefinitions = $this->_compileModuleDefinitions($moduleDir); - $this->_removeModelAndBlockConstructors($moduleDefinitions); - - array_walk($moduleDefinitions, function (&$item) - { - unset($item['supertypes']); - }); - - return $moduleDefinitions; - } - - /** - * Check is module enabled - * - * @param string $moduleName - * @return bool - */ - public function isModuleEnabled($moduleName) - { - return $this->_config->isModuleEnabled($moduleName); - } - - /** - * Init list of common dependencies of model and block abstract classes - * - * @return ArrayDefinitionCompiler - */ - protected function _initCommonDependencies() - { - $classList = array( - self::ABSTRACT_MODEL, - self::ABSTRACT_BLOCK - ); - - foreach ($classList as $className) { - $this->_constructorList[$className] = new ReflectionMethod($className, '__construct'); - - /** @var $param ReflectionParameter */ - foreach ($this->_constructorList[$className]->getParameters() as $param) { - if ($param->getClass() && !in_array($param->getClass()->getName(), $this->_commonDependencies)) { - $this->_commonDependencies[] = $param->getClass()->getName(); - } - } - } - - return $this; - } - - /** - * Compile definitions using Magento_Di_Definition_CompilerDefinition_Zend - * - * @param string $moduleDir - * @return array - */ - protected function _compileModuleDefinitions($moduleDir) - { - $strategy = new \Zend\Di\Definition\IntrospectionStrategy(new \Zend\Code\Annotation\AnnotationManager()); - $strategy->setMethodNameInclusionPatterns(array()); - $strategy->setInterfaceInjectionInclusionPatterns(array()); - - $compiler = new Magento_Di_Definition_CompilerDefinition_Zend($strategy); - $compiler->addDirectory($moduleDir); - - $controllerPath = $moduleDir . '/controllers/'; - if (file_exists($controllerPath)) { - /** @var $file DirectoryIterator */ - foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($controllerPath)) as $file) { - if (!$file->isDir()) { - require_once $file->getPathname(); - } - } - } - - $compiler->compile(); - $moduleDefinitions = $compiler->toArray(); - - return $moduleDefinitions; - } - - /** - * Remove model and block constructors - * - * @see Zend\Di\Di::newInstance() - * @param $moduleDefinitions - */ - protected function _removeModelAndBlockConstructors(&$moduleDefinitions) - { - foreach ($moduleDefinitions as $name => $definition) { - if (!$this->_hasConstructorParams($name, $definition) - || $this->_areConstructorParamsEquals(self::ABSTRACT_MODEL, $definition) - || $this->_areConstructorParamsEquals(self::ABSTRACT_BLOCK, $definition) - ) { - unset($moduleDefinitions[$name]); - } - } - } - - /** - * Check if class has constructor params - * - * For cases when *_Model_* found function will return true, because such classes must be in compiled array. - * - * @param $className - * @param $definition - * @return bool - */ - protected function _hasConstructorParams($className, $definition) - { - $constructorParams = array(); - if (isset($definition['parameters']['__construct'])) { - $constructorParams = array_values($definition['parameters']['__construct']); - } - - $paramNumber = count($constructorParams); - if (!$paramNumber && in_array($className, $this->_commonDependencies)) { - return true; - } - - return (bool) $paramNumber; - } - - /** - * Check is class constructor params are same as in abstract - * - * @param string $className - * @param array $definition - * @return bool - */ - protected function _areConstructorParamsEquals($className, $definition) - { - if (!isset($this->_constructorList[$className])) { - $this->_constructorList[$className] = new ReflectionMethod($className, '__construct'); - } - - if (isset($definition['supertypes']) && isset($definition['parameters']['__construct'])) { - foreach ($definition['supertypes'] as $type) { - if (($type == $className) - && (count($definition['parameters']['__construct']) == - count($this->_constructorList[$className]->getParameters()) - ) - ) { - return $this->_compareConstructorParams($definition['parameters']['__construct'], - $this->_constructorList[$className]->getParameters() - ); - } - } - } - - return false; - } - - /** - * Compare constructors params - * - * @param array $classArguments - * @param ReflectionParameter[] $abstractArguments - * @return bool - */ - protected function _compareConstructorParams($classArguments, $abstractArguments) - { - $index = 0; - foreach ($classArguments as $argumentInfo) { - $argumentType = null; - if ($abstractArguments[$index]->getClass()) { - $argumentType = $abstractArguments[$index]->getClass()->getName(); - } - if ($argumentInfo[1] != $argumentType) { - return false; - } - $index++; - } - return true; - } -} - -$definitions = array(); -$compiler = new ArrayDefinitionCompiler(); - -foreach (glob(BP . '/app/code/*') as $codePoolDir) { - foreach (glob($codePoolDir . '/*') as $vendorDir) { - foreach (glob($vendorDir . '/*') as $moduleDir) { - $moduleName = basename($vendorDir) . '_' . basename($moduleDir); - if (is_dir($moduleDir) && $compiler->isModuleEnabled($moduleName)) { - echo "Compiling module " . $moduleName . "\n"; - $definitions = array_merge_recursive($definitions, $compiler->compileModule($moduleDir)); - } - } - } -} - -echo "Compiling Varien\n"; -$definitions = array_merge_recursive($definitions, $compiler->compileModule(BP . '/lib/Varien')); -echo "Compiling Magento\n"; -$definitions = array_merge_recursive($definitions, $compiler->compileModule(BP . '/lib/Magento')); -echo "Compiling Mage\n"; -$definitions = array_merge_recursive($definitions, $compiler->compileModule(BP . '/lib/Mage')); -if (is_readable(BP . '/var/generation')) { - echo "Compiling generated entities\n"; - $definitions = array_merge_recursive($definitions, $compiler->compileModule(BP . '/var/generation')); -} -foreach ($definitions as $key => $definition) { - $definitions[$key] = json_encode($definition); -} -if (!file_exists(BP . '/var/di/')) { - mkdir(BP . '/var/di', 0777, true); -} - -file_put_contents(BP . '/var/di/definitions.php', serialize($definitions)); diff --git a/dev/tools/di/entity_generator.php b/dev/tools/di/entity_generator.php deleted file mode 100644 index 10b0a38afa816..0000000000000 --- a/dev/tools/di/entity_generator.php +++ /dev/null @@ -1,60 +0,0 @@ -getGeneratedEntities(); -if (!isset($argv[1]) || in_array($argv[1], array('-?', '/?', '-help', '--help'))) { - $message = " * Usage: php entity_generator.php [" . implode('|', $generatedEntities) - . "] \n" - . " * Example: php entity_generator.php factory Mage_Tag_Model_Tag" - . " - will generate file var/generation/Mage/Tag/Model/TagFactory.php\n"; - print($message); - exit(); -} - -$entityType = $argv[1]; -if (!in_array($argv[1], $generatedEntities)) { - print "Error! Unknown entity type.\n"; - exit(); -} - -if (!isset($argv[2])) { - print "Error! Please, specify class name.\n"; - exit(); -} -$className = $argv[2] . ucfirst($entityType); - -try { - if ($generator->generateClass($className)) { - print("Class {$className} was successfully generated.\n"); - } else { - print("Can't generate class {$className}. This class either not generated entity, or it already exists.\n"); - } -} catch (Magento_Exception $e) { - print("Error! {$e->getMessage()}\n"); -} diff --git a/dev/tools/migration/System/Configuration/Generator.php b/dev/tools/migration/System/Configuration/Generator.php index caac333784777..34639459789a6 100644 --- a/dev/tools/migration/System/Configuration/Generator.php +++ b/dev/tools/migration/System/Configuration/Generator.php @@ -66,7 +66,7 @@ public function __construct( $this->_basePath = realpath(dirname(__FILE__) . '/../../../../../'); $this->_fileSchemaPath = $this->_basePath - . '/app/code/core/Mage/Backend/etc/system_file.xsd'; + . '/app/code/Mage/Backend/etc/system_file.xsd'; } /** diff --git a/dev/tools/migration/aliases_map/composite_modules_ce.php b/dev/tools/migration/aliases_map/composite_modules_ce.php index 82ca6e11af927..e4d8b7ad914af 100644 --- a/dev/tools/migration/aliases_map/composite_modules_ce.php +++ b/dev/tools/migration/aliases_map/composite_modules_ce.php @@ -29,8 +29,8 @@ */ require_once realpath(dirname(dirname(dirname(dirname(__DIR__))))) - . '/app/code/core/Mage/Core/Model/Resource/Setup.php'; + . '/app/code/Mage/Core/Model/Resource/Setup.php'; require_once realpath(dirname(dirname(dirname(dirname(__DIR__))))) - . '/app/code/core/Mage/Core/Model/Resource/Setup/Migration.php'; + . '/app/code/Mage/Core/Model/Resource/Setup/Migration.php'; return Mage_Core_Model_Resource_Setup_Migration::getCompositeModules(); diff --git a/dev/tools/migration/themes_view.php b/dev/tools/migration/themes_view.php index febc8a3b3078f..b118dd9d06421 100644 --- a/dev/tools/migration/themes_view.php +++ b/dev/tools/migration/themes_view.php @@ -23,9 +23,7 @@ * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - require_once __DIR__ . '/../../../app/bootstrap.php'; -Mage::setIsDeveloperMode(true); try { Mage::getConfig()->cleanCache(); diff --git a/dev/tools/view/Generator/Config.php b/dev/tools/view/Generator/Config.php new file mode 100644 index 0000000000000..706abe07fd4db --- /dev/null +++ b/dev/tools/view/Generator/Config.php @@ -0,0 +1,109 @@ +getDir(Mage_Core_Model_Dir::STATIC_VIEW); + } + if (!is_dir($destinationDir)) { + throw new Magento_Exception('Destination directory does not exist: ' . $destinationDir); + } + if (glob($destinationDir . DIRECTORY_SEPARATOR . '*')) { + throw new Magento_Exception("Destination directory must be empty: {$destinationDir}"); + } + + $isDryRun = isset($cmdOptions['dry-run']); + + // Assign to internal values + $this->_sourceDir = $sourceDir; + $this->_destinationDir = $destinationDir; + $this->_isDryRun = $isDryRun; + } + + /** + * Return configured source path + * + * @return string + */ + public function getSourceDir() + { + return $this->_sourceDir; + } + + /** + * Return configured destination path + * + * @return string + */ + public function getDestinationDir() + { + return $this->_destinationDir; + } + + /** + * Return, whether dry run is turned on + * + * @return bool + */ + public function isDryRun() + { + return $this->_isDryRun; + } +} diff --git a/dev/tools/view/Generator/CopyRule.php b/dev/tools/view/Generator/CopyRule.php new file mode 100644 index 0000000000000..e16f9aa1652ca --- /dev/null +++ b/dev/tools/view/Generator/CopyRule.php @@ -0,0 +1,175 @@ +_filesystem = $filesystem; + $this->_themes = $themes; + $this->_fallbackRule = $fallbackRule; + } + + /** + * Get rules for copying static view files + * returns array( + * array('source' => , 'destinationContext' => ), + * ...... + * ) + * + * @return array + */ + public function getCopyRules() + { + $params = array( + 'namespace' => $this->_composePlaceholder('namespace'), + 'module' => $this->_composePlaceholder('module'), + ); + $result = array(); + /** @var $theme Mage_Core_Model_ThemeInterface */ + foreach ($this->_themes as $theme) { + $area = $theme->getArea(); + $params['area'] = $area; + $params['theme'] = $theme; + $patternDirs = $this->_fallbackRule->getPatternDirs($params); + foreach (array_reverse($patternDirs) as $pattern) { + $pattern = Magento_Filesystem::fixSeparator($pattern); + foreach ($this->_getMatchingDirs($pattern) as $srcDir) { + $paramsFromDir = $this->_parsePlaceholders($srcDir, $pattern); + if (!empty($paramsFromDir['namespace']) && !empty($paramsFromDir['module'])) { + $module = $paramsFromDir['namespace'] . '_' . $paramsFromDir['module']; + } else { + $module = null; + } + + $destinationContext = array( + 'area' => $area, + 'themePath' => $theme->getThemePath(), + 'locale' => null, // Temporary locale is not taken into account + 'module' => $module + ); + + $result[] = array( + 'source' => $srcDir, + 'destinationContext' => $destinationContext, + ); + } + } + } + return $result; + } + + /** + * Compose a named placeholder that does not require escaping when directly used in a PCRE + * + * @param string $name + * @return string + */ + private function _composePlaceholder($name) + { + return '%' . $name . '%'; + } + + /** + * Retrieve absolute directory paths matching a pattern with placeholders + * + * @param string $dirPattern + * @return array + */ + private function _getMatchingDirs($dirPattern) + { + $patternGlob = preg_replace($this->_placeholderPcre, '*', $dirPattern, -1, $placeholderCount); + if ($placeholderCount) { + // autodetect pattern base directory because the filesystem interface requires it + $firstPlaceholderPos = strpos($patternGlob, '*'); + $patternBaseDir = substr($patternGlob, 0, $firstPlaceholderPos); + $patternTrailing = substr($patternGlob, $firstPlaceholderPos); + $paths = $this->_filesystem->searchKeys($patternBaseDir, $patternTrailing); + } else { + // pattern is already a valid path containing no placeholders + $paths = array($dirPattern); + } + $result = array(); + foreach ($paths as $path) { + if ($this->_filesystem->isDirectory($path)) { + $result[] = $path; + } + } + return $result; + } + + /** + * Retrieve placeholder values + * + * @param string $subject + * @param string $pattern + * @return array + */ + private function _parsePlaceholders($subject, $pattern) + { + $pattern = preg_quote($pattern, '#'); + $parserPcre = '#^' . preg_replace($this->_placeholderPcre, '(?P<\\1>.+?)', $pattern) . '$#'; + if (preg_match($parserPcre, $subject, $placeholders)) { + return $placeholders; + } + return array(); + } +} diff --git a/dev/tools/view/Generator/ThemeDeployment.php b/dev/tools/view/Generator/ThemeDeployment.php new file mode 100644 index 0000000000000..8ec977ba4e8c1 --- /dev/null +++ b/dev/tools/view/Generator/ThemeDeployment.php @@ -0,0 +1,321 @@ + ext, so lookup by hash is possible. + * + * @var array + */ + private $_permitted = array(); + + /** + * List of extensions for files, which must not be deployed + * For efficiency it is a map of ext => ext, so lookup by hash is possible. + * + * @var array + */ + private $_forbidden = array(); + + /** + * Whether to actually do anything inside the filesystem + * + * @var bool + */ + private $_isDryRun; + + /** + * Constructor + * + * @param string $destinationHomeDir + * @param string $configPermitted + * @param string|null $configForbidden + * @param bool $isDryRun + * @throws Magento_Exception + */ + public function __construct($destinationHomeDir, $configPermitted, $configForbidden = null, $isDryRun = false) + { + $this->_destinationHomeDir = $destinationHomeDir; + $this->_isDryRun = $isDryRun; + $this->_permitted = $this->_loadConfig($configPermitted); + if ($configForbidden) { + $this->_forbidden = $this->_loadConfig($configForbidden); + } + $conflicts = array_intersect($this->_permitted, $this->_forbidden); + if ($conflicts) { + $message = 'Conflicts: the following extensions are added both to permitted and forbidden lists: %s'; + throw new Magento_Exception(sprintf($message, implode(', ', $conflicts))); + } + } + + /** + * Load config with file extensions + * + * @param string $path + * @return array + * @throws Magento_Exception + */ + protected function _loadConfig($path) + { + if (!file_exists($path)) { + throw new Magento_Exception("Config file does not exist: {$path}"); + } + + $contents = include($path); + $contents = array_unique($contents); + $contents = array_map('strtolower', $contents); + $contents = $contents ? array_combine($contents, $contents) : array(); + return $contents; + } + + /** + * Copy all the files according to $copyRules + * + * @param array $copyRules + */ + public function run($copyRules) + { + foreach ($copyRules as $copyRule) { + $destinationContext = $copyRule['destinationContext']; + $context = array( + 'source' => $copyRule['source'], + 'destinationContext' => $destinationContext, + ); + + $destDir = Mage_Core_Model_Design_Package::getPublishedViewFileRelPath( + $destinationContext['area'], + $destinationContext['themePath'], + $destinationContext['locale'], + '', + $destinationContext['module'] + ); + $destDir = rtrim($destDir, '\\/'); + + $this->_copyDirStructure( + $copyRule['source'], + $this->_destinationHomeDir . DIRECTORY_SEPARATOR . $destDir, + $context + ); + } + } + + + /** + * Copy dir structure and files from $sourceDir to $destinationDir + * + * @param string $sourceDir + * @param string $destinationDir + * @param array $context + * @throws Magento_Exception + */ + protected function _copyDirStructure($sourceDir, $destinationDir, $context) + { + $files = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($sourceDir, RecursiveDirectoryIterator::SKIP_DOTS) + ); + foreach ($files as $fileSource) { + $fileSource = (string) $fileSource; + $extension = strtolower(pathinfo($fileSource, PATHINFO_EXTENSION)); + + if (isset($this->_forbidden[$extension])) { + continue; + } + + if (!isset($this->_permitted[$extension])) { + $message = sprintf( + 'The file extension "%s" must be added either to the permitted or forbidden list. File: %s', + $extension, + $fileSource + ); + throw new Magento_Exception($message); + } + + $fileDestination = $destinationDir . substr($fileSource, strlen($sourceDir)); + $this->_deployFile($fileSource, $fileDestination, $context); + } + } + + /** + * Deploy file to the destination path, also processing modular paths inside css-files. + * + * @param string $fileSource + * @param string $fileDestination + * @param array $context + */ + protected function _deployFile($fileSource, $fileDestination, $context) + { + $context['fileSource'] = $fileSource; + $context['fileDestination'] = $fileDestination; + + // Create directory + $dir = dirname($fileDestination); + if (!is_dir($dir) && !$this->_isDryRun) { + mkdir($dir, 0777, true); + } + + // Copy file + $extension = pathinfo($fileSource, PATHINFO_EXTENSION); + if (strtolower($extension) == 'css') { + // For CSS files we need to replace modular urls + $content = $this->_processCssContent($fileSource, $context); + if (!$this->_isDryRun) { + file_put_contents($fileDestination, $content); + } + } else { + if (!$this->_isDryRun) { + copy($fileSource, $fileDestination); + } + } + } + + /** + * Processes CSS file contents, replacing modular urls to the appropriate values + * + * @param string $fileSource + * @param array $context + * @return string + */ + protected function _processCssContent($fileSource, $context) + { + $content = file_get_contents($fileSource); + $relativeUrls = $this->_extractModuleUrls($content); + foreach ($relativeUrls as $urlNotation => $moduleUrl) { + $fileUrlNew = $this->_expandModuleUrl($moduleUrl, $context); + $urlNotationNew = str_replace($moduleUrl, $fileUrlNew, $urlNotation); + $content = str_replace($urlNotation, $urlNotationNew, $content); + } + return $content; + } + + /** + * Extract module urls (e.g. Mage_Cms::images/something.png) from the css file content + * + * @param string $cssContent + * @return array + */ + protected function _extractModuleUrls($cssContent) + { + preg_match_all(Mage_Core_Model_Design_Package::REGEX_CSS_RELATIVE_URLS, $cssContent, $matches); + if (empty($matches[0]) || empty($matches[1])) { + return array(); + } + $relativeUrls = array_combine($matches[0], $matches[1]); + + // Leave only modular urls + foreach ($relativeUrls as $key => $relativeUrl) { + if (!strpos($relativeUrl, Mage_Core_Model_Design_Package::SCOPE_SEPARATOR)) { + unset($relativeUrls[$key]); + } + } + + return $relativeUrls; + } + + /** + * Changes module url to normal relative url (it will be relative to the destination file location) + * + * @param string $moduleUrl + * @param array $context + * @return string + */ + protected function _expandModuleUrl($moduleUrl, $context) + { + $fileDestination = $context['fileDestination']; + $destinationContext = $context['destinationContext']; + + list($module, $file) = $this->_extractModuleAndFile($moduleUrl); + $relPath = Mage_Core_Model_Design_Package::getPublishedViewFileRelPath( + $destinationContext['area'], $destinationContext['themePath'], $destinationContext['locale'], $file, $module + ); + $relatedFile = $this->_destinationHomeDir . DIRECTORY_SEPARATOR . $relPath; + + return $this->_composeUrlOffset($relatedFile, $fileDestination); + } + + /** + * Divides module url into module name and file path. + * + * @param string $moduleUrl + * @return array + * @throws Magento_Exception + */ + protected function _extractModuleAndFile($moduleUrl) + { + $parts = explode(Mage_Core_Model_Design_Package::SCOPE_SEPARATOR, $moduleUrl); + if ((count($parts) != 2) || !strlen($parts[0]) || !strlen($parts[1])) { + throw new Magento_Exception("Wrong module url: {$moduleUrl}"); + } + return $parts; + } + + /** + * Returns url offset to $filePath as relative to $baseFilePath + * + * @param string $filePath + * @param string $baseFilePath + * @return string + */ + protected function _composeUrlOffset($filePath, $baseFilePath) + { + $filePath = str_replace('\\', '/', $filePath); + $baseFilePath = str_replace('\\', '/', $baseFilePath); + + $partsFile = explode('/', dirname($filePath)); + $partsBase = explode('/', dirname($baseFilePath)); + + // Go until paths become different + while (count($partsFile) && count($partsBase) && ($partsFile[0] == $partsBase[0])) { + array_shift($partsFile); + array_shift($partsBase); + } + + // Add '../' for every left level in $partsBase + $relDir = ''; + if (count($partsBase)) { + $relDir = str_repeat('../', count($partsBase)); + } + + // Add subdirs from $partsFile + if (count($partsFile)) { + $relDir .= implode('/', $partsFile) . '/'; + } + + // Return resulting path + return $relDir . basename($filePath); + } +} diff --git a/dev/tools/view/Generator/ThemeLight.php b/dev/tools/view/Generator/ThemeLight.php new file mode 100644 index 0000000000000..28b8972ac5a2e --- /dev/null +++ b/dev/tools/view/Generator/ThemeLight.php @@ -0,0 +1,63 @@ +getData('area'); + } + + /** + * {@inheritdoc} + */ + public function getThemePath() + { + return $this->getData('theme_path'); + } + + /** + * {@inheritdoc} + */ + public function getFullPath() + { + return $this->getArea() . Mage_Core_Model_Theme::PATH_SEPARATOR . $this->getThemePath(); + } + + /** + * {@inheritdoc} + */ + public function getParentTheme() + { + return $this->getData('parent_theme'); + } +} diff --git a/dev/tools/view/config/forbidden.php b/dev/tools/view/config/forbidden.php new file mode 100644 index 0000000000000..3ad94ad057699 --- /dev/null +++ b/dev/tools/view/config/forbidden.php @@ -0,0 +1,37 @@ +] [--destination ] [--dry-run] + php -f generator.php -- --help + + --source Root directory to start search of static view files from. + If omitted, the application root directory is used. + + --destination Directory to copy files to. + If omitted, public location of static view files is used. + + --dry-run Do not create directories and files in a destination path. + + --help Print this usage information. + +USAGE +); + +$options = getopt('', array('help', 'dry-run', 'source:', 'destination:')); +if (isset($options['help'])) { + echo SYNOPSIS; + exit(0); +} + +echo "Deploying...\n"; +try { + $config = new Generator_Config(BP, $options); + + $filesystem = new Magento_Filesystem(new Magento_Filesystem_Adapter_Local); + $dirs = new Mage_Core_Model_Dir($filesystem, $config->getSourceDir()); + $objectManager = new Magento_ObjectManager_ObjectManager(); + + $themes = new Mage_Core_Model_Theme_Collection($filesystem, $objectManager, $dirs); + $themes->setItemObjectClass('Generator_ThemeLight'); + $themes->addDefaultPattern('*'); + + $generator = new Generator_CopyRule($filesystem, $themes, new Mage_Core_Model_Design_Fallback_List_View($dirs)); + $copyRules = $generator->getCopyRules(); + + $deployment = new Generator_ThemeDeployment( + $config->getDestinationDir(), + __DIR__ . '/config/permitted.php', + __DIR__ . '/config/forbidden.php', + $config->isDryRun() + ); + $deployment->run($copyRules); +} catch (Exception $e) { + echo 'Error: ' . $e->getMessage(); + exit(1); +} +echo "Completed successfully."; diff --git a/downloader/lib/Mage/Connect/Package/Target.php b/downloader/lib/Mage/Connect/Package/Target.php index b452ae0440313..cc63c4f45172f 100644 --- a/downloader/lib/Mage/Connect/Package/Target.php +++ b/downloader/lib/Mage/Connect/Package/Target.php @@ -58,9 +58,7 @@ protected function _getTargetMap() { if (is_null($this->_targetMap)) { $this->_targetMap = array(); - $this->_targetMap[] = array('name'=>"magelocal" ,'label'=>"Magento Local module file" , 'uri'=>"./app/code/local"); - $this->_targetMap[] = array('name'=>"magecommunity" ,'label'=>"Magento Community module file" , 'uri'=>"./app/code/community"); - $this->_targetMap[] = array('name'=>"magecore" ,'label'=>"Magento Core team module file" , 'uri'=>"./app/code/core"); + $this->_targetMap[] = array('name'=>"magecore" ,'label'=>"Magento module file" , 'uri'=>"./app/code"); $this->_targetMap[] = array('name'=>"magedesign" ,'label'=>"Magento User Interface (layouts, templates)" , 'uri'=>"./app/design"); $this->_targetMap[] = array('name'=>"mageetc" ,'label'=>"Magento Global Configuration" , 'uri'=>"./app/etc"); $this->_targetMap[] = array('name'=>"magelib" ,'label'=>"Magento PHP Library file" , 'uri'=>"./lib"); diff --git a/downloader/target.xml b/downloader/target.xml index b22dce987279b..21eade7632329 100644 --- a/downloader/target.xml +++ b/downloader/target.xml @@ -26,9 +26,7 @@ */ --> - - - + diff --git a/index.php b/index.php index 66af3179d40ee..7bf6f2ead1e5a 100644 --- a/index.php +++ b/index.php @@ -8,7 +8,7 @@ * $params['MAGE_RUN_CODE'] = 'website2'; * $params['MAGE_RUN_TYPE'] = 'website'; * ... - * new Mage_Core_Model_EntryPoint_Http(BP, $params) + * $entryPoint = new Mage_Core_Model_EntryPoint_Http(new Mage_Core_Model_Config_Primary(BP, $params)); * -------------------------------------------- * * Magento @@ -35,6 +35,6 @@ require __DIR__ . '/app/bootstrap.php'; Magento_Profiler::start('mage'); -$entryPoint = new Mage_Core_Model_EntryPoint_Http(BP, $_SERVER); +$entryPoint = new Mage_Core_Model_EntryPoint_Http(new Mage_Core_Model_Config_Primary(BP, $_SERVER)); $entryPoint->processRequest(); Magento_Profiler::stop('mage'); diff --git a/lib/Mage/Connect/Package/Target.php b/lib/Mage/Connect/Package/Target.php index d602ddc33f9c6..aa3a61dc288ab 100644 --- a/lib/Mage/Connect/Package/Target.php +++ b/lib/Mage/Connect/Package/Target.php @@ -58,9 +58,7 @@ protected function _getTargetMap() { if (is_null($this->_targetMap)) { $this->_targetMap = array(); - $this->_targetMap[] = array('name'=>"magelocal" ,'label'=>"Magento Local module file" , 'uri'=>"./app/code/local"); - $this->_targetMap[] = array('name'=>"magecommunity" ,'label'=>"Magento Community module file" , 'uri'=>"./app/code/community"); - $this->_targetMap[] = array('name'=>"magecore" ,'label'=>"Magento Core team module file" , 'uri'=>"./app/code/core"); + $this->_targetMap[] = array('name'=>"magecore" ,'label'=>"Magento module file" , 'uri'=>"./app/code"); $this->_targetMap[] = array('name'=>"magedesign" ,'label'=>"Magento User Interface (layouts, templates)" , 'uri'=>"./app/design"); $this->_targetMap[] = array('name'=>"mageetc" ,'label'=>"Magento Global Configuration" , 'uri'=>"./app/etc"); $this->_targetMap[] = array('name'=>"magelib" ,'label'=>"Magento PHP Library file" , 'uri'=>"./lib"); diff --git a/lib/Magento/Acl/ResourceFactory.php b/lib/Magento/Acl/ResourceFactory.php index abd876f0a6158..74186ca578d9f 100644 --- a/lib/Magento/Acl/ResourceFactory.php +++ b/lib/Magento/Acl/ResourceFactory.php @@ -48,6 +48,6 @@ public function __construct(Magento_ObjectManager $objectManager) */ public function createResource(array $arguments = array()) { - return $this->_objectManager->create(self::RESOURCE_CLASS_NAME, $arguments, false); + return $this->_objectManager->create(self::RESOURCE_CLASS_NAME, $arguments); } } diff --git a/lib/Magento/AclFactory.php b/lib/Magento/AclFactory.php new file mode 100644 index 0000000000000..4c31bb8d1143c --- /dev/null +++ b/lib/Magento/AclFactory.php @@ -0,0 +1,50 @@ +_objectManager = $objectManager; + } + + /** + * Create new magento acl instance + * + * @return Magento_Acl + */ + public function create() + { + return $this->_objectManager->create('Magento_Acl'); + } +} diff --git a/lib/Magento/BootstrapException.php b/lib/Magento/BootstrapException.php old mode 100755 new mode 100644 diff --git a/lib/Magento/Cache/Backend/Decorator/Compression.php b/lib/Magento/Cache/Backend/Decorator/Compression.php new file mode 100644 index 0000000000000..943c2d9741bf8 --- /dev/null +++ b/lib/Magento/Cache/Backend/Decorator/Compression.php @@ -0,0 +1,133 @@ + 512 + ); + + /** + * Test if a cache is available for the given id and (if yes) return it (false else) + * + * Note : return value is always "string" (unserialization is done by the core not by the backend) + * + * @param string $cacheId Cache id + * @param boolean $noTestCacheValidity If set to true, the cache validity won't be tested + * @return string|false cached datas + */ + public function load($cacheId, $noTestCacheValidity = false) + { + $data = $this->_backend->load($cacheId, $noTestCacheValidity); + + if ($data && $this->_isDecompressionNeeded($data)) { + $data = self::_decompressData($data); + } + + return $data; + } + + /** + * Save some string datas into a cache record + * + * Note : $data is always "string" (serialization is done by the + * core not by the backend) + * + * @param string $data Datas to cache + * @param string $cacheId Cache id + * @param array $tags Array of strings, the cache record will be tagged by each string entry + * @param bool $specificLifetime If != false, set a specific lifetime for this cache record + * (null => infinite lifetime) + * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by + * some particular backends + * @return boolean true if no problem + */ + public function save($data, $cacheId, $tags = array(), $specificLifetime = false, $priority = 8) + { + if ($this->_isCompressionNeeded($data)) { + $data = self::_compressData($data); + } + + return $this->_backend->save($data, $cacheId, $tags, $specificLifetime, $priority); + } + + /** + * Compress data and add specific prefix to distinguish compressed and non-compressed data + * + * @param string $data + * @return string + */ + protected static function _compressData($data) + { + return self::COMPRESSION_PREFIX . gzcompress($data); + } + + /** + * Get whether compression is needed + * + * @param string $data + * @return bool + */ + protected function _isCompressionNeeded($data) + { + return (strlen($data) > (int)$this->_decoratorOptions['compression_threshold']); + } + + /** + * Remove special prefix and decompress data + * + * @param string $data + * @return string + */ + protected static function _decompressData($data) + { + return gzuncompress(substr($data, strlen(self::COMPRESSION_PREFIX))); + } + + /** + * Get whether decompression is needed + * + * @param string $data + * @return bool + */ + protected function _isDecompressionNeeded($data) + { + return (strpos($data, self::COMPRESSION_PREFIX) === 0); + } + +} diff --git a/lib/Magento/Cache/Backend/Decorator/DecoratorAbstract.php b/lib/Magento/Cache/Backend/Decorator/DecoratorAbstract.php new file mode 100644 index 0000000000000..21b28de2622d0 --- /dev/null +++ b/lib/Magento/Cache/Backend/Decorator/DecoratorAbstract.php @@ -0,0 +1,322 @@ +_backend = $options['concrete_backend']; + unset($options['concrete_backend']); + } else { + Zend_Cache::throwException( + "'concrete_backend' is not specified or it does not implement 'Zend_Cache_Backend_Interface' interface" + ); + } + foreach ($options as $optionName => $optionValue) { + if (array_key_exists($optionName, $this->_decoratorOptions)) { + $this->_decoratorOptions[$optionName] = $optionValue; + } + } + } + + /** + * Set the frontend directives + * + * @param array $directives assoc of directives + * @return void + */ + public function setDirectives($directives) + { + $this->_backend->setDirectives($directives); + } + + /** + * Test if a cache is available for the given id and (if yes) return it (false else) + * + * Note : return value is always "string" (unserialization is done by the core not by the backend) + * + * @param string $cacheId Cache id + * @param boolean $noTestCacheValidity If set to true, the cache validity won't be tested + * @return string|false cached datas + */ + public function load($cacheId, $noTestCacheValidity = false) + { + return $this->_backend->load($cacheId, $noTestCacheValidity); + } + + /** + * Test if a cache is available or not (for the given id) + * + * @param string $cacheId cache id + * @return mixed|false (a cache is not available) or "last modified" timestamp (int) of the available cache record + */ + public function test($cacheId) + { + return $this->_backend->test($cacheId); + } + + /** + * Save some string datas into a cache record + * + * Note : $data is always "string" (serialization is done by the + * core not by the backend) + * + * @param string $data Datas to cache + * @param string $cacheId Cache id + * @param array $tags Array of strings, the cache record will be tagged by each string entry + * @param bool $specificLifetime If != false, set a specific lifetime for this cache record + * (null => infinite lifetime) + * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by + * some particular backends + * @return boolean true if no problem + */ + public function save($data, $cacheId, $tags = array(), $specificLifetime = false, $priority = 8) + { + return $this->_backend->save($data, $cacheId, $tags, $specificLifetime, $priority); + } + + /** + * Remove a cache record + * + * @param string $cacheId Cache id + * @return boolean True if no problem + */ + public function remove($cacheId) + { + return $this->_backend->remove($cacheId); + } + + /** + * Clean some cache records + * + * Available modes are : + * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) + * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) + * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags + * ($tags can be an array of strings or a single string) + * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags} + * ($tags can be an array of strings or a single string) + * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags + * ($tags can be an array of strings or a single string) + * + * @param string $mode Clean mode + * @param array $tags Array of tags + * @return boolean true if no problem + */ + public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) + { + return $this->_backend->clean($mode, $tags); + } + + /** + * Return an array of stored cache ids + * + * @return array array of stored cache ids (string) + */ + public function getIds() + { + return $this->_backend->getIds(); + } + + /** + * Return an array of stored tags + * + * @return array array of stored tags (string) + */ + public function getTags() + { + return $this->_backend->getTags(); + } + + /** + * Return an array of stored cache ids which match given tags + * + * In case of multiple tags, a logical AND is made between tags + * + * @param array $tags array of tags + * @return array array of matching cache ids (string) + */ + public function getIdsMatchingTags($tags = array()) + { + return $this->_backend->getIdsMatchingTags($tags); + } + + /** + * Return an array of stored cache ids which don't match given tags + * + * In case of multiple tags, a logical OR is made between tags + * + * @param array $tags array of tags + * @return array array of not matching cache ids (string) + */ + public function getIdsNotMatchingTags($tags = array()) + { + return $this->_backend->getIdsNotMatchingTags($tags); + } + + /** + * Return an array of stored cache ids which match any given tags + * + * In case of multiple tags, a logical AND is made between tags + * + * @param array $tags array of tags + * @return array array of any matching cache ids (string) + */ + public function getIdsMatchingAnyTags($tags = array()) + { + return $this->_backend->getIdsMatchingAnyTags($tags); + } + + /** + * Return the filling percentage of the backend storage + * + * @return int integer between 0 and 100 + */ + public function getFillingPercentage() + { + return $this->_backend->getFillingPercentage(); + } + + /** + * Return an array of metadatas for the given cache id + * + * The array must include these keys : + * - expire : the expire timestamp + * - tags : a string array of tags + * - mtime : timestamp of last modification time + * + * @param string $cacheId cache id + * @return array array of metadatas (false if the cache id is not found) + */ + public function getMetadatas($cacheId) + { + return $this->_backend->getMetadatas($cacheId); + } + + /** + * Give (if possible) an extra lifetime to the given cache id + * + * @param string $cacheId cache id + * @param int $extraLifetime + * @return boolean true if ok + */ + public function touch($cacheId, $extraLifetime) + { + return $this->_backend->touch($cacheId, $extraLifetime); + } + + /** + * Return an associative array of capabilities (booleans) of the backend + * + * The array must include these keys : + * - automatic_cleaning (is automating cleaning necessary) + * - tags (are tags supported) + * - expired_read (is it possible to read expired cache records + * (for doNotTestCacheValidity option for example)) + * - priority does the backend deal with priority when saving + * - infinite_lifetime (is infinite lifetime can work with this backend) + * - get_list (is it possible to get the list of cache ids and the complete list of tags) + * + * @return array associative of with capabilities + */ + public function getCapabilities() + { + return $this->_backend->getCapabilities(); + } + + /** + * Set an option + * + * @param string $name + * @param mixed $value + * @throws Zend_Cache_Exception + * @return void + */ + public function setOption($name, $value) + { + $this->_backend->setOption($name, $value); + } + + /** + * Get the life time + * + * if $specificLifetime is not false, the given specific life time is used + * else, the global lifetime is used + * + * @param int $specificLifetime + * @return int Cache life time + */ + public function getLifetime($specificLifetime) + { + return $this->_backend->getLifetime($specificLifetime); + } + + /** + * Return true if the automatic cleaning is available for the backend + * + * DEPRECATED : use getCapabilities() instead + * + * @deprecated + * @return boolean + */ + public function isAutomaticCleaningAvailable() + { + return $this->_backend->isAutomaticCleaningAvailable(); + } + + /** + * Determine system TMP directory and detect if we have read access + * + * inspired from Zend_File_Transfer_Adapter_Abstract + * + * @return string + * @throws Zend_Cache_Exception if unable to determine directory + */ + public function getTmpDir() + { + return $this->_backend->getTmpDir(); + } +} diff --git a/lib/Magento/Cache/Backend/MongoDb.php b/lib/Magento/Cache/Backend/MongoDb.php index 49d165e1f3354..ca30f10c5c8a5 100644 --- a/lib/Magento/Cache/Backend/MongoDb.php +++ b/lib/Magento/Cache/Backend/MongoDb.php @@ -293,7 +293,7 @@ public function load($cacheId, $notTestCacheValidity = false) ); } $result = $this->_getCollection()->findOne($query, array('data')); - return $result ? $result['data'] : false; + return $result ? $result['data']->bin : false; } /** @@ -336,7 +336,7 @@ public function save($data, $cacheId, $tags = array(), $specificLifetime = false $tags = array_map(array($this, '_quoteString'), $tags); $document = array( '_id' => $this->_quoteString($cacheId), - 'data' => $this->_quoteString($data), + 'data' => new MongoBinData($this->_quoteString($data), MongoBinData::BYTE_ARRAY), 'tags' => $tags, 'mtime' => $time, 'expire' => $expire, diff --git a/lib/Magento/Cache/Frontend/Adapter/Zend.php b/lib/Magento/Cache/Frontend/Adapter/Zend.php new file mode 100644 index 0000000000000..ba028a0fc6ca5 --- /dev/null +++ b/lib/Magento/Cache/Frontend/Adapter/Zend.php @@ -0,0 +1,133 @@ + Zend cache frontend interfaces + */ +class Magento_Cache_Frontend_Adapter_Zend implements Magento_Cache_FrontendInterface +{ + /** + * @var Zend_Cache_Core + */ + protected $_frontend; + + /** + * @param Zend_Cache_Core $frontend + */ + public function __construct(Zend_Cache_Core $frontend) + { + $this->_frontend = $frontend; + } + + /** + * {@inheritdoc} + */ + public function test($identifier) + { + return $this->_frontend->test($this->_unifyId($identifier)); + } + + /** + * {@inheritdoc} + */ + public function load($identifier) + { + return $this->_frontend->load($this->_unifyId($identifier)); + } + + /** + * {@inheritdoc} + */ + public function save($data, $identifier, array $tags = array(), $lifeTime = null) + { + return $this->_frontend->save($data, $this->_unifyId($identifier), $this->_unifyIds($tags), $lifeTime); + } + + /** + * {@inheritdoc} + */ + public function remove($identifier) + { + return $this->_frontend->remove($this->_unifyId($identifier)); + } + + /** + * {@inheritdoc} + * + * @throws InvalidArgumentException Exception is thrown when non-supported cleaning mode is specified + */ + public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, array $tags = array()) + { + // Cleaning modes 'old' and 'notMatchingTag' are prohibited as a trade off for decoration reliability + if (!in_array($mode, array( + Zend_Cache::CLEANING_MODE_ALL, + Zend_Cache::CLEANING_MODE_MATCHING_TAG, + Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, + ))) { + throw new InvalidArgumentException("Magento cache frontend does not support the cleaning mode '$mode'."); + } + return $this->_frontend->clean($mode, $this->_unifyIds($tags)); + } + + /** + * {@inheritdoc} + */ + public function getBackend() + { + return $this->_frontend->getBackend(); + } + + /** + * {@inheritdoc} + */ + public function getLowLevelFrontend() + { + return $this->_frontend; + } + + /** + * Retrieve single unified identifier + * + * @param string $identifier + * @return string + */ + protected function _unifyId($identifier) + { + return strtoupper($identifier); + } + + /** + * Retrieve multiple unified identifiers + * + * @param array $ids + * @return array + */ + protected function _unifyIds(array $ids) + { + foreach ($ids as $key => $value) { + $ids[$key] = $this->_unifyId($value); + } + return $ids; + } +} diff --git a/lib/Magento/Cache/Frontend/Decorator/Bare.php b/lib/Magento/Cache/Frontend/Decorator/Bare.php new file mode 100644 index 0000000000000..53fcc8c12f1f7 --- /dev/null +++ b/lib/Magento/Cache/Frontend/Decorator/Bare.php @@ -0,0 +1,113 @@ +_frontend = $frontend; + } + + /** + * Retrieve cache frontend instance being decorated + * + * @return Magento_Cache_FrontendInterface + */ + protected function _getFrontend() + { + return $this->_frontend; + } + + /** + * {@inheritdoc} + */ + public function test($identifier) + { + return $this->_frontend->test($identifier); + } + + /** + * {@inheritdoc} + */ + public function load($identifier) + { + return $this->_frontend->load($identifier); + } + + /** + * Enforce marking with a tag + * + * {@inheritdoc} + */ + public function save($data, $identifier, array $tags = array(), $lifeTime = null) + { + return $this->_frontend->save($data, $identifier, $tags, $lifeTime); + } + + /** + * {@inheritdoc} + */ + public function remove($identifier) + { + return $this->_frontend->remove($identifier); + } + + /** + * {@inheritdoc} + */ + public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, array $tags = array()) + { + return $this->_frontend->clean($mode, $tags); + } + + /** + * {@inheritdoc} + */ + public function getBackend() + { + return $this->_frontend->getBackend(); + } + + /** + * {@inheritdoc} + */ + public function getLowLevelFrontend() + { + return $this->_frontend->getLowLevelFrontend(); + } +} diff --git a/lib/Magento/Cache/Frontend/Decorator/Profiler.php b/lib/Magento/Cache/Frontend/Decorator/Profiler.php new file mode 100644 index 0000000000000..b5f69fdbe07e3 --- /dev/null +++ b/lib/Magento/Cache/Frontend/Decorator/Profiler.php @@ -0,0 +1,138 @@ +_backendPrefixes = $backendPrefixes; + } + + /** + * Retrieve profiler tags that correspond to a cache operation + * + * @param string $operation + * @return array + */ + protected function _getProfilerTags($operation) + { + return array( + 'group' => 'cache', + 'operation' => 'cache:' . $operation, + 'frontend_type' => get_class($this->getLowLevelFrontend()), + 'backend_type' => $this->_getBackendType(), + ); + } + + /** + * Get short cache backend type name by striping known backend class prefixes + * + * @return string + */ + protected function _getBackendType() + { + $result = get_class($this->getBackend()); + foreach ($this->_backendPrefixes as $backendClassPrefix) { + if (substr($result, 0, strlen($backendClassPrefix)) == $backendClassPrefix) { + $result = substr($result, strlen($backendClassPrefix)); + break; + } + } + return $result; + } + + /** + * {@inheritdoc} + */ + public function test($identifier) + { + Magento_Profiler::start('cache_test', $this->_getProfilerTags('test')); + $result = parent::test($identifier); + Magento_Profiler::stop('cache_test'); + return $result; + } + + /** + * {@inheritdoc} + */ + public function load($identifier) + { + Magento_Profiler::start('cache_load', $this->_getProfilerTags('load')); + $result = parent::load($identifier); + Magento_Profiler::stop('cache_load'); + return $result; + } + + /** + * Enforce marking with a tag + * + * {@inheritdoc} + */ + public function save($data, $identifier, array $tags = array(), $lifeTime = null) + { + Magento_Profiler::start('cache_save', $this->_getProfilerTags('save')); + $result = parent::save($data, $identifier, $tags, $lifeTime); + Magento_Profiler::stop('cache_save'); + return $result; + } + + /** + * {@inheritdoc} + */ + public function remove($identifier) + { + Magento_Profiler::start('cache_remove', $this->_getProfilerTags('remove')); + $result = parent::remove($identifier); + Magento_Profiler::stop('cache_remove'); + return $result; + } + + /** + * {@inheritdoc} + */ + public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, array $tags = array()) + { + Magento_Profiler::start('cache_clean', $this->_getProfilerTags('clean')); + $result = parent::clean($mode, $tags); + Magento_Profiler::stop('cache_clean'); + return $result; + } +} diff --git a/lib/Magento/Cache/Frontend/Decorator/TagMarker.php b/lib/Magento/Cache/Frontend/Decorator/TagMarker.php new file mode 100644 index 0000000000000..503d8aa31125b --- /dev/null +++ b/lib/Magento/Cache/Frontend/Decorator/TagMarker.php @@ -0,0 +1,67 @@ +_tag = $tag; + } + + /** + * Retrieve cache tag name + * + * @return string + */ + public function getTag() + { + return $this->_tag; + } + + /** + * Enforce marking with a tag + * + * {@inheritdoc} + */ + public function save($data, $identifier, array $tags = array(), $lifeTime = null) + { + $tags[] = $this->_tag; + return parent::save($data, $identifier, $tags, $lifeTime); + } +} diff --git a/lib/Magento/Cache/Frontend/Decorator/TagScope.php b/lib/Magento/Cache/Frontend/Decorator/TagScope.php new file mode 100644 index 0000000000000..ce5916b3a99b5 --- /dev/null +++ b/lib/Magento/Cache/Frontend/Decorator/TagScope.php @@ -0,0 +1,56 @@ +getTag(); + if ($mode == Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG) { + $result = false; + foreach ($tags as $tag) { + if (parent::clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array($tag, $enforcedTag))) { + $result = true; + } + } + } else { + if ($mode == Zend_Cache::CLEANING_MODE_ALL) { + $mode = Zend_Cache::CLEANING_MODE_MATCHING_TAG; + $tags = array($enforcedTag); + } else { + $tags[] = $enforcedTag; + } + $result = parent::clean($mode, $tags); + } + return $result; + } +} diff --git a/lib/Magento/Cache/FrontendInterface.php b/lib/Magento/Cache/FrontendInterface.php new file mode 100644 index 0000000000000..11e2363c85e6e --- /dev/null +++ b/lib/Magento/Cache/FrontendInterface.php @@ -0,0 +1,88 @@ +_generator = $generator; + $this->_autoloader = $autoloader ? : new Magento_Autoload_IncludePath(); + $this->_ioObject = $ioObject ? : new Magento_Code_Generator_Io(new Varien_Io_File(), $this->_autoloader); + } + + /** + * @return array + */ + public function getGeneratedEntities() + { + return $this->_generatedEntities; + } + + /** + * @param string $className + * @return string const + * @throws Magento_Exception + */ + public function generateClass($className) + { + // check if source class a generated entity + $entity = null; + $entityName = null; + foreach ($this->_generatedEntities as $entityType) { + $entitySuffix = ucfirst($entityType); + // if $className string ends on $entitySuffix substring + if (strrpos($className, $entitySuffix) === strlen($className) - strlen($entitySuffix)) { + $entity = $entityType; + $entityName = rtrim(substr($className, 0, -1 * strlen($entitySuffix)), '_'); + break; + } + } + if (!$entity || !$entityName) { + return self::GENERATION_ERROR; + } + + // check if file already exists + $autoloader = $this->_autoloader; + if ($autoloader::getFile($className)) { + return self::GENERATION_SKIP; + } + + // generate class file + $this->_initGenerator($entity, $entityName, $className); + if (!$this->_generator->generate()) { + $errors = $this->_generator->getErrors(); + throw new Magento_Exception(implode(' ', $errors)); + } + + // remove generator + $this->_generator = null; + + return self::GENERATION_SUCCESS; + } + + /** + * Get generator by entity type + * + * @param string $entity + * @param string $sourceClassName + * @param string $resultClassName + * @return Magento_Code_Generator_EntityAbstract|Magento_Code_Generator_Factory|Magento_Code_Generator_Proxy + * @throws InvalidArgumentException + */ + protected function _initGenerator($entity, $sourceClassName, $resultClassName) + { + if (!$this->_generator) { + switch ($entity) { + case Magento_Code_Generator_Factory::ENTITY_TYPE: + $this->_generator = new Magento_Code_Generator_Factory($sourceClassName, $resultClassName, + $this->_ioObject + ); + break; + case Magento_Code_Generator_Proxy::ENTITY_TYPE: + $this->_generator = new Magento_Code_Generator_Proxy($sourceClassName, $resultClassName, + $this->_ioObject + ); + break; + default: + throw new InvalidArgumentException('Unknown generation entity.'); + break; + } + } + + return $this->_generator; + } +} diff --git a/lib/Magento/Di/Generator/Class.php b/lib/Magento/Code/Generator/Class.php similarity index 81% rename from lib/Magento/Di/Generator/Class.php rename to lib/Magento/Code/Generator/Class.php index ac337e0f8d22e..59f4faec6ca9b 100644 --- a/lib/Magento/Di/Generator/Class.php +++ b/lib/Magento/Code/Generator/Class.php @@ -19,24 +19,24 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Di + * @package Magento_Code * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Magento_Di_Generator_Class +class Magento_Code_Generator_Class { /** - * @var Magento_Di_Generator + * @var Magento_Code_Generator */ protected $_generator; /** - * @param Magento_Di_Generator $generator + * @param Magento_Code_Generator $generator */ - public function __construct(Magento_Di_Generator $generator = null) + public function __construct(Magento_Code_Generator $generator = null) { - $this->_generator = $generator ?: new Magento_Di_Generator(); + $this->_generator = $generator ?: new Magento_Code_Generator(); } /** @@ -46,6 +46,9 @@ public function __construct(Magento_Di_Generator $generator = null) */ public function generateForConstructor($className) { + if (!class_exists($className)) { + $this->_generator->generateClass($className); + } $reflectionClass = new ReflectionClass($className); if ($reflectionClass->hasMethod('__construct')) { $constructor = $reflectionClass->getMethod('__construct'); diff --git a/lib/Magento/Code/Generator/CodeGenerator/Interface.php b/lib/Magento/Code/Generator/CodeGenerator/Interface.php new file mode 100644 index 0000000000000..464030d49f52b --- /dev/null +++ b/lib/Magento/Code/Generator/CodeGenerator/Interface.php @@ -0,0 +1,66 @@ + 'setShortDescription', + 'longDescription' => 'setLongDescription', + 'tags' => 'setTags' + ); + + /** + * Possible class property options + * + * @var array + */ + protected $_propertyOptions = array( + 'name' => 'setName', + 'const' => 'setConst', + 'static' => 'setStatic', + 'visibility' => 'setVisibility', + 'defaultValue' => 'setDefaultValue', + ); + + /** + * Possible class method options + * + * @var array + */ + protected $_methodOptions = array( + 'name' => 'setName', + 'final' => 'setFinal', + 'static' => 'setStatic', + 'abstract' => 'setAbstract', + 'visibility' => 'setVisibility', + 'body' => 'setBody', + ); + + /** + * Possible method parameter options + * + * @var array + */ + protected $_parameterOptions = array( + 'name' => 'setName', + 'type' => 'setType', + 'defaultValue' => 'setDefaultValue', + 'passedByReference' => 'setPassedByReference' + ); + + /** + * @param object $object + * @param array $data + * @param array $map + * @return void + */ + protected function _setDataToObject($object, array $data, array $map) + { + foreach ($map as $arrayKey => $setterName) { + if (isset($data[$arrayKey])) { + $object->{$setterName}($data[$arrayKey]); + } + } + } + + /** + * Set class dock block + * + * @param array $docBlock + * @return Magento_Code_Generator_CodeGenerator_Zend + */ + public function setClassDocBlock(array $docBlock) + { + $docBlockObject = new Zend\Code\Generator\DocBlockGenerator(); + $this->_setDataToObject($docBlockObject, $docBlock, $this->_docBlockOptions); + + return parent::setDocBlock($docBlockObject); + } + + /** + * addMethods() + * + * @param array $methods + * @return Magento_Code_Generator_CodeGenerator_Zend + */ + public function addMethods(array $methods) + { + foreach ($methods as $methodOptions) { + $methodObject = new Zend\Code\Generator\MethodGenerator(); + $this->_setDataToObject($methodObject, $methodOptions, $this->_methodOptions); + + if (isset($methodOptions['parameters']) && is_array($methodOptions['parameters']) + && count($methodOptions['parameters']) > 0 + ) { + $parametersArray = array(); + foreach ($methodOptions['parameters'] as $parameterOptions) { + $parameterObject = new Zend\Code\Generator\ParameterGenerator(); + $this->_setDataToObject($parameterObject, $parameterOptions, $this->_parameterOptions); + $parametersArray[] = $parameterObject; + } + + $methodObject->setParameters($parametersArray); + } + + if (isset($methodOptions['docblock']) && is_array($methodOptions['docblock'])) { + $docBlockObject = new Zend\Code\Generator\DocBlockGenerator(); + $this->_setDataToObject($docBlockObject, $methodOptions['docblock'], $this->_docBlockOptions); + + $methodObject->setDocBlock($docBlockObject); + } + + $this->addMethodFromGenerator($methodObject); + } + return $this; + } + + /** + * Add method from MethodGenerator + * + * @param Zend\Code\Generator\MethodGenerator $method + * @return Magento_Code_Generator_CodeGenerator_Zend + * @throws InvalidArgumentException + */ + public function addMethodFromGenerator(Zend\Code\Generator\MethodGenerator $method) + { + if (!is_string($method->getName())) { + throw new InvalidArgumentException( + 'addMethodFromGenerator() expects string for name' + ); + } + + return parent::addMethodFromGenerator($method); + } + + /** + * addProperties() + * + * @param array $properties + * @return Magento_Code_Generator_CodeGenerator_Zend + * @throws InvalidArgumentException + */ + public function addProperties(array $properties) + { + foreach ($properties as $propertyOptions) { + $propertyObject = new Zend\Code\Generator\PropertyGenerator(); + $this->_setDataToObject($propertyObject, $propertyOptions, $this->_propertyOptions); + + if (isset($propertyOptions['docblock'])) { + $docBlock = $propertyOptions['docblock']; + if (is_array($docBlock)) { + $docBlockObject = new Zend\Code\Generator\DocBlockGenerator(); + $this->_setDataToObject($docBlockObject, $docBlock, $this->_docBlockOptions); + $propertyObject->setDocBlock($docBlockObject); + } + } + + $this->addPropertyFromGenerator($propertyObject); + } + + return $this; + } + + /** + * Add property from PropertyGenerator + * + * @param Zend\Code\Generator\PropertyGenerator $property + * @throws InvalidArgumentException + * @return Magento_Code_Generator_CodeGenerator_Zend + */ + public function addPropertyFromGenerator(Zend\Code\Generator\PropertyGenerator $property) + { + if (!is_string($property->getName())) { + throw new InvalidArgumentException( + 'addPropertyFromGenerator() expects string for name' + ); + } + + return parent::addPropertyFromGenerator($property); + } +} diff --git a/lib/Magento/Code/Generator/DefinitionDecorator.php b/lib/Magento/Code/Generator/DefinitionDecorator.php new file mode 100644 index 0000000000000..1a9512ccd4b9c --- /dev/null +++ b/lib/Magento/Code/Generator/DefinitionDecorator.php @@ -0,0 +1,85 @@ +_decoratedDefinition = $definition; + $this->_generator = $generator ?: new Magento_Code_Generator_Class(); + } + + /** + * Get list of method parameters + * + * Retrieve an ordered list of constructor parameters. + * Each value is an array with following entries: + * + * array( + * 0, // string: Parameter name + * 1, // string|null: Parameter type + * 2, // bool: whether this param is required + * 3, // mixed: default value + * ); + * + * @param string $className + * @return array|null + */ + public function getParameters($className) + { + if (!array_key_exists($className, $this->_processedClasses)) { + $this->_generator->generateForConstructor($className); + $this->_processedClasses[$className] = 1; + } + return $this->_decoratedDefinition->getParameters($className); + } +} diff --git a/lib/Magento/Di/Generator/EntityAbstract.php b/lib/Magento/Code/Generator/EntityAbstract.php similarity index 93% rename from lib/Magento/Di/Generator/EntityAbstract.php rename to lib/Magento/Code/Generator/EntityAbstract.php index 5ff7980fee6d4..3f70f797754bc 100644 --- a/lib/Magento/Di/Generator/EntityAbstract.php +++ b/lib/Magento/Code/Generator/EntityAbstract.php @@ -19,12 +19,12 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Di + * @package Magento_Code * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -abstract class Magento_Di_Generator_EntityAbstract +abstract class Magento_Code_Generator_EntityAbstract { /** * Entity type @@ -51,7 +51,7 @@ abstract class Magento_Di_Generator_EntityAbstract private $_resultClassName; /** - * @var Magento_Di_Generator_Io + * @var Magento_Code_Generator_Io */ private $_ioObject; @@ -65,22 +65,22 @@ abstract class Magento_Di_Generator_EntityAbstract /** * Class generator object * - * @var Magento_Di_Generator_CodeGenerator_Interface + * @var Magento_Code_Generator_CodeGenerator_Interface */ protected $_classGenerator; /** * @param string $sourceClassName * @param string $resultClassName - * @param Magento_Di_Generator_Io $ioObject - * @param Magento_Di_Generator_CodeGenerator_Interface $classGenerator + * @param Magento_Code_Generator_Io $ioObject + * @param Magento_Code_Generator_CodeGenerator_Interface $classGenerator * @param Magento_Autoload_IncludePath $autoLoader */ public function __construct( $sourceClassName = null, $resultClassName = null, - Magento_Di_Generator_Io $ioObject = null, - Magento_Di_Generator_CodeGenerator_Interface $classGenerator = null, + Magento_Code_Generator_Io $ioObject = null, + Magento_Code_Generator_CodeGenerator_Interface $classGenerator = null, Magento_Autoload_IncludePath $autoLoader = null ) { if ($autoLoader) { @@ -91,12 +91,12 @@ public function __construct( if ($ioObject) { $this->_ioObject = $ioObject; } else { - $this->_ioObject = new Magento_Di_Generator_Io(new Varien_Io_File(), $this->_autoloader); + $this->_ioObject = new Magento_Code_Generator_Io(new Varien_Io_File(), $this->_autoloader); } if ($classGenerator) { $this->_classGenerator = $classGenerator; } else { - $this->_classGenerator = new Magento_Di_Generator_CodeGenerator_Zend(); + $this->_classGenerator = new Magento_Code_Generator_CodeGenerator_Zend(); } $this->_sourceClassName = ltrim($sourceClassName, Magento_Autoload_IncludePath::NS_SEPARATOR); @@ -255,7 +255,7 @@ protected function _generateCode() /** * @param string $message - * @return Magento_Di_Generator_EntityAbstract + * @return Magento_Code_Generator_EntityAbstract */ protected function _addError($message) { diff --git a/lib/Magento/Code/Generator/Factory.php b/lib/Magento/Code/Generator/Factory.php new file mode 100644 index 0000000000000..daeb755eacc91 --- /dev/null +++ b/lib/Magento/Code/Generator/Factory.php @@ -0,0 +1,65 @@ +_getDefaultConstructorDefinition(); + + // public function create(array $data = array()) + $create = array( + 'name' => 'create', + 'parameters' => array( + array('name' => 'data', 'type' => 'array', 'defaultValue' => array()), + ), + 'body' => 'return $this->_objectManager->create(self::CLASS_NAME, $data);', + 'docblock' => array( + 'shortDescription' => 'Create class instance with specified parameters', + 'tags' => array( + array( + 'name' => 'param', + 'description' => 'array $data' + ), + array( + 'name' => 'return', + 'description' => $this->_getFullyQualifiedClassName($this->_getSourceClassName()) + ), + ), + ), + ); + + return array($construct, $create); + } +} diff --git a/lib/Magento/Di/Generator/Io.php b/lib/Magento/Code/Generator/Io.php similarity index 98% rename from lib/Magento/Di/Generator/Io.php rename to lib/Magento/Code/Generator/Io.php index f8a4ccf89ef09..987369775326b 100644 --- a/lib/Magento/Di/Generator/Io.php +++ b/lib/Magento/Code/Generator/Io.php @@ -19,12 +19,12 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Di + * @package Magento_Code * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Magento_Di_Generator_Io +class Magento_Code_Generator_Io { /** * Default code generation directory diff --git a/lib/Magento/Code/Generator/Proxy.php b/lib/Magento/Code/Generator/Proxy.php new file mode 100644 index 0000000000000..76e3622b45de7 --- /dev/null +++ b/lib/Magento/Code/Generator/Proxy.php @@ -0,0 +1,196 @@ + '_subject', + 'visibility' => 'protected', + 'docblock' => array( + 'shortDescription' => 'Proxied instance', + 'tags' => array( + array('name' => 'var', 'description' => $this->_getSourceClassName()) + ) + ), + ); + return $properties; + } + + /** + * @return array + */ + protected function _getClassMethods() + { + $construct = $this->_getDefaultConstructorDefinition(); + + // create proxy methods for all non-static and non-final public methods (excluding constructor) + $methods = array($construct); + $methods[] = array( + 'name' => '__sleep', + 'body' => 'return array(\'_subject\');', + 'docblock' => array( + 'shortDescription' => '@return array', + ), + ); + $methods[] = array( + 'name' => '__wakeup', + 'body' => '$this->_objectManager = Mage::getObjectManager();', + 'docblock' => array( + 'shortDescription' => 'Retrieve ObjectManager from global scope', + ), + ); + $methods[] = array( + 'name' => '__clone', + 'body' => '$this->_subject = clone $this->_objectManager->get(self::CLASS_NAME);', + 'docblock' => array( + 'shortDescription' => 'Clone proxied instance', + ), + ); + $reflectionClass = new ReflectionClass($this->_getSourceClassName()); + $publicMethods = $reflectionClass->getMethods(ReflectionMethod::IS_PUBLIC); + foreach ($publicMethods as $method) { + if (!($method->isConstructor() || $method->isFinal() || $method->isStatic() || $method->isDestructor()) + && !in_array($method->getName(), array('__sleep', '__wakeup', '__clone')) + ) { + $methods[] = $this->_getMethodInfo($method); + } + } + + return $methods; + } + + /** + * @return string + */ + protected function _generateCode() + { + $this->_classGenerator->setExtendedClass($this->_getFullyQualifiedClassName($this->_getSourceClassName())); + + return parent::_generateCode(); + } + + /** + * Collect method info + * + * @param ReflectionMethod $method + * @return array + */ + protected function _getMethodInfo(ReflectionMethod $method) + { + $parameterNames = array(); + $parameters = array(); + foreach ($method->getParameters() as $parameter) { + $parameterNames[] = '$' . $parameter->getName(); + $parameters[] = $this->_getMethodParameterInfo($parameter); + } + + $methodInfo = array( + 'name' => $method->getName(), + 'parameters' => $parameters, + 'body' => $this->_getMethodBody($method->getName(), $parameterNames), + 'docblock' => array( + 'shortDescription' => '{@inheritdoc}', + ), + ); + + return $methodInfo; + } + + /** + * Collect method parameter info + * + * @param ReflectionParameter $parameter + * @return array + */ + protected function _getMethodParameterInfo(ReflectionParameter $parameter) + { + $parameterInfo = array( + 'name' => $parameter->getName(), + 'passedByReference' => $parameter->isPassedByReference() + ); + + if ($parameter->isArray()) { + $parameterInfo['type'] = 'array'; + } elseif ($parameter->getClass()) { + $parameterInfo['type'] = $this->_getFullyQualifiedClassName($parameter->getClass()->getName()); + } + + if ($parameter->isOptional() && $parameter->isDefaultValueAvailable()) { + $defaultValue = $parameter->getDefaultValue(); + if (is_string($defaultValue)) { + $parameterInfo['defaultValue'] = $this->_escapeDefaultValue($parameter->getDefaultValue()); + } elseif ($defaultValue === null) { + $parameterInfo['defaultValue'] = $this->_getNullDefaultValue(); + } else { + $parameterInfo['defaultValue'] = $defaultValue; + } + } + + return $parameterInfo; + } + + /** + * Build proxy method body + * + * @param string $name + * @param array $parameters + * @return string + */ + protected function _getMethodBody($name, array $parameters = array()) + { + if (count($parameters) == 0) { + $methodCall = sprintf('%s()', $name); + } else { + $methodCall = sprintf('%s(%s)', $name, implode(', ', $parameters)); + } + return "if (!\$this->_subject) {\n" . + " \$this->_subject = \$this->_objectManager->get(self::CLASS_NAME);\n" . + "}\n". + 'return $this->_subject->' . $methodCall . ';'; + } +} diff --git a/lib/Magento/Code/Reader/ClassReader.php b/lib/Magento/Code/Reader/ClassReader.php new file mode 100644 index 0000000000000..fa8fc083f2b98 --- /dev/null +++ b/lib/Magento/Code/Reader/ClassReader.php @@ -0,0 +1,54 @@ +getConstructor(); + if ($constructor) { + $result = array(); + /** @var $parameter ReflectionParameter */ + foreach ($constructor->getParameters() as $parameter) { + $result[] = array( + $parameter->getName(), + ($parameter->getClass() !== null) ? $parameter->getClass()->getName() : null, + !$parameter->isOptional(), + $parameter->isOptional() ? + $parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null : + null + ); + } + } + return $result; + } +} diff --git a/lib/Magento/Config/Dom.php b/lib/Magento/Config/Dom.php index 25fcc554ea0a4..53515ffa2a683 100644 --- a/lib/Magento/Config/Dom.php +++ b/lib/Magento/Config/Dom.php @@ -179,9 +179,9 @@ protected function _getMatchedNode($nodePath) * * @param DOMDocument $dom * @param string $schemaFileName - * @return array + * @return array of errors */ - protected function _validateDomDocument(DOMDocument $dom, $schemaFileName) + public static function validateDomDocument(DOMDocument $dom, $schemaFileName) { libxml_use_internal_errors(true); $result = $dom->schemaValidate($schemaFileName); @@ -222,7 +222,7 @@ protected function _initDom($xml) $dom = new DOMDocument(); $dom->loadXML($xml); if ($this->_schemaFile) { - $errors = $this->_validateDomDocument($dom, $this->_schemaFile); + $errors = self::validateDomDocument($dom, $this->_schemaFile); if (count($errors)) { throw new Magento_Config_Dom_ValidationException(implode("\n", $errors)); } @@ -239,7 +239,7 @@ protected function _initDom($xml) */ public function validate($schemaFileName, &$errors = array()) { - $errors = $this->_validateDomDocument($this->_dom, $schemaFileName); + $errors = self::validateDomDocument($this->_dom, $schemaFileName); return !count($errors); } } diff --git a/lib/Magento/Config/View.php b/lib/Magento/Config/View.php index ee7407a1549a3..0c5dd1e9982ae 100644 --- a/lib/Magento/Config/View.php +++ b/lib/Magento/Config/View.php @@ -87,6 +87,16 @@ public function getVarValue($module, $var) return isset($this->_data[$module][$var]) ? $this->_data[$module][$var] : false; } + /** + * Return copy of DOM + * + * @return Magento_Config_Dom + */ + public function getDomConfigCopy() + { + return clone $this->_getDomConfigModel(); + } + /** * Getter for initial view.xml contents * diff --git a/lib/Magento/Controller/Router/Route/Factory.php b/lib/Magento/Controller/Router/Route/Factory.php index 0d19a78ab82ea..5d1a272872140 100644 --- a/lib/Magento/Controller/Router/Route/Factory.php +++ b/lib/Magento/Controller/Router/Route/Factory.php @@ -44,8 +44,7 @@ public function createRoute( 'defaults' => $defaults, 'regs' => $reqs, 'locale' => $locale - ), - false + ) ); if (!$route instanceof Zend_Controller_Router_Route_Interface) { throw new LogicException('Route must implement "Zend_Controller_Router_Route_Interface".'); diff --git a/lib/Magento/Datasource/Config/Interface.php b/lib/Magento/Datasource/Config/Interface.php new file mode 100644 index 0000000000000..eb050595c8025 --- /dev/null +++ b/lib/Magento/Datasource/Config/Interface.php @@ -0,0 +1,11 @@ +_config = $config; + $this->_objectManager = $objectManager; + $this->_repository = $repository; + } + + public function getConfig() + { + return $this->_config; + } + + /** + * takes array of the following structure + * and initializes all of the data sources + * + * array(dataSourceName => array( + * blocks => array( + * 'namespace' => aliasInNamespace + * )) + * + * @param array $dataSourcesList + * @return Magento_Datasource_Factory + */ + public function init(array $dataSourcesList) + { + foreach ($dataSourcesList as $dataSourceName => $namespaceConfig) { + $this->initDataSource($dataSourceName); + $this->assignToNamespace($dataSourceName, $namespaceConfig); + } + return $this; + } + + /** + * Assign service call name to the namespace + * @param $dataSourceName + * @param $namespaceConfig + * @throws Exception + */ + public function assignToNamespace($dataSourceName, $namespaceConfig) + { + if (!isset($namespaceConfig['namespaces'])) { + throw new Exception("Data reference configuration doesn't have a block to link to"); + } + foreach ($namespaceConfig['namespaces'] as $namespaceName => $aliasInNamespace) { + $this->getRepository()->addNameInNamespace($namespaceName, $dataSourceName, $aliasInNamespace); + } + } + + /** + * Retrieve all data for the service calls for particular namespace + * + * @param $namespace + * @return mixed + */ + public function getByNamespace($namespace) + { + $dataSources = $this->getRepository()->getByNamespace($namespace); + return $dataSources; + } + + /** + * Retrieve the data or the service call based on its name + * @param $sourceName + * @return bool|mixed + */ + public function get($sourceName) + { + $dataSource = $this->getRepository()->get($sourceName); + if ($dataSource == null) { + $dataSource = $this->initDataSource($sourceName); + } + return $dataSource; + } + + /** + * Retrieve repository for the data from service calls + * @return array|Magento_Datasource_Repository + */ + public function getRepository() + { + return $this->_repository; + } + + /** + * Init single service call + * + * @param $sourceName + * @return bool|mixed + */ + public function initDataSource($sourceName) + { + if ($dataSource = $this->getRepository()->get($sourceName) !== null) { + return $dataSource; + } + + $classInformation = $this->getConfig()->getClassByAlias($sourceName); + $instance = $this->_objectManager->create($classInformation['class']); + $dataSource = $this->_applyMethod($instance, $classInformation['retrieveMethod'], + $classInformation['methodArguments']); + + $this->getRepository()->add($sourceName, $dataSource); + return $dataSource; + } + + /** + * Invoke method configuraed for service call + * + * @param $object + * @param $methodName + * @param $methodArguments + * @return mixed + */ + protected function _applyMethod($object, $methodName, $methodArguments) + { + $result = null; + $arguments = array(); + if (is_array($methodArguments)) { + $arguments = $this->_prepareArguments($methodArguments); + } + $result = call_user_func_array(array($object, $methodName), $arguments); + return $result; + } + + /** + * Get the value for the method argument + * + * @param $path + * @return null + */ + public function getArgumentValue($path) + { + /** @var $visitor Magento_Datasource_Path_Visitor */ + $visitor = $this->_objectManager->create('Magento_Datasource_Path_Visitor', + array('path' => $path, 'separator' => '.')); + /** @var $pathRepository Magento_Datasource_Path_Composite */ + $pathRepository = $this->_objectManager->create('Magento_Datasource_Path_Composite'); + $result = $visitor->visit($pathRepository); + return $result; + } + + /** + * Prepare values for the method params + * + * @param $argumentsList + * @return array + */ + protected function _prepareArguments($argumentsList) + { + $result = array(); + foreach ($argumentsList as $name => $value) { + $result[$name] = $this->getArgumentValue($value); + } + return $result; + } + + + /** + * Make the Datasource Object visitable + * + * @param Magento_Datasource_Path_Visitor $visitor + * @return bool|mixed + */ + public function visit(Magento_Datasource_Path_Visitor $visitor) + { + return $this->get($visitor->getCurrentPathElement()); + } +} diff --git a/lib/Magento/Datasource/Path/Composite.php b/lib/Magento/Datasource/Path/Composite.php new file mode 100644 index 0000000000000..2b802dfb05aeb --- /dev/null +++ b/lib/Magento/Datasource/Path/Composite.php @@ -0,0 +1,25 @@ + $item) { + $this->_children[$key] = $objectManager->create($item); + } + } + + public function visit(Magento_Datasource_Path_Visitor $visitor) + { + $result = $visitor->visitArray($this->_children); + return $result; + } +} \ No newline at end of file diff --git a/lib/Magento/Datasource/Path/Visitable.php b/lib/Magento/Datasource/Path/Visitable.php new file mode 100644 index 0000000000000..36cae7e9021e8 --- /dev/null +++ b/lib/Magento/Datasource/Path/Visitable.php @@ -0,0 +1,11 @@ +_path = trim($path, '{}'); + $this->_separator = $separator; + return $this; + } + + public function getCurrentPathElement() + { + return $this->_currentPathElement; + } + + public function chopCurrentPathElement() + { + if (strpos($this->_path, $this->_separator) !== false) { + $this->_currentPathElement = substr($this->_path, 0, strpos($this->_path, $this->_separator)); + $this->_path = substr($this->_path, strpos($this->_path, $this->_separator) + 1); + } else { + $this->_currentPathElement = $this->_path; + $this->_path = ''; + } + return $this->_currentPathElement; + } + + /** + * @param Magento_Datasource_Path_Visitable $object + * @return null + * @throws InvalidArgumentException + */ + public function visitObject(Magento_Datasource_Path_Visitable $object) + { + $target = $object->visit($this); + if ($target == null) { + return null; + } + return $target; + } + + public function visitArray(Array $target) + { + if (isset($target[$this->getCurrentPathElement()])) { + return $target[$this->getCurrentPathElement()]; + } else { + return null; + } + } + + public function visit($target) + { + $this->chopCurrentPathElement(); + if (is_array($target)) { + $target = $this->visitArray($target); + } else if (is_object($target)) { + try { + $target = $this->visitObject($target); + } catch (Exception $e) {var_dump($e->getMessage()); + throw new \InvalidArgumentException('Search is not possible on the target object type'); + } + } else { + return null; + } + if (strlen($this->_path) == 0) { + return $target; + } + return $this->visit($target); + } +} \ No newline at end of file diff --git a/lib/Magento/Datasource/Repository.php b/lib/Magento/Datasource/Repository.php new file mode 100644 index 0000000000000..cae894f0600ee --- /dev/null +++ b/lib/Magento/Datasource/Repository.php @@ -0,0 +1,51 @@ +_namespaces[$namespace])) { + $this->_namespaces[$namespace][$name] = $nameInNamespace; + } else { + $this->_namespaces[$namespace] = array($name => $nameInNamespace); + } + return $this; + } + + public function getByNamespace($namespace) + { + if (!isset($this->_namespaces[$namespace])) { + return array(); + } + $dataSources = array(); + $dataSourcesNames = $this->_namespaces[$namespace]; + foreach ($dataSourcesNames as $name => $nameInNamespace) { + $dataSources[$nameInNamespace] = $this->get($name); + } + return $dataSources; + } + + public function add($name, $dataSource) + { + $this->_dataSources[$name] = $dataSource; + return $this; + } + + public function get($name) + { + if (!isset($this->_dataSources[$name])) { + return null; + } + return $this->_dataSources[$name]; + } +} \ No newline at end of file diff --git a/lib/Magento/Di.php b/lib/Magento/Di.php deleted file mode 100644 index 4211f59798d97..0000000000000 --- a/lib/Magento/Di.php +++ /dev/null @@ -1,45 +0,0 @@ -dataArray = $dataArray; - } - - /** - * Check whether definition contains class - * - * @param string $class - * @return bool - */ - public function hasClass($class) - { - $result = array_key_exists($class, $this->dataArray); - if ($result && !is_array($this->dataArray[$class])) { - $this->dataArray[$class] = json_decode($this->dataArray[$class], true); - } - return $result; - } -} diff --git a/lib/Magento/Di/Definition/CompilerDefinition.php b/lib/Magento/Di/Definition/CompilerDefinition.php deleted file mode 100644 index 97107d3750e60..0000000000000 --- a/lib/Magento/Di/Definition/CompilerDefinition.php +++ /dev/null @@ -1,47 +0,0 @@ -_classGenerator = $classGenerator ?: new Magento_Di_Generator_Class(); - } - - /** - * Process class method parameters - * - * @param array $def - * @param Zend\Code\Reflection\ClassReflection $rClass - * @param Zend\Code\Reflection\MethodReflection $rMethod - */ - protected function processParams(&$def, Reflection\ClassReflection $rClass, Reflection\MethodReflection $rMethod) - { - if (count($rMethod->getParameters()) === 0) { - return; - } - - parent::processParams($def, $rClass, $rMethod); - - $methodName = $rMethod->getName(); - - /** @var $p \ReflectionParameter */ - foreach ($rMethod->getParameters() as $p) { - $fqName = $rClass->getName() . '::' . $rMethod->getName() . ':' . $p->getPosition(); - - $def['parameters'][$methodName][$fqName][] = ($p->isOptional() && $p->isDefaultValueAvailable()) - ? $p->getDefaultValue() - : null; - } - } - - /** - * Get definition as array - * - * @return array - */ - public function toArray() - { - return $this->toArrayDefinition()->toArray(); - } - - /** - * Convert to array definition - * - * @return Magento_Di_Definition_ArrayDefinition - */ - public function toArrayDefinition() - { - return new Magento_Di_Definition_ArrayDefinition_Zend( - $this->classes - ); - } - - /** - * @param string $class - */ - protected function processClass($class) - { - $this->_classGenerator->generateForConstructor($class); - parent::processClass($class); - } -} diff --git a/lib/Magento/Di/Definition/RuntimeDefinition.php b/lib/Magento/Di/Definition/RuntimeDefinition.php deleted file mode 100644 index ca011efd0ee8b..0000000000000 --- a/lib/Magento/Di/Definition/RuntimeDefinition.php +++ /dev/null @@ -1,29 +0,0 @@ -_classGenerator = $classGenerator ?: new Magento_Di_Generator_Class(); - } - - /** - * Process method parameters - * - * @param array $def - * @param Reflection\ClassReflection $rClass - * @param Reflection\MethodReflection $rMethod - */ - protected function processParams(&$def, Reflection\ClassReflection $rClass, Reflection\MethodReflection $rMethod) - { - if (count($rMethod->getParameters()) === 0) { - return; - } - - $methodName = $rMethod->getName(); - - // @todo annotations here for alternate names? - - $def['parameters'][$methodName] = array(); - - foreach ($rMethod->getParameters() as $p) { - - /** @var $p \ReflectionParameter */ - $actualParamName = $p->getName(); - - $fqName = $rClass->getName() . '::' . $rMethod->getName() . ':' . $p->getPosition(); - - $def['parameters'][$methodName][$fqName] = array(); - - // set the class name, if it exists - $def['parameters'][$methodName][$fqName][] = $actualParamName; - $def['parameters'][$methodName][$fqName][] = ($p->getClass() !== null) ? $p->getClass()->getName() : null; - $def['parameters'][$methodName][$fqName][] = !$p->isOptional(); - $def['parameters'][$methodName][$fqName][] = ($p->isOptional() && $p->isDefaultValueAvailable()) - ? $p->getDefaultValue() - : null; - } - - } - - /** - * @param string $class - * @return array|string - */ - public function getInstantiator($class) - { - $this->_classGenerator->generateForConstructor($class); - return parent::getInstantiator($class); - } -} diff --git a/lib/Magento/Di/DefinitionList/Zend.php b/lib/Magento/Di/DefinitionList/Zend.php deleted file mode 100644 index 61fd1c99656d6..0000000000000 --- a/lib/Magento/Di/DefinitionList/Zend.php +++ /dev/null @@ -1,69 +0,0 @@ -hasClass($class) && $definition->hasMethodParameters($class, $method)) { - return $definition->getMethodParameters($class, $method); - } - } - return array(); - } - - /** - * Fix bug for in ZF2: https://github.com/zendframework/zf2/commit/26c8899ddfc4fe2672b2efa9ff3cf3cac600bec3 - * @todo Delete this method after ZF2 library update - * {@inheritDoc} - */ - public function hasMethod($class, $method) - { - /** @var $definition Zend\Di\Definition\DefinitionInterface */ - foreach ($this as $definition) { - if ($definition->hasClass($class)) { - if ($definition->hasMethods($class) === false - && $definition instanceof Zend\Di\Definition\PartialMarker - ) { - continue; - } else { - return $definition->hasMethod($class, $method); - } - } - } - - return false; - } -} diff --git a/lib/Magento/Di/Generator.php b/lib/Magento/Di/Generator.php deleted file mode 100644 index 0cac4b05c3abf..0000000000000 --- a/lib/Magento/Di/Generator.php +++ /dev/null @@ -1,148 +0,0 @@ -_generator = $generator; - $this->_autoloader = $autoloader ? : new Magento_Autoload_IncludePath(); - $this->_ioObject = $ioObject ? : new Magento_Di_Generator_Io(new Varien_Io_File(), $this->_autoloader); - } - - /** - * @return array - */ - public function getGeneratedEntities() - { - return $this->_generatedEntities; - } - - /** - * @param $className - * @return bool - * @throws Magento_Exception - */ - public function generateClass($className) - { - // check if source class a generated entity - $entity = null; - $entityName = null; - foreach ($this->_generatedEntities as $entityType) { - $entitySuffix = ucfirst($entityType); - // if $className string ends on $entitySuffix substring - if (strrpos($className, $entitySuffix) === strlen($className) - strlen($entitySuffix)) { - $entity = $entityType; - $entityName = rtrim(substr($className, 0, -1 * strlen($entitySuffix)), '_'); - break; - } - } - if (!$entity || !$entityName) { - return false; - } - - // check if file already exists - $autoloader = $this->_autoloader; - if ($autoloader::getFile($className)) { - return false; - } - - // generate class file - $this->_initGenerator($entity, $entityName, $className); - if (!$this->_generator->generate()) { - $errors = $this->_generator->getErrors(); - throw new Magento_Exception(implode(' ', $errors)); - } - - // remove generator - $this->_generator = null; - - return true; - } - - /** - * Get generator by entity type - * - * @param string $entity - * @param string $sourceClassName - * @param string $resultClassName - * @return Magento_Di_Generator_EntityAbstract|Magento_Di_Generator_Factory|Magento_Di_Generator_Proxy - * @throws InvalidArgumentException - */ - protected function _initGenerator($entity, $sourceClassName, $resultClassName) - { - if (!$this->_generator) { - switch ($entity) { - case Magento_Di_Generator_Factory::ENTITY_TYPE: - $this->_generator = new Magento_Di_Generator_Factory($sourceClassName, $resultClassName, - $this->_ioObject - ); - break; - case Magento_Di_Generator_Proxy::ENTITY_TYPE: - $this->_generator = new Magento_Di_Generator_Proxy($sourceClassName, $resultClassName, - $this->_ioObject - ); - break; - default: - throw new InvalidArgumentException('Unknown generation entity.'); - break; - } - } - - return $this->_generator; - } -} diff --git a/lib/Magento/Di/Generator/CodeGenerator/Interface.php b/lib/Magento/Di/Generator/CodeGenerator/Interface.php deleted file mode 100644 index fa0af4e56445a..0000000000000 --- a/lib/Magento/Di/Generator/CodeGenerator/Interface.php +++ /dev/null @@ -1,66 +0,0 @@ - 'setShortDescription', - 'longDescription' => 'setLongDescription', - 'tags' => 'setTags' - ); - - /** - * Possible class property options - * - * @var array - */ - protected $_propertyOptions = array( - 'name' => 'setName', - 'const' => 'setConst', - 'static' => 'setStatic', - 'visibility' => 'setVisibility', - 'defaultValue' => 'setDefaultValue', - ); - - /** - * Possible class method options - * - * @var array - */ - protected $_methodOptions = array( - 'name' => 'setName', - 'final' => 'setFinal', - 'static' => 'setStatic', - 'abstract' => 'setAbstract', - 'visibility' => 'setVisibility', - 'body' => 'setBody', - ); - - /** - * Possible method parameter options - * - * @var array - */ - protected $_parameterOptions = array( - 'name' => 'setName', - 'type' => 'setType', - 'defaultValue' => 'setDefaultValue', - 'passedByReference' => 'setPassedByReference' - ); - - /** - * @param object $object - * @param array $data - * @param array $map - * @return void - */ - protected function _setDataToObject($object, array $data, array $map) - { - foreach ($map as $arrayKey => $setterName) { - if (isset($data[$arrayKey])) { - $object->{$setterName}($data[$arrayKey]); - } - } - } - - /** - * Set class dock block - * - * @param array $docBlock - * @return Magento_Di_Generator_CodeGenerator_Zend - */ - public function setClassDocBlock(array $docBlock) - { - $docBlockObject = new Zend\Code\Generator\DocBlockGenerator(); - $this->_setDataToObject($docBlockObject, $docBlock, $this->_docBlockOptions); - - return parent::setDocBlock($docBlockObject); - } - - /** - * addMethods() - * - * @param array $methods - * @return Magento_Di_Generator_CodeGenerator_Zend - */ - public function addMethods(array $methods) - { - foreach ($methods as $methodOptions) { - $methodObject = new Zend\Code\Generator\MethodGenerator(); - $this->_setDataToObject($methodObject, $methodOptions, $this->_methodOptions); - - if (isset($methodOptions['parameters']) && is_array($methodOptions['parameters']) - && count($methodOptions['parameters']) > 0 - ) { - $parametersArray = array(); - foreach ($methodOptions['parameters'] as $parameterOptions) { - $parameterObject = new Zend\Code\Generator\ParameterGenerator(); - $this->_setDataToObject($parameterObject, $parameterOptions, $this->_parameterOptions); - $parametersArray[] = $parameterObject; - } - - $methodObject->setParameters($parametersArray); - } - - if (isset($methodOptions['docblock']) && is_array($methodOptions['docblock'])) { - $docBlockObject = new Zend\Code\Generator\DocBlockGenerator(); - $this->_setDataToObject($docBlockObject, $methodOptions['docblock'], $this->_docBlockOptions); - - $methodObject->setDocBlock($docBlockObject); - } - - $this->addMethodFromGenerator($methodObject); - } - return $this; - } - - /** - * Add method from MethodGenerator - * - * @param Zend\Code\Generator\MethodGenerator $method - * @return Magento_Di_Generator_CodeGenerator_Zend - * @throws InvalidArgumentException - */ - public function addMethodFromGenerator(Zend\Code\Generator\MethodGenerator $method) - { - if (!is_string($method->getName())) { - throw new InvalidArgumentException( - 'addMethodFromGenerator() expects string for name' - ); - } - - return parent::addMethodFromGenerator($method); - } - - /** - * addProperties() - * - * @param array $properties - * @return Magento_Di_Generator_CodeGenerator_Zend - * @throws InvalidArgumentException - */ - public function addProperties(array $properties) - { - foreach ($properties as $propertyOptions) { - $propertyObject = new Zend\Code\Generator\PropertyGenerator(); - $this->_setDataToObject($propertyObject, $propertyOptions, $this->_propertyOptions); - - if (isset($propertyOptions['docblock'])) { - $docBlock = $propertyOptions['docblock']; - if (is_array($docBlock)) { - $docBlockObject = new Zend\Code\Generator\DocBlockGenerator(); - $this->_setDataToObject($docBlockObject, $docBlock, $this->_docBlockOptions); - $propertyObject->setDocBlock($docBlockObject); - } - } - - $this->addPropertyFromGenerator($propertyObject); - } - - return $this; - } - - /** - * Add property from PropertyGenerator - * - * @param Zend\Code\Generator\PropertyGenerator $property - * @throws InvalidArgumentException - * @return Magento_Di_Generator_CodeGenerator_Zend - */ - public function addPropertyFromGenerator(Zend\Code\Generator\PropertyGenerator $property) - { - if (!is_string($property->getName())) { - throw new InvalidArgumentException( - 'addPropertyFromGenerator() expects string for name' - ); - } - - return parent::addPropertyFromGenerator($property); - } -} diff --git a/lib/Magento/Di/Generator/Factory.php b/lib/Magento/Di/Generator/Factory.php deleted file mode 100644 index 129522392bafe..0000000000000 --- a/lib/Magento/Di/Generator/Factory.php +++ /dev/null @@ -1,80 +0,0 @@ -_classGenerator->setImplementedInterfaces(array(self::FACTORY_INTERFACE)); - - return parent::_generateCode(); - } - - /** - * @return array - */ - protected function _getClassMethods() - { - $construct = $this->_getDefaultConstructorDefinition(); - - // public function createFromArray(array $data = array()) - $createFromArray = array( - 'name' => 'createFromArray', - 'parameters' => array( - array('name' => 'data', 'type' => 'array', 'defaultValue' => array()), - ), - 'body' => 'return $this->_objectManager->create(self::CLASS_NAME, $data, false);', - 'docblock' => array( - 'shortDescription' => 'Create class instance with specified parameters', - 'tags' => array( - array( - 'name' => 'param', - 'description' => 'array $data' - ), - array( - 'name' => 'return', - 'description' => $this->_getFullyQualifiedClassName($this->_getSourceClassName()) - ), - ), - ), - ); - - return array($construct, $createFromArray); - } -} diff --git a/lib/Magento/Di/Generator/Proxy.php b/lib/Magento/Di/Generator/Proxy.php deleted file mode 100644 index db03002296fc2..0000000000000 --- a/lib/Magento/Di/Generator/Proxy.php +++ /dev/null @@ -1,141 +0,0 @@ -_getDefaultConstructorDefinition(); - - // create proxy methods for all non-static and non-final public methods (excluding constructor) - $methods = array($construct); - $reflectionClass = new ReflectionClass($this->_getSourceClassName()); - $publicMethods = $reflectionClass->getMethods(ReflectionMethod::IS_PUBLIC); - foreach ($publicMethods as $method) { - if (!($method->isConstructor() || $method->isFinal() || $method->isStatic())) { - $methods[] = $this->_getMethodInfo($method); - } - } - - return $methods; - } - - /** - * @return string - */ - protected function _generateCode() - { - $this->_classGenerator->setExtendedClass($this->_getFullyQualifiedClassName($this->_getSourceClassName())); - - return parent::_generateCode(); - } - - /** - * Collect method info - * - * @param ReflectionMethod $method - * @return array - */ - protected function _getMethodInfo(ReflectionMethod $method) - { - $parameterNames = array(); - $parameters = array(); - foreach ($method->getParameters() as $parameter) { - $parameterNames[] = '$' . $parameter->getName(); - $parameters[] = $this->_getMethodParameterInfo($parameter); - } - - $methodInfo = array( - 'name' => $method->getName(), - 'parameters' => $parameters, - 'body' => $this->_getMethodBody($method->getName(), $parameterNames), - 'docblock' => array( - 'shortDescription' => '{@inheritdoc}', - ), - ); - - return $methodInfo; - } - - /** - * Collect method parameter info - * - * @param ReflectionParameter $parameter - * @return array - */ - protected function _getMethodParameterInfo(ReflectionParameter $parameter) - { - $parameterInfo = array( - 'name' => $parameter->getName(), - 'passedByReference' => $parameter->isPassedByReference() - ); - - if ($parameter->isArray()) { - $parameterInfo['type'] = 'array'; - } elseif ($parameter->getClass()) { - $parameterInfo['type'] = $this->_getFullyQualifiedClassName($parameter->getClass()->getName()); - } - - if ($parameter->isOptional() && $parameter->isDefaultValueAvailable()) { - $defaultValue = $parameter->getDefaultValue(); - if (is_string($defaultValue)) { - $parameterInfo['defaultValue'] = $this->_escapeDefaultValue($parameter->getDefaultValue()); - } elseif ($defaultValue === null) { - $parameterInfo['defaultValue'] = $this->_getNullDefaultValue(); - } else { - $parameterInfo['defaultValue'] = $defaultValue; - } - } - - return $parameterInfo; - } - - /** - * Build proxy method body - * - * @param string $name - * @param array $parameters - * @return string - */ - protected function _getMethodBody($name, array $parameters = array()) - { - if (count($parameters) == 0) { - $methodCall = sprintf('%s()', $name); - } else { - $methodCall = sprintf('%s(%s)', $name, implode(', ', $parameters)); - } - - return 'return $this->_objectManager->get(self::CLASS_NAME)->' . $methodCall . ';'; - } -} diff --git a/lib/Magento/Di/InstanceManager.php b/lib/Magento/Di/InstanceManager.php deleted file mode 100644 index 419b48db9a16a..0000000000000 --- a/lib/Magento/Di/InstanceManager.php +++ /dev/null @@ -1,70 +0,0 @@ -_generator = $classGenerator ?: new Magento_Di_Generator(); - } - - /** - * Remove shared instance - * - * @param string $classOrAlias - * @return Magento_Di_InstanceManager_Zend - */ - public function removeSharedInstance($classOrAlias) - { - unset($this->sharedInstances[$classOrAlias]); - - return $this; - } - - /** - * Add type preference from configuration - * - * @param string $interfaceOrAbstract - * @param string $implementation - * @return Zend\Di\InstanceManager - */ - public function addTypePreference($interfaceOrAbstract, $implementation) - { - $this->_generator->generateClass($implementation); - return parent::addTypePreference($interfaceOrAbstract, $implementation); - } - - /** - * Set parameters from configuration - * - * @param string $aliasOrClass - * @param array $parameters - */ - public function setParameters($aliasOrClass, array $parameters) - { - foreach ($parameters as $parameter) { - if (is_string($parameter)) { - $this->_generator->generateClass($parameter); - } - } - parent::setParameters($aliasOrClass, $parameters); - } -} diff --git a/lib/Magento/Di/Zend.php b/lib/Magento/Di/Zend.php deleted file mode 100644 index 159dc4bdd3a64..0000000000000 --- a/lib/Magento/Di/Zend.php +++ /dev/null @@ -1,578 +0,0 @@ -setInstanceManager($instanceManager); - } - - /** - * Retrieve a new instance of a class - * - * Forces retrieval of a discrete instance of the given class, using the - * constructor parameters provided. - * - * @param mixed $name - * @param array $parameters - * @param bool $isShared - * @return null|object - * @throws Zend\Di\Exception\RuntimeException - * @throws Zend\Di\Exception\ClassNotFoundException - * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.NPathComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - * @todo Need to refactor this method - */ - public function newInstance($name, array $parameters = array(), $isShared = true) - { - // localize dependencies - $definitions = $this->definitions; - - if (!$this->definitions()->hasClass($name)) { - array_push($this->instanceContext, array('NEW', $name, $name)); - - if ($this->_isArrayHasDataKey($parameters)) { - $parameters = reset($parameters); - } - - if (preg_match('/\w*_\w*\_Model/', $name)) { - $instance = new $name( - $this->_getCachedDependency('Mage_Core_Model_Event_Manager'), - $this->_getCachedDependency('Mage_Core_Model_Cache'), - null, - null, - $parameters - ); - } else if (preg_match('/\w*_\w*\_Block/', $name)) { - $instance = new $name( - $this->_getCachedDependency('Mage_Core_Controller_Request_Http'), - $this->_getCachedDependency('Mage_Core_Model_Layout'), - $this->_getCachedDependency('Mage_Core_Model_Event_Manager'), - $this->_getCachedDependency('Mage_Core_Model_Url'), - $this->_getCachedDependency('Mage_Core_Model_Translate'), - $this->_getCachedDependency('Mage_Core_Model_Cache'), - $this->_getCachedDependency('Mage_Core_Model_Design_Package'), - $this->_getCachedDependency('Mage_Core_Model_Session'), - $this->_getCachedDependency('Mage_Core_Model_Store_Config'), - $this->_getCachedDependency('Mage_Core_Controller_Varien_Front'), - $this->_getCachedDependency('Mage_Core_Model_Factory_Helper'), - $parameters - ); - } else { - $instance = new $name(); - } - if ($isShared) { - $this->_addSharedInstance($instance, $name, $parameters); - } - array_pop($this->instanceContext); - return $instance; - } - - $instanceManager = $this->instanceManager(); - - if ($instanceManager->hasAlias($name)) { - $class = $instanceManager->getClassFromAlias($name); - $alias = $name; - } else { - $class = $name; - $alias = null; - } - - array_push($this->instanceContext, array('NEW', $class, $alias)); - - if (!$definitions->hasClass($class)) { - $aliasMsg = ($alias) ? '(specified by alias ' . $alias . ') ' : ''; - throw new Exception\ClassNotFoundException( - 'Class ' . $aliasMsg . $class . ' could not be located in provided definitions.' - ); - } - - $instantiator = $definitions->getInstantiator($class); - - if ($instantiator === '__construct') { - $instance = $this->createInstanceViaConstructor($class, $parameters, $alias); - } elseif (is_callable($instantiator, false)) { - $instance = $this->createInstanceViaCallback($instantiator, $parameters, $alias); - } else { - if (is_array($instantiator)) { - $msg = sprintf( - 'Invalid instantiator: %s::%s() is not callable.', - isset($instantiator[0]) ? $instantiator[0] : 'NoClassGiven', - isset($instantiator[1]) ? $instantiator[1] : 'NoMethodGiven' - ); - } else { - $msg = sprintf( - 'Invalid instantiator of type "%s" for "%s".', - gettype($instantiator), - $name - ); - } - throw new Exception\RuntimeException($msg); - } - - if ($isShared) { - $this->_addSharedInstance($instance, $name, $parameters); - } - - array_pop($this->instanceContext); - return $instance; - } - - /** - * Check is array has 'data' key - * Function used to provide possibility to use old and new format of params array, when new model instantiated - * - * @param $array - * @return bool - */ - protected function _isArrayHasDataKey($array) - { - return (count($array) == 1) && array_key_exists('data', $array); - } - - /** - * Add shared instance to instance manager - * - * @param object $instance - * @param string $name - * @param array $parameters - * @return Magento_Di - */ - protected function _addSharedInstance($instance, $name, array $parameters = array()) - { - if ($parameters) { - $this->instanceManager->addSharedInstanceWithParameters($instance, $name, $parameters); - } else { - $this->instanceManager->addSharedInstance($instance, $name); - } - - return $this; - } - - /** - * Retrieve cached object - * - * @param string $className - * @return mixed - */ - protected function _getCachedDependency($className) - { - if (!isset($this->_cachedInstances[$className])) { - $this->_cachedInstances[$className] = $this->get($className); - } - - return $this->_cachedInstances[$className]; - } - - /** - * Retrieve a class instance based on class name - * - * Any parameters provided will be used as constructor arguments. If any - * given parameter is a DependencyReference object, it will be fetched - * from the container so that the instance may be injected. - * - * @param string $class - * @param array $params - * @param string|null $alias - * @return object - * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @todo Need to refactor this method - */ - protected function createInstanceViaConstructor($class, $params, $alias = null) - { - $callParameters = array(); - if ($this->definitions->hasMethodParameters($class, '__construct')) { - $callParameters = $this->resolveMethodParameters($class, '__construct', $params, $alias, true, true); - } - - // Hack to avoid Reflection in most common use cases - switch (count($callParameters)) { - case 0: - return new $class(); - case 1: - return new $class($callParameters[0]); - case 2: - return new $class($callParameters[0], $callParameters[1]); - case 3: - return new $class($callParameters[0], $callParameters[1], $callParameters[2]); - case 4: - return new $class($callParameters[0], $callParameters[1], $callParameters[2], $callParameters[3]); - case 5: - return new $class($callParameters[0], $callParameters[1], $callParameters[2], $callParameters[3], - $callParameters[4] - ); - case 6: - return new $class($callParameters[0], $callParameters[1], $callParameters[2], $callParameters[3], - $callParameters[4], $callParameters[5] - ); - case 7: - return new $class($callParameters[0], $callParameters[1], $callParameters[2], $callParameters[3], - $callParameters[4], $callParameters[5], $callParameters[6] - ); - case 8: - return new $class($callParameters[0], $callParameters[1], $callParameters[2], $callParameters[3], - $callParameters[4], $callParameters[5], $callParameters[6], $callParameters[7] - ); - case 9: - return new $class($callParameters[0], $callParameters[1], $callParameters[2], $callParameters[3], - $callParameters[4], $callParameters[5], $callParameters[6], $callParameters[7], $callParameters[8] - ); - case 10: - return new $class($callParameters[0], $callParameters[1], $callParameters[2], $callParameters[3], - $callParameters[4], $callParameters[5], $callParameters[6], $callParameters[7], $callParameters[8], - $callParameters[9] - ); - - default: - $reflection = new \ReflectionClass($class); - return $reflection->newInstanceArgs($callParameters); - } - } - - /** - * Resolve parameters referencing other services - * - * @param string $class - * @param string $method - * @param array $callTimeUserParams - * @param string $alias - * @param bool $methodIsRequired - * @param bool $isInstantiator - * @return array|bool - * @throws Zend\Di\Exception\MissingPropertyException - * @throws Zend\Di\Exception\CircularDependencyException - * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.NPathComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - * @todo Need to refactor this method - */ - protected function resolveMethodParameters($class, $method, array $callTimeUserParams, $alias, $methodIsRequired, - $isInstantiator = false - ) { - // parameters for this method, in proper order, to be returned - $resolvedParams = array(); - - // parameter requirements from the definition - $methodParameters = $this->definitions->getMethodParameters($class, $method); - - /** Magento */ - $callTimeParamNames = array_keys($callTimeUserParams); - $isPositional = false; - $parameterNames = array(); - - foreach ($methodParameters as $param) { - $parameterNames[] = $param[0]; - } - - foreach ($callTimeParamNames as $name) { - if (is_numeric($name)) { - $isPositional = true; - $callTimeUserParams[$parameterNames[$name]] = $callTimeUserParams[$name]; - } - } - - if (!$isPositional) { - if (count($callTimeUserParams) - && !isset($callTimeUserParams['data']) - ) { - if (in_array('data', $parameterNames)) { - $intersection = array_intersect($callTimeParamNames, $parameterNames); - if (!$intersection) { - $callTimeUserParams = array('data' => $callTimeUserParams); - } - } - } - } - - // computed parameters array - $computedParams = array( - 'value' => array(), - 'required' => array(), - 'optional' => array() - ); - - // retrieve instance configurations for all contexts - $iConfig = array(); - $aliases = $this->instanceManager->getAliases(); - - // for the alias in the dependency tree - if ($alias && $this->instanceManager->hasConfig($alias)) { - $iConfig['thisAlias'] = $this->instanceManager->getConfig($alias); - } - - // for the current class in the dependency tree - if ($this->instanceManager->hasConfig($class)) { - $iConfig['thisClass'] = $this->instanceManager->getConfig($class); - } - - // for the parent class, provided we are deeper than one node - if (isset($this->instanceContext[0])) { - list($requestedClass, $requestedAlias) = ($this->instanceContext[0][0] == 'NEW') - ? array($this->instanceContext[0][1], $this->instanceContext[0][2]) - : array($this->instanceContext[1][1], $this->instanceContext[1][2]); - } else { - $requestedClass = $requestedAlias = null; - } - - if ($requestedClass != $class && $this->instanceManager->hasConfig($requestedClass)) { - $iConfig['requestedClass'] = $this->instanceManager->getConfig($requestedClass); - if ($requestedAlias) { - $iConfig['requestedAlias'] = $this->instanceManager->getConfig($requestedAlias); - } - } - - // This is a 2 pass system for resolving parameters - // first pass will find the sources, the second pass will order them and resolve lookups if they exist - // MOST methods will only have a single parameters to resolve, so this should be fast - - foreach ($methodParameters as $fqParamPos => $info) { - list($name, $type, $isRequired) = $info; - - $fqParamName = substr_replace($fqParamPos, ':' . $info[0], strrpos($fqParamPos, ':')); - - // PRIORITY 1 - consult user provided parameters - if (isset($callTimeUserParams[$fqParamPos]) || isset($callTimeUserParams[$name])) { - - if (isset($callTimeUserParams[$fqParamPos])) { - $callTimeCurValue =& $callTimeUserParams[$fqParamPos]; - } elseif (isset($callTimeUserParams[$fqParamName])) { - $callTimeCurValue =& $callTimeUserParams[$fqParamName]; - } else { - $callTimeCurValue =& $callTimeUserParams[$name]; - } - - if ($type && is_string($callTimeCurValue)) { - if ($this->instanceManager->hasAlias($callTimeCurValue)) { - // was an alias provided? - $computedParams['required'][$fqParamPos] = array( - $callTimeUserParams[$name], - $this->instanceManager->getClassFromAlias($callTimeCurValue) - ); - } elseif ($this->definitions->hasClass($callTimeUserParams[$name])) { - // was a known class provided? - $computedParams['required'][$fqParamPos] = array( - $callTimeCurValue, - $callTimeCurValue - ); - } else { - // must be a value - $computedParams['value'][$fqParamPos] = $callTimeCurValue; - } - } else { - // int, float, null, object, etc - $computedParams['value'][$fqParamPos] = $callTimeCurValue; - } - unset($callTimeCurValue); - continue; - } - - // PRIORITY 2 -specific instance configuration (thisAlias) - this alias - // PRIORITY 3 -THEN specific instance configuration (thisClass) - this class - // PRIORITY 4 -THEN specific instance configuration (requestedAlias) - requested alias - // PRIORITY 5 -THEN specific instance configuration (requestedClass) - requested class - - foreach (array('thisAlias', 'thisClass', 'requestedAlias', 'requestedClass') as $thisIndex) { - // check the provided parameters config - if (isset($iConfig[$thisIndex]['parameters'][$fqParamPos]) - || isset($iConfig[$thisIndex]['parameters'][$fqParamName]) - || isset($iConfig[$thisIndex]['parameters'][$name])) { - - if (isset($iConfig[$thisIndex]['parameters'][$fqParamPos])) { - $iConfigCurValue =& $iConfig[$thisIndex]['parameters'][$fqParamPos]; - } elseif (isset($iConfig[$thisIndex]['parameters'][$fqParamName])) { - $iConfigCurValue =& $iConfig[$thisIndex]['parameters'][$fqParamName]; - } else { - $iConfigCurValue =& $iConfig[$thisIndex]['parameters'][$name]; - } - - if ($type === false && is_string($iConfigCurValue)) { - $computedParams['value'][$fqParamPos] = $iConfigCurValue; - } elseif (is_string($iConfigCurValue) - && isset($aliases[$iConfigCurValue])) { - $computedParams['required'][$fqParamPos] = array( - $iConfig[$thisIndex]['parameters'][$name], - $this->instanceManager->getClassFromAlias($iConfigCurValue) - ); - } elseif (is_string($iConfigCurValue) - && $this->definitions->hasClass($iConfigCurValue)) { - $computedParams['required'][$fqParamPos] = array( - $iConfigCurValue, - $iConfigCurValue - ); - } elseif (is_object($iConfigCurValue) - && $iConfigCurValue instanceof Closure - && $type !== 'Closure') { - $computedParams['value'][$fqParamPos] = $iConfigCurValue(); - } else { - $computedParams['value'][$fqParamPos] = $iConfigCurValue; - } - unset($iConfigCurValue); - continue 2; - } - - } - - // PRIORITY 6 - globally preferred implementations - - // next consult alias level preferred instances - if ($alias && $this->instanceManager->hasTypePreferences($alias)) { - $pInstances = $this->instanceManager->getTypePreferences($alias); - foreach ($pInstances as $pInstance) { - if (is_object($pInstance)) { - $computedParams['value'][$fqParamPos] = $pInstance; - continue 2; - } - $pInstanceClass = ($this->instanceManager->hasAlias($pInstance)) ? - $this->instanceManager->getClassFromAlias($pInstance) : $pInstance; - if ($pInstanceClass === $type || $this->isSubclassOf($pInstanceClass, $type)) { - $computedParams['required'][$fqParamPos] = array($pInstance, $pInstanceClass); - continue 2; - } - } - } - - // next consult class level preferred instances - if ($type && $this->instanceManager->hasTypePreferences($type)) { - $pInstances = $this->instanceManager->getTypePreferences($type); - foreach ($pInstances as $pInstance) { - if (is_object($pInstance)) { - $computedParams['value'][$fqParamPos] = $pInstance; - continue 2; - } - $pInstanceClass = ($this->instanceManager->hasAlias($pInstance)) ? - $this->instanceManager->getClassFromAlias($pInstance) : $pInstance; - if ($pInstanceClass === $type || $this->isSubclassOf($pInstanceClass, $type)) { - $computedParams['required'][$fqParamPos] = array($pInstance, $pInstanceClass); - continue 2; - } - } - } - - if (!$isRequired) { - $computedParams['optional'][$fqParamPos] = true; - } - - if ($type && $isRequired && $methodIsRequired) { - $computedParams['required'][$fqParamPos] = array($type, $type); - } - - } - - $index = 0; - foreach ($methodParameters as $fqParamPos => $value) { - $name = $value[0]; - $defaultValue = $value[3]; - - if (isset($computedParams['value'][$fqParamPos])) { - - // if there is a value supplied, use it - $resolvedParams[$index] = $computedParams['value'][$fqParamPos]; - - } elseif (isset($computedParams['required'][$fqParamPos])) { - - // detect circular dependencies! (they can only happen in instantiators) - if ($isInstantiator - && in_array($computedParams['required'][$fqParamPos][1], $this->currentDependencies)) { - throw new Exception\CircularDependencyException( - "Circular dependency detected: $class depends on {$value[1]} and vice versa" - ); - } - array_push($this->currentDependencies, $class); - $dConfig = $this->instanceManager->getConfig($computedParams['required'][$fqParamPos][0]); - if ($dConfig['shared'] === false) { - $resolvedParams[$index] - = $this->newInstance($computedParams['required'][$fqParamPos][0], $callTimeUserParams, false); - } else { - $resolvedParams[$index] = $this->get($computedParams['required'][$fqParamPos][0]); - } - - array_pop($this->currentDependencies); - - } elseif (!array_key_exists($fqParamPos, $computedParams['optional'])) { - - if ($methodIsRequired) { - // if this item was not marked as optional, - // plus it cannot be resolve, and no value exist, bail out - throw new Exception\MissingPropertyException(sprintf( - 'Missing %s for parameter ' . $name . ' for ' . $class . '::' . $method, - (($value[0] === null) ? 'value' : 'instance/object' ) - )); - } else { - return false; - } - - } else { - $resolvedParams[$index] = $defaultValue; - } - - $index++; - } - - return $resolvedParams; // return ordered list of parameters - } -} diff --git a/lib/Magento/DomDocument/Factory.php b/lib/Magento/DomDocument/Factory.php index 5f7bde0ff6356..f2e575c16c742 100644 --- a/lib/Magento/DomDocument/Factory.php +++ b/lib/Magento/DomDocument/Factory.php @@ -26,6 +26,6 @@ public function __construct(Magento_ObjectManager $objectManager) */ public function createDomDocument() { - return $this->_objectManager->create('DOMDocument', array(), false); + return $this->_objectManager->create('DOMDocument', array()); } } diff --git a/lib/Magento/ObjectManager.php b/lib/Magento/ObjectManager.php index da06c126d5e75..d53c36f0b2348 100644 --- a/lib/Magento/ObjectManager.php +++ b/lib/Magento/ObjectManager.php @@ -31,69 +31,22 @@ interface Magento_ObjectManager * * @param string $className * @param array $arguments - * @param bool $isShared * @return mixed */ - public function create($className, array $arguments = array(), $isShared = true); + public function create($className, array $arguments = array()); /** * Retrieve cached object instance * * @param string $className - * @param array $arguments * @return mixed */ - public function get($className, array $arguments = array()); + public function get($className); /** - * Set DI configuration + * Configure object manager * * @param array $configuration - * @return Magento_ObjectManager - */ - public function setConfiguration(array $configuration = array()); - - /** - * Add shared instance - * - * @param object $instance - * @param string $classOrAlias - * @return Magento_ObjectManager - */ - public function addSharedInstance($instance, $classOrAlias); - - /** - * Remove shared instance - * - * @param string $classOrAlias - * @return Magento_ObjectManager - */ - public function removeSharedInstance($classOrAlias); - - /** - * Check whether object manager has shared instance of given class (alias) - * - * @param string $classOrAlias - * @return bool - */ - public function hasSharedInstance($classOrAlias); - - /** - * Add alias - * - * @param string $alias - * @param string $class - * @param array $parameters - * @return Magento_ObjectManager - * @throws Zend\Di\Exception\InvalidArgumentException - */ - public function addAlias($alias, $class, array $parameters = array()); - - /** - * Get class name by alias - * - * @param string - * @return string|bool */ - public function getClassFromAlias($alias); + public function configure(array $configuration); } diff --git a/lib/Magento/ObjectManager/ContextInterface.php b/lib/Magento/ObjectManager/ContextInterface.php new file mode 100644 index 0000000000000..b30a02f679e39 --- /dev/null +++ b/lib/Magento/ObjectManager/ContextInterface.php @@ -0,0 +1,28 @@ +_signatures, $this->_definitions) = $definitions; + } + + /** + * Unpack signature + * + * @param string $signature + * @return mixed + */ + abstract protected function _unpack($signature); + + /** + * Get list of method parameters + * + * Retrieve an ordered list of constructor parameters. + * Each value is an array with following entries: + * + * array( + * 0, // string: Parameter name + * 1, // string|null: Parameter type + * 2, // bool: whether this param is required + * 3, // mixed: default value + * ); + * + * @param string $className + * @return array|null + */ + public function getParameters($className) + { + $definition = $this->_definitions[$className]; + if ($definition !== null) { + if (is_string($this->_signatures[$definition])) { + $this->_signatures[$definition] = $this->_unpack($this->_signatures[$definition]); + } + return $this->_signatures[$definition]; + } + return null; + } +} diff --git a/lib/Magento/ObjectManager/Definition/Compiled/Binary.php b/lib/Magento/ObjectManager/Definition/Compiled/Binary.php new file mode 100644 index 0000000000000..95ee9de6b429e --- /dev/null +++ b/lib/Magento/ObjectManager/Definition/Compiled/Binary.php @@ -0,0 +1,38 @@ +_reader = $reader ?: new Magento_Code_Reader_ClassReader(); + } + + /** + * Get list of method parameters + * + * Retrieve an ordered list of constructor parameters. + * Each value is an array with following entries: + * + * array( + * 0, // string: Parameter name + * 1, // string|null: Parameter type + * 2, // bool: whether this param is required + * 3, // mixed: default value + * ); + * + * @param string $className + * @return array|null + */ + public function getParameters($className) + { + if (!array_key_exists($className, $this->_definitions)) { + $this->_definitions[$className] = $this->_reader->getConstructor($className); + } + return $this->_definitions[$className]; + } +} diff --git a/lib/Magento/ObjectManager/Factory.php b/lib/Magento/ObjectManager/Factory.php deleted file mode 100644 index 09cfddcf6bb20..0000000000000 --- a/lib/Magento/ObjectManager/Factory.php +++ /dev/null @@ -1,35 +0,0 @@ -_definitions = $definitions ?: new Magento_ObjectManager_Definition_Runtime(); + $this->_sharedInstances = $sharedInstances; + $this->_sharedInstances['Magento_ObjectManager'] = $this; + $this->configure($configuration); + } + + /** + * Resolve constructor arguments + * + * @param string $className + * @param array $parameters + * @param array $arguments + * @return array + * @throws InvalidArgumentException + * @throws LogicException + * @throws BadMethodCallException + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) + */ + protected function _resolveArguments($className, array $parameters, array $arguments = array()) + { + $resolvedArguments = array(); + if (isset($this->_arguments[$className])) { + $arguments = array_replace($this->_arguments[$className], $arguments); + } + $paramPosition = 0; + foreach ($parameters as $parameter) { + list($paramName, $paramType, $paramRequired, $paramDefault) = $parameter; + $argument = null; + $hasPositionalArg = array_key_exists($paramPosition, $arguments); + $hasNamedArg = array_key_exists($paramName, $arguments); + if ($hasPositionalArg && $hasNamedArg) { + throw new InvalidArgumentException( + 'Ambiguous argument $' . $paramName . ': positional and named binding is used at the same time.' + ); + } + if ($hasPositionalArg) { + $argument = $arguments[$paramPosition]; + } else if ($hasNamedArg) { + $argument = $arguments[$paramName]; + } else if ($paramRequired) { + if (!$paramType) { + throw new BadMethodCallException( + 'Missing required argument $' . $paramName . ' for ' . $className . '.' + ); + } + $argument = $paramType; + } else { + $argument = $paramDefault; + } + if ($paramRequired && $paramType && !is_object($argument)) { + if (isset($this->_creationStack[$argument])) { + throw new LogicException( + 'Circular dependency: ' . $argument . ' depends on ' . $className . ' and viceversa.' + ); + } + + $this->_creationStack[$className] = 1; + $argument = isset($this->_nonShared[$argument]) ? + $this->create($argument) : + $this->get($argument); + unset($this->_creationStack[$className]); + } + $resolvedArguments[] = $argument; + $paramPosition++; + } + return $resolvedArguments; + } + + /** + * Resolve Class name + * + * @param string $className + * @return string + * @throws LogicException + */ + protected function _resolveClassName($className) + { + $preferencePath = array(); + while (isset($this->_preferences[$className])) { + if (isset($preferencePath[$this->_preferences[$className]])) { + throw new LogicException( + 'Circular type preference: ' . $className . ' relates to ' + . $this->_preferences[$className] . ' and viceversa.' + ); + } + $className = $this->_preferences[$className]; + $preferencePath[$className] = 1; + } + return $className; + } + + /** + * Create instance with call time arguments + * + * @param string $resolvedClassName + * @param array $arguments + * @return object + * @throws LogicException + * @throws BadMethodCallException + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + */ + protected function _create($resolvedClassName, array $arguments = array()) + { + $parameters = $this->_definitions->getParameters($resolvedClassName); + if ($parameters == null) { + return new $resolvedClassName(); + } + $args = $this->_resolveArguments($resolvedClassName, $parameters, $arguments); + + switch(count($args)) { + case 1: + return new $resolvedClassName($args[0]); + + case 2: + return new $resolvedClassName($args[0], $args[1]); + + case 3: + return new $resolvedClassName($args[0], $args[1], $args[2]); + + case 4: + return new $resolvedClassName($args[0], $args[1], $args[2], $args[3]); + + case 5: + return new $resolvedClassName($args[0], $args[1], $args[2], $args[3], $args[4]); + + case 6: + return new $resolvedClassName($args[0], $args[1], $args[2], $args[3], $args[4], $args[5]); + + case 7: + return new $resolvedClassName($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6]); + + case 8: + return new $resolvedClassName( + $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7] + ); + + case 9: + return new $resolvedClassName( + $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8] + ); + + case 10: + return new $resolvedClassName( + $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9] + ); + + case 11: + return new $resolvedClassName( + $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9], + $args[10] + ); + + case 12: + return new $resolvedClassName( + $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9], + $args[10], $args[11] + ); + + case 13: + return new $resolvedClassName( + $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9], + $args[10], $args[11], $args[12] + ); + + case 14: + return new $resolvedClassName( + $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9], + $args[10], $args[11], $args[12], $args[13] + ); + + case 15: + return new $resolvedClassName( + $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9], + $args[10], $args[11], $args[12], $args[13], $args[14] + ); + + case 16: + return new $resolvedClassName( + $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9], + $args[10], $args[11], $args[12], $args[13], $args[14], $args[15] + ); + + case 17: + return new $resolvedClassName( + $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9], + $args[10], $args[11], $args[12], $args[13], $args[14], $args[15], $args[16] + ); + + case 18: + return new $resolvedClassName( + $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9], + $args[10], $args[11], $args[12], $args[13], $args[14], $args[15], $args[16], $args[17] + ); + + default: + $reflection = new \ReflectionClass($resolvedClassName); + return $reflection->newInstanceArgs($args); + } + } + + /** + * Create new object instance + * + * @param string $className + * @param array $arguments + * @return mixed + */ + public function create($className, array $arguments = array()) + { + if (isset($this->_preferences[$className])) { + $className = $this->_resolveClassName($className); + } + return $this->_create($className, $arguments); + } + + /** + * Retrieve cached object instance + * + * @param string $className + * @return mixed + */ + public function get($className) + { + if (isset($this->_preferences[$className])) { + $className = $this->_resolveClassName($className); + } + if (!isset($this->_sharedInstances[$className])) { + $this->_sharedInstances[$className] = $this->_create($className); + } + return $this->_sharedInstances[$className]; + } + + /** + * Configure di instance + * + * @param array $configuration + */ + public function configure(array $configuration) + { + foreach ($configuration as $key => $curConfig) { + switch ($key) { + case 'preferences': + $this->_preferences = array_replace($this->_preferences, $curConfig); + break; + + default: + if (isset($curConfig['parameters'])) { + if (isset($this->_arguments[$key])) { + $this->_arguments[$key] = array_replace($this->_arguments[$key], $curConfig['parameters']); + } else { + $this->_arguments[$key] = $curConfig['parameters']; + } + } + if (isset($curConfig['shared'])) { + if (!$curConfig['shared'] || $curConfig['shared'] == 'false') { + $this->_nonShared[$key] = 1; + } else { + unset($this->_nonShared[$key]); + } + } + break; + } + } + } +} diff --git a/lib/Magento/ObjectManager/Zend.php b/lib/Magento/ObjectManager/Zend.php deleted file mode 100644 index af6b896c4715f..0000000000000 --- a/lib/Magento/ObjectManager/Zend.php +++ /dev/null @@ -1,189 +0,0 @@ -_di = $diInstance ?: new Magento_Di_Zend(null, $instanceManager, null, $definitionsFile); - $this->_di->instanceManager()->addSharedInstance($this, 'Magento_ObjectManager'); - } - - /** - * Create new object instance - * - * @param string $className - * @param array $arguments - * @param bool $isShared - * @return object - */ - public function create($className, array $arguments = array(), $isShared = true) - { - $object = $this->_di->newInstance($className, $arguments, $isShared); - - return $object; - } - - /** - * Retrieve cached object instance - * - * @param string $className - * @param array $arguments - * @return object - */ - public function get($className, array $arguments = array()) - { - $object = $this->_di->get($className, $arguments); - - return $object; - } - - /** - * Load DI configuration for specified config area - * - * @param array $configuration - * @return Magento_ObjectManager_Zend - */ - public function setConfiguration(array $configuration = array()) - { - if (isset($configuration['preferences']) && is_array($configuration['preferences'])) { - $this->_unsetOldPreferences($configuration['preferences']); - } - $diConfiguration = new Config(array('instance' => $configuration)); - $diConfiguration->configure($this->_di); - - return $this; - } - - /** - * Unset old preferences because preferences from some area must override global preferences - * - * @param array $preferences - */ - protected function _unsetOldPreferences(array $preferences) - { - foreach (array_keys($preferences) as $type) { - $this->_di->instanceManager()->unsetTypePreferences($type); - } - } - - /** - * A proxy for adding shared instance - * - * Normally Di object manager determines a hash based on the class name and incoming arguments. - * But in client code it is inconvenient (or nearly impossible) to "know" arguments for the objects you depend on. - * This is a dirty hack that allows bypassing "hash checking" by Di object manager and therefore referring - * to an instance using class name (or alias), but not specifying its non-injectable arguments. - * - * @param object $instance - * @param string $classOrAlias - * @return Magento_ObjectManager_Zend - */ - public function addSharedInstance($instance, $classOrAlias) - { - $this->_di->instanceManager()->addSharedInstance($instance, $classOrAlias); - - return $this; - } - - /** - * Remove shared instance - * - * @param string $classOrAlias - * @return Magento_ObjectManager_Zend - */ - public function removeSharedInstance($classOrAlias) - { - /** @var $instanceManager Magento_Di_InstanceManager_Zend */ - $instanceManager = $this->_di->instanceManager(); - $instanceManager->removeSharedInstance($classOrAlias); - - return $this; - } - - /** - * Check whether instance manager has shared instance of given class (alias) - * - * @param string $classOrAlias - * @return bool - */ - public function hasSharedInstance($classOrAlias) - { - /** @var $instanceManager Magento_Di_InstanceManager_Zend */ - $instanceManager = $this->_di->instanceManager(); - return $instanceManager->hasSharedInstance($classOrAlias); - } - - /** - * Add alias - * - * @param string $alias - * @param string $class - * @param array $parameters - * @return Magento_ObjectManager_Zend - * @throws Zend\Di\Exception\InvalidArgumentException - */ - public function addAlias($alias, $class, array $parameters = array()) - { - $this->_di->instanceManager()->addAlias($alias, $class, $parameters); - - return $this; - } - - /** - * Get class name by alias - * - * @param string - * @return string|bool - * @throws Zend\Di\Exception\RuntimeException - */ - public function getClassFromAlias($alias) - { - return $this->_di->instanceManager()->getClassFromAlias($alias); - } -} diff --git a/lib/Symfony/Component/Yaml/.gitignore b/lib/Symfony/Component/Yaml/.gitignore new file mode 100644 index 0000000000000..44de97a36a6df --- /dev/null +++ b/lib/Symfony/Component/Yaml/.gitignore @@ -0,0 +1,4 @@ +vendor/ +composer.lock +phpunit.xml + diff --git a/lib/Symfony/Component/Yaml/CHANGELOG.md b/lib/Symfony/Component/Yaml/CHANGELOG.md new file mode 100644 index 0000000000000..096cf654d8058 --- /dev/null +++ b/lib/Symfony/Component/Yaml/CHANGELOG.md @@ -0,0 +1,8 @@ +CHANGELOG +========= + +2.1.0 +----- + + * Yaml::parse() does not evaluate loaded files as PHP files by default + anymore (call Yaml::enablePhpParsing() to get back the old behavior) diff --git a/lib/Symfony/Component/Yaml/Dumper.php b/lib/Symfony/Component/Yaml/Dumper.php new file mode 100644 index 0000000000000..8709f8b7e4628 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Dumper.php @@ -0,0 +1,73 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml; + +/** + * Dumper dumps PHP variables to YAML strings. + * + * @author Fabien Potencier + */ +class Dumper +{ + /** + * The amount of spaces to use for indentation of nested nodes. + * + * @var integer + */ + protected $indentation = 4; + + /** + * Sets the indentation. + * + * @param integer $num The amount of spaces to use for indentation of nested nodes. + */ + public function setIndentation($num) + { + $this->indentation = (int) $num; + } + + /** + * Dumps a PHP value to YAML. + * + * @param mixed $input The PHP value + * @param integer $inline The level where you switch to inline YAML + * @param integer $indent The level of indentation (used internally) + * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param Boolean $objectSupport true if object support is enabled, false otherwise + * + * @return string The YAML representation of the PHP value + */ + public function dump($input, $inline = 0, $indent = 0, $exceptionOnInvalidType = false, $objectSupport = false) + { + $output = ''; + $prefix = $indent ? str_repeat(' ', $indent) : ''; + + if ($inline <= 0 || !is_array($input) || empty($input)) { + $output .= $prefix.Inline::dump($input, $exceptionOnInvalidType, $objectSupport); + } else { + $isAHash = array_keys($input) !== range(0, count($input) - 1); + + foreach ($input as $key => $value) { + $willBeInlined = $inline - 1 <= 0 || !is_array($value) || empty($value); + + $output .= sprintf('%s%s%s%s', + $prefix, + $isAHash ? Inline::dump($key, $exceptionOnInvalidType, $objectSupport).':' : '-', + $willBeInlined ? ' ' : "\n", + $this->dump($value, $inline - 1, $willBeInlined ? 0 : $indent + $this->indentation, $exceptionOnInvalidType, $objectSupport) + ).($willBeInlined ? "\n" : ''); + } + } + + return $output; + } +} diff --git a/lib/Symfony/Component/Yaml/Escaper.php b/lib/Symfony/Component/Yaml/Escaper.php new file mode 100644 index 0000000000000..f77545db95632 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Escaper.php @@ -0,0 +1,88 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml; + +/** + * Escaper encapsulates escaping rules for single and double-quoted + * YAML strings. + * + * @author Matthew Lewinski + */ +class Escaper +{ + // Characters that would cause a dumped string to require double quoting. + const REGEX_CHARACTER_TO_ESCAPE = "[\\x00-\\x1f]|\xc2\x85|\xc2\xa0|\xe2\x80\xa8|\xe2\x80\xa9"; + + // Mapping arrays for escaping a double quoted string. The backslash is + // first to ensure proper escaping because str_replace operates iteratively + // on the input arrays. This ordering of the characters avoids the use of strtr, + // which performs more slowly. + private static $escapees = array('\\\\', '\\"', '"', + "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", + "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f", + "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", + "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f", + "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9"); + private static $escaped = array('\\"', '\\\\', '\\"', + "\\0", "\\x01", "\\x02", "\\x03", "\\x04", "\\x05", "\\x06", "\\a", + "\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\x0e", "\\x0f", + "\\x10", "\\x11", "\\x12", "\\x13", "\\x14", "\\x15", "\\x16", "\\x17", + "\\x18", "\\x19", "\\x1a", "\\e", "\\x1c", "\\x1d", "\\x1e", "\\x1f", + "\\N", "\\_", "\\L", "\\P"); + + /** + * Determines if a PHP value would require double quoting in YAML. + * + * @param string $value A PHP value + * + * @return Boolean True if the value would require double quotes. + */ + public static function requiresDoubleQuoting($value) + { + return preg_match('/'.self::REGEX_CHARACTER_TO_ESCAPE.'/u', $value); + } + + /** + * Escapes and surrounds a PHP value with double quotes. + * + * @param string $value A PHP value + * + * @return string The quoted, escaped string + */ + public static function escapeWithDoubleQuotes($value) + { + return sprintf('"%s"', str_replace(self::$escapees, self::$escaped, $value)); + } + + /** + * Determines if a PHP value would require single quoting in YAML. + * + * @param string $value A PHP value + * + * @return Boolean True if the value would require single quotes. + */ + public static function requiresSingleQuoting($value) + { + return preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ - ? | < > = ! % @ ` ]/x', $value); + } + + /** + * Escapes and surrounds a PHP value with single quotes. + * + * @param string $value A PHP value + * + * @return string The quoted, escaped string + */ + public static function escapeWithSingleQuotes($value) + { + return sprintf("'%s'", str_replace('\'', '\'\'', $value)); + } +} diff --git a/lib/Symfony/Component/Yaml/Exception/DumpException.php b/lib/Symfony/Component/Yaml/Exception/DumpException.php new file mode 100644 index 0000000000000..9b3e6de079588 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Exception/DumpException.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml\Exception; + +/** + * Exception class thrown when an error occurs during dumping. + * + * @author Fabien Potencier + * + * @api + */ +class DumpException extends RuntimeException +{ +} diff --git a/lib/Symfony/Component/Yaml/Exception/ExceptionInterface.php b/lib/Symfony/Component/Yaml/Exception/ExceptionInterface.php new file mode 100644 index 0000000000000..92e5c2ea4e841 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Exception/ExceptionInterface.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml\Exception; + +/** + * Exception interface for all exceptions thrown by the component. + * + * @author Fabien Potencier + * + * @api + */ +interface ExceptionInterface +{ +} diff --git a/lib/Symfony/Component/Yaml/Exception/ParseException.php b/lib/Symfony/Component/Yaml/Exception/ParseException.php new file mode 100644 index 0000000000000..a27a005e6f551 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Exception/ParseException.php @@ -0,0 +1,143 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml\Exception; + +/** + * Exception class thrown when an error occurs during parsing. + * + * @author Fabien Potencier + * + * @api + */ +class ParseException extends RuntimeException +{ + private $parsedFile; + private $parsedLine; + private $snippet; + private $rawMessage; + + /** + * Constructor. + * + * @param string $message The error message + * @param integer $parsedLine The line where the error occurred + * @param integer $snippet The snippet of code near the problem + * @param string $parsedFile The file name where the error occurred + * @param Exception $previous The previous exception + */ + public function __construct($message, $parsedLine = -1, $snippet = null, $parsedFile = null, Exception $previous = null) + { + $this->parsedFile = $parsedFile; + $this->parsedLine = $parsedLine; + $this->snippet = $snippet; + $this->rawMessage = $message; + + $this->updateRepr(); + + parent::__construct($this->message, 0, $previous); + } + + /** + * Gets the snippet of code near the error. + * + * @return string The snippet of code + */ + public function getSnippet() + { + return $this->snippet; + } + + /** + * Sets the snippet of code near the error. + * + * @param string $snippet The code snippet + */ + public function setSnippet($snippet) + { + $this->snippet = $snippet; + + $this->updateRepr(); + } + + /** + * Gets the filename where the error occurred. + * + * This method returns null if a string is parsed. + * + * @return string The filename + */ + public function getParsedFile() + { + return $this->parsedFile; + } + + /** + * Sets the filename where the error occurred. + * + * @param string $parsedFile The filename + */ + public function setParsedFile($parsedFile) + { + $this->parsedFile = $parsedFile; + + $this->updateRepr(); + } + + /** + * Gets the line where the error occurred. + * + * @return integer The file line + */ + public function getParsedLine() + { + return $this->parsedLine; + } + + /** + * Sets the line where the error occurred. + * + * @param integer $parsedLine The file line + */ + public function setParsedLine($parsedLine) + { + $this->parsedLine = $parsedLine; + + $this->updateRepr(); + } + + private function updateRepr() + { + $this->message = $this->rawMessage; + + $dot = false; + if ('.' === substr($this->message, -1)) { + $this->message = substr($this->message, 0, -1); + $dot = true; + } + + if (null !== $this->parsedFile) { + $this->message .= sprintf(' in %s', json_encode($this->parsedFile)); + } + + if ($this->parsedLine >= 0) { + $this->message .= sprintf(' at line %d', $this->parsedLine); + } + + if ($this->snippet) { + $this->message .= sprintf(' (near "%s")', $this->snippet); + } + + if ($dot) { + $this->message .= '.'; + } + } +} diff --git a/lib/Symfony/Component/Yaml/Exception/RuntimeException.php b/lib/Symfony/Component/Yaml/Exception/RuntimeException.php new file mode 100644 index 0000000000000..3573bf15abb81 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Exception/RuntimeException.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml\Exception; + +/** + * Exception class thrown when an error occurs during parsing. + * + * @author Romain Neutron + * + * @api + */ +class RuntimeException extends \RuntimeException implements ExceptionInterface +{ +} diff --git a/lib/Symfony/Component/Yaml/Inline.php b/lib/Symfony/Component/Yaml/Inline.php new file mode 100644 index 0000000000000..21a121a060dbf --- /dev/null +++ b/lib/Symfony/Component/Yaml/Inline.php @@ -0,0 +1,467 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml; + +use Symfony\Component\Yaml\Exception\ParseException; +use Symfony\Component\Yaml\Exception\DumpException; + +/** + * Inline implements a YAML parser/dumper for the YAML inline syntax. + * + * @author Fabien Potencier + */ +class Inline +{ + const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\']*(?:\'\'[^\']*)*)\')'; + + private static $exceptionOnInvalidType = false; + private static $objectSupport = false; + + /** + * Converts a YAML string to a PHP array. + * + * @param string $value A YAML string + * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param Boolean $objectSupport true if object support is enabled, false otherwise + * + * @return array A PHP array representing the YAML string + * + * @throws ParseException + */ + public static function parse($value, $exceptionOnInvalidType = false, $objectSupport = false) + { + self::$exceptionOnInvalidType = $exceptionOnInvalidType; + self::$objectSupport = $objectSupport; + + $value = trim($value); + + if (0 == strlen($value)) { + return ''; + } + + if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) { + $mbEncoding = mb_internal_encoding(); + mb_internal_encoding('ASCII'); + } + + $i = 0; + switch ($value[0]) { + case '[': + $result = self::parseSequence($value, $i); + ++$i; + break; + case '{': + $result = self::parseMapping($value, $i); + ++$i; + break; + default: + $result = self::parseScalar($value, null, array('"', "'"), $i); + } + + // some comments are allowed at the end + if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) { + throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i))); + } + + if (isset($mbEncoding)) { + mb_internal_encoding($mbEncoding); + } + + return $result; + } + + /** + * Dumps a given PHP variable to a YAML string. + * + * @param mixed $value The PHP variable to convert + * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param Boolean $objectSupport true if object support is enabled, false otherwise + * + * @return string The YAML string representing the PHP array + * + * @throws DumpException When trying to dump PHP resource + */ + public static function dump($value, $exceptionOnInvalidType = false, $objectSupport = false) + { + switch (true) { + case is_resource($value): + if ($exceptionOnInvalidType) { + throw new DumpException(sprintf('Unable to dump PHP resources in a YAML file ("%s").', get_resource_type($value))); + } + + return 'null'; + case is_object($value): + if ($objectSupport) { + return '!!php/object:'.serialize($value); + } + + if ($exceptionOnInvalidType) { + throw new DumpException('Object support when dumping a YAML file has been disabled.'); + } + + return 'null'; + case is_array($value): + return self::dumpArray($value, $exceptionOnInvalidType, $objectSupport); + case null === $value: + return 'null'; + case true === $value: + return 'true'; + case false === $value: + return 'false'; + case ctype_digit($value): + return is_string($value) ? "'$value'" : (int) $value; + case is_numeric($value): + $locale = setlocale(LC_NUMERIC, 0); + if (false !== $locale) { + setlocale(LC_NUMERIC, 'C'); + } + $repr = is_string($value) ? "'$value'" : (is_infinite($value) ? str_ireplace('INF', '.Inf', strval($value)) : strval($value)); + + if (false !== $locale) { + setlocale(LC_NUMERIC, $locale); + } + + return $repr; + case Escaper::requiresDoubleQuoting($value): + return Escaper::escapeWithDoubleQuotes($value); + case Escaper::requiresSingleQuoting($value): + return Escaper::escapeWithSingleQuotes($value); + case '' == $value: + return "''"; + case preg_match(self::getTimestampRegex(), $value): + case in_array(strtolower($value), array('null', '~', 'true', 'false')): + return "'$value'"; + default: + return $value; + } + } + + /** + * Dumps a PHP array to a YAML string. + * + * @param array $value The PHP array to dump + * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param Boolean $objectSupport true if object support is enabled, false otherwise + * + * @return string The YAML string representing the PHP array + */ + private static function dumpArray($value, $exceptionOnInvalidType, $objectSupport) + { + // array + $keys = array_keys($value); + if ((1 == count($keys) && '0' == $keys[0]) + || (count($keys) > 1 && array_reduce($keys, function ($v, $w) { return (integer) $v + $w; }, 0) == count($keys) * (count($keys) - 1) / 2) + ) { + $output = array(); + foreach ($value as $val) { + $output[] = self::dump($val, $exceptionOnInvalidType, $objectSupport); + } + + return sprintf('[%s]', implode(', ', $output)); + } + + // mapping + $output = array(); + foreach ($value as $key => $val) { + $output[] = sprintf('%s: %s', self::dump($key, $exceptionOnInvalidType, $objectSupport), self::dump($val, $exceptionOnInvalidType, $objectSupport)); + } + + return sprintf('{ %s }', implode(', ', $output)); + } + + /** + * Parses a scalar to a YAML string. + * + * @param scalar $scalar + * @param string $delimiters + * @param array $stringDelimiters + * @param integer &$i + * @param Boolean $evaluate + * + * @return string A YAML string + * + * @throws ParseException When malformed inline YAML string is parsed + */ + public static function parseScalar($scalar, $delimiters = null, $stringDelimiters = array('"', "'"), &$i = 0, $evaluate = true) + { + if (in_array($scalar[$i], $stringDelimiters)) { + // quoted scalar + $output = self::parseQuotedScalar($scalar, $i); + + if (null !== $delimiters) { + $tmp = ltrim(substr($scalar, $i), ' '); + if (!in_array($tmp[0], $delimiters)) { + throw new ParseException(sprintf('Unexpected characters (%s).', substr($scalar, $i))); + } + } + } else { + // "normal" string + if (!$delimiters) { + $output = substr($scalar, $i); + $i += strlen($output); + + // remove comments + if (false !== $strpos = strpos($output, ' #')) { + $output = rtrim(substr($output, 0, $strpos)); + } + } elseif (preg_match('/^(.+?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) { + $output = $match[1]; + $i += strlen($output); + } else { + throw new ParseException(sprintf('Malformed inline YAML string (%s).', $scalar)); + } + + $output = $evaluate ? self::evaluateScalar($output) : $output; + } + + return $output; + } + + /** + * Parses a quoted scalar to YAML. + * + * @param string $scalar + * @param integer &$i + * + * @return string A YAML string + * + * @throws ParseException When malformed inline YAML string is parsed + */ + private static function parseQuotedScalar($scalar, &$i) + { + // Only check the current item we're dealing with (for sequences) + $subject = substr($scalar, $i); + $items = preg_split('/[\'"]\s*(?:[,:]|[}\]]\s*,)/', $subject); + $subject = substr($subject, 0, strlen($items[0]) + 1); + + if (!preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) { + throw new ParseException(sprintf('Malformed inline YAML string (%s).', substr($scalar, $i))); + } + + $output = substr($match[0], 1, strlen($match[0]) - 2); + + $unescaper = new Unescaper(); + if ('"' == $scalar[$i]) { + $output = $unescaper->unescapeDoubleQuotedString($output); + } else { + $output = $unescaper->unescapeSingleQuotedString($output); + } + + $i += strlen($match[0]); + + return $output; + } + + /** + * Parses a sequence to a YAML string. + * + * @param string $sequence + * @param integer &$i + * + * @return string A YAML string + * + * @throws ParseException When malformed inline YAML string is parsed + */ + private static function parseSequence($sequence, &$i = 0) + { + $output = array(); + $len = strlen($sequence); + $i += 1; + + // [foo, bar, ...] + while ($i < $len) { + switch ($sequence[$i]) { + case '[': + // nested sequence + $output[] = self::parseSequence($sequence, $i); + break; + case '{': + // nested mapping + $output[] = self::parseMapping($sequence, $i); + break; + case ']': + return $output; + case ',': + case ' ': + break; + default: + $isQuoted = in_array($sequence[$i], array('"', "'")); + $value = self::parseScalar($sequence, array(',', ']'), array('"', "'"), $i); + + if (!$isQuoted && false !== strpos($value, ': ')) { + // embedded mapping? + try { + $value = self::parseMapping('{'.$value.'}'); + } catch (\InvalidArgumentException $e) { + // no, it's not + } + } + + $output[] = $value; + + --$i; + } + + ++$i; + } + + throw new ParseException(sprintf('Malformed inline YAML string %s', $sequence)); + } + + /** + * Parses a mapping to a YAML string. + * + * @param string $mapping + * @param integer &$i + * + * @return string A YAML string + * + * @throws ParseException When malformed inline YAML string is parsed + */ + private static function parseMapping($mapping, &$i = 0) + { + $output = array(); + $len = strlen($mapping); + $i += 1; + + // {foo: bar, bar:foo, ...} + while ($i < $len) { + switch ($mapping[$i]) { + case ' ': + case ',': + ++$i; + continue 2; + case '}': + return $output; + } + + // key + $key = self::parseScalar($mapping, array(':', ' '), array('"', "'"), $i, false); + + // value + $done = false; + while ($i < $len) { + switch ($mapping[$i]) { + case '[': + // nested sequence + $output[$key] = self::parseSequence($mapping, $i); + $done = true; + break; + case '{': + // nested mapping + $output[$key] = self::parseMapping($mapping, $i); + $done = true; + break; + case ':': + case ' ': + break; + default: + $output[$key] = self::parseScalar($mapping, array(',', '}'), array('"', "'"), $i); + $done = true; + --$i; + } + + ++$i; + + if ($done) { + continue 2; + } + } + } + + throw new ParseException(sprintf('Malformed inline YAML string %s', $mapping)); + } + + /** + * Evaluates scalars and replaces magic values. + * + * @param string $scalar + * + * @return string A YAML string + */ + private static function evaluateScalar($scalar) + { + $scalar = trim($scalar); + + switch (true) { + case 'null' == strtolower($scalar): + case '' == $scalar: + case '~' == $scalar: + return null; + case 0 === strpos($scalar, '!str'): + return (string) substr($scalar, 5); + case 0 === strpos($scalar, '! '): + return intval(self::parseScalar(substr($scalar, 2))); + case 0 === strpos($scalar, '!!php/object:'): + if (self::$objectSupport) { + return unserialize(substr($scalar, 13)); + } + + if (self::$exceptionOnInvalidType) { + throw new ParseException('Object support when parsing a YAML file has been disabled.'); + } + + return null; + case ctype_digit($scalar): + $raw = $scalar; + $cast = intval($scalar); + + return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw); + case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)): + $raw = $scalar; + $cast = intval($scalar); + + return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw); + case 'true' === strtolower($scalar): + return true; + case 'false' === strtolower($scalar): + return false; + case is_numeric($scalar): + return '0x' == $scalar[0].$scalar[1] ? hexdec($scalar) : floatval($scalar); + case 0 == strcasecmp($scalar, '.inf'): + case 0 == strcasecmp($scalar, '.NaN'): + return -log(0); + case 0 == strcasecmp($scalar, '-.inf'): + return log(0); + case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar): + return floatval(str_replace(',', '', $scalar)); + case preg_match(self::getTimestampRegex(), $scalar): + return strtotime($scalar); + default: + return (string) $scalar; + } + } + + /** + * Gets a regex that matches a YAML date. + * + * @return string The regular expression + * + * @see http://www.yaml.org/spec/1.2/spec.html#id2761573 + */ + private static function getTimestampRegex() + { + return <<[0-9][0-9][0-9][0-9]) + -(?P[0-9][0-9]?) + -(?P[0-9][0-9]?) + (?:(?:[Tt]|[ \t]+) + (?P[0-9][0-9]?) + :(?P[0-9][0-9]) + :(?P[0-9][0-9]) + (?:\.(?P[0-9]*))? + (?:[ \t]*(?PZ|(?P[-+])(?P[0-9][0-9]?) + (?::(?P[0-9][0-9]))?))?)? + $~x +EOF; + } +} diff --git a/lib/Symfony/Component/Yaml/LICENSE b/lib/Symfony/Component/Yaml/LICENSE new file mode 100644 index 0000000000000..88a57f8d8da49 --- /dev/null +++ b/lib/Symfony/Component/Yaml/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2004-2013 Fabien Potencier + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/lib/Symfony/Component/Yaml/Parser.php b/lib/Symfony/Component/Yaml/Parser.php new file mode 100644 index 0000000000000..8129b41e070c4 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Parser.php @@ -0,0 +1,621 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml; + +use Symfony\Component\Yaml\Exception\ParseException; + +/** + * Parser parses YAML strings to convert them to PHP arrays. + * + * @author Fabien Potencier + */ +class Parser +{ + private $offset = 0; + private $lines = array(); + private $currentLineNb = -1; + private $currentLine = ''; + private $refs = array(); + + /** + * Constructor + * + * @param integer $offset The offset of YAML document (used for line numbers in error messages) + */ + public function __construct($offset = 0) + { + $this->offset = $offset; + } + + /** + * Parses a YAML string to a PHP value. + * + * @param string $value A YAML string + * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param Boolean $objectSupport true if object support is enabled, false otherwise + * + * @return mixed A PHP value + * + * @throws ParseException If the YAML is not valid + */ + public function parse($value, $exceptionOnInvalidType = false, $objectSupport = false) + { + $this->currentLineNb = -1; + $this->currentLine = ''; + $this->lines = explode("\n", $this->cleanup($value)); + + if (function_exists('mb_detect_encoding') && false === mb_detect_encoding($value, 'UTF-8', true)) { + throw new ParseException('The YAML value does not appear to be valid UTF-8.'); + } + + if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) { + $mbEncoding = mb_internal_encoding(); + mb_internal_encoding('UTF-8'); + } + + $data = array(); + $context = null; + while ($this->moveToNextLine()) { + if ($this->isCurrentLineEmpty()) { + continue; + } + + // tab? + if ("\t" === $this->currentLine[0]) { + throw new ParseException('A YAML file cannot contain tabs as indentation.', $this->getRealCurrentLineNb() + 1, $this->currentLine); + } + + $isRef = $isInPlace = $isProcessed = false; + if (preg_match('#^\-((?P\s+)(?P.+?))?\s*$#u', $this->currentLine, $values)) { + if ($context && 'mapping' == $context) { + throw new ParseException('You cannot define a sequence item when in a mapping'); + } + $context = 'sequence'; + + if (isset($values['value']) && preg_match('#^&(?P[^ ]+) *(?P.*)#u', $values['value'], $matches)) { + $isRef = $matches['ref']; + $values['value'] = $matches['value']; + } + + // array + if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) { + $c = $this->getRealCurrentLineNb() + 1; + $parser = new Parser($c); + $parser->refs =& $this->refs; + $data[] = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport); + } else { + if (isset($values['leadspaces']) + && ' ' == $values['leadspaces'] + && preg_match('#^(?P'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P.+?))?\s*$#u', $values['value'], $matches) + ) { + // this is a compact notation element, add to next block and parse + $c = $this->getRealCurrentLineNb(); + $parser = new Parser($c); + $parser->refs =& $this->refs; + + $block = $values['value']; + if (!$this->isNextLineIndented()) { + $block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + 2); + } + + $data[] = $parser->parse($block, $exceptionOnInvalidType, $objectSupport); + } else { + $data[] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport); + } + } + } elseif (preg_match('#^(?P'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P.+?))?\s*$#u', $this->currentLine, $values)) { + if ($context && 'sequence' == $context) { + throw new ParseException('You cannot define a mapping item when in a sequence'); + } + $context = 'mapping'; + + // force correct settings + Inline::parse(null, $exceptionOnInvalidType, $objectSupport); + try { + $key = Inline::parseScalar($values['key']); + } catch (ParseException $e) { + $e->setParsedLine($this->getRealCurrentLineNb() + 1); + $e->setSnippet($this->currentLine); + + throw $e; + } + + if ('<<' === $key) { + if (isset($values['value']) && 0 === strpos($values['value'], '*')) { + $isInPlace = substr($values['value'], 1); + if (!array_key_exists($isInPlace, $this->refs)) { + throw new ParseException(sprintf('Reference "%s" does not exist.', $isInPlace), $this->getRealCurrentLineNb() + 1, $this->currentLine); + } + } else { + if (isset($values['value']) && $values['value'] !== '') { + $value = $values['value']; + } else { + $value = $this->getNextEmbedBlock(); + } + $c = $this->getRealCurrentLineNb() + 1; + $parser = new Parser($c); + $parser->refs =& $this->refs; + $parsed = $parser->parse($value, $exceptionOnInvalidType, $objectSupport); + + $merged = array(); + if (!is_array($parsed)) { + throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine); + } elseif (isset($parsed[0])) { + // Numeric array, merge individual elements + foreach (array_reverse($parsed) as $parsedItem) { + if (!is_array($parsedItem)) { + throw new ParseException('Merge items must be arrays.', $this->getRealCurrentLineNb() + 1, $parsedItem); + } + $merged = array_merge($parsedItem, $merged); + } + } else { + // Associative array, merge + $merged = array_merge($merged, $parsed); + } + + $isProcessed = $merged; + } + } elseif (isset($values['value']) && preg_match('#^&(?P[^ ]+) *(?P.*)#u', $values['value'], $matches)) { + $isRef = $matches['ref']; + $values['value'] = $matches['value']; + } + + if ($isProcessed) { + // Merge keys + $data = $isProcessed; + // hash + } elseif (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) { + // if next line is less indented or equal, then it means that the current value is null + if ($this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) { + $data[$key] = null; + } else { + $c = $this->getRealCurrentLineNb() + 1; + $parser = new Parser($c); + $parser->refs =& $this->refs; + $data[$key] = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport); + } + } else { + if ($isInPlace) { + $data = $this->refs[$isInPlace]; + } else { + $data[$key] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport); + } + } + } else { + // 1-liner optionally followed by newline + $lineCount = count($this->lines); + if (1 === $lineCount || (2 === $lineCount && empty($this->lines[1]))) { + try { + $value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport); + } catch (ParseException $e) { + $e->setParsedLine($this->getRealCurrentLineNb() + 1); + $e->setSnippet($this->currentLine); + + throw $e; + } + + if (is_array($value)) { + $first = reset($value); + if (is_string($first) && 0 === strpos($first, '*')) { + $data = array(); + foreach ($value as $alias) { + $data[] = $this->refs[substr($alias, 1)]; + } + $value = $data; + } + } + + if (isset($mbEncoding)) { + mb_internal_encoding($mbEncoding); + } + + return $value; + } + + switch (preg_last_error()) { + case PREG_INTERNAL_ERROR: + $error = 'Internal PCRE error.'; + break; + case PREG_BACKTRACK_LIMIT_ERROR: + $error = 'pcre.backtrack_limit reached.'; + break; + case PREG_RECURSION_LIMIT_ERROR: + $error = 'pcre.recursion_limit reached.'; + break; + case PREG_BAD_UTF8_ERROR: + $error = 'Malformed UTF-8 data.'; + break; + case PREG_BAD_UTF8_OFFSET_ERROR: + $error = 'Offset doesn\'t correspond to the begin of a valid UTF-8 code point.'; + break; + default: + $error = 'Unable to parse.'; + } + + throw new ParseException($error, $this->getRealCurrentLineNb() + 1, $this->currentLine); + } + + if ($isRef) { + $this->refs[$isRef] = end($data); + } + } + + if (isset($mbEncoding)) { + mb_internal_encoding($mbEncoding); + } + + return empty($data) ? null : $data; + } + + /** + * Returns the current line number (takes the offset into account). + * + * @return integer The current line number + */ + private function getRealCurrentLineNb() + { + return $this->currentLineNb + $this->offset; + } + + /** + * Returns the current line indentation. + * + * @return integer The current line indentation + */ + private function getCurrentLineIndentation() + { + return strlen($this->currentLine) - strlen(ltrim($this->currentLine, ' ')); + } + + /** + * Returns the next embed block of YAML. + * + * @param integer $indentation The indent level at which the block is to be read, or null for default + * + * @return string A YAML string + * + * @throws ParseException When indentation problem are detected + */ + private function getNextEmbedBlock($indentation = null) + { + $this->moveToNextLine(); + + if (null === $indentation) { + $newIndent = $this->getCurrentLineIndentation(); + + $unindentedEmbedBlock = $this->isStringUnIndentedCollectionItem($this->currentLine); + + if (!$this->isCurrentLineEmpty() && 0 === $newIndent && !$unindentedEmbedBlock) { + throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine); + } + } else { + $newIndent = $indentation; + } + + $data = array(substr($this->currentLine, $newIndent)); + + $isItUnindentedCollection = $this->isStringUnIndentedCollectionItem($this->currentLine); + + while ($this->moveToNextLine()) { + + if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem($this->currentLine)) { + $this->moveToPreviousLine(); + break; + } + + if ($this->isCurrentLineEmpty()) { + if ($this->isCurrentLineBlank()) { + $data[] = substr($this->currentLine, $newIndent); + } + + continue; + } + + $indent = $this->getCurrentLineIndentation(); + + if (preg_match('#^(?P *)$#', $this->currentLine, $match)) { + // empty line + $data[] = $match['text']; + } elseif ($indent >= $newIndent) { + $data[] = substr($this->currentLine, $newIndent); + } elseif (0 == $indent) { + $this->moveToPreviousLine(); + + break; + } else { + throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine); + } + } + + return implode("\n", $data); + } + + /** + * Moves the parser to the next line. + * + * @return Boolean + */ + private function moveToNextLine() + { + if ($this->currentLineNb >= count($this->lines) - 1) { + return false; + } + + $this->currentLine = $this->lines[++$this->currentLineNb]; + + return true; + } + + /** + * Moves the parser to the previous line. + */ + private function moveToPreviousLine() + { + $this->currentLine = $this->lines[--$this->currentLineNb]; + } + + /** + * Parses a YAML value. + * + * @param string $value A YAML value + * + * @return mixed A PHP value + * + * @throws ParseException When reference does not exist + */ + private function parseValue($value, $exceptionOnInvalidType, $objectSupport) + { + if (0 === strpos($value, '*')) { + if (false !== $pos = strpos($value, '#')) { + $value = substr($value, 1, $pos - 2); + } else { + $value = substr($value, 1); + } + + if (!array_key_exists($value, $this->refs)) { + throw new ParseException(sprintf('Reference "%s" does not exist.', $value), $this->currentLine); + } + + return $this->refs[$value]; + } + + if (preg_match('/^(?P\||>)(?P\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P +#.*)?$/', $value, $matches)) { + $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : ''; + + return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), intval(abs($modifiers))); + } + + try { + return Inline::parse($value, $exceptionOnInvalidType, $objectSupport); + } catch (ParseException $e) { + $e->setParsedLine($this->getRealCurrentLineNb() + 1); + $e->setSnippet($this->currentLine); + + throw $e; + } + } + + /** + * Parses a folded scalar. + * + * @param string $separator The separator that was used to begin this folded scalar (| or >) + * @param string $indicator The indicator that was used to begin this folded scalar (+ or -) + * @param integer $indentation The indentation that was used to begin this folded scalar + * + * @return string The text value + */ + private function parseFoldedScalar($separator, $indicator = '', $indentation = 0) + { + $separator = '|' == $separator ? "\n" : ' '; + $text = ''; + + $notEOF = $this->moveToNextLine(); + + while ($notEOF && $this->isCurrentLineBlank()) { + $text .= "\n"; + + $notEOF = $this->moveToNextLine(); + } + + if (!$notEOF) { + return ''; + } + + if (!preg_match('#^(?P'.($indentation ? str_repeat(' ', $indentation) : ' +').')(?P.*)$#u', $this->currentLine, $matches)) { + $this->moveToPreviousLine(); + + return ''; + } + + $textIndent = $matches['indent']; + $previousIndent = 0; + + $text .= $matches['text'].$separator; + while ($this->currentLineNb + 1 < count($this->lines)) { + $this->moveToNextLine(); + + if (preg_match('#^(?P {'.strlen($textIndent).',})(?P.+)$#u', $this->currentLine, $matches)) { + if (' ' == $separator && $previousIndent != $matches['indent']) { + $text = substr($text, 0, -1)."\n"; + } + $previousIndent = $matches['indent']; + + $text .= str_repeat(' ', $diff = strlen($matches['indent']) - strlen($textIndent)).$matches['text'].($diff ? "\n" : $separator); + } elseif (preg_match('#^(?P *)$#', $this->currentLine, $matches)) { + $text .= preg_replace('#^ {1,'.strlen($textIndent).'}#', '', $matches['text'])."\n"; + } else { + $this->moveToPreviousLine(); + + break; + } + } + + if (' ' == $separator) { + // replace last separator by a newline + $text = preg_replace('/ (\n*)$/', "\n$1", $text); + } + + switch ($indicator) { + case '': + $text = preg_replace('#\n+$#s', "\n", $text); + break; + case '+': + break; + case '-': + $text = preg_replace('#\n+$#s', '', $text); + break; + } + + return $text; + } + + /** + * Returns true if the next line is indented. + * + * @return Boolean Returns true if the next line is indented, false otherwise + */ + private function isNextLineIndented() + { + $currentIndentation = $this->getCurrentLineIndentation(); + $notEOF = $this->moveToNextLine(); + + while ($notEOF && $this->isCurrentLineEmpty()) { + $notEOF = $this->moveToNextLine(); + } + + if (false === $notEOF) { + return false; + } + + $ret = false; + if ($this->getCurrentLineIndentation() <= $currentIndentation) { + $ret = true; + } + + $this->moveToPreviousLine(); + + return $ret; + } + + /** + * Returns true if the current line is blank or if it is a comment line. + * + * @return Boolean Returns true if the current line is empty or if it is a comment line, false otherwise + */ + private function isCurrentLineEmpty() + { + return $this->isCurrentLineBlank() || $this->isCurrentLineComment(); + } + + /** + * Returns true if the current line is blank. + * + * @return Boolean Returns true if the current line is blank, false otherwise + */ + private function isCurrentLineBlank() + { + return '' == trim($this->currentLine, ' '); + } + + /** + * Returns true if the current line is a comment line. + * + * @return Boolean Returns true if the current line is a comment line, false otherwise + */ + private function isCurrentLineComment() + { + //checking explicitly the first char of the trim is faster than loops or strpos + $ltrimmedLine = ltrim($this->currentLine, ' '); + + return $ltrimmedLine[0] === '#'; + } + + /** + * Cleanups a YAML string to be parsed. + * + * @param string $value The input YAML string + * + * @return string A cleaned up YAML string + */ + private function cleanup($value) + { + $value = str_replace(array("\r\n", "\r"), "\n", $value); + + // strip YAML header + $count = 0; + $value = preg_replace('#^\%YAML[: ][\d\.]+.*\n#su', '', $value, -1, $count); + $this->offset += $count; + + // remove leading comments + $trimmedValue = preg_replace('#^(\#.*?\n)+#s', '', $value, -1, $count); + if ($count == 1) { + // items have been removed, update the offset + $this->offset += substr_count($value, "\n") - substr_count($trimmedValue, "\n"); + $value = $trimmedValue; + } + + // remove start of the document marker (---) + $trimmedValue = preg_replace('#^\-\-\-.*?\n#s', '', $value, -1, $count); + if ($count == 1) { + // items have been removed, update the offset + $this->offset += substr_count($value, "\n") - substr_count($trimmedValue, "\n"); + $value = $trimmedValue; + + // remove end of the document marker (...) + $value = preg_replace('#\.\.\.\s*$#s', '', $value); + } + + return $value; + } + + /** + * Returns true if the next line starts unindented collection + * + * @return Boolean Returns true if the next line starts unindented collection, false otherwise + */ + private function isNextLineUnIndentedCollection() + { + $currentIndentation = $this->getCurrentLineIndentation(); + $notEOF = $this->moveToNextLine(); + + while ($notEOF && $this->isCurrentLineEmpty()) { + $notEOF = $this->moveToNextLine(); + } + + if (false === $notEOF) { + return false; + } + + $ret = false; + if ( + $this->getCurrentLineIndentation() == $currentIndentation + && + $this->isStringUnIndentedCollectionItem($this->currentLine) + ) { + $ret = true; + } + + $this->moveToPreviousLine(); + + return $ret; + } + + /** + * Returns true if the string is un-indented collection item + * + * @return Boolean Returns true if the string is un-indented collection item, false otherwise + */ + private function isStringUnIndentedCollectionItem() + { + return (0 === strpos($this->currentLine, '- ')); + } + +} diff --git a/lib/Symfony/Component/Yaml/README.md b/lib/Symfony/Component/Yaml/README.md new file mode 100644 index 0000000000000..0864e49dca05e --- /dev/null +++ b/lib/Symfony/Component/Yaml/README.md @@ -0,0 +1,19 @@ +Yaml Component +============== + +YAML implements most of the YAML 1.2 specification. + + use Symfony\Component\Yaml\Yaml; + + $array = Yaml::parse($file); + + print Yaml::dump($array); + +Resources +--------- + +You can run the unit tests with the following command: + + $ cd path/to/Symfony/Component/Yaml/ + $ composer.phar install --dev + $ phpunit diff --git a/lib/Symfony/Component/Yaml/Tests/DumperTest.php b/lib/Symfony/Component/Yaml/Tests/DumperTest.php new file mode 100644 index 0000000000000..1199118d77981 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/DumperTest.php @@ -0,0 +1,181 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml\Tests; + +use Symfony\Component\Yaml\Yaml; +use Symfony\Component\Yaml\Parser; +use Symfony\Component\Yaml\Dumper; + +class DumperTest extends \PHPUnit_Framework_TestCase +{ + protected $parser; + protected $dumper; + protected $path; + + protected function setUp() + { + $this->parser = new Parser(); + $this->dumper = new Dumper(); + $this->path = __DIR__.'/Fixtures'; + } + + protected function tearDown() + { + $this->parser = null; + $this->dumper = null; + $this->path = null; + } + + public function testSpecifications() + { + $files = $this->parser->parse(file_get_contents($this->path.'/index.yml')); + foreach ($files as $file) { + $yamls = file_get_contents($this->path.'/'.$file.'.yml'); + + // split YAMLs documents + foreach (preg_split('/^---( %YAML\:1\.0)?/m', $yamls) as $yaml) { + if (!$yaml) { + continue; + } + + $test = $this->parser->parse($yaml); + if (isset($test['dump_skip']) && $test['dump_skip']) { + continue; + } elseif (isset($test['todo']) && $test['todo']) { + // TODO + } else { + $expected = eval('return '.trim($test['php']).';'); + + $this->assertEquals($expected, $this->parser->parse($this->dumper->dump($expected, 10)), $test['test']); + } + } + } + } + + public function testInlineLevel() + { + // inline level + $array = array( + '' => 'bar', + 'foo' => '#bar', + 'foo\'bar' => array(), + 'bar' => array(1, 'foo'), + 'foobar' => array( + 'foo' => 'bar', + 'bar' => array(1, 'foo'), + 'foobar' => array( + 'foo' => 'bar', + 'bar' => array(1, 'foo'), + ), + ), + ); + + $expected = <<assertEquals($expected, $this->dumper->dump($array, -10), '->dump() takes an inline level argument'); +$this->assertEquals($expected, $this->dumper->dump($array, 0), '->dump() takes an inline level argument'); + +$expected = <<assertEquals($expected, $this->dumper->dump($array, 1), '->dump() takes an inline level argument'); + + $expected = <<assertEquals($expected, $this->dumper->dump($array, 2), '->dump() takes an inline level argument'); + + $expected = <<assertEquals($expected, $this->dumper->dump($array, 3), '->dump() takes an inline level argument'); + + $expected = <<assertEquals($expected, $this->dumper->dump($array, 4), '->dump() takes an inline level argument'); + $this->assertEquals($expected, $this->dumper->dump($array, 10), '->dump() takes an inline level argument'); + } + + public function testObjectSupportEnabled() + { + $dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, false, true); + + $this->assertEquals('{ foo: !!php/object:O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}, bar: 1 }', $dump, '->dump() is able to dump objects'); + } + + public function testObjectSupportDisabledButNoExceptions() + { + $dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1)); + + $this->assertEquals('{ foo: null, bar: 1 }', $dump, '->dump() does not dump objects when disabled'); + } + + /** + * @expectedException \Symfony\Component\Yaml\Exception\DumpException + */ + public function testObjectSupportDisabledWithExceptions() + { + $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, true, false); + } +} + +class A +{ + public $a = 'foo'; +} diff --git a/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsAnchorAlias.yml b/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsAnchorAlias.yml new file mode 100644 index 0000000000000..5f9c94275b7d2 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsAnchorAlias.yml @@ -0,0 +1,31 @@ +--- %YAML:1.0 +test: Simple Alias Example +brief: > + If you need to refer to the same item of data twice, + you can give that item an alias. The alias is a plain + string, starting with an ampersand. The item may then + be referred to by the alias throughout your document + by using an asterisk before the name of the alias. + This is called an anchor. +yaml: | + - &showell Steve + - Clark + - Brian + - Oren + - *showell +php: | + array('Steve', 'Clark', 'Brian', 'Oren', 'Steve') + +--- +test: Alias of a Mapping +brief: > + An alias can be used on any item of data, including + sequences, mappings, and other complex data types. +yaml: | + - &hello + Meat: pork + Starch: potato + - banana + - *hello +php: | + array(array('Meat'=>'pork', 'Starch'=>'potato'), 'banana', array('Meat'=>'pork', 'Starch'=>'potato')) diff --git a/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsBasicTests.yml b/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsBasicTests.yml new file mode 100644 index 0000000000000..5542b0dc6326c --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsBasicTests.yml @@ -0,0 +1,178 @@ +--- %YAML:1.0 +test: Simple Sequence +brief: | + You can specify a list in YAML by placing each + member of the list on a new line with an opening + dash. These lists are called sequences. +yaml: | + - apple + - banana + - carrot +php: | + array('apple', 'banana', 'carrot') +--- +test: Nested Sequences +brief: | + You can include a sequence within another + sequence by giving the sequence an empty + dash, followed by an indented list. +yaml: | + - + - foo + - bar + - baz +php: | + array(array('foo', 'bar', 'baz')) +--- +test: Mixed Sequences +brief: | + Sequences can contain any YAML data, + including strings and other sequences. +yaml: | + - apple + - + - foo + - bar + - x123 + - banana + - carrot +php: | + array('apple', array('foo', 'bar', 'x123'), 'banana', 'carrot') +--- +test: Deeply Nested Sequences +brief: | + Sequences can be nested even deeper, with each + level of indentation representing a level of + depth. +yaml: | + - + - + - uno + - dos +php: | + array(array(array('uno', 'dos'))) +--- +test: Simple Mapping +brief: | + You can add a keyed list (also known as a dictionary or + hash) to your document by placing each member of the + list on a new line, with a colon seperating the key + from its value. In YAML, this type of list is called + a mapping. +yaml: | + foo: whatever + bar: stuff +php: | + array('foo' => 'whatever', 'bar' => 'stuff') +--- +test: Sequence in a Mapping +brief: | + A value in a mapping can be a sequence. +yaml: | + foo: whatever + bar: + - uno + - dos +php: | + array('foo' => 'whatever', 'bar' => array('uno', 'dos')) +--- +test: Nested Mappings +brief: | + A value in a mapping can be another mapping. +yaml: | + foo: whatever + bar: + fruit: apple + name: steve + sport: baseball +php: | + array( + 'foo' => 'whatever', + 'bar' => array( + 'fruit' => 'apple', + 'name' => 'steve', + 'sport' => 'baseball' + ) + ) +--- +test: Mixed Mapping +brief: | + A mapping can contain any assortment + of mappings and sequences as values. +yaml: | + foo: whatever + bar: + - + fruit: apple + name: steve + sport: baseball + - more + - + python: rocks + perl: papers + ruby: scissorses +php: | + array( + 'foo' => 'whatever', + 'bar' => array( + array( + 'fruit' => 'apple', + 'name' => 'steve', + 'sport' => 'baseball' + ), + 'more', + array( + 'python' => 'rocks', + 'perl' => 'papers', + 'ruby' => 'scissorses' + ) + ) + ) +--- +test: Mapping-in-Sequence Shortcut +todo: true +brief: | + If you are adding a mapping to a sequence, you + can place the mapping on the same line as the + dash as a shortcut. +yaml: | + - work on YAML.py: + - work on Store +php: | + array(array('work on YAML.py' => array('work on Store'))) +--- +test: Sequence-in-Mapping Shortcut +todo: true +brief: | + The dash in a sequence counts as indentation, so + you can add a sequence inside of a mapping without + needing spaces as indentation. +yaml: | + allow: + - 'localhost' + - '%.sourceforge.net' + - '%.freepan.org' +php: | + array('allow' => array('localhost', '%.sourceforge.net', '%.freepan.org')) +--- +todo: true +test: Merge key +brief: | + A merge key ('<<') can be used in a mapping to insert other mappings. If + the value associated with the merge key is a mapping, each of its key/value + pairs is inserted into the current mapping. +yaml: | + mapping: + name: Joe + job: Accountant + <<: + age: 38 +php: | + array( + 'mapping' => + array( + 'name' => 'Joe', + 'job' => 'Accountant', + 'age' => 38 + ) + ) diff --git a/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsBlockMapping.yml b/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsBlockMapping.yml new file mode 100644 index 0000000000000..f7ca469b40793 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsBlockMapping.yml @@ -0,0 +1,51 @@ +--- +test: One Element Mapping +brief: | + A mapping with one key/value pair +yaml: | + foo: bar +php: | + array('foo' => 'bar') +--- +test: Multi Element Mapping +brief: | + More than one key/value pair +yaml: | + red: baron + white: walls + blue: berries +php: | + array( + 'red' => 'baron', + 'white' => 'walls', + 'blue' => 'berries', + ) +--- +test: Values aligned +brief: | + Often times human editors of documents will align the values even + though YAML emitters generally don't. +yaml: | + red: baron + white: walls + blue: berries +php: | + array( + 'red' => 'baron', + 'white' => 'walls', + 'blue' => 'berries', + ) +--- +test: Colons aligned +brief: | + Spaces can come before the ': ' key/value separator. +yaml: | + red : baron + white : walls + blue : berries +php: | + array( + 'red' => 'baron', + 'white' => 'walls', + 'blue' => 'berries', + ) diff --git a/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsDocumentSeparator.yml b/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsDocumentSeparator.yml new file mode 100644 index 0000000000000..f8501ddc29646 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsDocumentSeparator.yml @@ -0,0 +1,85 @@ +--- %YAML:1.0 +test: Trailing Document Separator +todo: true +brief: > + You can separate YAML documents + with a string of three dashes. +yaml: | + - foo: 1 + bar: 2 + --- + more: stuff +python: | + [ + [ { 'foo': 1, 'bar': 2 } ], + { 'more': 'stuff' } + ] +ruby: | + [ { 'foo' => 1, 'bar' => 2 } ] + +--- +test: Leading Document Separator +todo: true +brief: > + You can explicity give an opening + document separator to your YAML stream. +yaml: | + --- + - foo: 1 + bar: 2 + --- + more: stuff +python: | + [ + [ {'foo': 1, 'bar': 2}], + {'more': 'stuff'} + ] +ruby: | + [ { 'foo' => 1, 'bar' => 2 } ] + +--- +test: YAML Header +todo: true +brief: > + The opening separator can contain directives + to the YAML parser, such as the version + number. +yaml: | + --- %YAML:1.0 + foo: 1 + bar: 2 +php: | + array('foo' => 1, 'bar' => 2) +documents: 1 + +--- +test: Red Herring Document Separator +brief: > + Separators included in blocks or strings + are treated as blocks or strings, as the + document separator should have no indentation + preceding it. +yaml: | + foo: | + --- +php: | + array('foo' => "---\n") + +--- +test: Multiple Document Separators in Block +brief: > + This technique allows you to embed other YAML + documents within literal blocks. +yaml: | + foo: | + --- + foo: bar + --- + yo: baz + bar: | + fooness +php: | + array( + 'foo' => "---\nfoo: bar\n---\nyo: baz\n", + 'bar' => "fooness\n" + ) diff --git a/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsErrorTests.yml b/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsErrorTests.yml new file mode 100644 index 0000000000000..e8506fcb66bb3 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsErrorTests.yml @@ -0,0 +1,25 @@ +--- +test: Missing value for hash item +todo: true +brief: | + Third item in this hash doesn't have a value +yaml: | + okay: value + also okay: ~ + causes error because no value specified + last key: value okay here too +python-error: causes error because no value specified + +--- +test: Not indenting enough +brief: | + There was a bug in PyYaml where it was off by one + in the indentation check. It was allowing the YAML + below. +# This is actually valid YAML now. Someone should tell showell. +yaml: | + foo: + firstline: 1 + secondline: 2 +php: | + array('foo' => null, 'firstline' => 1, 'secondline' => 2) diff --git a/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsFlowCollections.yml b/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsFlowCollections.yml new file mode 100644 index 0000000000000..03090e4abc40e --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsFlowCollections.yml @@ -0,0 +1,60 @@ +--- +test: Simple Inline Array +brief: > + Sequences can be contained on a + single line, using the inline syntax. + Separate each entry with commas and + enclose in square brackets. +yaml: | + seq: [ a, b, c ] +php: | + array('seq' => array('a', 'b', 'c')) +--- +test: Simple Inline Hash +brief: > + Mapping can also be contained on + a single line, using the inline + syntax. Each key-value pair is + separated by a colon, with a comma + between each entry in the mapping. + Enclose with curly braces. +yaml: | + hash: { name: Steve, foo: bar } +php: | + array('hash' => array('name' => 'Steve', 'foo' => 'bar')) +--- +test: Multi-line Inline Collections +todo: true +brief: > + Both inline sequences and inline mappings + can span multiple lines, provided that you + indent the additional lines. +yaml: | + languages: [ Ruby, + Perl, + Python ] + websites: { YAML: yaml.org, + Ruby: ruby-lang.org, + Python: python.org, + Perl: use.perl.org } +php: | + array( + 'languages' => array('Ruby', 'Perl', 'Python'), + 'websites' => array( + 'YAML' => 'yaml.org', + 'Ruby' => 'ruby-lang.org', + 'Python' => 'python.org', + 'Perl' => 'use.perl.org' + ) + ) +--- +test: Commas in Values (not in the spec!) +todo: true +brief: > + List items in collections are delimited by commas, but + there must be a space after each comma. This allows you + to add numbers without quoting. +yaml: | + attendances: [ 45,123, 70,000, 17,222 ] +php: | + array('attendances' => array(45123, 70000, 17222)) diff --git a/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsFoldedScalars.yml b/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsFoldedScalars.yml new file mode 100644 index 0000000000000..a14735a55a507 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsFoldedScalars.yml @@ -0,0 +1,176 @@ +--- %YAML:1.0 +test: Single ending newline +brief: > + A pipe character, followed by an indented + block of text is treated as a literal + block, in which newlines are preserved + throughout the block, including the final + newline. +yaml: | + --- + this: | + Foo + Bar +php: | + array('this' => "Foo\nBar\n") +--- +test: The '+' indicator +brief: > + The '+' indicator says to keep newlines at the end of text + blocks. +yaml: | + normal: | + extra new lines not kept + + preserving: |+ + extra new lines are kept + + + dummy: value +php: | + array( + 'normal' => "extra new lines not kept\n", + 'preserving' => "extra new lines are kept\n\n\n", + 'dummy' => 'value' + ) +--- +test: Three trailing newlines in literals +brief: > + To give you more control over how space + is preserved in text blocks, YAML has + the keep '+' and chomp '-' indicators. + The keep indicator will preserve all + ending newlines, while the chomp indicator + will strip all ending newlines. +yaml: | + clipped: | + This has one newline. + + + + same as "clipped" above: "This has one newline.\n" + + stripped: |- + This has no newline. + + + + same as "stripped" above: "This has no newline." + + kept: |+ + This has four newlines. + + + + same as "kept" above: "This has four newlines.\n\n\n\n" +php: | + array( + 'clipped' => "This has one newline.\n", + 'same as "clipped" above' => "This has one newline.\n", + 'stripped' => 'This has no newline.', + 'same as "stripped" above' => 'This has no newline.', + 'kept' => "This has four newlines.\n\n\n\n", + 'same as "kept" above' => "This has four newlines.\n\n\n\n" + ) +--- +test: Extra trailing newlines with spaces +todo: true +brief: > + Normally, only a single newline is kept + from the end of a literal block, unless the + keep '+' character is used in combination + with the pipe. The following example + will preserve all ending whitespace + since the last line of both literal blocks + contains spaces which extend past the indentation + level. +yaml: | + --- + this: | + Foo + + + kept: |+ + Foo + + +php: | + array('this' => "Foo\n\n \n", + 'kept' => "Foo\n\n \n" ) + +--- +test: Folded Block in a Sequence +brief: > + A greater-then character, followed by an indented + block of text is treated as a folded block, in + which lines of text separated by a single newline + are concatenated as a single line. +yaml: | + --- + - apple + - banana + - > + can't you see + the beauty of yaml? + hmm + - dog +php: | + array( + 'apple', + 'banana', + "can't you see the beauty of yaml? hmm\n", + 'dog' + ) +--- +test: Folded Block as a Mapping Value +brief: > + Both literal and folded blocks can be + used in collections, as values in a + sequence or a mapping. +yaml: | + --- + quote: > + Mark McGwire's + year was crippled + by a knee injury. + source: espn +php: | + array( + 'quote' => "Mark McGwire's year was crippled by a knee injury.\n", + 'source' => 'espn' + ) +--- +test: Three trailing newlines in folded blocks +brief: > + The keep and chomp indicators can also + be applied to folded blocks. +yaml: | + clipped: > + This has one newline. + + + + same as "clipped" above: "This has one newline.\n" + + stripped: >- + This has no newline. + + + + same as "stripped" above: "This has no newline." + + kept: >+ + This has four newlines. + + + + same as "kept" above: "This has four newlines.\n\n\n\n" +php: | + array( + 'clipped' => "This has one newline.\n", + 'same as "clipped" above' => "This has one newline.\n", + 'stripped' => 'This has no newline.', + 'same as "stripped" above' => 'This has no newline.', + 'kept' => "This has four newlines.\n\n\n\n", + 'same as "kept" above' => "This has four newlines.\n\n\n\n" + ) diff --git a/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsNullsAndEmpties.yml b/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsNullsAndEmpties.yml new file mode 100644 index 0000000000000..9a5300f2eff6a --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsNullsAndEmpties.yml @@ -0,0 +1,45 @@ +--- %YAML:1.0 +test: Empty Sequence +brief: > + You can represent the empty sequence + with an empty inline sequence. +yaml: | + empty: [] +php: | + array('empty' => array()) +--- +test: Empty Mapping +brief: > + You can represent the empty mapping + with an empty inline mapping. +yaml: | + empty: {} +php: | + array('empty' => array()) +--- +test: Empty Sequence as Entire Document +yaml: | + [] +php: | + array() +--- +test: Empty Mapping as Entire Document +yaml: | + {} +php: | + array() +--- +test: Null as Document +yaml: | + ~ +php: | + null +--- +test: Empty String +brief: > + You can represent an empty string + with a pair of quotes. +yaml: | + '' +php: | + '' diff --git a/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml b/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml new file mode 100644 index 0000000000000..6f99f75453060 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml @@ -0,0 +1,1695 @@ +--- %YAML:1.0 +test: Sequence of scalars +spec: 2.1 +yaml: | + - Mark McGwire + - Sammy Sosa + - Ken Griffey +php: | + array('Mark McGwire', 'Sammy Sosa', 'Ken Griffey') +--- +test: Mapping of scalars to scalars +spec: 2.2 +yaml: | + hr: 65 + avg: 0.278 + rbi: 147 +php: | + array('hr' => 65, 'avg' => 0.278, 'rbi' => 147) +--- +test: Mapping of scalars to sequences +spec: 2.3 +yaml: | + american: + - Boston Red Sox + - Detroit Tigers + - New York Yankees + national: + - New York Mets + - Chicago Cubs + - Atlanta Braves +php: | + array('american' => + array( 'Boston Red Sox', 'Detroit Tigers', + 'New York Yankees' ), + 'national' => + array( 'New York Mets', 'Chicago Cubs', + 'Atlanta Braves' ) + ) +--- +test: Sequence of mappings +spec: 2.4 +yaml: | + - + name: Mark McGwire + hr: 65 + avg: 0.278 + - + name: Sammy Sosa + hr: 63 + avg: 0.288 +php: | + array( + array('name' => 'Mark McGwire', 'hr' => 65, 'avg' => 0.278), + array('name' => 'Sammy Sosa', 'hr' => 63, 'avg' => 0.288) + ) +--- +test: Legacy A5 +todo: true +spec: legacy_A5 +yaml: | + ? + - New York Yankees + - Atlanta Braves + : + - 2001-07-02 + - 2001-08-12 + - 2001-08-14 + ? + - Detroit Tigers + - Chicago Cubs + : + - 2001-07-23 +perl-busted: > + YAML.pm will be able to emulate this behavior soon. In this regard + it may be somewhat more correct than Python's native behaviour which + can only use tuples as mapping keys. PyYAML will also need to figure + out some clever way to roundtrip structured keys. +python: | + [ + { + ('New York Yankees', 'Atlanta Braves'): + [yaml.timestamp('2001-07-02'), + yaml.timestamp('2001-08-12'), + yaml.timestamp('2001-08-14')], + ('Detroit Tigers', 'Chicago Cubs'): + [yaml.timestamp('2001-07-23')] + } + ] +ruby: | + { + [ 'New York Yankees', 'Atlanta Braves' ] => + [ Date.new( 2001, 7, 2 ), Date.new( 2001, 8, 12 ), Date.new( 2001, 8, 14 ) ], + [ 'Detroit Tigers', 'Chicago Cubs' ] => + [ Date.new( 2001, 7, 23 ) ] + } +syck: | + struct test_node seq1[] = { + { T_STR, 0, "New York Yankees" }, + { T_STR, 0, "Atlanta Braves" }, + end_node + }; + struct test_node seq2[] = { + { T_STR, 0, "2001-07-02" }, + { T_STR, 0, "2001-08-12" }, + { T_STR, 0, "2001-08-14" }, + end_node + }; + struct test_node seq3[] = { + { T_STR, 0, "Detroit Tigers" }, + { T_STR, 0, "Chicago Cubs" }, + end_node + }; + struct test_node seq4[] = { + { T_STR, 0, "2001-07-23" }, + end_node + }; + struct test_node map[] = { + { T_SEQ, 0, 0, seq1 }, + { T_SEQ, 0, 0, seq2 }, + { T_SEQ, 0, 0, seq3 }, + { T_SEQ, 0, 0, seq4 }, + end_node + }; + struct test_node stream[] = { + { T_MAP, 0, 0, map }, + end_node + }; + +--- +test: Sequence of sequences +spec: 2.5 +yaml: | + - [ name , hr , avg ] + - [ Mark McGwire , 65 , 0.278 ] + - [ Sammy Sosa , 63 , 0.288 ] +php: | + array( + array( 'name', 'hr', 'avg' ), + array( 'Mark McGwire', 65, 0.278 ), + array( 'Sammy Sosa', 63, 0.288 ) + ) +--- +test: Mapping of mappings +todo: true +spec: 2.6 +yaml: | + Mark McGwire: {hr: 65, avg: 0.278} + Sammy Sosa: { + hr: 63, + avg: 0.288 + } +php: | + array( + 'Mark McGwire' => + array( 'hr' => 65, 'avg' => 0.278 ), + 'Sammy Sosa' => + array( 'hr' => 63, 'avg' => 0.288 ) + ) +--- +test: Two documents in a stream each with a leading comment +todo: true +spec: 2.7 +yaml: | + # Ranking of 1998 home runs + --- + - Mark McGwire + - Sammy Sosa + - Ken Griffey + + # Team ranking + --- + - Chicago Cubs + - St Louis Cardinals +ruby: | + y = YAML::Stream.new + y.add( [ 'Mark McGwire', 'Sammy Sosa', 'Ken Griffey' ] ) + y.add( [ 'Chicago Cubs', 'St Louis Cardinals' ] ) +documents: 2 + +--- +test: Play by play feed from a game +todo: true +spec: 2.8 +yaml: | + --- + time: 20:03:20 + player: Sammy Sosa + action: strike (miss) + ... + --- + time: 20:03:47 + player: Sammy Sosa + action: grand slam + ... +perl: | + [ 'Mark McGwire', 'Sammy Sosa', 'Ken Griffey' ] +documents: 2 + +--- +test: Single document with two comments +spec: 2.9 +yaml: | + hr: # 1998 hr ranking + - Mark McGwire + - Sammy Sosa + rbi: + # 1998 rbi ranking + - Sammy Sosa + - Ken Griffey +php: | + array( + 'hr' => array( 'Mark McGwire', 'Sammy Sosa' ), + 'rbi' => array( 'Sammy Sosa', 'Ken Griffey' ) + ) +--- +test: Node for Sammy Sosa appears twice in this document +spec: 2.10 +yaml: | + --- + hr: + - Mark McGwire + # Following node labeled SS + - &SS Sammy Sosa + rbi: + - *SS # Subsequent occurance + - Ken Griffey +php: | + array( + 'hr' => + array('Mark McGwire', 'Sammy Sosa'), + 'rbi' => + array('Sammy Sosa', 'Ken Griffey') + ) +--- +test: Mapping between sequences +todo: true +spec: 2.11 +yaml: | + ? # PLAY SCHEDULE + - Detroit Tigers + - Chicago Cubs + : + - 2001-07-23 + + ? [ New York Yankees, + Atlanta Braves ] + : [ 2001-07-02, 2001-08-12, + 2001-08-14 ] +ruby: | + { + [ 'Detroit Tigers', 'Chicago Cubs' ] => [ Date.new( 2001, 7, 23 ) ], + [ 'New York Yankees', 'Atlanta Braves' ] => [ Date.new( 2001, 7, 2 ), Date.new( 2001, 8, 12 ), Date.new( 2001, 8, 14 ) ] + } +syck: | + struct test_node seq1[] = { + { T_STR, 0, "New York Yankees" }, + { T_STR, 0, "Atlanta Braves" }, + end_node + }; + struct test_node seq2[] = { + { T_STR, 0, "2001-07-02" }, + { T_STR, 0, "2001-08-12" }, + { T_STR, 0, "2001-08-14" }, + end_node + }; + struct test_node seq3[] = { + { T_STR, 0, "Detroit Tigers" }, + { T_STR, 0, "Chicago Cubs" }, + end_node + }; + struct test_node seq4[] = { + { T_STR, 0, "2001-07-23" }, + end_node + }; + struct test_node map[] = { + { T_SEQ, 0, 0, seq3 }, + { T_SEQ, 0, 0, seq4 }, + { T_SEQ, 0, 0, seq1 }, + { T_SEQ, 0, 0, seq2 }, + end_node + }; + struct test_node stream[] = { + { T_MAP, 0, 0, map }, + end_node + }; + +--- +test: Sequence key shortcut +spec: 2.12 +yaml: | + --- + # products purchased + - item : Super Hoop + quantity: 1 + - item : Basketball + quantity: 4 + - item : Big Shoes + quantity: 1 +php: | + array ( + array ( + 'item' => 'Super Hoop', + 'quantity' => 1, + ), + array ( + 'item' => 'Basketball', + 'quantity' => 4, + ), + array ( + 'item' => 'Big Shoes', + 'quantity' => 1, + ) + ) +perl: | + [ + { item => 'Super Hoop', quantity => 1 }, + { item => 'Basketball', quantity => 4 }, + { item => 'Big Shoes', quantity => 1 } + ] + +ruby: | + [ + { 'item' => 'Super Hoop', 'quantity' => 1 }, + { 'item' => 'Basketball', 'quantity' => 4 }, + { 'item' => 'Big Shoes', 'quantity' => 1 } + ] +python: | + [ + { 'item': 'Super Hoop', 'quantity': 1 }, + { 'item': 'Basketball', 'quantity': 4 }, + { 'item': 'Big Shoes', 'quantity': 1 } + ] +syck: | + struct test_node map1[] = { + { T_STR, 0, "item" }, + { T_STR, 0, "Super Hoop" }, + { T_STR, 0, "quantity" }, + { T_STR, 0, "1" }, + end_node + }; + struct test_node map2[] = { + { T_STR, 0, "item" }, + { T_STR, 0, "Basketball" }, + { T_STR, 0, "quantity" }, + { T_STR, 0, "4" }, + end_node + }; + struct test_node map3[] = { + { T_STR, 0, "item" }, + { T_STR, 0, "Big Shoes" }, + { T_STR, 0, "quantity" }, + { T_STR, 0, "1" }, + end_node + }; + struct test_node seq[] = { + { T_MAP, 0, 0, map1 }, + { T_MAP, 0, 0, map2 }, + { T_MAP, 0, 0, map3 }, + end_node + }; + struct test_node stream[] = { + { T_SEQ, 0, 0, seq }, + end_node + }; + + +--- +test: Literal perserves newlines +todo: true +spec: 2.13 +yaml: | + # ASCII Art + --- | + \//||\/|| + // || ||_ +perl: | + "\\//||\\/||\n// || ||_\n" +ruby: | + "\\//||\\/||\n// || ||_\n" +python: | + [ + flushLeft( + """ + \//||\/|| + // || ||_ + """ + ) + ] +syck: | + struct test_node stream[] = { + { T_STR, 0, "\\//||\\/||\n// || ||_\n" }, + end_node + }; + +--- +test: Folded treats newlines as a space +todo: true +spec: 2.14 +yaml: | + --- + Mark McGwire's + year was crippled + by a knee injury. +perl: | + "Mark McGwire's year was crippled by a knee injury." +ruby: | + "Mark McGwire's year was crippled by a knee injury." +python: | + [ "Mark McGwire's year was crippled by a knee injury." ] +syck: | + struct test_node stream[] = { + { T_STR, 0, "Mark McGwire's year was crippled by a knee injury." }, + end_node + }; + +--- +test: Newlines preserved for indented and blank lines +todo: true +spec: 2.15 +yaml: | + --- > + Sammy Sosa completed another + fine season with great stats. + + 63 Home Runs + 0.288 Batting Average + + What a year! +perl: | + "Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n" +ruby: | + "Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n" +python: | + [ + flushLeft( + """ + Sammy Sosa completed another fine season with great stats. + + 63 Home Runs + 0.288 Batting Average + + What a year! + """ + ) + ] +syck: | + struct test_node stream[] = { + { T_STR, 0, "Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n" }, + end_node + }; + + +--- +test: Indentation determines scope +spec: 2.16 +yaml: | + name: Mark McGwire + accomplishment: > + Mark set a major league + home run record in 1998. + stats: | + 65 Home Runs + 0.278 Batting Average +php: | + array( + 'name' => 'Mark McGwire', + 'accomplishment' => "Mark set a major league home run record in 1998.\n", + 'stats' => "65 Home Runs\n0.278 Batting Average\n" + ) +--- +test: Quoted scalars +todo: true +spec: 2.17 +yaml: | + unicode: "Sosa did fine.\u263A" + control: "\b1998\t1999\t2000\n" + hexesc: "\x0D\x0A is \r\n" + + single: '"Howdy!" he cried.' + quoted: ' # not a ''comment''.' + tie-fighter: '|\-*-/|' +ruby: | + { + "tie-fighter" => "|\\-*-/|", + "control"=>"\0101998\t1999\t2000\n", + "unicode"=>"Sosa did fine." + ["263A".hex ].pack('U*'), + "quoted"=>" # not a 'comment'.", + "single"=>"\"Howdy!\" he cried.", + "hexesc"=>"\r\n is \r\n" + } +--- +test: Multiline flow scalars +todo: true +spec: 2.18 +yaml: | + plain: + This unquoted scalar + spans many lines. + + quoted: "So does this + quoted scalar.\n" +ruby: | + { + 'plain' => 'This unquoted scalar spans many lines.', + 'quoted' => "So does this quoted scalar.\n" + } +--- +test: Integers +spec: 2.19 +yaml: | + canonical: 12345 + decimal: +12,345 + octal: 014 + hexadecimal: 0xC +php: | + array( + 'canonical' => 12345, + 'decimal' => 12345, + 'octal' => 014, + 'hexadecimal' => 0xC + ) +--- +# FIX: spec shows parens around -inf and NaN +test: Floating point +spec: 2.20 +yaml: | + canonical: 1.23015e+3 + exponential: 12.3015e+02 + fixed: 1,230.15 + negative infinity: -.inf + not a number: .NaN +php: | + array( + 'canonical' => 1230.15, + 'exponential' => 1230.15, + 'fixed' => 1230.15, + 'negative infinity' => log(0), + 'not a number' => -log(0), + ) +--- +test: Miscellaneous +spec: 2.21 +yaml: | + null: ~ + true: true + false: false + string: '12345' +php: | + array( + '' => null, + 1 => true, + 0 => false, + 'string' => '12345' + ) +--- +test: Timestamps +todo: true +spec: 2.22 +yaml: | + canonical: 2001-12-15T02:59:43.1Z + iso8601: 2001-12-14t21:59:43.10-05:00 + spaced: 2001-12-14 21:59:43.10 -05:00 + date: 2002-12-14 # Time is noon UTC +php: | + array( + 'canonical' => YAML::mktime( 2001, 12, 15, 2, 59, 43, 0.10 ), + 'iso8601' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ), + 'spaced' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ), + 'date' => Date.new( 2002, 12, 14 ) + ) +--- +test: legacy Timestamps test +todo: true +spec: legacy D4 +yaml: | + canonical: 2001-12-15T02:59:43.00Z + iso8601: 2001-02-28t21:59:43.00-05:00 + spaced: 2001-12-14 21:59:43.00 -05:00 + date: 2002-12-14 +php: | + array( + 'canonical' => Time::utc( 2001, 12, 15, 2, 59, 43, 0 ), + 'iso8601' => YAML::mktime( 2001, 2, 28, 21, 59, 43, 0, "-05:00" ), + 'spaced' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0, "-05:00" ), + 'date' => Date.new( 2002, 12, 14 ) + ) +--- +test: Various explicit families +todo: true +spec: 2.23 +yaml: | + not-date: !str 2002-04-28 + picture: !binary | + R0lGODlhDAAMAIQAAP//9/X + 17unp5WZmZgAAAOfn515eXv + Pz7Y6OjuDg4J+fn5OTk6enp + 56enmleECcgggoBADs= + + application specific tag: !!something | + The semantics of the tag + above may be different for + different documents. + +ruby-setup: | + YAML.add_private_type( "something" ) do |type, val| + "SOMETHING: #{val}" + end +ruby: | + { + 'not-date' => '2002-04-28', + 'picture' => "GIF89a\f\000\f\000\204\000\000\377\377\367\365\365\356\351\351\345fff\000\000\000\347\347\347^^^\363\363\355\216\216\216\340\340\340\237\237\237\223\223\223\247\247\247\236\236\236i^\020' \202\n\001\000;", + 'application specific tag' => "SOMETHING: The semantics of the tag\nabove may be different for\ndifferent documents.\n" + } +--- +test: Application specific family +todo: true +spec: 2.24 +yaml: | + # Establish a tag prefix + --- !clarkevans.com,2002/graph/^shape + # Use the prefix: shorthand for + # !clarkevans.com,2002/graph/circle + - !^circle + center: &ORIGIN {x: 73, 'y': 129} + radius: 7 + - !^line # !clarkevans.com,2002/graph/line + start: *ORIGIN + finish: { x: 89, 'y': 102 } + - !^label + start: *ORIGIN + color: 0xFFEEBB + value: Pretty vector drawing. +ruby-setup: | + YAML.add_domain_type( "clarkevans.com,2002", 'graph/shape' ) { |type, val| + if Array === val + val << "Shape Container" + val + else + raise YAML::Error, "Invalid graph of class #{ val.class }: " + val.inspect + end + } + one_shape_proc = Proc.new { |type, val| + scheme, domain, type = type.split( /:/, 3 ) + if val.is_a? ::Hash + val['TYPE'] = "Shape: #{type}" + val + else + raise YAML::Error, "Invalid graph of class #{ val.class }: " + val.inspect + end + } + YAML.add_domain_type( "clarkevans.com,2002", 'graph/circle', &one_shape_proc ) + YAML.add_domain_type( "clarkevans.com,2002", 'graph/line', &one_shape_proc ) + YAML.add_domain_type( "clarkevans.com,2002", 'graph/label', &one_shape_proc ) +ruby: | + [ + { + "radius" => 7, + "center"=> + { + "x" => 73, + "y" => 129 + }, + "TYPE" => "Shape: graph/circle" + }, { + "finish" => + { + "x" => 89, + "y" => 102 + }, + "TYPE" => "Shape: graph/line", + "start" => + { + "x" => 73, + "y" => 129 + } + }, { + "TYPE" => "Shape: graph/label", + "value" => "Pretty vector drawing.", + "start" => + { + "x" => 73, + "y" => 129 + }, + "color" => 16772795 + }, + "Shape Container" + ] +# --- +# test: Unordered set +# spec: 2.25 +# yaml: | +# # sets are represented as a +# # mapping where each key is +# # associated with the empty string +# --- !set +# ? Mark McGwire +# ? Sammy Sosa +# ? Ken Griff +--- +test: Ordered mappings +todo: true +spec: 2.26 +yaml: | + # ordered maps are represented as + # a sequence of mappings, with + # each mapping having one key + --- !omap + - Mark McGwire: 65 + - Sammy Sosa: 63 + - Ken Griffy: 58 +ruby: | + YAML::Omap[ + 'Mark McGwire', 65, + 'Sammy Sosa', 63, + 'Ken Griffy', 58 + ] +--- +test: Invoice +dump_skip: true +spec: 2.27 +yaml: | + --- !clarkevans.com,2002/^invoice + invoice: 34843 + date : 2001-01-23 + bill-to: &id001 + given : Chris + family : Dumars + address: + lines: | + 458 Walkman Dr. + Suite #292 + city : Royal Oak + state : MI + postal : 48046 + ship-to: *id001 + product: + - + sku : BL394D + quantity : 4 + description : Basketball + price : 450.00 + - + sku : BL4438H + quantity : 1 + description : Super Hoop + price : 2392.00 + tax : 251.42 + total: 4443.52 + comments: > + Late afternoon is best. + Backup contact is Nancy + Billsmer @ 338-4338. +php: | + array( + 'invoice' => 34843, 'date' => mktime(0, 0, 0, 1, 23, 2001), + 'bill-to' => + array( 'given' => 'Chris', 'family' => 'Dumars', 'address' => array( 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ) ) + , 'ship-to' => + array( 'given' => 'Chris', 'family' => 'Dumars', 'address' => array( 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ) ) + , 'product' => + array( + array( 'sku' => 'BL394D', 'quantity' => 4, 'description' => 'Basketball', 'price' => 450.00 ), + array( 'sku' => 'BL4438H', 'quantity' => 1, 'description' => 'Super Hoop', 'price' => 2392.00 ) + ), + 'tax' => 251.42, 'total' => 4443.52, + 'comments' => "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.\n" + ) +--- +test: Log file +todo: true +spec: 2.28 +yaml: | + --- + Time: 2001-11-23 15:01:42 -05:00 + User: ed + Warning: > + This is an error message + for the log file + --- + Time: 2001-11-23 15:02:31 -05:00 + User: ed + Warning: > + A slightly different error + message. + --- + Date: 2001-11-23 15:03:17 -05:00 + User: ed + Fatal: > + Unknown variable "bar" + Stack: + - file: TopClass.py + line: 23 + code: | + x = MoreObject("345\n") + - file: MoreClass.py + line: 58 + code: |- + foo = bar +ruby: | + y = YAML::Stream.new + y.add( { 'Time' => YAML::mktime( 2001, 11, 23, 15, 01, 42, 00, "-05:00" ), + 'User' => 'ed', 'Warning' => "This is an error message for the log file\n" } ) + y.add( { 'Time' => YAML::mktime( 2001, 11, 23, 15, 02, 31, 00, "-05:00" ), + 'User' => 'ed', 'Warning' => "A slightly different error message.\n" } ) + y.add( { 'Date' => YAML::mktime( 2001, 11, 23, 15, 03, 17, 00, "-05:00" ), + 'User' => 'ed', 'Fatal' => "Unknown variable \"bar\"\n", + 'Stack' => [ + { 'file' => 'TopClass.py', 'line' => 23, 'code' => "x = MoreObject(\"345\\n\")\n" }, + { 'file' => 'MoreClass.py', 'line' => 58, 'code' => "foo = bar" } ] } ) +documents: 3 + +--- +test: Throwaway comments +yaml: | + ### These are four throwaway comment ### + + ### lines (the second line is empty). ### + this: | # Comments may trail lines. + contains three lines of text. + The third one starts with a + # character. This isn't a comment. + + # These are three throwaway comment + # lines (the first line is empty). +php: | + array( + 'this' => "contains three lines of text.\nThe third one starts with a\n# character. This isn't a comment.\n" + ) +--- +test: Document with a single value +todo: true +yaml: | + --- > + This YAML stream contains a single text value. + The next stream is a log file - a sequence of + log entries. Adding an entry to the log is a + simple matter of appending it at the end. +ruby: | + "This YAML stream contains a single text value. The next stream is a log file - a sequence of log entries. Adding an entry to the log is a simple matter of appending it at the end.\n" +--- +test: Document stream +todo: true +yaml: | + --- + at: 2001-08-12 09:25:00.00 Z + type: GET + HTTP: '1.0' + url: '/index.html' + --- + at: 2001-08-12 09:25:10.00 Z + type: GET + HTTP: '1.0' + url: '/toc.html' +ruby: | + y = YAML::Stream.new + y.add( { + 'at' => Time::utc( 2001, 8, 12, 9, 25, 00 ), + 'type' => 'GET', + 'HTTP' => '1.0', + 'url' => '/index.html' + } ) + y.add( { + 'at' => Time::utc( 2001, 8, 12, 9, 25, 10 ), + 'type' => 'GET', + 'HTTP' => '1.0', + 'url' => '/toc.html' + } ) +documents: 2 + +--- +test: Top level mapping +yaml: | + # This stream is an example of a top-level mapping. + invoice : 34843 + date : 2001-01-23 + total : 4443.52 +php: | + array( + 'invoice' => 34843, + 'date' => mktime(0, 0, 0, 1, 23, 2001), + 'total' => 4443.52 + ) +--- +test: Single-line documents +todo: true +yaml: | + # The following is a sequence of three documents. + # The first contains an empty mapping, the second + # an empty sequence, and the last an empty string. + --- {} + --- [ ] + --- '' +ruby: | + y = YAML::Stream.new + y.add( {} ) + y.add( [] ) + y.add( '' ) +documents: 3 + +--- +test: Document with pause +todo: true +yaml: | + # A communication channel based on a YAML stream. + --- + sent at: 2002-06-06 11:46:25.10 Z + payload: Whatever + # Receiver can process this as soon as the following is sent: + ... + # Even if the next message is sent long after: + --- + sent at: 2002-06-06 12:05:53.47 Z + payload: Whatever + ... +ruby: | + y = YAML::Stream.new + y.add( + { 'sent at' => YAML::mktime( 2002, 6, 6, 11, 46, 25, 0.10 ), + 'payload' => 'Whatever' } + ) + y.add( + { "payload" => "Whatever", "sent at" => YAML::mktime( 2002, 6, 6, 12, 5, 53, 0.47 ) } + ) +documents: 2 + +--- +test: Explicit typing +yaml: | + integer: 12 + also int: ! "12" + string: !str 12 +php: | + array( 'integer' => 12, 'also int' => 12, 'string' => '12' ) +--- +test: Private types +todo: true +yaml: | + # Both examples below make use of the 'x-private:ball' + # type family URI, but with different semantics. + --- + pool: !!ball + number: 8 + color: black + --- + bearing: !!ball + material: steel +ruby: | + y = YAML::Stream.new + y.add( { 'pool' => + YAML::PrivateType.new( 'ball', + { 'number' => 8, 'color' => 'black' } ) } + ) + y.add( { 'bearing' => + YAML::PrivateType.new( 'ball', + { 'material' => 'steel' } ) } + ) +documents: 2 + +--- +test: Type family under yaml.org +yaml: | + # The URI is 'tag:yaml.org,2002:str' + - !str a Unicode string +php: | + array( 'a Unicode string' ) +--- +test: Type family under perl.yaml.org +todo: true +yaml: | + # The URI is 'tag:perl.yaml.org,2002:Text::Tabs' + - !perl/Text::Tabs {} +ruby: | + [ YAML::DomainType.new( 'perl.yaml.org,2002', 'Text::Tabs', {} ) ] +--- +test: Type family under clarkevans.com +todo: true +yaml: | + # The URI is 'tag:clarkevans.com,2003-02:timesheet' + - !clarkevans.com,2003-02/timesheet {} +ruby: | + [ YAML::DomainType.new( 'clarkevans.com,2003-02', 'timesheet', {} ) ] +--- +test: URI Escaping +todo: true +yaml: | + same: + - !domain.tld,2002/type\x30 value + - !domain.tld,2002/type0 value + different: # As far as the YAML parser is concerned + - !domain.tld,2002/type%30 value + - !domain.tld,2002/type0 value +ruby-setup: | + YAML.add_domain_type( "domain.tld,2002", "type0" ) { |type, val| + "ONE: #{val}" + } + YAML.add_domain_type( "domain.tld,2002", "type%30" ) { |type, val| + "TWO: #{val}" + } +ruby: | + { 'same' => [ 'ONE: value', 'ONE: value' ], 'different' => [ 'TWO: value', 'ONE: value' ] } +--- +test: URI Prefixing +todo: true +yaml: | + # 'tag:domain.tld,2002:invoice' is some type family. + invoice: !domain.tld,2002/^invoice + # 'seq' is shorthand for 'tag:yaml.org,2002:seq'. + # This does not effect '^customer' below + # because it is does not specify a prefix. + customers: !seq + # '^customer' is shorthand for the full + # notation 'tag:domain.tld,2002:customer'. + - !^customer + given : Chris + family : Dumars +ruby-setup: | + YAML.add_domain_type( "domain.tld,2002", /(invoice|customer)/ ) { |type, val| + if val.is_a? ::Hash + scheme, domain, type = type.split( /:/, 3 ) + val['type'] = "domain #{type}" + val + else + raise YAML::Error, "Not a Hash in domain.tld/invoice: " + val.inspect + end + } +ruby: | + { "invoice"=> { "customers"=> [ { "given"=>"Chris", "type"=>"domain customer", "family"=>"Dumars" } ], "type"=>"domain invoice" } } + +--- +test: Overriding anchors +yaml: | + anchor : &A001 This scalar has an anchor. + override : &A001 > + The alias node below is a + repeated use of this value. + alias : *A001 +php: | + array( 'anchor' => 'This scalar has an anchor.', + 'override' => "The alias node below is a repeated use of this value.\n", + 'alias' => "The alias node below is a repeated use of this value.\n" ) +--- +test: Flow and block formatting +todo: true +yaml: | + empty: [] + flow: [ one, two, three # May span lines, + , four, # indentation is + five ] # mostly ignored. + block: + - First item in top sequence + - + - Subordinate sequence entry + - > + A folded sequence entry + - Sixth item in top sequence +ruby: | + { 'empty' => [], 'flow' => [ 'one', 'two', 'three', 'four', 'five' ], + 'block' => [ 'First item in top sequence', [ 'Subordinate sequence entry' ], + "A folded sequence entry\n", 'Sixth item in top sequence' ] } +--- +test: Complete mapping test +todo: true +yaml: | + empty: {} + flow: { one: 1, two: 2 } + spanning: { one: 1, + two: 2 } + block: + first : First entry + second: + key: Subordinate mapping + third: + - Subordinate sequence + - { } + - Previous mapping is empty. + - A key: value pair in a sequence. + A second: key:value pair. + - The previous entry is equal to the following one. + - + A key: value pair in a sequence. + A second: key:value pair. + !float 12 : This key is a float. + ? > + ? + : This key had to be protected. + "\a" : This key had to be escaped. + ? > + This is a + multi-line + folded key + : Whose value is + also multi-line. + ? this also works as a key + : with a value at the next line. + ? + - This key + - is a sequence + : + - With a sequence value. + ? + This: key + is a: mapping + : + with a: mapping value. +ruby: | + { 'empty' => {}, 'flow' => { 'one' => 1, 'two' => 2 }, + 'spanning' => { 'one' => 1, 'two' => 2 }, + 'block' => { 'first' => 'First entry', 'second' => + { 'key' => 'Subordinate mapping' }, 'third' => + [ 'Subordinate sequence', {}, 'Previous mapping is empty.', + { 'A key' => 'value pair in a sequence.', 'A second' => 'key:value pair.' }, + 'The previous entry is equal to the following one.', + { 'A key' => 'value pair in a sequence.', 'A second' => 'key:value pair.' } ], + 12.0 => 'This key is a float.', "?\n" => 'This key had to be protected.', + "\a" => 'This key had to be escaped.', + "This is a multi-line folded key\n" => "Whose value is also multi-line.", + 'this also works as a key' => 'with a value at the next line.', + [ 'This key', 'is a sequence' ] => [ 'With a sequence value.' ] } } + # Couldn't recreate map exactly, so we'll do a detailed check to be sure it's entact + obj_y['block'].keys.each { |k| + if Hash === k + v = obj_y['block'][k] + if k['This'] == 'key' and k['is a'] == 'mapping' and v['with a'] == 'mapping value.' + obj_r['block'][k] = v + end + end + } +--- +test: Literal explicit indentation +yaml: | + # Explicit indentation must + # be given in all the three + # following cases. + leading spaces: |2 + This value starts with four spaces. + + leading line break: |2 + + This value starts with a line break. + + leading comment indicator: |2 + # first line starts with a + # character. + + # Explicit indentation may + # also be given when it is + # not required. + redundant: |2 + This value is indented 2 spaces. +php: | + array( + 'leading spaces' => " This value starts with four spaces.\n", + 'leading line break' => "\nThis value starts with a line break.\n", + 'leading comment indicator' => "# first line starts with a\n# character.\n", + 'redundant' => "This value is indented 2 spaces.\n" + ) +--- +test: Chomping and keep modifiers +yaml: | + clipped: | + This has one newline. + + same as "clipped" above: "This has one newline.\n" + + stripped: |- + This has no newline. + + same as "stripped" above: "This has no newline." + + kept: |+ + This has two newlines. + + same as "kept" above: "This has two newlines.\n\n" +php: | + array( + 'clipped' => "This has one newline.\n", + 'same as "clipped" above' => "This has one newline.\n", + 'stripped' => 'This has no newline.', + 'same as "stripped" above' => 'This has no newline.', + 'kept' => "This has two newlines.\n\n", + 'same as "kept" above' => "This has two newlines.\n\n" + ) +--- +test: Literal combinations +todo: true +yaml: | + empty: | + + literal: | + The \ ' " characters may be + freely used. Leading white + space is significant. + + Line breaks are significant. + Thus this value contains one + empty line and ends with a + single line break, but does + not start with one. + + is equal to: "The \\ ' \" characters may \ + be\nfreely used. Leading white\n space \ + is significant.\n\nLine breaks are \ + significant.\nThus this value contains \ + one\nempty line and ends with a\nsingle \ + line break, but does\nnot start with one.\n" + + # Comments may follow a block + # scalar value. They must be + # less indented. + + # Modifiers may be combined in any order. + indented and chomped: |2- + This has no newline. + + also written as: |-2 + This has no newline. + + both are equal to: " This has no newline." +php: | + array( + 'empty' => '', + 'literal' => "The \\ ' \" characters may be\nfreely used. Leading white\n space " + + "is significant.\n\nLine breaks are significant.\nThus this value contains one\n" + + "empty line and ends with a\nsingle line break, but does\nnot start with one.\n", + 'is equal to' => "The \\ ' \" characters may be\nfreely used. Leading white\n space " + + "is significant.\n\nLine breaks are significant.\nThus this value contains one\n" + + "empty line and ends with a\nsingle line break, but does\nnot start with one.\n", + 'indented and chomped' => ' This has no newline.', + 'also written as' => ' This has no newline.', + 'both are equal to' => ' This has no newline.' + ) +--- +test: Folded combinations +todo: true +yaml: | + empty: > + + one paragraph: > + Line feeds are converted + to spaces, so this value + contains no line breaks + except for the final one. + + multiple paragraphs: >2 + + An empty line, either + at the start or in + the value: + + Is interpreted as a + line break. Thus this + value contains three + line breaks. + + indented text: > + This is a folded + paragraph followed + by a list: + * first entry + * second entry + Followed by another + folded paragraph, + another list: + + * first entry + + * second entry + + And a final folded + paragraph. + + above is equal to: | + This is a folded paragraph followed by a list: + * first entry + * second entry + Followed by another folded paragraph, another list: + + * first entry + + * second entry + + And a final folded paragraph. + + # Explicit comments may follow + # but must be less indented. +php: | + array( + 'empty' => '', + 'one paragraph' => 'Line feeds are converted to spaces, so this value'. + " contains no line breaks except for the final one.\n", + 'multiple paragraphs' => "\nAn empty line, either at the start or in the value:\n". + "Is interpreted as a line break. Thus this value contains three line breaks.\n", + 'indented text' => "This is a folded paragraph followed by a list:\n". + " * first entry\n * second entry\nFollowed by another folded paragraph, ". + "another list:\n\n * first entry\n\n * second entry\n\nAnd a final folded paragraph.\n", + 'above is equal to' => "This is a folded paragraph followed by a list:\n". + " * first entry\n * second entry\nFollowed by another folded paragraph, ". + "another list:\n\n * first entry\n\n * second entry\n\nAnd a final folded paragraph.\n" + ) +--- +test: Single quotes +todo: true +yaml: | + empty: '' + second: '! : \ etc. can be used freely.' + third: 'a single quote '' must be escaped.' + span: 'this contains + six spaces + + and one + line break' + is same as: "this contains six spaces\nand one line break" +php: | + array( + 'empty' => '', + 'second' => '! : \\ etc. can be used freely.', + 'third' => "a single quote ' must be escaped.", + 'span' => "this contains six spaces\nand one line break", + 'is same as' => "this contains six spaces\nand one line break" + ) +--- +test: Double quotes +todo: true +yaml: | + empty: "" + second: "! : etc. can be used freely." + third: "a \" or a \\ must be escaped." + fourth: "this value ends with an LF.\n" + span: "this contains + four \ + spaces" + is equal to: "this contains four spaces" +php: | + array( + 'empty' => '', + 'second' => '! : etc. can be used freely.', + 'third' => 'a " or a \\ must be escaped.', + 'fourth' => "this value ends with an LF.\n", + 'span' => "this contains four spaces", + 'is equal to' => "this contains four spaces" + ) +--- +test: Unquoted strings +todo: true +yaml: | + first: There is no unquoted empty string. + + second: 12 ## This is an integer. + + third: !str 12 ## This is a string. + + span: this contains + six spaces + + and one + line break + + indicators: this has no comments. + #:foo and bar# are + both text. + + flow: [ can span + lines, # comment + like + this ] + + note: { one-line keys: but multi-line values } + +php: | + array( + 'first' => 'There is no unquoted empty string.', + 'second' => 12, + 'third' => '12', + 'span' => "this contains six spaces\nand one line break", + 'indicators' => "this has no comments. #:foo and bar# are both text.", + 'flow' => [ 'can span lines', 'like this' ], + 'note' => { 'one-line keys' => 'but multi-line values' } + ) +--- +test: Spanning sequences +todo: true +yaml: | + # The following are equal seqs + # with different identities. + flow: [ one, two ] + spanning: [ one, + two ] + block: + - one + - two +php: | + array( + 'flow' => [ 'one', 'two' ], + 'spanning' => [ 'one', 'two' ], + 'block' => [ 'one', 'two' ] + ) +--- +test: Flow mappings +yaml: | + # The following are equal maps + # with different identities. + flow: { one: 1, two: 2 } + block: + one: 1 + two: 2 +php: | + array( + 'flow' => array( 'one' => 1, 'two' => 2 ), + 'block' => array( 'one' => 1, 'two' => 2 ) + ) +--- +test: Representations of 12 +todo: true +yaml: | + - 12 # An integer + # The following scalars + # are loaded to the + # string value '1' '2'. + - !str 12 + - '12' + - "12" + - "\ + 1\ + 2\ + " + # Strings containing paths and regexps can be unquoted: + - /foo/bar + - d:/foo/bar + - foo/bar + - /a.*b/ +php: | + array( 12, '12', '12', '12', '12', '/foo/bar', 'd:/foo/bar', 'foo/bar', '/a.*b/' ) +--- +test: "Null" +todo: true +yaml: | + canonical: ~ + + english: null + + # This sequence has five + # entries, two with values. + sparse: + - ~ + - 2nd entry + - Null + - 4th entry + - + + four: This mapping has five keys, + only two with values. + +php: | + array ( + 'canonical' => null, + 'english' => null, + 'sparse' => array( null, '2nd entry', null, '4th entry', null ]), + 'four' => 'This mapping has five keys, only two with values.' + ) +--- +test: Omap +todo: true +yaml: | + # Explicitly typed dictionary. + Bestiary: !omap + - aardvark: African pig-like ant eater. Ugly. + - anteater: South-American ant eater. Two species. + - anaconda: South-American constrictor snake. Scary. + # Etc. +ruby: | + { + 'Bestiary' => YAML::Omap[ + 'aardvark', 'African pig-like ant eater. Ugly.', + 'anteater', 'South-American ant eater. Two species.', + 'anaconda', 'South-American constrictor snake. Scary.' + ] + } + +--- +test: Pairs +todo: true +yaml: | + # Explicitly typed pairs. + tasks: !pairs + - meeting: with team. + - meeting: with boss. + - break: lunch. + - meeting: with client. +ruby: | + { + 'tasks' => YAML::Pairs[ + 'meeting', 'with team.', + 'meeting', 'with boss.', + 'break', 'lunch.', + 'meeting', 'with client.' + ] + } + +--- +test: Set +todo: true +yaml: | + # Explicitly typed set. + baseball players: !set + Mark McGwire: + Sammy Sosa: + Ken Griffey: +ruby: | + { + 'baseball players' => YAML::Set[ + 'Mark McGwire', nil, + 'Sammy Sosa', nil, + 'Ken Griffey', nil + ] + } + +--- +test: Boolean +yaml: | + false: used as key + logical: true + answer: false +php: | + array( + false => 'used as key', + 'logical' => true, + 'answer' => false + ) +--- +test: Integer +yaml: | + canonical: 12345 + decimal: +12,345 + octal: 014 + hexadecimal: 0xC +php: | + array( + 'canonical' => 12345, + 'decimal' => 12345, + 'octal' => 12, + 'hexadecimal' => 12 + ) +--- +test: Float +yaml: | + canonical: 1.23015e+3 + exponential: 12.3015e+02 + fixed: 1,230.15 + negative infinity: -.inf + not a number: .NaN +php: | + array( + 'canonical' => 1230.15, + 'exponential' => 1230.15, + 'fixed' => 1230.15, + 'negative infinity' => log(0), + 'not a number' => -log(0) + ) +--- +test: Timestamp +todo: true +yaml: | + canonical: 2001-12-15T02:59:43.1Z + valid iso8601: 2001-12-14t21:59:43.10-05:00 + space separated: 2001-12-14 21:59:43.10 -05:00 + date (noon UTC): 2002-12-14 +ruby: | + array( + 'canonical' => YAML::mktime( 2001, 12, 15, 2, 59, 43, 0.10 ), + 'valid iso8601' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ), + 'space separated' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ), + 'date (noon UTC)' => Date.new( 2002, 12, 14 ) + ) +--- +test: Binary +todo: true +yaml: | + canonical: !binary "\ + R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5\ + OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+\ + +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC\ + AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=" + base64: !binary | + R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5 + OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+ + +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC + AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs= + description: > + The binary value above is a tiny arrow + encoded as a gif image. +ruby-setup: | + arrow_gif = "GIF89a\f\000\f\000\204\000\000\377\377\367\365\365\356\351\351\345fff\000\000\000\347\347\347^^^\363\363\355\216\216\216\340\340\340\237\237\237\223\223\223\247\247\247\236\236\236iiiccc\243\243\243\204\204\204\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371!\376\016Made with GIMP\000,\000\000\000\000\f\000\f\000\000\005, \216\2010\236\343@\024\350i\020\304\321\212\010\034\317\200M$z\357\3770\205p\270\2601f\r\e\316\001\303\001\036\020' \202\n\001\000;" +ruby: | + { + 'canonical' => arrow_gif, + 'base64' => arrow_gif, + 'description' => "The binary value above is a tiny arrow encoded as a gif image.\n" + } + +--- +test: Merge key +todo: true +yaml: | + --- + - &CENTER { x: 1, y: 2 } + - &LEFT { x: 0, y: 2 } + - &BIG { r: 10 } + - &SMALL { r: 1 } + + # All the following maps are equal: + + - # Explicit keys + x: 1 + y: 2 + r: 10 + label: center/big + + - # Merge one map + << : *CENTER + r: 10 + label: center/big + + - # Merge multiple maps + << : [ *CENTER, *BIG ] + label: center/big + + - # Override + << : [ *BIG, *LEFT, *SMALL ] + x: 1 + label: center/big + +ruby-setup: | + center = { 'x' => 1, 'y' => 2 } + left = { 'x' => 0, 'y' => 2 } + big = { 'r' => 10 } + small = { 'r' => 1 } + node1 = { 'x' => 1, 'y' => 2, 'r' => 10, 'label' => 'center/big' } + node2 = center.dup + node2.update( { 'r' => 10, 'label' => 'center/big' } ) + node3 = big.dup + node3.update( center ) + node3.update( { 'label' => 'center/big' } ) + node4 = small.dup + node4.update( left ) + node4.update( big ) + node4.update( { 'x' => 1, 'label' => 'center/big' } ) + +ruby: | + [ + center, left, big, small, node1, node2, node3, node4 + ] + +--- +test: Default key +todo: true +yaml: | + --- # Old schema + link with: + - library1.dll + - library2.dll + --- # New schema + link with: + - = : library1.dll + version: 1.2 + - = : library2.dll + version: 2.3 +ruby: | + y = YAML::Stream.new + y.add( { 'link with' => [ 'library1.dll', 'library2.dll' ] } ) + obj_h = Hash[ 'version' => 1.2 ] + obj_h.default = 'library1.dll' + obj_h2 = Hash[ 'version' => 2.3 ] + obj_h2.default = 'library2.dll' + y.add( { 'link with' => [ obj_h, obj_h2 ] } ) +documents: 2 + +--- +test: Special keys +todo: true +yaml: | + "!": These three keys + "&": had to be quoted + "=": and are normal strings. + # NOTE: the following node should NOT be serialized this way. + encoded node : + !special '!' : '!type' + !special|canonical '&' : 12 + = : value + # The proper way to serialize the above node is as follows: + node : !!type &12 value +ruby: | + { '!' => 'These three keys', '&' => 'had to be quoted', + '=' => 'and are normal strings.', + 'encoded node' => YAML::PrivateType.new( 'type', 'value' ), + 'node' => YAML::PrivateType.new( 'type', 'value' ) } diff --git a/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsTypeTransfers.yml b/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsTypeTransfers.yml new file mode 100644 index 0000000000000..9972c1f0d9d52 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsTypeTransfers.yml @@ -0,0 +1,244 @@ +--- %YAML:1.0 +test: Strings +brief: > + Any group of characters beginning with an + alphabetic or numeric character is a string, + unless it belongs to one of the groups below + (such as an Integer or Time). +yaml: | + String +php: | + 'String' +--- +test: String characters +brief: > + A string can contain any alphabetic or + numeric character, along with many + punctuation characters, including the + period, dash, space, quotes, exclamation, and + question mark. +yaml: | + - What's Yaml? + - It's for writing data structures in plain text. + - And? + - And what? That's not good enough for you? + - No, I mean, "And what about Yaml?" + - Oh, oh yeah. Uh.. Yaml for Ruby. +php: | + array( + "What's Yaml?", + "It's for writing data structures in plain text.", + "And?", + "And what? That's not good enough for you?", + "No, I mean, \"And what about Yaml?\"", + "Oh, oh yeah. Uh.. Yaml for Ruby." + ) +--- +test: Indicators in Strings +brief: > + Be careful using indicators in strings. In particular, + the comma, colon, and pound sign must be used carefully. +yaml: | + the colon followed by space is an indicator: but is a string:right here + same for the pound sign: here we have it#in a string + the comma can, honestly, be used in most cases: [ but not in, inline collections ] +php: | + array( + 'the colon followed by space is an indicator' => 'but is a string:right here', + 'same for the pound sign' => 'here we have it#in a string', + 'the comma can, honestly, be used in most cases' => array('but not in', 'inline collections') + ) +--- +test: Forcing Strings +brief: > + Any YAML type can be forced into a string using the + explicit !str method. +yaml: | + date string: !str 2001-08-01 + number string: !str 192 +php: | + array( + 'date string' => '2001-08-01', + 'number string' => '192' + ) +--- +test: Single-quoted Strings +brief: > + You can also enclose your strings within single quotes, + which allows use of slashes, colons, and other indicators + freely. Inside single quotes, you can represent a single + quote in your string by using two single quotes next to + each other. +yaml: | + all my favorite symbols: '#:!/%.)' + a few i hate: '&(*' + why do i hate them?: 'it''s very hard to explain' + entities: '£ me' +php: | + array( + 'all my favorite symbols' => '#:!/%.)', + 'a few i hate' => '&(*', + 'why do i hate them?' => 'it\'s very hard to explain', + 'entities' => '£ me' + ) +--- +test: Double-quoted Strings +brief: > + Enclosing strings in double quotes allows you + to use escapings to represent ASCII and + Unicode characters. +yaml: | + i know where i want my line breaks: "one here\nand another here\n" +php: | + array( + 'i know where i want my line breaks' => "one here\nand another here\n" + ) +--- +test: Multi-line Quoted Strings +todo: true +brief: > + Both single- and double-quoted strings may be + carried on to new lines in your YAML document. + They must be indented a step and indentation + is interpreted as a single space. +yaml: | + i want a long string: "so i'm going to + let it go on and on to other lines + until i end it with a quote." +php: | + array('i want a long string' => "so i'm going to ". + "let it go on and on to other lines ". + "until i end it with a quote." + ) + +--- +test: Plain scalars +todo: true +brief: > + Unquoted strings may also span multiple lines, if they + are free of YAML space indicators and indented. +yaml: | + - My little toe is broken in two places; + - I'm crazy to have skied this way; + - I'm not the craziest he's seen, since there was always the German guy + who skied for 3 hours on a broken shin bone (just below the kneecap); + - Nevertheless, second place is respectable, and he doesn't + recommend going for the record; + - He's going to put my foot in plaster for a month; + - This would impair my skiing ability somewhat for the + duration, as can be imagined. +php: | + array( + "My little toe is broken in two places;", + "I'm crazy to have skied this way;", + "I'm not the craziest he's seen, since there was always ". + "the German guy who skied for 3 hours on a broken shin ". + "bone (just below the kneecap);", + "Nevertheless, second place is respectable, and he doesn't ". + "recommend going for the record;", + "He's going to put my foot in plaster for a month;", + "This would impair my skiing ability somewhat for the duration, ". + "as can be imagined." + ) +--- +test: 'Null' +brief: > + You can use the tilde '~' character for a null value. +yaml: | + name: Mr. Show + hosted by: Bob and David + date of next season: ~ +php: | + array( + 'name' => 'Mr. Show', + 'hosted by' => 'Bob and David', + 'date of next season' => null + ) +--- +test: Boolean +brief: > + You can use 'true' and 'false' for Boolean values. +yaml: | + Is Gus a Liar?: true + Do I rely on Gus for Sustenance?: false +php: | + array( + 'Is Gus a Liar?' => true, + 'Do I rely on Gus for Sustenance?' => false + ) +--- +test: Integers +dump_skip: true +brief: > + An integer is a series of numbers, optionally + starting with a positive or negative sign. Integers + may also contain commas for readability. +yaml: | + zero: 0 + simple: 12 + one-thousand: 1,000 + negative one-thousand: -1,000 +php: | + array( + 'zero' => 0, + 'simple' => 12, + 'one-thousand' => 1000, + 'negative one-thousand' => -1000 + ) +--- +test: Integers as Map Keys +brief: > + An integer can be used a dictionary key. +yaml: | + 1: one + 2: two + 3: three +php: | + array( + 1 => 'one', + 2 => 'two', + 3 => 'three' + ) +--- +test: Floats +dump_skip: true +brief: > + Floats are represented by numbers with decimals, + allowing for scientific notation, as well as + positive and negative infinity and "not a number." +yaml: | + a simple float: 2.00 + larger float: 1,000.09 + scientific notation: 1.00009e+3 +php: | + array( + 'a simple float' => 2.0, + 'larger float' => 1000.09, + 'scientific notation' => 1000.09 + ) +--- +test: Time +todo: true +brief: > + You can represent timestamps by using + ISO8601 format, or a variation which + allows spaces between the date, time and + time zone. +yaml: | + iso8601: 2001-12-14t21:59:43.10-05:00 + space seperated: 2001-12-14 21:59:43.10 -05:00 +php: | + array( + 'iso8601' => mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ), + 'space seperated' => mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ) + ) +--- +test: Date +todo: true +brief: > + A date can be represented by its year, + month and day in ISO8601 order. +yaml: | + 1976-07-31 +php: | + date( 1976, 7, 31 ) diff --git a/lib/Symfony/Component/Yaml/Tests/Fixtures/embededPhp.yml b/lib/Symfony/Component/Yaml/Tests/Fixtures/embededPhp.yml new file mode 100644 index 0000000000000..ec456ed09fb38 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/Fixtures/embededPhp.yml @@ -0,0 +1 @@ +value: diff --git a/lib/Symfony/Component/Yaml/Tests/Fixtures/escapedCharacters.yml b/lib/Symfony/Component/Yaml/Tests/Fixtures/escapedCharacters.yml new file mode 100644 index 0000000000000..09bf86e79027d --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/Fixtures/escapedCharacters.yml @@ -0,0 +1,147 @@ +test: outside double quotes +yaml: | + \0 \ \a \b \n +php: | + "\\0 \\ \\a \\b \\n" +--- +test: null +yaml: | + "\0" +php: | + "\x00" +--- +test: bell +yaml: | + "\a" +php: | + "\x07" +--- +test: backspace +yaml: | + "\b" +php: | + "\x08" +--- +test: horizontal tab (1) +yaml: | + "\t" +php: | + "\x09" +--- +test: horizontal tab (2) +yaml: | + "\ " +php: | + "\x09" +--- +test: line feed +yaml: | + "\n" +php: | + "\x0a" +--- +test: vertical tab +yaml: | + "\v" +php: | + "\x0b" +--- +test: form feed +yaml: | + "\f" +php: | + "\x0c" +--- +test: carriage return +yaml: | + "\r" +php: | + "\x0d" +--- +test: escape +yaml: | + "\e" +php: | + "\x1b" +--- +test: space +yaml: | + "\ " +php: | + "\x20" +--- +test: slash +yaml: | + "\/" +php: | + "\x2f" +--- +test: backslash +yaml: | + "\\" +php: | + "\\" +--- +test: Unicode next line +yaml: | + "\N" +php: | + "\xc2\x85" +--- +test: Unicode non-breaking space +yaml: | + "\_" +php: | + "\xc2\xa0" +--- +test: Unicode line separator +yaml: | + "\L" +php: | + "\xe2\x80\xa8" +--- +test: Unicode paragraph separator +yaml: | + "\P" +php: | + "\xe2\x80\xa9" +--- +test: Escaped 8-bit Unicode +yaml: | + "\x42" +php: | + "B" +--- +test: Escaped 16-bit Unicode +yaml: | + "\u20ac" +php: | + "\xe2\x82\xac" +--- +test: Escaped 32-bit Unicode +yaml: | + "\U00000043" +php: | + "C" +--- +test: Example 5.13 Escaped Characters +note: | + Currently throws an error parsing first line. Maybe Symfony Yaml doesn't support + continuation of string across multiple lines? Keeping test here but disabled. +todo: true +yaml: | + "Fun with \\ + \" \a \b \e \f \ + \n \r \t \v \0 \ + \ \_ \N \L \P \ + \x41 \u0041 \U00000041" +php: | + "Fun with \x5C\n\x22 \x07 \x08 \x1B \x0C\n\x0A \x0D \x09 \x0B \x00\n\x20 \xA0 \x85 \xe2\x80\xa8 \xe2\x80\xa9\nA A A" +--- +test: Double quotes with a line feed +yaml: | + { double: "some value\n \"some quoted string\" and 'some single quotes one'" } +php: | + array( + 'double' => "some value\n \"some quoted string\" and 'some single quotes one'" + ) diff --git a/lib/Symfony/Component/Yaml/Tests/Fixtures/index.yml b/lib/Symfony/Component/Yaml/Tests/Fixtures/index.yml new file mode 100644 index 0000000000000..3216a89ebbc39 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/Fixtures/index.yml @@ -0,0 +1,18 @@ +- escapedCharacters +- sfComments +- sfCompact +- sfTests +- sfObjects +- sfMergeKey +- sfQuotes +- YtsAnchorAlias +- YtsBasicTests +- YtsBlockMapping +- YtsDocumentSeparator +- YtsErrorTests +- YtsFlowCollections +- YtsFoldedScalars +- YtsNullsAndEmpties +- YtsSpecificationExamples +- YtsTypeTransfers +- unindentedCollections diff --git a/lib/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml b/lib/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml new file mode 100644 index 0000000000000..34225e11e0a9f --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml @@ -0,0 +1,51 @@ +--- %YAML:1.0 +test: Comments at the end of a line +brief: > + Comments at the end of a line +yaml: | + ex1: "foo # bar" + ex2: "foo # bar" # comment + ex3: 'foo # bar' # comment + ex4: foo # comment +php: | + array('ex1' => 'foo # bar', 'ex2' => 'foo # bar', 'ex3' => 'foo # bar', 'ex4' => 'foo') +--- +test: Comments in the middle +brief: > + Comments in the middle +yaml: | + foo: + # some comment + # some comment + bar: foo + # some comment + # some comment +php: | + array('foo' => array('bar' => 'foo')) +--- +test: Comments on a hash line +brief: > + Comments on a hash line +yaml: | + foo: # a comment + foo: bar # a comment +php: | + array('foo' => array('foo' => 'bar')) +--- +test: 'Value starting with a #' +brief: > + 'Value starting with a #' +yaml: | + foo: '#bar' +php: | + array('foo' => '#bar') +--- +test: Document starting with a comment and a separator +brief: > + Commenting before document start is allowed +yaml: | + # document comment + --- + foo: bar # a comment +php: | + array('foo' => 'bar') diff --git a/lib/Symfony/Component/Yaml/Tests/Fixtures/sfCompact.yml b/lib/Symfony/Component/Yaml/Tests/Fixtures/sfCompact.yml new file mode 100644 index 0000000000000..1339d23a6305c --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/Fixtures/sfCompact.yml @@ -0,0 +1,159 @@ +--- %YAML:1.0 +test: Compact notation +brief: | + Compact notation for sets of mappings with single element +yaml: | + --- + # products purchased + - item : Super Hoop + - item : Basketball + quantity: 1 + - item: + name: Big Shoes + nick: Biggies + quantity: 1 +php: | + array ( + array ( + 'item' => 'Super Hoop', + ), + array ( + 'item' => 'Basketball', + 'quantity' => 1, + ), + array ( + 'item' => array( + 'name' => 'Big Shoes', + 'nick' => 'Biggies' + ), + 'quantity' => 1 + ) + ) +--- +test: Compact notation combined with inline notation +brief: | + Combinations of compact and inline notation are allowed +yaml: | + --- + items: + - { item: Super Hoop, quantity: 1 } + - [ Basketball, Big Shoes ] +php: | + array ( + 'items' => array ( + array ( + 'item' => 'Super Hoop', + 'quantity' => 1, + ), + array ( + 'Basketball', + 'Big Shoes' + ) + ) + ) +--- %YAML:1.0 +test: Compact notation +brief: | + Compact notation for sets of mappings with single element +yaml: | + --- + # products purchased + - item : Super Hoop + - item : Basketball + quantity: 1 + - item: + name: Big Shoes + nick: Biggies + quantity: 1 +php: | + array ( + array ( + 'item' => 'Super Hoop', + ), + array ( + 'item' => 'Basketball', + 'quantity' => 1, + ), + array ( + 'item' => array( + 'name' => 'Big Shoes', + 'nick' => 'Biggies' + ), + 'quantity' => 1 + ) + ) +--- +test: Compact notation combined with inline notation +brief: | + Combinations of compact and inline notation are allowed +yaml: | + --- + items: + - { item: Super Hoop, quantity: 1 } + - [ Basketball, Big Shoes ] +php: | + array ( + 'items' => array ( + array ( + 'item' => 'Super Hoop', + 'quantity' => 1, + ), + array ( + 'Basketball', + 'Big Shoes' + ) + ) + ) +--- %YAML:1.0 +test: Compact notation +brief: | + Compact notation for sets of mappings with single element +yaml: | + --- + # products purchased + - item : Super Hoop + - item : Basketball + quantity: 1 + - item: + name: Big Shoes + nick: Biggies + quantity: 1 +php: | + array ( + array ( + 'item' => 'Super Hoop', + ), + array ( + 'item' => 'Basketball', + 'quantity' => 1, + ), + array ( + 'item' => array( + 'name' => 'Big Shoes', + 'nick' => 'Biggies' + ), + 'quantity' => 1 + ) + ) +--- +test: Compact notation combined with inline notation +brief: | + Combinations of compact and inline notation are allowed +yaml: | + --- + items: + - { item: Super Hoop, quantity: 1 } + - [ Basketball, Big Shoes ] +php: | + array ( + 'items' => array ( + array ( + 'item' => 'Super Hoop', + 'quantity' => 1, + ), + array ( + 'Basketball', + 'Big Shoes' + ) + ) + ) diff --git a/lib/Symfony/Component/Yaml/Tests/Fixtures/sfMergeKey.yml b/lib/Symfony/Component/Yaml/Tests/Fixtures/sfMergeKey.yml new file mode 100644 index 0000000000000..3eec4f877daac --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/Fixtures/sfMergeKey.yml @@ -0,0 +1,27 @@ +--- %YAML:1.0 +test: Simple In Place Substitution +brief: > + If you want to reuse an entire alias, only overwriting what is different + you can use a << in place substitution. This is not part of the official + YAML spec, but a widely implemented extension. See the following URL for + details: http://yaml.org/type/merge.html +yaml: | + foo: &foo + a: Steve + b: Clark + c: Brian + bar: &bar + <<: *foo + x: Oren + foo2: &foo2 + a: Ballmer + ding: &dong [ fi, fei, fo, fam] + check: + <<: + - *foo + - *dong + isit: tested + head: + <<: [ *foo , *dong , *foo2 ] +php: | + array('foo' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian'), 'bar' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'x' => 'Oren'), 'foo2' => array('a' => 'Ballmer'), 'ding' => array('fi', 'fei', 'fo', 'fam'), 'check' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'fi', 'fei', 'fo', 'fam', 'isit' => 'tested'), 'head' => array('a' => 'Ballmer', 'b' => 'Clark', 'c' => 'Brian', 'fi', 'fei', 'fo', 'fam')) diff --git a/lib/Symfony/Component/Yaml/Tests/Fixtures/sfObjects.yml b/lib/Symfony/Component/Yaml/Tests/Fixtures/sfObjects.yml new file mode 100644 index 0000000000000..ee124b2446eb9 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/Fixtures/sfObjects.yml @@ -0,0 +1,11 @@ +--- %YAML:1.0 +test: Objects +brief: > + Comments at the end of a line +yaml: | + ex1: "foo # bar" + ex2: "foo # bar" # comment + ex3: 'foo # bar' # comment + ex4: foo # comment +php: | + array('ex1' => 'foo # bar', 'ex2' => 'foo # bar', 'ex3' => 'foo # bar', 'ex4' => 'foo') diff --git a/lib/Symfony/Component/Yaml/Tests/Fixtures/sfQuotes.yml b/lib/Symfony/Component/Yaml/Tests/Fixtures/sfQuotes.yml new file mode 100644 index 0000000000000..741f1befeb8e7 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/Fixtures/sfQuotes.yml @@ -0,0 +1,33 @@ +--- %YAML:1.0 +test: Some characters at the beginning of a string must be escaped +brief: > + Some characters at the beginning of a string must be escaped +yaml: | + foo: | bar +php: | + array('foo' => '| bar') +--- +test: A key can be a quoted string +brief: > + A key can be a quoted string +yaml: | + "foo1": bar + 'foo2': bar + "foo \" bar": bar + 'foo '' bar': bar + 'foo3: ': bar + "foo4: ": bar + foo5: { "foo \" bar: ": bar, 'foo '' bar: ': bar } +php: | + array( + 'foo1' => 'bar', + 'foo2' => 'bar', + 'foo " bar' => 'bar', + 'foo \' bar' => 'bar', + 'foo3: ' => 'bar', + 'foo4: ' => 'bar', + 'foo5' => array( + 'foo " bar: ' => 'bar', + 'foo \' bar: ' => 'bar', + ), + ) diff --git a/lib/Symfony/Component/Yaml/Tests/Fixtures/sfTests.yml b/lib/Symfony/Component/Yaml/Tests/Fixtures/sfTests.yml new file mode 100644 index 0000000000000..7a54f1639b117 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/Fixtures/sfTests.yml @@ -0,0 +1,135 @@ +--- %YAML:1.0 +test: Multiple quoted string on one line +brief: > + Multiple quoted string on one line +yaml: | + stripped_title: { name: "foo bar", help: "bar foo" } +php: | + array('stripped_title' => array('name' => 'foo bar', 'help' => 'bar foo')) +--- +test: Empty sequence +yaml: | + foo: [ ] +php: | + array('foo' => array()) +--- +test: Empty value +yaml: | + foo: +php: | + array('foo' => null) +--- +test: Inline string parsing +brief: > + Inline string parsing +yaml: | + test: ['complex: string', 'another [string]'] +php: | + array('test' => array('complex: string', 'another [string]')) +--- +test: Boolean +brief: > + Boolean +yaml: | + - false + - true + - null + - ~ + - 'false' + - 'true' + - 'null' + - '~' +php: | + array( + false, + true, + null, + null, + 'false', + 'true', + 'null', + '~', + ) +--- +test: Empty lines in folded blocks +brief: > + Empty lines in folded blocks +yaml: | + foo: + bar: | + foo + + + + bar +php: | + array('foo' => array('bar' => "foo\n\n\n \nbar\n")) +--- +test: IP addresses +brief: > + IP addresses +yaml: | + foo: 10.0.0.2 +php: | + array('foo' => '10.0.0.2') +--- +test: A sequence with an embedded mapping +brief: > + A sequence with an embedded mapping +yaml: | + - foo + - bar: { bar: foo } +php: | + array('foo', array('bar' => array('bar' => 'foo'))) +--- +test: A sequence with an unordered array +brief: > + A sequence with an unordered array +yaml: | + 1: foo + 0: bar +php: | + array(1 => 'foo', 0 => 'bar') +--- +test: Octal +brief: as in spec example 2.19, octal value is converted +yaml: | + foo: 0123 +php: | + array('foo' => 83) +--- +test: Octal strings +brief: Octal notation in a string must remain a string +yaml: | + foo: "0123" +php: | + array('foo' => '0123') +--- +test: Octal strings +brief: Octal notation in a string must remain a string +yaml: | + foo: '0123' +php: | + array('foo' => '0123') +--- +test: Octal strings +brief: Octal notation in a string must remain a string +yaml: | + foo: | + 0123 +php: | + array('foo' => "0123\n") +--- +test: Document as a simple hash +brief: Document as a simple hash +yaml: | + { foo: bar } +php: | + array('foo' => 'bar') +--- +test: Document as a simple array +brief: Document as a simple array +yaml: | + [ foo, bar ] +php: | + array('foo', 'bar') diff --git a/lib/Symfony/Component/Yaml/Tests/Fixtures/unindentedCollections.yml b/lib/Symfony/Component/Yaml/Tests/Fixtures/unindentedCollections.yml new file mode 100644 index 0000000000000..fd8ad7ed448db --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/Fixtures/unindentedCollections.yml @@ -0,0 +1,62 @@ +--- %YAML:1.0 +test: Unindented collection +brief: > + Unindented collection +yaml: | + collection: + - item1 + - item2 + - item3 +php: | + array('collection' => array('item1', 'item2', 'item3')) +--- +test: Nested unindented collection (two levels) +brief: > + Nested unindented collection +yaml: | + collection: + key: + - a + - b + - c +php: | + array('collection' => array('key' => array('a', 'b', 'c'))) +--- +test: Nested unindented collection (three levels) +brief: > + Nested unindented collection +yaml: | + collection: + key: + subkey: + - one + - two + - three +php: | + array('collection' => array('key' => array('subkey' => array('one', 'two', 'three')))) +--- +test: Key/value after unindented collection (1) +brief: > + Key/value after unindented collection (1) +yaml: | + collection: + key: + - a + - b + - c + foo: bar +php: | + array('collection' => array('key' => array('a', 'b', 'c')), 'foo' => 'bar') +--- +test: Key/value after unindented collection (at the same level) +brief: > + Key/value after unindented collection +yaml: | + collection: + key: + - a + - b + - c + foo: bar +php: | + array('collection' => array('key' => array('a', 'b', 'c'), 'foo' => 'bar')) diff --git a/lib/Symfony/Component/Yaml/Tests/InlineTest.php b/lib/Symfony/Component/Yaml/Tests/InlineTest.php new file mode 100644 index 0000000000000..04e9d4df80985 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/InlineTest.php @@ -0,0 +1,230 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml\Tests; + +use Symfony\Component\Yaml\Yaml; +use Symfony\Component\Yaml\Inline; + +class InlineTest extends \PHPUnit_Framework_TestCase +{ + public function testParse() + { + foreach ($this->getTestsForParse() as $yaml => $value) { + $this->assertSame($value, Inline::parse($yaml), sprintf('::parse() converts an inline YAML to a PHP structure (%s)', $yaml)); + } + } + + public function testDump() + { + $testsForDump = $this->getTestsForDump(); + + foreach ($testsForDump as $yaml => $value) { + $this->assertEquals($yaml, Inline::dump($value), sprintf('::dump() converts a PHP structure to an inline YAML (%s)', $yaml)); + } + + foreach ($this->getTestsForParse() as $yaml => $value) { + $this->assertEquals($value, Inline::parse(Inline::dump($value)), 'check consistency'); + } + + foreach ($testsForDump as $yaml => $value) { + $this->assertEquals($value, Inline::parse(Inline::dump($value)), 'check consistency'); + } + } + + public function testDumpNumericValueWithLocale() + { + $locale = setlocale(LC_NUMERIC, 0); + if (false === $locale) { + $this->markTestSkipped('Your platform does not support locales.'); + } + + $required_locales = array('fr_FR.UTF-8', 'fr_FR.UTF8', 'fr_FR.utf-8', 'fr_FR.utf8', 'French_France.1252'); + if (false === setlocale(LC_ALL, $required_locales)) { + $this->markTestSkipped('Could not set any of required locales: ' . implode(", ", $required_locales)); + } + + $this->assertEquals('1.2', Inline::dump(1.2)); + $this->assertContains('fr', strtolower(setlocale(LC_NUMERIC, 0))); + + setlocale(LC_ALL, $locale); + } + + public function testHashStringsResemblingExponentialNumericsShouldNotBeChangedToINF() + { + $value = '686e444'; + + $this->assertSame($value, Inline::parse(Inline::dump($value))); + } + + /** + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + */ + public function testParseScalarWithIncorrectlyQuotedStringShouldThrowException() + { + $value = "'don't do somthin' like that'"; + Inline::parse($value); + } + + /** + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + */ + public function testParseScalarWithIncorrectlyDoubleQuotedStringShouldThrowException() + { + $value = '"don"t do somthin" like that"'; + Inline::parse($value); + } + + /** + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + */ + public function testParseInvalidMappingKeyShouldThrowException() + { + $value = '{ "foo " bar": "bar" }'; + Inline::parse($value); + } + + /** + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + */ + public function testParseInvalidMappingShouldThrowException() + { + Inline::parse('[foo] bar'); + } + + /** + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + */ + public function testParseInvalidSequenceShouldThrowException() + { + Inline::parse('{ foo: bar } bar'); + } + + public function testParseScalarWithCorrectlyQuotedStringShouldReturnString() + { + $value = "'don''t do somthin'' like that'"; + $expect = "don't do somthin' like that"; + + $this->assertSame($expect, Inline::parseScalar($value)); + } + + protected function getTestsForParse() + { + return array( + '' => '', + 'null' => null, + 'false' => false, + 'true' => true, + '12' => 12, + '-12' => -12, + '"quoted string"' => 'quoted string', + "'quoted string'" => 'quoted string', + '12.30e+02' => 12.30e+02, + '0x4D2' => 0x4D2, + '02333' => 02333, + '.Inf' => -log(0), + '-.Inf' => log(0), + "'686e444'" => '686e444', + '686e444' => 646e444, + '123456789123456789123456789123456789' => '123456789123456789123456789123456789', + '"foo\r\nbar"' => "foo\r\nbar", + "'foo#bar'" => 'foo#bar', + "'foo # bar'" => 'foo # bar', + "'#cfcfcf'" => '#cfcfcf', + '::form_base.html.twig' => '::form_base.html.twig', + + '2007-10-30' => mktime(0, 0, 0, 10, 30, 2007), + '2007-10-30T02:59:43Z' => gmmktime(2, 59, 43, 10, 30, 2007), + '2007-10-30 02:59:43 Z' => gmmktime(2, 59, 43, 10, 30, 2007), + '1960-10-30 02:59:43 Z' => gmmktime(2, 59, 43, 10, 30, 1960), + '1730-10-30T02:59:43Z' => gmmktime(2, 59, 43, 10, 30, 1730), + + '"a \\"string\\" with \'quoted strings inside\'"' => 'a "string" with \'quoted strings inside\'', + "'a \"string\" with ''quoted strings inside'''" => 'a "string" with \'quoted strings inside\'', + + // sequences + // urls are no key value mapping. see #3609. Valid yaml "key: value" mappings require a space after the colon + '[foo, http://urls.are/no/mappings, false, null, 12]' => array('foo', 'http://urls.are/no/mappings', false, null, 12), + '[ foo , bar , false , null , 12 ]' => array('foo', 'bar', false, null, 12), + '[\'foo,bar\', \'foo bar\']' => array('foo,bar', 'foo bar'), + + // mappings + '{foo:bar,bar:foo,false:false,null:null,integer:12}' => array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12), + '{ foo : bar, bar : foo, false : false, null : null, integer : 12 }' => array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12), + '{foo: \'bar\', bar: \'foo: bar\'}' => array('foo' => 'bar', 'bar' => 'foo: bar'), + '{\'foo\': \'bar\', "bar": \'foo: bar\'}' => array('foo' => 'bar', 'bar' => 'foo: bar'), + '{\'foo\'\'\': \'bar\', "bar\"": \'foo: bar\'}' => array('foo\'' => 'bar', "bar\"" => 'foo: bar'), + '{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}' => array('foo: ' => 'bar', "bar: " => 'foo: bar'), + + // nested sequences and mappings + '[foo, [bar, foo]]' => array('foo', array('bar', 'foo')), + '[foo, {bar: foo}]' => array('foo', array('bar' => 'foo')), + '{ foo: {bar: foo} }' => array('foo' => array('bar' => 'foo')), + '{ foo: [bar, foo] }' => array('foo' => array('bar', 'foo')), + + '[ foo, [ bar, foo ] ]' => array('foo', array('bar', 'foo')), + + '[{ foo: {bar: foo} }]' => array(array('foo' => array('bar' => 'foo'))), + + '[foo, [bar, [foo, [bar, foo]], foo]]' => array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo')), + + '[foo, {bar: foo, foo: [foo, {bar: foo}]}, [foo, {bar: foo}]]' => array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo'))), + + '[foo, bar: { foo: bar }]' => array('foo', '1' => array('bar' => array('foo' => 'bar'))), + '[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']' => array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%',), true, '@service_container',), + ); + } + + protected function getTestsForDump() + { + return array( + 'null' => null, + 'false' => false, + 'true' => true, + '12' => 12, + "'quoted string'" => 'quoted string', + '12.30e+02' => 12.30e+02, + '1234' => 0x4D2, + '1243' => 02333, + '.Inf' => -log(0), + '-.Inf' => log(0), + "'686e444'" => '686e444', + '.Inf' => 646e444, + '"foo\r\nbar"' => "foo\r\nbar", + "'foo#bar'" => 'foo#bar', + "'foo # bar'" => 'foo # bar', + "'#cfcfcf'" => '#cfcfcf', + + "'a \"string\" with ''quoted strings inside'''" => 'a "string" with \'quoted strings inside\'', + + // sequences + '[foo, bar, false, null, 12]' => array('foo', 'bar', false, null, 12), + '[\'foo,bar\', \'foo bar\']' => array('foo,bar', 'foo bar'), + + // mappings + '{ foo: bar, bar: foo, \'false\': false, \'null\': null, integer: 12 }' => array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12), + '{ foo: bar, bar: \'foo: bar\' }' => array('foo' => 'bar', 'bar' => 'foo: bar'), + + // nested sequences and mappings + '[foo, [bar, foo]]' => array('foo', array('bar', 'foo')), + + '[foo, [bar, [foo, [bar, foo]], foo]]' => array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo')), + + '{ foo: { bar: foo } }' => array('foo' => array('bar' => 'foo')), + + '[foo, { bar: foo }]' => array('foo', array('bar' => 'foo')), + + '[foo, { bar: foo, foo: [foo, { bar: foo }] }, [foo, { bar: foo }]]' => array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo'))), + + '[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']' => array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%',), true, '@service_container',), + ); + } +} diff --git a/lib/Symfony/Component/Yaml/Tests/ParserTest.php b/lib/Symfony/Component/Yaml/Tests/ParserTest.php new file mode 100644 index 0000000000000..231a37b7d1588 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Tests/ParserTest.php @@ -0,0 +1,404 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml\Tests; + +use Symfony\Component\Yaml\Yaml; +use Symfony\Component\Yaml\Parser; + +class ParserTest extends \PHPUnit_Framework_TestCase +{ + protected $parser; + + protected function setUp() + { + $this->parser = new Parser(); + } + + protected function tearDown() + { + $this->parser = null; + } + + /** + * @dataProvider getDataFormSpecifications + */ + public function testSpecifications($file, $expected, $yaml, $comment) + { + if ('escapedCharacters' == $file) { + if (!function_exists('iconv') && !function_exists('mb_convert_encoding')) { + $this->markTestSkipped('The iconv and mbstring extensions are not available.'); + } + } + + $this->assertEquals($expected, var_export($this->parser->parse($yaml), true), $comment); + } + + public function getDataFormSpecifications() + { + $parser = new Parser(); + $path = __DIR__.'/Fixtures'; + + $tests = array(); + $files = $parser->parse(file_get_contents($path.'/index.yml')); + foreach ($files as $file) { + $yamls = file_get_contents($path.'/'.$file.'.yml'); + + // split YAMLs documents + foreach (preg_split('/^---( %YAML\:1\.0)?/m', $yamls) as $yaml) { + if (!$yaml) { + continue; + } + + $test = $parser->parse($yaml); + if (isset($test['todo']) && $test['todo']) { + // TODO + } else { + $expected = var_export(eval('return '.trim($test['php']).';'), true); + + $tests[] = array($file, $expected, $test['yaml'], $test['test']); + } + } + } + + return $tests; + } + + public function testTabsInYaml() + { + // test tabs in YAML + $yamls = array( + "foo:\n bar", + "foo:\n bar", + "foo:\n bar", + "foo:\n bar", + ); + + foreach ($yamls as $yaml) { + try { + $content = $this->parser->parse($yaml); + + $this->fail('YAML files must not contain tabs'); + } catch (\Exception $e) { + $this->assertInstanceOf('\Exception', $e, 'YAML files must not contain tabs'); + $this->assertEquals('A YAML file cannot contain tabs as indentation at line 2 (near "'.strpbrk($yaml, "\t").'").', $e->getMessage(), 'YAML files must not contain tabs'); + } + } + } + + public function testEndOfTheDocumentMarker() + { + $yaml = <<assertEquals('foo', $this->parser->parse($yaml)); + } + + public function getBlockChompingTests() + { + $tests = array(); + + $yaml = <<<'EOF' +foo: |- + one + two + +bar: |- + one + two + +EOF; + $expected = array( + 'foo' => "one\ntwo", + 'bar' => "one\ntwo", + ); + $tests['Literal block chomping strip with trailing newline'] = array($expected, $yaml); + + $yaml = <<<'EOF' +foo: |- + one + two +bar: |- + one + two +EOF; + $expected = array( + 'foo' => "one\ntwo", + 'bar' => "one\ntwo", + ); + $tests['Literal block chomping strip without trailing newline'] = array($expected, $yaml); + + $yaml = <<<'EOF' +foo: | + one + two + +bar: | + one + two + +EOF; + $expected = array( + 'foo' => "one\ntwo\n", + 'bar' => "one\ntwo\n", + ); + $tests['Literal block chomping clip with trailing newline'] = array($expected, $yaml); + + $yaml = <<<'EOF' +foo: | + one + two +bar: | + one + two +EOF; + $expected = array( + 'foo' => "one\ntwo\n", + 'bar' => "one\ntwo\n", + ); + $tests['Literal block chomping clip without trailing newline'] = array($expected, $yaml); + + $yaml = <<<'EOF' +foo: |+ + one + two + +bar: |+ + one + two + +EOF; + $expected = array( + 'foo' => "one\ntwo\n\n", + 'bar' => "one\ntwo\n\n", + ); + $tests['Literal block chomping keep with trailing newline'] = array($expected, $yaml); + + $yaml = <<<'EOF' +foo: |+ + one + two +bar: |+ + one + two +EOF; + $expected = array( + 'foo' => "one\ntwo\n", + 'bar' => "one\ntwo\n", + ); + $tests['Literal block chomping keep without trailing newline'] = array($expected, $yaml); + + $yaml = <<<'EOF' +foo: >- + one + two + +bar: >- + one + two + +EOF; + $expected = array( + 'foo' => "one two", + 'bar' => "one two", + ); + $tests['Folded block chomping strip with trailing newline'] = array($expected, $yaml); + + $yaml = <<<'EOF' +foo: >- + one + two +bar: >- + one + two +EOF; + $expected = array( + 'foo' => "one two", + 'bar' => "one two", + ); + $tests['Folded block chomping strip without trailing newline'] = array($expected, $yaml); + + $yaml = <<<'EOF' +foo: > + one + two + +bar: > + one + two + +EOF; + $expected = array( + 'foo' => "one two\n", + 'bar' => "one two\n", + ); + $tests['Folded block chomping clip with trailing newline'] = array($expected, $yaml); + + $yaml = <<<'EOF' +foo: > + one + two +bar: > + one + two +EOF; + $expected = array( + 'foo' => "one two\n", + 'bar' => "one two\n", + ); + $tests['Folded block chomping clip without trailing newline'] = array($expected, $yaml); + + $yaml = <<<'EOF' +foo: >+ + one + two + +bar: >+ + one + two + +EOF; + $expected = array( + 'foo' => "one two\n\n", + 'bar' => "one two\n\n", + ); + $tests['Folded block chomping keep with trailing newline'] = array($expected, $yaml); + + $yaml = <<<'EOF' +foo: >+ + one + two +bar: >+ + one + two +EOF; + $expected = array( + 'foo' => "one two\n", + 'bar' => "one two\n", + ); + $tests['Folded block chomping keep without trailing newline'] = array($expected, $yaml); + + return $tests; + } + + /** + * @dataProvider getBlockChompingTests + */ + public function testBlockChomping($expected, $yaml) + { + $this->assertSame($expected, $this->parser->parse($yaml)); + } + + public function testObjectSupportEnabled() + { + $input = <<assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($input, false, true), '->parse() is able to parse objects'); + } + + public function testObjectSupportDisabledButNoExceptions() + { + $input = <<assertEquals(array('foo' => null, 'bar' => 1), $this->parser->parse($input), '->parse() does not parse objects'); + } + + /** + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + */ + public function testObjectsSupportDisabledWithExceptions() + { + $this->parser->parse('foo: !!php/object:O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";}', true, false); + } + + public function testNonUtf8Exception() + { + if (!function_exists('mb_detect_encoding') || !function_exists('iconv')) { + $this->markTestSkipped('Exceptions for non-utf8 charsets require the mb_detect_encoding() and iconv() functions.'); + + return; + } + + $yamls = array( + iconv("UTF-8", "ISO-8859-1", "foo: 'äöüß'"), + iconv("UTF-8", "ISO-8859-15", "euro: '€'"), + iconv("UTF-8", "CP1252", "cp1252: '©ÉÇáñ'") + ); + + foreach ($yamls as $yaml) { + try { + $this->parser->parse($yaml); + + $this->fail('charsets other than UTF-8 are rejected.'); + } catch (\Exception $e) { + $this->assertInstanceOf('Symfony\Component\Yaml\Exception\ParseException', $e, 'charsets other than UTF-8 are rejected.'); + } + } + } + + /** + * + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + * + */ + public function testUnindentedCollectionException() + { + $yaml = <<parser->parse($yaml); + } + + /** + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + */ + public function testSequenceInAMapping() + { + Yaml::parse(<< + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml\Tests; + +use Symfony\Component\Yaml\Yaml; + +class YamlTest extends \PHPUnit_Framework_TestCase +{ + + public function testParseAndDump() + { + $data = array('lorem' => 'ipsum', 'dolor' => 'sit'); + $yml = Yaml::dump($data); + $parsed = Yaml::parse($yml); + $this->assertEquals($data, $parsed); + + $filename = __DIR__.'/Fixtures/index.yml'; + $contents = file_get_contents($filename); + $parsedByFilename = Yaml::parse($filename); + $parsedByContents = Yaml::parse($contents); + $this->assertEquals($parsedByFilename, $parsedByContents); + } + + public function testEmbededPhp() + { + $filename = __DIR__.'/Fixtures/embededPhp.yml'; + Yaml::enablePhpParsing(); + $parsed = Yaml::parse($filename); + $this->assertEquals(array('value' => 6), $parsed); + } + +} diff --git a/lib/Symfony/Component/Yaml/Unescaper.php b/lib/Symfony/Component/Yaml/Unescaper.php new file mode 100644 index 0000000000000..708f2a18f2851 --- /dev/null +++ b/lib/Symfony/Component/Yaml/Unescaper.php @@ -0,0 +1,145 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml; + +/** + * Unescaper encapsulates unescaping rules for single and double-quoted + * YAML strings. + * + * @author Matthew Lewinski + */ +class Unescaper +{ + // Parser and Inline assume UTF-8 encoding, so escaped Unicode characters + // must be converted to that encoding. + const ENCODING = 'UTF-8'; + + // Regex fragment that matches an escaped character in a double quoted + // string. + const REGEX_ESCAPED_CHARACTER = "\\\\([0abt\tnvfre \\\"\\/\\\\N_LP]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})"; + + /** + * Unescapes a single quoted string. + * + * @param string $value A single quoted string. + * + * @return string The unescaped string. + */ + public function unescapeSingleQuotedString($value) + { + return str_replace('\'\'', '\'', $value); + } + + /** + * Unescapes a double quoted string. + * + * @param string $value A double quoted string. + * + * @return string The unescaped string. + */ + public function unescapeDoubleQuotedString($value) + { + $self = $this; + $callback = function($match) use ($self) { + return $self->unescapeCharacter($match[0]); + }; + + // evaluate the string + return preg_replace_callback('/'.self::REGEX_ESCAPED_CHARACTER.'/u', $callback, $value); + } + + /** + * Unescapes a character that was found in a double-quoted string + * + * @param string $value An escaped character + * + * @return string The unescaped character + */ + public function unescapeCharacter($value) + { + switch ($value{1}) { + case '0': + return "\x0"; + case 'a': + return "\x7"; + case 'b': + return "\x8"; + case 't': + return "\t"; + case "\t": + return "\t"; + case 'n': + return "\n"; + case 'v': + return "\xb"; + case 'f': + return "\xc"; + case 'r': + return "\xd"; + case 'e': + return "\x1b"; + case ' ': + return ' '; + case '"': + return '"'; + case '/': + return '/'; + case '\\': + return '\\'; + case 'N': + // U+0085 NEXT LINE + return $this->convertEncoding("\x00\x85", self::ENCODING, 'UCS-2BE'); + case '_': + // U+00A0 NO-BREAK SPACE + return $this->convertEncoding("\x00\xA0", self::ENCODING, 'UCS-2BE'); + case 'L': + // U+2028 LINE SEPARATOR + return $this->convertEncoding("\x20\x28", self::ENCODING, 'UCS-2BE'); + case 'P': + // U+2029 PARAGRAPH SEPARATOR + return $this->convertEncoding("\x20\x29", self::ENCODING, 'UCS-2BE'); + case 'x': + $char = pack('n', hexdec(substr($value, 2, 2))); + + return $this->convertEncoding($char, self::ENCODING, 'UCS-2BE'); + case 'u': + $char = pack('n', hexdec(substr($value, 2, 4))); + + return $this->convertEncoding($char, self::ENCODING, 'UCS-2BE'); + case 'U': + $char = pack('N', hexdec(substr($value, 2, 8))); + + return $this->convertEncoding($char, self::ENCODING, 'UCS-4BE'); + } + } + + /** + * Convert a string from one encoding to another. + * + * @param string $value The string to convert + * @param string $to The input encoding + * @param string $from The output encoding + * + * @return string The string with the new encoding + * + * @throws RuntimeException if no suitable encoding function is found (iconv or mbstring) + */ + private function convertEncoding($value, $to, $from) + { + if (function_exists('mb_convert_encoding')) { + return mb_convert_encoding($value, $to, $from); + } elseif (function_exists('iconv')) { + return iconv($from, $to, $value); + } + + throw new RuntimeException('No suitable convert encoding function (install the iconv or mbstring extension).'); + } +} diff --git a/lib/Symfony/Component/Yaml/Yaml.php b/lib/Symfony/Component/Yaml/Yaml.php new file mode 100644 index 0000000000000..adc99c471e4db --- /dev/null +++ b/lib/Symfony/Component/Yaml/Yaml.php @@ -0,0 +1,159 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml; + +use Symfony\Component\Yaml\Exception\ParseException; + +/** + * Yaml offers convenience methods to load and dump YAML. + * + * @author Fabien Potencier + * + * @api + */ +class Yaml +{ + /** + * Be warned that PHP support will be removed in Symfony 2.3. + * + * @deprecated Deprecated since version 2.0, to be removed in 2.3. + */ + public static $enablePhpParsing = false; + + /** + * Enables PHP support when parsing YAML files. + * + * Be warned that PHP support will be removed in Symfony 2.3. + * + * @deprecated Deprecated since version 2.0, to be removed in 2.3. + */ + public static function enablePhpParsing() + { + self::$enablePhpParsing = true; + } + + /** + * Sets the PHP support flag when parsing YAML files. + * + * Be warned that PHP support will be removed in Symfony 2.3. + * + * @param Boolean $boolean true if PHP parsing support is enabled, false otherwise + * + * @deprecated Deprecated since version 2.0, to be removed in 2.3. + */ + public static function setPhpParsing($boolean) + { + self::$enablePhpParsing = (Boolean) $boolean; + } + + /** + * Checks if PHP support is enabled when parsing YAML files. + * + * Be warned that PHP support will be removed in Symfony 2.3. + * + * @return Boolean true if PHP parsing support is enabled, false otherwise + * + * @deprecated Deprecated since version 2.0, to be removed in 2.3. + */ + public static function supportsPhpParsing() + { + return self::$enablePhpParsing; + } + + /** + * Parses YAML into a PHP array. + * + * The parse method, when supplied with a YAML stream (string or file), + * will do its best to convert YAML in a file into a PHP array. + * + * Usage: + * + * $array = Yaml::parse('config.yml'); + * print_r($array); + * + * + * As this method accepts both plain strings and file names as an input, + * you must validate the input before calling this method. Passing a file + * as an input is a deprecated feature and will be removed in 3.0. + * + * @param string $input Path to a YAML file or a string containing YAML + * + * @return array The YAML converted to a PHP array + * + * @throws ParseException If the YAML is not valid + * + * @api + */ + public static function parse($input, $exceptionOnInvalidType = false, $objectSupport = false) + { + // if input is a file, process it + $file = ''; + if (strpos($input, "\n") === false && is_file($input)) { + if (false === is_readable($input)) { + throw new ParseException(sprintf('Unable to parse "%s" as the file is not readable.', $input)); + } + + $file = $input; + if (self::$enablePhpParsing) { + ob_start(); + $retval = include($file); + $content = ob_get_clean(); + + // if an array is returned by the config file assume it's in plain php form else in YAML + $input = is_array($retval) ? $retval : $content; + + // if an array is returned by the config file assume it's in plain php form else in YAML + if (is_array($input)) { + return $input; + } + } else { + $input = file_get_contents($file); + } + } + + $yaml = new Parser(); + + try { + return $yaml->parse($input, $exceptionOnInvalidType, $objectSupport); + } catch (ParseException $e) { + if ($file) { + $e->setParsedFile($file); + } + + throw $e; + } + } + + /** + * Dumps a PHP array to a YAML string. + * + * The dump method, when supplied with an array, will do its best + * to convert the array into friendly YAML. + * + * @param array $array PHP array + * @param integer $inline The level where you switch to inline YAML + * @param integer $indent The amount of spaces to use for indentation of nested nodes. + * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param Boolean $objectSupport true if object support is enabled, false otherwise + * + * @return string A YAML string representing the original PHP array + * + * @api + */ + public static function dump($array, $inline = 2, $indent = 4, $exceptionOnInvalidType = false, $objectSupport = false) + { + $yaml = new Dumper(); + $yaml->setIndentation($indent); + + return $yaml->dump($array, $inline, 0, $exceptionOnInvalidType, $objectSupport); + } +} diff --git a/lib/Symfony/Component/Yaml/composer.json b/lib/Symfony/Component/Yaml/composer.json new file mode 100644 index 0000000000000..1a009c16d6a27 --- /dev/null +++ b/lib/Symfony/Component/Yaml/composer.json @@ -0,0 +1,31 @@ +{ + "name": "symfony/yaml", + "type": "library", + "description": "Symfony Yaml Component", + "keywords": [], + "homepage": "http://symfony.com", + "license": "MIT", + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "require": { + "php": ">=5.3.3" + }, + "autoload": { + "psr-0": { "Symfony\\Component\\Yaml\\": "" } + }, + "target-dir": "Symfony/Component/Yaml", + "minimum-stability": "dev", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + } +} diff --git a/lib/Symfony/Component/Yaml/phpunit.xml.dist b/lib/Symfony/Component/Yaml/phpunit.xml.dist new file mode 100644 index 0000000000000..aa77e9de77ce0 --- /dev/null +++ b/lib/Symfony/Component/Yaml/phpunit.xml.dist @@ -0,0 +1,29 @@ + + + + + + ./Tests/ + + + + + + ./ + + ./vendor + ./Tests + + + + diff --git a/lib/Varien/Cache/Core.php b/lib/Varien/Cache/Core.php index 8e7c4743acc0e..98cac174d5a79 100644 --- a/lib/Varien/Cache/Core.php +++ b/lib/Varien/Cache/Core.php @@ -26,23 +26,37 @@ class Varien_Cache_Core extends Zend_Cache_Core { + /** + * Available options + * + * ====> (array) backend_decorators : + * - array of decorators to decorate cache backend. Each element of this array should contain: + * -- 'class' - concrete decorator, descendant of Magento_Cache_Backend_Decorator_Abstract + * -- 'options' - optional array of specific decorator options + * @var array + */ + protected $_specificOptions = array( + 'backend_decorators' => array(), + 'disable_save' => false, + ); + /** * Make and return a cache id * * Checks 'cache_id_prefix' and returns new id with prefix or simply the id if null * - * @param string $id Cache id + * @param string $cacheId Cache id * @return string Cache id (with or without prefix) */ - protected function _id($id) + protected function _id($cacheId) { - if ($id !== null) { - $id = preg_replace('/([^a-zA-Z0-9_]{1,1})/', '_', $id); + if ($cacheId !== null) { + $cacheId = preg_replace('/([^a-zA-Z0-9_]{1,1})/', '_', $cacheId); if (isset($this->_options['cache_id_prefix'])) { - $id = $this->_options['cache_id_prefix'] . $id; + $cacheId = $this->_options['cache_id_prefix'] . $cacheId; } } - return $id; + return $cacheId; } /** @@ -62,18 +76,23 @@ protected function _tags($tags) /** * Save some data in a cache * - * @param mixed $data Data to put in cache (can be another type than string if automatic_serialization is on) - * @param string $id Cache id (if not set, the last cache id will be used) - * @param array $tags Cache tags - * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime) - * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends - * @throws Zend_Cache_Exception - * @return boolean True if no problem + * @param mixed $data Data to put in cache (can be another type than string if + * automatic_serialization is on) + * @param null|string $cacheId Cache id (if not set, the last cache id will be used) + * @param array $tags Cache tags + * @param bool|int $specificLifetime If != false, set a specific lifetime for this cache record + * (null => infinite lifetime) + * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by + * some particular backends + * @return boolean True if no problem */ - public function save($data, $id = null, $tags = array(), $specificLifetime = false, $priority = 8) + public function save($data, $cacheId = null, $tags = array(), $specificLifetime = false, $priority = 8) { + if ($this->getOption('disable_save')) { + return true; + } $tags = $this->_tags($tags); - return parent::save($data, $id, $tags, $specificLifetime, $priority); + return parent::save($data, $cacheId, $tags, $specificLifetime, $priority); } /** @@ -127,4 +146,51 @@ public function getIdsNotMatchingTags($tags = array()) $tags = $this->_tags($tags); return parent::getIdsNotMatchingTags($tags); } -} \ No newline at end of file + + /** + * Set the backend + * + * @param Zend_Cache_Backend $backendObject + * @return void + */ + public function setBackend(Zend_Cache_Backend $backendObject) + { + $backendObject = $this->_decorateBackend($backendObject); + parent::setBackend($backendObject); + } + + /** + * Decorate cache backend with additional functionality + * + * @param Zend_Cache_Backend + * @return Zend_Cache_Backend + */ + protected function _decorateBackend(Zend_Cache_Backend $backendObject) + { + if (!is_array($this->_specificOptions['backend_decorators'])) { + Zend_Cache::throwException("'backend_decorator' option should be an array"); + } + + foreach ($this->_specificOptions['backend_decorators'] as $decoratorName => $decoratorOptions) { + if (!is_array($decoratorOptions) || !array_key_exists('class', $decoratorOptions)) { + Zend_Cache::throwException("Concrete decorator options in '" . $decoratorName + . "' should be an array containing 'class' key" ); + } + $classOptions = array_key_exists('options', $decoratorOptions) ? $decoratorOptions['options'] : array(); + $classOptions['concrete_backend'] = $backendObject; + + if (!class_exists($decoratorOptions['class'])) { + Zend_Cache::throwException("Class '" . $decoratorOptions['class'] . "' specified in '" + . $decoratorName . "' does not exist"); + } + + $backendObject = new $decoratorOptions['class']($classOptions); + if (!($backendObject instanceof Magento_Cache_Backend_Decorator_DecoratorAbstract)) { + Zend_Cache::throwException("Decorator in '" . $decoratorName + . "' should extend Magento_Cache_Backend_Decorator_DecoratorAbstract"); + } + } + + return $backendObject; + } +} diff --git a/lib/Varien/Data/Collection/Db.php b/lib/Varien/Data/Collection/Db.php index 760d590c71436..8b60536d01a16 100644 --- a/lib/Varien/Data/Collection/Db.php +++ b/lib/Varien/Data/Collection/Db.php @@ -591,6 +591,9 @@ public function load($printQuery = false, $logQuery = false) public function fetchItem() { if (null === $this->_fetchStmt) { + $this->_renderOrders() + ->_renderLimit(); + $this->_fetchStmt = $this->getConnection() ->query($this->getSelect()); } diff --git a/lib/Varien/Data/Form.php b/lib/Varien/Data/Form.php index 9483fbb775a1c..c7cdaac2f7d30 100644 --- a/lib/Varien/Data/Form.php +++ b/lib/Varien/Data/Form.php @@ -30,6 +30,10 @@ * @category Varien * @package Varien_Data * @author Magento Core Team + * + * @method Varien_Data_Form setParent($block) + * @method Mage_Backend_Block_Widget_Form getParent() + * @method Mage_Backend_Block_Widget_Form setUseContainer($flag) */ class Varien_Data_Form extends Varien_Data_Form_Abstract { diff --git a/lib/Varien/Data/Form/Abstract.php b/lib/Varien/Data/Form/Abstract.php index 474400445ea41..46cda2eb9a2ba 100644 --- a/lib/Varien/Data/Form/Abstract.php +++ b/lib/Varien/Data/Form/Abstract.php @@ -71,7 +71,7 @@ protected function _construct() } /** - * Enter description here... + * Add element type * * @param string $type * @param string $className @@ -84,7 +84,7 @@ public function addType($type, $className) } /** - * Enter description here... + * Get elements collection * * @return Varien_Data_Form_Element_Collection */ @@ -150,9 +150,8 @@ public function addField($elementId, $type, $config, $after=false) { if (isset($this->_types[$type])) { $className = $this->_types[$type]; - } - else { - $className = 'Varien_Data_Form_Element_'.ucfirst(strtolower($type)); + } else { + $className = 'Varien_Data_Form_Element_' . ucfirst(strtolower($type)); } $element = new $className($config); $element->setId($elementId); @@ -173,12 +172,12 @@ public function removeField($elementId) } /** - * Enter description here... + * Add fieldset * * @param string $elementId * @param array $config * @param bool|string|null $after - * + * @param bool $isAdvanced * @return Varien_Data_Form_Element_Fieldset */ public function addFieldset($elementId, $config, $after = false, $isAdvanced = false) @@ -191,7 +190,7 @@ public function addFieldset($elementId, $config, $after = false, $isAdvanced = f } /** - * Enter description here... + * Add column element * * @param string $elementId * @param array $config @@ -207,7 +206,7 @@ public function addColumn($elementId, $config) } /** - * Enter description here... + * Convert elements to array * * @param array $arrAttributes * @return array diff --git a/lib/Varien/Data/Form/Element/Button.php b/lib/Varien/Data/Form/Element/Button.php index 296d93b5a0d24..6eff5d477c1ba 100644 --- a/lib/Varien/Data/Form/Element/Button.php +++ b/lib/Varien/Data/Form/Element/Button.php @@ -33,10 +33,31 @@ */ class Varien_Data_Form_Element_Button extends Varien_Data_Form_Element_Abstract { + /** + * Additional html attributes + * + * @var array + */ + protected $_htmlAttributes = array('data-mage-init'); + + /** + * @param array $attributes + */ public function __construct($attributes=array()) { parent::__construct($attributes); $this->setType('button'); $this->setExtType('textfield'); } -} \ No newline at end of file + + /** + * Html attributes + * + * @return array + */ + public function getHtmlAttributes() + { + $attributes = parent::getHtmlAttributes(); + return array_merge($attributes, $this->_htmlAttributes); + } +} diff --git a/lib/Varien/Data/Form/Element/Date.php b/lib/Varien/Data/Form/Element/Date.php index 757727abc0d3a..1753c9717a3f5 100644 --- a/lib/Varien/Data/Form/Element/Date.php +++ b/lib/Varien/Data/Form/Element/Date.php @@ -153,14 +153,6 @@ public function getValueInstance() public function getElementHtml() { $this->addClass('input-text'); - - $html = sprintf( - '', - $this->getName(), - $this->getHtmlId(), - $this->_escape($this->getValue()), - $this->serialize($this->getHtmlAttributes()) - ); $dateFormat = $this->getDateFormat(); $timeFormat = $this->getTimeFormat(); if (empty($dateFormat)) { @@ -168,30 +160,30 @@ public function getElementHtml() . 'Please, specify "format" key in constructor, or set it using setFormat().'); } - $html .= sprintf(' - ', + $dataInit = 'data-mage-init="' + . $this->_escape(json_encode( + array( + 'calendar' => array( + 'dateFormat' => $dateFormat, + 'showsTime' => !empty($timeFormat), + 'timeFormat' => $timeFormat, + 'buttonImage' => $this->getImage(), + 'buttonText' => 'Select Date', + 'disabled' => $this->getDisabled(), + ) + ) + )) + . '"'; + + $html = sprintf( + '', + $this->getName(), $this->getHtmlId(), - $dateFormat, - $timeFormat ? 'true' : 'false', - $timeFormat ?: '', - $this->getImage(), - 'Select Date', - ($this->getDisabled() ? 'true' : 'false') + $this->_escape($this->getValue()), + $this->serialize($this->getHtmlAttributes()), + $dataInit ); - $html .= $this->getAfterElementHtml(); - return $html; } } diff --git a/lib/Varien/Data/Form/Element/Editor.php b/lib/Varien/Data/Form/Element/Editor.php index ac211238ae300..75807f0621617 100644 --- a/lib/Varien/Data/Form/Element/Editor.php +++ b/lib/Varien/Data/Form/Element/Editor.php @@ -101,9 +101,10 @@ public function getElementHtml() } $html = $this->_getButtonsHtml() - . '' . $js . '