Public Member Functions | |
getSecure () | |
setRouteParams (array $data, $unsetOldParams=true) | |
getUrl ($routePath=null, $routeParams=null) | |
getSecretKey ($controller=null, $action=null) | |
useSecretKey () | |
turnOnSecretKey () | |
turnOffSecretKey () | |
renewSecretUrls () | |
Public Attributes | |
const | SECRET_KEY_PARAM_NAME = 'key' |
Definition at line 26 of file Url.php.
getSecretKey | ( | $ | controller = null , |
|
$ | action = null | |||
) |
Generate secret key for controller and action based on form key
string | $controller Controller name | |
string | $action Action name |
Definition at line 100 of file Url.php.
00101 { 00102 $salt = Mage::getSingleton('core/session')->getFormKey(); 00103 00104 $p = explode('/', trim($this->getRequest()->getOriginalPathInfo(), '/')); 00105 if (!$controller) { 00106 $controller = !empty($p[1]) ? $p[1] : $this->getRequest()->getControllerName(); 00107 } 00108 if (!$action) { 00109 $action = !empty($p[2]) ? $p[2] : $this->getRequest()->getActionName(); 00110 } 00111 00112 $secret = $controller . $action . $salt; 00113 return Mage::helper('core')->getHash($secret); 00114 }
getSecure | ( | ) |
Retrieve is secure mode for ULR logic
Reimplemented from Mage_Core_Model_Url.
Definition at line 38 of file Url.php.
00039 { 00040 if ($this->hasData('secure_is_forced')) { 00041 return $this->getData('secure'); 00042 } 00043 return Mage::getStoreConfigFlag('web/secure/use_in_adminhtml'); 00044 }
getUrl | ( | $ | routePath = null , |
|
$ | routeParams = null | |||
) |
Custom logic to retrieve Urls
string | $routePath | |
array | $routeParams |
Reimplemented from Mage_Core_Model_Url.
Definition at line 70 of file Url.php.
00071 { 00072 $result = parent::getUrl($routePath, $routeParams); 00073 00074 if (!$this->useSecretKey()) { 00075 return $result; 00076 } 00077 00078 $_route = $this->getRouteName() ? $this->getRouteName() : '*'; 00079 $_controller = $this->getControllerName() ? $this->getControllerName() : $this->getDefaultControllerName(); 00080 $_action = $this->getActionName() ? $this->getActionName() : $this->getDefaultActionName(); 00081 $secret = array(self::SECRET_KEY_PARAM_NAME => $this->getSecretKey($_controller, $_action)); 00082 if (is_array($routeParams)) { 00083 $routeParams = array_merge($secret, $routeParams); 00084 } else { 00085 $routeParams = $secret; 00086 } 00087 if (is_array($this->getRouteParams())) { 00088 $routeParams = array_merge($this->getRouteParams(), $routeParams); 00089 } 00090 return parent::getUrl("{$_route}/{$_controller}/{$_action}", $routeParams); 00091 }
renewSecretUrls | ( | ) |
Refresh admin menu cache etc.
Definition at line 153 of file Url.php.
00154 { 00155 Mage::app()->cleanCache(array(Mage_Adminhtml_Block_Page_Menu::CACHE_TAGS)); 00156 }
Force strip secret key param if _nosecret param specified
Reimplemented from Mage_Core_Model_Url.
Definition at line 51 of file Url.php.
00052 { 00053 if (isset($data['_nosecret'])) { 00054 $this->setNoSecret(true); 00055 unset($data['_nosecret']); 00056 } else { 00057 $this->setNoSecret(false); 00058 } 00059 00060 return parent::setRouteParams($data, $unsetOldParams); 00061 }
turnOffSecretKey | ( | ) |
turnOnSecretKey | ( | ) |
useSecretKey | ( | ) |
Return secret key settings flag
Definition at line 121 of file Url.php.
00122 { 00123 return Mage::getStoreConfigFlag('admin/security/use_form_key') && !$this->getNoSecret(); 00124 }
const SECRET_KEY_PARAM_NAME = 'key' |