Mage_Adminhtml_Controller_Action Class Reference

Inheritance diagram for Mage_Adminhtml_Controller_Action:

Mage_Core_Controller_Varien_Action Mage_Adminhtml_Api_RoleController Mage_Adminhtml_Api_UserController Mage_Adminhtml_Catalog_CategoryController Mage_Adminhtml_Catalog_DatafeedsController Mage_Adminhtml_Catalog_Product_Action_AttributeController Mage_Adminhtml_Catalog_Product_AttributeController Mage_Adminhtml_Catalog_Product_GalleryController Mage_Adminhtml_Catalog_Product_GroupController Mage_Adminhtml_Catalog_Product_ReviewController Mage_Adminhtml_Catalog_Product_SetController Mage_Adminhtml_Catalog_ProductController Mage_Adminhtml_Catalog_SearchController Mage_Adminhtml_CatalogController Mage_Adminhtml_Checkout_AgreementController Mage_Adminhtml_Cms_BlockController Mage_Adminhtml_Cms_PageController Mage_Adminhtml_Controller_Sales_Creditmemo Mage_Adminhtml_Controller_Sales_Invoice Mage_Adminhtml_Controller_Sales_Shipment Mage_Adminhtml_Customer_ConfigController Mage_Adminhtml_Customer_GroupController Mage_Adminhtml_Customer_OnlineController Mage_Adminhtml_CustomerController Mage_Adminhtml_DashboardController Mage_Adminhtml_Extensions_ConfigController Mage_Adminhtml_Extensions_ConsoleController Mage_Adminhtml_Extensions_CustomController Mage_Adminhtml_Extensions_FileController Mage_Adminhtml_Extensions_LocalController Mage_Adminhtml_Extensions_RemoteController Mage_Adminhtml_IndexController Mage_Adminhtml_JsonController Mage_Adminhtml_Media_EditorController Mage_Adminhtml_Media_UploaderController Mage_Adminhtml_Newsletter_ProblemController Mage_Adminhtml_Newsletter_QueueController Mage_Adminhtml_Newsletter_SubscriberController Mage_Adminhtml_Newsletter_TemplateController Mage_Adminhtml_NotificationController Mage_Adminhtml_Permissions_RoleController Mage_Adminhtml_Permissions_UserController Mage_Adminhtml_Poll_AnswerController Mage_Adminhtml_PollController Mage_Adminhtml_Promo_CatalogController Mage_Adminhtml_Promo_QuoteController Mage_Adminhtml_Promo_WidgetController Mage_Adminhtml_PromoController Mage_Adminhtml_RatingController Mage_Adminhtml_Report_CustomerController Mage_Adminhtml_Report_ProductController Mage_Adminhtml_Report_ReviewController Mage_Adminhtml_Report_SalesController Mage_Adminhtml_Report_ShopcartController Mage_Adminhtml_Report_TagController Mage_Adminhtml_ReportController Mage_Adminhtml_Rss_CatalogController Mage_Adminhtml_Rss_OrderController Mage_Adminhtml_Sales_Order_CreateController Mage_Adminhtml_Sales_Order_View_GiftmessageController Mage_Adminhtml_Sales_OrderController Mage_Adminhtml_SalesController Mage_Adminhtml_SitemapController Mage_Adminhtml_System_AccountController Mage_Adminhtml_System_BackupController Mage_Adminhtml_System_CacheController Mage_Adminhtml_System_ConfigController Mage_Adminhtml_System_Convert_ProfileController Mage_Adminhtml_System_CurrencyController Mage_Adminhtml_System_DesignController Mage_Adminhtml_System_Email_TemplateController Mage_Adminhtml_System_StoreController Mage_Adminhtml_SystemController Mage_Adminhtml_TagController Mage_Adminhtml_Tax_Class_CustomerController Mage_Adminhtml_Tax_Class_ProductController Mage_Adminhtml_Tax_ClassController Mage_Adminhtml_Tax_RateController Mage_Adminhtml_Tax_RuleController Mage_Adminhtml_UrlrewriteController Mage_Bundle_SelectionController Mage_Compiler_ProcessController Mage_Downloadable_FileController Mage_GoogleBase_ItemsController Mage_GoogleBase_SelectionController Mage_GoogleBase_TypesController Mage_GoogleOptimizer_IndexController

List of all members.

Public Member Functions

 preDispatch ()
 deniedAction ()
 loadLayout ($ids=null, $generateBlocks=true, $generateXml=true)
 norouteAction ($coreRoute=null)
 getUsedModuleName ()
 setUsedModuleName ($moduleName)
 __ ()
 getUrl ($route='', $params=array())

Public Attributes

const FLAG_IS_URLS_CHECKED = 'check_url_settings'

Protected Member Functions

 _isAllowed ()
 _getSession ()
 _getHelper ()
 _setActiveMenu ($menuPath)
 _addBreadcrumb ($label, $title, $link=null)
 _addContent (Mage_Core_Block_Abstract $block)
 _addLeft (Mage_Core_Block_Abstract $block)
 _addJs (Mage_Core_Block_Abstract $block)
 _checkUrlSettings ()
 _redirectReferer ($defaultUrl=null)
 _prepareDownloadResponse ($fileName, $content, $contentType= 'application/octet-stream', $contentLength=null)
 _redirect ($path, $arguments=array())
 _forward ($action, $controller=null, $module=null, array $params=null)
 _validateSecretKey ()

Protected Attributes

 $_publicActions = array()
 $_usedModuleName = 'adminhtml'


Detailed Description

Definition at line 34 of file Action.php.


Member Function Documentation

__ (  ) 

Translate a phrase

Returns:
string

Definition at line 278 of file Action.php.

00279     {
00280         $args = func_get_args();
00281         $expr = new Mage_Core_Model_Translate_Expr(array_shift($args), $this->getUsedModuleName());
00282         array_unshift($args, $expr);
00283         return Mage::app()->getTranslator()->translate($args);
00284     }

_addBreadcrumb ( label,
title,
link = null 
) [protected]

Returns:
Mage_Adminhtml_Controller_Action

Definition at line 89 of file Action.php.

00090     {
00091         $this->getLayout()->getBlock('breadcrumbs')->addLink($label, $title, $link);
00092         return $this;
00093     }

_addContent ( Mage_Core_Block_Abstract block  )  [protected]

Returns:
Mage_Adminhtml_Controller_Action

Definition at line 98 of file Action.php.

00099     {
00100         $this->getLayout()->getBlock('content')->append($block);
00101         return $this;
00102     }

_addJs ( Mage_Core_Block_Abstract block  )  [protected]

Definition at line 110 of file Action.php.

00111     {
00112         $this->getLayout()->getBlock('js')->append($block);
00113         return $this;
00114     }

_addLeft ( Mage_Core_Block_Abstract block  )  [protected]

Definition at line 104 of file Action.php.

00105     {
00106         $this->getLayout()->getBlock('left')->append($block);
00107         return $this;
00108     }

_checkUrlSettings (  )  [protected]

Don't check for data saving actions

Definition at line 179 of file Action.php.

00180     {
00181         /**
00182          * Don't check for data saving actions
00183          */
00184         if ($this->getRequest()->getPost() || $this->getRequest()->getQuery('isAjax')) {
00185             return $this;
00186         }
00187 
00188         $configData = Mage::getModel('core/config_data');
00189 
00190         $defaultUnsecure= (string) Mage::getConfig()->getNode('default/'.Mage_Core_Model_Store::XML_PATH_UNSECURE_BASE_URL);
00191         $defaultSecure  = (string) Mage::getConfig()->getNode('default/'.Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL);
00192 
00193         if ($defaultSecure == '{{base_url}}' || $defaultUnsecure == '{{base_url}}') {
00194             $this->_getSession()->addNotice(
00195                 $this->__('{{base_url}} is not recommended to use in a production environment to declare the Base Unsecure Url / Base Secure Url. It is highly recommended to change this value in your Magento <a href="%s">configuration</a>.', $this->getUrl('adminhtml/system_config/edit', array('section'=>'web')))
00196             );
00197             return $this;
00198         }
00199 
00200         $dataCollection = $configData->getCollection()
00201             ->addValueFilter('{{base_url}}');
00202 
00203         $url = false;
00204         foreach ($dataCollection as $data) {
00205             if ($data->getScope() == 'stores') {
00206                 $code = Mage::app()->getStore($data->getScopeId())->getCode();
00207                 $url = $this->getUrl('adminhtml/system_config/edit', array('section'=>'web', 'store'=>$code));
00208             }
00209             if ($data->getScope() == 'websites') {
00210                 $code = Mage::app()->getWebsite($data->getScopeId())->getCode();
00211                 $url = $this->getUrl('adminhtml/system_config/edit', array('section'=>'web', 'website'=>$code));
00212             }
00213 
00214             if ($url) {
00215                 $this->_getSession()->addNotice(
00216                     $this->__('{{base_url}} is not recommended to use in a production environment to declare the Base Unsecure Url / Base Secure Url. It is highly recommended to change this value in your Magento <a href="%s">configuration</a>.', $url)
00217                 );
00218                 return $this;
00219             }
00220         }
00221         return $this;
00222     }

_forward ( action,
controller = null,
module = null,
array params = null 
) [protected]

Reimplemented from Mage_Core_Controller_Varien_Action.

Definition at line 344 of file Action.php.

00345     {
00346         $this->_getSession()->setIsUrlNotice($this->getFlag('', self::FLAG_IS_URLS_CHECKED));
00347         return parent::_forward($action, $controller, $module, $params);
00348     }

_getHelper (  )  [protected]

Retrieve base admihtml helper

Returns:
Mage_Adminhtml_Helper_Data

Reimplemented in Mage_Adminhtml_Catalog_Product_Action_AttributeController.

Definition at line 70 of file Action.php.

00071     {
00072         return Mage::helper('adminhtml');
00073     }

_getSession (  )  [protected]

Retrieve adminhtml session model object

Returns:
Mage_Adminhtml_Model_Session

Reimplemented in Mage_Adminhtml_Sales_Order_CreateController, Mage_Adminhtml_System_BackupController, and Mage_Adminhtml_System_CacheController.

Definition at line 60 of file Action.php.

00061     {
00062         return Mage::getSingleton('adminhtml/session');
00063     }

_isAllowed (  )  [protected]

Reimplemented in Mage_Adminhtml_Controller_Sales_Creditmemo, Mage_Adminhtml_Controller_Sales_Invoice, Mage_Adminhtml_Controller_Sales_Shipment, Mage_Adminhtml_Api_RoleController, Mage_Adminhtml_Api_UserController, Mage_Adminhtml_Catalog_CategoryController, Mage_Adminhtml_Catalog_Product_Action_AttributeController, Mage_Adminhtml_Catalog_Product_AttributeController, Mage_Adminhtml_Catalog_Product_GalleryController, Mage_Adminhtml_Catalog_Product_GroupController, Mage_Adminhtml_Catalog_Product_ReviewController, Mage_Adminhtml_Catalog_Product_SetController, Mage_Adminhtml_Catalog_ProductController, Mage_Adminhtml_Catalog_SearchController, Mage_Adminhtml_CatalogController, Mage_Adminhtml_Checkout_AgreementController, Mage_Adminhtml_Cms_BlockController, Mage_Adminhtml_Cms_PageController, Mage_Adminhtml_Customer_ConfigController, Mage_Adminhtml_Customer_GroupController, Mage_Adminhtml_Customer_OnlineController, Mage_Adminhtml_CustomerController, Mage_Adminhtml_DashboardController, Mage_Adminhtml_Extensions_ConfigController, Mage_Adminhtml_Extensions_ConsoleController, Mage_Adminhtml_Extensions_CustomController, Mage_Adminhtml_Extensions_FileController, Mage_Adminhtml_Extensions_LocalController, Mage_Adminhtml_Extensions_RemoteController, Mage_Adminhtml_IndexController, Mage_Adminhtml_Media_EditorController, Mage_Adminhtml_Media_UploaderController, Mage_Adminhtml_Newsletter_ProblemController, Mage_Adminhtml_Newsletter_QueueController, Mage_Adminhtml_Newsletter_SubscriberController, Mage_Adminhtml_Newsletter_TemplateController, Mage_Adminhtml_NotificationController, Mage_Adminhtml_Permissions_RoleController, Mage_Adminhtml_Permissions_UserController, Mage_Adminhtml_Poll_AnswerController, Mage_Adminhtml_PollController, Mage_Adminhtml_Promo_CatalogController, Mage_Adminhtml_Promo_QuoteController, Mage_Adminhtml_Promo_WidgetController, Mage_Adminhtml_PromoController, Mage_Adminhtml_RatingController, Mage_Adminhtml_Report_CustomerController, Mage_Adminhtml_Report_ProductController, Mage_Adminhtml_Report_ReviewController, Mage_Adminhtml_Report_SalesController, Mage_Adminhtml_Report_ShopcartController, Mage_Adminhtml_Report_TagController, Mage_Adminhtml_ReportController, Mage_Adminhtml_Sales_Order_CreateController, Mage_Adminhtml_Sales_OrderController, Mage_Adminhtml_SalesController, Mage_Adminhtml_SitemapController, Mage_Adminhtml_System_AccountController, Mage_Adminhtml_System_BackupController, Mage_Adminhtml_System_CacheController, Mage_Adminhtml_System_ConfigController, Mage_Adminhtml_System_Convert_GuiController, Mage_Adminhtml_System_Convert_ProfileController, Mage_Adminhtml_System_CurrencyController, Mage_Adminhtml_System_DesignController, Mage_Adminhtml_System_Email_TemplateController, Mage_Adminhtml_System_StoreController, Mage_Adminhtml_SystemController, Mage_Adminhtml_TagController, Mage_Adminhtml_Tax_Class_CustomerController, Mage_Adminhtml_Tax_Class_ProductController, Mage_Adminhtml_Tax_RateController, Mage_Adminhtml_Tax_RuleController, Mage_Adminhtml_UrlrewriteController, Mage_Compiler_ProcessController, Mage_Downloadable_FileController, Mage_GoogleBase_ItemsController, and Mage_GoogleBase_TypesController.

Definition at line 50 of file Action.php.

00051     {
00052         return true;
00053     }

_prepareDownloadResponse ( fileName,
content,
contentType = 'application/octet-stream',
contentLength = null 
) [protected]

Declare headers and content file in responce for file download

Parameters:
string $fileName
string $content set to null to avoid starting output, $contentLength should be set explicitly in that case
string $contentType
int $contentLength explicit content length, if strlen($content) isn't applicable
Returns:
Mage_Adminhtml_Controller_Action

Definition at line 310 of file Action.php.

00311     {
00312         $session = Mage::getSingleton('admin/session');
00313         if ($session->isFirstPageAfterLogin()) {
00314             $this->_redirect($session->getUser()->getStartupPageUrl());
00315             return $this;
00316         }
00317         $this->getResponse()
00318             ->setHttpResponseCode(200)
00319             ->setHeader('Pragma', 'public', true)
00320             ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
00321             ->setHeader('Content-type', $contentType, true)
00322             ->setHeader('Content-Length', is_null($contentLength) ? strlen($content) : $contentLength)
00323             ->setHeader('Content-Disposition', 'attachment; filename=' . $fileName)
00324             ->setHeader('Last-Modified', date('r'));
00325         if (!is_null($content)) {
00326             $this->getResponse()->setBody($content);
00327         }
00328         return $this;
00329     }

_redirect ( path,
arguments = array() 
) [protected]

Set redirect into responce

Parameters:
string $path
array $arguments

Reimplemented from Mage_Core_Controller_Varien_Action.

Definition at line 337 of file Action.php.

00338     {
00339         $this->_getSession()->setIsUrlNotice($this->getFlag('', self::FLAG_IS_URLS_CHECKED));
00340         $this->getResponse()->setRedirect($this->getUrl($path, $arguments));
00341         return $this;
00342     }

_redirectReferer ( defaultUrl = null  )  [protected]

Set referer url for redirect in responce

Is overriden here to set defaultUrl to admin url

Parameters:
string $defaultUrl
Returns:
Mage_Adminhtml_Controller_Action

Reimplemented from Mage_Core_Controller_Varien_Action.

Definition at line 294 of file Action.php.

00295     {
00296         $defaultUrl = empty($defaultUrl) ? $this->getUrl('*') : $defaultUrl;
00297         parent::_redirectReferer($defaultUrl);
00298         return $this;
00299     }

_setActiveMenu ( menuPath  )  [protected]

Define active menu item in menu block

Returns:
Mage_Adminhtml_Controller_Action

Definition at line 80 of file Action.php.

00081     {
00082         $this->getLayout()->getBlock('menu')->setActive($menuPath);
00083         return $this;
00084     }

_validateSecretKey (  )  [protected]

Validate Secret Key

Returns:
bool

Definition at line 367 of file Action.php.

00368     {
00369         if (is_array($this->_publicActions) && in_array($this->getRequest()->getActionName(), $this->_publicActions)) {
00370             return true;
00371         }
00372 
00373         if (!($secretKey = $this->getRequest()->getParam(Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME, null))
00374             || $secretKey != Mage::getSingleton('adminhtml/url')->getSecretKey()) {
00375             return false;
00376         }
00377         return true;
00378     }

deniedAction (  ) 

Definition at line 224 of file Action.php.

00225     {
00226         $this->getResponse()->setHeader('HTTP/1.1','403 Forbidden');
00227         if (!Mage::getSingleton('admin/session')->isLoggedIn()) {
00228             $this->_redirect('*/index/login');
00229             return;
00230         }
00231         $this->loadLayout(array('default', 'adminhtml_denied'));
00232         $this->renderLayout();
00233     }

getUrl ( route = '',
params = array() 
)

Generate url by route and parameters

Parameters:
string $route
array $params
Returns:
string

Definition at line 357 of file Action.php.

00358     {
00359         return Mage::helper('adminhtml')->getUrl($route, $params);
00360     }

getUsedModuleName (  ) 

Retrieve currently used module name

Returns:
string

Definition at line 256 of file Action.php.

00257     {
00258         return $this->_usedModuleName;
00259     }

loadLayout ( handles = null,
generateBlocks = true,
generateXml = true 
)

Load layout by handles(s)

Parameters:
string $handles
string $cacheId
boolean $generateBlocks
Returns:
Mage_Core_Controller_Varien_Action

Reimplemented from Mage_Core_Controller_Varien_Action.

Definition at line 235 of file Action.php.

00236     {
00237         parent::loadLayout($ids, $generateBlocks, $generateXml);
00238         $this->_initLayoutMessages('adminhtml/session');
00239         return $this;
00240     }

norouteAction ( coreRoute = null  ) 

Reimplemented from Mage_Core_Controller_Varien_Action.

Definition at line 242 of file Action.php.

00243     {
00244         $this->getResponse()->setHeader('HTTP/1.1','404 Not Found');
00245         $this->getResponse()->setHeader('Status','404 File not found');
00246         $this->loadLayout(array('default', 'adminhtml_noroute'));
00247         $this->renderLayout();
00248     }

preDispatch (  ) 

Controller predispatch method

Returns:
Mage_Adminhtml_Controller_Action

Reimplemented from Mage_Core_Controller_Varien_Action.

Reimplemented in Mage_Adminhtml_Catalog_Product_AttributeController, Mage_Adminhtml_Rss_CatalogController, Mage_Adminhtml_Rss_OrderController, and Mage_Compiler_ProcessController.

Definition at line 121 of file Action.php.

00122     {
00123         Mage::getDesign()->setArea('adminhtml')
00124             ->setPackageName((string)Mage::getConfig()->getNode('stores/admin/design/package/name'))
00125             ->setTheme((string)Mage::getConfig()->getNode('stores/admin/design/theme/default'));
00126 
00127         $this->getLayout()->setArea('adminhtml');
00128 
00129         Mage::dispatchEvent('adminhtml_controller_action_predispatch_start', array());
00130         parent::preDispatch();
00131         $_isValidFormKey = true;
00132         $_isValidSecretKey = true;
00133         $_keyErrorMsg = '';
00134         if (Mage::getSingleton('admin/session')->isLoggedIn()) {
00135             if ($this->getRequest()->isPost()) {
00136                 $_isValidFormKey = $this->_validateFormKey();
00137                 $_keyErrorMsg = Mage::helper('adminhtml')->__('Invalid Form Key. Please refresh the page.');
00138             } elseif (Mage::getSingleton('adminhtml/url')->useSecretKey()) {
00139                 $_isValidSecretKey = $this->_validateSecretKey();
00140                 $_keyErrorMsg = Mage::helper('adminhtml')->__('Invalid Secret Key. Please refresh the page.');
00141             }
00142         }
00143         if (!$_isValidFormKey || !$_isValidSecretKey) {
00144             $this->setFlag('', self::FLAG_NO_DISPATCH, true);
00145             $this->setFlag('', self::FLAG_NO_POST_DISPATCH, true);
00146             if ($this->getRequest()->getQuery('isAjax', false) || $this->getRequest()->getQuery('ajax', false)) {
00147                 $this->getResponse()->setBody(Zend_Json::encode(array(
00148                     'error' => true,
00149                     'message' => $_keyErrorMsg
00150                 )));
00151             } else {
00152                 $this->_redirect( Mage::getSingleton('admin/session')->getUser()->getStartupPageUrl() );
00153             }
00154             return $this;
00155         }
00156 
00157         if ($this->getRequest()->isDispatched()
00158             && $this->getRequest()->getActionName() !== 'denied'
00159             && !$this->_isAllowed()) {
00160             $this->_forward('denied');
00161             $this->setFlag('', self::FLAG_NO_DISPATCH, true);
00162             return $this;
00163         }
00164 
00165         if (!$this->getFlag('', self::FLAG_IS_URLS_CHECKED)
00166             && !$this->getRequest()->getParam('forwarded')
00167             && !$this->_getSession()->getIsUrlNotice(true)
00168             && !Mage::getConfig()->getNode('global/can_use_base_url')) {
00169             $this->_checkUrlSettings();
00170             $this->setFlag('', self::FLAG_IS_URLS_CHECKED, true);
00171         }
00172         if (is_null(Mage::getSingleton('adminhtml/session')->getLocale())) {
00173             Mage::getSingleton('adminhtml/session')->setLocale(Mage::app()->getLocale()->getLocaleCode());
00174         }
00175 
00176         return $this;
00177     }

setUsedModuleName ( moduleName  ) 

Set currently used module name

Parameters:
string $moduleName
Returns:
Mage_Adminhtml_Controller_Action

Definition at line 267 of file Action.php.

00268     {
00269         $this->_usedModuleName = $moduleName;
00270         return $this;
00271     }


Member Data Documentation

$_publicActions = array() [protected]

Reimplemented in Mage_Adminhtml_Sales_OrderController.

Definition at line 43 of file Action.php.

$_usedModuleName = 'adminhtml' [protected]

Used module name in current adminhtml controller

Definition at line 48 of file Action.php.

const FLAG_IS_URLS_CHECKED = 'check_url_settings'

Definition at line 36 of file Action.php.


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

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