Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update as of 6/7/2012

* Fixed various crashes of visual design editor
* Fixed some layouts that caused visual design editor toolbar disappearing, also fixed some confusing page type labels
* Eliminated "after commit callback" workaround from integration tests by implementing "transparent transactions" capability in integration testing framework
* Refactored admin authentication/authorization in RSS module. Removed program termination and covered the controllers with tests
* Removed HTML-report feature of copy-paste detector which never worked anyway (`dev/tests/static/framework/Inspection/CopyPasteDetector/html_report.xslt` and all related code)
* Github requests:
** [#19](#19) Implemented "soft" dependency between modules and performed several improvements in the related code, covered with tests
  • Loading branch information...
commit 93f38e9b3c74fb61df0da2ef5047aeca64a4356a 1 parent 99b4374
@mage2-team mage2-team authored
Showing with 1,613 additions and 1,241 deletions.
  1. +10 −0 CHANGELOG.markdown
  2. +2 −17 app/Mage.php
  3. +2 −2 app/code/core/Mage/Api2/view/adminhtml/layout.xml
  4. +3 −6 app/code/core/Mage/Catalog/view/frontend/msrp.xml
  5. +5 −13 app/code/core/Mage/Checkout/view/frontend/layout.xml
  6. +28 −31 app/code/core/Mage/Core/Helper/Http.php
  7. +5 −107 app/code/core/Mage/Core/Model/Config.php
  8. +193 −0 app/code/core/Mage/Core/Model/Config/Module.php
  9. +0 −4 app/code/core/Mage/Core/view/frontend/layout.xml
  10. +0 −2  app/code/core/Mage/DesignEditor/view/frontend/layout.xml
  11. +3 −1 app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php
  12. +0 −7 app/code/core/Mage/Install/Model/Observer.php
  13. +0 −8 app/code/core/Mage/Install/etc/config.xml
  14. +10 −16 app/code/core/Mage/Oauth/view/adminhtml/layout.xml
  15. +8 −8 app/code/core/Mage/Oauth/view/frontend/layout.xml
  16. +1 −2  app/code/core/Mage/Paypal/view/frontend/layout.xml
  17. +1 −2  app/code/core/Mage/PaypalUk/view/frontend/layout.xml
  18. +0 −10 app/code/core/Mage/Review/etc/config.xml
  19. +0 −13 app/code/core/Mage/Review/view/frontend/layout.xml
  20. +2 −2 app/code/core/Mage/Rss/Block/Catalog/New.php
  21. +1 −24 app/code/core/Mage/Rss/Block/Catalog/NotifyStock.php
  22. +1 −24 app/code/core/Mage/Rss/Block/Catalog/Review.php
  23. +1 −19 app/code/core/Mage/Rss/Block/Order/New.php
  24. +0 −59 app/code/core/Mage/Rss/Controller/AdminhtmlAbstract.php
  25. +0 −72 app/code/core/Mage/Rss/Helper/Data.php
  26. +0 −76 app/code/core/Mage/Rss/Model/Observer.php
  27. +0 −51 app/code/core/Mage/Rss/Model/Session.php
  28. +64 −55 app/code/core/Mage/Rss/controllers/CatalogController.php
  29. +18 −39 app/code/core/Mage/Rss/controllers/IndexController.php
  30. +41 −18 app/code/core/Mage/Rss/controllers/OrderController.php
  31. +0 −18 app/code/core/Mage/Rss/etc/config.xml
  32. +7 −19 app/code/core/Mage/Rss/view/frontend/layout.xml
  33. +5 −5 app/code/core/Mage/Sales/view/frontend/layout.xml
  34. +1 −1  app/design/frontend/default/iphone/Mage_Catalog/layout.xml
  35. +1 −1  app/design/frontend/default/iphone/Mage_CatalogSearch/layout.xml
  36. +2 −2 app/design/frontend/default/iphone/Mage_Checkout/layout.xml
  37. +1 −1  app/design/frontend/default/iphone/Mage_Customer/layout.xml
  38. +1 −1  app/design/frontend/default/iphone/Mage_Newsletter/layout.xml
  39. +1 −1  app/design/frontend/default/iphone/Mage_Page/layout.xml
  40. +0 −12 app/design/frontend/default/iphone/Mage_Review/layout.xml
  41. +8 −12 app/design/frontend/default/iphone/Mage_Rss/layout.xml
  42. +21 −21 app/design/frontend/default/iphone/Mage_Sales/layout.xml
  43. +4 −4 app/design/frontend/default/iphone/Mage_Wishlist/layout.xml
  44. +1 −1  app/design/frontend/default/modern/Mage_Catalog/layout.xml
  45. +1 −1  app/design/frontend/default/modern/Mage_Checkout/layout.xml
  46. +1 −1  app/design/frontend/default/modern/Mage_Customer/layout.xml
  47. +0 −12 app/design/frontend/default/modern/Mage_Review/layout.xml
  48. +7 −19 app/design/frontend/default/modern/Mage_Rss/layout.xml
  49. +5 −5 app/design/frontend/default/modern/Mage_Sales/layout.xml
  50. +9 −0 dev/tests/integration/etc/local-mysql.xml.dist
  51. +81 −0 dev/tests/integration/framework/Magento/Test/Db/Adapter/Mysql.php
  52. +28 −3 ...les/order_standard_commit_workaround.php → framework/Magento/Test/Db/Adapter/TransactionInterface.php}
  53. +2 −2 dev/tests/integration/framework/Magento/Test/Listener/Annotation/Fixture.php
  54. +35 −0 dev/tests/integration/framework/Magento/Test/Request.php
  55. +31 −1 dev/tests/integration/framework/Magento/Test/TestCase/ControllerAbstract.php
  56. +106 −0 dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Db/Adapter/TransactionInterfaceTest.php
  57. +23 −3 dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/RequestTest.php
  58. +2 −2 dev/tests/integration/testsuite/Mage/Adminhtml/controllers/Sales/OrderControllerTest.php
  59. +4 −3 ...uite/Mage/{Sales/_files/transactions_commit_workaround.php → Catalog/_files/product_special_price.php}
  60. +2 −0  dev/tests/integration/testsuite/Mage/Catalog/_files/products_new.php
  61. +1 −1  dev/tests/integration/testsuite/Mage/Catalog/_files/two_products.php
  62. +1 −1  dev/tests/integration/testsuite/Mage/Core/Model/_files/_layout_update.xml
  63. +1 −1  dev/tests/integration/testsuite/Mage/Core/Model/_files/design/frontend/test/default/Mage_Core/layout.xml
  64. +2 −2 dev/tests/integration/testsuite/Mage/Paypal/Model/IpnTest.php
  65. +1 −1  dev/tests/integration/testsuite/Mage/Paypal/controllers/HostedproControllerTest.php
  66. +2 −2 dev/tests/integration/testsuite/Mage/Paypal/controllers/PayflowControllerTest.php
  67. +1 −1  dev/tests/integration/testsuite/Mage/Paypal/controllers/PayflowadvancedControllerTest.php
  68. +2 −2 dev/tests/integration/testsuite/Mage/Paypal/controllers/StandardControllerTest.php
  69. +14 −3 ...ests/integration/testsuite/Mage/{Sales/_files/order_commit_workaround.php → Review/_files/reviews.php}
  70. +0 −70 dev/tests/integration/testsuite/Mage/Rss/Helper/DataTest.php
  71. +115 −34 dev/tests/integration/testsuite/Mage/Rss/controllers/CatalogControllerTest.php
  72. +69 −0 dev/tests/integration/testsuite/Mage/Rss/controllers/IndexControllerTest.php
  73. +49 −33 dev/tests/integration/testsuite/Mage/Rss/controllers/OrderControllerTest.php
  74. +1 −1  dev/tests/integration/testsuite/Mage/Sales/Model/AbstractTest.php
  75. +1 −1  dev/tests/integration/testsuite/Mage/Sales/Model/Order/Payment/TransactionTest.php
  76. +1 −0  dev/tests/integration/testsuite/Mage/Sales/_files/order.php
  77. +1 −1  dev/tests/integration/testsuite/Mage/Wishlist/_files/wishlist.php
  78. +11 −42 dev/tests/integration/testsuite/integrity/LayoutTest.php
  79. +4 −1 dev/tests/integration/testsuite/integrity/modular/TemplateFilesTest.php
  80. +0 −40 dev/tests/static/framework/Inspection/CopyPasteDetector/Command.php
  81. +0 −98 dev/tests/static/framework/Inspection/CopyPasteDetector/html_report.xslt
  82. +0 −24 dev/tests/static/framework/tests/unit/testsuite/Inspection/CopyPasteDetector/CommandTest.php
  83. +54 −23 dev/tests/static/testsuite/Integrity/LayoutTest.php
  84. +6 −5 dev/tests/static/testsuite/Legacy/LayoutTest.php
  85. +2 −0  dev/tests/static/testsuite/Legacy/_files/obsolete_classes.php
  86. +3 −0  dev/tests/static/testsuite/Legacy/_files/obsolete_constants.php
  87. +4 −1 dev/tests/static/testsuite/Legacy/_files/obsolete_methods.php
  88. +1 −0  dev/tests/static/testsuite/Php/_files/whitelist/core.txt
  89. +103 −0 dev/tests/unit/testsuite/Mage/Core/Helper/HttpTest.php
  90. +105 −0 dev/tests/unit/testsuite/Mage/Core/Model/Config/ModuleTest.php
  91. +43 −0 dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_dependency_circular_input.xml
  92. +43 −0 dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_dependency_circular_soft_input.xml
  93. +15 −5 ...feed.phtml → dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_dependency_linear_input.xml
  94. +21 −9 ...ommit_workaround.php → unit/testsuite/Mage/Core/Model/Config/_files/module_dependency_wrong_input.xml}
  95. +44 −0 dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_filtered.xml
  96. +53 −0 dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_input.xml
  97. +50 −0 dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_sorted.xml
