Skip to content

Commit

Permalink
Update as of 7/3/2012
Browse files Browse the repository at this point in the history
* Refactored backend (admin) menu generation:
  * Menu is separated from `adminhtml.xml` files into `menu.xml` files
  * Rendering menu became responsibility of `Mage_Backend` instead of `Mage_Adminhtml` module
  * Implemented XML-Schema for `menu.xml`
  * Actions with menu items defined in schema: add, remove, move, update, change parent and position
* Refactored customers import feature. New ability to provide import data in 3 files: master file (key customer information) + address file (customer id + address info) + financial file (customer id + reward points & store credit)
* Optimized memory consumption in integration tests:
  * Found and eliminated memory leaks in `Mage_Core_Model_App_Area`, `Mage_Core_Model_Layout`
  * Manually unset objects from PHPUnit test case object in `tearDown()` in integration tests. Garbage collector didn't purge them because of these references
  * Disabled running `integrity` test suite by default in integration tests
* Improvements in visual design editor JavaScript:
  * eliminated dependency of code on HTML-literals, reduced code coupling between templates and JavaScript files
  * implemented blocking unwanted JavaScript activity in visual design editor mode
* Various fixes in UX, code stability, modularity
* GitHub requests:
  * [#23](#23) -- added `Mage_Customer_Block_Account_Navigation::removeLink()`
  • Loading branch information
magento-team committed Jul 3, 2012
1 parent 0c3e67e commit 3330e25
Show file tree
Hide file tree
Showing 532 changed files with 16,594 additions and 2,446 deletions.
25 changes: 22 additions & 3 deletions CHANGELOG.markdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
Update as of 7/3/2012
=====================
* Refactored backend (admin) menu generation:
* Menu is separated from `adminhtml.xml` files into `menu.xml` files
* Rendering menu became responsibility of `Mage_Backend` instead of `Mage_Adminhtml` module
* Implemented XML-Schema for `menu.xml`
* Actions with menu items defined in schema: add, remove, move, update, change parent and position
* Refactored customers import feature. New ability to provide import data in 3 files: master file (key customer information) + address file (customer id + address info) + financial file (customer id + reward points & store credit)
* Optimized memory consumption in integration tests:
* Found and eliminated memory leaks in `Mage_Core_Model_App_Area`, `Mage_Core_Model_Layout`
* Manually unset objects from PHPUnit test case object in `tearDown()` in integration tests. Garbage collector didn't purge them because of these references
* Disabled running `integrity` test suite by default in integration tests
* Improvements in visual design editor JavaScript:
* eliminated dependency of code on HTML-literals, reduced code coupling between templates and JavaScript files
* implemented blocking unwanted JavaScript activity in visual design editor mode
* Various fixes in UX, code stability, modularity
* GitHub requests:
* [#23](https://github.com/magento/magento2/pull/23) -- added `Mage_Customer_Block_Account_Navigation::removeLink()`

Update as of 6/20/2012
=====================
* Implemented locale translation inheritance
Expand All @@ -8,7 +27,7 @@ Update as of 6/20/2012
* Implemented optional tracking of changes in view files fallback - cached by default, tracked in developer mode
* Introduced `@magentoDbIsolation` annotation in integration tests - isolates DB modifications made by tests
* Started refactoring of Visual Design Editor Javascript architecture
* Github requests:
* GitHub requests:
* [#25](https://github.com/magento/magento2/issues/25) Removed unused `Mage_Core_Block_Abstract::getHelper()` method
* Fixed:
* "$_FILES array is empty" messages in exception log upon installation
Expand All @@ -26,8 +45,8 @@ Update as of 6/7/2012
* Eliminated "after commit callback" workaround from integration tests by implementing "transparent transactions" capability in integration testing framework
* Refactored admin authentication/authorization in RSS module. Removed program termination and covered the controllers with tests
* Removed HTML-report feature of copy-paste detector which never worked anyway (`dev/tests/static/framework/Inspection/CopyPasteDetector/html_report.xslt` and all related code)
* Github requests:
** [#19](https://github.com/magento/magento2/pull/19) Implemented "soft" dependency between modules and performed several improvements in the related code, covered with tests
* GitHub requests:
* [#19](https://github.com/magento/magento2/pull/19) Implemented "soft" dependency between modules and performed several improvements in the related code, covered with tests

Update as of 5/31/2012
======================
Expand Down
16 changes: 0 additions & 16 deletions app/code/core/Mage/Admin/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,20 +333,4 @@ public function getAdminhtmlConfig()
{
return $this->_adminhtmlConfig;
}

/**
* Get menu item label by item path
*
* @param string $path
* @return string
*/
public function getMenuItemLabel($path)
{
$moduleName = 'Mage_Adminhtml_Helper_Data';
$menuNode = $this->getAdminhtmlConfig()->getNode('menu/' . str_replace('/', '/children/', trim($path, '/')));
if ($menuNode->getAttribute('module')) {
$moduleName = (string)$menuNode->getAttribute('module');
}
return $this->_getHelper($moduleName)->__((string)$menuNode->title);
}
}
11 changes: 0 additions & 11 deletions app/code/core/Mage/AdminNotification/etc/adminhtml.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,4 @@
</admin>
</resources>
</acl>
<menu>
<system>
<children>
<adminnotification translate="title" module="Mage_AdminNotification">
<title>Notifications</title>
<action>adminhtml/notification</action>
<sort_order>15</sort_order>
</adminnotification>
</children>
</system>
</menu>
</config>
32 changes: 32 additions & 0 deletions app/code/core/Mage/AdminNotification/etc/adminhtml/menu.xml
Original file line number Diff line number Diff line change
@@ -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) 2012 Magento 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="15" parent="Mage_Adminhtml::system" action="adminhtml/notification" />
</menu>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Mage_Adminhtml_Block_Report_Product_Viewed_Grid extends Mage_Adminhtml_Blo
*
* @var string
*/
protected $_resourceCollectionName = 'Mage_Reports_Model_Resource_Product_Viewed_Collection';
protected $_resourceCollectionName = 'Mage_Reports_Model_Resource_Report_Product_Viewed_Collection';

/**
* Init grid parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,16 @@ protected function _getSystemConfigPathsParts($paths)
$result = $urlParams = $prefixParts = array();
$scopeLabel = Mage::helper('Mage_Adminhtml_Helper_Data')->__('GLOBAL');
if ($paths) {
/** @var $menu Mage_Backend_Model_Menu */
$menu = Mage::getSingleton('Mage_Backend_Model_Menu_Config')->getMenu();
$item = $menu->get('Mage_Adminhtml::system');
// create prefix path parts
$prefixParts[] = array(
'title' => Mage::getSingleton('Mage_Admin_Model_Config')->getMenuItemLabel('system'),
'title' => $item->getModuleHelper()->__($item->getTitle()),
);
$item = $menu->get('Mage_Adminhtml::system_config');
$prefixParts[] = array(
'title' => Mage::getSingleton('Mage_Admin_Model_Config')->getMenuItemLabel('system/config'),
'title' => $item->getModuleHelper()->__($item->getTitle()),
'url' => $this->getUrl('adminhtml/system_config/'),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function _construct()
protected function _initAction()
{
$this->loadLayout()
->_setActiveMenu('sales/order')
->_setActiveMenu('Mage_Sales::sales_order')
->_addBreadcrumb($this->__('Sales'), $this->__('Sales'))
->_addBreadcrumb($this->__('Credit Memos'),$this->__('Credit Memos'));
return $this;
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function _construct()
protected function _initAction()
{
$this->loadLayout()
->_setActiveMenu('sales/order')
->_setActiveMenu('Mage_Sales::sales_order')
->_addBreadcrumb($this->__('Sales'), $this->__('Sales'))
->_addBreadcrumb($this->__('Invoices'),$this->__('Invoices'));
return $this;
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function _construct()
protected function _initAction()
{
$this->loadLayout()
->_setActiveMenu('sales/order')
->_setActiveMenu('Mage_Sales::sales_order')
->_addBreadcrumb($this->__('Sales'), $this->__('Sales'))
->_addBreadcrumb($this->__('Shipments'),$this->__('Shipments'));
return $this;
Expand Down
161 changes: 56 additions & 105 deletions app/code/core/Mage/Adminhtml/Model/System/Config/Source/Admin/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,136 +34,87 @@
*/
class Mage_Adminhtml_Model_System_Config_Source_Admin_Page
{
protected $_url;
/**
* Menu model
*
* @var Mage_Backend_Model_Menu
*/
protected $_menu;

/**
* Object factory
*
* @var Mage_Core_Model_Config
*/
protected $_objectFactory;

/**
* Default construct
*/
public function __construct(array $data = array())
{
$this->_menu = isset($data['menu']) ?
$data['menu'] :
Mage::getSingleton('Mage_Backend_Model_Menu_Config')->getMenu();

$this->_objectFactory = isset($data['objectFactory']) ? $data['objectFactory'] : Mage::getConfig();
}

public function toOptionArray()
{
$options = array();
$menu = $this->_buildMenuArray();

$this->_createOptions($options, $menu);

$this->_createOptions($options, $this->_menu);
return $options;
}

protected function _createOptions(&$optionArray, $menuNode)
/**
* Get menu filter iterator
*
* @param Mage_Backend_Model_Menu $menu menu model
* @return Mage_Backend_Model_Menu_Filter_Iterator
*/
protected function _getMenuIterator(Mage_Backend_Model_Menu $menu)
{
return $this->_objectFactory->getModelInstance('Mage_Backend_Model_Menu_Filter_Iterator', $menu->getIterator());
}

/**
* Create options array
*
* @param array $optionArray
* @param Mage_Backend_Model_Menu $menu
* @param int $level
*/
protected function _createOptions(&$optionArray, Mage_Backend_Model_Menu $menu, $level = 0)
{
$nonEscapableNbspChar = html_entity_decode('&#160;', ENT_NOQUOTES, 'UTF-8');
$paddingString = str_repeat($nonEscapableNbspChar, ($level * 4));

foreach ($menuNode as $menu) {
foreach ($this->_getMenuIterator($menu) as $menuItem) {

if (!empty($menu['url'])) {
/**@var $menuItem Mage_Backend_Model_Menu_Item */
if ($menuItem->getAction()) {
$optionArray[] = array(
'label' => str_repeat($nonEscapableNbspChar, ($menu['level'] * 4)) . $menu['label'],
'value' => $menu['path'],
'label' => $paddingString . $menuItem->getTitle(),
'value' => $menuItem->getId(),
);

if (isset($menu['children'])) {
$this->_createOptions($optionArray, $menu['children']);
if ($menuItem->hasChildren()) {
$this->_createOptions($optionArray, $menuItem->getChildren(), $level + 1);
}
}
else {
$children = array();

if(isset($menu['children'])) {
$this->_createOptions($children, $menu['children']);
if($menuItem->hasChildren()) {
$this->_createOptions($children, $menuItem->getChildren(), $level + 1);
}

$optionArray[] = array(
'label' => str_repeat($nonEscapableNbspChar, ($menu['level'] * 4)) . $menu['label'],
'label' => $paddingString . $menuItem->getTitle(),
'value' => $children,
);
}
}
}

protected function _getUrlModel()
{
if (is_null($this->_url)) {
$this->_url = Mage::getModel('Mage_Adminhtml_Model_Url');
}
return $this->_url;
}

protected function _buildMenuArray(Varien_Simplexml_Element $parent=null, $path='', $level=0)
{
if (is_null($parent)) {
$parent = Mage::getSingleton('Mage_Admin_Model_Config')->getAdminhtmlConfig()->getNode('menu');
}

$parentArr = array();
$sortOrder = 0;
foreach ($parent->children() as $childName=>$child) {
if ((1 == $child->disabled)
|| ($child->depends && !$this->_checkDepends($child->depends))
) {
continue;
}

$menuArr = array();
$menuArr['label'] = $this->_getHelperValue($child);

$menuArr['sort_order'] = $child->sort_order ? (int)$child->sort_order : $sortOrder;

if ($child->action) {
$menuArr['url'] = (string)$child->action;
} else {
$menuArr['url'] = '';
}

$menuArr['level'] = $level;
$menuArr['path'] = $path . $childName;

if ($child->children) {
$menuArr['children'] = $this->_buildMenuArray($child->children, $path.$childName.'/', $level+1);
}
$parentArr[$childName] = $menuArr;

$sortOrder++;
}

uasort($parentArr, array($this, '_sortMenu'));

while (list($key, $value) = each($parentArr)) {
$last = $key;
}
if (isset($last)) {
$parentArr[$last]['last'] = true;
}

return $parentArr;
}

protected function _sortMenu($a, $b)
{
return $a['sort_order']<$b['sort_order'] ? -1 : ($a['sort_order']>$b['sort_order'] ? 1 : 0);
}

protected function _checkDepends(Varien_Simplexml_Element $depends)
{
if ($depends->module) {
$modulesConfig = Mage::getConfig()->getNode('modules');
foreach ($depends->module as $module) {
if (!$modulesConfig->$module || !$modulesConfig->$module->is('active')) {
return false;
}
}
}

return true;
}

protected function _getHelperValue(Varien_Simplexml_Element $child)
{
$helperName = 'Mage_Adminhtml_Helper_Data';
$titleNodeName = 'title';
$childAttributes = $child->attributes();
if (isset($childAttributes['module'])) {
$helperName = (string)$childAttributes['module'];
}

$titleNodeName = 'title';

return Mage::helper($helperName)->__((string)$child->$titleNodeName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Mage_Adminhtml_Api_RoleController extends Mage_Adminhtml_Controller_Action
protected function _initAction()
{
$this->loadLayout();
$this->_setActiveMenu('system/services/roles');
$this->_setActiveMenu('Mage_Api::system_api_roles');
$this->_addBreadcrumb($this->__('Web services'), $this->__('Web services'));
$this->_addBreadcrumb($this->__('Permissions'), $this->__('Permissions'));
$this->_addBreadcrumb($this->__('Roles'), $this->__('Roles'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Mage_Adminhtml_Api_UserController extends Mage_Adminhtml_Controller_Action
protected function _initAction()
{
$this->loadLayout()
->_setActiveMenu('system/services/users')
->_setActiveMenu('Mage_Api::system_api_users')
->_addBreadcrumb($this->__('Web Services'), $this->__('Web Services'))
->_addBreadcrumb($this->__('Permissions'), $this->__('Permissions'))
->_addBreadcrumb($this->__('Users'), $this->__('Users'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function indexAction()
$this->_title($this->__('System'))->_title($this->__('Cache Management'));

$this->loadLayout()
->_setActiveMenu('system/cache')
->_setActiveMenu('Mage_Adminhtml::system_cache')
->renderLayout();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function editAction()
}

$this->loadLayout();
$this->_setActiveMenu('catalog/categories');
$this->_setActiveMenu('Mage_Catalog::catalog_categories');
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true)
->setContainerCssClass('catalog-categories');

Expand Down
Loading

0 comments on commit 3330e25

Please sign in to comment.