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 '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
diff --git a/.gitignore b/.gitignore
index 490342a..1eb8629 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,7 +13,8 @@
/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 @@
/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 a301068..b181ed3 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 7b63049..483a51f 100644
--- a/app/Mage.php
+++ b/app/Mage.php
@@ -47,6 +47,11 @@
const PARAM_RUN_TYPE = 'MAGE_RUN_TYPE';
/**
+ * Application run code
+ */
+ const PARAM_MODE = 'MAGE_MODE';
+
+ /**
* Base directory
*/
const PARAM_BASEDIR = 'base_dir';
@@ -99,7 +104,7 @@
*
* @var array
*/
- static private $_registry = array();
+ static private $_registry = array();
/**
* Application root absolute path
@@ -141,21 +146,14 @@
*
* @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 @@
'revision' => '0',
'patch' => '0',
'stability' => 'dev',
- 'number' => '43',
+ 'number' => '44',
);
}
@@ -258,9 +256,9 @@
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 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 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 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 @@
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 @@
}
/**
- * 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 @@
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 isInstalled()
{
- return (bool) self::$_objectManager->get('Mage_Core_Model_Config_Primary')->getInstallDate();
+ return (bool) Mage::getSingleton('Mage_Core_Model_Config_Primary')->getInstallDate();
}
/**
@@ -724,28 +721,25 @@
}
/**
- * 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 printException(Exception $e, $extra = '')
{
- if (self::$_isDeveloperMode) {
+ if (self::getIsDeveloperMode()) {
print '<pre>';
if (!empty($extra)) {
diff --git a/app/bootstrap.php b/app/bootstrap.php
index d20ee4c..d258845 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 <<<HTML
<div style="font:12px/1.35em arial, helvetica, sans-serif;">
@@ -71,7 +69,7 @@
<h3 style="margin:0;font-size:1.7em;font-weight:normal;text-transform:none;text-align:left;color:#2f2f2f;">
Whoops, it looks like you have an invalid PHP version.</h3>
</div>
- <p>Magento supports PHP 5.3.0 or newer.
+ <p>Magento supports PHP 5.3.3 or newer.
<a href="http://www.magento.com/install" target="">Find out</a>
how to install Magento using PHP-CGI as a work-around.
</p>
@@ -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 0000000..39db7fd
--- /dev/null
+++ b/app/code/Mage/AdminNotification/etc/adminhtml/acl.xml
@@ -0,0 +1,45 @@
+<?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_AdminNotification
+ * @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::system_other_settings">
+ <resource id="Mage_AdminNotification::adminnotification" module="Mage_AdminNotification" title="Notifications" sortOrder="10">
+ <resource id="Mage_AdminNotification::show_toolbar" module="Mage_AdminNotification" title="Show Toolbar" sortOrder="10" />
+ <resource id="Mage_AdminNotification::show_list" module="Mage_AdminNotification" title="Show List" sortOrder="20" />
+ <resource id="Mage_AdminNotification::mark_as_read" module="Mage_AdminNotification" title="Mark as Read" sortOrder="30" />
+ <resource id="Mage_AdminNotification::adminnotification_remove" module="Mage_AdminNotification" title="Remove" sortOrder="40" />
+ </resource>
+ </resource>
+ </resource>
+ </resource>
+ </resources>
+ </acl>
+</config>
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 0000000..edcecc1
--- /dev/null
+++ b/app/code/Mage/AdminNotification/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_AdminNotification
+ * @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_AdminNotification::system_adminnotification" title="Notifications" module="Mage_AdminNotification" sortOrder="10" parent="Mage_Adminhtml::system_other_settings" action="adminhtml/notification" resource="Mage_AdminNotification::adminnotification"/>
+ </menu>
+</config>
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 0000000..76aa739
--- /dev/null
+++ b/app/code/Mage/AdminNotification/etc/config.xml
@@ -0,0 +1,81 @@
+<?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_AdminNotification
+ * @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_AdminNotification>
+ <version>1.6.0.0</version>
+ <active>true</active>
+ <depends>
+ <Mage_Core/>
+ <Mage_Adminhtml/>
+ </depends>
+ </Mage_AdminNotification>
+ </modules>
+ <global>
+ <resources>
+ <adminnotification_setup>
+ <setup>
+ <module>Mage_AdminNotification</module>
+ </setup>
+ </adminnotification_setup>
+ </resources>
+ </global>
+ <adminhtml>
+ <translate>
+ <modules>
+ <Mage_AdminNotification>
+ <files>
+ <default>Mage_AdminNotification.csv</default>
+ </files>
+ </Mage_AdminNotification>
+ </modules>
+ </translate>
+ <events>
+ <controller_action_predispatch>
+ <observers>
+ <adminnotification>
+ <class>Mage_AdminNotification_Model_Observer</class>
+ <method>preDispatch</method>
+ </adminnotification>
+ </observers>
+ </controller_action_predispatch>
+ </events>
+ </adminhtml>
+ <default>
+ <system>
+ <adminnotification>
+ <feed_url>notifications.magentocommerce.com/community/notifications.rss</feed_url>
+ <popup_url>widgets.magentocommerce.com/notificationPopup</popup_url>
+ <severity_icons_url>widgets.magentocommerce.com/%s/%s.gif</severity_icons_url>
+ <use_https>0</use_https>
+ <frequency>1</frequency>
+ <last_update>0</last_update>
+ </adminnotification>
+ </system>
+ </default>
+</config>
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/Mage/Adminhtml/Block/Api/Tab/Rolesusers.php b/app/code/Mage/Adminhtml/Block/Api/Tab/Rolesusers.php
new file mode 100644
index 0000000..f7bbd86
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Api/Tab/Rolesusers.php
@@ -0,0 +1,54 @@
+<?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_Adminhtml
+ * @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_Api_Tab_Rolesusers extends Mage_Adminhtml_Block_Widget_Tabs {
+
+ protected function _construct()
+ {
+ parent::_construct();
+
+ $roleId = $this->getRequest()->getParam('rid', false);
+
+ $users = Mage::getModel('Mage_Api_Model_User')->getCollection()->load();
+ $this->setTemplate('api/rolesusers.phtml')
+ ->assign('users', $users->getItems())
+ ->assign('roleId', $roleId);
+ }
+
+ protected function _prepareLayout()
+ {
+ $this->setChild(
+ 'userGrid',
+ $this->getLayout()->createBlock('Mage_Adminhtml_Block_Api_Role_Grid_User', 'roleUsersGrid')
+ );
+ return parent::_prepareLayout();
+ }
+
+ 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/Mage/Adminhtml/Block/Catalog/Category/Tree.php b/app/code/Mage/Adminhtml/Block/Catalog/Category/Tree.php
new file mode 100644
index 0000000..2223168
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Category/Tree.php
@@ -0,0 +1,409 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+
+/**
+ * Categories tree block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+class Mage_Adminhtml_Block_Catalog_Category_Tree extends Mage_Adminhtml_Block_Catalog_Category_Abstract
+{
+ protected $_withProductCount;
+
+ protected $_template = 'catalog/category/tree.phtml';
+
+
+ protected function _construct()
+ {
+ parent::_construct();
+ $this->setUseAjax(true);
+ $this->_withProductCount = true;
+ }
+
+ protected function _prepareLayout()
+ {
+ $addUrl = $this->getUrl("*/*/add", array(
+ '_current'=>true,
+ 'id'=>null,
+ '_query' => false
+ ));
+
+ $this->addChild('add_sub_button', 'Mage_Adminhtml_Block_Widget_Button', array(
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Add Subcategory'),
+ 'onclick' => "addNew('".$addUrl."', false)",
+ 'class' => 'add',
+ 'id' => 'add_subcategory_button',
+ 'style' => $this->canAddSubCategory() ? '' : 'display: none;'
+ ));
+
+ if ($this->canAddRootCategory()) {
+ $this->addChild('add_root_button', 'Mage_Adminhtml_Block_Widget_Button', array(
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Add Root Category'),
+ 'onclick' => "addNew('".$addUrl."', true)",
+ 'class' => 'add',
+ 'id' => 'add_root_category_button'
+ ));
+ }
+
+ $this->setChild('store_switcher',
+ $this->getLayout()->createBlock('Mage_Backend_Block_Store_Switcher')
+ ->setSwitchUrl($this->getUrl('*/*/*', array('_current'=>true, '_query'=>false, 'store'=>null)))
+ ->setTemplate('store/switcher/enhanced.phtml')
+ );
+ return parent::_prepareLayout();
+ }
+
+ protected function _getDefaultStoreId()
+ {
+ return Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID;
+ }
+
+ public function getCategoryCollection()
+ {
+ $storeId = $this->getRequest()->getParam('store', $this->_getDefaultStoreId());
+ $collection = $this->getData('category_collection');
+ if (is_null($collection)) {
+ $collection = Mage::getModel('Mage_Catalog_Model_Category')->getCollection();
+
+ /* @var $collection Mage_Catalog_Model_Resource_Category_Collection */
+ $collection->addAttributeToSelect('name')
+ ->addAttributeToSelect('is_active')
+ ->setProductStoreId($storeId)
+ ->setLoadProductCount($this->_withProductCount)
+ ->setStoreId($storeId);
+
+ $this->setData('category_collection', $collection);
+ }
+ return $collection;
+ }
+
+ /**
+ * Retrieve list of categories with name containing $namePart and their parents
+ *
+ * @param string $namePart
+ * @return string
+ */
+ public function getSuggestedCategoriesJson($namePart)
+ {
+ $storeId = $this->getRequest()->getParam('store', $this->_getDefaultStoreId());
+
+ /* @var $collection Mage_Catalog_Model_Resource_Category_Collection */
+ $collection = Mage::getModel('Mage_Catalog_Model_Category')->getCollection();
+
+ $matchingNamesCollection = clone $collection;
+ $escapedNamePart = Mage::getResourceHelper('Mage_Core')->addLikeEscape($namePart, array('position' => 'any'));
+ $matchingNamesCollection->addAttributeToFilter('name', array('like' => $escapedNamePart))
+ ->addAttributeToFilter('entity_id', array('neq' => Mage_Catalog_Model_Category::TREE_ROOT_ID))
+ ->addAttributeToSelect('path')
+ ->setStoreId($storeId);
+
+ $shownCategoriesIds = array();
+ foreach ($matchingNamesCollection as $category) {
+ foreach (explode('/', $category->getPath()) as $parentId) {
+ $shownCategoriesIds[$parentId] = 1;
+ }
+ }
+
+ $collection->addAttributeToFilter('entity_id', array('in' => array_keys($shownCategoriesIds)))
+ ->addAttributeToSelect(array('name', 'is_active', 'parent_id'))
+ ->setStoreId($storeId);
+
+ $categoryById = array(
+ Mage_Catalog_Model_Category::TREE_ROOT_ID => array(
+ 'id' => Mage_Catalog_Model_Category::TREE_ROOT_ID,
+ 'children' => array()
+ )
+ );
+ foreach ($collection as $category) {
+ foreach (array($category->getId(), $category->getParentId()) as $categoryId) {
+ if (!isset($categoryById[$categoryId])) {
+ $categoryById[$categoryId] = array('id' => $categoryId, 'children' => array());
+ }
+ }
+ $categoryById[$category->getId()]['is_active'] = $category->getIsActive();
+ $categoryById[$category->getId()]['label'] = $category->getName();
+ $categoryById[$category->getParentId()]['children'][] = &$categoryById[$category->getId()];
+ }
+
+ return Mage::helper('Mage_Core_Helper_Data')->jsonEncode(
+ $categoryById[Mage_Catalog_Model_Category::TREE_ROOT_ID]['children']
+ );
+ }
+
+ public function getAddRootButtonHtml()
+ {
+ return $this->getChildHtml('add_root_button');
+ }
+
+ public function getAddSubButtonHtml()
+ {
+ return $this->getChildHtml('add_sub_button');
+ }
+
+ public function getExpandButtonHtml()
+ {
+ return $this->getChildHtml('expand_button');
+ }
+
+ public function getCollapseButtonHtml()
+ {
+ return $this->getChildHtml('collapse_button');
+ }
+
+ public function getStoreSwitcherHtml()
+ {
+ return $this->getChildHtml('store_switcher');
+ }
+
+ public function getLoadTreeUrl($expanded=null)
+ {
+ $params = array('_current'=>true, 'id'=>null,'store'=>null);
+ if (
+ (is_null($expanded) && Mage::getSingleton('Mage_Backend_Model_Auth_Session')->getIsTreeWasExpanded())
+ || $expanded == true) {
+ $params['expand_all'] = true;
+ }
+ return $this->getUrl('*/*/categoriesJson', $params);
+ }
+
+ public function getNodesUrl()
+ {
+ return $this->getUrl('*/catalog_category/jsonTree');
+ }
+
+ public function getSwitchTreeUrl()
+ {
+ return $this->getUrl(
+ "*/catalog_category/tree",
+ array('_current'=>true, 'store'=>null, '_query'=>false, 'id'=>null, 'parent'=>null)
+ );
+ }
+
+ public function getIsWasExpanded()
+ {
+ return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->getIsTreeWasExpanded();
+ }
+
+ public function getMoveUrl()
+ {
+ return $this->getUrl('*/catalog_category/move', array('store'=>$this->getRequest()->getParam('store')));
+ }
+
+ public function getTree($parenNodeCategory=null)
+ {
+ $rootArray = $this->_getNodeJson($this->getRoot($parenNodeCategory));
+ $tree = isset($rootArray['children']) ? $rootArray['children'] : array();
+ return $tree;
+ }
+
+ public function getTreeJson($parenNodeCategory=null)
+ {
+ $rootArray = $this->_getNodeJson($this->getRoot($parenNodeCategory));
+ $json = Mage::helper('Mage_Core_Helper_Data')->jsonEncode(
+ isset($rootArray['children']) ? $rootArray['children'] : array()
+ );
+ return $json;
+ }
+
+ /**
+ * Get JSON of array of categories, that are breadcrumbs for specified category path
+ *
+ * @param string $path
+ * @param string $javascriptVarName
+ * @return string
+ */
+ public function getBreadcrumbsJavascript($path, $javascriptVarName)
+ {
+ if (empty($path)) {
+ return '';
+ }
+
+ $categories = Mage::getResourceSingleton('Mage_Catalog_Model_Resource_Category_Tree')
+ ->setStoreId($this->getStore()->getId())->loadBreadcrumbsArray($path);
+ if (empty($categories)) {
+ return '';
+ }
+ foreach ($categories as $key => $category) {
+ $categories[$key] = $this->_getNodeJson($category);
+ }
+ return
+ '<script type="text/javascript">'
+ . $javascriptVarName . ' = ' . Mage::helper('Mage_Core_Helper_Data')->jsonEncode($categories) . ';'
+ . ($this->canAddSubCategory()
+ ? '$("add_subcategory_button").show();'
+ : '$("add_subcategory_button").hide();')
+ . '</script>';
+ }
+
+ /**
+ * Get JSON of a tree node or an associative array
+ *
+ * @param Varien_Data_Tree_Node|array $node
+ * @param int $level
+ * @return string
+ */
+ protected function _getNodeJson($node, $level = 0)
+ {
+ // create a node from data array
+ if (is_array($node)) {
+ $node = new Varien_Data_Tree_Node($node, 'entity_id', new Varien_Data_Tree);
+ }
+
+ $item = array();
+ $item['text'] = $this->buildNodeName($node);
+
+ /* $rootForStores = Mage::getModel('Mage_Core_Model_Store')
+ ->getCollection()
+ ->loadByCategoryIds(array($node->getEntityId())); */
+ $rootForStores = in_array($node->getEntityId(), $this->getRootIds());
+
+ $item['id'] = $node->getId();
+ $item['store'] = (int) $this->getStore()->getId();
+ $item['path'] = $node->getData('path');
+
+ $item['cls'] = 'folder ' . ($node->getIsActive() ? 'active-category' : 'no-active-category');
+ //$item['allowDrop'] = ($level<3) ? true : false;
+ $allowMove = $this->_isCategoryMoveable($node);
+ $item['allowDrop'] = $allowMove;
+ // disallow drag if it's first level and category is root of a store
+ $item['allowDrag'] = $allowMove && (($node->getLevel()==1 && $rootForStores) ? false : true);
+
+ if ((int)$node->getChildrenCount()>0) {
+ $item['children'] = array();
+ }
+
+ $isParent = $this->_isParentSelectedCategory($node);
+
+ if ($node->hasChildren()) {
+ $item['children'] = array();
+ if (!($this->getUseAjax() && $node->getLevel() > 1 && !$isParent)) {
+ foreach ($node->getChildren() as $child) {
+ $item['children'][] = $this->_getNodeJson($child, $level+1);
+ }
+ }
+ }
+
+ if ($isParent || $node->getLevel() < 2) {
+ $item['expanded'] = true;
+ }
+
+ return $item;
+ }
+
+ /**
+ * Get category name
+ *
+ * @param Varien_Object $node
+ * @return string
+ */
+ public function buildNodeName($node)
+ {
+ $result = $this->escapeHtml($node->getName());
+ if ($this->_withProductCount) {
+ $result .= ' (' . $node->getProductCount() . ')';
+ }
+ return $result;
+ }
+
+ protected function _isCategoryMoveable($node)
+ {
+ $options = new Varien_Object(array(
+ 'is_moveable' => true,
+ 'category' => $node
+ ));
+
+ Mage::dispatchEvent('adminhtml_catalog_category_tree_is_moveable',
+ array('options'=>$options)
+ );
+
+ return $options->getIsMoveable();
+ }
+
+ protected function _isParentSelectedCategory($node)
+ {
+ if ($node && $this->getCategory()) {
+ $pathIds = $this->getCategory()->getPathIds();
+ if (in_array($node->getId(), $pathIds)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Check if page loaded by outside link to category edit
+ *
+ * @return boolean
+ */
+ public function isClearEdit()
+ {
+ return (bool) $this->getRequest()->getParam('clear');
+ }
+
+ /**
+ * Check availability of adding root category
+ *
+ * @return boolean
+ */
+ public function canAddRootCategory()
+ {
+ $options = new Varien_Object(array('is_allow'=>true));
+ Mage::dispatchEvent(
+ 'adminhtml_catalog_category_tree_can_add_root_category',
+ array(
+ 'category' => $this->getCategory(),
+ 'options' => $options,
+ 'store' => $this->getStore()->getId()
+ )
+ );
+
+ return $options->getIsAllow();
+ }
+
+ /**
+ * Check availability of adding sub category
+ *
+ * @return boolean
+ */
+ public function canAddSubCategory()
+ {
+ $options = new Varien_Object(array('is_allow'=>true));
+ Mage::dispatchEvent(
+ 'adminhtml_catalog_category_tree_can_add_sub_category',
+ array(
+ 'category' => $this->getCategory(),
+ 'options' => $options,
+ 'store' => $this->getStore()->getId()
+ )
+ );
+
+ return $options->getIsAllow();
+ }
+}
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 0000000..4ab9d28
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Helper/Form/Wysiwyg.php
@@ -0,0 +1,96 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Catalog textarea attribute WYSIWYG button
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 .= <<<HTML
+<script type="text/javascript">
+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()
+ );
+</script>
+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 0000000..faafc38
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit.php
@@ -0,0 +1,123 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Product attribute edit page
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+
+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/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Created.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Created.php
new file mode 100644
index 0000000..2053341
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Created.php
@@ -0,0 +1,99 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * New product attribute created on product edit page
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+class Mage_Adminhtml_Block_Catalog_Product_Attribute_New_Product_Created extends Mage_Adminhtml_Block_Widget
+{
+
+ protected $_template = 'catalog/product/attribute/new/created.phtml';
+
+ /**
+ * Add additional blocks to layout
+ *
+ * @return void
+ */
+ protected function _prepareLayout()
+ {
+ $this->setChild(
+ 'attributes',
+ $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Attribute_New_Product_Attributes')
+ ->setGroupAttributes($this->_getGroupAttributes())
+ );
+ }
+
+ /**
+ * Retrieve list of product attributes
+ *
+ * @return array
+ */
+ protected function _getGroupAttributes()
+ {
+ $attributes = array();
+ /** @var $product Mage_Catalog_Model_Product */
+ $product = Mage::registry('product');
+ foreach($product->getAttributes($this->getRequest()->getParam('group')) as $attribute) {
+ /** @var $attribute Mage_Eav_Model_Entity_Attribute */
+ if ($attribute->getId() == $this->getRequest()->getParam('attribute')) {
+ $attributes[] = $attribute;
+ }
+ }
+ return $attributes;
+ }
+
+ /**
+ * Retrieve HTML for 'Close' button
+ *
+ * @return string
+ */
+ public function getCloseButtonHtml()
+ {
+ return $this->getChildHtml('close_button');
+ }
+
+ /**
+ * Retrieve attributes data as JSON
+ *
+ * @return string
+ */
+ public function getAttributesBlockJson()
+ {
+ $result = array(
+ $this->getRequest()->getParam('product_tab') => $this->getChildHtml('attributes')
+ );
+ $newAttributeSetId = $this->getRequest()->getParam('new_attribute_set_id');
+ if ($newAttributeSetId) {
+ $result['newAttributeSetId'] = $newAttributeSetId;
+ }
+
+ return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($result);
+ }
+}
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 0000000..be947e0
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Add.php
@@ -0,0 +1,89 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * description
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..23a5431
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit.php
@@ -0,0 +1,360 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Customer edit block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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/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
new file mode 100644
index 0000000..35b4a2a
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tab/Inventory.php
@@ -0,0 +1,102 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Products mass update inventory tab
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+class Mage_Adminhtml_Block_Catalog_Product_Edit_Action_Attribute_Tab_Inventory
+ extends Mage_Adminhtml_Block_Widget
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
+{
+ /**
+ * Retrieve Backorders Options
+ *
+ * @return array
+ */
+ public function getBackordersOption()
+ {
+ return Mage::getSingleton('Mage_CatalogInventory_Model_Source_Backorders')->toOptionArray();
+ }
+
+ /**
+ * Retrieve field suffix
+ *
+ * @return string
+ */
+ public function getFieldSuffix()
+ {
+ return 'inventory';
+ }
+
+ /**
+ * Retrieve current store id
+ *
+ * @return int
+ */
+ public function getStoreId()
+ {
+ $storeId = $this->getRequest()->getParam('store');
+ return intval($storeId);
+ }
+
+ /**
+ * Get default config value
+ *
+ * @param string $field
+ * @return mixed
+ */
+ public function getDefaultConfigValue($field)
+ {
+ return Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_ITEM . $field, $this->getStoreId());
+ }
+
+ /**
+ * ######################## TAB settings #################################
+ */
+ public function getTabLabel()
+ {
+ return Mage::helper('Mage_Catalog_Helper_Data')->__('Advanced Inventory');
+ }
+
+ public function getTabTitle()
+ {
+ return Mage::helper('Mage_Catalog_Helper_Data')->__('Advanced Inventory');
+ }
+
+ public function canShowTab()
+ {
+ return true;
+ }
+
+ public function isHidden()
+ {
+ return false;
+ }
+}
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/Mage/Adminhtml/Block/Catalog/Product/Edit/AttributeSet.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/AttributeSet.php
new file mode 100644
index 0000000..d8b09c5
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/AttributeSet.php
@@ -0,0 +1,53 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Create product attribute set selector
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+class Mage_Adminhtml_Block_Catalog_Product_Edit_AttributeSet extends Mage_Backend_Block_Widget_Form
+{
+
+ /**
+ * Get options for suggest widget
+ *
+ * @return array
+ */
+ public function getSelectorOptions()
+ {
+ return array(
+ 'source' => $this->getUrl('*/catalog_product/suggestProductTemplates'),
+ 'className' => 'category-select',
+ 'showRecent' => true,
+ 'storageKey' => 'product-template-key',
+ 'minLength' => 0,
+ '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/Mage/Adminhtml/Block/Catalog/Product/Edit/NewCategory.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/NewCategory.php
new file mode 100644
index 0000000..8b27087
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/NewCategory.php
@@ -0,0 +1,104 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * New category creation form
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+class Mage_Adminhtml_Block_Catalog_Product_Edit_NewCategory extends Mage_Backend_Block_Widget_Form
+{
+ /**
+ * Form preparation
+ */
+ protected function _prepareForm()
+ {
+ $form = new Varien_Data_Form();
+
+ $form->addField('new_category_messages', 'note', array());
+
+ $fieldset = $form->addFieldset('new_category_form', array());
+
+ $fieldset->addField('new_category_name', 'text', array(
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Category Name'),
+ 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Category Name'),
+ 'required' => true,
+ ));
+
+ $fieldset->addField('new_category_parent', 'select', array(
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Parent Category'),
+ 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Parent Category'),
+ 'required' => true,
+ 'options' => array(),
+ 'class' => 'validate-parent-category',
+ ));
+
+ $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
+ *
+ * @return string
+ */
+ public function getAfterElementHtml()
+ {
+ /** @var $coreHelper Mage_Core_Helper_Data */
+ $coreHelper = Mage::helper('Mage_Core_Helper_Data');
+ $widgetUrl = $coreHelper->jsonEncode($this->getViewFileUrl('Mage_Catalog::js/new-category-dialog.js'));
+ $widgetOptions = $coreHelper->jsonEncode(array(
+ 'suggestOptions' => array(
+ 'source' => $this->getUrl('adminhtml/catalog_category/suggestCategories'),
+ 'valueField' => '#new_category_parent',
+ 'className' => 'category-select',
+ 'multiselect' => true,
+ 'showAll' => true,
+ ),
+ 'saveCategoryUrl' => $this->getUrl('adminhtml/catalog_category/save'),
+ ));
+ return <<<HTML
+<script>
+ head.js($widgetUrl, function () {
+ jQuery(function($) { // waiting for page to load to have '#category_ids-template' available
+ $('#new-category').mage('newCategoryDialog', $widgetOptions);
+ });
+ });
+</script>
+HTML;
+ }
+}
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 0000000..acdee5b
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php
@@ -0,0 +1,184 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Product attributes tab
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..389f898
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes/Create.php
@@ -0,0 +1,113 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * New attribute panel on product edit page
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php
new file mode 100644
index 0000000..236e759
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php
@@ -0,0 +1,272 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Crossell products admin grid
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Crosssell extends Mage_Adminhtml_Block_Widget_Grid
+{
+ /**
+ * Set grid params
+ *
+ */
+ protected function _construct()
+ {
+ parent::_construct();
+ $this->setId('cross_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_Crosssell
+ */
+ 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;
+ }
+
+ /**
+ * Prepare collection
+ *
+ * @return Mage_Adminhtml_Block_Widget_Grid
+ */
+ protected function _prepareCollection()
+ {
+ /* @var $collection Mage_Catalog_Model_Resource_Product_Link_Product_Collection */
+ $collection = Mage::getModel('Mage_Catalog_Model_Product_Link')->useCrossSellLinks()
+ ->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();
+ }
+
+ /**
+ * Checks when this block is readonly
+ *
+ * @return boolean
+ */
+ public function isReadonly()
+ {
+ return $this->_getProduct() && $this->_getProduct()->getCrosssellReadonly();
+ }
+
+ /**
+ * Add columns to grid
+ *
+ * @return Mage_Adminhtml_Block_Widget_Grid
+ */
+ protected function _prepareColumns()
+ {
+ if (!$this->isReadonly()) {
+ $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->isReadonly(),
+ '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('*/*/crosssellGrid', array('_current'=>true));
+ }
+
+ /**
+ * Retrieve selected crosssell products
+ *
+ * @return array
+ */
+ protected function _getSelectedProducts()
+ {
+ $products = $this->getProductsCrossSell();
+ if (!is_array($products)) {
+ $products = array_keys($this->getSelectedCrossSellProducts());
+ }
+ return $products;
+ }
+
+ /**
+ * Retrieve crosssell products
+ *
+ * @return array
+ */
+ public function getSelectedCrossSellProducts()
+ {
+ $products = array();
+ foreach (Mage::registry('current_product')->getCrossSellProducts() as $product) {
+ $products[$product->getId()] = array('position' => $product->getPosition());
+ }
+ return $products;
+ }
+}
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 0000000..87e4008
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options.php
@@ -0,0 +1,67 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * customers defined options
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+
+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 0000000..43a51e6
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php
@@ -0,0 +1,352 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * customers defined options
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+
+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 = '<div class="field-service">'
+ . '<label for="' . $this->getFieldId() . '_' . $id . '_' . $selectIdHtml . $name . '" class="use-default">'
+ . '<input value="1" type="checkbox" class="use-default-control"'
+ . 'name="' . $this->getFieldName() . '[' . $id . ']' . $selectNameHtml . '[scope][' . $name . ']"'
+ . 'id="' . $this->getFieldId() . '_' . $id . '_' . $selectIdHtml . $name . '_use_default"' . $checkedHtml
+ .' /><span class="use-default-label">' . Mage::helper('Mage_Catalog_Helper_Data')->__('Use Default')
+ . '</span></label></div>';
+
+ 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 0000000..1bbe4db
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Abstract.php
@@ -0,0 +1,69 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * customers defined options
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+
+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 0000000..6ebde3a
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Select.php
@@ -0,0 +1,87 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * customers defined options
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+
+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/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Related.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Related.php
new file mode 100644
index 0000000..655d55d
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Related.php
@@ -0,0 +1,270 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Related products admin grid
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Related extends Mage_Adminhtml_Block_Widget_Grid
+{
+ /**
+ * Set grid params
+ *
+ */
+ protected function _construct()
+ {
+ parent::_construct();
+ $this->setId('related_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_Related
+ */
+ 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;
+ }
+
+ /**
+ * Prepare collection
+ *
+ * @return Mage_Adminhtml_Block_Widget_Grid
+ */
+ protected function _prepareCollection()
+ {
+ $collection = Mage::getModel('Mage_Catalog_Model_Product_Link')->useRelatedLinks()
+ ->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();
+ }
+
+ /**
+ * Checks when this block is readonly
+ *
+ * @return boolean
+ */
+ public function isReadonly()
+ {
+ return $this->_getProduct() && $this->_getProduct()->getRelatedReadonly();
+ }
+
+ /**
+ * Add columns to grid
+ *
+ * @return Mage_Adminhtml_Block_Widget_Grid
+ */
+ protected function _prepareColumns()
+ {
+ if (!$this->isReadonly()) {
+ $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()->getRelatedReadonly(),
+ '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('*/*/relatedGrid', array('_current' => true));
+ }
+
+ /**
+ * Retrieve selected related products
+ *
+ * @return array
+ */
+ protected function _getSelectedProducts()
+ {
+ $products = $this->getProductsRelated();
+ if (!is_array($products)) {
+ $products = array_keys($this->getSelectedRelatedProducts());
+ }
+ return $products;
+ }
+
+ /**
+ * Retrieve related products
+ *
+ * @return array
+ */
+ public function getSelectedRelatedProducts()
+ {
+ $products = array();
+ foreach (Mage::registry('current_product')->getRelatedProducts() as $product) {
+ $products[$product->getId()] = array('position' => $product->getPosition());
+ }
+ return $products;
+ }
+}
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 0000000..1940b4f
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config.php
@@ -0,0 +1,383 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+
+/**
+ * Adminhtml catalog super product configurable tab
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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/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
new file mode 100644
index 0000000..bc7feea
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Matrix.php
@@ -0,0 +1,239 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Product variations matrix block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Matrix
+ extends Mage_Backend_Block_Template
+{
+ /**
+ * Get configurable product type
+ *
+ * @return Mage_Catalog_Model_Product_Type_Configurable
+ */
+ protected function _getProductType()
+ {
+ return Mage::getSingleton('Mage_Catalog_Model_Product_Type_Configurable');
+ }
+
+ /**
+ * Retrieve currently edited product object
+ *
+ * @return Mage_Catalog_Model_Product
+ */
+ public function getProduct()
+ {
+ return Mage::registry('current_product');
+ }
+
+ /**
+ * Retrieve all possible attribute values combinations
+ *
+ * @return array
+ */
+ public function getVariations()
+ {
+ $variationalAttributes = array();
+ $usedProductAttributes = $this->getAttributes();
+ foreach ($usedProductAttributes as &$attribute) {
+ $options = array();
+ foreach ($attribute['options'] as $valueInfo) {
+ foreach ($attribute['values'] as $priceData) {
+ if ($priceData['value_index'] == $valueInfo['value']
+ && (!isset($priceData['include']) || $priceData['include'])
+ ) {
+ $valueInfo['price'] = $priceData;
+ $options[] = $valueInfo;
+ }
+ }
+ }
+ /** @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
+ $variationalAttributes[] = array(
+ 'id' => $attribute['attribute_id'],
+ 'values' => $options,
+ );
+
+ }
+ $attributesCount = count($variationalAttributes);
+ if ($attributesCount === 0) {
+ return array();
+ }
+
+ $variations = array();
+ $currentVariation = array_fill(0, $attributesCount, 0);
+ $variationalAttributes = array_reverse($variationalAttributes);
+ $lastAttribute = $attributesCount - 1;
+ do {
+ for ($attributeIndex = 0; $attributeIndex < $attributesCount - 1; ++$attributeIndex) {
+ if ($currentVariation[$attributeIndex] >= count($variationalAttributes[$attributeIndex]['values'])) {
+ $currentVariation[$attributeIndex] = 0;
+ ++$currentVariation[$attributeIndex + 1];
+ }
+ }
+ if ($currentVariation[$lastAttribute] >= count($variationalAttributes[$lastAttribute]['values'])) {
+ break;
+ }
+
+ $filledVariation = array();
+ for ($attributeIndex = $attributesCount; $attributeIndex--;) {
+ $currentAttribute = $variationalAttributes[$attributeIndex];
+ $filledVariation[$currentAttribute['id']] =
+ $currentAttribute['values'][$currentVariation[$attributeIndex]];
+ }
+
+ $variations[] = $filledVariation;
+ $currentVariation[0]++;
+ } while (1);
+ return $variations;
+ }
+
+ /**
+ * Get url for product edit
+ *
+ * @param $id
+ *
+ * @return string
+ */
+ public function getEditProductUrl($id)
+ {
+ return $this->getUrl('*/*/edit', array('id' => $id));
+ }
+
+
+ /**
+ * 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()
+ );
+ }
+ }
+ }
+
+ $this->setData('attributes', $attributes);
+ }
+ return $this->getData('attributes');
+ }
+
+ /**
+ * Get used product attributes
+ *
+ * @return array
+ */
+ public function getUsedAttributes()
+ {
+ return $this->_getProductType()->getUsedProductAttributes($this->getProduct());
+ }
+
+ /**
+ * Retrieve actual list of associated products, array key is obtained from varying attributes values
+ *
+ * @return array
+ */
+ public function getAssociatedProducts()
+ {
+ $productByUsedAttributes = array();
+ foreach ($this->_getAssociatedProducts() as $product) {
+ $keys = array();
+ foreach ($this->getUsedAttributes() as $attribute) {
+ /** @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
+ $keys[] = $product->getData($attribute->getAttributeCode());
+ }
+ $productByUsedAttributes[implode('-', $keys)] = $product;
+ }
+ return $productByUsedAttributes;
+ }
+
+ /**
+ * Retrieve actual list of associated products (i.e. if product contains variations matrix form data
+ * - previously saved in database relations are not considered)
+ *
+ * @return array
+ */
+ protected function _getAssociatedProducts()
+ {
+ $product = $this->getProduct();
+ $ids = $this->getProduct()->getAssociatedProductIds();
+ if ($ids === null) { // form data overrides any relations stored in database
+ return $this->_getProductType()->getUsedProducts($product);
+ }
+ $products = array();
+ foreach ($ids as $productId) {
+ /** @var $product Mage_Catalog_Model_Product */
+ $product = Mage::getModel('Mage_Catalog_Model_Product')->load($productId);
+ if ($product->getId()) {
+ $products[] = $product;
+ }
+ }
+ return $products;
+ }
+
+ /**
+ * Get html class for attribute
+ *
+ * @param string $code
+ * @return string
+ */
+ public function getAttributeFrontendClass($code)
+ {
+ /** @var $config Mage_Catalog_Model_Config */
+ $config = Mage::getSingleton('Mage_Catalog_Model_Config');
+ /** @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
+ $attribute = $config->getAttribute(Mage_Catalog_Model_Product::ENTITY, $code);
+ return $attribute instanceof Mage_Eav_Model_Entity_Attribute_Abstract
+ ? $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 0000000..b8e6d55
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Upsell.php
@@ -0,0 +1,269 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Upsell products admin grid
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..73279db
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs.php
@@ -0,0 +1,260 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * admin product edit tabs
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..a353a70
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Grid.php
@@ -0,0 +1,353 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Adminhtml customer grid block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/BaseImage.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/BaseImage.php
new file mode 100644
index 0000000..b963468
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/BaseImage.php
@@ -0,0 +1,183 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Product form image field helper
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_BaseImage extends Varien_Data_Form_Element_Abstract
+{
+ /**
+ * Model Url instance
+ *
+ * @var Mage_Backend_Model_Url
+ */
+ protected $_url;
+
+ /**
+ * @var Mage_Core_Helper_Data
+ */
+ protected $_coreHelper;
+
+ /**
+ * @var Mage_Catalog_Helper_Data
+ */
+ protected $_catalogHelperData;
+
+ /**
+ * @var Magento_File_Size
+ */
+ protected $_fileConfig;
+
+ /**
+ * Constructor
+ *
+ * @param array $attributes
+ */
+ public function __construct(array $attributes = array())
+ {
+ parent::__construct($attributes);
+
+ $this->_url = isset($attributes['url']) ? $attributes['url']
+ : Mage::getModel('Mage_Backend_Model_Url');
+ $this->_coreHelper = isset($attributes['coreHelper']) ? $attributes['coreHelper']
+ : Mage::helper('Mage_Core_Helper_Data');
+ $this->_catalogHelperData = isset($attributes['catalogHelperData']) ? $attributes['catalogHelperData']
+ : Mage::helper('Mage_Catalog_Helper_Data');
+ $this->_fileConfig = isset($attributes['fileConfig']) ? $attributes['fileConfig'] :
+ Mage::getSingleton('Magento_File_Size');
+ $this->_maxFileSize = $this->_getFileMaxSize();
+ }
+
+ /**
+ * Get label
+ *
+ * @return string
+ */
+ public function getLabel()
+ {
+ return $this->helper('Mage_Catalog_Helper_Data')->__('Images');
+ }
+
+ /**
+ * Translate message
+ *
+ * @param string $message
+ */
+ private function __($message) {
+ return $this->helper('Mage_Catalog_Helper_Data')->__($message);
+ }
+
+ /**
+ * Return element html code
+ *
+ * @return string
+ */
+ 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 = <<<HTML
+<div id="{$htmlId}-container" class="images"
+ data-mage-init="{baseImage:{}}"
+ data-max-file-size="{$this->_getFileMaxSize()}"
+ >
+ <div class="image image-placeholder">
+ <input type="file" name="image" data-url="{$uploadUrl}" multiple="multiple" />
+ <img class="spacer" src="{$spacerImage}"/>
+ <p class="image-placeholder-text">{$this->__('Click here or drag and drop to add images')}</p>
+ </div>
+ <script id="{$htmlId}-template" class="image-template" type="text/x-jquery-tmpl">
+ <div class="image" data-image-label="{$this->__('Main')}" data-image-hidden-label="{$this->__('Hidden')}">
+ <img class="spacer" src="{$spacerImage}"/>
+ <img class="product-image" src="\${url}" data-position="\${position}" alt="\${label}" />
+ <div class="actions">
+ <button class="action-delete" data-role="delete-button" title="{$this->__('Delete image')}">
+ <span>{$this->__('Delete image')}</span>
+ </button>
+ <button class="action-make-main" data-role="make-main-button" title="{$this->__('Make Base')}">
+ <span>{$this->__('Make Base')}</span>
+ </button>
+ <div class="draggable-handle"></div>
+ </div>
+ </div>
+ </script>
+</div>
+<span class="action-manage-images" data-activate-tab="image-management">
+ <span>{$this->helper('Mage_Catalog_Helper_Data')->__('Image Management')}</span>
+</span>
+<script>
+ (function($) {
+ 'use strict';
+
+ $('[data-activate-tab="image-management"]')
+ .on('click.toggleImageManagementTab', function() {
+ $('#product_info_tabs_image-management').trigger('click');
+ });
+ })(window.jQuery);
+</script>
+
+HTML;
+ return $html;
+ }
+
+ /**
+ * Get url to upload files
+ *
+ * @return string
+ */
+ protected function _getUploadUrl()
+ {
+ return $this->_url->getUrl('adminhtml/catalog_product_gallery/upload');
+ }
+
+ /**
+ * Get maximum file size to upload in bytes
+ *
+ * @return int
+ */
+ protected function _getFileMaxSize()
+ {
+ return $this->_fileConfig->getMaxFileSize();
+ }
+
+ /**
+ * Dummy function to give translation tool the ability to pick messages
+ * Must be called with Mage_Catalog_Helper_Data $className only
+ *
+ * @param string $className
+ * @return Mage_Catalog_Helper_Data|Mage_Core_Helper_Data
+ */
+ private function helper($className)
+ {
+ return $className === 'Mage_Catalog_Helper_Data' ? $this->_catalogHelperData : $this->_coreHelper;
+ }
+}
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 0000000..a020e82
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Category.php
@@ -0,0 +1,111 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Product form category field helper
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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
+ <input id="{$htmlId}-suggest" placeholder="$suggestPlaceholder" />
+ <script>
+ jQuery('#{$htmlId}-suggest').treeSuggest({$selectorOptions});
+ </script>
+ <button title="{$newCategoryCaption}" type="button" onclick="jQuery('#new-category').dialog('open')">
+ <span><span><span>{$newCategoryCaption}</span></span></span>
+ </button>
+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 0000000..7148ee6
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery/Content.php
@@ -0,0 +1,175 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+
+/**
+ * Catalog product form gallery content
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ *
+ * @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 0000000..ce9e91d
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Weight.php
@@ -0,0 +1,95 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Product form weight field helper
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 '<div class="fields-group-2"><div class="field"><div class="addon"><div class="control">'
+ . parent::getElementHtml()
+ . '<label class="addafter" for="'
+ . $this->getHtmlId()
+ . '"><strong>'. Mage::helper('Mage_Adminhtml_Helper_Data')->__('lbs') .'</strong></label>'
+ . '</div></div></div><div class="field choice">'
+ . $this->_virtual->getElementHtml() . $this->_virtual->getLabelHtml()
+ . '</div></div>';
+ }
+
+ /**
+ * 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 0000000..9bcaaec
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Widget/Chooser.php
@@ -0,0 +1,296 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Product Chooser for "Product Link" Cms Widget Plugin
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..cbc69d3
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Checkout/Agreement/Grid.php
@@ -0,0 +1,116 @@
+<?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_Adminhtml
+ * @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_Checkout_Agreement_Grid extends Mage_Adminhtml_Block_Widget_Grid
+{
+
+ protected function _construct()
+ {
+ parent::_construct();
+ $this->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 0000000..661863f
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Cms/Page/Edit.php
@@ -0,0 +1,155 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Admin CMS page
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..c73a441
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Cms/Page/Widget/Chooser.php
@@ -0,0 +1,169 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * CMS page chooser for Wysiwyg CMS widget
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..9f6109d
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content.php
@@ -0,0 +1,161 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Wysiwyg Images content block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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/Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php
new file mode 100644
index 0000000..54111b9
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php
@@ -0,0 +1,399 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Customer account form block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+class Mage_Adminhtml_Block_Customer_Edit_Tab_Account extends Mage_Adminhtml_Block_Widget_Form
+{
+
+ /*
+ * Disable Auto Group Change Attribute Name
+ */
+ const DISABLE_ATTRIBUTE_NAME = 'disable_auto_group_change';
+
+ /**
+ * Initialize form
+ *
+ * @return Mage_Adminhtml_Block_Customer_Edit_Tab_Account
+ */
+ public function initForm()
+ {
+ $form = new Varien_Data_Form();
+ $form->setHtmlIdPrefix('_account');
+ $form->setFieldNameSuffix('account');
+
+ $fieldset = $form->addFieldset('base_fieldset', array(
+ 'legend' => Mage::helper('Mage_Customer_Helper_Data')->__('Account Information')
+ ));
+
+ $customer = Mage::registry('current_customer');
+ /** @var $customerForm Mage_Customer_Model_Form */
+ $customerForm = $this->_initCustomerForm($customer);
+ $attributes = $this->_initCustomerAttributes($customerForm);
+ $this->_setFieldset($attributes, $fieldset, array(self::DISABLE_ATTRIBUTE_NAME));
+
+ $form->getElement('group_id')->setRenderer($this->getLayout()
+ ->createBlock('Mage_Adminhtml_Block_Customer_Edit_Renderer_Attribute_Group')
+ ->setDisableAutoGroupChangeAttribute($customerForm->getAttribute(self::DISABLE_ATTRIBUTE_NAME))
+ ->setDisableAutoGroupChangeAttributeValue($customer->getData(self::DISABLE_ATTRIBUTE_NAME))
+ );
+
+ $this->_setCustomerWebsiteId($customer);
+ $customerStoreId = $this->_getCustomerStoreId($customer);
+
+ $prefixElement = $form->getElement('prefix');
+ if ($prefixElement) {
+ $prefixOptions = $this->helper('Mage_Customer_Helper_Data')->getNamePrefixOptions($customerStoreId);
+ if (!empty($prefixOptions)) {
+ $fieldset->removeField($prefixElement->getId());
+ $prefixField = $fieldset->addField($prefixElement->getId(),
+ 'select',
+ $prefixElement->getData(),
+ $form->getElement('group_id')->getId()
+ );
+ $prefixField->setValues($prefixOptions);
+ if ($customer->getId()) {
+ $prefixField->addElementValues($customer->getPrefix());
+ }
+ }
+ }
+
+ $suffixElement = $form->getElement('suffix');
+ if ($suffixElement) {
+ $suffixOptions = $this->helper('Mage_Customer_Helper_Data')->getNameSuffixOptions($customerStoreId);
+ if (!empty($suffixOptions)) {
+ $fieldset->removeField($suffixElement->getId());
+ $suffixField = $fieldset->addField($suffixElement->getId(),
+ 'select',
+ $suffixElement->getData(),
+ $form->getElement('lastname')->getId()
+ );
+ $suffixField->setValues($suffixOptions);
+ if ($customer->getId()) {
+ $suffixField->addElementValues($customer->getSuffix());
+ }
+ }
+ }
+
+ if ($customer->getId()) {
+ $this->_addEditCustomerFormFields($form, $fieldset, $customer);
+ } else {
+ $this->_addNewCustomerFormFields($form, $fieldset);
+ $customer->setData('sendemail', '1');
+ }
+
+ $this->_disableSendEmailStoreForEmptyWebsite($form);
+ $this->_handleReadOnlyCustomer($form, $customer);
+
+ $form->setValues($customer->getData());
+ $this->setForm($form);
+ return $this;
+ }
+
+ /**
+ * Return predefined additional element types
+ *
+ * @return array
+ */
+ protected function _getAdditionalElementTypes()
+ {
+ return array(
+ 'file' => 'Mage_Adminhtml_Block_Customer_Form_Element_File',
+ 'image' => 'Mage_Adminhtml_Block_Customer_Form_Element_Image',
+ 'boolean' => 'Mage_Adminhtml_Block_Customer_Form_Element_Boolean',
+ );
+ }
+
+ /**
+ * Initialize attribute set
+ *
+ * @param Mage_Customer_Model_Form $customerFor
+ * @return Mage_Eav_Model_Entity_Attribute[]
+ */
+ protected function _initCustomerAttributes(Mage_Customer_Model_Form $customerForm)
+ {
+ $attributes = $customerForm->getAttributes();
+ foreach ($attributes as $attribute) {
+ /* @var $attribute Mage_Eav_Model_Entity_Attribute */
+ $attributeLabel = Mage::helper('Mage_Customer_Helper_Data')->__($attribute->getFrontend()->getLabel());
+ $attribute->setFrontendLabel($attributeLabel);
+ $attribute->unsIsVisible();
+ }
+ return $attributes;
+ }
+
+ /**
+ * Initialize customer form
+ *
+ * @param Mage_Customer_Model_Customer $customer
+ * @return Mage_Customer_Model_Form $customerForm
+ */
+ protected function _initCustomerForm(Mage_Customer_Model_Customer $customer)
+ {
+ /** @var $customerForm Mage_Customer_Model_Form */
+ $customerForm = Mage::getModel('Mage_Customer_Model_Form');
+ $customerForm->setEntity($customer)
+ ->setFormCode('adminhtml_customer')
+ ->initDefaultValues();
+
+ return $customerForm;
+ }
+
+ /**
+ * Handle Read-Only customer
+ *
+ * @param Varien_Data_Form $form
+ * @param Mage_Customer_Model_Customer $customer
+ */
+ protected function _handleReadOnlyCustomer($form, $customer)
+ {
+ if (!$customer->isReadonly()) {
+ return;
+ }
+ foreach ($customer->getAttributes() as $attribute) {
+ $element = $form->getElement($attribute->getAttributeCode());
+ if ($element) {
+ $element->setReadonly(true, true);
+ }
+ }
+ }
+
+ /**
+ * Make sendemail or sendmail_store_id disabled if website_id has an empty value
+ *
+ * @param Varien_Data_Form $form
+ */
+ protected function _disableSendEmailStoreForEmptyWebsite(Varien_Data_Form $form)
+ {
+ $isSingleMode = Mage::app()->isSingleStoreMode();
+ $sendEmailId = $isSingleMode ? 'sendemail' : 'sendemail_store_id';
+ $sendEmail = $form->getElement($sendEmailId);
+
+ $prefix = $form->getHtmlIdPrefix();
+ if ($sendEmail) {
+ $_disableStoreField = '';
+ if (!$isSingleMode) {
+ $_disableStoreField = "$('{$prefix}sendemail_store_id').disabled=(''==this.value || '0'==this.value);";
+ }
+ $sendEmail->setAfterElementHtml(
+ '<script type="text/javascript">'
+ . "
+ $('{$prefix}website_id').disableSendemail = function() {
+ $('{$prefix}sendemail').disabled = ('' == this.value || '0' == this.value);".
+ $_disableStoreField
+ ."}.bind($('{$prefix}website_id'));
+ Event.observe('{$prefix}website_id', 'change', $('{$prefix}website_id').disableSendemail);
+ $('{$prefix}website_id').disableSendemail();
+ "
+ . '</script>'
+ );
+ }
+ }
+
+ /**
+ * Create New Customer form fields
+ *
+ * @param Varien_Data_Form $form
+ * @param Varien_Data_Form_Element_Fieldset $fieldset
+ */
+ protected function _addNewCustomerFormFields($form, $fieldset)
+ {
+ $fieldset->removeField('created_in');
+
+ $this->_addPasswordManagementFieldset($form, 'Password', false);
+
+ // Prepare send welcome email checkbox
+ $fieldset->addField('sendemail', 'checkbox', array(
+ 'label' => Mage::helper('Mage_Customer_Helper_Data')->__('Send Welcome Email'),
+ 'name' => 'sendemail',
+ 'id' => 'sendemail',
+ ));
+ if (!Mage::app()->isSingleStoreMode()) {
+ $form->getElement('website_id')->addClass('validate-website-has-store');
+
+ $websites = array();
+ foreach (Mage::app()->getWebsites(true) as $website) {
+ $websites[$website->getId()] = !is_null($website->getDefaultStore());
+ }
+ $prefix = $form->getHtmlIdPrefix();
+
+ $note = Mage::helper('Mage_Customer_Helper_Data')->__('Please select a website which contains store view');
+ $form->getElement('website_id')->setAfterElementHtml(
+ '<script type="text/javascript">'
+ . "
+ var {$prefix}_websites = " . Mage::helper('Mage_Core_Helper_Data')->jsonEncode($websites) .";
+ jQuery.validator.addMethod('validate-website-has-store', function(v, elem){
+ return {$prefix}_websites[elem.value] == true;
+ },
+ '" . $note . "'
+ );
+ Element.observe('{$prefix}website_id', 'change', function(){
+ jQuery.validator.validateElement('#{$prefix}website_id');
+ }.bind($('{$prefix}website_id')));
+ "
+ . '</script>'
+ );
+ $renderer = $this->getLayout()
+ ->createBlock('Mage_Backend_Block_Store_Switcher_Form_Renderer_Fieldset_Element');
+ $form->getElement('website_id')->setRenderer($renderer);
+
+ $fieldset->addField('sendemail_store_id', 'select', array(
+ 'label' => $this->helper('Mage_Customer_Helper_Data')->__('Send From'),
+ 'name' => 'sendemail_store_id',
+ 'values' => Mage::getSingleton('Mage_Core_Model_System_Store')->getStoreValuesForForm()
+ ));
+ } else {
+ $fieldset->removeField('website_id');
+ $fieldset->addField('website_id', 'hidden', array(
+ 'name' => 'website_id'
+ ));
+ }
+ }
+
+ /**
+ * Edit/View Existing Customer form fields
+ *
+ * @param Varien_Data_Form $form
+ * @param Varien_Data_Form_Element_Fieldset $fieldset
+ * @param Mage_Customer_Model_Customer $customer
+ */
+ protected function _addEditCustomerFormFields($form, $fieldset, $customer)
+ {
+ $form->getElement('created_in')->setDisabled('disabled');
+ if (!Mage::app()->isSingleStoreMode()) {
+ $form->getElement('website_id')->setDisabled('disabled');
+ $renderer = $this->getLayout()
+ ->createBlock('Mage_Backend_Block_Store_Switcher_Form_Renderer_Fieldset_Element');
+ $form->getElement('website_id')->setRenderer($renderer);
+ } else {
+ $fieldset->removeField('website_id');
+ }
+
+ if ($customer->isReadonly()) {
+ return;
+ }
+ $this->_addPasswordManagementFieldset($form, 'New Password', true);
+
+ // Prepare customer confirmation control (only for existing customers)
+ $confirmationKey = $customer->getConfirmation();
+ if ($confirmationKey || $customer->isConfirmationRequired()) {
+ $confirmationAttr = $customer->getAttribute('confirmation');
+ if (!$confirmationKey) {
+ $confirmationKey = $customer->getRandomConfirmationKey();
+ }
+
+ $element = $fieldset->addField('confirmation', 'select', array(
+ 'name' => 'confirmation',
+ 'label' => Mage::helper('Mage_Customer_Helper_Data')->__($confirmationAttr->getFrontendLabel()),
+ ));
+ $element->setEntityAttribute($confirmationAttr);
+ $element->setValues(array(
+ '' => 'Confirmed',
+ $confirmationKey => 'Not confirmed'
+ ));
+
+ // Prepare send welcome email checkbox if customer is not confirmed
+ // no need to add it, if website ID is empty
+ if ($customer->getConfirmation() && $customer->getWebsiteId()) {
+ $fieldset->addField('sendemail', 'checkbox', array(
+ 'name' => 'sendemail',
+ 'label' => Mage::helper('Mage_Customer_Helper_Data')->__('Send Welcome Email after Confirmation')
+ ));
+ $customer->setData('sendemail', '1');
+ }
+ }
+ }
+
+ /**
+ * Add Password management fieldset
+ *
+ * @param Varien_Data_Form $form
+ * @param string $fieldLabel
+ * @param boolean $isNew whether we set initial password or change existing one
+ */
+ protected function _addPasswordManagementFieldset($form, $fieldLabel, $isNew)
+ {
+ // Add password management fieldset
+ $newFieldset = $form->addFieldset(
+ 'password_fieldset',
+ array('legend' => Mage::helper('Mage_Customer_Helper_Data')->__('Password Management'))
+ );
+ if ($isNew) {
+ // New customer password for existing customer
+ $elementId = 'new_password';
+ $elementClass = 'validate-new-password';
+ } else {
+ // Password field for newly generated customer
+ $elementId = 'password';
+ $elementClass = 'input-text required-entry validate-password';
+ }
+ $field = $newFieldset->addField($elementId, 'text',
+ array(
+ 'label' => Mage::helper('Mage_Customer_Helper_Data')->__($fieldLabel),
+ 'name' => $elementId,
+ 'class' => $elementClass,
+ 'required' => !$isNew,
+ )
+ );
+ $field->setRenderer(
+ $this->getLayout()->createBlock('Mage_Adminhtml_Block_Customer_Edit_Renderer_Newpass')
+ );
+ }
+
+ /**
+ * Get Customer Store Id
+ *
+ * @param Mage_Customer_Model_Customer $customer
+ * @return int|null
+ */
+ protected function _getCustomerStoreId(Mage_Customer_Model_Customer $customer)
+ {
+ $customerStoreId = null;
+ if ($customer->getId()) {
+ $customerStoreId = Mage::app()->getWebsite($customer->getWebsiteId())
+ ->getDefaultStore()
+ ->getId();
+ }
+ return $customerStoreId;
+ }
+
+ /**
+ * Set Customer Website Id in Single Store Mode
+ *
+ * @param Mage_Customer_Model_Customer $customer
+ */
+ protected function _setCustomerWebsiteId(Mage_Customer_Model_Customer $customer)
+ {
+ if (Mage::app()->hasSingleStore()) {
+ $customer->setWebsiteId(Mage::app()->getStore(true)->getWebsiteId());
+ }
+ }
+}
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/Mage/Adminhtml/Block/Customer/Edit/Tab/Carts.php b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Carts.php
new file mode 100644
index 0000000..dfe4758
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tab/Carts.php
@@ -0,0 +1,64 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Obtain all carts contents for specified client
+ *
+ */
+class Mage_Adminhtml_Block_Customer_Edit_Tab_Carts extends Mage_Adminhtml_Block_Template
+{
+ /**
+ * Add shopping cart grid of each website
+ *
+ * @return Mage_Adminhtml_Block_Customer_Edit_Tab_Carts
+ */
+ protected function _prepareLayout()
+ {
+ $sharedWebsiteIds = Mage::registry('current_customer')->getSharedWebsiteIds();
+ $isShared = count($sharedWebsiteIds) > 1;
+ foreach ($sharedWebsiteIds as $websiteId) {
+ $blockName = 'customer_cart_' . $websiteId;
+ $block = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Customer_Edit_Tab_Cart',
+ $blockName, array('data' => array('website_id' => $websiteId)));
+ if ($isShared) {
+ $block->setCartHeader($this->__('Shopping Cart from %s', Mage::app()->getWebsite($websiteId)->getName()));
+ }
+ $this->setChild($blockName, $block);
+ }
+ return parent::_prepareLayout();
+ }
+
+ /**
+ * Just get child blocks html
+ *
+ * @return string
+ */
+ protected function _toHtml()
+ {
+ Mage::dispatchEvent('adminhtml_block_html_before', array('block' => $this));
+ return $this->getChildHtml();
+ }
+}
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 0000000..865a567
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Customer/Edit/Tabs.php
@@ -0,0 +1,129 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * admin customer left menu
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..544b9f1
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Customer/System/Config/Validatevat.php
@@ -0,0 +1,158 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Adminhtml VAT ID validation block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..07f8ab3
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Customer/System/Config/ValidatevatFactory.php
@@ -0,0 +1,45 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Factory for Adminhtml VAT validation block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..8f4c953
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Html/Date.php
@@ -0,0 +1,36 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Adminhtml HTML select element block
+ *
+ * @category Mage
+ * @package Mage_Core
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..7b0c630
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Html/Select.php
@@ -0,0 +1,36 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Adminhtml HTML select element block
+ *
+ * @category Mage
+ * @package Mage_Core
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..caf9d10
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Messages.php
@@ -0,0 +1,37 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+
+/**
+ * Adminhtml messages block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..eae0330
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php
@@ -0,0 +1,259 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Adminhtml newsletter queue edit block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+
+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 0000000..6bd9fce
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid.php
@@ -0,0 +1,237 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Adminhtml newsletter subscribers grid block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..b80a9c2
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Newsletter/Template/Edit.php
@@ -0,0 +1,327 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+
+/**
+ * Adminhtml Newsletter Template Edit Block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..21336ff
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Newsletter/Template/Grid.php
@@ -0,0 +1,139 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Adminhtml newsletter templates grid block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..1772410
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Page/Head.php
@@ -0,0 +1,47 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Adminhtml header block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..75a7961
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Labels.php
@@ -0,0 +1,166 @@
+<?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_Adminhtml
+ * @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_Labels
+ extends Mage_Backend_Block_Widget_Form
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
+{
+ /**
+ * 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 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 0000000..6a81fce
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Rating/Edit/Tab/Form.php
@@ -0,0 +1,190 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Poll edit form
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+
+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 '<div>
+<ul class="messages">
+ <li class="notice-msg">
+ <ul>
+ <li>'.Mage::helper('Mage_Rating_Helper_Data')->__('If you do not specify a rating title for a store, the default value will be used.').'</li>
+ </ul>
+ </li>
+</ul>
+</div>';
+ }
+
+
+}
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 0000000..9b558e7
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Report/Product/Downloads/Grid.php
@@ -0,0 +1,122 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Adminhtml product downloads report grid
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..18b0910
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Report/Product/Lowstock/Grid.php
@@ -0,0 +1,110 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Adminhtml low stock products report grid block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..4dcedf4
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Report/Product/Viewed/Grid.php
@@ -0,0 +1,132 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Adminhtml most viewed products report grid block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..48cf762
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Report/Sales/Bestsellers/Grid.php
@@ -0,0 +1,104 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Adminhtml bestsellers report grid block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..1ee65bb
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Report/Sales/Coupons/Grid.php
@@ -0,0 +1,198 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Adminhtml coupons report grid block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..646a9bf
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Report/Sales/Invoiced/Grid.php
@@ -0,0 +1,132 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Adminhtml invoiced report grid block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..85a214d
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Report/Sales/Refunded/Grid.php
@@ -0,0 +1,122 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Adminhtml refunded report grid block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..c9f7ec8
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Report/Sales/Sales/Grid.php
@@ -0,0 +1,270 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Adminhtml sales report grid block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..1f4b5ed
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Report/Sales/Shipping/Grid.php
@@ -0,0 +1,124 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Adminhtml shipping report grid block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..69fb256
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Report/Sales/Tax/Grid.php
@@ -0,0 +1,140 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Adminhtml tax report grid block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..e217ed6
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Report/Shopcart/Abandoned/Grid.php
@@ -0,0 +1,183 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Adminhtml abandoned shopping carts report grid block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..06187cb
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Report/Shopcart/Product/Grid.php
@@ -0,0 +1,112 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Adminhtml products in carts report grid block
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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 0000000..27c5214
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Sales/Creditmemo/Grid.php
@@ -0,0 +1,181 @@
+<?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_Adminhtml
+ * @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)
+ */
+
+/**
+ * Adminhtml sales orders grid
+ *
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+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',