View
10 CHANGELOG.markdown
@@ -1,3 +1,13 @@
+Update as of 6/7/2012
+=====================
+* Fixed various crashes of visual design editor
+* Fixed some layouts that caused visual design editor toolbar disappearing, also fixed some confusing page type labels
+* Eliminated "after commit callback" workaround from integration tests by implementing "transparent transactions" capability in integration testing framework
+* Refactored admin authentication/authorization in RSS module. Removed program termination and covered the controllers with tests
+* Removed HTML-report feature of copy-paste detector which never worked anyway (`dev/tests/static/framework/Inspection/CopyPasteDetector/html_report.xslt` and all related code)
+* Github requests:
+** [#19](https://github.com/magento/magento2/pull/19) Implemented "soft" dependency between modules and performed several improvements in the related code, covered with tests
+
Update as of 5/31/2012
======================
* Implemented backend authentication independent of `Mage_Adminhtml` module. Authentication can be disabled
View
19 app/Mage.php
@@ -659,25 +659,10 @@ public static function run($code = '', $type = 'store', $options = array())
Magento_Profiler::stop('mage');
} catch (Mage_Core_Model_Session_Exception $e) {
header('Location: ' . self::getBaseUrl());
- die();
} catch (Mage_Core_Model_Store_Exception $e) {
- require_once(self::getBaseDir() . DS . 'pub' . DS . 'errors' . DS . '404.php');
- die();
+ require_once(self::getBaseDir() . '/pub/errors/404.php');
} catch (Exception $e) {
- if (self::isInstalled() || self::$_isDownloader) {
- self::printException($e);
- exit();
- }
- try {
- self::dispatchEvent('mage_run_exception', array('exception' => $e));
- if (!headers_sent()) {
- header('Location:' . self::getUrl('install'));
- } else {
- self::printException($e);
- }
- } catch (Exception $ne) {
- self::printException($ne, $e->getMessage());
- }
+ self::printException($e);
}
}
View
4 app/code/core/Mage/Api2/view/adminhtml/layout.xml
@@ -92,12 +92,12 @@
<adminhtml_api2_role_grid>
<remove name="root"/>
- <block type="Mage_Api2_Block_Adminhtml_Roles_Grid" name="api2_roles.grid" output="toHtml"/>
+ <block type="Mage_Api2_Block_Adminhtml_Roles_Grid" name="api2_roles.grid" output="1"/>
</adminhtml_api2_role_grid>
<adminhtml_api2_role_usersgrid>
<remove name="root"/>
- <block type="Mage_Api2_Block_Adminhtml_Roles_Tab_Users" name="adminhtml.role.edit.tab.users" output="toHtml"/>
+ <block type="Mage_Api2_Block_Adminhtml_Roles_Tab_Users" name="adminhtml.role.edit.tab.users" output="1"/>
</adminhtml_api2_role_usersgrid>
<!-- admin acl users edit page -->
View
9 app/code/core/Mage/Catalog/view/frontend/msrp.xml
@@ -74,8 +74,7 @@ Default layout, loads most of the pages
<update handle="MAP_popup" />
</tag_customer_view>
- <MAP_popup translate="label">
- <label>Catalog MAP Popup</label>
+ <MAP_popup>
<reference name="head">
<action method="addJs" ifconfig="sales/msrp/enabled"><file>Mage_Catalog::msrp.js</file></action>
</reference>
@@ -83,8 +82,7 @@ Default layout, loads most of the pages
<block type="Mage_Core_Block_Template" template="Mage_Catalog::msrp/popup.phtml" name="product.tooltip"/>
</reference>
</MAP_popup>
- <MAP_price_msrp_item translate="label">
- <label>Catalog MAP Price MSRP Item</label>
+ <MAP_price_msrp_item>
<reference name="catalog_product_price_template">
<action method="addPriceBlockType"><type>msrp</type><block>Mage_Catalog_Block_Product_Price</block><template>product/price_msrp_item.phtml</template></action>
</reference>
@@ -92,8 +90,7 @@ Default layout, loads most of the pages
<action method="addPriceBlockType"><type>msrp</type><block>Mage_Catalog_Block_Product_Price</block><template>product/price_msrp_item.phtml</template></action>
</reference>
</MAP_price_msrp_item>
- <MAP_price_msrp_wishlist_item translate="label">
- <label>Catalog MAP Price MSRP Wishlist Item</label>
+ <MAP_price_msrp_wishlist_item>
<reference name="catalog_product_price_template">
<action method="addPriceBlockType"><type>msrp</type><block>Mage_Catalog_Block_Product_Price</block><template>Mage_Wishlist::render/item/price_msrp_item.phtml</template></action>
</reference>
View
18 app/code/core/Mage/Checkout/view/frontend/layout.xml
@@ -90,10 +90,10 @@ Default layout, loads most of the pages
</checkout_cart_index>
<checkout_cart_configure translate="label" type="page" parent="catalog_product_view">
- <label>Configure Cart Item</label>
+ <label>Configure Cart Item (Any)</label>
<update handle="catalog_product_view"/>
<reference name="product.info">
- <block type="Mage_Checkout_Block_Cart_Item_Configure" name="checkout.cart.item.configure.block"></block>
+ <block type="Mage_Checkout_Block_Cart_Item_Configure" name="checkout.cart.item.configure.block"/>
</reference>
<reference name="product.info.addtocart">
<action method="setTemplate"><template>Mage_Checkout::cart/item/configure/updatecart.phtml</template></action>
@@ -104,17 +104,17 @@ Default layout, loads most of the pages
</checkout_cart_configure>
<checkout_cart_configure_type_downloadable translate="label" module="Mage_Downloadable" type="page" parent="checkout_cart_configure">
- <label>Configure Cart Item</label>
+ <label>Configure Cart Item (Downloadable)</label>
<update handle="catalog_product_view_type_downloadable"/>
</checkout_cart_configure_type_downloadable>
<checkout_cart_configure_type_configurable translate="label" module="Mage_Catalog" type="page" parent="checkout_cart_configure">
- <label>Configure Cart Item</label>
+ <label>Configure Cart Item (Configurable)</label>
<update handle="catalog_product_view_type_configurable"/>
</checkout_cart_configure_type_configurable>
<checkout_cart_configure_type_bundle translate="label" module="Mage_Bundle" type="page" parent="checkout_cart_configure">
- <label>Configure Bundle Cart Item</label>
+ <label>Configure Cart Item (Bundle)</label>
<update handle="catalog_product_view_type_bundle"/>
<reference name="product.info.addtocart.bundle">
<action method="setTemplate"><template>Mage_Checkout::cart/item/configure/updatecart.phtml</template></action>
@@ -434,12 +434,4 @@ One page checkout order review block
<block type="Mage_Checkout_Block_Onepage_Failure" name="checkout.failure" template="onepage/failure.phtml"/>
</reference>
</checkout_onepage_failure>
-
- <checkout_onepage_savepayment translate="label">
- <label>One Page Checkout Save Payment</label>
- </checkout_onepage_savepayment>
-
- <checkout_onepage_reorder translate="label">
- <label>One Page Checkout Reorder</label>
- </checkout_onepage_reorder>
</layout>
View
59 app/code/core/Mage/Core/Helper/Http.php
@@ -43,63 +43,60 @@ class Mage_Core_Helper_Http extends Mage_Core_Helper_Abstract
protected $_remoteAddr;
/**
- * Validate and retrieve user and password from HTTP
+ * Extract "login" and "password" credentials from HTTP-request
*
+ * Returns plain array with 2 items: login and password respectively
+ *
+ * @param Zend_Controller_Request_Http $request
* @return array
*/
- public function authValidate($headers = null)
+ public function getHttpAuthCredentials(Zend_Controller_Request_Http $request)
{
- if(!is_null($headers)) {
- $_SERVER = $headers;
- }
-
+ $server = $request->getServer();
$user = '';
$pass = '';
- // moshe's fix for CGI
- if (empty($_SERVER['HTTP_AUTHORIZATION'])) {
- foreach ($_SERVER as $k=>$v) {
- if (substr($k, -18)==='HTTP_AUTHORIZATION' && !empty($v)) {
- $_SERVER['HTTP_AUTHORIZATION'] = $v;
+ if (empty($server['HTTP_AUTHORIZATION'])) {
+ foreach ($server as $k => $v) {
+ if (substr($k, -18) === 'HTTP_AUTHORIZATION' && !empty($v)) {
+ $server['HTTP_AUTHORIZATION'] = $v;
break;
}
}
}
- if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
- $user = $_SERVER['PHP_AUTH_USER'];
- $pass = $_SERVER['PHP_AUTH_PW'];
+ if (isset($server['PHP_AUTH_USER']) && isset($server['PHP_AUTH_PW'])) {
+ $user = $server['PHP_AUTH_USER'];
+ $pass = $server['PHP_AUTH_PW'];
}
- // IIS Note:: For HTTP Authentication to work with IIS,
- // the PHP directive cgi.rfc2616_headers must be set to 0 (the default value).
- elseif (!empty($_SERVER['HTTP_AUTHORIZATION'])) {
- $auth = $_SERVER['HTTP_AUTHORIZATION'];
+ /**
+ * IIS Note: for HTTP authentication to work with IIS,
+ * the PHP directive cgi.rfc2616_headers must be set to 0 (the default value).
+ */
+ elseif (!empty($server['HTTP_AUTHORIZATION'])) {
+ $auth = $server['HTTP_AUTHORIZATION'];
list($user, $pass) = explode(':', base64_decode(substr($auth, strpos($auth, " ") + 1)));
}
- elseif (!empty($_SERVER['Authorization'])) {
- $auth = $_SERVER['Authorization'];
+ elseif (!empty($server['Authorization'])) {
+ $auth = $server['Authorization'];
list($user, $pass) = explode(':', base64_decode(substr($auth, strpos($auth, " ") + 1)));
}
- if (!$user || !$pass) {
- $this->authFailed();
- }
-
return array($user, $pass);
}
/**
- * Send auth failed Headers and exit
+ * Set "auth failed" headers to the specified response object
*
+ * @param Zend_Controller_Response_Http $response
+ * @param string $realm
*/
- public function authFailed()
+ public function failHttpAuthentication(Zend_Controller_Response_Http $response, $realm)
{
- Mage::app()->getResponse()
- ->setHeader('HTTP/1.1','401 Unauthorized')
- ->setHeader('WWW-Authenticate','Basic realm="RSS Feeds"')
+ $response->setHeader('HTTP/1.1', '401 Unauthorized')
+ ->setHeader('WWW-Authenticate', 'Basic realm="' . $realm . '"')
->setBody('<h1>401 Unauthorized</h1>')
- ->sendResponse();
- exit;
+ ;
}
/**
View
112 app/code/core/Mage/Core/Model/Config.php
@@ -753,21 +753,6 @@ public function addAllowedModules($module)
}
/**
- * Define if module is allowed
- *
- * @param string $moduleName
- * @return bool
- */
- protected function _isAllowedModule($moduleName)
- {
- if (empty($this->_allowedModules)) {
- return true;
- } else {
- return in_array($moduleName, $this->_allowedModules);
- }
- }
-
- /**
* Load declared modules configuration
*
* @return Mage_Core_Model_Config
@@ -776,57 +761,18 @@ protected function _loadDeclaredModules()
{
$moduleFiles = $this->_getDeclaredModuleFiles();
if (!$moduleFiles) {
- return ;
+ return $this;
}
Magento_Profiler::start('load_modules_declaration');
- $unsortedConfig = new Mage_Core_Model_Config_Base();
- $unsortedConfig->loadString('<config/>');
- $fileConfig = new Mage_Core_Model_Config_Base();
-
- // load modules declarations
- foreach ($moduleFiles as $file) {
- $fileConfig->loadFile($file);
+ $unsortedConfig = new Mage_Core_Model_Config_Base('<config/>');
+ foreach ($moduleFiles as $oneConfigFile) {
+ $fileConfig = new Mage_Core_Model_Config_Base($oneConfigFile);
$unsortedConfig->extend($fileConfig);
}
- $moduleDepends = array();
- foreach ($unsortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) {
- if (!$this->_isAllowedModule($moduleName)) {
- continue;
- }
-
- $depends = array();
- if ($moduleNode->depends) {
- foreach ($moduleNode->depends->children() as $depend) {
- $depends[$depend->getName()] = true;
- }
- }
- $moduleDepends[$moduleName] = array(
- 'module' => $moduleName,
- 'depends' => $depends,
- 'active' => ('true' === (string)$moduleNode->active ? true : false),
- );
- }
-
- // check and sort module dependence
- $moduleDepends = $this->_sortModuleDepends($moduleDepends);
-
- // create sorted config
- $sortedConfig = new Mage_Core_Model_Config_Base();
- $sortedConfig->loadString('<config><modules/></config>');
-
- foreach ($unsortedConfig->getNode()->children() as $nodeName => $node) {
- if ($nodeName != 'modules') {
- $sortedConfig->getNode()->appendChild($node);
- }
- }
-
- foreach ($moduleDepends as $moduleProp) {
- $node = $unsortedConfig->getNode('modules/'.$moduleProp['module']);
- $sortedConfig->getNode('modules')->appendChild($node);
- }
+ $sortedConfig = new Mage_Core_Model_Config_Module($unsortedConfig, $this->_allowedModules);
$this->extend($sortedConfig);
@@ -835,54 +781,6 @@ protected function _loadDeclaredModules()
}
/**
- * Sort modules and check depends
- *
- * @param array $modules
- * @return array
- */
- protected function _sortModuleDepends($modules)
- {
- foreach ($modules as $moduleName => $moduleProps) {
- $depends = $moduleProps['depends'];
- foreach ($moduleProps['depends'] as $depend => $true) {
- if ($moduleProps['active'] && ((!isset($modules[$depend])) || empty($modules[$depend]['active']))) {
- Mage::throwException(
- Mage::helper('Mage_Core_Helper_Data')->__('Module "%1$s" requires module "%2$s".', $moduleName, $depend)
- );
- }
- $depends = array_merge($depends, $modules[$depend]['depends']);
- }
- $modules[$moduleName]['depends'] = $depends;
- }
- $modules = array_values($modules);
-
- $size = count($modules) - 1;
- for ($i = $size; $i >= 0; $i--) {
- for ($j = $size; $i < $j; $j--) {
- if (isset($modules[$i]['depends'][$modules[$j]['module']])) {
- $value = $modules[$i];
- $modules[$i] = $modules[$j];
- $modules[$j] = $value;
- }
- }
- }
-
- $definedModules = array();
- foreach ($modules as $moduleProp) {
- foreach ($moduleProp['depends'] as $dependModule => $true) {
- if (!isset($definedModules[$dependModule])) {
- Mage::throwException(
- Mage::helper('Mage_Core_Helper_Data')->__('Module "%1$s" cannot depend on "%2$s".', $moduleProp['module'], $dependModule)
- );
- }
- }
- $definedModules[$moduleProp['module']] = true;
- }
-
- return $modules;
- }
-
- /**
* Determine whether provided name begins from any available modules, according to namespaces priority
* If matched, returns as the matched module "factory" name or a fully qualified module name
*
View
193 app/code/core/Mage/Core/Model/Config/Module.php
@@ -0,0 +1,193 @@
+<?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_Core
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
+ */
+
+/**
+ * Configuration for modules availability and dependencies
+ */
+class Mage_Core_Model_Config_Module extends Mage_Core_Model_Config_Base
+{
+ /**
+ * Types of dependencies between modules
+ */
+ const DEPENDENCY_TYPE_SOFT = 'soft';
+ const DEPENDENCY_TYPE_HARD = 'hard';
+
+ /**
+ * Constructor
+ *
+ * @param Mage_Core_Model_Config_Base $modulesConfig Modules configuration merged from the config files
+ * @param array $allowedModules When not empty, defines modules to be taken into account
+ */
+ public function __construct(Mage_Core_Model_Config_Base $modulesConfig, array $allowedModules = array())
+ {
+ // initialize empty modules configuration
+ parent::__construct('<config><modules/></config>');
+
+ $moduleDependencies = $this->_loadModuleDependencies($modulesConfig, $allowedModules);
+
+ $this->_checkModuleRequirements($moduleDependencies);
+
+ $moduleDependencies = $this->_sortModuleDependencies($moduleDependencies);
+
+ // create sorted configuration
+ foreach ($modulesConfig->getNode()->children() as $nodeName => $node) {
+ if ($nodeName != 'modules') {
+ $this->getNode()->appendChild($node);
+ }
+ }
+ foreach ($moduleDependencies as $moduleInfo) {
+ $node = $modulesConfig->getNode('modules/' . $moduleInfo['module']);
+ $this->getNode('modules')->appendChild($node);
+ }
+ }
+
+ /**
+ * Load dependencies for active & allowed modules into an array structure
+ *
+ * @param Mage_Core_Model_Config_Base $modulesConfig
+ * @param array $allowedModules
+ * @return array
+ */
+ protected function _loadModuleDependencies(Mage_Core_Model_Config_Base $modulesConfig, array $allowedModules)
+ {
+ $result = array();
+ foreach ($modulesConfig->getNode('modules')->children() as $moduleName => $moduleNode) {
+ $isModuleActive = 'true' === (string)$moduleNode->active;
+ $isModuleAllowed = empty($allowedModules) || in_array($moduleName, $allowedModules);
+ if (!$isModuleActive || !$isModuleAllowed) {
+ continue;
+ }
+ $dependencies = array();
+ if ($moduleNode->depends) {
+ /** @var $dependencyNode Varien_Simplexml_Element */
+ foreach ($moduleNode->depends->children() as $dependencyNode) {
+ $dependencyModuleName = $dependencyNode->getName();
+ $dependencies[$dependencyModuleName] = $this->_getDependencyType($dependencyNode);
+ }
+ }
+ $result[$moduleName] = array(
+ 'module' => $moduleName,
+ 'dependencies' => $dependencies,
+ );
+ }
+ return $result;
+ }
+
+ /**
+ * Determine dependency type from XML node that defines module dependency
+ *
+ * @param Varien_Simplexml_Element $dependencyNode
+ * @return string
+ * @throws UnexpectedValueException
+ */
+ protected function _getDependencyType(Varien_Simplexml_Element $dependencyNode)
+ {
+ $result = $dependencyNode->getAttribute('type') ?: self::DEPENDENCY_TYPE_HARD;
+ if (!in_array($result, array(self::DEPENDENCY_TYPE_HARD, self::DEPENDENCY_TYPE_SOFT))) {
+ $dependencyNodeXml = trim($dependencyNode->asNiceXml());
+ throw new UnexpectedValueException(
+ "Unknown module dependency type '$result' in declaration '$dependencyNodeXml'."
+ );
+ }
+ return $result;
+ }
+
+ /**
+ * Check whether module requirements are fulfilled
+ *
+ * @param array $moduleDependencies
+ * @throws Magento_Exception
+ */
+ protected function _checkModuleRequirements(array $moduleDependencies)
+ {
+ foreach ($moduleDependencies as $moduleName => $moduleInfo) {
+ foreach ($moduleInfo['dependencies'] as $relatedModuleName => $dependencyType) {
+ $relatedModuleActive = isset($moduleDependencies[$relatedModuleName]);
+ if (!$relatedModuleActive && $dependencyType == self::DEPENDENCY_TYPE_HARD) {
+ throw new Magento_Exception("Module '$moduleName' requires module '$relatedModuleName'.");
+ }
+ }
+ }
+ }
+
+ /**
+ * Sort modules until dependent modules go after ones they depend on
+ *
+ * @param array $moduleDependencies
+ * @return array
+ */
+ protected function _sortModuleDependencies(array $moduleDependencies)
+ {
+ // add indirect dependencies
+ foreach ($moduleDependencies as $moduleName => &$moduleInfo) {
+ $moduleInfo['dependencies'] = $this->_getAllDependencies($moduleDependencies, $moduleName);
+ }
+ unset($moduleInfo);
+
+ // "bubble sort" modules until dependent modules go after ones they depend on
+ $moduleDependencies = array_values($moduleDependencies);
+ $size = count($moduleDependencies) - 1;
+ for ($i = $size; $i >= 0; $i--) {
+ for ($j = $size; $i < $j; $j--) {
+ if (isset($moduleDependencies[$i]['dependencies'][$moduleDependencies[$j]['module']])) {
+ $tempValue = $moduleDependencies[$i];
+ $moduleDependencies[$i] = $moduleDependencies[$j];
+ $moduleDependencies[$j] = $tempValue;
+ }
+ }
+ }
+
+ return $moduleDependencies;
+ }
+
+ /**
+ * Recursively compute all dependencies and detect circular ones
+ *
+ * @param array $moduleDependencies
+ * @param string $moduleName
+ * @param array $usedModules Keep track of used modules to detect circular dependencies
+ * @return array
+ * @throws Magento_Exception
+ */
+ protected function _getAllDependencies(array $moduleDependencies, $moduleName, $usedModules = array())
+ {
+ $usedModules[] = $moduleName;
+ $result = $moduleDependencies[$moduleName]['dependencies'];
+ foreach (array_keys($result) as $relatedModuleName) {
+ if (in_array($relatedModuleName, $usedModules)) {
+ throw new Magento_Exception(
+ "Module '$moduleName' cannot depend on '$relatedModuleName' since it creates circular dependency."
+ );
+ }
+ if (empty($moduleDependencies[$relatedModuleName])) {
+ continue;
+ }
+ $relatedDependencies = $this->_getAllDependencies($moduleDependencies, $relatedModuleName, $usedModules);
+ $result = array_merge($result, $relatedDependencies);
+ }
+ return $result;
+ }
+}
View
4 app/code/core/Mage/Core/view/frontend/layout.xml
@@ -30,8 +30,4 @@
<default>
<block name="formkey" type="Mage_Core_Block_Template" template="Mage_Core::formkey.phtml" />
</default>
-
- <calendar translate="label">
- <label>Calendar</label>
- </calendar>
</layout>
View
2  app/code/core/Mage/DesignEditor/view/frontend/layout.xml
@@ -27,7 +27,6 @@
-->
<layout>
<design_editor_toolbar>
- <label>Design Editor Toolbar</label>
<reference name="head">
<action method="addJs"><file>jquery/jquery-1.7.1.min.js</file></action>
<action method="addJs"><file>mage/jquery-no-conflict.js</file></action>
@@ -53,7 +52,6 @@
</design_editor_toolbar>
<design_editor_page>
- <label>Design Editor Page Blocks Management Page</label>
<reference name="root">
<action method="setTemplate"><template>Mage_DesignEditor::page.phtml</template></action>
<block type="Mage_Page_Block_Html_Head" name="head" as="head"/>
View
4 app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php
@@ -792,7 +792,9 @@ public function export()
$dataRow[self::COL_TYPE] = null;
} else {
$dataRow[self::COL_STORE] = null;
- $dataRow += $stockItemRows[$productId];
+ if (isset($stockItemRows[$productId])) {
+ array_merge($dataRow, $stockItemRows[$productId]);
+ }
}
$this->_updateDataWithCategoryColumns($dataRow, $rowCategories, $productId);
View
7 app/code/core/Mage/Install/Model/Observer.php
@@ -40,11 +40,4 @@ public function bindLocale($observer)
}
return $this;
}
-
- public function installFailure($observer)
- {
- echo "<h2>There was a problem proceeding with Magento installation.</h2>";
- echo "<p>Please contact developers with error messages on this page.</p>";
- echo Mage::printException($observer->getEvent()->getException());
- }
}
View
8 app/code/core/Mage/Install/etc/config.xml
@@ -65,14 +65,6 @@
</checkConnection>
</observers>
</controller_action_predispatch>
- <mage_run_exception>
- <observers>
- <install_failure>
- <class>Mage_Install_Model_Observer</class>
- <method>installFailure</method>
- </install_failure>
- </observers>
- </mage_run_exception>
<core_locale_set_locale>
<observers>
<bind_locale>
View
26 app/code/core/Mage/Oauth/view/adminhtml/layout.xml
@@ -35,7 +35,7 @@
<adminhtml_oauth_consumer_grid>
<remove name="root"/>
- <block type="Mage_Oauth_Block_Adminhtml_Oauth_Consumer_Grid" name="oauth_consumer.grid" output="toHtml"/>
+ <block type="Mage_Oauth_Block_Adminhtml_Oauth_Consumer_Grid" name="oauth_consumer.grid" output="1"/>
</adminhtml_oauth_consumer_grid>
<adminhtml_oauth_consumer_new>
@@ -64,7 +64,7 @@
<adminhtml_oauth_admin_token_grid>
<remove name="root"/>
- <block type="Mage_Oauth_Block_Adminhtml_Oauth_Admin_Token_Grid" name="oauth_admin_token.grid" output="toHtml"/>
+ <block type="Mage_Oauth_Block_Adminhtml_Oauth_Admin_Token_Grid" name="oauth_admin_token.grid" output="1"/>
</adminhtml_oauth_admin_token_grid>
<!-- EOF My Applications -->
@@ -116,7 +116,7 @@
<oauth_root_handle_simple>
<remove name="js_cookie" />
- <block type="Mage_Adminhtml_Block_Page" name="root" output="toHtml" template="Mage_Oauth::empty.phtml">
+ <block type="Mage_Adminhtml_Block_Page" name="root" output="1" template="Mage_Oauth::empty.phtml">
<block type="Mage_Adminhtml_Block_Page_Head" name="head" as="head" template="Mage_Oauth::authorize/head-simple.phtml">
<action method="addCss"><name>Mage_Oauth::css/oauth-simple.css</name></action>
</block>
@@ -126,18 +126,16 @@
<!-- Authorize -->
<!--Handle for simple pages-->
- <adminhtml_oauth_authorize_index translate="label">
+ <adminhtml_oauth_authorize_index>
<update handle="oauth_root_handle"/>
- <label>OAuth authorization for admin</label>
<reference name="content">
<block type="Mage_Oauth_Block_Adminhtml_Oauth_Authorize" name="oauth.authorize.form" template="authorize/form/login.phtml"/>
<block type="Mage_Oauth_Block_Adminhtml_Oauth_Authorize_Button" name="oauth.authorize.button" template="authorize/button.phtml" />
</reference>
</adminhtml_oauth_authorize_index>
- <adminhtml_oauth_authorize_simple translate="label">
+ <adminhtml_oauth_authorize_simple>
<update handle="oauth_root_handle_simple"/>
- <label>OAuth authorization simple for admin</label>
<reference name="content">
<block type="Mage_Oauth_Block_Adminhtml_Oauth_Authorize" name="oauth.authorize.form" template="authorize/form/login-simple.phtml"/>
<block type="Mage_Oauth_Block_Adminhtml_Oauth_Authorize_Button" name="oauth.authorize.button" template="authorize/button-simple.phtml" />
@@ -146,17 +144,15 @@
<!-- EOF Authorize -->
<!-- Confirm Authorization -->
- <adminhtml_oauth_authorize_confirm translate="label">
+ <adminhtml_oauth_authorize_confirm>
<update handle="oauth_root_handle"/>
- <label>Confirm token authorization for admin</label>
<reference name="content">
<block type="Mage_Core_Block_Template" name="oauth.authorize.confirm" template="Mage_Oauth::authorize/confirm.phtml" />
</reference>
</adminhtml_oauth_authorize_confirm>
- <adminhtml_oauth_authorize_confirmsimple translate="label">
+ <adminhtml_oauth_authorize_confirmsimple>
<update handle="oauth_root_handle_simple"/>
- <label>Confirm token authorization Pop Up for admin</label>
<reference name="content">
<block type="Mage_Core_Block_Template" name="oauth.authorize.confirm" template="Mage_Oauth::authorize/confirm-simple.phtml" />
</reference>
@@ -164,17 +160,15 @@
<!-- EOF Confirm Authorization -->
<!-- Reject Authorization -->
- <adminhtml_oauth_authorize_reject translate="label">
+ <adminhtml_oauth_authorize_reject>
<update handle="oauth_root_handle"/>
- <label>Reject token authorization for admin</label>
<reference name="content">
<block type="Mage_Core_Block_Template" name="oauth.authorize.reject" template="Mage_Oauth::authorize/reject.phtml" />
</reference>
</adminhtml_oauth_authorize_reject>
- <adminhtml_oauth_authorize_rejectsimple translate="label">
+ <adminhtml_oauth_authorize_rejectsimple>
<update handle="oauth_root_handle_simple"/>
- <label>Reject token authorization Pop Up for admin</label>
<reference name="content">
<block type="Mage_Core_Block_Template" name="oauth.authorize.reject" template="Mage_Oauth::authorize/reject-simple.phtml" />
</reference>
@@ -189,6 +183,6 @@
<adminhtml_oauth_authorizedtokens_grid>
<remove name="root"/>
- <block type="Mage_Oauth_Block_Adminhtml_Oauth_AuthorizedTokens_Grid" name="oauth_authorizedTokens.grid" output="toHtml"/>
+ <block type="Mage_Oauth_Block_Adminhtml_Oauth_AuthorizedTokens_Grid" name="oauth_authorizedTokens.grid" output="1"/>
</adminhtml_oauth_authorizedtokens_grid>
</layout>
View
16 app/code/core/Mage/Oauth/view/frontend/layout.xml
@@ -50,7 +50,7 @@
<oauth_root_handle_simple>
<remove name="js_cookie" />
- <block type="Mage_Page_Block_Html" name="root" output="toHtml" template="empty.phtml">
+ <block type="Mage_Page_Block_Html" name="root" output="1" template="empty.phtml">
<block type="Mage_Page_Block_Html_Head" name="head" as="head" template="Mage_Oauth::authorize/head-simple.phtml">
<action method="addCss"><stylesheet>Mage_Oauth::css/oauth-simple.css</stylesheet></action>
</block>
@@ -59,7 +59,7 @@
</oauth_root_handle_simple>
<!-- Authorization -->
- <oauth_authorize_index translate="label">
+ <oauth_authorize_index translate="label" type="page">
<update handle="oauth_root_handle"/>
<label>Oauth authorization for customer</label>
<reference name="content">
@@ -68,7 +68,7 @@
</reference>
</oauth_authorize_index>
- <oauth_authorize_simple translate="label">
+ <oauth_authorize_simple translate="label" type="page" parent="default">
<update handle="oauth_root_handle_simple"/>
<remove name="header"/>
<label>Oauth authorization Pop Up for customer</label>
@@ -80,7 +80,7 @@
<!-- EOF Authorization -->
<!-- Confirm Authorization -->
- <oauth_authorize_confirm translate="label">
+ <oauth_authorize_confirm translate="label" type="page" parent="default">
<update handle="oauth_root_handle"/>
<label>Confirm Oauth token authorization</label>
<reference name="content">
@@ -88,7 +88,7 @@
</reference>
</oauth_authorize_confirm>
- <oauth_authorize_confirmsimple translate="label">
+ <oauth_authorize_confirmsimple translate="label" type="page">
<update handle="oauth_root_handle_simple"/>
<label>Confirm Oauth token authorization (Simple)</label>
<remove name="header"/>
@@ -99,7 +99,7 @@
<!-- EOF Confirm Authorization -->
<!-- Reject Authorization -->
- <oauth_authorize_reject translate="label">
+ <oauth_authorize_reject translate="label" type="page">
<update handle="oauth_root_handle"/>
<label>Reject Oauth token authorization</label>
<reference name="content">
@@ -107,7 +107,7 @@
</reference>
</oauth_authorize_reject>
- <oauth_authorize_rejectsimple translate="label">
+ <oauth_authorize_rejectsimple translate="label" type="page" parent="default">
<update handle="oauth_root_handle_simple"/>
<label>Reject Oauth token authorization (Simple)</label>
<remove name="header"/>
@@ -128,7 +128,7 @@
</reference>
</customer_account>
- <oauth_customer_token_index translate="label">
+ <oauth_customer_token_index translate="label" type="page" parent="default">
<label>Customer My Account My OAuth Applications</label>
<update handle="customer_account"/>
<reference name="my.account.wrapper">
View
3  app/code/core/Mage/Paypal/view/frontend/layout.xml
@@ -209,8 +209,7 @@ Available logo types can be assigned with action="setLogoType":
</block>
</paypal_standard_redirect>
- <SHORTCUT_popup translate="label">
- <label>Paypal Shortcut Popup</label>
+ <SHORTCUT_popup>
<reference name="product.tooltip">
<container name="product.info.addtocart.paypal.wrapper" label="PayPal Express Checkout Shortcut Wrapper" htmlTag="div">
<block type="Mage_Paypal_Block_Express_Shortcut" name="product.info.addtocart.paypal" template="express/shortcut.phtml">
View
3  app/code/core/Mage/PaypalUk/view/frontend/layout.xml
@@ -136,8 +136,7 @@
<update handle="SHORTCUT_uk_popup" />
</checkout_onepage_failure>
- <SHORTCUT_uk_popup translate="label">
- <label>PaypalUk Shortcut Popup</label>
+ <SHORTCUT_uk_popup>
<reference name="product.tooltip">
<container name="product.info.addtocart.paypaluk.wrapper" label="PayPal Express Checkout (Payflow Edition) Shortcut Wrapper" htmlTag="div">
<block type="Mage_PaypalUk_Block_Express_Shortcut" name="product.info.addtocart.paypaluk" template="Mage_Paypal::express/shortcut.phtml">
View
10 app/code/core/Mage/Review/etc/config.xml
@@ -71,16 +71,6 @@
</args>
</review>
</routers>
- <events>
- <review_save_after>
- <observers>
- <rss>
- <class>Mage_Rss_Model_Observer</class>
- <method>reviewSaveAfter</method>
- </rss>
- </observers>
- </review_save_after>
- </events>
<translate>
<modules>
<Mage_Review>
View
13 app/code/core/Mage/Review/view/frontend/layout.xml
@@ -49,19 +49,6 @@ Customer account home dashboard layout
</customer_account_index>
-
-<!--
-Product reviews page (?)
--->
-
- <reviews translate="label">
- <label>Review</label>
- <!-- Mage_Review -->
- <reference name="root">
- <action method="setTemplate"><template>2columns-left.phtml</template></action>
- </reference>
- </reviews>
-
<!--
Product reviews page
-->
View
4 app/code/core/Mage/Rss/Block/Catalog/New.php
@@ -92,11 +92,11 @@ protected function _toHtml()
)
)
->addAttributeToSort('news_from_date','desc')
- ->addAttributeToSelect(array('name', 'short_description', 'description', 'thumbnail'), 'inner')
+ ->addAttributeToSelect(array('name', 'short_description', 'description'), 'inner')
->addAttributeToSelect(
array(
'price', 'special_price', 'special_from_date', 'special_to_date',
- 'msrp_enabled', 'msrp_display_actual_price_type', 'msrp'
+ 'msrp_enabled', 'msrp_display_actual_price_type', 'msrp', 'thumbnail'
),
'left'
)
View
25 app/code/core/Mage/Rss/Block/Catalog/NotifyStock.php
@@ -31,31 +31,8 @@
* @package Mage_Rss
* @author Magento Core Team <core@magentocommerce.com>
*/
-class Mage_Rss_Block_Catalog_NotifyStock extends Mage_Rss_Block_Abstract
+class Mage_Rss_Block_Catalog_NotifyStock extends Mage_Core_Block_Abstract
{
-
- /**
- * Cache tag constant for feed notify stock
- *
- * @var string
- */
- const CACHE_TAG = 'block_html_rss_catalog_notifystock';
-
- /**
- * Constructor
- *
- * @return null
- */
- protected function _construct()
- {
- $this->setCacheTags(array(self::CACHE_TAG));
- /*
- * setting cache to save the rss for 10 minutes
- */
- $this->setCacheKey('rss_catalog_notifystock');
- $this->setCacheLifetime(600);
- }
-
/**
* Render RSS
*
View
25 app/code/core/Mage/Rss/Block/Catalog/Review.php
@@ -31,31 +31,8 @@
* @package Mage_Rss
* @author Magento Core Team <core@magentocommerce.com>
*/
-class Mage_Rss_Block_Catalog_Review extends Mage_Rss_Block_Abstract
+class Mage_Rss_Block_Catalog_Review extends Mage_Core_Block_Abstract
{
-
- /**
- * Cache tag constant for feed reviews
- *
- * @var string
- */
- const CACHE_TAG = 'block_html_rss_catalog_review';
-
- /**
- * Initialize cache
- *
- * @return null
- */
- protected function _construct()
- {
- $this->setCacheTags(array(self::CACHE_TAG));
- /*
- * setting cache to save the rss for 10 minutes
- */
- $this->setCacheKey('rss_catalog_review');
- $this->setCacheLifetime(600);
- }
-
/**
* Render XML response
*
View
20 app/code/core/Mage/Rss/Block/Order/New.php
@@ -31,26 +31,8 @@
* @package Mage_Rss
* @author Magento Core Team <core@magentocommerce.com>
*/
-class Mage_Rss_Block_Order_New extends Mage_Core_Block_Template
+class Mage_Rss_Block_Order_New extends Mage_Core_Block_Abstract
{
-
- /**
- * Cache tag constant for feed new orders
- *
- * @var string
- */
- const CACHE_TAG = 'block_html_rss_order_new';
-
- protected function _construct()
- {
- $this->setCacheTags(array(self::CACHE_TAG));
- /*
- * setting cache to save the rss for 10 minutes
- */
- $this->setCacheKey('rss_order_new');
- $this->setCacheLifetime(600);
- }
-
protected function _toHtml()
{
$order = Mage::getModel('Mage_Sales_Model_Order');
View
59 app/code/core/Mage/Rss/Controller/AdminhtmlAbstract.php
@@ -1,59 +0,0 @@
-<?php
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @category Mage
- * @package Mage_Rss
- * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- */
-
-/**
- * Base class for Rss controllers, where admin login required for some actions
- *
- * @category Mage
- * @package Mage_Rss
- * @author Magento Core Team <core@magentocommerce.com>
- */
-abstract class Mage_Rss_Controller_AdminhtmlAbstract extends Mage_Core_Controller_Front_Action
-{
- /**
- * Returns map of action to acl paths, needed to check user's access to a specific action
- *
- * @return array
- */
- abstract protected function _getAdminAclMap();
-
- /**
- * Controller predispatch method to change area for a specific action
- *
- * @return Mage_Rss_Controller_AdminhtmlAbstract
- */
- public function preDispatch()
- {
- $action = $this->getRequest()->getActionName();
- $map = $this->_getAdminAclMap();
- if (isset($map[$action])) {
- $this->_currentArea = 'adminhtml';
- $path = $map[$action];
- Mage::helper('Mage_Rss_Helper_Data')->authAdmin($path);
- }
- return parent::preDispatch();
- }
-}
View
72 app/code/core/Mage/Rss/Helper/Data.php
@@ -35,78 +35,6 @@
class Mage_Rss_Helper_Data extends Mage_Core_Helper_Abstract
{
/**
- * Authenticate customer on frontend
- *
- */
- public function authFrontend()
- {
- $session = Mage::getSingleton('Mage_Rss_Model_Session');
- if ($session->isCustomerLoggedIn()) {
- return;
- }
- list($username, $password) = $this->authValidate();
- $customer = Mage::getModel('Mage_Customer_Model_Customer')->authenticate($username, $password);
- if ($customer && $customer->getId()) {
- Mage::getSingleton('Mage_Rss_Model_Session')->settCustomer($customer);
- } else {
- $this->authFailed();
- }
- }
-
- /**
- * Authenticates admin user and checks ACL. Returns user model upon successful authentication.
- * If user authentication fails, then shows error and exits php instantly.
- *
- * @param string $path
- * @return Mage_User_Model_User
- */
- public function authAdmin($path)
- {
- $session = Mage::getSingleton('Mage_Rss_Model_Session');
- if ($session->isAdminLoggedIn()) {
- return $session->getAdmin();
- }
-
- list($username, $password) = $this->authValidate();
- Mage::getSingleton('Mage_Adminhtml_Model_Url')->setNoSecret(true);
-
- $auth = Mage::getSingleton('Mage_Backend_Model_Auth');
- $auth->login($username, $password);
- $adminSession = $auth->getAuthStorage();
-
- $user = $adminSession->getUser();
-
- if ($user && $user->getIsActive() == '1' && $adminSession->isAllowed($path)){
- $session->setAdmin($user);
- return $user;
- } else {
- // Error is shown and exit() is called
- Mage::helper('Mage_Core_Helper_Http')->authFailed();
- }
- }
-
- /**
- * Validate Authenticate
- *
- * @param array $headers
- * @return array
- */
- public function authValidate($headers=null)
- {
- $userPass = Mage::helper('Mage_Core_Helper_Http')->authValidate($headers);
- return $userPass;
- }
-
- /**
- * Send authenticate failed headers
- *
- */
- public function authFailed()
- {
- Mage::helper('Mage_Core_Helper_Http')->authFailed();
- }
-
- /**
* Disable using of flat catalog and/or product model to prevent limiting results to single store. Probably won't
* work inside a controller.
*
View
76 app/code/core/Mage/Rss/Model/Observer.php
@@ -1,76 +0,0 @@
-<?php
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @category Mage
- * @package Mage_Rss
- * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- */
-
-
-/**
- * Rss Observer Model
- *
- * @category Mage
- * @package Mage_Rss
- * @author Magento Core Team <core@magentocommerce.com>
- */
-class Mage_Rss_Model_Observer
-{
-
- /**
- * Clean cache for catalog review rss
- *
- * @param Varien_Event_Observer $observer
- * @return void
- */
- public function reviewSaveAfter(Varien_Event_Observer $observer)
- {
-
- Mage::app()->cleanCache(array(Mage_Rss_Block_Catalog_Review::CACHE_TAG));
-
- }
-
- /**
- * Clean cache for notify stock rss
- *
- * @param Varien_Event_Observer $observer
- * @return void
- */
- public function salesOrderItemSaveAfterNotifyStock(Varien_Event_Observer $observer)
- {
-
- Mage::app()->cleanCache(array(Mage_Rss_Block_Catalog_NotifyStock::CACHE_TAG));
-
- }
-
- /**
- * Clean cache for catalog new orders rss
- *
- * @param Varien_Event_Observer $observer
- * @return void
- */
- public function salesOrderItemSaveAfterOrderNew(Varien_Event_Observer $observer)
- {
-
- Mage::app()->cleanCache(array(Mage_Rss_Block_Order_New::CACHE_TAG));
-
- }
-}
View
51 app/code/core/Mage/Rss/Model/Session.php
@@ -1,51 +0,0 @@
-<?php
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @category Mage
- * @package Mage_Rss
- * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- */
-
-
-/**
- * Auth session model
- *
- * @category Mage
- * @package Mage_Rss
- * @author Magento Core Team <core@magentocommerce.com>
- */
-class Mage_Rss_Model_Session extends Mage_Core_Model_Session_Abstract
-{
- public function __construct()
- {
- $this->init('rss');
- }
-
- public function isAdminLoggedIn()
- {
- return $this->getAdmin() && $this->getAdmin()->getId();
- }
-
- public function isCustomerLoggedIn()
- {
- return $this->getCustomer() && $this->getCustomer()->getId();
- }
-}
View
119 app/code/core/Mage/Rss/controllers/CatalogController.php
@@ -24,6 +24,8 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+require_once __DIR__ . '/OrderController.php';
+
/**
* Customer reviews controller
*
@@ -31,96 +33,103 @@
* @package Mage_Rss
* @author Magento Core Team <core@magentocommerce.com>
*/
-
-class Mage_Rss_CatalogController extends Mage_Rss_Controller_AdminhtmlAbstract
+class Mage_Rss_CatalogController extends Mage_Core_Controller_Front_Action
{
/**
- * Returns map of action to acl paths, needed to check user's access to a specific action
- *
- * @return array
+ * Emulate admin area for certain actions
*/
- protected function _getAdminAclMap()
- {
- return array(
- 'notifystock' => 'catalog/products',
- 'review' => 'catalog/reviews_ratings'
- );
- }
-
- protected function isFeedEnable($code)
+ public function preDispatch()
{
- return Mage::getStoreConfig('rss/catalog/'.$code);
- }
-
- protected function checkFeedEnable($code)
- {
- if ($this->isFeedEnable($code)) {
- $this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8');
- return true;
- } else {
- $this->getResponse()->setHeader('HTTP/1.1','404 Not Found');
- $this->getResponse()->setHeader('Status','404 File not found');
- $this->_forward('nofeed','index','rss');
- return false;
+ $action = $this->getRequest()->getActionName();
+ $acl = array('notifystock' => 'catalog/products', 'review' => 'catalog/reviews_ratings');
+ if (isset($acl[$action])) {
+ $this->setCurrentArea('adminhtml');
+ if (Mage_Rss_OrderController::authenticateAndAuthorizeAdmin($this, $acl[$action])) {
+ return;
+ }
}
+ parent::preDispatch();
}
public function newAction()
{
- $this->checkFeedEnable('new');
- $this->loadLayout(false);
- $this->renderLayout();
+ $this->_genericAction('new');
}
public function specialAction()
{
- $this->checkFeedEnable('special');
- $this->loadLayout(false);
- $this->renderLayout();
+ $this->_genericAction('special');
}
public function salesruleAction()
{
- $this->checkFeedEnable('salesrule');
- $this->loadLayout(false);
- $this->renderLayout();
+ $this->_genericAction('salesrule');
}
public function tagAction()
{
- if ($this->checkFeedEnable('tag')) {
- $tagName = urldecode($this->getRequest()->getParam('tagName'));
- $tagModel = Mage::getModel('Mage_Tag_Model_Tag');
- $tagModel->loadByName($tagName);
- if ($tagModel->getId() && $tagModel->getStatus()==$tagModel->getApprovedStatus()) {
- Mage::register('tag_model', $tagModel);
- $this->loadLayout(false);
- $this->renderLayout();
- return;
- }
+ if (!$this->_isEnabled('tag')) {
+ $this->_forward('nofeed', 'index', 'rss');
+ return;
+ }
+ $tagName = urldecode($this->getRequest()->getParam('tagName'));
+ $tagModel = Mage::getModel('Mage_Tag_Model_Tag');
+ $tagModel->loadByName($tagName);
+ if ($tagModel->getId() && $tagModel->getStatus() == $tagModel->getApprovedStatus()) {
+ Mage::register('tag_model', $tagModel);
+ $this->_render();
+ return;
}
$this->_forward('nofeed', 'index', 'rss');
}
public function notifystockAction()
{
- $this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8');
- $this->loadLayout(false);
- $this->renderLayout();
+ $this->_render();
}
public function reviewAction()
{
- $this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8');
- $this->loadLayout(false);
- $this->renderLayout();
+ $this->_render();
}
public function categoryAction()
{
- if ($this->checkFeedEnable('category')) {
- $this->loadLayout(false);
- $this->renderLayout();
+ $this->_genericAction('category');
+ }
+
+ /**
+ * Render or forward to "no route" action if this type of RSS is disabled
+ *
+ * @param string $code
+ */
+ protected function _genericAction($code)
+ {
+ if ($this->_isEnabled($code)) {
+ $this->_render();
+ } else {
+ $this->_forward('nofeed', 'index', 'rss');
}
}
+
+ /**
+ * Whether specified type of RSS is enabled
+ *
+ * @param string $code
+ * @return bool
+ */
+ protected function _isEnabled($code)
+ {
+ return Mage::getStoreConfigFlag("rss/catalog/{$code}");
+ }
+
+ /**
+ * Render as XML-document using layout handle without inheriting any other handles
+ */
+ protected function _render()
+ {
+ $this->getResponse()->setHeader('Content-Type', 'text/xml; charset=UTF-8');
+ $this->loadLayout(false);
+ $this->renderLayout();
+ }
}
View
57 app/code/core/Mage/Rss/controllers/IndexController.php
@@ -56,9 +56,7 @@ public function indexAction()
$this->loadLayout();
$this->renderLayout();
} else {
- $this->getResponse()->setHeader('HTTP/1.1','404 Not Found');
- $this->getResponse()->setHeader('Status','404 File not found');
- $this->_forward('defaultNoRoute');
+ $this->norouteAction();
}
}
@@ -67,10 +65,11 @@ public function indexAction()
*/
public function nofeedAction()
{
- $this->getResponse()->setHeader('HTTP/1.1','404 Not Found');
- $this->getResponse()->setHeader('Status','404 File not found');
- $this->loadLayout(false);
- $this->renderLayout();
+ $this->getResponse()->setHeader('HTTP/1.1', '404 Not Found')
+ ->setHeader('Status', '404 File not found')
+ ->setHeader('Content-Type', 'text/plain; charset=UTF-8')
+ ->setBody($this->__('There was no RSS feed enabled.'))
+ ;
}
/**
@@ -81,39 +80,19 @@ public function nofeedAction()
*/
public function wishlistAction()
{
- if (!Mage::getStoreConfig('rss/wishlist/active')) {
- $this->getResponse()->setHeader('HTTP/1.1','404 Not Found');
- $this->getResponse()->setHeader('Status','404 File not found');
- $this->_forward('nofeed','index','rss');
- return;
- }
-
- $wishlist = $this->_getWishlist();
- if (!$wishlist) {
- $this->_forward('nofeed','index','rss');
- return;
- }
-
- if ($wishlist->getVisibility()) {
- $this->_showWishlistRss();
- return ;
- } else if (Mage::getSingleton('Mage_Customer_Model_Session')->authenticate($this)
- && $wishlist->getCustomerId() == $this->_getCustomer()->getId()
- ) {
- $this->_showWishlistRss();
- } else {
- $this->_forward('nofeed','index','rss');
+ if (Mage::getStoreConfig('rss/wishlist/active')) {
+ $wishlist = $this->_getWishlist();
+ if ($wishlist && ($wishlist->getVisibility()
+ || Mage::getSingleton('Mage_Customer_Model_Session')->authenticate($this)
+ && $wishlist->getCustomerId() == $this->_getCustomer()->getId())
+ ) {
+ $this->getResponse()->setHeader('Content-Type', 'text/xml; charset=UTF-8');
+ $this->loadLayout(false);
+ $this->renderLayout();
+ return;
+ }
}
- }
-
- /**
- * Show wishlist rss
- */
- protected function _showWishlistRss()
- {
- $this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8');
- $this->loadLayout(false);
- $this->renderLayout();
+ $this->nofeedAction();
}
/**
View
59 app/code/core/Mage/Rss/controllers/OrderController.php
@@ -32,18 +32,52 @@
* @author Magento Core Team <core@magentocommerce.com>
*/
-class Mage_Rss_OrderController extends Mage_Rss_Controller_AdminhtmlAbstract
+class Mage_Rss_OrderController extends Mage_Core_Controller_Front_Action
{
+ public function preDispatch()
+ {
+ if ('new' === $this->getRequest()->getActionName()) {
+ $this->setCurrentArea('adminhtml');
+ if (!self::authenticateAndAuthorizeAdmin($this, 'sales/order')) {
+ return;
+ }
+ }
+ parent::preDispatch();
+ }
+
/**
- * Returns map of action to acl paths, needed to check user's access to a specific action
+ * Check if admin is logged in and authorized to access resource by specified ACL path
*
- * @return array
+ * If not authenticated, will try to do it using credentials from HTTP-request
+ *
+ * @param Mage_Core_Controller_Front_Action $controller
+ * @param string $aclResource
+ * @return bool
*/
- protected function _getAdminAclMap()
+ public static function authenticateAndAuthorizeAdmin(Mage_Core_Controller_Front_Action $controller, $aclResource)
{
- return array(
- 'new' => 'sales/order'
- );
+ /** @var $auth Mage_Backend_Model_Auth */
+ $auth = Mage::getModel('Mage_Backend_Model_Auth');
+ $session = $auth->getAuthStorage();
+
+ // try to login using HTTP-authentication
+ if (!$session->isLoggedIn()) {
+ list($login, $password) = Mage::helper('Mage_Core_Helper_Http')
+ ->getHttpAuthCredentials($controller->getRequest());
+ try {
+ $auth->login($login, $password);
+ } catch (Mage_Backend_Model_Auth_Exception $e) {
+ Mage::logException($e);
+ }
+ }
+
+ // verify if logged in and authorized
+ if (!$session->isLoggedIn() || !$session->isAllowed($aclResource)) {
+ Mage::helper('Mage_Core_Helper_Http')->failHttpAuthentication($controller->getResponse(), 'RSS Feeds');
+ $controller->setFlag('', self::FLAG_NO_DISPATCH, true);
+ return false;
+ }
+ return true;
}
public function newAction()
@@ -53,17 +87,6 @@ public function newAction()
$this->renderLayout();
}
- public function customerAction()
- {
- if (Mage::app()->getStore()->isCurrentlySecure()) {
- $this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8');
- Mage::helper('Mage_Rss_Helper_Data')->authFrontend();
- } else {
- $this->_redirect('rss/order/customer', array('_secure'=>true));
- return $this;
- }
- }
-
/**
* Order status action
*/
View
18 app/code/core/Mage/Rss/etc/config.xml
@@ -53,24 +53,6 @@
</layout>
</adminhtml>
<frontend>
- <events>
- <sales_order_save_after>
- <observers>
- <notifystock>
- <class>Mage_Rss_Model_Observer</class>
- <method>salesOrderItemSaveAfterNotifyStock</method>
- </notifystock>
- </observers>
- </sales_order_save_after>
- <sales_order_save_after>
- <observers>
- <ordernew>
- <class>Mage_Rss_Model_Observer</class>
- <method>salesOrderItemSaveAfterOrderNew</method>
- </ordernew>
- </observers>
- </sales_order_save_after>
- </events>
<translate>
<modules>
<Mage_Rss>
View
26 app/code/core/Mage/Rss/view/frontend/layout.xml
@@ -46,13 +46,7 @@
</reference>
</rss_index_index>
- <rss_index_nofeed translate="label" type="page" parent="rss_index_index">
- <label>RSS No Feed</label>
- <block type="Mage_Core_Block_Template" name="root" output="1" template="Mage_Rss::nofeed.phtml"/>
- </rss_index_nofeed>
-
- <rss_index_wishlist translate="label" type="page" parent="rss_index_index">
- <label>RSS Wishlist</label>
+ <rss_index_wishlist>
<block type="Mage_Rss_Block_Wishlist" name="rss.wishlist" output="1">
<action method="addPriceBlockType"><type>msrp_rss</type><block>Mage_Catalog_Block_Product_Price</block><template>Mage_Wishlist::render/item/price_msrp_rss.phtml</template></action>
</block>
@@ -60,32 +54,27 @@
<!--
Catalog layout
-->
- <rss_catalog_new translate="label" type="page" parent="rss_index_index">
- <label>RSS New</label>
+ <rss_catalog_new>
<block type="Mage_Rss_Block_Catalog_New" output="1" name="rss.catalog.new">
<action method="addPriceBlockType"><type>msrp_rss</type><block>Mage_Catalog_Block_Product_Price</block><template>product/price_msrp_rss.phtml</template></action>
</block>
</rss_catalog_new>
- <rss_catalog_special translate="label" type="page" parent="rss_catalog_new">
- <label>RSS Special</label>
+ <rss_catalog_special>
<block type="Mage_Rss_Block_Catalog_Special" output="1" name="rss.catalog.special" />
</rss_catalog_special>
- <rss_catalog_salesrule translate="label" type="page" parent="rss_catalog_new">
- <label>RSS Sales Rule</label>
+ <rss_catalog_salesrule>
<block type="Mage_Rss_Block_Catalog_Salesrule" output="1" name="rss.catalog.salesrule" />
</rss_catalog_salesrule>
- <rss_catalog_tag translate="label" type="page" parent="rss_catalog_new">
- <label>RSS Tag</label>
+ <rss_catalog_tag>
<block type="Mage_Rss_Block_Catalog_Tag" output="1" name="rss.catalog.tag">
<action method="addPriceBlockType"><type>msrp_rss</type><block>Mage_Catalog_Block_Product_Price</block><template>product/price_msrp_rss.phtml</template></action>
</block>
</rss_catalog_tag>
- <rss_catalog_category translate="label" type="page" parent="rss_catalog_new">
- <label>RSS Catalog Category</label>
+ <rss_catalog_category>
<block type="Mage_Rss_Block_Catalog_Category" output="1" name="rss.catalog.category">
<action method="addPriceBlockType"><type>msrp_rss</type><block>Mage_Catalog_Block_Product_Price</block><template>product/price_msrp_rss.phtml</template></action>
</block>
@@ -93,8 +82,7 @@ Catalog layout
<!--
Order layout
-->
- <rss_order_status translate="label" type="page" parent="rss_index_index">
- <label>RSS Order Status</label>
+ <rss_order_status>
<block type="Mage_Rss_Block_Order_Status" output="1" name="rss.order.status"/>
</rss_order_status>
</layout>
View
10 app/code/core/Mage/Sales/view/frontend/layout.xml
@@ -83,8 +83,8 @@ Customer account home dashboard layout
<sales_order_view translate="label" type="page" parent="default">
- <label>Customer My Account Order View</label>
<update handle="customer_account"/>
+ <label>Customer My Account Order View</label>
<reference name="my.account.wrapper">
<block type="Mage_Sales_Block_Order_Info" as="info" name="sales.order.info">
<block type="Mage_Sales_Block_Order_Info_Buttons" as="buttons" name="sales.order.info.buttons" />
@@ -330,7 +330,7 @@ Guest
<sales_guest_view translate="label" type="page" parent="default">
- <label>Customer My Account Order View</label>
+ <label>Guest Order View</label>
<reference name="root">
<action method="setTemplate"><template>1column.phtml</template></action>
</reference>
@@ -359,7 +359,7 @@ Guest
</sales_guest_view>
<sales_guest_invoice translate="label" type="page" parent="sales_guest_view">
- <label>Customer My Account Order Invoice View</label>
+ <label>Guest Order Invoice View</label>
<reference name="root">
<action method="setTemplate"><template>1column.phtml</template></action>
</reference>
@@ -389,7 +389,7 @@ Guest
</sales_guest_invoice>
<sales_guest_shipment translate="label" type="page" parent="sales_guest_view">
- <label>Customer My Account Order Shipment View</label>
+ <label>Guest Order Shipment View</label>
<reference name="root">
<action method="setTemplate"><template>1column.phtml</template></action>
</reference>
@@ -413,7 +413,7 @@ Guest
</sales_guest_shipment>
<sales_guest_creditmemo translate="label" type="page" parent="sales_guest_view">
- <label>Customer My Account Order Creditmemo View</label>
+ <label>Guest Order Creditmemo View</label>
<reference name="root">
<action method="setTemplate"><template>1column.phtml</template></action>
</reference>
View
2  app/design/frontend/default/iphone/Mage_Catalog/layout.xml
@@ -86,7 +86,7 @@ Category default layout
Category layered navigation layout
-->
- <catalog_category_view_type_layered translate="label">
+ <catalog_category_view_type_layered translate="label" type="page" parent="catalog_category_view">
<label>Catalog Category (Anchor)</label>
<reference name="content">
<block type="Mage_Catalog_Block_Category_View" name="category.products" template="category/view.phtml">
View
2  app/design/frontend/default/iphone/Mage_CatalogSearch/layout.xml
@@ -34,7 +34,7 @@
</reference>
</default>
- <catalogsearch_result_index translate="label">
+ <catalogsearch_result_index translate="label" module="Mage_CatalogSearch" type="page" parent="default">
<label>Quick Search Form</label>
<reference name="root">
<action method="setTemplate"><template>1column.phtml</template></action>
View
4 app/design/frontend/default/iphone/Mage_Checkout/layout.xml
@@ -78,10 +78,10 @@ Default layout, loads most of the pages
</checkout_cart_index>
<checkout_cart_configure translate="label" type="page" parent="catalog_product_view">