Mage_Adminhtml_Model_Url Class Reference

Inheritance diagram for Mage_Adminhtml_Model_Url:

Mage_Core_Model_Url Varien_Object

List of all members.

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'


Detailed Description

Definition at line 26 of file Url.php.


Member Function Documentation

getSecretKey ( controller = null,
action = null 
)

Generate secret key for controller and action based on form key

Parameters:
string $controller Controller name
string $action Action name
Returns:
string

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

Returns:
bool

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

Parameters:
string $routePath
array $routeParams
Returns:
string

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.

Returns:
Mage_Adminhtml_Model_Url

Definition at line 153 of file Url.php.

00154     {
00155         Mage::app()->cleanCache(array(Mage_Adminhtml_Block_Page_Menu::CACHE_TAGS));
00156     }

setRouteParams ( array data,
unsetOldParams = true 
)

Force strip secret key param if _nosecret param specified

Returns:
Mage_Core_Model_Url

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 (  ) 

Disable secret key using

Returns:
Mage_Adminhtml_Model_Url

Definition at line 142 of file Url.php.

00143     {
00144         $this->setNoSecret(true);
00145         return $this;
00146     }

turnOnSecretKey (  ) 

Enable secret key using

Returns:
Mage_Adminhtml_Model_Url

Definition at line 131 of file Url.php.

00132     {
00133         $this->setNoSecret(false);
00134         return $this;
00135     }

useSecretKey (  ) 

Return secret key settings flag

Returns:
boolean

Definition at line 121 of file Url.php.

00122     {
00123         return Mage::getStoreConfigFlag('admin/security/use_form_key') && !$this->getNoSecret();
00124     }


Member Data Documentation

const SECRET_KEY_PARAM_NAME = 'key'

Secret key query param name

Definition at line 31 of file Url.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:14 2009 for Magento by  doxygen 1.5.8