| Server IP : 213.186.33.4 / Your IP : 216.73.216.193 Web Server : Apache System : Linux webm006.cluster103.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : awebpaca ( 35430) PHP Version : 8.5.0 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/awebpaca/boutiques/app/code/core/Mage/Adminhtml/Block/Page/ |
Upload File : |
<?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) 2010 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
/**
* Adminhtml menu block
*
* @category Mage
* @package Mage_Adminhtml
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Adminhtml_Block_Page_Menu extends Mage_Adminhtml_Block_Template
{
const CACHE_TAGS = 'BACKEND_MAINMENU';
/**
* Adminhtml URL instance
*
* @var Mage_Adminhtml_Model_Url
*/
protected $_url;
/**
* Initialize template and cache settings
*
*/
protected function _construct()
{
parent::_construct();
$this->setTemplate('page/menu.phtml');
$this->_url = Mage::getModel('adminhtml/url');
$this->setCacheTags(array(self::CACHE_TAGS));
}
/**
* Retrieve cache lifetime
*
* @return int
*/
public function getCacheLifetime()
{
return 86400;
}
/**
* Get Key pieces for caching block content
*
* @return array
*/
public function getCacheKeyInfo()
{
return array(
'admin_top_nav',
$this->getActive(),
Mage::getSingleton('admin/session')->getUser()->getId(),
Mage::app()->getLocale()->getLocaleCode()
);
}
/**
* Retrieve Adminhtml Menu array
*
* @return array
*/
public function getMenuArray()
{
return $this->_buildMenuArray();
}
/**
* Retrieve Title value for menu node
*
* @param Varien_Simplexml_Element $child
* @return string
*/
protected function _getHelperValue(Varien_Simplexml_Element $child)
{
$helperName = 'adminhtml';
$titleNodeName = 'title';
$childAttributes = $child->attributes();
if (isset($childAttributes['module'])) {
$helperName = (string)$childAttributes['module'];
}
// if (isset($childAttributes['translate'])) {
// $titleNodeName = (string)$childAttributes['translate'];
// }
return Mage::helper($helperName)->__((string)$child->$titleNodeName);
}
/**
* Recursive Build Menu array
*
* @param Varien_Simplexml_Element $parent
* @param string $path
* @param int $level
* @return array
*/
protected function _buildMenuArray(Varien_Simplexml_Element $parent=null, $path='', $level=0)
{
if (is_null($parent)) {
$parent = Mage::getSingleton('admin/config')->getAdminhtmlConfig()->getNode('menu');
}
$parentArr = array();
$sortOrder = 0;
foreach ($parent->children() as $childName => $child) {
if (1 == $child->disabled) {
continue;
}
$aclResource = 'admin/' . ($child->resource ? (string)$child->resource : $path . $childName);
if (!$this->_checkAcl($aclResource)) {
continue;
}
if ($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'] = $this->_url->getUrl((string)$child->action, array('_cache_secret_key' => true));
} else {
$menuArr['url'] = '#';
$menuArr['click'] = 'return false';
}
$menuArr['active'] = ($this->getActive()==$path.$childName)
|| (strpos($this->getActive(), $path.$childName.'/')===0);
$menuArr['level'] = $level;
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;
}
/**
* Sort menu comparison function
*
* @param int $a
* @param int $b
* @return int
*/
protected function _sortMenu($a, $b)
{
return $a['sort_order']<$b['sort_order'] ? -1 : ($a['sort_order']>$b['sort_order'] ? 1 : 0);
}
/**
* Check Depends
*
* @param Varien_Simplexml_Element $depends
* @return bool
*/
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;
}
}
}
if ($depends->config) {
foreach ($depends->config as $path) {
if (!Mage::getStoreConfigFlag((string)$path)) {
return false;
}
}
}
return true;
}
/*protected function _checkAcl(Varien_Simplexml_Element $acl)
{
return true;
$resource = (string)$acl->resource;
$privilege = (string)$acl->privilege;
return Mage::getSingleton('admin/session')->isAllowed($resource, $privilege);
}*/
/**
* Check is Allow menu item for admin user
*
* @param string $resource
* @return bool
*/
protected function _checkAcl($resource)
{
try {
$res = Mage::getSingleton('admin/session')->isAllowed($resource);
} catch (Exception $e) {
return false;
}
return $res;
}
/**
* Processing block html after rendering
*
* @param string $html
* @return string
*/
protected function _afterToHtml($html)
{
$html = preg_replace_callback('#'.Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME.'/\$([^\/].*)/([^\$].*)\$#', array($this, '_callbackSecretKey'), $html);
return $html;
}
/**
* Replace Callback Secret Key
*
* @param array $match
* @return string
*/
protected function _callbackSecretKey($match)
{
return Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME . '/'
. $this->_url->getSecretKey($match[1], $match[2]);
}
}