1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Adminhtml
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27: /**
28: * Adminhtml base helper
29: *
30: * @category Mage
31: * @package Mage_Adminhtml
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Adminhtml_Helper_Data extends Mage_Core_Helper_Abstract
35: {
36: const XML_PATH_ADMINHTML_ROUTER_FRONTNAME = 'admin/routers/adminhtml/args/frontName';
37: const XML_PATH_USE_CUSTOM_ADMIN_URL = 'default/admin/url/use_custom';
38: const XML_PATH_USE_CUSTOM_ADMIN_PATH = 'default/admin/url/use_custom_path';
39: const XML_PATH_CUSTOM_ADMIN_PATH = 'default/admin/url/custom_path';
40:
41: protected $_pageHelpUrl;
42:
43: public function getPageHelpUrl()
44: {
45: if (!$this->_pageHelpUrl) {
46: $this->setPageHelpUrl();
47: }
48: return $this->_pageHelpUrl;
49: }
50:
51: public function setPageHelpUrl($url=null)
52: {
53: if (is_null($url)) {
54: $request = Mage::app()->getRequest();
55: $frontModule = $request->getControllerModule();
56: if (!$frontModule) {
57: $frontName = $request->getModuleName();
58: $router = Mage::app()->getFrontController()->getRouterByFrontName($frontName);
59:
60: $frontModule = $router->getModuleByFrontName($frontName);
61: if (is_array($frontModule)) {
62: $frontModule = $frontModule[0];
63: }
64: }
65: $url = 'http://www.magentocommerce.com/gethelp/';
66: $url.= Mage::app()->getLocale()->getLocaleCode().'/';
67: $url.= $frontModule.'/';
68: $url.= $request->getControllerName().'/';
69: $url.= $request->getActionName().'/';
70:
71: $this->_pageHelpUrl = $url;
72: }
73: $this->_pageHelpUrl = $url;
74:
75: return $this;
76: }
77:
78: public function addPageHelpUrl($suffix)
79: {
80: $this->_pageHelpUrl = $this->getPageHelpUrl().$suffix;
81: return $this;
82: }
83:
84: public static function getUrl($route='', $params=array())
85: {
86: return Mage::getModel('adminhtml/url')->getUrl($route, $params);
87: }
88:
89: // public function getCurrentUserId()
90: // {
91: // return Mage::getSingleton('admin/session')->getUser()->getId();
92: // }
93: public function getCurrentUserId()
94: {
95: if (Mage::getSingleton('admin/session')->getUser()) {
96: return Mage::getSingleton('admin/session')->getUser()->getId();
97: }
98: return false;
99: }
100:
101: /**
102: * Decode filter string
103: *
104: * @param string $filterString
105: * @return data
106: */
107: public function prepareFilterString($filterString)
108: {
109: $data = array();
110: $filterString = base64_decode($filterString);
111: parse_str($filterString, $data);
112: array_walk_recursive($data, array($this, 'decodeFilter'));
113: return $data;
114: }
115:
116: /**
117: * Decode URL encoded filter value recursive callback method
118: *
119: * @param string $value
120: */
121: public function decodeFilter(&$value)
122: {
123: $value = rawurldecode($value);
124: }
125: }
126: