Mage_Adminhtml_UrlrewriteController Class Reference

Inheritance diagram for Mage_Adminhtml_UrlrewriteController:

Mage_Adminhtml_Controller_Action Mage_Core_Controller_Varien_Action

List of all members.

Public Member Functions

 indexAction ()
 editAction ()
 productGridAction ()
 categoriesJsonAction ()
 saveAction ()
 deleteAction ()

Protected Member Functions

 _initRegistry ()
 _isAllowed ()


Detailed Description

Definition at line 34 of file UrlrewriteController.php.


Member Function Documentation

_initRegistry (  )  [protected]

Instantiate urlrewrite, product and category

Returns:
Mage_Adminhtml_UrlrewriteController

Definition at line 41 of file UrlrewriteController.php.

00042     {
00043         // initialize urlrewrite, product and category models
00044         Mage::register('current_urlrewrite', Mage::getModel('core/url_rewrite')
00045             ->load($this->getRequest()->getParam('id', 0))
00046         );
00047         $productId  = $this->getRequest()->getParam('product', 0);
00048         $categoryId = $this->getRequest()->getParam('category', 0);
00049         if (Mage::registry('current_urlrewrite')->getId()) {
00050             $productId  = Mage::registry('current_urlrewrite')->getProductId();
00051             $categoryId = Mage::registry('current_urlrewrite')->getCategoryId();
00052         }
00053 
00054         Mage::register('current_product', Mage::getModel('catalog/product')->load($productId));
00055         Mage::register('current_category', Mage::getModel('catalog/category')->load($categoryId));
00056 
00057         return $this;
00058     }

_isAllowed (  )  [protected]

Check whether this contoller is allowed in admin permissions

Returns:
bool

Reimplemented from Mage_Adminhtml_Controller_Action.

Definition at line 199 of file UrlrewriteController.php.

00200     {
00201         return Mage::getSingleton('admin/session')->isAllowed('catalog/urlrewrite');
00202     }

categoriesJsonAction (  ) 

Ajax categories tree loader action

Definition at line 102 of file UrlrewriteController.php.

00103     {
00104         $id = $this->getRequest()->getParam('id', null);
00105         $this->getResponse()->setBody(Mage::getBlockSingleton('adminhtml/urlrewrite_category_tree')
00106             ->getTreeArray($id, true, 1)
00107         );
00108     }

deleteAction (  ) 

Urlrewrite delete action

Definition at line 174 of file UrlrewriteController.php.

00175     {
00176         $this->_initRegistry();
00177 
00178         if (Mage::registry('current_urlrewrite')->getId()) {
00179             try {
00180                 Mage::registry('current_urlrewrite')->delete();
00181                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__(
00182                     'Urlrewrite has been successfully deleted'
00183                 ));
00184             }
00185             catch (Exception $e) {
00186                 Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
00187                 $this->_redirectReferer();
00188                 return;
00189             }
00190         }
00191         $this->_redirect('*/*/');
00192     }

editAction (  ) 

Show urlrewrite edit/create page

Definition at line 79 of file UrlrewriteController.php.

00080     {
00081         $this->loadLayout();
00082         $this->_setActiveMenu('catalog/urlrewrite');
00083         $this->_initRegistry();
00084         $this->_addContent($this->getLayout()->createBlock('adminhtml/urlrewrite_edit'));
00085         $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
00086         $this->renderLayout();
00087     }

indexAction (  ) 

Show urlrewrites index page

Definition at line 64 of file UrlrewriteController.php.

00065     {
00066         $this->loadLayout();
00067         $this->_setActiveMenu('catalog/urlrewrite');
00068         $this->_initRegistry();
00069         $this->_addContent(
00070             $this->getLayout()->createBlock('adminhtml/urlrewrite')
00071         );
00072         $this->renderLayout();
00073     }

productGridAction (  ) 

Ajax products grid action

Definition at line 93 of file UrlrewriteController.php.

00094     {
00095         $this->getResponse()->setBody($this->getLayout()->createBlock('adminhtml/urlrewrite_product_grid')->toHtml());
00096     }

saveAction (  ) 

Urlrewrite save action

Definition at line 114 of file UrlrewriteController.php.

00115     {
00116         $this->_initRegistry();
00117 
00118         if ($data = $this->getRequest()->getPost()) {
00119             try {
00120                 // set basic urlrewrite data
00121                 $model = Mage::registry('current_urlrewrite');
00122 
00123                 $model->setIdPath($this->getRequest()->getParam('id_path'))
00124                     ->setTargetPath($this->getRequest()->getParam('target_path'))
00125                     ->setOptions($this->getRequest()->getParam('options'))
00126                     ->setDescription($this->getRequest()->getParam('description'))
00127                     ->setRequestPath($this->getRequest()->getParam('request_path'))
00128                 ;
00129                 if (!$model->getId()) {
00130                     $model->setIsSystem(0);
00131                 }
00132                 if (!$model->getIsSystem()) {
00133                     $model->setStoreId($this->getRequest()->getParam('store_id', 0));
00134                 }
00135 
00136                 // override urlrewrite data, basing on current registry combination
00137                 $category = Mage::registry('current_category')->getId() ? Mage::registry('current_category') : null;
00138                 if ($category) {
00139                     $model->setCategoryId($category->getId());
00140                 }
00141                 $product  = Mage::registry('current_product')->getId() ? Mage::registry('current_product') : null;
00142                 if ($product) {
00143                     $model->setProductId($product->getId());
00144                 }
00145                 if ($product || $category) {
00146                     $catalogUrlModel = Mage::getSingleton('catalog/url');
00147                     $model->setIdPath($catalogUrlModel->generatePath('id', $product, $category));
00148                     $model->setTargetPath($catalogUrlModel->generatePath('target', $product, $category));
00149                 }
00150 
00151                 // save and redirect
00152                 $model->save();
00153                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__(
00154                     'Urlrewrite has been successfully saved'
00155                 ));
00156                 $this->_redirect('*/*/');
00157                 return;
00158             }
00159             catch (Exception $e) {
00160                 Mage::getSingleton('adminhtml/session')
00161                     ->addError($e->getMessage())
00162                     ->setUrlrewriteData($data)
00163                 ;
00164                 // return intentionally omitted
00165             }
00166         }
00167         $this->_redirectReferer();
00168     }


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

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